payload-live-preview 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=Object.defineProperty,t=(t,i)=>e(t,"name",{value:i,configurable:!0}),i="1.0.4",n="data-payload-field",r="data-payload-type",l="data-payload-attribute",s="data-payload-href",o="data-payload-src",a="data-payload-alt",u="data-payload-array-template",h="data-payload-array-separator",d="data-payload-locale",c="data-payload-richtext",f="data-payload-html",p="data-payload-array",g="data-payload-structural",m=[n,r,l,s,o,a,u,h,d,c,f,p,g,"type"],y=`[${n}]`,v=new Set(["text","textarea","richText","email","number","checkbox","date","select","radio","array","blocks","group","tabs","row","collapsible","relationship","upload","point","json","code","ui","html","url","image","structural-array"]),b=class{static{t(this,"ElementCache")}#e=new Map;#t=new WeakMap;#i;constructor(e={}){this.#i=e.filter??S}buildFromRoot(e){let t=performance.now();this.clear();let i=e.querySelectorAll(y),n=0;for(let e of i)void 0!==this.add(e)&&(n+=1);return{elementCount:n,fieldCount:this.#e.size,durationMs:performance.now()-t}}add(e){let t=this.#i(e)?this.#n(e):void 0,i=this.#t.get(e);if(void 0!==t)return void 0!==i&&this.#r(i,t)?(this.#t.set(e,t),t):(void 0!==i&&this.#l(e,i),this.#s(t),this.#t.set(e,t),t);void 0!==i&&this.#l(e,i)}remove(e){let t=this.#t.get(e);return!!t&&this.#l(e,t)}#r(e,t){if(e.fieldName!==t.fieldName)return!1;let i=this.#e.get(e.fieldName);if(!i)return!1;let n=i.indexOf(e);return!(n<0||(i[n]=t,0))}#l(e,t){let i=this.#e.get(t.fieldName);if(!i)return this.#t.delete(e),!1;let n=i.indexOf(t);return n<0?(this.#t.delete(e),!1):(i.splice(n,1),0===i.length&&this.#e.delete(t.fieldName),this.#t.delete(e),!0)}get(e){return this.#e.get(e)}getByElement(e){return this.#t.get(e)}get fieldCount(){return this.#e.size}get elementCount(){let e=0;for(let t of this.#e.values())e+=t.length;return e}entries(){return this.#e.entries()}*values(){for(let e of this.#e.values())yield*e}has(e){return this.#t.has(e)}clear(){this.#e.clear(),this.#t=new WeakMap}#s(e){let t=this.#e.get(e.fieldName);t?t.push(e):this.#e.set(e.fieldName,[e])}#n(e){let t=e.getAttribute(n);if(null===t||0===t.length)return;let i=e.getAttribute(r),c=w(e),f=e.getAttribute(l),p=e.getAttribute(s),g=e.getAttribute(o),m=e.getAttribute(a),y=e.getAttribute(u),b=e.getAttribute(h),S=e.getAttribute(d);return{element:e,fieldName:t,fieldType:c,explicitFieldType:null!==i&&v.has(i),...null!==f&&f.length>0?{targetAttribute:f}:{},...null!==p&&p.length>0?{hrefField:p}:{},...null!==g&&g.length>0?{srcField:g}:{},...null!==m&&m.length>0?{altField:m}:{},...null!==y?{arrayTemplate:y}:{},...null!==b?{arraySeparator:b}:{},...null!==S&&S.length>0?{locale:S}:{}}}};function w(e){let t=e.getAttribute(r);if(null!==t&&v.has(t))return t;if(e.hasAttribute(c))return"richText";if(e.hasAttribute(f))return"html";if(e.hasAttribute(g))return"structural-array";if(e.hasAttribute(p))return"array";if("IMG"===e.tagName)return"image";if("A"===e.tagName)return"url";if("TIME"===e.tagName)return"date";if("INPUT"===e.tagName){let t=e.type;if("checkbox"===t)return"checkbox";if("number"===t)return"number";if("date"===t||"datetime-local"===t)return"date"}return"text"}function S(){return!0}t(w,"resolveFieldType"),t(S,"alwaysTrue");var A=class{static{t(this,"ObserverManager")}s;constructor(e,t={}){this.s=[e,t.mutationDebounceMs??100,t.intersectionRootMargin??"200px",new Set,null,null,null,0]}start(e){let t=this.s[7];this.stop();let i=t+1;if(this.s[7]!==i)return;let n=null,r=null;try{n=new MutationObserver(e=>{this.#e(e,i)}),r=new IntersectionObserver(e=>{this.#t(e,i)},{rootMargin:this.s[2],threshold:0}),n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...m]})}catch(e){throw n?.disconnect(),r?.disconnect(),e}if(this.s[7]!==i)return n.disconnect(),void r.disconnect();this.s[4]=n,this.s[5]=r}observeElement(e){this.s[5]?.observe(e)}unobserveElement(e){this.s[5]?.unobserve(e),this.s[3].delete(e)}markVisible(e,t){t?this.s[3].add(e):this.s[3].delete(e)}isVisible(e){return this.s[3].has(e)}stop(){this.s[7]+=1;let e=this.s[6],t=this.s[4],i=this.s[5];this.s[6]=null,this.s[4]=null,this.s[5]=null,this.s[3].clear(),null!==e&&clearTimeout(e);try{t?.disconnect()}finally{i?.disconnect()}}#e(e,t){if(!this.#i(t)||!T(e)||!this.#i(t))return;null!==this.s[6]&&clearTimeout(this.s[6]);let i=setTimeout(()=>{!this.#i(t)||this.s[6]!==i||(this.s[6]=null,this.s[0].onStructuralChange())},this.s[1]);this.s[6]=i}#t(e,t){for(let i of e){if(!this.#i(t))return;let e=i.target;if(i.isIntersecting){if(!this.s[3].has(e)&&(this.s[3].add(e),this.s[0].onVisibilityChange(e,!0),!this.#i(t)))return}else if(this.s[3].has(e)&&(this.s[3].delete(e),this.s[0].onVisibilityChange(e,!1),!this.#i(t)))return}}#i(e){return this.s[7]===e&&null!==this.s[5]}};function T(e){for(let t of e){if("attributes"===t.type&&null!==t.attributeName&&m.includes(t.attributeName)&&(t.attributeName===n||1===t.target.nodeType&&t.target.hasAttribute(n)))return!0;for(let e of t.addedNodes)if($(e))return!0;for(let e of t.removedNodes)if($(e))return!0}return!1}function $(e){if(1!==e.nodeType)return!1;let t=e;return!!t.hasAttribute(n)||null!==t.querySelector(`[${n}]`)}function k(e){if(!Array.isArray(e))return[];let t=[];for(let i of e){let e=x(i);e&&t.push(e)}return t}function x(e){if("object"!=typeof e||null===e)return;let t=e,i=t.name,n=t.type;if("string"!=typeof i||0===i.length||"string"!=typeof n||0===n.length)return;let r=k(t.fields),l=N(t.blocks),s={...t,name:i,type:n};return r.length>0?s.fields=r:delete s.fields,l.length>0?s.blocks=l:delete s.blocks,s}function N(e){if(!Array.isArray(e))return[];let t=[];for(let i of e){if("object"!=typeof i||null===i)continue;let e=i,n=e.slug;if("string"!=typeof n||0===n.length)continue;let r=k(e.fields);t.push({...e,slug:n,fields:r})}return t}t(T,"hasStructuralImpact"),t($,"containsTrackedElement"),t(k,"parseFieldSchema"),t(x,"parseFieldEntry"),t(N,"parseBlockSchema");var M=4,C={basic:1,"schema-json":2,"preview-token":3,"nested-arrays":4,"recursive-diffs":4};function R(e){let t="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,i=Math.min(4,t??1),n=new Set;for(let[e,t]of Object.entries(C))i>=t&&n.add(e);return{ours:4,...void 0!==t?{theirs:t}:{theirs:void 0},negotiated:i,capabilities:n}}function O(e,t){return e.capabilities.has(t)}function I(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}t(R,"negotiateProtocol"),t(O,"hasCapability"),t(I,"observeThenableResult");var F=class{static{t(this,"MessageBus")}s;constructor(e,t){this.s=[e,t,void 0,void 0,0,0,[],0]}attach(e=window){if(void 0!==this.s[3])return;let i=!1,n=t(e=>{if(!i||this.s[2]!==n)return;let t=this.s[4];try{this.#e(e,t)}catch{let i="";try{i=e.origin}catch{}this.#s("shape",i,t)}},"listener");this.s[4]+=1,this.#o(),this.s[3]=e,this.s[2]=n;try{e.addEventListener("message",n)}catch(t){this.s[2]===n&&(this.s[3]=void 0,this.s[2]=void 0,this.#o());try{e.removeEventListener("message",n)}catch{}throw t}if(this.s[2]===n)i=!0;else try{e.removeEventListener("message",n)}catch{}}detach(e){let t=this.s[3],i=this.s[2];void 0===t||void 0===i||(this.s[3]=void 0,this.s[2]=void 0,this.#o(),t.removeEventListener("message",i))}advanceGeneration(){return void 0!==this.s[3]&&(this.s[4]+=1,this.#o(),!0)}static sendReady(e,t){if(0===e.length||0===t.length)return;let i={type:"payload-live-preview",ready:!0,protocolVersion:4};for(let n of e)for(let e of t)try{n.postMessage(i,e)}catch{}}#e(e,t){if(!this.#a(t))return;let i=e.origin;if(!this.#a(t))return;if(!this.#n(i,t))return void this.#s("origin",i,t);let n=e.data;if(!this.#a(t))return;let r=L(n);if(!this.#a(t))return;if(!r)return void this.#s("shape",i,t);let l=n.type;if(this.#a(t))switch(l){case"payload-live-preview":{let e=E(n);if(!this.#a(t))return;if(!e)return void this.#s("shape",i,t);let r=_(n);if(!this.#a(t))return;return void this.#t(r,i,t)}case"payload-document-event":{let e,r=P(n);if(!this.#a(t))return;if(!r)return void this.#s("shape",i,t);try{e=this.s[1].onDocumentEvent}catch{return}if(!this.#a(t))return;return void this.#u(e,n,i)}default:this.#s("type",i,t)}}#t(e,t,i){if(!this.#a(i))return;let n=e.data;if(!this.#a(i))return;let r=U(n);if(!this.#a(i))return;let l,s=r?{generation:i,revision:this.s[5]+=1}:void 0;try{l=this.s[1].validateToken}catch{return}if(!this.#a(i))return;if(void 0===l)return void this.#l(e,t,i,s);if(!0===e.ready&&void 0===n)return void this.#l(e,t,i,void 0);let o,a={generation:i,message:e,origin:t,messageRevision:s,settled:!1,approved:!1};this.s[6].push(a);try{o=l(e.previewToken,t)}catch{return void this.#i(a,!1)}"boolean"!=typeof o?Promise.resolve(o).then(e=>{this.#i(a,!0===e)},()=>{this.#i(a,!1)}):this.#i(a,o)}#i(e,t){this.#a(e.generation)&&(e.approved=t,e.settled=!0,this.#r(e.generation))}#r(e){for(;this.#a(e);){let t=this.s[6][this.s[7]];if(void 0===t)return;if(this.#n(t.origin,e)){if(!t.settled)return;this.#h(t)&&(t.approved?this.#l(t.message,t.origin,t.generation,t.messageRevision):this.#s("token",t.origin,t.generation))}else{if(!this.#h(t))continue;this.#s("origin",t.origin,t.generation)}}}#l(e,t,i,n){if(!this.#a(i))return;let r;try{r=this.s[1].onUpdate}catch{return}this.#a(i)&&(void 0===n?this.#u(r,e,t):this.#u(r,e,t,n))}#s(e,t,i){if(!this.#a(i))return;let n;try{n=this.s[1].onInvalid}catch{return}this.#a(i)&&void 0!==n&&this.#u(n,e,t)}#n(e,t){if(!this.#a(t))return!1;try{return!0===this.s[0](e)&&this.#a(t)}catch{return!1}}#u(e,...t){try{I(e(...t))}catch{}}#a(e){return void 0!==this.s[3]&&this.s[4]===e}#h(e){let t=this.s;return t[6][t[7]]===e&&(t[7]+=1,t[7]===t[6].length?(this.#o(),!0):(t[7]>=1024&&2*t[7]>=t[6].length&&(t[6]=t[6].slice(t[7]),t[7]=0),!0))}#o(){this.s[6]=[],this.s[7]=0}};function L(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}function E(e){let t=e;return!!((void 0===t.data||null===t.data||U(t.data))&&D(t.fieldSchemaJSON,e=>Array.isArray(e))&&D(t.globalSlug,e=>"string"==typeof e)&&D(t.collectionSlug,e=>"string"==typeof e)&&D(t.locale,e=>"string"==typeof e)&&D(t.ready,e=>"boolean"==typeof e)&&D(t.previewToken,e=>"string"==typeof e)&&D(t.protocolVersion,e=>"number"==typeof e))}function P(e){let t=e;return!(!j(t.action,e=>"updated"===e||"created"===e||"deleted"===e)||!j(t.slug,e=>"string"==typeof e)||!j(t.id,e=>"string"==typeof e||"number"==typeof e&&Number.isFinite(e)))}function j(e,t){return void 0===e||t(e)}function D(e,t){return null==e||t(e)}function U(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}t(L,"isObjectMessage"),t(E,"isLivePreviewMessage"),t(P,"isDocumentEventMessage"),t(j,"optionalDocumentFieldOk"),t(D,"optionalTypeOk"),t(U,"isPlainObject");var W=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"];function _(e){let t,i={...e};for(let e of W)null===Reflect.get(i,e)&&Reflect.deleteProperty(i,e);if(!Array.isArray(i.fieldSchemaJSON))return i;try{t=k(i.fieldSchemaJSON)}catch{t=[]}return{...i,fieldSchemaJSON:t}}t(_,"normalizeLivePreviewMessage");var V=class{static{t(this,"HeartbeatTimer")}s;constructor(e){this.s=[e.timeoutMs??0,e.onTimeout,null,0]}kick(){if(this.s[3]=Date.now(),this.s[0]<=0)return;null!==this.s[2]&&clearTimeout(this.s[2]);let e=setTimeout(()=>{this.s[2]===e&&(this.s[2]=null,this.s[1]())},this.s[0]);this.s[2]=e}stop(){null!==this.s[2]&&(clearTimeout(this.s[2]),this.s[2]=null)}get lastKickAt(){return this.s[3]}get pending(){return null!==this.s[2]}},z=class{static{t(this,"ConnectionState")}s;constructor(e){this.s=["disconnected",e]}get status(){return this.s[0]}markConnected(){return this.transition("connected")}markConnecting(){return this.transition("connecting")}markDisconnected(){return this.transition("disconnected")}transition(e){if(this.s[0]===e)return!1;let t=this.s[0];return this.s[0]=e,this.s[1](e,t),!0}};function B(e){return(...t)=>{try{I(e(...t))}catch{}}}function K(){}t(B,"isolateDiagnostic"),t(K,"noopDiagnostic");var G=B((...e)=>console.error(...e)),q=B((...e)=>console.warn(...e)),H=B((...e)=>console.debug(...e));function J(e){for(let t of e){let e=t.codePointAt(0);if(void 0!==e&&(e<=31||127===e))return!0}return!1}function X(e){if(void 0===e||0===e.length||e.length>128||"."===e||".."===e||e.includes("/")||e.includes("\\")||e.includes("?")||e.includes("#")||J(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function Y(e){if("number"==typeof e)return Number.isFinite(e);if("string"!=typeof e||0===e.length||e.length>512||"."===e||".."===e||e.includes("/")||e.includes("\\")||J(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}t(J,"hasControlCharacter"),t(X,"isSafeSlug"),t(Y,"isSafeId");var Q=class{static{t(this,"DataMerger")}s;constructor(e){let t=e.serverURL.replace(/\/+$/,""),i=e.apiRoute??"/api";this.s=[t,i.startsWith("/")?i:`/${i}`,e.depth??1,e.fetchFn,void 0===e.log?K:B(e.log),null,0,0]}canMerge(e){try{return e.globalSlug?X(e.globalSlug):!!X(e.collectionSlug)&&Y(e.data.id)}catch{return!1}}async merge(e){if(this.s[7]>0)return{status:"superseded"};let t=this.s[6]+1;this.s[6]=t;let i=this.s[5];this.s[5]=null;let n=null;try{if(i?.abort(),!Z(this.s,t))return{status:"superseded"};if(!this.canMerge(e))return Z(this.s,t)?{status:"unavailable"}:{status:"superseded"};if(!Z(this.s,t))return{status:"superseded"};let r=this.s[3]??("function"==typeof fetch?fetch:void 0);if(!Z(this.s,t))return{status:"superseded"};if(void 0===r)return{status:"unavailable"};if(n=new AbortController,!Z(this.s,t))return n.abort(),{status:"superseded"};this.s[5]=n;let l=e.globalSlug?`globals/${encodeURIComponent(e.globalSlug)}`:`${encodeURIComponent(e.collectionSlug??"")}/${encodeURIComponent(String(e.data.id))}`,s=`${this.s[0]}${this.s[1]}/${l}`,o=JSON.stringify({data:e.data,depth:this.s[2],flattenLocales:!1,...void 0!==e.locale?{locale:e.locale}:{}});if(!Z(this.s,t))return{status:"superseded"};let a=await r(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:o,signal:n.signal});if(!Z(this.s,t)||ee(n.signal))return{status:"superseded"};let u=a.ok;if(!Z(this.s,t))return{status:"superseded"};if(!u){let e=a.status;return Z(this.s,t)?(this.s[4]("merge HTTP",e,s),Z(this.s,t)?{status:"unavailable"}:{status:"superseded"}):{status:"superseded"}}let h=await a.json();return!Z(this.s,t)||ee(n.signal)?{status:"superseded"}:null===h||"object"!=typeof h||Array.isArray(h)?(this.s[4]("merge invalid",s),Z(this.s,t)?{status:"unavailable"}:{status:"superseded"}):{status:"merged",doc:h}}catch(e){return!Z(this.s,t)||null!==n&&ee(n.signal)?{status:"superseded"}:(this.s[4]("merge exception",e),Z(this.s,t)?{status:"unavailable"}:{status:"superseded"})}finally{null!==n&&Z(this.s,t)&&this.s[5]===n&&(this.s[5]=null)}}destroy(){this.s[6]+=1;let e=this.s[5];this.s[5]=null,this.s[7]+=1;try{e?.abort()}finally{this.s[7]-=1}}};function Z(e,t){return e[6]===t}function ee(e){return e.aborted}t(Z,"isLatestAttempt"),t(ee,"isAborted");var te=new Set(["http:","https:","mailto:","tel:"]),ie=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,ne=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/;function re(e){if("string"!=typeof e||0===e.length)return!1;let t=e.trim();if(0===t.length||ie.test(t))return!1;if(t.startsWith("#")||t.startsWith("?")||t.startsWith("//")||t.startsWith("/"))return!0;try{let e=new URL(t);return te.has(e.protocol)}catch{return ne.test(t)}}function le(e){if(!re(e))return!1;let t=e.trim();return/^https?:\/\//i.test(t)||/^\/\/[^/]/.test(t)}t(re,"isSafeUrl"),t(le,"isExternalHttpUrl");var se=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),oe=new Set(["href","src","poster","cite","action","xlink:href","data"]);function ae(e,t,i){let n=t.toLowerCase().trim();if(0===n.length||n.startsWith("on")||se.has(n))return"blocked";if(null==i)return e.removeAttribute(n),"applied";if("string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i)return"blocked";let r=String(i);return oe.has(n)&&!re(r)?"blocked":(e.setAttribute(n,r),"applied")}t(ae,"applyAttributeBinding");var ue=new WeakSet;function he(e){return ue.add(e),e}function de(e){return ue.has(e)}function ce(e){return ue.has(e.render)}t(he,"markNoWriteCallback"),t(de,"usesNoWriteOutcome"),t(ce,"rendererUsesNoWriteOutcome");var fe=class{static{t(this,"UpdateScheduler")}s;constructor(e,t){let i=t.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):e=>setTimeout(()=>{e(performance.now())},0)),n=t.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):e=>{clearTimeout(e)});this.s=[e,t.debounceMs??50,t.isVisible,t.visibilityGateThreshold??50,t.disableVisibilityGate??!1,t.getCacheSize,t.onFlush,i,n,new Map,new Map,new Set,null,0,null,0,null,!1]}schedule(e){if(void 0!==e.identity&&(this.s[17]||!pe(e.identity,this.s[16])))return;let t=this.s[9],i=t.get(e.target.element);i?(i.value=e.value,i.allFields=e.allFields,i.identity=e.identity,i.data=e.data):t.set(e.target.element,{...e,identity:e.identity,data:e.data}),this.#e()}acceptRevision(e){let t=this.s[16];pe(e,t)||null!==t&&ge(e,t)<0||(this.#a(),this.#n(),this.s[16]=e,this.s[17]=!1)}cancelRevision(e){pe(e,this.s[16])&&(this.#a(),this.#n(),this.s[17]=!0)}flushNow(){return this.#a(),this.#i()}notifyVisible(e){let t=this.s[10],i=t.get(e);if(!i||(t.delete(e),!this.#r(i)))return;let n=performance.now(),r=this.#l(i)?1:0;this.s[6]?.(this.#u(i,r,0,performance.now()-n))}retarget(e){this.#s(this.s[9],e),this.#s(this.s[10],e);for(let t of this.s[11])this.#s(t,e)}forget(e){this.s[9].delete(e),this.s[10].delete(e);for(let t of this.s[11])t.delete(e)}destroy(){this.#a(),this.#n(),this.s[16]=null,this.s[17]=!1}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}#e(){let e=this.s[13]+=1,t=this.s[12];if(this.s[12]=null,null!==t&&clearTimeout(t),this.s[13]!==e)return;let i=setTimeout(()=>{this.s[13]===e&&(this.s[12]=null,this.#t())},this.s[1]);this.s[13]===e&&(this.s[12]=i)}#t(){let e=this.s[15]+=1,t=this.s[14];if(this.s[14]=null,null!==t&&this.s[8](t),this.s[15]!==e)return;let i=!1,n=this.s[7](()=>{this.s[15]===e&&(i=!0,this.s[14]=null,this.#i())});!i&&this.s[15]===e&&(this.s[14]=n)}#i(){let e=performance.now(),t=!this.s[4]&&this.s[5]()>this.s[3],i=this.s[9];this.s[9]=new Map;let n,r=0,l=0;this.s[11].add(i);try{for(let e of i.values()){if(!this.#r(e))continue;let i=!t||this.s[2](e.target.element);if(this.#r(e)){if(n??=e,!i){this.s[10].set(e.target.element,e),l+=1;continue}this.s[10].delete(e.target.element),this.#l(e)&&(r+=1)}}}finally{this.s[11].delete(i)}let s=this.#u(n,r,l,performance.now()-e);return this.s[6]?.(s),s}#r(e){return void 0===e.identity||!this.s[17]&&pe(e.identity,this.s[16])}#l(e){let t=this.s[0];return!1!==t(e)||!de(t)}#s(e,t){let i=e.get(t.element);if(void 0!==i){if(i.target.fieldName!==t.fieldName||i.target.locale!==t.locale)return void e.delete(t.element);i.target=t}}#n(){this.s[9].clear(),this.s[10].clear();for(let e of this.s[11])e.clear()}#u(e,t,i,n){return{applied:t,deferred:i,durationMs:n,...void 0!==e?.identity?{identity:e.identity}:{},...void 0!==e?.data?{data:e.data}:{}}}#a(){let e=this.s[12],t=this.s[14];this.s[13]+=1,this.s[15]+=1,this.s[12]=null,this.s[14]=null,null!==e&&clearTimeout(e),null!==t&&this.s[8](t)}};function pe(e,t){return null!==t&&e.generation===t.generation&&e.revision===t.revision}function ge(e,t){return e.generation!==t.generation?e.generation-t.generation:e.revision-t.revision}t(pe,"sameIdentity"),t(ge,"compareIdentity");var me=new Set(["__proto__","prototype","constructor"]);function ye(e,t,i,n=!1){if(n&&void 0!==i){let n=ve(e,`${t}_${i}`);if(void 0!==n)return n}let r=ve(e,t);if(void 0!==r)return r;if(t.includes(".")){let i=e,n=!0;for(let e of t.split(".")){if(me.has(e)||null===i||"object"!=typeof i){n=!1;break}if(i=ve(i,e),void 0===i){n=!1;break}}if(n)return i}return void 0===i?void 0:ve(e,`${t}_${i}`)}function ve(e,t){if(!me.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function be(){let e=we();if(void 0!==e)return e;let t=Se();return void 0!==t?t:"en"}function we(){if(typeof document>"u")return;let e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}function Se(){if(typeof navigator>"u")return;let e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}t(ye,"resolveFieldValue"),t(ve,"readOwn"),t(be,"detectInitialLocale"),t(we,"readHtmlLang"),t(Se,"readNavigatorLanguage");var Ae="payload-live-preview-a11y";function Te(e){return/^de(?:[-_]|$)/i.test(e)}t(Te,"isGerman");var $e=new WeakMap;function ke(e){let t=$e.get(e);return t??=[null,!1,null,0,null],$e.set(e,t),t[3]+=1,t}function xe(e){null!==e[4]&&(clearTimeout(e[4]),e[4]=null),e[2]?.remove(),e[2]=null}t(ke,"acquireDocumentLease"),t(xe,"clearLeaseMessage");var Ne=class{static{t(this,"A11yAnnouncer")}s;constructor(e,t){let i=t??(typeof document>"u"?null:document),n=i?.documentElement.getAttribute("lang")??"";this.s=[Te(e??(n.length>0?n:be())),i,null]}mount(){let e=this.s[1];if(null==e?.body)return null;let t=this.s[2];null===t&&(t=ke(e),this.s[2]=t);let i=t[0];if(i?.isConnected&&i.ownerDocument===e)return i;if(null!==i){let e=t[1];xe(t),e&&i.remove()}let n=e.getElementById(Ae);return t[1]=null===n,n||(n=e.createElement("div"),n.id=Ae,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0"),e.body.appendChild(n)),t[0]=n,n}announceConnected(){this.say(this.s[0]?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.s[0]?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(e){e<=0||this.say(this.s[0]?`${String(e)} ${1===e?"Änderung":"Änderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}detach(){let e=this.s[2],t=this.s[1];if(null===e||null===t||(this.s[2]=null,e[3]-=1,e[3]>0))return;let i=e[0];null!==i&&xe(e),e[1]&&i?.remove(),e[0]=null,$e.delete(t)}say(e){let t=this.mount(),i=this.s[2];if(null===t||null===i)return;let n=i[2];n?.parentNode!==t?(n?.remove(),n=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),i[2]=n,t.appendChild(n)):n.data=null===n.previousSibling?e:` ${e}`,null!==i[4]&&clearTimeout(i[4]);let r=setTimeout(()=>{i[4]===r&&i[0]===t&&xe(i)},1500);i[4]=r}},Me=new Set(["tabs","row","collapsible"]);function Ce(e,t=""){let i=new Map;return Re(e,t,i),i}function Re(e,t,i){for(let n of e){if(Me.has(n.type)){n.fields&&Re(n.fields,t,i);continue}if("group"===n.type){let e=""===t?n.name:`${t}.${n.name}`;i.set(e,n),n.fields&&Re(n.fields,e,i);continue}let e=""===t?n.name:`${t}.${n.name}`;if(i.set(e,n),"array"===n.type&&n.fields)Re(n.fields,`${e}.*`,i);else if("blocks"===n.type&&n.blocks)for(let t of n.blocks)Re(t.fields,`${e}.*.${t.slug}`,i)}}function Oe(e,t){if(e.has(t))return e.get(t);let i=t.replace(/\.\d+(?=\.|$)/g,".*");return e.has(i)?e.get(i):void 0}function Ie(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function Fe(e){if("object"!=typeof e||null===e)return;let t=e.blockType;return"string"==typeof t?t:void 0}function Le(e,t){return t.every(e=>void 0!==Ie(e))?Ee(e,t):Pe(e,t)}function Ee(e,t){let i=[],n=new Map;for(let t=0;t<e.length;t+=1){let i=Ie(e[t]);void 0!==i&&n.set(i,t)}let r=new Set;for(let l=0;l<t.length;l+=1){let s=t[l],o=Ie(s);if(void 0===o){i.push({kind:"insert",index:l,value:s});continue}let a=n.get(o);if(void 0===a){i.push({kind:"insert",index:l,value:s});continue}r.add(a);let u=e[a];Fe(u)===Fe(s)?(a!==l&&i.push({kind:"move",from:a,to:l,value:s}),je(u,s)||i.push({kind:"update",index:l,value:s})):i.push({kind:"replace",index:l,oldValue:u,value:s})}for(let t=0;t<e.length;t+=1)r.has(t)||i.push({kind:"remove",index:t,value:e[t]});return i}function Pe(e,t){let i=[],n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)je(e[r],t[r])||i.push({kind:"update",index:r,value:t[r]});if(t.length>e.length)for(let n=e.length;n<t.length;n+=1)i.push({kind:"insert",index:n,value:t[n]});if(e.length>t.length)for(let n=t.length;n<e.length;n+=1)i.push({kind:"remove",index:n,value:e[n]});return i}function je(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;let i=e,n=t,r=Object.keys(i),l=Object.keys(n);if(r.length!==l.length)return!1;for(let e of r)if(!Object.is(i[e],n[e]))return!1;return!0}t(Ce,"buildSchemaIndex"),t(Re,"walk"),t(Oe,"lookupSchema"),t(Ie,"getId"),t(Fe,"getBlockType"),t(Le,"diffArray"),t(Ee,"diffById"),t(Pe,"diffByPosition"),t(je,"shallowEqual");var De={text:"text",textarea:"textarea",richText:"richText",email:"email",number:"number",checkbox:"checkbox",date:"date",select:"select",radio:"radio",array:"array",blocks:"blocks",group:"text",tabs:"text",row:"text",collapsible:"text",relationship:"relationship",upload:"upload",point:"text",json:"text",code:"text",ui:"text"};function Ue(e){if(Object.prototype.hasOwnProperty.call(De,e))return De[e]}t(Ue,"payloadTypeToRenderer");var We=[0,500,1e3,2e3],_e=class{static{t(this,"LivePreviewRuntime")}d;l;constructor(e){let i=e.emitter,n=e.renderers,r=e.resolveRenderer??(e=>n[e]),l=e.transformValue,s=e.root??(typeof document<"u"?document:null),o=e.readyTargets,a=e.sendReady??He,u=e.onHeartbeatTimeout,h=void 0===e.log?K:B(e.log),d=void 0===e.warn?q:B(e.warn),c=Be(e),f=void 0!==e.dataMerge?new Q({serverURL:e.dataMerge.serverURL,...void 0!==e.dataMerge.apiRoute?{apiRoute:e.dataMerge.apiRoute}:{},...void 0!==e.dataMerge.depth?{depth:e.dataMerge.depth}:{},...void 0!==e.dataMerge.fetchFn?{fetchFn:e.dataMerge.fetchFn}:{},log:t((...e)=>{h(...e)},"log")}):null,p=new b,g=new A({onStructuralChange:t(()=>{this.#s()},"onStructuralChange"),onVisibilityChange:t((e,t)=>{t&&this.d[3].notifyVisible(e)},"onVisibilityChange")},{...void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}}),m=new fe(he(e=>this.#d(e)),{...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.disableVisibilityGate?{disableVisibilityGate:e.disableVisibilityGate}:{},...void 0!==e.visibilityGateThreshold?{visibilityGateThreshold:e.visibilityGateThreshold}:{},isVisible:t(e=>g.isVisible(e),"isVisible"),getCacheSize:t(()=>p.elementCount,"getCacheSize"),onFlush:t(e=>{this.#c(e)},"onFlush")}),y=new F(e.originMatcher,{onUpdate:t((e,t,i)=>{this.#u(e,t,i)},"onUpdate"),onDocumentEvent:t(()=>{i.emit("documentSave",{timestamp:Date.now()})},"onDocumentEvent"),onInvalid:t((e,t)=>{if("token"===e){let e=new Error(`Preview token rejected (origin: ${t})`);i.emit("error",{error:e,context:"token"})}h("message rejected:",e,t)},"onInvalid"),...void 0!==e.validateToken?{validateToken:e.validateToken}:{}}),v=new z(()=>{}),w=new V({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:t(()=>{this.#f()},"onTimeout")});this.d=[i,p,g,m,y,v,w,n,r,l,s,o,a,u,h,d,[],c,f],this.l=[void 0,void 0,void 0,R(void 0),!1,null,0,null,new Set]}start(){if(this.l[4])return!1;this.l[4]=!0;let e=this.d[10];if(Ke(e)&&"loading"===e.readyState){let i=t(()=>{if(this.l[4]){this.l[5]=null;try{this.#e()}catch(e){this.#i(),this.#p(e,"startup")}}},"onReady");this.l[5]=i;try{e.addEventListener("DOMContentLoaded",i,{once:!0})}catch(e){throw this.#i(),e}return!0}try{return this.#e(),!0}catch(e){throw this.#i(),e}}#e(){if(!this.l[4])return;let e=Ke(this.d[10])?Ge(this.d[10]):this.d[10];if(null===e)throw new Error("LivePreviewRuntime: document.body unavailable");if(this.d[2].start(e),this.#l(),this.#g()&&(this.d[4].attach(),this.d[0].emitWhile("init",{timestamp:Date.now()},()=>this.l[4]),this.#g()))for(let e of We){if(!this.#g())return;if(0===e){if(this.d[12](this.d[11]),!this.#g())return}else{let t=setTimeout(()=>{this.l[4]&&this.#m()},e);this.d[16].push(t)}}}destroy(){this.l[4]&&(this.#t()&&this.d[0].emit("disconnect",{reason:"destroy",timestamp:Date.now()}),this.d[17]?.detach(),this.d[0].emit("destroy",{timestamp:Date.now()}))}#t(){this.l[7]=null,this.l[4]=!1;let e=this.l[5];this.l[5]=null,null!==e&&Ke(this.d[10])&&this.#r(()=>{this.d[10].removeEventListener("DOMContentLoaded",e)});for(let e of this.d[16])this.#r(()=>{clearTimeout(e)});return this.d[16].length=0,this.#r(()=>{this.d[6].stop()}),this.#r(()=>{this.d[4].detach()}),this.#r(()=>{this.d[2].stop()}),this.#r(()=>{this.d[3].destroy()}),this.#r(()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()}#i(){this.#t(),this.#r(()=>{this.d[17]?.detach()})}#r(e){try{e()}catch(e){this.d[14]("cleanup failed:",e)}}refreshCache(){this.l[4]&&this.#s()}get status(){return this.d[5].status}get cache(){return this.d[1]}get updateCount(){return this.l[6]}get protocol(){return this.l[3]}#l(){if(!this.l[4])return;let e=this.d[1].buildFromRoot(this.d[10]);if(this.d[14]("cache",e),this.#g()&&(this.d[0].emitWhile("cacheRefresh",e,()=>this.l[4]),this.#g()))for(let e of this.d[1].values()){if(!this.#g())return;this.d[2].observeElement(e.element)}}#s(){if(!this.l[4])return;let e=new Map;for(let t of this.d[1].values())e.set(t.element,t),this.d[2].unobserveElement(t.element);if(this.#l(),this.#g()){for(let t of this.d[1].values())e.get(t.element)?.fieldName===t.fieldName?this.d[3].retarget(t):this.d[3].forget(t.element),e.delete(t.element);for(let t of e.values())this.d[3].forget(t.element)}}#n(e){let t=R(e);t.negotiated!==this.l[3].negotiated&&(this.l[3]=t,this.d[14]("protocol","ours=4",`theirs=${e}`,`negotiated=${t.negotiated}`))}#u(e,t,i){if(this.d[6].kick(),void 0===e.data)return void(void 0!==e.protocolVersion&&this.#n(e.protocolVersion));if(void 0===i)return;"string"==typeof e.locale&&(this.l[0]=e.locale),Array.isArray(e.fieldSchemaJSON)&&(this.l[1]=e.fieldSchemaJSON,this.l[2]=Ce(e.fieldSchemaJSON));let n={identity:i,message:e,locale:this.l[0],schema:this.l[1],schemaIndex:this.l[2],cancelled:!1};this.l[7]=n,this.d[3].acceptRevision(i),this.l[6]+=1,(void 0===e.protocolVersion||(this.#n(e.protocolVersion),this.l[4]&&this.l[7]===n))&&(this.d[5].markConnected()&&(this.d[17]?.announceConnected(),this.d[0].emit("connect",{origin:t,timestamp:Date.now()}),!this.l[4]||this.l[7]!==n||(this.d[14]("connection","disconnected","→","connected"),!this.l[4]||this.l[7]!==n))||this.#a(n))}async#a(e){let i=await this.#h(e);if(null===i||!this.l[4]||this.l[7]!==e)return;let{message:n}=e,r={fields:i,...void 0!==e.schema?{schema:e.schema}:{},..."string"==typeof n.globalSlug?{globalSlug:n.globalSlug}:{},..."string"==typeof n.collectionSlug?{collectionSlug:n.collectionSlug}:{},...void 0!==e.locale?{locale:e.locale}:{}};this.d[0].listenerCount("beforeUpdate")>0&&(!await this.d[0].emitWhile("beforeUpdate",{data:r,revision:e.identity.revision,cancel:t(()=>{e.cancelled=!0,this.d[3].cancelRevision(e.identity)},"cancel")},()=>!e.cancelled&&this.l[4]&&this.l[7]===e)||e.cancelled||!this.l[4]||this.l[7]!==e)||this.l[4]&&this.l[7]===e&&this.#o(e,r)}async#h(e){let{message:t}=e,i=t.data??{};if(null===this.d[18])return i;let n=await this.d[18].merge({collectionSlug:t.collectionSlug,globalSlug:t.globalSlug,data:i,locale:e.locale});return this.l[4]&&this.l[7]===e?"merged"===n.status?n.doc:"superseded"===n.status?null:i:null}#o(e,i){if(!this.l[4]||this.l[7]!==e)return;let n=t(()=>this.l[4]&&this.l[7]===e,"isCurrent");for(let[t,r]of this.d[1].entries()){if(!this.l[4]||this.l[7]!==e)return;for(let l of r){let r=ye(i.fields,t,l.locale??e.locale,void 0!==l.locale);if(void 0===r)continue;if(!this.l[4]||this.l[7]!==e)return;let s=this.#y(l,r,i.fields,n);if(!this.l[4]||this.l[7]!==e)return;let o={target:l,value:s,allFields:i.fields,identity:e.identity,data:i};if(!this.l[4]||this.l[7]!==e)return;this.d[3].schedule(o)}}this.#v(i.fields,e.locale)}#v(e,t){if(0===this.d[1].fieldCount)return;let i;for(let[n,r]of Object.entries(e)){if(this.l[8].has(n)||Xe.has(n)||!Ye(r))continue;let e=Qe(n,t);if(void 0===this.d[1].get(n)&&(e===n||void 0===this.d[1].get(e))){if(void 0===i){i=new Set;for(let[e,t]of this.d[1].entries())for(let n of t)void 0!==n.locale&&i.add(`${e}_${n.locale}`)}i.has(n)||(this.l[8].add(n),this.d[15](`[live-preview] update arrived for field "${n}" but no <… data-payload-field="${e}"> element exists on this page. Render the binding anchor unconditionally in your template so live edits to an initially-empty field have somewhere to land.`))}}}#y(e,t,i,n){if(void 0===this.d[9])return t;try{let r=this.d[9](e.fieldName,t,{element:e.element,allFields:i},n),l=I(r);if(!n())return t;if(l)throw new TypeError(`Transform for "${e.fieldName}" returned a Promise/thenable; transforms must be synchronous`);return r}catch(e){if(!n())return t;let i=e instanceof Error?e:new Error(String(e));return this.d[0].emit("error",{error:i,context:"transform"}),t}}#g(){return this.l[4]}#d(e){let t=this.l[7];if(null===t||void 0===e.identity||!Je(t.identity,e.identity)||!this.l[4]||this.l[7]!==t)return!1;let i,n=void 0!==t.schemaIndex?Oe(t.schemaIndex,e.target.fieldName):void 0,r=e.value,l=Ve(e.target,n?.type);"text"===l&&!0!==e.target.explicitFieldType&&qe(r)&&(l="richText");try{i=this.d[8](l)}catch(e){if(!this.l[4]||this.l[7]!==t)return!1;let i=e instanceof Error?e:new Error(String(e));return this.d[0].emitWhile("error",{error:i,context:"renderer"},()=>this.l[4]&&this.l[7]===t),!1}if(!this.l[4]||this.l[7]!==t)return!1;let s=this.d[0].listenerCount("elementUpdate")>0,o=s?Ze(e.target.element):void 0;if(!this.l[4]||this.l[7]!==t)return!1;let a={allFields:e.allFields,locale:e.target.locale??t.locale,schema:n};try{if(void 0!==e.target.targetAttribute){if("blocked"===ae(e.target.element,e.target.targetAttribute,r))return this.d[15](`[live-preview] refused to write field "${e.target.fieldName}" into attribute "${e.target.targetAttribute}" (unsafe attribute or value)`),!1}else{if(!i)return this.d[14]("no renderer for",l),!1;if(!1===ze(i,e.target,r,a)&&ce(i))return!1}}catch(e){if(!this.l[4]||this.l[7]!==t)return!1;let i=e instanceof Error?e:new Error(String(e));return this.d[0].emitWhile("error",{error:i,context:"renderer"},()=>this.l[4]&&this.l[7]===t),!1}return!(!this.l[4]||this.l[7]!==t)&&(s&&this.d[0].emitWhile("elementUpdate",{element:e.target.element,fieldName:e.target.fieldName,previousValue:o,nextValue:r,revision:t.identity.revision},()=>this.l[4]&&this.l[7]===t),this.l[4]&&this.l[7]===t)}#c(e){let{identity:i,data:n}=e;if(0===e.applied||void 0===i||void 0===n)return;let r=this.l[7];if(null===r||!this.l[4]||this.l[7]!==r||!Je(r.identity,i))return;let l=t(()=>this.l[4]&&this.l[7]===r&&Je(r.identity,i),"isCurrent");this.d[17]?.announceUpdate(e.applied),l()&&0!==this.d[0].listenerCount("afterUpdate")&&this.d[0].emitWhile("afterUpdate",{data:n,updatedCount:e.applied,durationMs:e.durationMs,revision:i.revision},l)}#f(){if(!this.#g())return;this.d[4].advanceGeneration();let e=this.l[7];this.l[7]=null,null!==e&&this.d[3].cancelRevision(e.identity),this.d[18]?.destroy();let t=this.d[5].markDisconnected();try{this.d[13]?.()}catch(e){this.d[14]("heartbeat:",e)}this.#g()&&(t&&this.#b()&&(this.d[17]?.announceDisconnected(),this.d[0].emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.#b()),!this.#g()||this.#b()&&(this.d[14]("connection","connected","→","disconnected"),!this.#g()))||this.#g()&&this.#m())}#m(){try{this.d[12](this.d[11])}catch(e){this.#p(e,"ready")}}#p(e,t){let i=e instanceof Error?e:new Error(String(e));this.d[0].emit("error",{error:i,context:t})}#b(){return this.l[4]&&"disconnected"===this.d[5].status&&null===this.l[7]}};function Ve(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){let e=Ue(t);if(void 0!==e)return e}return e.fieldType}function ze(e,t,i,n){return e.render(t,i,n)}function Be(e){if(!1===e.enableA11y)return null;let t=void 0===e.root?void 0:9===e.root.nodeType?e.root:e.root.ownerDocument;return new Ne(e.a11yLocale,t)}function Ke(e){return 9===e.nodeType}function Ge(e){return e.body}function qe(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&Array.isArray(t.children)}function He(e){if(typeof window>"u")return;let t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),F.sendReady(t,e)}function Je(e,t){return e.generation===t.generation&&e.revision===t.revision}t(Ve,"resolveRuntimeFieldType"),t(ze,"invokeRenderer"),t(Be,"createA11y"),t(Ke,"isDocumentRoot"),t(Ge,"readDocumentBody"),t(qe,"looksLikeLexicalRoot"),t(He,"defaultSendReady"),t(Je,"sameRevision");var Xe=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function Ye(e){return null!=e&&("string"==typeof e||"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)}function Qe(e,t){if(!t)return e;let i=`_${t}`;return e.endsWith(i)?e.slice(0,-i.length):e}function Ze(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:"IMG"===e.tagName?e.src:e.textContent}t(Ye,"isLiveBindableScalar"),t(Qe,"stripLocaleSuffix"),t(Ze,"readElementSnapshot");var et,tt=class{static{t(this,"EventEmitter")}#e=new Map;#t=new Map;on(e,t){return this.#r(this.#e,e,t)}once(e,t){return this.#r(this.#t,e,t)}off(e,t){this.#l(this.#e,e,t),this.#l(this.#t,e,t)}async emit(e,t){await this.#i(e,t)}async emitWhile(e,t,i){return this.#i(e,t,i)}async#i(e,i,n){let r=t(()=>n?.()??!0,"eligible");if(!r())return!1;let l=this.#e.get(e);if(l)for(let t of[...l])if(!r()||(await this.#s(t,i,e),!r()))return!1;if(!r())return!1;let s=this.#t.get(e);if(s&&s.size>0){let t=[...s];this.#t.delete(e);for(let n of t)if(!r()||(await this.#s(n,i,e),!r()))return!1}return r()}listenerCount(e){return(this.#e.get(e)?.size??0)+(this.#t.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#e.clear(),void this.#t.clear();this.#e.delete(e),this.#t.delete(e)}eventNames(){let e=new Set;for(let t of this.#e.keys())e.add(t);for(let t of this.#t.keys())e.add(t);return[...e]}#r(e,t,i){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n.add(i),()=>{this.#l(e,t,i)}}#l(e,t,i){let n=e.get(t);void 0!==n&&(n.delete(i),0===n.size&&e.delete(t))}async#s(e,t,i){try{await e(t)}catch(e){let t="string"==typeof i||"number"==typeof i?String(i):"<event>";G(`[live-preview] handler for "${t}" threw:`,e)}}};function it(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function nt(){return!(typeof window>"u")&&null!=window.opener}function rt(){return it()||nt()}function lt(){let e=ot();if(void 0!==e)return"production"!==e;let t=at();if(void 0!==t)return t;if(typeof window<"u"){let e=window.location.hostname;if("localhost"===e||"127.0.0.1"===e)return!0}return!1}function st(e){if(typeof process<"u"){let t=process.env[e];if("string"==typeof t&&t.length>0)return t}let t=ut();if(t){let i=t[e];if("string"==typeof i&&i.length>0)return i}}function ot(){if(typeof process>"u")return;let e=process.env.NODE_ENV;return"string"==typeof e?e:void 0}function at(){let e=ut();if(!e)return;let t=e.DEV;return"boolean"==typeof t?t:void 0}function ut(){if(!(typeof __INLINE_RUNTIME_BUILD__<"u"&&__INLINE_RUNTIME_BUILD__)){if(void 0!==et)return et??void 0;et=null;try{let e=new Function("try { return import.meta && import.meta.env; } catch (_) { return undefined; }")();if(e&&"object"==typeof e)return et=e}catch{}}}t(it,"isInIframe"),t(nt,"isInPopup"),t(rt,"isInPreviewContext"),t(lt,"isDevMode"),t(st,"getEnvVar"),t(ot,"readNodeEnv"),t(at,"readImportMetaDev"),t(ut,"tryReadImportMetaEnv");var ht=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,dt=/^https?:\/\/[^/?#\s]+$/i,ct=["PAYLOAD_ADMIN_ORIGIN","PUBLIC_PAYLOAD_ADMIN_ORIGIN","NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN"],ft=class{static{t(this,"OriginDetector")}#e;constructor(e={}){let t,i=new Set;for(let t of e.additionalOrigins??[]){let e=gt(t);void 0!==e&&i.add(e)}for(let e of ct){let t=st(e);if(void 0!==t)for(let e of t.split(",")){let t=gt(e);void 0!==t&&i.add(t)}}if(e.enableReferrerDetection??1){let i=e.referrer??(typeof document<"u"?document.referrer:"");if(i.length>0)try{let e=new URL(i).origin;e&&"null"!==e&&(t=e)}catch{}}let n=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??lt());this.#e=[i,t,n,void 0!==t,void 0]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#e[4]?e===this.#e[4]:!!(this.#e[0].has(e)||0===this.#e[0].size&&void 0!==this.#e[1]&&e===this.#e[1]||this.#e[2]&&ht.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#e[4]=e,!0)}unlockOrigin(){let e=this.#e[4];return this.#e[4]=void 0,e}get lockedOrigin(){return this.#e[4]}enumerate(){if(void 0!==this.#e[4])return[this.#e[4]];let e=new Set(this.#e[0]);if(0===this.#e[0].size&&void 0!==this.#e[1]&&e.add(this.#e[1]),this.#e[2])for(let t of pt)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#e[3]}get isProductionUnconfigured(){return!(!it()||this.#e[0].size>0||this.#e[2]||void 0!==this.#e[1])}get isReferrerOnlyTrust(){return!(this.#e[0].size>0||this.#e[2])&&void 0!==this.#e[1]}},pt=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function gt(e){let t=e.trim();if(0!==t.length)try{let e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||!dt.test(e.origin)?void 0:e.origin}catch{return}}t(gt,"normaliseOrigin");var mt=t(()=>{},"noopDisposer");function yt(e){return"function"==typeof e}t(yt,"isPluginDisposer");var vt,bt=class{static{t(this,"ResourceScope")}#e;#t;#i=new Set;#r="staging";constructor(e,t){this.#e=e,this.#t=t}assertOpen(){if("closed"===this.#r)throw new Error(`Plugin context for "${this.#e}" is no longer active`)}get active(){return"active"===this.#r}eligible(){return"closed"!==this.#r}own(e){return this.assertOpen(),this.#l({acquire:void 0,finalize:void 0,cleanup:e,disposed:!1})}stage(e,t){this.assertOpen();let i={acquire:e,finalize:t,cleanup:void 0,disposed:!1},n=this.#l(i);if("active"===this.#r)try{this.#s(i)}catch(e){throw this.#n(i),e}return n}commit(){if("staging"!==this.#r)throw new Error(`Plugin context for "${this.#e}" cannot be committed`);this.#r="committing";try{for(let e of this.#i)this.#s(e);this.#r="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#r){this.#r="closed";for(let e of[...this.#i].reverse())this.#n(e);this.#i.clear()}}#l(e){return this.#i.add(e),()=>{this.#n(e)}}#s(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;let t=e.acquire();e.cleanup=t??mt}#n(e){if(e.disposed)return;e.disposed=!0,this.#i.delete(e);let t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{I(t())&&this.#t(`plugin "${this.#e}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#t(`plugin "${this.#e}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#t(`plugin "${this.#e}" cleanup failed:`,e)}}},wt=class extends tt{static{t(this,"ScopedPluginEvents")}#e;#t;#i=new Set;constructor(e,t){super(),this.#e=e,this.#t=t}on(e,t){return this.#r("on",e,t)}once(e,t){return this.#r("once",e,t)}off(e,t){let i=t;for(let t of[...this.#i])t.event===e&&t.handler===i&&t.dispose()}emit(e,t){return this.#t.assertOpen(),this.#e.emit(e,t)}emitWhile(e,t,i){return this.#t.assertOpen(),this.#e.emitWhile(e,t,()=>{if(!this.#t.eligible())return!1;let e=i();return!!this.#t.eligible()&&e})}listenerCount(e){let t=0;for(let i of this.#i)i.event===e&&(t+=1);return t}removeAllListeners(e){for(let t of[...this.#i])(void 0===e||t.event===e)&&t.dispose()}eventNames(){let e=new Set;for(let t of this.#i)e.add(t.event);return[...e]}#r(e,i,n){this.#t.assertOpen();let r=n,l=[...this.#i].find(t=>t.kind===e&&t.event===i&&t.handler===r);if(void 0!==l)return l.dispose;let s=mt,o=!0,a=t(async t=>{!this.#t.active||!o||("once"===e&&s(),await n(t))},"wrapped"),u={kind:e,event:i,handler:r,dispose:mt};return s=this.#t.stage(()=>this.#e[e](i,a),()=>{o=!1,this.#i.delete(u)}),u.dispose=s,this.#i.add(u),s}},St=class{static{t(this,"PluginManager")}#e;#t;#i;#r;#l;#s=new Map;#n=new Map;#u=new Map;#a=new Set;#h=new Map;#o=Promise.resolve();#v=0;constructor(e){this.#e=e.events,this.#t=e.config,this.#i=e.registerFieldRenderer,this.#l=B(e.log);let t=e.onTransformError;this.#r=void 0===t?void 0:B((...e)=>{let i=e[0];if(i instanceof Error)try{return t(i)}catch(e){return void this.#l("transform error reporter failed:",e)}})}register(e){return this.#v>0?this.#y(e):this.#p(()=>this.#y(e))}unregister(e){return this.#v>0?this.#d(e):this.#p(async()=>{await this.#d(e)})}destroyAll(){return this.#v>0?this.#f():this.#p(async()=>{await this.#f()})}applyTransforms(e,t,i,n){let r=this.#h.get(e);if(void 0===r||0===r.length)return t;let l=t;for(let s of[...r]){if(!s.active)continue;let{transform:r}=s;if(!1===n?.())return t;try{l=r(l,{fieldName:e,element:i.element,allFields:i.allFields});let s=I(l);if(!1===n?.())return t;if(s)throw new TypeError(`Transform for "${e}" returned a Promise/thenable; transforms must be synchronous`)}catch(i){if(!1===n?.())return t;let r=i instanceof Error?i:new Error(String(i));return this.#l(`transform for "${e}" failed:`,r),this.#r?.(r),t}}return l}list(){return[...this.#s.keys()]}get size(){return this.#s.size}async#y(e){if(this.#s.has(e.name)||this.#n.has(e.name)||this.#u.has(e.name))return void this.#l(`plugin "${e.name}" already registered`);let t=new bt(e.name,this.#l),i=this.#g(e.name,t),n={scope:t,cancelled:!1};this.#n.set(e.name,n);try{if(await this.#m(()=>e.init(i)),n.cancelled)return;t.commit()}catch(i){return t.close(),void(n.cancelled||this.#l(`plugin "${e.name}" init failed:`,i))}finally{this.#n.get(e.name)===n&&this.#n.delete(e.name)}this.#s.set(e.name,{plugin:e,scope:t}),this.#l(`plugin "${e.name}" registered`)}#g(e,i){return{events:new wt(this.#e,i),registerFieldRenderer:t(e=>{i.stage(()=>{let t=this.#i(e);return yt(t)?t:void 0})},"registerFieldRenderer"),registerTransform:t((e,t)=>{let n={transform:t,active:!1};i.stage(()=>{n.active=!0;let t=this.#h.get(e);return void 0===t?this.#h.set(e,[n]):t.push(n),()=>{n.active=!1;let t=this.#h.get(e);if(void 0===t)return;let i=t.indexOf(n);i>=0&&t.splice(i,1),0===t.length&&this.#h.delete(e)}})},"registerTransform"),registerCleanup:t(e=>{i.own(e)},"registerCleanup"),getConfig:t(()=>this.#t,"getConfig"),log:t((...t)=>{this.#l(`[${e}]`,...t)},"log")}}#d(e){let t=this.#n.get(e);if(void 0!==t)return t.cancelled=!0,t.scope.close(),Promise.resolve();let i=this.#u.get(e);if(void 0!==i)return this.#a.has(e)?Promise.resolve():i;let n=this.#s.get(e);if(void 0===n)return Promise.resolve();this.#s.delete(e),n.scope.close();let r=Promise.resolve().then(()=>this.#c(e,n.plugin));return this.#u.set(e,r),r.then(()=>{this.#u.get(e)===r&&this.#u.delete(e)}),r}async#c(e,t){if(void 0!==t.destroy){this.#a.add(e);try{await this.#m(()=>t.destroy?.())}catch(t){this.#l(`plugin "${e}" destroy failed:`,t)}finally{this.#a.delete(e)}}}async#f(){for(let e of this.#n.values())e.cancelled=!0,e.scope.close();let e=[...this.#s.keys()];for(let t of e)await this.#d(t)}async#m(e){this.#v+=1;try{await e()}finally{this.#v-=1}}#p(e){let t=this.#o.then(e);return this.#o=t.catch(e=>{this.#l("plugin manager mutation failed:",e)}),t}},At=class{static{t(this,"RendererRegistry")}#e;#t;#i=new Map;constructor(e){this.#e=e,this.#t={...e}}get renderers(){return this.#t}resolve(e){return this.#t[e]}register(e){let t=e.name,i={renderer:e},n=this.#i.get(t);void 0===n?this.#i.set(t,[i]):n.push(i),this.#t[t]=e;let r=!0;return()=>{if(!r)return;r=!1;let e=this.#i.get(t);if(void 0===e)return;let n=e.indexOf(i);if(n<0)return;let l=n===e.length-1;if(e.splice(n,1),0===e.length&&this.#i.delete(t),!l)return;let s=e.at(-1)?.renderer??this.#e[t];void 0===s?Reflect.deleteProperty(this.#t,t):this.#t[t]=s}}},Tt=new Set(["p","br","strong","b","em","i","u","s","strike","mark","small","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","blockquote","code","pre","kbd","samp","var","a","span","div","section","article","aside","header","footer","nav","figure","figcaption","img","picture","source","audio","video","sub","sup","hr","time","abbr","cite","q","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col"]),$t=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),kt=new Set(["id","class","lang","dir","title","role","tabindex"]),xt={a:new Set(["href","target","rel","download","hreflang","type"]),img:new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:new Set([]),source:new Set(["src","srcset","sizes","type","media"]),audio:new Set(["src","controls","autoplay","loop","muted","preload"]),video:new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:new Set(["datetime"]),abbr:new Set(["title"]),q:new Set(["cite"]),blockquote:new Set(["cite"]),table:new Set(["summary"]),th:new Set(["colspan","rowspan","scope","headers","abbr"]),td:new Set(["colspan","rowspan","headers"]),col:new Set(["span"]),colgroup:new Set(["span"]),ol:new Set(["start","reversed","type"]),li:new Set(["value"]),code:new Set(["class"]),pre:new Set(["class"])},Nt=new Set(["href","src","cite","poster"]),Mt=class extends Error{static{t(this,"SanitizerEnvironmentError")}name="SanitizerEnvironmentError"};function Ct(e){if(!e){let e=new Map;for(let[t,i]of Object.entries(xt))e.set(t,i);return{allowedTags:Tt,attrByTag:e}}let t=new Set(Tt);for(let i of e.additionalAllowedTags??[])t.add(i);let i=new Map;for(let[e,t]of Object.entries(xt))i.set(e,t);for(let[t,n]of Object.entries(e.additionalAllowedAttributes??{})){let e=i.get(t),r=new Set(e??[]);for(let e of n)r.add(e);i.set(t,r)}return{allowedTags:t,attrByTag:i}}function Rt(e){vt=e??void 0}function Ot(e,t){let i=It();if(!i)throw new Mt("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===e)return"";let n=Ct(t),r=i.createElement("template");return r.innerHTML=e,Lt(r.content,n),r.innerHTML}function It(){return vt||(typeof document>"u"?void 0:document)}function Ft(){return void 0!==It()}function Lt(e,t){for(let i of Array.from(e.childNodes))1===i.nodeType?Et(i,t):8===i.nodeType&&i.remove()}function Et(e,t){let i=e.tagName.toLowerCase();if($t.has(i))e.remove();else{if(!t.allowedTags.has(i)){Lt(e,t);let i=e.parentNode;if(i){for(;e.firstChild;)i.insertBefore(e.firstChild,e);e.remove()}return}Pt(e,i,t),"a"===i&&Dt(e),Lt(e,t)}}function Pt(e,t,i){let n=i.attrByTag.get(t);for(let t of Array.from(e.attributes)){let i=t.name.toLowerCase();if(i.startsWith("on"))e.removeAttribute(t.name);else if("style"!==i){if(!(kt.has(i)||i.startsWith("aria-")||i.startsWith("data-"))){if(n?.has(i)){(Nt.has(i)&&!re(t.value)||"srcset"===i&&!jt(t.value))&&e.removeAttribute(t.name);continue}e.removeAttribute(t.name)}}else e.removeAttribute(t.name)}}function jt(e){let t=e.split(",");for(let e of t){let t=e.trim();if(0===t.length)continue;let i=t.search(/\s/);if(!re(-1===i?t:t.slice(0,i)))return!1}return!0}function Dt(e){let t=e.getAttribute("href");null===t||!le(t)||(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}t(Ct,"resolvePolicy"),t(Rt,"setSanitizerDocument"),t(Ot,"sanitizeHtml"),t(It,"resolveDocument"),t(Ft,"hasSanitizerDocument"),t(Lt,"sanitizeFragment"),t(Et,"sanitizeElement"),t(Pt,"sanitizeAttributes"),t(jt,"isSafeSrcset"),t(Dt,"hardenAnchor");var Ut=new Map;function Wt(e,t){Ut.set(e,t)}function _t(e){return Ut.get(e)}t(Wt,"register"),t(_t,"lookup");var Vt={1:"left",2:"center",3:"right",4:"justify"},zt=new Set(["left","center","right","justify","start","end"]);function Bt(e){let t=e.format;if("string"==typeof t&&zt.has(t))return t;if("number"==typeof t){let e=Vt[t];if(void 0!==e)return e}}function Kt(e){let t=e.indent;return"number"==typeof t&&t>0?t:0}function Gt(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function qt(e){let t=Bt(e),i=Kt(e),n=[];return void 0!==t&&n.push(`text-align:${t}`),i>0&&n.push(`padding-inline-start:${String(40*i)}px`),0===n.length?"":` style="${n.join(";")}"`}t(Bt,"resolveAlignment"),t(Kt,"resolveIndent"),t(Gt,"dirAttribute"),t(qt,"styleAttribute");var Ht=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),Jt=/[&<>"'/`=]/g;function Xt(e){return""===e?"":e.replace(Jt,e=>Ht[e])}function Yt(e){return e.replace(/['"()\\]/g,"\\$&")}t(Xt,"escapeHtml"),t(Yt,"escapeCssUrl");var Qt=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}),Zt=/[&<>"']/g;function ei(e){return""===e?"":e.replace(Zt,e=>Qt[e])}function ti(e){return Xt(e).replace(/\r\n|\r|\n/g,"<br>")}t(ei,"escapeHtmlAttribute"),t(ti,"escapeAndLinebreak");var ii=t(e=>{let t=Xt("string"==typeof e.text?e.text:""),i="number"==typeof e.format?e.format:0;return!!(16&i)&&(t=`<code>${t}</code>`),!!(1&i)&&(t=`<strong>${t}</strong>`),!!(2&i)&&(t=`<em>${t}</em>`),!!(8&i)&&(t=`<u>${t}</u>`),!!(4&i)&&(t=`<s>${t}</s>`),!!(32&i)&&(t=`<sub>${t}</sub>`),!!(64&i)&&(t=`<sup>${t}</sup>`),!!(128&i)&&(t=`<mark>${t}</mark>`),t},"textRenderer"),ni=t((e,t)=>{let i=t.renderChildren(e.children??[]);return`<p${Gt(e)}${qt(e)}>${i}</p>`},"paragraphRenderer"),ri=new Set(["h1","h2","h3","h4","h5","h6"]),li=t((e,t)=>{let i="string"==typeof e.tag?e.tag.toLowerCase():"h2",n=ri.has(i)?i:"h2",r=t.renderChildren(e.children??[]);return`<${n}${Gt(e)}${qt(e)}>${r}</${n}>`},"headingRenderer"),si=t((e,t)=>{let i="string"==typeof e.listType?e.listType:"bullet",n="number"===i?"ol":"ul",r="number"===i&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",l="check"===i?' role="list"':"",s=t.renderChildren(e.children??[]);return`<${n}${Gt(e)}${qt(e)}${r}${l}>${s}</${n}>`},"listRenderer"),oi=t((e,t)=>{let i=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${qt(e)}>${i}</li>`;let n="number"==typeof e.value?` value="${Xt(String(e.value))}"`:"";return`<li${Gt(e)}${qt(e)}${n}>${i}</li>`},"listItemRenderer"),ai=t((e,t)=>{let i="string"==typeof e.url?e.url:"",n=t.renderChildren(e.children??[]);if(0===i.length||!re(i))return n;let r=le(i)?' target="_blank" rel="noopener noreferrer"':ui(e),l="string"==typeof e.title?` title="${Xt(e.title)}"`:"";return`<a href="${ei(i)}"${r}${l}>${n}</a>`},"linkRenderer");function ui(e){let t="string"==typeof e.target?e.target:"";if(0===t.length)return"";let i=Xt(t);return"_blank"===t?' target="_blank" rel="noopener noreferrer"':` target="${i}"`}t(ui,"buildOptionalAttrs");var hi=t((e,t)=>{let i=t.renderChildren(e.children??[]);return`<blockquote${Gt(e)}${qt(e)}>${i}</blockquote>`},"quoteRenderer"),di=t(e=>{let t=pi("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${Xt(fi(e))}</code></pre>`},"codeRenderer"),ci=t(e=>{let t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${pi(e.highlightType)}"`:""}>${Xt(t)}</span>`},"codeHighlightRenderer");function fi(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(let i of e.children)t+=fi(i);return t}function pi(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}t(fi,"extractText"),t(pi,"sanitizeLangClass");var gi=t(()=>"<br>","linebreakRenderer"),mi=t(()=>"<hr>","horizontalRuleRenderer"),yi=t(()=>"\t","tabRenderer"),vi=t(e=>{let t=bi(e);if(void 0===t)return"";let i=t.url;if("string"!=typeof i||!re(i))return"";let n="string"==typeof t.mimeType?t.mimeType:"";return n.startsWith("video/")?Si(t,i):n.startsWith("audio/")?Ai(t,i):""===n||n.startsWith("image/")?wi(t,i):Ti(t,i)},"uploadRenderer");function bi(e){let t=e.value;if("object"==typeof t&&null!==t)return t}function wi(e,t){let i="string"==typeof e.alt?Xt(e.alt):"",n="number"==typeof e.width?` width="${String(e.width)}"`:"",r="number"==typeof e.height?` height="${String(e.height)}"`:"";return`<img src="${ei(t)}" alt="${i}"${n}${r} loading="lazy" decoding="async">`}function Si(e,t){let i="number"==typeof e.width?` width="${String(e.width)}"`:"",n="number"==typeof e.height?` height="${String(e.height)}"`:"",r="string"==typeof e.mimeType?` type="${ei(e.mimeType)}"`:"";return`<video controls${i}${n}><source src="${ei(t)}"${r}></video>`}function Ai(e,t){let i="string"==typeof e.mimeType?` type="${ei(e.mimeType)}"`:"";return`<audio controls><source src="${ei(t)}"${i}></audio>`}function Ti(e,t){let i="string"==typeof e.filename?Xt(e.filename):Xt(t);return`<a href="${ei(t)}" target="_blank" rel="noopener noreferrer">${i}</a>`}t(bi,"readUploadValue"),t(wi,"renderImage"),t(Si,"renderVideo"),t(Ai,"renderAudio"),t(Ti,"renderFallbackLink");var $i=t(e=>{let t="string"==typeof e.relationTo?e.relationTo:"",i=ki(e),n=Xt(xi(i,t)),r=""===t?"":` data-relation-to="${Xt(t)}"`,l=i?.url;return"string"==typeof l&&re(l)?`<a href="${ei(l)}"${r}>${n}</a>`:`<span${r}>${n}</span>`},"relationshipRenderer");function ki(e){let t=e.value;if("object"==typeof t&&null!==t)return t}function xi(e,t){return void 0===e?""===t?"#":`#${t}`:"string"==typeof e.title&&e.title.length>0?e.title:"string"==typeof e.name&&e.name.length>0?e.name:"string"==typeof e.slug&&e.slug.length>0?e.slug:void 0!==e.id?String(e.id):""===t?"#":`#${t}`}t(ki,"readValue"),t(xi,"pickLabel");var Ni=new Map;function Mi(e,t){Ni.set(e,t)}function Ci(e){return Ni.get(e)}t(Mi,"registerBlockRenderer"),t(Ci,"lookupBlockRenderer");var Ri=t((e,t)=>{let i=Oi(e),n="string"==typeof i.blockType?i.blockType:"",r=Ii(n);if(""!==n){let e=Ci(n)??Ci(r);if(e)return e(i,{renderChildren:t.renderChildren})}let l=[];""!==r&&l.push(`data-block-type="${Xt(r)}"`);for(let[e,t]of Object.entries(i)){if("blockType"===e||"id"===e||null==t)continue;let i="string"==typeof t||"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t);l.push(`data-block-${Ii(e)}="${Xt(i)}"`)}return`<div${0===l.length?"":` ${l.join(" ")}`}></div>`},"blockRenderer");function Oi(e){let t=e.fields;return"object"!=typeof t||null===t?{}:t}function Ii(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}t(Oi,"readFields"),t(Ii,"sanitizeIdent"),Wt("text",ii),Wt("paragraph",ni),Wt("heading",li),Wt("list",si),Wt("listitem",oi),Wt("link",ai),Wt("autolink",ai),Wt("quote",hi),Wt("code",di),Wt("code-highlight",ci),Wt("linebreak",gi),Wt("horizontalrule",mi),Wt("tab",yi),Wt("upload",vi),Wt("relationship",$i),Wt("block",Ri);var Fi={renderChildren:ji,resolveAlignment:Bt,resolveIndent:Kt};function Li(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function Ei(e,t={}){if(!Li(e))return"";let i=ji(e.root.children);return!1!==t.sanitize&&Ft()?Ot(i):i}function Pi(e){return Li(e)?e.root.children.map(Ui).join("\n").trim():""}function ji(e){let t="";for(let i of e)t+=Di(i);return t}function Di(e){let t=_t(e.type);return t?t(e,Fi):void 0!==e.children?ji(e.children):""}function Ui(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\n";if(void 0===e.children)return"";let t="";for(let i of e.children)t+=Ui(i);return t}function Wi(){let e=new WeakSet;return{name:"text",render:he((t,i)=>{let n=t.element,r=zi(i);if("INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName)return _i(n)&&!n.hasAttribute("data-payload-text")?(Vi(e,n,t.fieldName),!1):void(r.includes("\n")||r.includes("\r")?n.innerHTML=ti(r):n.textContent=r);n.value=r})}}function _i(e){return null!==e.firstElementChild}function Vi(e,t,i){e.has(t)||(e.add(t),q(`[live-preview] Skipping text update for "${i}": <${t.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}function zi(e){return null==e?"":Li(e)?Pi(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}function Bi(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return String(e);try{return JSON.stringify(e)}catch{return""}}t(Li,"isLexicalContent"),t(Ei,"lexicalToHtml"),t(Pi,"lexicalToPlainText"),t(ji,"renderChildren"),t(Di,"renderNode"),t(Ui,"extractPlainText"),t(Wi,"createTextRenderer"),t(_i,"hasStructuredChildren"),t(Vi,"warnOnce"),t(zi,"toPlainString"),t(Bi,"safeStringify");var Ki={name:"textarea",render(e,t){let i=e.element,n=Li(t)?Pi(t):Bi(t);"INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName?i.innerHTML=ti(n):i.value=n}},Gi={name:"richText",render:he((e,t)=>{if(Li(t))e.element.innerHTML=Ei(t);else{if("string"!=typeof t)return!1;e.element.innerHTML=Ot(t)}})},qi={name:"html",render(e,t){if(null==t)return void(e.element.textContent="");let i="string"==typeof t?t:Bi(t);e.element.innerHTML=Ot(i)}},Hi={name:"url",render(e,t,i){let n=e.element,r=Bi(t);if("A"===n.tagName){let l=n,s=e.hrefField,o=void 0===s||0===s.length?t:ye(i.allFields,s,i.locale,void 0!==e.locale);return"string"==typeof o&&re(o)&&(l.href=o),void(l.textContent=r)}"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName?n.textContent=r:n.value=r}},Ji={name:"image",render:he((e,t,i)=>{let n=e.element,r=Xi(t),l=void 0!==e.locale,s=Yi(r,t,e.srcField,i.allFields,i.locale,l);if(void 0===s)return!1;if("IMG"===n.tagName){let t=n;t.src=s;let o=Qi(r,e.altField,i.allFields,i.locale,l);return void(void 0!==o&&(t.alt=o))}n.style.backgroundImage=`url('${Yt(s)}')`})};function Xi(e){if("object"==typeof e&&null!==e)return e}function Yi(e,t,i,n,r,l){if(void 0!==i&&i.length>0){let e=ye(n,i,r,l);if("string"==typeof e&&re(e))return e;let t=Xi(e);return void 0!==t?.url&&re(t.url)?t.url:void 0}return void 0!==e?.url&&re(e.url)?e.url:"string"==typeof t&&re(t)?t:void 0}function Qi(e,t,i,n,r){if(void 0!==t&&t.length>0){let e=ye(i,t,n,r);return"string"==typeof e?e:void 0}if(void 0!==e?.alt)return e.alt}t(Xi,"readMedia"),t(Yi,"pickUrl"),t(Qi,"pickAlt");var Zi={name:"upload",render:he((e,t)=>{let i=e.element,n=en(t);if(void 0===n)return!1;let r=n.url;if("string"!=typeof r||!re(r))return!1;if("IMG"===i.tagName){let e=i;return e.src=r,void(void 0!==n.alt&&(e.alt=n.alt))}if("A"===i.tagName){let e=i;return e.href=r,void(e.textContent=n.filename??r)}let l=void 0!==n.filename?Xt(n.filename):Xt(r);i.innerHTML=`<a href="${ei(r)}">${l}</a>`})};function en(e){if("object"==typeof e&&null!==e)return e}t(en,"readMedia");var tn={name:"relationship",render(e,t){let i=e.element,n=nn(t).join(", ");if("A"===i.tagName&&!Array.isArray(t)){let e=i,r=t?.url;return"string"==typeof r&&re(r)&&(e.href=r),void(e.textContent=n)}i.textContent=n}};function nn(e){return null==e?[""]:Array.isArray(e)?e.map(rn):[rn(e)]}function rn(e){if("object"==typeof e&&null!==e){let t=e;return"string"==typeof t.title&&t.title.length>0?t.title:"string"==typeof t.name&&t.name.length>0?t.name:"string"==typeof t.slug&&t.slug.length>0?t.slug:void 0!==t.id?String(t.id):""}return Bi(e)}t(nn,"collectLabels"),t(rn,"pickLabel");var ln={name:"select",render(e,t){let i=e.element,n=sn(t);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let e=i;return void(e.checked=e.value===n)}i.textContent=n}else i.value=n}};function sn(e){return Array.isArray(e)?e.map(e=>sn(e)).join(", "):Bi(e)}t(sn,"stringify");var on={name:"checkbox",render(e,t){let i=e.element,n=!!t;"INPUT"!==i.tagName||"checkbox"!==i.type?i.hasAttribute("aria-checked")?i.setAttribute("aria-checked",n?"true":"false"):i.textContent=n?"true":"false":i.checked=n}},an=new Map,un=new Map;function hn(e,t){let i=cn(e,t),n=an.get(i);if(void 0!==n)return an.delete(i),an.set(i,n),n;let r=new Intl.NumberFormat(e,t);return an.set(i,r),pn(an),r}function dn(e,t){let i=cn(e,t),n=un.get(i);if(void 0!==n)return un.delete(i),un.set(i,n),n;let r=new Intl.DateTimeFormat(e,t);return un.set(i,r),pn(un),r}function cn(e,t){let i=e??"";if(null==t)return i;let n=fn(t);return"{}"===n?i:`${i}|${n}`}function fn(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>fn(e)).join(",")}]`;let t=e,i=Object.keys(t).sort(),n=[];for(let e of i){let i=t[e];void 0!==i&&n.push(`${JSON.stringify(e)}:${fn(i)}`)}return`{${n.join(",")}}`}function pn(e){for(;e.size>64;){let t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}t(hn,"getNumberFormat"),t(dn,"getDateTimeFormat"),t(cn,"buildKey"),t(fn,"stableStringify"),t(pn,"trimToLimit");var gn={name:"date",render(e,t,i){let n=e.element;if(null==t||""===t)return void("INPUT"===n.tagName?n.value="":("TIME"===n.tagName&&n.removeAttribute("datetime"),n.textContent=""));let r="string"==typeof t?t:Bi(t),l=new Date(r),s=!Number.isNaN(l.getTime());if("INPUT"!==n.tagName)return"TIME"===n.tagName?(n.setAttribute("datetime",s?l.toISOString():r),void(n.textContent=s?mn(l,i):r)):void(n.textContent=s?mn(l,i):r);n.value=s?yn(n.type,l):r}};function mn(e,t){let i=t.locale??be();try{return dn(i,{dateStyle:"medium",timeStyle:"short"}).format(e)}catch{return e.toISOString()}}function yn(e,t){return"date"===e?t.toISOString().slice(0,10):"datetime-local"===e?t.toISOString().slice(0,16):t.toISOString()}t(mn,"formatDate"),t(yn,"toIsoForInput");var vn={name:"number",render(e,t,i){let n=e.element;if(null==t||""===t)return void("INPUT"===n.tagName?n.value="":n.textContent="");let r="number"==typeof t?t:Number(Bi(t));Number.isNaN(r)?n.textContent=Bi(t):"INPUT"!==n.tagName?n.textContent=bn(r,i):n.value=String(r)}};function bn(e,t){let i=t.locale??be();try{return hn(i).format(e)}catch{return String(e)}}t(bn,"format");var wn=/\{\{([\s\S]*?)\}\}/g;function Sn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function An(e,t,i,n){let r="object"==typeof t&&null!==t?t:null;return e.replace(wn,(e,l)=>null!==r&&Sn(r,l)?Xt(n(Reflect.get(r,l))):null===r&&"value"===l?Xt(n(t)):"index"===l?String(i):e)}t(Sn,"hasOwn"),t(An,"interpolateArrayTemplate");var Tn={name:"array",render:he((e,t)=>{let i=e.element;if(!Array.isArray(t))return!1;let n=e.arrayTemplate;if(void 0!==n&&n.length>0){let e=$n(n,t);return void(i.innerHTML=Ot(e))}let r=e.arraySeparator??", ";i.textContent=t.map(xn).join(r)})};function $n(e,t){let i="";for(let n=0;n<t.length;n+=1)i+=kn(e,t[n],n);return i}function kn(e,t,i){return An(e,t,i,Bi)}function xn(e){return Bi(e)}t($n,"renderTemplate"),t(kn,"interpolate"),t(xn,"stringify");var Nn="data-payload-key",Mn="data-payload-nested-key",Cn="data-payload-nested-template";function Rn(){return new WeakMap}function On(e){let{template:t,container:i,patches:n,nextItems:r,store:l,forceRender:s=!1}=e,o=In(i,t,n,r,s,l);return null===o?null:Fn(o,l)}function In(e,t,i,n,r,l){let s=Ln(e,t,n,En(i),r,l.get(e),l);return null===s?null:[e,s,n]}function Fn(e,t){let[i,n,r]=e,l=new Set,s=!1;for(let e of n){let[n,r,o,a]=e,u=r;if(void 0!==o){for(let e of a)null!==e[0]&&(Dn(e[0],e[1]),e[1].replaceWith(e[0])),void 0!==e[2]&&Fn(e[2],t);null!==r&&(r.replaceWith(o),s=!0),u=o}if(null===u)continue;let h=i.children[n]??null;u!==h&&(i.insertBefore(u,h),s=!0),l.add(u)}for(let e of Array.from(i.children))l.has(e)||(e.remove(),s=!0);let o=Wn(i,t);o.clear();for(let e of r)_n(o,e);return s}function Ln(e,t,i,n,r,l,s){let o=Array.from(e.children),a=zn(o,Nn),u=new Set,h=[];for(let d=0;d<i.length;d+=1){let c=i[d],f=Vn(c),p=void 0===f?o[d]??null:Bn(a,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=n.replaces.has(d),m=r||n.renders.has(d)||null===p?Kn(e.ownerDocument,t,c,d):void 0;if(null===m)return null;let y=void 0===m?[]:Pn(g?null:p,m,c,l,s);if(null===y)return null;h.push([d,p,m??void 0,y])}return h}function En(e){let t=new Set,i=new Set;for(let n of e)"insert"===n.kind||"update"===n.kind?t.add(n.index):"replace"===n.kind&&(t.add(n.index),i.add(n.index));return{renders:t,replaces:i}}function Pn(e,t,i,n,r){let l=zn(null===e?[]:jn(e),Mn),s=Vn(i),o=void 0!==s?n?.get(s):void 0,a=[];for(let e of jn(t)){let t=e.getAttribute(Mn);if(null===t)continue;let n,s=Bn(l,t)??null,u=e.getAttribute(Cn),h=u?s:null,d=h?.getAttribute(Cn)??null;if(u){let l=Un(i,t);if(void 0!==l||null!==h){let i=l??[],s=Le(null===h?[]:Un(o,t)??[],i),a=null!==h&&d!==u;if((s.length>0||a)&&(n=In(h??e,u,s,i,a,r)??void 0,void 0===n))return null}}a.push([h,e,n])}return a}function jn(e){return Array.from(e.querySelectorAll(`[${Mn}]`)).filter(t=>{let i=t.parentElement;for(;null!==i&&i!==e;){if(i.hasAttribute(Mn))return!1;i=i.parentElement}return i===e})}function Dn(e,t){for(let i of Array.from(e.attributes))t.hasAttribute(i.name)||e.removeAttribute(i.name);for(let i of Array.from(t.attributes))e.getAttribute(i.name)!==i.value&&e.setAttribute(i.name,i.value)}function Un(e,t){if("object"!=typeof e||null===e)return;let i=e[t];return Array.isArray(i)?i:void 0}function Wn(e,t){let i=t.get(e);return i||(i=new Map,t.set(e,i)),i}function _n(e,t){let i=Vn(t);void 0!==i&&e.set(i,t)}function Vn(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function zn(e,t){let i=new Map;for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(void 0===r)continue;let l=r.getAttribute(t);if(null===l)continue;let s=i.get(l);void 0===s?i.set(l,[r]):s.push(r)}return i}function Bn(e,t){return e.get(t)?.pop()}function Kn(e,t,i,n){let r=Ot(Gn(t,i,n)),l=e.createElement("template");l.innerHTML=r;let s=l.content.firstElementChild;if(!s)return null;let o=Vn(i);return void 0!==o&&s.setAttribute(Nn,o),s}function Gn(e,t,i){return An(e,t,i,Bi)}function qn(){let e=new WeakMap,t=new WeakSet,i=Rn();return{name:"structural-array",render:he((n,r)=>{if(!Array.isArray(r))return!1;let l=n.element,s=n.arrayTemplate;if(void 0===s||0===s.length)return Qn(t,l,n.fieldName),!1;let o=e.get(l),a=Jn(l),u=Le(o?.values??Xn(a),r),h=Hn(o,s,a);if(0===u.length&&!h)return e.set(l,{values:r.slice(),template:s,domSnapshot:a}),!1;let d=On({template:s,container:l,patches:u,nextItems:r,store:i,forceRender:h});return null!==d&&(e.set(l,{values:r.slice(),template:s,domSnapshot:Jn(l)}),!!d&&void 0)})}}function Hn(e,t,i){return void 0===e||e.template!==t||!Yn(e.domSnapshot,i)}function Jn(e){return Array.from(e.children,e=>e.getAttribute(Nn))}function Xn(e){return e.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e})}function Yn(e,t){return e.length===t.length&&e.every((e,i)=>e===t[i])}function Qn(e,t,i){e.has(t)||(e.add(t),q(`[live-preview] Skipping structural update for "${i}": <${t.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}t(Rn,"createStructuralStore"),t(On,"applyStructuralPatches"),t(In,"prepareStructuralPlan"),t(Fn,"commitStructuralPlan"),t(Ln,"prepareReconciliation"),t(En,"createPatchPlan"),t(Pn,"prepareNestedSlots"),t(jn,"findDirectNestedSlots"),t(Dn,"synchronizeAttributes"),t(Un,"readNestedArray"),t(Wn,"getMemory"),t(_n,"rememberItem"),t(Vn,"readKey"),t(zn,"indexByAttribute"),t(Bn,"takeIndexedElement"),t(Kn,"renderItem"),t(Gn,"fillTemplate"),t(qn,"createStructuralArrayRenderer"),t(Hn,"needsForcedRender"),t(Jn,"readDomKeySnapshot"),t(Xn,"valuesFromDomSnapshot"),t(Yn,"sameDomKeySnapshot"),t(Qn,"warnMissingTemplate");var Zn=new Map;function er(e=[]){let t={};for(let i of e)t[i.name]=i;for(let[e,i]of Zn)t[e]=i;return Object.freeze(t)}function tr(e){Zn.set(e.name,e)}t(er,"buildBuiltinRenderers"),t(tr,"registerBuiltinRenderer");var ir=[Ki,Gi,qi,Hi,{...Hi,name:"email"},Ji,Zi,tn,ln,{...ln,name:"radio"},on,gn,vn,Tn,{...Tn,name:"blocks"}];function nr(){return er([Wi(),...ir,qn()])}t(nr,"buildBuiltinRenderers");var rr=class{static{t(this,"LivePreviewClient")}#e=new tt;#t;#i;#r;#l;#s;#n=!1;#u=!1;#a=null;constructor(e={}){let i=e.debug??lt();this.#s=i?(...e)=>{H("[live-preview]",...e)}:K,this.#t=new ft({...void 0!==e.allowedOrigins?{additionalOrigins:e.allowedOrigins}:{},...void 0!==e.disableReferrerDetection?{enableReferrerDetection:!e.disableReferrerDetection}:{},...void 0!==e.disableLocalhostMatching?{enableLocalhostMatching:!e.disableLocalhostMatching}:{}}),this.#t.isProductionUnconfigured&&this.#s("no trusted origin could be detected — set allowedOrigins or PAYLOAD_ADMIN_ORIGIN"),this.#i=new At(nr()),this.#l=new St({events:this.#e,config:Object.freeze({...e}),registerFieldRenderer:t(e=>this.#i.register(e),"registerFieldRenderer"),onTransformError:t(e=>{this.#e.emit("error",{error:e,context:"transform"})},"onTransformError"),log:this.#s}),this.#r=new _e({...void 0!==e.root?{root:e.root}:{},renderers:this.#i.renderers,resolveRenderer:t(e=>this.#i.resolve(e),"resolveRenderer"),transformValue:t((e,t,i,n)=>this.#l.applyTransforms(e,t,i,n),"transformValue"),originMatcher:t(e=>this.#t.matches(e),"originMatcher"),readyTargets:this.#t.enumerate(),emitter:this.#e,...void 0!==e.serverURL&&""!==e.serverURL?{dataMerge:{serverURL:e.serverURL,...void 0!==e.apiRoute?{apiRoute:e.apiRoute}:{},...void 0!==e.mergeDepth?{depth:e.mergeDepth}:{},...void 0!==e.mergeFetch?{fetchFn:e.mergeFetch}:{}}}:{},...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.heartbeatMs?{heartbeatMs:e.heartbeatMs}:{},...void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{},...void 0!==e.disableVisibilityGate?{disableVisibilityGate:e.disableVisibilityGate}:{},...void 0!==e.visibilityGateThreshold?{visibilityGateThreshold:e.visibilityGateThreshold}:{},...void 0!==e.enableA11y?{enableA11y:e.enableA11y}:{},...void 0!==e.a11yLocale?{a11yLocale:e.a11yLocale}:{},onHeartbeatTimeout:t(()=>{this.#t.unlockOrigin()},"onHeartbeatTimeout"),...void 0!==e.validateToken?{validateToken:e.validateToken}:{},log:this.#s}),this.#e.on("connect",e=>{this.#t.lockOrigin(e.origin)}),!1!==e.autoStart&&this.start()}start(){if(this.#u)return!1;if(this.#n)return this.#r.start(),!0;if(!rt())return!1;let e=this.#r.start();return e&&(this.#n=!0),e}destroy(){if(null!==this.#a)return this.#a;this.#u=!0;let e,t,i=new Promise((i,n)=>{e=i,t=n});this.#a=i;try{this.#r.destroy(),this.#l.destroyAll().finally(()=>{this.#e.removeAllListeners()}).then(e,t)}catch(e){this.#e.removeAllListeners(),t(e)}return i}async use(e){if(this.#u)throw new Error("LivePreviewClient: already destroyed");await this.#l.register(e)}async unuse(e){await this.#l.unregister(e)}refreshCache(){this.#r.refreshCache()}get events(){return this.#e}get plugins(){return this.#l.list()}get status(){return this.#r.status}get updateCount(){return this.#r.updateCount}get destroyed(){return this.#u}};function lr(e={}){let t=new rr({...e,autoStart:!1});return t.start()?t:null}t(lr,"initLivePreview");var sr='(()=>{function t(t){return("object"!=typeof t||null===t)&&"function"!=typeof t||"function"!=typeof t.then?0:(Promise.resolve(t).catch(()=>{}),1)}function e(e){return(...i)=>{try{t(e(...i))}catch{}}}function i(){}function n(){return 1}function r(t){if(t.nodeType!==Ge)return 0;let e=t;return e.hasAttribute(be)?1:null!==e.querySelector(`[${be}]`)}function l(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){let t=s(i);t&&e.push(t)}return e}function s(t){if("object"!=typeof t||null===t)return;let e=t,i=e.name,n=e.type;if("string"!=typeof i||0===i.length||"string"!=typeof n||0===n.length)return;let r=l(e.fields),s=function(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){if("object"!=typeof i||null===i)continue;let t=i,n=t.slug;if("string"!=typeof n||0===n.length)continue;let r=l(t.fields);e.push({...t,slug:n,fields:r})}return e}(e.blocks),o={...e,name:i,type:n};return r.length>0?o.fields=r:delete o.fields,s.length>0?o.blocks=s:delete o.blocks,o}function o(t){let e="number"==typeof t&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0,i=Math.min(4,e??1),n=new Set;for(let[t,e]of Object.entries(Ye))i>=e&&n.add(t);return{ours:4,...void 0!==e?{theirs:e}:{theirs:void 0},negotiated:i,capabilities:n}}function a(t,e){return void 0===t||e(t)}function u(t,e){return null==t?1:e(t)}function h(t){if("object"!=typeof t||null===t)return 0;let e=Object.getPrototypeOf(t);return null===e||null===Object.getPrototypeOf(e)}function c(t){for(let e of t){let t=e.codePointAt(0);if(void 0!==t&&(t<=31||127===t))return 1}return 0}function d(t){if(void 0===t||0===t.length||t.length>128||"."===t||".."===t||t.includes("/")||t.includes("\\\\")||t.includes("?")||t.includes("#")||c(t))return 0;try{return encodeURIComponent(t),1}catch{return 0}}function f(t,e){return t[6]===e}function p(t){return t.aborted}function g(t){if("string"!=typeof t||0===t.length)return 0;let e=t.trim();if(0===e.length||gi.test(e))return 0;if(e.startsWith("#")||e.startsWith("?")||e.startsWith("//")||e.startsWith("/"))return 1;try{let t=new URL(e);return pi.has(t.protocol)}catch{return mi.test(e)}}function m(t){if(!g(t))return 0;let e=t.trim();return/^https?:\\/\\//i.test(e)||/^\\/\\/[^/]/.test(e)}function y(t){return bi.add(t),t}function v(t,e){return null!==e&&t.generation===e.generation&&t.revision===e.revision}function b(t,e,i,n=0){if(n&&void 0!==i){let n=w(t,`${e}_${i}`);if(void 0!==n)return n}let r=w(t,e);if(void 0!==r)return r;if(e.includes(".")){let i=t,n=1;for(let t of e.split(".")){if(ji.has(t)||null===i||"object"!=typeof i){n=0;break}if(i=w(i,t),void 0===i){n=0;break}}if(n)return i}return void 0===i?void 0:w(t,`${e}_${i}`)}function w(t,e){if(!ji.has(e)&&Object.prototype.hasOwnProperty.call(t,e))return t[e]}function S(){let t=function(){if(typeof document>"u")return;let t=document.documentElement.getAttribute("lang");return null===t||0===t.length?void 0:t}();if(void 0!==t)return t;let e=function(){if(typeof navigator>"u")return;let t=navigator.language;return"string"==typeof t&&t.length>0?t:void 0}();return void 0!==e?e:"en"}function $(t){return/^de(?:[-_]|$)/i.test(t)}function A(t){null!==t[4]&&(clearTimeout(t[4]),t[4]=null),t[2]?.remove(),t[2]=null}function k(t,e=""){let i=new Map;return T(t,e,i),i}function T(t,e,i){for(let n of t){if(_i.has(n.type)){n.fields&&T(n.fields,e,i);continue}if("group"===n.type){let t=""===e?n.name:`${e}.${n.name}`;i.set(t,n),n.fields&&T(n.fields,t,i);continue}let t=""===e?n.name:`${e}.${n.name}`;if(i.set(t,n),"array"===n.type&&n.fields)T(n.fields,`${t}.*`,i);else if("blocks"===n.type&&n.blocks)for(let e of n.blocks)T(e.fields,`${t}.*.${e.slug}`,i)}}function x(t){if("object"!=typeof t||null===t)return;let e=t.id;return"string"==typeof e||"number"==typeof e?e:void 0}function N(t){if("object"!=typeof t||null===t)return;let e=t.blockType;return"string"==typeof e?e:void 0}function M(t,e){return e.every(t=>void 0!==x(t))?function(t,e){let i=[],n=new Map;for(let e=0;e<t.length;e+=1){let i=x(t[e]);void 0!==i&&n.set(i,e)}let r=new Set;for(let l=0;l<e.length;l+=1){let s=e[l],o=x(s);if(void 0===o){i.push({kind:"insert",index:l,value:s});continue}let a=n.get(o);if(void 0===a){i.push({kind:"insert",index:l,value:s});continue}r.add(a);let u=t[a];N(u)===N(s)?(a!==l&&i.push({kind:"move",from:a,to:l,value:s}),C(u,s)||i.push({kind:"update",index:l,value:s})):i.push({kind:"replace",index:l,oldValue:u,value:s})}for(let e=0;e<t.length;e+=1)r.has(e)||i.push({kind:"remove",index:e,value:t[e]});return i}(t,e):function(t,e){let i=[],n=Math.min(t.length,e.length);for(let r=0;r<n;r+=1)C(t[r],e[r])||i.push({kind:"update",index:r,value:e[r]});if(e.length>t.length)for(let n=t.length;n<e.length;n+=1)i.push({kind:"insert",index:n,value:e[n]});if(t.length>e.length)for(let n=e.length;n<t.length;n+=1)i.push({kind:"remove",index:n,value:t[n]});return i}(t,e)}function C(t,e){if(Object.is(t,e))return 1;if("object"!=typeof t||"object"!=typeof e||null===t||null===e)return 0;let i=t,n=e,r=Object.keys(i),l=Object.keys(n);if(r.length!==l.length)return 0;for(let t of r)if(!Object.is(i[t],n[t]))return 0;return 1}function O(t){return 9===t.nodeType}function j(t){if(typeof window>"u")return;let e=[];window.parent!==window&&e.push(window.parent),window.opener instanceof Window&&e.push(window.opener),Ze.sendReady(e,t)}function I(t,e){return t.generation===e.generation&&t.revision===e.revision}function E(t){return null==t?0:"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t}function R(t,e){if(!e)return t;let i=`_${e}`;return t.endsWith(i)?t.slice(0,-i.length):t}function _(){if(typeof window>"u")return 0;try{return window.self!==window.top}catch{return 1}}function L(t){if(typeof process<"u"){let e=process.env[t];if("string"==typeof e&&e.length>0)return e}}function W(t){let e=t.trim();if(0!==e.length)try{let t=new URL(e);return"http:"!==t.protocol&&"https:"!==t.protocol||!un.test(t.origin)?void 0:t.origin}catch{return}}function P(t,e){let i=F();if(!i)throw new An("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===t)return"";let n=function(t){if(!t){let t=new Map;for(let[e,i]of Object.entries(bn))t.set(e,i);return{allowedTags:pn,attrByTag:t}}let e=new Set(pn);for(let i of t.additionalAllowedTags??[])e.add(i);let i=new Map;for(let[t,e]of Object.entries(bn))i.set(t,e);for(let[e,n]of Object.entries(t.additionalAllowedAttributes??{})){let t=i.get(e),r=new Set(t??[]);for(let t of n)r.add(t);i.set(e,r)}return{allowedTags:e,attrByTag:i}}(e),r=i.createElement("template");return r.innerHTML=t,D(r.content,n),r.innerHTML}function F(){if(!(typeof document>"u"))return document}function D(t,e){for(let i of Array.from(t.childNodes))i.nodeType===Sn?U(i,e):i.nodeType===$n&&i.remove()}function U(t,e){let i=t.tagName.toLowerCase();if(gn.has(i))t.remove();else{if(!e.allowedTags.has(i)){D(t,e);let i=t.parentNode;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);t.remove()}return}(function(t,e,i){let n=i.attrByTag.get(e);for(let e of Array.from(t.attributes)){let i=e.name.toLowerCase();if(i.startsWith("on"))t.removeAttribute(e.name);else if("style"!==i){if(!(mn.has(i)||i.startsWith(yn)||i.startsWith(vn))){if(n?.has(i)){(wn.has(i)&&!g(e.value)||"srcset"===i&&!z(e.value))&&t.removeAttribute(e.name);continue}t.removeAttribute(e.name)}}else t.removeAttribute(e.name)}})(t,i,e),"a"===i&&function(t){let e=t.getAttribute("href");null===e||!m(e)||(t.setAttribute("rel","noopener noreferrer"),t.hasAttribute("target")||t.setAttribute("target","_blank"))}(t),D(t,e)}}function z(t){let e=t.split(",");for(let t of e){let e=t.trim();if(0===e.length)continue;let i=e.search(/\\s/);if(!g(-1===i?e:e.slice(0,i)))return 0}return 1}function V(t,e){kn.set(t,e)}function G(t){let e=t.format;if("string"==typeof e&&xn.has(e))return e;if("number"==typeof e){let t=Tn[e];if(void 0!==t)return t}}function H(t){let e=t.indent;return"number"==typeof e&&e>0?e:0}function q(t){return"rtl"===t.direction?\' dir="rtl"\':"ltr"===t.direction?\' dir="ltr"\':""}function J(t){let e=G(t),i=H(t),n=[];return void 0!==e&&n.push(`text-align:${e}`),i>0&&n.push(`padding-inline-start:${String(40*i)}px`),0===n.length?"":` style="${n.join(";")}"`}function B(t){return""===t?"":t.replace(Mn,t=>Nn[t])}function X(t){return""===t?"":t.replace(On,t=>Cn[t])}function Y(t){return B(t).replace(/\\r\\n|\\r|\\n/g,"<br>")}function Z(t){if("string"==typeof t.text)return t.text;if(!t.children)return"";let e="";for(let i of t.children)e+=Z(i);return e}function K(t){return t.replace(/[^a-zA-Z0-9_-]/g,"")}function Q(t){return En.get(t)}function tt(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function et(t){if("object"!=typeof t||null===t||!("root"in t))return 0;let e=t.root;return"object"==typeof e&&null!==e&&"children"in e?Array.isArray(e.children):0}function it(t){return et(t)?t.root.children.map(lt).join("\\n").trim():""}function nt(t){let e="";for(let i of t)e+=rt(i);return e}function rt(t){let e=function(t){return kn.get(t)}(t.type);return e?e(t,jt):void 0!==t.children?nt(t.children):""}function lt(t){if("string"==typeof t.text)return t.text;if("linebreak"===t.type)return"\\n";if(void 0===t.children)return"";let e="";for(let i of t.children)e+=lt(i);return e}function st(){let t=new WeakSet;return{name:"text",render:y((e,i)=>{let n=e.element,r=function(t){return null==t?"":et(t)?it(t):"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}(i);if("INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName){if(function(t){return null!==t.firstElementChild}(n)&&!n.hasAttribute(It))return function(t,e,i){t.has(e)||(t.add(e),ue(`[live-preview] Skipping text update for "${i}": <${e.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}(t,n,e.fieldName),0;r.includes("\\n")||r.includes("\\r")?n.innerHTML=Y(r):n.textContent=r}else n.value=r})}}function ot(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)return String(t);try{return JSON.stringify(t)}catch{return""}}function at(t){if("object"==typeof t&&null!==t)return t}function ut(t){if("object"==typeof t&&null!==t){let e=t;return"string"==typeof e.title&&e.title.length>0?e.title:"string"==typeof e.name&&e.name.length>0?e.name:"string"==typeof e.slug&&e.slug.length>0?e.slug:void 0!==e.id?String(e.id):""}return ot(t)}function ht(t){return Array.isArray(t)?t.map(t=>ht(t)).join(", "):ot(t)}function ct(t,e){let i=t??"";if(null==e)return i;let n=dt(e);return"{}"===n?i:`${i}|${n}`}function dt(t){if(null===t||"object"!=typeof t)return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(t=>dt(t)).join(",")}]`;let e=t,i=Object.keys(e).sort(),n=[];for(let t of i){let i=e[t];void 0!==i&&n.push(`${JSON.stringify(t)}:${dt(i)}`)}return`{${n.join(",")}}`}function ft(t){for(;t.size>Gt;){let e=t.keys().next().value;if(void 0===e)break;t.delete(e)}}function pt(t,e,i,n){let r="object"==typeof e&&null!==e?e:null;return t.replace(Jt,(t,l)=>null!==r&&function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r,l)?B(n(Reflect.get(r,l))):null===r&&"value"===l?B(n(e)):"index"===l?String(i):t)}function gt(t,e,i){return pt(t,e,i,ot)}function mt(t){return ot(t)}function yt(t){let{template:e,container:i,patches:n,nextItems:r,store:l,forceRender:s=0}=t,o=vt(i,e,n,r,s,l);return null===o?null:bt(o,l)}function vt(t,e,i,n,r,l){let s=function(t){let e=new Set,i=new Set;for(let n of t)"insert"===n.kind||"update"===n.kind?e.add(n.index):"replace"===n.kind&&(e.add(n.index),i.add(n.index));return{renders:e,replaces:i}}(i),o=function(t,e,i,n,r,l,s){let o=Array.from(t.children),a=xt(o,Xt),u=new Set,h=[];for(let c=0;c<i.length;c+=1){let d=i[c],f=Tt(d),p=void 0===f?o[c]??null:Nt(a,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=n.replaces.has(c),m=r||n.renders.has(c)||null===p?Mt(t.ownerDocument,e,d,c):void 0;if(null===m)return null;let y=void 0===m?[]:wt(g?null:p,m,d,l,s);if(null===y)return null;h.push([c,p,m??void 0,y])}return h}(t,e,n,s,r,l.get(t),l);return null===o?null:[t,o,n]}function bt(t,e){let[i,n,r]=t,l=new Set,s=0;for(let t of n){let[n,r,o,a]=t,u=r;if(void 0!==o){for(let t of a)null!==t[0]&&($t(t[0],t[1]),t[1].replaceWith(t[0])),void 0!==t[2]&&bt(t[2],e);null!==r&&(r.replaceWith(o),s=1),u=o}if(null===u)continue;let h=i.children[n]??null;u!==h&&(i.insertBefore(u,h),s=1),l.add(u)}for(let t of Array.from(i.children))l.has(t)||(t.remove(),s=1);let o=function(t,e){let i=e.get(t);return i||(i=new Map,e.set(t,i)),i}(i,e);o.clear();for(let t of r)kt(o,t);return s}function wt(t,e,i,n,r){let l=xt(null===t?[]:St(t),Yt),s=Tt(i),o=void 0!==s?n?.get(s):void 0,a=[];for(let t of St(e)){let e=t.getAttribute(Yt);if(null===e)continue;let n,s=Nt(l,e)??null,u=t.getAttribute(Zt),h=u?s:null,c=h?.getAttribute(Zt)??null;if(u){let l=At(i,e);if(void 0!==l||null!==h){let i=l??[],s=M(null===h?[]:At(o,e)??[],i),a=null!==h&&c!==u;if((s.length>0||a)&&(n=vt(h??t,u,s,i,a,r)??void 0,void 0===n))return null}}a.push([h,t,n])}return a}function St(t){return Array.from(t.querySelectorAll(`[${Yt}]`)).filter(e=>{let i=e.parentElement;for(;null!==i&&i!==t;){if(i.hasAttribute(Yt))return 0;i=i.parentElement}return i===t})}function $t(t,e){for(let i of Array.from(t.attributes))e.hasAttribute(i.name)||t.removeAttribute(i.name);for(let i of Array.from(e.attributes))t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}function At(t,e){if("object"!=typeof t||null===t)return;let i=t[e];return Array.isArray(i)?i:void 0}function kt(t,e){let i=Tt(e);void 0!==i&&t.set(i,e)}function Tt(t){if("object"!=typeof t||null===t)return;let e=t.id;return"string"==typeof e||"number"==typeof e?String(e):void 0}function xt(t,e){let i=new Map;for(let n=t.length-1;n>=0;n-=1){let r=t[n];if(void 0===r)continue;let l=r.getAttribute(e);if(null===l)continue;let s=i.get(l);void 0===s?i.set(l,[r]):s.push(r)}return i}function Nt(t,e){return t.get(e)?.pop()}function Mt(t,e,i,n){let r=function(t,e,i){return pt(t,e,i,ot)}(e,i,n),l=P(r),s=t.createElement("template");s.innerHTML=l;let o=s.content.firstElementChild;if(!o)return null;let a=Tt(i);return void 0!==a&&o.setAttribute(Xt,a),o}function Ct(){let t=new WeakMap,e=new WeakSet,i=new WeakMap;return{name:"structural-array",render:y((n,r)=>{if(!Array.isArray(r))return 0;let l=n.element,s=n.arrayTemplate;if(void 0===s||0===s.length)return function(t,e,i){t.has(e)||(t.add(e),ue(`[live-preview] Skipping structural update for "${i}": <${e.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(e,l,n.fieldName),0;let o=t.get(l),a=Ot(l),u=o?.values??function(t){return t.map((t,e)=>null===t?{__payloadDomPosition:e}:{id:t})}(a),h=M(u,r),c=function(t,e,i){return void 0===t?1:t.template!==e||!function(t,e){return t.length!==e.length?0:t.every((t,i)=>t===e[i])}(t.domSnapshot,i)}(o,s,a);if(0===h.length&&!c)return t.set(l,{values:r.slice(),template:s,domSnapshot:a}),0;let d=yt({template:s,container:l,patches:h,nextItems:r,store:i,forceRender:c});return null===d?0:(t.set(l,{values:r.slice(),template:s,domSnapshot:Ot(l)}),d?void 0:0)})}}function Ot(t){return Array.from(t.children,t=>t.getAttribute(Xt))}var jt,It,Et,Rt,_t,Lt,Wt,Pt,Ft,Dt,Ut,zt,Vt,Gt,Ht,qt,Jt,Bt,Xt,Yt,Zt,Kt,Qt,te=Object.defineProperty,ee=t=>{throw TypeError(t)},ie=(t,e,i)=>((t,e,i)=>e in t?te(t,e,{enumerable:1,configurable:1,writable:1,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),ne=(t,e,i)=>e.has(t)||ee("Cannot "+i),re=(t,e,i)=>(ne(t,e,"read from private field"),i?i.call(t):e.get(t)),le=(t,e,i)=>e.has(t)?ee("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),se=(t,e,i,n)=>(ne(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i),oe=(t,e,i)=>(ne(t,e,"access private method"),i),ae=e((...t)=>console.error(...t)),ue=e((...t)=>console.warn(...t)),he=e((...t)=>console.debug(...t)),ce=class{constructor(){le(this,pe);le(this,de,new Map);le(this,fe,new Map)}on(t,e){return oe(this,pe,me).call(this,re(this,de),t,e)}once(t,e){return oe(this,pe,me).call(this,re(this,fe),t,e)}off(t,e){oe(this,pe,ye).call(this,re(this,de),t,e),oe(this,pe,ye).call(this,re(this,fe),t,e)}async emit(t,e){await oe(this,pe,ge).call(this,t,e)}async emitWhile(t,e,i){return oe(this,pe,ge).call(this,t,e,i)}listenerCount(t){return(re(this,de).get(t)?.size??0)+(re(this,fe).get(t)?.size??0)}removeAllListeners(t){void 0!==t?(re(this,de).delete(t),re(this,fe).delete(t)):(re(this,de).clear(),re(this,fe).clear())}eventNames(){let t=new Set;for(let e of re(this,de).keys())t.add(e);for(let e of re(this,fe).keys())t.add(e);return[...t]}},de=new WeakMap,fe=new WeakMap,pe=new WeakSet,ge=async function(t,e,i){let n=()=>i?.()??1;if(!n())return 0;let r=re(this,de).get(t);if(r)for(let i of[...r])if(!n()||(await oe(this,pe,ve).call(this,i,e,t),!n()))return 0;if(!n())return 0;let l=re(this,fe).get(t);if(l&&l.size>0){let i=[...l];re(this,fe).delete(t);for(let r of i)if(!n()||(await oe(this,pe,ve).call(this,r,e,t),!n()))return 0}return n()},me=function(t,e,i){let n=t.get(e);return n||(n=new Set,t.set(e,n)),n.add(i),()=>{oe(this,pe,ye).call(this,t,e,i)}},ye=function(t,e,i){let n=t.get(e);void 0!==n&&(n.delete(i),0===n.size&&t.delete(e))},ve=async function(t,e,i){try{await t(e)}catch(t){let e="string"==typeof i||"number"==typeof i?String(i):"<event>";ae(`[live-preview] handler for "${e}" threw:`,t)}},be="data-payload-field",we="data-payload-type",Se="data-payload-attribute",$e="data-payload-href",Ae="data-payload-src",ke="data-payload-alt",Te="data-payload-array-template",xe="data-payload-array-separator",Ne="data-payload-locale",Me="data-payload-richtext",Ce="data-payload-html",Oe="data-payload-array",je="data-payload-structural",Ie=[be,we,Se,$e,Ae,ke,Te,xe,Ne,Me,Ce,Oe,je,"type"],Ee=`[${be}]`,Re=new Set(["text","textarea","richText","email","number","checkbox","date","select","radio","array","blocks","group","tabs","row","collapsible","relationship","upload","point","json","code","ui","html","url","image","structural-array"]),_e=class{constructor(t={}){le(this,Fe);le(this,Le,new Map);le(this,We,new WeakMap);le(this,Pe);se(this,Pe,t.filter??n)}buildFromRoot(t){let e=performance.now();this.clear();let i=t.querySelectorAll(Ee),n=0;for(let t of i)void 0!==this.add(t)&&(n+=1);return{elementCount:n,fieldCount:re(this,Le).size,durationMs:performance.now()-e}}add(t){let e=re(this,Pe).call(this,t)?oe(this,Fe,Ve).call(this,t):void 0,i=re(this,We).get(t);if(void 0!==e)return void 0!==i&&oe(this,Fe,De).call(this,i,e)?(re(this,We).set(t,e),e):(void 0!==i&&oe(this,Fe,Ue).call(this,t,i),oe(this,Fe,ze).call(this,e),re(this,We).set(t,e),e);void 0!==i&&oe(this,Fe,Ue).call(this,t,i)}remove(t){let e=re(this,We).get(t);return e?oe(this,Fe,Ue).call(this,t,e):0}get(t){return re(this,Le).get(t)}getByElement(t){return re(this,We).get(t)}get fieldCount(){return re(this,Le).size}get elementCount(){let t=0;for(let e of re(this,Le).values())t+=e.length;return t}entries(){return re(this,Le).entries()}*values(){for(let t of re(this,Le).values())yield*t}has(t){return re(this,We).has(t)}clear(){re(this,Le).clear(),se(this,We,new WeakMap)}},Le=new WeakMap,We=new WeakMap,Pe=new WeakMap,Fe=new WeakSet,De=function(t,e){if(t.fieldName!==e.fieldName)return 0;let i=re(this,Le).get(t.fieldName);if(!i)return 0;let n=i.indexOf(t);return n<0?0:(i[n]=e,1)},Ue=function(t,e){let i=re(this,Le).get(e.fieldName);if(!i)return re(this,We).delete(t),0;let n=i.indexOf(e);return n<0?(re(this,We).delete(t),0):(i.splice(n,1),0===i.length&&re(this,Le).delete(e.fieldName),re(this,We).delete(t),1)},ze=function(t){let e=re(this,Le).get(t.fieldName);e?e.push(t):re(this,Le).set(t.fieldName,[t])},Ve=function(t){let e=t.getAttribute(be);if(null===e||0===e.length)return;let i=t.getAttribute(we),n=function(t){let e=t.getAttribute(we);if(null!==e&&Re.has(e))return e;if(t.hasAttribute(Me))return"richText";if(t.hasAttribute(Ce))return"html";if(t.hasAttribute(je))return"structural-array";if(t.hasAttribute(Oe))return"array";if("IMG"===t.tagName)return"image";if("A"===t.tagName)return"url";if("TIME"===t.tagName)return"date";if("INPUT"===t.tagName){let e=t.type;if("checkbox"===e)return"checkbox";if("number"===e)return"number";if("date"===e||"datetime-local"===e)return"date"}return"text"}(t),r=t.getAttribute(Se),l=t.getAttribute($e),s=t.getAttribute(Ae),o=t.getAttribute(ke),a=t.getAttribute(Te),u=t.getAttribute(xe),h=t.getAttribute(Ne);return{element:t,fieldName:e,fieldType:n,explicitFieldType:null!==i&&Re.has(i),...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==l&&l.length>0?{hrefField:l}:{},...null!==s&&s.length>0?{srcField:s}:{},...null!==o&&o.length>0?{altField:o}:{},...null!==a?{arrayTemplate:a}:{},...null!==u?{arraySeparator:u}:{},...null!==h&&h.length>0?{locale:h}:{}}},Ge=1,He=class{constructor(t,e={}){le(this,qe);ie(this,"s");this.s=[t,e.mutationDebounceMs??100,e.intersectionRootMargin??"200px",new Set,null,null,null,0]}start(t){let e=this.s[7];this.stop();let i=e+1;if(this.s[7]!==i)return;let n=null,r=null;try{n=new MutationObserver(t=>{oe(this,qe,Je).call(this,t,i)}),r=new IntersectionObserver(t=>{oe(this,qe,Be).call(this,t,i)},{rootMargin:this.s[2],threshold:0}),n.observe(t,{childList:1,subtree:1,attributes:1,attributeFilter:[...Ie]})}catch(t){throw n?.disconnect(),r?.disconnect(),t}this.s[7]===i?(this.s[4]=n,this.s[5]=r):(n.disconnect(),r.disconnect())}observeElement(t){this.s[5]?.observe(t)}unobserveElement(t){this.s[5]?.unobserve(t),this.s[3].delete(t)}markVisible(t,e){e?this.s[3].add(t):this.s[3].delete(t)}isVisible(t){return this.s[3].has(t)}stop(){this.s[7]+=1;let t=this.s[6],e=this.s[4],i=this.s[5];this.s[6]=null,this.s[4]=null,this.s[5]=null,this.s[3].clear(),null!==t&&clearTimeout(t);try{e?.disconnect()}finally{i?.disconnect()}}},qe=new WeakSet,Je=function(t,e){if(!oe(this,qe,Xe).call(this,e)||!function(t){for(let e of t){if("attributes"===e.type&&null!==e.attributeName&&Ie.includes(e.attributeName)&&(e.attributeName===be||e.target.nodeType===Ge&&e.target.hasAttribute(be)))return 1;for(let t of e.addedNodes)if(r(t))return 1;for(let t of e.removedNodes)if(r(t))return 1}return 0}(t)||!oe(this,qe,Xe).call(this,e))return;null!==this.s[6]&&clearTimeout(this.s[6]);let i=setTimeout(()=>{!oe(this,qe,Xe).call(this,e)||this.s[6]!==i||(this.s[6]=null,this.s[0].onStructuralChange())},this.s[1]);this.s[6]=i},Be=function(t,e){for(let i of t){if(!oe(this,qe,Xe).call(this,e))return;let t=i.target;if(i.isIntersecting){if(!this.s[3].has(t)&&(this.s[3].add(t),this.s[0].onVisibilityChange(t,1),!oe(this,qe,Xe).call(this,e)))return}else if(this.s[3].has(t)&&(this.s[3].delete(t),this.s[0].onVisibilityChange(t,0),!oe(this,qe,Xe).call(this,e)))return}},Xe=function(t){return this.s[7]===t&&null!==this.s[5]},Ye={basic:1,"schema-json":2,"preview-token":3,"nested-arrays":4,"recursive-diffs":4},Ze=class{constructor(t,e){le(this,Ke);ie(this,"s");this.s=[t,e,void 0,void 0,0,0,[],0]}attach(t=window){if(void 0!==this.s[3])return;let e=0,i=t=>{if(!e||this.s[2]!==i)return;let n=this.s[4];try{oe(this,Ke,Qe).call(this,t,n)}catch{let e="";try{e=t.origin}catch{}oe(this,Ke,ri).call(this,"shape",e,n)}};this.s[4]+=1,oe(this,Ke,ui).call(this),this.s[3]=t,this.s[2]=i;try{t.addEventListener("message",i)}catch(e){this.s[2]===i&&(this.s[3]=void 0,this.s[2]=void 0,oe(this,Ke,ui).call(this));try{t.removeEventListener("message",i)}catch{}throw e}if(this.s[2]===i)e=1;else try{t.removeEventListener("message",i)}catch{}}detach(t){let e=this.s[3],i=this.s[2];void 0===e||void 0===i||(this.s[3]=void 0,this.s[2]=void 0,oe(this,Ke,ui).call(this),e.removeEventListener("message",i))}advanceGeneration(){return void 0===this.s[3]?0:(this.s[4]+=1,oe(this,Ke,ui).call(this),1)}static sendReady(t,e){if(0===t.length||0===e.length)return;let i={type:"payload-live-preview",ready:1,protocolVersion:4};for(let n of t)for(let t of e)try{n.postMessage(i,t)}catch{}}},Ke=new WeakSet,Qe=function(t,e){if(!oe(this,Ke,oi).call(this,e))return;let i=t.origin;if(!oe(this,Ke,oi).call(this,e))return;if(!oe(this,Ke,li).call(this,i,e)){oe(this,Ke,ri).call(this,"origin",i,e);return}let n=t.data;if(!oe(this,Ke,oi).call(this,e))return;let r=function(t){return"object"==typeof t&&null!==t&&"type"in t?"string"==typeof t.type:0}(n);if(!oe(this,Ke,oi).call(this,e))return;if(!r){oe(this,Ke,ri).call(this,"shape",i,e);return}let s=n.type;if(oe(this,Ke,oi).call(this,e))switch(s){case"payload-live-preview":{let t=function(t){let e=t;return!!((void 0===e.data||null===e.data||h(e.data))&&u(e.fieldSchemaJSON,t=>Array.isArray(t))&&u(e.globalSlug,t=>"string"==typeof t)&&u(e.collectionSlug,t=>"string"==typeof t)&&u(e.locale,t=>"string"==typeof t)&&u(e.ready,t=>"boolean"==typeof t)&&u(e.previewToken,t=>"string"==typeof t)&&u(e.protocolVersion,t=>"number"==typeof t))}(n);if(!oe(this,Ke,oi).call(this,e))return;if(!t){oe(this,Ke,ri).call(this,"shape",i,e);return}let r=function(t){let e={...t};for(let t of hi)null===Reflect.get(e,t)&&Reflect.deleteProperty(e,t);if(!Array.isArray(e.fieldSchemaJSON))return e;let i;try{i=l(e.fieldSchemaJSON)}catch{i=[]}return{...e,fieldSchemaJSON:i}}(n);if(!oe(this,Ke,oi).call(this,e))return;oe(this,Ke,ti).call(this,r,i,e);return}case"payload-document-event":{let t=function(t){let e=t;return!(!a(e.action,t=>"updated"===t||"created"===t||"deleted"===t)||!a(e.slug,t=>"string"==typeof t)||!a(e.id,t=>"string"==typeof t||"number"==typeof t&&Number.isFinite(t)))}(n);if(!oe(this,Ke,oi).call(this,e))return;if(!t){oe(this,Ke,ri).call(this,"shape",i,e);return}let r;try{r=this.s[1].onDocumentEvent}catch{return}if(!oe(this,Ke,oi).call(this,e))return;oe(this,Ke,si).call(this,r,n,i);return}default:oe(this,Ke,ri).call(this,"type",i,e)}},ti=function(t,e,i){if(!oe(this,Ke,oi).call(this,i))return;let n=t.data;if(!oe(this,Ke,oi).call(this,i))return;let r=h(n);if(!oe(this,Ke,oi).call(this,i))return;let l,s=r?{generation:i,revision:this.s[5]+=1}:void 0;try{l=this.s[1].validateToken}catch{return}if(!oe(this,Ke,oi).call(this,i))return;if(void 0===l){oe(this,Ke,ni).call(this,t,e,i,s);return}if(1==t.ready&&void 0===n){oe(this,Ke,ni).call(this,t,e,i,void 0);return}let o={generation:i,message:t,origin:e,messageRevision:s,settled:0,approved:0};this.s[6].push(o);let a;try{a=l(t.previewToken,e)}catch{oe(this,Ke,ei).call(this,o,0);return}"boolean"!=typeof a?Promise.resolve(a).then(t=>{oe(this,Ke,ei).call(this,o,1==t)},()=>{oe(this,Ke,ei).call(this,o,0)}):oe(this,Ke,ei).call(this,o,a)},ei=function(t,e){oe(this,Ke,oi).call(this,t.generation)&&(t.approved=e,t.settled=1,oe(this,Ke,ii).call(this,t.generation))},ii=function(t){for(;oe(this,Ke,oi).call(this,t);){let e=this.s[6][this.s[7]];if(void 0===e)return;if(oe(this,Ke,li).call(this,e.origin,t)){if(!e.settled)return;oe(this,Ke,ai).call(this,e)&&(e.approved?oe(this,Ke,ni).call(this,e.message,e.origin,e.generation,e.messageRevision):oe(this,Ke,ri).call(this,"token",e.origin,e.generation))}else{if(!oe(this,Ke,ai).call(this,e))continue;oe(this,Ke,ri).call(this,"origin",e.origin,e.generation)}}},ni=function(t,e,i,n){if(!oe(this,Ke,oi).call(this,i))return;let r;try{r=this.s[1].onUpdate}catch{return}oe(this,Ke,oi).call(this,i)&&(void 0===n?oe(this,Ke,si).call(this,r,t,e):oe(this,Ke,si).call(this,r,t,e,n))},ri=function(t,e,i){if(!oe(this,Ke,oi).call(this,i))return;let n;try{n=this.s[1].onInvalid}catch{return}oe(this,Ke,oi).call(this,i)&&void 0!==n&&oe(this,Ke,si).call(this,n,t,e)},li=function(t,e){if(!oe(this,Ke,oi).call(this,e))return 0;try{return 1==this.s[0](t)&&oe(this,Ke,oi).call(this,e)}catch{return 0}},si=function(e,...i){try{t(e(...i))}catch{}},oi=function(t){return void 0!==this.s[3]&&this.s[4]===t},ai=function(t){let e=this.s;return e[6][e[7]]!==t?0:(e[7]+=1,e[7]===e[6].length?(oe(this,Ke,ui).call(this),1):(e[7]>=1024&&2*e[7]>=e[6].length&&(e[6]=e[6].slice(e[7]),e[7]=0),1))},ui=function(){this.s[6]=[],this.s[7]=0},hi=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],ci=class{constructor(t){ie(this,"s");this.s=[t.timeoutMs??0,t.onTimeout,null,0]}kick(){if(this.s[3]=Date.now(),this.s[0]<=0)return;null!==this.s[2]&&clearTimeout(this.s[2]);let t=setTimeout(()=>{this.s[2]===t&&(this.s[2]=null,this.s[1]())},this.s[0]);this.s[2]=t}stop(){null!==this.s[2]&&(clearTimeout(this.s[2]),this.s[2]=null)}get lastKickAt(){return this.s[3]}get pending(){return null!==this.s[2]}},di=class{constructor(t){ie(this,"s");this.s=["disconnected",t]}get status(){return this.s[0]}markConnected(){return this.transition("connected")}markConnecting(){return this.transition("connecting")}markDisconnected(){return this.transition("disconnected")}transition(t){if(this.s[0]===t)return 0;let e=this.s[0];return this.s[0]=t,this.s[1](t,e),1}},fi=class{constructor(t){ie(this,"s");let n=t.serverURL.replace(/\\/+$/,""),r=t.apiRoute??"/api";this.s=[n,r.startsWith("/")?r:`/${r}`,t.depth??1,t.fetchFn,void 0===t.log?i:e(t.log),null,0,0]}canMerge(t){try{return t.globalSlug?d(t.globalSlug):d(t.collectionSlug)?function(t){if("number"==typeof t)return Number.isFinite(t);if("string"!=typeof t||0===t.length||t.length>512||"."===t||".."===t||t.includes("/")||t.includes("\\\\")||c(t))return 0;try{return encodeURIComponent(t),1}catch{return 0}}(t.data.id):0}catch{return 0}}async merge(t){if(this.s[7]>0)return{status:"superseded"};let e=this.s[6]+1;this.s[6]=e;let i=this.s[5];this.s[5]=null;let n=null;try{if(i?.abort(),!f(this.s,e))return{status:"superseded"};if(!this.canMerge(t))return f(this.s,e)?{status:"unavailable"}:{status:"superseded"};if(!f(this.s,e))return{status:"superseded"};let r=this.s[3]??("function"==typeof fetch?fetch:void 0);if(!f(this.s,e))return{status:"superseded"};if(void 0===r)return{status:"unavailable"};if(n=new AbortController,!f(this.s,e))return n.abort(),{status:"superseded"};this.s[5]=n;let l=t.globalSlug?`globals/${encodeURIComponent(t.globalSlug)}`:`${encodeURIComponent(t.collectionSlug??"")}/${encodeURIComponent(String(t.data.id))}`,s=`${this.s[0]}${this.s[1]}/${l}`,o=JSON.stringify({data:t.data,depth:this.s[2],flattenLocales:0,...void 0!==t.locale?{locale:t.locale}:{}});if(!f(this.s,e))return{status:"superseded"};let a=await r(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:o,signal:n.signal});if(!f(this.s,e)||p(n.signal))return{status:"superseded"};let u=a.ok;if(!f(this.s,e))return{status:"superseded"};if(!u){let t=a.status;return f(this.s,e)?(this.s[4]("merge HTTP",t,s),f(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"superseded"}}let h=await a.json();return!f(this.s,e)||p(n.signal)?{status:"superseded"}:null===h||"object"!=typeof h||Array.isArray(h)?(this.s[4]("merge invalid",s),f(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"merged",doc:h}}catch(t){return!f(this.s,e)||null!==n&&p(n.signal)?{status:"superseded"}:(this.s[4]("merge exception",t),f(this.s,e)?{status:"unavailable"}:{status:"superseded"})}finally{null!==n&&f(this.s,e)&&this.s[5]===n&&(this.s[5]=null)}}destroy(){this.s[6]+=1;let t=this.s[5];this.s[5]=null,this.s[7]+=1;try{t?.abort()}finally{this.s[7]-=1}}},pi=new Set(["http:","https:","mailto:","tel:"]),gi=/^\\s*(?:javascript|data|vbscript|file|blob|about)\\s*:/i,mi=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,yi=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),vi=new Set(["href","src","poster","cite","action","xlink:href","data"]),bi=new WeakSet,wi=class{constructor(t,e){le(this,Si);ie(this,"s");let i=e.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):t=>setTimeout(()=>{t(performance.now())},0)),n=e.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):t=>{clearTimeout(t)});this.s=[t,e.debounceMs??50,e.isVisible,e.visibilityGateThreshold??50,e.disableVisibilityGate??0,e.getCacheSize,e.onFlush,i,n,new Map,new Map,new Set,null,0,null,0,null,0]}schedule(t){if(void 0!==t.identity&&(this.s[17]||!v(t.identity,this.s[16])))return;let e=this.s[9],i=e.get(t.target.element);i?(i.value=t.value,i.allFields=t.allFields,i.identity=t.identity,i.data=t.data):e.set(t.target.element,{...t,identity:t.identity,data:t.data}),oe(this,Si,$i).call(this)}acceptRevision(t){let e=this.s[16];v(t,e)||null!==e&&function(t,e){return t.generation!==e.generation?t.generation-e.generation:t.revision-e.revision}(t,e)<0||(oe(this,Si,Oi).call(this),oe(this,Si,Mi).call(this),this.s[16]=t,this.s[17]=0)}cancelRevision(t){v(t,this.s[16])&&(oe(this,Si,Oi).call(this),oe(this,Si,Mi).call(this),this.s[17]=1)}flushNow(){return oe(this,Si,Oi).call(this),oe(this,Si,ki).call(this)}notifyVisible(t){let e=this.s[10],i=e.get(t);if(!i||(e.delete(t),!oe(this,Si,Ti).call(this,i)))return;let n=performance.now(),r=oe(this,Si,xi).call(this,i)?1:0;this.s[6]?.(oe(this,Si,Ci).call(this,i,r,0,performance.now()-n))}retarget(t){oe(this,Si,Ni).call(this,this.s[9],t),oe(this,Si,Ni).call(this,this.s[10],t);for(let e of this.s[11])oe(this,Si,Ni).call(this,e,t)}forget(t){this.s[9].delete(t),this.s[10].delete(t);for(let e of this.s[11])e.delete(t)}destroy(){oe(this,Si,Oi).call(this),oe(this,Si,Mi).call(this),this.s[16]=null,this.s[17]=0}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}},Si=new WeakSet,$i=function(){let t=this.s[13]+=1,e=this.s[12];if(this.s[12]=null,null!==e&&clearTimeout(e),this.s[13]!==t)return;let i=setTimeout(()=>{this.s[13]===t&&(this.s[12]=null,oe(this,Si,Ai).call(this))},this.s[1]);this.s[13]===t&&(this.s[12]=i)},Ai=function(){let t=this.s[15]+=1,e=this.s[14];if(this.s[14]=null,null!==e&&this.s[8](e),this.s[15]!==t)return;let i=0,n=this.s[7](()=>{this.s[15]===t&&(i=1,this.s[14]=null,oe(this,Si,ki).call(this))});!i&&this.s[15]===t&&(this.s[14]=n)},ki=function(){let t=performance.now(),e=!this.s[4]&&this.s[5]()>this.s[3],i=this.s[9];this.s[9]=new Map;let n,r=0,l=0;this.s[11].add(i);try{for(let t of i.values()){if(!oe(this,Si,Ti).call(this,t))continue;let i=!e||this.s[2](t.target.element);if(oe(this,Si,Ti).call(this,t)){if(n??(n=t),!i){this.s[10].set(t.target.element,t),l+=1;continue}this.s[10].delete(t.target.element),oe(this,Si,xi).call(this,t)&&(r+=1)}}}finally{this.s[11].delete(i)}let s=oe(this,Si,Ci).call(this,n,r,l,performance.now()-t);return this.s[6]?.(s),s},Ti=function(t){return void 0===t.identity||!this.s[17]&&v(t.identity,this.s[16])},xi=function(t){let e=this.s[0];return 0!=e(t)||!function(t){return bi.has(t)}(e)},Ni=function(t,e){let i=t.get(e.element);if(void 0!==i){if(i.target.fieldName!==e.fieldName||i.target.locale!==e.locale){t.delete(e.element);return}i.target=e}},Mi=function(){this.s[9].clear(),this.s[10].clear();for(let t of this.s[11])t.clear()},Ci=function(t,e,i,n){return{applied:e,deferred:i,durationMs:n,...void 0!==t?.identity?{identity:t.identity}:{},...void 0!==t?.data?{data:t.data}:{}}},Oi=function(){let t=this.s[12],e=this.s[14];this.s[13]+=1,this.s[15]+=1,this.s[12]=null,this.s[14]=null,null!==t&&clearTimeout(t),null!==e&&this.s[8](e)},ji=new Set(["__proto__","prototype","constructor"]),Ii="payload-live-preview-a11y",Ei=new WeakMap,Ri=class{constructor(t,e){ie(this,"s");let i=e??(typeof document>"u"?null:document),n=i?.documentElement.getAttribute("lang")??"";this.s=[$(t??(n.length>0?n:S())),i,null]}mount(){let t=this.s[1];if(null==t?.body)return null;let e=this.s[2];null===e&&(e=function(t){let e=Ei.get(t);return e??(e=[null,0,null,0,null]),Ei.set(t,e),e[3]+=1,e}(t),this.s[2]=e);let i=e[0];if(i?.isConnected&&i.ownerDocument===t)return i;if(null!==i){let t=e[1];A(e),t&&i.remove()}let n=t.getElementById(Ii);return e[1]=null===n,n||(n=t.createElement("div"),n.id=Ii,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0"),t.body.appendChild(n)),e[0]=n,n}announceConnected(){this.say(this.s[0]?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.s[0]?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(t){t<=0||this.say(this.s[0]?`${String(t)} ${1===t?"\\xc4nderung":"\\xc4nderungen"} angewendet`:`${String(t)} ${1===t?"change":"changes"} applied`)}detach(){let t=this.s[2],e=this.s[1];if(null===t||null===e||(this.s[2]=null,t[3]-=1,t[3]>0))return;let i=t[0];null!==i&&A(t),t[1]&&i?.remove(),t[0]=null,Ei.delete(e)}say(t){let e=this.mount(),i=this.s[2];if(null===e||null===i)return;let n=i[2];n?.parentNode!==e?(n?.remove(),n=e.ownerDocument.createTextNode(e.hasChildNodes()?` ${t}`:t),i[2]=n,e.appendChild(n)):n.data=null===n.previousSibling?t:` ${t}`,null!==i[4]&&clearTimeout(i[4]);let r=setTimeout(()=>{i[4]===r&&i[0]===e&&A(i)},1500);i[4]=r}},_i=new Set(["tabs","row","collapsible"]),Li={text:"text",textarea:"textarea",richText:"richText",email:"email",number:"number",checkbox:"checkbox",date:"date",select:"select",radio:"radio",array:"array",blocks:"blocks",group:"text",tabs:"text",row:"text",collapsible:"text",relationship:"relationship",upload:"upload",point:"text",json:"text",code:"text",ui:"text"},Wi=[0,500,1e3,2e3],Pi=class{constructor(t){le(this,Fi);ie(this,"d");ie(this,"l");let n=t.emitter,r=t.renderers,l=t.resolveRenderer??(t=>r[t]),s=t.transformValue,a=t.root??(typeof document<"u"?document:null),u=t.readyTargets,h=t.sendReady??j,c=t.onHeartbeatTimeout,d=void 0===t.log?i:e(t.log),f=void 0===t.warn?ue:e(t.warn),p=function(t){if(0==t.enableA11y)return null;let e=void 0===t.root?void 0:9===t.root.nodeType?t.root:t.root.ownerDocument;return new Ri(t.a11yLocale,e)}(t),g=void 0!==t.dataMerge?new fi({serverURL:t.dataMerge.serverURL,...void 0!==t.dataMerge.apiRoute?{apiRoute:t.dataMerge.apiRoute}:{},...void 0!==t.dataMerge.depth?{depth:t.dataMerge.depth}:{},...void 0!==t.dataMerge.fetchFn?{fetchFn:t.dataMerge.fetchFn}:{},log:(...t)=>{d(...t)}}):null,m=new _e,v=new He({onStructuralChange:()=>{oe(this,Fi,Hi).call(this)},onVisibilityChange:(t,e)=>{e&&this.d[3].notifyVisible(t)}},{...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{}}),b=new wi(y(t=>oe(this,Fi,tn).call(this,t)),{...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.disableVisibilityGate?{disableVisibilityGate:t.disableVisibilityGate}:{},...void 0!==t.visibilityGateThreshold?{visibilityGateThreshold:t.visibilityGateThreshold}:{},isVisible:t=>v.isVisible(t),getCacheSize:()=>m.elementCount,onFlush:t=>{oe(this,Fi,en).call(this,t)}}),w=new Ze(t.originMatcher,{onUpdate:(t,e,i)=>{oe(this,Fi,Ji).call(this,t,e,i)},onDocumentEvent:()=>{n.emit("documentSave",{timestamp:Date.now()})},onInvalid:(t,e)=>{if("token"===t){let t=new Error(`Preview token rejected (origin: ${e})`);n.emit("error",{error:t,context:"token"})}d("message rejected:",t,e)},...void 0!==t.validateToken?{validateToken:t.validateToken}:{}}),S=new di(()=>{}),$=new ci({...void 0!==t.heartbeatMs?{timeoutMs:t.heartbeatMs}:{},onTimeout:()=>{oe(this,Fi,nn).call(this)}});this.d=[n,m,v,b,w,S,$,r,l,s,a,u,h,c,d,f,[],p,g],this.l=[void 0,void 0,void 0,o(void 0),0,null,0,null,new Set]}start(){if(this.l[4])return 0;this.l[4]=1;let t=this.d[10];if(O(t)&&"loading"===t.readyState){let e=()=>{if(this.l[4]){this.l[5]=null;try{oe(this,Fi,Di).call(this)}catch(t){oe(this,Fi,zi).call(this),oe(this,Fi,ln).call(this,t,"startup")}}};this.l[5]=e;try{t.addEventListener("DOMContentLoaded",e,{once:1})}catch(t){throw oe(this,Fi,zi).call(this),t}return 1}try{return oe(this,Fi,Di).call(this),1}catch(t){throw oe(this,Fi,zi).call(this),t}}destroy(){this.l[4]&&(oe(this,Fi,Ui).call(this)&&this.d[0].emit("disconnect",{reason:"destroy",timestamp:Date.now()}),this.d[17]?.detach(),this.d[0].emit("destroy",{timestamp:Date.now()}))}refreshCache(){this.l[4]&&oe(this,Fi,Hi).call(this)}get status(){return this.d[5].status}get cache(){return this.d[1]}get updateCount(){return this.l[6]}get protocol(){return this.l[3]}},Fi=new WeakSet,Di=function(){if(!this.l[4])return;let t=O(this.d[10])?function(t){return t.body}(this.d[10]):this.d[10];if(null===t)throw new Error("LivePreviewRuntime: document.body unavailable");if(this.d[2].start(t),oe(this,Fi,Gi).call(this),oe(this,Fi,Qi).call(this)&&(this.d[4].attach(),this.d[0].emitWhile("init",{timestamp:Date.now()},()=>this.l[4]),oe(this,Fi,Qi).call(this)))for(let t of Wi){if(!oe(this,Fi,Qi).call(this))return;if(0===t){if(this.d[12](this.d[11]),!oe(this,Fi,Qi).call(this))return}else{let e=setTimeout(()=>{this.l[4]&&oe(this,Fi,rn).call(this)},t);this.d[16].push(e)}}},Ui=function(){this.l[7]=null,this.l[4]=0;let t=this.l[5];this.l[5]=null,null!==t&&O(this.d[10])&&oe(this,Fi,Vi).call(this,()=>{this.d[10].removeEventListener("DOMContentLoaded",t)});for(let t of this.d[16])oe(this,Fi,Vi).call(this,()=>{clearTimeout(t)});return this.d[16].length=0,oe(this,Fi,Vi).call(this,()=>{this.d[6].stop()}),oe(this,Fi,Vi).call(this,()=>{this.d[4].detach()}),oe(this,Fi,Vi).call(this,()=>{this.d[2].stop()}),oe(this,Fi,Vi).call(this,()=>{this.d[3].destroy()}),oe(this,Fi,Vi).call(this,()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()},zi=function(){oe(this,Fi,Ui).call(this),oe(this,Fi,Vi).call(this,()=>{this.d[17]?.detach()})},Vi=function(t){try{t()}catch(t){this.d[14]("cleanup failed:",t)}},Gi=function(){if(!this.l[4])return;let t=this.d[1].buildFromRoot(this.d[10]);if(this.d[14]("cache",t),oe(this,Fi,Qi).call(this)&&(this.d[0].emitWhile("cacheRefresh",t,()=>this.l[4]),oe(this,Fi,Qi).call(this)))for(let t of this.d[1].values()){if(!oe(this,Fi,Qi).call(this))return;this.d[2].observeElement(t.element)}},Hi=function(){if(!this.l[4])return;let t=new Map;for(let e of this.d[1].values())t.set(e.element,e),this.d[2].unobserveElement(e.element);if(oe(this,Fi,Gi).call(this),oe(this,Fi,Qi).call(this)){for(let e of this.d[1].values())t.get(e.element)?.fieldName===e.fieldName?this.d[3].retarget(e):this.d[3].forget(e.element),t.delete(e.element);for(let e of t.values())this.d[3].forget(e.element)}},qi=function(t){let e=o(t);e.negotiated!==this.l[3].negotiated&&(this.l[3]=e,this.d[14]("protocol","ours=4",`theirs=${t}`,`negotiated=${e.negotiated}`))},Ji=function(t,e,i){if(this.d[6].kick(),void 0===t.data){void 0!==t.protocolVersion&&oe(this,Fi,qi).call(this,t.protocolVersion);return}if(void 0===i)return;"string"==typeof t.locale&&(this.l[0]=t.locale),Array.isArray(t.fieldSchemaJSON)&&(this.l[1]=t.fieldSchemaJSON,this.l[2]=k(t.fieldSchemaJSON));let n={identity:i,message:t,locale:this.l[0],schema:this.l[1],schemaIndex:this.l[2],cancelled:0};this.l[7]=n,this.d[3].acceptRevision(i),this.l[6]+=1,(void 0===t.protocolVersion||(oe(this,Fi,qi).call(this,t.protocolVersion),this.l[4]&&this.l[7]===n))&&(this.d[5].markConnected()&&(this.d[17]?.announceConnected(),this.d[0].emit("connect",{origin:e,timestamp:Date.now()}),!this.l[4]||this.l[7]!==n||(this.d[14]("connection","disconnected","\\u2192","connected"),!this.l[4]||this.l[7]!==n))||oe(this,Fi,Bi).call(this,n))},Bi=async function(t){let e=await oe(this,Fi,Xi).call(this,t);if(null===e||!this.l[4]||this.l[7]!==t)return;let{message:i}=t,n={fields:e,...void 0!==t.schema?{schema:t.schema}:{},..."string"==typeof i.globalSlug?{globalSlug:i.globalSlug}:{},..."string"==typeof i.collectionSlug?{collectionSlug:i.collectionSlug}:{},...void 0!==t.locale?{locale:t.locale}:{}};this.d[0].listenerCount("beforeUpdate")>0&&(!await this.d[0].emitWhile("beforeUpdate",{data:n,revision:t.identity.revision,cancel:()=>{t.cancelled=1,this.d[3].cancelRevision(t.identity)}},()=>!t.cancelled&&this.l[4]&&this.l[7]===t)||t.cancelled||!this.l[4]||this.l[7]!==t)||this.l[4]&&this.l[7]===t&&oe(this,Fi,Yi).call(this,t,n)},Xi=async function(t){let{message:e}=t,i=e.data??{};if(null===this.d[18])return i;let n=await this.d[18].merge({collectionSlug:e.collectionSlug,globalSlug:e.globalSlug,data:i,locale:t.locale});return this.l[4]&&this.l[7]===t?"merged"===n.status?n.doc:"superseded"===n.status?null:i:null},Yi=function(t,e){if(!this.l[4]||this.l[7]!==t)return;let i=()=>this.l[4]&&this.l[7]===t;for(let[n,r]of this.d[1].entries()){if(!this.l[4]||this.l[7]!==t)return;for(let l of r){let r=b(e.fields,n,l.locale??t.locale,void 0!==l.locale);if(void 0===r)continue;if(!this.l[4]||this.l[7]!==t)return;let s=oe(this,Fi,Ki).call(this,l,r,e.fields,i);if(!this.l[4]||this.l[7]!==t)return;let o={target:l,value:s,allFields:e.fields,identity:t.identity,data:e};if(!this.l[4]||this.l[7]!==t)return;this.d[3].schedule(o)}}oe(this,Fi,Zi).call(this,e.fields,t.locale)},Zi=function(t,e){if(0===this.d[1].fieldCount)return;let i;for(let[n,r]of Object.entries(t)){if(this.l[8].has(n)||on.has(n)||!E(r))continue;let t=R(n,e);if(void 0===this.d[1].get(n)&&(t===n||void 0===this.d[1].get(t))){if(void 0===i){i=new Set;for(let[t,e]of this.d[1].entries())for(let n of e)void 0!==n.locale&&i.add(`${t}_${n.locale}`)}i.has(n)||(this.l[8].add(n),this.d[15](`[live-preview] update arrived for field "${n}" but no <\\u2026 data-payload-field="${t}"> element exists on this page. Render the binding anchor unconditionally in your template so live edits to an initially-empty field have somewhere to land.`))}}},Ki=function(e,i,n,r){if(void 0===this.d[9])return i;try{let l=this.d[9](e.fieldName,i,{element:e.element,allFields:n},r),s=t(l);if(!r())return i;if(s)throw new TypeError(`Transform for "${e.fieldName}" returned a Promise/thenable; transforms must be synchronous`);return l}catch(t){if(!r())return i;let e=t instanceof Error?t:new Error(String(t));return this.d[0].emit("error",{error:e,context:"transform"}),i}},Qi=function(){return this.l[4]},tn=function(t){let e=this.l[7];if(null===e||void 0===t.identity||!I(e.identity,t.identity)||!this.l[4]||this.l[7]!==e)return 0;let i=void 0!==e.schemaIndex?function(t,e){if(t.has(e))return t.get(e);let i=e.replace(/\\.\\d+(?=\\.|$)/g,".*");return t.has(i)?t.get(i):void 0}(e.schemaIndex,t.target.fieldName):void 0,n=t.value,r=function(t,e){if(t.explicitFieldType)return t.fieldType;if(void 0!==e){let t=function(t){if(Object.prototype.hasOwnProperty.call(Li,t))return Li[t]}(e);if(void 0!==t)return t}return t.fieldType}(t.target,i?.type);"text"===r&&1!=t.target.explicitFieldType&&function(t){if("object"!=typeof t||null===t||!("root"in t))return 0;let e=t.root;return"object"!=typeof e||null===e?0:Array.isArray(e.children)}(n)&&(r="richText");let l;try{l=this.d[8](r)}catch(t){if(!this.l[4]||this.l[7]!==e)return 0;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:i,context:"renderer"},()=>this.l[4]&&this.l[7]===e),0}if(!this.l[4]||this.l[7]!==e)return 0;let s=this.d[0].listenerCount("elementUpdate")>0,o=s?function(t){return"INPUT"===t.tagName||"TEXTAREA"===t.tagName?t.value:"IMG"===t.tagName?t.src:t.textContent}(t.target.element):void 0;if(!this.l[4]||this.l[7]!==e)return 0;let a={allFields:t.allFields,locale:t.target.locale??e.locale,schema:i};try{if(void 0!==t.target.targetAttribute){if("blocked"===function(t,e,i){let n=e.toLowerCase().trim();if(0===n.length||n.startsWith("on")||yi.has(n))return"blocked";if(null==i)return t.removeAttribute(n),"applied";if("string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i)return"blocked";let r=String(i);return vi.has(n)&&!g(r)?"blocked":(t.setAttribute(n,r),"applied")}(t.target.element,t.target.targetAttribute,n))return this.d[15](`[live-preview] refused to write field "${t.target.fieldName}" into attribute "${t.target.targetAttribute}" (unsafe attribute or value)`),0}else{if(!l)return this.d[14]("no renderer for",r),0;if(0==function(t,e,i,n){return t.render(e,i,n)}(l,t.target,n,a)&&function(t){return bi.has(t.render)}(l))return 0}}catch(t){if(!this.l[4]||this.l[7]!==e)return 0;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:i,context:"renderer"},()=>this.l[4]&&this.l[7]===e),0}return this.l[4]&&this.l[7]===e?(s&&this.d[0].emitWhile("elementUpdate",{element:t.target.element,fieldName:t.target.fieldName,previousValue:o,nextValue:n,revision:e.identity.revision},()=>this.l[4]&&this.l[7]===e),this.l[4]&&this.l[7]===e):0},en=function(t){let{identity:e,data:i}=t;if(0===t.applied||void 0===e||void 0===i)return;let n=this.l[7];if(null===n||!this.l[4]||this.l[7]!==n||!I(n.identity,e))return;let r=()=>this.l[4]&&this.l[7]===n&&I(n.identity,e);this.d[17]?.announceUpdate(t.applied),r()&&0!==this.d[0].listenerCount("afterUpdate")&&this.d[0].emitWhile("afterUpdate",{data:i,updatedCount:t.applied,durationMs:t.durationMs,revision:e.revision},r)},nn=function(){if(!oe(this,Fi,Qi).call(this))return;this.d[4].advanceGeneration();let t=this.l[7];this.l[7]=null,null!==t&&this.d[3].cancelRevision(t.identity),this.d[18]?.destroy();let e=this.d[5].markDisconnected();try{this.d[13]?.()}catch(t){this.d[14]("heartbeat:",t)}oe(this,Fi,Qi).call(this)&&(e&&oe(this,Fi,sn).call(this)&&(this.d[17]?.announceDisconnected(),this.d[0].emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>oe(this,Fi,sn).call(this)),!oe(this,Fi,Qi).call(this)||oe(this,Fi,sn).call(this)&&(this.d[14]("connection","connected","\\u2192","disconnected"),!oe(this,Fi,Qi).call(this)))||oe(this,Fi,Qi).call(this)&&oe(this,Fi,rn).call(this))},rn=function(){try{this.d[12](this.d[11])}catch(t){oe(this,Fi,ln).call(this,t,"ready")}},ln=function(t,e){let i=t instanceof Error?t:new Error(String(t));this.d[0].emit("error",{error:i,context:e})},sn=function(){return this.l[4]&&"disconnected"===this.d[5].status&&null===this.l[7]},on=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),an=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,un=/^https?:\\/\\/[^/?#\\s]+$/i,hn=["PAYLOAD_ADMIN_ORIGIN","PUBLIC_PAYLOAD_ADMIN_ORIGIN","NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN"],cn=class{constructor(t={}){le(this,dn);let e=new Set;for(let i of t.additionalOrigins??[]){let t=W(i);void 0!==t&&e.add(t)}for(let t of hn){let i=L(t);if(void 0!==i)for(let t of i.split(",")){let i=W(t);void 0!==i&&e.add(i)}}let i;if(t.enableReferrerDetection??1){let e=t.referrer??(typeof document<"u"?document.referrer:"");if(e.length>0)try{let t=new URL(e).origin;t&&"null"!==t&&(i=t)}catch{}}let n=(t.enableLocalhostMatching??1)&&(t.forceDevMode??function(){let t=function(){if(!(typeof process>"u"))return"production"}();if(void 0!==t)return"production"!==t;0;if(typeof window<"u"){let t=window.location.hostname;if("localhost"===t||"127.0.0.1"===t)return 1}return 0}());se(this,dn,[e,i,n,void 0!==i,void 0])}matches(t){return 0===t.length||"null"===t?0:void 0!==re(this,dn)[4]?t===re(this,dn)[4]:!!(re(this,dn)[0].has(t)||0===re(this,dn)[0].size&&void 0!==re(this,dn)[1]&&t===re(this,dn)[1]||re(this,dn)[2]&&an.test(t))}lockOrigin(t){return this.matches(t)?(re(this,dn)[4]=t,1):0}unlockOrigin(){let t=re(this,dn)[4];return re(this,dn)[4]=void 0,t}get lockedOrigin(){return re(this,dn)[4]}enumerate(){if(void 0!==re(this,dn)[4])return[re(this,dn)[4]];let t=new Set(re(this,dn)[0]);if(0===re(this,dn)[0].size&&void 0!==re(this,dn)[1]&&t.add(re(this,dn)[1]),re(this,dn)[2])for(let e of fn)t.add(`http://localhost:${String(e)}`),t.add(`http://127.0.0.1:${String(e)}`);return[...t]}get referrerWasAvailable(){return re(this,dn)[3]}get isProductionUnconfigured(){return!(!_()||re(this,dn)[0].size>0||re(this,dn)[2]||void 0!==re(this,dn)[1])}get isReferrerOnlyTrust(){return re(this,dn)[0].size>0||re(this,dn)[2]?0:void 0!==re(this,dn)[1]}},dn=new WeakMap,fn=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],pn=new Set(["p","br","strong","b","em","i","u","s","strike","mark","small","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","blockquote","code","pre","kbd","samp","var","a","span","div","section","article","aside","header","footer","nav","figure","figcaption","img","picture","source","audio","video","sub","sup","hr","time","abbr","cite","q","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col"]),gn=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),mn=new Set(["id","class","lang","dir","title","role","tabindex"]),yn="aria-",vn="data-",bn={a:new Set(["href","target","rel","download","hreflang","type"]),img:new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:new Set([]),source:new Set(["src","srcset","sizes","type","media"]),audio:new Set(["src","controls","autoplay","loop","muted","preload"]),video:new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:new Set(["datetime"]),abbr:new Set(["title"]),q:new Set(["cite"]),blockquote:new Set(["cite"]),table:new Set(["summary"]),th:new Set(["colspan","rowspan","scope","headers","abbr"]),td:new Set(["colspan","rowspan","headers"]),col:new Set(["span"]),colgroup:new Set(["span"]),ol:new Set(["start","reversed","type"]),li:new Set(["value"]),code:new Set(["class"]),pre:new Set(["class"])},wn=new Set(["href","src","cite","poster"]),Sn=1,$n=8,An=class extends Error{constructor(){super(...arguments);ie(this,"name","SanitizerEnvironmentError")}},kn=(Object.freeze({allowedTags:pn,removeCompletely:gn,globalAttributes:mn,attributesByTag:bn,urlAttributes:wn}),new Map),Tn={1:"left",2:"center",3:"right",4:"justify"},xn=new Set(["left","center","right","justify","start","end"]),Nn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),Mn=/[&<>"\'/`=]/g,Cn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),On=/[&<>"\']/g,jn=new Set(["h1","h2","h3","h4","h5","h6"]),In=(t,e)=>{let i="string"==typeof t.url?t.url:"",n=e.renderChildren(t.children??[]);if(0===i.length||!g(i))return n;let r=m(i)?\' target="_blank" rel="noopener noreferrer"\':function(t){let e="string"==typeof t.target?t.target:"";if(0===e.length)return"";let i=B(e);return"_blank"===e?\' target="_blank" rel="noopener noreferrer"\':` target="${i}"`}(t),l="string"==typeof t.title?` title="${B(t.title)}"`:"";return`<a href="${X(i)}"${r}${l}>${n}</a>`},En=new Map;V("text",t=>{let e=B("string"==typeof t.text?t.text:""),i="number"==typeof t.format?t.format:0;return!!(16&i)&&(e=`<code>${e}</code>`),!!(1&i)&&(e=`<strong>${e}</strong>`),!!(2&i)&&(e=`<em>${e}</em>`),!!(8&i)&&(e=`<u>${e}</u>`),!!(4&i)&&(e=`<s>${e}</s>`),!!(32&i)&&(e=`<sub>${e}</sub>`),!!(64&i)&&(e=`<sup>${e}</sup>`),!!(128&i)&&(e=`<mark>${e}</mark>`),e});V("paragraph",(t,e)=>{let i=e.renderChildren(t.children??[]);return`<p${q(t)}${J(t)}>${i}</p>`});V("heading",(t,e)=>{let i="string"==typeof t.tag?t.tag.toLowerCase():"h2",n=jn.has(i)?i:"h2",r=e.renderChildren(t.children??[]);return`<${n}${q(t)}${J(t)}>${r}</${n}>`});V("list",(t,e)=>{let i="string"==typeof t.listType?t.listType:"bullet",n="number"===i?"ol":"ul",r="number"===i&&"number"==typeof t.start&&t.start>1?` start="${String(t.start)}"`:"",l="check"===i?\' role="list"\':"",s=e.renderChildren(t.children??[]);return`<${n}${q(t)}${J(t)}${r}${l}>${s}</${n}>`});V("listitem",(t,e)=>{let i=e.renderChildren(t.children??[]);if("boolean"==typeof t.checked)return`<li role="checkbox" aria-checked="${t.checked?"true":"false"}"${J(t)}>${i}</li>`;let n="number"==typeof t.value?` value="${B(String(t.value))}"`:"";return`<li${q(t)}${J(t)}${n}>${i}</li>`});V("link",In);V("autolink",In);V("quote",(t,e)=>{let i=e.renderChildren(t.children??[]);return`<blockquote${q(t)}${J(t)}>${i}</blockquote>`});V("code",t=>{let e=K("string"==typeof t.language?t.language:"");return`<pre><code${""===e?"":` class="language-${e}"`}>${B(Z(t))}</code></pre>`});V("code-highlight",t=>{let e="string"==typeof t.text?t.text:"";return`<span${"string"==typeof t.highlightType?` class="token-${K(t.highlightType)}"`:""}>${B(e)}</span>`});V("linebreak",()=>"<br>");V("horizontalrule",()=>"<hr>");V("tab",()=>"\\t");V("upload",t=>{let e=function(t){let e=t.value;if("object"==typeof e&&null!==e)return e}(t);if(void 0===e)return"";let i=e.url;if("string"!=typeof i||!g(i))return"";let n="string"==typeof e.mimeType?e.mimeType:"";return n.startsWith("video/")?function(t,e){let i="number"==typeof t.width?` width="${String(t.width)}"`:"",n="number"==typeof t.height?` height="${String(t.height)}"`:"",r="string"==typeof t.mimeType?` type="${X(t.mimeType)}"`:"";return`<video controls${i}${n}><source src="${X(e)}"${r}></video>`}(e,i):n.startsWith("audio/")?function(t,e){let i="string"==typeof t.mimeType?` type="${X(t.mimeType)}"`:"";return`<audio controls><source src="${X(e)}"${i}></audio>`}(e,i):""===n||n.startsWith("image/")?function(t,e){let i="string"==typeof t.alt?B(t.alt):"",n="number"==typeof t.width?` width="${String(t.width)}"`:"",r="number"==typeof t.height?` height="${String(t.height)}"`:"";return`<img src="${X(e)}" alt="${i}"${n}${r} loading="lazy" decoding="async">`}(e,i):function(t,e){let i="string"==typeof t.filename?B(t.filename):B(e);return`<a href="${X(e)}" target="_blank" rel="noopener noreferrer">${i}</a>`}(e,i)});V("relationship",t=>{let e="string"==typeof t.relationTo?t.relationTo:"",i=function(t){let e=t.value;if("object"==typeof e&&null!==e)return e}(t),n=function(t,e){return void 0===t?""===e?"#":`#${e}`:"string"==typeof t.title&&t.title.length>0?t.title:"string"==typeof t.name&&t.name.length>0?t.name:"string"==typeof t.slug&&t.slug.length>0?t.slug:void 0!==t.id?String(t.id):""===e?"#":`#${e}`}(i,e),r=B(n),l=""===e?"":` data-relation-to="${B(e)}"`,s=i?.url;return"string"==typeof s&&g(s)?`<a href="${X(s)}"${l}>${r}</a>`:`<span${l}>${r}</span>`});V("block",(t,e)=>{let i=function(t){let e=t.fields;return"object"!=typeof e||null===e?{}:e}(t),n="string"==typeof i.blockType?i.blockType:"",r=tt(n);if(""!==n){let t=Q(n)??Q(r);if(t)return t(i,{renderChildren:e.renderChildren})}let l=[];""!==r&&l.push(`data-block-type="${B(r)}"`);for(let[t,e]of Object.entries(i)){if("blockType"===t||"id"===t||null==e)continue;let i="string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);l.push(`data-block-${tt(t)}="${B(i)}"`)}return`<div${0===l.length?"":` ${l.join(" ")}`}></div>`});jt={renderChildren:nt,resolveAlignment:G,resolveIndent:H};It="data-payload-text";Et={name:"textarea",render(t,e){let i=t.element,n=et(e)?it(e):ot(e);"INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName?i.innerHTML=Y(n):i.value=n}};Rt={name:"richText",render:y((t,e)=>{if(et(e))t.element.innerHTML=function(t,e={}){if(!et(t))return"";let i=nt(t.root.children);return 0==e.sanitize||void 0===F()?i:P(i)}(e);else{if("string"!=typeof e)return 0;t.element.innerHTML=P(e)}})};_t={name:"html",render(t,e){if(null==e){t.element.textContent="";return}let i="string"==typeof e?e:ot(e);t.element.innerHTML=P(i)}};Lt={name:"url",render(t,e,i){let n=t.element,r=ot(e);if("A"===n.tagName){let l=n,s=t.hrefField,o=void 0===s||0===s.length?e:b(i.allFields,s,i.locale,void 0!==t.locale);"string"==typeof o&&g(o)&&(l.href=o),l.textContent=r;return}"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName?n.textContent=r:n.value=r}};Wt={name:"image",render:y((t,e,i)=>{let n=t.element,r=at(e),l=void 0!==t.locale,s=function(t,e,i,n,r,l){if(void 0!==i&&i.length>0){let t=b(n,i,r,l);if("string"==typeof t&&g(t))return t;let e=at(t);return void 0!==e?.url&&g(e.url)?e.url:void 0}return void 0!==t?.url&&g(t.url)?t.url:"string"==typeof e&&g(e)?e:void 0}(r,e,t.srcField,i.allFields,i.locale,l);if(void 0===s)return 0;if("IMG"===n.tagName){let e=n;e.src=s;let o=function(t,e,i,n,r){if(void 0!==e&&e.length>0){let t=b(i,e,n,r);return"string"==typeof t?t:void 0}if(void 0!==t?.alt)return t.alt}(r,t.altField,i.allFields,i.locale,l);void 0!==o&&(e.alt=o);return}n.style.backgroundImage=`url(\'${function(t){return t.replace(/[\'"()\\\\]/g,"\\\\$&")}(s)}\')`})};Pt={name:"upload",render:y((t,e)=>{let i=t.element,n=function(t){if("object"==typeof t&&null!==t)return t}(e);if(void 0===n)return 0;let r=n.url;if("string"!=typeof r||!g(r))return 0;if("IMG"===i.tagName){let t=i;t.src=r,void 0!==n.alt&&(t.alt=n.alt);return}if("A"===i.tagName){let t=i;t.href=r,t.textContent=n.filename??r;return}let l=void 0!==n.filename?B(n.filename):B(r);i.innerHTML=`<a href="${X(r)}">${l}</a>`})};Ft={name:"relationship",render(t,e){let i=t.element,n=function(t){return null==t?[""]:Array.isArray(t)?t.map(ut):[ut(t)]}(e).join(", ");if("A"===i.tagName&&!Array.isArray(e)){let t=i,r=e?.url;"string"==typeof r&&g(r)&&(t.href=r),t.textContent=n;return}i.textContent=n}};Dt={name:"select",render(t,e){let i=t.element,n=ht(e);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let t=i;t.checked=t.value===n;return}i.textContent=n}else i.value=n}};Ut={name:"checkbox",render(t,e){let i=t.element,n=!!e;"INPUT"!==i.tagName||"checkbox"!==i.type?i.hasAttribute("aria-checked")?i.setAttribute("aria-checked",n?"true":"false"):i.textContent=n?"true":"false":i.checked=n}};zt=new Map,Vt=new Map,Gt=64;Ht={name:"date",render(t,e,i){let n=t.element;if(null==e||""===e){"INPUT"===n.tagName?n.value="":("TIME"===n.tagName&&n.removeAttribute("datetime"),n.textContent="");return}let r="string"==typeof e?e:ot(e),l=new Date(r),s=!Number.isNaN(l.getTime());"INPUT"!==n.tagName?("TIME"!==n.tagName||n.setAttribute("datetime",s?l.toISOString():r),n.textContent=s?function(t,e){let i=e.locale??S();try{return function(t,e){let i=ct(t,e),n=Vt.get(i);if(void 0!==n)return Vt.delete(i),Vt.set(i,n),n;let r=new Intl.DateTimeFormat(t,e);return Vt.set(i,r),ft(Vt),r}(i,{dateStyle:"medium",timeStyle:"short"}).format(t)}catch{return t.toISOString()}}(l,i):r):n.value=s?function(t,e){return"date"===t?e.toISOString().slice(0,10):"datetime-local"===t?e.toISOString().slice(0,16):e.toISOString()}(n.type,l):r}};qt={name:"number",render(t,e,i){let n=t.element;if(null==e||""===e){"INPUT"===n.tagName?n.value="":n.textContent="";return}let r="number"==typeof e?e:Number(ot(e));Number.isNaN(r)?n.textContent=ot(e):"INPUT"!==n.tagName?n.textContent=function(t,e){let i=e.locale??S();try{return function(t,e){let i=ct(t,e),n=zt.get(i);if(void 0!==n)return zt.delete(i),zt.set(i,n),n;let r=new Intl.NumberFormat(t,e);return zt.set(i,r),ft(zt),r}(i).format(t)}catch{return String(t)}}(r,i):n.value=String(r)}};Jt=/\\{\\{([\\s\\S]*?)\\}\\}/g;Bt={name:"array",render:y((t,e)=>{let i=t.element;if(!Array.isArray(e))return 0;let n=t.arrayTemplate;if(void 0!==n&&n.length>0){let t=function(t,e){let i="";for(let n=0;n<e.length;n+=1)i+=gt(t,e[n],n);return i}(n,e);i.innerHTML=P(t);return}let r=t.arraySeparator??", ";i.textContent=e.map(mt).join(r)})};Xt="data-payload-key",Yt="data-payload-nested-key",Zt="data-payload-nested-template";Kt=new Map;Qt=[Et,Rt,_t,Lt,{...Lt,name:"email"},Wt,Pt,Ft,Dt,{...Dt,name:"radio"},Ut,Ht,qt,Bt,{...Bt,name:"blocks"}];!function(){if(typeof window>"u"||!_()&&(typeof window>"u"||null==window.opener))return;let t=window.__livePreview;if(void 0!==t)return t;let[e=[],i="",n="/api",r=1,l=0,s=50,o=1,a=0,u=0,h=50,c="200px",d=0,f=0]=typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__,p=new cn({additionalOrigins:e,enableReferrerDetection:!d,enableLocalhostMatching:!f});p.isProductionUnconfigured?ue("[live-preview] No trusted origin. Set PAYLOAD_ADMIN_ORIGIN or pass allowedOrigins to generateInlineScript()."):p.isReferrerOnlyTrust&&ue("[live-preview] document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let g=new ce,m=function(t=[]){let e={};for(let i of t)e[i.name]=i;for(let[t,i]of Kt)e[t]=i;return Object.freeze(e)}([st(),...Qt,Ct()]),y=new Pi({renderers:m,originMatcher:t=>p.matches(t),readyTargets:p.enumerate(),emitter:g,...""!==i?{dataMerge:{serverURL:i,apiRoute:n,depth:r}}:{},debounceMs:s,heartbeatMs:a,intersectionRootMargin:c,disableVisibilityGate:u,visibilityGateThreshold:h,enableA11y:o,onHeartbeatTimeout:()=>{p.unlockOrigin()},...l?{log:(...t)=>{he("[live-preview]",...t)}}:{}});g.on("connect",t=>{p.lockOrigin(t.origin)}),y.start();let v=Object.freeze({version:"1.0.4",destroy:()=>{y.destroy();let t=window;t.__livePreview===v&&delete t.__livePreview},refresh:()=>{y.refreshCache()},enumerateOrigins:()=>p.enumerate()});try{Object.defineProperty(window,"__livePreview",{value:v,writable:0,configurable:1})}catch(t){throw y.destroy(),t}}()})();',or={generatedAt:"2026-08-14T18:09:33.000Z",size:63959};function ar(e={}){if(0===sr.length)throw new Error("[live-preview] runtime.generated.ts is empty. Run `npm run build:runtime` before bundling.");let t=[e.allowedOrigins,e.serverURL,e.apiRoute,e.mergeDepth,e.debug,e.debounceMs,e.enableA11y,e.heartbeatMs,e.disableVisibilityGate,e.visibilityGateThreshold,e.intersectionRootMargin,e.disableReferrerDetection,e.disableLocalhostMatching];for(;t.length>0&&void 0===t.at(-1);)t.pop();return[`var __LIVE_PREVIEW_CONFIG__=${`[${t.map(e=>void 0===e?"":JSON.stringify(e)).join(",")}]`.replace(/</g,"\\u003C")};`,sr].join("\n")}function ur(e,t={}){return`<script${void 0!==t.nonce?` nonce="${dr(t.nonce)}"`:""}>${e}<\/script>`}function hr(){return or}function dr(e){if(!/^[A-Za-z0-9+/=_-]+$/.test(e))throw new RangeError("wrapWithScriptTag: nonce contains invalid characters");return e}t(ar,"generateInlineScript"),t(ur,"wrapWithScriptTag"),t(hr,"runtimeBuildInfo"),t(dr,"escapeNonce");var cr,fr=/[\t\n\f\r ]+/,pr=/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;function gr(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function mr(e){cr=e??void 0}function yr(e=16){if(!Number.isInteger(e)||e<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(e)}`);let t=vr();if(!t)throw new Error("generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) once at startup, or run with --experimental-global-webcrypto. We won't fabricate a predictable nonce — that would silently defeat the entire CSP.");let i=new Uint8Array(e);return t.getRandomValues(i),br(i)}function vr(){if(cr?.getRandomValues)return cr;let e=globalThis.crypto;return e?.getRandomValues?e:void 0}function br(e){let t="";for(let i of e)t+=String.fromCharCode(i);return("function"==typeof btoa?btoa(t):Buffer.from(e).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function wr(e={}){let{self:t=!0,origins:i=[],allowNone:n=!1}=e,r=new Set,l=[];if(n&&!t&&0===i.length)return"'none'";t&&(l.push("'self'"),r.add("'self'"));for(let e of i){let t=e.trim();0===t.length||r.has(t)||(r.add(t),l.push(t))}return l.length>0?l.join(" "):"'none'"}function Sr(e,t={}){if(0===e.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");let{self:i=!0,extra:n=[],strictDynamic:r=!1}=t,l=[];i&&l.push("'self'"),l.push(`'nonce-${e}'`),r&&l.push("'strict-dynamic'");for(let e of n){let t=e.trim();t.length>0&&l.push(t)}return l.join(" ")}function Ar(e,t){let i=new Map;for(let t of e.split(";")){let e=t.replace(pr,"");if(0===e.length)continue;let n=e.search(fr),r=gr(n<0?e:e.slice(0,n));if(i.has(r))continue;let l=n<0?"":e.slice(n).replace(pr,"");i.set(r,l)}for(let[e,n]of Object.entries(t)){let t=gr(e),r="string"==typeof n?{value:n}:n,l=r.mode??"union",s=i.get(t);if("replace"===l||void 0===s||0===s.length){i.set(t,r.value);continue}let o=new Set,a=[];for(let e of[...s.split(fr),...r.value.split(fr)])0===e.length||o.has(e)||(o.add(e),a.push(e));let u=a.filter(e=>"'none'"!==e);i.set(t,(u.length>0?u:a).join(" "))}let n=[];for(let[e,t]of i)n.push(0===t.length?e:`${e} ${t}`);return n.join("; ")}t(gr,"asciiLowercase"),t(mr,"setCspCrypto"),t(yr,"generateCspNonce"),t(vr,"resolveCrypto"),t(br,"base64UrlEncode"),t(wr,"buildFrameAncestors"),t(Sr,"buildScriptSrcWithNonce"),t(Ar,"mergeCspHeader");var Tr=["preview","draft","livePreview"];function $r(e,t={}){let i=new Set(t.signals??["query","fetch-dest","referer"]),n=t.queryParams??Tr,r=(t.checkFetchDest??!0)&&i.has("fetch-dest");if(i.has("query")){let t;try{t=new URL(e.url)}catch{t=void 0}if(void 0!==t)for(let e of n){let i=t.searchParams.get(e);if("true"===i||"1"===i)return!0}}if(r&&"iframe"===e.headers.get("sec-fetch-dest"))return!0;let l=i.has("referer")?t.adminOrigins??[]:[];if(l.length>0){let t=e.headers.get("referer");if(null!==t)try{let e=new URL(t).origin;for(let t of l)try{if(new URL(t).origin===e)return!0}catch{}}catch{}}return!1}async function kr(e){let t=Mr(e);if(void 0!==e.id)return Rr(`${Nr(e)}/${encodeURIComponent(e.collection)}/${encodeURIComponent(String(e.id))}?${t.toString()}`,e);void 0!==e.where&&Cr(t,e.where,["where"]),t.set("limit","1");let i=`${Nr(e)}/${encodeURIComponent(e.collection)}?${t.toString()}`;return(await Rr(i,e))?.docs?.[0]??null}async function xr(e){let t=Mr(e);return Rr(`${Nr(e)}/globals/${encodeURIComponent(e.global)}?${t.toString()}`,e)}function Nr(e){let t=e.serverURL.replace(/\/+$/,""),i=e.apiRoute??"/api";return`${t}${i.startsWith("/")?i:`/${i}`}`}function Mr(e){let t=new URLSearchParams;return t.set("depth",String(e.depth??1)),(e.draft??!0)&&t.set("draft","true"),void 0!==e.locale&&t.set("locale",e.locale),t}function Cr(e,t,i){for(let[n,r]of Object.entries(t)){let t=[...i,n];if(null!==r&&"object"==typeof r&&!Array.isArray(r)){Cr(e,r,t);continue}let l=t.map((e,t)=>0===t?e:`[${e}]`).join("");Array.isArray(r)?e.set(l,r.map(String).join(",")):e.set(l,String(r))}}async function Rr(e,t){let i=t.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===i)return null;try{let n=await i(e,{credentials:"include",headers:{Accept:"application/json",...t.headers??{}}});if(!n.ok)return null;let r=await n.json();return null===r||"object"!=typeof r?null:r}catch{return null}}t($r,"isPreviewRequest"),t(kr,"fetchPreviewDocument"),t(xr,"fetchPreviewGlobal"),t(Nr,"apiBase"),t(Mr,"baseParams"),t(Cr,"appendWhere"),t(Rr,"requestJson");var Or="payload-live-preview-highlight",Ir=new WeakMap,Fr=new WeakMap,Lr={name:"highlight",version:"1.0.0",init:t(e=>{if(typeof document>"u"||typeof window>"u")return;let i="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,n=Er(document,i),r=i?1e3:600,l=new WeakMap,s=new Set;e.registerCleanup?.(()=>{for(let e of[...s])e();n()}),e.events.on("elementUpdate",e=>{let i=e.element;l.get(i)?.();let n=Pr(i),o=!1,a=t(()=>{o||(o=!0,window.clearTimeout(u),l.get(i)===a&&l.delete(i),s.delete(a),n())},"disposeTimer"),u=window.setTimeout(a,r);s.add(a),l.set(i,a)})},"init")};function Er(e,t){let i=Ir.get(e);if(void 0!==i&&!i.element.isConnected&&(Ir.delete(e),i=void 0),void 0===i){let n=e.getElementById(Or),r=n instanceof HTMLStyleElement?n:e.createElement("style"),l=null===n;l&&(r.id=Or,r.textContent=t?".lp-highlight{outline:2px solid rgba(0,102,204,0.85);outline-offset:2px;}":"@keyframes lp-highlight{0%{outline:2px solid rgba(0,102,204,0.85);outline-offset:2px}100%{outline:2px solid transparent;outline-offset:2px}}.lp-highlight{animation:lp-highlight 0.6s ease-out;}",e.head.appendChild(r)),i={element:r,pluginOwned:l,owners:0},Ir.set(e,i)}let n=i;n.owners+=1;let r=!0;return()=>{r&&(r=!1,n.owners-=1,!(n.owners>0)&&(Ir.get(e)===n&&Ir.delete(e),n.pluginOwned&&n.element.remove()))}}function Pr(e){let t=Fr.get(e);void 0===t&&(t={owners:0,pluginAdded:!e.classList.contains("lp-highlight")},Fr.set(e,t));let i=t;i.owners+=1,e.classList.add("lp-highlight");let n=!0;return()=>{n&&(n=!1,i.owners-=1,!(i.owners>0)&&(Fr.delete(e),i.pluginAdded&&e.classList.remove("lp-highlight")))}}t(Er,"acquireStyle"),t(Pr,"acquireHighlight");var jr={name:"debug",version:"1.0.0",init:t(e=>{e.events.on("init",()=>{e.log("init")}),e.events.on("connect",t=>{e.log("connect ←",t.origin)}),e.events.on("disconnect",t=>{e.log("disconnect (",t.reason,")")}),e.events.on("cacheRefresh",t=>{e.log("cacheRefresh",t.elementCount,"elements,",t.fieldCount,"fields")}),e.events.on("beforeUpdate",t=>{e.log("beforeUpdate",Object.keys(t.data.fields).length,"fields")}),e.events.on("afterUpdate",t=>{e.log("afterUpdate",t.updatedCount,"in",t.durationMs.toFixed(2),"ms")}),e.events.on("error",t=>{e.log("error in",t.context,":",t.error.message)})},"init")};function Dr(){let e=0,i=0,n=0;return{name:"analytics",version:"1.0.0",init:t(t=>{t.events.on("afterUpdate",t=>{e+=1,i+=t.updatedCount,n+=t.durationMs})},"init"),getStats:t(()=>({updateCount:e,totalElements:i,totalDurationMs:n,averageDurationMs:0===e?0:n/e}),"getStats")}}t(Dr,"createAnalyticsPlugin");var Ur="payload-live-preview:scroll";function Wr(){if(!(typeof window>"u"))try{sessionStorage.setItem(Ur,JSON.stringify({href:window.location.href,x:window.scrollX,y:window.scrollY}))}catch{}}function _r(){if(!(typeof window>"u"))try{let e=sessionStorage.getItem(Ur);if(null===e)return;sessionStorage.removeItem(Ur);let t=JSON.parse(e);if(t.href!==window.location.href)return;window.scrollTo(t.x??0,t.y??0)}catch{}}function Vr(){typeof window>"u"||(Wr(),window.location.reload())}function zr(e={}){let i=e.strategy??"silent";return{name:"document-save",version:"1.1.0",init:t(t=>{let n=!0,r=new Set;t.registerCleanup?.(()=>{n=!1;for(let e of r)e.abort();r.clear()}),_r(),t.events.on("documentSave",()=>{if(!n||"silent"===i)return;if("reload"===i)return void Vr();let l=new AbortController;r.add(l),("fetch"===i?Br(e,t.log,l.signal,()=>n):Kr(e,t.log,l.signal,()=>n)).finally(()=>{r.delete(l)})})},"init")}}async function Br(e,t,i,n){if(e.handler)try{await e.handler(i)}catch(e){if(!n()||i.aborted)return;t("document-save handler threw:",e)}else t("document-save: fetch strategy selected but no handler supplied")}async function Kr(e,t,i,n){if(typeof fetch>"u")return void t("document-save: revalidate strategy needs fetch — not available");let r=e.revalidateUrl??"/api/revalidate",l=!1;try{let s=await fetch(r,{method:"POST",signal:i,headers:{"Content-Type":"application/json",...e.revalidateHeaders??{}},body:JSON.stringify({source:"payload-live-preview"})});if(!n()||i.aborted)return;l=s.ok,l||t("document-save revalidate non-2xx:",s.status)}catch(e){if(!n()||i.aborted)return;t("document-save revalidate failed:",e)}!l&&"reload"===e.onRevalidateFailure&&Vr()}function Gr(e,t){return Hr(e,t)}function qr(e,t){let i=Jr(e);if(0===i.length)throw new Error("bindByPath: the picker did not read any field — return data.<field> instead of a constant");return Hr(i.join("."),t)}function Hr(e,t){if(0===e.length)throw new Error("bind: field name must be a non-empty string");let i={"data-payload-field":e};return void 0!==t?.attribute&&(i["data-payload-attribute"]=t.attribute),void 0!==t?.type&&(i["data-payload-type"]=t.type),i}function Jr(e){let t=[],i=new Proxy({},{get(e,n){if("symbol"!=typeof n)return/^\d+$/.test(n)||t.push(n),i}});try{e(i)}catch{}return t}t(Wr,"saveScrollPosition"),t(_r,"restoreScrollPosition"),t(Vr,"reloadPreservingScroll"),t(zr,"documentSavePlugin"),t(Br,"runFetch"),t(Kr,"runRevalidate"),t(Gr,"bind"),t(qr,"bindByPath"),t(Hr,"buildAttributes"),t(Jr,"recordPath");export{tt as EventEmitter,M as LIBRARY_PROTOCOL_VERSION,rr as LivePreviewClient,ft as OriginDetector,i as VERSION,Gr as bind,qr as bindByPath,nr as buildBuiltinRenderers,wr as buildFrameAncestors,Sr as buildScriptSrcWithNonce,Dr as createAnalyticsPlugin,jr as debugPlugin,be as detectInitialLocale,zr as documentSavePlugin,Xt as escapeHtml,ei as escapeHtmlAttribute,kr as fetchPreviewDocument,xr as fetchPreviewGlobal,yr as generateCspNonce,ar as generateInlineScript,O as hasCapability,Lr as highlightPlugin,lr as initLivePreview,lt as isDevMode,le as isExternalHttpUrl,it as isInIframe,nt as isInPopup,rt as isInPreviewContext,Li as isLexicalContent,$r as isPreviewRequest,re as isSafeUrl,Ei as lexicalToHtml,Pi as lexicalToPlainText,Ar as mergeCspHeader,R as negotiateProtocol,Mi as registerBlockRenderer,tr as registerBuiltinRenderer,hr as runtimeBuildInfo,Ot as sanitizeHtml,mr as setCspCrypto,Rt as setSanitizerDocument,ur as wrapWithScriptTag};
1
+ var e=Object.defineProperty,t=(t,i)=>e(t,"name",{value:i,configurable:!0}),i="1.0.5",n="data-payload-field",r="data-payload-type",l="data-payload-attribute",s="data-payload-href",o="data-payload-src",a="data-payload-alt",u="data-payload-array-template",h="data-payload-array-separator",d="data-payload-locale",c="data-payload-richtext",f="data-payload-html",p="data-payload-array",g="data-payload-structural",m=[n,r,l,s,o,a,u,h,d,c,f,p,g,"type"],y=`[${n}]`,v=new Set(["text","textarea","richText","email","number","checkbox","date","select","radio","array","blocks","group","tabs","row","collapsible","relationship","upload","point","json","code","ui","html","url","image","structural-array"]),b=class{static{t(this,"ElementCache")}#e=new Map;#t=new WeakMap;#i;constructor(e={}){this.#i=e.filter??S}buildFromRoot(e){let t=performance.now();this.clear();let i=e.querySelectorAll(y),n=0;for(let e of i)void 0!==this.add(e)&&(n+=1);return{elementCount:n,fieldCount:this.#e.size,durationMs:performance.now()-t}}add(e){let t=this.#i(e)?this.#n(e):void 0,i=this.#t.get(e);if(void 0!==t)return void 0!==i&&this.#r(i,t)?(this.#t.set(e,t),t):(void 0!==i&&this.#l(e,i),this.#s(t),this.#t.set(e,t),t);void 0!==i&&this.#l(e,i)}remove(e){let t=this.#t.get(e);return!!t&&this.#l(e,t)}#r(e,t){if(e.fieldName!==t.fieldName)return!1;let i=this.#e.get(e.fieldName);if(!i)return!1;let n=i.indexOf(e);return!(n<0||(i[n]=t,0))}#l(e,t){let i=this.#e.get(t.fieldName);if(!i)return this.#t.delete(e),!1;let n=i.indexOf(t);return n<0?(this.#t.delete(e),!1):(i.splice(n,1),0===i.length&&this.#e.delete(t.fieldName),this.#t.delete(e),!0)}get(e){return this.#e.get(e)}getByElement(e){return this.#t.get(e)}get fieldCount(){return this.#e.size}get elementCount(){let e=0;for(let t of this.#e.values())e+=t.length;return e}entries(){return this.#e.entries()}*values(){for(let e of this.#e.values())yield*e}has(e){return this.#t.has(e)}clear(){this.#e.clear(),this.#t=new WeakMap}#s(e){let t=this.#e.get(e.fieldName);t?t.push(e):this.#e.set(e.fieldName,[e])}#n(e){let t=e.getAttribute(n);if(null===t||0===t.length)return;let i=e.getAttribute(r),c=w(e),f=e.getAttribute(l),p=e.getAttribute(s),g=e.getAttribute(o),m=e.getAttribute(a),y=e.getAttribute(u),b=e.getAttribute(h),S=e.getAttribute(d);return{element:e,fieldName:t,fieldType:c,explicitFieldType:null!==i&&v.has(i),...null!==f&&f.length>0?{targetAttribute:f}:{},...null!==p&&p.length>0?{hrefField:p}:{},...null!==g&&g.length>0?{srcField:g}:{},...null!==m&&m.length>0?{altField:m}:{},...null!==y?{arrayTemplate:y}:{},...null!==b?{arraySeparator:b}:{},...null!==S&&S.length>0?{locale:S}:{}}}};function w(e){let t=e.getAttribute(r);if(null!==t&&v.has(t))return t;if(e.hasAttribute(c))return"richText";if(e.hasAttribute(f))return"html";if(e.hasAttribute(g))return"structural-array";if(e.hasAttribute(p))return"array";if("IMG"===e.tagName)return"image";if("A"===e.tagName)return"url";if("TIME"===e.tagName)return"date";if("INPUT"===e.tagName){let t=e.type;if("checkbox"===t)return"checkbox";if("number"===t)return"number";if("date"===t||"datetime-local"===t)return"date"}return"text"}function S(){return!0}t(w,"resolveFieldType"),t(S,"alwaysTrue");var A=class{static{t(this,"ObserverManager")}s;constructor(e,t={}){this.s=[e,t.mutationDebounceMs??100,t.intersectionRootMargin??"200px",new Set,null,null,null,0]}start(e){let t=this.s[7];this.stop();let i=t+1;if(this.s[7]!==i)return;let n=null,r=null;try{n=new MutationObserver(e=>{this.#e(e,i)}),r=new IntersectionObserver(e=>{this.#t(e,i)},{rootMargin:this.s[2],threshold:0}),n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...m]})}catch(e){throw n?.disconnect(),r?.disconnect(),e}if(this.s[7]!==i)return n.disconnect(),void r.disconnect();this.s[4]=n,this.s[5]=r}observeElement(e){this.s[5]?.observe(e)}unobserveElement(e){this.s[5]?.unobserve(e),this.s[3].delete(e)}markVisible(e,t){t?this.s[3].add(e):this.s[3].delete(e)}isVisible(e){return this.s[3].has(e)}stop(){this.s[7]+=1;let e=this.s[6],t=this.s[4],i=this.s[5];this.s[6]=null,this.s[4]=null,this.s[5]=null,this.s[3].clear(),null!==e&&clearTimeout(e);try{t?.disconnect()}finally{i?.disconnect()}}#e(e,t){if(!this.#i(t)||!T(e)||!this.#i(t))return;null!==this.s[6]&&clearTimeout(this.s[6]);let i=setTimeout(()=>{!this.#i(t)||this.s[6]!==i||(this.s[6]=null,this.s[0].onStructuralChange())},this.s[1]);this.s[6]=i}#t(e,t){for(let i of e){if(!this.#i(t))return;let e=i.target;if(i.isIntersecting){if(!this.s[3].has(e)&&(this.s[3].add(e),this.s[0].onVisibilityChange(e,!0),!this.#i(t)))return}else if(this.s[3].has(e)&&(this.s[3].delete(e),this.s[0].onVisibilityChange(e,!1),!this.#i(t)))return}}#i(e){return this.s[7]===e&&null!==this.s[5]}};function T(e){for(let t of e){if("attributes"===t.type&&null!==t.attributeName&&m.includes(t.attributeName)&&(t.attributeName===n||1===t.target.nodeType&&t.target.hasAttribute(n)))return!0;for(let e of t.addedNodes)if($(e))return!0;for(let e of t.removedNodes)if($(e))return!0}return!1}function $(e){if(1!==e.nodeType)return!1;let t=e;return!!t.hasAttribute(n)||null!==t.querySelector(`[${n}]`)}function k(e){if(!Array.isArray(e))return[];let t=[];for(let i of e){let e=x(i);e&&t.push(e)}return t}function x(e){if("object"!=typeof e||null===e)return;let t=e,i=t.name,n=t.type;if("string"!=typeof i||0===i.length||"string"!=typeof n||0===n.length)return;let r=k(t.fields),l=N(t.blocks),s={...t,name:i,type:n};return r.length>0?s.fields=r:delete s.fields,l.length>0?s.blocks=l:delete s.blocks,s}function N(e){if(!Array.isArray(e))return[];let t=[];for(let i of e){if("object"!=typeof i||null===i)continue;let e=i,n=e.slug;if("string"!=typeof n||0===n.length)continue;let r=k(e.fields);t.push({...e,slug:n,fields:r})}return t}t(T,"hasStructuralImpact"),t($,"containsTrackedElement"),t(k,"parseFieldSchema"),t(x,"parseFieldEntry"),t(N,"parseBlockSchema");var M=4,C={basic:1,"schema-json":2,"preview-token":3,"nested-arrays":4,"recursive-diffs":4};function R(e){let t="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,i=Math.min(4,t??1),n=new Set;for(let[e,t]of Object.entries(C))i>=t&&n.add(e);return{ours:4,...void 0!==t?{theirs:t}:{theirs:void 0},negotiated:i,capabilities:n}}function O(e,t){return e.capabilities.has(t)}function I(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}t(R,"negotiateProtocol"),t(O,"hasCapability"),t(I,"observeThenableResult");var F=class{static{t(this,"MessageBus")}s;constructor(e,t){this.s=[e,t,void 0,void 0,0,0,[],0]}attach(e=window){if(void 0!==this.s[3])return;let i=!1,n=t(e=>{if(!i||this.s[2]!==n)return;let t=this.s[4];try{this.#e(e,t)}catch{let i="";try{i=e.origin}catch{}this.#s("shape",i,t)}},"listener");this.s[4]+=1,this.#o(),this.s[3]=e,this.s[2]=n;try{e.addEventListener("message",n)}catch(t){this.s[2]===n&&(this.s[3]=void 0,this.s[2]=void 0,this.#o());try{e.removeEventListener("message",n)}catch{}throw t}if(this.s[2]===n)i=!0;else try{e.removeEventListener("message",n)}catch{}}detach(e){let t=this.s[3],i=this.s[2];void 0===t||void 0===i||(this.s[3]=void 0,this.s[2]=void 0,this.#o(),t.removeEventListener("message",i))}advanceGeneration(){return void 0!==this.s[3]&&(this.s[4]+=1,this.#o(),!0)}static sendReady(e,t){let i=e.length>0;if(!i||0===t.length)return;let n={type:"payload-live-preview",ready:i,protocolVersion:4};for(let i of e)for(let e of t)try{i.postMessage(n,e)}catch{}}#e(e,t){if(!this.#a(t))return;let i=e.origin;if(!this.#a(t))return;if(!this.#n(i,t))return void this.#s("origin",i,t);let n=e.data;if(!this.#a(t))return;let r=L(n);if(!this.#a(t))return;if(!r)return void this.#s("shape",i,t);let l=n.type;if(this.#a(t))switch(l){case"payload-live-preview":{let e=E(n);if(!this.#a(t))return;if(!e)return void this.#s("shape",i,t);let r=_(n);if(!this.#a(t))return;return void this.#t(r,i,t)}case"payload-document-event":{let e,r=P(n);if(!this.#a(t))return;if(!r)return void this.#s("shape",i,t);try{e=this.s[1].onDocumentEvent}catch{return}if(!this.#a(t))return;return void this.#u(e,n,i)}default:this.#s("type",i,t)}}#t(e,t,i){if(!this.#a(i))return;let n=e.data;if(!this.#a(i))return;let r=U(n);if(!this.#a(i))return;let l,s=r?{generation:i,revision:this.s[5]+=1}:void 0;try{l=this.s[1].validateToken}catch{return}if(!this.#a(i))return;if(void 0===l)return void this.#l(e,t,i,s);if(!0===e.ready&&void 0===n)return void this.#l(e,t,i,void 0);let o,a={generation:i,message:e,origin:t,messageRevision:s,settled:!1,approved:!1};this.s[6].push(a);try{o=l(e.previewToken,t)}catch{return void this.#i(a,!1)}"boolean"!=typeof o?Promise.resolve(o).then(e=>{this.#i(a,!0===e)},()=>{this.#i(a,!1)}):this.#i(a,o)}#i(e,t){this.#a(e.generation)&&(e.approved=t,e.settled=!0,this.#r(e.generation))}#r(e){for(;this.#a(e);){let t=this.s[6][this.s[7]];if(void 0===t)return;if(this.#n(t.origin,e)){if(!t.settled)return;this.#h(t)&&(t.approved?this.#l(t.message,t.origin,t.generation,t.messageRevision):this.#s("token",t.origin,t.generation))}else{if(!this.#h(t))continue;this.#s("origin",t.origin,t.generation)}}}#l(e,t,i,n){if(!this.#a(i))return;let r;try{r=this.s[1].onUpdate}catch{return}this.#a(i)&&(void 0===n?this.#u(r,e,t):this.#u(r,e,t,n))}#s(e,t,i){if(!this.#a(i))return;let n;try{n=this.s[1].onInvalid}catch{return}this.#a(i)&&void 0!==n&&this.#u(n,e,t)}#n(e,t){if(!this.#a(t))return!1;try{return!0===this.s[0](e)&&this.#a(t)}catch{return!1}}#u(e,...t){try{I(e(...t))}catch{}}#a(e){return void 0!==this.s[3]&&this.s[4]===e}#h(e){let t=this.s;return t[6][t[7]]===e&&(t[7]+=1,t[7]===t[6].length?(this.#o(),!0):(t[7]>=1024&&2*t[7]>=t[6].length&&(t[6]=t[6].slice(t[7]),t[7]=0),!0))}#o(){this.s[6]=[],this.s[7]=0}};function L(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}function E(e){let t=e;return!!((void 0===t.data||null===t.data||U(t.data))&&D(t.fieldSchemaJSON,e=>Array.isArray(e))&&D(t.globalSlug,e=>"string"==typeof e)&&D(t.collectionSlug,e=>"string"==typeof e)&&D(t.locale,e=>"string"==typeof e)&&D(t.ready,e=>"boolean"==typeof e)&&D(t.previewToken,e=>"string"==typeof e)&&D(t.protocolVersion,e=>"number"==typeof e))}function P(e){let t=e;return!(!j(t.action,e=>"updated"===e||"created"===e||"deleted"===e)||!j(t.slug,e=>"string"==typeof e)||!j(t.id,e=>"string"==typeof e||"number"==typeof e&&Number.isFinite(e)))}function j(e,t){return void 0===e||t(e)}function D(e,t){return null==e||t(e)}function U(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}t(L,"isObjectMessage"),t(E,"isLivePreviewMessage"),t(P,"isDocumentEventMessage"),t(j,"optionalDocumentFieldOk"),t(D,"optionalTypeOk"),t(U,"isPlainObject");var W=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"];function _(e){let t,i={...e};for(let e of W)null===Reflect.get(i,e)&&Reflect.deleteProperty(i,e);if(!Array.isArray(i.fieldSchemaJSON))return i;try{t=k(i.fieldSchemaJSON)}catch{t=[]}return{...i,fieldSchemaJSON:t}}t(_,"normalizeLivePreviewMessage");var V=class{static{t(this,"HeartbeatTimer")}s;constructor(e){this.s=[e.timeoutMs??0,e.onTimeout,null,0]}kick(){if(this.s[3]=Date.now(),this.s[0]<=0)return;null!==this.s[2]&&clearTimeout(this.s[2]);let e=setTimeout(()=>{this.s[2]===e&&(this.s[2]=null,this.s[1]())},this.s[0]);this.s[2]=e}stop(){null!==this.s[2]&&(clearTimeout(this.s[2]),this.s[2]=null)}get lastKickAt(){return this.s[3]}get pending(){return null!==this.s[2]}},z=class{static{t(this,"ConnectionState")}s;constructor(e){this.s=["disconnected",e]}get status(){return this.s[0]}markConnected(){return this.transition("connected")}markConnecting(){return this.transition("connecting")}markDisconnected(){return this.transition("disconnected")}transition(e){if(this.s[0]===e)return!1;let t=this.s[0];return this.s[0]=e,this.s[1](e,t),!0}};function B(e){return(...t)=>{try{I(e(...t))}catch{}}}function K(){}t(B,"isolateDiagnostic"),t(K,"noopDiagnostic");var G=B((...e)=>console.error(...e)),q=B((...e)=>console.warn(...e)),H=B((...e)=>console.debug(...e));function J(e){for(let t of e){let e=t.codePointAt(0);if(void 0!==e&&(e<=31||127===e))return!0}return!1}function X(e){if(void 0===e||0===e.length||e.length>128||"."===e||".."===e||e.includes("/")||e.includes("\\")||e.includes("?")||e.includes("#")||J(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function Y(e){if("number"==typeof e)return Number.isFinite(e);if("string"!=typeof e||0===e.length||e.length>512||"."===e||".."===e||e.includes("/")||e.includes("\\")||J(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}t(J,"hasControlCharacter"),t(X,"isSafeSlug"),t(Y,"isSafeId");var Q=class{static{t(this,"DataMerger")}s;constructor(e){let t=e.serverURL.replace(/\/+$/,""),i=e.apiRoute??"/api";this.s=[t,i.startsWith("/")?i:`/${i}`,e.depth??1,e.fetchFn,void 0===e.log?K:B(e.log),null,0,0]}canMerge(e){try{return e.globalSlug?X(e.globalSlug):!!X(e.collectionSlug)&&Y(e.data.id)}catch{return!1}}async merge(e){if(this.s[7]>0)return{status:"superseded"};let t=this.s[6]+1;this.s[6]=t;let i=this.s[5];this.s[5]=null;let n=null;try{if(i?.abort(),!Z(this.s,t))return{status:"superseded"};if(!this.canMerge(e))return Z(this.s,t)?{status:"unavailable"}:{status:"superseded"};if(!Z(this.s,t))return{status:"superseded"};let r=this.s[3]??("function"==typeof fetch?fetch:void 0);if(!Z(this.s,t))return{status:"superseded"};if(void 0===r)return{status:"unavailable"};if(n=new AbortController,!Z(this.s,t))return n.abort(),{status:"superseded"};this.s[5]=n;let l=e.globalSlug?`globals/${encodeURIComponent(e.globalSlug)}`:`${encodeURIComponent(e.collectionSlug??"")}/${encodeURIComponent(String(e.data.id))}`,s=`${this.s[0]}${this.s[1]}/${l}`,o=JSON.stringify({data:e.data,depth:this.s[2],flattenLocales:!1,...void 0!==e.locale?{locale:e.locale}:{}});if(!Z(this.s,t))return{status:"superseded"};let a=await r(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:o,signal:n.signal});if(!Z(this.s,t)||ee(n.signal))return{status:"superseded"};let u=a.ok;if(!Z(this.s,t))return{status:"superseded"};if(!u){let e=a.status;return Z(this.s,t)?(this.s[4]("merge HTTP",e,s),Z(this.s,t)?{status:"unavailable"}:{status:"superseded"}):{status:"superseded"}}let h=await a.json();return!Z(this.s,t)||ee(n.signal)?{status:"superseded"}:null===h||"object"!=typeof h||Array.isArray(h)?(this.s[4]("merge invalid",s),Z(this.s,t)?{status:"unavailable"}:{status:"superseded"}):{status:"merged",doc:h}}catch(e){return!Z(this.s,t)||null!==n&&ee(n.signal)?{status:"superseded"}:(this.s[4]("merge exception",e),Z(this.s,t)?{status:"unavailable"}:{status:"superseded"})}finally{null!==n&&Z(this.s,t)&&this.s[5]===n&&(this.s[5]=null)}}destroy(){this.s[6]+=1;let e=this.s[5];this.s[5]=null,this.s[7]+=1;try{e?.abort()}finally{this.s[7]-=1}}};function Z(e,t){return e[6]===t}function ee(e){return e.aborted}t(Z,"isLatestAttempt"),t(ee,"isAborted");var te=new Set(["http:","https:","mailto:","tel:"]),ie=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,ne=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/;function re(e){if("string"!=typeof e||0===e.length)return!1;let t=e.trim();if(0===t.length||ie.test(t))return!1;if(t.startsWith("#")||t.startsWith("?")||t.startsWith("//")||t.startsWith("/"))return!0;try{let e=new URL(t);return te.has(e.protocol)}catch{return ne.test(t)}}function le(e){if(!re(e))return!1;let t=e.trim();return/^https?:\/\//i.test(t)||/^\/\/[^/]/.test(t)}t(re,"isSafeUrl"),t(le,"isExternalHttpUrl");var se=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),oe=new Set(["href","src","poster","cite","action","xlink:href","data"]);function ae(e,t,i){let n=t.toLowerCase().trim();if(0===n.length||n.startsWith("on")||se.has(n))return"blocked";if(null==i)return e.removeAttribute(n),"applied";if("string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i)return"blocked";let r=String(i);return oe.has(n)&&!re(r)?"blocked":(e.setAttribute(n,r),"applied")}t(ae,"applyAttributeBinding");var ue=new WeakSet;function he(e){return ue.add(e),e}function de(e){return ue.has(e)}function ce(e){return ue.has(e.render)}t(he,"markNoWriteCallback"),t(de,"usesNoWriteOutcome"),t(ce,"rendererUsesNoWriteOutcome");var fe=class{static{t(this,"UpdateScheduler")}s;constructor(e,t){let i=t.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):e=>setTimeout(()=>{e(performance.now())},0)),n=t.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):e=>{clearTimeout(e)});this.s=[e,t.debounceMs??50,t.isVisible,t.visibilityGateThreshold??50,t.disableVisibilityGate??!1,t.getCacheSize,t.onFlush,i,n,new Map,new Map,new Set,null,0,null,0,null,!1]}schedule(e){if(void 0!==e.identity&&(this.s[17]||!pe(e.identity,this.s[16])))return;let t=this.s[9],i=t.get(e.target.element);i?(i.value=e.value,i.allFields=e.allFields,i.identity=e.identity,i.data=e.data):t.set(e.target.element,{...e,identity:e.identity,data:e.data}),this.#e()}acceptRevision(e){let t=this.s[16];pe(e,t)||null!==t&&ge(e,t)<0||(this.#a(),this.#n(),this.s[16]=e,this.s[17]=!1)}cancelRevision(e){pe(e,this.s[16])&&(this.#a(),this.#n(),this.s[17]=!0)}flushNow(){return this.#a(),this.#i()}notifyVisible(e){let t=this.s[10],i=t.get(e);if(!i||(t.delete(e),!this.#r(i)))return;let n=performance.now(),r=this.#l(i)?1:0;this.s[6]?.(this.#u(i,r,0,performance.now()-n))}retarget(e){this.#s(this.s[9],e),this.#s(this.s[10],e);for(let t of this.s[11])this.#s(t,e)}forget(e){this.s[9].delete(e),this.s[10].delete(e);for(let t of this.s[11])t.delete(e)}destroy(){this.#a(),this.#n(),this.s[16]=null,this.s[17]=!1}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}#e(){let e=this.s[13]+=1,t=this.s[12];if(this.s[12]=null,null!==t&&clearTimeout(t),this.s[13]!==e)return;let i=setTimeout(()=>{this.s[13]===e&&(this.s[12]=null,this.#t())},this.s[1]);this.s[13]===e&&(this.s[12]=i)}#t(){let e=this.s[15]+=1,t=this.s[14];if(this.s[14]=null,null!==t&&this.s[8](t),this.s[15]!==e)return;let i=!1,n=this.s[7](()=>{this.s[15]===e&&(i=!0,this.s[14]=null,this.#i())});!i&&this.s[15]===e&&(this.s[14]=n)}#i(){let e=performance.now(),t=!this.s[4]&&this.s[5]()>this.s[3],i=this.s[9];this.s[9]=new Map;let n,r=0,l=0;this.s[11].add(i);try{for(let e of i.values()){if(!this.#r(e))continue;let i=!t||this.s[2](e.target.element);if(this.#r(e)){if(n??=e,!i){this.s[10].set(e.target.element,e),l+=1;continue}this.s[10].delete(e.target.element),this.#l(e)&&(r+=1)}}}finally{this.s[11].delete(i)}let s=this.#u(n,r,l,performance.now()-e);return this.s[6]?.(s),s}#r(e){return void 0===e.identity||!this.s[17]&&pe(e.identity,this.s[16])}#l(e){let t=this.s[0];return!1!==t(e)||!de(t)}#s(e,t){let i=e.get(t.element);if(void 0!==i){if(i.target.fieldName!==t.fieldName||i.target.locale!==t.locale)return void e.delete(t.element);i.target=t}}#n(){this.s[9].clear(),this.s[10].clear();for(let e of this.s[11])e.clear()}#u(e,t,i,n){return{applied:t,deferred:i,durationMs:n,...void 0!==e?.identity?{identity:e.identity}:{},...void 0!==e?.data?{data:e.data}:{}}}#a(){let e=this.s[12],t=this.s[14];this.s[13]+=1,this.s[15]+=1,this.s[12]=null,this.s[14]=null,null!==e&&clearTimeout(e),null!==t&&this.s[8](t)}};function pe(e,t){return null!==t&&e.generation===t.generation&&e.revision===t.revision}function ge(e,t){return e.generation!==t.generation?e.generation-t.generation:e.revision-t.revision}t(pe,"sameIdentity"),t(ge,"compareIdentity");var me=new Set(["__proto__","prototype","constructor"]);function ye(e,t,i,n=!1){if(n&&void 0!==i){let n=ve(e,`${t}_${i}`);if(void 0!==n)return n}let r=ve(e,t);if(void 0!==r)return r;if(t.includes(".")){let i=e,n=!0;for(let e of t.split(".")){if(me.has(e)||null===i||"object"!=typeof i){n=!1;break}if(i=ve(i,e),void 0===i){n=!1;break}}if(n)return i}return void 0===i?void 0:ve(e,`${t}_${i}`)}function ve(e,t){if(!me.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function be(){let e=we();if(void 0!==e)return e;let t=Se();return void 0!==t?t:"en"}function we(){if(typeof document>"u")return;let e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}function Se(){if(typeof navigator>"u")return;let e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}t(ye,"resolveFieldValue"),t(ve,"readOwn"),t(be,"detectInitialLocale"),t(we,"readHtmlLang"),t(Se,"readNavigatorLanguage");var Ae="payload-live-preview-a11y";function Te(e){return/^de(?:[-_]|$)/i.test(e)}t(Te,"isGerman");var $e=new WeakMap;function ke(e){let t=$e.get(e);return t??=[null,!1,null,0,null],$e.set(e,t),t[3]+=1,t}function xe(e){null!==e[4]&&(clearTimeout(e[4]),e[4]=null),e[2]?.remove(),e[2]=null}t(ke,"acquireDocumentLease"),t(xe,"clearLeaseMessage");var Ne=class{static{t(this,"A11yAnnouncer")}s;constructor(e,t){let i=t??(typeof document>"u"?null:document),n=i?.documentElement.getAttribute("lang")??"";this.s=[Te(e??(n.length>0?n:be())),i,null]}mount(){let e=this.s[1];if(null==e?.body)return null;let t=this.s[2];null===t&&(t=ke(e),this.s[2]=t);let i=t[0];if(i?.isConnected&&i.ownerDocument===e)return i;if(null!==i){let e=t[1];xe(t),e&&i.remove()}let n=e.getElementById(Ae);return t[1]=null===n,n||(n=e.createElement("div"),n.id=Ae,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0"),e.body.appendChild(n)),t[0]=n,n}announceConnected(){this.say(this.s[0]?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.s[0]?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(e){e<=0||this.say(this.s[0]?`${String(e)} ${1===e?"Änderung":"Änderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}detach(){let e=this.s[2],t=this.s[1];if(null===e||null===t||(this.s[2]=null,e[3]-=1,e[3]>0))return;let i=e[0];null!==i&&xe(e),e[1]&&i?.remove(),e[0]=null,$e.delete(t)}say(e){let t=this.mount(),i=this.s[2];if(null===t||null===i)return;let n=i[2];n?.parentNode!==t?(n?.remove(),n=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),i[2]=n,t.appendChild(n)):n.data=null===n.previousSibling?e:` ${e}`,null!==i[4]&&clearTimeout(i[4]);let r=setTimeout(()=>{i[4]===r&&i[0]===t&&xe(i)},1500);i[4]=r}},Me=new Set(["tabs","row","collapsible"]);function Ce(e,t=""){let i=new Map;return Re(e,t,i),i}function Re(e,t,i){for(let n of e){if(Me.has(n.type)){n.fields&&Re(n.fields,t,i);continue}if("group"===n.type){let e=""===t?n.name:`${t}.${n.name}`;i.set(e,n),n.fields&&Re(n.fields,e,i);continue}let e=""===t?n.name:`${t}.${n.name}`;if(i.set(e,n),"array"===n.type&&n.fields)Re(n.fields,`${e}.*`,i);else if("blocks"===n.type&&n.blocks)for(let t of n.blocks)Re(t.fields,`${e}.*.${t.slug}`,i)}}function Oe(e,t){if(e.has(t))return e.get(t);let i=t.replace(/\.\d+(?=\.|$)/g,".*");return e.has(i)?e.get(i):void 0}function Ie(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function Fe(e){if("object"!=typeof e||null===e)return;let t=e.blockType;return"string"==typeof t?t:void 0}function Le(e,t){return t.every(e=>void 0!==Ie(e))?Ee(e,t):Pe(e,t)}function Ee(e,t){let i=[],n=new Map;for(let t=0;t<e.length;t+=1){let i=Ie(e[t]);void 0!==i&&n.set(i,t)}let r=new Set;for(let l=0;l<t.length;l+=1){let s=t[l],o=Ie(s);if(void 0===o){i.push({kind:"insert",index:l,value:s});continue}let a=n.get(o);if(void 0===a){i.push({kind:"insert",index:l,value:s});continue}r.add(a);let u=e[a];Fe(u)===Fe(s)?(a!==l&&i.push({kind:"move",from:a,to:l,value:s}),je(u,s)||i.push({kind:"update",index:l,value:s})):i.push({kind:"replace",index:l,oldValue:u,value:s})}for(let t=0;t<e.length;t+=1)r.has(t)||i.push({kind:"remove",index:t,value:e[t]});return i}function Pe(e,t){let i=[],n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)je(e[r],t[r])||i.push({kind:"update",index:r,value:t[r]});if(t.length>e.length)for(let n=e.length;n<t.length;n+=1)i.push({kind:"insert",index:n,value:t[n]});if(e.length>t.length)for(let n=t.length;n<e.length;n+=1)i.push({kind:"remove",index:n,value:e[n]});return i}function je(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;let i=e,n=t,r=Object.keys(i),l=Object.keys(n);if(r.length!==l.length)return!1;for(let e of r)if(!Object.is(i[e],n[e]))return!1;return!0}t(Ce,"buildSchemaIndex"),t(Re,"walk"),t(Oe,"lookupSchema"),t(Ie,"getId"),t(Fe,"getBlockType"),t(Le,"diffArray"),t(Ee,"diffById"),t(Pe,"diffByPosition"),t(je,"shallowEqual");var De={text:"text",textarea:"textarea",richText:"richText",email:"email",number:"number",checkbox:"checkbox",date:"date",select:"select",radio:"radio",array:"array",blocks:"blocks",group:"text",tabs:"text",row:"text",collapsible:"text",relationship:"relationship",upload:"upload",point:"text",json:"text",code:"text",ui:"text"};function Ue(e){if(Object.prototype.hasOwnProperty.call(De,e))return De[e]}t(Ue,"payloadTypeToRenderer");var We=[0,500,1e3,2e3],_e=class{static{t(this,"LivePreviewRuntime")}d;l;constructor(e){let i=e.emitter,n=e.renderers,r=e.resolveRenderer??(e=>n[e]),l=e.transformValue,s=e.root??(typeof document<"u"?document:null),o=e.readyTargets,a=e.sendReady??He,u=e.onHeartbeatTimeout,h=void 0===e.log?K:B(e.log),d=void 0===e.warn?q:B(e.warn),c=Be(e),f=void 0!==e.dataMerge?new Q({serverURL:e.dataMerge.serverURL,...void 0!==e.dataMerge.apiRoute?{apiRoute:e.dataMerge.apiRoute}:{},...void 0!==e.dataMerge.depth?{depth:e.dataMerge.depth}:{},...void 0!==e.dataMerge.fetchFn?{fetchFn:e.dataMerge.fetchFn}:{},log:t((...e)=>{h(...e)},"log")}):null,p=new b,g=new A({onStructuralChange:t(()=>{this.#s()},"onStructuralChange"),onVisibilityChange:t((e,t)=>{t&&this.d[3].notifyVisible(e)},"onVisibilityChange")},{...void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}}),m=new fe(he(e=>this.#d(e)),{...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.disableVisibilityGate?{disableVisibilityGate:e.disableVisibilityGate}:{},...void 0!==e.visibilityGateThreshold?{visibilityGateThreshold:e.visibilityGateThreshold}:{},isVisible:t(e=>g.isVisible(e),"isVisible"),getCacheSize:t(()=>p.elementCount,"getCacheSize"),onFlush:t(e=>{this.#c(e)},"onFlush")}),y=new F(e.originMatcher,{onUpdate:t((e,t,i)=>{this.#u(e,t,i)},"onUpdate"),onDocumentEvent:t(()=>{i.emit("documentSave",{timestamp:Date.now()})},"onDocumentEvent"),onInvalid:t((e,t)=>{if("token"===e){let e=new Error(`Preview token rejected (origin: ${t})`);i.emit("error",{error:e,context:"token"})}h("message rejected:",e,t)},"onInvalid"),...void 0!==e.validateToken?{validateToken:e.validateToken}:{}}),v=new z(()=>{}),w=new V({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:t(()=>{this.#f()},"onTimeout")});this.d=[i,p,g,m,y,v,w,n,r,l,s,o,a,u,h,d,[],c,f],this.l=[void 0,void 0,void 0,R(void 0),!1,null,0,null,new Set]}start(){if(this.l[4])return!1;this.l[4]=!0;let e=this.d[10];if(Ke(e)&&"loading"===e.readyState){let i=t(()=>{if(this.l[4]){this.l[5]=null;try{this.#e()}catch(e){this.#i(),this.#p(e,"startup")}}},"onReady");this.l[5]=i;try{e.addEventListener("DOMContentLoaded",i,{once:!0})}catch(e){throw this.#i(),e}return!0}try{return this.#e(),!0}catch(e){throw this.#i(),e}}#e(){if(!this.l[4])return;let e=Ke(this.d[10])?Ge(this.d[10]):this.d[10];if(null===e)throw new Error("LivePreviewRuntime: document.body unavailable");if(this.d[2].start(e),this.#l(),this.#g()&&(this.d[4].attach(),this.d[0].emitWhile("init",{timestamp:Date.now()},()=>this.l[4]),this.#g()))for(let e of We){if(!this.#g())return;if(0===e){if(this.d[12](this.d[11]),!this.#g())return}else{let t=setTimeout(()=>{this.l[4]&&this.#m()},e);this.d[16].push(t)}}}destroy(){this.l[4]&&(this.#t()&&this.d[0].emit("disconnect",{reason:"destroy",timestamp:Date.now()}),this.d[17]?.detach(),this.d[0].emit("destroy",{timestamp:Date.now()}))}#t(){this.l[7]=null,this.l[4]=!1;let e=this.l[5];this.l[5]=null,null!==e&&Ke(this.d[10])&&this.#r(()=>{this.d[10].removeEventListener("DOMContentLoaded",e)});for(let e of this.d[16])this.#r(()=>{clearTimeout(e)});return this.d[16].length=0,this.#r(()=>{this.d[6].stop()}),this.#r(()=>{this.d[4].detach()}),this.#r(()=>{this.d[2].stop()}),this.#r(()=>{this.d[3].destroy()}),this.#r(()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()}#i(){this.#t(),this.#r(()=>{this.d[17]?.detach()})}#r(e){try{e()}catch(e){this.d[14]("cleanup failed:",e)}}refreshCache(){this.l[4]&&this.#s()}get status(){return this.d[5].status}get cache(){return this.d[1]}get updateCount(){return this.l[6]}get protocol(){return this.l[3]}#l(){if(!this.l[4])return;let e=this.d[1].buildFromRoot(this.d[10]);if(this.d[14]("cache",e),this.#g()&&(this.d[0].emitWhile("cacheRefresh",e,()=>this.l[4]),this.#g()))for(let e of this.d[1].values()){if(!this.#g())return;this.d[2].observeElement(e.element)}}#s(){if(!this.l[4])return;let e=new Map;for(let t of this.d[1].values())e.set(t.element,t),this.d[2].unobserveElement(t.element);if(this.#l(),this.#g()){for(let t of this.d[1].values())e.get(t.element)?.fieldName===t.fieldName?this.d[3].retarget(t):this.d[3].forget(t.element),e.delete(t.element);for(let t of e.values())this.d[3].forget(t.element)}}#n(e){let t=R(e);t.negotiated!==this.l[3].negotiated&&(this.l[3]=t,this.d[14]("protocol","ours=4",`theirs=${e}`,`negotiated=${t.negotiated}`))}#u(e,t,i){if(this.d[6].kick(),void 0===e.data)return void(void 0!==e.protocolVersion&&this.#n(e.protocolVersion));if(void 0===i)return;"string"==typeof e.locale&&(this.l[0]=e.locale),Array.isArray(e.fieldSchemaJSON)&&(this.l[1]=e.fieldSchemaJSON,this.l[2]=Ce(e.fieldSchemaJSON));let n={identity:i,message:e,locale:this.l[0],schema:this.l[1],schemaIndex:this.l[2],cancelled:!1};this.l[7]=n,this.d[3].acceptRevision(i),this.l[6]+=1,(void 0===e.protocolVersion||(this.#n(e.protocolVersion),this.l[4]&&this.l[7]===n))&&(this.d[5].markConnected()&&(this.d[17]?.announceConnected(),this.d[0].emit("connect",{origin:t,timestamp:Date.now()}),!this.l[4]||this.l[7]!==n||(this.d[14]("connection","disconnected","→","connected"),!this.l[4]||this.l[7]!==n))||this.#a(n))}async#a(e){let i=await this.#h(e);if(null===i||!this.l[4]||this.l[7]!==e)return;let{message:n}=e,r={fields:i,...void 0!==e.schema?{schema:e.schema}:{},..."string"==typeof n.globalSlug?{globalSlug:n.globalSlug}:{},..."string"==typeof n.collectionSlug?{collectionSlug:n.collectionSlug}:{},...void 0!==e.locale?{locale:e.locale}:{}};this.d[0].listenerCount("beforeUpdate")>0&&(!await this.d[0].emitWhile("beforeUpdate",{data:r,revision:e.identity.revision,cancel:t(()=>{e.cancelled=!0,this.d[3].cancelRevision(e.identity)},"cancel")},()=>!e.cancelled&&this.l[4]&&this.l[7]===e)||e.cancelled||!this.l[4]||this.l[7]!==e)||this.l[4]&&this.l[7]===e&&this.#o(e,r)}async#h(e){let{message:t}=e,i=t.data??{};if(null===this.d[18])return i;let n=await this.d[18].merge({collectionSlug:t.collectionSlug,globalSlug:t.globalSlug,data:i,locale:e.locale});return this.l[4]&&this.l[7]===e?"merged"===n.status?n.doc:"superseded"===n.status?null:i:null}#o(e,i){if(!this.l[4]||this.l[7]!==e)return;let n=t(()=>this.l[4]&&this.l[7]===e,"isCurrent");for(let[t,r]of this.d[1].entries()){if(!this.l[4]||this.l[7]!==e)return;for(let l of r){let r=ye(i.fields,t,l.locale??e.locale,void 0!==l.locale);if(void 0===r)continue;if(!this.l[4]||this.l[7]!==e)return;let s=this.#y(l,r,i.fields,n);if(!this.l[4]||this.l[7]!==e)return;let o={target:l,value:s,allFields:i.fields,identity:e.identity,data:i};if(!this.l[4]||this.l[7]!==e)return;this.d[3].schedule(o)}}this.#v(i.fields,e.locale)}#v(e,t){if(0===this.d[1].fieldCount)return;let i;for(let[n,r]of Object.entries(e)){if(this.l[8].has(n)||Xe.has(n)||!Ye(r))continue;let e=Qe(n,t);if(void 0===this.d[1].get(n)&&(e===n||void 0===this.d[1].get(e))){if(void 0===i){i=new Set;for(let[e,t]of this.d[1].entries())for(let n of t)void 0!==n.locale&&i.add(`${e}_${n.locale}`)}i.has(n)||(this.l[8].add(n),this.d[15](`[live-preview] update arrived for field "${n}" but no <… data-payload-field="${e}"> element exists on this page. Render the binding anchor unconditionally in your template so live edits to an initially-empty field have somewhere to land.`))}}}#y(e,t,i,n){if(void 0===this.d[9])return t;try{let r=this.d[9](e.fieldName,t,{element:e.element,allFields:i},n),l=I(r);if(!n())return t;if(l)throw new TypeError(`Transform for "${e.fieldName}" returned a Promise/thenable; transforms must be synchronous`);return r}catch(e){if(!n())return t;let i=e instanceof Error?e:new Error(String(e));return this.d[0].emit("error",{error:i,context:"transform"}),t}}#g(){return this.l[4]}#d(e){let t=this.l[7];if(null===t||void 0===e.identity||!Je(t.identity,e.identity)||!this.l[4]||this.l[7]!==t)return!1;let i,n=void 0!==t.schemaIndex?Oe(t.schemaIndex,e.target.fieldName):void 0,r=e.value,l=Ve(e.target,n?.type);"text"===l&&!0!==e.target.explicitFieldType&&qe(r)&&(l="richText");try{i=this.d[8](l)}catch(e){if(!this.l[4]||this.l[7]!==t)return!1;let i=e instanceof Error?e:new Error(String(e));return this.d[0].emitWhile("error",{error:i,context:"renderer"},()=>this.l[4]&&this.l[7]===t),!1}if(!this.l[4]||this.l[7]!==t)return!1;let s=this.d[0].listenerCount("elementUpdate")>0,o=s?Ze(e.target.element):void 0;if(!this.l[4]||this.l[7]!==t)return!1;let a={allFields:e.allFields,locale:e.target.locale??t.locale,schema:n};try{if(void 0!==e.target.targetAttribute){if("blocked"===ae(e.target.element,e.target.targetAttribute,r))return this.d[15](`[live-preview] refused to write field "${e.target.fieldName}" into attribute "${e.target.targetAttribute}" (unsafe attribute or value)`),!1}else{if(!i)return this.d[14]("no renderer for",l),!1;if(!1===ze(i,e.target,r,a)&&ce(i))return!1}}catch(e){if(!this.l[4]||this.l[7]!==t)return!1;let i=e instanceof Error?e:new Error(String(e));return this.d[0].emitWhile("error",{error:i,context:"renderer"},()=>this.l[4]&&this.l[7]===t),!1}return!(!this.l[4]||this.l[7]!==t)&&(s&&this.d[0].emitWhile("elementUpdate",{element:e.target.element,fieldName:e.target.fieldName,previousValue:o,nextValue:r,revision:t.identity.revision},()=>this.l[4]&&this.l[7]===t),this.l[4]&&this.l[7]===t)}#c(e){let{identity:i,data:n}=e;if(0===e.applied||void 0===i||void 0===n)return;let r=this.l[7];if(null===r||!this.l[4]||this.l[7]!==r||!Je(r.identity,i))return;let l=t(()=>this.l[4]&&this.l[7]===r&&Je(r.identity,i),"isCurrent");this.d[17]?.announceUpdate(e.applied),l()&&0!==this.d[0].listenerCount("afterUpdate")&&this.d[0].emitWhile("afterUpdate",{data:n,updatedCount:e.applied,durationMs:e.durationMs,revision:i.revision},l)}#f(){if(!this.#g())return;this.d[4].advanceGeneration();let e=this.l[7];this.l[7]=null,null!==e&&this.d[3].cancelRevision(e.identity),this.d[18]?.destroy();let t=this.d[5].markDisconnected();try{this.d[13]?.()}catch(e){this.d[14]("heartbeat:",e)}this.#g()&&(t&&this.#b()&&(this.d[17]?.announceDisconnected(),this.d[0].emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.#b()),!this.#g()||this.#b()&&(this.d[14]("connection","connected","→","disconnected"),!this.#g()))||this.#g()&&this.#m())}#m(){try{this.d[12](this.d[11])}catch(e){this.#p(e,"ready")}}#p(e,t){let i=e instanceof Error?e:new Error(String(e));this.d[0].emit("error",{error:i,context:t})}#b(){return this.l[4]&&"disconnected"===this.d[5].status&&null===this.l[7]}};function Ve(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){let e=Ue(t);if(void 0!==e)return e}return e.fieldType}function ze(e,t,i,n){return e.render(t,i,n)}function Be(e){if(!1===e.enableA11y)return null;let t=void 0===e.root?void 0:9===e.root.nodeType?e.root:e.root.ownerDocument;return new Ne(e.a11yLocale,t)}function Ke(e){return 9===e.nodeType}function Ge(e){return e.body}function qe(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&Array.isArray(t.children)}function He(e){if(typeof window>"u")return;let t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),F.sendReady(t,e)}function Je(e,t){return e.generation===t.generation&&e.revision===t.revision}t(Ve,"resolveRuntimeFieldType"),t(ze,"invokeRenderer"),t(Be,"createA11y"),t(Ke,"isDocumentRoot"),t(Ge,"readDocumentBody"),t(qe,"looksLikeLexicalRoot"),t(He,"defaultSendReady"),t(Je,"sameRevision");var Xe=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function Ye(e){return null!=e&&("string"==typeof e||"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)}function Qe(e,t){if(!t)return e;let i=`_${t}`;return e.endsWith(i)?e.slice(0,-i.length):e}function Ze(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:"IMG"===e.tagName?e.src:e.textContent}t(Ye,"isLiveBindableScalar"),t(Qe,"stripLocaleSuffix"),t(Ze,"readElementSnapshot");var et,tt=class{static{t(this,"EventEmitter")}#e=new Map;#t=new Map;on(e,t){return this.#r(this.#e,e,t)}once(e,t){return this.#r(this.#t,e,t)}off(e,t){this.#l(this.#e,e,t),this.#l(this.#t,e,t)}async emit(e,t){await this.#i(e,t)}async emitWhile(e,t,i){return this.#i(e,t,i)}async#i(e,i,n){let r=t(()=>n?.()??!0,"eligible");if(!r())return!1;let l=this.#e.get(e);if(l)for(let t of[...l])if(!r()||(await this.#s(t,i,e),!r()))return!1;if(!r())return!1;let s=this.#t.get(e);if(s&&s.size>0){let t=[...s];this.#t.delete(e);for(let n of t)if(!r()||(await this.#s(n,i,e),!r()))return!1}return r()}listenerCount(e){return(this.#e.get(e)?.size??0)+(this.#t.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#e.clear(),void this.#t.clear();this.#e.delete(e),this.#t.delete(e)}eventNames(){let e=new Set;for(let t of this.#e.keys())e.add(t);for(let t of this.#t.keys())e.add(t);return[...e]}#r(e,t,i){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n.add(i),()=>{this.#l(e,t,i)}}#l(e,t,i){let n=e.get(t);void 0!==n&&(n.delete(i),0===n.size&&e.delete(t))}async#s(e,t,i){try{await e(t)}catch(e){let t="string"==typeof i||"number"==typeof i?String(i):"<event>";G(`[live-preview] handler for "${t}" threw:`,e)}}};function it(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function nt(){return!(typeof window>"u")&&null!=window.opener}function rt(){return it()||nt()}function lt(){let e=ot();if(void 0!==e)return"production"!==e;let t=at();if(void 0!==t)return t;if(typeof window<"u"){let e=window.location.hostname;if("localhost"===e||"127.0.0.1"===e)return!0}return!1}function st(e){if(typeof process<"u"){let t=process.env[e];if("string"==typeof t&&t.length>0)return t}let t=ut();if(t){let i=t[e];if("string"==typeof i&&i.length>0)return i}}function ot(){if(typeof process>"u")return;let e=process.env.NODE_ENV;return"string"==typeof e?e:void 0}function at(){let e=ut();if(!e)return;let t=e.DEV;return"boolean"==typeof t?t:void 0}function ut(){if(!(typeof __INLINE_RUNTIME_BUILD__<"u"&&__INLINE_RUNTIME_BUILD__)){if(void 0!==et)return et??void 0;et=null;try{let e=new Function("try { return import.meta && import.meta.env; } catch (_) { return undefined; }")();if(e&&"object"==typeof e)return et=e}catch{}}}t(it,"isInIframe"),t(nt,"isInPopup"),t(rt,"isInPreviewContext"),t(lt,"isDevMode"),t(st,"getEnvVar"),t(ot,"readNodeEnv"),t(at,"readImportMetaDev"),t(ut,"tryReadImportMetaEnv");var ht=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,dt=/^https?:\/\/[^/?#\s]+$/i,ct=["PAYLOAD_ADMIN_ORIGIN","PUBLIC_PAYLOAD_ADMIN_ORIGIN","NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN"],ft=class{static{t(this,"OriginDetector")}#e;constructor(e={}){let t,i=new Set;for(let t of e.additionalOrigins??[]){let e=gt(t);void 0!==e&&i.add(e)}for(let e of ct){let t=st(e);if(void 0!==t)for(let e of t.split(",")){let t=gt(e);void 0!==t&&i.add(t)}}if(e.enableReferrerDetection??1){let i=e.referrer??(typeof document<"u"?document.referrer:"");if(i.length>0)try{let e=new URL(i).origin;e&&"null"!==e&&(t=e)}catch{}}let n=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??lt());this.#e=[i,t,n,void 0!==t,void 0]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#e[4]?e===this.#e[4]:!!(this.#e[0].has(e)||0===this.#e[0].size&&void 0!==this.#e[1]&&e===this.#e[1]||this.#e[2]&&ht.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#e[4]=e,!0)}unlockOrigin(){let e=this.#e[4];return this.#e[4]=void 0,e}get lockedOrigin(){return this.#e[4]}enumerate(){if(void 0!==this.#e[4])return[this.#e[4]];let e=new Set(this.#e[0]);if(0===this.#e[0].size&&void 0!==this.#e[1]&&e.add(this.#e[1]),this.#e[2])for(let t of pt)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#e[3]}get isProductionUnconfigured(){return!(!it()||this.#e[0].size>0||this.#e[2]||void 0!==this.#e[1])}get isReferrerOnlyTrust(){return!(this.#e[0].size>0||this.#e[2])&&void 0!==this.#e[1]}},pt=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function gt(e){let t=e.trim();if(0!==t.length)try{let e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||!dt.test(e.origin)?void 0:e.origin}catch{return}}t(gt,"normaliseOrigin");var mt=t(()=>{},"noopDisposer");function yt(e){return"function"==typeof e}t(yt,"isPluginDisposer");var vt,bt=class{static{t(this,"ResourceScope")}#e;#t;#i=new Set;#r="staging";constructor(e,t){this.#e=e,this.#t=t}assertOpen(){if("closed"===this.#r)throw new Error(`Plugin context for "${this.#e}" is no longer active`)}get active(){return"active"===this.#r}eligible(){return"closed"!==this.#r}own(e){return this.assertOpen(),this.#l({acquire:void 0,finalize:void 0,cleanup:e,disposed:!1})}stage(e,t){this.assertOpen();let i={acquire:e,finalize:t,cleanup:void 0,disposed:!1},n=this.#l(i);if("active"===this.#r)try{this.#s(i)}catch(e){throw this.#n(i),e}return n}commit(){if("staging"!==this.#r)throw new Error(`Plugin context for "${this.#e}" cannot be committed`);this.#r="committing";try{for(let e of this.#i)this.#s(e);this.#r="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#r){this.#r="closed";for(let e of[...this.#i].reverse())this.#n(e);this.#i.clear()}}#l(e){return this.#i.add(e),()=>{this.#n(e)}}#s(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;let t=e.acquire();e.cleanup=t??mt}#n(e){if(e.disposed)return;e.disposed=!0,this.#i.delete(e);let t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{I(t())&&this.#t(`plugin "${this.#e}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#t(`plugin "${this.#e}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#t(`plugin "${this.#e}" cleanup failed:`,e)}}},wt=class extends tt{static{t(this,"ScopedPluginEvents")}#e;#t;#i=new Set;constructor(e,t){super(),this.#e=e,this.#t=t}on(e,t){return this.#r("on",e,t)}once(e,t){return this.#r("once",e,t)}off(e,t){let i=t;for(let t of[...this.#i])t.event===e&&t.handler===i&&t.dispose()}emit(e,t){return this.#t.assertOpen(),this.#e.emit(e,t)}emitWhile(e,t,i){return this.#t.assertOpen(),this.#e.emitWhile(e,t,()=>{if(!this.#t.eligible())return!1;let e=i();return!!this.#t.eligible()&&e})}listenerCount(e){let t=0;for(let i of this.#i)i.event===e&&(t+=1);return t}removeAllListeners(e){for(let t of[...this.#i])(void 0===e||t.event===e)&&t.dispose()}eventNames(){let e=new Set;for(let t of this.#i)e.add(t.event);return[...e]}#r(e,i,n){this.#t.assertOpen();let r=n,l=[...this.#i].find(t=>t.kind===e&&t.event===i&&t.handler===r);if(void 0!==l)return l.dispose;let s=mt,o=!0,a=t(async t=>{!this.#t.active||!o||("once"===e&&s(),await n(t))},"wrapped"),u={kind:e,event:i,handler:r,dispose:mt};return s=this.#t.stage(()=>this.#e[e](i,a),()=>{o=!1,this.#i.delete(u)}),u.dispose=s,this.#i.add(u),s}},St=class{static{t(this,"PluginManager")}#e;#t;#i;#r;#l;#s=new Map;#n=new Map;#u=new Map;#a=new Set;#h=new Map;#o=Promise.resolve();#v=0;constructor(e){this.#e=e.events,this.#t=e.config,this.#i=e.registerFieldRenderer,this.#l=B(e.log);let t=e.onTransformError;this.#r=void 0===t?void 0:B((...e)=>{let i=e[0];if(i instanceof Error)try{return t(i)}catch(e){return void this.#l("transform error reporter failed:",e)}})}register(e){return this.#v>0?this.#y(e):this.#p(()=>this.#y(e))}unregister(e){return this.#v>0?this.#d(e):this.#p(async()=>{await this.#d(e)})}destroyAll(){return this.#v>0?this.#f():this.#p(async()=>{await this.#f()})}applyTransforms(e,t,i,n){let r=this.#h.get(e);if(void 0===r||0===r.length)return t;let l=t;for(let s of[...r]){if(!s.active)continue;let{transform:r}=s;if(!1===n?.())return t;try{l=r(l,{fieldName:e,element:i.element,allFields:i.allFields});let s=I(l);if(!1===n?.())return t;if(s)throw new TypeError(`Transform for "${e}" returned a Promise/thenable; transforms must be synchronous`)}catch(i){if(!1===n?.())return t;let r=i instanceof Error?i:new Error(String(i));return this.#l(`transform for "${e}" failed:`,r),this.#r?.(r),t}}return l}list(){return[...this.#s.keys()]}get size(){return this.#s.size}async#y(e){if(this.#s.has(e.name)||this.#n.has(e.name)||this.#u.has(e.name))return void this.#l(`plugin "${e.name}" already registered`);let t=new bt(e.name,this.#l),i=this.#g(e.name,t),n={scope:t,cancelled:!1};this.#n.set(e.name,n);try{if(await this.#m(()=>e.init(i)),n.cancelled)return;t.commit()}catch(i){return t.close(),void(n.cancelled||this.#l(`plugin "${e.name}" init failed:`,i))}finally{this.#n.get(e.name)===n&&this.#n.delete(e.name)}this.#s.set(e.name,{plugin:e,scope:t}),this.#l(`plugin "${e.name}" registered`)}#g(e,i){return{events:new wt(this.#e,i),registerFieldRenderer:t(e=>{i.stage(()=>{let t=this.#i(e);return yt(t)?t:void 0})},"registerFieldRenderer"),registerTransform:t((e,t)=>{let n={transform:t,active:!1};i.stage(()=>{n.active=!0;let t=this.#h.get(e);return void 0===t?this.#h.set(e,[n]):t.push(n),()=>{n.active=!1;let t=this.#h.get(e);if(void 0===t)return;let i=t.indexOf(n);i>=0&&t.splice(i,1),0===t.length&&this.#h.delete(e)}})},"registerTransform"),registerCleanup:t(e=>{i.own(e)},"registerCleanup"),getConfig:t(()=>this.#t,"getConfig"),log:t((...t)=>{this.#l(`[${e}]`,...t)},"log")}}#d(e){let t=this.#n.get(e);if(void 0!==t)return t.cancelled=!0,t.scope.close(),Promise.resolve();let i=this.#u.get(e);if(void 0!==i)return this.#a.has(e)?Promise.resolve():i;let n=this.#s.get(e);if(void 0===n)return Promise.resolve();this.#s.delete(e),n.scope.close();let r=Promise.resolve().then(()=>this.#c(e,n.plugin));return this.#u.set(e,r),r.then(()=>{this.#u.get(e)===r&&this.#u.delete(e)}),r}async#c(e,t){if(void 0!==t.destroy){this.#a.add(e);try{await this.#m(()=>t.destroy?.())}catch(t){this.#l(`plugin "${e}" destroy failed:`,t)}finally{this.#a.delete(e)}}}async#f(){for(let e of this.#n.values())e.cancelled=!0,e.scope.close();let e=[...this.#s.keys()];for(let t of e)await this.#d(t)}async#m(e){this.#v+=1;try{await e()}finally{this.#v-=1}}#p(e){let t=this.#o.then(e);return this.#o=t.catch(e=>{this.#l("plugin manager mutation failed:",e)}),t}},At=class{static{t(this,"RendererRegistry")}#e;#t;#i=new Map;constructor(e){this.#e=e,this.#t={...e}}get renderers(){return this.#t}resolve(e){return this.#t[e]}register(e){let t=e.name,i={renderer:e},n=this.#i.get(t);void 0===n?this.#i.set(t,[i]):n.push(i),this.#t[t]=e;let r=!0;return()=>{if(!r)return;r=!1;let e=this.#i.get(t);if(void 0===e)return;let n=e.indexOf(i);if(n<0)return;let l=n===e.length-1;if(e.splice(n,1),0===e.length&&this.#i.delete(t),!l)return;let s=e.at(-1)?.renderer??this.#e[t];void 0===s?Reflect.deleteProperty(this.#t,t):this.#t[t]=s}}},Tt=new Set(["p","br","strong","b","em","i","u","s","strike","mark","small","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","blockquote","code","pre","kbd","samp","var","a","span","div","section","article","aside","header","footer","nav","figure","figcaption","img","picture","source","audio","video","sub","sup","hr","time","abbr","cite","q","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col"]),$t=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),kt=new Set(["id","class","lang","dir","title","role","tabindex"]),xt={a:new Set(["href","target","rel","download","hreflang","type"]),img:new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:new Set([]),source:new Set(["src","srcset","sizes","type","media"]),audio:new Set(["src","controls","autoplay","loop","muted","preload"]),video:new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:new Set(["datetime"]),abbr:new Set(["title"]),q:new Set(["cite"]),blockquote:new Set(["cite"]),table:new Set(["summary"]),th:new Set(["colspan","rowspan","scope","headers","abbr"]),td:new Set(["colspan","rowspan","headers"]),col:new Set(["span"]),colgroup:new Set(["span"]),ol:new Set(["start","reversed","type"]),li:new Set(["value"]),code:new Set(["class"]),pre:new Set(["class"])},Nt=new Set(["href","src","cite","poster"]),Mt=class extends Error{static{t(this,"SanitizerEnvironmentError")}name="SanitizerEnvironmentError"};function Ct(e){if(!e){let e=new Map;for(let[t,i]of Object.entries(xt))e.set(t,i);return{allowedTags:Tt,attrByTag:e}}let t=new Set(Tt);for(let i of e.additionalAllowedTags??[])t.add(i);let i=new Map;for(let[e,t]of Object.entries(xt))i.set(e,t);for(let[t,n]of Object.entries(e.additionalAllowedAttributes??{})){let e=i.get(t),r=new Set(e??[]);for(let e of n)r.add(e);i.set(t,r)}return{allowedTags:t,attrByTag:i}}function Rt(e){vt=e??void 0}function Ot(e,t){let i=It();if(!i)throw new Mt("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===e)return"";let n=Ct(t),r=i.createElement("template");return r.innerHTML=e,Lt(r.content,n),r.innerHTML}function It(){return vt||(typeof document>"u"?void 0:document)}function Ft(){return void 0!==It()}function Lt(e,t){for(let i of Array.from(e.childNodes))1===i.nodeType?Et(i,t):8===i.nodeType&&i.remove()}function Et(e,t){let i=e.tagName.toLowerCase();if($t.has(i))e.remove();else{if(!t.allowedTags.has(i)){Lt(e,t);let i=e.parentNode;if(i){for(;e.firstChild;)i.insertBefore(e.firstChild,e);e.remove()}return}Pt(e,i,t),"a"===i&&Dt(e),Lt(e,t)}}function Pt(e,t,i){let n=i.attrByTag.get(t);for(let t of Array.from(e.attributes)){let i=t.name.toLowerCase();if(i.startsWith("on"))e.removeAttribute(t.name);else if("style"!==i){if(!(kt.has(i)||i.startsWith("aria-")||i.startsWith("data-"))){if(n?.has(i)){(Nt.has(i)&&!re(t.value)||"srcset"===i&&!jt(t.value))&&e.removeAttribute(t.name);continue}e.removeAttribute(t.name)}}else e.removeAttribute(t.name)}}function jt(e){let t=e.split(",");for(let e of t){let t=e.trim();if(0===t.length)continue;let i=t.search(/\s/);if(!re(-1===i?t:t.slice(0,i)))return!1}return!0}function Dt(e){let t=e.getAttribute("href");null===t||!le(t)||(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}t(Ct,"resolvePolicy"),t(Rt,"setSanitizerDocument"),t(Ot,"sanitizeHtml"),t(It,"resolveDocument"),t(Ft,"hasSanitizerDocument"),t(Lt,"sanitizeFragment"),t(Et,"sanitizeElement"),t(Pt,"sanitizeAttributes"),t(jt,"isSafeSrcset"),t(Dt,"hardenAnchor");var Ut=new Map;function Wt(e,t){Ut.set(e,t)}function _t(e){return Ut.get(e)}t(Wt,"register"),t(_t,"lookup");var Vt={1:"left",2:"center",3:"right",4:"justify"},zt=new Set(["left","center","right","justify","start","end"]);function Bt(e){let t=e.format;if("string"==typeof t&&zt.has(t))return t;if("number"==typeof t){let e=Vt[t];if(void 0!==e)return e}}function Kt(e){let t=e.indent;return"number"==typeof t&&t>0?t:0}function Gt(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function qt(e){let t=Bt(e),i=Kt(e),n=[];return void 0!==t&&n.push(`text-align:${t}`),i>0&&n.push(`padding-inline-start:${String(40*i)}px`),0===n.length?"":` style="${n.join(";")}"`}t(Bt,"resolveAlignment"),t(Kt,"resolveIndent"),t(Gt,"dirAttribute"),t(qt,"styleAttribute");var Ht=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),Jt=/[&<>"'/`=]/g;function Xt(e){return""===e?"":e.replace(Jt,e=>Ht[e])}function Yt(e){return e.replace(/['"()\\]/g,"\\$&")}t(Xt,"escapeHtml"),t(Yt,"escapeCssUrl");var Qt=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}),Zt=/[&<>"']/g;function ei(e){return""===e?"":e.replace(Zt,e=>Qt[e])}function ti(e){return Xt(e).replace(/\r\n|\r|\n/g,"<br>")}t(ei,"escapeHtmlAttribute"),t(ti,"escapeAndLinebreak");var ii=t(e=>{let t=Xt("string"==typeof e.text?e.text:""),i="number"==typeof e.format?e.format:0;return!!(16&i)&&(t=`<code>${t}</code>`),!!(1&i)&&(t=`<strong>${t}</strong>`),!!(2&i)&&(t=`<em>${t}</em>`),!!(8&i)&&(t=`<u>${t}</u>`),!!(4&i)&&(t=`<s>${t}</s>`),!!(32&i)&&(t=`<sub>${t}</sub>`),!!(64&i)&&(t=`<sup>${t}</sup>`),!!(128&i)&&(t=`<mark>${t}</mark>`),t},"textRenderer"),ni=t((e,t)=>{let i=t.renderChildren(e.children??[]);return`<p${Gt(e)}${qt(e)}>${i}</p>`},"paragraphRenderer"),ri=new Set(["h1","h2","h3","h4","h5","h6"]),li=t((e,t)=>{let i="string"==typeof e.tag?e.tag.toLowerCase():"h2",n=ri.has(i)?i:"h2",r=t.renderChildren(e.children??[]);return`<${n}${Gt(e)}${qt(e)}>${r}</${n}>`},"headingRenderer"),si=t((e,t)=>{let i="string"==typeof e.listType?e.listType:"bullet",n="number"===i?"ol":"ul",r="number"===i&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",l="check"===i?' role="list"':"",s=t.renderChildren(e.children??[]);return`<${n}${Gt(e)}${qt(e)}${r}${l}>${s}</${n}>`},"listRenderer"),oi=t((e,t)=>{let i=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${qt(e)}>${i}</li>`;let n="number"==typeof e.value?` value="${Xt(String(e.value))}"`:"";return`<li${Gt(e)}${qt(e)}${n}>${i}</li>`},"listItemRenderer"),ai=t((e,t)=>{let i="string"==typeof e.url?e.url:"",n=t.renderChildren(e.children??[]);if(0===i.length||!re(i))return n;let r=le(i)?' target="_blank" rel="noopener noreferrer"':ui(e),l="string"==typeof e.title?` title="${Xt(e.title)}"`:"";return`<a href="${ei(i)}"${r}${l}>${n}</a>`},"linkRenderer");function ui(e){let t="string"==typeof e.target?e.target:"";if(0===t.length)return"";let i=Xt(t);return"_blank"===t?' target="_blank" rel="noopener noreferrer"':` target="${i}"`}t(ui,"buildOptionalAttrs");var hi=t((e,t)=>{let i=t.renderChildren(e.children??[]);return`<blockquote${Gt(e)}${qt(e)}>${i}</blockquote>`},"quoteRenderer"),di=t(e=>{let t=pi("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${Xt(fi(e))}</code></pre>`},"codeRenderer"),ci=t(e=>{let t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${pi(e.highlightType)}"`:""}>${Xt(t)}</span>`},"codeHighlightRenderer");function fi(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(let i of e.children)t+=fi(i);return t}function pi(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}t(fi,"extractText"),t(pi,"sanitizeLangClass");var gi=t(()=>"<br>","linebreakRenderer"),mi=t(()=>"<hr>","horizontalRuleRenderer"),yi=t(()=>"\t","tabRenderer"),vi=t(e=>{let t=bi(e);if(void 0===t)return"";let i=t.url;if("string"!=typeof i||!re(i))return"";let n="string"==typeof t.mimeType?t.mimeType:"";return n.startsWith("video/")?Si(t,i):n.startsWith("audio/")?Ai(t,i):""===n||n.startsWith("image/")?wi(t,i):Ti(t,i)},"uploadRenderer");function bi(e){let t=e.value;if("object"==typeof t&&null!==t)return t}function wi(e,t){let i="string"==typeof e.alt?Xt(e.alt):"",n="number"==typeof e.width?` width="${String(e.width)}"`:"",r="number"==typeof e.height?` height="${String(e.height)}"`:"";return`<img src="${ei(t)}" alt="${i}"${n}${r} loading="lazy" decoding="async">`}function Si(e,t){let i="number"==typeof e.width?` width="${String(e.width)}"`:"",n="number"==typeof e.height?` height="${String(e.height)}"`:"",r="string"==typeof e.mimeType?` type="${ei(e.mimeType)}"`:"";return`<video controls${i}${n}><source src="${ei(t)}"${r}></video>`}function Ai(e,t){let i="string"==typeof e.mimeType?` type="${ei(e.mimeType)}"`:"";return`<audio controls><source src="${ei(t)}"${i}></audio>`}function Ti(e,t){let i="string"==typeof e.filename?Xt(e.filename):Xt(t);return`<a href="${ei(t)}" target="_blank" rel="noopener noreferrer">${i}</a>`}t(bi,"readUploadValue"),t(wi,"renderImage"),t(Si,"renderVideo"),t(Ai,"renderAudio"),t(Ti,"renderFallbackLink");var $i=t(e=>{let t="string"==typeof e.relationTo?e.relationTo:"",i=ki(e),n=Xt(xi(i,t)),r=""===t?"":` data-relation-to="${Xt(t)}"`,l=i?.url;return"string"==typeof l&&re(l)?`<a href="${ei(l)}"${r}>${n}</a>`:`<span${r}>${n}</span>`},"relationshipRenderer");function ki(e){let t=e.value;if("object"==typeof t&&null!==t)return t}function xi(e,t){return void 0===e?""===t?"#":`#${t}`:"string"==typeof e.title&&e.title.length>0?e.title:"string"==typeof e.name&&e.name.length>0?e.name:"string"==typeof e.slug&&e.slug.length>0?e.slug:void 0!==e.id?String(e.id):""===t?"#":`#${t}`}t(ki,"readValue"),t(xi,"pickLabel");var Ni=new Map;function Mi(e,t){Ni.set(e,t)}function Ci(e){return Ni.get(e)}t(Mi,"registerBlockRenderer"),t(Ci,"lookupBlockRenderer");var Ri=t((e,t)=>{let i=Oi(e),n="string"==typeof i.blockType?i.blockType:"",r=Ii(n);if(""!==n){let e=Ci(n)??Ci(r);if(e)return e(i,{renderChildren:t.renderChildren})}let l=[];""!==r&&l.push(`data-block-type="${Xt(r)}"`);for(let[e,t]of Object.entries(i)){if("blockType"===e||"id"===e||null==t)continue;let i="string"==typeof t||"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t);l.push(`data-block-${Ii(e)}="${Xt(i)}"`)}return`<div${0===l.length?"":` ${l.join(" ")}`}></div>`},"blockRenderer");function Oi(e){let t=e.fields;return"object"!=typeof t||null===t?{}:t}function Ii(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}t(Oi,"readFields"),t(Ii,"sanitizeIdent"),Wt("text",ii),Wt("paragraph",ni),Wt("heading",li),Wt("list",si),Wt("listitem",oi),Wt("link",ai),Wt("autolink",ai),Wt("quote",hi),Wt("code",di),Wt("code-highlight",ci),Wt("linebreak",gi),Wt("horizontalrule",mi),Wt("tab",yi),Wt("upload",vi),Wt("relationship",$i),Wt("block",Ri);var Fi={renderChildren:ji,resolveAlignment:Bt,resolveIndent:Kt};function Li(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function Ei(e,t={}){if(!Li(e))return"";let i=ji(e.root.children);return!1!==t.sanitize&&Ft()?Ot(i):i}function Pi(e){return Li(e)?e.root.children.map(Ui).join("\n").trim():""}function ji(e){let t="";for(let i of e)t+=Di(i);return t}function Di(e){let t=_t(e.type);return t?t(e,Fi):void 0!==e.children?ji(e.children):""}function Ui(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\n";if(void 0===e.children)return"";let t="";for(let i of e.children)t+=Ui(i);return t}function Wi(){let e=new WeakSet;return{name:"text",render:he((t,i)=>{let n=t.element,r=zi(i);if("INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName)return _i(n)&&!n.hasAttribute("data-payload-text")?(Vi(e,n,t.fieldName),!1):void(r.includes("\n")||r.includes("\r")?n.innerHTML=ti(r):n.textContent=r);n.value=r})}}function _i(e){return null!==e.firstElementChild}function Vi(e,t,i){e.has(t)||(e.add(t),q(`[live-preview] Skipping text update for "${i}": <${t.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}function zi(e){return null==e?"":Li(e)?Pi(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}function Bi(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return String(e);try{return JSON.stringify(e)}catch{return""}}t(Li,"isLexicalContent"),t(Ei,"lexicalToHtml"),t(Pi,"lexicalToPlainText"),t(ji,"renderChildren"),t(Di,"renderNode"),t(Ui,"extractPlainText"),t(Wi,"createTextRenderer"),t(_i,"hasStructuredChildren"),t(Vi,"warnOnce"),t(zi,"toPlainString"),t(Bi,"safeStringify");var Ki={name:"textarea",render(e,t){let i=e.element,n=Li(t)?Pi(t):Bi(t);"INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName?i.innerHTML=ti(n):i.value=n}},Gi={name:"richText",render:he((e,t)=>{if(Li(t))e.element.innerHTML=Ei(t);else{if("string"!=typeof t)return!1;e.element.innerHTML=Ot(t)}})},qi={name:"html",render(e,t){if(null==t)return void(e.element.textContent="");let i="string"==typeof t?t:Bi(t);e.element.innerHTML=Ot(i)}},Hi={name:"url",render(e,t,i){let n=e.element,r=Bi(t);if("A"===n.tagName){let l=n,s=e.hrefField,o=void 0===s||0===s.length?t:ye(i.allFields,s,i.locale,void 0!==e.locale);return"string"==typeof o&&re(o)&&(l.href=o),void(l.textContent=r)}"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName?n.textContent=r:n.value=r}},Ji={name:"image",render:he((e,t,i)=>{let n=e.element,r=Xi(t),l=void 0!==e.locale,s=Yi(r,t,e.srcField,i.allFields,i.locale,l);if(void 0===s)return!1;if("IMG"===n.tagName){let t=n;t.src=s;let o=Qi(r,e.altField,i.allFields,i.locale,l);return void(void 0!==o&&(t.alt=o))}n.style.backgroundImage=`url('${Yt(s)}')`})};function Xi(e){if("object"==typeof e&&null!==e)return e}function Yi(e,t,i,n,r,l){if(void 0!==i&&i.length>0){let e=ye(n,i,r,l);if("string"==typeof e&&re(e))return e;let t=Xi(e);return void 0!==t?.url&&re(t.url)?t.url:void 0}return void 0!==e?.url&&re(e.url)?e.url:"string"==typeof t&&re(t)?t:void 0}function Qi(e,t,i,n,r){if(void 0!==t&&t.length>0){let e=ye(i,t,n,r);return"string"==typeof e?e:void 0}if(void 0!==e?.alt)return e.alt}t(Xi,"readMedia"),t(Yi,"pickUrl"),t(Qi,"pickAlt");var Zi={name:"upload",render:he((e,t)=>{let i=e.element,n=en(t);if(void 0===n)return!1;let r=n.url;if("string"!=typeof r||!re(r))return!1;if("IMG"===i.tagName){let e=i;return e.src=r,void(void 0!==n.alt&&(e.alt=n.alt))}if("A"===i.tagName){let e=i;return e.href=r,void(e.textContent=n.filename??r)}let l=void 0!==n.filename?Xt(n.filename):Xt(r);i.innerHTML=`<a href="${ei(r)}">${l}</a>`})};function en(e){if("object"==typeof e&&null!==e)return e}t(en,"readMedia");var tn={name:"relationship",render(e,t){let i=e.element,n=nn(t).join(", ");if("A"===i.tagName&&!Array.isArray(t)){let e=i,r=t?.url;return"string"==typeof r&&re(r)&&(e.href=r),void(e.textContent=n)}i.textContent=n}};function nn(e){return null==e?[""]:Array.isArray(e)?e.map(rn):[rn(e)]}function rn(e){if("object"==typeof e&&null!==e){let t=e;return"string"==typeof t.title&&t.title.length>0?t.title:"string"==typeof t.name&&t.name.length>0?t.name:"string"==typeof t.slug&&t.slug.length>0?t.slug:void 0!==t.id?String(t.id):""}return Bi(e)}t(nn,"collectLabels"),t(rn,"pickLabel");var ln={name:"select",render(e,t){let i=e.element,n=sn(t);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let e=i;return void(e.checked=e.value===n)}i.textContent=n}else i.value=n}};function sn(e){return Array.isArray(e)?e.map(e=>sn(e)).join(", "):Bi(e)}t(sn,"stringify");var on={name:"checkbox",render(e,t){let i=e.element,n=!!t;"INPUT"!==i.tagName||"checkbox"!==i.type?i.hasAttribute("aria-checked")?i.setAttribute("aria-checked",n?"true":"false"):i.textContent=n?"true":"false":i.checked=n}},an=new Map,un=new Map;function hn(e,t){let i=cn(e,t),n=an.get(i);if(void 0!==n)return an.delete(i),an.set(i,n),n;let r=new Intl.NumberFormat(e,t);return an.set(i,r),pn(an),r}function dn(e,t){let i=cn(e,t),n=un.get(i);if(void 0!==n)return un.delete(i),un.set(i,n),n;let r=new Intl.DateTimeFormat(e,t);return un.set(i,r),pn(un),r}function cn(e,t){let i=e??"";if(null==t)return i;let n=fn(t);return"{}"===n?i:`${i}|${n}`}function fn(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>fn(e)).join(",")}]`;let t=e,i=Object.keys(t).sort(),n=[];for(let e of i){let i=t[e];void 0!==i&&n.push(`${JSON.stringify(e)}:${fn(i)}`)}return`{${n.join(",")}}`}function pn(e){for(;e.size>64;){let t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}t(hn,"getNumberFormat"),t(dn,"getDateTimeFormat"),t(cn,"buildKey"),t(fn,"stableStringify"),t(pn,"trimToLimit");var gn={name:"date",render(e,t,i){let n=e.element;if(null==t||""===t)return void("INPUT"===n.tagName?n.value="":("TIME"===n.tagName&&n.removeAttribute("datetime"),n.textContent=""));let r="string"==typeof t?t:Bi(t),l=new Date(r),s=!Number.isNaN(l.getTime());if("INPUT"!==n.tagName)return"TIME"===n.tagName?(n.setAttribute("datetime",s?l.toISOString():r),void(n.textContent=s?mn(l,i):r)):void(n.textContent=s?mn(l,i):r);n.value=s?yn(n.type,l):r}};function mn(e,t){let i=t.locale??be();try{return dn(i,{dateStyle:"medium",timeStyle:"short"}).format(e)}catch{return e.toISOString()}}function yn(e,t){return"date"===e?t.toISOString().slice(0,10):"datetime-local"===e?t.toISOString().slice(0,16):t.toISOString()}t(mn,"formatDate"),t(yn,"toIsoForInput");var vn={name:"number",render(e,t,i){let n=e.element;if(null==t||""===t)return void("INPUT"===n.tagName?n.value="":n.textContent="");let r="number"==typeof t?t:Number(Bi(t));Number.isNaN(r)?n.textContent=Bi(t):"INPUT"!==n.tagName?n.textContent=bn(r,i):n.value=String(r)}};function bn(e,t){let i=t.locale??be();try{return hn(i).format(e)}catch{return String(e)}}t(bn,"format");var wn=/\{\{([\s\S]*?)\}\}/g;function Sn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function An(e,t,i,n){let r="object"==typeof t&&null!==t?t:null;return e.replace(wn,(e,l)=>null!==r&&Sn(r,l)?Xt(n(Reflect.get(r,l))):null===r&&"value"===l?Xt(n(t)):"index"===l?String(i):e)}t(Sn,"hasOwn"),t(An,"interpolateArrayTemplate");var Tn={name:"array",render:he((e,t)=>{let i=e.element;if(!Array.isArray(t))return!1;let n=e.arrayTemplate;if(void 0!==n&&n.length>0){let e=$n(n,t);return void(i.innerHTML=Ot(e))}let r=e.arraySeparator??", ";i.textContent=t.map(xn).join(r)})};function $n(e,t){let i="";for(let n=0;n<t.length;n+=1)i+=kn(e,t[n],n);return i}function kn(e,t,i){return An(e,t,i,Bi)}function xn(e){return Bi(e)}t($n,"renderTemplate"),t(kn,"interpolate"),t(xn,"stringify");var Nn="data-payload-key",Mn="data-payload-nested-key",Cn="data-payload-nested-template";function Rn(){return new WeakMap}function On(e){let{template:t,container:i,patches:n,nextItems:r,store:l,forceRender:s=!1}=e,o=In(i,t,n,r,s,l);return null===o?null:Fn(o,l)}function In(e,t,i,n,r,l){let s=Ln(e,t,n,En(i),r,l.get(e),l);return null===s?null:[e,s,n]}function Fn(e,t){let[i,n,r]=e,l=new Set,s=!1;for(let e of n){let[n,r,o,a]=e,u=r;if(void 0!==o){for(let e of a)null!==e[0]&&(Dn(e[0],e[1]),e[1].replaceWith(e[0])),void 0!==e[2]&&Fn(e[2],t);null!==r&&(r.replaceWith(o),s=!0),u=o}if(null===u)continue;let h=i.children[n]??null;u!==h&&(i.insertBefore(u,h),s=!0),l.add(u)}for(let e of Array.from(i.children))l.has(e)||(e.remove(),s=!0);let o=Wn(i,t);o.clear();for(let e of r)_n(o,e);return s}function Ln(e,t,i,n,r,l,s){let o=Array.from(e.children),a=zn(o,Nn),u=new Set,h=[];for(let d=0;d<i.length;d+=1){let c=i[d],f=Vn(c),p=void 0===f?o[d]??null:Bn(a,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=n.replaces.has(d),m=r||n.renders.has(d)||null===p?Kn(e.ownerDocument,t,c,d):void 0;if(null===m)return null;let y=void 0===m?[]:Pn(g?null:p,m,c,l,s);if(null===y)return null;h.push([d,p,m??void 0,y])}return h}function En(e){let t=new Set,i=new Set;for(let n of e)"insert"===n.kind||"update"===n.kind?t.add(n.index):"replace"===n.kind&&(t.add(n.index),i.add(n.index));return{renders:t,replaces:i}}function Pn(e,t,i,n,r){let l=zn(null===e?[]:jn(e),Mn),s=Vn(i),o=void 0!==s?n?.get(s):void 0,a=[];for(let e of jn(t)){let t=e.getAttribute(Mn);if(null===t)continue;let n,s=Bn(l,t)??null,u=e.getAttribute(Cn),h=u?s:null,d=h?.getAttribute(Cn)??null;if(u){let l=Un(i,t);if(void 0!==l||null!==h){let i=l??[],s=Le(null===h?[]:Un(o,t)??[],i),a=null!==h&&d!==u;if((s.length>0||a)&&(n=In(h??e,u,s,i,a,r)??void 0,void 0===n))return null}}a.push([h,e,n])}return a}function jn(e){return Array.from(e.querySelectorAll(`[${Mn}]`)).filter(t=>{let i=t.parentElement;for(;null!==i&&i!==e;){if(i.hasAttribute(Mn))return!1;i=i.parentElement}return i===e})}function Dn(e,t){for(let i of Array.from(e.attributes))t.hasAttribute(i.name)||e.removeAttribute(i.name);for(let i of Array.from(t.attributes))e.getAttribute(i.name)!==i.value&&e.setAttribute(i.name,i.value)}function Un(e,t){if("object"!=typeof e||null===e)return;let i=e[t];return Array.isArray(i)?i:void 0}function Wn(e,t){let i=t.get(e);return i||(i=new Map,t.set(e,i)),i}function _n(e,t){let i=Vn(t);void 0!==i&&e.set(i,t)}function Vn(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function zn(e,t){let i=new Map;for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(void 0===r)continue;let l=r.getAttribute(t);if(null===l)continue;let s=i.get(l);void 0===s?i.set(l,[r]):s.push(r)}return i}function Bn(e,t){return e.get(t)?.pop()}function Kn(e,t,i,n){let r=Ot(Gn(t,i,n)),l=e.createElement("template");l.innerHTML=r;let s=l.content.firstElementChild;if(!s)return null;let o=Vn(i);return void 0!==o&&s.setAttribute(Nn,o),s}function Gn(e,t,i){return An(e,t,i,Bi)}function qn(){let e=new WeakMap,t=new WeakSet,i=Rn();return{name:"structural-array",render:he((n,r)=>{if(!Array.isArray(r))return!1;let l=n.element,s=n.arrayTemplate;if(void 0===s||0===s.length)return Qn(t,l,n.fieldName),!1;let o=e.get(l),a=Jn(l),u=Le(o?.values??Xn(a),r),h=Hn(o,s,a);if(0===u.length&&!h)return e.set(l,{values:r.slice(),template:s,domSnapshot:a}),!1;let d=On({template:s,container:l,patches:u,nextItems:r,store:i,forceRender:h});return null!==d&&(e.set(l,{values:r.slice(),template:s,domSnapshot:Jn(l)}),!!d&&void 0)})}}function Hn(e,t,i){return void 0===e||e.template!==t||!Yn(e.domSnapshot,i)}function Jn(e){return Array.from(e.children,e=>e.getAttribute(Nn))}function Xn(e){return e.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e})}function Yn(e,t){return e.length===t.length&&e.every((e,i)=>e===t[i])}function Qn(e,t,i){e.has(t)||(e.add(t),q(`[live-preview] Skipping structural update for "${i}": <${t.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}t(Rn,"createStructuralStore"),t(On,"applyStructuralPatches"),t(In,"prepareStructuralPlan"),t(Fn,"commitStructuralPlan"),t(Ln,"prepareReconciliation"),t(En,"createPatchPlan"),t(Pn,"prepareNestedSlots"),t(jn,"findDirectNestedSlots"),t(Dn,"synchronizeAttributes"),t(Un,"readNestedArray"),t(Wn,"getMemory"),t(_n,"rememberItem"),t(Vn,"readKey"),t(zn,"indexByAttribute"),t(Bn,"takeIndexedElement"),t(Kn,"renderItem"),t(Gn,"fillTemplate"),t(qn,"createStructuralArrayRenderer"),t(Hn,"needsForcedRender"),t(Jn,"readDomKeySnapshot"),t(Xn,"valuesFromDomSnapshot"),t(Yn,"sameDomKeySnapshot"),t(Qn,"warnMissingTemplate");var Zn=new Map;function er(e=[]){let t={};for(let i of e)t[i.name]=i;for(let[e,i]of Zn)t[e]=i;return Object.freeze(t)}function tr(e){Zn.set(e.name,e)}t(er,"buildBuiltinRenderers"),t(tr,"registerBuiltinRenderer");var ir=[Ki,Gi,qi,Hi,{...Hi,name:"email"},Ji,Zi,tn,ln,{...ln,name:"radio"},on,gn,vn,Tn,{...Tn,name:"blocks"}];function nr(){return er([Wi(),...ir,qn()])}t(nr,"buildBuiltinRenderers");var rr=class{static{t(this,"LivePreviewClient")}#e=new tt;#t;#i;#r;#l;#s;#n=!1;#u=!1;#a=null;constructor(e={}){let i=e.debug??lt();this.#s=i?(...e)=>{H("[live-preview]",...e)}:K,this.#t=new ft({...void 0!==e.allowedOrigins?{additionalOrigins:e.allowedOrigins}:{},...void 0!==e.disableReferrerDetection?{enableReferrerDetection:!e.disableReferrerDetection}:{},...void 0!==e.disableLocalhostMatching?{enableLocalhostMatching:!e.disableLocalhostMatching}:{}}),this.#t.isProductionUnconfigured&&this.#s("no trusted origin could be detected — set allowedOrigins or PAYLOAD_ADMIN_ORIGIN"),this.#i=new At(nr()),this.#l=new St({events:this.#e,config:Object.freeze({...e}),registerFieldRenderer:t(e=>this.#i.register(e),"registerFieldRenderer"),onTransformError:t(e=>{this.#e.emit("error",{error:e,context:"transform"})},"onTransformError"),log:this.#s}),this.#r=new _e({...void 0!==e.root?{root:e.root}:{},renderers:this.#i.renderers,resolveRenderer:t(e=>this.#i.resolve(e),"resolveRenderer"),transformValue:t((e,t,i,n)=>this.#l.applyTransforms(e,t,i,n),"transformValue"),originMatcher:t(e=>this.#t.matches(e),"originMatcher"),readyTargets:this.#t.enumerate(),emitter:this.#e,...void 0!==e.serverURL&&""!==e.serverURL?{dataMerge:{serverURL:e.serverURL,...void 0!==e.apiRoute?{apiRoute:e.apiRoute}:{},...void 0!==e.mergeDepth?{depth:e.mergeDepth}:{},...void 0!==e.mergeFetch?{fetchFn:e.mergeFetch}:{}}}:{},...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.heartbeatMs?{heartbeatMs:e.heartbeatMs}:{},...void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{},...void 0!==e.disableVisibilityGate?{disableVisibilityGate:e.disableVisibilityGate}:{},...void 0!==e.visibilityGateThreshold?{visibilityGateThreshold:e.visibilityGateThreshold}:{},...void 0!==e.enableA11y?{enableA11y:e.enableA11y}:{},...void 0!==e.a11yLocale?{a11yLocale:e.a11yLocale}:{},onHeartbeatTimeout:t(()=>{this.#t.unlockOrigin()},"onHeartbeatTimeout"),...void 0!==e.validateToken?{validateToken:e.validateToken}:{},log:this.#s}),this.#e.on("connect",e=>{this.#t.lockOrigin(e.origin)}),!1!==e.autoStart&&this.start()}start(){if(this.#u)return!1;if(this.#n)return this.#r.start(),!0;if(!rt())return!1;let e=this.#r.start();return e&&(this.#n=!0),e}destroy(){if(null!==this.#a)return this.#a;this.#u=!0;let e,t,i=new Promise((i,n)=>{e=i,t=n});this.#a=i;try{this.#r.destroy(),this.#l.destroyAll().finally(()=>{this.#e.removeAllListeners()}).then(e,t)}catch(e){this.#e.removeAllListeners(),t(e)}return i}async use(e){if(this.#u)throw new Error("LivePreviewClient: already destroyed");await this.#l.register(e)}async unuse(e){await this.#l.unregister(e)}refreshCache(){this.#r.refreshCache()}get events(){return this.#e}get plugins(){return this.#l.list()}get status(){return this.#r.status}get updateCount(){return this.#r.updateCount}get destroyed(){return this.#u}};function lr(e={}){let t=new rr({...e,autoStart:!1});return t.start()?t:null}t(lr,"initLivePreview");var sr='(()=>{function t(t){return("object"!=typeof t||null===t)&&"function"!=typeof t||"function"!=typeof t.then?0:(Promise.resolve(t).catch(()=>{}),1)}function e(e){return(...i)=>{try{t(e(...i))}catch{}}}function i(){}function n(){return 1}function r(t){if(t.nodeType!==Ge)return 0;let e=t;return e.hasAttribute(be)?1:null!==e.querySelector(`[${be}]`)}function l(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){let t=s(i);t&&e.push(t)}return e}function s(t){if("object"!=typeof t||null===t)return;let e=t,i=e.name,n=e.type;if("string"!=typeof i||0===i.length||"string"!=typeof n||0===n.length)return;let r=l(e.fields),s=function(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){if("object"!=typeof i||null===i)continue;let t=i,n=t.slug;if("string"!=typeof n||0===n.length)continue;let r=l(t.fields);e.push({...t,slug:n,fields:r})}return e}(e.blocks),o={...e,name:i,type:n};return r.length>0?o.fields=r:delete o.fields,s.length>0?o.blocks=s:delete o.blocks,o}function o(t){let e="number"==typeof t&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0,i=Math.min(4,e??1),n=new Set;for(let[t,e]of Object.entries(Ye))i>=e&&n.add(t);return{ours:4,...void 0!==e?{theirs:e}:{theirs:void 0},negotiated:i,capabilities:n}}function a(t,e){return void 0===t||e(t)}function u(t,e){return null==t?1:e(t)}function h(t){if("object"!=typeof t||null===t)return 0;let e=Object.getPrototypeOf(t);return null===e||null===Object.getPrototypeOf(e)}function c(t){for(let e of t){let t=e.codePointAt(0);if(void 0!==t&&(t<=31||127===t))return 1}return 0}function d(t){if(void 0===t||0===t.length||t.length>128||"."===t||".."===t||t.includes("/")||t.includes("\\\\")||t.includes("?")||t.includes("#")||c(t))return 0;try{return encodeURIComponent(t),1}catch{return 0}}function f(t,e){return t[6]===e}function p(t){return t.aborted}function g(t){if("string"!=typeof t||0===t.length)return 0;let e=t.trim();if(0===e.length||gi.test(e))return 0;if(e.startsWith("#")||e.startsWith("?")||e.startsWith("//")||e.startsWith("/"))return 1;try{let t=new URL(e);return pi.has(t.protocol)}catch{return mi.test(e)}}function m(t){if(!g(t))return 0;let e=t.trim();return/^https?:\\/\\//i.test(e)||/^\\/\\/[^/]/.test(e)}function y(t){return bi.add(t),t}function v(t,e){return null!==e&&t.generation===e.generation&&t.revision===e.revision}function b(t,e,i,n=0){if(n&&void 0!==i){let n=w(t,`${e}_${i}`);if(void 0!==n)return n}let r=w(t,e);if(void 0!==r)return r;if(e.includes(".")){let i=t,n=1;for(let t of e.split(".")){if(ji.has(t)||null===i||"object"!=typeof i){n=0;break}if(i=w(i,t),void 0===i){n=0;break}}if(n)return i}return void 0===i?void 0:w(t,`${e}_${i}`)}function w(t,e){if(!ji.has(e)&&Object.prototype.hasOwnProperty.call(t,e))return t[e]}function S(){let t=function(){if(typeof document>"u")return;let t=document.documentElement.getAttribute("lang");return null===t||0===t.length?void 0:t}();if(void 0!==t)return t;let e=function(){if(typeof navigator>"u")return;let t=navigator.language;return"string"==typeof t&&t.length>0?t:void 0}();return void 0!==e?e:"en"}function $(t){return/^de(?:[-_]|$)/i.test(t)}function A(t){null!==t[4]&&(clearTimeout(t[4]),t[4]=null),t[2]?.remove(),t[2]=null}function k(t,e=""){let i=new Map;return T(t,e,i),i}function T(t,e,i){for(let n of t){if(_i.has(n.type)){n.fields&&T(n.fields,e,i);continue}if("group"===n.type){let t=""===e?n.name:`${e}.${n.name}`;i.set(t,n),n.fields&&T(n.fields,t,i);continue}let t=""===e?n.name:`${e}.${n.name}`;if(i.set(t,n),"array"===n.type&&n.fields)T(n.fields,`${t}.*`,i);else if("blocks"===n.type&&n.blocks)for(let e of n.blocks)T(e.fields,`${t}.*.${e.slug}`,i)}}function x(t){if("object"!=typeof t||null===t)return;let e=t.id;return"string"==typeof e||"number"==typeof e?e:void 0}function N(t){if("object"!=typeof t||null===t)return;let e=t.blockType;return"string"==typeof e?e:void 0}function M(t,e){return e.every(t=>void 0!==x(t))?function(t,e){let i=[],n=new Map;for(let e=0;e<t.length;e+=1){let i=x(t[e]);void 0!==i&&n.set(i,e)}let r=new Set;for(let l=0;l<e.length;l+=1){let s=e[l],o=x(s);if(void 0===o){i.push({kind:"insert",index:l,value:s});continue}let a=n.get(o);if(void 0===a){i.push({kind:"insert",index:l,value:s});continue}r.add(a);let u=t[a];N(u)===N(s)?(a!==l&&i.push({kind:"move",from:a,to:l,value:s}),C(u,s)||i.push({kind:"update",index:l,value:s})):i.push({kind:"replace",index:l,oldValue:u,value:s})}for(let e=0;e<t.length;e+=1)r.has(e)||i.push({kind:"remove",index:e,value:t[e]});return i}(t,e):function(t,e){let i=[],n=Math.min(t.length,e.length);for(let r=0;r<n;r+=1)C(t[r],e[r])||i.push({kind:"update",index:r,value:e[r]});if(e.length>t.length)for(let n=t.length;n<e.length;n+=1)i.push({kind:"insert",index:n,value:e[n]});if(t.length>e.length)for(let n=e.length;n<t.length;n+=1)i.push({kind:"remove",index:n,value:t[n]});return i}(t,e)}function C(t,e){if(Object.is(t,e))return 1;if("object"!=typeof t||"object"!=typeof e||null===t||null===e)return 0;let i=t,n=e,r=Object.keys(i),l=Object.keys(n);if(r.length!==l.length)return 0;for(let t of r)if(!Object.is(i[t],n[t]))return 0;return 1}function O(t){return 9===t.nodeType}function j(t){if(typeof window>"u")return;let e=[];window.parent!==window&&e.push(window.parent),window.opener instanceof Window&&e.push(window.opener),Ze.sendReady(e,t)}function I(t,e){return t.generation===e.generation&&t.revision===e.revision}function E(t){return null==t?0:"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t}function R(t,e){if(!e)return t;let i=`_${e}`;return t.endsWith(i)?t.slice(0,-i.length):t}function _(){if(typeof window>"u")return 0;try{return window.self!==window.top}catch{return 1}}function L(t){if(typeof process<"u"){let e=process.env[t];if("string"==typeof e&&e.length>0)return e}}function W(t){let e=t.trim();if(0!==e.length)try{let t=new URL(e);return"http:"!==t.protocol&&"https:"!==t.protocol||!un.test(t.origin)?void 0:t.origin}catch{return}}function P(t,e){let i=F();if(!i)throw new An("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===t)return"";let n=function(t){if(!t){let t=new Map;for(let[e,i]of Object.entries(bn))t.set(e,i);return{allowedTags:pn,attrByTag:t}}let e=new Set(pn);for(let i of t.additionalAllowedTags??[])e.add(i);let i=new Map;for(let[t,e]of Object.entries(bn))i.set(t,e);for(let[e,n]of Object.entries(t.additionalAllowedAttributes??{})){let t=i.get(e),r=new Set(t??[]);for(let t of n)r.add(t);i.set(e,r)}return{allowedTags:e,attrByTag:i}}(e),r=i.createElement("template");return r.innerHTML=t,D(r.content,n),r.innerHTML}function F(){if(!(typeof document>"u"))return document}function D(t,e){for(let i of Array.from(t.childNodes))i.nodeType===Sn?U(i,e):i.nodeType===$n&&i.remove()}function U(t,e){let i=t.tagName.toLowerCase();if(gn.has(i))t.remove();else{if(!e.allowedTags.has(i)){D(t,e);let i=t.parentNode;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);t.remove()}return}(function(t,e,i){let n=i.attrByTag.get(e);for(let e of Array.from(t.attributes)){let i=e.name.toLowerCase();if(i.startsWith("on"))t.removeAttribute(e.name);else if("style"!==i){if(!(mn.has(i)||i.startsWith(yn)||i.startsWith(vn))){if(n?.has(i)){(wn.has(i)&&!g(e.value)||"srcset"===i&&!z(e.value))&&t.removeAttribute(e.name);continue}t.removeAttribute(e.name)}}else t.removeAttribute(e.name)}})(t,i,e),"a"===i&&function(t){let e=t.getAttribute("href");null===e||!m(e)||(t.setAttribute("rel","noopener noreferrer"),t.hasAttribute("target")||t.setAttribute("target","_blank"))}(t),D(t,e)}}function z(t){let e=t.split(",");for(let t of e){let e=t.trim();if(0===e.length)continue;let i=e.search(/\\s/);if(!g(-1===i?e:e.slice(0,i)))return 0}return 1}function V(t,e){kn.set(t,e)}function G(t){let e=t.format;if("string"==typeof e&&xn.has(e))return e;if("number"==typeof e){let t=Tn[e];if(void 0!==t)return t}}function H(t){let e=t.indent;return"number"==typeof e&&e>0?e:0}function q(t){return"rtl"===t.direction?\' dir="rtl"\':"ltr"===t.direction?\' dir="ltr"\':""}function J(t){let e=G(t),i=H(t),n=[];return void 0!==e&&n.push(`text-align:${e}`),i>0&&n.push(`padding-inline-start:${String(40*i)}px`),0===n.length?"":` style="${n.join(";")}"`}function B(t){return""===t?"":t.replace(Mn,t=>Nn[t])}function X(t){return""===t?"":t.replace(On,t=>Cn[t])}function Y(t){return B(t).replace(/\\r\\n|\\r|\\n/g,"<br>")}function Z(t){if("string"==typeof t.text)return t.text;if(!t.children)return"";let e="";for(let i of t.children)e+=Z(i);return e}function K(t){return t.replace(/[^a-zA-Z0-9_-]/g,"")}function Q(t){return En.get(t)}function tt(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function et(t){if("object"!=typeof t||null===t||!("root"in t))return 0;let e=t.root;return"object"==typeof e&&null!==e&&"children"in e?Array.isArray(e.children):0}function it(t){return et(t)?t.root.children.map(lt).join("\\n").trim():""}function nt(t){let e="";for(let i of t)e+=rt(i);return e}function rt(t){let e=function(t){return kn.get(t)}(t.type);return e?e(t,jt):void 0!==t.children?nt(t.children):""}function lt(t){if("string"==typeof t.text)return t.text;if("linebreak"===t.type)return"\\n";if(void 0===t.children)return"";let e="";for(let i of t.children)e+=lt(i);return e}function st(){let t=new WeakSet;return{name:"text",render:y((e,i)=>{let n=e.element,r=function(t){return null==t?"":et(t)?it(t):"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}(i);if("INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName){if(function(t){return null!==t.firstElementChild}(n)&&!n.hasAttribute(It))return function(t,e,i){t.has(e)||(t.add(e),ue(`[live-preview] Skipping text update for "${i}": <${e.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}(t,n,e.fieldName),0;r.includes("\\n")||r.includes("\\r")?n.innerHTML=Y(r):n.textContent=r}else n.value=r})}}function ot(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)return String(t);try{return JSON.stringify(t)}catch{return""}}function at(t){if("object"==typeof t&&null!==t)return t}function ut(t){if("object"==typeof t&&null!==t){let e=t;return"string"==typeof e.title&&e.title.length>0?e.title:"string"==typeof e.name&&e.name.length>0?e.name:"string"==typeof e.slug&&e.slug.length>0?e.slug:void 0!==e.id?String(e.id):""}return ot(t)}function ht(t){return Array.isArray(t)?t.map(t=>ht(t)).join(", "):ot(t)}function ct(t,e){let i=t??"";if(null==e)return i;let n=dt(e);return"{}"===n?i:`${i}|${n}`}function dt(t){if(null===t||"object"!=typeof t)return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(t=>dt(t)).join(",")}]`;let e=t,i=Object.keys(e).sort(),n=[];for(let t of i){let i=e[t];void 0!==i&&n.push(`${JSON.stringify(t)}:${dt(i)}`)}return`{${n.join(",")}}`}function ft(t){for(;t.size>Gt;){let e=t.keys().next().value;if(void 0===e)break;t.delete(e)}}function pt(t,e,i,n){let r="object"==typeof e&&null!==e?e:null;return t.replace(Jt,(t,l)=>null!==r&&function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r,l)?B(n(Reflect.get(r,l))):null===r&&"value"===l?B(n(e)):"index"===l?String(i):t)}function gt(t,e,i){return pt(t,e,i,ot)}function mt(t){return ot(t)}function yt(t){let{template:e,container:i,patches:n,nextItems:r,store:l,forceRender:s=0}=t,o=vt(i,e,n,r,s,l);return null===o?null:bt(o,l)}function vt(t,e,i,n,r,l){let s=function(t){let e=new Set,i=new Set;for(let n of t)"insert"===n.kind||"update"===n.kind?e.add(n.index):"replace"===n.kind&&(e.add(n.index),i.add(n.index));return{renders:e,replaces:i}}(i),o=function(t,e,i,n,r,l,s){let o=Array.from(t.children),a=xt(o,Xt),u=new Set,h=[];for(let c=0;c<i.length;c+=1){let d=i[c],f=Tt(d),p=void 0===f?o[c]??null:Nt(a,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=n.replaces.has(c),m=r||n.renders.has(c)||null===p?Mt(t.ownerDocument,e,d,c):void 0;if(null===m)return null;let y=void 0===m?[]:wt(g?null:p,m,d,l,s);if(null===y)return null;h.push([c,p,m??void 0,y])}return h}(t,e,n,s,r,l.get(t),l);return null===o?null:[t,o,n]}function bt(t,e){let[i,n,r]=t,l=new Set,s=0;for(let t of n){let[n,r,o,a]=t,u=r;if(void 0!==o){for(let t of a)null!==t[0]&&($t(t[0],t[1]),t[1].replaceWith(t[0])),void 0!==t[2]&&bt(t[2],e);null!==r&&(r.replaceWith(o),s=1),u=o}if(null===u)continue;let h=i.children[n]??null;u!==h&&(i.insertBefore(u,h),s=1),l.add(u)}for(let t of Array.from(i.children))l.has(t)||(t.remove(),s=1);let o=function(t,e){let i=e.get(t);return i||(i=new Map,e.set(t,i)),i}(i,e);o.clear();for(let t of r)kt(o,t);return s}function wt(t,e,i,n,r){let l=xt(null===t?[]:St(t),Yt),s=Tt(i),o=void 0!==s?n?.get(s):void 0,a=[];for(let t of St(e)){let e=t.getAttribute(Yt);if(null===e)continue;let n,s=Nt(l,e)??null,u=t.getAttribute(Zt),h=u?s:null,c=h?.getAttribute(Zt)??null;if(u){let l=At(i,e);if(void 0!==l||null!==h){let i=l??[],s=M(null===h?[]:At(o,e)??[],i),a=null!==h&&c!==u;if((s.length>0||a)&&(n=vt(h??t,u,s,i,a,r)??void 0,void 0===n))return null}}a.push([h,t,n])}return a}function St(t){return Array.from(t.querySelectorAll(`[${Yt}]`)).filter(e=>{let i=e.parentElement;for(;null!==i&&i!==t;){if(i.hasAttribute(Yt))return 0;i=i.parentElement}return i===t})}function $t(t,e){for(let i of Array.from(t.attributes))e.hasAttribute(i.name)||t.removeAttribute(i.name);for(let i of Array.from(e.attributes))t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}function At(t,e){if("object"!=typeof t||null===t)return;let i=t[e];return Array.isArray(i)?i:void 0}function kt(t,e){let i=Tt(e);void 0!==i&&t.set(i,e)}function Tt(t){if("object"!=typeof t||null===t)return;let e=t.id;return"string"==typeof e||"number"==typeof e?String(e):void 0}function xt(t,e){let i=new Map;for(let n=t.length-1;n>=0;n-=1){let r=t[n];if(void 0===r)continue;let l=r.getAttribute(e);if(null===l)continue;let s=i.get(l);void 0===s?i.set(l,[r]):s.push(r)}return i}function Nt(t,e){return t.get(e)?.pop()}function Mt(t,e,i,n){let r=function(t,e,i){return pt(t,e,i,ot)}(e,i,n),l=P(r),s=t.createElement("template");s.innerHTML=l;let o=s.content.firstElementChild;if(!o)return null;let a=Tt(i);return void 0!==a&&o.setAttribute(Xt,a),o}function Ct(){let t=new WeakMap,e=new WeakSet,i=new WeakMap;return{name:"structural-array",render:y((n,r)=>{if(!Array.isArray(r))return 0;let l=n.element,s=n.arrayTemplate;if(void 0===s||0===s.length)return function(t,e,i){t.has(e)||(t.add(e),ue(`[live-preview] Skipping structural update for "${i}": <${e.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(e,l,n.fieldName),0;let o=t.get(l),a=Ot(l),u=o?.values??function(t){return t.map((t,e)=>null===t?{__payloadDomPosition:e}:{id:t})}(a),h=M(u,r),c=function(t,e,i){return void 0===t?1:t.template!==e||!function(t,e){return t.length!==e.length?0:t.every((t,i)=>t===e[i])}(t.domSnapshot,i)}(o,s,a);if(0===h.length&&!c)return t.set(l,{values:r.slice(),template:s,domSnapshot:a}),0;let d=yt({template:s,container:l,patches:h,nextItems:r,store:i,forceRender:c});return null===d?0:(t.set(l,{values:r.slice(),template:s,domSnapshot:Ot(l)}),d?void 0:0)})}}function Ot(t){return Array.from(t.children,t=>t.getAttribute(Xt))}var jt,It,Et,Rt,_t,Lt,Wt,Pt,Ft,Dt,Ut,zt,Vt,Gt,Ht,qt,Jt,Bt,Xt,Yt,Zt,Kt,Qt,te=Object.defineProperty,ee=t=>{throw TypeError(t)},ie=(t,e,i)=>((t,e,i)=>e in t?te(t,e,{enumerable:1,configurable:1,writable:1,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),ne=(t,e,i)=>e.has(t)||ee("Cannot "+i),re=(t,e,i)=>(ne(t,e,"read from private field"),i?i.call(t):e.get(t)),le=(t,e,i)=>e.has(t)?ee("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),se=(t,e,i,n)=>(ne(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i),oe=(t,e,i)=>(ne(t,e,"access private method"),i),ae=e((...t)=>console.error(...t)),ue=e((...t)=>console.warn(...t)),he=e((...t)=>console.debug(...t)),ce=class{constructor(){le(this,pe);le(this,de,new Map);le(this,fe,new Map)}on(t,e){return oe(this,pe,me).call(this,re(this,de),t,e)}once(t,e){return oe(this,pe,me).call(this,re(this,fe),t,e)}off(t,e){oe(this,pe,ye).call(this,re(this,de),t,e),oe(this,pe,ye).call(this,re(this,fe),t,e)}async emit(t,e){await oe(this,pe,ge).call(this,t,e)}async emitWhile(t,e,i){return oe(this,pe,ge).call(this,t,e,i)}listenerCount(t){return(re(this,de).get(t)?.size??0)+(re(this,fe).get(t)?.size??0)}removeAllListeners(t){void 0!==t?(re(this,de).delete(t),re(this,fe).delete(t)):(re(this,de).clear(),re(this,fe).clear())}eventNames(){let t=new Set;for(let e of re(this,de).keys())t.add(e);for(let e of re(this,fe).keys())t.add(e);return[...t]}},de=new WeakMap,fe=new WeakMap,pe=new WeakSet,ge=async function(t,e,i){let n=()=>i?.()??1;if(!n())return 0;let r=re(this,de).get(t);if(r)for(let i of[...r])if(!n()||(await oe(this,pe,ve).call(this,i,e,t),!n()))return 0;if(!n())return 0;let l=re(this,fe).get(t);if(l&&l.size>0){let i=[...l];re(this,fe).delete(t);for(let r of i)if(!n()||(await oe(this,pe,ve).call(this,r,e,t),!n()))return 0}return n()},me=function(t,e,i){let n=t.get(e);return n||(n=new Set,t.set(e,n)),n.add(i),()=>{oe(this,pe,ye).call(this,t,e,i)}},ye=function(t,e,i){let n=t.get(e);void 0!==n&&(n.delete(i),0===n.size&&t.delete(e))},ve=async function(t,e,i){try{await t(e)}catch(t){let e="string"==typeof i||"number"==typeof i?String(i):"<event>";ae(`[live-preview] handler for "${e}" threw:`,t)}},be="data-payload-field",we="data-payload-type",Se="data-payload-attribute",$e="data-payload-href",Ae="data-payload-src",ke="data-payload-alt",Te="data-payload-array-template",xe="data-payload-array-separator",Ne="data-payload-locale",Me="data-payload-richtext",Ce="data-payload-html",Oe="data-payload-array",je="data-payload-structural",Ie=[be,we,Se,$e,Ae,ke,Te,xe,Ne,Me,Ce,Oe,je,"type"],Ee=`[${be}]`,Re=new Set(["text","textarea","richText","email","number","checkbox","date","select","radio","array","blocks","group","tabs","row","collapsible","relationship","upload","point","json","code","ui","html","url","image","structural-array"]),_e=class{constructor(t={}){le(this,Fe);le(this,Le,new Map);le(this,We,new WeakMap);le(this,Pe);se(this,Pe,t.filter??n)}buildFromRoot(t){let e=performance.now();this.clear();let i=t.querySelectorAll(Ee),n=0;for(let t of i)void 0!==this.add(t)&&(n+=1);return{elementCount:n,fieldCount:re(this,Le).size,durationMs:performance.now()-e}}add(t){let e=re(this,Pe).call(this,t)?oe(this,Fe,Ve).call(this,t):void 0,i=re(this,We).get(t);if(void 0!==e)return void 0!==i&&oe(this,Fe,De).call(this,i,e)?(re(this,We).set(t,e),e):(void 0!==i&&oe(this,Fe,Ue).call(this,t,i),oe(this,Fe,ze).call(this,e),re(this,We).set(t,e),e);void 0!==i&&oe(this,Fe,Ue).call(this,t,i)}remove(t){let e=re(this,We).get(t);return e?oe(this,Fe,Ue).call(this,t,e):0}get(t){return re(this,Le).get(t)}getByElement(t){return re(this,We).get(t)}get fieldCount(){return re(this,Le).size}get elementCount(){let t=0;for(let e of re(this,Le).values())t+=e.length;return t}entries(){return re(this,Le).entries()}*values(){for(let t of re(this,Le).values())yield*t}has(t){return re(this,We).has(t)}clear(){re(this,Le).clear(),se(this,We,new WeakMap)}},Le=new WeakMap,We=new WeakMap,Pe=new WeakMap,Fe=new WeakSet,De=function(t,e){if(t.fieldName!==e.fieldName)return 0;let i=re(this,Le).get(t.fieldName);if(!i)return 0;let n=i.indexOf(t);return n<0?0:(i[n]=e,1)},Ue=function(t,e){let i=re(this,Le).get(e.fieldName);if(!i)return re(this,We).delete(t),0;let n=i.indexOf(e);return n<0?(re(this,We).delete(t),0):(i.splice(n,1),0===i.length&&re(this,Le).delete(e.fieldName),re(this,We).delete(t),1)},ze=function(t){let e=re(this,Le).get(t.fieldName);e?e.push(t):re(this,Le).set(t.fieldName,[t])},Ve=function(t){let e=t.getAttribute(be);if(null===e||0===e.length)return;let i=t.getAttribute(we),n=function(t){let e=t.getAttribute(we);if(null!==e&&Re.has(e))return e;if(t.hasAttribute(Me))return"richText";if(t.hasAttribute(Ce))return"html";if(t.hasAttribute(je))return"structural-array";if(t.hasAttribute(Oe))return"array";if("IMG"===t.tagName)return"image";if("A"===t.tagName)return"url";if("TIME"===t.tagName)return"date";if("INPUT"===t.tagName){let e=t.type;if("checkbox"===e)return"checkbox";if("number"===e)return"number";if("date"===e||"datetime-local"===e)return"date"}return"text"}(t),r=t.getAttribute(Se),l=t.getAttribute($e),s=t.getAttribute(Ae),o=t.getAttribute(ke),a=t.getAttribute(Te),u=t.getAttribute(xe),h=t.getAttribute(Ne);return{element:t,fieldName:e,fieldType:n,explicitFieldType:null!==i&&Re.has(i),...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==l&&l.length>0?{hrefField:l}:{},...null!==s&&s.length>0?{srcField:s}:{},...null!==o&&o.length>0?{altField:o}:{},...null!==a?{arrayTemplate:a}:{},...null!==u?{arraySeparator:u}:{},...null!==h&&h.length>0?{locale:h}:{}}},Ge=1,He=class{constructor(t,e={}){le(this,qe);ie(this,"s");this.s=[t,e.mutationDebounceMs??100,e.intersectionRootMargin??"200px",new Set,null,null,null,0]}start(t){let e=this.s[7];this.stop();let i=e+1;if(this.s[7]!==i)return;let n=null,r=null;try{n=new MutationObserver(t=>{oe(this,qe,Je).call(this,t,i)}),r=new IntersectionObserver(t=>{oe(this,qe,Be).call(this,t,i)},{rootMargin:this.s[2],threshold:0}),n.observe(t,{childList:1,subtree:1,attributes:1,attributeFilter:[...Ie]})}catch(t){throw n?.disconnect(),r?.disconnect(),t}this.s[7]===i?(this.s[4]=n,this.s[5]=r):(n.disconnect(),r.disconnect())}observeElement(t){this.s[5]?.observe(t)}unobserveElement(t){this.s[5]?.unobserve(t),this.s[3].delete(t)}markVisible(t,e){e?this.s[3].add(t):this.s[3].delete(t)}isVisible(t){return this.s[3].has(t)}stop(){this.s[7]+=1;let t=this.s[6],e=this.s[4],i=this.s[5];this.s[6]=null,this.s[4]=null,this.s[5]=null,this.s[3].clear(),null!==t&&clearTimeout(t);try{e?.disconnect()}finally{i?.disconnect()}}},qe=new WeakSet,Je=function(t,e){if(!oe(this,qe,Xe).call(this,e)||!function(t){for(let e of t){if("attributes"===e.type&&null!==e.attributeName&&Ie.includes(e.attributeName)&&(e.attributeName===be||e.target.nodeType===Ge&&e.target.hasAttribute(be)))return 1;for(let t of e.addedNodes)if(r(t))return 1;for(let t of e.removedNodes)if(r(t))return 1}return 0}(t)||!oe(this,qe,Xe).call(this,e))return;null!==this.s[6]&&clearTimeout(this.s[6]);let i=setTimeout(()=>{!oe(this,qe,Xe).call(this,e)||this.s[6]!==i||(this.s[6]=null,this.s[0].onStructuralChange())},this.s[1]);this.s[6]=i},Be=function(t,e){for(let i of t){if(!oe(this,qe,Xe).call(this,e))return;let t=i.target;if(i.isIntersecting){if(!this.s[3].has(t)&&(this.s[3].add(t),this.s[0].onVisibilityChange(t,1),!oe(this,qe,Xe).call(this,e)))return}else if(this.s[3].has(t)&&(this.s[3].delete(t),this.s[0].onVisibilityChange(t,0),!oe(this,qe,Xe).call(this,e)))return}},Xe=function(t){return this.s[7]===t&&null!==this.s[5]},Ye={basic:1,"schema-json":2,"preview-token":3,"nested-arrays":4,"recursive-diffs":4},Ze=class{constructor(t,e){le(this,Ke);ie(this,"s");this.s=[t,e,void 0,void 0,0,0,[],0]}attach(t=window){if(void 0!==this.s[3])return;let e=0,i=t=>{if(!e||this.s[2]!==i)return;let n=this.s[4];try{oe(this,Ke,Qe).call(this,t,n)}catch{let e="";try{e=t.origin}catch{}oe(this,Ke,ri).call(this,"shape",e,n)}};this.s[4]+=1,oe(this,Ke,ui).call(this),this.s[3]=t,this.s[2]=i;try{t.addEventListener("message",i)}catch(e){this.s[2]===i&&(this.s[3]=void 0,this.s[2]=void 0,oe(this,Ke,ui).call(this));try{t.removeEventListener("message",i)}catch{}throw e}if(this.s[2]===i)e=1;else try{t.removeEventListener("message",i)}catch{}}detach(t){let e=this.s[3],i=this.s[2];void 0===e||void 0===i||(this.s[3]=void 0,this.s[2]=void 0,oe(this,Ke,ui).call(this),e.removeEventListener("message",i))}advanceGeneration(){return void 0===this.s[3]?0:(this.s[4]+=1,oe(this,Ke,ui).call(this),1)}static sendReady(t,e){let i=t.length>0;if(!i||0===e.length)return;let n={type:"payload-live-preview",ready:i,protocolVersion:4};for(let i of t)for(let t of e)try{i.postMessage(n,t)}catch{}}},Ke=new WeakSet,Qe=function(t,e){if(!oe(this,Ke,oi).call(this,e))return;let i=t.origin;if(!oe(this,Ke,oi).call(this,e))return;if(!oe(this,Ke,li).call(this,i,e)){oe(this,Ke,ri).call(this,"origin",i,e);return}let n=t.data;if(!oe(this,Ke,oi).call(this,e))return;let r=function(t){return"object"==typeof t&&null!==t&&"type"in t?"string"==typeof t.type:0}(n);if(!oe(this,Ke,oi).call(this,e))return;if(!r){oe(this,Ke,ri).call(this,"shape",i,e);return}let s=n.type;if(oe(this,Ke,oi).call(this,e))switch(s){case"payload-live-preview":{let t=function(t){let e=t;return!!((void 0===e.data||null===e.data||h(e.data))&&u(e.fieldSchemaJSON,t=>Array.isArray(t))&&u(e.globalSlug,t=>"string"==typeof t)&&u(e.collectionSlug,t=>"string"==typeof t)&&u(e.locale,t=>"string"==typeof t)&&u(e.ready,t=>"boolean"==typeof t)&&u(e.previewToken,t=>"string"==typeof t)&&u(e.protocolVersion,t=>"number"==typeof t))}(n);if(!oe(this,Ke,oi).call(this,e))return;if(!t){oe(this,Ke,ri).call(this,"shape",i,e);return}let r=function(t){let e={...t};for(let t of hi)null===Reflect.get(e,t)&&Reflect.deleteProperty(e,t);if(!Array.isArray(e.fieldSchemaJSON))return e;let i;try{i=l(e.fieldSchemaJSON)}catch{i=[]}return{...e,fieldSchemaJSON:i}}(n);if(!oe(this,Ke,oi).call(this,e))return;oe(this,Ke,ti).call(this,r,i,e);return}case"payload-document-event":{let t=function(t){let e=t;return!(!a(e.action,t=>"updated"===t||"created"===t||"deleted"===t)||!a(e.slug,t=>"string"==typeof t)||!a(e.id,t=>"string"==typeof t||"number"==typeof t&&Number.isFinite(t)))}(n);if(!oe(this,Ke,oi).call(this,e))return;if(!t){oe(this,Ke,ri).call(this,"shape",i,e);return}let r;try{r=this.s[1].onDocumentEvent}catch{return}if(!oe(this,Ke,oi).call(this,e))return;oe(this,Ke,si).call(this,r,n,i);return}default:oe(this,Ke,ri).call(this,"type",i,e)}},ti=function(t,e,i){if(!oe(this,Ke,oi).call(this,i))return;let n=t.data;if(!oe(this,Ke,oi).call(this,i))return;let r=h(n);if(!oe(this,Ke,oi).call(this,i))return;let l,s=r?{generation:i,revision:this.s[5]+=1}:void 0;try{l=this.s[1].validateToken}catch{return}if(!oe(this,Ke,oi).call(this,i))return;if(void 0===l){oe(this,Ke,ni).call(this,t,e,i,s);return}if(1==t.ready&&void 0===n){oe(this,Ke,ni).call(this,t,e,i,void 0);return}let o={generation:i,message:t,origin:e,messageRevision:s,settled:0,approved:0};this.s[6].push(o);let a;try{a=l(t.previewToken,e)}catch{oe(this,Ke,ei).call(this,o,0);return}"boolean"!=typeof a?Promise.resolve(a).then(t=>{oe(this,Ke,ei).call(this,o,1==t)},()=>{oe(this,Ke,ei).call(this,o,0)}):oe(this,Ke,ei).call(this,o,a)},ei=function(t,e){oe(this,Ke,oi).call(this,t.generation)&&(t.approved=e,t.settled=1,oe(this,Ke,ii).call(this,t.generation))},ii=function(t){for(;oe(this,Ke,oi).call(this,t);){let e=this.s[6][this.s[7]];if(void 0===e)return;if(oe(this,Ke,li).call(this,e.origin,t)){if(!e.settled)return;oe(this,Ke,ai).call(this,e)&&(e.approved?oe(this,Ke,ni).call(this,e.message,e.origin,e.generation,e.messageRevision):oe(this,Ke,ri).call(this,"token",e.origin,e.generation))}else{if(!oe(this,Ke,ai).call(this,e))continue;oe(this,Ke,ri).call(this,"origin",e.origin,e.generation)}}},ni=function(t,e,i,n){if(!oe(this,Ke,oi).call(this,i))return;let r;try{r=this.s[1].onUpdate}catch{return}oe(this,Ke,oi).call(this,i)&&(void 0===n?oe(this,Ke,si).call(this,r,t,e):oe(this,Ke,si).call(this,r,t,e,n))},ri=function(t,e,i){if(!oe(this,Ke,oi).call(this,i))return;let n;try{n=this.s[1].onInvalid}catch{return}oe(this,Ke,oi).call(this,i)&&void 0!==n&&oe(this,Ke,si).call(this,n,t,e)},li=function(t,e){if(!oe(this,Ke,oi).call(this,e))return 0;try{return 1==this.s[0](t)&&oe(this,Ke,oi).call(this,e)}catch{return 0}},si=function(e,...i){try{t(e(...i))}catch{}},oi=function(t){return void 0!==this.s[3]&&this.s[4]===t},ai=function(t){let e=this.s;return e[6][e[7]]!==t?0:(e[7]+=1,e[7]===e[6].length?(oe(this,Ke,ui).call(this),1):(e[7]>=1024&&2*e[7]>=e[6].length&&(e[6]=e[6].slice(e[7]),e[7]=0),1))},ui=function(){this.s[6]=[],this.s[7]=0},hi=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],ci=class{constructor(t){ie(this,"s");this.s=[t.timeoutMs??0,t.onTimeout,null,0]}kick(){if(this.s[3]=Date.now(),this.s[0]<=0)return;null!==this.s[2]&&clearTimeout(this.s[2]);let t=setTimeout(()=>{this.s[2]===t&&(this.s[2]=null,this.s[1]())},this.s[0]);this.s[2]=t}stop(){null!==this.s[2]&&(clearTimeout(this.s[2]),this.s[2]=null)}get lastKickAt(){return this.s[3]}get pending(){return null!==this.s[2]}},di=class{constructor(t){ie(this,"s");this.s=["disconnected",t]}get status(){return this.s[0]}markConnected(){return this.transition("connected")}markConnecting(){return this.transition("connecting")}markDisconnected(){return this.transition("disconnected")}transition(t){if(this.s[0]===t)return 0;let e=this.s[0];return this.s[0]=t,this.s[1](t,e),1}},fi=class{constructor(t){ie(this,"s");let n=t.serverURL.replace(/\\/+$/,""),r=t.apiRoute??"/api";this.s=[n,r.startsWith("/")?r:`/${r}`,t.depth??1,t.fetchFn,void 0===t.log?i:e(t.log),null,0,0]}canMerge(t){try{return t.globalSlug?d(t.globalSlug):d(t.collectionSlug)?function(t){if("number"==typeof t)return Number.isFinite(t);if("string"!=typeof t||0===t.length||t.length>512||"."===t||".."===t||t.includes("/")||t.includes("\\\\")||c(t))return 0;try{return encodeURIComponent(t),1}catch{return 0}}(t.data.id):0}catch{return 0}}async merge(t){if(this.s[7]>0)return{status:"superseded"};let e=this.s[6]+1;this.s[6]=e;let i=this.s[5];this.s[5]=null;let n=null;try{if(i?.abort(),!f(this.s,e))return{status:"superseded"};if(!this.canMerge(t))return f(this.s,e)?{status:"unavailable"}:{status:"superseded"};if(!f(this.s,e))return{status:"superseded"};let r=this.s[3]??("function"==typeof fetch?fetch:void 0);if(!f(this.s,e))return{status:"superseded"};if(void 0===r)return{status:"unavailable"};if(n=new AbortController,!f(this.s,e))return n.abort(),{status:"superseded"};this.s[5]=n;let l=t.globalSlug?`globals/${encodeURIComponent(t.globalSlug)}`:`${encodeURIComponent(t.collectionSlug??"")}/${encodeURIComponent(String(t.data.id))}`,s=`${this.s[0]}${this.s[1]}/${l}`,o=JSON.stringify({data:t.data,depth:this.s[2],flattenLocales:0,...void 0!==t.locale?{locale:t.locale}:{}});if(!f(this.s,e))return{status:"superseded"};let a=await r(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:o,signal:n.signal});if(!f(this.s,e)||p(n.signal))return{status:"superseded"};let u=a.ok;if(!f(this.s,e))return{status:"superseded"};if(!u){let t=a.status;return f(this.s,e)?(this.s[4]("merge HTTP",t,s),f(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"superseded"}}let h=await a.json();return!f(this.s,e)||p(n.signal)?{status:"superseded"}:null===h||"object"!=typeof h||Array.isArray(h)?(this.s[4]("merge invalid",s),f(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"merged",doc:h}}catch(t){return!f(this.s,e)||null!==n&&p(n.signal)?{status:"superseded"}:(this.s[4]("merge exception",t),f(this.s,e)?{status:"unavailable"}:{status:"superseded"})}finally{null!==n&&f(this.s,e)&&this.s[5]===n&&(this.s[5]=null)}}destroy(){this.s[6]+=1;let t=this.s[5];this.s[5]=null,this.s[7]+=1;try{t?.abort()}finally{this.s[7]-=1}}},pi=new Set(["http:","https:","mailto:","tel:"]),gi=/^\\s*(?:javascript|data|vbscript|file|blob|about)\\s*:/i,mi=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,yi=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),vi=new Set(["href","src","poster","cite","action","xlink:href","data"]),bi=new WeakSet,wi=class{constructor(t,e){le(this,Si);ie(this,"s");let i=e.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):t=>setTimeout(()=>{t(performance.now())},0)),n=e.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):t=>{clearTimeout(t)});this.s=[t,e.debounceMs??50,e.isVisible,e.visibilityGateThreshold??50,e.disableVisibilityGate??0,e.getCacheSize,e.onFlush,i,n,new Map,new Map,new Set,null,0,null,0,null,0]}schedule(t){if(void 0!==t.identity&&(this.s[17]||!v(t.identity,this.s[16])))return;let e=this.s[9],i=e.get(t.target.element);i?(i.value=t.value,i.allFields=t.allFields,i.identity=t.identity,i.data=t.data):e.set(t.target.element,{...t,identity:t.identity,data:t.data}),oe(this,Si,$i).call(this)}acceptRevision(t){let e=this.s[16];v(t,e)||null!==e&&function(t,e){return t.generation!==e.generation?t.generation-e.generation:t.revision-e.revision}(t,e)<0||(oe(this,Si,Oi).call(this),oe(this,Si,Mi).call(this),this.s[16]=t,this.s[17]=0)}cancelRevision(t){v(t,this.s[16])&&(oe(this,Si,Oi).call(this),oe(this,Si,Mi).call(this),this.s[17]=1)}flushNow(){return oe(this,Si,Oi).call(this),oe(this,Si,ki).call(this)}notifyVisible(t){let e=this.s[10],i=e.get(t);if(!i||(e.delete(t),!oe(this,Si,Ti).call(this,i)))return;let n=performance.now(),r=oe(this,Si,xi).call(this,i)?1:0;this.s[6]?.(oe(this,Si,Ci).call(this,i,r,0,performance.now()-n))}retarget(t){oe(this,Si,Ni).call(this,this.s[9],t),oe(this,Si,Ni).call(this,this.s[10],t);for(let e of this.s[11])oe(this,Si,Ni).call(this,e,t)}forget(t){this.s[9].delete(t),this.s[10].delete(t);for(let e of this.s[11])e.delete(t)}destroy(){oe(this,Si,Oi).call(this),oe(this,Si,Mi).call(this),this.s[16]=null,this.s[17]=0}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}},Si=new WeakSet,$i=function(){let t=this.s[13]+=1,e=this.s[12];if(this.s[12]=null,null!==e&&clearTimeout(e),this.s[13]!==t)return;let i=setTimeout(()=>{this.s[13]===t&&(this.s[12]=null,oe(this,Si,Ai).call(this))},this.s[1]);this.s[13]===t&&(this.s[12]=i)},Ai=function(){let t=this.s[15]+=1,e=this.s[14];if(this.s[14]=null,null!==e&&this.s[8](e),this.s[15]!==t)return;let i=0,n=this.s[7](()=>{this.s[15]===t&&(i=1,this.s[14]=null,oe(this,Si,ki).call(this))});!i&&this.s[15]===t&&(this.s[14]=n)},ki=function(){let t=performance.now(),e=!this.s[4]&&this.s[5]()>this.s[3],i=this.s[9];this.s[9]=new Map;let n,r=0,l=0;this.s[11].add(i);try{for(let t of i.values()){if(!oe(this,Si,Ti).call(this,t))continue;let i=!e||this.s[2](t.target.element);if(oe(this,Si,Ti).call(this,t)){if(n??(n=t),!i){this.s[10].set(t.target.element,t),l+=1;continue}this.s[10].delete(t.target.element),oe(this,Si,xi).call(this,t)&&(r+=1)}}}finally{this.s[11].delete(i)}let s=oe(this,Si,Ci).call(this,n,r,l,performance.now()-t);return this.s[6]?.(s),s},Ti=function(t){return void 0===t.identity||!this.s[17]&&v(t.identity,this.s[16])},xi=function(t){let e=this.s[0];return 0!=e(t)||!function(t){return bi.has(t)}(e)},Ni=function(t,e){let i=t.get(e.element);if(void 0!==i){if(i.target.fieldName!==e.fieldName||i.target.locale!==e.locale){t.delete(e.element);return}i.target=e}},Mi=function(){this.s[9].clear(),this.s[10].clear();for(let t of this.s[11])t.clear()},Ci=function(t,e,i,n){return{applied:e,deferred:i,durationMs:n,...void 0!==t?.identity?{identity:t.identity}:{},...void 0!==t?.data?{data:t.data}:{}}},Oi=function(){let t=this.s[12],e=this.s[14];this.s[13]+=1,this.s[15]+=1,this.s[12]=null,this.s[14]=null,null!==t&&clearTimeout(t),null!==e&&this.s[8](e)},ji=new Set(["__proto__","prototype","constructor"]),Ii="payload-live-preview-a11y",Ei=new WeakMap,Ri=class{constructor(t,e){ie(this,"s");let i=e??(typeof document>"u"?null:document),n=i?.documentElement.getAttribute("lang")??"";this.s=[$(t??(n.length>0?n:S())),i,null]}mount(){let t=this.s[1];if(null==t?.body)return null;let e=this.s[2];null===e&&(e=function(t){let e=Ei.get(t);return e??(e=[null,0,null,0,null]),Ei.set(t,e),e[3]+=1,e}(t),this.s[2]=e);let i=e[0];if(i?.isConnected&&i.ownerDocument===t)return i;if(null!==i){let t=e[1];A(e),t&&i.remove()}let n=t.getElementById(Ii);return e[1]=null===n,n||(n=t.createElement("div"),n.id=Ii,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0"),t.body.appendChild(n)),e[0]=n,n}announceConnected(){this.say(this.s[0]?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.s[0]?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(t){t<=0||this.say(this.s[0]?`${String(t)} ${1===t?"\\xc4nderung":"\\xc4nderungen"} angewendet`:`${String(t)} ${1===t?"change":"changes"} applied`)}detach(){let t=this.s[2],e=this.s[1];if(null===t||null===e||(this.s[2]=null,t[3]-=1,t[3]>0))return;let i=t[0];null!==i&&A(t),t[1]&&i?.remove(),t[0]=null,Ei.delete(e)}say(t){let e=this.mount(),i=this.s[2];if(null===e||null===i)return;let n=i[2];n?.parentNode!==e?(n?.remove(),n=e.ownerDocument.createTextNode(e.hasChildNodes()?` ${t}`:t),i[2]=n,e.appendChild(n)):n.data=null===n.previousSibling?t:` ${t}`,null!==i[4]&&clearTimeout(i[4]);let r=setTimeout(()=>{i[4]===r&&i[0]===e&&A(i)},1500);i[4]=r}},_i=new Set(["tabs","row","collapsible"]),Li={text:"text",textarea:"textarea",richText:"richText",email:"email",number:"number",checkbox:"checkbox",date:"date",select:"select",radio:"radio",array:"array",blocks:"blocks",group:"text",tabs:"text",row:"text",collapsible:"text",relationship:"relationship",upload:"upload",point:"text",json:"text",code:"text",ui:"text"},Wi=[0,500,1e3,2e3],Pi=class{constructor(t){le(this,Fi);ie(this,"d");ie(this,"l");let n=t.emitter,r=t.renderers,l=t.resolveRenderer??(t=>r[t]),s=t.transformValue,a=t.root??(typeof document<"u"?document:null),u=t.readyTargets,h=t.sendReady??j,c=t.onHeartbeatTimeout,d=void 0===t.log?i:e(t.log),f=void 0===t.warn?ue:e(t.warn),p=function(t){if(0==t.enableA11y)return null;let e=void 0===t.root?void 0:9===t.root.nodeType?t.root:t.root.ownerDocument;return new Ri(t.a11yLocale,e)}(t),g=void 0!==t.dataMerge?new fi({serverURL:t.dataMerge.serverURL,...void 0!==t.dataMerge.apiRoute?{apiRoute:t.dataMerge.apiRoute}:{},...void 0!==t.dataMerge.depth?{depth:t.dataMerge.depth}:{},...void 0!==t.dataMerge.fetchFn?{fetchFn:t.dataMerge.fetchFn}:{},log:(...t)=>{d(...t)}}):null,m=new _e,v=new He({onStructuralChange:()=>{oe(this,Fi,Hi).call(this)},onVisibilityChange:(t,e)=>{e&&this.d[3].notifyVisible(t)}},{...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{}}),b=new wi(y(t=>oe(this,Fi,tn).call(this,t)),{...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.disableVisibilityGate?{disableVisibilityGate:t.disableVisibilityGate}:{},...void 0!==t.visibilityGateThreshold?{visibilityGateThreshold:t.visibilityGateThreshold}:{},isVisible:t=>v.isVisible(t),getCacheSize:()=>m.elementCount,onFlush:t=>{oe(this,Fi,en).call(this,t)}}),w=new Ze(t.originMatcher,{onUpdate:(t,e,i)=>{oe(this,Fi,Ji).call(this,t,e,i)},onDocumentEvent:()=>{n.emit("documentSave",{timestamp:Date.now()})},onInvalid:(t,e)=>{if("token"===t){let t=new Error(`Preview token rejected (origin: ${e})`);n.emit("error",{error:t,context:"token"})}d("message rejected:",t,e)},...void 0!==t.validateToken?{validateToken:t.validateToken}:{}}),S=new di(()=>{}),$=new ci({...void 0!==t.heartbeatMs?{timeoutMs:t.heartbeatMs}:{},onTimeout:()=>{oe(this,Fi,nn).call(this)}});this.d=[n,m,v,b,w,S,$,r,l,s,a,u,h,c,d,f,[],p,g],this.l=[void 0,void 0,void 0,o(void 0),0,null,0,null,new Set]}start(){if(this.l[4])return 0;this.l[4]=1;let t=this.d[10];if(O(t)&&"loading"===t.readyState){let e=()=>{if(this.l[4]){this.l[5]=null;try{oe(this,Fi,Di).call(this)}catch(t){oe(this,Fi,zi).call(this),oe(this,Fi,ln).call(this,t,"startup")}}};this.l[5]=e;try{t.addEventListener("DOMContentLoaded",e,{once:1})}catch(t){throw oe(this,Fi,zi).call(this),t}return 1}try{return oe(this,Fi,Di).call(this),1}catch(t){throw oe(this,Fi,zi).call(this),t}}destroy(){this.l[4]&&(oe(this,Fi,Ui).call(this)&&this.d[0].emit("disconnect",{reason:"destroy",timestamp:Date.now()}),this.d[17]?.detach(),this.d[0].emit("destroy",{timestamp:Date.now()}))}refreshCache(){this.l[4]&&oe(this,Fi,Hi).call(this)}get status(){return this.d[5].status}get cache(){return this.d[1]}get updateCount(){return this.l[6]}get protocol(){return this.l[3]}},Fi=new WeakSet,Di=function(){if(!this.l[4])return;let t=O(this.d[10])?function(t){return t.body}(this.d[10]):this.d[10];if(null===t)throw new Error("LivePreviewRuntime: document.body unavailable");if(this.d[2].start(t),oe(this,Fi,Gi).call(this),oe(this,Fi,Qi).call(this)&&(this.d[4].attach(),this.d[0].emitWhile("init",{timestamp:Date.now()},()=>this.l[4]),oe(this,Fi,Qi).call(this)))for(let t of Wi){if(!oe(this,Fi,Qi).call(this))return;if(0===t){if(this.d[12](this.d[11]),!oe(this,Fi,Qi).call(this))return}else{let e=setTimeout(()=>{this.l[4]&&oe(this,Fi,rn).call(this)},t);this.d[16].push(e)}}},Ui=function(){this.l[7]=null,this.l[4]=0;let t=this.l[5];this.l[5]=null,null!==t&&O(this.d[10])&&oe(this,Fi,Vi).call(this,()=>{this.d[10].removeEventListener("DOMContentLoaded",t)});for(let t of this.d[16])oe(this,Fi,Vi).call(this,()=>{clearTimeout(t)});return this.d[16].length=0,oe(this,Fi,Vi).call(this,()=>{this.d[6].stop()}),oe(this,Fi,Vi).call(this,()=>{this.d[4].detach()}),oe(this,Fi,Vi).call(this,()=>{this.d[2].stop()}),oe(this,Fi,Vi).call(this,()=>{this.d[3].destroy()}),oe(this,Fi,Vi).call(this,()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()},zi=function(){oe(this,Fi,Ui).call(this),oe(this,Fi,Vi).call(this,()=>{this.d[17]?.detach()})},Vi=function(t){try{t()}catch(t){this.d[14]("cleanup failed:",t)}},Gi=function(){if(!this.l[4])return;let t=this.d[1].buildFromRoot(this.d[10]);if(this.d[14]("cache",t),oe(this,Fi,Qi).call(this)&&(this.d[0].emitWhile("cacheRefresh",t,()=>this.l[4]),oe(this,Fi,Qi).call(this)))for(let t of this.d[1].values()){if(!oe(this,Fi,Qi).call(this))return;this.d[2].observeElement(t.element)}},Hi=function(){if(!this.l[4])return;let t=new Map;for(let e of this.d[1].values())t.set(e.element,e),this.d[2].unobserveElement(e.element);if(oe(this,Fi,Gi).call(this),oe(this,Fi,Qi).call(this)){for(let e of this.d[1].values())t.get(e.element)?.fieldName===e.fieldName?this.d[3].retarget(e):this.d[3].forget(e.element),t.delete(e.element);for(let e of t.values())this.d[3].forget(e.element)}},qi=function(t){let e=o(t);e.negotiated!==this.l[3].negotiated&&(this.l[3]=e,this.d[14]("protocol","ours=4",`theirs=${t}`,`negotiated=${e.negotiated}`))},Ji=function(t,e,i){if(this.d[6].kick(),void 0===t.data){void 0!==t.protocolVersion&&oe(this,Fi,qi).call(this,t.protocolVersion);return}if(void 0===i)return;"string"==typeof t.locale&&(this.l[0]=t.locale),Array.isArray(t.fieldSchemaJSON)&&(this.l[1]=t.fieldSchemaJSON,this.l[2]=k(t.fieldSchemaJSON));let n={identity:i,message:t,locale:this.l[0],schema:this.l[1],schemaIndex:this.l[2],cancelled:0};this.l[7]=n,this.d[3].acceptRevision(i),this.l[6]+=1,(void 0===t.protocolVersion||(oe(this,Fi,qi).call(this,t.protocolVersion),this.l[4]&&this.l[7]===n))&&(this.d[5].markConnected()&&(this.d[17]?.announceConnected(),this.d[0].emit("connect",{origin:e,timestamp:Date.now()}),!this.l[4]||this.l[7]!==n||(this.d[14]("connection","disconnected","\\u2192","connected"),!this.l[4]||this.l[7]!==n))||oe(this,Fi,Bi).call(this,n))},Bi=async function(t){let e=await oe(this,Fi,Xi).call(this,t);if(null===e||!this.l[4]||this.l[7]!==t)return;let{message:i}=t,n={fields:e,...void 0!==t.schema?{schema:t.schema}:{},..."string"==typeof i.globalSlug?{globalSlug:i.globalSlug}:{},..."string"==typeof i.collectionSlug?{collectionSlug:i.collectionSlug}:{},...void 0!==t.locale?{locale:t.locale}:{}};this.d[0].listenerCount("beforeUpdate")>0&&(!await this.d[0].emitWhile("beforeUpdate",{data:n,revision:t.identity.revision,cancel:()=>{t.cancelled=1,this.d[3].cancelRevision(t.identity)}},()=>!t.cancelled&&this.l[4]&&this.l[7]===t)||t.cancelled||!this.l[4]||this.l[7]!==t)||this.l[4]&&this.l[7]===t&&oe(this,Fi,Yi).call(this,t,n)},Xi=async function(t){let{message:e}=t,i=e.data??{};if(null===this.d[18])return i;let n=await this.d[18].merge({collectionSlug:e.collectionSlug,globalSlug:e.globalSlug,data:i,locale:t.locale});return this.l[4]&&this.l[7]===t?"merged"===n.status?n.doc:"superseded"===n.status?null:i:null},Yi=function(t,e){if(!this.l[4]||this.l[7]!==t)return;let i=()=>this.l[4]&&this.l[7]===t;for(let[n,r]of this.d[1].entries()){if(!this.l[4]||this.l[7]!==t)return;for(let l of r){let r=b(e.fields,n,l.locale??t.locale,void 0!==l.locale);if(void 0===r)continue;if(!this.l[4]||this.l[7]!==t)return;let s=oe(this,Fi,Ki).call(this,l,r,e.fields,i);if(!this.l[4]||this.l[7]!==t)return;let o={target:l,value:s,allFields:e.fields,identity:t.identity,data:e};if(!this.l[4]||this.l[7]!==t)return;this.d[3].schedule(o)}}oe(this,Fi,Zi).call(this,e.fields,t.locale)},Zi=function(t,e){if(0===this.d[1].fieldCount)return;let i;for(let[n,r]of Object.entries(t)){if(this.l[8].has(n)||on.has(n)||!E(r))continue;let t=R(n,e);if(void 0===this.d[1].get(n)&&(t===n||void 0===this.d[1].get(t))){if(void 0===i){i=new Set;for(let[t,e]of this.d[1].entries())for(let n of e)void 0!==n.locale&&i.add(`${t}_${n.locale}`)}i.has(n)||(this.l[8].add(n),this.d[15](`[live-preview] update arrived for field "${n}" but no <\\u2026 data-payload-field="${t}"> element exists on this page. Render the binding anchor unconditionally in your template so live edits to an initially-empty field have somewhere to land.`))}}},Ki=function(e,i,n,r){if(void 0===this.d[9])return i;try{let l=this.d[9](e.fieldName,i,{element:e.element,allFields:n},r),s=t(l);if(!r())return i;if(s)throw new TypeError(`Transform for "${e.fieldName}" returned a Promise/thenable; transforms must be synchronous`);return l}catch(t){if(!r())return i;let e=t instanceof Error?t:new Error(String(t));return this.d[0].emit("error",{error:e,context:"transform"}),i}},Qi=function(){return this.l[4]},tn=function(t){let e=this.l[7];if(null===e||void 0===t.identity||!I(e.identity,t.identity)||!this.l[4]||this.l[7]!==e)return 0;let i=void 0!==e.schemaIndex?function(t,e){if(t.has(e))return t.get(e);let i=e.replace(/\\.\\d+(?=\\.|$)/g,".*");return t.has(i)?t.get(i):void 0}(e.schemaIndex,t.target.fieldName):void 0,n=t.value,r=function(t,e){if(t.explicitFieldType)return t.fieldType;if(void 0!==e){let t=function(t){if(Object.prototype.hasOwnProperty.call(Li,t))return Li[t]}(e);if(void 0!==t)return t}return t.fieldType}(t.target,i?.type);"text"===r&&1!=t.target.explicitFieldType&&function(t){if("object"!=typeof t||null===t||!("root"in t))return 0;let e=t.root;return"object"!=typeof e||null===e?0:Array.isArray(e.children)}(n)&&(r="richText");let l;try{l=this.d[8](r)}catch(t){if(!this.l[4]||this.l[7]!==e)return 0;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:i,context:"renderer"},()=>this.l[4]&&this.l[7]===e),0}if(!this.l[4]||this.l[7]!==e)return 0;let s=this.d[0].listenerCount("elementUpdate")>0,o=s?function(t){return"INPUT"===t.tagName||"TEXTAREA"===t.tagName?t.value:"IMG"===t.tagName?t.src:t.textContent}(t.target.element):void 0;if(!this.l[4]||this.l[7]!==e)return 0;let a={allFields:t.allFields,locale:t.target.locale??e.locale,schema:i};try{if(void 0!==t.target.targetAttribute){if("blocked"===function(t,e,i){let n=e.toLowerCase().trim();if(0===n.length||n.startsWith("on")||yi.has(n))return"blocked";if(null==i)return t.removeAttribute(n),"applied";if("string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i)return"blocked";let r=String(i);return vi.has(n)&&!g(r)?"blocked":(t.setAttribute(n,r),"applied")}(t.target.element,t.target.targetAttribute,n))return this.d[15](`[live-preview] refused to write field "${t.target.fieldName}" into attribute "${t.target.targetAttribute}" (unsafe attribute or value)`),0}else{if(!l)return this.d[14]("no renderer for",r),0;if(0==function(t,e,i,n){return t.render(e,i,n)}(l,t.target,n,a)&&function(t){return bi.has(t.render)}(l))return 0}}catch(t){if(!this.l[4]||this.l[7]!==e)return 0;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:i,context:"renderer"},()=>this.l[4]&&this.l[7]===e),0}return this.l[4]&&this.l[7]===e?(s&&this.d[0].emitWhile("elementUpdate",{element:t.target.element,fieldName:t.target.fieldName,previousValue:o,nextValue:n,revision:e.identity.revision},()=>this.l[4]&&this.l[7]===e),this.l[4]&&this.l[7]===e):0},en=function(t){let{identity:e,data:i}=t;if(0===t.applied||void 0===e||void 0===i)return;let n=this.l[7];if(null===n||!this.l[4]||this.l[7]!==n||!I(n.identity,e))return;let r=()=>this.l[4]&&this.l[7]===n&&I(n.identity,e);this.d[17]?.announceUpdate(t.applied),r()&&0!==this.d[0].listenerCount("afterUpdate")&&this.d[0].emitWhile("afterUpdate",{data:i,updatedCount:t.applied,durationMs:t.durationMs,revision:e.revision},r)},nn=function(){if(!oe(this,Fi,Qi).call(this))return;this.d[4].advanceGeneration();let t=this.l[7];this.l[7]=null,null!==t&&this.d[3].cancelRevision(t.identity),this.d[18]?.destroy();let e=this.d[5].markDisconnected();try{this.d[13]?.()}catch(t){this.d[14]("heartbeat:",t)}oe(this,Fi,Qi).call(this)&&(e&&oe(this,Fi,sn).call(this)&&(this.d[17]?.announceDisconnected(),this.d[0].emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>oe(this,Fi,sn).call(this)),!oe(this,Fi,Qi).call(this)||oe(this,Fi,sn).call(this)&&(this.d[14]("connection","connected","\\u2192","disconnected"),!oe(this,Fi,Qi).call(this)))||oe(this,Fi,Qi).call(this)&&oe(this,Fi,rn).call(this))},rn=function(){try{this.d[12](this.d[11])}catch(t){oe(this,Fi,ln).call(this,t,"ready")}},ln=function(t,e){let i=t instanceof Error?t:new Error(String(t));this.d[0].emit("error",{error:i,context:e})},sn=function(){return this.l[4]&&"disconnected"===this.d[5].status&&null===this.l[7]},on=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),an=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,un=/^https?:\\/\\/[^/?#\\s]+$/i,hn=["PAYLOAD_ADMIN_ORIGIN","PUBLIC_PAYLOAD_ADMIN_ORIGIN","NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN"],cn=class{constructor(t={}){le(this,dn);let e=new Set;for(let i of t.additionalOrigins??[]){let t=W(i);void 0!==t&&e.add(t)}for(let t of hn){let i=L(t);if(void 0!==i)for(let t of i.split(",")){let i=W(t);void 0!==i&&e.add(i)}}let i;if(t.enableReferrerDetection??1){let e=t.referrer??(typeof document<"u"?document.referrer:"");if(e.length>0)try{let t=new URL(e).origin;t&&"null"!==t&&(i=t)}catch{}}let n=(t.enableLocalhostMatching??1)&&(t.forceDevMode??function(){let t=function(){if(!(typeof process>"u"))return"production"}();if(void 0!==t)return"production"!==t;0;if(typeof window<"u"){let t=window.location.hostname;if("localhost"===t||"127.0.0.1"===t)return 1}return 0}());se(this,dn,[e,i,n,void 0!==i,void 0])}matches(t){return 0===t.length||"null"===t?0:void 0!==re(this,dn)[4]?t===re(this,dn)[4]:!!(re(this,dn)[0].has(t)||0===re(this,dn)[0].size&&void 0!==re(this,dn)[1]&&t===re(this,dn)[1]||re(this,dn)[2]&&an.test(t))}lockOrigin(t){return this.matches(t)?(re(this,dn)[4]=t,1):0}unlockOrigin(){let t=re(this,dn)[4];return re(this,dn)[4]=void 0,t}get lockedOrigin(){return re(this,dn)[4]}enumerate(){if(void 0!==re(this,dn)[4])return[re(this,dn)[4]];let t=new Set(re(this,dn)[0]);if(0===re(this,dn)[0].size&&void 0!==re(this,dn)[1]&&t.add(re(this,dn)[1]),re(this,dn)[2])for(let e of fn)t.add(`http://localhost:${String(e)}`),t.add(`http://127.0.0.1:${String(e)}`);return[...t]}get referrerWasAvailable(){return re(this,dn)[3]}get isProductionUnconfigured(){return!(!_()||re(this,dn)[0].size>0||re(this,dn)[2]||void 0!==re(this,dn)[1])}get isReferrerOnlyTrust(){return re(this,dn)[0].size>0||re(this,dn)[2]?0:void 0!==re(this,dn)[1]}},dn=new WeakMap,fn=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],pn=new Set(["p","br","strong","b","em","i","u","s","strike","mark","small","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","blockquote","code","pre","kbd","samp","var","a","span","div","section","article","aside","header","footer","nav","figure","figcaption","img","picture","source","audio","video","sub","sup","hr","time","abbr","cite","q","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col"]),gn=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),mn=new Set(["id","class","lang","dir","title","role","tabindex"]),yn="aria-",vn="data-",bn={a:new Set(["href","target","rel","download","hreflang","type"]),img:new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:new Set([]),source:new Set(["src","srcset","sizes","type","media"]),audio:new Set(["src","controls","autoplay","loop","muted","preload"]),video:new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:new Set(["datetime"]),abbr:new Set(["title"]),q:new Set(["cite"]),blockquote:new Set(["cite"]),table:new Set(["summary"]),th:new Set(["colspan","rowspan","scope","headers","abbr"]),td:new Set(["colspan","rowspan","headers"]),col:new Set(["span"]),colgroup:new Set(["span"]),ol:new Set(["start","reversed","type"]),li:new Set(["value"]),code:new Set(["class"]),pre:new Set(["class"])},wn=new Set(["href","src","cite","poster"]),Sn=1,$n=8,An=class extends Error{constructor(){super(...arguments);ie(this,"name","SanitizerEnvironmentError")}},kn=(Object.freeze({allowedTags:pn,removeCompletely:gn,globalAttributes:mn,attributesByTag:bn,urlAttributes:wn}),new Map),Tn={1:"left",2:"center",3:"right",4:"justify"},xn=new Set(["left","center","right","justify","start","end"]),Nn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),Mn=/[&<>"\'/`=]/g,Cn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),On=/[&<>"\']/g,jn=new Set(["h1","h2","h3","h4","h5","h6"]),In=(t,e)=>{let i="string"==typeof t.url?t.url:"",n=e.renderChildren(t.children??[]);if(0===i.length||!g(i))return n;let r=m(i)?\' target="_blank" rel="noopener noreferrer"\':function(t){let e="string"==typeof t.target?t.target:"";if(0===e.length)return"";let i=B(e);return"_blank"===e?\' target="_blank" rel="noopener noreferrer"\':` target="${i}"`}(t),l="string"==typeof t.title?` title="${B(t.title)}"`:"";return`<a href="${X(i)}"${r}${l}>${n}</a>`},En=new Map;V("text",t=>{let e=B("string"==typeof t.text?t.text:""),i="number"==typeof t.format?t.format:0;return!!(16&i)&&(e=`<code>${e}</code>`),!!(1&i)&&(e=`<strong>${e}</strong>`),!!(2&i)&&(e=`<em>${e}</em>`),!!(8&i)&&(e=`<u>${e}</u>`),!!(4&i)&&(e=`<s>${e}</s>`),!!(32&i)&&(e=`<sub>${e}</sub>`),!!(64&i)&&(e=`<sup>${e}</sup>`),!!(128&i)&&(e=`<mark>${e}</mark>`),e});V("paragraph",(t,e)=>{let i=e.renderChildren(t.children??[]);return`<p${q(t)}${J(t)}>${i}</p>`});V("heading",(t,e)=>{let i="string"==typeof t.tag?t.tag.toLowerCase():"h2",n=jn.has(i)?i:"h2",r=e.renderChildren(t.children??[]);return`<${n}${q(t)}${J(t)}>${r}</${n}>`});V("list",(t,e)=>{let i="string"==typeof t.listType?t.listType:"bullet",n="number"===i?"ol":"ul",r="number"===i&&"number"==typeof t.start&&t.start>1?` start="${String(t.start)}"`:"",l="check"===i?\' role="list"\':"",s=e.renderChildren(t.children??[]);return`<${n}${q(t)}${J(t)}${r}${l}>${s}</${n}>`});V("listitem",(t,e)=>{let i=e.renderChildren(t.children??[]);if("boolean"==typeof t.checked)return`<li role="checkbox" aria-checked="${t.checked?"true":"false"}"${J(t)}>${i}</li>`;let n="number"==typeof t.value?` value="${B(String(t.value))}"`:"";return`<li${q(t)}${J(t)}${n}>${i}</li>`});V("link",In);V("autolink",In);V("quote",(t,e)=>{let i=e.renderChildren(t.children??[]);return`<blockquote${q(t)}${J(t)}>${i}</blockquote>`});V("code",t=>{let e=K("string"==typeof t.language?t.language:"");return`<pre><code${""===e?"":` class="language-${e}"`}>${B(Z(t))}</code></pre>`});V("code-highlight",t=>{let e="string"==typeof t.text?t.text:"";return`<span${"string"==typeof t.highlightType?` class="token-${K(t.highlightType)}"`:""}>${B(e)}</span>`});V("linebreak",()=>"<br>");V("horizontalrule",()=>"<hr>");V("tab",()=>"\\t");V("upload",t=>{let e=function(t){let e=t.value;if("object"==typeof e&&null!==e)return e}(t);if(void 0===e)return"";let i=e.url;if("string"!=typeof i||!g(i))return"";let n="string"==typeof e.mimeType?e.mimeType:"";return n.startsWith("video/")?function(t,e){let i="number"==typeof t.width?` width="${String(t.width)}"`:"",n="number"==typeof t.height?` height="${String(t.height)}"`:"",r="string"==typeof t.mimeType?` type="${X(t.mimeType)}"`:"";return`<video controls${i}${n}><source src="${X(e)}"${r}></video>`}(e,i):n.startsWith("audio/")?function(t,e){let i="string"==typeof t.mimeType?` type="${X(t.mimeType)}"`:"";return`<audio controls><source src="${X(e)}"${i}></audio>`}(e,i):""===n||n.startsWith("image/")?function(t,e){let i="string"==typeof t.alt?B(t.alt):"",n="number"==typeof t.width?` width="${String(t.width)}"`:"",r="number"==typeof t.height?` height="${String(t.height)}"`:"";return`<img src="${X(e)}" alt="${i}"${n}${r} loading="lazy" decoding="async">`}(e,i):function(t,e){let i="string"==typeof t.filename?B(t.filename):B(e);return`<a href="${X(e)}" target="_blank" rel="noopener noreferrer">${i}</a>`}(e,i)});V("relationship",t=>{let e="string"==typeof t.relationTo?t.relationTo:"",i=function(t){let e=t.value;if("object"==typeof e&&null!==e)return e}(t),n=function(t,e){return void 0===t?""===e?"#":`#${e}`:"string"==typeof t.title&&t.title.length>0?t.title:"string"==typeof t.name&&t.name.length>0?t.name:"string"==typeof t.slug&&t.slug.length>0?t.slug:void 0!==t.id?String(t.id):""===e?"#":`#${e}`}(i,e),r=B(n),l=""===e?"":` data-relation-to="${B(e)}"`,s=i?.url;return"string"==typeof s&&g(s)?`<a href="${X(s)}"${l}>${r}</a>`:`<span${l}>${r}</span>`});V("block",(t,e)=>{let i=function(t){let e=t.fields;return"object"!=typeof e||null===e?{}:e}(t),n="string"==typeof i.blockType?i.blockType:"",r=tt(n);if(""!==n){let t=Q(n)??Q(r);if(t)return t(i,{renderChildren:e.renderChildren})}let l=[];""!==r&&l.push(`data-block-type="${B(r)}"`);for(let[t,e]of Object.entries(i)){if("blockType"===t||"id"===t||null==e)continue;let i="string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);l.push(`data-block-${tt(t)}="${B(i)}"`)}return`<div${0===l.length?"":` ${l.join(" ")}`}></div>`});jt={renderChildren:nt,resolveAlignment:G,resolveIndent:H};It="data-payload-text";Et={name:"textarea",render(t,e){let i=t.element,n=et(e)?it(e):ot(e);"INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName?i.innerHTML=Y(n):i.value=n}};Rt={name:"richText",render:y((t,e)=>{if(et(e))t.element.innerHTML=function(t,e={}){if(!et(t))return"";let i=nt(t.root.children);return 0==e.sanitize||void 0===F()?i:P(i)}(e);else{if("string"!=typeof e)return 0;t.element.innerHTML=P(e)}})};_t={name:"html",render(t,e){if(null==e){t.element.textContent="";return}let i="string"==typeof e?e:ot(e);t.element.innerHTML=P(i)}};Lt={name:"url",render(t,e,i){let n=t.element,r=ot(e);if("A"===n.tagName){let l=n,s=t.hrefField,o=void 0===s||0===s.length?e:b(i.allFields,s,i.locale,void 0!==t.locale);"string"==typeof o&&g(o)&&(l.href=o),l.textContent=r;return}"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName?n.textContent=r:n.value=r}};Wt={name:"image",render:y((t,e,i)=>{let n=t.element,r=at(e),l=void 0!==t.locale,s=function(t,e,i,n,r,l){if(void 0!==i&&i.length>0){let t=b(n,i,r,l);if("string"==typeof t&&g(t))return t;let e=at(t);return void 0!==e?.url&&g(e.url)?e.url:void 0}return void 0!==t?.url&&g(t.url)?t.url:"string"==typeof e&&g(e)?e:void 0}(r,e,t.srcField,i.allFields,i.locale,l);if(void 0===s)return 0;if("IMG"===n.tagName){let e=n;e.src=s;let o=function(t,e,i,n,r){if(void 0!==e&&e.length>0){let t=b(i,e,n,r);return"string"==typeof t?t:void 0}if(void 0!==t?.alt)return t.alt}(r,t.altField,i.allFields,i.locale,l);void 0!==o&&(e.alt=o);return}n.style.backgroundImage=`url(\'${function(t){return t.replace(/[\'"()\\\\]/g,"\\\\$&")}(s)}\')`})};Pt={name:"upload",render:y((t,e)=>{let i=t.element,n=function(t){if("object"==typeof t&&null!==t)return t}(e);if(void 0===n)return 0;let r=n.url;if("string"!=typeof r||!g(r))return 0;if("IMG"===i.tagName){let t=i;t.src=r,void 0!==n.alt&&(t.alt=n.alt);return}if("A"===i.tagName){let t=i;t.href=r,t.textContent=n.filename??r;return}let l=void 0!==n.filename?B(n.filename):B(r);i.innerHTML=`<a href="${X(r)}">${l}</a>`})};Ft={name:"relationship",render(t,e){let i=t.element,n=function(t){return null==t?[""]:Array.isArray(t)?t.map(ut):[ut(t)]}(e).join(", ");if("A"===i.tagName&&!Array.isArray(e)){let t=i,r=e?.url;"string"==typeof r&&g(r)&&(t.href=r),t.textContent=n;return}i.textContent=n}};Dt={name:"select",render(t,e){let i=t.element,n=ht(e);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let t=i;t.checked=t.value===n;return}i.textContent=n}else i.value=n}};Ut={name:"checkbox",render(t,e){let i=t.element,n=!!e;"INPUT"!==i.tagName||"checkbox"!==i.type?i.hasAttribute("aria-checked")?i.setAttribute("aria-checked",n?"true":"false"):i.textContent=n?"true":"false":i.checked=n}};zt=new Map,Vt=new Map,Gt=64;Ht={name:"date",render(t,e,i){let n=t.element;if(null==e||""===e){"INPUT"===n.tagName?n.value="":("TIME"===n.tagName&&n.removeAttribute("datetime"),n.textContent="");return}let r="string"==typeof e?e:ot(e),l=new Date(r),s=!Number.isNaN(l.getTime());"INPUT"!==n.tagName?("TIME"!==n.tagName||n.setAttribute("datetime",s?l.toISOString():r),n.textContent=s?function(t,e){let i=e.locale??S();try{return function(t,e){let i=ct(t,e),n=Vt.get(i);if(void 0!==n)return Vt.delete(i),Vt.set(i,n),n;let r=new Intl.DateTimeFormat(t,e);return Vt.set(i,r),ft(Vt),r}(i,{dateStyle:"medium",timeStyle:"short"}).format(t)}catch{return t.toISOString()}}(l,i):r):n.value=s?function(t,e){return"date"===t?e.toISOString().slice(0,10):"datetime-local"===t?e.toISOString().slice(0,16):e.toISOString()}(n.type,l):r}};qt={name:"number",render(t,e,i){let n=t.element;if(null==e||""===e){"INPUT"===n.tagName?n.value="":n.textContent="";return}let r="number"==typeof e?e:Number(ot(e));Number.isNaN(r)?n.textContent=ot(e):"INPUT"!==n.tagName?n.textContent=function(t,e){let i=e.locale??S();try{return function(t,e){let i=ct(t,e),n=zt.get(i);if(void 0!==n)return zt.delete(i),zt.set(i,n),n;let r=new Intl.NumberFormat(t,e);return zt.set(i,r),ft(zt),r}(i).format(t)}catch{return String(t)}}(r,i):n.value=String(r)}};Jt=/\\{\\{([\\s\\S]*?)\\}\\}/g;Bt={name:"array",render:y((t,e)=>{let i=t.element;if(!Array.isArray(e))return 0;let n=t.arrayTemplate;if(void 0!==n&&n.length>0){let t=function(t,e){let i="";for(let n=0;n<e.length;n+=1)i+=gt(t,e[n],n);return i}(n,e);i.innerHTML=P(t);return}let r=t.arraySeparator??", ";i.textContent=e.map(mt).join(r)})};Xt="data-payload-key",Yt="data-payload-nested-key",Zt="data-payload-nested-template";Kt=new Map;Qt=[Et,Rt,_t,Lt,{...Lt,name:"email"},Wt,Pt,Ft,Dt,{...Dt,name:"radio"},Ut,Ht,qt,Bt,{...Bt,name:"blocks"}];!function(){if(typeof window>"u"||!_()&&(typeof window>"u"||null==window.opener))return;let t=window.__livePreview;if(void 0!==t)return t;let[e=[],i="",n="/api",r=1,l=0,s=50,o=1,a=0,u=0,h=50,c="200px",d=0,f=0]=typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__,p=new cn({additionalOrigins:e,enableReferrerDetection:!d,enableLocalhostMatching:!f});p.isProductionUnconfigured?ue("[live-preview] No trusted origin. Set PAYLOAD_ADMIN_ORIGIN or pass allowedOrigins to generateInlineScript()."):p.isReferrerOnlyTrust&&ue("[live-preview] document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let g=new ce,m=function(t=[]){let e={};for(let i of t)e[i.name]=i;for(let[t,i]of Kt)e[t]=i;return Object.freeze(e)}([st(),...Qt,Ct()]),y=new Pi({renderers:m,originMatcher:t=>p.matches(t),readyTargets:p.enumerate(),emitter:g,...""!==i?{dataMerge:{serverURL:i,apiRoute:n,depth:r}}:{},debounceMs:s,heartbeatMs:a,intersectionRootMargin:c,disableVisibilityGate:u,visibilityGateThreshold:h,enableA11y:o,onHeartbeatTimeout:()=>{p.unlockOrigin()},...l?{log:(...t)=>{he("[live-preview]",...t)}}:{}});g.on("connect",t=>{p.lockOrigin(t.origin)}),y.start();let v=Object.freeze({version:"1.0.5",destroy:()=>{y.destroy();let t=window;t.__livePreview===v&&delete t.__livePreview},refresh:()=>{y.refreshCache()},enumerateOrigins:()=>p.enumerate()});try{Object.defineProperty(window,"__livePreview",{value:v,writable:0,configurable:1})}catch(t){throw y.destroy(),t}}()})();',or={generatedAt:"2026-08-16T22:53:17.000Z",size:63966};function ar(e={}){if(0===sr.length)throw new Error("[live-preview] runtime.generated.ts is empty. Run `npm run build:runtime` before bundling.");let t=[e.allowedOrigins,e.serverURL,e.apiRoute,e.mergeDepth,e.debug,e.debounceMs,e.enableA11y,e.heartbeatMs,e.disableVisibilityGate,e.visibilityGateThreshold,e.intersectionRootMargin,e.disableReferrerDetection,e.disableLocalhostMatching];for(;t.length>0&&void 0===t.at(-1);)t.pop();return[`var __LIVE_PREVIEW_CONFIG__=${`[${t.map(e=>void 0===e?"":JSON.stringify(e)).join(",")}]`.replace(/</g,"\\u003C")};`,sr].join("\n")}function ur(e,t={}){return`<script${void 0!==t.nonce?` nonce="${dr(t.nonce)}"`:""}>${e}<\/script>`}function hr(){return or}function dr(e){if(!/^[A-Za-z0-9+/=_-]+$/.test(e))throw new RangeError("wrapWithScriptTag: nonce contains invalid characters");return e}t(ar,"generateInlineScript"),t(ur,"wrapWithScriptTag"),t(hr,"runtimeBuildInfo"),t(dr,"escapeNonce");var cr,fr=/[\t\n\f\r ]+/,pr=/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;function gr(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function mr(e){cr=e??void 0}function yr(e=16){if(!Number.isInteger(e)||e<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(e)}`);let t=vr();if(!t)throw new Error("generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) once at startup, or run with --experimental-global-webcrypto. We won't fabricate a predictable nonce — that would silently defeat the entire CSP.");let i=new Uint8Array(e);return t.getRandomValues(i),br(i)}function vr(){if(cr?.getRandomValues)return cr;let e=globalThis.crypto;return e?.getRandomValues?e:void 0}function br(e){let t="";for(let i of e)t+=String.fromCharCode(i);return("function"==typeof btoa?btoa(t):Buffer.from(e).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function wr(e={}){let{self:t=!0,origins:i=[],allowNone:n=!1}=e,r=new Set,l=[];if(n&&!t&&0===i.length)return"'none'";t&&(l.push("'self'"),r.add("'self'"));for(let e of i){let t=e.trim();0===t.length||r.has(t)||(r.add(t),l.push(t))}return l.length>0?l.join(" "):"'none'"}function Sr(e,t={}){if(0===e.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");let{self:i=!0,extra:n=[],strictDynamic:r=!1}=t,l=[];i&&l.push("'self'"),l.push(`'nonce-${e}'`),r&&l.push("'strict-dynamic'");for(let e of n){let t=e.trim();t.length>0&&l.push(t)}return l.join(" ")}function Ar(e,t){let i=new Map;for(let t of e.split(";")){let e=t.replace(pr,"");if(0===e.length)continue;let n=e.search(fr),r=gr(n<0?e:e.slice(0,n));if(i.has(r))continue;let l=n<0?"":e.slice(n).replace(pr,"");i.set(r,l)}for(let[e,n]of Object.entries(t)){let t=gr(e),r="string"==typeof n?{value:n}:n,l=r.mode??"union",s=i.get(t);if("replace"===l||void 0===s||0===s.length){i.set(t,r.value);continue}let o=new Set,a=[];for(let e of[...s.split(fr),...r.value.split(fr)])0===e.length||o.has(e)||(o.add(e),a.push(e));let u=a.filter(e=>"'none'"!==e);i.set(t,(u.length>0?u:a).join(" "))}let n=[];for(let[e,t]of i)n.push(0===t.length?e:`${e} ${t}`);return n.join("; ")}t(gr,"asciiLowercase"),t(mr,"setCspCrypto"),t(yr,"generateCspNonce"),t(vr,"resolveCrypto"),t(br,"base64UrlEncode"),t(wr,"buildFrameAncestors"),t(Sr,"buildScriptSrcWithNonce"),t(Ar,"mergeCspHeader");var Tr=["preview","draft","livePreview"];function $r(e,t={}){let i=new Set(t.signals??["query","fetch-dest","referer"]),n=t.queryParams??Tr,r=(t.checkFetchDest??!0)&&i.has("fetch-dest");if(i.has("query")){let t;try{t=new URL(e.url)}catch{t=void 0}if(void 0!==t)for(let e of n){let i=t.searchParams.get(e);if("true"===i||"1"===i)return!0}}if(r&&"iframe"===e.headers.get("sec-fetch-dest"))return!0;let l=i.has("referer")?t.adminOrigins??[]:[];if(l.length>0){let t=e.headers.get("referer");if(null!==t)try{let e=new URL(t).origin;for(let t of l)try{if(new URL(t).origin===e)return!0}catch{}}catch{}}return!1}async function kr(e){let t=Mr(e);if(void 0!==e.id)return Rr(`${Nr(e)}/${encodeURIComponent(e.collection)}/${encodeURIComponent(String(e.id))}?${t.toString()}`,e);void 0!==e.where&&Cr(t,e.where,["where"]),t.set("limit","1");let i=`${Nr(e)}/${encodeURIComponent(e.collection)}?${t.toString()}`;return(await Rr(i,e))?.docs?.[0]??null}async function xr(e){let t=Mr(e);return Rr(`${Nr(e)}/globals/${encodeURIComponent(e.global)}?${t.toString()}`,e)}function Nr(e){let t=e.serverURL.replace(/\/+$/,""),i=e.apiRoute??"/api";return`${t}${i.startsWith("/")?i:`/${i}`}`}function Mr(e){let t=new URLSearchParams;return t.set("depth",String(e.depth??1)),(e.draft??!0)&&t.set("draft","true"),void 0!==e.locale&&t.set("locale",e.locale),t}function Cr(e,t,i){for(let[n,r]of Object.entries(t)){let t=[...i,n];if(null!==r&&"object"==typeof r&&!Array.isArray(r)){Cr(e,r,t);continue}let l=t.map((e,t)=>0===t?e:`[${e}]`).join("");Array.isArray(r)?e.set(l,r.map(String).join(",")):e.set(l,String(r))}}async function Rr(e,t){let i=t.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===i)return null;try{let n=await i(e,{credentials:"include",headers:{Accept:"application/json",...t.headers??{}}});if(!n.ok)return null;let r=await n.json();return null===r||"object"!=typeof r?null:r}catch{return null}}t($r,"isPreviewRequest"),t(kr,"fetchPreviewDocument"),t(xr,"fetchPreviewGlobal"),t(Nr,"apiBase"),t(Mr,"baseParams"),t(Cr,"appendWhere"),t(Rr,"requestJson");var Or="payload-live-preview-highlight",Ir=new WeakMap,Fr=new WeakMap,Lr={name:"highlight",version:"1.0.0",init:t(e=>{if(typeof document>"u"||typeof window>"u")return;let i="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,n=Er(document,i),r=i?1e3:600,l=new WeakMap,s=new Set;e.registerCleanup?.(()=>{for(let e of[...s])e();n()}),e.events.on("elementUpdate",e=>{let i=e.element;l.get(i)?.();let n=Pr(i),o=!1,a=t(()=>{o||(o=!0,window.clearTimeout(u),l.get(i)===a&&l.delete(i),s.delete(a),n())},"disposeTimer"),u=window.setTimeout(a,r);s.add(a),l.set(i,a)})},"init")};function Er(e,t){let i=Ir.get(e);if(void 0!==i&&!i.element.isConnected&&(Ir.delete(e),i=void 0),void 0===i){let n=e.getElementById(Or),r=n instanceof HTMLStyleElement?n:e.createElement("style"),l=null===n;l&&(r.id=Or,r.textContent=t?".lp-highlight{outline:2px solid rgba(0,102,204,0.85);outline-offset:2px;}":"@keyframes lp-highlight{0%{outline:2px solid rgba(0,102,204,0.85);outline-offset:2px}100%{outline:2px solid transparent;outline-offset:2px}}.lp-highlight{animation:lp-highlight 0.6s ease-out;}",e.head.appendChild(r)),i={element:r,pluginOwned:l,owners:0},Ir.set(e,i)}let n=i;n.owners+=1;let r=!0;return()=>{r&&(r=!1,n.owners-=1,!(n.owners>0)&&(Ir.get(e)===n&&Ir.delete(e),n.pluginOwned&&n.element.remove()))}}function Pr(e){let t=Fr.get(e);void 0===t&&(t={owners:0,pluginAdded:!e.classList.contains("lp-highlight")},Fr.set(e,t));let i=t;i.owners+=1,e.classList.add("lp-highlight");let n=!0;return()=>{n&&(n=!1,i.owners-=1,!(i.owners>0)&&(Fr.delete(e),i.pluginAdded&&e.classList.remove("lp-highlight")))}}t(Er,"acquireStyle"),t(Pr,"acquireHighlight");var jr={name:"debug",version:"1.0.0",init:t(e=>{e.events.on("init",()=>{e.log("init")}),e.events.on("connect",t=>{e.log("connect ←",t.origin)}),e.events.on("disconnect",t=>{e.log("disconnect (",t.reason,")")}),e.events.on("cacheRefresh",t=>{e.log("cacheRefresh",t.elementCount,"elements,",t.fieldCount,"fields")}),e.events.on("beforeUpdate",t=>{e.log("beforeUpdate",Object.keys(t.data.fields).length,"fields")}),e.events.on("afterUpdate",t=>{e.log("afterUpdate",t.updatedCount,"in",t.durationMs.toFixed(2),"ms")}),e.events.on("error",t=>{e.log("error in",t.context,":",t.error.message)})},"init")};function Dr(){let e=0,i=0,n=0;return{name:"analytics",version:"1.0.0",init:t(t=>{t.events.on("afterUpdate",t=>{e+=1,i+=t.updatedCount,n+=t.durationMs})},"init"),getStats:t(()=>({updateCount:e,totalElements:i,totalDurationMs:n,averageDurationMs:0===e?0:n/e}),"getStats")}}t(Dr,"createAnalyticsPlugin");var Ur="payload-live-preview:scroll";function Wr(){if(!(typeof window>"u"))try{sessionStorage.setItem(Ur,JSON.stringify({href:window.location.href,x:window.scrollX,y:window.scrollY}))}catch{}}function _r(){if(!(typeof window>"u"))try{let e=sessionStorage.getItem(Ur);if(null===e)return;sessionStorage.removeItem(Ur);let t=JSON.parse(e);if(t.href!==window.location.href)return;window.scrollTo(t.x??0,t.y??0)}catch{}}function Vr(){typeof window>"u"||(Wr(),window.location.reload())}function zr(e={}){let i=e.strategy??"silent";return{name:"document-save",version:"1.1.0",init:t(t=>{let n=!0,r=new Set;t.registerCleanup?.(()=>{n=!1;for(let e of r)e.abort();r.clear()}),_r(),t.events.on("documentSave",()=>{if(!n||"silent"===i)return;if("reload"===i)return void Vr();let l=new AbortController;r.add(l),("fetch"===i?Br(e,t.log,l.signal,()=>n):Kr(e,t.log,l.signal,()=>n)).finally(()=>{r.delete(l)})})},"init")}}async function Br(e,t,i,n){if(e.handler)try{await e.handler(i)}catch(e){if(!n()||i.aborted)return;t("document-save handler threw:",e)}else t("document-save: fetch strategy selected but no handler supplied")}async function Kr(e,t,i,n){if(typeof fetch>"u")return void t("document-save: revalidate strategy needs fetch — not available");let r=e.revalidateUrl??"/api/revalidate",l=!1;try{let s=await fetch(r,{method:"POST",signal:i,headers:{"Content-Type":"application/json",...e.revalidateHeaders??{}},body:JSON.stringify({source:"payload-live-preview"})});if(!n()||i.aborted)return;l=s.ok,l||t("document-save revalidate non-2xx:",s.status)}catch(e){if(!n()||i.aborted)return;t("document-save revalidate failed:",e)}!l&&"reload"===e.onRevalidateFailure&&Vr()}function Gr(e,t){return Hr(e,t)}function qr(e,t){let i=Jr(e);if(0===i.length)throw new Error("bindByPath: the picker did not read any field — return data.<field> instead of a constant");return Hr(i.join("."),t)}function Hr(e,t){if(0===e.length)throw new Error("bind: field name must be a non-empty string");let i={"data-payload-field":e};return void 0!==t?.attribute&&(i["data-payload-attribute"]=t.attribute),void 0!==t?.type&&(i["data-payload-type"]=t.type),i}function Jr(e){let t=[],i=new Proxy({},{get(e,n){if("symbol"!=typeof n)return/^\d+$/.test(n)||t.push(n),i}});try{e(i)}catch{}return t}t(Wr,"saveScrollPosition"),t(_r,"restoreScrollPosition"),t(Vr,"reloadPreservingScroll"),t(zr,"documentSavePlugin"),t(Br,"runFetch"),t(Kr,"runRevalidate"),t(Gr,"bind"),t(qr,"bindByPath"),t(Hr,"buildAttributes"),t(Jr,"recordPath");export{tt as EventEmitter,M as LIBRARY_PROTOCOL_VERSION,rr as LivePreviewClient,ft as OriginDetector,i as VERSION,Gr as bind,qr as bindByPath,nr as buildBuiltinRenderers,wr as buildFrameAncestors,Sr as buildScriptSrcWithNonce,Dr as createAnalyticsPlugin,jr as debugPlugin,be as detectInitialLocale,zr as documentSavePlugin,Xt as escapeHtml,ei as escapeHtmlAttribute,kr as fetchPreviewDocument,xr as fetchPreviewGlobal,yr as generateCspNonce,ar as generateInlineScript,O as hasCapability,Lr as highlightPlugin,lr as initLivePreview,lt as isDevMode,le as isExternalHttpUrl,it as isInIframe,nt as isInPopup,rt as isInPreviewContext,Li as isLexicalContent,$r as isPreviewRequest,re as isSafeUrl,Ei as lexicalToHtml,Pi as lexicalToPlainText,Ar as mergeCspHeader,R as negotiateProtocol,Mi as registerBlockRenderer,tr as registerBuiltinRenderer,hr as runtimeBuildInfo,Ot as sanitizeHtml,mr as setCspCrypto,Rt as setSanitizerDocument,ur as wrapWithScriptTag};
2
2
  //# sourceMappingURL=index.js.map