payload-live-preview 1.8.0 → 2.0.0-beta.0

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.
Files changed (98) hide show
  1. package/README.md +301 -93
  2. package/dist/adapters/astro/PreviewBoundary.astro +66 -0
  3. package/dist/adapters/astro/RichText.astro +6 -0
  4. package/dist/adapters/astro/index.d.ts +165 -134
  5. package/dist/adapters/astro/index.js +1 -1
  6. package/dist/adapters/astro/index.js.map +1 -1
  7. package/dist/adapters/astro/middleware-entry.d.ts +4 -9
  8. package/dist/adapters/astro/middleware-entry.js +1 -1
  9. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  10. package/dist/adapters/nextjs/index.d.ts +13 -80
  11. package/dist/adapters/nextjs/index.js +1 -1
  12. package/dist/adapters/nextjs/index.js.map +1 -1
  13. package/dist/adapters/nuxt/index.d.ts +46 -106
  14. package/dist/adapters/nuxt/index.js +1 -1
  15. package/dist/adapters/nuxt/index.js.map +1 -1
  16. package/dist/adapters/sveltekit/index.d.ts +10 -75
  17. package/dist/adapters/sveltekit/index.js +1 -1
  18. package/dist/adapters/sveltekit/index.js.map +1 -1
  19. package/dist/client.cjs +2 -0
  20. package/dist/client.cjs.map +1 -0
  21. package/dist/client.d.cts +747 -0
  22. package/dist/client.d.ts +747 -0
  23. package/dist/client.js +2 -0
  24. package/dist/client.js.map +1 -0
  25. package/dist/codegen-astro.d.ts +5 -27
  26. package/dist/codegen-astro.js +1 -1
  27. package/dist/codegen-astro.js.map +1 -1
  28. package/dist/codegen-cli.d.ts +3 -16
  29. package/dist/codegen-cli.js +1 -1
  30. package/dist/codegen-cli.js.map +1 -1
  31. package/dist/codegen.cjs +1 -1
  32. package/dist/codegen.cjs.map +1 -1
  33. package/dist/codegen.d.cts +37 -124
  34. package/dist/codegen.d.ts +37 -124
  35. package/dist/codegen.js +1 -1
  36. package/dist/codegen.js.map +1 -1
  37. package/dist/core.cjs +1 -1
  38. package/dist/core.cjs.map +1 -1
  39. package/dist/core.d.cts +647 -1100
  40. package/dist/core.d.ts +647 -1100
  41. package/dist/core.js +1 -1
  42. package/dist/core.js.map +1 -1
  43. package/dist/doctor-cli.d.ts +3 -28
  44. package/dist/doctor-cli.js +1 -1
  45. package/dist/doctor-cli.js.map +1 -1
  46. package/dist/doctor.d.ts +16 -32
  47. package/dist/doctor.js +1 -1
  48. package/dist/doctor.js.map +1 -1
  49. package/dist/fragment.cjs +2 -0
  50. package/dist/fragment.cjs.map +1 -0
  51. package/dist/fragment.d.cts +333 -0
  52. package/dist/fragment.d.ts +333 -0
  53. package/dist/fragment.js +2 -0
  54. package/dist/fragment.js.map +1 -0
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts +885 -1531
  58. package/dist/index.d.ts +885 -1531
  59. package/dist/index.js +1 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/lexical.cjs +2 -0
  62. package/dist/lexical.cjs.map +1 -0
  63. package/dist/lexical.d.cts +90 -0
  64. package/dist/lexical.d.ts +90 -0
  65. package/dist/lexical.js +2 -0
  66. package/dist/lexical.js.map +1 -0
  67. package/dist/middleware-CEPsY1P7.d.ts +40 -0
  68. package/dist/migrate.d.ts +73 -0
  69. package/dist/migrate.js +2 -0
  70. package/dist/migrate.js.map +1 -0
  71. package/dist/options-CEzzfHJu.d.ts +197 -0
  72. package/dist/payload.cjs +1 -1
  73. package/dist/payload.cjs.map +1 -1
  74. package/dist/payload.d.cts +11 -80
  75. package/dist/payload.d.ts +11 -80
  76. package/dist/payload.js +1 -1
  77. package/dist/payload.js.map +1 -1
  78. package/dist/plugins.cjs +2 -0
  79. package/dist/plugins.cjs.map +1 -0
  80. package/dist/plugins.d.cts +509 -0
  81. package/dist/plugins.d.ts +509 -0
  82. package/dist/plugins.js +2 -0
  83. package/dist/plugins.js.map +1 -0
  84. package/dist/{probe-tMHdim5y.d.ts → probe-CYtvj_Lm.d.ts} +43 -77
  85. package/dist/server.cjs +2 -0
  86. package/dist/server.cjs.map +1 -0
  87. package/dist/server.d.cts +435 -0
  88. package/dist/server.d.ts +435 -0
  89. package/dist/server.js +2 -0
  90. package/dist/server.js.map +1 -0
  91. package/dist/structural.cjs +3 -0
  92. package/dist/structural.cjs.map +1 -0
  93. package/dist/structural.d.cts +243 -0
  94. package/dist/structural.d.ts +243 -0
  95. package/dist/structural.js +3 -0
  96. package/dist/structural.js.map +1 -0
  97. package/package.json +86 -7
  98. package/dist/middleware-DD4Hwomt.d.ts +0 -189
@@ -1,2 +1,2 @@
1
- var t=Object.defineProperty,e=(e,i)=>t(e,"name",{value:i,configurable:!0}),i='(()=>{function t(t){return("object"==typeof t&&null!==t||"function"==typeof t)&&"function"==typeof t.then&&(Promise.resolve(t).catch(()=>{}),!0)}function e(e){return(...i)=>{try{t(e(...i))}catch{}}}function i(){}function n(){return!0}function r(t){return`global:${t}`}function l(t,e){return void 0===e||""===e?`collection:${t}`:`collection:${t}:${e}`}function s(t){return"string"==typeof t&&t.length>0}function o(t,e){return null!==e&&void 0!==t&&e.includes(t)}function a(t){let e=t.id;return"string"==typeof e&&e.length>0?e:"number"==typeof e&&Number.isFinite(e)?String(e):void 0}function u(t){if(t.nodeType!==Ze)return!1;let e=t;return!!e.hasAttribute(ke)||null!==e.querySelector(`[${ke}]`)}function h(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){let t=d(i);t&&e.push(t)}return e}function d(t){if("object"!=typeof t||null===t)return;let e=t,i=e.name,n=e.type;if("string"!=typeof i||0===i.length||"string"!=typeof n||0===n.length)return;let r=h(e.fields),l=function(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){if("object"!=typeof i||null===i)continue;let t=i,n=t.slug;if("string"!=typeof n||0===n.length)continue;let r=h(t.fields);e.push({...t,slug:n,fields:r})}return e}(e.blocks),s={...e,name:i,type:n};return r.length>0?s.fields=r:delete s.fields,l.length>0?s.blocks=l:delete s.blocks,s}function c(t){let e="number"==typeof t&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0,i=Math.min(4,e??1),n=new Set;for(let[t,e]of Object.entries(ni))i>=e&&n.add(t);return{ours:4,...void 0!==e?{theirs:e}:{theirs:void 0},negotiated:i,capabilities:n}}function f(t,e){return void 0===t||e(t)}function p(t,e){return null==t||e(t)}function g(t){if("object"!=typeof t||null===t)return!1;let e=Object.getPrototypeOf(t);return null===e||null===Object.getPrototypeOf(e)}function m(t){for(let e of t){let t=e.codePointAt(0);if(void 0!==t&&(t<=31||127===t))return!0}return!1}function y(t){if(void 0===t||0===t.length||t.length>128||"."===t||".."===t||t.includes("/")||t.includes("\\\\")||t.includes("?")||t.includes("#")||m(t))return!1;try{return encodeURIComponent(t),!0}catch{return!1}}function v(t,e){return t[6]===e}function b(t){return t.aborted}function w(t){if("string"!=typeof t||0===t.length)return!1;let e=t.trim();if(0===e.length||$i.test(e))return!1;if(e.startsWith("#")||e.startsWith("?")||e.startsWith("//")||e.startsWith("/"))return!0;try{let t=new URL(e);return Si.has(t.protocol)}catch{return Ai.test(e)}}function S(t){if(!w(t))return!1;let e=t.trim();return/^https?:\\/\\//i.test(e)||/^\\/\\/[^/]/.test(e)}function $(t){return Ni.add(t),t}function A(t,e){return null!==e&&t.generation===e.generation&&t.revision===e.revision}function k(t,e,i,n=!1){if(n&&void 0!==i){let n=T(t,`${e}_${i}`);if(void 0!==n)return n}let r=T(t,e);if(void 0!==r)return r;if(e.includes(".")){let i=t,n=!0;for(let t of e.split(".")){if(Fi.has(t)||null===i||"object"!=typeof i){n=!1;break}if(i=T(i,t),void 0===i){n=!1;break}}if(n)return i}return void 0===i?void 0:T(t,`${e}_${i}`)}function T(t,e){if(!Fi.has(e)&&Object.prototype.hasOwnProperty.call(t,e))return t[e]}function N(){let t=function(){if(typeof document>"u")return;let t=document.documentElement.getAttribute("lang");return null===t||0===t.length?void 0:t}();if(void 0!==t)return t;let e=function(){if(typeof navigator>"u")return;let t=navigator.language;return"string"==typeof t&&t.length>0?t:void 0}();return void 0!==e?e:"en"}function x(t){return/^de(?:[-_]|$)/i.test(t)}function M(t){null!==t[4]&&(clearTimeout(t[4]),t[4]=null),t[2]?.remove(),t[2]=null}function C(t,e=""){let i=new Map;return O(t,e,i),i}function O(t,e,i){for(let n of t){if(Vi.has(n.type)){n.fields&&O(n.fields,e,i);continue}if("group"===n.type){let t=""===e?n.name:`${e}.${n.name}`;i.set(t,n),n.fields&&O(n.fields,t,i);continue}let t=""===e?n.name:`${e}.${n.name}`;if(i.set(t,n),"array"===n.type&&n.fields)O(n.fields,`${t}.*`,i);else if("blocks"===n.type&&n.blocks)for(let e of n.blocks)O(e.fields,`${t}.*.${e.slug}`,i)}}function L(t){if("object"!=typeof t||null===t)return;let e=t.id;return"string"==typeof e||"number"==typeof e?e:void 0}function j(t){if("object"!=typeof t||null===t)return;let e=t.blockType;return"string"==typeof e?e:void 0}function E(t,e){return e.every(t=>void 0!==L(t))?function(t,e){let i=[],n=new Map;for(let e=0;e<t.length;e+=1){let i=L(t[e]);void 0!==i&&n.set(i,e)}let r=new Set;for(let l=0;l<e.length;l+=1){let s=e[l],o=L(s);if(void 0===o){i.push({kind:"insert",index:l,value:s});continue}let a=n.get(o);if(void 0===a){i.push({kind:"insert",index:l,value:s});continue}r.add(a);let u=t[a];j(u)===j(s)?(a!==l&&i.push({kind:"move",from:a,to:l,value:s}),I(u,s)||i.push({kind:"update",index:l,value:s})):i.push({kind:"replace",index:l,oldValue:u,value:s})}for(let e=0;e<t.length;e+=1)r.has(e)||i.push({kind:"remove",index:e,value:t[e]});return i}(t,e):function(t,e){let i=[],n=Math.min(t.length,e.length);for(let r=0;r<n;r+=1)I(t[r],e[r])||i.push({kind:"update",index:r,value:e[r]});if(e.length>t.length)for(let n=t.length;n<e.length;n+=1)i.push({kind:"insert",index:n,value:e[n]});if(t.length>e.length)for(let n=e.length;n<t.length;n+=1)i.push({kind:"remove",index:n,value:t[n]});return i}(t,e)}function I(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||"object"!=typeof e||null===t||null===e)return!1;let i=t,n=e,r=Object.keys(i),l=Object.keys(n);if(r.length!==l.length)return!1;for(let t of r)if(!Object.is(i[t],n[t]))return!1;return!0}function P(t){return 9===t.nodeType}function R(t){if(typeof window>"u")return;let e=[];window.parent!==window&&e.push(window.parent),window.opener instanceof Window&&e.push(window.opener),ri.sendReady(e,t)}function _(t,e){return t.generation===e.generation&&t.revision===e.revision}function W(t){return null!=t&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)}function F(t,e){if(!e)return t;let i=`_${e}`;return t.endsWith(i)?t.slice(0,-i.length):t}function D(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function U(t){if(typeof process<"u"){let e=process.env[t];if("string"==typeof e&&e.length>0)return e}}function z(t){let e=t.trim();if(0!==e.length)try{let t=new URL(e);return"http:"!==t.protocol&&"https:"!==t.protocol||!Sn.test(t.origin)?void 0:t.origin}catch{return}}function V(t,e){let i=G();if(!i)throw new Pn("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===t)return"";let n=function(t){if(!t){let t=new Map;for(let[e,i]of Object.entries(Ln))t.set(e,i);return{allowedTags:Nn,attrByTag:t}}let e=new Set(Nn);for(let i of t.additionalAllowedTags??[])e.add(i);let i=new Map;for(let[t,e]of Object.entries(Ln))i.set(t,e);for(let[e,n]of Object.entries(t.additionalAllowedAttributes??{})){let t=i.get(e),r=new Set(t??[]);for(let t of n)r.add(t);i.set(e,r)}return{allowedTags:e,attrByTag:i}}(e),r=i.createElement("template");return r.innerHTML=t,B(r.content,n),r.innerHTML}function G(){if(!(typeof document>"u"))return document}function B(t,e){for(let i of Array.from(t.childNodes))i.nodeType===En?H(i,e):i.nodeType===In&&i.remove()}function H(t,e){let i=t.tagName.toLowerCase();if(xn.has(i))t.remove();else{if(!e.allowedTags.has(i)){B(t,e);let i=t.parentNode;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);t.remove()}return}(function(t,e,i){let n=i.attrByTag.get(e);for(let e of Array.from(t.attributes)){let i=e.name.toLowerCase();if(i.startsWith("on"))t.removeAttribute(e.name);else if("style"!==i){if(!(Mn.has(i)||i.startsWith(Cn)||i.startsWith(On))){if(n?.has(i)){(jn.has(i)&&!w(e.value)||"srcset"===i&&!q(e.value))&&t.removeAttribute(e.name);continue}t.removeAttribute(e.name)}}else t.removeAttribute(e.name)}})(t,i,e),"a"===i&&function(t){let e=t.getAttribute("href");null===e||!S(e)||(t.setAttribute("rel","noopener noreferrer"),t.hasAttribute("target")||t.setAttribute("target","_blank"))}(t),B(t,e)}}function q(t){let e=t.split(",");for(let t of e){let e=t.trim();if(0===e.length)continue;let i=e.search(/\\s/);if(!w(-1===i?e:e.slice(0,i)))return!1}return!0}function J(t,e){Rn.set(t,e)}function X(t){let e=t.format;if("string"==typeof e&&Wn.has(e))return e;if("number"==typeof e){let t=_n[e];if(void 0!==t)return t}}function Y(t){let e=t.indent;return"number"==typeof e&&e>0?e:0}function Z(t){return"rtl"===t.direction?\' dir="rtl"\':"ltr"===t.direction?\' dir="ltr"\':""}function K(t){let e=X(t),i=Y(t),n=[];return void 0!==e&&n.push(`text-align:${e}`),i>0&&n.push(`padding-inline-start:${String(40*i)}px`),0===n.length?"":` style="${n.join(";")}"`}function Q(t){return""===t?"":t.replace(Dn,t=>Fn[t])}function tt(t){return""===t?"":t.replace(zn,t=>Un[t])}function et(t){return Q(t).replace(/\\r\\n|\\r|\\n/g,"<br>")}function it(t){if("string"==typeof t.text)return t.text;if(!t.children)return"";let e="";for(let i of t.children)e+=it(i);return e}function nt(t){return t.replace(/[^a-zA-Z0-9_-]/g,"")}function rt(t){return Bn.get(t)}function lt(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function st(t){if("object"!=typeof t||null===t||!("root"in t))return!1;let e=t.root;return"object"==typeof e&&null!==e&&"children"in e&&Array.isArray(e.children)}function ot(t){return st(t)?t.root.children.map(ht).join("\\n").trim():""}function at(t){let e="";for(let i of t)e+=ut(i);return e}function ut(t){let e=function(t){return Rn.get(t)}(t.type);return e?e(t,Rt):void 0!==t.children?at(t.children):""}function ht(t){if("string"==typeof t.text)return t.text;if("linebreak"===t.type)return"\\n";if(void 0===t.children)return"";let e="";for(let i of t.children)e+=ht(i);return e}function dt(){let t=new WeakSet;return{name:"text",render:$((e,i)=>{let n=e.element,r=function(t){return null==t?"":st(t)?ot(t):"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}(i);if("INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName){if(function(t){return null!==t.firstElementChild}(n)&&!n.hasAttribute(_t))return function(t,e,i){t.has(e)||(t.add(e),pe(`[live-preview] LP0402: Skipping text update for "${i}": <${e.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}(t,n,e.fieldName),!1;r.includes("\\n")||r.includes("\\r")?n.innerHTML=et(r):n.textContent=r}else n.value=r})}}function ct(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)return String(t);try{return JSON.stringify(t)}catch{return""}}function ft(t){if("object"==typeof t&&null!==t)return t}function pt(t){if("object"==typeof t&&null!==t){let e=t;return"string"==typeof e.title&&e.title.length>0?e.title:"string"==typeof e.name&&e.name.length>0?e.name:"string"==typeof e.slug&&e.slug.length>0?e.slug:void 0!==e.id?String(e.id):""}return ct(t)}function gt(t){return Array.isArray(t)?t.map(t=>gt(t)).join(", "):ct(t)}function mt(t,e){let i=t??"";if(null==e)return i;let n=yt(e);return"{}"===n?i:`${i}|${n}`}function yt(t){if(null===t||"object"!=typeof t)return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(t=>yt(t)).join(",")}]`;let e=t,i=Object.keys(e).sort(),n=[];for(let t of i){let i=e[t];void 0!==i&&n.push(`${JSON.stringify(t)}:${yt(i)}`)}return`{${n.join(",")}}`}function vt(t){for(;t.size>Xt;){let e=t.keys().next().value;if(void 0===e)break;t.delete(e)}}function bt(t,e,i,n){let r="object"==typeof e&&null!==e?e:null;return t.replace(Kt,(t,l)=>null!==r&&function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r,l)?Q(n(Reflect.get(r,l))):null===r&&"value"===l?Q(n(e)):"index"===l?String(i):t)}function wt(t,e,i){return bt(t,e,i,ct)}function St(t){return ct(t)}function $t(t){let{template:e,container:i,patches:n,nextItems:r,store:l,forceRender:s=!1}=t,o=At(i,e,n,r,s,l);return null===o?null:kt(o,l)}function At(t,e,i,n,r,l){let s=function(t){let e=new Set,i=new Set;for(let n of t)"insert"===n.kind||"update"===n.kind?e.add(n.index):"replace"===n.kind&&(e.add(n.index),i.add(n.index));return{renders:e,replaces:i}}(i),o=function(t,e,i,n,r,l,s){let o=Array.from(t.children),a=Lt(o,te),u=new Set,h=[];for(let d=0;d<i.length;d+=1){let c=i[d],f=Ot(c),p=void 0===f?o[d]??null:jt(a,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=n.replaces.has(d),m=r||n.renders.has(d)||null===p?Et(t.ownerDocument,e,c,d):void 0;if(null===m)return null;let y=void 0===m?[]:Tt(g?null:p,m,c,l,s);if(null===y)return null;h.push([d,p,m??void 0,y])}return h}(t,e,n,s,r,l.get(t),l);return null===o?null:[t,o,n]}function kt(t,e){let[i,n,r]=t,l=new Set,s=!1;for(let t of n){let[n,r,o,a]=t,u=r;if(void 0!==o){for(let t of a)null!==t[0]&&(xt(t[0],t[1]),t[1].replaceWith(t[0])),void 0!==t[2]&&kt(t[2],e);null!==r&&(r.replaceWith(o),s=!0),u=o}if(null===u)continue;let h=i.children[n]??null;u!==h&&(i.insertBefore(u,h),s=!0),l.add(u)}for(let t of Array.from(i.children))l.has(t)||(t.remove(),s=!0);let o=function(t,e){let i=e.get(t);return i||(i=new Map,e.set(t,i)),i}(i,e);o.clear();for(let t of r)Ct(o,t);return s}function Tt(t,e,i,n,r){let l=Lt(null===t?[]:Nt(t),ee),s=Ot(i),o=void 0!==s?n?.get(s):void 0,a=[];for(let t of Nt(e)){let e=t.getAttribute(ee);if(null===e)continue;let n,s=jt(l,e)??null,u=t.getAttribute(ie),h=u?s:null,d=h?.getAttribute(ie)??null;if(u){let l=Mt(i,e);if(void 0!==l||null!==h){let i=l??[],s=E(null===h?[]:Mt(o,e)??[],i),a=null!==h&&d!==u;if((s.length>0||a)&&(n=At(h??t,u,s,i,a,r)??void 0,void 0===n))return null}}a.push([h,t,n])}return a}function Nt(t){return Array.from(t.querySelectorAll(`[${ee}]`)).filter(e=>{let i=e.parentElement;for(;null!==i&&i!==t;){if(i.hasAttribute(ee))return!1;i=i.parentElement}return i===t})}function xt(t,e){for(let i of Array.from(t.attributes))e.hasAttribute(i.name)||t.removeAttribute(i.name);for(let i of Array.from(e.attributes))t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}function Mt(t,e){if("object"!=typeof t||null===t)return;let i=t[e];return Array.isArray(i)?i:void 0}function Ct(t,e){let i=Ot(e);void 0!==i&&t.set(i,e)}function Ot(t){if("object"!=typeof t||null===t)return;let e=t.id;return"string"==typeof e||"number"==typeof e?String(e):void 0}function Lt(t,e){let i=new Map;for(let n=t.length-1;n>=0;n-=1){let r=t[n];if(void 0===r)continue;let l=r.getAttribute(e);if(null===l)continue;let s=i.get(l);void 0===s?i.set(l,[r]):s.push(r)}return i}function jt(t,e){return t.get(e)?.pop()}function Et(t,e,i,n){let r=function(t,e,i){return bt(t,e,i,ct)}(e,i,n),l=V(r),s=t.createElement("template");s.innerHTML=l;let o=s.content.firstElementChild;if(!o)return null;let a=Ot(i);return void 0!==a&&o.setAttribute(te,a),o}function It(){let t=new WeakMap,e=new WeakSet,i=new WeakMap;return{name:"structural-array",render:$((n,r)=>{if(!Array.isArray(r))return!1;let l=n.element,s=n.arrayTemplate;if(void 0===s||0===s.length)return function(t,e,i){t.has(e)||(t.add(e),pe(`[live-preview] LP0403: Skipping structural update for "${i}": <${e.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(e,l,n.fieldName),!1;let o=t.get(l),a=Pt(l),u=o?.values??function(t){return t.map((t,e)=>null===t?{__payloadDomPosition:e}:{id:t})}(a),h=E(u,r),d=function(t,e,i){return void 0===t||t.template!==e||!function(t,e){return t.length===e.length&&t.every((t,i)=>t===e[i])}(t.domSnapshot,i)}(o,s,a);if(0===h.length&&!d)return t.set(l,{values:r.slice(),template:s,domSnapshot:a}),!1;let c=$t({template:s,container:l,patches:h,nextItems:r,store:i,forceRender:d});return null!==c&&(t.set(l,{values:r.slice(),template:s,domSnapshot:Pt(l)}),!!c&&void 0)})}}function Pt(t){return Array.from(t.children,t=>t.getAttribute(te))}var Rt,_t,Wt,Ft,Dt,Ut,zt,Vt,Gt,Bt,Ht,qt,Jt,Xt,Yt,Zt,Kt,Qt,te,ee,ie,ne,re,le=Object.defineProperty,se=t=>{throw TypeError(t)},oe=(t,e,i)=>((t,e,i)=>e in t?le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),ae=(t,e,i)=>e.has(t)||se("Cannot "+i),ue=(t,e,i)=>(ae(t,e,"read from private field"),i?i.call(t):e.get(t)),he=(t,e,i)=>e.has(t)?se("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),de=(t,e,i,n)=>(ae(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i),ce=(t,e,i)=>(ae(t,e,"access private method"),i),fe=e((...t)=>console.error(...t)),pe=e((...t)=>console.warn(...t)),ge=e((...t)=>console.debug(...t)),me=class{constructor(){he(this,be);he(this,ye,new Map);he(this,ve,new Map)}on(t,e){return ce(this,be,Se).call(this,ue(this,ye),t,e)}once(t,e){return ce(this,be,Se).call(this,ue(this,ve),t,e)}off(t,e){ce(this,be,$e).call(this,ue(this,ye),t,e),ce(this,be,$e).call(this,ue(this,ve),t,e)}async emit(t,e){await ce(this,be,we).call(this,t,e)}async emitWhile(t,e,i){return ce(this,be,we).call(this,t,e,i)}listenerCount(t){return(ue(this,ye).get(t)?.size??0)+(ue(this,ve).get(t)?.size??0)}removeAllListeners(t){void 0!==t?(ue(this,ye).delete(t),ue(this,ve).delete(t)):(ue(this,ye).clear(),ue(this,ve).clear())}eventNames(){let t=new Set;for(let e of ue(this,ye).keys())t.add(e);for(let e of ue(this,ve).keys())t.add(e);return[...t]}},ye=new WeakMap,ve=new WeakMap,be=new WeakSet,we=async function(t,e,i){let n=()=>i?.()??!0;if(!n())return!1;let r=ue(this,ye).get(t);if(r)for(let i of[...r])if(!n()||(await ce(this,be,Ae).call(this,i,e,t),!n()))return!1;if(!n())return!1;let l=ue(this,ve).get(t);if(l&&l.size>0){let i=[...l];ue(this,ve).delete(t);for(let r of i)if(!n()||(await ce(this,be,Ae).call(this,r,e,t),!n()))return!1}return n()},Se=function(t,e,i){let n=t.get(e);return n||(n=new Set,t.set(e,n)),n.add(i),()=>{ce(this,be,$e).call(this,t,e,i)}},$e=function(t,e,i){let n=t.get(e);void 0!==n&&(n.delete(i),0===n.size&&t.delete(e))},Ae=async function(t,e,i){try{await t(e)}catch(t){let e="string"==typeof i||"number"==typeof i?String(i):"<event>";fe(`[live-preview] LP0601: handler for "${e}" threw:`,t)}},ke="data-payload-field",Te="data-payload-type",Ne="data-payload-attribute",xe="data-payload-href",Me="data-payload-src",Ce="data-payload-alt",Oe="data-payload-array-template",Le="data-payload-array-separator",je="data-payload-locale",Ee="data-payload-richtext",Ie="data-payload-html",Pe="data-payload-array",Re="data-payload-structural",_e="data-payload-owner",We=[ke,Te,Ne,xe,Me,Ce,Oe,Le,je,Ee,Ie,Pe,Re,_e,"type"],Fe=`[${ke}]`,De=`[${_e}]`,Ue=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"]),ze=class{constructor(t={}){he(this,He);he(this,Ve,new Map);he(this,Ge,new WeakMap);he(this,Be);de(this,Be,t.filter??n)}buildFromRoot(t){let e=performance.now();this.clear();let i=t.querySelectorAll(Fe),n=0;for(let t of i)void 0!==this.add(t)&&(n+=1);return{elementCount:n,fieldCount:ue(this,Ve).size,durationMs:performance.now()-e}}add(t){let e=ue(this,Be).call(this,t)?ce(this,He,Ye).call(this,t):void 0,i=ue(this,Ge).get(t);if(void 0!==e)return void 0!==i&&ce(this,He,qe).call(this,i,e)?(ue(this,Ge).set(t,e),e):(void 0!==i&&ce(this,He,Je).call(this,t,i),ce(this,He,Xe).call(this,e),ue(this,Ge).set(t,e),e);void 0!==i&&ce(this,He,Je).call(this,t,i)}remove(t){let e=ue(this,Ge).get(t);return!!e&&ce(this,He,Je).call(this,t,e)}get(t){return ue(this,Ve).get(t)}getByElement(t){return ue(this,Ge).get(t)}get fieldCount(){return ue(this,Ve).size}get elementCount(){let t=0;for(let e of ue(this,Ve).values())t+=e.length;return t}entries(){return ue(this,Ve).entries()}*values(){for(let t of ue(this,Ve).values())yield*t}has(t){return ue(this,Ge).has(t)}clear(){ue(this,Ve).clear(),de(this,Ge,new WeakMap)}},Ve=new WeakMap,Ge=new WeakMap,Be=new WeakMap,He=new WeakSet,qe=function(t,e){if(t.fieldName!==e.fieldName)return!1;let i=ue(this,Ve).get(t.fieldName);if(!i)return!1;let n=i.indexOf(t);return!(n<0||(i[n]=e,0))},Je=function(t,e){let i=ue(this,Ve).get(e.fieldName);if(!i)return ue(this,Ge).delete(t),!1;let n=i.indexOf(e);return n<0?(ue(this,Ge).delete(t),!1):(i.splice(n,1),0===i.length&&ue(this,Ve).delete(e.fieldName),ue(this,Ge).delete(t),!0)},Xe=function(t){let e=ue(this,Ve).get(t.fieldName);e?e.push(t):ue(this,Ve).set(t.fieldName,[t])},Ye=function(t){let e=t.getAttribute(ke);if(null===e||0===e.length)return;let i=t.getAttribute(Te),n=function(t){let e=t.getAttribute(Te);if(null!==e&&Ue.has(e))return e;if(t.hasAttribute(Ee))return"richText";if(t.hasAttribute(Ie))return"html";if(t.hasAttribute(Re))return"structural-array";if(t.hasAttribute(Pe))return"array";if("IMG"===t.tagName)return"image";if("A"===t.tagName)return"url";if("TIME"===t.tagName)return"date";if("INPUT"===t.tagName){let e=t.type;if("checkbox"===e)return"checkbox";if("number"===e)return"number";if("date"===e||"datetime-local"===e)return"date"}return"text"}(t),r=t.getAttribute(Ne),l=t.getAttribute(xe),s=t.getAttribute(Me),o=t.getAttribute(Ce),a=t.getAttribute(Oe),u=t.getAttribute(Le),h=t.getAttribute(je),d=function(t){let e=t.closest(De)?.getAttribute(_e);return null==e||0===e.length?void 0:e}(t);return{element:t,fieldName:e,fieldType:n,explicitFieldType:null!==i&&Ue.has(i),...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==l&&l.length>0?{hrefField:l}:{},...null!==s&&s.length>0?{srcField:s}:{},...null!==o&&o.length>0?{altField:o}:{},...null!==a?{arrayTemplate:a}:{},...null!==u?{arraySeparator:u}:{},...null!==h&&h.length>0?{locale:h}:{},...void 0!==d?{owner:d}:{}}},Ze=1,Ke=class{constructor(t,e={}){he(this,Qe);oe(this,"s");this.s=[t,e.mutationDebounceMs??100,e.intersectionRootMargin??"200px",new Set,null,null,null,0]}start(t){let e=this.s[7];this.stop();let i=e+1;if(this.s[7]!==i)return;let n=null,r=null;try{n=new MutationObserver(t=>{ce(this,Qe,ti).call(this,t,i)}),r=new IntersectionObserver(t=>{ce(this,Qe,ei).call(this,t,i)},{rootMargin:this.s[2],threshold:0}),n.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...We]})}catch(t){throw n?.disconnect(),r?.disconnect(),t}this.s[7]===i?(this.s[4]=n,this.s[5]=r):(n.disconnect(),r.disconnect())}observeElement(t){this.s[5]?.observe(t)}unobserveElement(t){this.s[5]?.unobserve(t),this.s[3].delete(t)}markVisible(t,e){e?this.s[3].add(t):this.s[3].delete(t)}isVisible(t){return this.s[3].has(t)}stop(){this.s[7]+=1;let t=this.s[6],e=this.s[4],i=this.s[5];this.s[6]=null,this.s[4]=null,this.s[5]=null,this.s[3].clear(),null!==t&&clearTimeout(t);try{e?.disconnect()}finally{i?.disconnect()}}},Qe=new WeakSet,ti=function(t,e){if(!ce(this,Qe,ii).call(this,e)||!function(t){for(let e of t){if("attributes"===e.type&&null!==e.attributeName&&We.includes(e.attributeName)&&(e.attributeName===ke||e.attributeName===_e||e.target.nodeType===Ze&&e.target.hasAttribute(ke)))return!0;for(let t of e.addedNodes)if(u(t))return!0;for(let t of e.removedNodes)if(u(t))return!0}return!1}(t)||!ce(this,Qe,ii).call(this,e))return;null!==this.s[6]&&clearTimeout(this.s[6]);let i=setTimeout(()=>{!ce(this,Qe,ii).call(this,e)||this.s[6]!==i||(this.s[6]=null,this.s[0].onStructuralChange())},this.s[1]);this.s[6]=i},ei=function(t,e){for(let i of t){if(!ce(this,Qe,ii).call(this,e))return;let t=i.target;if(i.isIntersecting){if(!this.s[3].has(t)&&(this.s[3].add(t),this.s[0].onVisibilityChange(t,!0),!ce(this,Qe,ii).call(this,e)))return}else if(this.s[3].has(t)&&(this.s[3].delete(t),this.s[0].onVisibilityChange(t,!1),!ce(this,Qe,ii).call(this,e)))return}},ii=function(t){return this.s[7]===t&&null!==this.s[5]},ni={basic:1,"schema-json":2,"preview-token":3,"nested-arrays":4,"recursive-diffs":4},ri=class{constructor(t,e){he(this,li);oe(this,"s");this.s=[t,e,void 0,void 0,0,0,[],0]}attach(t=window){if(void 0!==this.s[3])return;let e=!1,i=t=>{if(!e||this.s[2]!==i)return;let n=this.s[4];try{ce(this,li,si).call(this,t,n)}catch{let e="";try{e=t.origin}catch{}ce(this,li,di).call(this,"shape",e,n)}};this.s[4]+=1,ce(this,li,mi).call(this),this.s[3]=t,this.s[2]=i;try{t.addEventListener("message",i)}catch(e){this.s[2]===i&&(this.s[3]=void 0,this.s[2]=void 0,ce(this,li,mi).call(this));try{t.removeEventListener("message",i)}catch{}throw e}if(this.s[2]===i)e=!0;else try{t.removeEventListener("message",i)}catch{}}detach(t){let e=this.s[3],i=this.s[2];void 0===e||void 0===i||(this.s[3]=void 0,this.s[2]=void 0,ce(this,li,mi).call(this),e.removeEventListener("message",i))}advanceGeneration(){return void 0!==this.s[3]&&(this.s[4]+=1,ce(this,li,mi).call(this),!0)}static sendReady(t,e){let i=t.length>0;if(!i||0===e.length)return;let n={type:"payload-live-preview",ready:i,protocolVersion:4};for(let i of t)for(let t of e)try{i.postMessage(n,t)}catch{}}},li=new WeakSet,si=function(t,e){if(!ce(this,li,pi).call(this,e))return;let i=t.origin;if(!ce(this,li,pi).call(this,e))return;if(!ce(this,li,ci).call(this,i,e)){ce(this,li,di).call(this,"origin",i,e);return}let n=t.data;if(!ce(this,li,pi).call(this,e))return;let r=function(t){return"object"==typeof t&&null!==t&&"type"in t&&"string"==typeof t.type}(n);if(!ce(this,li,pi).call(this,e))return;if(!r){ce(this,li,di).call(this,"shape",i,e);return}let l=n.type;if(ce(this,li,pi).call(this,e))switch(l){case"payload-live-preview":{let t=function(t){let e=t;return!!((void 0===e.data||null===e.data||g(e.data))&&p(e.fieldSchemaJSON,t=>Array.isArray(t))&&p(e.globalSlug,t=>"string"==typeof t)&&p(e.collectionSlug,t=>"string"==typeof t)&&p(e.locale,t=>"string"==typeof t)&&p(e.ready,t=>"boolean"==typeof t)&&p(e.previewToken,t=>"string"==typeof t)&&p(e.protocolVersion,t=>"number"==typeof t))}(n);if(!ce(this,li,pi).call(this,e))return;if(!t){ce(this,li,di).call(this,"shape",i,e);return}let r=function(t){let e={...t};for(let t of yi)null===Reflect.get(e,t)&&Reflect.deleteProperty(e,t);if(!Array.isArray(e.fieldSchemaJSON))return e;let i;try{i=h(e.fieldSchemaJSON)}catch{i=[]}return{...e,fieldSchemaJSON:i}}(n);if(!ce(this,li,pi).call(this,e))return;ce(this,li,oi).call(this,r,i,e);return}case"payload-document-event":{let t=function(t){let e=t;return!(!f(e.action,t=>"updated"===t||"created"===t||"deleted"===t)||!f(e.slug,t=>"string"==typeof t)||!f(e.id,t=>"string"==typeof t||"number"==typeof t&&Number.isFinite(t)))}(n);if(!ce(this,li,pi).call(this,e))return;if(!t){ce(this,li,di).call(this,"shape",i,e);return}let r;try{r=this.s[1].onDocumentEvent}catch{return}if(!ce(this,li,pi).call(this,e))return;ce(this,li,fi).call(this,r,n,i);return}default:ce(this,li,di).call(this,"type",i,e)}},oi=function(t,e,i){if(!ce(this,li,pi).call(this,i))return;let n=t.data;if(!ce(this,li,pi).call(this,i))return;let r=g(n);if(!ce(this,li,pi).call(this,i))return;let l,s=r?{generation:i,revision:this.s[5]+=1}:void 0;try{l=this.s[1].validateToken}catch{return}if(!ce(this,li,pi).call(this,i))return;if(void 0===l){ce(this,li,hi).call(this,t,e,i,s);return}if(!0===t.ready&&void 0===n){ce(this,li,hi).call(this,t,e,i,void 0);return}let o={generation:i,message:t,origin:e,messageRevision:s,settled:!1,approved:!1};this.s[6].push(o);let a;try{a=l(t.previewToken,e)}catch{ce(this,li,ai).call(this,o,!1);return}"boolean"!=typeof a?Promise.resolve(a).then(t=>{ce(this,li,ai).call(this,o,!0===t)},()=>{ce(this,li,ai).call(this,o,!1)}):ce(this,li,ai).call(this,o,a)},ai=function(t,e){ce(this,li,pi).call(this,t.generation)&&(t.approved=e,t.settled=!0,ce(this,li,ui).call(this,t.generation))},ui=function(t){for(;ce(this,li,pi).call(this,t);){let e=this.s[6][this.s[7]];if(void 0===e)return;if(ce(this,li,ci).call(this,e.origin,t)){if(!e.settled)return;ce(this,li,gi).call(this,e)&&(e.approved?ce(this,li,hi).call(this,e.message,e.origin,e.generation,e.messageRevision):ce(this,li,di).call(this,"token",e.origin,e.generation))}else{if(!ce(this,li,gi).call(this,e))continue;ce(this,li,di).call(this,"origin",e.origin,e.generation)}}},hi=function(t,e,i,n){if(!ce(this,li,pi).call(this,i))return;let r;try{r=this.s[1].onUpdate}catch{return}ce(this,li,pi).call(this,i)&&(void 0===n?ce(this,li,fi).call(this,r,t,e):ce(this,li,fi).call(this,r,t,e,n))},di=function(t,e,i){if(!ce(this,li,pi).call(this,i))return;let n;try{n=this.s[1].onInvalid}catch{return}ce(this,li,pi).call(this,i)&&void 0!==n&&ce(this,li,fi).call(this,n,t,e)},ci=function(t,e){if(!ce(this,li,pi).call(this,e))return!1;try{return!0===this.s[0](t)&&ce(this,li,pi).call(this,e)}catch{return!1}},fi=function(e,...i){try{t(e(...i))}catch{}},pi=function(t){return void 0!==this.s[3]&&this.s[4]===t},gi=function(t){let e=this.s;return e[6][e[7]]===t&&(e[7]+=1,e[7]===e[6].length?(ce(this,li,mi).call(this),!0):(e[7]>=1024&&2*e[7]>=e[6].length&&(e[6]=e[6].slice(e[7]),e[7]=0),!0))},mi=function(){this.s[6]=[],this.s[7]=0},yi=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],vi=class{constructor(t){oe(this,"s");this.s=[t.timeoutMs??0,t.onTimeout,null,0]}kick(){if(this.s[3]=Date.now(),this.s[0]<=0)return;null!==this.s[2]&&clearTimeout(this.s[2]);let t=setTimeout(()=>{this.s[2]===t&&(this.s[2]=null,this.s[1]())},this.s[0]);this.s[2]=t}stop(){null!==this.s[2]&&(clearTimeout(this.s[2]),this.s[2]=null)}get lastKickAt(){return this.s[3]}get pending(){return null!==this.s[2]}},bi=class{constructor(t){oe(this,"s");this.s=["disconnected",t]}get status(){return this.s[0]}markConnected(){return this.transition("connected")}markConnecting(){return this.transition("connecting")}markDisconnected(){return this.transition("disconnected")}transition(t){if(this.s[0]===t)return!1;let e=this.s[0];return this.s[0]=t,this.s[1](t,e),!0}},wi=class{constructor(t){oe(this,"s");let n=t.serverURL.replace(/\\/+$/,""),r=t.apiRoute??"/api";this.s=[n,r.startsWith("/")?r:`/${r}`,t.depth??1,t.fetchFn,void 0===t.log?i:e(t.log),null,0,0]}canMerge(t){try{return t.globalSlug?y(t.globalSlug):!!y(t.collectionSlug)&&function(t){if("number"==typeof t)return Number.isFinite(t);if("string"!=typeof t||0===t.length||t.length>512||"."===t||".."===t||t.includes("/")||t.includes("\\\\")||m(t))return!1;try{return encodeURIComponent(t),!0}catch{return!1}}(t.data.id)}catch{return!1}}async merge(t){if(this.s[7]>0)return{status:"superseded"};let e=this.s[6]+1;this.s[6]=e;let i=this.s[5];this.s[5]=null;let n=null;try{if(i?.abort(),!v(this.s,e))return{status:"superseded"};if(!this.canMerge(t))return v(this.s,e)?{status:"unavailable"}:{status:"superseded"};if(!v(this.s,e))return{status:"superseded"};let r=this.s[3]??("function"==typeof fetch?fetch:void 0);if(!v(this.s,e))return{status:"superseded"};if(void 0===r)return{status:"unavailable"};if(n=new AbortController,!v(this.s,e))return n.abort(),{status:"superseded"};this.s[5]=n;let l=t.globalSlug?`globals/${encodeURIComponent(t.globalSlug)}`:`${encodeURIComponent(t.collectionSlug??"")}/${encodeURIComponent(String(t.data.id))}`,s=`${this.s[0]}${this.s[1]}/${l}`,o=JSON.stringify({data:t.data,depth:this.s[2],flattenLocales:!1,...void 0!==t.locale?{locale:t.locale}:{}});if(!v(this.s,e))return{status:"superseded"};let a=await r(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:o,signal:n.signal});if(!v(this.s,e)||b(n.signal))return{status:"superseded"};let u=a.ok;if(!v(this.s,e))return{status:"superseded"};if(!u){let t=a.status;return v(this.s,e)?(this.s[4]("merge HTTP",t,s),v(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"superseded"}}let h=await a.json();return!v(this.s,e)||b(n.signal)?{status:"superseded"}:null===h||"object"!=typeof h||Array.isArray(h)?(this.s[4]("merge invalid",s),v(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"merged",doc:h}}catch(t){return!v(this.s,e)||null!==n&&b(n.signal)?{status:"superseded"}:(this.s[4]("merge exception",t),v(this.s,e)?{status:"unavailable"}:{status:"superseded"})}finally{null!==n&&v(this.s,e)&&this.s[5]===n&&(this.s[5]=null)}}destroy(){this.s[6]+=1;let t=this.s[5];this.s[5]=null,this.s[7]+=1;try{t?.abort()}finally{this.s[7]-=1}}},Si=new Set(["http:","https:","mailto:","tel:"]),$i=/^\\s*(?:javascript|data|vbscript|file|blob|about)\\s*:/i,Ai=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,ki=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Ti=new Set(["href","src","poster","cite","action","xlink:href","data"]),Ni=new WeakSet,xi=class{constructor(t,e){he(this,Mi);oe(this,"s");let i=e.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):t=>setTimeout(()=>{t(performance.now())},0)),n=e.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):t=>{clearTimeout(t)});this.s=[t,e.debounceMs??50,e.isVisible,e.visibilityGateThreshold??50,e.disableVisibilityGate??!1,e.getCacheSize,e.onFlush,i,n,new Map,new Map,new Set,null,0,null,0,null,!1]}schedule(t){if(void 0!==t.identity&&(this.s[17]||!A(t.identity,this.s[16])))return;let e=this.s[9],i=e.get(t.target.element);i?(i.value=t.value,i.allFields=t.allFields,i.identity=t.identity,i.data=t.data):e.set(t.target.element,{...t,identity:t.identity,data:t.data}),ce(this,Mi,Ci).call(this)}acceptRevision(t){let e=this.s[16];A(t,e)||null!==e&&function(t,e){return t.generation!==e.generation?t.generation-e.generation:t.revision-e.revision}(t,e)<0||(ce(this,Mi,_i).call(this),ce(this,Mi,Pi).call(this),this.s[16]=t,this.s[17]=!1)}cancelRevision(t){A(t,this.s[16])&&(ce(this,Mi,_i).call(this),ce(this,Mi,Pi).call(this),this.s[17]=!0)}flushNow(){return ce(this,Mi,_i).call(this),ce(this,Mi,Li).call(this)}notifyVisible(t){let e=this.s[10],i=e.get(t);if(!i||(e.delete(t),!ce(this,Mi,ji).call(this,i)))return;let n=performance.now(),r=ce(this,Mi,Ei).call(this,i)?1:0;this.s[6]?.(ce(this,Mi,Ri).call(this,i,r,0,performance.now()-n,1===r?[i.target.fieldName]:[]))}retarget(t){ce(this,Mi,Ii).call(this,this.s[9],t),ce(this,Mi,Ii).call(this,this.s[10],t);for(let e of this.s[11])ce(this,Mi,Ii).call(this,e,t)}forget(t){this.s[9].delete(t),this.s[10].delete(t);for(let e of this.s[11])e.delete(t)}destroy(){ce(this,Mi,_i).call(this),ce(this,Mi,Pi).call(this),this.s[16]=null,this.s[17]=!1}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}get gateThreshold(){return this.s[3]}get gateActive(){return!this.s[4]&&this.s[5]()>this.s[3]}},Mi=new WeakSet,Ci=function(){let t=this.s[13]+=1,e=this.s[12];if(this.s[12]=null,null!==e&&clearTimeout(e),this.s[13]!==t)return;let i=setTimeout(()=>{this.s[13]===t&&(this.s[12]=null,ce(this,Mi,Oi).call(this))},this.s[1]);this.s[13]===t&&(this.s[12]=i)},Oi=function(){let t=this.s[15]+=1,e=this.s[14];if(this.s[14]=null,null!==e&&this.s[8](e),this.s[15]!==t)return;let i=!1,n=this.s[7](()=>{this.s[15]===t&&(i=!0,this.s[14]=null,ce(this,Mi,Li).call(this))});!i&&this.s[15]===t&&(this.s[14]=n)},Li=function(){let t=performance.now(),e=!this.s[4]&&this.s[5]()>this.s[3],i=this.s[9];this.s[9]=new Map;let n,r=0,l=[],s=0;this.s[11].add(i);try{for(let t of i.values()){if(!ce(this,Mi,ji).call(this,t))continue;let i=!e||this.s[2](t.target.element);if(ce(this,Mi,ji).call(this,t)){if(n??(n=t),!i){this.s[10].set(t.target.element,t),s+=1;continue}this.s[10].delete(t.target.element),ce(this,Mi,Ei).call(this,t)&&(r+=1,l.push(t.target.fieldName))}}}finally{this.s[11].delete(i)}let o=ce(this,Mi,Ri).call(this,n,r,s,performance.now()-t,l);return this.s[6]?.(o),o},ji=function(t){return void 0===t.identity||!this.s[17]&&A(t.identity,this.s[16])},Ei=function(t){let e=this.s[0];return!1!==e(t)||!function(t){return Ni.has(t)}(e)},Ii=function(t,e){let i=t.get(e.element);if(void 0!==i){if(i.target.fieldName!==e.fieldName||i.target.locale!==e.locale){t.delete(e.element);return}i.target=e}},Pi=function(){this.s[9].clear(),this.s[10].clear();for(let t of this.s[11])t.clear()},Ri=function(t,e,i,n,r){return{applied:e,appliedFields:r,deferred:i,durationMs:n,...void 0!==t?.identity?{identity:t.identity}:{},...void 0!==t?.data?{data:t.data}:{}}},_i=function(){let t=this.s[12],e=this.s[14];this.s[13]+=1,this.s[15]+=1,this.s[12]=null,this.s[14]=null,null!==t&&clearTimeout(t),null!==e&&this.s[8](e)},Wi="1.8.0",Fi=new Set(["__proto__","prototype","constructor"]),Di="payload-live-preview-a11y",Ui=new WeakMap,zi=class{constructor(t,e){oe(this,"s");let i=e??(typeof document>"u"?null:document),n=i?.documentElement.getAttribute("lang")??"";this.s=[x(t??(n.length>0?n:N())),i,null]}mount(){let t=this.s[1];if(null==t?.body)return null;let e=this.s[2];null===e&&(e=function(t){let e=Ui.get(t);return e??(e=[null,!1,null,0,null]),Ui.set(t,e),e[3]+=1,e}(t),this.s[2]=e);let i=e[0];if(i?.isConnected&&i.ownerDocument===t)return i;if(null!==i){let t=e[1];M(e),t&&i.remove()}let n=t.getElementById(Di);return e[1]=null===n,n||(n=t.createElement("div"),n.id=Di,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0"),t.body.appendChild(n)),e[0]=n,n}announceConnected(){this.say(this.s[0]?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.s[0]?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(t){t<=0||this.say(this.s[0]?`${String(t)} ${1===t?"\\xc4nderung":"\\xc4nderungen"} angewendet`:`${String(t)} ${1===t?"change":"changes"} applied`)}detach(){let t=this.s[2],e=this.s[1];if(null===t||null===e||(this.s[2]=null,t[3]-=1,t[3]>0))return;let i=t[0];null!==i&&M(t),t[1]&&i?.remove(),t[0]=null,Ui.delete(e)}say(t){let e=this.mount(),i=this.s[2];if(null===e||null===i)return;let n=i[2];n?.parentNode!==e?(n?.remove(),n=e.ownerDocument.createTextNode(e.hasChildNodes()?` ${t}`:t),i[2]=n,e.appendChild(n)):n.data=null===n.previousSibling?t:` ${t}`,null!==i[4]&&clearTimeout(i[4]);let r=setTimeout(()=>{i[4]===r&&i[0]===e&&M(i)},1500);i[4]=r}},Vi=new Set(["tabs","row","collapsible"]),Gi={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"},Bi=[0,500,1e3,2e3],Hi=class{constructor(t){he(this,qi);oe(this,"d");oe(this,"l");let n=t.emitter,r=t.renderers,l=t.resolveRenderer??(t=>r[t]),s=t.transformValue,o=t.root??(typeof document<"u"?document:null),a=t.readyTargets,u=t.sendReady??R,h=t.onHeartbeatTimeout,d=void 0===t.log?i:e(t.log),f=void 0===t.warn?pe:e(t.warn),p=function(t){if(!1===t.enableA11y)return null;let e=void 0===t.root?void 0:9===t.root.nodeType?t.root:t.root.ownerDocument;return new zi(t.a11yLocale,e)}(t),g=void 0!==t.dataMerge?new wi({serverURL:t.dataMerge.serverURL,...void 0!==t.dataMerge.apiRoute?{apiRoute:t.dataMerge.apiRoute}:{},...void 0!==t.dataMerge.depth?{depth:t.dataMerge.depth}:{},...void 0!==t.dataMerge.fetchFn?{fetchFn:t.dataMerge.fetchFn}:{},log:(...t)=>{d(...t)}}):null,m=new ze,y=new Ke({onStructuralChange:()=>{ce(this,qi,Qi).call(this)},onVisibilityChange:(t,e)=>{e&&this.d[3].notifyVisible(t)}},{...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{}}),v=new xi($(t=>ce(this,qi,fn).call(this,t)),{...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.disableVisibilityGate?{disableVisibilityGate:t.disableVisibilityGate}:{},...void 0!==t.visibilityGateThreshold?{visibilityGateThreshold:t.visibilityGateThreshold}:{},isVisible:t=>y.isVisible(t),getCacheSize:()=>m.elementCount,onFlush:t=>{ce(this,qi,pn).call(this,t)}}),b=new ri(t.originMatcher,{onUpdate:(t,e,i)=>{ce(this,qi,en).call(this,t,e,i)},onDocumentEvent:()=>{n.emit("documentSave",{timestamp:Date.now()})},onInvalid:(t,e)=>{if("token"===t){let t=new Error(`Preview token rejected (origin: ${e})`);n.emit("error",{error:t,context:"token",code:"LP0502"})}d("LP0501 message rejected:",t,e)},...void 0!==t.validateToken?{validateToken:t.validateToken}:{}}),w=new bi(()=>{}),S=new vi({...void 0!==t.heartbeatMs?{timeoutMs:t.heartbeatMs}:{},onTimeout:()=>{ce(this,qi,gn).call(this)}});this.d=[n,m,y,v,b,w,S,r,l,s,o,a,u,h,d,f,[],p,g,!0===t.scopeBindingsByOwner,t.lockedOrigin??(()=>{})],this.l=[void 0,void 0,void 0,c(void 0),!1,null,0,null,new Set,!1,!1,0,null,new Set]}start(){if(this.l[4])return!1;this.l[4]=!0;let t=this.d[10];if(P(t)&&"loading"===t.readyState){let e=()=>{if(this.l[4]){this.l[5]=null;try{ce(this,qi,Ji).call(this)}catch(t){ce(this,qi,Yi).call(this),ce(this,qi,yn).call(this,t,"startup","LP0605")}}};this.l[5]=e;try{t.addEventListener("DOMContentLoaded",e,{once:!0})}catch(t){throw ce(this,qi,Yi).call(this),t}return!0}try{return ce(this,qi,Ji).call(this),!0}catch(t){throw ce(this,qi,Yi).call(this),t}}suspend(){return!!this.l[4]&&(ce(this,qi,Xi).call(this)&&this.d[0].emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0)}destroy(){this.l[4]&&(ce(this,qi,Xi).call(this)&&this.d[0].emit("disconnect",{reason:"destroy",timestamp:Date.now()}),this.d[17]?.detach(),this.d[0].emit("destroy",{timestamp:Date.now()}))}refreshCache(){this.l[4]&&ce(this,qi,Qi).call(this)}get status(){return this.d[5].status}get cache(){return this.d[1]}get updateCount(){return this.l[6]}get protocol(){return this.l[3]}inspect(){let t=this.d[1],e=this.d[3],i=this.l[3],n=this.l[7],r=this.l[12],l=[],s=new Set;for(let[e,i]of t.entries()){l.push(e);for(let t of i)void 0!==t.owner&&s.add(t.owner)}return{version:Wi,started:this.l[4],status:this.d[5].status,origins:{trusted:[...this.d[11]],locked:this.d[20]()},protocol:{ours:i.ours,theirs:i.theirs,negotiated:i.negotiated,capabilities:[...i.capabilities].sort()},revisions:{accepted:this.l[6],superseded:this.l[11],active:null===n?void 0:n.identity.revision},bindings:{elements:t.elementCount,fields:t.fieldCount,fieldNames:l.sort(),absentFields:[...this.l[13]].sort(),orphanFields:[...this.l[8]].sort(),ownerScoped:this.d[19],owners:[...s].sort()},scheduler:{pending:e.pendingCount,deferred:e.replayCount,visibilityGateThreshold:e.gateThreshold,visibilityGateActive:e.gateActive,lastFlush:null===r?void 0:{applied:r.applied,appliedFields:r.appliedFields,deferred:r.deferred,durationMs:r.durationMs}},renderers:Object.keys(this.d[7]).sort()}}},qi=new WeakSet,Ji=function(){if(!this.l[4])return;let t=P(this.d[10])?function(t){return t.body}(this.d[10]):this.d[10];if(null===t)throw new Error("LivePreviewRuntime: document.body unavailable");if(this.d[2].start(t),ce(this,qi,Ki).call(this),ce(this,qi,dn).call(this)&&(this.d[4].attach(),this.d[0].emitWhile("init",{timestamp:Date.now()},()=>this.l[4]),ce(this,qi,dn).call(this)))for(let t of Bi){if(!ce(this,qi,dn).call(this))return;if(0===t){if(this.d[12](this.d[11]),!ce(this,qi,dn).call(this))return}else{let e=setTimeout(()=>{this.l[4]&&ce(this,qi,mn).call(this)},t);this.d[16].push(e)}}},Xi=function(){this.l[7]=null,this.l[4]=!1;let t=this.l[5];this.l[5]=null,null!==t&&P(this.d[10])&&ce(this,qi,Zi).call(this,()=>{this.d[10].removeEventListener("DOMContentLoaded",t)});for(let t of this.d[16])ce(this,qi,Zi).call(this,()=>{clearTimeout(t)});return this.d[16].length=0,ce(this,qi,Zi).call(this,()=>{this.d[6].stop()}),ce(this,qi,Zi).call(this,()=>{this.d[4].detach()}),ce(this,qi,Zi).call(this,()=>{this.d[2].stop()}),ce(this,qi,Zi).call(this,()=>{this.d[3].destroy()}),ce(this,qi,Zi).call(this,()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()},Yi=function(){ce(this,qi,Xi).call(this),ce(this,qi,Zi).call(this,()=>{this.d[17]?.detach()})},Zi=function(t){try{t()}catch(t){this.d[14]("cleanup failed:",t)}},Ki=function(){if(!this.l[4])return;let t=this.d[1].buildFromRoot(this.d[10]);if(this.d[14]("cache",t),ce(this,qi,dn).call(this)&&(this.d[0].emitWhile("cacheRefresh",t,()=>this.l[4]),ce(this,qi,dn).call(this)))for(let t of this.d[1].values()){if(!ce(this,qi,dn).call(this))return;this.d[2].observeElement(t.element)}},Qi=function(){if(!this.l[4])return;let t=new Map;for(let e of this.d[1].values())t.set(e.element,e),this.d[2].unobserveElement(e.element);if(ce(this,qi,Ki).call(this),ce(this,qi,dn).call(this)){for(let e of this.d[1].values())t.get(e.element)?.fieldName===e.fieldName?this.d[3].retarget(e):this.d[3].forget(e.element),t.delete(e.element);for(let e of t.values())this.d[3].forget(e.element)}},tn=function(t){let e=this.l[3];if(e.theirs===t)return;let i=c(t);this.l[3]=i,i.negotiated!==e.negotiated&&this.d[14]("protocol","ours=4",`theirs=${t}`,`negotiated=${i.negotiated}`)},en=function(t,e,i){if(this.d[6].kick(),void 0===t.data){void 0!==t.protocolVersion&&ce(this,qi,tn).call(this,t.protocolVersion);return}if(void 0===i)return;"string"==typeof t.locale&&(this.l[0]=t.locale),Array.isArray(t.fieldSchemaJSON)&&(this.l[1]=t.fieldSchemaJSON,this.l[2]=C(t.fieldSchemaJSON));let n={identity:i,message:t,locale:this.l[0],schema:this.l[1],schemaIndex:this.l[2],cancelled:!1};null!==this.l[7]&&(this.l[11]+=1),this.l[7]=n,this.d[3].acceptRevision(i),this.l[6]+=1,(void 0===t.protocolVersion||(ce(this,qi,tn).call(this,t.protocolVersion),this.l[4]&&this.l[7]===n))&&(this.d[5].markConnected()&&(this.d[17]?.announceConnected(),this.d[0].emit("connect",{origin:e,timestamp:Date.now()}),!this.l[4]||this.l[7]!==n||(this.d[14]("connection","disconnected","\\u2192","connected"),!this.l[4]||this.l[7]!==n))||ce(this,qi,nn).call(this,n))},nn=async function(t){let e=await ce(this,qi,rn).call(this,t);if(null===e||!this.l[4]||this.l[7]!==t)return;let{message:i}=t,n={fields:e,...void 0!==t.schema?{schema:t.schema}:{},..."string"==typeof i.globalSlug?{globalSlug:i.globalSlug}:{},..."string"==typeof i.collectionSlug?{collectionSlug:i.collectionSlug}:{},...void 0!==t.locale?{locale:t.locale}:{}};this.d[0].listenerCount("beforeUpdate")>0&&(!await this.d[0].emitWhile("beforeUpdate",{data:n,revision:t.identity.revision,cancel:()=>{t.cancelled=!0,this.d[3].cancelRevision(t.identity)}},()=>!t.cancelled&&this.l[4]&&this.l[7]===t)||t.cancelled||!this.l[4]||this.l[7]!==t)||this.l[4]&&this.l[7]===t&&ce(this,qi,ln).call(this,t,n)},rn=async function(t){let{message:e}=t,i=e.data??{};if(null===this.d[18])return i;let n=await this.d[18].merge({collectionSlug:e.collectionSlug,globalSlug:e.globalSlug,data:i,locale:t.locale});return this.l[4]&&this.l[7]===t?"merged"===n.status?n.doc:"superseded"===n.status?null:i:null},ln=function(t,e){if(!this.l[4]||this.l[7]!==t)return;let i=()=>this.l[4]&&this.l[7]===t,n=ce(this,qi,sn).call(this,t,e.fields);for(let[r,l]of this.d[1].entries()){if(!this.l[4]||this.l[7]!==t)return;for(let s of l){if(!1!==n&&!o(s.owner,n))continue;let l=k(e.fields,r,s.locale??t.locale,void 0!==s.locale);if(void 0===l){this.l[13].add(r);continue}if(!this.l[4]||this.l[7]!==t)return;let a=ce(this,qi,hn).call(this,s,l,e.fields,i);if(!this.l[4]||this.l[7]!==t)return;let u={target:s,value:a,allFields:e.fields,identity:t.identity,data:e};if(!this.l[4]||this.l[7]!==t)return;this.d[3].schedule(u)}}ce(this,qi,un).call(this,e.fields,t.locale,n)},sn=function(t,e){if(!this.d[19])return!1;let{message:i}=t,n=function(t){if(s(t.globalSlug))return[r(t.globalSlug)];if(!s(t.collectionSlug))return null;let e=l(t.collectionSlug);return s(t.documentId)?[e,l(t.collectionSlug,t.documentId)]:[e]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:a(e)});return null===n&&!this.l[9]&&(this.l[9]=!0,this.d[15]("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),n},on=function(t){for(let e of this.d[1].values())if(o(e.owner,t))return!0;return!1},an=function(t,e){let i=this.d[1].get(t);return void 0!==i&&(!1===e||i.some(t=>o(t.owner,e)))},un=function(t,e,i){if(0===this.d[1].fieldCount||!1!==i&&!ce(this,qi,on).call(this,i))return;let n;for(let[r,l]of Object.entries(t)){if(this.l[8].has(r)||bn.has(r)||!W(l))continue;let t=F(r,e);if(!(ce(this,qi,an).call(this,r,i)||t!==r&&ce(this,qi,an).call(this,t,i))){if(void 0===n){n=new Set;for(let[t,e]of this.d[1].entries())for(let r of e)!1!==i&&!o(r.owner,i)||void 0!==r.locale&&n.add(`${t}_${r.locale}`)}n.has(r)||(this.l[8].add(r),this.d[15](`[live-preview] LP0201: update arrived for field "${r}" but no <\\u2026 data-payload-field="${t}"> element exists on this page. Render the binding anchor unconditionally in your template so live edits to an initially-empty field have somewhere to land.`))}}},hn=function(e,i,n,r){if(void 0===this.d[9])return i;try{let l=this.d[9](e.fieldName,i,{element:e.element,allFields:n},r),s=t(l);if(!r())return i;if(s)throw new TypeError(`Transform for "${e.fieldName}" returned a Promise/thenable; transforms must be synchronous`);return l}catch(t){if(!r())return i;let e=t instanceof Error?t:new Error(String(t));return this.d[0].emit("error",{error:e,context:"transform",code:"LP0602"}),i}},dn=function(){return this.l[4]},cn=function(t){0!==t.deferred&&(this.l[10]||(this.l[10]=!0,this.d[15](`[live-preview] LP0301: visibility gate held ${String(t.deferred)} offscreen update(s) until scrolled into view; see visibilityGateThreshold.`)))},fn=function(t){let e=this.l[7];if(null===e||void 0===t.identity||!_(e.identity,t.identity)||!this.l[4]||this.l[7]!==e)return!1;let i=void 0!==e.schemaIndex?function(t,e){if(t.has(e))return t.get(e);let i=e.replace(/\\.\\d+(?=\\.|$)/g,".*");return t.has(i)?t.get(i):void 0}(e.schemaIndex,t.target.fieldName):void 0,n=t.value,r=function(t,e){if(t.explicitFieldType)return t.fieldType;if(void 0!==e){let t=function(t){if(Object.prototype.hasOwnProperty.call(Gi,t))return Gi[t]}(e);if(void 0!==t)return t}return t.fieldType}(t.target,i?.type);"text"===r&&!0!==t.target.explicitFieldType&&function(t){if("object"!=typeof t||null===t||!("root"in t))return!1;let e=t.root;return"object"==typeof e&&null!==e&&Array.isArray(e.children)}(n)&&(r="richText");let l;try{l=this.d[8](r)}catch(t){if(!this.l[4]||this.l[7]!==e)return!1;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:i,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===e),!1}if(!this.l[4]||this.l[7]!==e)return!1;let s=this.d[0].listenerCount("elementUpdate")>0,o=s?function(t){return"INPUT"===t.tagName||"TEXTAREA"===t.tagName?t.value:"IMG"===t.tagName?t.src:t.textContent}(t.target.element):void 0;if(!this.l[4]||this.l[7]!==e)return!1;let a={allFields:t.allFields,locale:t.target.locale??e.locale,schema:i};try{if(void 0!==t.target.targetAttribute){if("blocked"===function(t,e,i){let n=e.toLowerCase().trim();if(0===n.length||n.startsWith("on")||ki.has(n))return"blocked";if(null==i)return t.removeAttribute(n),"applied";if("string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i)return"blocked";let r=String(i);return Ti.has(n)&&!w(r)?"blocked":(t.setAttribute(n,r),"applied")}(t.target.element,t.target.targetAttribute,n))return this.d[15](`[live-preview] LP0401: refused to write field "${t.target.fieldName}" into attribute "${t.target.targetAttribute}" (unsafe attribute or value)`),!1}else{if(!l)return this.d[14]("no renderer for",r),!1;if(!1===function(t,e,i,n){return t.render(e,i,n)}(l,t.target,n,a)&&function(t){return Ni.has(t.render)}(l))return!1}}catch(t){if(!this.l[4]||this.l[7]!==e)return!1;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:i,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===e),!1}return!(!this.l[4]||this.l[7]!==e)&&(s&&this.d[0].emitWhile("elementUpdate",{element:t.target.element,fieldName:t.target.fieldName,previousValue:o,nextValue:n,revision:e.identity.revision},()=>this.l[4]&&this.l[7]===e),this.l[4]&&this.l[7]===e)},pn=function(t){this.l[12]=t,ce(this,qi,cn).call(this,t);let{identity:e,data:i}=t;if(0===t.applied||void 0===e||void 0===i)return;let n=this.l[7];if(null===n||!this.l[4]||this.l[7]!==n||!_(n.identity,e))return;let r=()=>this.l[4]&&this.l[7]===n&&_(n.identity,e);this.d[17]?.announceUpdate(t.applied),r()&&0!==this.d[0].listenerCount("afterUpdate")&&this.d[0].emitWhile("afterUpdate",{data:i,updatedCount:t.applied,durationMs:t.durationMs,revision:e.revision},r)},gn=function(){if(!ce(this,qi,dn).call(this))return;this.d[4].advanceGeneration();let t=this.l[7];this.l[7]=null,null!==t&&this.d[3].cancelRevision(t.identity),this.d[18]?.destroy();let e=this.d[5].markDisconnected();try{this.d[13]?.()}catch(t){this.d[14]("heartbeat:",t)}ce(this,qi,dn).call(this)&&(e&&ce(this,qi,vn).call(this)&&(this.d[17]?.announceDisconnected(),this.d[0].emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>ce(this,qi,vn).call(this)),!ce(this,qi,dn).call(this)||ce(this,qi,vn).call(this)&&(this.d[14]("connection","connected","\\u2192","disconnected"),!ce(this,qi,dn).call(this)))||ce(this,qi,dn).call(this)&&ce(this,qi,mn).call(this))},mn=function(){try{this.d[12](this.d[11])}catch(t){ce(this,qi,yn).call(this,t,"ready","LP0606")}},yn=function(t,e,i){let n=t instanceof Error?t:new Error(String(t));this.d[0].emit("error",{error:n,context:e,code:i})},vn=function(){return this.l[4]&&"disconnected"===this.d[5].status&&null===this.l[7]},bn=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),wn=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,Sn=/^https?:\\/\\/[^/?#\\s]+$/i,$n=["PAYLOAD_ADMIN_ORIGIN","PUBLIC_PAYLOAD_ADMIN_ORIGIN","NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN"],An=class{constructor(t={}){he(this,kn);let e=new Set;for(let i of t.additionalOrigins??[]){let t=z(i);void 0!==t&&e.add(t)}for(let t of $n){let i=U(t);if(void 0!==i)for(let t of i.split(",")){let i=z(t);void 0!==i&&e.add(i)}}let i;if(t.enableReferrerDetection??1){let e=t.referrer??(typeof document<"u"?document.referrer:"");if(e.length>0)try{let t=new URL(e).origin;t&&"null"!==t&&(i=t)}catch{}}let n=(t.enableLocalhostMatching??!0)&&(t.forceDevMode??function(){let t=function(){if(!(typeof process>"u"))return"production"}();if(void 0!==t)return"production"!==t;0;if(typeof window<"u"){let t=window.location.hostname;if("localhost"===t||"127.0.0.1"===t)return!0}return!1}());de(this,kn,[e,i,n,void 0!==i,void 0])}matches(t){return 0!==t.length&&"null"!==t&&(void 0!==ue(this,kn)[4]?t===ue(this,kn)[4]:!!(ue(this,kn)[0].has(t)||0===ue(this,kn)[0].size&&void 0!==ue(this,kn)[1]&&t===ue(this,kn)[1]||ue(this,kn)[2]&&wn.test(t)))}lockOrigin(t){return!!this.matches(t)&&(ue(this,kn)[4]=t,!0)}unlockOrigin(){let t=ue(this,kn)[4];return ue(this,kn)[4]=void 0,t}get lockedOrigin(){return ue(this,kn)[4]}enumerate(){if(void 0!==ue(this,kn)[4])return[ue(this,kn)[4]];let t=new Set(ue(this,kn)[0]);if(0===ue(this,kn)[0].size&&void 0!==ue(this,kn)[1]&&t.add(ue(this,kn)[1]),ue(this,kn)[2])for(let e of Tn)t.add(`http://localhost:${String(e)}`),t.add(`http://127.0.0.1:${String(e)}`);return[...t]}get referrerWasAvailable(){return ue(this,kn)[3]}get isProductionUnconfigured(){return!(!D()||ue(this,kn)[0].size>0||ue(this,kn)[2]||void 0!==ue(this,kn)[1])}get isReferrerOnlyTrust(){return!(ue(this,kn)[0].size>0||ue(this,kn)[2])&&void 0!==ue(this,kn)[1]}},kn=new WeakMap,Tn=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],Nn=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"]),xn=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),Mn=new Set(["id","class","lang","dir","title","role","tabindex"]),Cn="aria-",On="data-",Ln={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"])},jn=new Set(["href","src","cite","poster"]),En=1,In=8,Pn=class extends Error{constructor(){super(...arguments);oe(this,"name","SanitizerEnvironmentError")}},Rn=(Object.freeze({allowedTags:Nn,removeCompletely:xn,globalAttributes:Mn,attributesByTag:Ln,urlAttributes:jn}),new Map),_n={1:"left",2:"center",3:"right",4:"justify"},Wn=new Set(["left","center","right","justify","start","end"]),Fn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),Dn=/[&<>"\'/`=]/g,Un=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),zn=/[&<>"\']/g,Vn=new Set(["h1","h2","h3","h4","h5","h6"]),Gn=(t,e)=>{let i="string"==typeof t.url?t.url:"",n=e.renderChildren(t.children??[]);if(0===i.length||!w(i))return n;let r=S(i)?\' target="_blank" rel="noopener noreferrer"\':function(t){let e="string"==typeof t.target?t.target:"";if(0===e.length)return"";let i=Q(e);return"_blank"===e?\' target="_blank" rel="noopener noreferrer"\':` target="${i}"`}(t),l="string"==typeof t.title?` title="${Q(t.title)}"`:"";return`<a href="${tt(i)}"${r}${l}>${n}</a>`},Bn=new Map;J("text",t=>{let e=Q("string"==typeof t.text?t.text:""),i="number"==typeof t.format?t.format:0;return!!(16&i)&&(e=`<code>${e}</code>`),!!(1&i)&&(e=`<strong>${e}</strong>`),!!(2&i)&&(e=`<em>${e}</em>`),!!(8&i)&&(e=`<u>${e}</u>`),!!(4&i)&&(e=`<s>${e}</s>`),!!(32&i)&&(e=`<sub>${e}</sub>`),!!(64&i)&&(e=`<sup>${e}</sup>`),!!(128&i)&&(e=`<mark>${e}</mark>`),e});J("paragraph",(t,e)=>{let i=e.renderChildren(t.children??[]);return`<p${Z(t)}${K(t)}>${i}</p>`});J("heading",(t,e)=>{let i="string"==typeof t.tag?t.tag.toLowerCase():"h2",n=Vn.has(i)?i:"h2",r=e.renderChildren(t.children??[]);return`<${n}${Z(t)}${K(t)}>${r}</${n}>`});J("list",(t,e)=>{let i="string"==typeof t.listType?t.listType:"bullet",n="number"===i?"ol":"ul",r="number"===i&&"number"==typeof t.start&&t.start>1?` start="${String(t.start)}"`:"",l="check"===i?\' role="list"\':"",s=e.renderChildren(t.children??[]);return`<${n}${Z(t)}${K(t)}${r}${l}>${s}</${n}>`});J("listitem",(t,e)=>{let i=e.renderChildren(t.children??[]);if("boolean"==typeof t.checked)return`<li role="checkbox" aria-checked="${t.checked?"true":"false"}"${K(t)}>${i}</li>`;let n="number"==typeof t.value?` value="${Q(String(t.value))}"`:"";return`<li${Z(t)}${K(t)}${n}>${i}</li>`});J("link",Gn);J("autolink",Gn);J("quote",(t,e)=>{let i=e.renderChildren(t.children??[]);return`<blockquote${Z(t)}${K(t)}>${i}</blockquote>`});J("code",t=>{let e=nt("string"==typeof t.language?t.language:"");return`<pre><code${""===e?"":` class="language-${e}"`}>${Q(it(t))}</code></pre>`});J("code-highlight",t=>{let e="string"==typeof t.text?t.text:"";return`<span${"string"==typeof t.highlightType?` class="token-${nt(t.highlightType)}"`:""}>${Q(e)}</span>`});J("linebreak",()=>"<br>");J("horizontalrule",()=>"<hr>");J("tab",()=>"\\t");J("upload",t=>{let e=function(t){let e=t.value;if("object"==typeof e&&null!==e)return e}(t);if(void 0===e)return"";let i=e.url;if("string"!=typeof i||!w(i))return"";let n="string"==typeof e.mimeType?e.mimeType:"";return n.startsWith("video/")?function(t,e){let i="number"==typeof t.width?` width="${String(t.width)}"`:"",n="number"==typeof t.height?` height="${String(t.height)}"`:"",r="string"==typeof t.mimeType?` type="${tt(t.mimeType)}"`:"";return`<video controls${i}${n}><source src="${tt(e)}"${r}></video>`}(e,i):n.startsWith("audio/")?function(t,e){let i="string"==typeof t.mimeType?` type="${tt(t.mimeType)}"`:"";return`<audio controls><source src="${tt(e)}"${i}></audio>`}(e,i):""===n||n.startsWith("image/")?function(t,e){let i="string"==typeof t.alt?Q(t.alt):"",n="number"==typeof t.width?` width="${String(t.width)}"`:"",r="number"==typeof t.height?` height="${String(t.height)}"`:"";return`<img src="${tt(e)}" alt="${i}"${n}${r} loading="lazy" decoding="async">`}(e,i):function(t,e){let i="string"==typeof t.filename?Q(t.filename):Q(e);return`<a href="${tt(e)}" target="_blank" rel="noopener noreferrer">${i}</a>`}(e,i)});J("relationship",t=>{let e="string"==typeof t.relationTo?t.relationTo:"",i=function(t){let e=t.value;if("object"==typeof e&&null!==e)return e}(t),n=function(t,e){return void 0===t?""===e?"#":`#${e}`:"string"==typeof t.title&&t.title.length>0?t.title:"string"==typeof t.name&&t.name.length>0?t.name:"string"==typeof t.slug&&t.slug.length>0?t.slug:void 0!==t.id?String(t.id):""===e?"#":`#${e}`}(i,e),r=Q(n),l=""===e?"":` data-relation-to="${Q(e)}"`,s=i?.url;return"string"==typeof s&&w(s)?`<a href="${tt(s)}"${l}>${r}</a>`:`<span${l}>${r}</span>`});J("block",(t,e)=>{let i=function(t){let e=t.fields;return"object"!=typeof e||null===e?{}:e}(t),n="string"==typeof i.blockType?i.blockType:"",r=lt(n);if(""!==n){let t=rt(n)??rt(r);if(t)return t(i,{renderChildren:e.renderChildren})}let l=[];""!==r&&l.push(`data-block-type="${Q(r)}"`);for(let[t,e]of Object.entries(i)){if("blockType"===t||"id"===t||null==e)continue;let i="string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);l.push(`data-block-${lt(t)}="${Q(i)}"`)}return`<div${0===l.length?"":` ${l.join(" ")}`}></div>`});Rt={renderChildren:at,resolveAlignment:X,resolveIndent:Y};_t="data-payload-text";Wt={name:"textarea",render(t,e){let i=t.element,n=st(e)?ot(e):ct(e);"INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName?i.innerHTML=et(n):i.value=n}};Ft={name:"richText",render:$((t,e)=>{if(st(e))t.element.innerHTML=function(t,e={}){if(!st(t))return"";let i=at(t.root.children);return!1===e.sanitize||void 0===G()?i:V(i)}(e);else{if("string"!=typeof e)return!1;t.element.innerHTML=V(e)}})};Dt={name:"html",render(t,e){if(null==e){t.element.textContent="";return}let i="string"==typeof e?e:ct(e);t.element.innerHTML=V(i)}};Ut={name:"url",render(t,e,i){let n=t.element,r=ct(e);if("A"===n.tagName){let l=n,s=t.hrefField,o=void 0===s||0===s.length?e:k(i.allFields,s,i.locale,void 0!==t.locale);"string"==typeof o&&w(o)&&(l.href=o),l.textContent=r;return}"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName?n.textContent=r:n.value=r}};zt={name:"image",render:$((t,e,i)=>{let n=t.element,r=ft(e),l=void 0!==t.locale,s=function(t,e,i,n,r,l){if(void 0!==i&&i.length>0){let t=k(n,i,r,l);if("string"==typeof t&&w(t))return t;let e=ft(t);return void 0!==e?.url&&w(e.url)?e.url:void 0}return void 0!==t?.url&&w(t.url)?t.url:"string"==typeof e&&w(e)?e:void 0}(r,e,t.srcField,i.allFields,i.locale,l);if(void 0===s)return!1;if("IMG"===n.tagName){let e=n;e.src=s;let o=function(t,e,i,n,r){if(void 0!==e&&e.length>0){let t=k(i,e,n,r);return"string"==typeof t?t:void 0}if(void 0!==t?.alt)return t.alt}(r,t.altField,i.allFields,i.locale,l);void 0!==o&&(e.alt=o);return}n.style.backgroundImage=`url(\'${function(t){return t.replace(/[\'"()\\\\]/g,"\\\\$&")}(s)}\')`})};Vt={name:"upload",render:$((t,e)=>{let i=t.element,n=function(t){if("object"==typeof t&&null!==t)return t}(e);if(void 0===n)return!1;let r=n.url;if("string"!=typeof r||!w(r))return!1;if("IMG"===i.tagName){let t=i;t.src=r,void 0!==n.alt&&(t.alt=n.alt);return}if("A"===i.tagName){let t=i;t.href=r,t.textContent=n.filename??r;return}let l=void 0!==n.filename?Q(n.filename):Q(r);i.innerHTML=`<a href="${tt(r)}">${l}</a>`})};Gt={name:"relationship",render(t,e){let i=t.element,n=function(t){return null==t?[""]:Array.isArray(t)?t.map(pt):[pt(t)]}(e).join(", ");if("A"===i.tagName&&!Array.isArray(e)){let t=i,r=e?.url;"string"==typeof r&&w(r)&&(t.href=r),t.textContent=n;return}i.textContent=n}};Bt={name:"select",render(t,e){let i=t.element,n=gt(e);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let t=i;t.checked=t.value===n;return}i.textContent=n}else i.value=n}};Ht={name:"checkbox",render(t,e){let i=t.element,n=!!e;"INPUT"!==i.tagName||"checkbox"!==i.type?i.hasAttribute("aria-checked")?i.setAttribute("aria-checked",n?"true":"false"):i.textContent=n?"true":"false":i.checked=n}};qt=new Map,Jt=new Map,Xt=64;Yt={name:"date",render(t,e,i){let n=t.element;if(null==e||""===e){"INPUT"===n.tagName?n.value="":("TIME"===n.tagName&&n.removeAttribute("datetime"),n.textContent="");return}let r="string"==typeof e?e:ct(e),l=new Date(r),s=!Number.isNaN(l.getTime());"INPUT"!==n.tagName?("TIME"!==n.tagName||n.setAttribute("datetime",s?l.toISOString():r),n.textContent=s?function(t,e){let i=e.locale??N();try{return function(t,e){let i=mt(t,e),n=Jt.get(i);if(void 0!==n)return Jt.delete(i),Jt.set(i,n),n;let r=new Intl.DateTimeFormat(t,e);return Jt.set(i,r),vt(Jt),r}(i,{dateStyle:"medium",timeStyle:"short"}).format(t)}catch{return t.toISOString()}}(l,i):r):n.value=s?function(t,e){return"date"===t?e.toISOString().slice(0,10):"datetime-local"===t?e.toISOString().slice(0,16):e.toISOString()}(n.type,l):r}};Zt={name:"number",render(t,e,i){let n=t.element;if(null==e||""===e){"INPUT"===n.tagName?n.value="":n.textContent="";return}let r="number"==typeof e?e:Number(ct(e));Number.isNaN(r)?n.textContent=ct(e):"INPUT"!==n.tagName?n.textContent=function(t,e){let i=e.locale??N();try{return function(t,e){let i=mt(t,e),n=qt.get(i);if(void 0!==n)return qt.delete(i),qt.set(i,n),n;let r=new Intl.NumberFormat(t,e);return qt.set(i,r),vt(qt),r}(i).format(t)}catch{return String(t)}}(r,i):n.value=String(r)}};Kt=/\\{\\{([\\s\\S]*?)\\}\\}/g;Qt={name:"array",render:$((t,e)=>{let i=t.element;if(!Array.isArray(e))return!1;let n=t.arrayTemplate;if(void 0!==n&&n.length>0){let t=function(t,e){let i="";for(let n=0;n<e.length;n+=1)i+=wt(t,e[n],n);return i}(n,e);i.innerHTML=V(t);return}let r=t.arraySeparator??", ";i.textContent=e.map(St).join(r)})};te="data-payload-key",ee="data-payload-nested-key",ie="data-payload-nested-template";ne=new Map;re=[Wt,Ft,Dt,Ut,{...Ut,name:"email"},zt,Vt,Gt,Bt,{...Bt,name:"radio"},Ht,Yt,Zt,Qt,{...Qt,name:"blocks"}];!function(){if(typeof window>"u"||!D()&&(typeof window>"u"||null==window.opener))return;let t=window.__livePreview;if(void 0!==t)return t;let[e=[],i="",n="/api",r=1,l=!1,s=50,o=!0,a=0,u=!1,h=50,d="200px",c=!1,f=!1,p=!1]=typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__,g=new An({additionalOrigins:e,enableReferrerDetection:!c,enableLocalhostMatching:!f});g.isProductionUnconfigured?pe("[live-preview] LP0101: No trusted origin. Set PAYLOAD_ADMIN_ORIGIN or pass allowedOrigins to generateInlineScript()."):g.isReferrerOnlyTrust&&pe("[live-preview] LP0102: document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let m=new me,y=function(t=[]){let e={};for(let i of t)e[i.name]=i;for(let[t,i]of ne)e[t]=i;return Object.freeze(e)}([dt(),...re,It()]),v=new Hi({renderers:y,originMatcher:t=>g.matches(t),lockedOrigin:()=>g.lockedOrigin,readyTargets:g.enumerate(),emitter:m,...""!==i?{dataMerge:{serverURL:i,apiRoute:n,depth:r}}:{},debounceMs:s,heartbeatMs:a,intersectionRootMargin:d,disableVisibilityGate:u,visibilityGateThreshold:h,enableA11y:o,scopeBindingsByOwner:p,onHeartbeatTimeout:()=>{g.unlockOrigin()},...l?{log:(...t)=>{ge("[live-preview]",...t)}}:{}});m.on("connect",t=>{g.lockOrigin(t.origin)}),v.start();let b=function(t,e={}){let i=e.windowTarget??globalThis.window,n=e.documentTarget??globalThis.document,r=e.softNavigationEvents??[],l=()=>{t.suspend()},s=e=>{!0===e.persisted&&t.resume()},o=()=>{t.refreshCache()};i?.addEventListener("pagehide",l),i?.addEventListener("pageshow",s);for(let t of r)n?.addEventListener(t,o);let a=!1;return()=>{if(!a){a=!0,i?.removeEventListener("pagehide",l),i?.removeEventListener("pageshow",s);for(let t of r)n?.removeEventListener(t,o)}}}({suspend:()=>v.suspend(),resume:()=>v.start(),refreshCache:()=>{v.refreshCache()}}),w=Object.freeze({version:Wi,destroy:()=>{b(),v.destroy();let t=window;t.__livePreview===w&&delete t.__livePreview},refresh:()=>{v.refreshCache()},enumerateOrigins:()=>g.enumerate(),inspect:()=>v.inspect()});try{Object.defineProperty(window,"__livePreview",{value:w,writable:!1,configurable:!0})}catch(t){throw b(),v.destroy(),t}}()})();',n='"use strict";(()=>{function t(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function r(){return typeof window>"u"?!1:window.opener!=null}function e(){return t()||r()}function o(){let n=document.createElement("script");n.src=__LP_RUNTIME_SRC__,__LP_RUNTIME_INTEGRITY__!==""&&(n.integrity=__LP_RUNTIME_INTEGRITY__,n.crossOrigin="anonymous"),n.async=!0,document.head.appendChild(n)}e()&&o();})();';function r(t={}){if(0===i.length)throw new Error("[live-preview] runtime.generated.ts is empty. Run `npm run build:runtime` before bundling.");return[`var __LIVE_PREVIEW_CONFIG__=${l(t)};`,i].join("\n")}function l(t){let e=[t.allowedOrigins,t.serverURL,t.apiRoute,t.mergeDepth,t.debug,t.debounceMs,t.enableA11y,t.heartbeatMs,t.disableVisibilityGate,t.visibilityGateThreshold,t.intersectionRootMargin,t.disableReferrerDetection,t.disableLocalhostMatching,t.scopeBindingsByOwner];for(;e.length>0&&void 0===e.at(-1);)e.pop();return`[${e.map(t=>void 0===t?"":JSON.stringify(t)).join(",")}]`.replace(/</g,"\\u003C")}function s(t={},i){if(0===n.length)throw new Error("[live-preview] loader.generated.ts is empty. Run `npm run build:runtime` before bundling.");if(""===i.runtimeSrc)throw new Error("[live-preview] generateLoaderScript needs a runtimeSrc.");let r=e(t=>JSON.stringify(t).replace(/</gu,"\\u003C"),"encode");return[`var __LIVE_PREVIEW_CONFIG__=${l(t)};`,`var __LP_RUNTIME_SRC__=${r(i.runtimeSrc)};`,`var __LP_RUNTIME_INTEGRITY__=${r(i.integrity??"")};`,n].join("\n")}function o(t,e={}){return`<script${void 0!==e.nonce?` nonce="${a(e.nonce)}"`:""}>${t}<\/script>`}function a(t){if(!/^[A-Za-z0-9+/=_-]+$/.test(t))throw new RangeError("wrapWithScriptTag: nonce contains invalid characters");return t}function u(t="/"){let e="_payload-live-preview/runtime.82620c90d7307b6d.js",n=`/${t.replace(/^\/+|\/+$/gu,"")}`;return{fileName:e,urlPath:"/"===n?`/${e}`:`${n}/${e}`,integrity:"sha384-xnuuxRgWkWDi/7WE4cxwZ9KX/pYzfs8zbXhlYw9E+N3soc8cJ+9MQtBFGbEG6V0C",source:i}}e(r,"generateInlineScript"),e(l,"buildConfigLiteral"),e(s,"generateLoaderScript"),e(o,"wrapWithScriptTag"),e(a,"escapeNonce"),e(u,"loaderAsset");var c="virtual:payload-live-preview/options",h=`\0${c}`;function d(t={}){return{name:"payload-live-preview",hooks:{"astro:config:setup":e(e=>{if("middleware"!==t.mode){if(!1!==t.autoInject){if("loader"===t.mode)return void f(e,t);e.injectScript("head-inline",r(p(t)))}}else g(e,t)},"astro:config:setup")}}}function f(t,e){if(void 0===t.updateConfig)throw new Error("payload-live-preview: mode 'loader' needs Astro's updateConfig hook (Astro >= 4) to publish the runtime asset. Upgrade Astro or use the default inline mode.");let i=u(t.config?.base??"/");t.injectScript("head-inline",s(p(e),{runtimeSrc:i.urlPath,integrity:i.integrity})),t.updateConfig({vite:{plugins:[{name:"payload-live-preview:loader-asset",generateBundle(){this.emitFile({type:"asset",fileName:i.fileName,source:i.source})},configureServer(t){t.middlewares.use((t,e,n)=>{(t.url??"").split("?")[0]===i.urlPath?(e.statusCode=200,e.setHeader("Content-Type","text/javascript; charset=utf-8"),e.setHeader("Cache-Control","no-cache"),e.end(i.source)):n()})}}]}})}function p(t){return{...void 0!==t.allowedOrigins?{allowedOrigins:t.allowedOrigins}:{},...void 0!==t.serverURL?{serverURL:t.serverURL}:{},...void 0!==t.apiRoute?{apiRoute:t.apiRoute}:{},...void 0!==t.mergeDepth?{mergeDepth:t.mergeDepth}:{},...void 0!==t.debug?{debug:t.debug}:{},...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.heartbeatMs?{heartbeatMs:t.heartbeatMs}:{}}}function g(t,i){if(void 0===t.addMiddleware||void 0===t.updateConfig)throw new Error("payload-live-preview: mode 'middleware' needs Astro's addMiddleware/updateConfig hooks (Astro >= 4). Upgrade Astro or use the default inline mode.");if(void 0!==i.shouldInject)throw new Error("payload-live-preview: `shouldInject` cannot be used with mode 'middleware' — options are serialized into the build. Use `previewQueryParams`/`previewSignals`, or register createLivePreviewMiddleware() manually in src/middleware.ts.");let{mode:n,shouldInject:r,...l}=i,s=`export default ${JSON.stringify(l).replace(/</g,"\\u003C")};`;t.updateConfig({vite:{plugins:[{name:"payload-live-preview-options",resolveId:e(t=>t===c?h:void 0,"resolveId"),load:e(t=>t===h?s:void 0,"load")}]}}),t.addMiddleware({entrypoint:"payload-live-preview/astro/middleware-entry",order:"pre"})}e(d,"livePreview"),e(f,"setupLoaderMode"),e(p,"inlineConfigFrom"),e(g,"setupMiddlewareMode");var m=/[\t\n\f\r ]+/,v=/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;function y(t){return t.replace(/[A-Z]/g,t=>t.toLowerCase())}function b(t=16){if(!Number.isInteger(t)||t<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(t)}`);let e=w();if(!e)throw new Error("generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) once at startup, or run with --experimental-global-webcrypto. We won't fabricate a predictable nonce — that would silently defeat the entire CSP.");let i=new Uint8Array(t);return e.getRandomValues(i),S(i)}function w(){let t=globalThis.crypto;if(t?.getRandomValues)return t}function S(t){let e="";for(let i of t)e+=String.fromCharCode(i);return("function"==typeof btoa?btoa(e):Buffer.from(t).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function k(t={}){let{self:e=!0,origins:i=[],allowNone:n=!1}=t,r=new Set,l=[];if(n&&!e&&0===i.length)return"'none'";e&&(l.push("'self'"),r.add("'self'"));for(let t of i){let e=t.trim();0===e.length||r.has(e)||(r.add(e),l.push(e))}return l.length>0?l.join(" "):"'none'"}function $(t,e={}){if(0===t.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");let{self:i=!0,extra:n=[],strictDynamic:r=!1}=e,l=[];i&&l.push("'self'"),l.push(`'nonce-${t}'`),r&&l.push("'strict-dynamic'");for(let t of n){let e=t.trim();e.length>0&&l.push(e)}return l.join(" ")}function T(t,e){let i=new Map;for(let e of t.split(";")){let t=e.replace(v,"");if(0===t.length)continue;let n=t.search(m),r=y(n<0?t:t.slice(0,n));if(i.has(r))continue;let l=n<0?"":t.slice(n).replace(v,"");i.set(r,l)}for(let[t,n]of Object.entries(e)){let e=y(t),r="string"==typeof n?{value:n}:n,l=r.mode??"union",s=i.get(e);if("replace"===l||void 0===s||0===s.length){i.set(e,r.value);continue}let o=new Set,a=[];for(let t of[...s.split(m),...r.value.split(m)])0===t.length||o.has(t)||(o.add(t),a.push(t));let u=a.filter(t=>"'none'"!==t);i.set(e,(u.length>0?u:a).join(" "))}let n=[];for(let[t,e]of i)n.push(0===e.length?t:`${t} ${e}`);return n.join("; ")}e(y,"asciiLowercase"),e(b,"generateCspNonce"),e(w,"resolveCrypto"),e(S,"base64UrlEncode"),e(k,"buildFrameAncestors"),e($,"buildScriptSrcWithNonce"),e(T,"mergeCspHeader");var A=["preview","draft","livePreview"];function M(t,e={}){let i=new Set(e.signals??["query","fetch-dest","referer"]),n=e.queryParams??A,r=(e.checkFetchDest??!0)&&i.has("fetch-dest");if(i.has("query")){let e;try{e=new URL(t.url)}catch{e=void 0}if(void 0!==e)for(let t of n){let i=e.searchParams.get(t);if("true"===i||"1"===i)return!0}}if(r&&"iframe"===t.headers.get("sec-fetch-dest"))return!0;let l=i.has("referer")?e.adminOrigins??[]:[];if(l.length>0){let e=t.headers.get("referer");if(null!==e)try{let t=new URL(e).origin;for(let e of l)try{if(new URL(e).origin===t)return!0}catch{}}catch{}}return!1}e(M,"isPreviewRequest");var N="livePreviewNonce",x=/text\/html/i,C=/<head(\s[^>]*)?>/i;function O(t={}){let i,n=t.allowedOrigins??[],l=t.autoInject??!0,s=t.inject??"preview-only",o=L(t.manageCsp),a=t.shouldInject,u=e(()=>(i??=r({...void 0!==t.allowedOrigins?{allowedOrigins:t.allowedOrigins}:{},...void 0!==t.serverURL?{serverURL:t.serverURL}:{},...void 0!==t.apiRoute?{apiRoute:t.apiRoute}:{},...void 0!==t.mergeDepth?{mergeDepth:t.mergeDepth}:{},...void 0!==t.debug?{debug:t.debug}:{},...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.heartbeatMs?{heartbeatMs:t.heartbeatMs}:{}}),i),"scriptBody");return async(e,i)=>{let r=b();e.locals[N]=r;let c=await i();if(!0===e.isPrerendered||"always"!==s&&!M(e.request,{...void 0!==t.previewQueryParams?{queryParams:t.previewQueryParams}:{},...void 0!==t.previewSignals?{signals:t.previewSignals}:{},adminOrigins:n}))return c;let h=c,d=c.headers.get("content-type")??"";return l&&(a?.(e.request)??!0)&&x.test(d)&&(h=await R(c,r,u())),!1!==o&&(h=_(h,r,n,o,t)),h}}function L(t){return!1!==t&&("full"===t?"full":"frame-ancestors")}async function R(t,e,i){let n=await t.text(),r=new Headers(t.headers);if(r.delete("content-length"),!C.test(n))return new Response(n,{status:t.status,statusText:t.statusText,headers:r});let l=o(i,{nonce:e}),s=n.replace(C,t=>`${t}${l}`);return new Response(s,{status:t.status,statusText:t.statusText,headers:r})}function _(t,e,i,n,r){let l={"frame-ancestors":k({self:!0,origins:[...i,...r.frameAncestorsExtra??[]]})};"full"===n&&(l["script-src"]=$(e,{self:!0,strictDynamic:r.strictDynamic??!1,...void 0!==r.scriptSrcExtra?{extra:r.scriptSrcExtra}:{}}));let s=T(t.headers.get("content-security-policy")??"",l);try{return t.headers.set("content-security-policy",s),t}catch{let e=new Headers(t.headers);return e.set("content-security-policy",s),new Response(t.body,{status:t.status,statusText:t.statusText,headers:e})}}function E(t={}){return o(r({...void 0!==t.allowedOrigins?{allowedOrigins:t.allowedOrigins}:{},...void 0!==t.serverURL?{serverURL:t.serverURL}:{},...void 0!==t.apiRoute?{apiRoute:t.apiRoute}:{},...void 0!==t.mergeDepth?{mergeDepth:t.mergeDepth}:{},...void 0!==t.debug?{debug:t.debug}:{},...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.heartbeatMs?{heartbeatMs:t.heartbeatMs}:{},...void 0!==t.nonce?{nonce:t.nonce}:{}}),void 0!==t.nonce?{nonce:t.nonce}:{})}e(O,"createLivePreviewMiddleware"),e(L,"normalizeManageCsp"),e(R,"injectScript"),e(_,"applyCspHeaders"),e(E,"renderLivePreviewScript");export{N as NONCE_LOCALS_KEY,O as createLivePreviewMiddleware,M as isPreviewRequest,d as livePreview,E as renderLivePreviewScript};
1
+ var e='(()=>{function e(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function t(t){return(...n)=>{try{e(t(...n))}catch{}}}function n(){}function i(){return function(){if(typeof document>"u")return;let e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}()??function(){if(typeof navigator>"u")return;let e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}()??"en"}function r(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}function l(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=o(n);e&&t.push(e)}return t}function o(e){if("object"!=typeof e||null===e)return;let t=e,n=t.name,i=t.type;if("string"!=typeof n||0===n.length||"string"!=typeof i||0===i.length)return;let r=l(t.fields),o=function(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if("object"!=typeof n||null===n)continue;let e=n,i=e.slug;if("string"!=typeof i||0===i.length)continue;let r=l(e.fields);t.push({...e,slug:i,fields:r})}return t}(t.blocks),a={...t,name:n,type:i};return r.length>0?a.fields=r:delete a.fields,o.length>0?a.blocks=o:delete a.blocks,a}function a(e,t=""){let n=new Map;return s(e,t,n),n}function s(e,t,n){for(let i of e){if(Dt.has(i.type)){i.fields&&s(i.fields,t,n);continue}let e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&s(i.fields,e,n);else if("array"===i.type&&i.fields)s(i.fields,`${e}.*`,n);else if("blocks"===i.type&&i.blocks)for(let t of i.blocks)s(t.fields,`${e}.*.${t.slug}`,n)}}function u(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function d(e){if("object"!=typeof e||null===e)return;let t=e.blockType;return"string"==typeof t?t:void 0}function c(e,t){return t.every(e=>void 0!==u(e))?function(e,t){let n=[],i=new Map;for(let t=0;t<e.length;t+=1){let n=u(e[t]);void 0!==n&&i.set(n,t)}let r=new Set;for(let l=0;l<t.length;l+=1){let o=t[l],a=u(o);if(void 0===a){n.push({kind:"insert",index:l,value:o});continue}let s=i.get(a);if(void 0===s){n.push({kind:"insert",index:l,value:o});continue}r.add(s);let c=e[s];d(c)===d(o)?(s!==l&&n.push({kind:"move",from:s,to:l,value:o}),h(c,o)||n.push({kind:"update",index:l,value:o})):n.push({kind:"replace",index:l,oldValue:c,value:o})}for(let t=0;t<e.length;t+=1)r.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){let n=[],i=Math.min(e.length,t.length);for(let r=0;r<i;r+=1)h(e[r],t[r])||n.push({kind:"update",index:r,value:t[r]});if(t.length>e.length)for(let i=e.length;i<t.length;i+=1)n.push({kind:"insert",index:i,value:t[i]});if(e.length>t.length)for(let i=t.length;i<e.length;i+=1)n.push({kind:"remove",index:i,value:e[i]});return n}(e,t)}function h(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;let n=e,i=t,r=Object.keys(n),l=Object.keys(i);if(r.length!==l.length)return!1;for(let e of r)if(!Object.is(n[e],i[e]))return!1;return!0}function f(e){if("string"!=typeof e||0===e.length)return!1;let t=e.trim().replace(Gt,"");if(0===t.length||_t.test(t))return!1;if(t.startsWith("#")||t.startsWith("?")||zt.test(t)||t.startsWith("/"))return!0;try{let e=new URL(t);return Bt.has(e.protocol)}catch{return Ht.test(t)}}function p(e){if(!f(e))return!1;let t=e.trim().replace(Gt,"");return/^https?:\\/\\//i.test(t)||zt.test(t)}function g(e){return Kt.add(e),e}function m(e){switch(typeof e){case"string":return e.length>65536?void 0:`s:${e}`;case"number":return`n:${Object.is(e,-0)?"-0":String(e)}`;case"boolean":return"b:"+(e?"1":"0");case"bigint":return`i:${String(e)}`;case"undefined":return"u";case"object":{if(null===e)return"z";let t;try{t=JSON.stringify(e)}catch{return}return t.length>65536?void 0:`o:${t}`}case"symbol":case"function":return}}function v(e,t=[]){let n="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,i=Math.min(4,n??1),r=new Set(t),l=new Set;for(let e of Zt)(i>=Xt[e].since||r.has(e))&&l.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:i,capabilities:l,observed:r}}function y(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function b(e,t){return e.generation===t.generation&&e.revision===t.revision}function w(...e){let t=new Map;for(let n of e)for(let[e,i]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=new Set,t.set(e,n));for(let e of i)n.add(e)}let n={};for(let[e,i]of t)n[e]=[...i];return n}function S(e,t){let n={};for(let i of t)i!==e&&(n[i]=[e]);return n}function k(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(ln)}function T(e){return"patch"===e.getAttribute(ln)}function A(e){return e.closest(`[${an}]`)}function C(e){let t=e.getAttribute(sn);return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==A(e)?"fragment":null!==e.closest("head")?"route":"patch"}function $(e){return Mn.has(e)||Nn.test(e)}function F(e){let t=e.getAttribute(dn);if(null!==t&&$(t))return t;if(e.hasAttribute(yn))return"richText";if(e.hasAttribute(bn))return"html";if(e.hasAttribute(Sn))return"structural-array";if(e.hasAttribute(wn))return"array";if("IMG"===e.tagName)return"image";if("A"===e.tagName)return"url";if("TIME"===e.tagName)return"date";if("INPUT"===e.tagName){let t=e.type;if("checkbox"===t)return"checkbox";if("number"===t)return"number";if("date"===t||"datetime-local"===t)return"date"}return"text"}function R(){return!0}function N(e){for(let t of e){let e=t.codePointAt(0);if(void 0!==e&&(e<=31||127===e))return!0}return!1}function M(e){if(void 0===e||0===e.length||e.length>128||"."===e||".."===e||e.includes("/")||e.includes("\\\\")||e.includes("?")||e.includes("#")||N(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function x(e){return e.aborted}function E(e){return e.has("schema-json")?Ln:e.has("document-events")||e.has("relationship-events")?On:Un}function I(e,t){return void 0===e||t(e)}function L(e,t){return null==e||t(e)}function O(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}function U(e){if(e.nodeType!==Wn)return!1;let t=e;return t.hasAttribute(un)||null!==t.querySelector(`[${un}]`)}function P(e){return`global:${e}`}function j(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function W(e){return"string"==typeof e&&e.length>0}function D(e,t){return null!==t&&void 0!==e&&t.includes(e)}function V(e){let t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function B(e,t,n,i=!1){if(i&&void 0!==n){let i=_(e,`${t}_${n}`);if(void 0!==i)return i}let r=_(e,t);if(void 0!==r)return r;if(t.includes(".")){let n=e,i=!0;for(let e of t.split(".")){if(_n.has(e)||null===n||"object"!=typeof n){i=!1;break}if(n=_(n,e),void 0===n){i=!1;break}}if(i)return n}return void 0===n?void 0:_(e,`${t}_${n}`)}function _(e,t){if(!_n.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function H(e,t,n){let i=e.get(t);return void 0!==i&&(!1===n||i.some(e=>D(e.owner,n)))}function z(e,t){let n=new Set;for(let[i,r]of e.entries())for(let e of r)!1!==t&&!D(e.owner,t)||void 0!==e.locale&&n.add(`${i}_${e.locale}`);return n}function G(e){let t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function q(e,t){if(void 0===t||0===t.length)return e;let n=`_${t}`;return e.endsWith(n)?e.slice(0,-n.length):e}function J(e){let t=function(){if(void 0!==vt)return vt;let e=function(){let e=globalThis.trustedTypes;return"object"!=typeof e||null===e?void 0:"function"==typeof e.createPolicy?e:void 0}();if(void 0===e)return vt=null,null;try{vt=e.createPolicy(zn,{createHTML:e=>e})}catch{vt=null}return vt}();return null===t?e:t.createHTML(e)}function K(e,t){for(let n of t.keyAttributes){let t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function Q(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(ln)||e.hasAttribute(Gn))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function X(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!Q(e)&&!Q(t)}(e,t))return t;let i=function(e){let t=e.ownerDocument.activeElement;return t instanceof HTMLElement&&e.contains(t)?{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}:null}(e);return function(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||qn.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(let n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}(e,t),!0!==n.retainChildrenOf?.(e,t)&&function(e,t,n){let i=function(e,t){let n,i=new Map;for(let r of Array.from(e.children)){let e=K(r,t);if(void 0!==e){if(i.has(e)){n??(n=e.slice(e.indexOf("=")+1));continue}i.set(e,r)}}return void 0!==n&&t.onDuplicateKey?.(e,n),i}(e,n),r=new Set(i.values()),l=Array.from(e.childNodes).filter(e=>!r.has(e)),o=new Set,a=new Set,s=Array.from(t.childNodes),u=e.firstChild,d=0;for(let t=0;t<s.length;t+=1){let r=s[t],c=null,h=r instanceof Element?K(r,n):void 0;if(void 0!==h&&a.has(h)&&(h=void 0),void 0!==h){a.add(h);let e=i.get(h);if(void 0!==e&&!o.has(e)&&(c=Z(e,r,n)===e?e:null,null===c)){e.replaceWith(r),o.add(r),u=r.nextSibling;continue}}else{for(;d<l.length;){let i=l[d];if(d+=1,!o.has(i)){if(ee(i,r)){c=Z(i,r,n)===i?i:null,null===c&&(e.replaceChild(r,i),o.add(r),u=r.nextSibling);break}if(i instanceof Element){let n=s[t+1];if(!(r instanceof Element)||void 0!==n&&ee(i,n)){d-=1;break}e.replaceChild(r,i),o.add(r),u=r.nextSibling;break}if(!(r instanceof Element)){e.replaceChild(r,i),o.add(r),u=r.nextSibling;break}}}if(null===c&&o.has(r))continue}let f=c??r;for(o.add(f);null!==u&&u!==f&&!o.has(u)&&Y(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(let t of Array.from(e.childNodes))o.has(t)||t.remove()}(e,t,n),function(e){if(null===e)return;let{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});let[e,i]=n??[null,null];null!==e&&null!==i&&t.setSelectionRange(e,i)}catch{}}(i),e}function Z(e,t,n){return e instanceof Element&&t instanceof Element?Q(e)&&Q(t)?e:X(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function Y(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function ee(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function te(e,t){let n=ne();if(!n)throw new Error("sanitizeHtml needs a DOM");if(""===e)return"";let i=function(e){if(!e){let e=new Map;for(let[t,n]of Object.entries(ti))e.set(t,n);return{allowedTags:Jn,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:oi,allowedData:new Set}}let t=new Set(Jn);for(let n of e.additionalAllowedTags??[])t.add(n);if(!0===e.allowFormControls)for(let e of Kn)t.add(e);let n=new Map;for(let[e,t]of Object.entries(ti))n.set(e,t);for(let[t,i]of Object.entries(e.additionalAllowedAttributes??{})){let e=n.get(t),r=new Set(e??[]);for(let e of i)r.add(e);n.set(t,r)}return{allowedTags:t,attrByTag:n,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:e.policy??oi,allowedData:new Set((e.allowedDataAttributes??[]).map(e=>e.toLowerCase()))}}(t),r=n.createElement("template");return r.innerHTML=J(e),ie(r.content,i),r.innerHTML}function ne(){if(!(typeof document>"u"))return document}function ie(e,t){for(let n of Array.from(e.childNodes))n.nodeType===ii?re(n,t):n.nodeType===ri&&n.remove()}function re(e,t){let n=e.tagName.toLowerCase();if(!Qn.has(n)||t.allowFormControls&&Kn.has(n)){if(!t.allowedTags.has(n)){ie(e,t);let n=e.parentNode;if(n){for(;e.firstChild;)n.insertBefore(e.firstChild,e);e.remove()}return}(function(e,t,n){let i=n.attrByTag.get(t);for(let t of Array.from(e.attributes)){let r=t.name.toLowerCase();if(r.startsWith("on")||"style"===r)e.removeAttribute(t.name);else{if("strict"===n.mode){if(n.templateMode&&li.has(r))continue;if("id"===r||"name"===r||r.startsWith(ei)){e.removeAttribute(t.name);continue}if(r.startsWith(Yn)){n.allowedData.has(r)||e.removeAttribute(t.name);continue}if(Xn.has(r)||r.startsWith(Zn))continue}else if(Xn.has(r)||r.startsWith(Zn)||r.startsWith(Yn))continue;i?.has(r)?(ni.has(r)&&!f(t.value)||"srcset"===r&&!le(t.value))&&e.removeAttribute(t.name):e.removeAttribute(t.name)}}})(e,n,t),"a"===n&&function(e){let t=e.getAttribute("href");null===t||!p(t)||(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),ie(e,t)}else e.remove()}function le(e){for(let t of e.split(",")){let e=t.trim();if(0===e.length)continue;let n=e.search(/\\s/);if(!f(-1===n?e:e.slice(0,n)))return!1}return!0}function oe(e){return""===e?"":e.replace(si,e=>ai[e])}function ae(e){return""===e?"":e.replace(di,e=>ui[e])}function se(e,t,n,i){let r="object"==typeof t&&null!==t?t:null;return e.replace(ci,(e,l)=>null!==r&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(r,l)?oe(i(Reflect.get(r,l))):null===r&&"value"===l?oe(i(t)):"index"===l?String(n):e)}function ue(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return String(e);try{return JSON.stringify(e)}catch{return""}}function de(e){return null==e||""===e}function ce(e){let t=gi.get(e);if(void 0!==t)return t;let n=new Set(hi);for(let t of e.matchAll(pi)){let e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}let i={};for(let e of n)i[e]=fi;let r={additionalAllowedTags:[...n],additionalAllowedAttributes:i,allowFormControls:!0,templateMode:!0};return gi.set(e,r),r}function he(e){let{template:t,container:n,patches:i,nextItems:r,store:l,forceRender:o=!1}=e,a=pe(n,t,i,r,o,l);return null===a?null:ge(a,l,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function fe(e,t){return t.hasAttribute(vi)&&t.hasAttribute(yi)}function pe(e,t,n,i,r,l){let o=function(e,t,n,i,r,l,o){let a=Array.from(e.children),s=ke(a,mi),u=new Set,d=[];for(let c=0;c<n.length;c+=1){let h=n[c],f=Se(h),p=void 0===f?a[c]??null:Te(s,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=i.replaces.has(c),m=r||i.renders.has(c)||null===p?Ae(e.ownerDocument,t,h,c):void 0;if(null===m)return null;let v=void 0===m?[]:me(g?null:p,m,h,l,o);if(null===v)return null;d.push([c,p,m??void 0,v,g])}return d}(e,t,i,function(e){let t=new Set,n=new Set;for(let i of e)"insert"===i.kind||"update"===i.kind?t.add(i.index):"replace"===i.kind&&(t.add(i.index),n.add(i.index));return{renders:t,replaces:n}}(n),r,l.get(e),l);return null===o?null:[e,o,i]}function ge(e,t,n){let[i,r,l]=e,o=new Set,a=!1;for(let[e,l,s,u,d]of r){let r=l;if(void 0!==s){let e=!(!n.morph||d||null===l)&&X(l,s,{keyAttributes:[mi,vi],retainChildrenOf:fe,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===l;if(!e)for(let[e,t]of u)null!==e&&(ye(e,t),t.replaceWith(e));for(let[,,e]of u)void 0!==e&&ge(e,t,n);e?a=!0:(null!==l&&(l.replaceWith(s),a=!0),r=s)}if(null===r)continue;let c=i.children[e]??null;r!==c&&(i.insertBefore(r,c),a=!0),o.add(r)}for(let e of Array.from(i.children))o.has(e)||(e.remove(),a=!0);let s=function(e,t){let n=t.get(e);return n||(n=new Map,t.set(e,n)),n}(i,t);s.clear();for(let e of l)we(s,e);return a}function me(e,t,n,i,r){let l=ke(null===e?[]:ve(e),vi),o=Se(n),a=void 0!==o?i?.get(o):void 0,s=[];for(let e of ve(t)){let t=e.getAttribute(vi);if(null===t)continue;let i,o=Te(l,t)??null,u=e.getAttribute(yi),d=u?o:null,h=d?.getAttribute(yi)??null;if(u){let l=be(n,t);if(void 0!==l||null!==d){let n=l??[],o=c(null===d?[]:be(a,t)??[],n),s=null!==d&&h!==u;if((o.length>0||s)&&(i=pe(d??e,u,o,n,s,r)??void 0,void 0===i))return null}}s.push([d,e,i])}return s}function ve(e){return Array.from(e.querySelectorAll(`[${vi}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(vi))return!1;n=n.parentElement}return n===e})}function ye(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||e.removeAttribute(n.name);for(let n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function be(e,t){if("object"!=typeof e||null===e)return;let n=e[t];return Array.isArray(n)?n:void 0}function we(e,t){let n=Se(t);void 0!==n&&e.set(n,t)}function Se(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function ke(e,t){let n=new Map;for(let i=e.length-1;i>=0;i-=1){let r=e[i];if(void 0===r)continue;let l=r.getAttribute(t);if(null===l)continue;let o=n.get(l);void 0===o?n.set(l,[r]):o.push(r)}return n}function Te(e,t){return e.get(t)?.pop()}function Ae(e,t,n,i){let r=te(se(t,n,i,ue),ce(t)),l=e.createElement("template");l.innerHTML=J(r);let o=l.content.firstElementChild;if(!o)return null;let a=Se(n);return void 0!==a&&o.setAttribute(mi,a),o}function Ce(e,t,n,i){let r=m(t);if(void 0===r)return;let l=[e.hrefField,e.srcField,e.altField],o=r;for(let t of l){if(void 0===t||0===t.length)continue;let r=m(B(n,t,e.locale??i,void 0!==e.locale));if(void 0===r)return;o+=`|${t}=${r}`}return o}function $e(e,t){return null!==t&&e.generation===t.generation&&e.revision===t.revision}function Fe(e){if(!1===e.enableA11y)return null;let t=e.root,n=void 0===t?void 0:Re(t)?t:t.ownerDocument;return new Wt(e.a11yLocale,n)}function Re(e){return 9===e.nodeType}function Ne(e){return e.body}function Me(e){if(typeof window>"u")return;let t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),jn.sendReady(t,e)}function xe(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Ee(e){let t=e.trim();if(0!==t.length)try{let e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||!Ci.test(e.origin)?void 0:e.origin}catch{return}}function Ie(e){let t=e.format;return"string"==typeof t&&Mi.has(t)?t:"number"==typeof t?Ni[t]:void 0}function Le(e){let t=e.indent;return"number"==typeof t&&t>0?t:0}function Oe(e){return"rtl"===e.direction?\' dir="rtl"\':"ltr"===e.direction?\' dir="ltr"\':""}function Ue(e){let t=Ie(e),n=Le(e),i=[];return void 0!==t&&i.push(`lp-align-${t}`),n>0&&i.push(`lp-indent-${String(n)}`),0===i.length?"":` class="${i.join(" ")}"`}function Pe(e){return"object"==typeof e&&null!==e?e:void 0}function je(e){return Pe(e)}function We(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function De(e){return"string"==typeof e&&e.length>0?e:void 0}function Ve(e){let t=De(e.title)??De(e.name)??De(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}function Be(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(let n of e.children)t+=Be(n);return t}function _e(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function He(e){return"string"==typeof e.mimeType?` type="${ae(e.mimeType)}"`:""}function ze(e){return Li.get(e)}function Ge(e,t,n,i){let r=Pe(e.fields)??{},l="string"==typeof r.blockType?r.blockType:"",o=We(l);if(""!==l){let e=ze(l)??ze(o);if(e)return e(r,{renderChildren:t.renderChildren})}return`<${n} class="${""===o?i:`${i} ${i}--${o}`}"></${n}>`}function qe(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}function Je(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function Ke(e){let t="";for(let n of e)t+=Qe(n);return t}function Qe(e){let t=function(e){return Ui.get(e)??Oi[e]}(e.type);return t?t(e,Pi):void 0!==e.children?Ke(e.children):""}function Xe(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\\n";if(void 0===e.children)return"";let t="";for(let n of e.children)t+=Xe(n);return t}function Ze(e="text"){let t=new WeakSet;return{name:e,render:g((e,n)=>{let i=e.element,r=function(e){return null==e?"":Je(e)?function(e){return Je(e)?e.root.children.map(Xe).join("\\n").trim():""}(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName){if(function(e){return null!==e.querySelector(":scope > :not(br)")}(i)&&!i.hasAttribute(Wi))return function(e,t,n){e.has(t)||(e.add(t),Ft(`[live-preview] LP0402: Skipping text update for "${n}": <${t.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}(t,i,e.fieldName),!1;r.includes("\\n")||r.includes("\\r")?i.innerHTML=J(function(e){return oe(e).replace(/\\r\\n|\\r|\\n/g,"<br>")}(r)):i.textContent=r}else i.value=r})}}function Ye(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:f(n)?{kind:"safe",url:n}:(Bi.has(e)||(Bi.add(e),Ft(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function et(e,t=e=>e){return{name:e,render(e,n,i){let r=e.element;if(de(n)){!function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(r);return}let l=ue(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName){if("A"===r.tagName){let n=e.hrefField,o=void 0===n||0===n.length?t(l):B(i.allFields,n,i.locale,void 0!==e.locale),a=Ye(r,e.fieldName,o);"safe"===a.kind?r.setAttribute("href",a.url):"unsafe"===a.kind&&r.removeAttribute("href")}r.textContent=l}else r.value=l}}}function tt(e){for(let t of Gi)e.removeAttribute(t)}function nt(e,t,n){e.src=t;let i=function(e){if(void 0===e?.sizes)return;let t=[];for(let n of Object.values(e.sizes))"string"!=typeof n.url||"number"!=typeof n.width||!f(n.url)||t.push(`${it(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&f(e.url)&&t.push(`${it(e.url)} ${String(e.width)}w`),t.join(", ")):void 0}(n);void 0!==i?e.setAttribute("srcset",i):(e.removeAttribute("srcset"),e.removeAttribute("sizes"))}function it(e){return e.replace(/[\\s,]/g,encodeURIComponent)}function rt(e){"IMG"===e.tagName?tt(e):e.style.backgroundImage=""}function lt(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):tt(e)}function ot(e){let t=Pe(e);return void 0===t?ue(e):Ve(t)??""}function at(e,t){let n=e??"";if(null==t)return n;let i=st(t);return"{}"===i?n:`${n}|${i}`}function st(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>st(e)).join(",")}]`;let t=e,n=Object.keys(t).sort(),i=[];for(let e of n){let n=t[e];void 0!==n&&i.push(`${JSON.stringify(e)}:${st(n)}`)}return`{${i.join(",")}}`}function ut(e){for(;e.size>tr;){let t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}function dt(e){return String(e).padStart(2,"0")}function ct(){let e=new WeakMap,t=new WeakSet,n=new WeakMap,i=new WeakMap;return{name:"structural-array",render:g((r,l)=>{let o=de(l)?[]:l;if(!Array.isArray(o))return!1;let a=r.element,s=r.arrayTemplate;if(void 0===s||0===s.length)return function(e,t,n){e.has(t)||(e.add(t),Ft(`[live-preview] LP0403: Skipping structural update for "${n}": <${t.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(t,a,r.fieldName),!1;let u=e.get(a),d=ht(a),h=u?.values??function(e){return e.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e})}(d),f=c(h,o),p=function(e,t,n){return void 0===e||e.template!==t||!function(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}(e.domSnapshot,n)}(u,s,d);if(0===f.length&&!p)return e.set(a,{values:o.slice(),template:s,domSnapshot:d}),!1;!function(e,t,n,i,r){let l=r.map(ft),o=new Set,a=l.find(e=>!(void 0===e||!o.has(e)&&(o.add(e),1)));if(void 0!==a&&pt(e,t,n,a),l.some(e=>void 0===e)&&gt(e,t,"LP0404",`LP0404: an item of "${n}" has no id and pairs by position, so an insert re-renders every row after it. Give items a stable id.`),i?.length===r.length&&r.length>1){let r=new Set(i.map(ft).filter(e=>void 0!==e)),o=l.some(e=>void 0!==e&&r.has(e));r.size>0&&!o&&gt(e,t,"LP0406",`LP0406: every key of "${n}" changed at once; the source generates ids per message, so no item can be retained across updates.`)}}(n,a,r.fieldName,u?.values,o);let g=he({template:s,container:a,patches:f,nextItems:o,store:i,forceRender:p,onDuplicateKey:(e,t)=>{pt(n,e,r.fieldName,t)}});return null!==g&&(e.set(a,{values:o.slice(),template:s,domSnapshot:ht(a)}),!!g&&void 0)})}}function ht(e){return Array.from(e.children,e=>e.getAttribute(mi))}function ft(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function pt(e,t,n,i){gt(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${i}"; later ones pair by position. Make \\`id\\` unique per item.`)}function gt(e,t,n,i){let r=e.get(t);void 0===r&&(r=new Set,e.set(t,r)),!r.has(n)&&(r.add(n),Ft(`[live-preview] ${i}`))}function mt(){return typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__}var vt,yt=Object.defineProperty,bt=e=>{throw TypeError(e)},wt=(e,t,n)=>((e,t,n)=>t in e?yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),St=(e,t,n)=>t.has(e)||bt("Cannot "+n),kt=(e,t,n)=>(St(e,t,"read from private field"),n?n.call(e):t.get(e)),Tt=(e,t,n)=>t.has(e)?bt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),At=(e,t,n,i)=>(St(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),Ct=(e,t,n)=>(St(e,t,"access private method"),n),$t=t((...e)=>console.error(...e)),Ft=t((...e)=>console.warn(...e)),Rt=t((...e)=>console.debug(...e)),Nt=class{constructor(){Tt(this,Et);Tt(this,Mt,new Map);Tt(this,xt,new Map)}on(e,t){return Ct(this,Et,Lt).call(this,kt(this,Mt),e,t)}once(e,t){return Ct(this,Et,Lt).call(this,kt(this,xt),e,t)}off(e,t){Ct(this,Et,Ot).call(this,kt(this,Mt),e,t),Ct(this,Et,Ot).call(this,kt(this,xt),e,t)}async emit(e,t){await Ct(this,Et,It).call(this,e,t)}async emitWhile(e,t,n){return Ct(this,Et,It).call(this,e,t,n)}listenerCount(e){return(kt(this,Mt).get(e)?.size??0)+(kt(this,xt).get(e)?.size??0)}removeAllListeners(e){void 0!==e?(kt(this,Mt).delete(e),kt(this,xt).delete(e)):(kt(this,Mt).clear(),kt(this,xt).clear())}eventNames(){let e=new Set;for(let t of kt(this,Mt).keys())e.add(t);for(let t of kt(this,xt).keys())e.add(t);return[...e]}},Mt=new WeakMap,xt=new WeakMap,Et=new WeakSet,It=async function(e,t,n){let i=()=>n?.()??!0;if(!i())return!1;let r=kt(this,Mt).get(e);if(r)for(let n of[...r])if(!i()||(await Ct(this,Et,Ut).call(this,n,t,e),!i()))return!1;if(!i())return!1;let l=kt(this,xt).get(e);if(l&&l.size>0){let n=[...l];kt(this,xt).delete(e);for(let r of n)if(!i()||(await Ct(this,Et,Ut).call(this,r,t,e),!i()))return!1}return i()},Lt=function(e,t,n){let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(n),()=>{Ct(this,Et,Ot).call(this,e,t,n)}},Ot=function(e,t,n){let i=e.get(t);void 0!==i&&(i.delete(n),0===i.size&&e.delete(t))},Ut=async function(e,t,n){try{await e(t)}catch(e){let t="string"==typeof n||"number"==typeof n?String(n):"<event>";$t(`[live-preview] LP0601: handler for "${t}" threw:`,e)}},Pt="payload-live-preview-a11y",jt=new WeakMap,Wt=class{constructor(e,t){wt(this,"german");wt(this,"document");wt(this,"lease",null);let n=t??(typeof document>"u"?null:document),r=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(r.length>0?r:i())),this.document=n}mount(){let e=this.document;if(null==e?.body)return null;this.lease??(this.lease=function(e){let t=jt.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},jt.set(e,t)),t.refs+=1,t}(e));let t=this.lease,n=t.element;if(n?.isConnected&&n.ownerDocument===e)return n;if(null!==n){let e=t.owned;r(t),e&&n.remove()}let i=e.getElementById(Pt);return t.owned=null===i,null===i&&(i=e.createElement("div"),i.id=Pt,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-atomic","true"),i.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0"),e.body.appendChild(i)),t.element=i,i}announceConnected(){this.say(this.german?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.german?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(e){e<=0||this.say(this.german?`${String(e)} ${1===e?"\\xc4nderung":"\\xc4nderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}detach(){let e=this.lease,t=this.document;if(null===e||null===t||(this.lease=null,e.refs-=1,e.refs>0))return;let n=e.element;null!==n&&r(e),e.owned&&n?.remove(),e.element=null,jt.delete(t)}say(e){let t=this.mount(),n=this.lease;if(null===t||null===n)return;let i=n.messageNode;i?.parentNode!==t?(i?.remove(),i=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),n.messageNode=i,t.appendChild(i)):i.data=null===i.previousSibling?e:` ${e}`,null!==n.timer&&clearTimeout(n.timer);let l=setTimeout(()=>{n.timer===l&&n.element===t&&r(n)},1500);n.timer=l}},Dt=new Set(["tabs","row","collapsible"]),Vt={text:"text",textarea:"textarea",richText:"richText",email:"email",number:"number",checkbox:"checkbox",date:"date",select:"select",radio:"radio",array:"array",blocks:"blocks",group:"text",tabs:"text",row:"text",collapsible:"text",relationship:"relationship",upload:"upload",point:"text",json:"text",code:"text",ui:"text"},Bt=new Set(["http:","https:","mailto:","tel:"]),_t=/^\\s*(?:javascript|data|vbscript|file|blob|about)\\s*:/i,Ht=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,zt=/^[\\\\/]{2}/,Gt=/[\\t\\n\\r]/g,qt=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Jt=new Set(["href","src","poster","cite","action","xlink:href","data"]),Kt=new WeakSet,Qt=class{constructor(){wt(this,"previous",null)}diff(e,t){let n=this.previous,i=new Map,r=new Set;for(let[t,l]of Object.entries(e)){let e=m(l);i.set(t,e),(null===n||void 0===e||n.get(t)!==e)&&r.add(t)}if(null!==n)for(let e of n.keys())i.has(e)||r.add(e);this.previous=i;let l=new Set;for(let[e,n]of Object.entries(t))if(r.has(e))for(let e of n)l.add(e);return{changed:r,invalidated:l}}reset(){this.previous=null}},Xt={basic:{since:1},"schema-json":{since:2,observed:"schema"},locale:{since:2,observed:"locale"},"preview-token":{since:3,observed:"preview-token"},"nested-arrays":{since:4},"recursive-diffs":{since:4},"document-events":{since:4,observed:"document-event"},"relationship-events":{since:4,observed:"relationship-event"}},Zt=Object.keys(Xt),Yt=class{constructor(){wt(this,"negotiation",v(void 0));wt(this,"observed",new Set)}observe(e,t){let n=e.filter(e=>!this.observed.has(e));if(0!==n.length){for(let e of n)this.observed.add(e);this.negotiation=v(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}applyVersion(e,t){let n=this.negotiation;if(n.theirs===e)return;let i=v(e,this.observed);this.negotiation=i,i.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${i.negotiated}`)}},en=class{constructor(){Tt(this,tn)}reveal(e,t,n){return e===kt(this,tn)?"skipped-same":(At(this,tn,e),function(e,t){return function(e,t){let n=e.getBoundingClientRect(),i=n.bottom>0&&n.top<t.innerHeight,r=n.right>0&&n.left<t.innerWidth;return i&&r}(e,t)?"already-visible":(e.scrollIntoView({behavior:y(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){At(this,tn,void 0)}},tn=new WeakMap,nn=class{constructor(){wt(this,"started",!1);wt(this,"suspended",!1);wt(this,"deferredStart",null);wt(this,"activeUpdate",null);wt(this,"locale");wt(this,"schema");wt(this,"schemaIndex");wt(this,"updateCount",0);wt(this,"supersededCount",0);wt(this,"completedCount",0);wt(this,"skippedUnchangedCount",0);wt(this,"lastFlush",null);wt(this,"absentFields",new Set);wt(this,"warnedOrphanFields",new Set);wt(this,"warnedStrategy",new WeakSet);wt(this,"warnedUnattributableMessage",!1);wt(this,"warnedVisibilityGate",!1);wt(this,"warnedFragmentFallback",!1);wt(this,"lastAppliedIdentity",new WeakMap);wt(this,"seenFieldIdentity",new Map);wt(this,"fragmentStats",{rendered:0,failed:0,superseded:0});wt(this,"routeStats",{refreshes:0,failed:0,loopStopped:0});wt(this,"fragmentController",null);wt(this,"routeController",null);wt(this,"readyTimers",[]);wt(this,"revealer",new en);wt(this,"changes",new Qt);wt(this,"protocol",new Yt)}isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){e.completed||(e.completed=!0,this.completedCount+=1)}abortStrategies(){for(let e of["fragmentController","routeController"]){let t=this[e];null!==t&&(this[e]=null,t.abort())}}},rn=class{constructor(e,t){wt(this,"deps",e);wt(this,"state",t)}apply(e){let{deps:t,state:n}=this,i=n.activeUpdate;if(null===i||void 0===e.identity||!b(i.identity,e.identity)||!n.isCurrent(i))return!1;let{target:r,value:l}=e,o=void 0!==i.schemaIndex?function(e,t){if(e.has(t))return e.get(t);let n=t.replace(/\\.\\d+(?=\\.|$)/g,".*");return e.has(n)?e.get(n):void 0}(i.schemaIndex,r.fieldName):void 0,a=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){let e=function(e){if(Object.prototype.hasOwnProperty.call(Vt,e))return Vt[e]}(t);if(void 0!==e)return e}return e.fieldType}(r,o?.type);"text"===a&&!0!==r.explicitFieldType&&function(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&Array.isArray(t.children)}(l)&&(a="richText");let s;try{s=t.resolveRenderer(a,r)}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;let u=t.emitter.listenerCount("elementUpdate")>0,d=u?function(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:"IMG"===e.tagName?e.src:e.textContent}(r.element):void 0;if(!n.isCurrent(i))return!1;let c={allFields:e.allFields,locale:r.locale??i.locale,schema:o,...void 0!==t.renderRichText?{renderRichText:t.renderRichText}:{}};!0===r.boundary&&r.element.toggleAttribute("hidden",function(e){return null==e||("string"==typeof e?0===e.trim().length:Array.isArray(e)&&0===e.length)}(l));try{if(void 0!==r.targetAttribute){if("blocked"===function(e,t,n){let i=t.toLowerCase().trim();if(0===i.length||i.startsWith("on")||qt.has(i))return"blocked";if(null==n)return e.removeAttribute(i),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";let r=String(n);return Jt.has(i)&&!f(r)?"blocked":(e.setAttribute(i,r),"applied")}(r.element,r.targetAttribute,l))return t.warn(`[live-preview] LP0401: refused to write "${r.fieldName}" into attribute "${r.targetAttribute}"`),!1}else{if(void 0===s)return t.log("no renderer for",a),!1;if(!1===function(e,t,n,i){return e.render(t,n,i)}(s,r,l,c)&&function(e){return Kt.has(e.render)}(s))return!1}}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;u&&t.emitter.emitWhile("elementUpdate",{element:r.element,fieldName:r.fieldName,previousValue:d,nextValue:l,revision:i.identity.revision,receivedAt:i.receivedAt,source:"patch"},()=>n.isCurrent(i));let h=n.isCurrent(i);return h&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(r.element,e.valueIdentity):n.lastAppliedIdentity.delete(r.element)),h}fail(e,t){if(!this.state.isCurrent(e))return!1;let n=t instanceof Error?t:new Error(String(t));return this.deps.emitter.emitWhile("error",{error:n,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}},ln="data-payload-island",on=`astro-island, [${ln}]`,an="data-payload-fragment",sn="data-payload-strategy",un="data-payload-field",dn="data-payload-type",cn="data-payload-attribute",hn="data-payload-href",fn="data-payload-src",pn="data-payload-alt",gn="data-payload-array-template",mn="data-payload-array-separator",vn="data-payload-locale",yn="data-payload-richtext",bn="data-payload-html",wn="data-payload-array",Sn="data-payload-structural",kn="data-payload-owner",Tn="data-payload-depends",An="data-payload-strategy",Cn="data-payload-boundary",$n=[un,dn,cn,hn,fn,pn,gn,mn,vn,yn,bn,wn,Sn,kn,Tn,An,Cn,"type"],Fn=`[${un}]`,Rn=`[${kn}]`,Nn=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,Mn=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"]),xn=class{constructor(e={}){wt(this,"entriesByField",new Map);wt(this,"entryByElement",new WeakMap);wt(this,"filter");wt(this,"count",0);wt(this,"dependencies",null);wt(this,"islandRoots",[]);this.filter=e.filter??R}dependencyMap(){if(null!==this.dependencies)return this.dependencies;let e=[];for(let t of this.values())void 0!==t.dependsOn&&e.push(S(t.fieldName,t.dependsOn));return this.dependencies=w(...e),this.dependencies}get islands(){return this.islandRoots}buildFromRoot(e){let t=performance.now();this.clear();let n=0;for(let t of e.querySelectorAll(Fn))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){let t=[];for(let n of e.querySelectorAll(on))T(n)||t.push(n);return t}(e),{elementCount:n,fieldCount:this.entriesByField.size,durationMs:performance.now()-t}}add(e){let t=this.filter(e)?this.resolveBinding(e):void 0,n=this.entryByElement.get(e);if(this.dependencies=null,void 0!==t)return void 0!==n&&this.replaceEntry(n,t)?(this.entryByElement.set(e,t),t):(void 0!==n&&this.removeEntry(e,n),this.append(t),this.entryByElement.set(e,t),t);void 0!==n&&this.removeEntry(e,n)}remove(e){let t=this.entryByElement.get(e);return!!t&&(this.dependencies=null,this.removeEntry(e,t))}get(e){return this.entriesByField.get(e)}getByElement(e){return this.entryByElement.get(e)}get fieldCount(){return this.entriesByField.size}get elementCount(){return this.count}entries(){return this.entriesByField.entries()}*values(){for(let e of this.entriesByField.values())yield*e}has(e){return this.entryByElement.has(e)}clear(){this.entriesByField.clear(),this.entryByElement=new WeakMap,this.count=0,this.dependencies=null,this.islandRoots=[]}replaceEntry(e,t){if(e.fieldName!==t.fieldName)return!1;let n=this.entriesByField.get(e.fieldName),i=void 0===n?-1:n.indexOf(e);return!(void 0===n||i<0||(n[i]=t,0))}removeEntry(e,t){this.entryByElement.delete(e);let n=this.entriesByField.get(t.fieldName),i=void 0===n?-1:n.indexOf(t);return!(void 0===n||i<0||(n.splice(i,1),0===n.length&&this.entriesByField.delete(t.fieldName),this.count-=1,0))}append(e){let t=this.entriesByField.get(e.fieldName);t?t.push(e):this.entriesByField.set(e.fieldName,[e]),this.count+=1}resolveBinding(e){let t=e.getAttribute(un);if(null===t||0===t.length)return;let n=e.getAttribute(dn),i=e.getAttribute(cn),r=e.getAttribute(hn),l=e.getAttribute(fn),o=e.getAttribute(pn),a=e.getAttribute(gn),s=e.getAttribute(mn),u=e.getAttribute(vn),d=function(e){let t=e.closest(Rn)?.getAttribute(kn);return null==t||0===t.length?void 0:t}(e),c=function(e){if(null==e)return[];let t=new Set,n=[];for(let i of e.split(/[\\s,]+/)){let e=i.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}(e.getAttribute(Tn)),h=e.getAttribute(An),f=A(e);return{element:e,fieldName:t,fieldType:F(e),explicitFieldType:null!==n&&$(n),strategyKind:C(e)??"unknown",...null!==f?{fragmentBoundary:f}:{},...null!==i&&i.length>0?{targetAttribute:i}:{},...null!==r&&r.length>0?{hrefField:r}:{},...null!==l&&l.length>0?{srcField:l}:{},...null!==o&&o.length>0?{altField:o}:{},...null!==a?{arrayTemplate:a}:{},...null!==s?{arraySeparator:s}:{},...null!==u&&u.length>0?{locale:u}:{},...void 0!==d?{owner:d}:{},...c.length>0?{dependsOn:c}:{},...null!==h&&h.length>0?{strategy:h}:{},...e.hasAttribute(Cn)?{boundary:!0}:{}}}},En=class{constructor(e){wt(this,"serverURL");wt(this,"apiRoute");wt(this,"depth");wt(this,"fetchFn");wt(this,"log");wt(this,"inflight",null);wt(this,"attempt",0);wt(this,"destroyDepth",0);this.serverURL=e.serverURL.replace(/\\/+$/,"");let i=e.apiRoute??"/api";this.apiRoute=i.startsWith("/")?i:`/${i}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=void 0===e.log?n:t(e.log)}canMerge(e){try{return e.globalSlug?M(e.globalSlug):!!M(e.collectionSlug)&&function(e){if("number"==typeof e)return Number.isFinite(e);if("string"!=typeof e||0===e.length||e.length>512||"."===e||".."===e||e.includes("/")||e.includes("\\\\")||N(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}(e.data.id)}catch{return!1}}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};let t=this.attempt+=1,n=this.inflight;this.inflight=null;let i=null,r=()=>this.attempt!==t;try{if(n?.abort(),r())return{status:"superseded"};if(!this.canMerge(e))return r()?{status:"superseded"}:{status:"unavailable"};let t=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===t)return{status:"unavailable"};i=new AbortController,this.inflight=i;let l=e.globalSlug?`globals/${encodeURIComponent(e.globalSlug)}`:`${encodeURIComponent(e.collectionSlug??"")}/${encodeURIComponent(String(e.data.id))}`,o=`${this.serverURL}${this.apiRoute}/${l}`,a=await t(o,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,...void 0!==e.locale?{locale:e.locale}:{}}),signal:i.signal});if(r()||x(i.signal))return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,o),{status:"unavailable"};let s=await a.json();return r()||x(i.signal)?{status:"superseded"}:null===s||"object"!=typeof s||Array.isArray(s)?(this.log("merge invalid",o),{status:"unavailable"}):{status:"merged",doc:s}}catch(e){return r()||null!==i&&x(i.signal)?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{null!==i&&!r()&&this.inflight===i&&(this.inflight=null)}}destroy(){this.attempt+=1;let e=this.inflight;this.inflight=null,this.destroyDepth+=1;try{e?.abort()}finally{this.destroyDepth-=1}}},In="2.0.0-beta.0",Ln={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},On={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},Un={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1},Pn=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],jn=class{constructor(e,t){wt(this,"matcher");wt(this,"handlers");wt(this,"boundListener");wt(this,"attachedTarget");wt(this,"generation",0);wt(this,"revision",0);wt(this,"queue",[]);wt(this,"queueHead",0);this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1,n=e=>{if(!t||this.boundListener!==n)return;let i=this.generation;try{this.receive(e,i)}catch{let t;try{t=e.origin}catch{t=""}this.reportInvalid("shape",t,i)}};this.generation+=1,this.resetQueue(),this.attachedTarget=e,this.boundListener=n;try{e.addEventListener("message",n)}catch(t){this.boundListener===n&&(this.attachedTarget=void 0,this.boundListener=void 0,this.resetQueue());try{e.removeEventListener("message",n)}catch{}throw t}if(this.boundListener===n)t=!0;else try{e.removeEventListener("message",n)}catch{}}detach(){let e=this.attachedTarget,t=this.boundListener;void 0===e||void 0===t||(this.attachedTarget=void 0,this.boundListener=void 0,this.resetQueue(),e.removeEventListener("message",t))}advanceGeneration(){return void 0!==this.attachedTarget&&(this.generation+=1,this.resetQueue(),!0)}static sendReady(e,t){if(0===e.length||0===t.length)return;let n={type:"payload-live-preview",ready:!0,protocolVersion:4};for(let i of e)for(let e of t)try{i.postMessage(n,e)}catch{}}receive(e,t){if(!this.isCurrentGeneration(t))return;let n=e.origin;if(!this.matchesOrigin(n,t)){this.reportInvalid("origin",n,t);return}if(!this.matchesSource(e)){this.reportInvalid("source",n,t);return}let i=e.data;if(function(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}(i))switch(i.type){case"payload-live-preview":if(!function(e){let t=e;return!(void 0!==t.data&&null!==t.data&&!O(t.data))&&L(t.fieldSchemaJSON,e=>Array.isArray(e))&&L(t.globalSlug,e=>"string"==typeof e)&&L(t.collectionSlug,e=>"string"==typeof e)&&L(t.locale,e=>"string"==typeof e)&&L(t.ready,e=>"boolean"==typeof e)&&L(t.previewToken,e=>"string"==typeof e)&&L(t.protocolVersion,e=>"number"==typeof e)}(i)){this.reportInvalid("shape",n,t);return}this.dispatchUpdate(function(e){let t={...e};for(let e of Pn)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=l(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(i),n,t);return;case"payload-document-event":if(!function(e){let t=e;return I(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&I(t.slug,e=>"string"==typeof e)&&I(t.id,e=>"string"==typeof e||"number"==typeof e&&Number.isFinite(e))}(i)){this.reportInvalid("shape",n,t);return}this.invokeHandler(t,this.handlers.onDocumentEvent,i,n);return;case"payload-live-preview-focus":{let e=function(e){let t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(i);if(void 0===e){this.reportInvalid("shape",n,t);return}let r=this.handlers.onFocusField;void 0!==r&&this.invokeHandler(t,r,e,n);return}default:this.reportInvalid("type",n,t)}else this.reportInvalid("shape",n,t)}dispatchUpdate(e,t,n){let i=O(e.data);if(!this.isCurrentGeneration(n))return;let r=i?{generation:n,revision:this.revision+=1}:void 0,l=this.handlers.validateToken;if(!this.isCurrentGeneration(n))return;if(void 0===l){this.commitUpdate(e,t,n,r);return}if(!0===e.ready&&void 0===e.data){this.commitUpdate(e,t,n,void 0);return}let o={generation:n,message:e,origin:t,messageRevision:r,settled:!1,approved:!1};this.queue.push(o);let a;try{a=l(e.previewToken,t)}catch{this.settleValidation(o,!1);return}"boolean"!=typeof a?Promise.resolve(a).then(e=>{this.settleValidation(o,!0===e)},()=>{this.settleValidation(o,!1)}):this.settleValidation(o,a)}settleValidation(e,t){this.isCurrentGeneration(e.generation)&&(e.approved=t,e.settled=!0,this.drainQueue(e.generation))}drainQueue(e){for(;this.isCurrentGeneration(e);){let t=this.queue[this.queueHead];if(void 0===t)return;if(this.matchesOrigin(t.origin,e)){if(!t.settled)return;this.dequeue(t)&&(t.approved?this.commitUpdate(t.message,t.origin,t.generation,t.messageRevision):this.reportInvalid("token",t.origin,t.generation))}else{if(!this.dequeue(t))continue;this.reportInvalid("origin",t.origin,t.generation)}}}commitUpdate(e,t,n,i){this.isCurrentGeneration(n)&&(void 0===i?this.invokeHandler(n,this.handlers.onUpdate,e,t):this.invokeHandler(n,this.handlers.onUpdate,e,t,i))}reportInvalid(e,t,n){if(!this.isCurrentGeneration(n))return;let i=this.handlers.onInvalid;void 0!==i&&this.invokeHandler(n,i,e,t)}matchesSource(e){if("parent-or-opener"!==this.handlers.sourcePolicy)return!0;let t=this.attachedTarget;if(void 0===t)return!1;try{let n=e.source;if(null===n)return!1;let i=t.parent;if(i!==t&&n===i)return!0;let r=t.opener;return null!=r&&n===r}catch{return!1}}matchesOrigin(e,t){if(!this.isCurrentGeneration(t))return!1;try{return!0===this.matcher(e)&&this.isCurrentGeneration(t)}catch{return!1}}invokeHandler(t,n,...i){if(this.isCurrentGeneration(t))try{e(n(...i))}catch{}}isCurrentGeneration(e){return void 0!==this.attachedTarget&&this.generation===e}dequeue(e){return this.queue[this.queueHead]===e&&(this.queueHead+=1,this.queueHead===this.queue.length?(this.resetQueue(),!0):(this.queueHead>=1024&&2*this.queueHead>=this.queue.length&&(this.queue=this.queue.slice(this.queueHead),this.queueHead=0),!0))}resetQueue(){this.queue=[],this.queueHead=0}},Wn=1,Dn=class{constructor(e,t={}){wt(this,"callbacks");wt(this,"debounceMs");wt(this,"rootMargin");wt(this,"visible",new Set);wt(this,"mutation",null);wt(this,"intersection",null);wt(this,"debounceTimer",null);wt(this,"generation",0);this.callbacks=e,this.debounceMs=t.mutationDebounceMs??100,this.rootMargin=t.intersectionRootMargin??"200px"}start(e){let t=this.generation;this.stop();let n=t+1;if(this.generation!==n)return;let i=null,r=null;try{i=new MutationObserver(e=>{this.handleMutations(e,n)}),r=new IntersectionObserver(e=>{this.handleIntersection(e,n)},{rootMargin:this.rootMargin,threshold:0}),i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...$n]})}catch(e){throw i?.disconnect(),r?.disconnect(),e}this.generation===n?(this.mutation=i,this.intersection=r):(i.disconnect(),r.disconnect())}observeElement(e){this.intersection?.observe(e)}unobserveElement(e){this.intersection?.unobserve(e),this.visible.delete(e)}markVisible(e,t){t?this.visible.add(e):this.visible.delete(e)}isVisible(e){return this.visible.has(e)}stop(){this.generation+=1;let e=this.debounceTimer,t=this.mutation,n=this.intersection;this.debounceTimer=null,this.mutation=null,this.intersection=null,this.visible.clear(),null!==e&&clearTimeout(e);try{t?.disconnect()}finally{n?.disconnect()}}handleMutations(e,t){if(!this.isCurrentGeneration(t)||!function(e){for(let t of e){if("attributes"===t.type&&null!==t.attributeName&&$n.includes(t.attributeName)&&(t.attributeName===un||t.attributeName===kn||t.target.nodeType===Wn&&t.target.hasAttribute(un)))return!0;for(let e of t.addedNodes)if(U(e))return!0;for(let e of t.removedNodes)if(U(e))return!0}return!1}(e))return;null!==this.debounceTimer&&clearTimeout(this.debounceTimer);let n=setTimeout(()=>{!this.isCurrentGeneration(t)||this.debounceTimer!==n||(this.debounceTimer=null,this.callbacks.onStructuralChange())},this.debounceMs);this.debounceTimer=n}handleIntersection(e,t){for(let n of e){if(!this.isCurrentGeneration(t))return;let{target:e}=n;if(n.isIntersecting){if(this.visible.has(e))continue;this.visible.add(e),this.callbacks.onVisibilityChange(e,!0)}else this.visible.has(e)&&(this.visible.delete(e),this.callbacks.onVisibilityChange(e,!1))}}isCurrentGeneration(e){return this.generation===e&&null!==this.intersection}},Vn=class{constructor(e){wt(this,"timeoutMs");wt(this,"onTimeout");wt(this,"handle",null);wt(this,"lastKick",0);this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){if(this.lastKick=Date.now(),this.timeoutMs<=0)return;null!==this.handle&&clearTimeout(this.handle);let e=setTimeout(()=>{this.handle===e&&(this.handle=null,this.onTimeout())},this.timeoutMs);this.handle=e}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick}get pending(){return null!==this.handle}},Bn=class{constructor(){wt(this,"current","disconnected")}get status(){return this.current}markConnected(){return this.transition("connected")}markDisconnected(){return this.transition("disconnected")}transition(e){return this.current!==e&&(this.current=e,!0)}},_n=new Set(["__proto__","prototype","constructor"]),Hn=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),zn="payload-live-preview",Gn="data-payload-owned",qn=new Set(["open","value","checked","selected"]),Jn=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"]),Kn=new Set(["input","button","textarea","select","option","label"]),Qn=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),Xn=new Set(["id","class","lang","dir","title","role","tabindex"]),Zn="aria-",Yn="data-",ei="data-payload-",ti={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"])},ni=new Set(["href","src","cite","poster"]),ii=1,ri=8,li=(Error,new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"])),oi="strict",ai=(Object.freeze({allowedTags:Jn,removeCompletely:Qn,globalAttributes:Xn,attributesByTag:ti,urlAttributes:ni}),Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"})),si=/[&<>"\'/`=]/g,ui=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),di=/[&<>"\']/g,ci=/\\{\\{([\\s\\S]*?)\\}\\}/g,hi=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],fi=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],pi=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\\b/gi,gi=new Map,mi="data-payload-key",vi="data-payload-nested-key",yi="data-payload-nested-template",bi=class{constructor(e,t,n){wt(this,"deps",e);wt(this,"state",t);wt(this,"host",n)}planFragments(e){let t=this.deps.strategies.fragment;if(void 0===t)return null;let n=t.plan(this.deps.root,e),i=new Set(n);return{boundaries:n,strategy:t,covers:e=>void 0!==e.fragmentBoundary&&i.has(e.fragmentBoundary)}}hasRouteBinding(e){for(let[t,n]of this.deps.cache.entries())if(e.has(t)&&n.some(e=>"route"===e.strategyKind))return!0;return!1}async runFragments(e,t,n){let{deps:i,state:r}=this,l=new AbortController;r.fragmentController=l;let o=()=>r.isCurrent(e)&&!l.signal.aborted,{emitter:a}=i,{message:s}=e,u=e.identity.revision,d=e.receivedAt,c={root:i.root,revision:u,receivedAt:d,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof s.collectionSlug?s.collectionSlug:void 0,globalSlug:"string"==typeof s.globalSlug?s.globalSlug:void 0,signal:l.signal,isCurrent:o,log:(e,t)=>{i.log("fragment",e,t)},morph:(e,t)=>{!function(e,t){let n=e.ownerDocument.createElement("template");n.innerHTML=J(t);let i=e.cloneNode(!1);i.append(n.content),X(e,i,{keyAttributes:[mi]})}(e,t)},patch:n=>{this.patchFallback(e,t,n)},rendered:(t,n,i)=>{e.pendingFragments-=1,a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"rendered",revision:u,receivedAt:d},o)},failed:(t,n,i,r,l)=>{e.pendingFragments-=1,a.emitWhile("error",{error:new Error(`fragment "${n}" fell back to patch: ${l}`),context:"fragment",code:r},o),a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"failed",code:r,revision:u,receivedAt:d},o)}},h={rendered:0,failed:0,superseded:0};try{h=await n.strategy.render(c,n.boundaries)}catch(r){if(i.log("fragment","LP0801",r),o()){for(let i of n.boundaries)this.patchFallback(e,t,i);h={rendered:0,failed:n.boundaries.length,superseded:0}}}r.fragmentStats.rendered+=h.rendered,r.fragmentStats.failed+=h.failed,r.fragmentStats.superseded+=h.superseded,o()&&(r.fragmentController===l&&(r.fragmentController=null),e.pendingFragments=0,0===i.scheduler.pendingCount&&r.complete(e),this.host.revealPending(e),o()&&(0===h.rendered||0===a.listenerCount("afterUpdate")||a.emitWhile("afterUpdate",{data:t,updatedCount:h.rendered,durationMs:Date.now()-d,revision:u,receivedAt:d,source:"fragment"},o)))}async refreshRoute(e,t,n){let{deps:i,state:r}=this,l=r.routeStats;if(e.routeRefreshed){l.loopStopped+=1,i.log("route","LP0805",`revision ${String(e.identity.revision)} asked for a second refresh`);return}e.routeRefreshed=!0;let o=new AbortController;r.routeController=o;let a,s=()=>r.isCurrent(e)&&!o.signal.aborted;try{a=await n.refresh({revision:e.identity.revision,receivedAt:e.receivedAt,signal:o.signal,isCurrent:s,log:(e,t)=>{i.log("route",e,t)}})}catch(e){i.log("route","LP0801",e),a="failed"}if(s()){if(r.routeController===o&&(r.routeController=null),"refreshed"===a){if(l.refreshes+=1,r.lastAppliedIdentity=new WeakMap,this.host.rebuildCache(),!s())return;this.host.reapply(e,t),i.emitter.listenerCount("afterUpdate")>0&&i.emitter.emitWhile("afterUpdate",{data:t,updatedCount:i.cache.elementCount,durationMs:Date.now()-e.receivedAt,revision:e.identity.revision,receivedAt:e.receivedAt,source:"route"},s);return}"failed"===a&&(l.failed+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){this.state.warnedFragmentFallback||(this.state.warnedFragmentFallback=!0,this.deps.warn(`[live-preview] LP0806: "${e.fieldName}" asks for the fragment strategy but no handler is configured; patching instead`))}warnUnsupportedStrategy(e){this.state.warnedStrategy.has(e.element)||(this.state.warnedStrategy.add(e.element),this.deps.warn(`[live-preview] LP0407: "${e.fieldName}" asks for strategy "${String(e.strategy)}"; only patch, fragment and route exist`))}patchFallback(e,t,n){for(let[i,r]of this.deps.cache.entries())for(let l of r){if(l.fragmentBoundary!==n)continue;let r=B(t.fields,i,l.locale??e.locale,void 0!==l.locale);void 0!==r&&this.deps.scheduler.schedule({target:l,value:this.host.transform(l,r,t.fields,()=>!0),allFields:t.fields,identity:e.identity,data:t})}}},wi=class{constructor(e,t,n){wt(this,"deps",e);wt(this,"state",t);wt(this,"strategies");this.strategies=new bi(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(e,t,n,i)=>this.transformForBinding(e,t,n,i),rebuildCache:n,revealPending:e=>{this.revealPending(e)}})}handleUpdate(e,t,n){let{deps:i,state:r}=this;if(i.heartbeat.kick(),r.protocol.observe(function(e){let t=[];return Array.isArray(e.fieldSchemaJSON)&&t.push("schema-json"),"string"==typeof e.locale&&t.push("locale"),"string"==typeof e.previewToken&&t.push("preview-token"),"object"==typeof e.externallyUpdatedRelationship&&null!==e.externallyUpdatedRelationship&&t.push("relationship-events"),t}(e),i.log),void 0===e.data){void 0!==e.protocolVersion&&r.protocol.applyVersion(e.protocolVersion,i.log);return}if(void 0===n)return;let l=e.externallyUpdatedRelationship,o="object"==typeof l&&null!==l;o&&i.emitter.emit("relationshipUpdate",{detail:l,timestamp:Date.now()}),"string"==typeof e.locale&&(r.locale=e.locale),Array.isArray(e.fieldSchemaJSON)&&(r.schema=e.fieldSchemaJSON,r.schemaIndex=a(e.fieldSchemaJSON));let s={identity:n,message:e,locale:r.locale,schema:r.schema,schemaIndex:r.schemaIndex,receivedAt:Date.now(),forceRender:o,touched:new Set,invalidated:new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},u=r.activeUpdate;r.abortStrategies(),null!==u&&!u.completed&&(r.supersededCount+=1),r.activeUpdate=s,i.scheduler.acceptRevision(n),r.updateCount+=1,(void 0===e.protocolVersion||(r.protocol.applyVersion(e.protocolVersion,i.log),r.isCurrent(s)))&&(i.connection.markConnected()&&(i.a11y?.announceConnected(),i.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!r.isCurrent(s)||(i.log("connection","disconnected","\\u2192","connected"),!r.isCurrent(s)))||this.processUpdate(s).catch(e=>{i.log("update failed:",e)}))}async processUpdate(e){let{deps:t,state:n}=this,i=await this.resolveIncomingFields(e);if(null===i||!n.isCurrent(e))return;let{message:r}=e,l={fields:i,...void 0!==e.schema?{schema:e.schema}:{},..."string"==typeof r.globalSlug?{globalSlug:r.globalSlug}:{},..."string"==typeof r.collectionSlug?{collectionSlug:r.collectionSlug}:{},...void 0!==e.locale?{locale:e.locale}:{}};if(t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:l,revision:e.identity.revision,receivedAt:e.receivedAt,source:"patch",cancel:()=>{e.cancelled=!0,t.scheduler.cancelRevision(e.identity)}},()=>!e.cancelled&&n.isCurrent(e))||e.cancelled||!n.isCurrent(e)))return;let o=w(t.dependencies,t.cache.dependencyMap()),a=n.changes.diff(i,o);e.invalidated=a.invalidated,e.touched=new Set([...a.changed,...a.invalidated]),this.scheduleAllFields(e,l)}async resolveIncomingFields(e){let{deps:t,state:n}=this,i=e.message.data??{};if(null===t.merger||"admin"===E(n.protocol.observed).populatesRelationships)return i;let{message:r}=e,l=await t.merger.merge({collectionSlug:r.collectionSlug,globalSlug:r.globalSlug,data:i,locale:e.locale});return n.isCurrent(e)?"merged"===l.status?l.doc:"superseded"===l.status?null:i:null}scheduleAllFields(e,t){let{deps:n,state:i}=this;if(!i.isCurrent(e))return;let r=()=>i.isCurrent(e),l=this.ownerKeysForUpdate(e,t.fields),{touched:o}=e,a=n.strategies.route;if(void 0!==a&&!e.routeRefreshed&&(a.plan(n.root,o)||this.strategies.hasRouteBinding(o))){this.strategies.refreshRoute(e,t,a);return}let s=this.strategies.planFragments(o),u=n.skipUnchanged,d=0;for(let[o,a]of n.cache.entries()){if(!r())return;for(let c of a){if(!1!==l&&!D(c.owner,l))continue;if(!0===s?.covers(c)){n.revealEditedField&&this.noteRevealCandidate(e,c,this.rawValue(e,c,t));continue}let a=c.strategyKind??C(c.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(c);continue}"fragment"===a&&null===s&&this.strategies.warnFragmentFallback(c);let h=B(t.fields,o,c.locale??e.locale,void 0!==c.locale);if(void 0===h){i.absentFields.add(o);continue}if(this.noteRevealCandidate(e,c,h),!r())return;let f=this.transformForBinding(c,h,t.fields,r);if(!r())return;let p=u?Ce(c,f,t.fields,e.locale):void 0,g=i.lastAppliedIdentity.get(c.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&g===p&&!e.invalidated.has(o)){i.skippedUnchangedCount+=1;continue}let m={target:c,value:f,allFields:t.fields,identity:e.identity,data:t,valueIdentity:p};n.scheduler.schedule(m),d+=1}}(function(e,t,n,i){let{cache:r,warned:l,warn:o}=e;if(0===r.fieldCount||!1!==i&&!function(e,t){for(let n of e.values())if(D(n.owner,t))return!0;return!1}(r,i))return;let a;for(let[e,s]of Object.entries(t)){if(l.has(e)||Hn.has(e)||!G(s))continue;let t=q(e,n);H(r,e,i)||t!==e&&H(r,t,i)||(a??(a=z(r,i)),!a.has(e)&&(l.add(e),o(`[live-preview] LP0201: no <\\u2026 data-payload-field="${t}"> for field "${e}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)))}})({cache:n.cache,warned:i.warnedOrphanFields,warn:n.warn},t.fields,e.locale,l),null!==s&&s.boundaries.length>0&&(e.pendingFragments=s.boundaries.length,this.strategies.runFragments(e,t,s)),0===d&&0===e.pendingFragments&&(i.complete(e),this.revealPending(e))}rawValue(e,t,n){return B(n.fields,t.fieldName,t.locale??e.locale,void 0!==t.locale)}noteRevealCandidate(e,t,n){let{deps:i,state:r}=this;if(!i.revealEditedField)return;let l=m(n);if(void 0===l)return;let o=`${t.owner??""}\\0${t.locale??""}\\0${t.fieldName}`,a=r.seenFieldIdentity.get(o);void 0!==a?a!==l&&(e.revealIdentities.push([o,l]),e.revealTarget??(e.revealTarget=t)):r.seenFieldIdentity.set(o,l)}ownerKeysForUpdate(e,t){let{deps:n,state:i}=this;if(!n.scopeBindingsByOwner)return!1;let{message:r}=e,l=function(e){if(W(e.globalSlug))return[P(e.globalSlug)];if(!W(e.collectionSlug))return null;let t=j(e.collectionSlug);return W(e.documentId)?[t,j(e.collectionSlug,e.documentId)]:[t]}({globalSlug:"string"==typeof r.globalSlug?r.globalSlug:void 0,collectionSlug:"string"==typeof r.collectionSlug?r.collectionSlug:void 0,documentId:V(t)});return null===l&&!i.warnedUnattributableMessage&&(i.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),l}transformForBinding(t,n,i,r){let l=this.deps.transformValue;if(void 0===l)return n;try{let o=l(t.fieldName,n,{element:t.element,allFields:i},r),a=e(o);if(!r())return n;if(a)throw new TypeError(`Transform for "${t.fieldName}" returned a thenable; transforms must be synchronous`);return o}catch(e){if(!r())return n;let t=e instanceof Error?e:new Error(String(e));return this.deps.emitter.emit("error",{error:t,context:"transform",code:"LP0602"}),n}}onFlush(e){let{deps:t,state:n}=this;n.lastFlush=e,e.deferred>0&&!n.warnedVisibilityGate&&(n.warnedVisibilityGate=!0,t.warn(`[live-preview] LP0301: visibility gate held ${String(e.deferred)} off-screen update(s) until scrolled into view; see visibilityGateThreshold`));let{identity:i,data:r}=e;if(void 0===i)return;let l=n.activeUpdate;if(null===l||!n.isCurrent(l)||!b(l.identity,i))return;0===l.pendingFragments&&n.complete(l);let o=()=>n.isCurrent(l)&&b(l.identity,i);this.revealPending(l),o()&&(0===e.applied||void 0===r||(t.a11y?.announceUpdate(e.applied),o()&&(function(e,t){for(let n of e)n.dispatchEvent(new CustomEvent("payload-live-preview:update",{detail:t,bubbles:!1}));e.length}(t.cache.islands,{fields:r.fields,revision:i.revision,receivedAt:l.receivedAt,locale:l.locale}),o()&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:r,updatedCount:e.applied,durationMs:e.durationMs,revision:i.revision,receivedAt:l.receivedAt,source:"patch"},o))))}revealPending(e){for(let[t,n]of e.revealIdentities)this.state.seenFieldIdentity.set(t,n);e.revealIdentities=[];let t=e.revealTarget;if(void 0!==t){e.revealTarget=void 0;try{this.revealBinding(t)}catch(e){this.deps.log("reveal",e)}}}revealField(e){let t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":this.revealBinding(t)}revealBinding(e){let{element:t}=e,n=t.ownerDocument.defaultView;if(null===n)return"no-element";let i=`${e.owner??""} ${e.fieldName}`;return this.state.revealer.reveal(i,t,n)}},Si=class{constructor(e,t){wt(this,"apply");wt(this,"debounceMs");wt(this,"maxWaitMs");wt(this,"isVisible");wt(this,"gateThresholdValue");wt(this,"gateDisabled");wt(this,"getCacheSize");wt(this,"onFlush");wt(this,"scheduleFrame");wt(this,"cancelFrame");wt(this,"pending",new Map);wt(this,"replay",new Map);wt(this,"activeFlushes",new Set);wt(this,"debounceTimer",null);wt(this,"debounceToken",0);wt(this,"deadlineTimer",null);wt(this,"frameHandle",null);wt(this,"frameToken",0);wt(this,"activeIdentity",null);wt(this,"activeRevisionCancelled",!1);this.apply=e,this.debounceMs=t.debounceMs??50,this.maxWaitMs=t.maxWaitMs??4*this.debounceMs,this.isVisible=t.isVisible,this.gateThresholdValue=t.visibilityGateThreshold??50,this.gateDisabled=t.disableVisibilityGate??!1,this.getCacheSize=t.getCacheSize,this.onFlush=t.onFlush,this.scheduleFrame=t.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):e=>setTimeout(()=>{e(performance.now())},0)),this.cancelFrame=t.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):e=>{clearTimeout(e)})}schedule(e){if(void 0!==e.identity&&(this.activeRevisionCancelled||!$e(e.identity,this.activeIdentity)))return;let t=this.pending.get(e.target.element);t?(t.value=e.value,t.allFields=e.allFields,t.identity=e.identity,t.data=e.data,t.valueIdentity=e.valueIdentity):this.pending.set(e.target.element,{target:e.target,value:e.value,allFields:e.allFields,identity:e.identity,data:e.data,valueIdentity:e.valueIdentity}),this.armDebounce()}acceptRevision(e){$e(e,this.activeIdentity)||null!==this.activeIdentity&&function(e,t){return e.generation!==t.generation?e.generation-t.generation:e.revision-t.revision}(e,this.activeIdentity)<0||(this.cancelScheduledWork(),this.clearWork(),this.activeIdentity=e,this.activeRevisionCancelled=!1)}cancelRevision(e){$e(e,this.activeIdentity)&&(this.cancelScheduledWork(),this.clearWork(),this.activeRevisionCancelled=!0)}flushNow(){return this.cancelScheduledWork(),this.flush()}notifyVisible(e){let t=this.replay.get(e);if(!t||(this.replay.delete(e),!this.isCurrent(t)))return;let n=performance.now(),i=this.didApply(t)?1:0;this.onFlush?.(this.statsFor(t,i,0,performance.now()-n,1===i?[t.target.fieldName]:[]))}retarget(e){this.retargetBuffer(this.pending,e),this.retargetBuffer(this.replay,e);for(let t of this.activeFlushes)this.retargetBuffer(t,e)}forget(e){this.pending.delete(e),this.replay.delete(e);for(let t of this.activeFlushes)t.delete(e)}destroy(){this.cancelScheduledWork(),this.clearWork(),this.activeIdentity=null,this.activeRevisionCancelled=!1}get pendingCount(){return this.pending.size}get replayCount(){return this.replay.size}get gateThreshold(){return this.gateThresholdValue}get gateActive(){return!this.gateDisabled&&this.getCacheSize()>this.gateThresholdValue}armDebounce(){let e=this.debounceToken+=1,t=this.debounceTimer;if(this.debounceTimer=null,null!==t&&clearTimeout(t),this.debounceToken!==e)return;let n=setTimeout(()=>{this.debounceToken===e&&(this.debounceTimer=null,this.requestFrame())},this.debounceMs);this.debounceToken===e&&(this.debounceTimer=n),null===this.deadlineTimer&&this.maxWaitMs>this.debounceMs&&(this.deadlineTimer=setTimeout(()=>{this.deadlineTimer=null,this.pending.size>0&&this.requestFrame()},this.maxWaitMs))}requestFrame(){let e=this.frameToken+=1,t=this.frameHandle;if(this.frameHandle=null,null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1,i=this.scheduleFrame(()=>{this.frameToken===e&&(n=!0,this.frameHandle=null,this.flush())});!n&&this.frameToken===e&&(this.frameHandle=i)}flush(){let e=performance.now();this.clearDeadline();let t=this.gateActive,n=this.pending;this.pending=new Map;let i,r=0,l=[],o=0;this.activeFlushes.add(n);try{for(let e of n.values()){if(!this.isCurrent(e))continue;let n=!t||this.isVisible(e.target.element);if(this.isCurrent(e)){if(i??(i=e),!n){this.replay.set(e.target.element,e),o+=1;continue}this.replay.delete(e.target.element),this.didApply(e)&&(r+=1,l.push(e.target.fieldName))}}}finally{this.activeFlushes.delete(n)}let a=this.statsFor(i,r,o,performance.now()-e,l);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.identity||!this.activeRevisionCancelled&&$e(e.identity,this.activeIdentity)}didApply(e){return!1!==this.apply(e)||!function(e){return Kt.has(e)}(this.apply)}retargetBuffer(e,t){let n=e.get(t.element);if(void 0!==n){if(n.target.fieldName!==t.fieldName||n.target.locale!==t.locale){e.delete(t.element);return}n.target=t}}clearWork(){this.pending.clear(),this.replay.clear();for(let e of this.activeFlushes)e.clear()}statsFor(e,t,n,i,r){return{applied:t,appliedFields:r,deferred:n,durationMs:i,...void 0!==e?.identity?{identity:e.identity}:{},...void 0!==e?.data?{data:e.data}:{}}}clearDeadline(){null!==this.deadlineTimer&&(clearTimeout(this.deadlineTimer),this.deadlineTimer=null)}cancelScheduledWork(){let e=this.debounceTimer,t=this.frameHandle;this.debounceToken+=1,this.frameToken+=1,this.debounceTimer=null,this.frameHandle=null,this.clearDeadline(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}},ki=[0,500,1e3,2e3],Ti=class{constructor(e){wt(this,"deps");wt(this,"state",new nn);wt(this,"pipeline");wt(this,"writer");wt(this,"rootSentinel",null);wt(this,"observedRoot",null);let{emitter:i,renderers:r}=e,l=void 0===e.log?n:t(e.log),o=void 0===e.warn?Ft:t(e.warn),a=e.root??(typeof document<"u"?document:null),s=new xn({filter:e=>!function(e){let t=e;for(;null!==t;){if(k(t)&&!T(t))return!0;t=t.parentElement}return!1}(e)}),u=new Dn({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&d.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),d=new Si(g(e=>this.writer.apply(e)),{...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.disableVisibilityGate?{disableVisibilityGate:e.disableVisibilityGate}:{},...void 0!==e.visibilityGateThreshold?{visibilityGateThreshold:e.visibilityGateThreshold}:{},isVisible:e=>u.isVisible(e),getCacheSize:()=>s.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),c=new jn(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],l),i.emit("documentSave",{timestamp:Date.now()})},onFocusField:e=>{this.deps.revealEditedField&&this.pipeline.revealField(e)},onInvalid:(e,t)=>{if("token"===e){let e=new Error(`Preview token rejected (origin: ${t})`);i.emit("error",{error:e,context:"token",code:"LP0502"})}l("LP0501 message rejected:",e,t)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),h=e.dataMerge;this.deps={emitter:i,cache:s,observers:u,scheduler:d,bus:c,connection:new Bn,heartbeat:new Vn({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:r,resolveRenderer:e.resolveRenderer??(e=>r[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,root:a,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??Me,onHeartbeatTimeout:e.onHeartbeatTimeout,log:l,warn:o,a11y:Fe(e),merger:void 0===h?null:new En({serverURL:h.serverURL,...void 0!==h.apiRoute?{apiRoute:h.apiRoute}:{},...void 0!==h.depth?{depth:h.depth}:{},...void 0!==h.fetchFn?{fetchFn:h.fetchFn}:{},log:l}),scopeBindingsByOwner:!0===e.scopeBindingsByOwner,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField},this.writer=new rn(this.deps,this.state),this.pipeline=new wi(this.deps,this.state,()=>{this.rebuildCache()})}start(){let{state:e,deps:t}=this;if(e.isRunning())return!1;if(e.started=!0,e.suspended=!1,Re(t.root)&&"loading"===t.root.readyState){let n=()=>{if(e.isRunning()){e.deferredStart=null;try{this.startNow()}catch(e){this.rollbackFailedStart(),this.reportError(e,"startup","LP0605")}}};e.deferredStart=n;try{t.root.addEventListener("DOMContentLoaded",n,{once:!0})}catch(e){throw this.rollbackFailedStart(),e}return!0}try{return this.startNow(),!0}catch(e){throw this.rollbackFailedStart(),e}}startNow(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=Re(t.root)?Ne(t.root):t.root;if(null===n)throw new Error("LivePreviewRuntime: document.body unavailable");if(t.observers.start(n),this.observedRoot=n,this.watchRootReplacement(),this.buildCacheAndObserve(),e.isRunning()&&(t.bus.attach(),t.emitter.emitWhile("init",{timestamp:Date.now()},()=>e.isRunning()),e.isRunning()))for(let n of ki){if(!e.isRunning())return;0===n?t.sendReady(t.readyTargets()):e.readyTimers.push(setTimeout(()=>{e.isRunning()&&this.sendReadyAfterStart()},n))}}suspend(){if(!this.state.isRunning())return!1;let e=this.release();return this.state.suspended=!0,e&&this.deps.emitter.emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0}destroy(){let{state:e,deps:t}=this;if(!e.isRunning()&&!e.suspended)return;let n=!!e.isRunning()&&this.release();e.suspended=!1,n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}release(){let{state:e,deps:t}=this;e.activeUpdate=null,e.started=!1;let n=e.deferredStart;e.deferredStart=null,null!==n&&Re(t.root)&&this.runCleanup(()=>{t.root.removeEventListener("DOMContentLoaded",n)});for(let t of e.readyTimers)this.runCleanup(()=>{clearTimeout(t)});return e.readyTimers.length=0,this.runCleanup(()=>{t.heartbeat.stop()}),this.runCleanup(()=>{t.bus.detach()}),e.abortStrategies(),this.runCleanup(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),this.runCleanup(()=>{t.observers.stop()}),this.runCleanup(()=>{t.scheduler.destroy()}),this.runCleanup(()=>{t.merger?.destroy()}),t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release(),this.runCleanup(()=>{this.deps.a11y?.detach()})}runCleanup(e){try{e()}catch(e){this.deps.log("cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}watchRootReplacement(){let{root:e}=this.deps;!Re(e)||typeof MutationObserver>"u"||(this.rootSentinel?.disconnect(),this.rootSentinel=new MutationObserver(()=>{this.followReplacedRoot()}),this.rootSentinel.observe(e.documentElement,{childList:!0}))}followReplacedRoot(){let{root:e}=this.deps;if(!this.state.isRunning()||!Re(e))return!1;let t=Ne(e);return null!==t&&t!==this.observedRoot&&(this.observedRoot=t,this.deps.observers.start(t),this.rebuildCache(),!0)}get status(){return this.deps.connection.status}get cache(){return this.deps.cache}get updateCount(){return this.state.updateCount}get protocol(){return this.state.protocol.negotiation}inspect(){return function(e,t){let{cache:n,scheduler:i}=e,r=t.protocol.negotiation,l=t.activeUpdate,o=t.lastFlush,a=[],s=new Set;for(let[e,t]of n.entries()){a.push(e);for(let e of t)void 0!==e.owner&&s.add(e.owner)}return{version:In,started:t.started,status:e.connection.status,origins:{trusted:[...e.readyTargets()],locked:e.lockedOrigin()},protocol:{ours:r.ours,theirs:r.theirs,negotiated:r.negotiated,capabilities:[...r.capabilities].sort(),observed:[...r.observed].sort(),profile:E(r.observed).name},revisions:{accepted:t.updateCount,superseded:t.supersededCount,completed:t.completedCount,skippedUnchanged:t.skippedUnchangedCount,active:null===l?void 0:l.identity.revision},bindings:{elements:n.elementCount,fields:n.fieldCount,fieldNames:a.sort(),absentFields:[...t.absentFields].sort(),orphanFields:[...t.warnedOrphanFields].sort(),ownerScoped:e.scopeBindingsByOwner,owners:[...s].sort()},route:{handler:void 0!==e.strategies.route,...t.routeStats},fragments:{handler:void 0!==e.strategies.fragment,inFlight:l?.pendingFragments??0,...t.fragmentStats},scheduler:{pending:i.pendingCount,deferred:i.replayCount,visibilityGateThreshold:i.gateThreshold,visibilityGateActive:i.gateActive,lastFlush:null===o?void 0:{applied:o.applied,appliedFields:o.appliedFields,deferred:o.deferred,durationMs:o.durationMs}},plugins:[],renderers:Object.keys(e.renderers).sort()}}(this.deps,this.state)}buildCacheAndObserve(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=t.cache.buildFromRoot(t.root);if(t.log("cache",n),e.isRunning()&&(t.emitter.emitWhile("cacheRefresh",n,()=>e.isRunning()),e.isRunning()))for(let n of t.cache.values()){if(!e.isRunning())return;t.observers.observeElement(n.element)}}rebuildCache(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=new Map;for(let e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),e.isRunning()){for(let e of t.cache.values())n.get(e.element)?.fieldName===e.fieldName?t.scheduler.retarget(e):t.scheduler.forget(e.element),n.delete(e.element);for(let e of n.values())t.scheduler.forget(e.element)}}onHeartbeatTimeout(){let{state:e,deps:t}=this;if(!e.isRunning())return;t.bus.advanceGeneration();let n=e.activeUpdate;e.activeUpdate=null,null!==n&&t.scheduler.cancelRevision(n.identity),t.merger?.destroy();let i=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}e.isRunning()&&(i&&this.isIdleDisconnected()&&(t.a11y?.announceDisconnected(),t.emitter.emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.isIdleDisconnected()),!e.isRunning()||(this.isIdleDisconnected()&&t.log("connection","connected","\\u2192","disconnected"),!e.isRunning()))||this.sendReadyAfterStart())}sendReadyAfterStart(){try{this.deps.sendReady(this.deps.readyTargets())}catch(e){this.reportError(e,"ready","LP0606")}}reportError(e,t,n){let i=e instanceof Error?e:new Error(String(e));this.deps.emitter.emit("error",{error:i,context:t,code:n})}isIdleDisconnected(){return this.state.isRunning()&&"disconnected"===this.deps.connection.status&&null===this.state.activeUpdate}},Ai=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,Ci=/^https?:\\/\\/[^/?#\\s]+$/i,$i=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],Fi=class{constructor(e={}){Tt(this,Ri);let t=new Set;for(let n of e.additionalOrigins??[]){let e=Ee(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){let t=e.referrer??(typeof document<"u"?document.referrer:"");if(t.length>0)try{let e=new URL(t).origin;e&&"null"!==e&&(n=e)}catch{}}let i=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??function(){let e=function(){if(!(typeof process>"u"))return"production"}();if(void 0!==e)return"production"!==e;if(typeof window<"u"){let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}());At(this,Ri,[t,n,i,void 0!==n,void 0])}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==kt(this,Ri)[4]?e===kt(this,Ri)[4]:!!(kt(this,Ri)[0].has(e)||0===kt(this,Ri)[0].size&&void 0!==kt(this,Ri)[1]&&e===kt(this,Ri)[1]||kt(this,Ri)[2]&&Ai.test(e)))}lockOrigin(e){return!!this.matches(e)&&(kt(this,Ri)[4]=e,!0)}unlockOrigin(){let e=kt(this,Ri)[4];return kt(this,Ri)[4]=void 0,e}get lockedOrigin(){return kt(this,Ri)[4]}enumerate(){if(void 0!==kt(this,Ri)[4])return[kt(this,Ri)[4]];let e=new Set(kt(this,Ri)[0]);if(0===kt(this,Ri)[0].size&&void 0!==kt(this,Ri)[1]&&e.add(kt(this,Ri)[1]),kt(this,Ri)[2])for(let t of $i)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return kt(this,Ri)[3]}get isProductionUnconfigured(){return!(!xe()||kt(this,Ri)[0].size>0||kt(this,Ri)[2]||void 0!==kt(this,Ri)[1])}get isReferrerOnlyTrust(){return!(kt(this,Ri)[0].size>0||kt(this,Ri)[2])&&void 0!==kt(this,Ri)[1]}},Ri=new WeakMap,Ni={1:"left",2:"center",3:"right",4:"justify"},Mi=new Set(["left","center","right","justify","start","end"]),xi=new Set(["h1","h2","h3","h4","h5","h6"]),Ei=\' target="_blank" rel="noopener noreferrer"\',Ii=(e,t)=>{let n=t.renderChildren(e.children??[]),i=Pe(e.fields),r=function(e,t){if("internal"===t?.linkType)return function(e){let t=Pe(Pe(e)?.value),n=t?.url;if("string"==typeof n&&n.length>0)return n;let i=t?.slug;return"string"==typeof i&&i.length>0?`/${i}`:void 0}(t.doc);let n=t?.url??e.url;return"string"==typeof n&&n.length>0?n:void 0}(e,i);if(void 0===r||!f(r))return n;let l="string"==typeof e.title?` title="${oe(e.title)}"`:"";return`<a href="${ae(r)}"${function(e,t,n){if(!0===t?.newTab||p(n))return Ei;let i="string"==typeof e.target?e.target:"";return""===i?"":"_blank"===i?Ei:` target="${oe(i)}"`}(e,i,r)}${l}>${n}</a>`},Li=new Map,Oi={text:e=>{let t=oe("string"==typeof e.text?e.text:""),n="number"==typeof e.format?e.format:0;return!!(16&n)&&(t=`<code>${t}</code>`),!!(1&n)&&(t=`<strong>${t}</strong>`),!!(2&n)&&(t=`<em>${t}</em>`),!!(8&n)&&(t=`<u>${t}</u>`),!!(4&n)&&(t=`<s>${t}</s>`),!!(32&n)&&(t=`<sub>${t}</sub>`),!!(64&n)&&(t=`<sup>${t}</sup>`),!!(128&n)&&(t=`<mark>${t}</mark>`),t},paragraph:(e,t)=>{let n=t.renderChildren(e.children??[]);return`<p${Oe(e)}${Ue(e)}>${n}</p>`},heading:(e,t)=>{let n="string"==typeof e.tag?e.tag.toLowerCase():"h2",i=xi.has(n)?n:"h2",r=t.renderChildren(e.children??[]);return`<${i}${Oe(e)}${Ue(e)}>${r}</${i}>`},list:(e,t)=>{let n="string"==typeof e.listType?e.listType:"bullet",i="number"===n?"ol":"ul",r="number"===n&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",l="check"===n?\' role="list"\':"",o=t.renderChildren(e.children??[]);return`<${i}${Oe(e)}${Ue(e)}${r}${l}>${o}</${i}>`},listitem:(e,t)=>{let n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${Ue(e)}>${n}</li>`;let i="number"==typeof e.value?` value="${oe(String(e.value))}"`:"";return`<li${Oe(e)}${Ue(e)}${i}>${n}</li>`},link:Ii,autolink:Ii,quote:(e,t)=>{let n=t.renderChildren(e.children??[]);return`<blockquote${Oe(e)}${Ue(e)}>${n}</blockquote>`},code:e=>{let t=We("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${oe(Be(e))}</code></pre>`},"code-highlight":e=>{let t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${We(e.highlightType)}"`:""}>${oe(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\\t",upload:e=>{let t=je(e.value);if(void 0===t)return"";let n=t.url;if("string"!=typeof n||!f(n))return"";let i="string"==typeof t.mimeType?t.mimeType:"";return i.startsWith("video/")?function(e,t){return`<video controls${_e(e)}><source src="${ae(t)}"${He(e)}></video>`}(t,n):i.startsWith("audio/")?function(e,t){return`<audio controls><source src="${ae(t)}"${He(e)}></audio>`}(t,n):""===i||i.startsWith("image/")?function(e,t){let n="string"==typeof e.alt?oe(e.alt):"";return`<img src="${ae(t)}" alt="${n}"${_e(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){let n="string"==typeof e.filename?oe(e.filename):oe(t);return`<a href="${ae(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{let t="string"==typeof e.relationTo?e.relationTo:"",n=Pe(e.value),i=oe((n&&Ve(n))??`#${t}`),r=We(t),l=""===r?\' class="lp-relation"\':` class="lp-relation lp-relation--${r}"`,o=n?.url;return"string"==typeof o&&f(o)?`<a href="${ae(o)}"${l}>${i}</a>`:`<span${l}>${i}</span>`},block:(e,t)=>Ge(e,t,"div","lp-block"),inlineBlock:(e,t)=>Ge(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${Oe(e)}><tbody>${t.renderChildren(e.children??[])}</tbody></table>`,tablerow:(e,t)=>`<tr>${t.renderChildren(e.children??[])}</tr>`,tablecell:(e,t)=>{let n="number"==typeof e.headerState?e.headerState:0,i=3&n?"th":"td";return`<${i}${1===n?\' scope="col"\':2===n?\' scope="row"\':""}${qe("colspan",e.colSpan)}${qe("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${i}>`}},Ui=new Map,Pi={renderChildren:Ke,resolveAlignment:Ie,resolveIndent:Le},ji=!1,Wi="data-payload-text",Di={name:"richText",render:g((e,t,n)=>{let i=e.element;if(de(t))i.textContent="";else{if(void 0!==n.renderRichText){let r=n.renderRichText(t,{fieldName:e.fieldName,element:i,locale:n.locale});i.innerHTML=J(te(r));return}if(Je(t))i.innerHTML=J(function(e,t={}){if(!Je(e))return"";let n=Ke(e.root.children);return!1===t.sanitize?n:void 0!==ne()?te(n):(function(){if(!ji){ji=!0;try{console.warn("[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; call setSanitizerDocument() (linkedom/jsdom) for server rendering, see docs/security.md \\xa73.")}catch{}}}(),n)}(t));else{if("string"!=typeof t)return!1;i.innerHTML=J(te(t))}}})},Vi={name:"html",render(e,t){if(de(t)){e.element.textContent="";return}let n="string"==typeof t?t:ue(t);e.element.innerHTML=J(te(n))}},Bi=new WeakSet,_i=et("url"),Hi=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,zi=et("email",function(e){let t=e.trim();return Hi.test(t)||!t.includes("@")?t:`mailto:${t}`}),Gi=["src","srcset","sizes"],qi={name:"image",render:g((e,t,n)=>{let i=e.element;if(de(t)){rt(i);return}let r=void 0!==e.locale,{media:l,candidate:o}=function(e,t,n,i){let r=void 0!==e.srcField&&e.srcField.length>0?B(n.allFields,e.srcField,n.locale,i):t,l=je(r);return{media:l,candidate:void 0===l?r:l.url}}(e,t,n,r),a=Ye(i,e.fieldName,o);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===i.tagName){let t=i;nt(t,a.url,l);let o=function(e,t,n,i,r){if(void 0!==t&&t.length>0){let e=B(n,t,i,r);return"string"==typeof e?e:void 0}return e?.alt}(l,e.altField,n.allFields,n.locale,r);void 0!==o&&(t.alt=o);return}i.style.backgroundImage=`url(\'${function(e){return e.replace(/[\'"()\\\\]/g,"\\\\$&")}(a.url)}\')`}else rt(i)})},Ji={name:"upload",render:g((e,t)=>{let n=e.element;if(de(t)){lt(n);return}let i=je(t);if(void 0===i)return!1;let r=Ye(n,e.fieldName,i.url);if("none"===r.kind)return!1;if("unsafe"===r.kind){lt(n);return}let l=r.url;if("IMG"===n.tagName){let e=n;nt(e,l,i),void 0!==i.alt&&(e.alt=i.alt);return}if("A"===n.tagName){n.setAttribute("href",l),n.textContent=i.filename??l;return}let o=oe(i.filename??l);n.innerHTML=J(`<a href="${ae(l)}">${o}</a>`)})},Ki={name:"relationship",render(e,t){let n=e.element;if(de(t))n.removeAttribute("href"),n.textContent="";else{if("A"===n.tagName&&!Array.isArray(t)){let i=Ye(n,e.fieldName,Pe(t)?.url);"safe"===i.kind?n.setAttribute("href",i.url):"unsafe"===i.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(ot).join(", "):ot(t)}}},Qi={name:"select",render(e,t,n){let i=e.element,r=de(t)?[]:function(e){return Array.isArray(e)?e.map(ue):[ue(e)]}(t);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let e=i;e.checked=r.includes(e.value);return}i.textContent=r.map(e=>function(e,t){let n=t.schema?.options;if(!Array.isArray(n))return e;for(let t of n){let n=Pe(t);if(void 0!==n&&ue(n.value)===e)return"string"==typeof n.label?n.label:e}return e}(e,n)).join(", ")}else!function(e,t){if(e.multiple)for(let n of Array.from(e.options))n.selected=t.includes(n.value);else e.value=t[0]??""}(i,r)}},Xi=new Set(["","false","0","off","no"]),Zi={name:"checkbox",render(e,t){let n=e.element,i=function(e){return"boolean"==typeof e?e:"string"==typeof e?!Xi.has(e.trim().toLowerCase()):"number"==typeof e?0!==e:null!=e}(t);"INPUT"!==n.tagName||"checkbox"!==n.type?n.hasAttribute("aria-checked")?n.setAttribute("aria-checked",i?"true":"false"):n.textContent=i?"true":"false":n.checked=i}},Yi=new Map,er=new Map,tr=64,nr={name:"date",render(e,t,n){let r=e.element;if(de(t)){"INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent="");return}let l="number"==typeof t?t:ue(t),o=new Date(l),a=!Number.isNaN(o.getTime()),s=String(l);"INPUT"!==r.tagName?("TIME"===r.tagName&&r.setAttribute("datetime",a?o.toISOString():s),r.textContent=a?function(e,t){let n=t.locale??i();try{return function(e,t){let n=at(e,t),i=er.get(n);if(void 0!==i)return er.delete(n),er.set(n,i),i;let r=new Intl.DateTimeFormat(e,t);return er.set(n,r),ut(er),r}(n,{dateStyle:"medium",timeStyle:"short"}).format(e)}catch{return e.toISOString()}}(o,n):s):r.value=a?function(e,t){let n=`${String(t.getFullYear()).padStart(4,"0")}-${dt(t.getMonth()+1)}-${dt(t.getDate())}`,i=`${dt(t.getHours())}:${dt(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${i}`:"time"===e?i:t.toISOString()}(r.type,o):s}},ir={name:"number",render(e,t,n){let r=e.element;if(de(t)){"INPUT"===r.tagName?r.value="":r.textContent="";return}let l="number"==typeof t?t:Number(ue(t));Number.isNaN(l)?r.textContent=ue(t):"INPUT"!==r.tagName?r.textContent=function(e,t){let n=t.locale??i();try{return function(e,t){let n=at(e,t),i=Yi.get(n);if(void 0!==i)return Yi.delete(n),Yi.set(n,i),i;let r=new Intl.NumberFormat(e,t);return Yi.set(n,r),ut(Yi),r}(n).format(e)}catch{return String(e)}}(l,n):r.value=String(l)}},rr={name:"array",render:g((e,t)=>{let n=e.element;if(de(t)){n.textContent="";return}if(!Array.isArray(t))return!1;let i=e.arrayTemplate;if(void 0!==i&&i.length>0){let e=function(e,t){let n="";for(let i=0;i<t.length;i+=1)n+=se(e,t[i],i,ue);return n}(i,t);n.innerHTML=J(te(e,ce(i)));return}n.textContent=t.map(ue).join(e.arraySeparator??", ")})},lr=new Map;!function(){if(typeof window>"u"||!xe()&&(typeof window>"u"||null==window.opener))return;let e=window.__livePreview,t=JSON.stringify(mt());if(void 0!==e&&(void 0===e.configSignature||e.configSignature===t))return e.refresh(),e;let[n=[],i="",r="/api",l=1,o=!1,a=50,s=!0,u=0,d=!1,c=50,h="200px",f=!0,p=!1,g=!1,m=!0,v="parent-or-opener",y="strict",b,w=!1]=mt(),S=typeof __LIVE_PREVIEW_FRAGMENT__<"u"&&"string"==typeof b&&b.length>0?{fragment:__LIVE_PREVIEW_FRAGMENT__.createFragmentStrategy({endpoint:b}),route:__LIVE_PREVIEW_FRAGMENT__.createRouteStrategy()}:void 0;!function(e){oi=e}(y);let k=new Fi({additionalOrigins:n,enableReferrerDetection:!f,enableLocalhostMatching:!p});k.isProductionUnconfigured?Ft("[live-preview] LP0101: No trusted origin. Pass allowedOrigins to generateInlineScript() (or to the adapter) \\u2014 the runtime reads no environment variable in the browser."):k.isReferrerOnlyTrust&&Ft("[live-preview] LP0102: document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let T=new Nt,A=function(){let e=[Di,Vi,_i,zi,qi,Ji,Ki,Qi,{...Qi,name:"radio"},Zi,nr,ir,rr,{...rr,name:"blocks"}];return function(e=[]){let t={};for(let n of e)t[n.name]=n;for(let[e,n]of lr)t[e]=n;return Object.freeze(t)}([Ze("text"),Ze("textarea"),...e,ct()])}(),C=new Ti({renderers:A,originMatcher:e=>k.matches(e),lockedOrigin:()=>k.lockedOrigin,readyTargets:()=>k.enumerate(),emitter:T,eventSourcePolicy:v,...""!==i?{dataMerge:{serverURL:i,apiRoute:r,depth:l}}:{},debounceMs:a,heartbeatMs:u,intersectionRootMargin:h,disableVisibilityGate:d,visibilityGateThreshold:c,enableA11y:s,scopeBindingsByOwner:g,skipUnchanged:m,revealEditedField:w,...void 0!==S?{strategies:S}:{},onHeartbeatTimeout:()=>{k.unlockOrigin()},...o?{log:(...e)=>{Rt("[live-preview]",...e)}}:{}});T.on("connect",e=>{k.lockOrigin(e.origin)}),C.start(),e?.destroy();let $=function(e,t={}){let n=t.windowTarget??globalThis.window,i=t.documentTarget??globalThis.document,r=t.softNavigationEvents??[],l=()=>{e.suspend()},o=t=>{!0===t.persisted&&e.resume()},a=()=>{e.refreshCache()};n?.addEventListener("pagehide",l),n?.addEventListener("pageshow",o);for(let e of r)i?.addEventListener(e,a);let s=!1;return()=>{if(!s){s=!0,n?.removeEventListener("pagehide",l),n?.removeEventListener("pageshow",o);for(let e of r)i?.removeEventListener(e,a)}}}({suspend:()=>C.suspend(),resume:()=>C.start(),refreshCache:()=>{C.refreshCache()}}),F=Object.freeze({version:In,configSignature:t,destroy:()=>{$(),C.destroy();let e=window;e.__livePreview===F&&delete e.__livePreview},refresh:()=>{C.refreshCache()},enumerateOrigins:()=>k.enumerate(),inspect:()=>C.inspect()});try{Object.defineProperty(window,"__livePreview",{value:F,writable:!1,configurable:!0})}catch(e){throw $(),C.destroy(),e}}()})();',t='"use strict";var __LIVE_PREVIEW_FRAGMENT__=(()=>{var N=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var ee=(e,n)=>{for(var t in n)N(e,t,{get:n[t],enumerable:!0})},ne=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Q(n))!Z.call(e,r)&&r!==t&&N(e,r,{get:()=>n[r],enumerable:!(o=J(n,r))||o.enumerable});return e};var te=e=>ne(N({},"__esModule",{value:!0}),e);var De={};ee(De,{createFragmentStrategy:()=>z,createRouteStrategy:()=>X});var R="data-payload-island",Pe=`astro-island, [${R}]`;function re(e){return e.tagName.toLowerCase()==="astro-island"||e.hasAttribute(R)}function oe(e){return e.getAttribute(R)==="patch"}function _(e){let n=e;for(;n!==null;){if(re(n)&&!oe(n))return!0;n=n.parentElement}return!1}function w(e){if(e==null)return[];let n=new Set,t=[];for(let o of e.split(/[\\s,]+/)){let r=o.trim();r.length===0||n.has(r)||(n.add(r),t.push(r))}return t}var b="data-payload-fragment";var D="data-payload-fragment-key",ae="data-payload-depends";function M(e){let n=e.getAttribute(b);if(n===null||n.length===0)return null;let t=e.getAttribute(D);return{element:e,id:n,key:t===null||t.length===0?void 0:t,dependsOn:w(e.getAttribute(ae))}}function L(e,n){let t=[];for(let o of e.querySelectorAll(`[${b}]`)){let r=M(o);r===null||_(o)||r.dependsOn.length>0&&!r.dependsOn.some(a=>n.has(a))||t.push(r)}return t}var B="x-payload-fragment-version";function v(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e){if(!v(e))return null;let{html:n,boundary:t,revision:o,metadata:r}=e;return typeof n!="string"||!v(t)||typeof t.id!="string"||t.key!==void 0&&typeof t.key!="string"||typeof o!="number"||!v(r)||typeof r.renderedAt!="string"||typeof r.renderer!="string"?null:e}function U(e){let n={};for(let[t,o]of Object.entries(e))o!==void 0&&(n[t]=o);return n}function H(e){let n=0,t=[],o=()=>{let r=t.shift();r===void 0?n-=1:r()};return async r=>{n<e?n+=1:await new Promise(a=>{t.push(a)});try{return await r()}finally{o()}}}var le=5e3,se=4,de=512*1024,A={status:"superseded"};function h(e,n){return{status:"failed",code:e,reason:n}}function ue(e){return e instanceof Error?e.message:String(e)}function ce(e){let n=()=>{throw new TypeError(\'createFragmentStrategy: endpoint must be a same-origin path starting with "/"\')};if((typeof e!="string"||!e.startsWith("/")||e.startsWith("//")||e.includes("\\\\"))&&n(),typeof location<"u"){let t;try{t=new URL(e,location.href)}catch{t=void 0}t?.origin!==location.origin&&n()}return e}function fe(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}async function me(e,n,t){let o=e.body;if(!fe(o)){let s=await e.text();return new TextEncoder().encode(s).byteLength>n?null:s}let r=o.getReader(),a=()=>{r.cancel().catch(()=>{})};t.addEventListener("abort",a,{once:!0});let l=new TextDecoder,i="",u=0;try{for(;;){let{done:s,value:y}=await r.read();if(s)break;if(u+=y.byteLength,u>n)return a(),null;i+=l.decode(y,{stream:!0})}}finally{t.removeEventListener("abort",a)}return i+l.decode()}function K(e){let n=ce(e.endpoint),t=e.timeoutMs??le,o=e.maxResponseBytes??de,r=H(Math.max(1,e.maxConcurrent??se)),a=new Map;async function l(i,u){let s=()=>i.signal.aborted;if(s())return A;let y=e.location??location,m=U({fragment:u.id,key:u.key,route:y.pathname,search:y.search,revision:i.revision,locale:i.locale,collectionSlug:i.collectionSlug,globalSlug:i.globalSlug,fields:i.fields}),d=new AbortController,f=()=>{d.abort()};i.signal.addEventListener("abort",f,{once:!0});let g={timedOut:!1},E=setTimeout(()=>{g.timedOut=!0,d.abort()},t),c=p=>s()?A:g.timedOut?h("LP0801",`timeout after ${String(t)} ms`):h("LP0801",ue(p));try{let p;try{p=await(e.fetch??fetch)(n,{method:"POST",credentials:"same-origin",headers:{...e.headers,accept:"application/json","content-type":"application/json",[B]:String(1)},body:JSON.stringify(m),signal:d.signal})}catch(O){return c(O)}if(s())return A;if(p.status===401||p.status===403)return h("LP0803",`endpoint refused the preview (${String(p.status)})`);if(!p.ok)return h("LP0801",`endpoint answered ${String(p.status)}`);let T=p.headers.get("content-type")??"";if(!T.toLowerCase().startsWith("application/json"))return h("LP0802",`unexpected content type "${T}"`);if(Number(p.headers.get("content-length")??"0")>o)return h("LP0802","response exceeds the size limit");let k;try{k=await me(p,o,d.signal)}catch(O){return c(O)}if(s())return A;if(g.timedOut)return h("LP0801",`timeout after ${String(t)} ms`);if(k===null)return h("LP0802","response exceeds the size limit");let I;try{I=JSON.parse(k)}catch{return h("LP0802","response is not JSON")}let S=C(I);return S===null?h("LP0802","response has the wrong shape"):S.boundary.id!==u.id?h("LP0802","response is for another boundary"):S.revision!==i.revision?A:{status:"rendered",html:S.html,metadata:S.metadata}}finally{clearTimeout(E),i.signal.removeEventListener("abort",f)}}return(i,u)=>{let s=`${u.id} ${u.key??""} ${String(i.revision)}`,y=a.get(s);if(y!==void 0)return y;let m=r(()=>l(i,u));a.set(s,m);let d=()=>{a.get(s)===m&&a.delete(s)};return m.then(d,d),m}}var F="data-payload-owned",ye=new Set(["open","value","checked","selected"]);function q(e,n){for(let t of n.keyAttributes){let o=e.getAttribute(t);if(o!==null&&o.length>0)return`${t}=${o}`}}function x(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(R)||e.hasAttribute(F))return!0;let n=e.getAttribute("contenteditable");return n!==null&&n!=="false"}function ge(e,n){return e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI&&!x(e)&&!x(n)}function P(e,n,t){if(!ge(e,n))return n;let o=Se(e);return pe(e,n),t.retainChildrenOf?.(e,n)!==!0&&he(e,n,t),Re(o),e}function pe(e,n){for(let t of Array.from(e.attributes))n.hasAttribute(t.name)||ye.has(t.name.toLowerCase())||e.removeAttribute(t.name);for(let t of Array.from(n.attributes))e.getAttribute(t.name)!==t.value&&e.setAttribute(t.name,t.value)}function he(e,n,t){let o=be(e,t),r=new Set(o.values()),a=Array.from(e.childNodes).filter(m=>!r.has(m)),l=new Set,i=new Set,u=Array.from(n.childNodes),s=e.firstChild,y=0;for(let m=0;m<u.length;m+=1){let d=u[m],f=null,g=d instanceof Element?q(d,t):void 0;if(g!==void 0&&i.has(g)&&(g=void 0),g!==void 0){i.add(g);let c=o.get(g);if(c!==void 0&&!l.has(c)&&(f=$(c,d,t)===c?c:null,f===null)){c.replaceWith(d),l.add(d),s=d.nextSibling;continue}}else{for(;y<a.length;){let c=a[y];if(y+=1,!l.has(c)){if(G(c,d)){f=$(c,d,t)===c?c:null,f===null&&(e.replaceChild(d,c),l.add(d),s=d.nextSibling);break}if(c instanceof Element){let p=u[m+1];if(!(d instanceof Element)||p!==void 0&&G(c,p)){y-=1;break}e.replaceChild(d,c),l.add(d),s=d.nextSibling;break}if(!(d instanceof Element)){e.replaceChild(d,c),l.add(d),s=d.nextSibling;break}}}if(f===null&&l.has(d))continue}let E=f??d;for(l.add(E);s!==null&&s!==E&&!l.has(s)&&Ee(s);)s=s.nextSibling;E!==s&&e.insertBefore(E,s),s=E.nextSibling}for(let m of Array.from(e.childNodes))l.has(m)||m.remove()}function $(e,n,t){return e instanceof Element&&n instanceof Element?x(e)&&x(n)?e:P(e,n,t):(e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue),e)}function Ee(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function G(e,n){return e.nodeType!==n.nodeType?!1:e instanceof Element&&n instanceof Element?e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI:!0}function be(e,n){let t=new Map,o;for(let r of Array.from(e.children)){let a=q(r,n);if(a!==void 0){if(t.has(a)){o??(o=a.slice(a.indexOf("=")+1));continue}t.set(a,r)}}return o!==void 0&&n.onDuplicateKey?.(e,o),t}function Se(e){let n=e.ownerDocument.activeElement;if(!(n instanceof HTMLElement)||!e.contains(n))return null;let t=n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement?[n.selectionStart,n.selectionEnd]:null;return{element:n,selection:t}}function Re(e){if(e===null)return;let{element:n,selection:t}=e;if(!(n.ownerDocument.activeElement===n||!n.isConnected))try{n.focus({preventScroll:!0});let[o,r]=t??[null,null];o!==null&&r!==null&&n.setSelectionRange(o,r)}catch{}}var V="data-payload-key";var W="data-payload-strategy",Y="data-payload-field",Ae="data-payload-depends",Te="x-payload-live-preview",we=8e3,xe=1e3;function Fe(e){let n=e.getAttribute(W);return n!==null?n==="route":e.closest("head")!==null}function ke(e){let n=e.getAttribute(Y),t=w(e.getAttribute(Ae));return n===null||n.length===0?t:[n,...t]}function j(e){if(e.tagName==="META"){let n=e.getAttribute("name")??e.getAttribute("property");return n===null?null:`meta:${n}`}return e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"?"link:canonical":null}function Oe(e,n){n.title!==e.title&&(e.title=n.title);let t=new Map;for(let r of e.head.querySelectorAll("meta, link")){let a=j(r);a!==null&&!t.has(a)&&t.set(a,r)}let o=new Set;for(let r of n.head.querySelectorAll("meta, link")){let a=j(r);if(a===null)continue;o.add(a);let l=t.get(a);if(l===void 0){e.head.append(e.importNode(r,!0));continue}if(!l.hasAttribute(F))for(let i of Array.from(r.attributes))l.getAttribute(i.name)!==i.value&&l.setAttribute(i.name,i.value)}for(let[r,a]of t)!o.has(r)&&!a.hasAttribute(F)&&a.remove()}function X(e={}){let n=e.timeoutMs??we,t=e.minIntervalMs??xe,o=-1/0;return{plan(r,a){for(let l of r.querySelectorAll(`[${Y}], [${W}="route"]`)){if(!Fe(l))continue;let i=ke(l);if(i.length===0||i.some(u=>a.has(u)))return!0}return!1},async refresh(r){let a=Date.now();if(a-o<t)return r.log("LP0805",`route refresh for revision ${String(r.revision)} refused: the previous one was ${String(a-o)} ms ago`),"failed";o=a;let l=e.document??document,i=e.location??location,u=e.window??window,s=new AbortController,y=()=>{s.abort()};r.signal.addEventListener("abort",y,{once:!0});let m=setTimeout(()=>{s.abort()},n),d=f=>r.signal.aborted?"superseded":(r.log("LP0801",f instanceof Error?f.message:String(f)),"failed");try{let f;try{f=await(e.fetch??fetch)(i.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[Te]:"route"},signal:s.signal})}catch(g){return d(g)}if(r.signal.aborted)return"superseded";if(!f.ok||!(f.headers.get("content-type")??"").includes("text/html"))return r.log("LP0802",`route answered ${String(f.status)} ${f.headers.get("content-type")??""}`),"failed";try{let g=await f.text();if(!r.isCurrent())return"superseded";let E=new DOMParser().parseFromString(g,"text/html"),c=u.scrollX,p=u.scrollY;return Oe(l,E),P(l.body,E.body,{keyAttributes:[V,D,b],retainChildrenOf:T=>T.hasAttribute(b)}),u.scrollTo(c,p),"refreshed"}catch(g){return d(g)}}finally{clearTimeout(m),r.signal.removeEventListener("abort",y)}}}}function Ne(e){return{plan:(n,t)=>L(n,t).map(o=>o.element),async render(n,t){let o={rendered:0,failed:0,superseded:0},r={revision:n.revision,receivedAt:n.receivedAt,fields:n.fields,locale:n.locale,collectionSlug:n.collectionSlug,globalSlug:n.globalSlug,signal:n.signal};return await Promise.all(t.map(async a=>{let l=M(a);if(l===null)return;let i;try{i=await e(r,l)}catch(u){i={status:"failed",code:"LP0801",reason:u instanceof Error?u.message:String(u)}}if(!n.isCurrent()||i.status==="superseded"){o.superseded+=1,n.log("LP0804",`fragment "${l.id}" for revision ${String(r.revision)} discarded as superseded`);return}if(i.status==="rendered"){n.morph(a,i.html),n.rendered(a,l.id,l.key),o.rendered+=1;return}n.failed(a,l.id,l.key,i.code,i.reason),n.isCurrent()&&n.patch(a),o.failed+=1})),o}}}function z(e){return Ne(K(e))}return te(De);})();',n='"use strict";(()=>{function o(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function t(){return typeof window>"u"?!1:window.opener!=null}function e(){return o()||t()}function r(){let n=document.createElement("script");n.src=__LP_RUNTIME_SRC__,__LP_RUNTIME_INTEGRITY__!==""&&(n.integrity=__LP_RUNTIME_INTEGRITY__,n.crossOrigin="anonymous"),n.async=!0,document.head.appendChild(n)}e()&&r();})();',i=["allowedOrigins","serverURL","apiRoute","mergeDepth","debug","debounceMs","enableA11y","heartbeatMs","disableVisibilityGate","visibilityGateThreshold","intersectionRootMargin","disableReferrerDetection","disableLocalhostMatching","scopeBindingsByOwner","skipUnchanged","eventSourcePolicy","sanitizerPolicy","fragmentEndpoint","revealEditedField"];function r(e,t){if(0===e.length)throw new Error(`[live-preview] ${t} is empty. Run \`npm run build:runtime\` before bundling.`)}function generateInlineScript(t={}){return r(e,"runtime.generated.ts"),[l(t),...o(t),e].join("\n")}function o(e){return null==e.fragmentEndpoint?[]:(r(t,"fragment.generated.ts"),[t])}function l(e){return`var __LIVE_PREVIEW_CONFIG__=${function(e){if("v1"!==e.defaults&&""!==(e.serverURL??"")&&null==e.mergeDepth)throw new Error("payload-live-preview: `serverURL` needs an explicit `mergeDepth` under the 2.0 defaults — choose the population depth deliberately (0 for none), or pass `defaults: 'v1'` to keep the 1.x default of 1 while migrating (ADR 0007, entry 10).");const t=i.map(t=>e[t]??void 0);for(;t.length>0&&void 0===t.at(-1);)t.pop();return`[${t.map(e=>void 0===e?"":JSON.stringify(e)).join(",")}]`.replace(/</g,"\\u003C")}(e)};`}function a(e,t={}){return`<script${void 0!==t.nonce?` nonce="${function(e){if(!/^[A-Za-z0-9+/=_-]+$/.test(e))throw new RangeError("wrapWithScriptTag: nonce contains invalid characters");return e}(t.nonce)}"`:""}>${e}<\/script>`}var s=/[\t\n\f\r ]+/;function u(e,t){const n=e.charCodeAt(t);return 9===n||10===n||12===n||13===n||32===n}function d(e){let t=0,n=e.length;for(;t<n&&u(e,t);)t+=1;for(;n>t&&u(e,n-1);)n-=1;return 0===t&&n===e.length?e:e.slice(t,n)}function c(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function buildFrameAncestors(e={}){const{self:t=!0,origins:n=[],allowNone:i=!1}=e,r=/* @__PURE__ */new Set,o=[];if(i&&!t&&0===n.length)return"'none'";t&&(o.push("'self'"),r.add("'self'"));for(const e of n){const t=e.trim();0===t.length||r.has(t)||(r.add(t),o.push(t))}return o.length>0?o.join(" "):"'none'"}function h(e,t){const n=/* @__PURE__ */new Map;for(const t of e.split(";")){const e=d(t);if(0===e.length)continue;const i=e.search(s),r=c(i<0?e:e.slice(0,i));if(n.has(r))continue;const o=i<0?"":d(e.slice(i));n.set(r,o)}for(const[e,i]of Object.entries(t)){const t=c(e),r="string"==typeof i?{value:i}:i,o=r.mode??"union",l=n.get(t);if("replace"===o||void 0===l||0===l.length){n.set(t,r.value);continue}const a=/* @__PURE__ */new Set,u=[];for(const e of[...l.split(s),...r.value.split(s)])0===e.length||a.has(e)||(a.add(e),u.push(e));const d=u.filter(e=>"'none'"!==e);n.set(t,(d.length>0?d:u).join(" "))}const i=[];for(const[e,t]of n)i.push(0===t.length?e:`${e} ${t}`);return i.join("; ")}var f=class extends Error{name="PreviewConfigurationError"};function p(e){return{authorized:!1,outcome:e,context:null}}var g="payload-live-preview.authorized-preview-context",m=Symbol.for(g);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[m]&&Object.isFrozen(e)}function v(e){return Object.freeze({...e,scope:Object.freeze({...e.scope}),payloadHeaders:Object.freeze({...e.payloadHeaders}),[m]:!0,[g]:!0})}var y=Object.freeze({strict:!0,previewSignals:Object.freeze(["query"])}),b=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),w=Object.freeze({strict:!1,previewSignals:Object.freeze(["query","fetch-dest","referer"])}),S=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"}),k=["preview","draft","livePreview"];function A(e,t={}){const n=new Set(t.signals??["query","fetch-dest","referer"]),i=t.queryParams??k;if(n.has("query")){let t;try{t=new URL(e.url)}catch{t=void 0}if(void 0!==t)for(const e of i){const n=t.searchParams.get(e);if("true"===n||"1"===n)return!0}}if(n.has("fetch-dest")&&"iframe"===e.headers.get("sec-fetch-dest"))return!0;const r=n.has("referer")?t.adminOrigins??[]:[];if(r.length>0){const t=e.headers.get("referer");if(null!==t)try{const e=new URL(t).origin;for(const t of r)try{if(new URL(t).origin===e)return!0}catch{}}catch{}}return!1}function T(){try{const e=globalThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}var C=/<head(\s[^>]*)?>/i,R=/text\/html/i,$=/<meta\s+(?:[^>]*\s)?(?:charset\s*=|http-equiv\s*=\s*["']?content-type)[^>]*>/i;function x(e){const t="v1"===e.defaults?w:y,n="v1"===e.defaults?S:b,i=e=>n[e]!==b[e]?n[e]:void 0;return{strict:e.strict??t.strict,previewSignals:e.previewSignals??t.previewSignals,skipUnchanged:e.skipUnchanged??i("skipUnchanged"),disableReferrerDetection:e.disableReferrerDetection??i("disableReferrerDetection"),disableLocalhostMatching:e.disableLocalhostMatching,eventSourcePolicy:e.eventSourcePolicy??i("eventSourcePolicy"),sanitizerPolicy:e.sanitizerPolicy??i("sanitizerPolicy")}}function E(e){N(e);const t=x(e);return{...void 0!==e.defaults?{defaults:e.defaults}:{},...void 0!==e.allowedOrigins?{allowedOrigins:e.allowedOrigins}:{},...void 0!==e.serverURL?{serverURL:e.serverURL}:{},...void 0!==e.apiRoute?{apiRoute:e.apiRoute}:{},...void 0!==e.mergeDepth?{mergeDepth:e.mergeDepth}:{},...void 0!==e.revealEditedField?{revealEditedField:e.revealEditedField}:{},...void 0!==e.debug?{debug:e.debug}:{},...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.heartbeatMs?{heartbeatMs:e.heartbeatMs}:{},...void 0!==t.skipUnchanged?{skipUnchanged:t.skipUnchanged}:{},...void 0!==e.scopeBindingsByOwner?{scopeBindingsByOwner:e.scopeBindingsByOwner}:{},...void 0!==t.disableReferrerDetection?{disableReferrerDetection:t.disableReferrerDetection}:{},...void 0!==t.disableLocalhostMatching?{disableLocalhostMatching:t.disableLocalhostMatching}:{},...void 0!==t.eventSourcePolicy?{eventSourcePolicy:t.eventSourcePolicy}:{},...void 0!==t.sanitizerPolicy?{sanitizerPolicy:t.sanitizerPolicy}:{},...void 0!==e.fragments?{fragmentEndpoint:e.fragments.endpoint}:{}}}function N(e){if("v1"!==e.defaults&&void 0!==e.serverURL&&void 0===e.mergeDepth)throw new Error("payload-live-preview: `serverURL` needs an explicit `mergeDepth` under the 2.0 defaults — choose the relationship population depth deliberately (0 for none). Pass `defaults: 'v1'` to keep the 1.x default of 1 while migrating (ADR 0007, entry 10).")}var M=Object.freeze({isPreview:!1,authorization:null,outcome:void 0,inject:!1,cspMode:!1,exposeNonce:!1});function F(e){const t=x(e);N(e);const n="function"==typeof e.authorizePreview;t.strict?function(e){if("function"!=typeof e.authorizePreview)throw new Error("payload-live-preview: strict mode requires `authorizePreview` — response changes must be gated on a verified context, not on intent (ADR 0006).");const t=e.allowedOrigins??[];if(0===t.length)throw new Error("payload-live-preview: strict mode requires explicit, non-empty `allowedOrigins`.");if(!T())for(const e of t){let t;try{t=new URL(e).protocol}catch{t=void 0}if("https:"!==t)throw new Error(`payload-live-preview: strict mode requires https admin origins in production; got "${e}".`)}if(!0===x(e).previewSignals?.includes("referer"))throw new Error("payload-live-preview: strict mode disables referrer trust; remove 'referer' from `previewSignals` (the 'v1' profile includes it).")}(e):n||function(e){if(!T())return;const t=globalThis,n=t.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!n.has(e)){n.add(e);try{console.warn("[payload-live-preview] preview responses are gated on client-controlled intent only. Configure `authorizePreview` (see authorizePreviewRequest) before production; `strict: true` enforces it. ADR 0006 explains why intent is not authorization.")}catch{}}}("intent-only-preview");const i=!1!==(r=e.manageCsp)&&("full"===r?"full":"frame-ancestors");var r;const o=e.autoInject??!0;let l;return{authorizes:n,async decide(t,r={}){if(n&&void 0===r.authorize)throw new Error("payload-live-preview: `authorizePreview` is configured but decide() was called without an `authorize` hook; bind the hook to the request (bindDecisionHooks).");const l=function(e,t){const n=x(t).previewSignals;return"always"===(t.inject??"preview-only")||A(e,{...void 0!==t.previewQueryParams?{queryParams:t.previewQueryParams}:{},...void 0!==n?{signals:n}:{},adminOrigins:t.allowedOrigins??[]})}(t,e);if(!l)return M;let a,s=null;if(void 0!==r.authorize){let e;try{e=await r.authorize()}catch(t){if(function(e){return e instanceof f||e instanceof Error&&"PreviewConfigurationError"===e.name}(t))throw t;e={authorized:!1,outcome:"unavailable",context:null}}if(({context:s,outcome:a}=function(e){return isAuthorizedPreviewContext(e)?{context:e,outcome:"authorized"}:"object"==typeof e&&null!==e&&"authorized"in e?e.authorized&&isAuthorizedPreviewContext(e.context)?{context:e.context,outcome:"authorized"}:{context:null,outcome:e.authorized?"invalid":e.outcome}:{context:null,outcome:"invalid"}}(e)),null===s)return{isPreview:l,authorization:s,outcome:a,inject:!1,cspMode:!1,exposeNonce:!1}}return{isPreview:l,authorization:s,outcome:a,inject:o&&(r.shouldInject?.()??!0),cspMode:i,exposeNonce:!0}},scriptTag:t=>a((l??=generateInlineScript(E(e)),l),{nonce:t}),csp:(t,n,i)=>function(e,t,n,i){const r={"frame-ancestors":buildFrameAncestors({self:!0,origins:[...e.allowedOrigins??[],...e.frameAncestorsExtra??[]]})};return"full"===i&&(r["script-src"]=function buildScriptSrcWithNonce(e,t={}){if(0===e.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");const{self:n=!0,extra:i=[],strictDynamic:r=!1}=t,o=[];n&&o.push("'self'"),o.push(`'nonce-${e}'`),r&&o.push("'strict-dynamic'");for(const e of i){const t=e.trim();t.length>0&&o.push(t)}return o.join(" ")}(t,{self:!0,strictDynamic:e.strictDynamic??!1,...void 0!==e.scriptSrcExtra?{extra:e.scriptSrcExtra}:{}})),function(e,t){const n=e.split(",").filter(e=>e.trim().length>0);return 0===n.length?h("",t):n.map(e=>h(e,t)).join(", ")}(n,r)}(e,n,t,i),nonce:()=>function generateCspNonce(e=16){if(!Number.isInteger(e)||e<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(e)}`);const t=function(){const e=globalThis.crypto;return e?.getRandomValues?e:void 0}();if(!t)throw new Error("generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) once at startup, or run with --experimental-global-webcrypto. We won't fabricate a predictable nonce — that would silently defeat the entire CSP.");const n=new Uint8Array(e);return t.getRandomValues(n),function(e){let t="";for(const n of e)t+=String.fromCharCode(n);return("function"==typeof btoa?btoa(t):Buffer.from(e).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}(n)}()}}var L="virtual:payload-live-preview/options",P=`\0${L}`;function O(t={}){return{name:"payload-live-preview",hooks:{"astro:config:setup":i=>{"middleware"!==t.mode?!1!==t.autoInject&&("loader"!==t.mode?i.injectScript("head-inline",generateInlineScript(E(t))):function(t,i){if(void 0===t.updateConfig)throw new Error("payload-live-preview: mode 'loader' needs Astro's updateConfig hook (Astro >= 4) to publish the runtime asset. Upgrade Astro or use the default inline mode.");const a=function(t="/"){const n="_payload-live-preview/runtime.1185dfbfe640ed73.js",i=`/${t.replace(/^\/+|\/+$/gu,"")}`;return{fileName:n,urlPath:"/"===i?`/${n}`:`${i}/${n}`,integrity:"sha384-I9LyG2ZEhry95cbM0dFAWbkM9q9GaWoapFEJ00ko1Xzv+rrGIl0X/yUSu1QLDOI+",source:e}}(t.config?.base??"/");t.injectScript("head-inline",function(e={},t){if(r(n,"loader.generated.ts"),""===t.runtimeSrc)throw new Error("[live-preview] generateLoaderScript needs a runtimeSrc.");const i=e=>JSON.stringify(e).replace(/</gu,"\\u003C");return[l(e),`var __LP_RUNTIME_SRC__=${i(t.runtimeSrc)};`,`var __LP_RUNTIME_INTEGRITY__=${i(t.integrity??"")};`,...o(e),n].join("\n")}(E(i),{runtimeSrc:a.urlPath,integrity:a.integrity})),t.updateConfig({vite:{plugins:[{name:"payload-live-preview:loader-asset",generateBundle(){this.emitFile({type:"asset",fileName:a.fileName,source:a.source})},configureServer(e){e.middlewares.use((e,t,n)=>{(e.url??"").split("?")[0]===a.urlPath?(t.statusCode=200,t.setHeader("Content-Type","text/javascript; charset=utf-8"),t.setHeader("Cache-Control","no-cache"),t.end(a.source)):n()})}}]}})}(i,t)):function(e,t){if(void 0===e.addMiddleware||void 0===e.updateConfig)throw new Error("payload-live-preview: mode 'middleware' needs Astro's addMiddleware/updateConfig hooks (Astro >= 4). Upgrade Astro or use the default inline mode.");if(void 0!==t.authorizePreview)throw new Error("payload-live-preview: `authorizePreview` cannot be used with mode 'middleware' — options are serialized into the build. Compose `createLivePreviewMiddleware()` in your own `src/middleware.ts` to pass the hook.");if(void 0!==t.shouldInject)throw new Error("payload-live-preview: `shouldInject` cannot be used with mode 'middleware' — options are serialized into the build. Use `previewQueryParams`/`previewSignals`, or register createLivePreviewMiddleware() manually in src/middleware.ts.");if(t.strict??"v1"!==t.defaults)throw new Error("payload-live-preview: mode 'middleware' cannot satisfy the 2.0 strict default — it serializes its options into the build, so it cannot carry the `authorizePreview` function strict mode requires. Either register `createLivePreviewMiddleware({ authorizePreview, ... })` yourself in src/middleware.ts (recommended: response changes stay gated on a verified context), or pass `defaults: 'v1'` (or `strict: false`) to run intent-only middleware (ADR 0006 explains why intent is not authorization).");const{mode:n,shouldInject:i,...r}=t,o=`export default ${JSON.stringify(r).replace(/</g,"\\u003C")};`;e.updateConfig({vite:{plugins:[{name:"payload-live-preview-options",resolveId:e=>e===L?P:void 0,load:e=>e===P?o:void 0}]}}),e.addMiddleware({entrypoint:"payload-live-preview/astro/middleware-entry",order:"pre"})}(i,t)}}}}var I="livePreviewNonce",j="livePreviewAuthorization",U="livePreviewAuthorizationOutcome";function z(e={}){const t=F(e);return async(n,i)=>{const r=t.nonce();if(!0===n.isPrerendered)return n.locals[I]=r,i();const o=await t.decide(n.request,function(e,t,n){return{shouldInject:()=>t.shouldInject?.(n)??!0,...e.authorizes?{authorize:()=>t.authorizePreview?.(n)}:{}}}(t,e,n.request));!function(e,t,n){!t.exposeNonce&&t.isPreview||(e[I]=n),null!==t.authorization&&(e[j]=t.authorization),void 0!==t.outcome&&(e[U]=t.outcome)}(n.locals,o,r);const l=await i();return o.isPreview?async function(e,t,n,i){return n.inject||!1!==n.cspMode?function(e,t,n,i){const r=n.cspMode;return function(e,t){try{return t(e.headers),e}catch{const n=new Headers(e.headers);return t(n),new Response(e.body,{status:e.status,statusText:e.statusText,headers:n})}}(e,e=>{if(!1!==r){const n=e.get("content-security-policy")??"";e.set("content-security-policy",t.csp(n,i,r))}!function(e){const t=e.get("cache-control")??"";/\bno-store\b/i.test(t)||e.set("cache-control","private, no-store");const n=(e.get("vary")??"").trim(),i=n.split(",").map(e=>e.trim().toLowerCase());i.includes("*")||i.includes("cookie")||e.set("vary",0===n.length?"Cookie":`${n}, Cookie`)}(e)})}(n.inject?await async function(e,t){if(null===e.body)return e;if(!R.test(e.headers.get("content-type")??""))return e;const n=function(e,t){const n=C.exec(e);if(null===n)return;const i=n.index+n[0].length,r=e.indexOf("</head",i),o=$.exec(e.slice(i,-1===r?void 0:r)),l=null===o?i:i+o.index+o[0].length;return`${e.slice(0,l)}${t}${e.slice(l)}`}(await e.clone().text(),t);if(void 0===n)return e;const i=new Headers(e.headers);return i.delete("content-length"),i.delete("content-encoding"),i.delete("etag"),new Response(n,{status:e.status,statusText:e.statusText,headers:i})}(e,t.scriptTag(i)):e,t,n,i):e}(l,t,o,r):l}}function D(e={}){return function(e){return a(generateInlineScript(E(e)),void 0!==e.nonce?{nonce:e.nonce}:{})}(e)}var _,W="users",B=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,V=/^[A-Za-z0-9._~-]+$/;function H(){return _??=new TextEncoder,_}function q(e){if(!/^[A-Za-z0-9_-]*$/.test(e))return;const t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4);try{const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)n[t]=e.charCodeAt(t);return n}catch{return}}async function G(e,t){switch(t.type){case"payload-session":return async function(e,t){const n=function(e){const t=e??"payload-token";if(!B.test(t))throw new f(`payload-live-preview: cookie name "${t}" is not a valid cookie-name token`);return t}(t.cookieName),i=function(e){let t;try{t=new URL(e)}catch{throw new f(`payload-live-preview: serverURL "${e}" is not an absolute URL`)}if("https:"!==t.protocol&&"http:"!==t.protocol)throw new f(`payload-live-preview: serverURL must be http(s), got "${t.protocol}"`);return t.origin}(t.serverURL),r=function(e,t,n=4096){if(null===e||0===e.length)return null;const i=`${t}=`,r=[];for(const t of e.split(";")){const e=t.trim();e.startsWith(i)&&r.push(e.slice(i.length))}if(1!==r.length)return null;const o=r[0]??"";return 0===o.length||o.length>n||!V.test(o)?null:o}(e.headers.get("cookie"),n,t.maxCookieLength??4096);if(null===r)return p("missing-credential");const o=t.now??Date.now,l=Math.max(250,t.timeoutMs??3e3),a=t.fetch??globalThis.fetch,s=encodeURIComponent(t.usersSlug??W),u=`${n}=${r}`;let d;try{const e=await a(`${i}/api/${s}/me?depth=0`,{headers:{cookie:u,accept:"application/json"},signal:AbortSignal.timeout(l)});if(!e.ok)return p(401===e.status?"invalid":"unavailable");d=await e.json()}catch{return p("unavailable")}const c=function(e,t){if("object"!=typeof e||null===e||Array.isArray(e))return null;const n=e.user;if("object"!=typeof n||null===n||Array.isArray(n))return null;const i=e.collection??n.collection;if(void 0!==i&&i!==t)return null;const r=n.id;return"string"==typeof r&&r.length>0?r:"number"==typeof r&&Number.isFinite(r)?String(r):null}(d,t.usersSlug??W);if(null===c)return p("invalid");const h=function(e){const t=e.exp;return"number"!=typeof t||!Number.isFinite(t)||t<=0?void 0:t<1e11?1e3*t:t}(d);return void 0!==h&&h<=o()?p("expired"):{authorized:!0,outcome:"authorized",context:v({strategy:"payload-session",subject:c,authorizedAt:o(),expiresAt:h,scope:{},payloadHeaders:{cookie:u}})}}(e,t);case"signed-token":return async function(e,t){const n=function(e){const t="string"==typeof e?H().encode(e):e;if(t.byteLength<32)throw new f(`payload-live-preview: the preview token secret must be at least ${String(32)} bytes`);return t}(t.secret),i=function(e){if(void 0!==e)return e;const t=globalThis.crypto;return"object"==typeof t?.subtle?t:void 0}(t.crypto);if(void 0===i)return p("unavailable");const r=function(e,t){if("header"===t?.kind)return e.headers.get(t.name??"x-preview-token");let n;try{n=new URL(e.url)}catch{return null}const i=n.searchParams.getAll(t?.param??"previewToken");return 1===i.length?i[0]??null:null}(e,t.transport);if(null===r||0===r.length)return p("missing-credential");if(r.length>4096)return p("invalid");const o=r.split(".");if(3!==o.length||"v1"!==o[0])return p("invalid");const l=o[1]??"",a=q(l),s=q(o[2]??"");if(void 0===a||32!==s?.byteLength)return p("invalid");let u;try{const e=await async function(e,t){return e.subtle.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}(i,n);u=await i.subtle.verify("HMAC",e,s,H().encode(`v1.${l}`))}catch{return p("unavailable")}if(!u)return p("invalid");const d=function(e){let t;try{t=JSON.parse((new TextDecoder).decode(e))}catch{return}if("object"!=typeof t||null===t)return;const n=t,i=e=>void 0===n[e]||"string"==typeof n[e];return 1===n.v&&"string"==typeof n.aud&&"string"==typeof n.pur&&"number"==typeof n.iat&&"number"==typeof n.exp&&"string"==typeof n.jti&&i("pth")&&i("loc")&&i("sub")?n:void 0}(a);if(void 0===d)return p("invalid");const c=(t.now??Date.now)();if(d.exp<=c||d.iat>d.exp)return p("expired");if(d.aud!==t.audience)return p("wrong-audience");if(d.pur!==(t.purpose??"live-preview"))return p("wrong-purpose");if(void 0!==d.pth){let t;try{t=new URL(e.url).pathname}catch{return p("invalid")}if(d.pth!==t)return p("wrong-path")}if(void 0!==d.loc){const n=t.locale?.(e);if(n!==d.loc)return p("wrong-locale")}if(void 0!==t.replay)try{if(await t.replay.isUsed(d.jti))return p("replayed");await t.replay.markUsed(d.jti,d.exp)}catch{return p("unavailable")}return{authorized:!0,outcome:"authorized",context:v({strategy:"signed-token",subject:d.sub,authorizedAt:c,expiresAt:d.exp,scope:{audience:d.aud,...void 0!==d.pth?{path:d.pth}:{},...void 0!==d.loc?{locale:d.loc}:{}},payloadHeaders:{}})}}(e,t);case"verifier":return async function(e,t){let n;try{n=await t.verify(e)}catch{return p("unavailable")}if(null===n)return p("invalid");const i=(t.now??Date.now)();return void 0!==n.expiresAt&&n.expiresAt<=i?p("expired"):{authorized:!0,outcome:"authorized",context:v({strategy:"verifier",subject:n.subject,authorizedAt:i,expiresAt:n.expiresAt,scope:n.scope??{},payloadHeaders:n.payloadHeaders??{}})}}(e,t)}}var J="x-payload-fragment-version";function K(e,t){if(t>12||"object"!=typeof e||null===e)return t;let n=t;for(const i of Object.values(e))if(n=Math.max(n,K(i,t+1)),n>12)break;return n}function Q(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function X(e){if(!Q(e))return null;const t=e.fragment;if("string"!=typeof t||!/^[a-z][a-z0-9-]{0,63}$/iu.test(t))return null;const n=e.key;if(void 0!==n&&("string"!=typeof n||n.length>128))return null;const i=e.route;if("string"!=typeof i||!i.startsWith("/")||i.length>2048)return null;const r=e.search;if("string"!=typeof r||r.length>4096||""!==r&&!r.startsWith("?"))return null;const o=e.revision;if("number"!=typeof o||!Number.isInteger(o)||o<0)return null;const l=[];for(const t of["locale","collectionSlug","globalSlug"]){const n=e[t];if(void 0!==n){if("string"!=typeof n||n.length>128)return null;l.push(n)}else l.push(void 0)}const[a,s,u]=l,d=e.fields;return!Q(d)||K(d,0)>12?null:{fragment:t,..."string"==typeof n?{key:n}:{},route:i,search:r,revision:o,...void 0!==a?{locale:a}:{},...void 0!==s?{collectionSlug:s}:{},...void 0!==u?{globalSlug:u}:{},fields:d}}var Y,Z={"cache-control":"private, no-store","x-content-type-options":"nosniff",vary:"Cookie",[J]:String(1)};function ee(e,t){return new Response(JSON.stringify({error:t}),{status:e,headers:{...Z,"content-type":"application/json; charset=utf-8"}})}async function te(e,t){return Y??=(async()=>{const e="astro/container",t=await(import(e));return await t.experimental_AstroContainer.create()})(),(await Y).renderToString(e,{props:t})}function ne(e,t){return new Promise((n,i)=>{const r=setTimeout(()=>{i(new Error("fragment render timed out"))},t);e.then(e=>{clearTimeout(r),n(e)},e=>{clearTimeout(r),i(e instanceof Error?e:new Error(String(e)))})})}function ie(e){const t=e.render??te,n=new Set(e.allowedOrigins??[]),i=e.limits?.bodyBytes??65536,r=e.limits?.timeoutMs??5e3,o=e.registry;return async({request:l})=>{if("POST"!==l.method)return ee(405,"method");if(!function(e,t){const n=e.headers.get("sec-fetch-site");if(null!==n&&"same-origin"!==n&&"none"!==n)return!1;const i=e.headers.get("origin");return null===i||i===new URL(e.url).origin||t.has(i)}(l,n))return ee(403,"origin");if(!(l.headers.get("content-type")??"").toLowerCase().startsWith("application/json"))return ee(415,"content-type");const a=await async function(e,t){if(Number(e.headers.get("content-length")??"0")>t)return null;const n=await e.text();if(n.length>t)return null;try{return JSON.parse(n)}catch{return null}}(l,i);if(null===a)return ee(413,"body");const s=X(a);if(null===s)return ee(400,"shape");const u=new URL(l.url).origin,d=new Request(`${u}${s.route}${s.search}`,{headers:l.headers}),c=await G(d,e.authorize);if(!c.authorized||!function(e,t){const n=e.scope;return void 0===n.locale||void 0===t.locale||n.locale===t.locale}(c.context,s))return ee(403,"unauthorized");const h=Object.prototype.hasOwnProperty.call(o,s.fragment)?o[s.fragment]:void 0;if(void 0===h)return ee(404,"fragment");const f={id:s.fragment,key:s.key,revision:s.revision,fields:s.fields,locale:s.locale,collectionSlug:s.collectionSlug,globalSlug:s.globalSlug,route:s.route,authorization:c.context,request:l},p=Date.now();let g;try{const e=await ne(Promise.resolve(h.props(f)),r);g=await ne(t(h.component,e,f),r)}catch{return ee(500,"render")}const m={html:g,boundary:{id:s.fragment,...void 0!==s.key?{key:s.key}:{}},revision:s.revision,metadata:{renderedAt:/* @__PURE__ */(new Date).toISOString(),renderer:void 0===e.render?"astro-container":"custom",durationMs:Date.now()-p}};return new Response(JSON.stringify(m),{status:200,headers:{...Z,"content-type":"application/json; charset=utf-8"}})}}export{j as AUTHORIZATION_LOCALS_KEY,U as AUTHORIZATION_OUTCOME_LOCALS_KEY,I as NONCE_LOCALS_KEY,ie as createFragmentEndpoint,z as createLivePreviewMiddleware,A as hasPreviewIntent,O as livePreview,D as renderLivePreviewScript};
2
2
  //# sourceMappingURL=index.js.map