payload-live-preview 1.0.2 → 1.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/security/csp.ts","../../../src/inline/runtime.generated.ts","../../../src/inline/generator.ts","../../../src/adapters/shared/preview-request.ts","../../../src/adapters/nextjs/index.ts"],"names":[],"mappings":";;;AAoBA,IAAM,mBAAA,GAAsB,EAAA;AAgDrB,SAAS,gBAAA,CAAiB,QAAgB,mBAAA,EAA6B;AAC5E,EAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,IAAK,QAAQ,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,qDAAA,EAAwD,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F;AACA,EAAA,MAAM,SAAS,aAAA,EAAc;AAC7B,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAGF;AAAA,EACF;AACA,EAAA,MAAM,MAAA,GAAS,IAAI,UAAA,CAAW,KAAK,CAAA;AACnC,EAAA,MAAA,CAAO,gBAAgB,MAAM,CAAA;AAC7B,EAAA,OAAO,gBAAgB,MAAM,CAAA;AAC/B;AAEA,SAAS,aAAA,GAA2C;AAElD,EAAA,MAAM,aAAc,UAAA,CAA0C,MAAA;AAC9D,EAAA,IAAI,UAAA,EAAY,iBAAiB,OAAO,UAAA;AACxC,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,gBAAgB,KAAA,EAA2B;AAClD,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,EAAO,MAAA,IAAU,MAAA,CAAO,aAAa,IAAI,CAAA;AAC5D,EAAA,MAAM,MAAA,GAAS,OAAO,IAAA,KAAS,UAAA,GAAa,IAAA,CAAK,MAAM,CAAA,GAAI,MAA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A,GAAoC,EAAE,iBAAA,EAAmB,cAAA,EAAe;AAC9E,EAAA,IAAI,SAAS,MAAA,EAAQ;AACnB,IAAA,SAAA,CAAU,YAAY,CAAA,GAAI,uBAAA,CAAwB,KAAA,EAAO;AAAA,MACvD,IAAA,EAAM,IAAA;AAAA,MACN,aAAA,EAAe,QAAQ,aAAA,IAAiB,KAAA;AAAA,MACxC,GAAI,QAAQ,cAAA,KAAmB,MAAA,GAAY,EAAE,KAAA,EAAO,OAAA,CAAQ,cAAA,EAAe,GAAI;AAAC,KACjF,CAAA;AAAA,EACH;AACA,EAAA,MAAM,QAAA,GAAW,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,yBAAyB,CAAA,IAAK,EAAA;AACpE,EAAA,MAAM,IAAA,GAAO,cAAA,CAAe,QAAA,EAAU,SAAS,CAAA;AAC/C,EAAA,IAAI;AACF,IAAA,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,sBAAA,EAAwB,KAAK,CAAA;AAClD,IAAA,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,yBAAA,EAA2B,IAAI,CAAA;AACpD,IAAA,OAAO,QAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAQ,QAAA,CAAS,OAAO,CAAA;AAC5C,IAAA,OAAA,CAAQ,GAAA,CAAI,wBAAwB,KAAK,CAAA;AACzC,IAAA,OAAA,CAAQ,GAAA,CAAI,2BAA2B,IAAI,CAAA;AAC3C,IAAA,OAAO,IAAI,QAAA,CAAS,QAAA,CAAS,IAAA,EAAM;AAAA,MACjC,QAAQ,QAAA,CAAS,MAAA;AAAA,MACjB,YAAY,QAAA,CAAS,UAAA;AAAA,MACrB;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"index.cjs","sourcesContent":["/**\n * Content-Security-Policy helpers.\n *\n * Two responsibilities:\n *\n * 1. Generate cryptographic nonces so consumers can opt into a strict\n * `script-src 'nonce-...'` policy and avoid `'unsafe-inline'`.\n * 2. Build the `frame-ancestors` directive value, restricting which\n * origins may embed the preview page in an iframe.\n *\n * Both functions are isomorphic — they work in browsers, Node, and\n * edge runtimes that expose Web Crypto via `globalThis.crypto`.\n *\n * @module @security/csp\n */\n\n/**\n * Default byte-length for nonces. 16 bytes → 22 base64url characters,\n * which exceeds the 128-bit entropy threshold recommended by OWASP.\n */\nconst DEFAULT_NONCE_BYTES = 16;\n\n/**\n * Minimal Web-Crypto surface area we actually call. The full `Crypto`\n * type drags in browser-only declarations that don't typecheck cleanly\n * against Node's `webcrypto` shape — this narrower interface accepts\n * both without an unsafe cast.\n */\ninterface WebCryptoLike {\n getRandomValues: <T extends ArrayBufferView | null>(array: T) => T;\n}\n\nlet cryptoOverride: WebCryptoLike | undefined;\n\n/**\n * Inject a Web Crypto implementation to use when `globalThis.crypto`\n * is unavailable.\n *\n * Node.js exposed `globalThis.crypto` globally starting with v19. On\n * Node 18 (still LTS at time of writing) consumers can flip the\n * `--experimental-global-webcrypto` flag *or* call this function once\n * at startup:\n *\n * ```ts\n * import { webcrypto } from 'node:crypto';\n * import { setCspCrypto } from 'payload-live-preview';\n * setCspCrypto(webcrypto as { getRandomValues: typeof webcrypto.getRandomValues });\n * ```\n *\n * Browser bundles never need to call this — `globalThis.crypto` is\n * always present there, and the override only matters when the global\n * is missing.\n *\n * Pass `null` to clear a previous override (mostly useful for tests).\n */\nexport function setCspCrypto(crypto: WebCryptoLike | null): void {\n cryptoOverride = crypto ?? undefined;\n}\n\n/**\n * Generate a base64url-encoded cryptographic nonce.\n *\n * Uses `crypto.getRandomValues` everywhere — falls back to throwing\n * if no Web Crypto implementation is available, because a predictable\n * nonce would silently defeat the entire CSP.\n *\n * @param bytes Number of random bytes (defaults to 16 → 128-bit entropy).\n */\nexport function generateCspNonce(bytes: number = DEFAULT_NONCE_BYTES): string {\n if (!Number.isInteger(bytes) || bytes < 8) {\n throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(bytes)}`);\n }\n const crypto = resolveCrypto();\n if (!crypto) {\n throw new Error(\n 'generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) ' +\n \"once at startup, or run with --experimental-global-webcrypto. We won't fabricate \" +\n 'a predictable nonce — that would silently defeat the entire CSP.',\n );\n }\n const buffer = new Uint8Array(bytes);\n crypto.getRandomValues(buffer);\n return base64UrlEncode(buffer);\n}\n\nfunction resolveCrypto(): WebCryptoLike | undefined {\n if (cryptoOverride?.getRandomValues) return cryptoOverride;\n const fromGlobal = (globalThis as { crypto?: WebCryptoLike }).crypto;\n if (fromGlobal?.getRandomValues) return fromGlobal;\n return undefined;\n}\n\nfunction base64UrlEncode(bytes: Uint8Array): string {\n let binary = '';\n for (const byte of bytes) binary += String.fromCharCode(byte);\n const base64 = typeof btoa === 'function' ? btoa(binary) : Buffer.from(bytes).toString('base64');\n return base64.replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '');\n}\n\n/**\n * Sources allowed in the `frame-ancestors` directive.\n *\n * Conceptually a union of `'self'`, `'none'`, or an explicit origin\n * string. TypeScript collapses literal-vs-string unions, so we expose\n * a `string` alias and document the special values.\n */\nexport type FrameAncestorSource = string;\n\nexport interface FrameAncestorsOptions {\n readonly self?: boolean;\n readonly origins?: readonly string[];\n readonly allowNone?: boolean;\n}\n\n/**\n * Build the value for `frame-ancestors` in a `Content-Security-Policy`\n * header.\n *\n * Returns `'none'` if `allowNone: true` and no other sources are\n * provided. Otherwise concatenates `'self'` (if requested) with the\n * given origins, deduplicating and trimming entries.\n *\n * @example\n * `frame-ancestors ${buildFrameAncestors({ self: true, origins: [adminUrl] })}`\n */\nexport function buildFrameAncestors(options: FrameAncestorsOptions = {}): string {\n const { self = true, origins = [], allowNone = false } = options;\n const seen = new Set<string>();\n const out: FrameAncestorSource[] = [];\n if (allowNone && !self && origins.length === 0) return \"'none'\";\n if (self) {\n out.push(\"'self'\");\n seen.add(\"'self'\");\n }\n for (const origin of origins) {\n const trimmed = origin.trim();\n if (trimmed.length === 0 || seen.has(trimmed)) continue;\n seen.add(trimmed);\n out.push(trimmed);\n }\n return out.length > 0 ? out.join(' ') : \"'none'\";\n}\n\n/**\n * Build a `script-src` value that permits a single nonce plus optional\n * extra sources.\n *\n * `'strict-dynamic'` is **opt-in**: under CSP 3 it makes browsers\n * ignore `'self'` and every host source in the directive, so any\n * parser-inserted script without a nonce (framework hydration scripts,\n * consumer `<script>` tags) would be blocked. Only enable it when every\n * script on the page carries the nonce.\n */\nexport function buildScriptSrcWithNonce(\n nonce: string,\n options: {\n readonly self?: boolean;\n readonly extra?: readonly string[];\n readonly strictDynamic?: boolean;\n } = {},\n): string {\n if (nonce.length === 0) throw new RangeError('buildScriptSrcWithNonce: nonce is empty');\n const { self = true, extra = [], strictDynamic = false } = options;\n const parts: string[] = [];\n if (self) parts.push(\"'self'\");\n parts.push(`'nonce-${nonce}'`);\n if (strictDynamic) parts.push(\"'strict-dynamic'\");\n for (const e of extra) {\n const trimmed = e.trim();\n if (trimmed.length > 0) parts.push(trimmed);\n }\n return parts.join(' ');\n}\n\n/**\n * How a directive is merged into an existing CSP header value.\n *\n * - `union` (default) — the new sources are added to the existing\n * directive's sources (deduplicated). An existing `'none'` is\n * dropped when real sources are added, since `'none'` may not be\n * combined with other sources.\n * - `replace` — the new value overwrites the existing directive.\n */\nexport interface CspDirectiveMerge {\n readonly value: string;\n readonly mode?: 'union' | 'replace';\n}\n\n/**\n * Merge directives into an existing `Content-Security-Policy` header\n * value without clobbering what a consumer (or another middleware)\n * already configured. Directives not mentioned in `additions` pass\n * through untouched; new directives are appended.\n *\n * This is the single CSP-merge implementation shared by every adapter.\n */\nexport function mergeCspHeader(\n existing: string,\n additions: Readonly<Record<string, string | CspDirectiveMerge>>,\n): string {\n const directives = new Map<string, string>();\n for (const part of existing.split(';')) {\n const trimmed = part.trim();\n if (trimmed.length === 0) continue;\n const spaceIndex = trimmed.indexOf(' ');\n if (spaceIndex < 0) {\n directives.set(trimmed.toLowerCase(), '');\n continue;\n }\n directives.set(\n trimmed.slice(0, spaceIndex).toLowerCase(),\n trimmed.slice(spaceIndex + 1).trim(),\n );\n }\n\n for (const [rawName, rawAddition] of Object.entries(additions)) {\n const name = rawName.toLowerCase();\n const addition: CspDirectiveMerge =\n typeof rawAddition === 'string' ? { value: rawAddition } : rawAddition;\n const mode = addition.mode ?? 'union';\n const current = directives.get(name);\n if (mode === 'replace' || current === undefined || current.length === 0) {\n directives.set(name, addition.value);\n continue;\n }\n const seen = new Set<string>();\n const merged: string[] = [];\n for (const token of [...current.split(/\\s+/), ...addition.value.split(/\\s+/)]) {\n if (token.length === 0 || seen.has(token)) continue;\n seen.add(token);\n merged.push(token);\n }\n // `'none'` cannot coexist with other sources.\n const withoutNone = merged.filter((token) => token !== \"'none'\");\n directives.set(name, (withoutNone.length > 0 ? withoutNone : merged).join(' '));\n }\n\n const out: string[] = [];\n for (const [name, value] of directives) {\n out.push(value.length === 0 ? name : `${name} ${value}`);\n }\n return out.join('; ');\n}\n","// Auto-generated by scripts/build-runtime.ts — do not edit.\nexport interface RuntimeBuildInfo { readonly generatedAt: string; readonly size: number }\nexport const RUNTIME_SOURCE: string = \"\\\"use strict\\\";(()=>{var Xr=Object.defineProperty;var Dn=t=>{throw TypeError(t)};var Zr=(t,e,n)=>e in t?Xr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var $n=(t,e,n)=>Zr(t,typeof e!=\\\"symbol\\\"?e+\\\"\\\":e,n),Ft=(t,e,n)=>e.has(t)||Dn(\\\"Cannot \\\"+n);var i=(t,e,n)=>(Ft(t,e,\\\"read from private field\\\"),n?n.call(t):e.get(t)),l=(t,e,n)=>e.has(t)?Dn(\\\"Cannot add the same private member more than once\\\"):e instanceof WeakSet?e.add(t):e.set(t,n),d=(t,e,n,r)=>(Ft(t,e,\\\"write to private field\\\"),r?r.call(t,n):e.set(t,n),n),f=(t,e,n)=>(Ft(t,e,\\\"access private method\\\"),n);var F,_,ne,Dt,$t,Tt=class{constructor(){l(this,ne);l(this,F,new Map);l(this,_,new Map)}on(e,n){return f(this,ne,Dt).call(this,i(this,F),e,n)}once(e,n){return f(this,ne,Dt).call(this,i(this,_),e,n)}off(e,n){i(this,F).get(e)?.delete(n),i(this,_).get(e)?.delete(n)}async emit(e,n){let r=i(this,F).get(e);if(r)for(let s of[...r])await f(this,ne,$t).call(this,s,n,e);let o=i(this,_).get(e);if(o&&o.size>0){let s=[...o];i(this,_).delete(e);for(let a of s)await f(this,ne,$t).call(this,a,n,e)}}listenerCount(e){return(i(this,F).get(e)?.size??0)+(i(this,_).get(e)?.size??0)}removeAllListeners(e){if(e===void 0){i(this,F).clear(),i(this,_).clear();return}i(this,F).delete(e),i(this,_).delete(e)}eventNames(){let e=new Set;for(let n of i(this,F).keys())e.add(n);for(let n of i(this,_).keys())e.add(n);return[...e]}};F=new WeakMap,_=new WeakMap,ne=new WeakSet,Dt=function(e,n,r){let o=e.get(n);return o||(o=new Set,e.set(n,o)),o.add(r),()=>{e.get(n)?.delete(r)}},$t=async function(e,n,r){try{await e(n)}catch(o){let s=typeof r==\\\"string\\\"||typeof r==\\\"number\\\"?String(r):\\\"<event>\\\";console.error(`[live-preview] handler for \\\"${s}\\\" threw:`,o)}};var ue=\\\"data-payload-field\\\",Un=\\\"data-payload-type\\\",Qr=\\\"data-payload-attribute\\\",ei=\\\"data-payload-href\\\",ti=\\\"data-payload-src\\\",ni=\\\"data-payload-alt\\\",ri=\\\"data-payload-array-template\\\",ii=\\\"data-payload-array-separator\\\",oi=\\\"data-payload-locale\\\",si=`[${ue}]`,Hn=new Set([\\\"text\\\",\\\"textarea\\\",\\\"richText\\\",\\\"email\\\",\\\"number\\\",\\\"checkbox\\\",\\\"date\\\",\\\"select\\\",\\\"radio\\\",\\\"array\\\",\\\"blocks\\\",\\\"group\\\",\\\"tabs\\\",\\\"row\\\",\\\"collapsible\\\",\\\"relationship\\\",\\\"upload\\\",\\\"point\\\",\\\"json\\\",\\\"code\\\",\\\"ui\\\",\\\"html\\\",\\\"url\\\",\\\"image\\\",\\\"structural-array\\\"]),E,Y,we,re,Ut,Ht,wt=class{constructor(e={}){l(this,re);l(this,E,new Map);l(this,Y,new WeakMap);l(this,we);d(this,we,e.filter??di)}buildFromRoot(e){let n=performance.now();i(this,E).clear();let r=e.querySelectorAll(si),o=0;for(let s of r){if(!i(this,we).call(this,s))continue;let a=f(this,re,Ht).call(this,s);a&&(f(this,re,Ut).call(this,a),i(this,Y).set(s,a),o+=1)}return{elementCount:o,fieldCount:i(this,E).size,durationMs:performance.now()-n}}add(e){if(!i(this,we).call(this,e))return;let n=f(this,re,Ht).call(this,e);if(n)return f(this,re,Ut).call(this,n),i(this,Y).set(e,n),n}remove(e){let n=i(this,Y).get(e);if(!n)return!1;i(this,Y).delete(e);let r=i(this,E).get(n.fieldName);if(!r)return!1;let o=r.indexOf(n);return o<0?!1:(r.splice(o,1),r.length===0&&i(this,E).delete(n.fieldName),!0)}get(e){return i(this,E).get(e)}getByElement(e){return i(this,Y).get(e)}get fieldCount(){return i(this,E).size}get elementCount(){let e=0;for(let n of i(this,E).values())e+=n.length;return e}entries(){return i(this,E).entries()}*values(){for(let e of i(this,E).values())yield*e}has(e){return i(this,Y).has(e)}clear(){i(this,E).clear()}};E=new WeakMap,Y=new WeakMap,we=new WeakMap,re=new WeakSet,Ut=function(e){let n=i(this,E).get(e.fieldName);if(n){n.push(e);return}i(this,E).set(e.fieldName,[e])},Ht=function(e){let n=e.getAttribute(ue);if(n===null||n.length===0)return;let r=e.getAttribute(Un),o=ai(e),s=e.getAttribute(Qr),a=e.getAttribute(ei),u=e.getAttribute(ti),m=e.getAttribute(ni),T=e.getAttribute(ri),W=e.getAttribute(ii),c=e.getAttribute(oi);return{element:e,fieldName:n,fieldType:o,explicitFieldType:r!==null&&Hn.has(r),...s!==null&&s.length>0?{targetAttribute:s}:{},...a!==null?{hrefField:a}:{},...u!==null?{srcField:u}:{},...m!==null?{altField:m}:{},...T!==null?{arrayTemplate:T}:{},...W!==null?{arraySeparator:W}:{},...c!==null?{locale:c}:{}}};function ai(t){let e=t.getAttribute(Un);if(e!==null&&Hn.has(e))return e;if(t.hasAttribute(\\\"data-payload-richtext\\\"))return\\\"richText\\\";if(t.hasAttribute(\\\"data-payload-html\\\"))return\\\"html\\\";if(t.hasAttribute(\\\"data-payload-structural\\\"))return\\\"structural-array\\\";if(t.hasAttribute(\\\"data-payload-array\\\"))return\\\"array\\\";if(t.tagName===\\\"IMG\\\")return\\\"image\\\";if(t.tagName===\\\"A\\\")return\\\"url\\\";if(t.tagName===\\\"TIME\\\")return\\\"date\\\";if(t.tagName===\\\"INPUT\\\"){let n=t.type;if(n===\\\"checkbox\\\")return\\\"checkbox\\\";if(n===\\\"number\\\")return\\\"number\\\";if(n===\\\"date\\\"||n===\\\"datetime-local\\\")return\\\"date\\\"}return\\\"text\\\"}function di(){return!0}var li=100,ui=\\\"200px\\\",ce,$e,Ue,M,fe,ie,D,xe,jn,Vn,xt=class{constructor(e,n={}){l(this,xe);l(this,ce);l(this,$e);l(this,Ue);l(this,M,new Set);l(this,fe,null);l(this,ie,null);l(this,D,null);d(this,ce,e),d(this,$e,n.mutationDebounceMs??li),d(this,Ue,n.intersectionRootMargin??ui)}start(e){d(this,fe,new MutationObserver(n=>{f(this,xe,jn).call(this,n)})),i(this,fe).observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[ue]}),d(this,ie,new IntersectionObserver(n=>{f(this,xe,Vn).call(this,n)},{rootMargin:i(this,Ue),threshold:0}))}observeElement(e){i(this,ie)?.observe(e)}unobserveElement(e){i(this,ie)?.unobserve(e),i(this,M).delete(e)}markVisible(e,n){n?i(this,M).add(e):i(this,M).delete(e)}isVisible(e){return i(this,M).has(e)}stop(){i(this,D)!==null&&(clearTimeout(i(this,D)),d(this,D,null)),i(this,fe)?.disconnect(),i(this,ie)?.disconnect(),d(this,fe,null),d(this,ie,null),i(this,M).clear()}};ce=new WeakMap,$e=new WeakMap,Ue=new WeakMap,M=new WeakMap,fe=new WeakMap,ie=new WeakMap,D=new WeakMap,xe=new WeakSet,jn=function(e){ci(e)&&(i(this,D)!==null&&clearTimeout(i(this,D)),d(this,D,setTimeout(()=>{d(this,D,null),i(this,ce).onStructuralChange()},i(this,$e))))},Vn=function(e){for(let n of e){let r=n.target;n.isIntersecting?i(this,M).has(r)||(i(this,M).add(r),i(this,ce).onVisibilityChange(r,!0)):i(this,M).has(r)&&(i(this,M).delete(r),i(this,ce).onVisibilityChange(r,!1))}};function ci(t){for(let e of t){if(e.type===\\\"attributes\\\"&&e.attributeName===ue)return!0;for(let n of e.addedNodes)if(Bn(n))return!0;for(let n of e.removedNodes)if(Bn(n))return!0}return!1}function Bn(t){if(t.nodeType!==Node.ELEMENT_NODE)return!1;let e=t;return e.hasAttribute(ue)?!0:e.querySelector(`[${ue}]`)!==null}var fi={basic:1,\\\"schema-json\\\":2,\\\"preview-token\\\":3,\\\"nested-arrays\\\":4,\\\"recursive-diffs\\\":4};function Bt(t){let e=typeof t==\\\"number\\\"&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0,r=Math.min(4,e??1),o=new Set;for(let[s,a]of Object.entries(fi))r>=a&&o.add(s);return{ours:4,...e!==void 0?{theirs:e}:{theirs:void 0},negotiated:r,capabilities:o}}var Be,x,ve,pe,je,Se,Gn,Wn,He=class{constructor(e,n){l(this,Se);l(this,Be);l(this,x);l(this,ve);l(this,pe,!1);l(this,je,Promise.resolve());d(this,Be,e),d(this,x,n),d(this,ve,r=>{f(this,Se,Gn).call(this,r)})}attach(e=window){i(this,pe)||(e.addEventListener(\\\"message\\\",i(this,ve)),d(this,pe,!0))}detach(e=window){i(this,pe)&&(e.removeEventListener(\\\"message\\\",i(this,ve)),d(this,pe,!1))}static sendReady(e,n){if(e.length===0||n.length===0)return;let r={type:\\\"payload-live-preview\\\",ready:!0,protocolVersion:4};for(let o of e)for(let s of n)try{o.postMessage(r,s)}catch{}}};Be=new WeakMap,x=new WeakMap,ve=new WeakMap,pe=new WeakMap,je=new WeakMap,Se=new WeakSet,Gn=function(e){let n=e.origin;if(!i(this,Be).call(this,n)){i(this,x).onInvalid?.(\\\"origin\\\",n);return}let r=e.data;if(!pi(r)){i(this,x).onInvalid?.(\\\"shape\\\",n);return}switch(r.type){case\\\"payload-live-preview\\\":if(!mi(r)){i(this,x).onInvalid?.(\\\"shape\\\",n);return}f(this,Se,Wn).call(this,r,n);return;case\\\"payload-document-event\\\":i(this,x).onDocumentEvent(r,n);return;default:i(this,x).onInvalid?.(\\\"type\\\",n)}},Wn=function(e,n){let r=i(this,x).validateToken;if(r===void 0){i(this,x).onUpdate(e,n);return}if(e.ready===!0&&e.data===void 0){i(this,x).onUpdate(e,n);return}let o;try{o=r(e.previewToken,n)}catch{i(this,x).onInvalid?.(\\\"token\\\",n);return}if(typeof o==\\\"boolean\\\"){o?i(this,x).onUpdate(e,n):i(this,x).onInvalid?.(\\\"token\\\",n);return}d(this,je,i(this,je).then(async()=>{let s;try{s=await o}catch{i(this,x).onInvalid?.(\\\"token\\\",n);return}s?i(this,x).onUpdate(e,n):i(this,x).onInvalid?.(\\\"token\\\",n)}))};function pi(t){return typeof t!=\\\"object\\\"||t===null||!(\\\"type\\\"in t)?!1:typeof t.type==\\\"string\\\"}function mi(t){let e=t;return!(e.data!==void 0&&!hi(e.data)||e.fieldSchemaJSON!==void 0&&!Array.isArray(e.fieldSchemaJSON)||e.globalSlug!==void 0&&typeof e.globalSlug!=\\\"string\\\"||e.collectionSlug!==void 0&&typeof e.collectionSlug!=\\\"string\\\"||e.locale!==void 0&&typeof e.locale!=\\\"string\\\"||e.ready!==void 0&&typeof e.ready!=\\\"boolean\\\"||e.previewToken!==void 0&&typeof e.previewToken!=\\\"string\\\"||e.protocolVersion!==void 0&&typeof e.protocolVersion!=\\\"number\\\")}function hi(t){return typeof t==\\\"object\\\"&&t!==null&&!Array.isArray(t)}var Ee,Ve,C,ze,St=class{constructor(e){l(this,Ee);l(this,Ve);l(this,C,null);l(this,ze,0);d(this,Ee,e.timeoutMs??0),d(this,Ve,e.onTimeout)}kick(){d(this,ze,Date.now()),!(i(this,Ee)<=0)&&(i(this,C)!==null&&clearTimeout(i(this,C)),d(this,C,setTimeout(()=>{d(this,C,null),i(this,Ve).call(this)},i(this,Ee))))}stop(){i(this,C)!==null&&(clearTimeout(i(this,C)),d(this,C,null))}get lastKickAt(){return i(this,ze)}get pending(){return i(this,C)!==null}};Ee=new WeakMap,Ve=new WeakMap,C=new WeakMap,ze=new WeakMap;var me,Ge,ke,vt,Et=class{constructor(e){l(this,ke);l(this,me,\\\"disconnected\\\");l(this,Ge);d(this,Ge,e)}get status(){return i(this,me)}markConnected(){return f(this,ke,vt).call(this,\\\"connected\\\")}markConnecting(){return f(this,ke,vt).call(this,\\\"connecting\\\")}markDisconnected(){return f(this,ke,vt).call(this,\\\"disconnected\\\")}};me=new WeakMap,Ge=new WeakMap,ke=new WeakSet,vt=function(e){if(i(this,me)===e)return!1;let n=i(this,me);return d(this,me,e),i(this,Ge).call(this,e,n),!0};var yi=()=>{},We,Ye,qe,Ke,he,q,kt=class{constructor(e){l(this,We);l(this,Ye);l(this,qe);l(this,Ke);l(this,he);l(this,q,null);d(this,We,e.serverURL.replace(/\\\\/+$/,\\\"\\\"));let n=e.apiRoute??\\\"/api\\\";d(this,Ye,n.startsWith(\\\"/\\\")?n:`/${n}`),d(this,qe,e.depth??1),d(this,Ke,e.fetchFn),d(this,he,e.log??yi)}canMerge(e){if(e.globalSlug!==void 0&&e.globalSlug!==\\\"\\\")return!0;if(e.collectionSlug===void 0||e.collectionSlug===\\\"\\\")return!1;let n=e.data.id;return typeof n==\\\"string\\\"||typeof n==\\\"number\\\"}async merge(e){if(!this.canMerge(e))return{status:\\\"unavailable\\\"};let n=i(this,Ke)??(typeof fetch==\\\"function\\\"?fetch:void 0);if(n===void 0)return{status:\\\"unavailable\\\"};i(this,q)?.abort();let r=new AbortController;d(this,q,r);let o=e.globalSlug!==void 0&&e.globalSlug!==\\\"\\\"?`globals/${e.globalSlug}`:`${e.collectionSlug}/${String(e.data.id)}`,s=`${i(this,We)}${i(this,Ye)}/${encodeURI(o)}`;try{let a=await n(s,{method:\\\"POST\\\",credentials:\\\"include\\\",headers:{\\\"Content-Type\\\":\\\"application/json\\\",\\\"X-Payload-HTTP-Method-Override\\\":\\\"GET\\\"},body:JSON.stringify({data:e.data,depth:i(this,qe),flattenLocales:!1,...e.locale!==void 0?{locale:e.locale}:{}}),signal:r.signal});if(!a.ok)return i(this,he).call(this,\\\"merge fetch failed\\\",a.status,s),{status:\\\"unavailable\\\"};let u=await a.json();return u===null||typeof u!=\\\"object\\\"||Array.isArray(u)?(i(this,he).call(this,\\\"merge fetch returned non-object\\\",s),{status:\\\"unavailable\\\"}):{status:\\\"merged\\\",doc:u}}catch(a){return r.signal.aborted?{status:\\\"superseded\\\"}:(i(this,he).call(this,\\\"merge fetch error\\\",a),{status:\\\"unavailable\\\"})}finally{i(this,q)===r&&d(this,q,null)}}destroy(){i(this,q)?.abort(),d(this,q,null)}};We=new WeakMap,Ye=new WeakMap,qe=new WeakMap,Ke=new WeakMap,he=new WeakMap,q=new WeakMap;var gi=new Set([\\\"http:\\\",\\\"https:\\\",\\\"mailto:\\\",\\\"tel:\\\"]),bi=/^\\\\s*(?:javascript|data|vbscript|file|blob|about)\\\\s*:/i,Ri=/^(?:\\\\.{1,2}\\\\/|[a-zA-Z0-9_-]+\\\\/?)/;function b(t){if(typeof t!=\\\"string\\\"||t.length===0)return!1;let e=t.trim();if(e.length===0||bi.test(e))return!1;if(e.startsWith(\\\"#\\\")||e.startsWith(\\\"?\\\")||e.startsWith(\\\"//\\\")||e.startsWith(\\\"/\\\"))return!0;try{let n=new URL(e);return gi.has(n.protocol)}catch{return Ri.test(e)}}function At(t){if(!b(t))return!1;let e=t.trim();return/^https?:\\\\/\\\\//i.test(e)||/^\\\\/\\\\/[^/]/.test(e)}var Ti=new Set([\\\"style\\\",\\\"srcdoc\\\",\\\"formaction\\\",\\\"form\\\",\\\"id\\\",\\\"name\\\",\\\"is\\\",\\\"srcset\\\",\\\"imagesrcset\\\"]),wi=new Set([\\\"href\\\",\\\"src\\\",\\\"poster\\\",\\\"cite\\\",\\\"action\\\",\\\"xlink:href\\\",\\\"data\\\"]);function Yn(t,e,n){let r=e.toLowerCase().trim();if(r.length===0||r.startsWith(\\\"on\\\")||Ti.has(r))return\\\"blocked\\\";if(n==null)return t.removeAttribute(r),\\\"applied\\\";if(typeof n!=\\\"string\\\"&&typeof n!=\\\"number\\\"&&typeof n!=\\\"boolean\\\")return\\\"blocked\\\";let o=String(n);return wi.has(r)&&!b(o)?\\\"blocked\\\":(t.setAttribute(r,o),\\\"applied\\\")}var Ae,Je,Xe,Ze,Qe,et,tt,nt,Le,$,K,k,U,J,qn,Kn,jt,Lt=class{constructor(e,n){l(this,J);l(this,Ae);l(this,Je);l(this,Xe);l(this,Ze);l(this,Qe);l(this,et);l(this,tt);l(this,nt);l(this,Le);l(this,$,new Map);l(this,K,new Map);l(this,k,null);l(this,U,null);d(this,Ae,e),d(this,Je,n.debounceMs??50),d(this,Xe,n.isVisible),d(this,Ze,n.visibilityGateThreshold??50),d(this,Qe,n.disableVisibilityGate??!1),d(this,et,n.getCacheSize),d(this,tt,n.onFlush),d(this,nt,n.scheduleFrame??(typeof requestAnimationFrame==\\\"function\\\"?requestAnimationFrame.bind(globalThis):r=>setTimeout(()=>{r(performance.now())},0))),d(this,Le,n.cancelFrame??(typeof cancelAnimationFrame==\\\"function\\\"?cancelAnimationFrame.bind(globalThis):r=>{clearTimeout(r)}))}schedule(e){let n=i(this,$).get(e.target.element);n?(n.value=e.value,n.allFields=e.allFields):i(this,$).set(e.target.element,{target:e.target,value:e.value,allFields:e.allFields}),f(this,J,qn).call(this)}flushNow(){return i(this,k)!==null&&(clearTimeout(i(this,k)),d(this,k,null)),f(this,J,jt).call(this)}notifyVisible(e){let n=i(this,K).get(e);n&&(i(this,K).delete(e),i(this,Ae).call(this,n))}forget(e){i(this,$).delete(e),i(this,K).delete(e)}destroy(){i(this,k)!==null&&(clearTimeout(i(this,k)),d(this,k,null)),i(this,U)!==null&&(i(this,Le).call(this,i(this,U)),d(this,U,null)),i(this,$).clear(),i(this,K).clear()}get pendingCount(){return i(this,$).size}get replayCount(){return i(this,K).size}};Ae=new WeakMap,Je=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,Le=new WeakMap,$=new WeakMap,K=new WeakMap,k=new WeakMap,U=new WeakMap,J=new WeakSet,qn=function(){i(this,k)!==null&&clearTimeout(i(this,k)),d(this,k,setTimeout(()=>{d(this,k,null),f(this,J,Kn).call(this)},i(this,Je)))},Kn=function(){i(this,U)!==null&&i(this,Le).call(this,i(this,U)),d(this,U,i(this,nt).call(this,()=>{d(this,U,null),f(this,J,jt).call(this)}))},jt=function(){var u;let e=performance.now(),n=!i(this,Qe)&&i(this,et).call(this)>i(this,Ze),r=i(this,$);d(this,$,new Map);let o=0,s=0;for(let m of r.values()){if(n&&!i(this,Xe).call(this,m.target.element)){i(this,K).set(m.target.element,m),s+=1;continue}i(this,Ae).call(this,m),o+=1}let a={applied:o,deferred:s,durationMs:performance.now()-e};return(u=i(this,tt))==null||u.call(this,a),a};function Me(){let t=xi();if(t!==void 0)return t;let e=vi();return e!==void 0?e:\\\"en\\\"}function xi(){if(typeof document>\\\"u\\\")return;let t=document.documentElement.getAttribute(\\\"lang\\\");return t===null||t.length===0?void 0:t}function vi(){if(typeof navigator>\\\"u\\\")return;let t=navigator.language;return typeof t==\\\"string\\\"&&t.length>0?t:void 0}var Jn=\\\"payload-live-preview-a11y\\\",Si=1500,Ei=[\\\"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\\\"].join(\\\";\\\"),Xn={connected:\\\"Live preview connected\\\",disconnected:\\\"Live preview disconnected\\\",updated:t=>`${String(t)} ${t===1?\\\"change\\\":\\\"changes\\\"} applied`},ki={en:Xn,de:{connected:\\\"Vorschau verbunden\\\",disconnected:\\\"Vorschau getrennt\\\",updated:t=>`${String(t)} ${t===1?\\\"\\\\xC4nderung\\\":\\\"\\\\xC4nderungen\\\"} angewendet`}};function Ai(t){let e=t.split(/[-_]/)[0]?.toLowerCase()??\\\"en\\\";return ki[e]??Xn}var I,ye,H,oe,Zn,Mt,rt=class{constructor(e=Me()){l(this,oe);l(this,I,null);l(this,ye);l(this,H,null);d(this,ye,Ai(e))}announceConnected(){f(this,oe,Mt).call(this,i(this,ye).connected)}announceDisconnected(){f(this,oe,Mt).call(this,i(this,ye).disconnected)}announceUpdate(e){e<=0||f(this,oe,Mt).call(this,i(this,ye).updated(e))}detach(){i(this,H)!==null&&(clearTimeout(i(this,H)),d(this,H,null)),i(this,I)?.parentNode&&i(this,I).parentNode.removeChild(i(this,I))}};I=new WeakMap,ye=new WeakMap,H=new WeakMap,oe=new WeakSet,Zn=function(){if(i(this,I)!==null&&i(this,I).isConnected)return i(this,I);if(typeof document>\\\"u\\\"||document.body===null)return null;let e=document.getElementById(Jn);return e||(e=document.createElement(\\\"div\\\"),e.id=Jn,e.setAttribute(\\\"role\\\",\\\"status\\\"),e.setAttribute(\\\"aria-live\\\",\\\"polite\\\"),e.setAttribute(\\\"aria-atomic\\\",\\\"true\\\"),e.setAttribute(\\\"style\\\",Ei),document.body.appendChild(e)),d(this,I,e),e},Mt=function(e){let n=f(this,oe,Zn).call(this);n&&(n.textContent=e,i(this,H)!==null&&clearTimeout(i(this,H)),d(this,H,setTimeout(()=>{d(this,H,null),i(this,I)&&(i(this,I).textContent=\\\"\\\")},Si)))};var Li=new Set([\\\"tabs\\\",\\\"row\\\",\\\"collapsible\\\"]);function Vt(t,e=\\\"\\\"){let n=new Map;return it(t,e,n),n}function it(t,e,n){for(let r of t){if(Li.has(r.type)){r.fields&&it(r.fields,e,n);continue}if(r.type===\\\"group\\\"){let s=e===\\\"\\\"?r.name:`${e}.${r.name}`;n.set(s,r),r.fields&&it(r.fields,s,n);continue}let o=e===\\\"\\\"?r.name:`${e}.${r.name}`;if(n.set(o,r),r.type===\\\"array\\\"&&r.fields)it(r.fields,`${o}.*`,n);else if(r.type===\\\"blocks\\\"&&r.blocks)for(let s of r.blocks)it(s.fields,`${o}.*.${s.slug}`,n)}}function zt(t,e){if(t.has(e))return t.get(e);let n=e.replace(/\\\\.\\\\d+(?=\\\\.|$)/g,\\\".*\\\");if(t.has(n))return t.get(n)}function Gt(t){if(typeof t!=\\\"object\\\"||t===null)return;let e=t.id;if(typeof e==\\\"string\\\"||typeof e==\\\"number\\\")return e}function Qn(t){if(typeof t!=\\\"object\\\"||t===null)return;let e=t.blockType;return typeof e==\\\"string\\\"?e:void 0}function ot(t,e){return e.every(r=>Gt(r)!==void 0)?Mi(t,e):Ii(t,e)}function Mi(t,e){let n=[],r=new Map;for(let s=0;s<t.length;s+=1){let a=Gt(t[s]);a!==void 0&&r.set(a,s)}let o=new Set;for(let s=0;s<e.length;s+=1){let a=e[s],u=Gt(a);if(u===void 0){n.push({kind:\\\"insert\\\",index:s,value:a});continue}let m=r.get(u);if(m===void 0){n.push({kind:\\\"insert\\\",index:s,value:a});continue}o.add(m);let T=t[m];if(Qn(T)!==Qn(a)){n.push({kind:\\\"replace\\\",index:s,oldValue:T,value:a});continue}m!==s&&n.push({kind:\\\"move\\\",from:m,to:s,value:a}),er(T,a)||n.push({kind:\\\"update\\\",index:s,value:a})}for(let s=0;s<t.length;s+=1)o.has(s)||n.push({kind:\\\"remove\\\",index:s,value:t[s]});return n}function Ii(t,e){let n=[],r=Math.min(t.length,e.length);for(let o=0;o<r;o+=1)er(t[o],e[o])||n.push({kind:\\\"update\\\",index:o,value:e[o]});if(e.length>t.length)for(let o=t.length;o<e.length;o+=1)n.push({kind:\\\"insert\\\",index:o,value:e[o]});if(t.length>e.length)for(let o=e.length;o<t.length;o+=1)n.push({kind:\\\"remove\\\",index:o,value:t[o]});return n}function er(t,e){if(Object.is(t,e))return!0;if(typeof t!=\\\"object\\\"||typeof e!=\\\"object\\\"||t===null||e===null)return!1;let n=t,r=e,o=Object.keys(n),s=Object.keys(r);if(o.length!==s.length)return!1;for(let a of o)if(!Object.is(n[a],r[a]))return!1;return!0}var tr={text:\\\"text\\\",textarea:\\\"textarea\\\",richText:\\\"richText\\\",email:\\\"email\\\",number:\\\"number\\\",checkbox:\\\"checkbox\\\",date:\\\"date\\\",select:\\\"select\\\",radio:\\\"radio\\\",array:\\\"array\\\",blocks:\\\"blocks\\\",group:\\\"text\\\",tabs:\\\"text\\\",row:\\\"text\\\",collapsible:\\\"text\\\",relationship:\\\"relationship\\\",upload:\\\"upload\\\",point:\\\"text\\\",json:\\\"text\\\",code:\\\"text\\\",ui:\\\"text\\\"};function Wt(t){if(Object.prototype.hasOwnProperty.call(tr,t))return tr[t]}var Ni=[0,500,1e3,2e3],S,A,X,se,Ie,Z,Ne,st,B,ge,be,at,O,_e,Ce,Q,Re,N,Oe,Pe,Fe,Te,ae,dt,lt,h,Yt,qt,Kt,rr,ir,or,sr,ar,dr,lr,ur,cr,fr,pr,It=class{constructor(e){l(this,h);l(this,S);l(this,A);l(this,X);l(this,se);l(this,Ie);l(this,Z);l(this,Ne);l(this,st);l(this,B);l(this,ge);l(this,be);l(this,at);l(this,O);l(this,_e);l(this,Ce,[]);l(this,Q);l(this,Re);l(this,N);l(this,Oe);l(this,Pe);l(this,Fe,Bt(void 0));l(this,Te,!1);l(this,ae,null);l(this,dt,0);l(this,lt,new Set);d(this,S,e.emitter),d(this,st,e.renderers),d(this,B,e.root??(typeof document<\\\"u\\\"?document:null)),d(this,ge,e.readyTargets),d(this,be,e.sendReady??Fi),d(this,at,e.onHeartbeatTimeout),d(this,O,e.log??Ci),d(this,_e,e.warn??Pi),d(this,Q,_i(e)),d(this,Re,e.dataMerge!==void 0?new kt({serverURL:e.dataMerge.serverURL,...e.dataMerge.apiRoute!==void 0?{apiRoute:e.dataMerge.apiRoute}:{},...e.dataMerge.depth!==void 0?{depth:e.dataMerge.depth}:{},...e.dataMerge.fetchFn!==void 0?{fetchFn:e.dataMerge.fetchFn}:{},log:(...n)=>{i(this,O).call(this,...n)}}):null),d(this,A,new wt),d(this,X,new xt({onStructuralChange:()=>{f(this,h,Kt).call(this)},onVisibilityChange:(n,r)=>{r&&i(this,se).notifyVisible(n)}},{...e.intersectionRootMargin!==void 0?{intersectionRootMargin:e.intersectionRootMargin}:{}})),d(this,se,new Lt(n=>{f(this,h,ur).call(this,n)},{...e.debounceMs!==void 0?{debounceMs:e.debounceMs}:{},...e.disableVisibilityGate!==void 0?{disableVisibilityGate:e.disableVisibilityGate}:{},...e.visibilityGateThreshold!==void 0?{visibilityGateThreshold:e.visibilityGateThreshold}:{},isVisible:n=>i(this,X).isVisible(n),getCacheSize:()=>i(this,A).elementCount,onFlush:n=>{f(this,h,fr).call(this,n)}})),d(this,Ie,new He(e.originMatcher,{onUpdate:(n,r)=>{f(this,h,or).call(this,n,r)},onDocumentEvent:(n,r)=>{f(this,h,ar).call(this,n,r)},onInvalid:(n,r)=>{if(n===\\\"token\\\"){let o=new Error(`Preview token rejected (origin: ${r})`);i(this,S).emit(\\\"error\\\",{error:o,context:\\\"token\\\"})}i(this,O).call(this,\\\"message rejected:\\\",n,r)},...e.validateToken!==void 0?{validateToken:e.validateToken}:{}})),d(this,Z,new Et((n,r)=>{i(this,O).call(this,\\\"connection\\\",r,\\\"\\\\u2192\\\",n)})),d(this,Ne,new St({...e.heartbeatMs!==void 0?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{f(this,h,pr).call(this)}}))}start(){if(i(this,Te))return!1;d(this,Te,!0);let e=i(this,B);if(e instanceof Document&&e.readyState===\\\"loading\\\"){let n=()=>{d(this,ae,null),f(this,h,Yt).call(this)};return d(this,ae,n),e.addEventListener(\\\"DOMContentLoaded\\\",n,{once:!0}),!0}return f(this,h,Yt).call(this),!0}destroy(){if(!i(this,Te))return;if(d(this,Te,!1),i(this,ae)!==null){let n=i(this,B);n instanceof Document&&n.removeEventListener(\\\"DOMContentLoaded\\\",i(this,ae)),d(this,ae,null),i(this,S).emit(\\\"destroy\\\",{timestamp:Date.now()});return}for(let n of i(this,Ce))clearTimeout(n);i(this,Ce).length=0,i(this,Ne).stop(),i(this,Ie).detach(),i(this,X).stop(),i(this,se).destroy(),i(this,Re)?.destroy(),i(this,A).clear();let e=i(this,Z).status===\\\"connected\\\";i(this,Z).markDisconnected(),e&&(i(this,Q)?.announceDisconnected(),i(this,S).emit(\\\"disconnect\\\",{reason:\\\"destroy\\\",timestamp:Date.now()})),i(this,Q)?.detach(),i(this,S).emit(\\\"destroy\\\",{timestamp:Date.now()})}refreshCache(){f(this,h,Kt).call(this)}get status(){return i(this,Z).status}get cache(){return i(this,A)}get updateCount(){return i(this,dt)}get protocol(){return i(this,Fe)}};S=new WeakMap,A=new WeakMap,X=new WeakMap,se=new WeakMap,Ie=new WeakMap,Z=new WeakMap,Ne=new WeakMap,st=new WeakMap,B=new WeakMap,ge=new WeakMap,be=new WeakMap,at=new WeakMap,O=new WeakMap,_e=new WeakMap,Ce=new WeakMap,Q=new WeakMap,Re=new WeakMap,N=new WeakMap,Oe=new WeakMap,Pe=new WeakMap,Fe=new WeakMap,Te=new WeakMap,ae=new WeakMap,dt=new WeakMap,lt=new WeakMap,h=new WeakSet,Yt=function(){f(this,h,qt).call(this),i(this,X).start(i(this,B)instanceof Document?i(this,B).body:i(this,B)),i(this,Ie).attach(),f(this,h,rr).call(this);for(let e of Ni)if(e===0)i(this,be).call(this,i(this,ge));else{let n=setTimeout(()=>{i(this,be).call(this,i(this,ge))},e);i(this,Ce).push(n)}},qt=function(){let e=i(this,A).buildFromRoot(i(this,B));i(this,O).call(this,\\\"cache built\\\",e),i(this,S).emit(\\\"cacheRefresh\\\",e);for(let n of i(this,A).values())i(this,X).observeElement(n.element)},Kt=function(){for(let e of i(this,A).values())i(this,X).unobserveElement(e.element),i(this,se).forget(e.element);f(this,h,qt).call(this)},rr=function(){i(this,S).emit(\\\"init\\\",{timestamp:Date.now()})},ir=function(e){let n=Bt(e);n.negotiated!==i(this,Fe).negotiated&&(d(this,Fe,n),i(this,O).call(this,\\\"protocol negotiated\\\",`ours=${4}`,`theirs=${e}`,`negotiated=${n.negotiated}`))},or=function(e,n){i(this,Ne).kick(),e.protocolVersion!==void 0&&f(this,h,ir).call(this,e.protocolVersion),e.data!==void 0&&(i(this,Z).markConnected()&&(i(this,Q)?.announceConnected(),i(this,S).emit(\\\"connect\\\",{origin:n,timestamp:Date.now()})),d(this,dt,i(this,dt)+1),e.locale!==void 0&&d(this,N,e.locale),e.fieldSchemaJSON!==void 0&&(d(this,Oe,e.fieldSchemaJSON),d(this,Pe,Vt(e.fieldSchemaJSON))),f(this,h,sr).call(this,e).then(r=>{if(r===null)return;let o={fields:r,...i(this,Oe)!==void 0?{schema:i(this,Oe)}:{},...e.globalSlug!==void 0?{globalSlug:e.globalSlug}:{},...e.collectionSlug!==void 0?{collectionSlug:e.collectionSlug}:{},...i(this,N)!==void 0?{locale:i(this,N)}:{}},s=!1;i(this,S).emit(\\\"beforeUpdate\\\",{data:o,cancel:()=>{s=!0}}).then(()=>{s||f(this,h,dr).call(this,o)})}))},sr=async function(e){let n=e.data??{};if(i(this,Re)===null)return n;let r=await i(this,Re).merge({collectionSlug:e.collectionSlug,globalSlug:e.globalSlug,data:n,locale:i(this,N)});return r.status===\\\"merged\\\"?r.doc:r.status===\\\"superseded\\\"?null:n},ar=function(e,n){i(this,S).emit(\\\"documentSave\\\",{timestamp:Date.now()})},dr=function(e){for(let[n,r]of i(this,A).entries()){let o=Hi(e.fields,n,i(this,N));if(o!==void 0)for(let s of r){let a={target:s,value:o,allFields:e.fields};i(this,se).schedule(a)}}f(this,h,lr).call(this,e.fields)},lr=function(e){if(i(this,A).elementCount===0)return;let n=new Set;for(let[r]of i(this,A).entries())n.add(r);for(let[r,o]of Object.entries(e)){if(i(this,lt).has(r)||Di.has(r)||!$i(o))continue;let s=Ui(r,i(this,N));n.has(r)||n.has(s)||(i(this,lt).add(r),i(this,_e).call(this,`[live-preview] update arrived for field \\\"${r}\\\" but no <\\\\u2026 data-payload-field=\\\"${s}\\\"> 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.`))}},ur=function(e){let n=i(this,Pe)!==void 0?zt(i(this,Pe),e.target.fieldName):void 0,r=f(this,h,cr).call(this,e.target,n?.type);r===\\\"text\\\"&&e.target.explicitFieldType!==!0&&Oi(e.value)&&(r=\\\"richText\\\");let o=i(this,st)[r],s=Bi(e.target.element),a={allFields:e.allFields,locale:i(this,N),schema:n};try{e.target.targetAttribute!==void 0?Yn(e.target.element,e.target.targetAttribute,e.value)===\\\"blocked\\\"&&i(this,_e).call(this,`[live-preview] refused to write field \\\"${e.target.fieldName}\\\" into attribute \\\"${e.target.targetAttribute}\\\" (unsafe attribute or value)`):o?o.render(e.target,e.value,a):i(this,O).call(this,\\\"no renderer for\\\",r)}catch(u){let m=u instanceof Error?u:new Error(String(u));i(this,S).emit(\\\"error\\\",{error:m,context:\\\"renderer\\\"});return}i(this,S).emit(\\\"elementUpdate\\\",{element:e.target.element,fieldName:e.target.fieldName,previousValue:s,nextValue:e.value})},cr=function(e,n){if(e.explicitFieldType)return e.fieldType;if(n!==void 0){let r=Wt(n);if(r!==void 0)return r}return e.fieldType},fr=function(e){e.applied===0&&e.deferred===0||(e.applied>0&&i(this,Q)?.announceUpdate(e.applied),i(this,S).emit(\\\"afterUpdate\\\",{data:{fields:{},...i(this,N)!==void 0?{locale:i(this,N)}:{}},updatedCount:e.applied,durationMs:e.durationMs}))},pr=function(){var e;i(this,Z).markDisconnected()&&(i(this,Q)?.announceDisconnected(),i(this,S).emit(\\\"disconnect\\\",{reason:\\\"timeout\\\",timestamp:Date.now()}));try{(e=i(this,at))==null||e.call(this)}catch(n){i(this,O).call(this,\\\"onHeartbeatTimeout hook threw:\\\",n)}i(this,be).call(this,i(this,ge))};function _i(t){return t.enableA11y===!1?null:t.a11yLocale!==void 0?new rt(t.a11yLocale):new rt}function Ci(){}function Oi(t){if(typeof t!=\\\"object\\\"||t===null||!(\\\"root\\\"in t))return!1;let e=t.root;return typeof e!=\\\"object\\\"||e===null?!1:Array.isArray(e.children)}function Pi(...t){typeof console<\\\"u\\\"&&typeof console.warn==\\\"function\\\"&&console.warn(...t)}function Fi(t){if(typeof window>\\\"u\\\")return;let e=[];window.parent!==window&&e.push(window.parent),window.opener instanceof Window&&e.push(window.opener),He.sendReady(e,t)}var mr=new Set([\\\"__proto__\\\",\\\"prototype\\\",\\\"constructor\\\"]),Di=new Set([\\\"id\\\",\\\"_id\\\",\\\"createdAt\\\",\\\"updatedAt\\\",\\\"createdBy\\\",\\\"updatedBy\\\",\\\"_status\\\",\\\"globalType\\\",\\\"collection\\\",\\\"locale\\\",\\\"localized\\\"]);function $i(t){return t==null?!1:typeof t==\\\"string\\\"||typeof t==\\\"number\\\"||typeof t==\\\"boolean\\\"||typeof t==\\\"bigint\\\"}function Ui(t,e){if(!e)return t;let n=`_${e}`;return t.endsWith(n)?t.slice(0,-n.length):t}function Hi(t,e,n){let r=nr(t,e);if(r!==void 0)return r;if(e.includes(\\\".\\\")){let o=e.split(\\\".\\\"),s=t;for(let a of o){if(mr.has(a)||s===null||typeof s!=\\\"object\\\")return;s=s[a]}if(s!==void 0)return s}if(n!==void 0){let o=nr(t,`${e}_${n}`);if(o!==void 0)return o}}function nr(t,e){if(!mr.has(e)&&Object.prototype.hasOwnProperty.call(t,e))return t[e]}function Bi(t){return t.tagName===\\\"INPUT\\\"||t.tagName===\\\"TEXTAREA\\\"?t.value:t.tagName===\\\"IMG\\\"?t.src:t.textContent}function ut(){if(typeof window>\\\"u\\\")return!1;try{return window.self!==window.top}catch{return!0}}function Jt(){return typeof window>\\\"u\\\"?!1:window.opener!=null}function Xt(){return ut()||Jt()}function hr(){let t=ji();if(t!==void 0)return t!==\\\"production\\\";let e=Vi();if(e!==void 0)return e;if(typeof window<\\\"u\\\"){let n=window.location.hostname;if(n===\\\"localhost\\\"||n===\\\"127.0.0.1\\\")return!0}return!1}function yr(t){if(typeof process<\\\"u\\\"){let n=process.env[t];if(typeof n==\\\"string\\\"&&n.length>0)return n}let e=void 0;if(e){let n=e[t];if(typeof n==\\\"string\\\"&&n.length>0)return n}}function ji(){if(typeof process>\\\"u\\\")return;let t=\\\"production\\\";return typeof t==\\\"string\\\"?t:void 0}function Vi(){let t=void 0;if(!t)return;let e=t.DEV;return typeof e==\\\"boolean\\\"?e:void 0}var zi=/^https?:\\\\/\\\\/(localhost|127\\\\.0\\\\.0\\\\.1)(?::\\\\d+)?$/i,Gi=/^https?:\\\\/\\\\/[^/?#\\\\s]+$/i,Wi=[\\\"PAYLOAD_ADMIN_ORIGIN\\\",\\\"PUBLIC_PAYLOAD_ADMIN_ORIGIN\\\",\\\"NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN\\\"],j,V,de,ct,P,Nt=class{constructor(e={}){l(this,j);l(this,V);l(this,de);l(this,ct);l(this,P);let n=new Set;for(let a of e.additionalOrigins??[]){let u=gr(a);u!==void 0&&n.add(u)}for(let a of Wi){let u=yr(a);if(u!==void 0)for(let m of u.split(\\\",\\\")){let T=gr(m);T!==void 0&&n.add(T)}}d(this,j,n);let r=e.enableReferrerDetection??!0,o;if(r){let a=e.referrer??(typeof document<\\\"u\\\"?document.referrer:\\\"\\\");if(a.length>0)try{let u=new URL(a).origin;u&&u!==\\\"null\\\"&&(o=u)}catch{}}d(this,V,o),d(this,ct,o!==void 0);let s=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??hr());d(this,de,s)}matches(e){return e.length===0||e===\\\"null\\\"?!1:i(this,P)!==void 0?e===i(this,P):!!(i(this,j).has(e)||i(this,j).size===0&&i(this,V)!==void 0&&e===i(this,V)||i(this,de)&&zi.test(e))}lockOrigin(e){return this.matches(e)?(d(this,P,e),!0):!1}unlockOrigin(){let e=i(this,P);return d(this,P,void 0),e}get lockedOrigin(){return i(this,P)}enumerate(){if(i(this,P)!==void 0)return[i(this,P)];let e=new Set(i(this,j));if(i(this,j).size===0&&i(this,V)!==void 0&&e.add(i(this,V)),i(this,de))for(let n of Yi)e.add(`http://localhost:${String(n)}`),e.add(`http://127.0.0.1:${String(n)}`);return[...e]}get referrerWasAvailable(){return i(this,ct)}get isProductionUnconfigured(){return!(!ut()||i(this,j).size>0||i(this,de)||i(this,V)!==void 0)}get isReferrerOnlyTrust(){return i(this,j).size>0||i(this,de)?!1:i(this,V)!==void 0}};j=new WeakMap,V=new WeakMap,de=new WeakMap,ct=new WeakMap,P=new WeakMap;var Yi=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function gr(t){let e=t.trim();if(e.length!==0)try{let n=new URL(e);return n.protocol!==\\\"http:\\\"&&n.protocol!==\\\"https:\\\"||!Gi.test(n.origin)?void 0:n.origin}catch{return}}var br={name:\\\"payload-live-preview\\\",version:\\\"1.0.2\\\",description:\\\"Live preview for Payload CMS in Astro and any SSR/static frontend (SvelteKit, Nuxt, Next.js, plain HTML). Patches the DOM live, no rebuild.\\\",author:\\\"relative23\\\",license:\\\"MIT\\\",type:\\\"module\\\",main:\\\"./dist/index.cjs\\\",module:\\\"./dist/index.js\\\",types:\\\"./dist/index.d.ts\\\",exports:{\\\".\\\":{import:{types:\\\"./dist/index.d.ts\\\",default:\\\"./dist/index.js\\\"},require:{types:\\\"./dist/index.d.cts\\\",default:\\\"./dist/index.cjs\\\"}},\\\"./core\\\":{import:{types:\\\"./dist/core.d.ts\\\",default:\\\"./dist/core.js\\\"},require:{types:\\\"./dist/core.d.cts\\\",default:\\\"./dist/core.cjs\\\"}},\\\"./astro\\\":{import:{types:\\\"./dist/adapters/astro/index.d.ts\\\",default:\\\"./dist/adapters/astro/index.js\\\"}},\\\"./nextjs\\\":{import:{types:\\\"./dist/adapters/nextjs/index.d.ts\\\",default:\\\"./dist/adapters/nextjs/index.js\\\"}},\\\"./sveltekit\\\":{import:{types:\\\"./dist/adapters/sveltekit/index.d.ts\\\",default:\\\"./dist/adapters/sveltekit/index.js\\\"}},\\\"./nuxt\\\":{import:{types:\\\"./dist/adapters/nuxt/index.d.ts\\\",default:\\\"./dist/adapters/nuxt/index.js\\\"}},\\\"./codegen\\\":{import:{types:\\\"./dist/codegen.d.ts\\\",default:\\\"./dist/codegen.js\\\"},require:{types:\\\"./dist/codegen.d.cts\\\",default:\\\"./dist/codegen.cjs\\\"}},\\\"./codegen/astro\\\":{import:{types:\\\"./dist/codegen-astro.d.ts\\\",default:\\\"./dist/codegen-astro.js\\\"}},\\\"./payload\\\":{import:{types:\\\"./dist/payload.d.ts\\\",default:\\\"./dist/payload.js\\\"},require:{types:\\\"./dist/payload.d.cts\\\",default:\\\"./dist/payload.cjs\\\"}},\\\"./astro/RichText.astro\\\":\\\"./dist/adapters/astro/RichText.astro\\\",\\\"./astro/middleware-entry\\\":{import:{types:\\\"./dist/adapters/astro/middleware-entry.d.ts\\\",default:\\\"./dist/adapters/astro/middleware-entry.js\\\"}}},bin:{\\\"pll-codegen\\\":\\\"./dist/codegen-cli.js\\\"},files:[\\\"dist\\\",\\\"README.md\\\",\\\"LICENSE\\\"],sideEffects:!1,scripts:{prepare:\\\"npm run build:runtime\\\",\\\"build:runtime\\\":\\\"tsx scripts/build-runtime.ts\\\",build:\\\"npm run build:runtime && tsup && npm run build:assets\\\",\\\"build:assets\\\":`node -e \\\"require('node:fs').copyFileSync('src/adapters/astro/RichText.astro','dist/adapters/astro/RichText.astro')\\\"`,dev:\\\"tsup --watch\\\",test:\\\"vitest run\\\",\\\"test:watch\\\":\\\"vitest\\\",\\\"test:unit\\\":\\\"vitest run tests/unit\\\",\\\"test:integration\\\":\\\"vitest run tests/integration\\\",\\\"test:e2e\\\":\\\"playwright test\\\",\\\"test:bench\\\":\\\"vitest bench tests/benchmarks\\\",\\\"test:coverage\\\":\\\"vitest run --coverage\\\",typecheck:\\\"tsc --noEmit\\\",lint:\\\"eslint .\\\",\\\"lint:fix\\\":\\\"eslint . --fix\\\",format:'prettier --write \\\"src/**/*.ts\\\" \\\"tests/**/*.ts\\\"',\\\"format:check\\\":'prettier --check \\\"src/**/*.ts\\\" \\\"tests/**/*.ts\\\"',check:\\\"npm run typecheck && npm run lint && npm run test\\\",prepublishOnly:\\\"npm run check && npm run build\\\",changeset:\\\"changeset\\\",version:\\\"changeset version\\\",release:\\\"npm run build && changeset publish\\\"},devDependencies:{\\\"@changesets/cli\\\":\\\"^2.31.0\\\",\\\"@eslint/js\\\":\\\"^10.0.1\\\",\\\"@playwright/test\\\":\\\"^1.61.1\\\",\\\"@types/node\\\":\\\"^22.20.1\\\",\\\"@vitest/coverage-v8\\\":\\\"^4.1.10\\\",esbuild:\\\"^0.28.1\\\",eslint:\\\"^10.7.0\\\",globals:\\\"^17.7.0\\\",jsdom:\\\"^29.1.1\\\",prettier:\\\"^3.9.5\\\",\\\"ts-morph\\\":\\\"^28.0.0\\\",tsup:\\\"^8.5.1\\\",tsx:\\\"^4.23.0\\\",typescript:\\\"^5.9.3\\\",\\\"typescript-eslint\\\":\\\"^8.63.0\\\",vitest:\\\"^4.1.10\\\"},keywords:[\\\"astro\\\",\\\"astro-payload\\\",\\\"astro-cms\\\",\\\"astro-integration\\\",\\\"astro-live-preview\\\",\\\"payload\\\",\\\"payload-cms\\\",\\\"payload-live-preview\\\",\\\"payload-plugin\\\",\\\"live-preview\\\",\\\"preview\\\",\\\"cms\\\",\\\"headless\\\",\\\"headless-cms\\\",\\\"lexical\\\",\\\"sveltekit\\\",\\\"nuxt\\\",\\\"nextjs\\\",\\\"ssr\\\",\\\"framework-agnostic\\\"],peerDependencies:{astro:\\\">=4.0.0 <8.0.0\\\",\\\"ts-morph\\\":\\\"^28.0.0\\\"},peerDependenciesMeta:{astro:{optional:!0},\\\"ts-morph\\\":{optional:!0}},engines:{node:\\\">=20.19.0\\\"},publishConfig:{access:\\\"public\\\",provenance:!0},repository:{type:\\\"git\\\",url:\\\"https://github.com/relative23/payload-live-preview.git\\\"},bugs:{url:\\\"https://github.com/relative23/payload-live-preview/issues\\\"},homepage:\\\"https://github.com/relative23/payload-live-preview#readme\\\"};var Rr=br.version;var Zt=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\\\"]),wr=new Set([\\\"script\\\",\\\"style\\\",\\\"iframe\\\",\\\"object\\\",\\\"embed\\\",\\\"link\\\",\\\"meta\\\",\\\"base\\\",\\\"form\\\",\\\"input\\\",\\\"button\\\",\\\"select\\\",\\\"textarea\\\",\\\"svg\\\",\\\"math\\\",\\\"template\\\",\\\"frame\\\",\\\"frameset\\\",\\\"noframes\\\",\\\"noscript\\\"]),xr=new Set([\\\"id\\\",\\\"class\\\",\\\"lang\\\",\\\"dir\\\",\\\"title\\\",\\\"role\\\",\\\"tabindex\\\"]),Ki=\\\"aria-\\\",Ji=\\\"data-\\\",Qt={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\\\"])},vr=new Set([\\\"href\\\",\\\"src\\\",\\\"cite\\\",\\\"poster\\\"]),en=class extends Error{constructor(){super(...arguments);$n(this,\\\"name\\\",\\\"SanitizerEnvironmentError\\\")}};function Xi(t){if(!t){let r=new Map;for(let[o,s]of Object.entries(Qt))r.set(o,s);return{allowedTags:Zt,attrByTag:r}}let e=new Set(Zt);for(let r of t.additionalAllowedTags??[])e.add(r);let n=new Map;for(let[r,o]of Object.entries(Qt))n.set(r,o);for(let[r,o]of Object.entries(t.additionalAllowedAttributes??{})){let s=n.get(r),a=new Set(s??[]);for(let u of o)a.add(u);n.set(r,a)}return{allowedTags:e,attrByTag:n}}var Tr;function z(t,e){let n=Sr();if(!n)throw new en(\\\"sanitizeHtml requires a DOM. Inject one via setSanitizerDocument() for SSR (linkedom, jsdom, happy-dom, \\\\u2026) or use the plain-text path on the server.\\\");if(t===\\\"\\\")return\\\"\\\";let r=Xi(e),o=n.createElement(\\\"template\\\");return o.innerHTML=t,tn(o.content,r),o.innerHTML}function Sr(){if(Tr)return Tr;if(!(typeof document>\\\"u\\\"))return document}function Er(){return Sr()!==void 0}function tn(t,e){for(let n of Array.from(t.childNodes))n.nodeType===Node.ELEMENT_NODE?Zi(n,e):n.nodeType===Node.COMMENT_NODE&&n.remove()}function Zi(t,e){let n=t.tagName.toLowerCase();if(wr.has(n)){t.remove();return}if(!e.allowedTags.has(n)){tn(t,e);let r=t.parentNode;if(r){for(;t.firstChild;)r.insertBefore(t.firstChild,t);t.remove()}return}Qi(t,n,e),n===\\\"a\\\"&&to(t),tn(t,e)}function Qi(t,e,n){let r=n.attrByTag.get(e);for(let o of Array.from(t.attributes)){let s=o.name.toLowerCase();if(s.startsWith(\\\"on\\\")){t.removeAttribute(o.name);continue}if(s===\\\"style\\\"){t.removeAttribute(o.name);continue}if(!(xr.has(s)||s.startsWith(Ki)||s.startsWith(Ji))){if(r?.has(s)){(vr.has(s)&&!b(o.value)||s===\\\"srcset\\\"&&!eo(o.value))&&t.removeAttribute(o.name);continue}t.removeAttribute(o.name)}}}function eo(t){let e=t.split(\\\",\\\");for(let n of e){let r=n.trim();if(r.length===0)continue;let o=r.split(/\\\\s+/,1)[0];if(o===void 0||o.length===0||!b(o))return!1}return!0}function to(t){let e=t.getAttribute(\\\"href\\\");e&&At(e)&&(t.setAttribute(\\\"rel\\\",\\\"noopener noreferrer\\\"),t.hasAttribute(\\\"target\\\")||t.setAttribute(\\\"target\\\",\\\"_blank\\\"))}var qs=Object.freeze({allowedTags:Zt,removeCompletely:wr,globalAttributes:xr,attributesByTag:Qt,urlAttributes:vr});var kr=new Map;function p(t,e){kr.set(t,e)}function Ar(t){return kr.get(t)}var no={1:\\\"left\\\",2:\\\"center\\\",3:\\\"right\\\",4:\\\"justify\\\"},ro=new Set([\\\"left\\\",\\\"center\\\",\\\"right\\\",\\\"justify\\\",\\\"start\\\",\\\"end\\\"]);function nn(t){let e=t.format;if(typeof e==\\\"string\\\"&&ro.has(e))return e;if(typeof e==\\\"number\\\"){let n=no[e];if(n!==void 0)return n}}function rn(t){let e=t.indent;return typeof e==\\\"number\\\"&&e>0?e:0}function ee(t){return t.direction===\\\"rtl\\\"?' dir=\\\"rtl\\\"':t.direction===\\\"ltr\\\"?' dir=\\\"ltr\\\"':\\\"\\\"}function G(t){let e=nn(t),n=rn(t),r=[];return e!==void 0&&r.push(`text-align:${e}`),n>0&&r.push(`padding-inline-start:${String(n*40)}px`),r.length===0?\\\"\\\":` style=\\\"${r.join(\\\";\\\")}\\\"`}var io=Object.freeze({\\\"&\\\":\\\"&amp;\\\",\\\"<\\\":\\\"&lt;\\\",\\\">\\\":\\\"&gt;\\\",'\\\"':\\\"&quot;\\\",\\\"'\\\":\\\"&#x27;\\\",\\\"/\\\":\\\"&#x2F;\\\",\\\"`\\\":\\\"&#x60;\\\",\\\"=\\\":\\\"&#x3D;\\\"}),oo=/[&<>\\\"'/`=]/g;function y(t){return t===\\\"\\\"?\\\"\\\":t.replace(oo,e=>io[e])}function Lr(t){return t.replace(/['\\\"()\\\\\\\\]/g,\\\"\\\\\\\\$&\\\")}var so=Object.freeze({\\\"&\\\":\\\"&amp;\\\",\\\"<\\\":\\\"&lt;\\\",\\\">\\\":\\\"&gt;\\\",'\\\"':\\\"&quot;\\\",\\\"'\\\":\\\"&#x27;\\\"}),ao=/[&<>\\\"']/g;function L(t){return t===\\\"\\\"?\\\"\\\":t.replace(ao,e=>so[e])}function _t(t){return y(t).replace(/\\\\r\\\\n|\\\\r|\\\\n/g,\\\"<br>\\\")}var te={BOLD:1,ITALIC:2,STRIKETHROUGH:4,UNDERLINE:8,CODE:16,SUBSCRIPT:32,SUPERSCRIPT:64,HIGHLIGHT:128};var on=t=>{let e=typeof t.text==\\\"string\\\"?t.text:\\\"\\\",n=y(e),r=typeof t.format==\\\"number\\\"?t.format:0;return(r&te.CODE)!==0&&(n=`<code>${n}</code>`),(r&te.BOLD)!==0&&(n=`<strong>${n}</strong>`),(r&te.ITALIC)!==0&&(n=`<em>${n}</em>`),(r&te.UNDERLINE)!==0&&(n=`<u>${n}</u>`),(r&te.STRIKETHROUGH)!==0&&(n=`<s>${n}</s>`),(r&te.SUBSCRIPT)!==0&&(n=`<sub>${n}</sub>`),(r&te.SUPERSCRIPT)!==0&&(n=`<sup>${n}</sup>`),(r&te.HIGHLIGHT)!==0&&(n=`<mark>${n}</mark>`),n};p(\\\"text\\\",on);var sn=(t,e)=>{let n=e.renderChildren(t.children??[]);return`<p${ee(t)}${G(t)}>${n}</p>`};p(\\\"paragraph\\\",sn);var lo=new Set([\\\"h1\\\",\\\"h2\\\",\\\"h3\\\",\\\"h4\\\",\\\"h5\\\",\\\"h6\\\"]),an=(t,e)=>{let n=typeof t.tag==\\\"string\\\"?t.tag.toLowerCase():\\\"h2\\\",r=lo.has(n)?n:\\\"h2\\\",o=e.renderChildren(t.children??[]);return`<${r}${ee(t)}${G(t)}>${o}</${r}>`};p(\\\"heading\\\",an);var dn=(t,e)=>{let n=typeof t.listType==\\\"string\\\"?t.listType:\\\"bullet\\\",r=n===\\\"number\\\"?\\\"ol\\\":\\\"ul\\\",o=n===\\\"number\\\"&&typeof t.start==\\\"number\\\"&&t.start>1?` start=\\\"${String(t.start)}\\\"`:\\\"\\\",s=n===\\\"check\\\"?' role=\\\"list\\\"':\\\"\\\",a=e.renderChildren(t.children??[]);return`<${r}${ee(t)}${G(t)}${o}${s}>${a}</${r}>`},ln=(t,e)=>{let n=e.renderChildren(t.children??[]);if(typeof t.checked==\\\"boolean\\\")return`<li role=\\\"checkbox\\\" aria-checked=\\\"${t.checked?\\\"true\\\":\\\"false\\\"}\\\"${G(t)}>${n}</li>`;let r=typeof t.value==\\\"number\\\"?` value=\\\"${y(String(t.value))}\\\"`:\\\"\\\";return`<li${ee(t)}${G(t)}${r}>${n}</li>`};p(\\\"list\\\",dn);p(\\\"listitem\\\",ln);var ft=(t,e)=>{let n=typeof t.url==\\\"string\\\"?t.url:\\\"\\\",r=e.renderChildren(t.children??[]);if(n.length===0||!b(n))return r;let o=At(n)?' target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\"':uo(t),s=typeof t.title==\\\"string\\\"?` title=\\\"${y(t.title)}\\\"`:\\\"\\\";return`<a href=\\\"${L(n)}\\\"${o}${s}>${r}</a>`};function uo(t){let e=typeof t.target==\\\"string\\\"?t.target:\\\"\\\";if(e.length===0)return\\\"\\\";let n=y(e);return e===\\\"_blank\\\"?' target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\"':` target=\\\"${n}\\\"`}p(\\\"link\\\",ft);p(\\\"autolink\\\",ft);var un=(t,e)=>{let n=e.renderChildren(t.children??[]);return`<blockquote${ee(t)}${G(t)}>${n}</blockquote>`};p(\\\"quote\\\",un);var cn=t=>{let e=Ir(typeof t.language==\\\"string\\\"?t.language:\\\"\\\"),n=Mr(t);return`<pre><code${e===\\\"\\\"?\\\"\\\":` class=\\\"language-${e}\\\"`}>${y(n)}</code></pre>`},fn=t=>{let e=typeof t.text==\\\"string\\\"?t.text:\\\"\\\";return`<span${typeof t.highlightType==\\\"string\\\"?` class=\\\"token-${Ir(t.highlightType)}\\\"`:\\\"\\\"}>${y(e)}</span>`};p(\\\"code\\\",cn);p(\\\"code-highlight\\\",fn);function Mr(t){if(typeof t.text==\\\"string\\\")return t.text;if(!t.children)return\\\"\\\";let e=\\\"\\\";for(let n of t.children)e+=Mr(n);return e}function Ir(t){return t.replace(/[^a-zA-Z0-9_-]/g,\\\"\\\")}var pn=()=>\\\"<br>\\\",mn=()=>\\\"<hr>\\\",hn=()=>\\\"\\t\\\";p(\\\"linebreak\\\",pn);p(\\\"horizontalrule\\\",mn);p(\\\"tab\\\",hn);var yn=t=>{let e=co(t);if(e===void 0)return\\\"\\\";let n=e.url;if(typeof n!=\\\"string\\\"||!b(n))return\\\"\\\";let r=typeof e.mimeType==\\\"string\\\"?e.mimeType:\\\"\\\";return r.startsWith(\\\"video/\\\")?po(e,n):r.startsWith(\\\"audio/\\\")?mo(e,n):r===\\\"\\\"||r.startsWith(\\\"image/\\\")?fo(e,n):ho(e,n)};p(\\\"upload\\\",yn);function co(t){let e=t.value;if(!(typeof e!=\\\"object\\\"||e===null))return e}function fo(t,e){let n=typeof t.alt==\\\"string\\\"?y(t.alt):\\\"\\\",r=typeof t.width==\\\"number\\\"?` width=\\\"${String(t.width)}\\\"`:\\\"\\\",o=typeof t.height==\\\"number\\\"?` height=\\\"${String(t.height)}\\\"`:\\\"\\\";return`<img src=\\\"${L(e)}\\\" alt=\\\"${n}\\\"${r}${o} loading=\\\"lazy\\\" decoding=\\\"async\\\">`}function po(t,e){let n=typeof t.width==\\\"number\\\"?` width=\\\"${String(t.width)}\\\"`:\\\"\\\",r=typeof t.height==\\\"number\\\"?` height=\\\"${String(t.height)}\\\"`:\\\"\\\",o=typeof t.mimeType==\\\"string\\\"?` type=\\\"${L(t.mimeType)}\\\"`:\\\"\\\";return`<video controls${n}${r}><source src=\\\"${L(e)}\\\"${o}></video>`}function mo(t,e){let n=typeof t.mimeType==\\\"string\\\"?` type=\\\"${L(t.mimeType)}\\\"`:\\\"\\\";return`<audio controls><source src=\\\"${L(e)}\\\"${n}></audio>`}function ho(t,e){let n=typeof t.filename==\\\"string\\\"?y(t.filename):y(e);return`<a href=\\\"${L(e)}\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">${n}</a>`}var gn=t=>{let e=typeof t.relationTo==\\\"string\\\"?t.relationTo:\\\"\\\",n=yo(t),r=go(n,e),o=y(r),s=e===\\\"\\\"?\\\"\\\":` data-relation-to=\\\"${y(e)}\\\"`,a=n?.url;return typeof a==\\\"string\\\"&&b(a)?`<a href=\\\"${L(a)}\\\"${s}>${o}</a>`:`<span${s}>${o}</span>`};p(\\\"relationship\\\",gn);function yo(t){let e=t.value;if(!(typeof e!=\\\"object\\\"||e===null))return e}function go(t,e){return t===void 0?e===\\\"\\\"?\\\"#\\\":`#${e}`:typeof t.title==\\\"string\\\"&&t.title.length>0?t.title:typeof t.name==\\\"string\\\"&&t.name.length>0?t.name:typeof t.slug==\\\"string\\\"&&t.slug.length>0?t.slug:t.id!==void 0?String(t.id):e===\\\"\\\"?\\\"#\\\":`#${e}`}var bo=new Map;function bn(t){return bo.get(t)}var Rn=(t,e)=>{let n=Ro(t),r=typeof n.blockType==\\\"string\\\"?n.blockType:\\\"\\\",o=Nr(r);if(r!==\\\"\\\"){let u=bn(r)??bn(o);if(u)return u(n,{renderChildren:e.renderChildren})}let s=[];o!==\\\"\\\"&&s.push(`data-block-type=\\\"${y(o)}\\\"`);for(let[u,m]of Object.entries(n)){if(u===\\\"blockType\\\"||u===\\\"id\\\"||m==null)continue;let T=typeof m==\\\"string\\\"||typeof m==\\\"number\\\"||typeof m==\\\"boolean\\\"?String(m):JSON.stringify(m);s.push(`data-block-${Nr(u)}=\\\"${y(T)}\\\"`)}return`<div${s.length===0?\\\"\\\":` ${s.join(\\\" \\\")}`}></div>`};p(\\\"block\\\",Rn);function Ro(t){let e=t.fields;return typeof e!=\\\"object\\\"||e===null?{}:e}function Nr(t){return t.replace(/[^a-zA-Z0-9_-]/g,\\\"-\\\").toLowerCase()}p(\\\"text\\\",on);p(\\\"paragraph\\\",sn);p(\\\"heading\\\",an);p(\\\"list\\\",dn);p(\\\"listitem\\\",ln);p(\\\"link\\\",ft);p(\\\"autolink\\\",ft);p(\\\"quote\\\",un);p(\\\"code\\\",cn);p(\\\"code-highlight\\\",fn);p(\\\"linebreak\\\",pn);p(\\\"horizontalrule\\\",mn);p(\\\"tab\\\",hn);p(\\\"upload\\\",yn);p(\\\"relationship\\\",gn);p(\\\"block\\\",Rn);var To={renderChildren:Tn,resolveAlignment:nn,resolveIndent:rn};function le(t){if(typeof t!=\\\"object\\\"||t===null||!(\\\"root\\\"in t))return!1;let e=t.root;return typeof e!=\\\"object\\\"||e===null||!(\\\"children\\\"in e)?!1:Array.isArray(e.children)}function _r(t,e={}){if(!le(t))return\\\"\\\";let n=Tn(t.root.children);return e.sanitize===!1||!Er()?n:z(n)}function Ct(t){return le(t)?t.root.children.map(Cr).join(`\\n`).trim():\\\"\\\"}function Tn(t){let e=\\\"\\\";for(let n of t)e+=wo(n);return e}function wo(t){let e=Ar(t.type);return e?e(t,To):t.children!==void 0?Tn(t.children):\\\"\\\"}function Cr(t){if(typeof t.text==\\\"string\\\")return t.text;if(t.type===\\\"linebreak\\\")return`\\n`;if(t.children===void 0)return\\\"\\\";let e=\\\"\\\";for(let n of t.children)e+=Cr(n);return e}var wn=new Map;function Or(t=[]){for(let n of t)wn.set(n.name,n);let e={};for(let[n,r]of wn)e[n]=r;return Object.freeze(e)}function g(t){wn.set(t.name,t)}var xo=\\\"data-payload-text\\\",Pr=new WeakSet,xn={name:\\\"text\\\",render(t,e){let n=t.element,r=Eo(e);if(n.tagName===\\\"INPUT\\\"||n.tagName===\\\"TEXTAREA\\\"){n.value=r;return}if(vo(n)&&!n.hasAttribute(xo)){So(n,t.fieldName);return}if(r.includes(`\\n`)||r.includes(\\\"\\\\r\\\")){n.innerHTML=_t(r);return}n.textContent=r}};function vo(t){return t.firstElementChild!==null}function So(t,e){Pr.has(t)||(Pr.add(t),console.warn(`[live-preview] Skipping text update for \\\"${e}\\\" \\\\u2014 the bound <${t.tagName.toLowerCase()}> has structured child elements. Either move data-payload-field to the element whose textContent is the field value, or opt in with data-payload-text to replace the structure.`))}function Eo(t){return t==null?\\\"\\\":le(t)?Ct(t):typeof t==\\\"string\\\"?t:typeof t==\\\"number\\\"||typeof t==\\\"boolean\\\"?String(t):JSON.stringify(t)}g(xn);function w(t){if(t==null)return\\\"\\\";if(typeof t==\\\"string\\\")return t;if(typeof t==\\\"number\\\"||typeof t==\\\"boolean\\\"||typeof t==\\\"bigint\\\")return String(t);try{return JSON.stringify(t)}catch{return\\\"\\\"}}var vn={name:\\\"textarea\\\",render(t,e){let n=t.element,r=le(e)?Ct(e):w(e);if(n.tagName===\\\"INPUT\\\"||n.tagName===\\\"TEXTAREA\\\"){n.value=r;return}n.innerHTML=_t(r)}};g(vn);var Sn={name:\\\"richText\\\",render(t,e){if(le(e)){t.element.innerHTML=_r(e);return}typeof e==\\\"string\\\"&&(t.element.innerHTML=z(e))}};g(Sn);var En={name:\\\"html\\\",render(t,e){if(e==null){t.element.textContent=\\\"\\\";return}let n=typeof e==\\\"string\\\"?e:w(e);t.element.innerHTML=z(n)}};g(En);var pt={name:\\\"url\\\",render(t,e,n){let r=t.element,o=w(e);if(r.tagName===\\\"A\\\"){let s=r,a=t.hrefField,u=a?n.allFields[a]:e;typeof u==\\\"string\\\"&&b(u)&&(s.href=u),s.textContent=o;return}if(r.tagName===\\\"INPUT\\\"||r.tagName===\\\"TEXTAREA\\\"){r.value=o;return}r.textContent=o}};g(pt);g({...pt,name:\\\"email\\\"});var kn={name:\\\"image\\\",render(t,e,n){let r=t.element,o=ko(e),s=Ao(o,e);if(s!==void 0){if(r.tagName===\\\"IMG\\\"){let a=r;a.src=s;let u=Lo(o,t.altField,n.allFields);u!==void 0&&(a.alt=u);return}r.style.backgroundImage=`url('${Lr(s)}')`}}};function ko(t){if(!(typeof t!=\\\"object\\\"||t===null))return t}function Ao(t,e){if(t?.url!==void 0&&b(t.url))return t.url;if(typeof e==\\\"string\\\"&&b(e))return e}function Lo(t,e,n){if(t?.alt!==void 0)return t.alt;if(e!==void 0){let r=n[e];if(typeof r==\\\"string\\\")return r}}g(kn);var An={name:\\\"upload\\\",render(t,e){let n=t.element,r=Mo(e);if(r===void 0)return;let o=r.url;if(typeof o!=\\\"string\\\"||!b(o))return;if(n.tagName===\\\"IMG\\\"){let a=n;a.src=o,r.alt!==void 0&&(a.alt=r.alt);return}if(n.tagName===\\\"A\\\"){let a=n;a.href=o,a.textContent=r.filename??o;return}let s=r.filename!==void 0?y(r.filename):y(o);n.innerHTML=`<a href=\\\"${L(o)}\\\">${s}</a>`}};function Mo(t){if(!(typeof t!=\\\"object\\\"||t===null))return t}g(An);var Ln={name:\\\"relationship\\\",render(t,e){let n=t.element,o=Io(e).join(\\\", \\\");if(n.tagName===\\\"A\\\"&&!Array.isArray(e)){let s=n,a=e?.url;typeof a==\\\"string\\\"&&b(a)&&(s.href=a),s.textContent=o;return}n.textContent=o}};function Io(t){return t==null?[\\\"\\\"]:Array.isArray(t)?t.map(Fr):[Fr(t)]}function Fr(t){if(typeof t==\\\"object\\\"&&t!==null){let e=t;return typeof e.title==\\\"string\\\"&&e.title.length>0?e.title:typeof e.name==\\\"string\\\"&&e.name.length>0?e.name:typeof e.slug==\\\"string\\\"&&e.slug.length>0?e.slug:e.id!==void 0?String(e.id):\\\"\\\"}return w(t)}g(Ln);var mt={name:\\\"select\\\",render(t,e){let n=t.element,r=Dr(e);if(n.tagName===\\\"SELECT\\\"){n.value=r;return}if(n.tagName===\\\"INPUT\\\"&&n.type===\\\"radio\\\"){let o=n;o.checked=o.value===r;return}n.textContent=r}};function Dr(t){return Array.isArray(t)?t.map(e=>Dr(e)).join(\\\", \\\"):w(t)}g(mt);g({...mt,name:\\\"radio\\\"});var Mn={name:\\\"checkbox\\\",render(t,e){let n=t.element,r=!!e;if(n.tagName===\\\"INPUT\\\"&&n.type===\\\"checkbox\\\"){n.checked=r;return}if(n.hasAttribute(\\\"aria-checked\\\")){n.setAttribute(\\\"aria-checked\\\",r?\\\"true\\\":\\\"false\\\");return}n.textContent=r?\\\"true\\\":\\\"false\\\"}};g(Mn);var ht=new Map,yt=new Map,No=64,_o=No;function $r(t,e){let n=Hr(t,e),r=ht.get(n);if(r!==void 0)return ht.delete(n),ht.set(n,r),r;let o=new Intl.NumberFormat(t,e);return ht.set(n,o),Br(ht),o}function Ur(t,e){let n=Hr(t,e),r=yt.get(n);if(r!==void 0)return yt.delete(n),yt.set(n,r),r;let o=new Intl.DateTimeFormat(t,e);return yt.set(n,o),Br(yt),o}function Hr(t,e){let n=t??\\\"\\\";if(e==null)return n;let r=In(e);return r===\\\"{}\\\"?n:`${n}|${r}`}function In(t){if(t===null||typeof t!=\\\"object\\\")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(o=>In(o)).join(\\\",\\\")}]`;let e=t,n=Object.keys(e).sort(),r=[];for(let o of n){let s=e[o];s!==void 0&&r.push(`${JSON.stringify(o)}:${In(s)}`)}return`{${r.join(\\\",\\\")}}`}function Br(t){for(;t.size>_o;){let e=t.keys().next().value;if(e===void 0)break;t.delete(e)}}var Nn={name:\\\"date\\\",render(t,e,n){let r=t.element;if(e==null||e===\\\"\\\"){r.tagName===\\\"INPUT\\\"?r.value=\\\"\\\":(r.tagName===\\\"TIME\\\"&&r.removeAttribute(\\\"datetime\\\"),r.textContent=\\\"\\\");return}let o=typeof e==\\\"string\\\"?e:w(e),s=new Date(o),a=!Number.isNaN(s.getTime());if(r.tagName===\\\"INPUT\\\"){r.value=a?Co(r.type,s):o;return}if(r.tagName===\\\"TIME\\\"){r.setAttribute(\\\"datetime\\\",a?s.toISOString():o),r.textContent=a?jr(s,n):o;return}r.textContent=a?jr(s,n):o}};function jr(t,e){let n=e.locale??Me();try{return Ur(n,{dateStyle:\\\"medium\\\",timeStyle:\\\"short\\\"}).format(t)}catch{return t.toISOString()}}function Co(t,e){return t===\\\"date\\\"?e.toISOString().slice(0,10):t===\\\"datetime-local\\\"?e.toISOString().slice(0,16):e.toISOString()}g(Nn);var _n={name:\\\"number\\\",render(t,e,n){let r=t.element;if(e==null||e===\\\"\\\"){r.tagName===\\\"INPUT\\\"?r.value=\\\"\\\":r.textContent=\\\"\\\";return}let o=typeof e==\\\"number\\\"?e:Number(w(e));if(Number.isNaN(o)){r.textContent=w(e);return}if(r.tagName===\\\"INPUT\\\"){r.value=String(o);return}r.textContent=Oo(o,n)}};function Oo(t,e){let n=e.locale??Me();try{return $r(n).format(t)}catch{return String(t)}}g(_n);var gt={name:\\\"array\\\",render(t,e){let n=t.element;if(!Array.isArray(e))return;let r=t.arrayTemplate;if(r!==void 0&&r.length>0){let s=Po(r,e);n.innerHTML=z(s);return}let o=t.arraySeparator??\\\", \\\";n.textContent=e.map($o).join(o)}};function Po(t,e){let n=\\\"\\\";for(let r=0;r<e.length;r+=1)n+=Fo(t,e[r],r);return n}function Fo(t,e,n){let r=t;if(typeof e==\\\"object\\\"&&e!==null)for(let[o,s]of Object.entries(e)){let a=new RegExp(`\\\\\\\\{\\\\\\\\{${Do(o)}\\\\\\\\}\\\\\\\\}`,\\\"g\\\");r=r.replace(a,y(w(s)))}else r=r.replace(/\\\\{\\\\{value\\\\}\\\\}/g,y(w(e)));return r=r.replace(/\\\\{\\\\{index\\\\}\\\\}/g,String(n)),r}function Do(t){return t.replace(/[.*+?^${}()|[\\\\]\\\\\\\\]/g,\\\"\\\\\\\\$&\\\")}function $o(t){return w(t)}g(gt);g({...gt,name:\\\"blocks\\\"});function Uo(){return typeof document>\\\"u\\\"?!1:typeof document.startViewTransition==\\\"function\\\"}async function Vr(t){if(!Uo()){t();return}let n=document.startViewTransition.call(document,t);try{await n.finished}catch{}}var Wr=\\\"data-payload-key\\\",bt=\\\"data-payload-nested-key\\\",Pn=\\\"data-payload-nested-template\\\";function Yr(){return new WeakMap}function Pt(t){let{template:e,container:n,patches:r,store:o}=t,s=Bo(n,o),a=[],u=[],m=[],T=[],W=[];for(let c of r)c.kind===\\\"remove\\\"?a.push(c):c.kind===\\\"insert\\\"?u.push(c):c.kind===\\\"move\\\"?m.push(c):c.kind===\\\"update\\\"?T.push(c):W.push(c);a.sort((c,R)=>Ot(R)-Ot(c));for(let c of a){if(c.kind!==\\\"remove\\\")continue;n.children[c.index]?.remove(),jo(s,c.value)}for(let c of W){if(c.kind!==\\\"replace\\\")continue;let R=n.children[c.index],v=On(e,c.value,c.index);!R||!v||(zr(v,c.value,o),n.replaceChild(v,R),Cn(s,c.value))}for(let c of T){if(c.kind!==\\\"update\\\")continue;let R=n.children[c.index],v=On(e,c.value,c.index);!R||!v||(Ho(R,v,c.value,s,o),n.replaceChild(v,R),Cn(s,c.value))}u.sort((c,R)=>Ot(c)-Ot(R));for(let c of u){if(c.kind!==\\\"insert\\\")continue;let R=n.children[c.index]??null,v=On(e,c.value,c.index);v&&(zr(v,c.value,o),n.insertBefore(v,R),Cn(s,c.value))}for(let c of m){if(c.kind!==\\\"move\\\")continue;let R=Rt(c.value),v=R!==void 0?Vo(n,R):null;if(!v)continue;let De=n.children[c.to]??null;v!==De&&n.insertBefore(v,De)}}function zr(t,e,n){let r=t.querySelectorAll(`[${bt}]`);for(let o of Array.from(r)){let s=o.getAttribute(bt);if(s===null)continue;let a=o.getAttribute(Pn);if(!a)continue;let u=Fn(e,s);if(u===void 0)continue;let m=ot([],u);m.length!==0&&Pt({template:a,container:o,patches:m,nextItems:u,store:n})}}function Ho(t,e,n,r,o){let s=t.querySelectorAll(`[${bt}]`);if(s.length===0)return;let a=Rt(n),u=a!==void 0?r.get(a):void 0;for(let m of Array.from(s)){let T=m.getAttribute(bt);if(T===null)continue;let W=e.querySelector(`[${bt}=\\\"${qr(T)}\\\"]`);if(!W)continue;W.replaceWith(m);let c=m.getAttribute(Pn)??W.getAttribute(Pn);if(!c)continue;let R=Fn(n,T)??[],v=Fn(u,T)??[],De=ot(v,R);De.length!==0&&Pt({template:c,container:m,patches:De,nextItems:R,store:o})}}function Fn(t,e){if(typeof t!=\\\"object\\\"||t===null)return;let n=t[e];if(Array.isArray(n))return n}function Bo(t,e){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}function Cn(t,e){let n=Rt(e);n!==void 0&&t.set(n,e)}function jo(t,e){let n=Rt(e);n!==void 0&&t.delete(n)}function Ot(t){return t.kind===\\\"move\\\"?t.to:t.index}function Rt(t){if(typeof t!=\\\"object\\\"||t===null)return;let e=t.id;if(typeof e==\\\"string\\\"||typeof e==\\\"number\\\")return String(e)}function Vo(t,e){return t.querySelector(`[${Wr}=\\\"${qr(e)}\\\"]`)}function qr(t){let e=globalThis.CSS;return e?.escape?e.escape(t):t.replace(/[^a-zA-Z0-9_-]/g,\\\"\\\\\\\\$&\\\")}function On(t,e,n){if(typeof document>\\\"u\\\")return null;let r=zo(t,e,n),o=z(r),s=document.createElement(\\\"template\\\");s.innerHTML=o;let a=s.content.firstElementChild;if(!a)return null;let u=Rt(e);return u!==void 0&&a.setAttribute(Wr,u),a}function zo(t,e,n){let r=t;if(typeof e==\\\"object\\\"&&e!==null)for(let[o,s]of Object.entries(e)){let a=new RegExp(`\\\\\\\\{\\\\\\\\{${Go(o)}\\\\\\\\}\\\\\\\\}`,\\\"g\\\"),u=y(Gr(s));r=r.replace(a,()=>u)}else{let o=y(Gr(e));r=r.replace(/\\\\{\\\\{value\\\\}\\\\}/g,()=>o)}return r.replace(/\\\\{\\\\{index\\\\}\\\\}/g,String(n))}function Gr(t){return t==null?\\\"\\\":typeof t==\\\"string\\\"?t:typeof t==\\\"number\\\"||typeof t==\\\"boolean\\\"||typeof t==\\\"bigint\\\"?String(t):JSON.stringify(t)}function Go(t){return t.replace(/[.*+?^${}()|[\\\\]\\\\\\\\]/g,\\\"\\\\\\\\$&\\\")}function Kr(){let t=new WeakMap,e=new WeakSet,n=Yr();return{name:\\\"structural-array\\\",render(r,o){if(!Array.isArray(o))return;let s=r.element,a=r.arrayTemplate;if(a===void 0||a.length===0){Wo(e,s,r.fieldName);return}let u=t.get(s)??[],m=ot(u,o);if(m.length===0){t.set(s,o.slice());return}Vr(()=>{Pt({template:a,container:s,patches:m,nextItems:o,store:n})}),t.set(s,o.slice())}}}function Wo(t,e,n){t.has(e)||(t.add(e),console.warn(`[live-preview] Skipping structural update for \\\"${n}\\\" \\\\u2014 the <${e.tagName.toLowerCase()}> with data-payload-structural is missing data-payload-array-template. Add an inline template (e.g., data-payload-array-template=\\\"<li>{{label}}</li>\\\") so the renderer can materialise new items.`))}var Yo=[xn,vn,Sn,En,pt,{...pt,name:\\\"email\\\"},kn,An,Ln,mt,{...mt,name:\\\"radio\\\"},Mn,Nn,_n,gt,{...gt,name:\\\"blocks\\\"}];function Jr(){return Or([...Yo,Kr()])}function qo(){if(typeof window>\\\"u\\\"||!Xt())return;let t=window.__livePreview;if(t!==void 0)return t;let e=Ko(),n=new Nt({additionalOrigins:e.additionalOrigins,enableReferrerDetection:!e.disableReferrerDetection,enableLocalhostMatching:!e.disableLocalhostMatching});n.isProductionUnconfigured?console.warn(\\\"[live-preview] No trusted origin could be detected. Set the PAYLOAD_ADMIN_ORIGIN env var or pass `allowedOrigins` to generateInlineScript().\\\"):n.isReferrerOnlyTrust&&console.warn(\\\"[live-preview] Trusting the embedding page via document.referrer only \\\\u2014 any site that frames this page could post preview updates. Pass explicit `allowedOrigins` and serve a `frame-ancestors` CSP for production.\\\");let r=new Tt,o=Jr(),s=new It({renderers:o,originMatcher:u=>n.matches(u),readyTargets:n.enumerate(),emitter:r,...typeof e.serverURL==\\\"string\\\"&&e.serverURL!==\\\"\\\"?{dataMerge:{serverURL:e.serverURL,...typeof e.apiRoute==\\\"string\\\"?{apiRoute:e.apiRoute}:{},...typeof e.mergeDepth==\\\"number\\\"?{depth:e.mergeDepth}:{}}}:{},debounceMs:e.debounceMs,heartbeatMs:e.heartbeatMs,intersectionRootMargin:e.intersectionRootMargin,disableVisibilityGate:e.disableVisibilityGate,visibilityGateThreshold:e.visibilityGateThreshold,enableA11y:e.enableA11y,onHeartbeatTimeout:()=>{n.unlockOrigin()},...e.debug?{log:(...u)=>{console.debug(\\\"[live-preview]\\\",...u)}}:{}});r.on(\\\"connect\\\",u=>{n.lockOrigin(u.origin)}),s.start();let a=Object.freeze({version:Rr,destroy:()=>{s.destroy();let u=window;u.__livePreview===a&&delete u.__livePreview},refresh:()=>{s.refreshCache()},enumerateOrigins:()=>n.enumerate()});return Object.defineProperty(window,\\\"__livePreview\\\",{value:a,writable:!1,configurable:!0}),a}function Ko(){let t=typeof __LIVE_PREVIEW_CONFIG__>\\\"u\\\"?void 0:__LIVE_PREVIEW_CONFIG__;return t!==void 0?t:{additionalOrigins:[],serverURL:\\\"\\\",apiRoute:\\\"/api\\\",mergeDepth:1,debug:!1,debounceMs:50,enableA11y:!0,heartbeatMs:0,disableVisibilityGate:!1,visibilityGateThreshold:50,intersectionRootMargin:\\\"200px\\\",disableReferrerDetection:!1,disableLocalhostMatching:!1}}var Jo=typeof __INLINE_BUILD__>\\\"u\\\"?!1:__INLINE_BUILD__;Jo&&qo();var Pl={isInIframe:ut,isInPopup:Jt,isInPreviewContext:Xt};})();\\n\";\nexport const RUNTIME_BUILD_INFO: RuntimeBuildInfo = { generatedAt: \"2026-07-11T19:02:27.899Z\", size: 58897 };\n","/**\n * Inline script generator.\n *\n * Wraps the build-time-generated runtime IIFE with consumer-provided\n * configuration. Returns a JavaScript string suitable for embedding\n * via `<script>` in any framework.\n *\n * The runtime body is identical to the one used by the high-level\n * client because both originate from `src/core/runtime.ts`. There is\n * no parallel implementation to drift out of sync.\n *\n * @module @inline/generator\n */\n\nimport { RUNTIME_SOURCE, RUNTIME_BUILD_INFO, type RuntimeBuildInfo } from './runtime.generated';\n\nexport interface InlineScriptConfig {\n /** Additional trusted origins to merge with auto-detected ones. */\n readonly allowedOrigins?: readonly string[];\n /**\n * Payload server origin, e.g. `https://cms.example.com`. When set,\n * every incoming update is re-fetched through the Payload REST API\n * (`X-Payload-HTTP-Method-Override: GET`, same strategy as the\n * official client) so relationship and upload fields render\n * populated instead of as bare IDs. Strongly recommended for\n * Payload 3.x. Requires the preview page to be able to reach the\n * API with credentials (same-site cookies or CORS `credentials`).\n */\n readonly serverURL?: string;\n /** REST API route prefix used with `serverURL`. Defaults to `/api`. */\n readonly apiRoute?: string;\n /** Population depth used with `serverURL`. Defaults to `1`. */\n readonly mergeDepth?: number;\n /** Enable verbose console logging. Defaults to `false`. */\n readonly debug?: boolean;\n /** Debounce window for incoming updates in ms. Defaults to `50`. */\n readonly debounceMs?: number;\n /** Enable screen-reader live region. Defaults to `true`. */\n readonly enableA11y?: boolean;\n /**\n * Heartbeat timeout in ms. Defaults to `0` (disabled). The Payload\n * admin only posts messages on form edits — there is no protocol\n * keepalive — so an idle-based timeout would fire spurious\n * disconnects while the editor pauses. Enable only if your admin\n * setup sends periodic messages.\n */\n readonly heartbeatMs?: number;\n /**\n * Bypass the visibility-gate optimisation and apply every update\n * regardless of viewport position. Default `false` — the gate kicks\n * in when the cache exceeds `visibilityGateThreshold` entries.\n */\n readonly disableVisibilityGate?: boolean;\n /**\n * Cache-size threshold above which the visibility gate activates.\n * Default `50`. Off-screen elements above this threshold are queued\n * for replay on intersection instead of being updated immediately.\n */\n readonly visibilityGateThreshold?: number;\n /**\n * `rootMargin` passed to the `IntersectionObserver` watching the\n * cached elements. Default `'200px'`. Increase to pre-render\n * further off-screen content; decrease for tighter visibility.\n */\n readonly intersectionRootMargin?: string;\n /**\n * Opt out of `document.referrer`-based origin auto-detection.\n * Useful when the page is loaded under `Referrer-Policy: no-referrer`\n * and you want predictable behaviour. Default `false`.\n */\n readonly disableReferrerDetection?: boolean;\n /**\n * Opt out of the dev-mode localhost-pattern matcher (any port on\n * `localhost` / `127.0.0.1`). Useful when running locally against\n * a production-like origin list. Default `false`.\n */\n readonly disableLocalhostMatching?: boolean;\n /**\n * Optional CSP nonce for the generated `<script>` tag. When provided\n * via `wrapWithScriptTag()` the nonce is set on the tag. Useful for\n * strict CSP policies that disallow `unsafe-inline`.\n */\n readonly nonce?: string;\n}\n\nconst DEFAULT_DEBOUNCE_MS = 50;\nconst DEFAULT_HEARTBEAT_MS = 0;\nconst DEFAULT_VISIBILITY_GATE_THRESHOLD = 50;\nconst DEFAULT_INTERSECTION_ROOT_MARGIN = '200px';\n\n/**\n * Build an inline script body. The result is a self-contained IIFE\n * with the build-time runtime, prefixed by a configuration block.\n *\n * The string does NOT include the `<script>` tags — use\n * `wrapWithScriptTag()` when you need them.\n */\nexport function generateInlineScript(config: InlineScriptConfig = {}): string {\n if (RUNTIME_SOURCE.length === 0) {\n throw new Error(\n '[live-preview] runtime.generated.ts is empty. Run `npm run build:runtime` before bundling.',\n );\n }\n const configLiteral = JSON.stringify({\n additionalOrigins: config.allowedOrigins ?? [],\n serverURL: config.serverURL ?? '',\n apiRoute: config.apiRoute ?? '/api',\n mergeDepth: config.mergeDepth ?? 1,\n debug: config.debug ?? false,\n debounceMs: config.debounceMs ?? DEFAULT_DEBOUNCE_MS,\n enableA11y: config.enableA11y ?? true,\n heartbeatMs: config.heartbeatMs ?? DEFAULT_HEARTBEAT_MS,\n disableVisibilityGate: config.disableVisibilityGate ?? false,\n visibilityGateThreshold: config.visibilityGateThreshold ?? DEFAULT_VISIBILITY_GATE_THRESHOLD,\n intersectionRootMargin: config.intersectionRootMargin ?? DEFAULT_INTERSECTION_ROOT_MARGIN,\n disableReferrerDetection: config.disableReferrerDetection ?? false,\n disableLocalhostMatching: config.disableLocalhostMatching ?? false,\n // `<` must never appear literally inside an inline <script> body —\n // a consumer-supplied string containing `</script>` would otherwise\n // terminate the tag early.\n }).replace(/</g, '\\\\u003C');\n // The IIFE declares its own scope. We inject the config via a global\n // assignment that the bundled runtime reads back through the\n // `__LIVE_PREVIEW_CONFIG__` constant placeholder.\n const generatedAt =\n RUNTIME_BUILD_INFO.generatedAt === '' ? 'dev' : RUNTIME_BUILD_INFO.generatedAt;\n return [\n `/* payload-live-preview runtime ${generatedAt} */`,\n `var __LIVE_PREVIEW_CONFIG__=${configLiteral};`,\n `var __INLINE_BUILD__=true;`,\n RUNTIME_SOURCE,\n ].join('\\n');\n}\n\n/**\n * Wrap an inline script body in a `<script>` tag. When a nonce is\n * provided it is added as the `nonce` attribute so CSP policies that\n * require `'nonce-...'` accept the script.\n */\nexport function wrapWithScriptTag(body: string, options: { nonce?: string } = {}): string {\n const nonceAttr = options.nonce !== undefined ? ` nonce=\"${escapeNonce(options.nonce)}\"` : '';\n return `<script${nonceAttr}>${body}</script>`;\n}\n\n/**\n * Snapshot of the build-time information for diagnostics.\n */\nexport function runtimeBuildInfo(): RuntimeBuildInfo {\n return RUNTIME_BUILD_INFO;\n}\n\nfunction escapeNonce(nonce: string): string {\n if (!/^[A-Za-z0-9+/=_-]+$/.test(nonce)) {\n throw new RangeError('wrapWithScriptTag: nonce contains invalid characters');\n }\n return nonce;\n}\n","/**\n * Server-side preview-request detection.\n *\n * The live-preview runtime only ever activates inside the Payload\n * admin's iframe, but the *server* still has to decide whether to\n * inject the (sizeable) inline script into a given HTML response.\n * Injecting it into every page for every visitor buffers every\n * response and ships dead bytes to production traffic — so adapters\n * gate injection on this predicate by default, and consumers with\n * hand-rolled middleware can import it directly.\n *\n * A request counts as a preview when any of these hold:\n *\n * 1. A preview query parameter is present (`?preview=true`,\n * `?draft=true`, `?livePreview=true` — configurable).\n * 2. `Sec-Fetch-Dest: iframe` — the document is being loaded as an\n * iframe, which is exactly how the Payload admin embeds it.\n * (Sent by all evergreen browsers; absence never *excludes* a\n * request, presence includes it.)\n * 3. The `Referer` points at one of the given admin origins.\n *\n * @module @adapters/shared/preview-request\n */\n\n/** The individual signals the predicate can consider. */\nexport type PreviewSignal = 'query' | 'fetch-dest' | 'referer';\n\nexport interface PreviewRequestOptions {\n /**\n * Which signals count as \"this is a preview request\". Default: all\n * three. High-security setups that must never relax framing headers\n * for unsolicited iframe loads can restrict to `['query']` — then\n * only an explicit `?preview=true` (e.g. from `buildLivePreviewUrl`)\n * activates preview handling.\n */\n readonly signals?: readonly PreviewSignal[];\n /**\n * Query parameters (with values `true` or `1`) that mark a request\n * as a preview. Default: `['preview', 'draft', 'livePreview']`.\n */\n readonly queryParams?: readonly string[];\n /**\n * Treat `Sec-Fetch-Dest: iframe` as a preview signal. Default `true`.\n * Legacy alias for excluding `'fetch-dest'` from `signals`.\n */\n readonly checkFetchDest?: boolean;\n /**\n * Admin origins whose `Referer` marks a request as a preview,\n * e.g. `['https://cms.example.com']`.\n */\n readonly adminOrigins?: readonly string[];\n}\n\nconst DEFAULT_QUERY_PARAMS = ['preview', 'draft', 'livePreview'] as const;\n\n/**\n * The minimal request surface the predicate needs. The standard\n * `Request` satisfies it structurally, and server frameworks without\n * fetch-style requests (e.g. Nitro/H3) can supply a tiny shim.\n */\nexport interface PreviewRequestLike {\n readonly url: string;\n readonly headers: { get(name: string): string | null };\n}\n\n/**\n * Decide whether `request` is a live-preview request. See the module\n * docblock for the exact signals.\n */\nexport function isPreviewRequest(\n request: PreviewRequestLike,\n options: PreviewRequestOptions = {},\n): boolean {\n const signals = new Set<PreviewSignal>(options.signals ?? ['query', 'fetch-dest', 'referer']);\n const queryParams = options.queryParams ?? DEFAULT_QUERY_PARAMS;\n const checkFetchDest = (options.checkFetchDest ?? true) && signals.has('fetch-dest');\n\n if (signals.has('query')) {\n let url: URL | undefined;\n try {\n url = new URL(request.url);\n } catch {\n url = undefined;\n }\n if (url !== undefined) {\n for (const param of queryParams) {\n const value = url.searchParams.get(param);\n if (value === 'true' || value === '1') return true;\n }\n }\n }\n\n if (checkFetchDest && request.headers.get('sec-fetch-dest') === 'iframe') {\n return true;\n }\n\n const adminOrigins = signals.has('referer') ? (options.adminOrigins ?? []) : [];\n if (adminOrigins.length > 0) {\n const referer = request.headers.get('referer');\n if (referer !== null) {\n try {\n const refererOrigin = new URL(referer).origin;\n for (const adminOrigin of adminOrigins) {\n try {\n if (new URL(adminOrigin).origin === refererOrigin) return true;\n } catch {\n // skip malformed configured origin\n }\n }\n } catch {\n // malformed referer — not a preview signal\n }\n }\n }\n\n return false;\n}\n","/**\n * Next.js adapter for Payload Live Preview.\n *\n * ⚠️ Scope: this package patches server-rendered/static DOM. For\n * client-rendered React trees prefer the official\n * `@payloadcms/live-preview-react` (`useLivePreview`) — React\n * re-renders can revert DOM patches made here.\n *\n * Provides:\n *\n * - `renderLivePreviewScript(options)` / `generateInlineScript` —\n * embed the script in your root layout via\n * `<script dangerouslySetInnerHTML>`. This is the PRIMARY wiring\n * for Next.js: standard middleware cannot inject into the HTML\n * body because `NextResponse.next()` carries no body.\n *\n * - `createLivePreviewMiddleware(options)` — merges CSP headers\n * (`frame-ancestors`) onto preview responses. Its script-injection\n * path only activates when you pass it a `Response` that actually\n * carries an HTML body (custom servers, route handlers returning\n * HTML) — in standard `middleware.ts` use `autoInject: false`.\n *\n * @module @adapters/nextjs\n */\n\nimport {\n generateCspNonce,\n buildFrameAncestors,\n buildScriptSrcWithNonce,\n mergeCspHeader,\n} from '@security/csp';\nimport { generateInlineScript, wrapWithScriptTag } from '@inline/generator';\nimport { isPreviewRequest } from '@adapters/shared/preview-request';\n\nexport interface LivePreviewNextOptions {\n readonly allowedOrigins?: readonly string[];\n /** Payload server origin for REST data merging (Payload 3.x). */\n readonly serverURL?: string;\n /** REST API route prefix used with `serverURL`. Defaults to `/api`. */\n readonly apiRoute?: string;\n /** Population depth used with `serverURL`. Defaults to `1`. */\n readonly mergeDepth?: number;\n readonly autoInject?: boolean;\n /**\n * `'preview-only'` (default) — inject only into responses that look\n * like preview requests. `'always'` — every HTML response.\n */\n readonly inject?: 'preview-only' | 'always';\n /** Query params that mark a preview request. Default `['preview', 'draft', 'livePreview']`. */\n readonly previewQueryParams?: readonly string[];\n /** Which signals count as a preview request. Default: query, fetch-dest, referer. */\n readonly previewSignals?: readonly ('query' | 'fetch-dest' | 'referer')[];\n readonly shouldInject?: (request: Request) => boolean;\n /**\n * CSP management: `'frame-ancestors'` (default) merges only the\n * embed permission; `'full'` also manages a nonce'd `script-src`;\n * `false` never touches CSP. `true` is a legacy alias for\n * `'frame-ancestors'`.\n */\n readonly manageCsp?: boolean | 'frame-ancestors' | 'full';\n /** Add `'strict-dynamic'` to the managed `script-src`. Default `false`. */\n readonly strictDynamic?: boolean;\n readonly frameAncestorsExtra?: readonly string[];\n readonly scriptSrcExtra?: readonly string[];\n readonly debug?: boolean;\n readonly debounceMs?: number;\n /** Heartbeat timeout in ms. Default `0` (disabled). */\n readonly heartbeatMs?: number;\n}\n\nexport type NextMiddleware = (request: Request) => Promise<Response | undefined>;\n\nconst HTML_CONTENT_TYPE = /text\\/html/i;\nconst HEAD_INSERT = /<head(\\s[^>]*)?>/i;\n\n/**\n * Build a Next.js-compatible middleware operating on the standard\n * `Request` / `Response` pair. Wrap with `NextResponse.next()` in your\n * project to integrate with Next's request pipeline.\n */\nexport function createLivePreviewMiddleware(\n options: LivePreviewNextOptions = {},\n): (request: Request, response: Response) => Promise<Response> {\n let cachedScriptBody: string | undefined;\n const scriptBody = (): string => {\n cachedScriptBody ??= buildScriptBody(options);\n return cachedScriptBody;\n };\n\n return async (request, response) => {\n const isPreview =\n (options.inject ?? 'preview-only') === 'always' ||\n isPreviewRequest(request, {\n ...(options.previewQueryParams !== undefined\n ? { queryParams: options.previewQueryParams }\n : {}),\n ...(options.previewSignals !== undefined ? { signals: options.previewSignals } : {}),\n adminOrigins: options.allowedOrigins ?? [],\n });\n if (!isPreview) return response;\n\n let outResponse = response;\n const apply = (options.autoInject ?? true) && (options.shouldInject?.(request) ?? true);\n const contentType = response.headers.get('content-type') ?? '';\n if (apply && HTML_CONTENT_TYPE.test(contentType)) {\n outResponse = await injectIntoResponse(response, scriptBody());\n }\n const manageCsp = normalizeManageCsp(options.manageCsp);\n if (manageCsp !== false) {\n outResponse = addCsp(outResponse, manageCsp, options);\n }\n return outResponse;\n };\n}\n\n/**\n * Render the live-preview `<script>` tag — for embedding manually in\n * App Router or Pages Router layouts.\n */\nexport function renderLivePreviewScript(\n options: LivePreviewNextOptions & { readonly nonce?: string } = {},\n): string {\n const body = generateInlineScript({\n ...(options.allowedOrigins !== undefined ? { allowedOrigins: options.allowedOrigins } : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n ...(options.nonce !== undefined ? { nonce: options.nonce } : {}),\n });\n return wrapWithScriptTag(body, options.nonce !== undefined ? { nonce: options.nonce } : {});\n}\n\nfunction buildScriptBody(options: LivePreviewNextOptions): string {\n return generateInlineScript({\n ...(options.allowedOrigins !== undefined ? { allowedOrigins: options.allowedOrigins } : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n });\n}\n\nfunction normalizeManageCsp(\n value: LivePreviewNextOptions['manageCsp'],\n): false | 'frame-ancestors' | 'full' {\n if (value === false) return false;\n if (value === 'full') return 'full';\n return 'frame-ancestors';\n}\n\nasync function injectIntoResponse(response: Response, body: string): Promise<Response> {\n const nonce = response.headers.get('x-live-preview-nonce') ?? generateCspNonce();\n const html = await response.text();\n const headers = new Headers(response.headers);\n headers.delete('content-length');\n headers.set('x-live-preview-nonce', nonce);\n\n // Fragment responses without a <head> are skipped, not prepended to.\n if (!HEAD_INSERT.test(html)) {\n return new Response(html, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n }\n\n const scriptTag = wrapWithScriptTag(body, { nonce });\n const out = html.replace(HEAD_INSERT, (match) => `${match}${scriptTag}`);\n return new Response(out, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n}\n\nfunction addCsp(\n response: Response,\n mode: 'frame-ancestors' | 'full',\n options: LivePreviewNextOptions,\n): Response {\n const nonce = response.headers.get('x-live-preview-nonce') ?? generateCspNonce();\n const frameAncestors = buildFrameAncestors({\n self: true,\n origins: [...(options.allowedOrigins ?? []), ...(options.frameAncestorsExtra ?? [])],\n });\n const additions: Record<string, string> = { 'frame-ancestors': frameAncestors };\n if (mode === 'full') {\n additions['script-src'] = buildScriptSrcWithNonce(nonce, {\n self: true,\n strictDynamic: options.strictDynamic ?? false,\n ...(options.scriptSrcExtra !== undefined ? { extra: options.scriptSrcExtra } : {}),\n });\n }\n const previous = response.headers.get('content-security-policy') ?? '';\n const next = mergeCspHeader(previous, additions);\n try {\n response.headers.set('x-live-preview-nonce', nonce);\n response.headers.set('content-security-policy', next);\n return response;\n } catch {\n const headers = new Headers(response.headers);\n headers.set('x-live-preview-nonce', nonce);\n headers.set('content-security-policy', next);\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../src/security/csp.ts","../../../src/inline/runtime.generated.ts","../../../src/inline/generator.ts","../../../src/adapters/shared/preview-request.ts","../../../src/adapters/nextjs/index.ts"],"names":[],"mappings":";;;AAoBA,IAAM,mBAAA,GAAsB,EAAA;AAgDrB,SAAS,gBAAA,CAAiB,QAAgB,mBAAA,EAA6B;AAC5E,EAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,IAAK,QAAQ,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,qDAAA,EAAwD,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F;AACA,EAAA,MAAM,SAAS,aAAA,EAAc;AAC7B,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAGF;AAAA,EACF;AACA,EAAA,MAAM,MAAA,GAAS,IAAI,UAAA,CAAW,KAAK,CAAA;AACnC,EAAA,MAAA,CAAO,gBAAgB,MAAM,CAAA;AAC7B,EAAA,OAAO,gBAAgB,MAAM,CAAA;AAC/B;AAEA,SAAS,aAAA,GAA2C;AAElD,EAAA,MAAM,aAAc,UAAA,CAA0C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CAAQ,GAAA,CAAI,2BAA2B,IAAI,CAAA;AAC3C,IAAA,OAAO,IAAI,QAAA,CAAS,QAAA,CAAS,IAAA,EAAM;AAAA,MACjC,QAAQ,QAAA,CAAS,MAAA;AAAA,MACjB,YAAY,QAAA,CAAS,UAAA;AAAA,MACrB;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"index.cjs","sourcesContent":["/**\n * Content-Security-Policy helpers.\n *\n * Two responsibilities:\n *\n * 1. Generate cryptographic nonces so consumers can opt into a strict\n * `script-src 'nonce-...'` policy and avoid `'unsafe-inline'`.\n * 2. Build the `frame-ancestors` directive value, restricting which\n * origins may embed the preview page in an iframe.\n *\n * Both functions are isomorphic — they work in browsers, Node, and\n * edge runtimes that expose Web Crypto via `globalThis.crypto`.\n *\n * @module @security/csp\n */\n\n/**\n * Default byte-length for nonces. 16 bytes → 22 base64url characters,\n * which exceeds the 128-bit entropy threshold recommended by OWASP.\n */\nconst DEFAULT_NONCE_BYTES = 16;\n\n/**\n * Minimal Web-Crypto surface area we actually call. The full `Crypto`\n * type drags in browser-only declarations that don't typecheck cleanly\n * against Node's `webcrypto` shape — this narrower interface accepts\n * both without an unsafe cast.\n */\ninterface WebCryptoLike {\n getRandomValues: <T extends ArrayBufferView | null>(array: T) => T;\n}\n\nlet cryptoOverride: WebCryptoLike | undefined;\n\n/**\n * Inject a Web Crypto implementation to use when `globalThis.crypto`\n * is unavailable.\n *\n * Node.js exposed `globalThis.crypto` globally starting with v19. On\n * Node 18 (still LTS at time of writing) consumers can flip the\n * `--experimental-global-webcrypto` flag *or* call this function once\n * at startup:\n *\n * ```ts\n * import { webcrypto } from 'node:crypto';\n * import { setCspCrypto } from 'payload-live-preview';\n * setCspCrypto(webcrypto as { getRandomValues: typeof webcrypto.getRandomValues });\n * ```\n *\n * Browser bundles never need to call this — `globalThis.crypto` is\n * always present there, and the override only matters when the global\n * is missing.\n *\n * Pass `null` to clear a previous override (mostly useful for tests).\n */\nexport function setCspCrypto(crypto: WebCryptoLike | null): void {\n cryptoOverride = crypto ?? undefined;\n}\n\n/**\n * Generate a base64url-encoded cryptographic nonce.\n *\n * Uses `crypto.getRandomValues` everywhere — falls back to throwing\n * if no Web Crypto implementation is available, because a predictable\n * nonce would silently defeat the entire CSP.\n *\n * @param bytes Number of random bytes (defaults to 16 → 128-bit entropy).\n */\nexport function generateCspNonce(bytes: number = DEFAULT_NONCE_BYTES): string {\n if (!Number.isInteger(bytes) || bytes < 8) {\n throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(bytes)}`);\n }\n const crypto = resolveCrypto();\n if (!crypto) {\n throw new Error(\n 'generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) ' +\n \"once at startup, or run with --experimental-global-webcrypto. We won't fabricate \" +\n 'a predictable nonce — that would silently defeat the entire CSP.',\n );\n }\n const buffer = new Uint8Array(bytes);\n crypto.getRandomValues(buffer);\n return base64UrlEncode(buffer);\n}\n\nfunction resolveCrypto(): WebCryptoLike | undefined {\n if (cryptoOverride?.getRandomValues) return cryptoOverride;\n const fromGlobal = (globalThis as { crypto?: WebCryptoLike }).crypto;\n if (fromGlobal?.getRandomValues) return fromGlobal;\n return undefined;\n}\n\nfunction base64UrlEncode(bytes: Uint8Array): string {\n let binary = '';\n for (const byte of bytes) binary += String.fromCharCode(byte);\n const base64 = typeof btoa === 'function' ? btoa(binary) : Buffer.from(bytes).toString('base64');\n return base64.replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '');\n}\n\n/**\n * Sources allowed in the `frame-ancestors` directive.\n *\n * Conceptually a union of `'self'`, `'none'`, or an explicit origin\n * string. TypeScript collapses literal-vs-string unions, so we expose\n * a `string` alias and document the special values.\n */\nexport type FrameAncestorSource = string;\n\nexport interface FrameAncestorsOptions {\n readonly self?: boolean;\n readonly origins?: readonly string[];\n readonly allowNone?: boolean;\n}\n\n/**\n * Build the value for `frame-ancestors` in a `Content-Security-Policy`\n * header.\n *\n * Returns `'none'` if `allowNone: true` and no other sources are\n * provided. Otherwise concatenates `'self'` (if requested) with the\n * given origins, deduplicating and trimming entries.\n *\n * @example\n * `frame-ancestors ${buildFrameAncestors({ self: true, origins: [adminUrl] })}`\n */\nexport function buildFrameAncestors(options: FrameAncestorsOptions = {}): string {\n const { self = true, origins = [], allowNone = false } = options;\n const seen = new Set<string>();\n const out: FrameAncestorSource[] = [];\n if (allowNone && !self && origins.length === 0) return \"'none'\";\n if (self) {\n out.push(\"'self'\");\n seen.add(\"'self'\");\n }\n for (const origin of origins) {\n const trimmed = origin.trim();\n if (trimmed.length === 0 || seen.has(trimmed)) continue;\n seen.add(trimmed);\n out.push(trimmed);\n }\n return out.length > 0 ? out.join(' ') : \"'none'\";\n}\n\n/**\n * Build a `script-src` value that permits a single nonce plus optional\n * extra sources.\n *\n * `'strict-dynamic'` is **opt-in**: under CSP 3 it makes browsers\n * ignore `'self'` and every host source in the directive, so any\n * parser-inserted script without a nonce (framework hydration scripts,\n * consumer `<script>` tags) would be blocked. Only enable it when every\n * script on the page carries the nonce.\n */\nexport function buildScriptSrcWithNonce(\n nonce: string,\n options: {\n readonly self?: boolean;\n readonly extra?: readonly string[];\n readonly strictDynamic?: boolean;\n } = {},\n): string {\n if (nonce.length === 0) throw new RangeError('buildScriptSrcWithNonce: nonce is empty');\n const { self = true, extra = [], strictDynamic = false } = options;\n const parts: string[] = [];\n if (self) parts.push(\"'self'\");\n parts.push(`'nonce-${nonce}'`);\n if (strictDynamic) parts.push(\"'strict-dynamic'\");\n for (const e of extra) {\n const trimmed = e.trim();\n if (trimmed.length > 0) parts.push(trimmed);\n }\n return parts.join(' ');\n}\n\n/**\n * How a directive is merged into an existing CSP header value.\n *\n * - `union` (default) — the new sources are added to the existing\n * directive's sources (deduplicated). An existing `'none'` is\n * dropped when real sources are added, since `'none'` may not be\n * combined with other sources.\n * - `replace` — the new value overwrites the existing directive.\n */\nexport interface CspDirectiveMerge {\n readonly value: string;\n readonly mode?: 'union' | 'replace';\n}\n\n/**\n * Merge directives into an existing `Content-Security-Policy` header\n * value without clobbering what a consumer (or another middleware)\n * already configured. Directives not mentioned in `additions` pass\n * through untouched; new directives are appended.\n *\n * This is the single CSP-merge implementation shared by every adapter.\n */\nexport function mergeCspHeader(\n existing: string,\n additions: Readonly<Record<string, string | CspDirectiveMerge>>,\n): string {\n const directives = new Map<string, string>();\n for (const part of existing.split(';')) {\n const trimmed = part.trim();\n if (trimmed.length === 0) continue;\n const spaceIndex = trimmed.indexOf(' ');\n if (spaceIndex < 0) {\n directives.set(trimmed.toLowerCase(), '');\n continue;\n }\n directives.set(\n trimmed.slice(0, spaceIndex).toLowerCase(),\n trimmed.slice(spaceIndex + 1).trim(),\n );\n }\n\n for (const [rawName, rawAddition] of Object.entries(additions)) {\n const name = rawName.toLowerCase();\n const addition: CspDirectiveMerge =\n typeof rawAddition === 'string' ? { value: rawAddition } : rawAddition;\n const mode = addition.mode ?? 'union';\n const current = directives.get(name);\n if (mode === 'replace' || current === undefined || current.length === 0) {\n directives.set(name, addition.value);\n continue;\n }\n const seen = new Set<string>();\n const merged: string[] = [];\n for (const token of [...current.split(/\\s+/), ...addition.value.split(/\\s+/)]) {\n if (token.length === 0 || seen.has(token)) continue;\n seen.add(token);\n merged.push(token);\n }\n // `'none'` cannot coexist with other sources.\n const withoutNone = merged.filter((token) => token !== \"'none'\");\n directives.set(name, (withoutNone.length > 0 ? withoutNone : merged).join(' '));\n }\n\n const out: string[] = [];\n for (const [name, value] of directives) {\n out.push(value.length === 0 ? name : `${name} ${value}`);\n }\n return out.join('; ');\n}\n","// Auto-generated by scripts/build-runtime.ts — do not edit.\nexport interface RuntimeBuildInfo { readonly generatedAt: string; readonly size: number }\nexport const RUNTIME_SOURCE: string = \"\\\"use strict\\\";(()=>{var Zr=Object.defineProperty;var $n=t=>{throw TypeError(t)};var Qr=(t,e,n)=>e in t?Zr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Un=(t,e,n)=>Qr(t,typeof e!=\\\"symbol\\\"?e+\\\"\\\":e,n),Dt=(t,e,n)=>e.has(t)||$n(\\\"Cannot \\\"+n);var i=(t,e,n)=>(Dt(t,e,\\\"read from private field\\\"),n?n.call(t):e.get(t)),d=(t,e,n)=>e.has(t)?$n(\\\"Cannot add the same private member more than once\\\"):e instanceof WeakSet?e.add(t):e.set(t,n),l=(t,e,n,r)=>(Dt(t,e,\\\"write to private field\\\"),r?r.call(t,n):e.set(t,n),n),f=(t,e,n)=>(Dt(t,e,\\\"access private method\\\"),n);var F,_,ne,$t,Ut,wt=class{constructor(){d(this,ne);d(this,F,new Map);d(this,_,new Map)}on(e,n){return f(this,ne,$t).call(this,i(this,F),e,n)}once(e,n){return f(this,ne,$t).call(this,i(this,_),e,n)}off(e,n){i(this,F).get(e)?.delete(n),i(this,_).get(e)?.delete(n)}async emit(e,n){let r=i(this,F).get(e);if(r)for(let s of[...r])await f(this,ne,Ut).call(this,s,n,e);let o=i(this,_).get(e);if(o&&o.size>0){let s=[...o];i(this,_).delete(e);for(let a of s)await f(this,ne,Ut).call(this,a,n,e)}}listenerCount(e){return(i(this,F).get(e)?.size??0)+(i(this,_).get(e)?.size??0)}removeAllListeners(e){if(e===void 0){i(this,F).clear(),i(this,_).clear();return}i(this,F).delete(e),i(this,_).delete(e)}eventNames(){let e=new Set;for(let n of i(this,F).keys())e.add(n);for(let n of i(this,_).keys())e.add(n);return[...e]}};F=new WeakMap,_=new WeakMap,ne=new WeakSet,$t=function(e,n,r){let o=e.get(n);return o||(o=new Set,e.set(n,o)),o.add(r),()=>{e.get(n)?.delete(r)}},Ut=async function(e,n,r){try{await e(n)}catch(o){let s=typeof r==\\\"string\\\"||typeof r==\\\"number\\\"?String(r):\\\"<event>\\\";console.error(`[live-preview] handler for \\\"${s}\\\" threw:`,o)}};var ue=\\\"data-payload-field\\\",Hn=\\\"data-payload-type\\\",ei=\\\"data-payload-attribute\\\",ti=\\\"data-payload-href\\\",ni=\\\"data-payload-src\\\",ri=\\\"data-payload-alt\\\",ii=\\\"data-payload-array-template\\\",oi=\\\"data-payload-array-separator\\\",si=\\\"data-payload-locale\\\",ai=`[${ue}]`,Bn=new Set([\\\"text\\\",\\\"textarea\\\",\\\"richText\\\",\\\"email\\\",\\\"number\\\",\\\"checkbox\\\",\\\"date\\\",\\\"select\\\",\\\"radio\\\",\\\"array\\\",\\\"blocks\\\",\\\"group\\\",\\\"tabs\\\",\\\"row\\\",\\\"collapsible\\\",\\\"relationship\\\",\\\"upload\\\",\\\"point\\\",\\\"json\\\",\\\"code\\\",\\\"ui\\\",\\\"html\\\",\\\"url\\\",\\\"image\\\",\\\"structural-array\\\"]),E,Y,xe,re,Ht,Bt,xt=class{constructor(e={}){d(this,re);d(this,E,new Map);d(this,Y,new WeakMap);d(this,xe);l(this,xe,e.filter??di)}buildFromRoot(e){let n=performance.now();i(this,E).clear();let r=e.querySelectorAll(ai),o=0;for(let s of r){if(!i(this,xe).call(this,s))continue;let a=f(this,re,Bt).call(this,s);a&&(f(this,re,Ht).call(this,a),i(this,Y).set(s,a),o+=1)}return{elementCount:o,fieldCount:i(this,E).size,durationMs:performance.now()-n}}add(e){if(!i(this,xe).call(this,e))return;let n=f(this,re,Bt).call(this,e);if(n)return f(this,re,Ht).call(this,n),i(this,Y).set(e,n),n}remove(e){let n=i(this,Y).get(e);if(!n)return!1;i(this,Y).delete(e);let r=i(this,E).get(n.fieldName);if(!r)return!1;let o=r.indexOf(n);return o<0?!1:(r.splice(o,1),r.length===0&&i(this,E).delete(n.fieldName),!0)}get(e){return i(this,E).get(e)}getByElement(e){return i(this,Y).get(e)}get fieldCount(){return i(this,E).size}get elementCount(){let e=0;for(let n of i(this,E).values())e+=n.length;return e}entries(){return i(this,E).entries()}*values(){for(let e of i(this,E).values())yield*e}has(e){return i(this,Y).has(e)}clear(){i(this,E).clear()}};E=new WeakMap,Y=new WeakMap,xe=new WeakMap,re=new WeakSet,Ht=function(e){let n=i(this,E).get(e.fieldName);if(n){n.push(e);return}i(this,E).set(e.fieldName,[e])},Bt=function(e){let n=e.getAttribute(ue);if(n===null||n.length===0)return;let r=e.getAttribute(Hn),o=li(e),s=e.getAttribute(ei),a=e.getAttribute(ti),u=e.getAttribute(ni),m=e.getAttribute(ri),T=e.getAttribute(ii),W=e.getAttribute(oi),c=e.getAttribute(si);return{element:e,fieldName:n,fieldType:o,explicitFieldType:r!==null&&Bn.has(r),...s!==null&&s.length>0?{targetAttribute:s}:{},...a!==null?{hrefField:a}:{},...u!==null?{srcField:u}:{},...m!==null?{altField:m}:{},...T!==null?{arrayTemplate:T}:{},...W!==null?{arraySeparator:W}:{},...c!==null?{locale:c}:{}}};function li(t){let e=t.getAttribute(Hn);if(e!==null&&Bn.has(e))return e;if(t.hasAttribute(\\\"data-payload-richtext\\\"))return\\\"richText\\\";if(t.hasAttribute(\\\"data-payload-html\\\"))return\\\"html\\\";if(t.hasAttribute(\\\"data-payload-structural\\\"))return\\\"structural-array\\\";if(t.hasAttribute(\\\"data-payload-array\\\"))return\\\"array\\\";if(t.tagName===\\\"IMG\\\")return\\\"image\\\";if(t.tagName===\\\"A\\\")return\\\"url\\\";if(t.tagName===\\\"TIME\\\")return\\\"date\\\";if(t.tagName===\\\"INPUT\\\"){let n=t.type;if(n===\\\"checkbox\\\")return\\\"checkbox\\\";if(n===\\\"number\\\")return\\\"number\\\";if(n===\\\"date\\\"||n===\\\"datetime-local\\\")return\\\"date\\\"}return\\\"text\\\"}function di(){return!0}var ui=100,ci=\\\"200px\\\",ce,Ue,He,M,fe,ie,D,ve,Vn,zn,vt=class{constructor(e,n={}){d(this,ve);d(this,ce);d(this,Ue);d(this,He);d(this,M,new Set);d(this,fe,null);d(this,ie,null);d(this,D,null);l(this,ce,e),l(this,Ue,n.mutationDebounceMs??ui),l(this,He,n.intersectionRootMargin??ci)}start(e){l(this,fe,new MutationObserver(n=>{f(this,ve,Vn).call(this,n)})),i(this,fe).observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[ue]}),l(this,ie,new IntersectionObserver(n=>{f(this,ve,zn).call(this,n)},{rootMargin:i(this,He),threshold:0}))}observeElement(e){i(this,ie)?.observe(e)}unobserveElement(e){i(this,ie)?.unobserve(e),i(this,M).delete(e)}markVisible(e,n){n?i(this,M).add(e):i(this,M).delete(e)}isVisible(e){return i(this,M).has(e)}stop(){i(this,D)!==null&&(clearTimeout(i(this,D)),l(this,D,null)),i(this,fe)?.disconnect(),i(this,ie)?.disconnect(),l(this,fe,null),l(this,ie,null),i(this,M).clear()}};ce=new WeakMap,Ue=new WeakMap,He=new WeakMap,M=new WeakMap,fe=new WeakMap,ie=new WeakMap,D=new WeakMap,ve=new WeakSet,Vn=function(e){fi(e)&&(i(this,D)!==null&&clearTimeout(i(this,D)),l(this,D,setTimeout(()=>{l(this,D,null),i(this,ce).onStructuralChange()},i(this,Ue))))},zn=function(e){for(let n of e){let r=n.target;n.isIntersecting?i(this,M).has(r)||(i(this,M).add(r),i(this,ce).onVisibilityChange(r,!0)):i(this,M).has(r)&&(i(this,M).delete(r),i(this,ce).onVisibilityChange(r,!1))}};function fi(t){for(let e of t){if(e.type===\\\"attributes\\\"&&e.attributeName===ue)return!0;for(let n of e.addedNodes)if(jn(n))return!0;for(let n of e.removedNodes)if(jn(n))return!0}return!1}function jn(t){if(t.nodeType!==Node.ELEMENT_NODE)return!1;let e=t;return e.hasAttribute(ue)?!0:e.querySelector(`[${ue}]`)!==null}var pi={basic:1,\\\"schema-json\\\":2,\\\"preview-token\\\":3,\\\"nested-arrays\\\":4,\\\"recursive-diffs\\\":4};function jt(t){let e=typeof t==\\\"number\\\"&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0,r=Math.min(4,e??1),o=new Set;for(let[s,a]of Object.entries(pi))r>=a&&o.add(s);return{ours:4,...e!==void 0?{theirs:e}:{theirs:void 0},negotiated:r,capabilities:o}}var je,x,Se,me,Ve,Ee,Wn,Yn,Be=class{constructor(e,n){d(this,Ee);d(this,je);d(this,x);d(this,Se);d(this,me,!1);d(this,Ve,Promise.resolve());l(this,je,e),l(this,x,n),l(this,Se,r=>{f(this,Ee,Wn).call(this,r)})}attach(e=window){i(this,me)||(e.addEventListener(\\\"message\\\",i(this,Se)),l(this,me,!0))}detach(e=window){i(this,me)&&(e.removeEventListener(\\\"message\\\",i(this,Se)),l(this,me,!1))}static sendReady(e,n){if(e.length===0||n.length===0)return;let r={type:\\\"payload-live-preview\\\",ready:!0,protocolVersion:4};for(let o of e)for(let s of n)try{o.postMessage(r,s)}catch{}}};je=new WeakMap,x=new WeakMap,Se=new WeakMap,me=new WeakMap,Ve=new WeakMap,Ee=new WeakSet,Wn=function(e){let n=e.origin;if(!i(this,je).call(this,n)){i(this,x).onInvalid?.(\\\"origin\\\",n);return}let r=e.data;if(!mi(r)){i(this,x).onInvalid?.(\\\"shape\\\",n);return}switch(r.type){case\\\"payload-live-preview\\\":if(!hi(r)){i(this,x).onInvalid?.(\\\"shape\\\",n);return}f(this,Ee,Yn).call(this,r,n);return;case\\\"payload-document-event\\\":i(this,x).onDocumentEvent(r,n);return;default:i(this,x).onInvalid?.(\\\"type\\\",n)}},Yn=function(e,n){let r=i(this,x).validateToken;if(r===void 0){i(this,x).onUpdate(e,n);return}if(e.ready===!0&&e.data===void 0){i(this,x).onUpdate(e,n);return}let o;try{o=r(e.previewToken,n)}catch{i(this,x).onInvalid?.(\\\"token\\\",n);return}if(typeof o==\\\"boolean\\\"){o?i(this,x).onUpdate(e,n):i(this,x).onInvalid?.(\\\"token\\\",n);return}l(this,Ve,i(this,Ve).then(async()=>{let s;try{s=await o}catch{i(this,x).onInvalid?.(\\\"token\\\",n);return}s?i(this,x).onUpdate(e,n):i(this,x).onInvalid?.(\\\"token\\\",n)}))};function mi(t){return typeof t!=\\\"object\\\"||t===null||!(\\\"type\\\"in t)?!1:typeof t.type==\\\"string\\\"}function hi(t){let e=t;return!(e.data!==void 0&&e.data!==null&&!yi(e.data)||!pe(e.fieldSchemaJSON,n=>Array.isArray(n))||!pe(e.globalSlug,n=>typeof n==\\\"string\\\")||!pe(e.collectionSlug,n=>typeof n==\\\"string\\\")||!pe(e.locale,n=>typeof n==\\\"string\\\")||!pe(e.ready,n=>typeof n==\\\"boolean\\\")||!pe(e.previewToken,n=>typeof n==\\\"string\\\")||!pe(e.protocolVersion,n=>typeof n==\\\"number\\\"))}function pe(t,e){return t==null?!0:e(t)}function yi(t){return typeof t==\\\"object\\\"&&t!==null&&!Array.isArray(t)}var ke,ze,C,Ge,Et=class{constructor(e){d(this,ke);d(this,ze);d(this,C,null);d(this,Ge,0);l(this,ke,e.timeoutMs??0),l(this,ze,e.onTimeout)}kick(){l(this,Ge,Date.now()),!(i(this,ke)<=0)&&(i(this,C)!==null&&clearTimeout(i(this,C)),l(this,C,setTimeout(()=>{l(this,C,null),i(this,ze).call(this)},i(this,ke))))}stop(){i(this,C)!==null&&(clearTimeout(i(this,C)),l(this,C,null))}get lastKickAt(){return i(this,Ge)}get pending(){return i(this,C)!==null}};ke=new WeakMap,ze=new WeakMap,C=new WeakMap,Ge=new WeakMap;var he,We,Ae,St,kt=class{constructor(e){d(this,Ae);d(this,he,\\\"disconnected\\\");d(this,We);l(this,We,e)}get status(){return i(this,he)}markConnected(){return f(this,Ae,St).call(this,\\\"connected\\\")}markConnecting(){return f(this,Ae,St).call(this,\\\"connecting\\\")}markDisconnected(){return f(this,Ae,St).call(this,\\\"disconnected\\\")}};he=new WeakMap,We=new WeakMap,Ae=new WeakSet,St=function(e){if(i(this,he)===e)return!1;let n=i(this,he);return l(this,he,e),i(this,We).call(this,e,n),!0};var gi=()=>{},Ye,qe,Ke,Je,ye,q,At=class{constructor(e){d(this,Ye);d(this,qe);d(this,Ke);d(this,Je);d(this,ye);d(this,q,null);l(this,Ye,e.serverURL.replace(/\\\\/+$/,\\\"\\\"));let n=e.apiRoute??\\\"/api\\\";l(this,qe,n.startsWith(\\\"/\\\")?n:`/${n}`),l(this,Ke,e.depth??1),l(this,Je,e.fetchFn),l(this,ye,e.log??gi)}canMerge(e){if(e.globalSlug!==void 0&&e.globalSlug!==\\\"\\\")return!0;if(e.collectionSlug===void 0||e.collectionSlug===\\\"\\\")return!1;let n=e.data.id;return typeof n==\\\"string\\\"||typeof n==\\\"number\\\"}async merge(e){if(!this.canMerge(e))return{status:\\\"unavailable\\\"};let n=i(this,Je)??(typeof fetch==\\\"function\\\"?fetch:void 0);if(n===void 0)return{status:\\\"unavailable\\\"};i(this,q)?.abort();let r=new AbortController;l(this,q,r);let o=e.globalSlug!==void 0&&e.globalSlug!==\\\"\\\"?`globals/${e.globalSlug}`:`${e.collectionSlug}/${String(e.data.id)}`,s=`${i(this,Ye)}${i(this,qe)}/${encodeURI(o)}`;try{let a=await n(s,{method:\\\"POST\\\",credentials:\\\"include\\\",headers:{\\\"Content-Type\\\":\\\"application/json\\\",\\\"X-Payload-HTTP-Method-Override\\\":\\\"GET\\\"},body:JSON.stringify({data:e.data,depth:i(this,Ke),flattenLocales:!1,...e.locale!==void 0?{locale:e.locale}:{}}),signal:r.signal});if(!a.ok)return i(this,ye).call(this,\\\"merge fetch failed\\\",a.status,s),{status:\\\"unavailable\\\"};let u=await a.json();return u===null||typeof u!=\\\"object\\\"||Array.isArray(u)?(i(this,ye).call(this,\\\"merge fetch returned non-object\\\",s),{status:\\\"unavailable\\\"}):{status:\\\"merged\\\",doc:u}}catch(a){return r.signal.aborted?{status:\\\"superseded\\\"}:(i(this,ye).call(this,\\\"merge fetch error\\\",a),{status:\\\"unavailable\\\"})}finally{i(this,q)===r&&l(this,q,null)}}destroy(){i(this,q)?.abort(),l(this,q,null)}};Ye=new WeakMap,qe=new WeakMap,Ke=new WeakMap,Je=new WeakMap,ye=new WeakMap,q=new WeakMap;var bi=new Set([\\\"http:\\\",\\\"https:\\\",\\\"mailto:\\\",\\\"tel:\\\"]),Ri=/^\\\\s*(?:javascript|data|vbscript|file|blob|about)\\\\s*:/i,Ti=/^(?:\\\\.{1,2}\\\\/|[a-zA-Z0-9_-]+\\\\/?)/;function b(t){if(typeof t!=\\\"string\\\"||t.length===0)return!1;let e=t.trim();if(e.length===0||Ri.test(e))return!1;if(e.startsWith(\\\"#\\\")||e.startsWith(\\\"?\\\")||e.startsWith(\\\"//\\\")||e.startsWith(\\\"/\\\"))return!0;try{let n=new URL(e);return bi.has(n.protocol)}catch{return Ti.test(e)}}function Lt(t){if(!b(t))return!1;let e=t.trim();return/^https?:\\\\/\\\\//i.test(e)||/^\\\\/\\\\/[^/]/.test(e)}var wi=new Set([\\\"style\\\",\\\"srcdoc\\\",\\\"formaction\\\",\\\"form\\\",\\\"id\\\",\\\"name\\\",\\\"is\\\",\\\"srcset\\\",\\\"imagesrcset\\\"]),xi=new Set([\\\"href\\\",\\\"src\\\",\\\"poster\\\",\\\"cite\\\",\\\"action\\\",\\\"xlink:href\\\",\\\"data\\\"]);function qn(t,e,n){let r=e.toLowerCase().trim();if(r.length===0||r.startsWith(\\\"on\\\")||wi.has(r))return\\\"blocked\\\";if(n==null)return t.removeAttribute(r),\\\"applied\\\";if(typeof n!=\\\"string\\\"&&typeof n!=\\\"number\\\"&&typeof n!=\\\"boolean\\\")return\\\"blocked\\\";let o=String(n);return xi.has(r)&&!b(o)?\\\"blocked\\\":(t.setAttribute(r,o),\\\"applied\\\")}var Le,Xe,Ze,Qe,et,tt,nt,rt,Me,$,K,k,U,J,Kn,Jn,Vt,Mt=class{constructor(e,n){d(this,J);d(this,Le);d(this,Xe);d(this,Ze);d(this,Qe);d(this,et);d(this,tt);d(this,nt);d(this,rt);d(this,Me);d(this,$,new Map);d(this,K,new Map);d(this,k,null);d(this,U,null);l(this,Le,e),l(this,Xe,n.debounceMs??50),l(this,Ze,n.isVisible),l(this,Qe,n.visibilityGateThreshold??50),l(this,et,n.disableVisibilityGate??!1),l(this,tt,n.getCacheSize),l(this,nt,n.onFlush),l(this,rt,n.scheduleFrame??(typeof requestAnimationFrame==\\\"function\\\"?requestAnimationFrame.bind(globalThis):r=>setTimeout(()=>{r(performance.now())},0))),l(this,Me,n.cancelFrame??(typeof cancelAnimationFrame==\\\"function\\\"?cancelAnimationFrame.bind(globalThis):r=>{clearTimeout(r)}))}schedule(e){let n=i(this,$).get(e.target.element);n?(n.value=e.value,n.allFields=e.allFields):i(this,$).set(e.target.element,{target:e.target,value:e.value,allFields:e.allFields}),f(this,J,Kn).call(this)}flushNow(){return i(this,k)!==null&&(clearTimeout(i(this,k)),l(this,k,null)),f(this,J,Vt).call(this)}notifyVisible(e){let n=i(this,K).get(e);n&&(i(this,K).delete(e),i(this,Le).call(this,n))}forget(e){i(this,$).delete(e),i(this,K).delete(e)}destroy(){i(this,k)!==null&&(clearTimeout(i(this,k)),l(this,k,null)),i(this,U)!==null&&(i(this,Me).call(this,i(this,U)),l(this,U,null)),i(this,$).clear(),i(this,K).clear()}get pendingCount(){return i(this,$).size}get replayCount(){return i(this,K).size}};Le=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,rt=new WeakMap,Me=new WeakMap,$=new WeakMap,K=new WeakMap,k=new WeakMap,U=new WeakMap,J=new WeakSet,Kn=function(){i(this,k)!==null&&clearTimeout(i(this,k)),l(this,k,setTimeout(()=>{l(this,k,null),f(this,J,Jn).call(this)},i(this,Xe)))},Jn=function(){i(this,U)!==null&&i(this,Me).call(this,i(this,U)),l(this,U,i(this,rt).call(this,()=>{l(this,U,null),f(this,J,Vt).call(this)}))},Vt=function(){var u;let e=performance.now(),n=!i(this,et)&&i(this,tt).call(this)>i(this,Qe),r=i(this,$);l(this,$,new Map);let o=0,s=0;for(let m of r.values()){if(n&&!i(this,Ze).call(this,m.target.element)){i(this,K).set(m.target.element,m),s+=1;continue}i(this,Le).call(this,m),o+=1}let a={applied:o,deferred:s,durationMs:performance.now()-e};return(u=i(this,nt))==null||u.call(this,a),a};function Ie(){let t=vi();if(t!==void 0)return t;let e=Si();return e!==void 0?e:\\\"en\\\"}function vi(){if(typeof document>\\\"u\\\")return;let t=document.documentElement.getAttribute(\\\"lang\\\");return t===null||t.length===0?void 0:t}function Si(){if(typeof navigator>\\\"u\\\")return;let t=navigator.language;return typeof t==\\\"string\\\"&&t.length>0?t:void 0}var Xn=\\\"payload-live-preview-a11y\\\",Ei=1500,ki=[\\\"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\\\"].join(\\\";\\\"),Zn={connected:\\\"Live preview connected\\\",disconnected:\\\"Live preview disconnected\\\",updated:t=>`${String(t)} ${t===1?\\\"change\\\":\\\"changes\\\"} applied`},Ai={en:Zn,de:{connected:\\\"Vorschau verbunden\\\",disconnected:\\\"Vorschau getrennt\\\",updated:t=>`${String(t)} ${t===1?\\\"\\\\xC4nderung\\\":\\\"\\\\xC4nderungen\\\"} angewendet`}};function Li(t){let e=t.split(/[-_]/)[0]?.toLowerCase()??\\\"en\\\";return Ai[e]??Zn}var I,ge,H,oe,Qn,It,it=class{constructor(e=Ie()){d(this,oe);d(this,I,null);d(this,ge);d(this,H,null);l(this,ge,Li(e))}announceConnected(){f(this,oe,It).call(this,i(this,ge).connected)}announceDisconnected(){f(this,oe,It).call(this,i(this,ge).disconnected)}announceUpdate(e){e<=0||f(this,oe,It).call(this,i(this,ge).updated(e))}detach(){i(this,H)!==null&&(clearTimeout(i(this,H)),l(this,H,null)),i(this,I)?.parentNode&&i(this,I).parentNode.removeChild(i(this,I))}};I=new WeakMap,ge=new WeakMap,H=new WeakMap,oe=new WeakSet,Qn=function(){if(i(this,I)!==null&&i(this,I).isConnected)return i(this,I);if(typeof document>\\\"u\\\"||document.body===null)return null;let e=document.getElementById(Xn);return e||(e=document.createElement(\\\"div\\\"),e.id=Xn,e.setAttribute(\\\"role\\\",\\\"status\\\"),e.setAttribute(\\\"aria-live\\\",\\\"polite\\\"),e.setAttribute(\\\"aria-atomic\\\",\\\"true\\\"),e.setAttribute(\\\"style\\\",ki),document.body.appendChild(e)),l(this,I,e),e},It=function(e){let n=f(this,oe,Qn).call(this);n&&(n.textContent=e,i(this,H)!==null&&clearTimeout(i(this,H)),l(this,H,setTimeout(()=>{l(this,H,null),i(this,I)&&(i(this,I).textContent=\\\"\\\")},Ei)))};var Mi=new Set([\\\"tabs\\\",\\\"row\\\",\\\"collapsible\\\"]);function zt(t,e=\\\"\\\"){let n=new Map;return ot(t,e,n),n}function ot(t,e,n){for(let r of t){if(Mi.has(r.type)){r.fields&&ot(r.fields,e,n);continue}if(r.type===\\\"group\\\"){let s=e===\\\"\\\"?r.name:`${e}.${r.name}`;n.set(s,r),r.fields&&ot(r.fields,s,n);continue}let o=e===\\\"\\\"?r.name:`${e}.${r.name}`;if(n.set(o,r),r.type===\\\"array\\\"&&r.fields)ot(r.fields,`${o}.*`,n);else if(r.type===\\\"blocks\\\"&&r.blocks)for(let s of r.blocks)ot(s.fields,`${o}.*.${s.slug}`,n)}}function Gt(t,e){if(t.has(e))return t.get(e);let n=e.replace(/\\\\.\\\\d+(?=\\\\.|$)/g,\\\".*\\\");if(t.has(n))return t.get(n)}function Wt(t){if(typeof t!=\\\"object\\\"||t===null)return;let e=t.id;if(typeof e==\\\"string\\\"||typeof e==\\\"number\\\")return e}function er(t){if(typeof t!=\\\"object\\\"||t===null)return;let e=t.blockType;return typeof e==\\\"string\\\"?e:void 0}function st(t,e){return e.every(r=>Wt(r)!==void 0)?Ii(t,e):Ni(t,e)}function Ii(t,e){let n=[],r=new Map;for(let s=0;s<t.length;s+=1){let a=Wt(t[s]);a!==void 0&&r.set(a,s)}let o=new Set;for(let s=0;s<e.length;s+=1){let a=e[s],u=Wt(a);if(u===void 0){n.push({kind:\\\"insert\\\",index:s,value:a});continue}let m=r.get(u);if(m===void 0){n.push({kind:\\\"insert\\\",index:s,value:a});continue}o.add(m);let T=t[m];if(er(T)!==er(a)){n.push({kind:\\\"replace\\\",index:s,oldValue:T,value:a});continue}m!==s&&n.push({kind:\\\"move\\\",from:m,to:s,value:a}),tr(T,a)||n.push({kind:\\\"update\\\",index:s,value:a})}for(let s=0;s<t.length;s+=1)o.has(s)||n.push({kind:\\\"remove\\\",index:s,value:t[s]});return n}function Ni(t,e){let n=[],r=Math.min(t.length,e.length);for(let o=0;o<r;o+=1)tr(t[o],e[o])||n.push({kind:\\\"update\\\",index:o,value:e[o]});if(e.length>t.length)for(let o=t.length;o<e.length;o+=1)n.push({kind:\\\"insert\\\",index:o,value:e[o]});if(t.length>e.length)for(let o=e.length;o<t.length;o+=1)n.push({kind:\\\"remove\\\",index:o,value:t[o]});return n}function tr(t,e){if(Object.is(t,e))return!0;if(typeof t!=\\\"object\\\"||typeof e!=\\\"object\\\"||t===null||e===null)return!1;let n=t,r=e,o=Object.keys(n),s=Object.keys(r);if(o.length!==s.length)return!1;for(let a of o)if(!Object.is(n[a],r[a]))return!1;return!0}var nr={text:\\\"text\\\",textarea:\\\"textarea\\\",richText:\\\"richText\\\",email:\\\"email\\\",number:\\\"number\\\",checkbox:\\\"checkbox\\\",date:\\\"date\\\",select:\\\"select\\\",radio:\\\"radio\\\",array:\\\"array\\\",blocks:\\\"blocks\\\",group:\\\"text\\\",tabs:\\\"text\\\",row:\\\"text\\\",collapsible:\\\"text\\\",relationship:\\\"relationship\\\",upload:\\\"upload\\\",point:\\\"text\\\",json:\\\"text\\\",code:\\\"text\\\",ui:\\\"text\\\"};function Yt(t){if(Object.prototype.hasOwnProperty.call(nr,t))return nr[t]}var _i=[0,500,1e3,2e3],S,A,X,se,Ne,Z,_e,at,B,be,Re,lt,O,Ce,Oe,Q,Te,N,Pe,Fe,De,we,ae,dt,ut,h,qt,Kt,Jt,ir,or,sr,ar,lr,dr,ur,cr,fr,pr,mr,Nt=class{constructor(e){d(this,h);d(this,S);d(this,A);d(this,X);d(this,se);d(this,Ne);d(this,Z);d(this,_e);d(this,at);d(this,B);d(this,be);d(this,Re);d(this,lt);d(this,O);d(this,Ce);d(this,Oe,[]);d(this,Q);d(this,Te);d(this,N);d(this,Pe);d(this,Fe);d(this,De,jt(void 0));d(this,we,!1);d(this,ae,null);d(this,dt,0);d(this,ut,new Set);l(this,S,e.emitter),l(this,at,e.renderers),l(this,B,e.root??(typeof document<\\\"u\\\"?document:null)),l(this,be,e.readyTargets),l(this,Re,e.sendReady??Di),l(this,lt,e.onHeartbeatTimeout),l(this,O,e.log??Oi),l(this,Ce,e.warn??Fi),l(this,Q,Ci(e)),l(this,Te,e.dataMerge!==void 0?new At({serverURL:e.dataMerge.serverURL,...e.dataMerge.apiRoute!==void 0?{apiRoute:e.dataMerge.apiRoute}:{},...e.dataMerge.depth!==void 0?{depth:e.dataMerge.depth}:{},...e.dataMerge.fetchFn!==void 0?{fetchFn:e.dataMerge.fetchFn}:{},log:(...n)=>{i(this,O).call(this,...n)}}):null),l(this,A,new xt),l(this,X,new vt({onStructuralChange:()=>{f(this,h,Jt).call(this)},onVisibilityChange:(n,r)=>{r&&i(this,se).notifyVisible(n)}},{...e.intersectionRootMargin!==void 0?{intersectionRootMargin:e.intersectionRootMargin}:{}})),l(this,se,new Mt(n=>{f(this,h,cr).call(this,n)},{...e.debounceMs!==void 0?{debounceMs:e.debounceMs}:{},...e.disableVisibilityGate!==void 0?{disableVisibilityGate:e.disableVisibilityGate}:{},...e.visibilityGateThreshold!==void 0?{visibilityGateThreshold:e.visibilityGateThreshold}:{},isVisible:n=>i(this,X).isVisible(n),getCacheSize:()=>i(this,A).elementCount,onFlush:n=>{f(this,h,pr).call(this,n)}})),l(this,Ne,new Be(e.originMatcher,{onUpdate:(n,r)=>{f(this,h,sr).call(this,n,r)},onDocumentEvent:(n,r)=>{f(this,h,lr).call(this,n,r)},onInvalid:(n,r)=>{if(n===\\\"token\\\"){let o=new Error(`Preview token rejected (origin: ${r})`);i(this,S).emit(\\\"error\\\",{error:o,context:\\\"token\\\"})}i(this,O).call(this,\\\"message rejected:\\\",n,r)},...e.validateToken!==void 0?{validateToken:e.validateToken}:{}})),l(this,Z,new kt((n,r)=>{i(this,O).call(this,\\\"connection\\\",r,\\\"\\\\u2192\\\",n)})),l(this,_e,new Et({...e.heartbeatMs!==void 0?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{f(this,h,mr).call(this)}}))}start(){if(i(this,we))return!1;l(this,we,!0);let e=i(this,B);if(e instanceof Document&&e.readyState===\\\"loading\\\"){let n=()=>{l(this,ae,null),f(this,h,qt).call(this)};return l(this,ae,n),e.addEventListener(\\\"DOMContentLoaded\\\",n,{once:!0}),!0}return f(this,h,qt).call(this),!0}destroy(){if(!i(this,we))return;if(l(this,we,!1),i(this,ae)!==null){let n=i(this,B);n instanceof Document&&n.removeEventListener(\\\"DOMContentLoaded\\\",i(this,ae)),l(this,ae,null),i(this,S).emit(\\\"destroy\\\",{timestamp:Date.now()});return}for(let n of i(this,Oe))clearTimeout(n);i(this,Oe).length=0,i(this,_e).stop(),i(this,Ne).detach(),i(this,X).stop(),i(this,se).destroy(),i(this,Te)?.destroy(),i(this,A).clear();let e=i(this,Z).status===\\\"connected\\\";i(this,Z).markDisconnected(),e&&(i(this,Q)?.announceDisconnected(),i(this,S).emit(\\\"disconnect\\\",{reason:\\\"destroy\\\",timestamp:Date.now()})),i(this,Q)?.detach(),i(this,S).emit(\\\"destroy\\\",{timestamp:Date.now()})}refreshCache(){f(this,h,Jt).call(this)}get status(){return i(this,Z).status}get cache(){return i(this,A)}get updateCount(){return i(this,dt)}get protocol(){return i(this,De)}};S=new WeakMap,A=new WeakMap,X=new WeakMap,se=new WeakMap,Ne=new WeakMap,Z=new WeakMap,_e=new WeakMap,at=new WeakMap,B=new WeakMap,be=new WeakMap,Re=new WeakMap,lt=new WeakMap,O=new WeakMap,Ce=new WeakMap,Oe=new WeakMap,Q=new WeakMap,Te=new WeakMap,N=new WeakMap,Pe=new WeakMap,Fe=new WeakMap,De=new WeakMap,we=new WeakMap,ae=new WeakMap,dt=new WeakMap,ut=new WeakMap,h=new WeakSet,qt=function(){f(this,h,Kt).call(this),i(this,X).start(i(this,B)instanceof Document?i(this,B).body:i(this,B)),i(this,Ne).attach(),f(this,h,ir).call(this);for(let e of _i)if(e===0)i(this,Re).call(this,i(this,be));else{let n=setTimeout(()=>{i(this,Re).call(this,i(this,be))},e);i(this,Oe).push(n)}},Kt=function(){let e=i(this,A).buildFromRoot(i(this,B));i(this,O).call(this,\\\"cache built\\\",e),i(this,S).emit(\\\"cacheRefresh\\\",e);for(let n of i(this,A).values())i(this,X).observeElement(n.element)},Jt=function(){for(let e of i(this,A).values())i(this,X).unobserveElement(e.element),i(this,se).forget(e.element);f(this,h,Kt).call(this)},ir=function(){i(this,S).emit(\\\"init\\\",{timestamp:Date.now()})},or=function(e){let n=jt(e);n.negotiated!==i(this,De).negotiated&&(l(this,De,n),i(this,O).call(this,\\\"protocol negotiated\\\",`ours=${4}`,`theirs=${e}`,`negotiated=${n.negotiated}`))},sr=function(e,n){i(this,_e).kick(),e.protocolVersion!==void 0&&f(this,h,or).call(this,e.protocolVersion),e.data!==void 0&&(i(this,Z).markConnected()&&(i(this,Q)?.announceConnected(),i(this,S).emit(\\\"connect\\\",{origin:n,timestamp:Date.now()})),l(this,dt,i(this,dt)+1),e.locale!==void 0&&l(this,N,e.locale),e.fieldSchemaJSON!==void 0&&(l(this,Pe,e.fieldSchemaJSON),l(this,Fe,zt(e.fieldSchemaJSON))),f(this,h,ar).call(this,e).then(r=>{if(r===null)return;let o={fields:r,...i(this,Pe)!==void 0?{schema:i(this,Pe)}:{},...e.globalSlug!==void 0?{globalSlug:e.globalSlug}:{},...e.collectionSlug!==void 0?{collectionSlug:e.collectionSlug}:{},...i(this,N)!==void 0?{locale:i(this,N)}:{}},s=!1;i(this,S).emit(\\\"beforeUpdate\\\",{data:o,cancel:()=>{s=!0}}).then(()=>{s||f(this,h,dr).call(this,o)})}))},ar=async function(e){let n=e.data??{};if(i(this,Te)===null)return n;let r=await i(this,Te).merge({collectionSlug:e.collectionSlug,globalSlug:e.globalSlug,data:n,locale:i(this,N)});return r.status===\\\"merged\\\"?r.doc:r.status===\\\"superseded\\\"?null:n},lr=function(e,n){i(this,S).emit(\\\"documentSave\\\",{timestamp:Date.now()})},dr=function(e){for(let[n,r]of i(this,A).entries()){let o=Bi(e.fields,n,i(this,N));if(o!==void 0)for(let s of r){let a={target:s,value:o,allFields:e.fields};i(this,se).schedule(a)}}f(this,h,ur).call(this,e.fields)},ur=function(e){if(i(this,A).elementCount===0)return;let n=new Set;for(let[r]of i(this,A).entries())n.add(r);for(let[r,o]of Object.entries(e)){if(i(this,ut).has(r)||$i.has(r)||!Ui(o))continue;let s=Hi(r,i(this,N));n.has(r)||n.has(s)||(i(this,ut).add(r),i(this,Ce).call(this,`[live-preview] update arrived for field \\\"${r}\\\" but no <\\\\u2026 data-payload-field=\\\"${s}\\\"> 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.`))}},cr=function(e){let n=i(this,Fe)!==void 0?Gt(i(this,Fe),e.target.fieldName):void 0,r=f(this,h,fr).call(this,e.target,n?.type);r===\\\"text\\\"&&e.target.explicitFieldType!==!0&&Pi(e.value)&&(r=\\\"richText\\\");let o=i(this,at)[r],s=ji(e.target.element),a={allFields:e.allFields,locale:i(this,N),schema:n};try{e.target.targetAttribute!==void 0?qn(e.target.element,e.target.targetAttribute,e.value)===\\\"blocked\\\"&&i(this,Ce).call(this,`[live-preview] refused to write field \\\"${e.target.fieldName}\\\" into attribute \\\"${e.target.targetAttribute}\\\" (unsafe attribute or value)`):o?o.render(e.target,e.value,a):i(this,O).call(this,\\\"no renderer for\\\",r)}catch(u){let m=u instanceof Error?u:new Error(String(u));i(this,S).emit(\\\"error\\\",{error:m,context:\\\"renderer\\\"});return}i(this,S).emit(\\\"elementUpdate\\\",{element:e.target.element,fieldName:e.target.fieldName,previousValue:s,nextValue:e.value})},fr=function(e,n){if(e.explicitFieldType)return e.fieldType;if(n!==void 0){let r=Yt(n);if(r!==void 0)return r}return e.fieldType},pr=function(e){e.applied===0&&e.deferred===0||(e.applied>0&&i(this,Q)?.announceUpdate(e.applied),i(this,S).emit(\\\"afterUpdate\\\",{data:{fields:{},...i(this,N)!==void 0?{locale:i(this,N)}:{}},updatedCount:e.applied,durationMs:e.durationMs}))},mr=function(){var e;i(this,Z).markDisconnected()&&(i(this,Q)?.announceDisconnected(),i(this,S).emit(\\\"disconnect\\\",{reason:\\\"timeout\\\",timestamp:Date.now()}));try{(e=i(this,lt))==null||e.call(this)}catch(n){i(this,O).call(this,\\\"onHeartbeatTimeout hook threw:\\\",n)}i(this,Re).call(this,i(this,be))};function Ci(t){return t.enableA11y===!1?null:t.a11yLocale!==void 0?new it(t.a11yLocale):new it}function Oi(){}function Pi(t){if(typeof t!=\\\"object\\\"||t===null||!(\\\"root\\\"in t))return!1;let e=t.root;return typeof e!=\\\"object\\\"||e===null?!1:Array.isArray(e.children)}function Fi(...t){typeof console<\\\"u\\\"&&typeof console.warn==\\\"function\\\"&&console.warn(...t)}function Di(t){if(typeof window>\\\"u\\\")return;let e=[];window.parent!==window&&e.push(window.parent),window.opener instanceof Window&&e.push(window.opener),Be.sendReady(e,t)}var hr=new Set([\\\"__proto__\\\",\\\"prototype\\\",\\\"constructor\\\"]),$i=new Set([\\\"id\\\",\\\"_id\\\",\\\"createdAt\\\",\\\"updatedAt\\\",\\\"createdBy\\\",\\\"updatedBy\\\",\\\"_status\\\",\\\"globalType\\\",\\\"collection\\\",\\\"locale\\\",\\\"localized\\\"]);function Ui(t){return t==null?!1:typeof t==\\\"string\\\"||typeof t==\\\"number\\\"||typeof t==\\\"boolean\\\"||typeof t==\\\"bigint\\\"}function Hi(t,e){if(!e)return t;let n=`_${e}`;return t.endsWith(n)?t.slice(0,-n.length):t}function Bi(t,e,n){let r=rr(t,e);if(r!==void 0)return r;if(e.includes(\\\".\\\")){let o=e.split(\\\".\\\"),s=t;for(let a of o){if(hr.has(a)||s===null||typeof s!=\\\"object\\\")return;s=s[a]}if(s!==void 0)return s}if(n!==void 0){let o=rr(t,`${e}_${n}`);if(o!==void 0)return o}}function rr(t,e){if(!hr.has(e)&&Object.prototype.hasOwnProperty.call(t,e))return t[e]}function ji(t){return t.tagName===\\\"INPUT\\\"||t.tagName===\\\"TEXTAREA\\\"?t.value:t.tagName===\\\"IMG\\\"?t.src:t.textContent}function ct(){if(typeof window>\\\"u\\\")return!1;try{return window.self!==window.top}catch{return!0}}function Xt(){return typeof window>\\\"u\\\"?!1:window.opener!=null}function Zt(){return ct()||Xt()}function yr(){let t=Vi();if(t!==void 0)return t!==\\\"production\\\";let e=zi();if(e!==void 0)return e;if(typeof window<\\\"u\\\"){let n=window.location.hostname;if(n===\\\"localhost\\\"||n===\\\"127.0.0.1\\\")return!0}return!1}function gr(t){if(typeof process<\\\"u\\\"){let n=process.env[t];if(typeof n==\\\"string\\\"&&n.length>0)return n}let e=void 0;if(e){let n=e[t];if(typeof n==\\\"string\\\"&&n.length>0)return n}}function Vi(){if(typeof process>\\\"u\\\")return;let t=\\\"production\\\";return typeof t==\\\"string\\\"?t:void 0}function zi(){let t=void 0;if(!t)return;let e=t.DEV;return typeof e==\\\"boolean\\\"?e:void 0}var Gi=/^https?:\\\\/\\\\/(localhost|127\\\\.0\\\\.0\\\\.1)(?::\\\\d+)?$/i,Wi=/^https?:\\\\/\\\\/[^/?#\\\\s]+$/i,Yi=[\\\"PAYLOAD_ADMIN_ORIGIN\\\",\\\"PUBLIC_PAYLOAD_ADMIN_ORIGIN\\\",\\\"NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN\\\"],j,V,le,ft,P,_t=class{constructor(e={}){d(this,j);d(this,V);d(this,le);d(this,ft);d(this,P);let n=new Set;for(let a of e.additionalOrigins??[]){let u=br(a);u!==void 0&&n.add(u)}for(let a of Yi){let u=gr(a);if(u!==void 0)for(let m of u.split(\\\",\\\")){let T=br(m);T!==void 0&&n.add(T)}}l(this,j,n);let r=e.enableReferrerDetection??!0,o;if(r){let a=e.referrer??(typeof document<\\\"u\\\"?document.referrer:\\\"\\\");if(a.length>0)try{let u=new URL(a).origin;u&&u!==\\\"null\\\"&&(o=u)}catch{}}l(this,V,o),l(this,ft,o!==void 0);let s=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??yr());l(this,le,s)}matches(e){return e.length===0||e===\\\"null\\\"?!1:i(this,P)!==void 0?e===i(this,P):!!(i(this,j).has(e)||i(this,j).size===0&&i(this,V)!==void 0&&e===i(this,V)||i(this,le)&&Gi.test(e))}lockOrigin(e){return this.matches(e)?(l(this,P,e),!0):!1}unlockOrigin(){let e=i(this,P);return l(this,P,void 0),e}get lockedOrigin(){return i(this,P)}enumerate(){if(i(this,P)!==void 0)return[i(this,P)];let e=new Set(i(this,j));if(i(this,j).size===0&&i(this,V)!==void 0&&e.add(i(this,V)),i(this,le))for(let n of qi)e.add(`http://localhost:${String(n)}`),e.add(`http://127.0.0.1:${String(n)}`);return[...e]}get referrerWasAvailable(){return i(this,ft)}get isProductionUnconfigured(){return!(!ct()||i(this,j).size>0||i(this,le)||i(this,V)!==void 0)}get isReferrerOnlyTrust(){return i(this,j).size>0||i(this,le)?!1:i(this,V)!==void 0}};j=new WeakMap,V=new WeakMap,le=new WeakMap,ft=new WeakMap,P=new WeakMap;var qi=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function br(t){let e=t.trim();if(e.length!==0)try{let n=new URL(e);return n.protocol!==\\\"http:\\\"&&n.protocol!==\\\"https:\\\"||!Wi.test(n.origin)?void 0:n.origin}catch{return}}var Rr={name:\\\"payload-live-preview\\\",version:\\\"1.0.3\\\",description:\\\"Live preview for Payload CMS in Astro and any SSR/static frontend (SvelteKit, Nuxt, Next.js, plain HTML). Patches the DOM live, no rebuild.\\\",author:\\\"relative23\\\",license:\\\"MIT\\\",type:\\\"module\\\",main:\\\"./dist/index.cjs\\\",module:\\\"./dist/index.js\\\",types:\\\"./dist/index.d.ts\\\",exports:{\\\".\\\":{import:{types:\\\"./dist/index.d.ts\\\",default:\\\"./dist/index.js\\\"},require:{types:\\\"./dist/index.d.cts\\\",default:\\\"./dist/index.cjs\\\"}},\\\"./core\\\":{import:{types:\\\"./dist/core.d.ts\\\",default:\\\"./dist/core.js\\\"},require:{types:\\\"./dist/core.d.cts\\\",default:\\\"./dist/core.cjs\\\"}},\\\"./astro\\\":{import:{types:\\\"./dist/adapters/astro/index.d.ts\\\",default:\\\"./dist/adapters/astro/index.js\\\"}},\\\"./nextjs\\\":{import:{types:\\\"./dist/adapters/nextjs/index.d.ts\\\",default:\\\"./dist/adapters/nextjs/index.js\\\"}},\\\"./sveltekit\\\":{import:{types:\\\"./dist/adapters/sveltekit/index.d.ts\\\",default:\\\"./dist/adapters/sveltekit/index.js\\\"}},\\\"./nuxt\\\":{import:{types:\\\"./dist/adapters/nuxt/index.d.ts\\\",default:\\\"./dist/adapters/nuxt/index.js\\\"}},\\\"./codegen\\\":{import:{types:\\\"./dist/codegen.d.ts\\\",default:\\\"./dist/codegen.js\\\"},require:{types:\\\"./dist/codegen.d.cts\\\",default:\\\"./dist/codegen.cjs\\\"}},\\\"./codegen/astro\\\":{import:{types:\\\"./dist/codegen-astro.d.ts\\\",default:\\\"./dist/codegen-astro.js\\\"}},\\\"./payload\\\":{import:{types:\\\"./dist/payload.d.ts\\\",default:\\\"./dist/payload.js\\\"},require:{types:\\\"./dist/payload.d.cts\\\",default:\\\"./dist/payload.cjs\\\"}},\\\"./astro/RichText.astro\\\":\\\"./dist/adapters/astro/RichText.astro\\\",\\\"./astro/middleware-entry\\\":{import:{types:\\\"./dist/adapters/astro/middleware-entry.d.ts\\\",default:\\\"./dist/adapters/astro/middleware-entry.js\\\"}}},bin:{\\\"pll-codegen\\\":\\\"./dist/codegen-cli.js\\\"},files:[\\\"dist\\\",\\\"README.md\\\",\\\"LICENSE\\\"],sideEffects:!1,scripts:{prepare:\\\"npm run build:runtime\\\",\\\"build:runtime\\\":\\\"tsx scripts/build-runtime.ts\\\",build:\\\"npm run build:runtime && tsup && npm run build:assets\\\",\\\"build:assets\\\":`node -e \\\"require('node:fs').copyFileSync('src/adapters/astro/RichText.astro','dist/adapters/astro/RichText.astro')\\\"`,dev:\\\"tsup --watch\\\",test:\\\"vitest run\\\",\\\"test:watch\\\":\\\"vitest\\\",\\\"test:unit\\\":\\\"vitest run tests/unit\\\",\\\"test:integration\\\":\\\"vitest run tests/integration\\\",\\\"test:e2e\\\":\\\"playwright test\\\",\\\"test:bench\\\":\\\"vitest bench tests/benchmarks\\\",\\\"test:coverage\\\":\\\"vitest run --coverage\\\",typecheck:\\\"tsc --noEmit\\\",lint:\\\"eslint .\\\",\\\"lint:fix\\\":\\\"eslint . --fix\\\",format:'prettier --write \\\"src/**/*.ts\\\" \\\"tests/**/*.ts\\\"',\\\"format:check\\\":'prettier --check \\\"src/**/*.ts\\\" \\\"tests/**/*.ts\\\"',check:\\\"npm run typecheck && npm run lint && npm run test\\\",prepublishOnly:\\\"npm run check && npm run build\\\",changeset:\\\"changeset\\\",version:\\\"changeset version\\\",release:\\\"npm run build && changeset publish\\\"},devDependencies:{\\\"@changesets/cli\\\":\\\"^2.31.0\\\",\\\"@eslint/js\\\":\\\"^10.0.1\\\",\\\"@playwright/test\\\":\\\"^1.61.1\\\",\\\"@types/node\\\":\\\"^22.20.1\\\",\\\"@vitest/coverage-v8\\\":\\\"^4.1.10\\\",esbuild:\\\"^0.28.1\\\",eslint:\\\"^10.7.0\\\",globals:\\\"^17.7.0\\\",jsdom:\\\"^29.1.1\\\",prettier:\\\"^3.9.5\\\",\\\"ts-morph\\\":\\\"^28.0.0\\\",tsup:\\\"^8.5.1\\\",tsx:\\\"^4.23.0\\\",typescript:\\\"^5.9.3\\\",\\\"typescript-eslint\\\":\\\"^8.63.0\\\",vitest:\\\"^4.1.10\\\"},keywords:[\\\"astro\\\",\\\"astro-payload\\\",\\\"astro-cms\\\",\\\"astro-integration\\\",\\\"astro-live-preview\\\",\\\"payload\\\",\\\"payload-cms\\\",\\\"payload-live-preview\\\",\\\"payload-plugin\\\",\\\"live-preview\\\",\\\"preview\\\",\\\"cms\\\",\\\"headless\\\",\\\"headless-cms\\\",\\\"lexical\\\",\\\"sveltekit\\\",\\\"nuxt\\\",\\\"nextjs\\\",\\\"ssr\\\",\\\"framework-agnostic\\\"],peerDependencies:{astro:\\\">=4.0.0 <8.0.0\\\",\\\"ts-morph\\\":\\\"^28.0.0\\\"},peerDependenciesMeta:{astro:{optional:!0},\\\"ts-morph\\\":{optional:!0}},engines:{node:\\\">=20.19.0\\\"},publishConfig:{access:\\\"public\\\",provenance:!0},repository:{type:\\\"git\\\",url:\\\"https://github.com/relative23/payload-live-preview.git\\\"},bugs:{url:\\\"https://github.com/relative23/payload-live-preview/issues\\\"},homepage:\\\"https://github.com/relative23/payload-live-preview#readme\\\"};var Tr=Rr.version;var Qt=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\\\"]),xr=new Set([\\\"script\\\",\\\"style\\\",\\\"iframe\\\",\\\"object\\\",\\\"embed\\\",\\\"link\\\",\\\"meta\\\",\\\"base\\\",\\\"form\\\",\\\"input\\\",\\\"button\\\",\\\"select\\\",\\\"textarea\\\",\\\"svg\\\",\\\"math\\\",\\\"template\\\",\\\"frame\\\",\\\"frameset\\\",\\\"noframes\\\",\\\"noscript\\\"]),vr=new Set([\\\"id\\\",\\\"class\\\",\\\"lang\\\",\\\"dir\\\",\\\"title\\\",\\\"role\\\",\\\"tabindex\\\"]),Ji=\\\"aria-\\\",Xi=\\\"data-\\\",en={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\\\"])},Sr=new Set([\\\"href\\\",\\\"src\\\",\\\"cite\\\",\\\"poster\\\"]),tn=class extends Error{constructor(){super(...arguments);Un(this,\\\"name\\\",\\\"SanitizerEnvironmentError\\\")}};function Zi(t){if(!t){let r=new Map;for(let[o,s]of Object.entries(en))r.set(o,s);return{allowedTags:Qt,attrByTag:r}}let e=new Set(Qt);for(let r of t.additionalAllowedTags??[])e.add(r);let n=new Map;for(let[r,o]of Object.entries(en))n.set(r,o);for(let[r,o]of Object.entries(t.additionalAllowedAttributes??{})){let s=n.get(r),a=new Set(s??[]);for(let u of o)a.add(u);n.set(r,a)}return{allowedTags:e,attrByTag:n}}var wr;function z(t,e){let n=Er();if(!n)throw new tn(\\\"sanitizeHtml requires a DOM. Inject one via setSanitizerDocument() for SSR (linkedom, jsdom, happy-dom, \\\\u2026) or use the plain-text path on the server.\\\");if(t===\\\"\\\")return\\\"\\\";let r=Zi(e),o=n.createElement(\\\"template\\\");return o.innerHTML=t,nn(o.content,r),o.innerHTML}function Er(){if(wr)return wr;if(!(typeof document>\\\"u\\\"))return document}function kr(){return Er()!==void 0}function nn(t,e){for(let n of Array.from(t.childNodes))n.nodeType===Node.ELEMENT_NODE?Qi(n,e):n.nodeType===Node.COMMENT_NODE&&n.remove()}function Qi(t,e){let n=t.tagName.toLowerCase();if(xr.has(n)){t.remove();return}if(!e.allowedTags.has(n)){nn(t,e);let r=t.parentNode;if(r){for(;t.firstChild;)r.insertBefore(t.firstChild,t);t.remove()}return}eo(t,n,e),n===\\\"a\\\"&&no(t),nn(t,e)}function eo(t,e,n){let r=n.attrByTag.get(e);for(let o of Array.from(t.attributes)){let s=o.name.toLowerCase();if(s.startsWith(\\\"on\\\")){t.removeAttribute(o.name);continue}if(s===\\\"style\\\"){t.removeAttribute(o.name);continue}if(!(vr.has(s)||s.startsWith(Ji)||s.startsWith(Xi))){if(r?.has(s)){(Sr.has(s)&&!b(o.value)||s===\\\"srcset\\\"&&!to(o.value))&&t.removeAttribute(o.name);continue}t.removeAttribute(o.name)}}}function to(t){let e=t.split(\\\",\\\");for(let n of e){let r=n.trim();if(r.length===0)continue;let o=r.split(/\\\\s+/,1)[0];if(o===void 0||o.length===0||!b(o))return!1}return!0}function no(t){let e=t.getAttribute(\\\"href\\\");e&&Lt(e)&&(t.setAttribute(\\\"rel\\\",\\\"noopener noreferrer\\\"),t.hasAttribute(\\\"target\\\")||t.setAttribute(\\\"target\\\",\\\"_blank\\\"))}var Ks=Object.freeze({allowedTags:Qt,removeCompletely:xr,globalAttributes:vr,attributesByTag:en,urlAttributes:Sr});var Ar=new Map;function p(t,e){Ar.set(t,e)}function Lr(t){return Ar.get(t)}var ro={1:\\\"left\\\",2:\\\"center\\\",3:\\\"right\\\",4:\\\"justify\\\"},io=new Set([\\\"left\\\",\\\"center\\\",\\\"right\\\",\\\"justify\\\",\\\"start\\\",\\\"end\\\"]);function rn(t){let e=t.format;if(typeof e==\\\"string\\\"&&io.has(e))return e;if(typeof e==\\\"number\\\"){let n=ro[e];if(n!==void 0)return n}}function on(t){let e=t.indent;return typeof e==\\\"number\\\"&&e>0?e:0}function ee(t){return t.direction===\\\"rtl\\\"?' dir=\\\"rtl\\\"':t.direction===\\\"ltr\\\"?' dir=\\\"ltr\\\"':\\\"\\\"}function G(t){let e=rn(t),n=on(t),r=[];return e!==void 0&&r.push(`text-align:${e}`),n>0&&r.push(`padding-inline-start:${String(n*40)}px`),r.length===0?\\\"\\\":` style=\\\"${r.join(\\\";\\\")}\\\"`}var oo=Object.freeze({\\\"&\\\":\\\"&amp;\\\",\\\"<\\\":\\\"&lt;\\\",\\\">\\\":\\\"&gt;\\\",'\\\"':\\\"&quot;\\\",\\\"'\\\":\\\"&#x27;\\\",\\\"/\\\":\\\"&#x2F;\\\",\\\"`\\\":\\\"&#x60;\\\",\\\"=\\\":\\\"&#x3D;\\\"}),so=/[&<>\\\"'/`=]/g;function y(t){return t===\\\"\\\"?\\\"\\\":t.replace(so,e=>oo[e])}function Mr(t){return t.replace(/['\\\"()\\\\\\\\]/g,\\\"\\\\\\\\$&\\\")}var ao=Object.freeze({\\\"&\\\":\\\"&amp;\\\",\\\"<\\\":\\\"&lt;\\\",\\\">\\\":\\\"&gt;\\\",'\\\"':\\\"&quot;\\\",\\\"'\\\":\\\"&#x27;\\\"}),lo=/[&<>\\\"']/g;function L(t){return t===\\\"\\\"?\\\"\\\":t.replace(lo,e=>ao[e])}function Ct(t){return y(t).replace(/\\\\r\\\\n|\\\\r|\\\\n/g,\\\"<br>\\\")}var te={BOLD:1,ITALIC:2,STRIKETHROUGH:4,UNDERLINE:8,CODE:16,SUBSCRIPT:32,SUPERSCRIPT:64,HIGHLIGHT:128};var sn=t=>{let e=typeof t.text==\\\"string\\\"?t.text:\\\"\\\",n=y(e),r=typeof t.format==\\\"number\\\"?t.format:0;return(r&te.CODE)!==0&&(n=`<code>${n}</code>`),(r&te.BOLD)!==0&&(n=`<strong>${n}</strong>`),(r&te.ITALIC)!==0&&(n=`<em>${n}</em>`),(r&te.UNDERLINE)!==0&&(n=`<u>${n}</u>`),(r&te.STRIKETHROUGH)!==0&&(n=`<s>${n}</s>`),(r&te.SUBSCRIPT)!==0&&(n=`<sub>${n}</sub>`),(r&te.SUPERSCRIPT)!==0&&(n=`<sup>${n}</sup>`),(r&te.HIGHLIGHT)!==0&&(n=`<mark>${n}</mark>`),n};p(\\\"text\\\",sn);var an=(t,e)=>{let n=e.renderChildren(t.children??[]);return`<p${ee(t)}${G(t)}>${n}</p>`};p(\\\"paragraph\\\",an);var uo=new Set([\\\"h1\\\",\\\"h2\\\",\\\"h3\\\",\\\"h4\\\",\\\"h5\\\",\\\"h6\\\"]),ln=(t,e)=>{let n=typeof t.tag==\\\"string\\\"?t.tag.toLowerCase():\\\"h2\\\",r=uo.has(n)?n:\\\"h2\\\",o=e.renderChildren(t.children??[]);return`<${r}${ee(t)}${G(t)}>${o}</${r}>`};p(\\\"heading\\\",ln);var dn=(t,e)=>{let n=typeof t.listType==\\\"string\\\"?t.listType:\\\"bullet\\\",r=n===\\\"number\\\"?\\\"ol\\\":\\\"ul\\\",o=n===\\\"number\\\"&&typeof t.start==\\\"number\\\"&&t.start>1?` start=\\\"${String(t.start)}\\\"`:\\\"\\\",s=n===\\\"check\\\"?' role=\\\"list\\\"':\\\"\\\",a=e.renderChildren(t.children??[]);return`<${r}${ee(t)}${G(t)}${o}${s}>${a}</${r}>`},un=(t,e)=>{let n=e.renderChildren(t.children??[]);if(typeof t.checked==\\\"boolean\\\")return`<li role=\\\"checkbox\\\" aria-checked=\\\"${t.checked?\\\"true\\\":\\\"false\\\"}\\\"${G(t)}>${n}</li>`;let r=typeof t.value==\\\"number\\\"?` value=\\\"${y(String(t.value))}\\\"`:\\\"\\\";return`<li${ee(t)}${G(t)}${r}>${n}</li>`};p(\\\"list\\\",dn);p(\\\"listitem\\\",un);var pt=(t,e)=>{let n=typeof t.url==\\\"string\\\"?t.url:\\\"\\\",r=e.renderChildren(t.children??[]);if(n.length===0||!b(n))return r;let o=Lt(n)?' target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\"':co(t),s=typeof t.title==\\\"string\\\"?` title=\\\"${y(t.title)}\\\"`:\\\"\\\";return`<a href=\\\"${L(n)}\\\"${o}${s}>${r}</a>`};function co(t){let e=typeof t.target==\\\"string\\\"?t.target:\\\"\\\";if(e.length===0)return\\\"\\\";let n=y(e);return e===\\\"_blank\\\"?' target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\"':` target=\\\"${n}\\\"`}p(\\\"link\\\",pt);p(\\\"autolink\\\",pt);var cn=(t,e)=>{let n=e.renderChildren(t.children??[]);return`<blockquote${ee(t)}${G(t)}>${n}</blockquote>`};p(\\\"quote\\\",cn);var fn=t=>{let e=Nr(typeof t.language==\\\"string\\\"?t.language:\\\"\\\"),n=Ir(t);return`<pre><code${e===\\\"\\\"?\\\"\\\":` class=\\\"language-${e}\\\"`}>${y(n)}</code></pre>`},pn=t=>{let e=typeof t.text==\\\"string\\\"?t.text:\\\"\\\";return`<span${typeof t.highlightType==\\\"string\\\"?` class=\\\"token-${Nr(t.highlightType)}\\\"`:\\\"\\\"}>${y(e)}</span>`};p(\\\"code\\\",fn);p(\\\"code-highlight\\\",pn);function Ir(t){if(typeof t.text==\\\"string\\\")return t.text;if(!t.children)return\\\"\\\";let e=\\\"\\\";for(let n of t.children)e+=Ir(n);return e}function Nr(t){return t.replace(/[^a-zA-Z0-9_-]/g,\\\"\\\")}var mn=()=>\\\"<br>\\\",hn=()=>\\\"<hr>\\\",yn=()=>\\\"\\t\\\";p(\\\"linebreak\\\",mn);p(\\\"horizontalrule\\\",hn);p(\\\"tab\\\",yn);var gn=t=>{let e=fo(t);if(e===void 0)return\\\"\\\";let n=e.url;if(typeof n!=\\\"string\\\"||!b(n))return\\\"\\\";let r=typeof e.mimeType==\\\"string\\\"?e.mimeType:\\\"\\\";return r.startsWith(\\\"video/\\\")?mo(e,n):r.startsWith(\\\"audio/\\\")?ho(e,n):r===\\\"\\\"||r.startsWith(\\\"image/\\\")?po(e,n):yo(e,n)};p(\\\"upload\\\",gn);function fo(t){let e=t.value;if(!(typeof e!=\\\"object\\\"||e===null))return e}function po(t,e){let n=typeof t.alt==\\\"string\\\"?y(t.alt):\\\"\\\",r=typeof t.width==\\\"number\\\"?` width=\\\"${String(t.width)}\\\"`:\\\"\\\",o=typeof t.height==\\\"number\\\"?` height=\\\"${String(t.height)}\\\"`:\\\"\\\";return`<img src=\\\"${L(e)}\\\" alt=\\\"${n}\\\"${r}${o} loading=\\\"lazy\\\" decoding=\\\"async\\\">`}function mo(t,e){let n=typeof t.width==\\\"number\\\"?` width=\\\"${String(t.width)}\\\"`:\\\"\\\",r=typeof t.height==\\\"number\\\"?` height=\\\"${String(t.height)}\\\"`:\\\"\\\",o=typeof t.mimeType==\\\"string\\\"?` type=\\\"${L(t.mimeType)}\\\"`:\\\"\\\";return`<video controls${n}${r}><source src=\\\"${L(e)}\\\"${o}></video>`}function ho(t,e){let n=typeof t.mimeType==\\\"string\\\"?` type=\\\"${L(t.mimeType)}\\\"`:\\\"\\\";return`<audio controls><source src=\\\"${L(e)}\\\"${n}></audio>`}function yo(t,e){let n=typeof t.filename==\\\"string\\\"?y(t.filename):y(e);return`<a href=\\\"${L(e)}\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">${n}</a>`}var bn=t=>{let e=typeof t.relationTo==\\\"string\\\"?t.relationTo:\\\"\\\",n=go(t),r=bo(n,e),o=y(r),s=e===\\\"\\\"?\\\"\\\":` data-relation-to=\\\"${y(e)}\\\"`,a=n?.url;return typeof a==\\\"string\\\"&&b(a)?`<a href=\\\"${L(a)}\\\"${s}>${o}</a>`:`<span${s}>${o}</span>`};p(\\\"relationship\\\",bn);function go(t){let e=t.value;if(!(typeof e!=\\\"object\\\"||e===null))return e}function bo(t,e){return t===void 0?e===\\\"\\\"?\\\"#\\\":`#${e}`:typeof t.title==\\\"string\\\"&&t.title.length>0?t.title:typeof t.name==\\\"string\\\"&&t.name.length>0?t.name:typeof t.slug==\\\"string\\\"&&t.slug.length>0?t.slug:t.id!==void 0?String(t.id):e===\\\"\\\"?\\\"#\\\":`#${e}`}var Ro=new Map;function Rn(t){return Ro.get(t)}var Tn=(t,e)=>{let n=To(t),r=typeof n.blockType==\\\"string\\\"?n.blockType:\\\"\\\",o=_r(r);if(r!==\\\"\\\"){let u=Rn(r)??Rn(o);if(u)return u(n,{renderChildren:e.renderChildren})}let s=[];o!==\\\"\\\"&&s.push(`data-block-type=\\\"${y(o)}\\\"`);for(let[u,m]of Object.entries(n)){if(u===\\\"blockType\\\"||u===\\\"id\\\"||m==null)continue;let T=typeof m==\\\"string\\\"||typeof m==\\\"number\\\"||typeof m==\\\"boolean\\\"?String(m):JSON.stringify(m);s.push(`data-block-${_r(u)}=\\\"${y(T)}\\\"`)}return`<div${s.length===0?\\\"\\\":` ${s.join(\\\" \\\")}`}></div>`};p(\\\"block\\\",Tn);function To(t){let e=t.fields;return typeof e!=\\\"object\\\"||e===null?{}:e}function _r(t){return t.replace(/[^a-zA-Z0-9_-]/g,\\\"-\\\").toLowerCase()}p(\\\"text\\\",sn);p(\\\"paragraph\\\",an);p(\\\"heading\\\",ln);p(\\\"list\\\",dn);p(\\\"listitem\\\",un);p(\\\"link\\\",pt);p(\\\"autolink\\\",pt);p(\\\"quote\\\",cn);p(\\\"code\\\",fn);p(\\\"code-highlight\\\",pn);p(\\\"linebreak\\\",mn);p(\\\"horizontalrule\\\",hn);p(\\\"tab\\\",yn);p(\\\"upload\\\",gn);p(\\\"relationship\\\",bn);p(\\\"block\\\",Tn);var wo={renderChildren:wn,resolveAlignment:rn,resolveIndent:on};function de(t){if(typeof t!=\\\"object\\\"||t===null||!(\\\"root\\\"in t))return!1;let e=t.root;return typeof e!=\\\"object\\\"||e===null||!(\\\"children\\\"in e)?!1:Array.isArray(e.children)}function Cr(t,e={}){if(!de(t))return\\\"\\\";let n=wn(t.root.children);return e.sanitize===!1||!kr()?n:z(n)}function Ot(t){return de(t)?t.root.children.map(Or).join(`\\n`).trim():\\\"\\\"}function wn(t){let e=\\\"\\\";for(let n of t)e+=xo(n);return e}function xo(t){let e=Lr(t.type);return e?e(t,wo):t.children!==void 0?wn(t.children):\\\"\\\"}function Or(t){if(typeof t.text==\\\"string\\\")return t.text;if(t.type===\\\"linebreak\\\")return`\\n`;if(t.children===void 0)return\\\"\\\";let e=\\\"\\\";for(let n of t.children)e+=Or(n);return e}var xn=new Map;function Pr(t=[]){for(let n of t)xn.set(n.name,n);let e={};for(let[n,r]of xn)e[n]=r;return Object.freeze(e)}function g(t){xn.set(t.name,t)}var vo=\\\"data-payload-text\\\",Fr=new WeakSet,vn={name:\\\"text\\\",render(t,e){let n=t.element,r=ko(e);if(n.tagName===\\\"INPUT\\\"||n.tagName===\\\"TEXTAREA\\\"){n.value=r;return}if(So(n)&&!n.hasAttribute(vo)){Eo(n,t.fieldName);return}if(r.includes(`\\n`)||r.includes(\\\"\\\\r\\\")){n.innerHTML=Ct(r);return}n.textContent=r}};function So(t){return t.firstElementChild!==null}function Eo(t,e){Fr.has(t)||(Fr.add(t),console.warn(`[live-preview] Skipping text update for \\\"${e}\\\" \\\\u2014 the bound <${t.tagName.toLowerCase()}> has structured child elements. Either move data-payload-field to the element whose textContent is the field value, or opt in with data-payload-text to replace the structure.`))}function ko(t){return t==null?\\\"\\\":de(t)?Ot(t):typeof t==\\\"string\\\"?t:typeof t==\\\"number\\\"||typeof t==\\\"boolean\\\"?String(t):JSON.stringify(t)}g(vn);function w(t){if(t==null)return\\\"\\\";if(typeof t==\\\"string\\\")return t;if(typeof t==\\\"number\\\"||typeof t==\\\"boolean\\\"||typeof t==\\\"bigint\\\")return String(t);try{return JSON.stringify(t)}catch{return\\\"\\\"}}var Sn={name:\\\"textarea\\\",render(t,e){let n=t.element,r=de(e)?Ot(e):w(e);if(n.tagName===\\\"INPUT\\\"||n.tagName===\\\"TEXTAREA\\\"){n.value=r;return}n.innerHTML=Ct(r)}};g(Sn);var En={name:\\\"richText\\\",render(t,e){if(de(e)){t.element.innerHTML=Cr(e);return}typeof e==\\\"string\\\"&&(t.element.innerHTML=z(e))}};g(En);var kn={name:\\\"html\\\",render(t,e){if(e==null){t.element.textContent=\\\"\\\";return}let n=typeof e==\\\"string\\\"?e:w(e);t.element.innerHTML=z(n)}};g(kn);var mt={name:\\\"url\\\",render(t,e,n){let r=t.element,o=w(e);if(r.tagName===\\\"A\\\"){let s=r,a=t.hrefField,u=a?n.allFields[a]:e;typeof u==\\\"string\\\"&&b(u)&&(s.href=u),s.textContent=o;return}if(r.tagName===\\\"INPUT\\\"||r.tagName===\\\"TEXTAREA\\\"){r.value=o;return}r.textContent=o}};g(mt);g({...mt,name:\\\"email\\\"});var An={name:\\\"image\\\",render(t,e,n){let r=t.element,o=Ao(e),s=Lo(o,e);if(s!==void 0){if(r.tagName===\\\"IMG\\\"){let a=r;a.src=s;let u=Mo(o,t.altField,n.allFields);u!==void 0&&(a.alt=u);return}r.style.backgroundImage=`url('${Mr(s)}')`}}};function Ao(t){if(!(typeof t!=\\\"object\\\"||t===null))return t}function Lo(t,e){if(t?.url!==void 0&&b(t.url))return t.url;if(typeof e==\\\"string\\\"&&b(e))return e}function Mo(t,e,n){if(t?.alt!==void 0)return t.alt;if(e!==void 0){let r=n[e];if(typeof r==\\\"string\\\")return r}}g(An);var Ln={name:\\\"upload\\\",render(t,e){let n=t.element,r=Io(e);if(r===void 0)return;let o=r.url;if(typeof o!=\\\"string\\\"||!b(o))return;if(n.tagName===\\\"IMG\\\"){let a=n;a.src=o,r.alt!==void 0&&(a.alt=r.alt);return}if(n.tagName===\\\"A\\\"){let a=n;a.href=o,a.textContent=r.filename??o;return}let s=r.filename!==void 0?y(r.filename):y(o);n.innerHTML=`<a href=\\\"${L(o)}\\\">${s}</a>`}};function Io(t){if(!(typeof t!=\\\"object\\\"||t===null))return t}g(Ln);var Mn={name:\\\"relationship\\\",render(t,e){let n=t.element,o=No(e).join(\\\", \\\");if(n.tagName===\\\"A\\\"&&!Array.isArray(e)){let s=n,a=e?.url;typeof a==\\\"string\\\"&&b(a)&&(s.href=a),s.textContent=o;return}n.textContent=o}};function No(t){return t==null?[\\\"\\\"]:Array.isArray(t)?t.map(Dr):[Dr(t)]}function Dr(t){if(typeof t==\\\"object\\\"&&t!==null){let e=t;return typeof e.title==\\\"string\\\"&&e.title.length>0?e.title:typeof e.name==\\\"string\\\"&&e.name.length>0?e.name:typeof e.slug==\\\"string\\\"&&e.slug.length>0?e.slug:e.id!==void 0?String(e.id):\\\"\\\"}return w(t)}g(Mn);var ht={name:\\\"select\\\",render(t,e){let n=t.element,r=$r(e);if(n.tagName===\\\"SELECT\\\"){n.value=r;return}if(n.tagName===\\\"INPUT\\\"&&n.type===\\\"radio\\\"){let o=n;o.checked=o.value===r;return}n.textContent=r}};function $r(t){return Array.isArray(t)?t.map(e=>$r(e)).join(\\\", \\\"):w(t)}g(ht);g({...ht,name:\\\"radio\\\"});var In={name:\\\"checkbox\\\",render(t,e){let n=t.element,r=!!e;if(n.tagName===\\\"INPUT\\\"&&n.type===\\\"checkbox\\\"){n.checked=r;return}if(n.hasAttribute(\\\"aria-checked\\\")){n.setAttribute(\\\"aria-checked\\\",r?\\\"true\\\":\\\"false\\\");return}n.textContent=r?\\\"true\\\":\\\"false\\\"}};g(In);var yt=new Map,gt=new Map,_o=64,Co=_o;function Ur(t,e){let n=Br(t,e),r=yt.get(n);if(r!==void 0)return yt.delete(n),yt.set(n,r),r;let o=new Intl.NumberFormat(t,e);return yt.set(n,o),jr(yt),o}function Hr(t,e){let n=Br(t,e),r=gt.get(n);if(r!==void 0)return gt.delete(n),gt.set(n,r),r;let o=new Intl.DateTimeFormat(t,e);return gt.set(n,o),jr(gt),o}function Br(t,e){let n=t??\\\"\\\";if(e==null)return n;let r=Nn(e);return r===\\\"{}\\\"?n:`${n}|${r}`}function Nn(t){if(t===null||typeof t!=\\\"object\\\")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(o=>Nn(o)).join(\\\",\\\")}]`;let e=t,n=Object.keys(e).sort(),r=[];for(let o of n){let s=e[o];s!==void 0&&r.push(`${JSON.stringify(o)}:${Nn(s)}`)}return`{${r.join(\\\",\\\")}}`}function jr(t){for(;t.size>Co;){let e=t.keys().next().value;if(e===void 0)break;t.delete(e)}}var _n={name:\\\"date\\\",render(t,e,n){let r=t.element;if(e==null||e===\\\"\\\"){r.tagName===\\\"INPUT\\\"?r.value=\\\"\\\":(r.tagName===\\\"TIME\\\"&&r.removeAttribute(\\\"datetime\\\"),r.textContent=\\\"\\\");return}let o=typeof e==\\\"string\\\"?e:w(e),s=new Date(o),a=!Number.isNaN(s.getTime());if(r.tagName===\\\"INPUT\\\"){r.value=a?Oo(r.type,s):o;return}if(r.tagName===\\\"TIME\\\"){r.setAttribute(\\\"datetime\\\",a?s.toISOString():o),r.textContent=a?Vr(s,n):o;return}r.textContent=a?Vr(s,n):o}};function Vr(t,e){let n=e.locale??Ie();try{return Hr(n,{dateStyle:\\\"medium\\\",timeStyle:\\\"short\\\"}).format(t)}catch{return t.toISOString()}}function Oo(t,e){return t===\\\"date\\\"?e.toISOString().slice(0,10):t===\\\"datetime-local\\\"?e.toISOString().slice(0,16):e.toISOString()}g(_n);var Cn={name:\\\"number\\\",render(t,e,n){let r=t.element;if(e==null||e===\\\"\\\"){r.tagName===\\\"INPUT\\\"?r.value=\\\"\\\":r.textContent=\\\"\\\";return}let o=typeof e==\\\"number\\\"?e:Number(w(e));if(Number.isNaN(o)){r.textContent=w(e);return}if(r.tagName===\\\"INPUT\\\"){r.value=String(o);return}r.textContent=Po(o,n)}};function Po(t,e){let n=e.locale??Ie();try{return Ur(n).format(t)}catch{return String(t)}}g(Cn);var bt={name:\\\"array\\\",render(t,e){let n=t.element;if(!Array.isArray(e))return;let r=t.arrayTemplate;if(r!==void 0&&r.length>0){let s=Fo(r,e);n.innerHTML=z(s);return}let o=t.arraySeparator??\\\", \\\";n.textContent=e.map(Uo).join(o)}};function Fo(t,e){let n=\\\"\\\";for(let r=0;r<e.length;r+=1)n+=Do(t,e[r],r);return n}function Do(t,e,n){let r=t;if(typeof e==\\\"object\\\"&&e!==null)for(let[o,s]of Object.entries(e)){let a=new RegExp(`\\\\\\\\{\\\\\\\\{${$o(o)}\\\\\\\\}\\\\\\\\}`,\\\"g\\\");r=r.replace(a,y(w(s)))}else r=r.replace(/\\\\{\\\\{value\\\\}\\\\}/g,y(w(e)));return r=r.replace(/\\\\{\\\\{index\\\\}\\\\}/g,String(n)),r}function $o(t){return t.replace(/[.*+?^${}()|[\\\\]\\\\\\\\]/g,\\\"\\\\\\\\$&\\\")}function Uo(t){return w(t)}g(bt);g({...bt,name:\\\"blocks\\\"});function Ho(){return typeof document>\\\"u\\\"?!1:typeof document.startViewTransition==\\\"function\\\"}async function zr(t){if(!Ho()){t();return}let n=document.startViewTransition.call(document,t);try{await n.finished}catch{}}var Yr=\\\"data-payload-key\\\",Rt=\\\"data-payload-nested-key\\\",Fn=\\\"data-payload-nested-template\\\";function qr(){return new WeakMap}function Ft(t){let{template:e,container:n,patches:r,store:o}=t,s=jo(n,o),a=[],u=[],m=[],T=[],W=[];for(let c of r)c.kind===\\\"remove\\\"?a.push(c):c.kind===\\\"insert\\\"?u.push(c):c.kind===\\\"move\\\"?m.push(c):c.kind===\\\"update\\\"?T.push(c):W.push(c);a.sort((c,R)=>Pt(R)-Pt(c));for(let c of a){if(c.kind!==\\\"remove\\\")continue;n.children[c.index]?.remove(),Vo(s,c.value)}for(let c of W){if(c.kind!==\\\"replace\\\")continue;let R=n.children[c.index],v=Pn(e,c.value,c.index);!R||!v||(Gr(v,c.value,o),n.replaceChild(v,R),On(s,c.value))}for(let c of T){if(c.kind!==\\\"update\\\")continue;let R=n.children[c.index],v=Pn(e,c.value,c.index);!R||!v||(Bo(R,v,c.value,s,o),n.replaceChild(v,R),On(s,c.value))}u.sort((c,R)=>Pt(c)-Pt(R));for(let c of u){if(c.kind!==\\\"insert\\\")continue;let R=n.children[c.index]??null,v=Pn(e,c.value,c.index);v&&(Gr(v,c.value,o),n.insertBefore(v,R),On(s,c.value))}for(let c of m){if(c.kind!==\\\"move\\\")continue;let R=Tt(c.value),v=R!==void 0?zo(n,R):null;if(!v)continue;let $e=n.children[c.to]??null;v!==$e&&n.insertBefore(v,$e)}}function Gr(t,e,n){let r=t.querySelectorAll(`[${Rt}]`);for(let o of Array.from(r)){let s=o.getAttribute(Rt);if(s===null)continue;let a=o.getAttribute(Fn);if(!a)continue;let u=Dn(e,s);if(u===void 0)continue;let m=st([],u);m.length!==0&&Ft({template:a,container:o,patches:m,nextItems:u,store:n})}}function Bo(t,e,n,r,o){let s=t.querySelectorAll(`[${Rt}]`);if(s.length===0)return;let a=Tt(n),u=a!==void 0?r.get(a):void 0;for(let m of Array.from(s)){let T=m.getAttribute(Rt);if(T===null)continue;let W=e.querySelector(`[${Rt}=\\\"${Kr(T)}\\\"]`);if(!W)continue;W.replaceWith(m);let c=m.getAttribute(Fn)??W.getAttribute(Fn);if(!c)continue;let R=Dn(n,T)??[],v=Dn(u,T)??[],$e=st(v,R);$e.length!==0&&Ft({template:c,container:m,patches:$e,nextItems:R,store:o})}}function Dn(t,e){if(typeof t!=\\\"object\\\"||t===null)return;let n=t[e];if(Array.isArray(n))return n}function jo(t,e){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}function On(t,e){let n=Tt(e);n!==void 0&&t.set(n,e)}function Vo(t,e){let n=Tt(e);n!==void 0&&t.delete(n)}function Pt(t){return t.kind===\\\"move\\\"?t.to:t.index}function Tt(t){if(typeof t!=\\\"object\\\"||t===null)return;let e=t.id;if(typeof e==\\\"string\\\"||typeof e==\\\"number\\\")return String(e)}function zo(t,e){return t.querySelector(`[${Yr}=\\\"${Kr(e)}\\\"]`)}function Kr(t){let e=globalThis.CSS;return e?.escape?e.escape(t):t.replace(/[^a-zA-Z0-9_-]/g,\\\"\\\\\\\\$&\\\")}function Pn(t,e,n){if(typeof document>\\\"u\\\")return null;let r=Go(t,e,n),o=z(r),s=document.createElement(\\\"template\\\");s.innerHTML=o;let a=s.content.firstElementChild;if(!a)return null;let u=Tt(e);return u!==void 0&&a.setAttribute(Yr,u),a}function Go(t,e,n){let r=t;if(typeof e==\\\"object\\\"&&e!==null)for(let[o,s]of Object.entries(e)){let a=new RegExp(`\\\\\\\\{\\\\\\\\{${Wo(o)}\\\\\\\\}\\\\\\\\}`,\\\"g\\\"),u=y(Wr(s));r=r.replace(a,()=>u)}else{let o=y(Wr(e));r=r.replace(/\\\\{\\\\{value\\\\}\\\\}/g,()=>o)}return r.replace(/\\\\{\\\\{index\\\\}\\\\}/g,String(n))}function Wr(t){return t==null?\\\"\\\":typeof t==\\\"string\\\"?t:typeof t==\\\"number\\\"||typeof t==\\\"boolean\\\"||typeof t==\\\"bigint\\\"?String(t):JSON.stringify(t)}function Wo(t){return t.replace(/[.*+?^${}()|[\\\\]\\\\\\\\]/g,\\\"\\\\\\\\$&\\\")}function Jr(){let t=new WeakMap,e=new WeakSet,n=qr();return{name:\\\"structural-array\\\",render(r,o){if(!Array.isArray(o))return;let s=r.element,a=r.arrayTemplate;if(a===void 0||a.length===0){Yo(e,s,r.fieldName);return}let u=t.get(s)??[],m=st(u,o);if(m.length===0){t.set(s,o.slice());return}zr(()=>{Ft({template:a,container:s,patches:m,nextItems:o,store:n})}),t.set(s,o.slice())}}}function Yo(t,e,n){t.has(e)||(t.add(e),console.warn(`[live-preview] Skipping structural update for \\\"${n}\\\" \\\\u2014 the <${e.tagName.toLowerCase()}> with data-payload-structural is missing data-payload-array-template. Add an inline template (e.g., data-payload-array-template=\\\"<li>{{label}}</li>\\\") so the renderer can materialise new items.`))}var qo=[vn,Sn,En,kn,mt,{...mt,name:\\\"email\\\"},An,Ln,Mn,ht,{...ht,name:\\\"radio\\\"},In,_n,Cn,bt,{...bt,name:\\\"blocks\\\"}];function Xr(){return Pr([...qo,Jr()])}function Ko(){if(typeof window>\\\"u\\\"||!Zt())return;let t=window.__livePreview;if(t!==void 0)return t;let e=Jo(),n=new _t({additionalOrigins:e.additionalOrigins,enableReferrerDetection:!e.disableReferrerDetection,enableLocalhostMatching:!e.disableLocalhostMatching});n.isProductionUnconfigured?console.warn(\\\"[live-preview] No trusted origin could be detected. Set the PAYLOAD_ADMIN_ORIGIN env var or pass `allowedOrigins` to generateInlineScript().\\\"):n.isReferrerOnlyTrust&&console.warn(\\\"[live-preview] Trusting the embedding page via document.referrer only \\\\u2014 any site that frames this page could post preview updates. Pass explicit `allowedOrigins` and serve a `frame-ancestors` CSP for production.\\\");let r=new wt,o=Xr(),s=new Nt({renderers:o,originMatcher:u=>n.matches(u),readyTargets:n.enumerate(),emitter:r,...typeof e.serverURL==\\\"string\\\"&&e.serverURL!==\\\"\\\"?{dataMerge:{serverURL:e.serverURL,...typeof e.apiRoute==\\\"string\\\"?{apiRoute:e.apiRoute}:{},...typeof e.mergeDepth==\\\"number\\\"?{depth:e.mergeDepth}:{}}}:{},debounceMs:e.debounceMs,heartbeatMs:e.heartbeatMs,intersectionRootMargin:e.intersectionRootMargin,disableVisibilityGate:e.disableVisibilityGate,visibilityGateThreshold:e.visibilityGateThreshold,enableA11y:e.enableA11y,onHeartbeatTimeout:()=>{n.unlockOrigin()},...e.debug?{log:(...u)=>{console.debug(\\\"[live-preview]\\\",...u)}}:{}});r.on(\\\"connect\\\",u=>{n.lockOrigin(u.origin)}),s.start();let a=Object.freeze({version:Tr,destroy:()=>{s.destroy();let u=window;u.__livePreview===a&&delete u.__livePreview},refresh:()=>{s.refreshCache()},enumerateOrigins:()=>n.enumerate()});return Object.defineProperty(window,\\\"__livePreview\\\",{value:a,writable:!1,configurable:!0}),a}function Jo(){let t=typeof __LIVE_PREVIEW_CONFIG__>\\\"u\\\"?void 0:__LIVE_PREVIEW_CONFIG__;return t!==void 0?t:{additionalOrigins:[],serverURL:\\\"\\\",apiRoute:\\\"/api\\\",mergeDepth:1,debug:!1,debounceMs:50,enableA11y:!0,heartbeatMs:0,disableVisibilityGate:!1,visibilityGateThreshold:50,intersectionRootMargin:\\\"200px\\\",disableReferrerDetection:!1,disableLocalhostMatching:!1}}var Xo=typeof __INLINE_BUILD__>\\\"u\\\"?!1:__INLINE_BUILD__;Xo&&Ko();var Fd={isInIframe:ct,isInPopup:Xt,isInPreviewContext:Zt};})();\\n\";\nexport const RUNTIME_BUILD_INFO: RuntimeBuildInfo = { generatedAt: \"2026-07-11T19:23:06.084Z\", size: 58853 };\n","/**\n * Inline script generator.\n *\n * Wraps the build-time-generated runtime IIFE with consumer-provided\n * configuration. Returns a JavaScript string suitable for embedding\n * via `<script>` in any framework.\n *\n * The runtime body is identical to the one used by the high-level\n * client because both originate from `src/core/runtime.ts`. There is\n * no parallel implementation to drift out of sync.\n *\n * @module @inline/generator\n */\n\nimport { RUNTIME_SOURCE, RUNTIME_BUILD_INFO, type RuntimeBuildInfo } from './runtime.generated';\n\nexport interface InlineScriptConfig {\n /** Additional trusted origins to merge with auto-detected ones. */\n readonly allowedOrigins?: readonly string[];\n /**\n * Payload server origin, e.g. `https://cms.example.com`. When set,\n * every incoming update is re-fetched through the Payload REST API\n * (`X-Payload-HTTP-Method-Override: GET`, same strategy as the\n * official client) so relationship and upload fields render\n * populated instead of as bare IDs. Strongly recommended for\n * Payload 3.x. Requires the preview page to be able to reach the\n * API with credentials (same-site cookies or CORS `credentials`).\n */\n readonly serverURL?: string;\n /** REST API route prefix used with `serverURL`. Defaults to `/api`. */\n readonly apiRoute?: string;\n /** Population depth used with `serverURL`. Defaults to `1`. */\n readonly mergeDepth?: number;\n /** Enable verbose console logging. Defaults to `false`. */\n readonly debug?: boolean;\n /** Debounce window for incoming updates in ms. Defaults to `50`. */\n readonly debounceMs?: number;\n /** Enable screen-reader live region. Defaults to `true`. */\n readonly enableA11y?: boolean;\n /**\n * Heartbeat timeout in ms. Defaults to `0` (disabled). The Payload\n * admin only posts messages on form edits — there is no protocol\n * keepalive — so an idle-based timeout would fire spurious\n * disconnects while the editor pauses. Enable only if your admin\n * setup sends periodic messages.\n */\n readonly heartbeatMs?: number;\n /**\n * Bypass the visibility-gate optimisation and apply every update\n * regardless of viewport position. Default `false` — the gate kicks\n * in when the cache exceeds `visibilityGateThreshold` entries.\n */\n readonly disableVisibilityGate?: boolean;\n /**\n * Cache-size threshold above which the visibility gate activates.\n * Default `50`. Off-screen elements above this threshold are queued\n * for replay on intersection instead of being updated immediately.\n */\n readonly visibilityGateThreshold?: number;\n /**\n * `rootMargin` passed to the `IntersectionObserver` watching the\n * cached elements. Default `'200px'`. Increase to pre-render\n * further off-screen content; decrease for tighter visibility.\n */\n readonly intersectionRootMargin?: string;\n /**\n * Opt out of `document.referrer`-based origin auto-detection.\n * Useful when the page is loaded under `Referrer-Policy: no-referrer`\n * and you want predictable behaviour. Default `false`.\n */\n readonly disableReferrerDetection?: boolean;\n /**\n * Opt out of the dev-mode localhost-pattern matcher (any port on\n * `localhost` / `127.0.0.1`). Useful when running locally against\n * a production-like origin list. Default `false`.\n */\n readonly disableLocalhostMatching?: boolean;\n /**\n * Optional CSP nonce for the generated `<script>` tag. When provided\n * via `wrapWithScriptTag()` the nonce is set on the tag. Useful for\n * strict CSP policies that disallow `unsafe-inline`.\n */\n readonly nonce?: string;\n}\n\nconst DEFAULT_DEBOUNCE_MS = 50;\nconst DEFAULT_HEARTBEAT_MS = 0;\nconst DEFAULT_VISIBILITY_GATE_THRESHOLD = 50;\nconst DEFAULT_INTERSECTION_ROOT_MARGIN = '200px';\n\n/**\n * Build an inline script body. The result is a self-contained IIFE\n * with the build-time runtime, prefixed by a configuration block.\n *\n * The string does NOT include the `<script>` tags — use\n * `wrapWithScriptTag()` when you need them.\n */\nexport function generateInlineScript(config: InlineScriptConfig = {}): string {\n if (RUNTIME_SOURCE.length === 0) {\n throw new Error(\n '[live-preview] runtime.generated.ts is empty. Run `npm run build:runtime` before bundling.',\n );\n }\n const configLiteral = JSON.stringify({\n additionalOrigins: config.allowedOrigins ?? [],\n serverURL: config.serverURL ?? '',\n apiRoute: config.apiRoute ?? '/api',\n mergeDepth: config.mergeDepth ?? 1,\n debug: config.debug ?? false,\n debounceMs: config.debounceMs ?? DEFAULT_DEBOUNCE_MS,\n enableA11y: config.enableA11y ?? true,\n heartbeatMs: config.heartbeatMs ?? DEFAULT_HEARTBEAT_MS,\n disableVisibilityGate: config.disableVisibilityGate ?? false,\n visibilityGateThreshold: config.visibilityGateThreshold ?? DEFAULT_VISIBILITY_GATE_THRESHOLD,\n intersectionRootMargin: config.intersectionRootMargin ?? DEFAULT_INTERSECTION_ROOT_MARGIN,\n disableReferrerDetection: config.disableReferrerDetection ?? false,\n disableLocalhostMatching: config.disableLocalhostMatching ?? false,\n // `<` must never appear literally inside an inline <script> body —\n // a consumer-supplied string containing `</script>` would otherwise\n // terminate the tag early.\n }).replace(/</g, '\\\\u003C');\n // The IIFE declares its own scope. We inject the config via a global\n // assignment that the bundled runtime reads back through the\n // `__LIVE_PREVIEW_CONFIG__` constant placeholder.\n const generatedAt =\n RUNTIME_BUILD_INFO.generatedAt === '' ? 'dev' : RUNTIME_BUILD_INFO.generatedAt;\n return [\n `/* payload-live-preview runtime ${generatedAt} */`,\n `var __LIVE_PREVIEW_CONFIG__=${configLiteral};`,\n `var __INLINE_BUILD__=true;`,\n RUNTIME_SOURCE,\n ].join('\\n');\n}\n\n/**\n * Wrap an inline script body in a `<script>` tag. When a nonce is\n * provided it is added as the `nonce` attribute so CSP policies that\n * require `'nonce-...'` accept the script.\n */\nexport function wrapWithScriptTag(body: string, options: { nonce?: string } = {}): string {\n const nonceAttr = options.nonce !== undefined ? ` nonce=\"${escapeNonce(options.nonce)}\"` : '';\n return `<script${nonceAttr}>${body}</script>`;\n}\n\n/**\n * Snapshot of the build-time information for diagnostics.\n */\nexport function runtimeBuildInfo(): RuntimeBuildInfo {\n return RUNTIME_BUILD_INFO;\n}\n\nfunction escapeNonce(nonce: string): string {\n if (!/^[A-Za-z0-9+/=_-]+$/.test(nonce)) {\n throw new RangeError('wrapWithScriptTag: nonce contains invalid characters');\n }\n return nonce;\n}\n","/**\n * Server-side preview-request detection.\n *\n * The live-preview runtime only ever activates inside the Payload\n * admin's iframe, but the *server* still has to decide whether to\n * inject the (sizeable) inline script into a given HTML response.\n * Injecting it into every page for every visitor buffers every\n * response and ships dead bytes to production traffic — so adapters\n * gate injection on this predicate by default, and consumers with\n * hand-rolled middleware can import it directly.\n *\n * A request counts as a preview when any of these hold:\n *\n * 1. A preview query parameter is present (`?preview=true`,\n * `?draft=true`, `?livePreview=true` — configurable).\n * 2. `Sec-Fetch-Dest: iframe` — the document is being loaded as an\n * iframe, which is exactly how the Payload admin embeds it.\n * (Sent by all evergreen browsers; absence never *excludes* a\n * request, presence includes it.)\n * 3. The `Referer` points at one of the given admin origins.\n *\n * @module @adapters/shared/preview-request\n */\n\n/** The individual signals the predicate can consider. */\nexport type PreviewSignal = 'query' | 'fetch-dest' | 'referer';\n\nexport interface PreviewRequestOptions {\n /**\n * Which signals count as \"this is a preview request\". Default: all\n * three. High-security setups that must never relax framing headers\n * for unsolicited iframe loads can restrict to `['query']` — then\n * only an explicit `?preview=true` (e.g. from `buildLivePreviewUrl`)\n * activates preview handling.\n */\n readonly signals?: readonly PreviewSignal[];\n /**\n * Query parameters (with values `true` or `1`) that mark a request\n * as a preview. Default: `['preview', 'draft', 'livePreview']`.\n */\n readonly queryParams?: readonly string[];\n /**\n * Treat `Sec-Fetch-Dest: iframe` as a preview signal. Default `true`.\n * Legacy alias for excluding `'fetch-dest'` from `signals`.\n */\n readonly checkFetchDest?: boolean;\n /**\n * Admin origins whose `Referer` marks a request as a preview,\n * e.g. `['https://cms.example.com']`.\n */\n readonly adminOrigins?: readonly string[];\n}\n\nconst DEFAULT_QUERY_PARAMS = ['preview', 'draft', 'livePreview'] as const;\n\n/**\n * The minimal request surface the predicate needs. The standard\n * `Request` satisfies it structurally, and server frameworks without\n * fetch-style requests (e.g. Nitro/H3) can supply a tiny shim.\n */\nexport interface PreviewRequestLike {\n readonly url: string;\n readonly headers: { get(name: string): string | null };\n}\n\n/**\n * Decide whether `request` is a live-preview request. See the module\n * docblock for the exact signals.\n */\nexport function isPreviewRequest(\n request: PreviewRequestLike,\n options: PreviewRequestOptions = {},\n): boolean {\n const signals = new Set<PreviewSignal>(options.signals ?? ['query', 'fetch-dest', 'referer']);\n const queryParams = options.queryParams ?? DEFAULT_QUERY_PARAMS;\n const checkFetchDest = (options.checkFetchDest ?? true) && signals.has('fetch-dest');\n\n if (signals.has('query')) {\n let url: URL | undefined;\n try {\n url = new URL(request.url);\n } catch {\n url = undefined;\n }\n if (url !== undefined) {\n for (const param of queryParams) {\n const value = url.searchParams.get(param);\n if (value === 'true' || value === '1') return true;\n }\n }\n }\n\n if (checkFetchDest && request.headers.get('sec-fetch-dest') === 'iframe') {\n return true;\n }\n\n const adminOrigins = signals.has('referer') ? (options.adminOrigins ?? []) : [];\n if (adminOrigins.length > 0) {\n const referer = request.headers.get('referer');\n if (referer !== null) {\n try {\n const refererOrigin = new URL(referer).origin;\n for (const adminOrigin of adminOrigins) {\n try {\n if (new URL(adminOrigin).origin === refererOrigin) return true;\n } catch {\n // skip malformed configured origin\n }\n }\n } catch {\n // malformed referer — not a preview signal\n }\n }\n }\n\n return false;\n}\n","/**\n * Next.js adapter for Payload Live Preview.\n *\n * ⚠️ Scope: this package patches server-rendered/static DOM. For\n * client-rendered React trees prefer the official\n * `@payloadcms/live-preview-react` (`useLivePreview`) — React\n * re-renders can revert DOM patches made here.\n *\n * Provides:\n *\n * - `renderLivePreviewScript(options)` / `generateInlineScript` —\n * embed the script in your root layout via\n * `<script dangerouslySetInnerHTML>`. This is the PRIMARY wiring\n * for Next.js: standard middleware cannot inject into the HTML\n * body because `NextResponse.next()` carries no body.\n *\n * - `createLivePreviewMiddleware(options)` — merges CSP headers\n * (`frame-ancestors`) onto preview responses. Its script-injection\n * path only activates when you pass it a `Response` that actually\n * carries an HTML body (custom servers, route handlers returning\n * HTML) — in standard `middleware.ts` use `autoInject: false`.\n *\n * @module @adapters/nextjs\n */\n\nimport {\n generateCspNonce,\n buildFrameAncestors,\n buildScriptSrcWithNonce,\n mergeCspHeader,\n} from '@security/csp';\nimport { generateInlineScript, wrapWithScriptTag } from '@inline/generator';\nimport { isPreviewRequest } from '@adapters/shared/preview-request';\n\nexport interface LivePreviewNextOptions {\n readonly allowedOrigins?: readonly string[];\n /** Payload server origin for REST data merging (Payload 3.x). */\n readonly serverURL?: string;\n /** REST API route prefix used with `serverURL`. Defaults to `/api`. */\n readonly apiRoute?: string;\n /** Population depth used with `serverURL`. Defaults to `1`. */\n readonly mergeDepth?: number;\n readonly autoInject?: boolean;\n /**\n * `'preview-only'` (default) — inject only into responses that look\n * like preview requests. `'always'` — every HTML response.\n */\n readonly inject?: 'preview-only' | 'always';\n /** Query params that mark a preview request. Default `['preview', 'draft', 'livePreview']`. */\n readonly previewQueryParams?: readonly string[];\n /** Which signals count as a preview request. Default: query, fetch-dest, referer. */\n readonly previewSignals?: readonly ('query' | 'fetch-dest' | 'referer')[];\n readonly shouldInject?: (request: Request) => boolean;\n /**\n * CSP management: `'frame-ancestors'` (default) merges only the\n * embed permission; `'full'` also manages a nonce'd `script-src`;\n * `false` never touches CSP. `true` is a legacy alias for\n * `'frame-ancestors'`.\n */\n readonly manageCsp?: boolean | 'frame-ancestors' | 'full';\n /** Add `'strict-dynamic'` to the managed `script-src`. Default `false`. */\n readonly strictDynamic?: boolean;\n readonly frameAncestorsExtra?: readonly string[];\n readonly scriptSrcExtra?: readonly string[];\n readonly debug?: boolean;\n readonly debounceMs?: number;\n /** Heartbeat timeout in ms. Default `0` (disabled). */\n readonly heartbeatMs?: number;\n}\n\nexport type NextMiddleware = (request: Request) => Promise<Response | undefined>;\n\nconst HTML_CONTENT_TYPE = /text\\/html/i;\nconst HEAD_INSERT = /<head(\\s[^>]*)?>/i;\n\n/**\n * Build a Next.js-compatible middleware operating on the standard\n * `Request` / `Response` pair. Wrap with `NextResponse.next()` in your\n * project to integrate with Next's request pipeline.\n */\nexport function createLivePreviewMiddleware(\n options: LivePreviewNextOptions = {},\n): (request: Request, response: Response) => Promise<Response> {\n let cachedScriptBody: string | undefined;\n const scriptBody = (): string => {\n cachedScriptBody ??= buildScriptBody(options);\n return cachedScriptBody;\n };\n\n return async (request, response) => {\n const isPreview =\n (options.inject ?? 'preview-only') === 'always' ||\n isPreviewRequest(request, {\n ...(options.previewQueryParams !== undefined\n ? { queryParams: options.previewQueryParams }\n : {}),\n ...(options.previewSignals !== undefined ? { signals: options.previewSignals } : {}),\n adminOrigins: options.allowedOrigins ?? [],\n });\n if (!isPreview) return response;\n\n let outResponse = response;\n const apply = (options.autoInject ?? true) && (options.shouldInject?.(request) ?? true);\n const contentType = response.headers.get('content-type') ?? '';\n if (apply && HTML_CONTENT_TYPE.test(contentType)) {\n outResponse = await injectIntoResponse(response, scriptBody());\n }\n const manageCsp = normalizeManageCsp(options.manageCsp);\n if (manageCsp !== false) {\n outResponse = addCsp(outResponse, manageCsp, options);\n }\n return outResponse;\n };\n}\n\n/**\n * Render the live-preview `<script>` tag — for embedding manually in\n * App Router or Pages Router layouts.\n */\nexport function renderLivePreviewScript(\n options: LivePreviewNextOptions & { readonly nonce?: string } = {},\n): string {\n const body = generateInlineScript({\n ...(options.allowedOrigins !== undefined ? { allowedOrigins: options.allowedOrigins } : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n ...(options.nonce !== undefined ? { nonce: options.nonce } : {}),\n });\n return wrapWithScriptTag(body, options.nonce !== undefined ? { nonce: options.nonce } : {});\n}\n\nfunction buildScriptBody(options: LivePreviewNextOptions): string {\n return generateInlineScript({\n ...(options.allowedOrigins !== undefined ? { allowedOrigins: options.allowedOrigins } : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n });\n}\n\nfunction normalizeManageCsp(\n value: LivePreviewNextOptions['manageCsp'],\n): false | 'frame-ancestors' | 'full' {\n if (value === false) return false;\n if (value === 'full') return 'full';\n return 'frame-ancestors';\n}\n\nasync function injectIntoResponse(response: Response, body: string): Promise<Response> {\n const nonce = response.headers.get('x-live-preview-nonce') ?? generateCspNonce();\n const html = await response.text();\n const headers = new Headers(response.headers);\n headers.delete('content-length');\n headers.set('x-live-preview-nonce', nonce);\n\n // Fragment responses without a <head> are skipped, not prepended to.\n if (!HEAD_INSERT.test(html)) {\n return new Response(html, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n }\n\n const scriptTag = wrapWithScriptTag(body, { nonce });\n const out = html.replace(HEAD_INSERT, (match) => `${match}${scriptTag}`);\n return new Response(out, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n}\n\nfunction addCsp(\n response: Response,\n mode: 'frame-ancestors' | 'full',\n options: LivePreviewNextOptions,\n): Response {\n const nonce = response.headers.get('x-live-preview-nonce') ?? generateCspNonce();\n const frameAncestors = buildFrameAncestors({\n self: true,\n origins: [...(options.allowedOrigins ?? []), ...(options.frameAncestorsExtra ?? [])],\n });\n const additions: Record<string, string> = { 'frame-ancestors': frameAncestors };\n if (mode === 'full') {\n additions['script-src'] = buildScriptSrcWithNonce(nonce, {\n self: true,\n strictDynamic: options.strictDynamic ?? false,\n ...(options.scriptSrcExtra !== undefined ? { extra: options.scriptSrcExtra } : {}),\n });\n }\n const previous = response.headers.get('content-security-policy') ?? '';\n const next = mergeCspHeader(previous, additions);\n try {\n response.headers.set('x-live-preview-nonce', nonce);\n response.headers.set('content-security-policy', next);\n return response;\n } catch {\n const headers = new Headers(response.headers);\n headers.set('x-live-preview-nonce', nonce);\n headers.set('content-security-policy', next);\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n }\n}\n"]}