payload-live-preview 1.8.0 → 1.8.2
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/adapters/astro/index.js +1 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/middleware-entry.js +1 -1
- package/dist/adapters/astro/middleware-entry.js.map +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +3 -2
- package/dist/core.d.ts +3 -2
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/core.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t="data-payload-field",e="data-payload-type",n="data-payload-attribute",i="data-payload-href",r="data-payload-src",s="data-payload-alt",o="data-payload-array-template",a="data-payload-array-separator",l="data-payload-locale",u="data-payload-richtext",c="data-payload-html",d="data-payload-array",h="data-payload-structural",f="data-payload-owner",p=[t,e,n,i,r,s,o,a,l,u,c,d,h,f,"type"],g=`[${t}]`,m=`[${f}]`,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"]),y=class{#t=new Map;#e=new WeakMap;#n;constructor(t={}){this.#n=t.filter??b}buildFromRoot(t){const e=performance.now();this.clear();const n=t.querySelectorAll(g);let i=0;for(const t of n)void 0!==this.add(t)&&(i+=1);return{elementCount:i,fieldCount:this.#t.size,durationMs:performance.now()-e}}add(t){const e=this.#n(t)?this.#i(t):void 0,n=this.#e.get(t);if(void 0!==e)return void 0!==n&&this.#r(n,e)?(this.#e.set(t,e),e):(void 0!==n&&this.#s(t,n),this.#o(e),this.#e.set(t,e),e);void 0!==n&&this.#s(t,n)}remove(t){const e=this.#e.get(t);return!!e&&this.#s(t,e)}#r(t,e){if(t.fieldName!==e.fieldName)return!1;const n=this.#t.get(t.fieldName);if(!n)return!1;const i=n.indexOf(t);return!(i<0||(n[i]=e,0))}#s(t,e){const n=this.#t.get(e.fieldName);if(!n)return this.#e.delete(t),!1;const i=n.indexOf(e);return i<0?(this.#e.delete(t),!1):(n.splice(i,1),0===n.length&&this.#t.delete(e.fieldName),this.#e.delete(t),!0)}get(t){return this.#t.get(t)}getByElement(t){return this.#e.get(t)}get fieldCount(){return this.#t.size}get elementCount(){let t=0;for(const e of this.#t.values())t+=e.length;return t}entries(){return this.#t.entries()}*values(){for(const t of this.#t.values())yield*t}has(t){return this.#e.has(t)}clear(){this.#t.clear(),this.#e=new WeakMap}#o(t){const e=this.#t.get(t.fieldName);e?e.push(t):this.#t.set(t.fieldName,[t])}#i(p){const g=p.getAttribute(t);if(null===g||0===g.length)return;const y=p.getAttribute(e),b=function(t){const n=t.getAttribute(e);if(null!==n&&v.has(n))return n;if(t.hasAttribute(u))return"richText";if(t.hasAttribute(c))return"html";if(t.hasAttribute(h))return"structural-array";if(t.hasAttribute(d))return"array";if("IMG"===t.tagName)return"image";if("A"===t.tagName)return"url";if("TIME"===t.tagName)return"date";if("INPUT"===t.tagName){const e=t.type;if("checkbox"===e)return"checkbox";if("number"===e)return"number";if("date"===e||"datetime-local"===e)return"date"}return"text"}(p),w=p.getAttribute(n),S=p.getAttribute(i),A=p.getAttribute(r),T=p.getAttribute(s),k=p.getAttribute(o),C=p.getAttribute(a),x=p.getAttribute(l),N=function(t){const e=t.closest(m)?.getAttribute(f);return null==e||0===e.length?void 0:e}(p);return{element:p,fieldName:g,fieldType:b,explicitFieldType:null!==y&&v.has(y),...null!==w&&w.length>0?{targetAttribute:w}:{},...null!==S&&S.length>0?{hrefField:S}:{},...null!==A&&A.length>0?{srcField:A}:{},...null!==T&&T.length>0?{altField:T}:{},...null!==k?{arrayTemplate:k}:{},...null!==C?{arraySeparator:C}:{},...null!==x&&x.length>0?{locale:x}:{},...void 0!==N?{owner:N}:{}}}};function b(){return!0}function w(t,e){return void 0===e||""===e?`collection:${t}`:`collection:${t}:${e}`}function S(t){return"string"==typeof t&&t.length>0}function A(t,e){return null!==e&&void 0!==t&&e.includes(t)}function T(t){const e=t.id;return"string"==typeof e&&e.length>0?e:"number"==typeof e&&Number.isFinite(e)?String(e):void 0}var k=class{s;constructor(t,e={}){this.s=[t,e.mutationDebounceMs??100,e.intersectionRootMargin??"200px",new Set,null,null,null,0]}start(t){const e=this.s[7];this.stop();const n=e+1;if(this.s[7]!==n)return;let i=null,r=null;try{i=new MutationObserver(t=>{this.#a(t,n)}),r=new IntersectionObserver(t=>{this.#l(t,n)},{rootMargin:this.s[2],threshold:0}),i.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...p]})}catch(t){throw i?.disconnect(),r?.disconnect(),t}if(this.s[7]!==n)return i.disconnect(),void r.disconnect();this.s[4]=i,this.s[5]=r}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;const t=this.s[6],e=this.s[4],n=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{n?.disconnect()}}#a(e,n){if(!this.#u(n))return;if(!function(e){for(const n of e){if("attributes"===n.type&&null!==n.attributeName&&p.includes(n.attributeName)&&(n.attributeName===t||n.attributeName===f||1===n.target.nodeType&&n.target.hasAttribute(t)))return!0;for(const t of n.addedNodes)if(C(t))return!0;for(const t of n.removedNodes)if(C(t))return!0}return!1}(e))return;if(!this.#u(n))return;null!==this.s[6]&&clearTimeout(this.s[6]);const i=setTimeout(()=>{this.#u(n)&&this.s[6]===i&&(this.s[6]=null,this.s[0].onStructuralChange())},this.s[1]);this.s[6]=i}#l(t,e){for(const n of t){if(!this.#u(e))return;const t=n.target;if(n.isIntersecting){if(!this.s[3].has(t)&&(this.s[3].add(t),this.s[0].onVisibilityChange(t,!0),!this.#u(e)))return}else if(this.s[3].has(t)&&(this.s[3].delete(t),this.s[0].onVisibilityChange(t,!1),!this.#u(e)))return}}#u(t){return this.s[7]===t&&null!==this.s[5]}};function C(e){if(1!==e.nodeType)return!1;const n=e;return!!n.hasAttribute(t)||null!==n.querySelector(`[${t}]`)}function x(t){if(!Array.isArray(t))return[];const e=[];for(const n of t){const t=N(n);t&&e.push(t)}return e}function N(t){if("object"!=typeof t||null===t)return;const e=t,n=e.name,i=e.type;if("string"!=typeof n||0===n.length)return;if("string"!=typeof i||0===i.length)return;const r=x(e.fields),s=function(t){if(!Array.isArray(t))return[];const e=[];for(const n of t){if("object"!=typeof n||null===n)continue;const t=n,i=t.slug;if("string"!=typeof i||0===i.length)continue;const r=x(t.fields);e.push({...t,slug:i,fields:r})}return e}(e.blocks),o={...e,name:n,type:i};return r.length>0?o.fields=r:delete o.fields,s.length>0?o.blocks=s:delete o.blocks,o}var $={basic:1,"schema-json":2,"preview-token":3,"nested-arrays":4,"recursive-diffs":4};function negotiateProtocol(t){const e="number"==typeof t&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0,n=e??1,i=Math.min(4,n),r=new Set;for(const[t,e]of Object.entries($))i>=e&&r.add(t);return{ours:4,...void 0!==e?{theirs:e}:{theirs:void 0},negotiated:i,capabilities:r}}function P(t){return("object"==typeof t&&null!==t||"function"==typeof t)&&"function"==typeof t.then&&(Promise.resolve(t).catch(()=>{}),!0)}var R=class{s;constructor(t,e){this.s=[t,e,void 0,void 0,0,0,[],0]}attach(t=window){if(void 0!==this.s[3])return;let e=!1;const n=t=>{if(!e||this.s[2]!==n)return;const i=this.s[4];try{this.#c(t,i)}catch{let e="";try{e=t.origin}catch{}this.#d("shape",e,i)}};this.s[4]+=1,this.#h(),this.s[3]=t,this.s[2]=n;try{t.addEventListener("message",n)}catch(e){this.s[2]===n&&(this.s[3]=void 0,this.s[2]=void 0,this.#h());try{t.removeEventListener("message",n)}catch{}throw e}if(this.s[2]===n)e=!0;else try{t.removeEventListener("message",n)}catch{}}detach(t){const e=this.s[3],n=this.s[2];void 0!==e&&void 0!==n&&(this.s[3]=void 0,this.s[2]=void 0,this.#h(),e.removeEventListener("message",n))}advanceGeneration(){return void 0!==this.s[3]&&(this.s[4]+=1,this.#h(),!0)}static sendReady(t,e){const n=t.length>0;if(!n||0===e.length)return;const i={type:"payload-live-preview",ready:n,protocolVersion:4};for(const n of t)for(const t of e)try{n.postMessage(i,t)}catch{}}#c(t,e){if(!this.#u(e))return;const n=t.origin;if(!this.#u(e))return;if(!this.#f(n,e))return void this.#d("origin",n,e);const i=t.data;if(!this.#u(e))return;const r="object"==typeof(s=i)&&null!==s&&"type"in s&&"string"==typeof s.type;var s;if(!this.#u(e))return;if(!r)return void this.#d("shape",n,e);const o=i.type;if(this.#u(e))switch(o){case"payload-live-preview":{const t=function(t){const e=t;return!!((void 0===e.data||null===e.data||L(e.data))&&M(e.fieldSchemaJSON,t=>Array.isArray(t))&&M(e.globalSlug,t=>"string"==typeof t)&&M(e.collectionSlug,t=>"string"==typeof t)&&M(e.locale,t=>"string"==typeof t)&&M(e.ready,t=>"boolean"==typeof t)&&M(e.previewToken,t=>"string"==typeof t)&&M(e.protocolVersion,t=>"number"==typeof t))}(i);if(!this.#u(e))return;if(!t)return void this.#d("shape",n,e);const r=function(t){const e={...t};for(const t of E)null===Reflect.get(e,t)&&Reflect.deleteProperty(e,t);if(!Array.isArray(e.fieldSchemaJSON))return e;let n;try{n=x(e.fieldSchemaJSON)}catch{n=[]}return{...e,fieldSchemaJSON:n}}(i);if(!this.#u(e))return;return void this.#p(r,n,e)}case"payload-document-event":{const t=function(t){const e=t;return!!O(e.action,t=>"updated"===t||"created"===t||"deleted"===t)&&!!O(e.slug,t=>"string"==typeof t)&&!!O(e.id,t=>"string"==typeof t||"number"==typeof t&&Number.isFinite(t))}(i);if(!this.#u(e))return;if(!t)return void this.#d("shape",n,e);let r;try{r=this.s[1].onDocumentEvent}catch{return}if(!this.#u(e))return;return void this.#g(r,i,n)}default:this.#d("type",n,e)}}#p(t,e,n){if(!this.#u(n))return;const i=t.data;if(!this.#u(n))return;const r=L(i);if(!this.#u(n))return;const s=r?{generation:n,revision:this.s[5]+=1}:void 0;let o;try{o=this.s[1].validateToken}catch{return}if(!this.#u(n))return;if(void 0===o)return void this.#m(t,e,n,s);if(!0===t.ready&&void 0===i)return void this.#m(t,e,n,void 0);const a={generation:n,message:t,origin:e,messageRevision:s,settled:!1,approved:!1};let l;this.s[6].push(a);try{l=o(t.previewToken,e)}catch{return void this.#v(a,!1)}"boolean"!=typeof l?Promise.resolve(l).then(t=>{this.#v(a,!0===t)},()=>{this.#v(a,!1)}):this.#v(a,l)}#v(t,e){this.#u(t.generation)&&(t.approved=e,t.settled=!0,this.#y(t.generation))}#y(t){for(;this.#u(t);){const e=this.s[6][this.s[7]];if(void 0===e)return;if(this.#f(e.origin,t)){if(!e.settled)return;this.#b(e)&&(e.approved?this.#m(e.message,e.origin,e.generation,e.messageRevision):this.#d("token",e.origin,e.generation))}else{if(!this.#b(e))continue;this.#d("origin",e.origin,e.generation)}}}#m(t,e,n,i){if(!this.#u(n))return;let r;try{r=this.s[1].onUpdate}catch{return}this.#u(n)&&(void 0===i?this.#g(r,t,e):this.#g(r,t,e,i))}#d(t,e,n){if(!this.#u(n))return;let i;try{i=this.s[1].onInvalid}catch{return}this.#u(n)&&void 0!==i&&this.#g(i,t,e)}#f(t,e){if(!this.#u(e))return!1;try{return!0===this.s[0](t)&&this.#u(e)}catch{return!1}}#g(t,...e){try{P(t(...e))}catch{}}#u(t){return void 0!==this.s[3]&&this.s[4]===t}#b(t){const e=this.s;return e[6][e[7]]===t&&(e[7]+=1,e[7]===e[6].length?(this.#h(),!0):(e[7]>=1024&&2*e[7]>=e[6].length&&(e[6]=e[6].slice(e[7]),e[7]=0),!0))}#h(){this.s[6]=[],this.s[7]=0}};function O(t,e){return void 0===t||e(t)}function M(t,e){return null==t||e(t)}function L(t){if("object"!=typeof t||null===t)return!1;const e=Object.getPrototypeOf(t);return null===e||null===Object.getPrototypeOf(e)}var E=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],I=class{s;constructor(t){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]);const 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]}},U=class{s;constructor(t){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!1;const e=this.s[0];return this.s[0]=t,this.s[1](t,e),!0}};function F(t){return(...e)=>{try{P(t(...e))}catch{}}}function j(){}var D=F((...t)=>console.error(...t)),H=F((...t)=>console.warn(...t)),G=F((...t)=>console.debug(...t));function z(t){for(const e of t){const t=e.codePointAt(0);if(void 0!==t&&(t<=31||127===t))return!0}return!1}function W(t){if(void 0===t||0===t.length||t.length>128||"."===t||".."===t||t.includes("/")||t.includes("\\")||t.includes("?")||t.includes("#")||z(t))return!1;try{return encodeURIComponent(t),!0}catch{return!1}}var V=class{s;constructor(t){const e=t.serverURL.replace(/\/+$/,""),n=t.apiRoute??"/api";this.s=[e,n.startsWith("/")?n:`/${n}`,t.depth??1,t.fetchFn,void 0===t.log?j:F(t.log),null,0,0]}canMerge(t){try{return t.globalSlug?W(t.globalSlug):!!W(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("\\")||z(t))return!1;try{return encodeURIComponent(t),!0}catch{return!1}}(t.data.id)}catch{return!1}}async merge(t){if(this.s[7]>0)return{status:"superseded"};const e=this.s[6]+1;this.s[6]=e;const n=this.s[5];this.s[5]=null;let i=null;try{if(n?.abort(),!B(this.s,e))return{status:"superseded"};if(!this.canMerge(t))return B(this.s,e)?{status:"unavailable"}:{status:"superseded"};if(!B(this.s,e))return{status:"superseded"};const r=this.s[3]??("function"==typeof fetch?fetch:void 0);if(!B(this.s,e))return{status:"superseded"};if(void 0===r)return{status:"unavailable"};if(i=new AbortController,!B(this.s,e))return i.abort(),{status:"superseded"};this.s[5]=i;const s=t.globalSlug?`globals/${encodeURIComponent(t.globalSlug)}`:`${encodeURIComponent(t.collectionSlug??"")}/${encodeURIComponent(String(t.data.id))}`,o=`${this.s[0]}${this.s[1]}/${s}`,a=JSON.stringify({data:t.data,depth:this.s[2],flattenLocales:!1,...void 0!==t.locale?{locale:t.locale}:{}});if(!B(this.s,e))return{status:"superseded"};const l=await r(o,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:a,signal:i.signal});if(!B(this.s,e)||_(i.signal))return{status:"superseded"};const u=l.ok;if(!B(this.s,e))return{status:"superseded"};if(!u){const t=l.status;return B(this.s,e)?(this.s[4]("merge HTTP",t,o),B(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"superseded"}}const c=await l.json();return!B(this.s,e)||_(i.signal)?{status:"superseded"}:null===c||"object"!=typeof c||Array.isArray(c)?(this.s[4]("merge invalid",o),B(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"merged",doc:c}}catch(t){return!B(this.s,e)||null!==i&&_(i.signal)?{status:"superseded"}:(this.s[4]("merge exception",t),B(this.s,e)?{status:"unavailable"}:{status:"superseded"})}finally{null!==i&&B(this.s,e)&&this.s[5]===i&&(this.s[5]=null)}}destroy(){this.s[6]+=1;const t=this.s[5];this.s[5]=null,this.s[7]+=1;try{t?.abort()}finally{this.s[7]-=1}}};function B(t,e){return t[6]===e}function _(t){return t.aborted}var q=new Set(["http:","https:","mailto:","tel:"]),J=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,Q=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/;function isSafeUrl(t){if("string"!=typeof t||0===t.length)return!1;const e=t.trim();if(0===e.length)return!1;if(J.test(e))return!1;if(e.startsWith("#")||e.startsWith("?"))return!0;if(e.startsWith("//"))return!0;if(e.startsWith("/"))return!0;try{const t=new URL(e);return q.has(t.protocol)}catch{return Q.test(e)}}function isExternalHttpUrl(t){if(!isSafeUrl(t))return!1;const e=t.trim();return/^https?:\/\//i.test(e)||/^\/\/[^/]/.test(e)}var X=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Y=new Set(["href","src","poster","cite","action","xlink:href","data"]),K=new WeakSet;function Z(t){return K.add(t),t}var tt=class{s;constructor(t,e){const n=e.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):t=>setTimeout(()=>{t(performance.now())},0)),i=e.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):t=>{clearTimeout(t)});this.s=[t,e.debounceMs??50,e.isVisible,e.visibilityGateThreshold??50,e.disableVisibilityGate??!1,e.getCacheSize,e.onFlush,n,i,new Map,new Map,new Set,null,0,null,0,null,!1]}schedule(t){if(void 0!==t.identity){if(this.s[17])return;if(!et(t.identity,this.s[16]))return}const e=this.s[9],n=e.get(t.target.element);n?(n.value=t.value,n.allFields=t.allFields,n.identity=t.identity,n.data=t.data):e.set(t.target.element,{...t,identity:t.identity,data:t.data}),this.#w()}acceptRevision(t){const e=this.s[16];var n,i;et(t,e)||null!==e&&(i=e,((n=t).generation!==i.generation?n.generation-i.generation:n.revision-i.revision)<0)||(this.#S(),this.#A(),this.s[16]=t,this.s[17]=!1)}cancelRevision(t){et(t,this.s[16])&&(this.#S(),this.#A(),this.s[17]=!0)}flushNow(){return this.#S(),this.#T()}notifyVisible(t){const e=this.s[10],n=e.get(t);if(!n)return;if(e.delete(t),!this.#k(n))return;const i=performance.now(),r=this.#C(n)?1:0;this.s[6]?.(this.#x(n,r,0,performance.now()-i,1===r?[n.target.fieldName]:[]))}retarget(t){this.#N(this.s[9],t),this.#N(this.s[10],t);for(const e of this.s[11])this.#N(e,t)}forget(t){this.s[9].delete(t),this.s[10].delete(t);for(const e of this.s[11])e.delete(t)}destroy(){this.#S(),this.#A(),this.s[16]=null,this.s[17]=!1}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}get gateThreshold(){return this.s[3]}get gateActive(){return!this.s[4]&&this.s[5]()>this.s[3]}#w(){const t=this.s[13]+=1,e=this.s[12];if(this.s[12]=null,null!==e&&clearTimeout(e),this.s[13]!==t)return;const n=setTimeout(()=>{this.s[13]===t&&(this.s[12]=null,this.#$())},this.s[1]);this.s[13]===t&&(this.s[12]=n)}#$(){const 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 n=!1;const i=this.s[7](()=>{this.s[15]===t&&(n=!0,this.s[14]=null,this.#T())});n||this.s[15]!==t||(this.s[14]=i)}#T(){const t=performance.now(),e=!this.s[4]&&this.s[5]()>this.s[3],n=this.s[9];this.s[9]=new Map;let i=0;const r=[];let s,o=0;this.s[11].add(n);try{for(const t of n.values()){if(!this.#k(t))continue;const n=!e||this.s[2](t.target.element);this.#k(t)&&(s??=t,n?(this.s[10].delete(t.target.element),this.#C(t)&&(i+=1,r.push(t.target.fieldName))):(this.s[10].set(t.target.element,t),o+=1))}}finally{this.s[11].delete(n)}const a=this.#x(s,i,o,performance.now()-t,r);return this.s[6]?.(a),a}#k(t){return void 0===t.identity||!this.s[17]&&et(t.identity,this.s[16])}#C(t){const e=this.s[0];return!1!==e(t)||(n=e,!K.has(n));var n}#N(t,e){const n=t.get(e.element);void 0!==n&&(n.target.fieldName===e.fieldName&&n.target.locale===e.locale?n.target=e:t.delete(e.element))}#A(){this.s[9].clear(),this.s[10].clear();for(const t of this.s[11])t.clear()}#x(t,e,n,i,r){return{applied:e,appliedFields:r,deferred:n,durationMs:i,...void 0!==t?.identity?{identity:t.identity}:{},...void 0!==t?.data?{data:t.data}:{}}}#S(){const 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)}};function et(t,e){return null!==e&&t.generation===e.generation&&t.revision===e.revision}var nt="1.8.0",it=new Set(["__proto__","prototype","constructor"]);function rt(t,e,n,i=!1){if(i&&void 0!==n){const i=st(t,`${e}_${n}`);if(void 0!==i)return i}const r=st(t,e);if(void 0!==r)return r;if(e.includes(".")){let n=t,i=!0;for(const t of e.split(".")){if(it.has(t)||null===n||"object"!=typeof n){i=!1;break}if(n=st(n,t),void 0===n){i=!1;break}}if(i)return n}return void 0===n?void 0:st(t,`${e}_${n}`)}function st(t,e){if(!it.has(e)&&Object.prototype.hasOwnProperty.call(t,e))return t[e]}function detectInitialLocale(){const t=function(){if("undefined"==typeof document)return;const t=document.documentElement.getAttribute("lang");return null===t||0===t.length?void 0:t}();if(void 0!==t)return t;const e=function(){if("undefined"==typeof navigator)return;const t=navigator.language;return"string"==typeof t&&t.length>0?t:void 0}();return void 0!==e?e:"en"}var ot="payload-live-preview-a11y";function at(t){return/^de(?:[-_]|$)/i.test(t)}var lt=new WeakMap;function ut(t){null!==t[4]&&(clearTimeout(t[4]),t[4]=null),t[2]?.remove(),t[2]=null}var ct=class{s;constructor(t,e){const n=e??("undefined"==typeof document?null:document),i=n?.documentElement.getAttribute("lang")??"";this.s=[at(t??(i.length>0?i:detectInitialLocale())),n,null]}mount(){const t=this.s[1];if(null==t?.body)return null;let e=this.s[2];null===e&&(e=function(t){let e=lt.get(t);return e??=[null,!1,null,0,null],lt.set(t,e),e[3]+=1,e}(t),this.s[2]=e);const n=e[0];if(n?.isConnected&&n.ownerDocument===t)return n;if(null!==n){const t=e[1];ut(e),t&&n.remove()}let i=t.getElementById(ot);return e[1]=null===i,i||(i=t.createElement("div"),i.id=ot,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-atomic","true"),i.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(i)),e[0]=i,i}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?"Änderung":"Änderungen"} angewendet`:`${String(t)} ${1===t?"change":"changes"} applied`)}detach(){const t=this.s[2],e=this.s[1];if(null===t||null===e)return;if(this.s[2]=null,t[3]-=1,t[3]>0)return;const n=t[0];null!==n&&ut(t),t[1]&&n?.remove(),t[0]=null,lt.delete(e)}say(t){const e=this.mount(),n=this.s[2];if(null===e||null===n)return;let i=n[2];i?.parentNode!==e?(i?.remove(),i=e.ownerDocument.createTextNode(e.hasChildNodes()?` ${t}`:t),n[2]=i,e.appendChild(i)):i.data=null===i.previousSibling?t:` ${t}`,null!==n[4]&&clearTimeout(n[4]);const r=setTimeout(()=>{n[4]===r&&n[0]===e&&ut(n)},1500);n[4]=r}},dt=new Set(["tabs","row","collapsible"]);function ht(t,e=""){const n=new Map;return ft(t,e,n),n}function ft(t,e,n){for(const i of t){if(dt.has(i.type)){i.fields&&ft(i.fields,e,n);continue}if("group"===i.type){const t=""===e?i.name:`${e}.${i.name}`;n.set(t,i),i.fields&&ft(i.fields,t,n);continue}const t=""===e?i.name:`${e}.${i.name}`;if(n.set(t,i),"array"===i.type&&i.fields)ft(i.fields,`${t}.*`,n);else if("blocks"===i.type&&i.blocks)for(const e of i.blocks)ft(e.fields,`${t}.*.${e.slug}`,n)}}function pt(t){if("object"!=typeof t||null===t)return;const e=t.id;return"string"==typeof e||"number"==typeof e?e:void 0}function gt(t){if("object"!=typeof t||null===t)return;const e=t.blockType;return"string"==typeof e?e:void 0}function mt(t,e){return e.every(t=>void 0!==pt(t))?function(t,e){const n=[],i=new Map;for(let e=0;e<t.length;e+=1){const n=pt(t[e]);void 0!==n&&i.set(n,e)}const r=new Set;for(let s=0;s<e.length;s+=1){const o=e[s],a=pt(o);if(void 0===a){n.push({kind:"insert",index:s,value:o});continue}const l=i.get(a);if(void 0===l){n.push({kind:"insert",index:s,value:o});continue}r.add(l);const u=t[l];gt(u)===gt(o)?(l!==s&&n.push({kind:"move",from:l,to:s,value:o}),vt(u,o)||n.push({kind:"update",index:s,value:o})):n.push({kind:"replace",index:s,oldValue:u,value:o})}for(let e=0;e<t.length;e+=1)r.has(e)||n.push({kind:"remove",index:e,value:t[e]});return n}(t,e):function(t,e){const n=[],i=Math.min(t.length,e.length);for(let r=0;r<i;r+=1)vt(t[r],e[r])||n.push({kind:"update",index:r,value:e[r]});if(e.length>t.length)for(let i=t.length;i<e.length;i+=1)n.push({kind:"insert",index:i,value:e[i]});if(t.length>e.length)for(let i=e.length;i<t.length;i+=1)n.push({kind:"remove",index:i,value:t[i]});return n}(t,e)}function vt(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||"object"!=typeof e||null===t||null===e)return!1;const n=t,i=e,r=Object.keys(n),s=Object.keys(i);if(r.length!==s.length)return!1;for(const t of r)if(!Object.is(n[t],i[t]))return!1;return!0}var yt={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"},bt=[0,500,1e3,2e3],wt=class{d;l;constructor(t){const e=t.emitter,n=t.renderers,i=t.resolveRenderer??(t=>n[t]),r=t.transformValue,s=t.root??("undefined"!=typeof document?document:null),o=t.readyTargets,a=t.sendReady??At,l=t.onHeartbeatTimeout,u=void 0===t.log?j:F(t.log),c=void 0===t.warn?H:F(t.warn),d=function(t){if(!1===t.enableA11y)return null;const e=void 0===t.root?void 0:9===t.root.nodeType?t.root:t.root.ownerDocument;return new ct(t.a11yLocale,e)}(t),h=void 0!==t.dataMerge?new V({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)=>{u(...t)}}):null,f=new y,p=new k({onStructuralChange:()=>{this.#P()},onVisibilityChange:(t,e)=>{e&&this.d[3].notifyVisible(t)}},{...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{}}),g=new tt(Z(t=>this.#R(t)),{...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.disableVisibilityGate?{disableVisibilityGate:t.disableVisibilityGate}:{},...void 0!==t.visibilityGateThreshold?{visibilityGateThreshold:t.visibilityGateThreshold}:{},isVisible:t=>p.isVisible(t),getCacheSize:()=>f.elementCount,onFlush:t=>{this.#O(t)}}),m=new R(t.originMatcher,{onUpdate:(t,e,n)=>{this.#M(t,e,n)},onDocumentEvent:()=>{e.emit("documentSave",{timestamp:Date.now()})},onInvalid:(t,n)=>{if("token"===t){const t=new Error(`Preview token rejected (origin: ${n})`);e.emit("error",{error:t,context:"token",code:"LP0502"})}u("LP0501 message rejected:",t,n)},...void 0!==t.validateToken?{validateToken:t.validateToken}:{}}),v=new U(()=>{}),b=new I({...void 0!==t.heartbeatMs?{timeoutMs:t.heartbeatMs}:{},onTimeout:()=>{this.#L()}});this.d=[e,f,p,g,m,v,b,n,i,r,s,o,a,l,u,c,[],d,h,!0===t.scopeBindingsByOwner,t.lockedOrigin??(()=>{})],this.l=[void 0,void 0,void 0,negotiateProtocol(void 0),!1,null,0,null,new Set,!1,!1,0,null,new Set]}start(){if(this.l[4])return!1;this.l[4]=!0;const t=this.d[10];if(St(t)&&"loading"===t.readyState){const e=()=>{if(this.l[4]){this.l[5]=null;try{this.#E()}catch(t){this.#I(),this.#U(t,"startup","LP0605")}}};this.l[5]=e;try{t.addEventListener("DOMContentLoaded",e,{once:!0})}catch(t){throw this.#I(),t}return!0}try{return this.#E(),!0}catch(t){throw this.#I(),t}}#E(){if(!this.l[4])return;const t=St(this.d[10])?this.d[10].body:this.d[10];if(null===t)throw new Error("LivePreviewRuntime: document.body unavailable");if(this.d[2].start(t),this.#F(),this.#j()&&(this.d[4].attach(),this.d[0].emitWhile("init",{timestamp:Date.now()},()=>this.l[4]),this.#j()))for(const t of bt){if(!this.#j())return;if(0===t){if(this.d[12](this.d[11]),!this.#j())return}else{const e=setTimeout(()=>{this.l[4]&&this.#D()},t);this.d[16].push(e)}}}suspend(){return!!this.l[4]&&(this.#H()&&this.d[0].emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0)}destroy(){this.l[4]&&(this.#H()&&this.d[0].emit("disconnect",{reason:"destroy",timestamp:Date.now()}),this.d[17]?.detach(),this.d[0].emit("destroy",{timestamp:Date.now()}))}#H(){this.l[7]=null,this.l[4]=!1;const t=this.l[5];this.l[5]=null,null!==t&&St(this.d[10])&&this.#G(()=>{this.d[10].removeEventListener("DOMContentLoaded",t)});for(const t of this.d[16])this.#G(()=>{clearTimeout(t)});return this.d[16].length=0,this.#G(()=>{this.d[6].stop()}),this.#G(()=>{this.d[4].detach()}),this.#G(()=>{this.d[2].stop()}),this.#G(()=>{this.d[3].destroy()}),this.#G(()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()}#I(){this.#H(),this.#G(()=>{this.d[17]?.detach()})}#G(t){try{t()}catch(t){this.d[14]("cleanup failed:",t)}}refreshCache(){this.l[4]&&this.#P()}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]}inspect(){const t=this.d[1],e=this.d[3],n=this.l[3],i=this.l[7],r=this.l[12],s=[],o=new Set;for(const[e,n]of t.entries()){s.push(e);for(const t of n)void 0!==t.owner&&o.add(t.owner)}return{version:nt,started:this.l[4],status:this.d[5].status,origins:{trusted:[...this.d[11]],locked:this.d[20]()},protocol:{ours:n.ours,theirs:n.theirs,negotiated:n.negotiated,capabilities:[...n.capabilities].sort()},revisions:{accepted:this.l[6],superseded:this.l[11],active:null===i?void 0:i.identity.revision},bindings:{elements:t.elementCount,fields:t.fieldCount,fieldNames:s.sort(),absentFields:[...this.l[13]].sort(),orphanFields:[...this.l[8]].sort(),ownerScoped:this.d[19],owners:[...o].sort()},scheduler:{pending:e.pendingCount,deferred:e.replayCount,visibilityGateThreshold:e.gateThreshold,visibilityGateActive:e.gateActive,lastFlush:null===r?void 0:{applied:r.applied,appliedFields:r.appliedFields,deferred:r.deferred,durationMs:r.durationMs}},renderers:Object.keys(this.d[7]).sort()}}#F(){if(!this.l[4])return;const t=this.d[1].buildFromRoot(this.d[10]);if(this.d[14]("cache",t),this.#j()&&(this.d[0].emitWhile("cacheRefresh",t,()=>this.l[4]),this.#j()))for(const t of this.d[1].values()){if(!this.#j())return;this.d[2].observeElement(t.element)}}#P(){if(!this.l[4])return;const t=new Map;for(const e of this.d[1].values())t.set(e.element,e),this.d[2].unobserveElement(e.element);if(this.#F(),this.#j()){for(const e of this.d[1].values()){const n=t.get(e.element);n?.fieldName===e.fieldName?this.d[3].retarget(e):this.d[3].forget(e.element),t.delete(e.element)}for(const e of t.values())this.d[3].forget(e.element)}}#z(t){const e=this.l[3];if(e.theirs===t)return;const n=negotiateProtocol(t);this.l[3]=n,n.negotiated!==e.negotiated&&this.d[14]("protocol","ours=4",`theirs=${t}`,`negotiated=${n.negotiated}`)}#M(t,e,n){if(this.d[6].kick(),void 0===t.data)return void(void 0!==t.protocolVersion&&this.#z(t.protocolVersion));if(void 0===n)return;"string"==typeof t.locale&&(this.l[0]=t.locale),Array.isArray(t.fieldSchemaJSON)&&(this.l[1]=t.fieldSchemaJSON,this.l[2]=ht(t.fieldSchemaJSON));const i={identity:n,message:t,locale:this.l[0],schema:this.l[1],schemaIndex:this.l[2],cancelled:!1};if(null!==this.l[7]&&(this.l[11]+=1),this.l[7]=i,this.d[3].acceptRevision(n),this.l[6]+=1,void 0===t.protocolVersion||(this.#z(t.protocolVersion),this.l[4]&&this.l[7]===i)){if(this.d[5].markConnected()){if(this.d[17]?.announceConnected(),this.d[0].emit("connect",{origin:e,timestamp:Date.now()}),!this.l[4]||this.l[7]!==i)return;if(this.d[14]("connection","disconnected","→","connected"),!this.l[4]||this.l[7]!==i)return}this.#W(i)}}async#W(t){const e=await this.#V(t);if(null===e||!this.l[4]||this.l[7]!==t)return;const{message:n}=t,i={fields:e,...void 0!==t.schema?{schema:t.schema}:{},..."string"==typeof n.globalSlug?{globalSlug:n.globalSlug}:{},..."string"==typeof n.collectionSlug?{collectionSlug:n.collectionSlug}:{},...void 0!==t.locale?{locale:t.locale}:{}};this.d[0].listenerCount("beforeUpdate")>0&&(!await this.d[0].emitWhile("beforeUpdate",{data:i,revision:t.identity.revision,cancel:()=>{t.cancelled=!0,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&&this.#B(t,i)}async#V(t){const{message:e}=t,n=e.data??{};if(null===this.d[18])return n;const i=await this.d[18].merge({collectionSlug:e.collectionSlug,globalSlug:e.globalSlug,data:n,locale:t.locale});return this.l[4]&&this.l[7]===t?"merged"===i.status?i.doc:"superseded"===i.status?null:n:null}#B(t,e){if(!this.l[4]||this.l[7]!==t)return;const n=()=>this.l[4]&&this.l[7]===t,i=this.#_(t,e.fields);for(const[r,s]of this.d[1].entries()){if(!this.l[4]||this.l[7]!==t)return;for(const o of s){if(!1!==i&&!A(o.owner,i))continue;const s=rt(e.fields,r,o.locale??t.locale,void 0!==o.locale);if(void 0===s){this.l[13].add(r);continue}if(!this.l[4]||this.l[7]!==t)return;const a=this.#q(o,s,e.fields,n);if(!this.l[4]||this.l[7]!==t)return;const l={target:o,value:a,allFields:e.fields,identity:t.identity,data:e};if(!this.l[4]||this.l[7]!==t)return;this.d[3].schedule(l)}}this.#J(e.fields,t.locale,i)}#_(t,e){if(!this.d[19])return!1;const{message:n}=t,i=function(t){if(S(t.globalSlug))return[(e=t.globalSlug,`global:${e}`)];var e;if(!S(t.collectionSlug))return null;const n=w(t.collectionSlug);return S(t.documentId)?[n,w(t.collectionSlug,t.documentId)]:[n]}({globalSlug:"string"==typeof n.globalSlug?n.globalSlug:void 0,collectionSlug:"string"==typeof n.collectionSlug?n.collectionSlug:void 0,documentId:T(e)});return null!==i||this.l[9]||(this.l[9]=!0,this.d[15]("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),i}#Q(t){for(const e of this.d[1].values())if(A(e.owner,t))return!0;return!1}#X(t,e){const n=this.d[1].get(t);return void 0!==n&&(!1===e||n.some(t=>A(t.owner,e)))}#J(t,e,n){if(0===this.d[1].fieldCount)return;if(!1!==n&&!this.#Q(n))return;let i;for(const[r,s]of Object.entries(t)){if(this.l[8].has(r))continue;if(kt.has(r))continue;if(!Ct(s))continue;const t=xt(r,e);if(!(this.#X(r,n)||t!==r&&this.#X(t,n))){if(void 0===i){i=new Set;for(const[t,e]of this.d[1].entries())for(const r of e)(!1===n||A(r.owner,n))&&void 0!==r.locale&&i.add(`${t}_${r.locale}`)}i.has(r)||(this.l[8].add(r),this.d[15](`[live-preview] LP0201: update arrived for field "${r}" but no <… 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.`))}}}#q(t,e,n,i){if(void 0===this.d[9])return e;try{const r=this.d[9](t.fieldName,e,{element:t.element,allFields:n},i),s=P(r);if(!i())return e;if(s)throw new TypeError(`Transform for "${t.fieldName}" returned a Promise/thenable; transforms must be synchronous`);return r}catch(t){if(!i())return e;const n=t instanceof Error?t:new Error(String(t));return this.d[0].emit("error",{error:n,context:"transform",code:"LP0602"}),e}}#j(){return this.l[4]}#Y(t){0!==t.deferred&&(this.l[10]||(this.l[10]=!0,this.d[15](`[live-preview] LP0301: visibility gate held ${String(t.deferred)} offscreen update(s) until scrolled into view; see visibilityGateThreshold.`)))}#R(t){const e=this.l[7];if(null===e||void 0===t.identity||!Tt(e.identity,t.identity)||!this.l[4]||this.l[7]!==e)return!1;const n=void 0!==e.schemaIndex?function(t,e){if(t.has(e))return t.get(e);const n=e.replace(/\.\d+(?=\.|$)/g,".*");return t.has(n)?t.get(n):void 0}(e.schemaIndex,t.target.fieldName):void 0,i=t.value;let r,s=function(t,e){if(t.explicitFieldType)return t.fieldType;if(void 0!==e){const t=function(t){if(Object.prototype.hasOwnProperty.call(yt,t))return yt[t]}(e);if(void 0!==t)return t}return t.fieldType}(t.target,n?.type);"text"===s&&!0!==t.target.explicitFieldType&&function(t){if("object"!=typeof t||null===t)return!1;if(!("root"in t))return!1;const e=t.root;return"object"==typeof e&&null!==e&&Array.isArray(e.children)}(i)&&(s="richText");try{r=this.d[8](s)}catch(t){if(!this.l[4]||this.l[7]!==e)return!1;const n=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:n,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===e),!1}if(!this.l[4]||this.l[7]!==e)return!1;const o=this.d[0].listenerCount("elementUpdate")>0,a=o?"INPUT"===(l=t.target.element).tagName||"TEXTAREA"===l.tagName?l.value:"IMG"===l.tagName?l.src:l.textContent:void 0;var l;if(!this.l[4]||this.l[7]!==e)return!1;const u={allFields:t.allFields,locale:t.target.locale??e.locale,schema:n};try{if(void 0!==t.target.targetAttribute){const e=function(t,e,n){const i=e.toLowerCase().trim();if(0===i.length)return"blocked";if(i.startsWith("on"))return"blocked";if(X.has(i))return"blocked";if(null==n)return t.removeAttribute(i),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";const r=String(n);return Y.has(i)&&!isSafeUrl(r)?"blocked":(t.setAttribute(i,r),"applied")}(t.target.element,t.target.targetAttribute,i);if("blocked"===e)return this.d[15](`[live-preview] LP0401: refused to write field "${t.target.fieldName}" into attribute "${t.target.targetAttribute}" (unsafe attribute or value)`),!1}else{if(!r)return this.d[14]("no renderer for",s),!1;{const e=function(t,e,n,i){return t.render(e,n,i)}(r,t.target,i,u);if(!1===e&&function(t){return K.has(t.render)}(r))return!1}}}catch(t){if(!this.l[4]||this.l[7]!==e)return!1;const n=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:n,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===e),!1}return!(!this.l[4]||this.l[7]!==e)&&(o&&this.d[0].emitWhile("elementUpdate",{element:t.target.element,fieldName:t.target.fieldName,previousValue:a,nextValue:i,revision:e.identity.revision},()=>this.l[4]&&this.l[7]===e),this.l[4]&&this.l[7]===e)}#O(t){this.l[12]=t,this.#Y(t);const{identity:e,data:n}=t;if(0===t.applied||void 0===e||void 0===n)return;const i=this.l[7];if(null===i||!this.l[4]||this.l[7]!==i||!Tt(i.identity,e))return;const r=()=>this.l[4]&&this.l[7]===i&&Tt(i.identity,e);this.d[17]?.announceUpdate(t.applied),r()&&0!==this.d[0].listenerCount("afterUpdate")&&this.d[0].emitWhile("afterUpdate",{data:n,updatedCount:t.applied,durationMs:t.durationMs,revision:e.revision},r)}#L(){if(!this.#j())return;this.d[4].advanceGeneration();const t=this.l[7];this.l[7]=null,null!==t&&this.d[3].cancelRevision(t.identity),this.d[18]?.destroy();const e=this.d[5].markDisconnected();try{this.d[13]?.()}catch(t){this.d[14]("heartbeat:",t)}if(this.#j()){if(e&&this.#K()){if(this.d[17]?.announceDisconnected(),this.d[0].emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.#K()),!this.#j())return;if(this.#K()&&(this.d[14]("connection","connected","→","disconnected"),!this.#j()))return}this.#j()&&this.#D()}}#D(){try{this.d[12](this.d[11])}catch(t){this.#U(t,"ready","LP0606")}}#U(t,e,n){const i=t instanceof Error?t:new Error(String(t));this.d[0].emit("error",{error:i,context:e,code:n})}#K(){return this.l[4]&&"disconnected"===this.d[5].status&&null===this.l[7]}};function St(t){return 9===t.nodeType}function At(t){if("undefined"==typeof window)return;const e=[];window.parent!==window&&e.push(window.parent),window.opener instanceof Window&&e.push(window.opener),R.sendReady(e,t)}function Tt(t,e){return t.generation===e.generation&&t.revision===e.revision}var kt=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function Ct(t){return null!=t&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)}function xt(t,e){if(!e)return t;const n=`_${e}`;return t.endsWith(n)?t.slice(0,-n.length):t}var Nt,$t=class{#Z=new Map;#tt=new Map;on(t,e){return this.#et(this.#Z,t,e)}once(t,e){return this.#et(this.#tt,t,e)}off(t,e){this.#nt(this.#Z,t,e),this.#nt(this.#tt,t,e)}async emit(t,e){await this.#it(t,e)}async emitWhile(t,e,n){return this.#it(t,e,n)}async#it(t,e,n){const i=()=>n?.()??!0;if(!i())return!1;const r=this.#Z.get(t);if(r)for(const n of[...r]){if(!i())return!1;if(await this.#rt(n,e,t),!i())return!1}if(!i())return!1;const s=this.#tt.get(t);if(s&&s.size>0){const n=[...s];this.#tt.delete(t);for(const r of n){if(!i())return!1;if(await this.#rt(r,e,t),!i())return!1}}return i()}listenerCount(t){return(this.#Z.get(t)?.size??0)+(this.#tt.get(t)?.size??0)}removeAllListeners(t){if(void 0===t)return this.#Z.clear(),void this.#tt.clear();this.#Z.delete(t),this.#tt.delete(t)}eventNames(){const t=new Set;for(const e of this.#Z.keys())t.add(e);for(const e of this.#tt.keys())t.add(e);return[...t]}#et(t,e,n){let i=t.get(e);return i||(i=new Set,t.set(e,i)),i.add(n),()=>{this.#nt(t,e,n)}}#nt(t,e,n){const i=t.get(e);void 0!==i&&(i.delete(n),0===i.size&&t.delete(e))}async#rt(t,e,n){try{await t(e)}catch(t){const e="string"==typeof n||"number"==typeof n?String(n):"<event>";D(`[live-preview] LP0601: handler for "${e}" threw:`,t)}}};function isInIframe(){if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch{return!0}}function isInPopup(){return"undefined"!=typeof window&&null!=window.opener}function isInPreviewContext(){return isInIframe()||isInPopup()}function isDevMode(){const t=function(){if("undefined"==typeof process)return;const t=process.env.NODE_ENV;return"string"==typeof t?t:void 0}();if(void 0!==t)return"production"!==t;const e=function(){const t=Rt();if(!t)return;const e=t.DEV;return"boolean"==typeof e?e:void 0}();if(void 0!==e)return e;if("undefined"!=typeof window){const t=window.location.hostname;if("localhost"===t||"127.0.0.1"===t)return!0}return!1}function Pt(t){if("undefined"!=typeof process){const e=process.env[t];if("string"==typeof e&&e.length>0)return e}const e=Rt();if(e){const n=e[t];if("string"==typeof n&&n.length>0)return n}}function Rt(){if("undefined"==typeof __INLINE_RUNTIME_BUILD__||!__INLINE_RUNTIME_BUILD__){if(void 0!==Nt)return Nt??void 0;Nt=null;try{const t=new Function("try { return import.meta && import.meta.env; } catch (_) { return undefined; }")();if(t&&"object"==typeof t)return Nt=t}catch{}}}var Ot=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,Mt=/^https?:\/\/[^/?#\s]+$/i,Lt=["PAYLOAD_ADMIN_ORIGIN","PUBLIC_PAYLOAD_ADMIN_ORIGIN","NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN"],Et=class{#st;constructor(t={}){const e=new Set;for(const n of t.additionalOrigins??[]){const t=Ut(n);void 0!==t&&e.add(t)}for(const t of Lt){const n=Pt(t);if(void 0!==n)for(const t of n.split(",")){const n=Ut(t);void 0!==n&&e.add(n)}}let n;if(t.enableReferrerDetection??1){const e=t.referrer??("undefined"!=typeof document?document.referrer:"");if(e.length>0)try{const t=new URL(e).origin;t&&"null"!==t&&(n=t)}catch{}}const i=(t.enableLocalhostMatching??!0)&&(t.forceDevMode??isDevMode());this.#st=[e,n,i,void 0!==n,void 0]}matches(t){return 0!==t.length&&"null"!==t&&(void 0!==this.#st[4]?t===this.#st[4]:!!this.#st[0].has(t)||0===this.#st[0].size&&void 0!==this.#st[1]&&t===this.#st[1]||!(!this.#st[2]||!Ot.test(t)))}lockOrigin(t){return!!this.matches(t)&&(this.#st[4]=t,!0)}unlockOrigin(){const t=this.#st[4];return this.#st[4]=void 0,t}get lockedOrigin(){return this.#st[4]}enumerate(){if(void 0!==this.#st[4])return[this.#st[4]];const t=new Set(this.#st[0]);if(0===this.#st[0].size&&void 0!==this.#st[1]&&t.add(this.#st[1]),this.#st[2])for(const e of It)t.add(`http://localhost:${String(e)}`),t.add(`http://127.0.0.1:${String(e)}`);return[...t]}get referrerWasAvailable(){return this.#st[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#st[0].size>0||this.#st[2]||void 0!==this.#st[1])}get isReferrerOnlyTrust(){return!(this.#st[0].size>0||this.#st[2]||void 0===this.#st[1])}},It=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function Ut(t){const e=t.trim();if(0!==e.length)try{const t=new URL(e);if("http:"!==t.protocol&&"https:"!==t.protocol)return;if(!Mt.test(t.origin))return;return t.origin}catch{return}}var Ft,jt=()=>{},Dt=class{#ot;#at;#lt=new Set;#st="staging";constructor(t,e){this.#ot=t,this.#at=e}assertOpen(){if("closed"===this.#st)throw new Error(`Plugin context for "${this.#ot}" is no longer active`)}get active(){return"active"===this.#st}eligible(){return"closed"!==this.#st}own(t){return this.assertOpen(),this.#ut({acquire:void 0,finalize:void 0,cleanup:t,disposed:!1})}stage(t,e){this.assertOpen();const n={acquire:t,finalize:e,cleanup:void 0,disposed:!1},i=this.#ut(n);if("active"===this.#st)try{this.#ct(n)}catch(t){throw this.#dt(n),t}return i}commit(){if("staging"!==this.#st)throw new Error(`Plugin context for "${this.#ot}" cannot be committed`);this.#st="committing";try{for(const t of this.#lt)this.#ct(t);this.#st="active"}catch(t){throw this.close(),t}}close(){if("closed"!==this.#st){this.#st="closed";for(const t of[...this.#lt].reverse())this.#dt(t);this.#lt.clear()}}#ut(t){return this.#lt.add(t),()=>{this.#dt(t)}}#ct(t){if(t.disposed||void 0!==t.cleanup||void 0===t.acquire)return;const e=t.acquire();t.cleanup=e??jt}#dt(t){if(t.disposed)return;t.disposed=!0,this.#lt.delete(t);const e=t.cleanup;if(t.cleanup=void 0,void 0!==e)try{P(e())&&this.#at(`plugin "${this.#ot}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(t){this.#at(`plugin "${this.#ot}" cleanup failed:`,t)}try{t.finalize?.()}catch(t){this.#at(`plugin "${this.#ot}" cleanup failed:`,t)}}},Ht=class extends $t{#ht;#ft;#pt=new Set;constructor(t,e){super(),this.#ht=t,this.#ft=e}on(t,e){return this.#gt("on",t,e)}once(t,e){return this.#gt("once",t,e)}off(t,e){const n=e;for(const e of[...this.#pt])e.event===t&&e.handler===n&&e.dispose()}emit(t,e){return this.#ft.assertOpen(),this.#ht.emit(t,e)}emitWhile(t,e,n){return this.#ft.assertOpen(),this.#ht.emitWhile(t,e,()=>{if(!this.#ft.eligible())return!1;const t=n();return!!this.#ft.eligible()&&t})}listenerCount(t){let e=0;for(const n of this.#pt)n.event===t&&(e+=1);return e}removeAllListeners(t){for(const e of[...this.#pt])void 0!==t&&e.event!==t||e.dispose()}eventNames(){const t=new Set;for(const e of this.#pt)t.add(e.event);return[...t]}#gt(t,e,n){this.#ft.assertOpen();const i=n,r=[...this.#pt].find(n=>n.kind===t&&n.event===e&&n.handler===i);if(void 0!==r)return r.dispose;let s=jt,o=!0;const a=async e=>{this.#ft.active&&o&&("once"===t&&s(),await n(e))},l={kind:t,event:e,handler:i,dispose:jt};return s=this.#ft.stage(()=>this.#ht[t](e,a),()=>{o=!1,this.#pt.delete(l)}),l.dispose=s,this.#pt.add(l),s}},Gt=class{#ht;#mt;#vt;#yt;#at;#bt=new Map;#wt=new Map;#St=new Map;#At=new Set;#Tt=new Map;#kt=Promise.resolve();#Ct=0;constructor(t){this.#ht=t.events,this.#mt=t.config,this.#vt=t.registerFieldRenderer,this.#at=F(t.log);const e=t.onTransformError;this.#yt=void 0===e?void 0:F((...t)=>{const n=t[0];if(n instanceof Error)try{return e(n)}catch(t){return void this.#at("transform error reporter failed:",t)}})}register(t){return this.#Ct>0?this.#xt(t):this.#Nt(()=>this.#xt(t))}unregister(t){return this.#Ct>0?this.#$t(t):this.#Nt(async()=>{await this.#$t(t)})}destroyAll(){return this.#Ct>0?this.#Pt():this.#Nt(async()=>{await this.#Pt()})}applyTransforms(t,e,n,i){const r=this.#Tt.get(t);if(void 0===r||0===r.length)return e;let s=e;for(const o of[...r]){if(!o.active)continue;const{transform:r}=o;if(!1===i?.())return e;try{s=r(s,{fieldName:t,element:n.element,allFields:n.allFields});const o=P(s);if(!1===i?.())return e;if(o)throw new TypeError(`Transform for "${t}" returned a Promise/thenable; transforms must be synchronous`)}catch(n){if(!1===i?.())return e;const r=n instanceof Error?n:new Error(String(n));return this.#at(`transform for "${t}" failed:`,r),this.#yt?.(r),e}}return s}list(){return[...this.#bt.keys()]}get size(){return this.#bt.size}async#xt(t){if(this.#bt.has(t.name)||this.#wt.has(t.name)||this.#St.has(t.name))return void this.#at(`plugin "${t.name}" already registered`);const e=new Dt(t.name,this.#at),n=this.#Rt(t.name,e),i={scope:e,cancelled:!1};this.#wt.set(t.name,i);try{if(await this.#Ot(()=>t.init(n)),i.cancelled)return;e.commit()}catch(n){return e.close(),void(i.cancelled||this.#at(`plugin "${t.name}" init failed:`,n))}finally{this.#wt.get(t.name)===i&&this.#wt.delete(t.name)}this.#bt.set(t.name,{plugin:t,scope:e}),this.#at(`plugin "${t.name}" registered`)}#Rt(t,e){return{events:new Ht(this.#ht,e),registerFieldRenderer:t=>{e.stage(()=>{const e=this.#vt(t);return"function"==typeof e?e:void 0})},registerTransform:(t,n)=>{const i={transform:n,active:!1};e.stage(()=>{i.active=!0;const e=this.#Tt.get(t);return void 0===e?this.#Tt.set(t,[i]):e.push(i),()=>{i.active=!1;const e=this.#Tt.get(t);if(void 0===e)return;const n=e.indexOf(i);n>=0&&e.splice(n,1),0===e.length&&this.#Tt.delete(t)}})},registerCleanup:t=>{e.own(t)},getConfig:()=>this.#mt,log:(...e)=>{this.#at(`[${t}]`,...e)}}}#$t(t){const e=this.#wt.get(t);if(void 0!==e)return e.cancelled=!0,e.scope.close(),Promise.resolve();const n=this.#St.get(t);if(void 0!==n)return this.#At.has(t)?Promise.resolve():n;const i=this.#bt.get(t);if(void 0===i)return Promise.resolve();this.#bt.delete(t),i.scope.close();const r=Promise.resolve().then(()=>this.#Mt(t,i.plugin));return this.#St.set(t,r),r.then(()=>{this.#St.get(t)===r&&this.#St.delete(t)}),r}async#Mt(t,e){if(void 0!==e.destroy){this.#At.add(t);try{await this.#Ot(()=>e.destroy?.())}catch(e){this.#at(`plugin "${t}" destroy failed:`,e)}finally{this.#At.delete(t)}}}async#Pt(){for(const t of this.#wt.values())t.cancelled=!0,t.scope.close();const t=[...this.#bt.keys()];for(const e of t)await this.#$t(e)}async#Ot(t){this.#Ct+=1;try{await t()}finally{this.#Ct-=1}}#Nt(t){const e=this.#kt.then(t);return this.#kt=e.catch(t=>{this.#at("plugin manager mutation failed:",t)}),e}},zt=class{#Lt;#Et;#It=new Map;constructor(t){this.#Lt=t,this.#Et={...t}}get renderers(){return this.#Et}resolve(t){return this.#Et[t]}register(t){const e=t.name,n={renderer:t},i=this.#It.get(e);void 0===i?this.#It.set(e,[n]):i.push(n),this.#Et[e]=t;let r=!0;return()=>{if(!r)return;r=!1;const t=this.#It.get(e);if(void 0===t)return;const i=t.indexOf(n);if(i<0)return;const s=i===t.length-1;if(t.splice(i,1),0===t.length&&this.#It.delete(e),!s)return;const o=t.at(-1),a=o?.renderer??this.#Lt[e];void 0===a?Reflect.deleteProperty(this.#Et,e):this.#Et[e]=a}}},Wt=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"]),Vt=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),Bt=new Set(["id","class","lang","dir","title","role","tabindex"]),_t={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"])},qt=new Set(["href","src","cite","poster"]),Jt=class extends Error{name="SanitizerEnvironmentError"};function sanitizeHtml(t,e){const n=Qt();if(!n)throw new Jt("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===t)return"";const i=function(t){if(!t){const t=new Map;for(const[e,n]of Object.entries(_t))t.set(e,n);return{allowedTags:Wt,attrByTag:t}}const e=new Set(Wt);for(const n of t.additionalAllowedTags??[])e.add(n);const n=new Map;for(const[t,e]of Object.entries(_t))n.set(t,e);for(const[e,i]of Object.entries(t.additionalAllowedAttributes??{})){const t=n.get(e),r=new Set(t??[]);for(const t of i)r.add(t);n.set(e,r)}return{allowedTags:e,attrByTag:n}}(e),r=n.createElement("template");return r.innerHTML=t,Xt(r.content,i),r.innerHTML}function Qt(){return Ft||("undefined"!=typeof document?document:void 0)}function Xt(t,e){for(const n of Array.from(t.childNodes))1===n.nodeType?Yt(n,e):8===n.nodeType&&n.remove()}function Yt(t,e){const n=t.tagName.toLowerCase();if(Vt.has(n))t.remove();else{if(!e.allowedTags.has(n)){Xt(t,e);const n=t.parentNode;if(n){for(;t.firstChild;)n.insertBefore(t.firstChild,t);t.remove()}return}!function(t,e,n){const i=n.attrByTag.get(e);for(const e of Array.from(t.attributes)){const n=e.name.toLowerCase();n.startsWith("on")?t.removeAttribute(e.name):"style"!==n?Bt.has(n)||n.startsWith("aria-")||n.startsWith("data-")||(i?.has(n)?qt.has(n)&&!isSafeUrl(e.value)?t.removeAttribute(e.name):"srcset"!==n||Kt(e.value)||t.removeAttribute(e.name):t.removeAttribute(e.name)):t.removeAttribute(e.name)}}(t,n,e),"a"===n&&function(t){const e=t.getAttribute("href");null!==e&&isExternalHttpUrl(e)&&(t.setAttribute("rel","noopener noreferrer"),t.hasAttribute("target")||t.setAttribute("target","_blank"))}(t),Xt(t,e)}}function Kt(t){const e=t.split(",");for(const t of e){const e=t.trim();if(0===e.length)continue;const n=e.search(/\s/);if(!isSafeUrl(-1===n?e:e.slice(0,n)))return!1}return!0}var Zt=new Map;function te(t,e){Zt.set(t,e)}var ee={1:"left",2:"center",3:"right",4:"justify"},ne=new Set(["left","center","right","justify","start","end"]);function ie(t){const e=t.format;if("string"==typeof e&&ne.has(e))return e;if("number"==typeof e){const t=ee[e];if(void 0!==t)return t}}function re(t){const e=t.indent;return"number"==typeof e&&e>0?e:0}function se(t){return"rtl"===t.direction?' dir="rtl"':"ltr"===t.direction?' dir="ltr"':""}function oe(t){const e=ie(t),n=re(t),i=[];return void 0!==e&&i.push(`text-align:${e}`),n>0&&i.push(`padding-inline-start:${String(40*n)}px`),0===i.length?"":` style="${i.join(";")}"`}var ae=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}),le=/[&<>"'/`=]/g;function escapeHtml(t){return""===t?"":t.replace(le,t=>ae[t])}var ue=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'"}),ce=/[&<>"']/g;function escapeHtmlAttribute(t){return""===t?"":t.replace(ce,t=>ue[t])}function de(t){return escapeHtml(t).replace(/\r\n|\r|\n/g,"<br>")}var he=new Set(["h1","h2","h3","h4","h5","h6"]),fe=(t,e)=>{const n="string"==typeof t.url?t.url:"",i=e.renderChildren(t.children??[]);if(0===n.length||!isSafeUrl(n))return i;const r=isExternalHttpUrl(n)?' target="_blank" rel="noopener noreferrer"':function(t){const e="string"==typeof t.target?t.target:"";if(0===e.length)return"";const n=escapeHtml(e);return"_blank"===e?' target="_blank" rel="noopener noreferrer"':` target="${n}"`}(t),s="string"==typeof t.title?` title="${escapeHtml(t.title)}"`:"";return`<a href="${escapeHtmlAttribute(n)}"${r}${s}>${i}</a>`};function pe(t){if("string"==typeof t.text)return t.text;if(!t.children)return"";let e="";for(const n of t.children)e+=pe(n);return e}function ge(t){return t.replace(/[^a-zA-Z0-9_-]/g,"")}var me=new Map;function ve(t){return me.get(t)}function ye(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}te("text",t=>{let e=escapeHtml("string"==typeof t.text?t.text:"");const n="number"==typeof t.format?t.format:0;return!!(16&n)&&(e=`<code>${e}</code>`),!!(1&n)&&(e=`<strong>${e}</strong>`),!!(2&n)&&(e=`<em>${e}</em>`),!!(8&n)&&(e=`<u>${e}</u>`),!!(4&n)&&(e=`<s>${e}</s>`),!!(32&n)&&(e=`<sub>${e}</sub>`),!!(64&n)&&(e=`<sup>${e}</sup>`),!!(128&n)&&(e=`<mark>${e}</mark>`),e}),te("paragraph",(t,e)=>{const n=e.renderChildren(t.children??[]);return`<p${se(t)}${oe(t)}>${n}</p>`}),te("heading",(t,e)=>{const n="string"==typeof t.tag?t.tag.toLowerCase():"h2",i=he.has(n)?n:"h2",r=e.renderChildren(t.children??[]);return`<${i}${se(t)}${oe(t)}>${r}</${i}>`}),te("list",(t,e)=>{const n="string"==typeof t.listType?t.listType:"bullet",i="number"===n?"ol":"ul",r="number"===n&&"number"==typeof t.start&&t.start>1?` start="${String(t.start)}"`:"",s="check"===n?' role="list"':"",o=e.renderChildren(t.children??[]);return`<${i}${se(t)}${oe(t)}${r}${s}>${o}</${i}>`}),te("listitem",(t,e)=>{const n=e.renderChildren(t.children??[]);if("boolean"==typeof t.checked)return`<li role="checkbox" aria-checked="${t.checked?"true":"false"}"${oe(t)}>${n}</li>`;const i="number"==typeof t.value?` value="${escapeHtml(String(t.value))}"`:"";return`<li${se(t)}${oe(t)}${i}>${n}</li>`}),te("link",fe),te("autolink",fe),te("quote",(t,e)=>{const n=e.renderChildren(t.children??[]);return`<blockquote${se(t)}${oe(t)}>${n}</blockquote>`}),te("code",t=>{const e=ge("string"==typeof t.language?t.language:"");return`<pre><code${""===e?"":` class="language-${e}"`}>${escapeHtml(pe(t))}</code></pre>`}),te("code-highlight",t=>{const e="string"==typeof t.text?t.text:"";return`<span${"string"==typeof t.highlightType?` class="token-${ge(t.highlightType)}"`:""}>${escapeHtml(e)}</span>`}),te("linebreak",()=>"<br>"),te("horizontalrule",()=>"<hr>"),te("tab",()=>"\t"),te("upload",t=>{const e=function(t){const e=t.value;return"object"!=typeof e||null===e?void 0:e}(t);if(void 0===e)return"";const n=e.url;if("string"!=typeof n||!isSafeUrl(n))return"";const i="string"==typeof e.mimeType?e.mimeType:"";return i.startsWith("video/")?function(t,e){const n="number"==typeof t.width?` width="${String(t.width)}"`:"",i="number"==typeof t.height?` height="${String(t.height)}"`:"",r="string"==typeof t.mimeType?` type="${escapeHtmlAttribute(t.mimeType)}"`:"";return`<video controls${n}${i}><source src="${escapeHtmlAttribute(e)}"${r}></video>`}(e,n):i.startsWith("audio/")?function(t,e){const n="string"==typeof t.mimeType?` type="${escapeHtmlAttribute(t.mimeType)}"`:"";return`<audio controls><source src="${escapeHtmlAttribute(e)}"${n}></audio>`}(e,n):""===i||i.startsWith("image/")?function(t,e){const n="string"==typeof t.alt?escapeHtml(t.alt):"",i="number"==typeof t.width?` width="${String(t.width)}"`:"",r="number"==typeof t.height?` height="${String(t.height)}"`:"";return`<img src="${escapeHtmlAttribute(e)}" alt="${n}"${i}${r} loading="lazy" decoding="async">`}(e,n):function(t,e){const n="string"==typeof t.filename?escapeHtml(t.filename):escapeHtml(e);return`<a href="${escapeHtmlAttribute(e)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(e,n)}),te("relationship",t=>{const e="string"==typeof t.relationTo?t.relationTo:"",n=function(t){const e=t.value;return"object"!=typeof e||null===e?void 0:e}(t),i=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}`}(n,e),r=escapeHtml(i),s=""===e?"":` data-relation-to="${escapeHtml(e)}"`,o=n?.url;return"string"==typeof o&&isSafeUrl(o)?`<a href="${escapeHtmlAttribute(o)}"${s}>${r}</a>`:`<span${s}>${r}</span>`}),te("block",(t,e)=>{const n=function(t){const e=t.fields;return"object"!=typeof e||null===e?{}:e}(t),i="string"==typeof n.blockType?n.blockType:"",r=ye(i);if(""!==i){const t=ve(i)??ve(r);if(t)return t(n,{renderChildren:e.renderChildren})}const s=[];""!==r&&s.push(`data-block-type="${escapeHtml(r)}"`);for(const[t,e]of Object.entries(n)){if("blockType"===t||"id"===t)continue;if(null==e)continue;const n="string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);s.push(`data-block-${ye(t)}="${escapeHtml(n)}"`)}return`<div${0===s.length?"":` ${s.join(" ")}`}></div>`});var be={renderChildren:Ae,resolveAlignment:ie,resolveIndent:re};function we(t){if("object"!=typeof t||null===t)return!1;if(!("root"in t))return!1;const e=t.root;return"object"==typeof e&&null!==e&&"children"in e&&Array.isArray(e.children)}function Se(t){return we(t)?t.root.children.map(ke).join("\n").trim():""}function Ae(t){let e="";for(const n of t)e+=Te(n);return e}function Te(t){const e=(n=t.type,Zt.get(n));var n;return e?e(t,be):void 0!==t.children?Ae(t.children):""}function ke(t){if("string"==typeof t.text)return t.text;if("linebreak"===t.type)return"\n";if(void 0===t.children)return"";let e="";for(const n of t.children)e+=ke(n);return e}function Ce(){const t=new WeakSet;return{name:"text",render:Z((e,n)=>{const i=e.element,r=function(t){return null==t?"":we(t)?Se(t):"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName)return function(t){return null!==t.firstElementChild}(i)&&!i.hasAttribute("data-payload-text")?(function(t,e,n){t.has(e)||(t.add(e),H(`[live-preview] LP0402: Skipping text update for "${n}": <${e.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}(t,i,e.fieldName),!1):void(r.includes("\n")||r.includes("\r")?i.innerHTML=de(r):i.textContent=r);i.value=r})}}function xe(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""}}var Ne={name:"textarea",render(t,e){const n=t.element,i=we(e)?Se(e):xe(e);"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName?n.innerHTML=de(i):n.value=i}},$e={name:"richText",render:Z((t,e)=>{if(we(e))t.element.innerHTML=function(t,e={}){if(!we(t))return"";const n=Ae(t.root.children);return!1===e.sanitize||void 0===Qt()?n:sanitizeHtml(n)}(e);else{if("string"!=typeof e)return!1;t.element.innerHTML=sanitizeHtml(e)}})},Pe={name:"html",render(t,e){if(null==e)return void(t.element.textContent="");const n="string"==typeof e?e:xe(e);t.element.innerHTML=sanitizeHtml(n)}},Re={name:"url",render(t,e,n){const i=t.element,r=xe(e);if("A"===i.tagName){const s=i,o=t.hrefField,a=void 0===o||0===o.length?e:rt(n.allFields,o,n.locale,void 0!==t.locale);return"string"==typeof a&&isSafeUrl(a)&&(s.href=a),void(s.textContent=r)}"INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName?i.textContent=r:i.value=r}},Oe={name:"image",render:Z((t,e,n)=>{const i=t.element,r=Me(e),s=void 0!==t.locale,o=function(t,e,n,i,r,s){if(void 0!==n&&n.length>0){const t=rt(i,n,r,s);if("string"==typeof t&&isSafeUrl(t))return t;const e=Me(t);return void 0!==e?.url&&isSafeUrl(e.url)?e.url:void 0}return void 0!==t?.url&&isSafeUrl(t.url)?t.url:"string"==typeof e&&isSafeUrl(e)?e:void 0}(r,e,t.srcField,n.allFields,n.locale,s);if(void 0===o)return!1;if("IMG"===i.tagName){const e=i;e.src=o;const a=function(t,e,n,i,r){if(void 0!==e&&e.length>0){const t=rt(n,e,i,r);return"string"==typeof t?t:void 0}return void 0!==t?.alt?t.alt:void 0}(r,t.altField,n.allFields,n.locale,s);return void(void 0!==a&&(e.alt=a))}i.style.backgroundImage=`url('${function(t){return t.replace(/['"()\\]/g,"\\$&")}(o)}')`})};function Me(t){if("object"==typeof t&&null!==t)return t}var Le={name:"upload",render:Z((t,e)=>{const n=t.element,i=function(t){return"object"!=typeof t||null===t?void 0:t}(e);if(void 0===i)return!1;const r=i.url;if("string"!=typeof r||!isSafeUrl(r))return!1;if("IMG"===n.tagName){const t=n;return t.src=r,void(void 0!==i.alt&&(t.alt=i.alt))}if("A"===n.tagName){const t=n;return t.href=r,void(t.textContent=i.filename??r)}const s=void 0!==i.filename?escapeHtml(i.filename):escapeHtml(r);n.innerHTML=`<a href="${escapeHtmlAttribute(r)}">${s}</a>`})},Ee={name:"relationship",render(t,e){const n=t.element,i=function(t){return null==t?[""]:Array.isArray(t)?t.map(Ie):[Ie(t)]}(e),r=i.join(", ");if("A"===n.tagName&&!Array.isArray(e)){const t=n,i=e?.url;return"string"==typeof i&&isSafeUrl(i)&&(t.href=i),void(t.textContent=r)}n.textContent=r}};function Ie(t){if("object"==typeof t&&null!==t){const 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 xe(t)}var Ue={name:"select",render(t,e){const n=t.element,i=Fe(e);if("SELECT"!==n.tagName){if("INPUT"===n.tagName&&"radio"===n.type){const t=n;return void(t.checked=t.value===i)}n.textContent=i}else n.value=i}};function Fe(t){return Array.isArray(t)?t.map(t=>Fe(t)).join(", "):xe(t)}var je={name:"checkbox",render(t,e){const n=t.element,i=Boolean(e);"INPUT"!==n.tagName||"checkbox"!==n.type?n.hasAttribute("aria-checked")?n.setAttribute("aria-checked",i?"true":"false"):n.textContent=i?"true":"false":n.checked=i}},De=new Map,He=new Map;function Ge(t,e){const n=t??"";if(null==e)return n;const i=ze(e);return"{}"===i?n:`${n}|${i}`}function ze(t){if(null===t||"object"!=typeof t)return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(t=>ze(t)).join(",")}]`;const e=t,n=Object.keys(e).sort(),i=[];for(const t of n){const n=e[t];void 0!==n&&i.push(`${JSON.stringify(t)}:${ze(n)}`)}return`{${i.join(",")}}`}function We(t){for(;t.size>64;){const e=t.keys().next().value;if(void 0===e)break;t.delete(e)}}var Ve={name:"date",render(t,e,n){const i=t.element;if(null==e||""===e)return void("INPUT"===i.tagName?i.value="":"TIME"===i.tagName?(i.removeAttribute("datetime"),i.textContent=""):i.textContent="");const r="string"==typeof e?e:xe(e),s=new Date(r),o=!Number.isNaN(s.getTime());if("INPUT"!==i.tagName)return"TIME"===i.tagName?(i.setAttribute("datetime",o?s.toISOString():r),void(i.textContent=o?Be(s,n):r)):void(i.textContent=o?Be(s,n):r);i.value=o?function(t,e){return"date"===t?e.toISOString().slice(0,10):"datetime-local"===t?e.toISOString().slice(0,16):e.toISOString()}(i.type,s):r}};function Be(t,e){const n=e.locale??detectInitialLocale();try{return function(t,e){const n=Ge(t,e),i=He.get(n);if(void 0!==i)return He.delete(n),He.set(n,i),i;const r=new Intl.DateTimeFormat(t,e);return He.set(n,r),We(He),r}(n,{dateStyle:"medium",timeStyle:"short"}).format(t)}catch{return t.toISOString()}}var _e={name:"number",render(t,e,n){const i=t.element;if(null==e||""===e)return void("INPUT"===i.tagName?i.value="":i.textContent="");const r="number"==typeof e?e:Number(xe(e));Number.isNaN(r)?i.textContent=xe(e):"INPUT"!==i.tagName?i.textContent=function(t,e){const n=e.locale??detectInitialLocale();try{return function(t,e){const n=Ge(t,e),i=De.get(n);if(void 0!==i)return De.delete(n),De.set(n,i),i;const r=new Intl.NumberFormat(t,e);return De.set(n,r),We(De),r}(n).format(t)}catch{return String(t)}}(r,n):i.value=String(r)}},qe=/\{\{([\s\S]*?)\}\}/g;function Je(t,e,n,i){const r="object"==typeof e&&null!==e?e:null;return t.replace(qe,(t,s)=>null!==r&&function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r,s)?escapeHtml(i(Reflect.get(r,s))):null===r&&"value"===s?escapeHtml(i(e)):"index"===s?String(n):t)}var Qe={name:"array",render:Z((t,e)=>{const n=t.element;if(!Array.isArray(e))return!1;const i=t.arrayTemplate;if(void 0!==i&&i.length>0){const t=function(t,e){let n="";for(let i=0;i<e.length;i+=1)n+=Xe(t,e[i],i);return n}(i,e);return void(n.innerHTML=sanitizeHtml(t))}const r=t.arraySeparator??", ";n.textContent=e.map(Ye).join(r)})};function Xe(t,e,n){return Je(t,e,n,xe)}function Ye(t){return xe(t)}var Ke="data-payload-key",Ze="data-payload-nested-key",tn="data-payload-nested-template";function en(t){const{template:e,container:n,patches:i,nextItems:r,store:s,forceRender:o=!1}=t,a=nn(n,e,i,r,o,s);return null===a?null:rn(a,s)}function nn(t,e,n,i,r,s){const o=function(t){const e=new Set,n=new Set;for(const i of t)"insert"===i.kind||"update"===i.kind?e.add(i.index):"replace"===i.kind&&(e.add(i.index),n.add(i.index));return{renders:e,replaces:n}}(n),a=function(t,e,n,i,r,s,o){const a=Array.from(t.children),l=dn(a,Ke),u=new Set,c=[];for(let d=0;d<n.length;d+=1){const h=n[d],f=cn(h);let p=void 0===f?a[d]??null:hn(l,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);const g=i.replaces.has(d),m=r||i.renders.has(d)||null===p?fn(t.ownerDocument,e,h,d):void 0;if(null===m)return null;const v=void 0===m?[]:sn(g?null:p,m,h,s,o);if(null===v)return null;c.push([d,p,m??void 0,v])}return c}(t,e,i,o,r,s.get(t),s);return null===a?null:[t,a,i]}function rn(t,e){const[n,i,r]=t,s=new Set;let o=!1;for(const t of i){const[i,r,a,l]=t;let u=r;if(void 0!==a){for(const t of l)null!==t[0]&&(an(t[0],t[1]),t[1].replaceWith(t[0])),void 0!==t[2]&&rn(t[2],e);null!==r&&(r.replaceWith(a),o=!0),u=a}if(null===u)continue;const c=n.children[i]??null;u!==c&&(n.insertBefore(u,c),o=!0),s.add(u)}for(const t of Array.from(n.children))s.has(t)||(t.remove(),o=!0);const a=function(t,e){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}(n,e);a.clear();for(const t of r)un(a,t);return o}function sn(t,e,n,i,r){const s=dn(null===t?[]:on(t),Ze),o=cn(n),a=void 0!==o?i?.get(o):void 0,l=[];for(const t of on(e)){const e=t.getAttribute(Ze);if(null===e)continue;const i=hn(s,e)??null,o=t.getAttribute(tn),u=o?i:null,c=u?.getAttribute(tn)??null;let d;if(o){const i=ln(n,e);if(void 0!==i||null!==u){const n=i??[],s=mt(null===u?[]:ln(a,e)??[],n),l=null!==u&&c!==o;if((s.length>0||l)&&(d=nn(u??t,o,s,n,l,r)??void 0,void 0===d))return null}}l.push([u,t,d])}return l}function on(t){return Array.from(t.querySelectorAll(`[${Ze}]`)).filter(e=>{let n=e.parentElement;for(;null!==n&&n!==t;){if(n.hasAttribute(Ze))return!1;n=n.parentElement}return n===t})}function an(t,e){for(const n of Array.from(t.attributes))e.hasAttribute(n.name)||t.removeAttribute(n.name);for(const n of Array.from(e.attributes))t.getAttribute(n.name)!==n.value&&t.setAttribute(n.name,n.value)}function ln(t,e){if("object"!=typeof t||null===t)return;const n=t[e];return Array.isArray(n)?n:void 0}function un(t,e){const n=cn(e);void 0!==n&&t.set(n,e)}function cn(t){if("object"!=typeof t||null===t)return;const e=t.id;return"string"==typeof e||"number"==typeof e?String(e):void 0}function dn(t,e){const n=new Map;for(let i=t.length-1;i>=0;i-=1){const r=t[i];if(void 0===r)continue;const s=r.getAttribute(e);if(null===s)continue;const o=n.get(s);void 0===o?n.set(s,[r]):o.push(r)}return n}function hn(t,e){return t.get(e)?.pop()}function fn(t,e,n,i){const r=function(t,e,n){return Je(t,e,n,xe)}(e,n,i),s=sanitizeHtml(r),o=t.createElement("template");o.innerHTML=s;const a=o.content.firstElementChild;if(!a)return null;const l=cn(n);return void 0!==l&&a.setAttribute(Ke,l),a}function pn(){const t=new WeakMap,e=new WeakSet,n=new WeakMap;return{name:"structural-array",render:Z((i,r)=>{if(!Array.isArray(r))return!1;const s=i.element,o=i.arrayTemplate;if(void 0===o||0===o.length)return function(t,e,n){t.has(e)||(t.add(e),H(`[live-preview] LP0403: Skipping structural update for "${n}": <${e.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(e,s,i.fieldName),!1;const a=t.get(s),l=gn(s),u=mt(a?.values??l.map((t,e)=>null===t?{__payloadDomPosition:e}:{id:t}),r),c=function(t,e,n){return void 0===t||t.template!==e||!function(t,e){return t.length===e.length&&t.every((t,n)=>t===e[n])}(t.domSnapshot,n)}(a,o,l);if(0===u.length&&!c)return t.set(s,{values:r.slice(),template:o,domSnapshot:l}),!1;const d=en({template:o,container:s,patches:u,nextItems:r,store:n,forceRender:c});return null!==d&&(t.set(s,{values:r.slice(),template:o,domSnapshot:gn(s)}),!!d&&void 0)})}}function gn(t){return Array.from(t.children,t=>t.getAttribute(Ke))}var mn,vn=new Map,yn=[Ne,$e,Pe,Re,{...Re,name:"email"},Oe,Le,Ee,Ue,{...Ue,name:"radio"},je,Ve,_e,Qe,{...Qe,name:"blocks"}],bn=class{#Ut=new $t;#Ft;#jt;#Dt;#bt;#at;#Ht=!1;#Gt=!1;#zt=null;constructor(t={}){const e=t.debug??isDevMode();this.#at=e?(...t)=>{G("[live-preview]",...t)}:j,this.#Ft=new Et({...void 0!==t.allowedOrigins?{additionalOrigins:t.allowedOrigins}:{},...void 0!==t.disableReferrerDetection?{enableReferrerDetection:!t.disableReferrerDetection}:{},...void 0!==t.disableLocalhostMatching?{enableLocalhostMatching:!t.disableLocalhostMatching}:{}}),this.#Ft.isProductionUnconfigured&&this.#at("no trusted origin could be detected — set allowedOrigins or PAYLOAD_ADMIN_ORIGIN"),this.#jt=new zt(function(t=[]){const e={};for(const n of t)e[n.name]=n;for(const[t,n]of vn)e[t]=n;return Object.freeze(e)}([Ce(),...yn,pn()])),this.#bt=new Gt({events:this.#Ut,config:Object.freeze({...t}),registerFieldRenderer:t=>this.#jt.register(t),onTransformError:t=>{this.#Ut.emit("error",{error:t,context:"transform",code:"LP0602"})},log:this.#at}),this.#Dt=new wt({...void 0!==t.root?{root:t.root}:{},renderers:this.#jt.renderers,resolveRenderer:t=>this.#jt.resolve(t),transformValue:(t,e,n,i)=>this.#bt.applyTransforms(t,e,n,i),originMatcher:t=>this.#Ft.matches(t),readyTargets:this.#Ft.enumerate(),emitter:this.#Ut,...void 0!==t.serverURL&&""!==t.serverURL?{dataMerge:{serverURL:t.serverURL,...void 0!==t.apiRoute?{apiRoute:t.apiRoute}:{},...void 0!==t.mergeDepth?{depth:t.mergeDepth}:{},...void 0!==t.mergeFetch?{fetchFn:t.mergeFetch}:{}}}:{},...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.heartbeatMs?{heartbeatMs:t.heartbeatMs}:{},...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{},...void 0!==t.scopeBindingsByOwner?{scopeBindingsByOwner:t.scopeBindingsByOwner}:{},...void 0!==t.disableVisibilityGate?{disableVisibilityGate:t.disableVisibilityGate}:{},...void 0!==t.visibilityGateThreshold?{visibilityGateThreshold:t.visibilityGateThreshold}:{},...void 0!==t.enableA11y?{enableA11y:t.enableA11y}:{},...void 0!==t.a11yLocale?{a11yLocale:t.a11yLocale}:{},onHeartbeatTimeout:()=>{this.#Ft.unlockOrigin()},lockedOrigin:()=>this.#Ft.lockedOrigin,...void 0!==t.validateToken?{validateToken:t.validateToken}:{},log:this.#at}),this.#Ut.on("connect",t=>{this.#Ft.lockOrigin(t.origin)}),!1!==t.autoStart&&this.start()}start(){if(this.#Gt)return!1;if(this.#Ht)return this.#Dt.start(),!0;if(!isInPreviewContext())return!1;const t=this.#Dt.start();return t&&(this.#Ht=!0),t}suspend(){return!(this.#Gt||!this.#Ht)&&this.#Dt.suspend()}resume(){return!(this.#Gt||!this.#Ht)&&this.#Dt.start()}destroy(){if(null!==this.#zt)return this.#zt;let t,e;this.#Gt=!0;const n=new Promise((n,i)=>{t=n,e=i});this.#zt=n;try{this.#Dt.destroy(),this.#bt.destroyAll().finally(()=>{this.#Ut.removeAllListeners()}).then(t,e)}catch(t){this.#Ut.removeAllListeners(),e(t)}return n}async use(t){if(this.#Gt)throw new Error("LivePreviewClient: already destroyed");await this.#bt.register(t)}async unuse(t){await this.#bt.unregister(t)}refreshCache(){this.#Dt.refreshCache()}get events(){return this.#Ut}get plugins(){return this.#bt.list()}get status(){return this.#Dt.status}inspect(){return this.#Dt.inspect()}get updateCount(){return this.#Dt.updateCount}get destroyed(){return this.#Gt}},wn=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",OrphanField:"LP0201",UnattributableUpdate:"LP0202",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",MessageRejected:"LP0501",TokenRejected:"LP0502",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",AuditRuntimeMissing:"LP0701",AuditNoFrameAncestors:"LP0702",AuditFrameOptionsBlocks:"LP0703",AuditBindingsExposed:"LP0704",AuditGateThresholdExceeded:"LP0705",AuditUnownedBindings:"LP0706",AuditNoBindings:"LP0707",AuditNotAPage:"LP0708"});function bind(t,e){return Sn(t,e)}function bindByPath(t,e){const n=function(t){const e=[],n=new Proxy({},{get(t,i){if("symbol"!=typeof i)return/^\d+$/.test(i)||e.push(i),n}});try{t(n)}catch{}return e}(t);if(0===n.length)throw new Error("bindByPath: the picker did not read any field — return data.<field> instead of a constant");return Sn(n.join("."),e)}function Sn(t,e){if(0===t.length)throw new Error("bind: field name must be a non-empty string");const n={"data-payload-field":t};return void 0!==e?.attribute&&(n["data-payload-attribute"]=e.attribute),void 0!==e?.type&&(n["data-payload-type"]=e.type),!0===e?.richtext&&(n["data-payload-richtext"]=""),!0===e?.html&&(n["data-payload-html"]=""),void 0!==e?.locale&&(n["data-payload-locale"]=e.locale),n}var An=Object.freeze({});for(const[t,e]of[[$t,"EventEmitter"],[bn,"LivePreviewClient"],[Et,"OriginDetector"]])Object.defineProperty(t,"name",{configurable:!0,value:e});exports.CORE_ENTRY=!0,exports.DIAGNOSTIC_CODES=wn,exports.EventEmitter=$t,exports.LIBRARY_PROTOCOL_VERSION=4,exports.LivePreviewClient=bn,exports.OriginDetector=Et,exports.VERSION=nt,exports.bind=bind,exports.bindByPath=bindByPath,exports.buildFrameAncestors=function buildFrameAncestors(t={}){const{self:e=!0,origins:n=[],allowNone:i=!1}=t,r=new Set,s=[];if(i&&!e&&0===n.length)return"'none'";e&&(s.push("'self'"),r.add("'self'"));for(const t of n){const e=t.trim();0===e.length||r.has(e)||(r.add(e),s.push(e))}return s.length>0?s.join(" "):"'none'"},exports.buildScriptSrcWithNonce=function buildScriptSrcWithNonce(t,e={}){if(0===t.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");const{self:n=!0,extra:i=[],strictDynamic:r=!1}=e,s=[];n&&s.push("'self'"),s.push(`'nonce-${t}'`),r&&s.push("'strict-dynamic'");for(const t of i){const e=t.trim();e.length>0&&s.push(e)}return s.join(" ")},exports.createPreviewBindings=function createPreviewBindings(t){const{authorized:e}=t,n=void 0!==t.owner&&t.owner.length>0?t.owner:void 0;return Object.freeze({authorized:e,bind:(t,n)=>e?bind(t,n):An,bindByPath:(t,n)=>e?bindByPath(t,n):An,owner:()=>e&&void 0!==n?{"data-payload-owner":n}:An})},exports.detectInitialLocale=detectInitialLocale,exports.escapeHtml=escapeHtml,exports.escapeHtmlAttribute=escapeHtmlAttribute,exports.generateCspNonce=function generateCspNonce(t=16){if(!Number.isInteger(t)||t<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(t)}`);const e=function(){if(mn?.getRandomValues)return mn;const t=globalThis.crypto;return t?.getRandomValues?t:void 0}();if(!e)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.");const n=new Uint8Array(t);return e.getRandomValues(n),function(t){let e="";for(const n of t)e+=String.fromCharCode(n);return("function"==typeof btoa?btoa(e):Buffer.from(t).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}(n)},exports.hasCapability=function hasCapability(t,e){return t.capabilities.has(e)},exports.initLivePreview=function initLivePreview(t={}){const e=new bn({...t,autoStart:!1});return e.start()?e:null},exports.isDevMode=isDevMode,exports.isExternalHttpUrl=isExternalHttpUrl,exports.isInIframe=isInIframe,exports.isInPopup=isInPopup,exports.isInPreviewContext=isInPreviewContext,exports.isSafeUrl=isSafeUrl,exports.negotiateProtocol=negotiateProtocol,exports.sanitizeHtml=sanitizeHtml,exports.setCspCrypto=function setCspCrypto(t){mn=t??void 0},exports.setSanitizerDocument=function setSanitizerDocument(t){Ft=t??void 0};
|
|
1
|
+
"use strict";var t="data-payload-field",e="data-payload-type",n="data-payload-attribute",i="data-payload-href",r="data-payload-src",s="data-payload-alt",o="data-payload-array-template",a="data-payload-array-separator",l="data-payload-locale",u="data-payload-richtext",c="data-payload-html",d="data-payload-array",h="data-payload-structural",f="data-payload-owner",p=[t,e,n,i,r,s,o,a,l,u,c,d,h,f,"type"],g=`[${t}]`,m=`[${f}]`,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"]),y=class{#t=new Map;#e=new WeakMap;#n;constructor(t={}){this.#n=t.filter??b}buildFromRoot(t){const e=performance.now();this.clear();const n=t.querySelectorAll(g);let i=0;for(const t of n)void 0!==this.add(t)&&(i+=1);return{elementCount:i,fieldCount:this.#t.size,durationMs:performance.now()-e}}add(t){const e=this.#n(t)?this.#i(t):void 0,n=this.#e.get(t);if(void 0!==e)return void 0!==n&&this.#r(n,e)?(this.#e.set(t,e),e):(void 0!==n&&this.#s(t,n),this.#o(e),this.#e.set(t,e),e);void 0!==n&&this.#s(t,n)}remove(t){const e=this.#e.get(t);return!!e&&this.#s(t,e)}#r(t,e){if(t.fieldName!==e.fieldName)return!1;const n=this.#t.get(t.fieldName);if(!n)return!1;const i=n.indexOf(t);return!(i<0||(n[i]=e,0))}#s(t,e){const n=this.#t.get(e.fieldName);if(!n)return this.#e.delete(t),!1;const i=n.indexOf(e);return i<0?(this.#e.delete(t),!1):(n.splice(i,1),0===n.length&&this.#t.delete(e.fieldName),this.#e.delete(t),!0)}get(t){return this.#t.get(t)}getByElement(t){return this.#e.get(t)}get fieldCount(){return this.#t.size}get elementCount(){let t=0;for(const e of this.#t.values())t+=e.length;return t}entries(){return this.#t.entries()}*values(){for(const t of this.#t.values())yield*t}has(t){return this.#e.has(t)}clear(){this.#t.clear(),this.#e=new WeakMap}#o(t){const e=this.#t.get(t.fieldName);e?e.push(t):this.#t.set(t.fieldName,[t])}#i(p){const g=p.getAttribute(t);if(null===g||0===g.length)return;const y=p.getAttribute(e),b=function(t){const n=t.getAttribute(e);if(null!==n&&v.has(n))return n;if(t.hasAttribute(u))return"richText";if(t.hasAttribute(c))return"html";if(t.hasAttribute(h))return"structural-array";if(t.hasAttribute(d))return"array";if("IMG"===t.tagName)return"image";if("A"===t.tagName)return"url";if("TIME"===t.tagName)return"date";if("INPUT"===t.tagName){const e=t.type;if("checkbox"===e)return"checkbox";if("number"===e)return"number";if("date"===e||"datetime-local"===e)return"date"}return"text"}(p),w=p.getAttribute(n),S=p.getAttribute(i),A=p.getAttribute(r),T=p.getAttribute(s),k=p.getAttribute(o),C=p.getAttribute(a),x=p.getAttribute(l),N=function(t){const e=t.closest(m)?.getAttribute(f);return null==e||0===e.length?void 0:e}(p);return{element:p,fieldName:g,fieldType:b,explicitFieldType:null!==y&&v.has(y),...null!==w&&w.length>0?{targetAttribute:w}:{},...null!==S&&S.length>0?{hrefField:S}:{},...null!==A&&A.length>0?{srcField:A}:{},...null!==T&&T.length>0?{altField:T}:{},...null!==k?{arrayTemplate:k}:{},...null!==C?{arraySeparator:C}:{},...null!==x&&x.length>0?{locale:x}:{},...void 0!==N?{owner:N}:{}}}};function b(){return!0}function w(t,e){return void 0===e||""===e?`collection:${t}`:`collection:${t}:${e}`}function S(t){return"string"==typeof t&&t.length>0}function A(t,e){return null!==e&&void 0!==t&&e.includes(t)}function T(t){const e=t.id;return"string"==typeof e&&e.length>0?e:"number"==typeof e&&Number.isFinite(e)?String(e):void 0}var k=class{s;constructor(t,e={}){this.s=[t,e.mutationDebounceMs??100,e.intersectionRootMargin??"200px",new Set,null,null,null,0]}start(t){const e=this.s[7];this.stop();const n=e+1;if(this.s[7]!==n)return;let i=null,r=null;try{i=new MutationObserver(t=>{this.#a(t,n)}),r=new IntersectionObserver(t=>{this.#l(t,n)},{rootMargin:this.s[2],threshold:0}),i.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...p]})}catch(t){throw i?.disconnect(),r?.disconnect(),t}if(this.s[7]!==n)return i.disconnect(),void r.disconnect();this.s[4]=i,this.s[5]=r}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;const t=this.s[6],e=this.s[4],n=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{n?.disconnect()}}#a(e,n){if(!this.#u(n))return;if(!function(e){for(const n of e){if("attributes"===n.type&&null!==n.attributeName&&p.includes(n.attributeName)&&(n.attributeName===t||n.attributeName===f||1===n.target.nodeType&&n.target.hasAttribute(t)))return!0;for(const t of n.addedNodes)if(C(t))return!0;for(const t of n.removedNodes)if(C(t))return!0}return!1}(e))return;if(!this.#u(n))return;null!==this.s[6]&&clearTimeout(this.s[6]);const i=setTimeout(()=>{this.#u(n)&&this.s[6]===i&&(this.s[6]=null,this.s[0].onStructuralChange())},this.s[1]);this.s[6]=i}#l(t,e){for(const n of t){if(!this.#u(e))return;const t=n.target;if(n.isIntersecting){if(!this.s[3].has(t)&&(this.s[3].add(t),this.s[0].onVisibilityChange(t,!0),!this.#u(e)))return}else if(this.s[3].has(t)&&(this.s[3].delete(t),this.s[0].onVisibilityChange(t,!1),!this.#u(e)))return}}#u(t){return this.s[7]===t&&null!==this.s[5]}};function C(e){if(1!==e.nodeType)return!1;const n=e;return!!n.hasAttribute(t)||null!==n.querySelector(`[${t}]`)}function x(t){if(!Array.isArray(t))return[];const e=[];for(const n of t){const t=N(n);t&&e.push(t)}return e}function N(t){if("object"!=typeof t||null===t)return;const e=t,n=e.name,i=e.type;if("string"!=typeof n||0===n.length)return;if("string"!=typeof i||0===i.length)return;const r=x(e.fields),s=function(t){if(!Array.isArray(t))return[];const e=[];for(const n of t){if("object"!=typeof n||null===n)continue;const t=n,i=t.slug;if("string"!=typeof i||0===i.length)continue;const r=x(t.fields);e.push({...t,slug:i,fields:r})}return e}(e.blocks),o={...e,name:n,type:i};return r.length>0?o.fields=r:delete o.fields,s.length>0?o.blocks=s:delete o.blocks,o}var $={basic:1,"schema-json":2,"preview-token":3,"nested-arrays":4,"recursive-diffs":4};function negotiateProtocol(t){const e="number"==typeof t&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0,n=e??1,i=Math.min(4,n),r=new Set;for(const[t,e]of Object.entries($))i>=e&&r.add(t);return{ours:4,...void 0!==e?{theirs:e}:{theirs:void 0},negotiated:i,capabilities:r}}function P(t){return("object"==typeof t&&null!==t||"function"==typeof t)&&"function"==typeof t.then&&(Promise.resolve(t).catch(()=>{}),!0)}var R=class{s;constructor(t,e){this.s=[t,e,void 0,void 0,0,0,[],0]}attach(t=window){if(void 0!==this.s[3])return;let e=!1;const n=t=>{if(!e||this.s[2]!==n)return;const i=this.s[4];try{this.#c(t,i)}catch{let e="";try{e=t.origin}catch{}this.#d("shape",e,i)}};this.s[4]+=1,this.#h(),this.s[3]=t,this.s[2]=n;try{t.addEventListener("message",n)}catch(e){this.s[2]===n&&(this.s[3]=void 0,this.s[2]=void 0,this.#h());try{t.removeEventListener("message",n)}catch{}throw e}if(this.s[2]===n)e=!0;else try{t.removeEventListener("message",n)}catch{}}detach(t){const e=this.s[3],n=this.s[2];void 0!==e&&void 0!==n&&(this.s[3]=void 0,this.s[2]=void 0,this.#h(),e.removeEventListener("message",n))}advanceGeneration(){return void 0!==this.s[3]&&(this.s[4]+=1,this.#h(),!0)}static sendReady(t,e){const n=t.length>0;if(!n||0===e.length)return;const i={type:"payload-live-preview",ready:n,protocolVersion:4};for(const n of t)for(const t of e)try{n.postMessage(i,t)}catch{}}#c(t,e){if(!this.#u(e))return;const n=t.origin;if(!this.#u(e))return;if(!this.#f(n,e))return void this.#d("origin",n,e);const i=t.data;if(!this.#u(e))return;const r="object"==typeof(s=i)&&null!==s&&"type"in s&&"string"==typeof s.type;var s;if(!this.#u(e))return;if(!r)return void this.#d("shape",n,e);const o=i.type;if(this.#u(e))switch(o){case"payload-live-preview":{const t=function(t){const e=t;return!!((void 0===e.data||null===e.data||L(e.data))&&M(e.fieldSchemaJSON,t=>Array.isArray(t))&&M(e.globalSlug,t=>"string"==typeof t)&&M(e.collectionSlug,t=>"string"==typeof t)&&M(e.locale,t=>"string"==typeof t)&&M(e.ready,t=>"boolean"==typeof t)&&M(e.previewToken,t=>"string"==typeof t)&&M(e.protocolVersion,t=>"number"==typeof t))}(i);if(!this.#u(e))return;if(!t)return void this.#d("shape",n,e);const r=function(t){const e={...t};for(const t of E)null===Reflect.get(e,t)&&Reflect.deleteProperty(e,t);if(!Array.isArray(e.fieldSchemaJSON))return e;let n;try{n=x(e.fieldSchemaJSON)}catch{n=[]}return{...e,fieldSchemaJSON:n}}(i);if(!this.#u(e))return;return void this.#p(r,n,e)}case"payload-document-event":{const t=function(t){const e=t;return!!O(e.action,t=>"updated"===t||"created"===t||"deleted"===t)&&!!O(e.slug,t=>"string"==typeof t)&&!!O(e.id,t=>"string"==typeof t||"number"==typeof t&&Number.isFinite(t))}(i);if(!this.#u(e))return;if(!t)return void this.#d("shape",n,e);let r;try{r=this.s[1].onDocumentEvent}catch{return}if(!this.#u(e))return;return void this.#g(r,i,n)}default:this.#d("type",n,e)}}#p(t,e,n){if(!this.#u(n))return;const i=t.data;if(!this.#u(n))return;const r=L(i);if(!this.#u(n))return;const s=r?{generation:n,revision:this.s[5]+=1}:void 0;let o;try{o=this.s[1].validateToken}catch{return}if(!this.#u(n))return;if(void 0===o)return void this.#m(t,e,n,s);if(!0===t.ready&&void 0===i)return void this.#m(t,e,n,void 0);const a={generation:n,message:t,origin:e,messageRevision:s,settled:!1,approved:!1};let l;this.s[6].push(a);try{l=o(t.previewToken,e)}catch{return void this.#v(a,!1)}"boolean"!=typeof l?Promise.resolve(l).then(t=>{this.#v(a,!0===t)},()=>{this.#v(a,!1)}):this.#v(a,l)}#v(t,e){this.#u(t.generation)&&(t.approved=e,t.settled=!0,this.#y(t.generation))}#y(t){for(;this.#u(t);){const e=this.s[6][this.s[7]];if(void 0===e)return;if(this.#f(e.origin,t)){if(!e.settled)return;this.#b(e)&&(e.approved?this.#m(e.message,e.origin,e.generation,e.messageRevision):this.#d("token",e.origin,e.generation))}else{if(!this.#b(e))continue;this.#d("origin",e.origin,e.generation)}}}#m(t,e,n,i){if(!this.#u(n))return;let r;try{r=this.s[1].onUpdate}catch{return}this.#u(n)&&(void 0===i?this.#g(r,t,e):this.#g(r,t,e,i))}#d(t,e,n){if(!this.#u(n))return;let i;try{i=this.s[1].onInvalid}catch{return}this.#u(n)&&void 0!==i&&this.#g(i,t,e)}#f(t,e){if(!this.#u(e))return!1;try{return!0===this.s[0](t)&&this.#u(e)}catch{return!1}}#g(t,...e){try{P(t(...e))}catch{}}#u(t){return void 0!==this.s[3]&&this.s[4]===t}#b(t){const e=this.s;return e[6][e[7]]===t&&(e[7]+=1,e[7]===e[6].length?(this.#h(),!0):(e[7]>=1024&&2*e[7]>=e[6].length&&(e[6]=e[6].slice(e[7]),e[7]=0),!0))}#h(){this.s[6]=[],this.s[7]=0}};function O(t,e){return void 0===t||e(t)}function M(t,e){return null==t||e(t)}function L(t){if("object"!=typeof t||null===t)return!1;const e=Object.getPrototypeOf(t);return null===e||null===Object.getPrototypeOf(e)}var E=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],I=class{s;constructor(t){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]);const 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]}},U=class{s;constructor(t){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!1;const e=this.s[0];return this.s[0]=t,this.s[1](t,e),!0}};function F(t){return(...e)=>{try{P(t(...e))}catch{}}}function j(){}var D=F((...t)=>console.error(...t)),H=F((...t)=>console.warn(...t)),G=F((...t)=>console.debug(...t));function z(t){for(const e of t){const t=e.codePointAt(0);if(void 0!==t&&(t<=31||127===t))return!0}return!1}function W(t){if(void 0===t||0===t.length||t.length>128||"."===t||".."===t||t.includes("/")||t.includes("\\")||t.includes("?")||t.includes("#")||z(t))return!1;try{return encodeURIComponent(t),!0}catch{return!1}}var V=class{s;constructor(t){const e=t.serverURL.replace(/\/+$/,""),n=t.apiRoute??"/api";this.s=[e,n.startsWith("/")?n:`/${n}`,t.depth??1,t.fetchFn,void 0===t.log?j:F(t.log),null,0,0]}canMerge(t){try{return t.globalSlug?W(t.globalSlug):!!W(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("\\")||z(t))return!1;try{return encodeURIComponent(t),!0}catch{return!1}}(t.data.id)}catch{return!1}}async merge(t){if(this.s[7]>0)return{status:"superseded"};const e=this.s[6]+1;this.s[6]=e;const n=this.s[5];this.s[5]=null;let i=null;try{if(n?.abort(),!B(this.s,e))return{status:"superseded"};if(!this.canMerge(t))return B(this.s,e)?{status:"unavailable"}:{status:"superseded"};if(!B(this.s,e))return{status:"superseded"};const r=this.s[3]??("function"==typeof fetch?fetch:void 0);if(!B(this.s,e))return{status:"superseded"};if(void 0===r)return{status:"unavailable"};if(i=new AbortController,!B(this.s,e))return i.abort(),{status:"superseded"};this.s[5]=i;const s=t.globalSlug?`globals/${encodeURIComponent(t.globalSlug)}`:`${encodeURIComponent(t.collectionSlug??"")}/${encodeURIComponent(String(t.data.id))}`,o=`${this.s[0]}${this.s[1]}/${s}`,a=JSON.stringify({data:t.data,depth:this.s[2],flattenLocales:!1,...void 0!==t.locale?{locale:t.locale}:{}});if(!B(this.s,e))return{status:"superseded"};const l=await r(o,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:a,signal:i.signal});if(!B(this.s,e)||_(i.signal))return{status:"superseded"};const u=l.ok;if(!B(this.s,e))return{status:"superseded"};if(!u){const t=l.status;return B(this.s,e)?(this.s[4]("merge HTTP",t,o),B(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"superseded"}}const c=await l.json();return!B(this.s,e)||_(i.signal)?{status:"superseded"}:null===c||"object"!=typeof c||Array.isArray(c)?(this.s[4]("merge invalid",o),B(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"merged",doc:c}}catch(t){return!B(this.s,e)||null!==i&&_(i.signal)?{status:"superseded"}:(this.s[4]("merge exception",t),B(this.s,e)?{status:"unavailable"}:{status:"superseded"})}finally{null!==i&&B(this.s,e)&&this.s[5]===i&&(this.s[5]=null)}}destroy(){this.s[6]+=1;const t=this.s[5];this.s[5]=null,this.s[7]+=1;try{t?.abort()}finally{this.s[7]-=1}}};function B(t,e){return t[6]===e}function _(t){return t.aborted}var q=new Set(["http:","https:","mailto:","tel:"]),J=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,Q=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/;function isSafeUrl(t){if("string"!=typeof t||0===t.length)return!1;const e=t.trim();if(0===e.length)return!1;if(J.test(e))return!1;if(e.startsWith("#")||e.startsWith("?"))return!0;if(e.startsWith("//"))return!0;if(e.startsWith("/"))return!0;try{const t=new URL(e);return q.has(t.protocol)}catch{return Q.test(e)}}function isExternalHttpUrl(t){if(!isSafeUrl(t))return!1;const e=t.trim();return/^https?:\/\//i.test(e)||/^\/\/[^/]/.test(e)}var X=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Y=new Set(["href","src","poster","cite","action","xlink:href","data"]),K=new WeakSet;function Z(t){return K.add(t),t}var tt=class{s;constructor(t,e){const n=e.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):t=>setTimeout(()=>{t(performance.now())},0)),i=e.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):t=>{clearTimeout(t)});this.s=[t,e.debounceMs??50,e.isVisible,e.visibilityGateThreshold??50,e.disableVisibilityGate??!1,e.getCacheSize,e.onFlush,n,i,new Map,new Map,new Set,null,0,null,0,null,!1]}schedule(t){if(void 0!==t.identity){if(this.s[17])return;if(!et(t.identity,this.s[16]))return}const e=this.s[9],n=e.get(t.target.element);n?(n.value=t.value,n.allFields=t.allFields,n.identity=t.identity,n.data=t.data):e.set(t.target.element,{...t,identity:t.identity,data:t.data}),this.#w()}acceptRevision(t){const e=this.s[16];var n,i;et(t,e)||null!==e&&(i=e,((n=t).generation!==i.generation?n.generation-i.generation:n.revision-i.revision)<0)||(this.#S(),this.#A(),this.s[16]=t,this.s[17]=!1)}cancelRevision(t){et(t,this.s[16])&&(this.#S(),this.#A(),this.s[17]=!0)}flushNow(){return this.#S(),this.#T()}notifyVisible(t){const e=this.s[10],n=e.get(t);if(!n)return;if(e.delete(t),!this.#k(n))return;const i=performance.now(),r=this.#C(n)?1:0;this.s[6]?.(this.#x(n,r,0,performance.now()-i,1===r?[n.target.fieldName]:[]))}retarget(t){this.#N(this.s[9],t),this.#N(this.s[10],t);for(const e of this.s[11])this.#N(e,t)}forget(t){this.s[9].delete(t),this.s[10].delete(t);for(const e of this.s[11])e.delete(t)}destroy(){this.#S(),this.#A(),this.s[16]=null,this.s[17]=!1}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}get gateThreshold(){return this.s[3]}get gateActive(){return!this.s[4]&&this.s[5]()>this.s[3]}#w(){const t=this.s[13]+=1,e=this.s[12];if(this.s[12]=null,null!==e&&clearTimeout(e),this.s[13]!==t)return;const n=setTimeout(()=>{this.s[13]===t&&(this.s[12]=null,this.#$())},this.s[1]);this.s[13]===t&&(this.s[12]=n)}#$(){const 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 n=!1;const i=this.s[7](()=>{this.s[15]===t&&(n=!0,this.s[14]=null,this.#T())});n||this.s[15]!==t||(this.s[14]=i)}#T(){const t=performance.now(),e=!this.s[4]&&this.s[5]()>this.s[3],n=this.s[9];this.s[9]=new Map;let i=0;const r=[];let s,o=0;this.s[11].add(n);try{for(const t of n.values()){if(!this.#k(t))continue;const n=!e||this.s[2](t.target.element);this.#k(t)&&(s??=t,n?(this.s[10].delete(t.target.element),this.#C(t)&&(i+=1,r.push(t.target.fieldName))):(this.s[10].set(t.target.element,t),o+=1))}}finally{this.s[11].delete(n)}const a=this.#x(s,i,o,performance.now()-t,r);return this.s[6]?.(a),a}#k(t){return void 0===t.identity||!this.s[17]&&et(t.identity,this.s[16])}#C(t){const e=this.s[0];return!1!==e(t)||(n=e,!K.has(n));var n}#N(t,e){const n=t.get(e.element);void 0!==n&&(n.target.fieldName===e.fieldName&&n.target.locale===e.locale?n.target=e:t.delete(e.element))}#A(){this.s[9].clear(),this.s[10].clear();for(const t of this.s[11])t.clear()}#x(t,e,n,i,r){return{applied:e,appliedFields:r,deferred:n,durationMs:i,...void 0!==t?.identity?{identity:t.identity}:{},...void 0!==t?.data?{data:t.data}:{}}}#S(){const 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)}};function et(t,e){return null!==e&&t.generation===e.generation&&t.revision===e.revision}var nt="1.8.2",it=new Set(["__proto__","prototype","constructor"]);function rt(t,e,n,i=!1){if(i&&void 0!==n){const i=st(t,`${e}_${n}`);if(void 0!==i)return i}const r=st(t,e);if(void 0!==r)return r;if(e.includes(".")){let n=t,i=!0;for(const t of e.split(".")){if(it.has(t)||null===n||"object"!=typeof n){i=!1;break}if(n=st(n,t),void 0===n){i=!1;break}}if(i)return n}return void 0===n?void 0:st(t,`${e}_${n}`)}function st(t,e){if(!it.has(e)&&Object.prototype.hasOwnProperty.call(t,e))return t[e]}function detectInitialLocale(){const t=function(){if("undefined"==typeof document)return;const t=document.documentElement.getAttribute("lang");return null===t||0===t.length?void 0:t}();if(void 0!==t)return t;const e=function(){if("undefined"==typeof navigator)return;const t=navigator.language;return"string"==typeof t&&t.length>0?t:void 0}();return void 0!==e?e:"en"}var ot="payload-live-preview-a11y";function at(t){return/^de(?:[-_]|$)/i.test(t)}var lt=new WeakMap;function ut(t){null!==t[4]&&(clearTimeout(t[4]),t[4]=null),t[2]?.remove(),t[2]=null}var ct=class{s;constructor(t,e){const n=e??("undefined"==typeof document?null:document),i=n?.documentElement.getAttribute("lang")??"";this.s=[at(t??(i.length>0?i:detectInitialLocale())),n,null]}mount(){const t=this.s[1];if(null==t?.body)return null;let e=this.s[2];null===e&&(e=function(t){let e=lt.get(t);return e??=[null,!1,null,0,null],lt.set(t,e),e[3]+=1,e}(t),this.s[2]=e);const n=e[0];if(n?.isConnected&&n.ownerDocument===t)return n;if(null!==n){const t=e[1];ut(e),t&&n.remove()}let i=t.getElementById(ot);return e[1]=null===i,i||(i=t.createElement("div"),i.id=ot,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-atomic","true"),i.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(i)),e[0]=i,i}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?"Änderung":"Änderungen"} angewendet`:`${String(t)} ${1===t?"change":"changes"} applied`)}detach(){const t=this.s[2],e=this.s[1];if(null===t||null===e)return;if(this.s[2]=null,t[3]-=1,t[3]>0)return;const n=t[0];null!==n&&ut(t),t[1]&&n?.remove(),t[0]=null,lt.delete(e)}say(t){const e=this.mount(),n=this.s[2];if(null===e||null===n)return;let i=n[2];i?.parentNode!==e?(i?.remove(),i=e.ownerDocument.createTextNode(e.hasChildNodes()?` ${t}`:t),n[2]=i,e.appendChild(i)):i.data=null===i.previousSibling?t:` ${t}`,null!==n[4]&&clearTimeout(n[4]);const r=setTimeout(()=>{n[4]===r&&n[0]===e&&ut(n)},1500);n[4]=r}},dt=new Set(["tabs","row","collapsible"]);function ht(t,e=""){const n=new Map;return ft(t,e,n),n}function ft(t,e,n){for(const i of t){if(dt.has(i.type)){i.fields&&ft(i.fields,e,n);continue}if("group"===i.type){const t=""===e?i.name:`${e}.${i.name}`;n.set(t,i),i.fields&&ft(i.fields,t,n);continue}const t=""===e?i.name:`${e}.${i.name}`;if(n.set(t,i),"array"===i.type&&i.fields)ft(i.fields,`${t}.*`,n);else if("blocks"===i.type&&i.blocks)for(const e of i.blocks)ft(e.fields,`${t}.*.${e.slug}`,n)}}function pt(t){if("object"!=typeof t||null===t)return;const e=t.id;return"string"==typeof e||"number"==typeof e?e:void 0}function gt(t){if("object"!=typeof t||null===t)return;const e=t.blockType;return"string"==typeof e?e:void 0}function mt(t,e){return e.every(t=>void 0!==pt(t))?function(t,e){const n=[],i=new Map;for(let e=0;e<t.length;e+=1){const n=pt(t[e]);void 0!==n&&i.set(n,e)}const r=new Set;for(let s=0;s<e.length;s+=1){const o=e[s],a=pt(o);if(void 0===a){n.push({kind:"insert",index:s,value:o});continue}const l=i.get(a);if(void 0===l){n.push({kind:"insert",index:s,value:o});continue}r.add(l);const u=t[l];gt(u)===gt(o)?(l!==s&&n.push({kind:"move",from:l,to:s,value:o}),vt(u,o)||n.push({kind:"update",index:s,value:o})):n.push({kind:"replace",index:s,oldValue:u,value:o})}for(let e=0;e<t.length;e+=1)r.has(e)||n.push({kind:"remove",index:e,value:t[e]});return n}(t,e):function(t,e){const n=[],i=Math.min(t.length,e.length);for(let r=0;r<i;r+=1)vt(t[r],e[r])||n.push({kind:"update",index:r,value:e[r]});if(e.length>t.length)for(let i=t.length;i<e.length;i+=1)n.push({kind:"insert",index:i,value:e[i]});if(t.length>e.length)for(let i=e.length;i<t.length;i+=1)n.push({kind:"remove",index:i,value:t[i]});return n}(t,e)}function vt(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||"object"!=typeof e||null===t||null===e)return!1;const n=t,i=e,r=Object.keys(n),s=Object.keys(i);if(r.length!==s.length)return!1;for(const t of r)if(!Object.is(n[t],i[t]))return!1;return!0}var yt={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"},bt=[0,500,1e3,2e3],wt=class{d;l;constructor(t){const e=t.emitter,n=t.renderers,i=t.resolveRenderer??(t=>n[t]),r=t.transformValue,s=t.root??("undefined"!=typeof document?document:null),o=t.readyTargets,a=t.sendReady??At,l=t.onHeartbeatTimeout,u=void 0===t.log?j:F(t.log),c=void 0===t.warn?H:F(t.warn),d=function(t){if(!1===t.enableA11y)return null;const e=void 0===t.root?void 0:9===t.root.nodeType?t.root:t.root.ownerDocument;return new ct(t.a11yLocale,e)}(t),h=void 0!==t.dataMerge?new V({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)=>{u(...t)}}):null,f=new y,p=new k({onStructuralChange:()=>{this.#P()},onVisibilityChange:(t,e)=>{e&&this.d[3].notifyVisible(t)}},{...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{}}),g=new tt(Z(t=>this.#R(t)),{...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.disableVisibilityGate?{disableVisibilityGate:t.disableVisibilityGate}:{},...void 0!==t.visibilityGateThreshold?{visibilityGateThreshold:t.visibilityGateThreshold}:{},isVisible:t=>p.isVisible(t),getCacheSize:()=>f.elementCount,onFlush:t=>{this.#O(t)}}),m=new R(t.originMatcher,{onUpdate:(t,e,n)=>{this.#M(t,e,n)},onDocumentEvent:()=>{e.emit("documentSave",{timestamp:Date.now()})},onInvalid:(t,n)=>{if("token"===t){const t=new Error(`Preview token rejected (origin: ${n})`);e.emit("error",{error:t,context:"token",code:"LP0502"})}u("LP0501 message rejected:",t,n)},...void 0!==t.validateToken?{validateToken:t.validateToken}:{}}),v=new U(()=>{}),b=new I({...void 0!==t.heartbeatMs?{timeoutMs:t.heartbeatMs}:{},onTimeout:()=>{this.#L()}});this.d=[e,f,p,g,m,v,b,n,i,r,s,o,a,l,u,c,[],d,h,!0===t.scopeBindingsByOwner,t.lockedOrigin??(()=>{})],this.l=[void 0,void 0,void 0,negotiateProtocol(void 0),!1,null,0,null,new Set,!1,!1,0,null,new Set]}start(){if(this.l[4])return!1;this.l[4]=!0;const t=this.d[10];if(St(t)&&"loading"===t.readyState){const e=()=>{if(this.l[4]){this.l[5]=null;try{this.#E()}catch(t){this.#I(),this.#U(t,"startup","LP0605")}}};this.l[5]=e;try{t.addEventListener("DOMContentLoaded",e,{once:!0})}catch(t){throw this.#I(),t}return!0}try{return this.#E(),!0}catch(t){throw this.#I(),t}}#E(){if(!this.l[4])return;const t=St(this.d[10])?this.d[10].body:this.d[10];if(null===t)throw new Error("LivePreviewRuntime: document.body unavailable");if(this.d[2].start(t),this.#F(),this.#j()&&(this.d[4].attach(),this.d[0].emitWhile("init",{timestamp:Date.now()},()=>this.l[4]),this.#j()))for(const t of bt){if(!this.#j())return;if(0===t){if(this.d[12](this.d[11]),!this.#j())return}else{const e=setTimeout(()=>{this.l[4]&&this.#D()},t);this.d[16].push(e)}}}suspend(){return!!this.l[4]&&(this.#H()&&this.d[0].emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0)}destroy(){this.l[4]&&(this.#H()&&this.d[0].emit("disconnect",{reason:"destroy",timestamp:Date.now()}),this.d[17]?.detach(),this.d[0].emit("destroy",{timestamp:Date.now()}))}#H(){this.l[7]=null,this.l[4]=!1;const t=this.l[5];this.l[5]=null,null!==t&&St(this.d[10])&&this.#G(()=>{this.d[10].removeEventListener("DOMContentLoaded",t)});for(const t of this.d[16])this.#G(()=>{clearTimeout(t)});return this.d[16].length=0,this.#G(()=>{this.d[6].stop()}),this.#G(()=>{this.d[4].detach()}),this.#G(()=>{this.d[2].stop()}),this.#G(()=>{this.d[3].destroy()}),this.#G(()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()}#I(){this.#H(),this.#G(()=>{this.d[17]?.detach()})}#G(t){try{t()}catch(t){this.d[14]("cleanup failed:",t)}}refreshCache(){this.l[4]&&this.#P()}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]}inspect(){const t=this.d[1],e=this.d[3],n=this.l[3],i=this.l[7],r=this.l[12],s=[],o=new Set;for(const[e,n]of t.entries()){s.push(e);for(const t of n)void 0!==t.owner&&o.add(t.owner)}return{version:nt,started:this.l[4],status:this.d[5].status,origins:{trusted:[...this.d[11]],locked:this.d[20]()},protocol:{ours:n.ours,theirs:n.theirs,negotiated:n.negotiated,capabilities:[...n.capabilities].sort()},revisions:{accepted:this.l[6],superseded:this.l[11],active:null===i?void 0:i.identity.revision},bindings:{elements:t.elementCount,fields:t.fieldCount,fieldNames:s.sort(),absentFields:[...this.l[13]].sort(),orphanFields:[...this.l[8]].sort(),ownerScoped:this.d[19],owners:[...o].sort()},scheduler:{pending:e.pendingCount,deferred:e.replayCount,visibilityGateThreshold:e.gateThreshold,visibilityGateActive:e.gateActive,lastFlush:null===r?void 0:{applied:r.applied,appliedFields:r.appliedFields,deferred:r.deferred,durationMs:r.durationMs}},renderers:Object.keys(this.d[7]).sort()}}#F(){if(!this.l[4])return;const t=this.d[1].buildFromRoot(this.d[10]);if(this.d[14]("cache",t),this.#j()&&(this.d[0].emitWhile("cacheRefresh",t,()=>this.l[4]),this.#j()))for(const t of this.d[1].values()){if(!this.#j())return;this.d[2].observeElement(t.element)}}#P(){if(!this.l[4])return;const t=new Map;for(const e of this.d[1].values())t.set(e.element,e),this.d[2].unobserveElement(e.element);if(this.#F(),this.#j()){for(const e of this.d[1].values()){const n=t.get(e.element);n?.fieldName===e.fieldName?this.d[3].retarget(e):this.d[3].forget(e.element),t.delete(e.element)}for(const e of t.values())this.d[3].forget(e.element)}}#z(t){const e=this.l[3];if(e.theirs===t)return;const n=negotiateProtocol(t);this.l[3]=n,n.negotiated!==e.negotiated&&this.d[14]("protocol","ours=4",`theirs=${t}`,`negotiated=${n.negotiated}`)}#M(t,e,n){if(this.d[6].kick(),void 0===t.data)return void(void 0!==t.protocolVersion&&this.#z(t.protocolVersion));if(void 0===n)return;"string"==typeof t.locale&&(this.l[0]=t.locale),Array.isArray(t.fieldSchemaJSON)&&(this.l[1]=t.fieldSchemaJSON,this.l[2]=ht(t.fieldSchemaJSON));const i={identity:n,message:t,locale:this.l[0],schema:this.l[1],schemaIndex:this.l[2],cancelled:!1};if(null!==this.l[7]&&(this.l[11]+=1),this.l[7]=i,this.d[3].acceptRevision(n),this.l[6]+=1,void 0===t.protocolVersion||(this.#z(t.protocolVersion),this.l[4]&&this.l[7]===i)){if(this.d[5].markConnected()){if(this.d[17]?.announceConnected(),this.d[0].emit("connect",{origin:e,timestamp:Date.now()}),!this.l[4]||this.l[7]!==i)return;if(this.d[14]("connection","disconnected","→","connected"),!this.l[4]||this.l[7]!==i)return}this.#W(i)}}async#W(t){const e=await this.#V(t);if(null===e||!this.l[4]||this.l[7]!==t)return;const{message:n}=t,i={fields:e,...void 0!==t.schema?{schema:t.schema}:{},..."string"==typeof n.globalSlug?{globalSlug:n.globalSlug}:{},..."string"==typeof n.collectionSlug?{collectionSlug:n.collectionSlug}:{},...void 0!==t.locale?{locale:t.locale}:{}};this.d[0].listenerCount("beforeUpdate")>0&&(!await this.d[0].emitWhile("beforeUpdate",{data:i,revision:t.identity.revision,cancel:()=>{t.cancelled=!0,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&&this.#B(t,i)}async#V(t){const{message:e}=t,n=e.data??{};if(null===this.d[18])return n;const i=await this.d[18].merge({collectionSlug:e.collectionSlug,globalSlug:e.globalSlug,data:n,locale:t.locale});return this.l[4]&&this.l[7]===t?"merged"===i.status?i.doc:"superseded"===i.status?null:n:null}#B(t,e){if(!this.l[4]||this.l[7]!==t)return;const n=()=>this.l[4]&&this.l[7]===t,i=this.#_(t,e.fields);for(const[r,s]of this.d[1].entries()){if(!this.l[4]||this.l[7]!==t)return;for(const o of s){if(!1!==i&&!A(o.owner,i))continue;const s=rt(e.fields,r,o.locale??t.locale,void 0!==o.locale);if(void 0===s){this.l[13].add(r);continue}if(!this.l[4]||this.l[7]!==t)return;const a=this.#q(o,s,e.fields,n);if(!this.l[4]||this.l[7]!==t)return;const l={target:o,value:a,allFields:e.fields,identity:t.identity,data:e};if(!this.l[4]||this.l[7]!==t)return;this.d[3].schedule(l)}}this.#J(e.fields,t.locale,i)}#_(t,e){if(!this.d[19])return!1;const{message:n}=t,i=function(t){if(S(t.globalSlug))return[(e=t.globalSlug,`global:${e}`)];var e;if(!S(t.collectionSlug))return null;const n=w(t.collectionSlug);return S(t.documentId)?[n,w(t.collectionSlug,t.documentId)]:[n]}({globalSlug:"string"==typeof n.globalSlug?n.globalSlug:void 0,collectionSlug:"string"==typeof n.collectionSlug?n.collectionSlug:void 0,documentId:T(e)});return null!==i||this.l[9]||(this.l[9]=!0,this.d[15]("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),i}#Q(t){for(const e of this.d[1].values())if(A(e.owner,t))return!0;return!1}#X(t,e){const n=this.d[1].get(t);return void 0!==n&&(!1===e||n.some(t=>A(t.owner,e)))}#J(t,e,n){if(0===this.d[1].fieldCount)return;if(!1!==n&&!this.#Q(n))return;let i;for(const[r,s]of Object.entries(t)){if(this.l[8].has(r))continue;if(kt.has(r))continue;if(!Ct(s))continue;const t=xt(r,e);if(!(this.#X(r,n)||t!==r&&this.#X(t,n))){if(void 0===i){i=new Set;for(const[t,e]of this.d[1].entries())for(const r of e)(!1===n||A(r.owner,n))&&void 0!==r.locale&&i.add(`${t}_${r.locale}`)}i.has(r)||(this.l[8].add(r),this.d[15](`[live-preview] LP0201: update arrived for field "${r}" but no <… 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.`))}}}#q(t,e,n,i){if(void 0===this.d[9])return e;try{const r=this.d[9](t.fieldName,e,{element:t.element,allFields:n},i),s=P(r);if(!i())return e;if(s)throw new TypeError(`Transform for "${t.fieldName}" returned a Promise/thenable; transforms must be synchronous`);return r}catch(t){if(!i())return e;const n=t instanceof Error?t:new Error(String(t));return this.d[0].emit("error",{error:n,context:"transform",code:"LP0602"}),e}}#j(){return this.l[4]}#Y(t){0!==t.deferred&&(this.l[10]||(this.l[10]=!0,this.d[15](`[live-preview] LP0301: visibility gate held ${String(t.deferred)} offscreen update(s) until scrolled into view; see visibilityGateThreshold.`)))}#R(t){const e=this.l[7];if(null===e||void 0===t.identity||!Tt(e.identity,t.identity)||!this.l[4]||this.l[7]!==e)return!1;const n=void 0!==e.schemaIndex?function(t,e){if(t.has(e))return t.get(e);const n=e.replace(/\.\d+(?=\.|$)/g,".*");return t.has(n)?t.get(n):void 0}(e.schemaIndex,t.target.fieldName):void 0,i=t.value;let r,s=function(t,e){if(t.explicitFieldType)return t.fieldType;if(void 0!==e){const t=function(t){if(Object.prototype.hasOwnProperty.call(yt,t))return yt[t]}(e);if(void 0!==t)return t}return t.fieldType}(t.target,n?.type);"text"===s&&!0!==t.target.explicitFieldType&&function(t){if("object"!=typeof t||null===t)return!1;if(!("root"in t))return!1;const e=t.root;return"object"==typeof e&&null!==e&&Array.isArray(e.children)}(i)&&(s="richText");try{r=this.d[8](s)}catch(t){if(!this.l[4]||this.l[7]!==e)return!1;const n=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:n,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===e),!1}if(!this.l[4]||this.l[7]!==e)return!1;const o=this.d[0].listenerCount("elementUpdate")>0,a=o?"INPUT"===(l=t.target.element).tagName||"TEXTAREA"===l.tagName?l.value:"IMG"===l.tagName?l.src:l.textContent:void 0;var l;if(!this.l[4]||this.l[7]!==e)return!1;const u={allFields:t.allFields,locale:t.target.locale??e.locale,schema:n};try{if(void 0!==t.target.targetAttribute){const e=function(t,e,n){const i=e.toLowerCase().trim();if(0===i.length)return"blocked";if(i.startsWith("on"))return"blocked";if(X.has(i))return"blocked";if(null==n)return t.removeAttribute(i),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";const r=String(n);return Y.has(i)&&!isSafeUrl(r)?"blocked":(t.setAttribute(i,r),"applied")}(t.target.element,t.target.targetAttribute,i);if("blocked"===e)return this.d[15](`[live-preview] LP0401: refused to write field "${t.target.fieldName}" into attribute "${t.target.targetAttribute}" (unsafe attribute or value)`),!1}else{if(!r)return this.d[14]("no renderer for",s),!1;{const e=function(t,e,n,i){return t.render(e,n,i)}(r,t.target,i,u);if(!1===e&&function(t){return K.has(t.render)}(r))return!1}}}catch(t){if(!this.l[4]||this.l[7]!==e)return!1;const n=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:n,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===e),!1}return!(!this.l[4]||this.l[7]!==e)&&(o&&this.d[0].emitWhile("elementUpdate",{element:t.target.element,fieldName:t.target.fieldName,previousValue:a,nextValue:i,revision:e.identity.revision},()=>this.l[4]&&this.l[7]===e),this.l[4]&&this.l[7]===e)}#O(t){this.l[12]=t,this.#Y(t);const{identity:e,data:n}=t;if(0===t.applied||void 0===e||void 0===n)return;const i=this.l[7];if(null===i||!this.l[4]||this.l[7]!==i||!Tt(i.identity,e))return;const r=()=>this.l[4]&&this.l[7]===i&&Tt(i.identity,e);this.d[17]?.announceUpdate(t.applied),r()&&0!==this.d[0].listenerCount("afterUpdate")&&this.d[0].emitWhile("afterUpdate",{data:n,updatedCount:t.applied,durationMs:t.durationMs,revision:e.revision},r)}#L(){if(!this.#j())return;this.d[4].advanceGeneration();const t=this.l[7];this.l[7]=null,null!==t&&this.d[3].cancelRevision(t.identity),this.d[18]?.destroy();const e=this.d[5].markDisconnected();try{this.d[13]?.()}catch(t){this.d[14]("heartbeat:",t)}if(this.#j()){if(e&&this.#K()){if(this.d[17]?.announceDisconnected(),this.d[0].emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.#K()),!this.#j())return;if(this.#K()&&(this.d[14]("connection","connected","→","disconnected"),!this.#j()))return}this.#j()&&this.#D()}}#D(){try{this.d[12](this.d[11])}catch(t){this.#U(t,"ready","LP0606")}}#U(t,e,n){const i=t instanceof Error?t:new Error(String(t));this.d[0].emit("error",{error:i,context:e,code:n})}#K(){return this.l[4]&&"disconnected"===this.d[5].status&&null===this.l[7]}};function St(t){return 9===t.nodeType}function At(t){if("undefined"==typeof window)return;const e=[];window.parent!==window&&e.push(window.parent),window.opener instanceof Window&&e.push(window.opener),R.sendReady(e,t)}function Tt(t,e){return t.generation===e.generation&&t.revision===e.revision}var kt=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function Ct(t){return null!=t&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)}function xt(t,e){if(!e)return t;const n=`_${e}`;return t.endsWith(n)?t.slice(0,-n.length):t}var Nt,$t=class{#Z=new Map;#tt=new Map;on(t,e){return this.#et(this.#Z,t,e)}once(t,e){return this.#et(this.#tt,t,e)}off(t,e){this.#nt(this.#Z,t,e),this.#nt(this.#tt,t,e)}async emit(t,e){await this.#it(t,e)}async emitWhile(t,e,n){return this.#it(t,e,n)}async#it(t,e,n){const i=()=>n?.()??!0;if(!i())return!1;const r=this.#Z.get(t);if(r)for(const n of[...r]){if(!i())return!1;if(await this.#rt(n,e,t),!i())return!1}if(!i())return!1;const s=this.#tt.get(t);if(s&&s.size>0){const n=[...s];this.#tt.delete(t);for(const r of n){if(!i())return!1;if(await this.#rt(r,e,t),!i())return!1}}return i()}listenerCount(t){return(this.#Z.get(t)?.size??0)+(this.#tt.get(t)?.size??0)}removeAllListeners(t){if(void 0===t)return this.#Z.clear(),void this.#tt.clear();this.#Z.delete(t),this.#tt.delete(t)}eventNames(){const t=new Set;for(const e of this.#Z.keys())t.add(e);for(const e of this.#tt.keys())t.add(e);return[...t]}#et(t,e,n){let i=t.get(e);return i||(i=new Set,t.set(e,i)),i.add(n),()=>{this.#nt(t,e,n)}}#nt(t,e,n){const i=t.get(e);void 0!==i&&(i.delete(n),0===i.size&&t.delete(e))}async#rt(t,e,n){try{await t(e)}catch(t){const e="string"==typeof n||"number"==typeof n?String(n):"<event>";D(`[live-preview] LP0601: handler for "${e}" threw:`,t)}}};function isInIframe(){if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch{return!0}}function isInPopup(){return"undefined"!=typeof window&&null!=window.opener}function isInPreviewContext(){return isInIframe()||isInPopup()}function isDevMode(){const t=function(){if("undefined"==typeof process)return;const t=process.env.NODE_ENV;return"string"==typeof t?t:void 0}();if(void 0!==t)return"production"!==t;const e=function(){const t=Rt();if(!t)return;const e=t.DEV;return"boolean"==typeof e?e:void 0}();if(void 0!==e)return e;if("undefined"!=typeof window){const t=window.location.hostname;if("localhost"===t||"127.0.0.1"===t)return!0}return!1}function Pt(t){if("undefined"!=typeof process){const e=process.env[t];if("string"==typeof e&&e.length>0)return e}const e=Rt();if(e){const n=e[t];if("string"==typeof n&&n.length>0)return n}}function Rt(){if("undefined"==typeof __INLINE_RUNTIME_BUILD__||!__INLINE_RUNTIME_BUILD__){if(void 0!==Nt)return Nt??void 0;Nt=null;try{const t=new Function("try { return import.meta && import.meta.env; } catch (_) { return undefined; }")();if(t&&"object"==typeof t)return Nt=t}catch{}}}var Ot=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,Mt=/^https?:\/\/[^/?#\s]+$/i,Lt=["PAYLOAD_ADMIN_ORIGIN","PUBLIC_PAYLOAD_ADMIN_ORIGIN","NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN"],Et=class{#st;constructor(t={}){const e=new Set;for(const n of t.additionalOrigins??[]){const t=Ut(n);void 0!==t&&e.add(t)}for(const t of Lt){const n=Pt(t);if(void 0!==n)for(const t of n.split(",")){const n=Ut(t);void 0!==n&&e.add(n)}}let n;if(t.enableReferrerDetection??1){const e=t.referrer??("undefined"!=typeof document?document.referrer:"");if(e.length>0)try{const t=new URL(e).origin;t&&"null"!==t&&(n=t)}catch{}}const i=(t.enableLocalhostMatching??!0)&&(t.forceDevMode??isDevMode());this.#st=[e,n,i,void 0!==n,void 0]}matches(t){return 0!==t.length&&"null"!==t&&(void 0!==this.#st[4]?t===this.#st[4]:!!this.#st[0].has(t)||0===this.#st[0].size&&void 0!==this.#st[1]&&t===this.#st[1]||!(!this.#st[2]||!Ot.test(t)))}lockOrigin(t){return!!this.matches(t)&&(this.#st[4]=t,!0)}unlockOrigin(){const t=this.#st[4];return this.#st[4]=void 0,t}get lockedOrigin(){return this.#st[4]}enumerate(){if(void 0!==this.#st[4])return[this.#st[4]];const t=new Set(this.#st[0]);if(0===this.#st[0].size&&void 0!==this.#st[1]&&t.add(this.#st[1]),this.#st[2])for(const e of It)t.add(`http://localhost:${String(e)}`),t.add(`http://127.0.0.1:${String(e)}`);return[...t]}get referrerWasAvailable(){return this.#st[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#st[0].size>0||this.#st[2]||void 0!==this.#st[1])}get isReferrerOnlyTrust(){return!(this.#st[0].size>0||this.#st[2]||void 0===this.#st[1])}},It=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function Ut(t){const e=t.trim();if(0!==e.length)try{const t=new URL(e);if("http:"!==t.protocol&&"https:"!==t.protocol)return;if(!Mt.test(t.origin))return;return t.origin}catch{return}}var Ft,jt=()=>{},Dt=class{#ot;#at;#lt=new Set;#st="staging";constructor(t,e){this.#ot=t,this.#at=e}assertOpen(){if("closed"===this.#st)throw new Error(`Plugin context for "${this.#ot}" is no longer active`)}get active(){return"active"===this.#st}eligible(){return"closed"!==this.#st}own(t){return this.assertOpen(),this.#ut({acquire:void 0,finalize:void 0,cleanup:t,disposed:!1})}stage(t,e){this.assertOpen();const n={acquire:t,finalize:e,cleanup:void 0,disposed:!1},i=this.#ut(n);if("active"===this.#st)try{this.#ct(n)}catch(t){throw this.#dt(n),t}return i}commit(){if("staging"!==this.#st)throw new Error(`Plugin context for "${this.#ot}" cannot be committed`);this.#st="committing";try{for(const t of this.#lt)this.#ct(t);this.#st="active"}catch(t){throw this.close(),t}}close(){if("closed"!==this.#st){this.#st="closed";for(const t of[...this.#lt].reverse())this.#dt(t);this.#lt.clear()}}#ut(t){return this.#lt.add(t),()=>{this.#dt(t)}}#ct(t){if(t.disposed||void 0!==t.cleanup||void 0===t.acquire)return;const e=t.acquire();t.cleanup=e??jt}#dt(t){if(t.disposed)return;t.disposed=!0,this.#lt.delete(t);const e=t.cleanup;if(t.cleanup=void 0,void 0!==e)try{P(e())&&this.#at(`plugin "${this.#ot}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(t){this.#at(`plugin "${this.#ot}" cleanup failed:`,t)}try{t.finalize?.()}catch(t){this.#at(`plugin "${this.#ot}" cleanup failed:`,t)}}},Ht=class extends $t{#ht;#ft;#pt=new Set;constructor(t,e){super(),this.#ht=t,this.#ft=e}on(t,e){return this.#gt("on",t,e)}once(t,e){return this.#gt("once",t,e)}off(t,e){const n=e;for(const e of[...this.#pt])e.event===t&&e.handler===n&&e.dispose()}emit(t,e){return this.#ft.assertOpen(),this.#ht.emit(t,e)}emitWhile(t,e,n){return this.#ft.assertOpen(),this.#ht.emitWhile(t,e,()=>{if(!this.#ft.eligible())return!1;const t=n();return!!this.#ft.eligible()&&t})}listenerCount(t){let e=0;for(const n of this.#pt)n.event===t&&(e+=1);return e}removeAllListeners(t){for(const e of[...this.#pt])void 0!==t&&e.event!==t||e.dispose()}eventNames(){const t=new Set;for(const e of this.#pt)t.add(e.event);return[...t]}#gt(t,e,n){this.#ft.assertOpen();const i=n,r=[...this.#pt].find(n=>n.kind===t&&n.event===e&&n.handler===i);if(void 0!==r)return r.dispose;let s=jt,o=!0;const a=async e=>{this.#ft.active&&o&&("once"===t&&s(),await n(e))},l={kind:t,event:e,handler:i,dispose:jt};return s=this.#ft.stage(()=>this.#ht[t](e,a),()=>{o=!1,this.#pt.delete(l)}),l.dispose=s,this.#pt.add(l),s}},Gt=class{#ht;#mt;#vt;#yt;#at;#bt=new Map;#wt=new Map;#St=new Map;#At=new Set;#Tt=new Map;#kt=Promise.resolve();#Ct=0;constructor(t){this.#ht=t.events,this.#mt=t.config,this.#vt=t.registerFieldRenderer,this.#at=F(t.log);const e=t.onTransformError;this.#yt=void 0===e?void 0:F((...t)=>{const n=t[0];if(n instanceof Error)try{return e(n)}catch(t){return void this.#at("transform error reporter failed:",t)}})}register(t){return this.#Ct>0?this.#xt(t):this.#Nt(()=>this.#xt(t))}unregister(t){return this.#Ct>0?this.#$t(t):this.#Nt(async()=>{await this.#$t(t)})}destroyAll(){return this.#Ct>0?this.#Pt():this.#Nt(async()=>{await this.#Pt()})}applyTransforms(t,e,n,i){const r=this.#Tt.get(t);if(void 0===r||0===r.length)return e;let s=e;for(const o of[...r]){if(!o.active)continue;const{transform:r}=o;if(!1===i?.())return e;try{s=r(s,{fieldName:t,element:n.element,allFields:n.allFields});const o=P(s);if(!1===i?.())return e;if(o)throw new TypeError(`Transform for "${t}" returned a Promise/thenable; transforms must be synchronous`)}catch(n){if(!1===i?.())return e;const r=n instanceof Error?n:new Error(String(n));return this.#at(`transform for "${t}" failed:`,r),this.#yt?.(r),e}}return s}list(){return[...this.#bt.keys()]}get size(){return this.#bt.size}async#xt(t){if(this.#bt.has(t.name)||this.#wt.has(t.name)||this.#St.has(t.name))return void this.#at(`plugin "${t.name}" already registered`);const e=new Dt(t.name,this.#at),n=this.#Rt(t.name,e),i={scope:e,cancelled:!1};this.#wt.set(t.name,i);try{if(await this.#Ot(()=>t.init(n)),i.cancelled)return;e.commit()}catch(n){return e.close(),void(i.cancelled||this.#at(`plugin "${t.name}" init failed:`,n))}finally{this.#wt.get(t.name)===i&&this.#wt.delete(t.name)}this.#bt.set(t.name,{plugin:t,scope:e}),this.#at(`plugin "${t.name}" registered`)}#Rt(t,e){return{events:new Ht(this.#ht,e),registerFieldRenderer:t=>{e.stage(()=>{const e=this.#vt(t);return"function"==typeof e?e:void 0})},registerTransform:(t,n)=>{const i={transform:n,active:!1};e.stage(()=>{i.active=!0;const e=this.#Tt.get(t);return void 0===e?this.#Tt.set(t,[i]):e.push(i),()=>{i.active=!1;const e=this.#Tt.get(t);if(void 0===e)return;const n=e.indexOf(i);n>=0&&e.splice(n,1),0===e.length&&this.#Tt.delete(t)}})},registerCleanup:t=>{e.own(t)},getConfig:()=>this.#mt,log:(...e)=>{this.#at(`[${t}]`,...e)}}}#$t(t){const e=this.#wt.get(t);if(void 0!==e)return e.cancelled=!0,e.scope.close(),Promise.resolve();const n=this.#St.get(t);if(void 0!==n)return this.#At.has(t)?Promise.resolve():n;const i=this.#bt.get(t);if(void 0===i)return Promise.resolve();this.#bt.delete(t),i.scope.close();const r=Promise.resolve().then(()=>this.#Mt(t,i.plugin));return this.#St.set(t,r),r.then(()=>{this.#St.get(t)===r&&this.#St.delete(t)}),r}async#Mt(t,e){if(void 0!==e.destroy){this.#At.add(t);try{await this.#Ot(()=>e.destroy?.())}catch(e){this.#at(`plugin "${t}" destroy failed:`,e)}finally{this.#At.delete(t)}}}async#Pt(){for(const t of this.#wt.values())t.cancelled=!0,t.scope.close();const t=[...this.#bt.keys()];for(const e of t)await this.#$t(e)}async#Ot(t){this.#Ct+=1;try{await t()}finally{this.#Ct-=1}}#Nt(t){const e=this.#kt.then(t);return this.#kt=e.catch(t=>{this.#at("plugin manager mutation failed:",t)}),e}},zt=class{#Lt;#Et;#It=new Map;constructor(t){this.#Lt=t,this.#Et={...t}}get renderers(){return this.#Et}resolve(t){return this.#Et[t]}register(t){const e=t.name,n={renderer:t},i=this.#It.get(e);void 0===i?this.#It.set(e,[n]):i.push(n),this.#Et[e]=t;let r=!0;return()=>{if(!r)return;r=!1;const t=this.#It.get(e);if(void 0===t)return;const i=t.indexOf(n);if(i<0)return;const s=i===t.length-1;if(t.splice(i,1),0===t.length&&this.#It.delete(e),!s)return;const o=t.at(-1),a=o?.renderer??this.#Lt[e];void 0===a?Reflect.deleteProperty(this.#Et,e):this.#Et[e]=a}}},Wt=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"]),Vt=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),Bt=new Set(["id","class","lang","dir","title","role","tabindex"]),_t={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"])},qt=new Set(["href","src","cite","poster"]),Jt=class extends Error{name="SanitizerEnvironmentError"};function sanitizeHtml(t,e){const n=Qt();if(!n)throw new Jt("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===t)return"";const i=function(t){if(!t){const t=new Map;for(const[e,n]of Object.entries(_t))t.set(e,n);return{allowedTags:Wt,attrByTag:t}}const e=new Set(Wt);for(const n of t.additionalAllowedTags??[])e.add(n);const n=new Map;for(const[t,e]of Object.entries(_t))n.set(t,e);for(const[e,i]of Object.entries(t.additionalAllowedAttributes??{})){const t=n.get(e),r=new Set(t??[]);for(const t of i)r.add(t);n.set(e,r)}return{allowedTags:e,attrByTag:n}}(e),r=n.createElement("template");r.innerHTML=t;const s=r.content;return Xt(s,i),function(t){const e=t.ownerDocument?.createElement("div"),n=t.firstChild;if(void 0!==e&&(e.append(t),e.firstChild===n))return e.innerHTML;throw new Jt("sanitizeHtml could not write what it cleaned with this document; use a browser, jsdom or linkedom document.")}(s)}function Qt(){return Ft||("undefined"!=typeof document?document:void 0)}function Xt(t,e){for(const n of Array.from(t.childNodes))1===n.nodeType?Yt(n,e):8===n.nodeType&&n.remove()}function Yt(t,e){const n=t.tagName.toLowerCase();if(Vt.has(n))t.remove();else{if(!e.allowedTags.has(n)){Xt(t,e);const n=t.parentNode;if(n){for(;t.firstChild;)n.insertBefore(t.firstChild,t);t.remove()}return}!function(t,e,n){const i=n.attrByTag.get(e);for(const e of Array.from(t.attributes)){const n=e.name.toLowerCase();n.startsWith("on")?t.removeAttribute(e.name):"style"!==n?Bt.has(n)||n.startsWith("aria-")||n.startsWith("data-")||(i?.has(n)?qt.has(n)&&!isSafeUrl(e.value)?t.removeAttribute(e.name):"srcset"!==n||Kt(e.value)||t.removeAttribute(e.name):t.removeAttribute(e.name)):t.removeAttribute(e.name)}}(t,n,e),"a"===n&&function(t){const e=t.getAttribute("href");null!==e&&isExternalHttpUrl(e)&&(t.setAttribute("rel","noopener noreferrer"),t.hasAttribute("target")||t.setAttribute("target","_blank"))}(t),Xt(t,e)}}function Kt(t){const e=t.split(",");for(const t of e){const e=t.trim();if(0===e.length)continue;const n=e.search(/\s/);if(!isSafeUrl(-1===n?e:e.slice(0,n)))return!1}return!0}var Zt=new Map;function te(t,e){Zt.set(t,e)}var ee={1:"left",2:"center",3:"right",4:"justify"},ne=new Set(["left","center","right","justify","start","end"]);function ie(t){const e=t.format;if("string"==typeof e&&ne.has(e))return e;if("number"==typeof e){const t=ee[e];if(void 0!==t)return t}}function re(t){const e=t.indent;return"number"==typeof e&&e>0?e:0}function se(t){return"rtl"===t.direction?' dir="rtl"':"ltr"===t.direction?' dir="ltr"':""}function oe(t){const e=ie(t),n=re(t),i=[];return void 0!==e&&i.push(`text-align:${e}`),n>0&&i.push(`padding-inline-start:${String(40*n)}px`),0===i.length?"":` style="${i.join(";")}"`}var ae=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}),le=/[&<>"'/`=]/g;function escapeHtml(t){return""===t?"":t.replace(le,t=>ae[t])}var ue=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'"}),ce=/[&<>"']/g;function escapeHtmlAttribute(t){return""===t?"":t.replace(ce,t=>ue[t])}function de(t){return escapeHtml(t).replace(/\r\n|\r|\n/g,"<br>")}var he=new Set(["h1","h2","h3","h4","h5","h6"]),fe=(t,e)=>{const n="string"==typeof t.url?t.url:"",i=e.renderChildren(t.children??[]);if(0===n.length||!isSafeUrl(n))return i;const r=isExternalHttpUrl(n)?' target="_blank" rel="noopener noreferrer"':function(t){const e="string"==typeof t.target?t.target:"";if(0===e.length)return"";const n=escapeHtml(e);return"_blank"===e?' target="_blank" rel="noopener noreferrer"':` target="${n}"`}(t),s="string"==typeof t.title?` title="${escapeHtml(t.title)}"`:"";return`<a href="${escapeHtmlAttribute(n)}"${r}${s}>${i}</a>`};function pe(t){if("string"==typeof t.text)return t.text;if(!t.children)return"";let e="";for(const n of t.children)e+=pe(n);return e}function ge(t){return t.replace(/[^a-zA-Z0-9_-]/g,"")}var me=new Map;function ve(t){return me.get(t)}function ye(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}te("text",t=>{let e=escapeHtml("string"==typeof t.text?t.text:"");const n="number"==typeof t.format?t.format:0;return!!(16&n)&&(e=`<code>${e}</code>`),!!(1&n)&&(e=`<strong>${e}</strong>`),!!(2&n)&&(e=`<em>${e}</em>`),!!(8&n)&&(e=`<u>${e}</u>`),!!(4&n)&&(e=`<s>${e}</s>`),!!(32&n)&&(e=`<sub>${e}</sub>`),!!(64&n)&&(e=`<sup>${e}</sup>`),!!(128&n)&&(e=`<mark>${e}</mark>`),e}),te("paragraph",(t,e)=>{const n=e.renderChildren(t.children??[]);return`<p${se(t)}${oe(t)}>${n}</p>`}),te("heading",(t,e)=>{const n="string"==typeof t.tag?t.tag.toLowerCase():"h2",i=he.has(n)?n:"h2",r=e.renderChildren(t.children??[]);return`<${i}${se(t)}${oe(t)}>${r}</${i}>`}),te("list",(t,e)=>{const n="string"==typeof t.listType?t.listType:"bullet",i="number"===n?"ol":"ul",r="number"===n&&"number"==typeof t.start&&t.start>1?` start="${String(t.start)}"`:"",s="check"===n?' role="list"':"",o=e.renderChildren(t.children??[]);return`<${i}${se(t)}${oe(t)}${r}${s}>${o}</${i}>`}),te("listitem",(t,e)=>{const n=e.renderChildren(t.children??[]);if("boolean"==typeof t.checked)return`<li role="checkbox" aria-checked="${t.checked?"true":"false"}"${oe(t)}>${n}</li>`;const i="number"==typeof t.value?` value="${escapeHtml(String(t.value))}"`:"";return`<li${se(t)}${oe(t)}${i}>${n}</li>`}),te("link",fe),te("autolink",fe),te("quote",(t,e)=>{const n=e.renderChildren(t.children??[]);return`<blockquote${se(t)}${oe(t)}>${n}</blockquote>`}),te("code",t=>{const e=ge("string"==typeof t.language?t.language:"");return`<pre><code${""===e?"":` class="language-${e}"`}>${escapeHtml(pe(t))}</code></pre>`}),te("code-highlight",t=>{const e="string"==typeof t.text?t.text:"";return`<span${"string"==typeof t.highlightType?` class="token-${ge(t.highlightType)}"`:""}>${escapeHtml(e)}</span>`}),te("linebreak",()=>"<br>"),te("horizontalrule",()=>"<hr>"),te("tab",()=>"\t"),te("upload",t=>{const e=function(t){const e=t.value;return"object"!=typeof e||null===e?void 0:e}(t);if(void 0===e)return"";const n=e.url;if("string"!=typeof n||!isSafeUrl(n))return"";const i="string"==typeof e.mimeType?e.mimeType:"";return i.startsWith("video/")?function(t,e){const n="number"==typeof t.width?` width="${String(t.width)}"`:"",i="number"==typeof t.height?` height="${String(t.height)}"`:"",r="string"==typeof t.mimeType?` type="${escapeHtmlAttribute(t.mimeType)}"`:"";return`<video controls${n}${i}><source src="${escapeHtmlAttribute(e)}"${r}></video>`}(e,n):i.startsWith("audio/")?function(t,e){const n="string"==typeof t.mimeType?` type="${escapeHtmlAttribute(t.mimeType)}"`:"";return`<audio controls><source src="${escapeHtmlAttribute(e)}"${n}></audio>`}(e,n):""===i||i.startsWith("image/")?function(t,e){const n="string"==typeof t.alt?escapeHtml(t.alt):"",i="number"==typeof t.width?` width="${String(t.width)}"`:"",r="number"==typeof t.height?` height="${String(t.height)}"`:"";return`<img src="${escapeHtmlAttribute(e)}" alt="${n}"${i}${r} loading="lazy" decoding="async">`}(e,n):function(t,e){const n="string"==typeof t.filename?escapeHtml(t.filename):escapeHtml(e);return`<a href="${escapeHtmlAttribute(e)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(e,n)}),te("relationship",t=>{const e="string"==typeof t.relationTo?t.relationTo:"",n=function(t){const e=t.value;return"object"!=typeof e||null===e?void 0:e}(t),i=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}`}(n,e),r=escapeHtml(i),s=""===e?"":` data-relation-to="${escapeHtml(e)}"`,o=n?.url;return"string"==typeof o&&isSafeUrl(o)?`<a href="${escapeHtmlAttribute(o)}"${s}>${r}</a>`:`<span${s}>${r}</span>`}),te("block",(t,e)=>{const n=function(t){const e=t.fields;return"object"!=typeof e||null===e?{}:e}(t),i="string"==typeof n.blockType?n.blockType:"",r=ye(i);if(""!==i){const t=ve(i)??ve(r);if(t)return t(n,{renderChildren:e.renderChildren})}const s=[];""!==r&&s.push(`data-block-type="${escapeHtml(r)}"`);for(const[t,e]of Object.entries(n)){if("blockType"===t||"id"===t)continue;if(null==e)continue;const n="string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);s.push(`data-block-${ye(t)}="${escapeHtml(n)}"`)}return`<div${0===s.length?"":` ${s.join(" ")}`}></div>`});var be={renderChildren:Ae,resolveAlignment:ie,resolveIndent:re};function we(t){if("object"!=typeof t||null===t)return!1;if(!("root"in t))return!1;const e=t.root;return"object"==typeof e&&null!==e&&"children"in e&&Array.isArray(e.children)}function Se(t){return we(t)?t.root.children.map(ke).join("\n").trim():""}function Ae(t){let e="";for(const n of t)e+=Te(n);return e}function Te(t){const e=(n=t.type,Zt.get(n));var n;return e?e(t,be):void 0!==t.children?Ae(t.children):""}function ke(t){if("string"==typeof t.text)return t.text;if("linebreak"===t.type)return"\n";if(void 0===t.children)return"";let e="";for(const n of t.children)e+=ke(n);return e}function Ce(){const t=new WeakSet;return{name:"text",render:Z((e,n)=>{const i=e.element,r=function(t){return null==t?"":we(t)?Se(t):"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName)return function(t){return null!==t.querySelector(":scope > :not(br)")}(i)&&!i.hasAttribute("data-payload-text")?(function(t,e,n){t.has(e)||(t.add(e),H(`[live-preview] LP0402: Skipping text update for "${n}": <${e.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}(t,i,e.fieldName),!1):void(r.includes("\n")||r.includes("\r")?i.innerHTML=de(r):i.textContent=r);i.value=r})}}function xe(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""}}var Ne={name:"textarea",render(t,e){const n=t.element,i=we(e)?Se(e):xe(e);"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName?n.innerHTML=de(i):n.value=i}},$e={name:"richText",render:Z((t,e)=>{if(we(e))t.element.innerHTML=function(t,e={}){if(!we(t))return"";const n=Ae(t.root.children);return!1===e.sanitize||void 0===Qt()?n:sanitizeHtml(n)}(e);else{if("string"!=typeof e)return!1;t.element.innerHTML=sanitizeHtml(e)}})},Pe={name:"html",render(t,e){if(null==e)return void(t.element.textContent="");const n="string"==typeof e?e:xe(e);t.element.innerHTML=sanitizeHtml(n)}},Re={name:"url",render(t,e,n){const i=t.element,r=xe(e);if("A"===i.tagName){const s=i,o=t.hrefField,a=void 0===o||0===o.length?e:rt(n.allFields,o,n.locale,void 0!==t.locale);return"string"==typeof a&&isSafeUrl(a)&&(s.href=a),void(s.textContent=r)}"INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName?i.textContent=r:i.value=r}},Oe={name:"image",render:Z((t,e,n)=>{const i=t.element,r=Me(e),s=void 0!==t.locale,o=function(t,e,n,i,r,s){if(void 0!==n&&n.length>0){const t=rt(i,n,r,s);if("string"==typeof t&&isSafeUrl(t))return t;const e=Me(t);return void 0!==e?.url&&isSafeUrl(e.url)?e.url:void 0}return void 0!==t?.url&&isSafeUrl(t.url)?t.url:"string"==typeof e&&isSafeUrl(e)?e:void 0}(r,e,t.srcField,n.allFields,n.locale,s);if(void 0===o)return!1;if("IMG"===i.tagName){const e=i;e.src=o;const a=function(t,e,n,i,r){if(void 0!==e&&e.length>0){const t=rt(n,e,i,r);return"string"==typeof t?t:void 0}return void 0!==t?.alt?t.alt:void 0}(r,t.altField,n.allFields,n.locale,s);return void(void 0!==a&&(e.alt=a))}i.style.backgroundImage=`url('${function(t){return t.replace(/['"()\\]/g,"\\$&")}(o)}')`})};function Me(t){if("object"==typeof t&&null!==t)return t}var Le={name:"upload",render:Z((t,e)=>{const n=t.element,i=function(t){return"object"!=typeof t||null===t?void 0:t}(e);if(void 0===i)return!1;const r=i.url;if("string"!=typeof r||!isSafeUrl(r))return!1;if("IMG"===n.tagName){const t=n;return t.src=r,void(void 0!==i.alt&&(t.alt=i.alt))}if("A"===n.tagName){const t=n;return t.href=r,void(t.textContent=i.filename??r)}const s=void 0!==i.filename?escapeHtml(i.filename):escapeHtml(r);n.innerHTML=`<a href="${escapeHtmlAttribute(r)}">${s}</a>`})},Ee={name:"relationship",render(t,e){const n=t.element,i=function(t){return null==t?[""]:Array.isArray(t)?t.map(Ie):[Ie(t)]}(e),r=i.join(", ");if("A"===n.tagName&&!Array.isArray(e)){const t=n,i=e?.url;return"string"==typeof i&&isSafeUrl(i)&&(t.href=i),void(t.textContent=r)}n.textContent=r}};function Ie(t){if("object"==typeof t&&null!==t){const 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 xe(t)}var Ue={name:"select",render(t,e){const n=t.element,i=Fe(e);if("SELECT"!==n.tagName){if("INPUT"===n.tagName&&"radio"===n.type){const t=n;return void(t.checked=t.value===i)}n.textContent=i}else n.value=i}};function Fe(t){return Array.isArray(t)?t.map(t=>Fe(t)).join(", "):xe(t)}var je={name:"checkbox",render(t,e){const n=t.element,i=Boolean(e);"INPUT"!==n.tagName||"checkbox"!==n.type?n.hasAttribute("aria-checked")?n.setAttribute("aria-checked",i?"true":"false"):n.textContent=i?"true":"false":n.checked=i}},De=new Map,He=new Map;function Ge(t,e){const n=t??"";if(null==e)return n;const i=ze(e);return"{}"===i?n:`${n}|${i}`}function ze(t){if(null===t||"object"!=typeof t)return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(t=>ze(t)).join(",")}]`;const e=t,n=Object.keys(e).sort(),i=[];for(const t of n){const n=e[t];void 0!==n&&i.push(`${JSON.stringify(t)}:${ze(n)}`)}return`{${i.join(",")}}`}function We(t){for(;t.size>64;){const e=t.keys().next().value;if(void 0===e)break;t.delete(e)}}var Ve={name:"date",render(t,e,n){const i=t.element;if(null==e||""===e)return void("INPUT"===i.tagName?i.value="":"TIME"===i.tagName?(i.removeAttribute("datetime"),i.textContent=""):i.textContent="");const r="string"==typeof e?e:xe(e),s=new Date(r),o=!Number.isNaN(s.getTime());if("INPUT"!==i.tagName)return"TIME"===i.tagName?(i.setAttribute("datetime",o?s.toISOString():r),void(i.textContent=o?Be(s,n):r)):void(i.textContent=o?Be(s,n):r);i.value=o?function(t,e){return"date"===t?e.toISOString().slice(0,10):"datetime-local"===t?e.toISOString().slice(0,16):e.toISOString()}(i.type,s):r}};function Be(t,e){const n=e.locale??detectInitialLocale();try{return function(t,e){const n=Ge(t,e),i=He.get(n);if(void 0!==i)return He.delete(n),He.set(n,i),i;const r=new Intl.DateTimeFormat(t,e);return He.set(n,r),We(He),r}(n,{dateStyle:"medium",timeStyle:"short"}).format(t)}catch{return t.toISOString()}}var _e={name:"number",render(t,e,n){const i=t.element;if(null==e||""===e)return void("INPUT"===i.tagName?i.value="":i.textContent="");const r="number"==typeof e?e:Number(xe(e));Number.isNaN(r)?i.textContent=xe(e):"INPUT"!==i.tagName?i.textContent=function(t,e){const n=e.locale??detectInitialLocale();try{return function(t,e){const n=Ge(t,e),i=De.get(n);if(void 0!==i)return De.delete(n),De.set(n,i),i;const r=new Intl.NumberFormat(t,e);return De.set(n,r),We(De),r}(n).format(t)}catch{return String(t)}}(r,n):i.value=String(r)}},qe=/\{\{([\s\S]*?)\}\}/g;function Je(t,e,n,i){const r="object"==typeof e&&null!==e?e:null;return t.replace(qe,(t,s)=>null!==r&&function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r,s)?escapeHtml(i(Reflect.get(r,s))):null===r&&"value"===s?escapeHtml(i(e)):"index"===s?String(n):t)}var Qe={name:"array",render:Z((t,e)=>{const n=t.element;if(!Array.isArray(e))return!1;const i=t.arrayTemplate;if(void 0!==i&&i.length>0){const t=function(t,e){let n="";for(let i=0;i<e.length;i+=1)n+=Xe(t,e[i],i);return n}(i,e);return void(n.innerHTML=sanitizeHtml(t))}const r=t.arraySeparator??", ";n.textContent=e.map(Ye).join(r)})};function Xe(t,e,n){return Je(t,e,n,xe)}function Ye(t){return xe(t)}var Ke="data-payload-key",Ze="data-payload-nested-key",tn="data-payload-nested-template";function en(t){const{template:e,container:n,patches:i,nextItems:r,store:s,forceRender:o=!1}=t,a=nn(n,e,i,r,o,s);return null===a?null:rn(a,s)}function nn(t,e,n,i,r,s){const o=function(t){const e=new Set,n=new Set;for(const i of t)"insert"===i.kind||"update"===i.kind?e.add(i.index):"replace"===i.kind&&(e.add(i.index),n.add(i.index));return{renders:e,replaces:n}}(n),a=function(t,e,n,i,r,s,o){const a=Array.from(t.children),l=dn(a,Ke),u=new Set,c=[];for(let d=0;d<n.length;d+=1){const h=n[d],f=cn(h);let p=void 0===f?a[d]??null:hn(l,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);const g=i.replaces.has(d),m=r||i.renders.has(d)||null===p?fn(t.ownerDocument,e,h,d):void 0;if(null===m)return null;const v=void 0===m?[]:sn(g?null:p,m,h,s,o);if(null===v)return null;c.push([d,p,m??void 0,v])}return c}(t,e,i,o,r,s.get(t),s);return null===a?null:[t,a,i]}function rn(t,e){const[n,i,r]=t,s=new Set;let o=!1;for(const t of i){const[i,r,a,l]=t;let u=r;if(void 0!==a){for(const t of l)null!==t[0]&&(an(t[0],t[1]),t[1].replaceWith(t[0])),void 0!==t[2]&&rn(t[2],e);null!==r&&(r.replaceWith(a),o=!0),u=a}if(null===u)continue;const c=n.children[i]??null;u!==c&&(n.insertBefore(u,c),o=!0),s.add(u)}for(const t of Array.from(n.children))s.has(t)||(t.remove(),o=!0);const a=function(t,e){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}(n,e);a.clear();for(const t of r)un(a,t);return o}function sn(t,e,n,i,r){const s=dn(null===t?[]:on(t),Ze),o=cn(n),a=void 0!==o?i?.get(o):void 0,l=[];for(const t of on(e)){const e=t.getAttribute(Ze);if(null===e)continue;const i=hn(s,e)??null,o=t.getAttribute(tn),u=o?i:null,c=u?.getAttribute(tn)??null;let d;if(o){const i=ln(n,e);if(void 0!==i||null!==u){const n=i??[],s=mt(null===u?[]:ln(a,e)??[],n),l=null!==u&&c!==o;if((s.length>0||l)&&(d=nn(u??t,o,s,n,l,r)??void 0,void 0===d))return null}}l.push([u,t,d])}return l}function on(t){return Array.from(t.querySelectorAll(`[${Ze}]`)).filter(e=>{let n=e.parentElement;for(;null!==n&&n!==t;){if(n.hasAttribute(Ze))return!1;n=n.parentElement}return n===t})}function an(t,e){for(const n of Array.from(t.attributes))e.hasAttribute(n.name)||t.removeAttribute(n.name);for(const n of Array.from(e.attributes))t.getAttribute(n.name)!==n.value&&t.setAttribute(n.name,n.value)}function ln(t,e){if("object"!=typeof t||null===t)return;const n=t[e];return Array.isArray(n)?n:void 0}function un(t,e){const n=cn(e);void 0!==n&&t.set(n,e)}function cn(t){if("object"!=typeof t||null===t)return;const e=t.id;return"string"==typeof e||"number"==typeof e?String(e):void 0}function dn(t,e){const n=new Map;for(let i=t.length-1;i>=0;i-=1){const r=t[i];if(void 0===r)continue;const s=r.getAttribute(e);if(null===s)continue;const o=n.get(s);void 0===o?n.set(s,[r]):o.push(r)}return n}function hn(t,e){return t.get(e)?.pop()}function fn(t,e,n,i){const r=function(t,e,n){return Je(t,e,n,xe)}(e,n,i),s=sanitizeHtml(r),o=t.createElement("template");o.innerHTML=s;const a=o.content.firstElementChild;if(!a)return null;const l=cn(n);return void 0!==l&&a.setAttribute(Ke,l),a}function pn(){const t=new WeakMap,e=new WeakSet,n=new WeakMap;return{name:"structural-array",render:Z((i,r)=>{if(!Array.isArray(r))return!1;const s=i.element,o=i.arrayTemplate;if(void 0===o||0===o.length)return function(t,e,n){t.has(e)||(t.add(e),H(`[live-preview] LP0403: Skipping structural update for "${n}": <${e.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(e,s,i.fieldName),!1;const a=t.get(s),l=gn(s),u=mt(a?.values??l.map((t,e)=>null===t?{__payloadDomPosition:e}:{id:t}),r),c=function(t,e,n){return void 0===t||t.template!==e||!function(t,e){return t.length===e.length&&t.every((t,n)=>t===e[n])}(t.domSnapshot,n)}(a,o,l);if(0===u.length&&!c)return t.set(s,{values:r.slice(),template:o,domSnapshot:l}),!1;const d=en({template:o,container:s,patches:u,nextItems:r,store:n,forceRender:c});return null!==d&&(t.set(s,{values:r.slice(),template:o,domSnapshot:gn(s)}),!!d&&void 0)})}}function gn(t){return Array.from(t.children,t=>t.getAttribute(Ke))}var mn,vn=new Map,yn=[Ne,$e,Pe,Re,{...Re,name:"email"},Oe,Le,Ee,Ue,{...Ue,name:"radio"},je,Ve,_e,Qe,{...Qe,name:"blocks"}],bn=class{#Ut=new $t;#Ft;#jt;#Dt;#bt;#at;#Ht=!1;#Gt=!1;#zt=null;constructor(t={}){const e=t.debug??isDevMode();this.#at=e?(...t)=>{G("[live-preview]",...t)}:j,this.#Ft=new Et({...void 0!==t.allowedOrigins?{additionalOrigins:t.allowedOrigins}:{},...void 0!==t.disableReferrerDetection?{enableReferrerDetection:!t.disableReferrerDetection}:{},...void 0!==t.disableLocalhostMatching?{enableLocalhostMatching:!t.disableLocalhostMatching}:{}}),this.#Ft.isProductionUnconfigured&&this.#at("no trusted origin could be detected — set allowedOrigins or PAYLOAD_ADMIN_ORIGIN"),this.#jt=new zt(function(t=[]){const e={};for(const n of t)e[n.name]=n;for(const[t,n]of vn)e[t]=n;return Object.freeze(e)}([Ce(),...yn,pn()])),this.#bt=new Gt({events:this.#Ut,config:Object.freeze({...t}),registerFieldRenderer:t=>this.#jt.register(t),onTransformError:t=>{this.#Ut.emit("error",{error:t,context:"transform",code:"LP0602"})},log:this.#at}),this.#Dt=new wt({...void 0!==t.root?{root:t.root}:{},renderers:this.#jt.renderers,resolveRenderer:t=>this.#jt.resolve(t),transformValue:(t,e,n,i)=>this.#bt.applyTransforms(t,e,n,i),originMatcher:t=>this.#Ft.matches(t),readyTargets:this.#Ft.enumerate(),emitter:this.#Ut,...void 0!==t.serverURL&&""!==t.serverURL?{dataMerge:{serverURL:t.serverURL,...void 0!==t.apiRoute?{apiRoute:t.apiRoute}:{},...void 0!==t.mergeDepth?{depth:t.mergeDepth}:{},...void 0!==t.mergeFetch?{fetchFn:t.mergeFetch}:{}}}:{},...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.heartbeatMs?{heartbeatMs:t.heartbeatMs}:{},...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{},...void 0!==t.scopeBindingsByOwner?{scopeBindingsByOwner:t.scopeBindingsByOwner}:{},...void 0!==t.disableVisibilityGate?{disableVisibilityGate:t.disableVisibilityGate}:{},...void 0!==t.visibilityGateThreshold?{visibilityGateThreshold:t.visibilityGateThreshold}:{},...void 0!==t.enableA11y?{enableA11y:t.enableA11y}:{},...void 0!==t.a11yLocale?{a11yLocale:t.a11yLocale}:{},onHeartbeatTimeout:()=>{this.#Ft.unlockOrigin()},lockedOrigin:()=>this.#Ft.lockedOrigin,...void 0!==t.validateToken?{validateToken:t.validateToken}:{},log:this.#at}),this.#Ut.on("connect",t=>{this.#Ft.lockOrigin(t.origin)}),!1!==t.autoStart&&this.start()}start(){if(this.#Gt)return!1;if(this.#Ht)return this.#Dt.start(),!0;if(!isInPreviewContext())return!1;const t=this.#Dt.start();return t&&(this.#Ht=!0),t}suspend(){return!(this.#Gt||!this.#Ht)&&this.#Dt.suspend()}resume(){return!(this.#Gt||!this.#Ht)&&this.#Dt.start()}destroy(){if(null!==this.#zt)return this.#zt;let t,e;this.#Gt=!0;const n=new Promise((n,i)=>{t=n,e=i});this.#zt=n;try{this.#Dt.destroy(),this.#bt.destroyAll().finally(()=>{this.#Ut.removeAllListeners()}).then(t,e)}catch(t){this.#Ut.removeAllListeners(),e(t)}return n}async use(t){if(this.#Gt)throw new Error("LivePreviewClient: already destroyed");await this.#bt.register(t)}async unuse(t){await this.#bt.unregister(t)}refreshCache(){this.#Dt.refreshCache()}get events(){return this.#Ut}get plugins(){return this.#bt.list()}get status(){return this.#Dt.status}inspect(){return this.#Dt.inspect()}get updateCount(){return this.#Dt.updateCount}get destroyed(){return this.#Gt}},wn=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",OrphanField:"LP0201",UnattributableUpdate:"LP0202",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",MessageRejected:"LP0501",TokenRejected:"LP0502",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",AuditRuntimeMissing:"LP0701",AuditNoFrameAncestors:"LP0702",AuditFrameOptionsBlocks:"LP0703",AuditBindingsExposed:"LP0704",AuditGateThresholdExceeded:"LP0705",AuditUnownedBindings:"LP0706",AuditNoBindings:"LP0707",AuditNotAPage:"LP0708"});function bind(t,e){return Sn(t,e)}function bindByPath(t,e){const n=function(t){const e=[],n=new Proxy({},{get(t,i){if("symbol"!=typeof i)return/^\d+$/.test(i)||e.push(i),n}});try{t(n)}catch{}return e}(t);if(0===n.length)throw new Error("bindByPath: the picker did not read any field — return data.<field> instead of a constant");return Sn(n.join("."),e)}function Sn(t,e){if(0===t.length)throw new Error("bind: field name must be a non-empty string");const n={"data-payload-field":t};return void 0!==e?.attribute&&(n["data-payload-attribute"]=e.attribute),void 0!==e?.type&&(n["data-payload-type"]=e.type),!0===e?.richtext&&(n["data-payload-richtext"]=""),!0===e?.html&&(n["data-payload-html"]=""),void 0!==e?.locale&&(n["data-payload-locale"]=e.locale),n}var An=Object.freeze({});for(const[t,e]of[[$t,"EventEmitter"],[bn,"LivePreviewClient"],[Et,"OriginDetector"]])Object.defineProperty(t,"name",{configurable:!0,value:e});exports.CORE_ENTRY=!0,exports.DIAGNOSTIC_CODES=wn,exports.EventEmitter=$t,exports.LIBRARY_PROTOCOL_VERSION=4,exports.LivePreviewClient=bn,exports.OriginDetector=Et,exports.VERSION=nt,exports.bind=bind,exports.bindByPath=bindByPath,exports.buildFrameAncestors=function buildFrameAncestors(t={}){const{self:e=!0,origins:n=[],allowNone:i=!1}=t,r=new Set,s=[];if(i&&!e&&0===n.length)return"'none'";e&&(s.push("'self'"),r.add("'self'"));for(const t of n){const e=t.trim();0===e.length||r.has(e)||(r.add(e),s.push(e))}return s.length>0?s.join(" "):"'none'"},exports.buildScriptSrcWithNonce=function buildScriptSrcWithNonce(t,e={}){if(0===t.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");const{self:n=!0,extra:i=[],strictDynamic:r=!1}=e,s=[];n&&s.push("'self'"),s.push(`'nonce-${t}'`),r&&s.push("'strict-dynamic'");for(const t of i){const e=t.trim();e.length>0&&s.push(e)}return s.join(" ")},exports.createPreviewBindings=function createPreviewBindings(t){const{authorized:e}=t,n=void 0!==t.owner&&t.owner.length>0?t.owner:void 0;return Object.freeze({authorized:e,bind:(t,n)=>e?bind(t,n):An,bindByPath:(t,n)=>e?bindByPath(t,n):An,owner:()=>e&&void 0!==n?{"data-payload-owner":n}:An})},exports.detectInitialLocale=detectInitialLocale,exports.escapeHtml=escapeHtml,exports.escapeHtmlAttribute=escapeHtmlAttribute,exports.generateCspNonce=function generateCspNonce(t=16){if(!Number.isInteger(t)||t<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(t)}`);const e=function(){if(mn?.getRandomValues)return mn;const t=globalThis.crypto;return t?.getRandomValues?t:void 0}();if(!e)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.");const n=new Uint8Array(t);return e.getRandomValues(n),function(t){let e="";for(const n of t)e+=String.fromCharCode(n);return("function"==typeof btoa?btoa(e):Buffer.from(t).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}(n)},exports.hasCapability=function hasCapability(t,e){return t.capabilities.has(e)},exports.initLivePreview=function initLivePreview(t={}){const e=new bn({...t,autoStart:!1});return e.start()?e:null},exports.isDevMode=isDevMode,exports.isExternalHttpUrl=isExternalHttpUrl,exports.isInIframe=isInIframe,exports.isInPopup=isInPopup,exports.isInPreviewContext=isInPreviewContext,exports.isSafeUrl=isSafeUrl,exports.negotiateProtocol=negotiateProtocol,exports.sanitizeHtml=sanitizeHtml,exports.setCspCrypto=function setCspCrypto(t){mn=t??void 0},exports.setSanitizerDocument=function setSanitizerDocument(t){Ft=t??void 0};
|
|
2
2
|
//# sourceMappingURL=core.cjs.map
|