payload-live-preview 2.0.6 → 2.1.1

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 (116) hide show
  1. package/README.md +148 -38
  2. package/dist/adapters/astro/FragmentBridge.astro +25 -0
  3. package/dist/adapters/astro/PreviewBoundary.astro +2 -4
  4. package/dist/adapters/astro/RichText.astro +26 -5
  5. package/dist/adapters/astro/index.d.ts +41 -9
  6. package/dist/adapters/astro/index.js +1 -1
  7. package/dist/adapters/astro/index.js.map +1 -1
  8. package/dist/adapters/astro/middleware-entry.d.ts +3 -3
  9. package/dist/adapters/astro/middleware-entry.js +1 -1
  10. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  11. package/dist/adapters/nextjs/index.d.ts +17 -12
  12. package/dist/adapters/nextjs/index.js +1 -1
  13. package/dist/adapters/nextjs/index.js.map +1 -1
  14. package/dist/adapters/nuxt/index.d.ts +11 -6
  15. package/dist/adapters/nuxt/index.js +1 -1
  16. package/dist/adapters/nuxt/index.js.map +1 -1
  17. package/dist/adapters/nuxt/module.d.ts +64 -13
  18. package/dist/adapters/nuxt/module.js +1 -1
  19. package/dist/adapters/nuxt/module.js.map +1 -1
  20. package/dist/adapters/react/index.d.ts +11 -7
  21. package/dist/adapters/react/index.js +1 -1
  22. package/dist/adapters/react/index.js.map +1 -1
  23. package/dist/adapters/sveltekit/index.d.ts +10 -5
  24. package/dist/adapters/sveltekit/index.js +1 -1
  25. package/dist/adapters/sveltekit/index.js.map +1 -1
  26. package/dist/adapters/vue/index.d.ts +10 -7
  27. package/dist/adapters/vue/index.js +1 -1
  28. package/dist/adapters/vue/index.js.map +1 -1
  29. package/dist/annotate.d.ts +15 -2
  30. package/dist/annotate.js.map +1 -1
  31. package/dist/client.cjs +1 -1
  32. package/dist/client.cjs.map +1 -1
  33. package/dist/client.d.cts +367 -266
  34. package/dist/client.d.ts +367 -266
  35. package/dist/client.js +1 -1
  36. package/dist/client.js.map +1 -1
  37. package/dist/codegen-cli.js.map +1 -1
  38. package/dist/codegen.cjs.map +1 -1
  39. package/dist/codegen.d.cts +7 -1
  40. package/dist/codegen.d.ts +7 -1
  41. package/dist/codegen.js.map +1 -1
  42. package/dist/core.cjs +1 -1
  43. package/dist/core.cjs.map +1 -1
  44. package/dist/core.d.cts +549 -393
  45. package/dist/core.d.ts +549 -393
  46. package/dist/core.js +1 -1
  47. package/dist/core.js.map +1 -1
  48. package/dist/doctor-cli.d.ts +1 -1
  49. package/dist/doctor-cli.js +1 -1
  50. package/dist/doctor-cli.js.map +1 -1
  51. package/dist/doctor.d.ts +2 -2
  52. package/dist/doctor.js +1 -1
  53. package/dist/doctor.js.map +1 -1
  54. package/dist/{document-session-BfBfLVpg.d.ts → document-session-DWi9H3Qk.d.ts} +7 -0
  55. package/dist/{fragment-endpoint-DATKU183.d.ts → fragment-endpoint-B2qcRw5T.d.ts} +22 -7
  56. package/dist/fragment.cjs +1 -1
  57. package/dist/fragment.cjs.map +1 -1
  58. package/dist/fragment.d.cts +37 -16
  59. package/dist/fragment.d.ts +37 -16
  60. package/dist/fragment.js +1 -1
  61. package/dist/fragment.js.map +1 -1
  62. package/dist/index.cjs +1 -1
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +607 -405
  65. package/dist/index.d.ts +607 -405
  66. package/dist/index.js +1 -1
  67. package/dist/index.js.map +1 -1
  68. package/dist/lean.cjs +1 -1
  69. package/dist/lean.cjs.map +1 -1
  70. package/dist/lean.d.cts +5 -2
  71. package/dist/lean.d.ts +5 -2
  72. package/dist/lean.js +1 -1
  73. package/dist/lean.js.map +1 -1
  74. package/dist/lexical.cjs +1 -1
  75. package/dist/lexical.cjs.map +1 -1
  76. package/dist/lexical.d.cts +32 -11
  77. package/dist/lexical.d.ts +32 -11
  78. package/dist/lexical.js +1 -1
  79. package/dist/lexical.js.map +1 -1
  80. package/dist/{locals-CNUGYbA_.d.ts → locals-B1mF3aTb.d.ts} +1 -1
  81. package/dist/{middleware-CWObDO37.d.ts → middleware-BGobLN9P.d.ts} +11 -5
  82. package/dist/migrate.js +1 -1
  83. package/dist/migrate.js.map +1 -1
  84. package/dist/{options-uHKrDM2U.d.ts → options-Cm8fC7dj.d.ts} +31 -1
  85. package/dist/payload.cjs +1 -1
  86. package/dist/payload.cjs.map +1 -1
  87. package/dist/payload.d.cts +18 -2
  88. package/dist/payload.d.ts +18 -2
  89. package/dist/payload.js +1 -1
  90. package/dist/payload.js.map +1 -1
  91. package/dist/plugin.cjs +2 -0
  92. package/dist/plugin.cjs.map +1 -0
  93. package/dist/plugin.d.cts +30 -0
  94. package/dist/plugin.d.ts +30 -0
  95. package/dist/plugin.js +2 -0
  96. package/dist/plugin.js.map +1 -0
  97. package/dist/plugins.cjs +1 -1
  98. package/dist/plugins.cjs.map +1 -1
  99. package/dist/plugins.d.cts +102 -29
  100. package/dist/plugins.d.ts +102 -29
  101. package/dist/plugins.js +1 -1
  102. package/dist/plugins.js.map +1 -1
  103. package/dist/{probe-Bzm4fYFL.d.ts → probe-DGPDsnbj.d.ts} +6 -2
  104. package/dist/server.cjs +1 -1
  105. package/dist/server.cjs.map +1 -1
  106. package/dist/server.d.cts +51 -7
  107. package/dist/server.d.ts +51 -7
  108. package/dist/server.js +1 -1
  109. package/dist/server.js.map +1 -1
  110. package/dist/structural.cjs +2 -2
  111. package/dist/structural.cjs.map +1 -1
  112. package/dist/structural.d.cts +61 -13
  113. package/dist/structural.d.ts +61 -13
  114. package/dist/structural.js +2 -2
  115. package/dist/structural.js.map +1 -1
  116. package/package.json +33 -4
@@ -1,2 +1,2 @@
1
- function e(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).")}var t=Object.freeze({strict:!0,previewSignals:Object.freeze(["query"])}),n=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),r=Object.freeze({strict:!1,previewSignals:Object.freeze(["query","fetch-dest","referer"])}),i=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"}),o=/* @__PURE__ */['(()=>{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(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function r(e,t,n,i){if(t.reportedUnfaithful.has(n.element))return;t.reportedUnfaithful.add(n.element),t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName);let r=e.onUnfaithfulPatch;if("ignore"!==r){if("warn"===r){e.warn(`[live-preview] LP0411: "${n.fieldName}" ${i}`);return}e.log("LP0411",n.fieldName,i),t.unfaithfulPatches.push(n)}}function l(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}function o(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function a(e){let t=e.trim();return JSON.stringify(t.length>Ln?`${t.slice(0,Ln)}\\u2026`:t)}function s(){return function(){if(typ','eof 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 u(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}function d(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=c(n);e&&t.push(e)}return t}function c(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=d(t.fields),l=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=d(e.fields);t.push({...e,slug:i,fields:r})}return t}(t.blocks),o={...t,name:n,type:i};return r.length>0?o.fields=r:delete o.fields,l.length>0?o.blocks=l:delete o.blocks,o}function h(e,t){return void 0===e||t(e)}function f(e,t){return null==e||t(e)}function p(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}function m(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 Bn)(i>=Wn[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 g(e,t){return e.generation===t.generation&&e.revision===t.revision}function v(e){return function(e){if(!1===e.enableA11y)return null;let t=e.root,n=void 0===t?void 0:function(e){return 9===e.nodeType}(t)?t:t.ownerDocument;return new jn(e.a11yLocale,n)}(e)}function y(e){if(typ','eof window>"u")return;let t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),zn.sendReady(t,e)}function b(e,t=""){let n=new Map;return w(e,t,n),n}function w(e,t,n){for(let i of e){if(Dn.has(i.type)){i.fields&&w(i.fields,t,n);continue}let e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&w(i.fields,e,n);else if("array"===i.type&&i.fields)w(i.fields,`${e}.*`,n);else if("blocks"===i.type&&i.blocks)for(let t of i.blocks)w(t.fields,`${e}.*.${t.slug}`,n)}}function S(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}function T(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function k(e){if("object"!=typeof e||null===e)return;let t=e.blockType;return"string"==typeof t?t:void 0}function A(e,t){return t.every(e=>void 0!==T(e))?function(e,t){let n=[],i=new Map;for(let t=0;t<e.length;t+=1){let n=T(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=T(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 u=e[s];k(u)===k(o)?(s!==l&&n.push({kind:"move",from:s,to:l,value:o}),C(u,o)||n.push({kind:"update",index:l,value:o})):n.push({kind:"replace",index:l,oldValue:u,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)C(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 C(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 $(e){if("string"!=typeof e)return!1;let t=e.trim().replace(Jn,"");if(0===t.length||Gn.test(t))return!1;if(t.startsWith("#")||t.startsWith("?")||Kn.test(t)||t.startsWith("/"))return!0;try{let e=new URL(t);return Hn.has(e.protocol)}catch{return qn.test(t)}}function R(e){let t=e.trim().replace(Jn,"");return/^https?:\\/\\//i.test(t)||Kn.test(t)}function F(e){return!e.startsWith("on")&&!Xn.has(e)}function N(e){return Zn.add(e),e}function x(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 M(e){return e.closest(`[${ei}]`)}function E(e){let t=e.getAttribute(ti);return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==M(e)?"fragment":null!==e.closest("head")?"route":"patch"}function O(e){return`global:${e}`}function P(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function L(e){return"string"==typeof e&&e.length>0}function U(e,t){return null!==t&&void 0!==e&&t.includes(e)}function I(e){let t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function j(e,t,n){let i=e.get(t);return void 0!==i&&(!1===n||i.some(e=>U(e.owner,n)))}function _(e,t,n){let i=`${t}.`;for(let[t,r]of e.entries())if(t.startsWith(i)&&(!1===n||r.some(e=>U(e.owner,n))))return!0;return!1}function W(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 B(e,t,n){let i;return r=>{if(j(e,r,n))return!0;let l=W(r,t);return!!(l!==r&&j(e,l,n)||_(e,r,n)||l!==r&&_(e,l,n))||(i??(i=function(e,t){let n=new Set;for(let[i,r]of e.entries())for(let e of r)!1!==t&&!U(e.owner,t)||void 0!==e.locale&&n.add(`${i}_${e.locale}`);return n}(e,n)),i.has(r))}}function z(e,t,n,i,r){return V(n)?!V(t)||function(e,t,n){let i=void 0===n?void 0:S(n,e);return void 0!==i&&!ii.has(i.type)||!0===t.get(e)?.some(D)||_(t,e,!1)}(e,i,r)?"keep":null==t?"ask":"own":"ask"}function D(e){return!ii.has(e.fieldType)}function V(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function H(e){return!0===e?.includes(".")}function G(e){return null!==e&&e.forceRender&&!e.completed}function q(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function K(...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 J(e,t){let n={};for(let i of t)i!==e&&(n[i]=[e]);return n}function X(e){return"patch"===e.getAttribute(fi)}function Q(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(fi)}(e)&&!X(e)}function Z(e){let t=e.closest(Li)?.getAttribute(Fi);return null==t||0===t.length?void 0:t}function Y(e){return Ii.has(e)||Ui.test(e)}function ee(e){let t=e.getAttribute(gi);if(null!==t&&Y(t))return t;if(e.hasAttribute(Ai))return"richText";if(e.hasAttribute(Ci))return"html";if(e.hasAttribute(Ri))return"structural-array";if(e.hasAttribute($i))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 te(){return!0}function ne(e,t){return e.length>0&&e.length<=t&&"."!==e&&".."!==e&&!e.includes("/")&&!e.includes("\\\\")&&!function(e){for(let t of e){let e=t.codePointAt(0)??0;if(e<=31||127===e)return!0}return!1}(e)}function ie(e){return ne(e,128)&&!e.includes("?")&&!e.includes("#")}function re(e){return e.has("schema-json")?Bi:e.has("document-events")||e.has("relationship-events")?zi:Di}function le(e){if(e.nodeType!==Vi)return!1;let t=e;return t.hasAttribute(mi)||null!==t.querySelector(`[${mi}]`)}function oe(){if(typ','eof window>"u")return;let e=window;return e[Gi]??(e[Gi]={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]})}function ae(){let e=oe();if(void 0===e||e.armed)return;e.armed=!0;let t=window,n=t.__REACT_DEVTOOLS_GLOBAL_HOOK__??(t.__REACT_DEVTOOLS_GLOBAL_HOOK__=function(){let e=new Map;return{supportsFiber:!0,renderers:e,inject:t=>{let n=e.size+1;return e.set(n,t),n}}}()),i=n.onCommitFiberRoot;n.onCommitFiberRoot=function(t,n,...r){try{i?.call(this,t,n,...r)}catch{}let l=n?.containerInfo;void 0===e.onCommit?e.commits.push(l):e.onCommit(l)}}function se(e){e.committed=!0;let t=e.waiters;e.waiters=[];for(let e of t)e()}function ue(e,t){let n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function de(e,t,n){if(e.committed)return null;let i=null,r=()=>{null!==i&&clearTimeout(i),i=null,t("committed")};return e.waiters.push(r),i=setTimeout(()=>{i=null,ue(e,r),t("timed-out")},n),()=>{null!==i&&clearTimeout(i),i=null,ue(e,r)}}function ce(){if(typ','eof window>"u")return;let e=window;return e[Ji]??(e[Ji]={armed:!1,committed:!1,waiters:[]})}function he(e){return Object.prototype.hasOwnProperty.call(e,Ki)?e[Ki]:void 0}function fe(){let e=ce();if(void 0===e||e.armed)return;e.armed=!0;let t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,Ki)&&Object.defineProperty(t,Ki,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,Ki,{value:e,writable:!0,configurable:!0,enumerable:!0});let t=ce();void 0===t||t.committed||null===this.querySelector(qi)||function(e,t){let n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?se(e):n.hook(Xi,()=>{e.committed||se(e)})}(t,e)}})}function pe(e){if(void 0===e.hydration){e.startNow();return}let t=t=>{e.later(()=>{me(e,t)})},n="react"===e.hydration?function(e,t=5e3){ae();let n=oe();if(void 0===n)return null;if(void 0===n.onCommit){let e=e=>{!n.committed&&function(e){let t=e;return 9===t?.nodeType||null!=t?.querySelector?.(qi)}(e)&&se(n)};n.onCommit=e;for(let t of n.commits.splice(0))e(t)}return de(n,e,t)}(t):function(e,t,n=5e3){fe();let i=ce();return void 0===i?null:(!i.committed&&function(e){for(let t=e.querySelector(qi);null!==t;t=t.parentElement)if(void 0!==he(t))return!0;return!1}(e)&&se(i),de(i,t,n))}(e.root,t);null!==n?(e.defer(n),e.hydrated("waiting")):me(e,"committed")}function me(e,t){e.hydrated(t),"timed-out"===t&&e.warn(`[live-preview] LP0607: no ${"react"===e.hydration?"React commit":"Vue mount"} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}function ge(e,t=tr){if("string"!=typeof e)return!1;let n=e.trim();return!(n.length<t||ir.test(n)||nr.has(n.toLowerCase())||rr.test(n)||lr.test(n))}function ve(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ye(e,t,n=tr){let i=new Map,r=(e,t,n)=>{i.set(e,i.has(e)?null:{field:t,media:n})};for(let[i,l]of Object.entries(e)){if(ni.has(i))continue;let e=W(i,t);if(ge(l,n))r(l.trim(),e,!1);else if(ve(l))if("string"==typeof l.url)r(l.url,e,!0);else if(!("id"in l)&&!("_id"in l))for(let[t,i]of Object.entries(l))ni.has(t)||!ge(i,n)||r(i.trim(),`${e}.${t}`,!1)}return i}function be(e){if(e.namespaceURI!==ar||or.has(e.tagName)||e.hasAttribute(mi)||e.hasAttribute(Yi)||e.hasAttribute(er)||Q(e))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function we(e){let t;for(let n=e.firstChild;null!==n;n=n.nextSibling){if(1===n.nodeType)return;if(3!==n.nodeType)continue;let e=n.data.trim();if(0!==e.length){if(void 0!==t)return;t=e}}return t}function Se(e){return F(e)&&!e.startsWith("data-payload-")&&"value"!==e}function Te(e,t,n){let i=e.byElement.get(t);void 0===i&&(i={attributes:new Map},e.byElement.set(t,i));let r=e.byField.get(n.field);return void 0===r&&(r=new Set,e.byField.set(n.field,r)),r.add(t),i}function ke(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(be(n))continue;let e=we(n),i=void 0===e?void 0:t.values.get(e);null!=i&&!i.media&&(Te(t,n,i).text=i.field);for(let e of n.getAttributeNames()){if(!Se(e))continue;let i=t.values.get(n.getAttribute(e)??"");null!=i&&(i.media&&("IMG"!==n.tagName||"src"!==e)||Te(t,n,i).attributes.set(e,i))}ke(n,t)}}function Ae(e,t,n){let i=e.tagName;if(void 0!==t){let r={[mi]:t};if("A"===i){let e=n.get("href");void 0===e?r[gi]="text":e!==t&&(r[yi]=e)}return{element:e,fieldName:t,matched:we(e)??"",stamps:r}}if("IMG"===i){let t=n.get("src");if(void 0!==t){let i=n.get("alt");return{element:e,fieldName:t,matched:e.getAttribute("src")??"",attribute:"src",stamps:{[mi]:t,...void 0!==i&&i!==t?{[wi]:i}:{}}}}}let r=n.entries().next();if(r.done)return;let[l,o]=r.value;return{element:e,fieldName:o,matched:e.getAttribute(l)??"",attribute:l,stamps:{[mi]:o,[vi]:l}}}function Ce(e,t){let n={values:t,byElement:new Map,byField:new Map};t.size>0&&!be(e)&&ke(e,n);let i=e=>1===n.byField.get(e)?.size,r=[];for(let[e,t]of n.byElement){let n=void 0!==t.text&&i(t.text)?t.text:void 0,l=new Map;for(let[e,n]of t.attributes)i(n.field)&&l.set(e,n.field);let o=Ae(e,n,l);void 0!==o&&r.push(o)}return r}function $e(e){return 9===e.nodeType?e.body:e}function Re(e,t,n,i){let r=[];for(let l of t){let{element:t}=l;if(!t.hasAttribute(mi)&&(!1===n||U(Z(t),n))){for(let[e,n]of Object.entries(l.stamps))t.setAttribute(e,n);if(t.setAttribute(Ei,l.matched),void 0===e.cache.add(t)){for(let e of Object.keys(l.stamps))t.removeAttribute(e);t.removeAttribute(Ei);continue}e.observers.observeElement(t),e.log("autoBind",l.fieldName,"\\u2192",`<${t.tagName.toLowerCase()}>`,l.attribute??"text",JSON.stringify(l.matched),i),r.push(l)}}return r}function Fe(e,t,n,i=!1){if(i&&void 0!==n){let i=Ne(e,`${t}_${n}`);if(void 0!==i)return i}let r=Ne(e,t);if(void 0!==r)return r;if(t.includes(".")){let n=e,i=!0;for(let e of t.split(".")){if(sr.has(e)||null===n||"object"!=typeof n){i=!1;break}if(n=Ne(n,e),void 0===n){i=!1;break}}if(i)return n}return void 0===n?void 0:Ne(e,`${t}_${n}`)}function Ne(e,t){if(!sr.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function xe(e,t,n,i){return Fe(e,n,t.locale??i,void 0!==t.locale)}function Me(e,t,n,i){let r=x(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=x(xe(n,e,t,i));if(void 0===r)return;o+=`|${t}=${r}`}return o}function Ee(e,t,n,i,r){let{warned:l,warn:o}=e;if(l.has(n)||t(n))return;l.add(n);let a=`data-payload-field="${W(n,i)}"`;o(""!==r?`[live-preview] LP0203: field "${n}" has a value and no <\\u2026 ${a}> on this page; editing it changes nothing here. Expected where the page shows part of the document: inspect().fidelity.fields lists these, onUnfaithfulPatch decides whether a server render is asked for.`:`[live-preview] LP0201: no <\\u2026 ${a}> for the empty field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)}function Oe(e){let t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function Pe(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Le(e){let t=function(){let e=function(){let e=globalThis,t=e[dr];if(void 0!==t)return t;let n={};return e[dr]=n,n}();if(void 0!==e.override)return e.override;if(void 0!==e.auto)return e.auto;let t=function(){let e=globalThis.trustedTypes;return"object"!=typeof e||null===e?void 0:"function"==typeof e.createPolicy?e:void 0}();try{e.auto=void 0===t?null:t.createPolicy(ur,{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===t?e:t.createHTML(e)}function Ue(e,t){for(let n of t.keyAttributes){let t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function Ie(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(fi)||e.hasAttribute(cr))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function je(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!Ie(e)&&!Ie(t)}(e,t))return t;let i=ze(e);return function(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||hr.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=Ue(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?Ue(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=_e(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(Be(i,r)){c=_e(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&&Be(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)&&We(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),De(i),e}function _e(e,t,n){return e instanceof Element&&t instanceof Element?Ie(e)&&Ie(t)?e:je(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function We(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function Be(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function ze(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}function De(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{}}function Ve(e){fr.has(e)||(fr.add(e),function(e){try{console.warn(e)}catch{}}(`[live-preview] LP0409: the strict sanitizer removed \\`${e}\\` from written markup; the 1.x default (\\`sanitizerPolicy: \'compat\'\\`) kept it. ${function(e){return e.startsWith(pr)?"A binding inside CMS content is refused by design \\u2014 an editor could otherwise aim a write at any element on the page (docs/security.md)":"id"===e||"name"===e?"CMS content that can name an element can shadow a global of that name \\u2014 DOM clobbering, refused by design (docs/security.md)":"List it in `allowedDataAttributes` if the page needs it, or set `sanitizerPolicy: \'compat\'` to keep every `data-*` as 1.x did"}(e)}.`))}function He(e,t,n){let i=Ge();if(!i)throw new Error("sanitizeHtml needs a DOM");if(""===e)return"";let r=function(e,t){let n=e?.policy??t??Rr;if(!e){let e=new Map;for(let[t,n]of Object.entries(Tr))e.set(t,n);return{allowedTags:mr,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:new Set}}let i=new Set(mr);if(e.additionalAllowedTags?.forEach(e=>i.add(e)),!0===e.allowFormControls)for(let e of gr)i.add(e);let r=new Map;for(let[e,t]of Object.entries(Tr))r.set(e,t);for(let[t,n]of Object.entries(e.additionalAllowedAttributes??{})){let e=new Set(r.get(t));for(let t of n)e.add(t);r.set(t,e)}return{allowedTags:i,attrByTag:r,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t),l=i.createElement("template");return l.innerHTML=Le(e),qe(l.content,r),l.innerHTML}function Ge(){if(!(typ','eof document>"u"))return document}function qe(e,t){for(let n of Array.from(e.childNodes))n.nodeType===Ar?Ke(n,t):n.nodeType===Cr&&n.remove()}function Ke(e,t){let n=e.tagName.toLowerCase();!vr.has(n)||t.allowFormControls&&gr.has(n)?t.allowedTags.has(n)?(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("is"!==r){if("strict"===n.mode){if(n.templateMode&&$r.has(r))continue;if("id"===r||"name"===r||r.startsWith(Sr)){e.removeAttribute(t.name),("name"!==r||!0===i?.has(r))&&Ve(r);continue}if(r.startsWith(wr)){n.allowedData.has(r)||(e.removeAttribute(t.name),Ve(r));continue}if(yr.has(r)||r.startsWith(br))continue}else if(yr.has(r)||r.startsWith(br)||r.startsWith(wr))continue;i?.has(r)?(kr.has(r)&&!$(t.value)||"srcset"===r&&!Je(t.value))&&e.removeAttribute(t.name):e.removeAttribute(t.name)}else e.setAttribute("is","")}}(e,n,t),"a"===n&&function(e){let t=e.getAttribute("href");null===t||!R(t)||(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),qe(e,t)):(qe(e,t),e.replaceWith(...e.childNodes)):e.remove()}function Je(e){for(let t of e.split(",")){let e=t.trim();if(0===e.length)continue;let[n=e]=e.split(/\\s/,1);if(!$(n))return!1}return!0}function Xe(e){return e.replace(Nr,e=>Fr[e])}function Qe(e){return e.replace(Mr,e=>xr[e])}function Ze(e){let t=new Set;for(let n of e)if("object"==typeof n&&null!==n)for(let e of Object.keys(n))t.add(e);return t}function Ye(e,t,n,i,r){let l="object"==typeof t&&null!==t?t:null;return e.replace(Er,(e,o)=>null!==l&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(l,o)?Xe(i(Reflect.get(l,o))):null===l&&"value"===o?Xe(i(t)):"index"===o?String(n):null!==l&&!0===r?.has(o)?"":e)}function et(e){let t=e.children,n=t[0];if(void 0===n)return[];let i=[];for(let{name:e,value:r}of Array.from(n.attributes)){if(!F(e)||e.startsWith(Or))continue;let n=!0;for(let i=1;i<t.length&&n;i+=1)n=t[i]?.getAttribute(e)===r;n&&i.push([e,r])}return i}function tt(e,t){for(let[n,i]of t)e.hasAttribute(n)||e.setAttribute(n,i)}function nt(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 it(e){return null==e||""===e}function rt(e,t){let n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function lt(e,t,n,i){return e.set(t,n),function(e,t){for(let n of e.keys()){if(e.size<=t)break;e.delete(n)}}(e,i),n}function ot(e){let t=rt(jr,e);if(void 0!==t)return t;let n=new Set(Pr);for(let t of e.matchAll(Ur)){let e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}let i={};for(let e of n)i[e]=Lr;let r={additionalAllowedTags:[...n],additionalAllowedAttributes:i,allowFormControls:!0,templateMode:!0};return lt(jr,e,r,Ir)}function at(e){let t=ut(e.container,e.patches,e);return null===t?null:dt(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function st(e,t){return t.hasAttribute(Wr)&&t.hasAttribute(Br)}function ut(e,t,n){let i=function(e,t,n){let{template:i,nextItems:r,forceRender:l=!1,store:o,sanitizerPolicy:a}=n,s=o.get(e),u=et(e),d=Ze(r),c=Array.from(e.children),h=vt(c,_r),f=new Set,p=[];for(let o=0;o<r.length;o+=1){let m=r[o],g=gt(m),v=void 0===g?c[o]??null:yt(h,g)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);let y=t.replaces.has(o),b=l||t.renders.has(o)||null===v?bt(e.ownerDocument,i,m,o,a,u,d):void 0;if(null===b)return null;let w=void 0===b?[]:ct(y?null:v,b,m,void 0===g?void 0:s?.get(g),n);if(null===w)return null;p.push([o,v,b,w,y])}return p}(e,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}}(t),n);return null===i?null:[e,i,n.nextItems]}function dt(e,t,n){let[i,r,l]=e,o=new Set,a=!1,s=ze(i);for(let[e,l,s,u,d]of r){let r=l;if(void 0!==s){let e=!(!n.morph||d||null===l)&&je(l,s,{keyAttributes:[_r,Wr],retainChildrenOf:st,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===l;if(!e)for(let[e,t]of u)null!==e&&(ft(e,t),t.replaceWith(e));for(let[,,e]of u)void 0!==e&&dt(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);De(s);let u=function(e,t){let n=t.get(e);return n||(n=new Map,t.set(e,n)),n}(i,t);u.clear();for(let e of l)mt(u,e);return a}function ct(e,t,n,i,r){let l=vt(null===e?[]:ht(e),Wr),o=[];for(let e of ht(t)){let t=e.getAttribute(Wr);if(null===t)continue;let a,s=yt(l,t)??null,u=e.getAttribute(Br),d=u?s:null,c=d?.getAttribute(Br)??null;if(u){let l=pt(n,t);if(void 0!==l||null!==d){let n=l??[],o=A(null===d?[]:pt(i,t)??[],n),s=null!==d&&c!==u;if((o.length>0||s)&&(a=ut(d??e,o,{template:u,nextItems:n,forceRender:s,store:r.store,sanitizerPolicy:r.sanitizerPolicy})??void 0,void 0===a))return null}}o.push([d,e,a])}return o}function ht(e){return Array.from(e.querySelectorAll(`[${Wr}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Wr))return!1;n=n.parentElement}return n===e})}function ft(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 pt(e,t){if("object"!=typeof e||null===e)return;let n=e[t];return Array.isArray(n)?n:void 0}function mt(e,t){let n=gt(t);void 0!==n&&e.set(n,t)}function gt(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function vt(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 yt(e,t){return e.get(t)?.pop()}function bt(e,t,n,i,r,l,o){let a=He(Ye(t,n,i,nt,o),r,ot(t)),s=e.createElement("template");s.innerHTML=Le(a);let u=s.content.firstElementChild;if(!u)return null;tt(u,l);let d=gt(n);return void 0!==d&&u.setAttribute(_r,d),u}function wt(e,t){let n=new Set(t);return{boundaries:t,strategy:e,covers:e=>void 0!==e.fragmentBoundary&&n.has(e.fragmentBoundary)}}function St(t,n,i,r,l){let o=t.transformValue;if(void 0===o)return i;try{let t=o(n.fieldName,i,{element:n.element,allFields:r},l),a=e(t);if(!l())return i;if(a)throw new TypeError(`Transform for "${n.fieldName}" returned a thenable; transforms must be synchronous`);return t}catch(e){if(!l())return i;let n=e instanceof Error?e:new Error(String(e));return t.emitter.emit("error",{error:n,context:"transform",code:"LP0602"}),i}}function Tt(e){return 9===e.nodeType}function kt(e){return e.body}function At(){if(typ','eof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Ct(e){let t=e.trim();if(0!==t.length)try{let e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||!Jr.test(e.origin)?void 0:e.origin}catch{return}}function $t(e){let t=e.format;return"string"==typeof t&&el.has(t)?t:"number"==typeof t?Yr[t]:void 0}function Rt(e){let t=e.indent;return"number"==typeof t&&t>0?t:0}function Ft(e){return"rtl"===e.direction?\' dir="rtl"\':"ltr"===e.direction?\' dir="ltr"\':""}function Nt(e){let t=$t(e),n=Rt(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 xt(e){return"object"==typeof e&&null!==e?e:void 0}function Mt(e){return xt(e)}function Et(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function Ot(e){return"string"==typeof e&&e.length>0?e:void 0}function Pt(e){let t=Ot(e.title)??Ot(e.name)??Ot(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}function Lt(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(let n of e.children)t+=Lt(n);return t}function Ut(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function It(e){return"string"==typeof e.mimeType?` type="${Qe(e.mimeType)}"`:""}function jt(e){return rl.get(e)}function _t(e,t,n,i){let r=xt(e.fields)??{},l="string"==typeof r.blockType?r.blockType:"",o=Et(l),a=""===o?i:`${i} ${i}--${o}`;if(""!==l){let e=jt(l)??jt(o);if(e)return e(r,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(l,a)}return`<${n} class="${a}"></${n}>`}function Wt(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}function Bt(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 zt(e,t){let n=function(e){return al.get(e)??ol[e]}(e.type);return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function Dt(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+=Dt(n);return t}function Vt(e="text"){let t=new WeakSet;return{name:e,render:N((e,n)=>{let i=e.element,r=function(e){return null==e?"":Bt(e)?function(e){return Bt(e)?e.root.children.map(Dt).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(ul))return function(e,t,n){e.has(t)||(e.add(t),An(`[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=Le(function(e){return Xe(e).replace(/\\r\\n|\\r|\\n/g,"<br>")}(r)):i.textContent=r}else i.value=r})}}function Ht(e,t){let n=e.cloneNode(!1);n.innerHTML=Le(t);let i=function(e,t){let n=e.firstElementChild;if(null!==n?.nextElementSibling||t.children.length<2||!hl.has(n.tagName)||n.hasAttribute(mi))return null;for(let e of t.children)if(e.tagName===n.tagName&&e.className===n.className)return null;return n}(e,n)??e,r=new Map,l=n.querySelectorAll(ll);if(l.length>0&&null!==i.firstElementChild){let e=[];Gt(i,n,e);for(let[t,n]of e)t.replaceWith(n),n.matches(ll)||r.set(t.className,!1);for(let e of l)null!==e.parentNode&&r.set(e.className,!0)}return i.replaceChildren(...n.childNodes),r}function Gt(e,t,n){if(e.children.length!==t.children.length)return;let i=e.firstElementChild,r=t.firstElementChild;for(;null!==i&&null!==r;)r.matches(ll)?n.push([r,i]):Gt(i,r,n),i=i.nextElementSibling,r=r.nextElementSibling}function qt(e,t,n,i){i&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);let r=i?cl:dl;r.has(n)||(r.add(n),An(`[live-preview] ${i?`LP0413: no renderer for block "${n}", and the markup the server rendered for it is lost.`:`LP0410: no renderer for block "${n}"; keeping what the server rendered for it.`} Register one with registerBlockRenderer().`))}function Kt(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:$(n)?{kind:"safe",url:n}:(ml.has(e)||(ml.add(e),An(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function Jt(e,t=e=>e){return{name:e,render(e,n,i){let r=e.element;if(it(n)){!function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(r);return}let l=nt(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):Fe(i.allFields,n,i.locale,void 0!==e.locale),a=Kt(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 Xt(e){for(let t of bl)e.removeAttribute(t)}function Qt(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||!$(n.url)||t.push(`${Zt(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&$(e.url)&&t.push(`${Zt(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 Zt(e){return e.replace(/[\\s,]/g,encodeURIComponent)}function Yt(e){"IMG"===e.tagName?Xt(e):e.style.backgroundImage=""}function en(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):Xt(e)}function tn(e){let t=xt(e);return void 0===t?nt(e):Pt(t)??""}function nn(e,t){let n=e??"";if(null==t)return n;let i=rn(t);return"{}"===i?n:`${n}|${i}`}function rn(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>rn(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)}:${rn(n)}`)}return`{${i.join(",")}}`}function ln(e){return{kind:"date",options:e}}function on(e){return{kind:"number",options:e}}function an(e,t,n,i){if(void 0===t||""===t)return;let r=function(e){let t=e.indexOf(":"),n=-1===t?e:e.slice(0,t),i=-1===t?void 0:e.slice(t+1);switch(n){case"date":return void 0===i?ln({dateStyle:"medium"}):Fl.has(i)?ln({dateStyle:i}):void 0;case"time":return void 0===i?ln({timeStyle:"short"}):Nl.has(i)?ln({timeStyle:i}):void 0;case"datetime":return void 0===i?ln({dateStyle:"medium",timeStyle:"short"}):Fl.has(i)?ln({dateStyle:i,timeStyle:"short"===i?"short":"medium"}):void 0;case"number":return void 0===i?on({}):Ml.test(i)?on({minimumFractionDigits:Number(i),maximumFractionDigits:Number(i)}):void 0;case"currency":return void 0!==i&&xl.test(i)?on({style:"currency",currency:i.toUpperCase()}):void 0;case"percent":return void 0===i?on({style:"percent"}):void 0;default:return}}(t);if(void 0!==r)return r.kind===e?r.options:void 0;!function(e,t,n){El.has(e)||(El.add(e),An(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, date:short|medium|long|full, time, datetime, number, number:0-4, currency:XXX, percent.`))}(n,i,t)}function sn(e){return String(e).padStart(2,"0")}function un(){let e=new WeakMap,t=new WeakSet,n=new WeakMap,i=new WeakMap;return{name:"structural-array",render:N((r,l,o)=>{let a=it(l)?[]:l;if(!Array.isArray(a))return!1;let s=r.element,u=r.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,n){e.has(t)||(e.add(t),An(`[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,s,r.fieldName),!1;let d=e.get(s),c=dn(s),h=d?.values??function(e){return e.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e})}(c),f=A(h,a),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)}(d,u,c);if(0===f.length&&!p)return e.set(s,{values:a.slice(),template:u,domSnapshot:c}),!1;!function(e,t,n,i,r){let l=r.map(cn),o=new Set,a=l.find(e=>!(void 0===e||!o.has(e)&&(o.add(e),1)));if(void 0!==a&&hn(e,t,n,a),l.some(e=>void 0===e)&&fn(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(cn).filter(e=>void 0!==e)),o=l.some(e=>void 0!==e&&r.has(e));r.size>0&&!o&&fn(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,s,r.fieldName,d?.values,a);let m=at({template:u,container:s,patches:f,nextItems:a,store:i,forceRender:p,sanitizerPolicy:o.sanitizerPolicy,onDuplicateKey:(e,t)=>{hn(n,e,r.fieldName,t)}});return null!==m&&(e.set(s,{values:a.slice(),template:u,domSnapshot:dn(s)}),!!m&&void 0)})}}function dn(e){return Array.from(e.children,e=>e.getAttribute(_r))}function cn(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function hn(e,t,n,i){fn(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${i}"; later ones pair by position. Make \\`id\\` unique per item.`)}function fn(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),An(`[live-preview] ${i}`))}function pn(){return typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__}var mn=Object.defineProperty,gn=e=>{throw TypeError(e)},vn=(e,t,n)=>((e,t,n)=>t in e?mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),yn=(e,t,n)=>t.has(e)||gn("Cannot "+n),bn=(e,t,n)=>(yn(e,t,"read from private field"),n?n.call(e):t.get(e)),wn=(e,t,n)=>t.has(e)?gn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Sn=(e,t,n,i)=>(yn(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),Tn=(e,t,n)=>(yn(e,t,"access private method"),n),kn=t((...e)=>console.error(...e)),An=t((...e)=>console.warn(...e)),Cn=t((...e)=>console.debug(...e)),$n=class{constructor(){wn(this,Nn);wn(this,Rn,new Map);wn(this,Fn,new Map)}on(e,t){return Tn(this,Nn,Mn).call(this,bn(this,Rn),e,t)}once(e,t){return Tn(this,Nn,Mn).call(this,bn(this,Fn),e,t)}off(e,t){Tn(this,Nn,En).call(this,bn(this,Rn),e,t),Tn(this,Nn,En).call(this,bn(this,Fn),e,t)}async emit(e,t){await Tn(this,Nn,xn).call(this,e,t)}async emitWhile(e,t,n){return Tn(this,Nn,xn).call(this,e,t,n)}listenerCount(e){return(bn(this,Rn).get(e)?.size??0)+(bn(this,Fn).get(e)?.size??0)}removeAllListeners(e){void 0!==e?(bn(this,Rn).delete(e),bn(this,Fn).delete(e)):(bn(this,Rn).clear(),bn(this,Fn).clear())}eventNames(){let e=new Set;for(let t of bn(this,Rn).keys())e.add(t);for(let t of bn(this,Fn).keys())e.add(t);return[...e]}},Rn=new WeakMap,Fn=new WeakMap,Nn=new WeakSet,xn=async function(e,t,n){let i=()=>n?.()??!0;if(!i())return!1;let r=bn(this,Rn).get(e);if(r)for(let n of[...r])if(!i()||(await Tn(this,Nn,On).call(this,n,t,e),!i()))return!1;if(!i())return!1;let l=bn(this,Fn).get(e);if(l&&l.size>0){let n=[...l];bn(this,Fn).delete(e);for(let r of n)if(!i()||(await Tn(this,Nn,On).call(this,r,t,e),!i()))return!1}return i()},Mn=function(e,t,n){let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(n),()=>{Tn(this,Nn,En).call(this,e,t,n)}},En=function(e,t,n){let i=e.get(t);void 0!==i&&(i.delete(n),0===i.size&&e.delete(t))},On=async function(e,t,n){try{await e(t)}catch(e){let t="string"==typeof n||"number"==typeof n?String(n):"<event>";kn(`[live-preview] LP0601: handler for "${t}" threw:`,e)}},Pn=new Set(["date","number","checkbox"]),Ln=40,Un="payload-live-preview-a11y",In=new WeakMap,jn=class{constructor(e,t){vn(this,"german");vn(this,"document");vn(this,"lease",null);let n=t??(typ','eof document>"u"?null:document),i=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(i.length>0?i:s())),this.document=n}mount(){let e=this.document;if(null==e?.body)return null;this.lease??(this.lease=function(e){let t=In.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},In.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;u(t),e&&n.remove()}let i=e.getElementById(Un);return t.owned=null===i,null===i&&(i=e.createElement("div"),i.id=Un,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&&u(e),e.owned&&n?.remove(),e.element=null,In.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 r=setTimeout(()=>{n.timer===r&&n.element===t&&u(n)},1500);n.timer=r}},_n=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],Wn={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"}},Bn=Object.keys(Wn),zn=class{constructor(e,t){vn(this,"matcher");vn(this,"handlers");vn(this,"boundListener");vn(this,"attachedTarget");vn(this,"generation",0);vn(this,"revision",0);vn(this,"queueHead");vn(this,"queueTail");this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1,n=i=>{if(!t||this.boundListener!==n)return;let r=this.generation;try{this.receive(i,r,e)}catch{let e;try{e=i.origin}catch{e=""}this.reportInvalid("shape",e,r)}};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){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,n){let i=e.origin;if(!this.matchesOrigin(i,t)){this.reportInvalid("origin",i,t);return}if(!this.matchesSource(e,n)){this.reportInvalid("source",i,t);return}let r=e.data;if(function(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}(r))switch(r.type){case"payload-live-preview":if(!function(e){let t=e;return!(void 0!==t.data&&null!==t.data&&!p(t.data))&&f(t.fieldSchemaJSON,e=>Array.isArray(e))&&f(t.globalSlug,e=>"string"==typeof e)&&f(t.collectionSlug,e=>"string"==typeof e)&&f(t.locale,e=>"string"==typeof e)&&f(t.ready,e=>"boolean"==typeof e)&&f(t.previewToken,e=>"string"==typeof e)&&f(t.protocolVersion,e=>"number"==typeof e)}(r)){this.reportInvalid("shape",i,t);return}this.dispatchUpdate(function(e){let t={...e};for(let e of _n)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=d(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(r),i,t);return;case"payload-document-event":if(!function(e){let t=e;return h(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&h(t.slug,e=>"string"==typeof e)&&h(t.id,e=>"string"==typeof e||Number.isFinite(e))}(r)){this.reportInvalid("shape",i,t);return}this.invokeHandler(t,this.handlers.onDocumentEvent,r,i);return;case"payload-live-preview-focus":{let e=function(e){let t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(r);if(void 0===e){this.reportInvalid("shape",i,t);return}this.invokeHandler(t,this.handlers.onFocusField,e,i);return}default:this.reportInvalid("type",i,t)}else this.reportInvalid("shape",i,t)}dispatchUpdate(e,t,n){let i=p(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,verdict:void 0,next:void 0};this.enqueue(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){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){let t=this.queueHead;if(void 0===t)return;if(this.matchesOrigin(t.origin,e)){if(void 0===t.verdict)return;this.dequeue(t)&&(t.verdict?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){void 0===i?this.invokeHandler(n,this.handlers.onUpdate,e,t):this.invokeHandler(n,this.handlers.onUpdate,e,t,i)}reportInvalid(e,t,n){this.invokeHandler(n,this.handlers.onInvalid,e,t)}matchesSource(e,t){if("parent-or-opener"!==this.handlers.sourcePolicy)return!0;try{let n=e.source;if("object"!=typeof n||null===n)return!1;let i=t.parent;return i!==t&&n===i||n===t.opener}catch{return!1}}matchesOrigin(e,t){try{return!0===(this.isCurrentGeneration(t)&&this.matcher(e))&&this.isCurrentGeneration(t)}catch{return!1}}invokeHandler(t,n,...i){if(void 0!==n&&this.isCurrentGeneration(t))try{e(n(...i))}catch{}}isCurrentGeneration(e){return void 0!==this.attachedTarget&&this.generation===e}enqueue(e){void 0===this.queueTail?this.queueHead=e:this.queueTail.next=e,this.queueTail=e}dequeue(e){return this.queueHead===e&&(this.queueHead=e.next,void 0===this.queueHead&&(this.queueTail=void 0),!0)}resetQueue(){this.queueHead=void 0,this.queueTail=void 0}},Dn=new Set(["tabs","row","collapsible"]),Vn={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"},Hn=new Set(["http:","https:","mailto:","tel:"]),Gn=/^\\s*(?:javascript|data|vbscript|file|blob|about)\\s*:/i,qn=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,Kn=/^[\\\\/]{2}/,Jn=/[\\t\\n\\r]/g,Xn=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Qn=new Set(["href","src","poster","cite","action","xlink:href","data"]),Zn=new WeakSet,Yn=class{constructor(){vn(this,"previous",null)}diff(e,t){let n=this.previous,i=null===n,r=new Map,l=new Set;for(let[t,i]of Object.entries(e)){let e=x(i);r.set(t,e),(null===n||void 0===e||n.get(t)!==e)&&l.add(t)}if(null!==n)for(let e of n.keys())r.has(e)||l.add(e);this.previous=r;let o=new Set;for(let[e,n]of Object.entries(t))if(l.has(e))for(let e of n)o.add(e);return{changed:l,invalidated:o,baseline:i}}reset(){this.previous=null}},ei="data-payload-fragment",ti="data-payload-strategy",ni=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),ii=new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),ri={},li=class{constructor(){vn(this,"rawChanges",new Yn);vn(this,"resolved",null);vn(this,"queued",null);vn(this,"pending",null);vn(this,"timer",null);vn(this,"openUntil",0)}decide(e,t){let n=t.message.data??{},{changed:i}=this.rawChanges.diff(n,ri);if(!function(e){let{cache:t,emitter:n}=e;if(t.islands.length>0||n.listenerCount("beforeUpdate")>0||n.listenerCount("afterUpdate")>0)return!0;for(let e of t.values())if(D(e)||e.fieldName.includes(".")||H(e.hrefField)||H(e.srcField)||H(e.altField))return!0;return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${ei}]`)}(e))return{merge:!1,fields:n};let r=this.resolved;if(null===r)return this.resolved=n,{merge:!0,fields:n};let l={...r},o=t.forceRender;for(let a of i){let i=n[a];if(ni.has(a)){l[a]=i;continue}let s=z(a,r[a],i,e.cache,t.schemaIndex);"own"!==s&&(o=!0),"keep"!==s&&(l[a]=i)}return this.resolved=l,{merge:o,fields:l}}request(e,t,n){let i=Date.now();return i>=this.openUntil?(this.dropQueued(),this.openUntil=i+t,{leading:!0,result:e.merge(n)}):(this.queued=n,this.openUntil=i+t,this.pending??(this.pending=function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}()),null!==this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush(e)},t),{leading:!1,result:this.pending.promise})}recordMerged(e){this.resolved=e}destroy(){this.dropQueued(),this.openUntil=0}dropQueued(){null!==this.timer&&clearTimeout(this.timer),this.timer=null,this.queued=null,this.pending?.settle({status:"superseded"}),this.pending=null}flush(e){let t=this.pending,n=this.queued;this.timer=null,this.pending=null,this.queued=null,null!==t&&null!==n&&e.merge(n).then(t.settle,()=>{t.settle({status:"unavailable"})})}},oi=class{constructor(){vn(this,"negotiation",m(void 0));vn(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=m(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}applyVersion(e,t){let n=this.negotiation;if(n.theirs===e)return;let i=m(e,this.observed);this.negotiation=i,i.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${i.negotiated}`)}},ai=class{constructor(){vn(this,"lastIdentity")}edit(e){let t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;let n=JSON.stringify([t.entitySlug,I(t),t.updatedAt]),i=n!==this.lastIdentity;return this.lastIdentity=n,i&&function(e,t){let n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;let i=I(e),r=I(t.data??{});return void 0!==i&&void 0!==r&&i!==r}(t,e)?t:null}},si=class{constructor(){wn(this,ui)}reveal(e,t,n){return e===bn(this,ui)?"skipped-same":(Sn(this,ui,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:q(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){Sn(this,ui,void 0)}},ui=new WeakMap,di=class{constructor(){vn(this,"seen",new Map)}note(e,t,n){let i=x(n);if(void 0===i)return;let r=`${t.owner??""}\\0${t.locale??""}\\0${t.fieldName}`,l=this.seen.get(r);void 0!==l?l!==i&&(e.revealIdentities.push([r,i]),e.revealTarget??(e.revealTarget=t)):this.seen.set(r,i)}commit(e){for(let[t,n]of e.revealIdentities)this.seen.set(t,n);e.revealIdentities=[];let t=e.revealTarget;return e.revealTarget=void 0,t}},ci=class{constructor(){vn(this,"started",!1);vn(this,"suspended",!1);vn(this,"deferredStart",null);vn(this,"hydration","idle");vn(this,"activeUpdate",null);vn(this,"locale");vn(this,"schema");vn(this,"schemaIndex");vn(this,"updateCount",0);vn(this,"supersededCount",0);vn(this,"completedCount",0);vn(this,"skippedUnchangedCount",0);vn(this,"lastFlush",null);vn(this,"absentFields",new Set);vn(this,"warnedOrphanFields",new Set);vn(this,"warnedStrategy",new WeakSet);vn(this,"warnedUnattributableMessage",!1);vn(this,"warnedVisibilityGate",!1);vn(this,"warnedFragmentFallback",!1);vn(this,"warnedEscalationUnavailable",!1);vn(this,"warnedProtocolShape",!1);vn(this,"reportedUnfaithful",new WeakSet);vn(this,"checkedServerFormat",new WeakSet);vn(this,"unfaithfulPatches",[]);vn(this,"unfaithfulCount",0);vn(this,"escalatedCount",0);vn(this,"unfaithfulFields",new Set);vn(this,"autoBindSearchMs");vn(this,"autoBindGuesses",null);vn(this,"warnedForeignSource",!1);vn(this,"lastAppliedIdentity",new WeakMap);vn(this,"revealLedger",new di);vn(this,"fragmentStats",{rendered:0,failed:0,superseded:0});vn(this,"routeStats",{refreshes:0,failed:0,refused:0,loopStopped:0});vn(this,"fragmentController",null);vn(this,"routeController",null);vn(this,"routeRetry",null);vn(this,"routeRefreshOwed",!1);vn(this,"readyTimers",[]);vn(this,"revealer",new si);vn(this,"changes",new Yn);vn(this,"merges",new li);vn(this,"protocol",new oi);vn(this,"relationships",new ai)}isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){e.completed||(e.completed=!0,this.completedCount+=1)}abortStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(let e of["fragmentController","routeController"]){let t=this[e];null!==t&&(this[e]=null,t.abort())}}},hi=class{constructor(e,t){vn(this,"deps",e);vn(this,"state",t);vn(this,"instanceContext");this.instanceContext=function(e){let t={};for(let[n,i]of Object.entries(e))void 0!==i&&(t[n]=i);return t}({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,reportUnfaithful:(n,i)=>{r(e,t,n,i)}})}apply(e){let{deps:t,state:n}=this,i=n.activeUpdate;if(null===i||void 0===e.revision||!g(i.revision,e.revision)||!n.isCurrent(i))return!1;let{target:l,value:s}=e,u=void 0!==i.schemaIndex?S(i.schemaIndex,l.fieldName):void 0,d=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){let e=function(e){if(Object.prototype.hasOwnProperty.call(Vn,e))return Vn[e]}(t);if(void 0!==e)return e}return e.fieldType}(l,u?.type);"text"===d&&!0!==l.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)}(s)&&(d="richText");let c;try{c=t.resolveRenderer(d,l)}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;let h=t.emitter.listenerCount("elementUpdate")>0,f=h?function(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:"IMG"===e.tagName?e.src:e.textContent}(l.element):void 0;if(!n.isCurrent(i))return!1;let p={allFields:e.allFields,locale:l.locale??i.locale,schema:u,...this.instanceContext};!0===l.hidesWhenEmpty&&l.element.toggleAttribute("hidden",function(e){return null==e||("string"==typeof e?0===e.trim().length:Array.isArray(e)&&0===e.length)}(s));try{if(void 0!==l.targetAttribute){if("blocked"===function(e,t,n){let i=t.toLowerCase().trim();if(0===i.length||!F(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 Qn.has(i)&&!$(r)?"blocked":(e.setAttribute(i,r),"applied")}(l.element,l.targetAttribute,s))return t.warn(`[live-preview] LP0401: refused to write "${l.fieldName}" into attribute "${l.targetAttribute}"`),!1}else{if(void 0===c)return t.log("no renderer for",d),r(t,n,l,`has no renderer for "${d}"`),!1;{let e=function(e,t,n,i){if("ignore"===e.onUnfaithfulPatch||void 0!==n.format||!Pn.has(i)||t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);let r=o(n.element);return r.trim().length>0?r:void 0}(t,n,l,d);if(!1===function(e,t,n,i){return e.render(t,n,i)}(c,l,s,p)&&function(e){return Zn.has(e.render)}(c))return r(t,n,l,`is a value ${c.name} cannot render`),!1;void 0!==e&&function(e,t,n){let i=o(t.element);i!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${a(n)}, the patch wrote ${a(i)} \\u2014 either an edit that arrived before the preview connected, or a template that formats this value differently. Set data-payload-format to match it.`)}(t,l,e)}}}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;h&&t.emitter.emitWhile("elementUpdate",{element:l.element,fieldName:l.fieldName,previousValue:f,nextValue:s,revision:i.revision.revision,receivedAt:i.receivedAt,source:"patch"},()=>n.isCurrent(i));let m=n.isCurrent(i);return m&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(l.element,e.valueIdentity):n.lastAppliedIdentity.delete(l.element)),m}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}},fi="data-payload-island",pi=`astro-island, [${fi}]`,mi="data-payload-field",gi="data-payload-type",vi="data-payload-attribute",yi="data-payload-href",bi="data-payload-src",wi="data-payload-alt",Si="data-payload-array-template",Ti="data-payload-array-separator",ki="data-payload-locale",Ai="data-payload-richtext",Ci="data-payload-html",$i="data-payload-array",Ri="data-payload-structural",Fi="data-payload-owner",Ni="data-payload-depends",xi="data-payload-strategy",Mi="data-payload-boundary",Ei="data-payload-guessed",Oi=[mi,gi,vi,yi,bi,wi,Si,Ti,ki,Ai,Ci,$i,Ri,Fi,Ni,xi,Mi,"type"],Pi=`[${mi}]`,Li=`[${Fi}]`,Ui=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,Ii=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"]),ji=class{constructor(e={}){vn(this,"entriesByField",new Map);vn(this,"entryByElement",new WeakMap);vn(this,"filter");vn(this,"count",0);vn(this,"dependencies",null);vn(this,"islandRoots",[]);this.filter=e.filter??te}dependencyMap(){if(null!==this.dependencies)return this.dependencies;let e=[];for(let t of this.values())void 0!==t.dependsOn&&e.push(J(t.fieldName,t.dependsOn));return this.dependencies=K(...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(Pi))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){let t=[];for(let n of e.querySelectorAll(pi))X(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(mi);if(null===t||0===t.length)return;let n=e.getAttribute(gi),i=e.getAttribute(vi),r=e.getAttribute(yi),l=e.getAttribute(bi),o=e.getAttribute(wi),a=e.getAttribute(Si),s=e.getAttribute(Ti),u=e.getAttribute(ki),d=e.getAttribute("data-payload-format"),c=Z(e),h=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(Ni)),f=e.getAttribute(xi),p=e.getAttribute(Ei),m=M(e);return{element:e,fieldName:t,fieldType:ee(e),explicitFieldType:null!==n&&Y(n),strategyKind:E(e)??"unknown",...null!==m?{fragmentBoundary:m}:{},...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}:{},...null!==d&&d.length>0?{format:d}:{},...void 0!==c?{owner:c}:{},...h.length>0?{dependsOn:h}:{},...null!==f&&f.length>0?{strategy:f}:{},...e.hasAttribute(Mi)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}},_i=class{constructor(e){vn(this,"serverURL");vn(this,"apiRoute");vn(this,"depth");vn(this,"fetchFn");vn(this,"log");vn(this,"inflight",null);vn(this,"attempt",0);vn(this,"destroyDepth",0);this.serverURL=function(e){let t=e.length;for(;e.endsWith("/",t);)t-=1;return e.slice(0,t)}(e.serverURL);let i=e.apiRoute??"/api";this.apiRoute=i.startsWith("/")?i:`/${i}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=t(e.log??n)}canMerge(e){return null!==this.endpointOf(e)}endpointOf(e){try{let t=e.globalSlug;if(t)return ie(t)?`globals/${encodeURIComponent(t)}`:null;let n=e.collectionSlug??"",i=e.data.id;return ie(n)&&function(e){return"number"==typeof e?Number.isFinite(e):"string"==typeof e&&ne(e,512)}(i)?`${encodeURIComponent(n)}/${encodeURIComponent(String(i))}`:null}catch{return null}}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"};let t=this.endpointOf(e);if(null===t)return r()?{status:"superseded"}:{status:"unavailable"};let l=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===l)return{status:"unavailable"};i=new AbortController,this.inflight=i;let o=`${this.serverURL}${this.apiRoute}/${t}`,a=await l(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,locale:e.locale}),signal:i.signal});if(r())return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,o),{status:"unavailable"};let s=await a.json();return r()?{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()?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{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}}},Wi="2.0.6",Bi={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},zi={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},Di={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1},Vi=1,Hi=class{constructor(e,t={}){vn(this,"callbacks");vn(this,"debounceMs");vn(this,"rootMargin");vn(this,"visible",new Set);vn(this,"mutation",null);vn(this,"intersection",null);vn(this,"debounceTimer",null);vn(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:[...Oi]})}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&&Oi.includes(t.attributeName)&&(t.attributeName===mi||t.attributeName===Fi||t.target.nodeType===Vi&&t.target.hasAttribute(mi)))return!0;for(let e of t.addedNodes)if(le(e))return!0;for(let e of t.removedNodes)if(le(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}},Gi="__livePreviewHydration",qi="[data-payload-field]",Ki="__vue_app__",Ji="__livePreviewVueHydration",Xi="app:suspense:resolve",Qi=class{constructor(e){vn(this,"timeoutMs");vn(this,"onTimeout");vn(this,"handle",null);vn(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}},Zi=class{constructor(){vn(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)}},Yi="data-payload-no-bind",er="data-payload-owned",tr=13,nr=new Set(["true","false","yes","no","on","off"]),ir=/^[\\d\\s.,:+/-]+$/u,rr=/^[a-z][a-z0-9_-]*$/u,lr=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,or=new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]),ar="http://www.w3.org/1999/xhtml",sr=new Set(["__proto__","prototype","constructor"]),ur="payload-live-preview",dr=Symbol.for("payload-live-preview.trusted-types"),cr="data-payload-owned",hr=new Set(["open","value","checked","selected"]),fr=new Set,pr="data-payload-",mr=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"]),gr=new Set(["input","button","textarea","select","option","label"]),vr=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),yr=new Set(["id","class","lang","dir","title","role","tabindex"]),br="aria-",wr="data-",Sr="data-payload-",Tr={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"])},kr=new Set(["href","src","cite","poster"]),Ar=1,Cr=8,$r=(Error,new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"])),Rr="strict",Fr=(Object.freeze({allowedTags:mr,removeCompletely:vr,globalAttributes:yr,attributesByTag:Tr,urlAttributes:kr}),Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"})),Nr=/[&<>"\'/`=]/g,xr=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),Mr=/[&<>"\']/g,Er=/\\{\\{([\\s\\S]*?)\\}\\}/g,Or="data-payload-",Pr=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],Lr=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],Ur=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\\b/gi,Ir=64,jr=new Map,_r="data-payload-key",Wr="data-payload-nested-key",Br="data-payload-nested-template",zr=class{constructor(e,t,n){vn(this,"deps",e);vn(this,"state",t);vn(this,"host",n)}planFragments(e){let t=this.deps.strategies.fragment;return void 0===t?null:wt(t,t.plan(this.deps.root,e))}escalateUnfaithful(e,t,n){if(e.routeRefreshed)return;let{fragment:i,route:r}=this.deps.strategies,l=void 0===i?void 0:function(e){let t=[];for(let n of e){let e=n.fragmentBoundary;if(void 0===e)return;t.includes(e)||t.push(e)}return t}(n);void 0===i||void 0===l?void 0!==r?(this.state.escalatedCount+=n.length,this.refreshRoute(e,t,r)):this.warnEscalationUnavailable(n.length):(this.state.escalatedCount+=n.length,e.pendingFragments+=l.length,this.runFragments(e,t,wt(i,l)))}warnEscalationUnavailable(e){let{deps:t,state:n}=this;n.warnedEscalationUnavailable||(n.warnedEscalationUnavailable=!0,t.warn(`[live-preview] LP0808: onUnfaithfulPatch: \'escalate\' has nowhere to go: ${String(e)} field(s) fell short and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, or onUnfaithfulPatch: \'warn\' to keep the patch and say so.`))}hasUnboundChange(e,t){let{deps:n,state:i}=this;if(e.baseline||e.routeRefreshed)return!1;let r=function(e,t,n,i){let r=B(e,n,i),l=[];for(let e of t)!ni.has(e)&&!r(e)&&l.push(e);return l}(n.cache,e.touched,e.locale,t),o=0;for(let e of r)l(i,e)&&(o+=1);let[a]=r;return void 0!==a&&"escalate"===n.onUnfaithfulPatch&&(void 0===n.strategies.route?(this.warnEscalationUnavailable(r.length),!1):(n.log("route","LP0807",`field "${a}" has no binding; refreshing the route`),i.escalatedCount+=o,!0))}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.revision.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=Le(t);let i=e.cloneNode(!1);i.append(n.content),je(e,i,{keyAttributes:[_r]})}(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,r,l,s)=>{e.pendingFragments-=1;let c=`fragment "${n}" fell back to patch: ${s}`;i.log("fragment",l,c),a.emitWhile("error",{error:new Error(c),context:"fragment",code:l},o),a.emitWhile("fragmentRender",{element:t,id:n,key:r,status:"failed",code:l,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,h.rendered>0&&this.host.restoreGuesses(e,t),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;e.routeRefreshed?(r.routeStats.loopStopped+=1,i.log("route","LP0805",`revision ${String(e.revision.revision)} asked for a second refresh`)):(e.routeRefreshed=!0,await this.runRoute(e,t,n))}armRouteRetry(e,t,n,i){let{state:r}=this;null!==r.routeRetry&&clearTimeout(r.routeRetry),r.routeRetry=setTimeout(()=>{r.routeRetry=null,r.isCurrent(e)&&this.runRoute(e,t,n)},i)}async runRoute(e,t,n){let{deps:i,state:r}=this,l=r.routeStats,o=new AbortController;r.routeController=o;let a,s=()=>r.isCurrent(e)&&!o.signal.aborted;try{a=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:o.signal,isCurrent:s,log:(e,t)=>{i.log("route",e,t)},retryAfter:i=>{this.armRouteRetry(e,t,n,i)}})}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.restoreGuesses(e,t),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.revision.revision,receivedAt:e.receivedAt,source:"route"},s);return}"failed"===a?l.failed+=1:"refused"===a&&(l.refused+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){!function(e,t,n){t.warnedFragmentFallback||(t.warnedFragmentFallback=!0,e.warn(`[live-preview] LP0806: "${n.fieldName}" asks for the fragment strategy but no handler is configured; patching instead`))}(this.deps,this.state,e)}warnUnsupportedStrategy(e){!function(e,t,n){t.warnedStrategy.has(n.element)||(t.warnedStrategy.add(n.element),e.warn(`[live-preview] LP0407: "${n.fieldName}" asks for strategy "${String(n.strategy)}"; only patch, fragment and route exist`))}(this.deps,this.state,e)}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=xe(t.fields,l,i,e.locale);void 0!==r&&this.deps.scheduler.schedule({target:l,value:this.host.transform(l,r,t.fields,()=>!0),allFields:t.fields,revision:e.revision,data:t})}}},Dr=new Set,Vr=class{constructor(e,t,n){vn(this,"deps",e);vn(this,"state",t);vn(this,"strategies");this.strategies=new zr(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,i,r)=>St(e,t,n,i,r),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},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=r.relationships.edit(e);null!==l&&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=b(e.fieldSchemaJSON));let o={revision:n,message:e,locale:r.locale,schema:r.schema,schemaIndex:r.schemaIndex,receivedAt:Date.now(),forceRender:null!==l||G(r.activeUpdate),touched:new Set,baseline:!1,invalidated:new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},a=r.activeUpdate;r.abortStrategies(),null!==a&&!a.completed&&(r.supersededCount+=1),r.activeUpdate=o,i.scheduler.acceptRevision(n),r.updateCount+=1,(void 0===e.protocolVersion||(r.protocol.applyVersion(e.protocolVersion,i.log),r.isCurrent(o)))&&(i.connection.markConnected()&&(i.a11y?.announceConnected(),i.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!r.isCurrent(o)||(i.log("connection","disconnected","\\u2192","connected"),!r.isCurrent(o)))||this.processUpdate(o).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 r=this.dataFor(e,i);t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:r,revision:e.revision.revision,receivedAt:e.receivedAt,source:"patch",cancel:()=>{e.cancelled=!0,t.scheduler.cancelRevision(e.revision)}},()=>!e.cancelled&&n.isCurrent(e))||e.cancelled||!n.isCurrent(e))||this.applyFields(e,r,!1)}dataFor(e,t){let{message:n}=e;return{fields:t,...void 0!==e.schema?{schema:e.schema}:{},..."string"==typeof n.globalSlug?{globalSlug:n.globalSlug}:{},..."string"==typeof n.collectionSlug?{collectionSlug:n.collectionSlug}:{},...void 0!==e.locale?{locale:e.locale}:{}}}applyFields(e,t,n){let{deps:i,state:r}=this,l=K(i.dependencies,i.cache.dependencyMap()),o=r.changes.diff(t.fields,l);if(o.baseline&&!n&&"off"!==i.autoBind){let n=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,i,r){let l=performance.now(),o=$e(e.root),a=ye(n,i),s=null===o?[]:Re(e,Ce(o,a),r,"on the first message");t.autoBindGuesses=function(e,t){let n=new Set;for(let{fieldName:e,stamps:i}of t){n.add(e);for(let e of[yi,wi]){let t=i[e];void 0!==t&&n.add(t)}}let i=new Map;for(let[t,r]of e)null!==r&&n.has(r.field)&&i.set(t,r);return{fields:n,values:i}}(a,s),t.autoBindSearchMs=performance.now()-l,s.length}(i,r,t.fields,e.locale,n)}e.baseline=o.baseline,e.invalidated=n?Dr:o.invalidated,e.touched=n?Dr:new Set([...o.changed,...o.invalidated]),this.scheduleAllFields(e,t)}async resolveIncomingFields(e){let{deps:t,state:n}=this,i=e.message.data??{};if(null===t.merger||"admin"===re(n.protocol.observed).populatesRelationships)return i;let r=n.merges.decide(t,e);if(!r.merge)return r.fields;let{message:l}=e,o=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:l.collectionSlug,globalSlug:l.globalSlug,data:i,locale:e.locale});if(!o.leading)return this.applyMerged(e,o.result).catch(e=>{t.log("update failed:",e)}),r.fields;let a=await o.result;return n.isCurrent(e)?"merged"===a.status?(n.merges.recordMerged(a.doc),a.doc):"superseded"===a.status?null:r.fields:null}async applyMerged(e,t){let{state:n}=this,i=await t;"merged"!==i.status||!n.isCurrent(e)||(n.merges.recordMerged(i.doc),this.applyFields(e,this.dataFor(e,i.doc),!0))}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,s=this.strategies.hasUnboundChange(e,l),u=i.routeRefreshOwed;if(void 0!==a&&!e.routeRefreshed&&(s||u||a.plan(n.root,o)||this.strategies.hasRouteBinding(o))){i.routeRefreshOwed=!1,this.strategies.refreshRoute(e,t,a);return}let d=this.strategies.planFragments(o),c=n.skipUnchanged,h=0;for(let[o,a]of n.cache.entries()){if(!r())return;for(let s of a){if(!1!==l&&!U(s.owner,l))continue;if(!0===d?.covers(s)){if(n.revealEditedField){let n=xe(t.fields,s,o,e.locale);i.revealLedger.note(e,s,n)}continue}let a=s.strategyKind??E(s.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(s);continue}"fragment"===a&&null===d&&this.strategies.warnFragmentFallback(s);let u=xe(t.fields,s,o,e.locale);if(void 0===u){i.absentFields.add(o);continue}if(n.revealEditedField&&i.revealLedger.note(e,s,u),!r())return;let f=St(n,s,u,t.fields,r);if(!r())return;let p=c?Me(s,f,t.fields,e.locale):void 0,m=i.lastAppliedIdentity.get(s.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&m===p&&!e.invalidated.has(o)){i.skippedUnchangedCount+=1;continue}let g={target:s,value:f,allFields:t.fields,revision:e.revision,data:t,valueIdentity:p};n.scheduler.schedule(g),h+=1}}(function(e,t,n,i){let{cache:r}=e;if(0===r.fieldCount||!1!==i&&!function(e,t){for(let n of e.values())if(U(n.owner,t))return!0;return!1}(r,i))return;let l=B(r,n,i);for(let[i,r]of Object.entries(t)){if(ni.has(i))continue;if(Oe(r)){Ee(e,l,i,n,r);continue}if(!Pe(r)||l(i))continue;let t=W(i,n);for(let[i,o]of Object.entries(r))!Oe(o)||ni.has(i)||Ee(e,l,`${t}.${i}`,n,o)}})({cache:n.cache,warned:i.warnedOrphanFields,warn:n.warn},t.fields,e.locale,l),null!==d&&d.boundaries.length>0&&(e.pendingFragments=d.boundaries.length,this.strategies.runFragments(e,t,d)),0===h&&0===e.pendingFragments&&(i.complete(e),this.revealPending(e),this.notifyIslands(e,t))}notifyIslands(e,t){0!==e.touched.size&&function(e,t){for(let n of e)n.dispatchEvent(new CustomEvent("payload-live-preview:update",{detail:t,bubbles:!1}));e.length}(this.deps.cache.islands,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale})}restoreGuesses(e,t){let{deps:n,state:i}=this;if("off"!==n.autoBind&&null!==i.autoBindGuesses){let r=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,i,r){let l=t.autoBindGuesses,o=$e(e.root);if(null===l||0===l.fields.size||null===o)return 0;let a=new Map(l.values);for(let[e,t]of ye(n,i)){if(null===t||!l.fields.has(t.field))continue;let n=a.get(e);void 0===n?a.set(e,t):n?.field!==t.field&&a.set(e,null)}Re(e,Ce(o,a),r,"after a server render").length}(n,i,t.fields,e.locale,r)}}ownerKeysForUpdate(e,t){let{deps:n,state:i}=this;if(!n.scopeBindingsByOwner)return!1;let{message:r}=e,l=function(e){if(L(e.globalSlug))return[O(e.globalSlug)];if(!L(e.collectionSlug))return null;let t=P(e.collectionSlug);return L(e.documentId)?[t,P(e.collectionSlug,e.documentId)]:[t]}({globalSlug:"string"==typeof r.globalSlug?r.globalSlug:void 0,collectionSlug:"string"==typeof r.collectionSlug?r.collectionSlug:void 0,documentId:I(t)});return null===l&&!i.warnedUnattributableMessage&&(i.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),l}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{revision:i,data:r}=e;if(void 0===i)return;let l=n.activeUpdate;if(null===l||!n.isCurrent(l)||!g(l.revision,i))return;0===l.pendingFragments&&n.complete(l);let o=()=>n.isCurrent(l)&&g(l.revision,i);if(this.revealPending(l),!o())return;let a=n.unfaithfulPatches;a.length>0&&(n.unfaithfulPatches=[],void 0!==r&&this.strategies.escalateUnfaithful(l,r,a),!o())||void 0!==r&&(e.applied>0&&t.a11y?.announceUpdate(e.applied),o()&&(this.notifyIslands(l,r),o()&&0!==e.applied&&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){let t=this.state.revealLedger.commit(e);if(void 0!==t)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)}},Hr=class{constructor(e,t){vn(this,"apply");vn(this,"debounceMs");vn(this,"maxWaitMs");vn(this,"isVisible");vn(this,"gateThresholdValue");vn(this,"gateDisabled");vn(this,"getCacheSize");vn(this,"onFlush");vn(this,"scheduleFrame");vn(this,"cancelFrame");vn(this,"pending",new Map);vn(this,"replay",new Map);vn(this,"activeFlushes",new Set);vn(this,"debounceTimer",null);vn(this,"debounceToken",0);vn(this,"deadlineTimer",null);vn(this,"frameHandle",null);vn(this,"frameToken",0);vn(this,"windowUntil",0);vn(this,"activeRevision",null);vn(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.revision&&(this.activeRevisionCancelled||null===this.activeRevision||!g(e.revision,this.activeRevision)))return;let t=this.pending.get(e.target.element);t?(t.value=e.value,t.allFields=e.allFields,t.revision=e.revision,t.data=e.data,t.valueIdentity=e.valueIdentity):this.pending.set(e.target.element,{target:e.target,value:e.value,allFields:e.allFields,revision:e.revision,data:e.data,valueIdentity:e.valueIdentity}),this.armDebounce()}acceptRevision(e){null!==this.activeRevision&&g(e,this.activeRevision)||null!==this.activeRevision&&function(e,t){return e.generation!==t.generation?e.generation-t.generation:e.revision-t.revision}(e,this.activeRevision)<0||(this.cancelScheduledWork(),this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1)}cancelRevision(e){null===this.activeRevision||!g(e,this.activeRevision)||(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.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0}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=Date.now(),t=e>=this.windowUntil;if(this.windowUntil=e+this.debounceMs,t){this.requestFrame();return}let n=this.debounceToken+=1,i=this.debounceTimer;if(this.debounceTimer=null,null!==i&&clearTimeout(i),this.debounceToken!==n)return;let r=setTimeout(()=>{this.debounceToken===n&&(this.debounceTimer=null,this.pending.size>0&&this.requestFrame())},this.debounceMs);this.debounceToken===n&&(this.debounceTimer=r),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.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&g(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||!function(e){return Zn.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?.revision?{revision:e.revision}:{},...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)}},Gr=[0,500,1e3,2e3],qr=class{constructor(e){vn(this,"deps");vn(this,"state",new ci);vn(this,"pipeline");vn(this,"writer");vn(this,"rootSentinel",null);vn(this,"observedRoot",null);let{emitter:r,renderers:l}=e,o=void 0===e.log?n:t(e.log),a=void 0===e.warn?An:t(e.warn),s=e.root??(typ','eof document<"u"?document:void 0);if(void 0===s)throw new Error("LivePreviewRuntime: no document; pass options.root");let u=new ji({filter:e=>!function(e){let t=e;for(;null!==t;){if(Q(t))return!0;t=t.parentElement}return!1}(e)}),d=new Hi({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&c.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),c=new Hr(N(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=>d.isVisible(e),getCacheSize:()=>u.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),h=new zn(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],o),r.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})`);r.emit("error",{error:e,context:"token",code:"LP0502"})}("shape"===e||"type"===e)&&!this.state.warnedProtocolShape&&(this.state.warnedProtocolShape=!0,a(`[live-preview] LP0503: ${t} posted a message this runtime does not recognise (${"type"===e?"unknown message type":"unexpected shape"}); it was ignored. A newer Payload or a custom sender: check that the versions match.`)),"source"===e&&!this.state.warnedForeignSource&&(this.state.warnedForeignSource=!0,a(`[live-preview] LP0501: a message from ${t} was ignored because it did not come from the window that framed or opened this page. \\`eventSourcePolicy\\` is \'parent-or-opener\' by default since 2.0, where 1.x accepted any window on a trusted origin. Set \\`eventSourcePolicy: \'any\'\\` if the admin posts from elsewhere.`)),o("LP0501 message rejected:",e,t)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),f=e.dataMerge;this.deps={emitter:r,cache:u,observers:d,scheduler:c,bus:h,connection:new Zi,heartbeat:new Qi({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:l,resolveRenderer:e.resolveRenderer??(e=>l[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,root:s,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??y,onHeartbeatTimeout:e.onHeartbeatTimeout,log:o,warn:a,a11y:v(e),merger:void 0===f?null:new _i({serverURL:f.serverURL,...void 0!==f.apiRoute?{apiRoute:f.apiRoute}:{},...void 0!==f.depth?{depth:f.depth}:{},...void 0!==f.fetchFn?{fetchFn:f.fetchFn}:{},log:o}),mergeWindowMs:e.debounceMs??50,scopeBindingsByOwner:!0===e.scopeBindingsByOwner,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:i(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new hi(this.deps,this.state),this.pipeline=new Vr(this.deps,this.state,()=>{this.rebuildCache()})}start(){let{state:e}=this;if(e.isRunning())return!1;e.started=!0,e.suspended=!1;try{return function(e){"react"===e.hydration?ae():"vue"===e.hydration&&fe();let{root:t}=e;if(!function(e){return 9===e.nodeType}(t)||"loading"!==t.readyState){pe(e);return}let n=()=>{e.isRunning()&&e.later(()=>{pe(e)})};t.addEventListener("DOMContentLoaded",n,{once:!0}),e.defer(()=>{t.removeEventListener("DOMContentLoaded",n)})}(this.startupHost()),!0}catch(e){throw this.rollbackFailedStart(),e}}startupHost(){let{state:e,deps:t}=this;return{root:t.root,hydration:t.hydration,isRunning:()=>e.isRunning(),defer:t=>{e.deferredStart=t},later:t=>{e.deferredStart=null;try{t()}catch(e){this.rollbackFailedStart(),this.reportError(e,"startup","LP0605")}},hydrated:t=>{e.hydration=t},warn:t.warn,startNow:()=>{this.startNow()}}}startNow(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=Tt(t.root)?kt(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 Gr){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&&this.runCleanup(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(),e.merges.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;!Tt(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()||!Tt(e))return!1;let t=kt(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,u=[];for(let[e,t]of n.entries()){a.push(e);for(let n of t)void 0!==n.owner&&s.add(n.owner),void 0!==n.guessed&&u.push({field:e,matched:n.guessed,attribute:n.targetAttribute??("IMG"===n.element.tagName?"src":void 0)})}return{version:Wi,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:re(r.observed).name},revisions:{accepted:t.updateCount,superseded:t.supersededCount,completed:t.completedCount,skippedUnchanged:t.skippedUnchangedCount,active:null===l?void 0:l.revision.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(),guessed:u.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:e.autoBind,searchMs:t.autoBindSearchMs}},route:{handler:void 0!==e.strategies.route,...t.routeStats},fidelity:{mode:e.onUnfaithfulPatch,canEscalate:void 0!==e.strategies.fragment||void 0!==e.strategies.route,unfaithful:t.unfaithfulCount,escalated:t.escalatedCount,fields:[...t.unfaithfulFields].sort()},hydration:{mode:e.hydration??"off",state:t.hydration},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.revision),t.merger?.destroy(),e.merges.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}},Kr=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,Jr=/^https?:\\/\\/[^/?#\\s]+$/i,Xr=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],Qr=class{constructor(e={}){wn(this,Zr);let t=new Set;for(let n of e.additionalOrigins??[]){let e=Ct(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){let t=e.referrer??(typ','eof 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(!(typ','eof process>"u"))return"production"}();if(void 0!==e)return"production"!==e;if(typ','eof window<"u"){let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}());Sn(this,Zr,[t,n,i,void 0!==n,void 0])}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==bn(this,Zr)[4]?e===bn(this,Zr)[4]:!!(bn(this,Zr)[0].has(e)||0===bn(this,Zr)[0].size&&void 0!==bn(this,Zr)[1]&&e===bn(this,Zr)[1]||bn(this,Zr)[2]&&Kr.test(e)))}lockOrigin(e){return!!this.matches(e)&&(bn(this,Zr)[4]=e,!0)}unlockOrigin(){let e=bn(this,Zr)[4];return bn(this,Zr)[4]=void 0,e}get lockedOrigin(){return bn(this,Zr)[4]}enumerate(){if(void 0!==bn(this,Zr)[4])return[bn(this,Zr)[4]];let e=new Set(bn(this,Zr)[0]);if(0===bn(this,Zr)[0].size&&void 0!==bn(this,Zr)[1]&&e.add(bn(this,Zr)[1]),bn(this,Zr)[2])for(let t of Xr)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return bn(this,Zr)[3]}get isProductionUnconfigured(){return!(!At()||bn(this,Zr)[0].size>0||bn(this,Zr)[2]||void 0!==bn(this,Zr)[1])}get isReferrerOnlyTrust(){return!(bn(this,Zr)[0].size>0||bn(this,Zr)[2])&&void 0!==bn(this,Zr)[1]}},Zr=new WeakMap,Yr={1:"left",2:"center",3:"right",4:"justify"},el=new Set(["left","center","right","justify","start","end"]),tl=new Set(["h1","h2","h3","h4","h5","h6"]),nl=\' target="_blank" rel="noopener noreferrer"\',il=(e,t)=>{let n=t.renderChildren(e.children??[]),i=xt(e.fields),r=function(e,t){if("internal"===t?.linkType)return function(e){let t=xt(xt(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||!$(r))return n;let l="string"==typeof e.title?` title="${Xe(e.title)}"`:"";return`<a href="${Qe(r)}"${function(e,t,n){if(!0===t?.newTab||R(n))return nl;let i="string"==typeof e.target?e.target:"";return""===i?"":"_blank"===i?nl:` target="${Xe(i)}"`}(e,i,r)}${l}>${n}</a>`},rl=new Map,ll=".lp-block:empty,.lp-inline-block:empty",ol={text:e=>{let t=Xe("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${Ft(e)}${Nt(e)}>${n}</p>`},heading:(e,t)=>{let n="string"==typeof e.tag?e.tag.toLowerCase():"h2",i=tl.has(n)?n:"h2",r=t.renderChildren(e.children??[]);return`<${i}${Ft(e)}${Nt(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}${Ft(e)}${Nt(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"}"${Nt(e)}>${n}</li>`;let i="number"==typeof e.value?` value="${Xe(String(e.value))}"`:"";return`<li${Ft(e)}${Nt(e)}${i}>${n}</li>`},link:il,autolink:il,quote:(e,t)=>{let n=t.renderChildren(e.children??[]);return`<blockquote${Ft(e)}${Nt(e)}>${n}</blockquote>`},code:e=>{let t=Et("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${Xe(Lt(e))}</code></pre>`},"code-highlight":e=>{let t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${Et(e.highlightType)}"`:""}>${Xe(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\\t",upload:e=>{let t=Mt(e.value);if(void 0===t)return"";let n=t.url;if("string"!=typeof n||!$(n))return"";let i="string"==typeof t.mimeType?t.mimeType:"";return i.startsWith("video/")?function(e,t){return`<video controls${Ut(e)}><source src="${Qe(t)}"${It(e)}></video>`}(t,n):i.startsWith("audio/")?function(e,t){return`<audio controls><source src="${Qe(t)}"${It(e)}></audio>`}(t,n):""===i||i.startsWith("image/")?function(e,t){let n="string"==typeof e.alt?Xe(e.alt):"";return`<img src="${Qe(t)}" alt="${n}"${Ut(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){let n="string"==typeof e.filename?Xe(e.filename):Xe(t);return`<a href="${Qe(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{let t="string"==typeof e.relationTo?e.relationTo:"",n=xt(e.value),i=Xe((n&&Pt(n))??`#${t}`),r=Et(t),l=""===r?\' class="lp-relation"\':` class="lp-relation lp-relation--${r}"`,o=n?.url;return"string"==typeof o&&$(o)?`<a href="${Qe(o)}"${l}>${i}</a>`:`<span${l}>${i}</span>`},block:(e,t)=>_t(e,t,"div","lp-block"),inlineBlock:(e,t)=>_t(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${Ft(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"\':""}${Wt("colspan",e.colSpan)}${Wt("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${i}>`}},al=new Map,sl=!1,ul="data-payload-text",dl=new Set,cl=new Set,hl=new Set(["DIV","SECTION","ARTICLE"]),fl={name:"richText",render:N((e,t,n)=>{let i=e.element;if(it(t)){i.textContent="";return}let r=n.sanitizerPolicy;if(void 0!==n.renderRichText){let l=n.renderRichText(t,{fieldName:e.fieldName,element:i,locale:n.locale});i.innerHTML=Le(He(l,r));return}if(Bt(t)){let l=new Map,o=Ht(i,He(function(e,t={}){if(!Bt(e))return"";let n=function(e){let t={renderChildren:e=>{let n="";for(let i of e)n+=zt(i,t);return n},resolveAlignment:$t,resolveIndent:Rt,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==Ge()?function(e){return He(e,void 0,void 0)}(n):(function(){if(!sl){sl=!0;try{console.warn(\'[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; call setSanitizerDocument() (linkedom/jsdom) for server rendering, see "HTML sanitization" in docs/security.md.\')}catch{}}}(),n)}(t,{sanitize:!1,onUnrenderedBlock:(e,t)=>{l.set(t,e)}}),r));for(let[t,i]of o){let r=l.get(t);void 0!==r&&qt(e,n,r,i)}return}if("string"!=typeof t)return!1;i.innerHTML=Le(He(t,r))})},pl={name:"html",render(e,t,n){if(it(t)){e.element.textContent="";return}let i="string"==typeof t?t:nt(t);e.element.innerHTML=Le(He(i,n.sanitizerPolicy))}},ml=new WeakSet,gl=Jt("url"),vl=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,yl=Jt("email",function(e){let t=e.trim();return vl.test(t)||!t.includes("@")?t:`mailto:${t}`}),bl=["src","srcset","sizes"],wl={name:"image",render:N((e,t,n)=>{let i=e.element;if(it(t)){Yt(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?Fe(n.allFields,e.srcField,n.locale,i):t,l=Mt(r);return{media:l,candidate:void 0===l?r:l.url}}(e,t,n,r),a=Kt(i,e.fieldName,o);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===i.tagName){let t=i;Qt(t,a.url,l);let o=function(e,t,n,i,r){if(void 0!==t&&t.length>0){let e=Fe(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 Yt(i)})},Sl={name:"upload",render:N((e,t)=>{let n=e.element;if(it(t)){en(n);return}let i=Mt(t);if(void 0===i)return!1;let r=Kt(n,e.fieldName,i.url);if("none"===r.kind)return!1;if("unsafe"===r.kind){en(n);return}let l=r.url;if("IMG"===n.tagName){let e=n;Qt(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=Xe(i.filename??l);n.innerHTML=Le(`<a href="${Qe(l)}">${o}</a>`)})},Tl={name:"relationship",render(e,t){let n=e.element;if(it(t))n.removeAttribute("href"),n.textContent="";else{if("A"===n.tagName&&!Array.isArray(t)){let i=Kt(n,e.fieldName,xt(t)?.url);"safe"===i.kind?n.setAttribute("href",i.url):"unsafe"===i.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(tn).join(", "):tn(t)}}},kl={name:"select",render(e,t,n){let i=e.element,r=it(t)?[]:function(e){return Array.isArray(e)?e.map(nt):[nt(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=xt(t);if(void 0!==n&&nt(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)}},Al=new Set(["","false","0","off","no"]),Cl={name:"checkbox",render(e,t){let n=e.element,i=function(e){return"boolean"==typeof e?e:"string"==typeof e?!Al.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}},$l=new Map,Rl=new Map,Fl=new Set(["short","medium","long","full"]),Nl=new Set(["short","medium","long","full"]),xl=/^[A-Za-z]{3}$/u,Ml=/^[0-4]$/u,El=new WeakSet,Ol={name:"date",render(e,t,n){let i=e.element;if(it(t)){"INPUT"===i.tagName?i.value="":(i.removeAttribute("datetime"),i.textContent="");return}let r="number"==typeof t?t:nt(t),l=new Date(r),o=!Number.isNaN(l.getTime()),a=String(r);"INPUT"!==i.tagName?("TIME"===i.tagName&&i.setAttribute("datetime",o?l.toISOString():a),i.textContent=o?function(e,t,n){let i=t.locale??n.locale??s(),r=an("date",t.format,t.element,t.fieldName)??Pl;try{return function(e,t){let n=nn(e,t);return rt(Rl,n)??lt(Rl,n,new Intl.DateTimeFormat(e,t),64)}(i,r).format(e)}catch{return e.toISOString()}}(l,e,n):a):i.value=o?function(e,t){let n=`${String(t.getFullYear()).padStart(4,"0")}-${sn(t.getMonth()+1)}-${sn(t.getDate())}`,i=`${sn(t.getHours())}:${sn(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${i}`:"time"===e?i:t.toISOString()}(i.type,l):a}},Pl={dateStyle:"medium",timeStyle:"short"},Ll={name:"number",render(e,t,n){let i=e.element;if(it(t)){"INPUT"===i.tagName?i.value="":i.textContent="";return}let r="number"==typeof t?t:Number(nt(t));Number.isNaN(r)?i.textContent=nt(t):"INPUT"!==i.tagName?i.textContent=function(e,t,n){let i=t.locale??n.locale??s(),r=an("number",t.format,t.element,t.fieldName);try{return function(e,t){let n=nn(e,t);return rt($l,n)??lt($l,n,new Intl.NumberFormat(e,t),64)}(i,r).format(e)}catch{return String(e)}}(r,e,n):i.value=String(r)}},Ul={name:"array",render:N((e,t,n)=>{let i=e.element;if(it(t)){i.textContent="";return}if(!Array.isArray(t))return!1;let r=e.arrayTemplate;if(void 0!==r&&r.length>0){let e=function(e,t){let n=Ze(t),i="";for(let r=0;r<t.length;r+=1)i+=Ye(e,t[r],r,nt,n);return i}(r,t),l=n.sanitizerPolicy,o=ot(r),a=et(i);i.innerHTML=Le(He(e,l,o));for(let e of Array.from(i.children))tt(e,a);return}i.textContent=t.map(nt).join(e.arraySeparator??", ")})},Il=new Map;!function(){if(typ','eof window>"u"||!At()&&(typ','eof window>"u"||null==window.opener))return;let e=window.__livePreview,t=JSON.stringify(pn());if(void 0!==e&&(void 0===e.configSignature||e.configSignature===t))return e.refresh(),e;let[n=[],r="",l="/api",o=1,a=!1,s=50,u=!0,d=0,c=!1,h=50,f="200px",p=!0,m=!1,g=!1,v=!0,y="parent-or-opener",b="strict",w,S=!1,T=!1,k,A,C="off",$]=pn(),R=function(e){let t=typeof __LIVE_PREVIEW_FRAGMENT__<"u"?__LIVE_PREVIEW_FRAGMENT__:void 0,n=t??(typeof __LIVE_PREVIEW_ROUTE__<"u"?__LIVE_PREVIEW_ROUTE__:void 0);if(void 0===n)return;let i=n.createRouteStrategy();return void 0===t||void 0===e||""===e?{route:i}:{fragment:t.createFragmentStrategy({endpoint:e}),route:i}}(w),F=new Qr({additionalOrigins:n,enableReferrerDetection:!p,enableLocalhostMatching:!m});F.isProductionUnconfigured?An("[live-preview] LP0101: No trusted origin. Pass allowedOrigins to generateInlineScript() (or to the adapter) \\u2014 the runtime reads no environment variable in the browser."):F.isReferrerOnlyTrust&&An("[live-preview] LP0102: document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let N=new $n,x=function(){let e=[fl,pl,gl,yl,wl,Sl,Tl,kl,{...kl,name:"radio"},Cl,Ol,Ll,Ul,{...Ul,name:"blocks"}];return function(e=[]){let t={};for(let n of e)t[n.name]=n;for(let[e,n]of Il)t[e]=n;return Object.freeze(t)}([Vt("text"),Vt("textarea"),...e,un()])}(),M=new qr({renderers:x,originMatcher:e=>F.matches(e),lockedOrigin:()=>F.lockedOrigin,readyTargets:()=>F.enumerate(),emitter:N,eventSourcePolicy:y,...""!==r?{dataMerge:{serverURL:r,apiRoute:l,depth:o}}:{},debounceMs:s,heartbeatMs:d,intersectionRootMargin:f,disableVisibilityGate:c,visibilityGateThreshold:h,enableA11y:u,scopeBindingsByOwner:g,skipUnchanged:v,revealEditedField:S,onUnfaithfulPatch:i({onUnfaithfulPatch:A,onUnboundChange:k}),autoBind:C,...void 0!==$?{hydration:$}:{},sanitizerPolicy:b,...void 0!==R?{strategies:R}:{},onHeartbeatTimeout:()=>{F.unlockOrigin()},...a?{log:(...e)=>{Cn("[live-preview]",...e)}}:{}});N.on("connect",e=>{F.lockOrigin(e.origin)}),M.start(),e?.destroy();let E=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:()=>M.suspend(),resume:()=>M.start(),refreshCache:()=>{M.refreshCache()}}),O=Object.freeze({version:Wi,configSignature:t,destroy:()=>{E(),M.destroy();let e=window;e.__livePreview===O&&delete e.__livePreview},refresh:()=>{M.refreshCache()},enumerateOrigins:()=>F.enumerate(),inspect:()=>M.inspect()});try{Object.defineProperty(window,"__livePreview",{value:O,writable:!1,configurable:!0})}catch(e){throw E(),M.destroy(),e}}()})();'].join(""),l=/* @__PURE__ */['"use strict";var __LIVE_PREVIEW_FRAGMENT__=(()=>{var P=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Z(t))!ee.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=Q(t,r))||o.enumerable});return e};var re=e=>ne(P({},"__esModule",{value:!0}),e);var De={};te(De,{createFragmentStrategy:()=>J,createRouteStrategy:()=>X});function w(e,t){let n=new AbortController,o=!1,r=()=>{n.abort()};e.addEventListener("abort",r,{once:!0});let i=setTimeout(()=>{o=!0,n.abort()},t);return{signal:n.signal,timedOut:()=>o,dispose:()=>{clearTimeout(i),e.removeEventListener("abort",r)}}}function S(e){return e instanceof Error?e.message:String(e)}var A="data-payload-island",Le=`astro-island, [${A}]`;function oe(e){return e.tagName.toLowerCase()==="astro-island"||e.hasAttribute(A)}function ie(e){return e.getAttribute(A)==="patch"}function ae(e){return oe(e)&&!ie(e)}function _(e){let t=e;for(;t!==null;){if(ae(t))return!0;t=t.parentElement}return!1}function k(e){if(e==null)return[];let t=new Set,n=[];for(let o of e.split(/[\\s,]+/)){let r=o.trim();r.length===0||t.has(r)||(t.add(r),n.push(r))}return n}var b="data-payload-fragment";var N="data-payload-fragment-key",le="data-payload-depends";function I(e){let t=e.getAttribute(b);if(t===null||t.length===0)return null;let n=e.getAttribute(N);return{element:e,id:t,key:n===null||n.length===0?void 0:n,dependsOn:k(e.getAttribute(le))}}function L(e,t){let n=[];for(let o of e.querySelectorAll(`[${b}]`)){let r=I(o);r===null||_(o)||r.dependsOn.length>0&&!r.dependsOn.some(i=>t.has(i))||n.push(r)}return n}var B="x-payload-fragment-version";function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e){if(!D(e))return null;let{html:t,boundary:n,revision:o,metadata:r}=e;return typeof t!="string"||!D(n)||typeof n.id!="string"||n.key!==void 0&&typeof n.key!="string"||typeof o!="number"||!D(r)||typeof r.renderedAt!="string"||typeof r.renderer!="string"?null:e}function U(e){let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t}function H(e){let t=0,n=[],o=()=>{let r=n.shift();r===void 0?t-=1:r()};return async r=>{t<e?t+=1:await new Promise(i=>{n.push(i)});try{return await r()}finally{o()}}}var de=5e3,ue=4,ce=512*1024,T={status:"superseded"};function h(e,t){return{status:"failed",code:e,reason:t}}function fe(e){let t=()=>{throw new TypeError(\'createFragmentStrategy: endpoint must be a same-origin path starting with "/"\')};if((typeof e!="string"||!e.startsWith("/")||e.startsWith("//")||e.includes("\\\\"))&&t(),typeof location<"u"){let n;try{n=new URL(e,location.href)}catch{n=void 0}n?.origin!==location.origin&&t()}return e}function me(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}async function ye(e,t,n){let o=e.body;if(!me(o)){let d=await e.text();return new TextEncoder().encode(d).byteLength>t?null:d}let r=o.getReader(),i=()=>{r.cancel().catch(()=>{})};n.addEventListener("abort",i,{once:!0});let s=new TextDecoder,a="",c=0;try{for(;;){let{done:d,value:p}=await r.read();if(d)break;if(c+=p.byteLength,c>t)return i(),null;a+=s.decode(p,{stream:!0})}}finally{n.removeEventListener("abort",i)}return a+s.decode()}function K(e){let t=fe(e.endpoint),n=e.timeoutMs??de,o=e.maxResponseBytes??ce,r=H(Math.max(1,e.maxConcurrent??ue)),i=new Map;async function s(a,c){let d=()=>a.signal.aborted;if(d())return T;let p=e.location??location,f=U({fragment:c.id,key:c.key,route:p.pathname,search:p.search,revision:a.revision,locale:a.locale,collectionSlug:a.collectionSlug,globalSlug:a.globalSlug,fields:a.fields}),l=w(a.signal,n),y=u=>d()?T:l.timedOut()?h("LP0801",`timeout after ${String(n)} ms`):h("LP0801",S(u));try{let u;try{u=await(e.fetch??fetch)(t,{method:"POST",credentials:"same-origin",headers:{...e.headers,accept:"application/json","content-type":"application/json",[B]:String(1)},body:JSON.stringify(f),signal:l.signal})}catch(M){return y(M)}if(d())return T;if(u.status===401||u.status===403)return h("LP0803",`endpoint refused the preview (${String(u.status)})`);if(!u.ok)return h("LP0801",`endpoint answered ${String(u.status)}`);let g=u.headers.get("content-type")??"";if(!g.toLowerCase().startsWith("application/json"))return h("LP0802",`unexpected content type "${g}"`);if(Number(u.headers.get("content-length")??"0")>o)return h("LP0802","response exceeds the size limit");let E;try{E=await ye(u,o,l.signal)}catch(M){return y(M)}if(d())return T;if(l.timedOut())return h("LP0801",`timeout after ${String(n)} ms`);if(E===null)return h("LP0802","response exceeds the size limit");let x;try{x=JSON.parse(E)}catch{return h("LP0802","response is not JSON")}let R=C(x);return R===null?h("LP0802","response has the wrong shape"):R.boundary.id!==c.id?h("LP0802","response is for another boundary"):R.revision!==a.revision?T:{status:"rendered",html:R.html,metadata:R.metadata}}finally{l.dispose()}}return(a,c)=>{let d=`${c.id} ${c.key??""} ${String(a.revision)}`,p=i.get(d);if(p!==void 0)return p;let f=r(()=>s(a,c));i.set(d,f);let l=()=>{i.get(d)===f&&i.delete(d)};return f.then(l,l),f}}var O="data-payload-owned",pe=new Set(["open","value","checked","selected"]);function q(e,t){for(let n of t.keyAttributes){let o=e.getAttribute(n);if(o!==null&&o.length>0)return`${n}=${o}`}}function F(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(A)||e.hasAttribute(O))return!0;let t=e.getAttribute("contenteditable");return t!==null&&t!=="false"}function ge(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!F(e)&&!F(t)}function v(e,t,n){if(!ge(e,t))return t;let o=Re(e);return he(e,t),n.retainChildrenOf?.(e,t)!==!0&&Ee(e,t,n),Ae(o),e}function he(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||pe.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)}function Ee(e,t,n){let o=be(e,n),r=new Set(o.values()),i=Array.from(e.childNodes).filter(f=>!r.has(f)),s=new Set,a=new Set,c=Array.from(t.childNodes),d=e.firstChild,p=0;for(let f=0;f<c.length;f+=1){let l=c[f],y=null,u=l instanceof Element?q(l,n):void 0;if(u!==void 0&&a.has(u)&&(u=void 0),u!==void 0){a.add(u);let m=o.get(u);if(m!==void 0&&!s.has(m)&&(y=$(m,l,n)===m?m:null,y===null)){m.replaceWith(l),s.add(l),d=l.nextSibling;continue}}else{for(;p<i.length;){let m=i[p];if(p+=1,!s.has(m)){if(G(m,l)){y=$(m,l,n)===m?m:null,y===null&&(e.replaceChild(l,m),s.add(l),d=l.nextSibling);break}if(m instanceof Element){let E=c[f+1];if(!(l instanceof Element)||E!==void 0&&G(m,E)){p-=1;break}e.replaceChild(l,m),s.add(l),d=l.nextSibling;break}if(!(l instanceof Element)){e.replaceChild(l,m),s.add(l),d=l.nextSibling;break}}}if(y===null&&s.has(l))continue}let g=y??l;for(s.add(g);d!==null&&d!==g&&!s.has(d)&&Se(d);)d=d.nextSibling;g!==d&&e.insertBefore(g,d),d=g.nextSibling}for(let f of Array.from(e.childNodes))s.has(f)||f.remove()}function $(e,t,n){return e instanceof Element&&t instanceof Element?F(e)&&F(t)?e:v(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function Se(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function G(e,t){return e.nodeType!==t.nodeType?!1:e instanceof Element&&t instanceof Element?e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI:!0}function be(e,t){let n=new Map,o;for(let r of Array.from(e.children)){let i=q(r,t);if(i!==void 0){if(n.has(i)){o??(o=i.slice(i.indexOf("=")+1));continue}n.set(i,r)}}return o!==void 0&&t.onDuplicateKey?.(e,o),n}function Re(e){let t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement)||!e.contains(t))return null;let n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null;return{element:t,selection:n}}function Ae(e){if(e===null)return;let{element:t,selection:n}=e;if(!(t.ownerDocument.activeElement===t||!t.isConnected))try{t.focus({preventScroll:!0});let[o,r]=n??[null,null];o!==null&&r!==null&&t.setSelectionRange(o,r)}catch{}}var W="data-payload-key";var Te="__livePreviewRouteRefresh";function xe(){return typ','eof window>"u"?void 0:window}function z(){return xe()?.[Te]}var j="data-payload-strategy",Y="data-payload-field",we="data-payload-depends",ke="x-payload-live-preview",Fe=8e3,Oe=1e3;function Me(e){let t=e.getAttribute(j);return t!==null?t==="route":e.closest("head")!==null}function Pe(e){let t=e.getAttribute(Y),n=k(e.getAttribute(we));return t===null||t.length===0?n:[t,...n]}function V(e){if(e.tagName==="META"){let t=e.getAttribute("name")??e.getAttribute("property");return t===null?null:`meta:${t}`}return e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"?"link:canonical":null}function Ne(e,t){t.title!==e.title&&(e.title=t.title);let n=new Map;for(let r of e.head.querySelectorAll("meta, link")){let i=V(r);i!==null&&!n.has(i)&&n.set(i,r)}let o=new Set;for(let r of t.head.querySelectorAll("meta, link")){let i=V(r);if(i===null)continue;o.add(i);let s=n.get(i);if(s===void 0){e.head.append(e.importNode(r,!0));continue}if(!s.hasAttribute(O))for(let a of Array.from(r.attributes))s.getAttribute(a.name)!==a.value&&s.setAttribute(a.name,a.value)}for(let[r,i]of n)!o.has(r)&&!i.hasAttribute(O)&&i.remove()}function X(e={}){let t=e.timeoutMs??Fe,n=e.minIntervalMs??Oe,o=-1/0;return{plan(r,i){for(let s of r.querySelectorAll(`[${Y}], [${j}="route"]`)){if(!Me(s))continue;let a=Pe(s);if(a.length===0||a.some(c=>i.has(c)))return!0}return!1},async refresh(r){let i=Date.now(),s=n-(i-o);if(s>0)return r.retryAfter?.(s),r.log("LP0805",`route refresh for revision ${String(r.revision)} refused: the previous one was ${String(i-o)} ms ago`),"refused";o=i;let a=e.document??document,c=e.location??location,d=e.window??window,p=w(r.signal,t),f=l=>{if(r.signal.aborted)return"superseded";let y=p.timedOut()?`route refresh timed out after ${String(t)} ms`:S(l);return r.log("LP0801",y),"failed"};try{let l=z();if(l!==void 0){try{await l()}catch(u){return f(u)}return r.isCurrent()?"refreshed":"superseded"}let y;try{y=await(e.fetch??fetch)(c.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[ke]:"route"},signal:p.signal})}catch(u){return f(u)}if(r.signal.aborted)return"superseded";if(!y.ok||!(y.headers.get("content-type")??"").includes("text/html"))return r.log("LP0802",`route answered ${String(y.status)} ${y.headers.get("content-type")??""}`),"failed";try{let u=await y.text();if(!r.isCurrent())return"superseded";let g=new DOMParser().parseFromString(u,"text/html"),m=d.scrollX,E=d.scrollY;return Ne(a,g),v(a.body,g.body,{keyAttributes:[W,N,b],retainChildrenOf:x=>x.hasAttribute(b)}),d.scrollTo(m,E),"refreshed"}catch(u){return f(u)}}finally{p.dispose()}}}}function Ie(e){return{plan:(t,n)=>L(t,n).map(o=>o.element),async render(t,n){let o={rendered:0,failed:0,superseded:0},r={revision:t.revision,receivedAt:t.receivedAt,fields:t.fields,locale:t.locale,collectionSlug:t.collectionSlug,globalSlug:t.globalSlug,signal:t.signal};return await Promise.all(n.map(async i=>{let s=I(i);if(s===null)return;let a;try{a=await e(r,s)}catch(c){a={status:"failed",code:"LP0801",reason:S(c)}}if(!t.isCurrent()||a.status==="superseded"){o.superseded+=1,t.log("LP0804",`fragment "${s.id}" for revision ${String(r.revision)} discarded as superseded`);return}if(a.status==="rendered"){t.morph(i,a.html),t.rendered(i,s.id,s.key),o.rendered+=1;return}t.failed(i,s.id,s.key,a.code,a.reason),t.isCurrent()&&t.patch(i),o.failed+=1})),o}}}function J(e){return Ie(K(e))}return re(De);})();'].join(""),a=/* @__PURE__ */['"use strict";var __LIVE_PREVIEW_ROUTE__=(()=>{var S=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var $=(e,n)=>{for(var t in n)S(e,t,{get:n[t],enumerable:!0})},H=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of L(n))!K.call(e,r)&&r!==t&&S(e,r,{get:()=>n[r],enumerable:!(o=U(n,r))||o.enumerable});return e};var z=e=>H(S({},"__esModule",{value:!0}),e);var ae={};$(ae,{createRouteStrategy:()=>B});var A="data-payload-island",se=`astro-island, [${A}]`;var b="data-payload-owned",W=new Set(["open","value","checked","selected"]);function k(e,n){for(let t of n.keyAttributes){let o=e.getAttribute(t);if(o!==null&&o.length>0)return`${t}=${o}`}}function E(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(A)||e.hasAttribute(b))return!0;let n=e.getAttribute("contenteditable");return n!==null&&n!=="false"}function q(e,n){return e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI&&!E(e)&&!E(n)}function R(e,n,t){if(!q(e,n))return n;let o=X(e);return Y(e,n),t.retainChildrenOf?.(e,n)!==!0&&G(e,n,t),J(o),e}function Y(e,n){for(let t of Array.from(e.attributes))n.hasAttribute(t.name)||W.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 G(e,n,t){let o=j(e,t),r=new Set(o.values()),l=Array.from(e.childNodes).filter(m=>!r.has(m)),a=new Set,f=new Set,g=Array.from(n.childNodes),s=e.firstChild,y=0;for(let m=0;m<g.length;m+=1){let i=g[m],u=null,c=i instanceof Element?k(i,t):void 0;if(c!==void 0&&f.has(c)&&(c=void 0),c!==void 0){f.add(c);let d=o.get(c);if(d!==void 0&&!a.has(d)&&(u=x(d,i,t)===d?d:null,u===null)){d.replaceWith(i),a.add(i),s=i.nextSibling;continue}}else{for(;y<l.length;){let d=l[y];if(y+=1,!a.has(d)){if(w(d,i)){u=x(d,i,t)===d?d:null,u===null&&(e.replaceChild(i,d),a.add(i),s=i.nextSibling);break}if(d instanceof Element){let h=g[m+1];if(!(i instanceof Element)||h!==void 0&&w(d,h)){y-=1;break}e.replaceChild(i,d),a.add(i),s=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,d),a.add(i),s=i.nextSibling;break}}}if(u===null&&a.has(i))continue}let p=u??i;for(a.add(p);s!==null&&s!==p&&!a.has(s)&&V(s);)s=s.nextSibling;p!==s&&e.insertBefore(p,s),s=p.nextSibling}for(let m of Array.from(e.childNodes))a.has(m)||m.remove()}function x(e,n,t){return e instanceof Element&&n instanceof Element?E(e)&&E(n)?e:R(e,n,t):(e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue),e)}function V(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function w(e,n){return e.nodeType!==n.nodeType?!1:e instanceof Element&&n instanceof Element?e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI:!0}function j(e,n){let t=new Map,o;for(let r of Array.from(e.children)){let l=k(r,n);if(l!==void 0){if(t.has(l)){o??(o=l.slice(l.indexOf("=")+1));continue}t.set(l,r)}}return o!==void 0&&n.onDuplicateKey?.(e,o),t}function X(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 J(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 I="data-payload-key";function N(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 Q="__livePreviewRouteRefresh";function Z(){return typ','eof window>"u"?void 0:window}function M(){return Z()?.[Q]}var T="data-payload-fragment";function v(e,n){let t=new AbortController,o=!1,r=()=>{t.abort()};e.addEventListener("abort",r,{once:!0});let l=setTimeout(()=>{o=!0,t.abort()},n);return{signal:t.signal,timedOut:()=>o,dispose:()=>{clearTimeout(l),e.removeEventListener("abort",r)}}}function D(e){return e instanceof Error?e.message:String(e)}var P="data-payload-fragment-key";var C="data-payload-strategy",_="data-payload-field",ee="data-payload-depends",ne="x-payload-live-preview",te=8e3,re=1e3;function oe(e){let n=e.getAttribute(C);return n!==null?n==="route":e.closest("head")!==null}function le(e){let n=e.getAttribute(_),t=N(e.getAttribute(ee));return n===null||n.length===0?t:[n,...t]}function O(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 ie(e,n){n.title!==e.title&&(e.title=n.title);let t=new Map;for(let r of e.head.querySelectorAll("meta, link")){let l=O(r);l!==null&&!t.has(l)&&t.set(l,r)}let o=new Set;for(let r of n.head.querySelectorAll("meta, link")){let l=O(r);if(l===null)continue;o.add(l);let a=t.get(l);if(a===void 0){e.head.append(e.importNode(r,!0));continue}if(!a.hasAttribute(b))for(let f of Array.from(r.attributes))a.getAttribute(f.name)!==f.value&&a.setAttribute(f.name,f.value)}for(let[r,l]of t)!o.has(r)&&!l.hasAttribute(b)&&l.remove()}function B(e={}){let n=e.timeoutMs??te,t=e.minIntervalMs??re,o=-1/0;return{plan(r,l){for(let a of r.querySelectorAll(`[${_}], [${C}="route"]`)){if(!oe(a))continue;let f=le(a);if(f.length===0||f.some(g=>l.has(g)))return!0}return!1},async refresh(r){let l=Date.now(),a=t-(l-o);if(a>0)return r.retryAfter?.(a),r.log("LP0805",`route refresh for revision ${String(r.revision)} refused: the previous one was ${String(l-o)} ms ago`),"refused";o=l;let f=e.document??document,g=e.location??location,s=e.window??window,y=v(r.signal,n),m=i=>{if(r.signal.aborted)return"superseded";let u=y.timedOut()?`route refresh timed out after ${String(n)} ms`:D(i);return r.log("LP0801",u),"failed"};try{let i=M();if(i!==void 0){try{await i()}catch(c){return m(c)}return r.isCurrent()?"refreshed":"superseded"}let u;try{u=await(e.fetch??fetch)(g.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[ne]:"route"},signal:y.signal})}catch(c){return m(c)}if(r.signal.aborted)return"superseded";if(!u.ok||!(u.headers.get("content-type")??"").includes("text/html"))return r.log("LP0802",`route answered ${String(u.status)} ${u.headers.get("content-type")??""}`),"failed";try{let c=await u.text();if(!r.isCurrent())return"superseded";let p=new DOMParser().parseFromString(c,"text/html"),d=s.scrollX,h=s.scrollY;return ie(f,p),R(f.body,p.body,{keyAttributes:[I,P,T],retainChildrenOf:F=>F.hasAttribute(T)}),s.scrollTo(d,h),"refreshed"}catch(c){return m(c)}}finally{y.dispose()}}}}return z(ae);})();'].join(""),s=/* @__PURE__ */['"use strict";(()=>{function o(){if(typ','eof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function t(){return typ','eof window>"u"?!1:window.opener!=null}function e(){return o()||t()}function i(){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()&&i();})();'].join(""),u=/* @__PURE__ */['"use strict";(()=>{function f(){if(typ','eof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function m(){return typ','eof window>"u"?!1:window.opener!=null}function d(){return f()||m()}var t="__livePreviewHydration";function l(){if(typ','eof window>"u")return;let n=window;return n[t]??(n[t]={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]})}function u(){let n=l();if(n===void 0||n.armed)return;n.armed=!0;let e=window,o=e.__REACT_DEVTOOLS_GLOBAL_HOOK__??(e.__REACT_DEVTOOLS_GLOBAL_HOOK__=_()),a=o.onCommitFiberRoot;o.onCommitFiberRoot=function(c,i,...s){try{a?.call(this,c,i,...s)}catch{}let r=i?.containerInfo;n.onCommit===void 0?n.commits.push(r):n.onCommit(r)}}function _(){let n=new Map;return{supportsFiber:!0,renderers:n,inject:e=>{let o=n.size+1;return n.set(o,e),o}}}function p(){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)}u();d()&&p();})();'].join(""),d=["allowedOrigins","serverURL","apiRoute","mergeDepth","debug","debounceMs","enableA11y","heartbeatMs","disableVisibilityGate","visibilityGateThreshold","intersectionRootMargin","disableReferrerDetection","disableLocalhostMatching","scopeBindingsByOwner","skipUnchanged","eventSourcePolicy","sanitizerPolicy","fragmentEndpoint","revealEditedField","routeStrategy","onUnboundChange","onUnfaithfulPatch","autoBind","hydration","defaults"];function c(e,t){if(0===e.length)throw new Error(`[live-preview] ${t} is empty. Run \`npm run build:runtime\` before bundling.`)}function generateInlineScript(e={}){const t=function(e){const t=e.runtime;if(void 0===t)return c(o,"runtime.generated.ts"),o;if(c(t.source,`the ${t.profile} runtime`),null!=e.fragmentEndpoint||!0===e.routeStrategy)throw new Error(`[live-preview] the ${t.profile} runtime and the fragment or route strategy exclude each other: it carries no strategy runner, so the prelude would have nothing to talk to. Drop the runtime option, or drop \`fragmentEndpoint\`/\`routeStrategy\`.`);return t.source}(e);return[h(e),...f(e),t].join("\n")}function f(e){return null!=e.fragmentEndpoint?(c(l,"fragment.generated.ts"),[l]):!0===e.routeStrategy?(c(a,"route.generated.ts"),[a]):[]}function h(t){return`var __LIVE_PREVIEW_CONFIG__=${function(t){e(t);const n=function(e){const t=e.defaults??"v2";return"v1"===t?{...i,defaults:t}:{defaults:t}}(t);return`[${d.map(e=>t[e]??n[e]).map(e=>void 0===e?"":JSON.stringify(e)).join(",")}]`.replace(/</g,"\\u003C")}(t)};`}function p(e={},t){const n=function(e){return"react"===e.hydration?(c(u,"loader-react.generated.ts"),u):(c(s,"loader.generated.ts"),s)}(e);if(""===t.runtimeSrc)throw new Error("[live-preview] generateLoaderScript needs a runtimeSrc.");const r=e=>JSON.stringify(e).replace(/</gu,"\\u003C");return[h(e),`var __LP_RUNTIME_SRC__=${r(t.runtimeSrc)};`,`var __LP_RUNTIME_INTEGRITY__=${r(t.integrity??"")};`,...f(e),n].join("\n")}function m(e,t={}){return`<script${void 0!==t.nonce?` nonce="${function(e){if(!/^[A-Za-z0-9+/=_-]+$/.test(e))throw new RangeError("nonce contains characters CSP does not allow");return e}(t.nonce)}"`:""}>${e}<\/script>`}function g(e){let t=0,n=e.length;for(;t<n&&"/"===e[t];)t+=1;for(;n>t&&"/"===e[n-1];)n-=1;const r=e.slice(t,n);return""===r?"":`/${r}`}function v(e={}){const t=e.runtime,n=`runtime.${t?.contentHash??"625953190b17ce09"}.js`;return{fileName:n,urlPath:`${g(e.assetPath??"/payload-live-preview")}/${n}`,integrity:t?.integrity??"sha384-3yPL/Ek3Pb5JmsiVZ7mfAVKXxjDBMjuvz7PD5a85UDKR1p9d11WXtsvjeLbuk10h",source:t?.source??o}}var y="_payload-live-preview";function b(e){const o="v1"===e.defaults?r:t,l="v1"===e.defaults?i:n,a=e=>l[e]!==n[e]?l[e]:void 0;return{strict:e.strict??o.strict,previewSignals:e.previewSignals??o.previewSignals,skipUnchanged:e.skipUnchanged??a("skipUnchanged"),disableReferrerDetection:e.disableReferrerDetection??a("disableReferrerDetection"),disableLocalhostMatching:e.disableLocalhostMatching,eventSourcePolicy:e.eventSourcePolicy??a("eventSourcePolicy"),sanitizerPolicy:e.sanitizerPolicy??a("sanitizerPolicy")}}function w(t,n={}){e(t);const r=b(t);return{...void 0!==t.defaults?{defaults:t.defaults}:{},...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.revealEditedField?{revealEditedField:t.revealEditedField}:{},...void 0!==t.debug?{debug:t.debug}:{},...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.heartbeatMs?{heartbeatMs:t.heartbeatMs}:{},...void 0!==r.skipUnchanged?{skipUnchanged:r.skipUnchanged}:{},...void 0!==t.scopeBindingsByOwner?{scopeBindingsByOwner:t.scopeBindingsByOwner}:{},...void 0!==r.disableReferrerDetection?{disableReferrerDetection:r.disableReferrerDetection}:{},...void 0!==r.disableLocalhostMatching?{disableLocalhostMatching:r.disableLocalhostMatching}:{},...void 0!==r.eventSourcePolicy?{eventSourcePolicy:r.eventSourcePolicy}:{},...void 0!==r.sanitizerPolicy?{sanitizerPolicy:r.sanitizerPolicy}:{},...void 0!==t.runtime?{runtime:t.runtime}:{},...void 0!==t.fragments?{fragmentEndpoint:t.fragments.endpoint}:{},...!0===t.routeStrategy&&void 0===t.fragments?{routeStrategy:!0}:{},...void 0!==t.onUnboundChange?{onUnboundChange:t.onUnboundChange}:{},...void 0!==t.onUnfaithfulPatch?{onUnfaithfulPatch:t.onUnfaithfulPatch}:{},...void 0!==t.autoBind?{autoBind:t.autoBind}:{},...void 0!==n.hydration?{hydration:n.hydration}:{}}}var S="virtual:payload-live-preview/options",A=`\0${S}`;function T(e={}){return{name:"payload-live-preview",hooks:{"astro:config:setup":t=>{"middleware"!==e.mode?!1!==e.autoInject&&("loader"!==e.mode?t.injectScript("head-inline",generateInlineScript(w(e))):function(e,t){if(void 0===e.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 n=function(e="/",t){const n=e.replace(/^\/+|\/+$/gu,""),r=v({assetPath:""===n?`/${y}`:`/${n}/${y}`,...void 0!==t?{runtime:t}:{}});return{fileName:`${y}/${r.fileName}`,urlPath:r.urlPath,integrity:r.integrity,source:r.source}}(e.config?.base??"/",t.runtime);e.injectScript("head-inline",p(w(t),{runtimeSrc:n.urlPath,integrity:n.integrity})),e.updateConfig({vite:{plugins:[{name:"payload-live-preview:loader-asset",generateBundle(){this.emitFile({type:"asset",fileName:n.fileName,source:n.source})},configureServer(e){e.middlewares.use((e,t,r)=>{(e.url??"").split("?")[0]===n.urlPath?(t.statusCode=200,t.setHeader("Content-Type","text/javascript; charset=utf-8"),t.setHeader("Cache-Control","no-cache"),t.end(n.source)):r()})}}]}})}(t,e)):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:r,...i}=t,o=`export default ${JSON.stringify(i).replace(/</g,"\\u003C")};`;e.updateConfig({vite:{plugins:[{name:"payload-live-preview-options",resolveId:e=>e===S?A:void 0,load:e=>e===A?o:void 0}]}}),e.addMiddleware({entrypoint:"payload-live-preview/astro/middleware-entry",order:"pre"})}(t,e)}}}}var k=/[\t\n\f\r ]+/;function C(e,t){const n=e.charCodeAt(t);return 9===n||10===n||12===n||13===n||32===n}function $(e){let t=0,n=e.length;for(;t<n&&C(e,t);)t+=1;for(;n>t&&C(e,n-1);)n-=1;return 0===t&&n===e.length?e:e.slice(t,n)}function R(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function buildFrameAncestors(e={}){const{self:t=!0,origins:n=[],allowNone:r=!1}=e,i=/* @__PURE__ */new Set,o=[];if(r&&!t&&0===n.length)return"'none'";t&&(o.push("'self'"),i.add("'self'"));for(const e of n){const t=e.trim();0===t.length||i.has(t)||(i.add(t),o.push(t))}return o.length>0?o.join(" "):"'none'"}function E(e,t){const n=/* @__PURE__ */new Map;for(const t of e.split(";")){const e=$(t);if(0===e.length)continue;const r=e.search(k),i=R(r<0?e:e.slice(0,r));if(n.has(i))continue;const o=r<0?"":$(e.slice(r));n.set(i,o)}for(const[e,r]of Object.entries(t)){const t=R(e),i="string"==typeof r?{value:r}:r,o=i.mode??"union",l=n.get(t);if("replace"===o||void 0===l||0===l.length){n.set(t,i.value);continue}const a=/* @__PURE__ */new Set,s=[];for(const e of[...l.split(k),...i.value.split(k)])0===e.length||a.has(e)||(a.add(e),s.push(e));const u=s.filter(e=>"'none'"!==e);n.set(t,(u.length>0?u:s).join(" "))}const r=[];for(const[e,t]of n)r.push(0===t.length?e:`${e} ${t}`);return r.join("; ")}var x=/<head(\s[^>]*)?>/i,N=/text\/html/i,P=/<meta\s+(?:[^>]*\s)?(?:charset\s*=|http-equiv\s*=\s*["']?content-type)[^>]*>/i;function M(e,t={}){const n=w(e,t);if("asset"!==e.delivery)return generateInlineScript(n);const r=v(e);return p(n,{runtimeSrc:r.urlPath,integrity:r.integrity})}var O=["preview","draft","livePreview"];function F(e,t={}){const n=new Set(t.signals??["query","fetch-dest","referer"]),r=t.queryParams??O;if(n.has("query")){let t;try{t=new URL(e.url)}catch{t=void 0}if(void 0!==t)for(const e of r){const n=t.searchParams.getAll(e).at(-1);if("true"===n||"1"===n)return!0}}if(n.has("fetch-dest")&&"iframe"===e.headers.get("sec-fetch-dest"))return!0;const i=t.allowedOrigins??t.adminOrigins??[],o=n.has("referer")?i:[];if(o.length>0){const t=e.headers.get("referer");if(null!==t)try{const e=new URL(t).origin;for(const t of o)try{if(new URL(t).origin===e)return!0}catch{}}catch{}}return!1}function L(){try{const e=globalThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}function U(e,t){if(!L())return;const n=globalThis,r=n.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!r.has(e)){r.add(e);try{console.warn(`[payload-live-preview] ${t}`)}catch{}}}var _=class extends Error{name="PreviewConfigurationError"};function I(e){return{authorized:!1,outcome:e,context:null}}var j="payload-live-preview.authorized-preview-context",z=Symbol.for(j);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[z]&&Object.isFrozen(e)}function D(e){return Object.freeze({...e,scope:Object.freeze({...e.scope}),payloadHeaders:Object.freeze({...e.payloadHeaders}),[z]:!0,[j]:!0})}async function W(e){let t;try{t=await e()}catch(e){if(function(e){return e instanceof _||e instanceof Error&&"PreviewConfigurationError"===e.name}(e))throw e;return I("unavailable")}return function(e){return isAuthorizedPreviewContext(e)?{authorized:!0,outcome:"authorized",context:e}:"object"==typeof e&&null!==e&&"authorized"in e?e.authorized&&isAuthorizedPreviewContext(e.context)?{authorized:!0,outcome:"authorized",context:e.context}:I(e.authorized?"invalid":e.outcome):I("invalid")}(t)}var B=" New in 2.0; `defaults: 'v1'` keeps the 1.x table while you migrate (docs/migration.md).";var V=Object.freeze({isPreview:!1,authorization:null,outcome:void 0,inject:!1,cspMode:!1,exposeNonce:!1});function H(t,n={}){const r=b(t);e(t);const i="function"==typeof t.authorizePreview;r.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)."+B);const t=e.allowedOrigins??[];if(0===t.length)throw new Error("payload-live-preview: strict mode requires explicit, non-empty `allowedOrigins`."+B);if(!L())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}".`+B)}if(!0===b(e).previewSignals?.includes("referer"))throw new Error("payload-live-preview: strict mode disables referrer trust; remove 'referer' from `previewSignals` (the 'v1' profile includes it).")}(t):i||U("intent-only-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.");const o=!1!==(l=t.manageCsp)&&("full"===l?"full":"frame-ancestors");var l;const a=t.autoInject??!0;let s;return{authorizes:i,async decide(e,n={}){if(i&&void 0===n.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 r=function(e,t){const n=b(t).previewSignals;return"always"===(t.inject??"preview-only")||F(e,{...void 0!==t.previewQueryParams?{queryParams:t.previewQueryParams}:{},...void 0!==n?{signals:n}:{},allowedOrigins:t.allowedOrigins??[]})}(e,t);if(!r)return V;let l,s=null;if(void 0!==n.authorize){const e=await W(n.authorize);if(l=e.outcome,!e.authorized)return{isPreview:r,authorization:null,outcome:l,inject:!1,cspMode:!1,exposeNonce:!1};s=e.context}return{isPreview:r,authorization:s,outcome:l,inject:a&&(n.shouldInject?.()??!0),cspMode:o,exposeNonce:!0}},scriptTag:e=>m((s??=M(t,n),s),{nonce:e}),csp:(e,n,r)=>function(e,t,n,r){const i={"frame-ancestors":buildFrameAncestors({self:!0,origins:[...e.allowedOrigins??[],...e.frameAncestorsExtra??[]]})};return"full"===r&&(i["script-src"]=function buildScriptSrcWithNonce(e,t={}){if(0===e.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");const{self:n=!0,extra:r=[],strictDynamic:i=!1}=t,o=[];n&&o.push("'self'"),o.push(`'nonce-${e}'`),i&&o.push("'strict-dynamic'");for(const e of r){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?E("",t):n.map(e=>E(e,t)).join(", ")}(n,i)}(t,n,e,r),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 q="livePreviewNonce",G="livePreviewAuthorization",Z="livePreviewAuthorizationOutcome";function K(e={}){const t=H(e);return async(n,r)=>{const i=t.nonce();if(!0===n.isPrerendered)return function(e,t){e.livePreviewNonce=t}(n.locals,i),r();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.livePreviewNonce=n),null!==t.authorization&&(e.livePreviewAuthorization=t.authorization),void 0!==t.outcome&&(e.livePreviewAuthorizationOutcome=t.outcome)}(n.locals,o,i);const l=await r();return o.isPreview?async function(e,t,n,r){return n.inject||!1!==n.cspMode?function(e,t,n,r){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=>{!function(e,t,n,r){const i=n.cspMode;if(!1!==i){const n=e.get("content-security-policy")??"";e.set("content-security-policy",t.csp(n,r,i))}!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(),r=n.split(",").map(e=>e.trim().toLowerCase());r.includes("*")||r.includes("cookie")||e.set("vary",0===n.length?"Cookie":`${n}, Cookie`)}(e)}(e,t,n,r)})}(n.inject?await async function(e,t){if(null===e.body)return e;if(!N.test(e.headers.get("content-type")??""))return e;const n=function(e,t){const n=x.exec(e);if(null===n)return;const r=n.index+n[0].length,i=e.indexOf("</head",r),o=P.exec(e.slice(r,-1===i?void 0:i)),l=null===o?r:r+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 r=new Headers(e.headers);return r.delete("content-length"),r.delete("content-encoding"),r.delete("etag"),new Response(n,{status:e.status,statusText:e.statusText,headers:r})}(e,t.scriptTag(r)):e,t,n,r):e}(l,t,o,i):l}}function J(e={}){return function(e,t={}){return m(M(e,t),void 0!==e.nonce?{nonce:e.nonce}:{})}(e)}var X,Q=F,Y="users",ee=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,te=/^[A-Za-z0-9._~-]+$/;function ne(){return X??=new TextEncoder,X}function re(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 ie(e,t){switch(t.type){case"payload-session":return async function(e,t){const n=function(e){const t=e??"payload-token";if(!ee.test(t))throw new _(`payload-live-preview: cookie name "${t}" is not a valid cookie-name token`);return t}(t.cookieName),r=function(e){let t;try{t=new URL(e)}catch{throw new _(`payload-live-preview: serverURL "${e}" is not an absolute URL`)}if("https:"!==t.protocol&&"http:"!==t.protocol)throw new _(`payload-live-preview: serverURL must be http(s), got "${t.protocol}"`);return t.origin}(t.serverURL),i=function(e,t,n=4096){if(null===e||0===e.length)return null;const r=`${t}=`,i=[];for(const t of e.split(";")){const e=t.trim();e.startsWith(r)&&i.push(e.slice(r.length))}if(1!==i.length)return null;const o=i[0]??"";return 0===o.length||o.length>n||!te.test(o)?null:o}(e.headers.get("cookie"),n,t.maxCookieLength??4096);if(null===i)return I("missing-credential");const o=t.now??Date.now,l=Math.max(250,t.timeoutMs??3e3),a=t.fetch??globalThis.fetch,s=encodeURIComponent(t.usersSlug??Y),u=`${n}=${i}`;let d;try{const e=await a(`${r}/api/${s}/me?depth=0`,{headers:{cookie:u,accept:"application/json"},signal:AbortSignal.timeout(l)});if(!e.ok)return I(401===e.status?"invalid":"unavailable");d=await e.json()}catch{return I("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 r=e.collection??n.collection;if(void 0!==r&&r!==t)return null;const i=n.id;return"string"==typeof i&&i.length>0?i:"number"==typeof i&&Number.isFinite(i)?String(i):null}(d,t.usersSlug??Y);if(null===c)return I("invalid");const f=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!==f&&f<=o()?I("expired"):{authorized:!0,outcome:"authorized",context:D({strategy:"payload-session",subject:c,authorizedAt:o(),expiresAt:f,scope:{},payloadHeaders:{cookie:u}})}}(e,t);case"signed-token":return async function(e,t){const n=function(e){const t="string"==typeof e?ne().encode(e):e;if(t.byteLength<32)throw new _(`payload-live-preview: the preview token secret must be at least ${String(32)} bytes`);return t}(t.secret),r=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===r)return I("unavailable");const i=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 r=n.searchParams.getAll(t?.param??"previewToken");return 1===r.length?r[0]??null:null}(e,t.transport);if(null===i||0===i.length)return I("missing-credential");if(i.length>4096)return I("invalid");const o=i.split(".");if(3!==o.length||"v1"!==o[0])return I("invalid");const l=o[1]??"",a=re(l),s=re(o[2]??"");if(void 0===a||32!==s?.byteLength)return I("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"])}(r,n);u=await r.subtle.verify("HMAC",e,s,ne().encode(`v1.${l}`))}catch{return I("unavailable")}if(!u)return I("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,r=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&&r("pth")&&r("loc")&&r("sub")?n:void 0}(a);if(void 0===d)return I("invalid");const c=(t.now??Date.now)();if(d.exp<=c||d.iat>d.exp)return I("expired");if(d.aud!==t.audience)return I("wrong-audience");if(d.pur!==(t.purpose??"live-preview"))return I("wrong-purpose");if(void 0!==d.pth){let t;try{t=new URL(e.url).pathname}catch{return I("invalid")}if(d.pth!==t)return I("wrong-path")}if(void 0!==d.loc){const n=t.locale?.(e);if(n!==d.loc)return I("wrong-locale")}if(void 0!==t.replay){let e;try{e=await async function(e,t,n){return"consume"in e?!0===await e.consume(t,n):!await e.isUsed(t)&&(await e.markUsed(t,n),!0)}(t.replay,d.jti,d.exp)}catch{return I("unavailable")}if(!e)return I("replayed")}return{authorized:!0,outcome:"authorized",context:D({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 I("unavailable")}if(null===n)return I("invalid");const r=(t.now??Date.now)();return void 0!==n.expiresAt&&n.expiresAt<=r?I("expired"):{authorized:!0,outcome:"authorized",context:D({strategy:"verifier",subject:n.subject,authorizedAt:r,expiresAt:n.expiresAt,scope:n.scope??{},payloadHeaders:n.payloadHeaders??{}})}}(e,t)}}var oe="x-payload-fragment-version";function le(e,t){if(t>64||"object"!=typeof e||null===e)return t;let n=t;for(const r of Object.values(e))if(n=Math.max(n,le(r,t+1)),n>64)break;return n}function ae(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function se(e){if(!ae(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 r=e.route;if("string"!=typeof r||!r.startsWith("/")||r.length>2048)return null;const i=e.search;if("string"!=typeof i||i.length>4096||""!==i&&!i.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!ae(d)||le(d,0)>64?null:{fragment:t,..."string"==typeof n?{key:n}:{},route:r,search:i,revision:o,...void 0!==a?{locale:a}:{},...void 0!==s?{collectionSlug:s}:{},...void 0!==u?{globalSlug:u}:{},fields:d}}var ue={"cache-control":"private, no-store","x-content-type-options":"nosniff",vary:"Cookie",[oe]:String(1)};function de(e,t){return new Response(JSON.stringify({error:t}),{status:e,headers:{...ue,"content-type":"application/json; charset=utf-8"}})}var ce=/* @__PURE__ */Symbol("body over the limit");function fe(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>{r(new Error("fragment render timed out"))},t);e.then(e=>{clearTimeout(i),n(e)},e=>{clearTimeout(i),r(e instanceof Error?e:new Error(String(e)))})})}var he=function(){let e;return()=>{if(void 0===e){const t=(async()=>{const e="astro/container";try{const t=await(import(e));return await t.experimental_AstroContainer.create()}catch(e){throw function(e,t){const n=e.map(e=>`\`${e}\``).join(" and "),r=1===e.length;return new Error(`payload-live-preview: this fragment endpoint renders with ${n}, ${r?"an optional peer":"optional peers"} this package does not install. ${r?"Install it":"Install them"}, or pass your own \`render\`.`,{cause:t})}(["astro"],e)}})();e=t,t.catch(()=>{e===t&&(e=void 0)})}return e}}(),pe=async(e,t)=>(await he()).renderToString(e,{props:t});function me(e){const t=function(e,t){const n=function(e){const{authorize:t,authorizePreview:n}=e;if(void 0!==n&&void 0!==t)throw new Error("payload-live-preview: createFragmentEndpoint() takes `authorizePreview` or `authorize`, not both — pass the middleware hook as `authorizePreview`, or a strategy as `authorize`.");if(void 0!==n)return e=>W(()=>n(e));if(void 0!==t)return e=>ie(e,t);throw new Error("payload-live-preview: createFragmentEndpoint() needs `authorizePreview` (the middleware hook) or `authorize` (a strategy); without one it would render drafts for anyone.")}(e),r=e.render??t.render,i=void 0===e.render?t.rendererName:"custom",o=new Set(e.allowedOrigins??[]),l=e.limits?.bodyBytes??65536,a=e.limits?.timeoutMs??5e3,s=e.registry;return async e=>{if("POST"!==e.method)return de(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 r=e.headers.get("origin");return null===r||r===new URL(e.url).origin||t.has(r)}(e,o))return de(403,"origin");if(!(e.headers.get("content-type")??"").toLowerCase().startsWith("application/json"))return de(415,"content-type");const t=await async function(e,t){if(Number(e.headers.get("content-length")??"0")>t)return ce;const n=await e.text();if(n.length>t)return ce;try{return JSON.parse(n)}catch{return null}}(e,l);if(t===ce)return de(413,"body");const u=se(t);if(null===u)return de(400,"shape");const d=new URL(e.url).origin,c=new Request(`${d}${u.route}${u.search}`,{headers:e.headers}),f=await n(c);if(!f.authorized||!function(e,t){const n=e.scope;return void 0===n.locale||void 0===t.locale||n.locale===t.locale}(f.context,u))return de(403,"unauthorized");const h=Object.prototype.hasOwnProperty.call(s,u.fragment)?s[u.fragment]:void 0;if(void 0===h)return de(404,"fragment");const p={id:u.fragment,key:u.key,revision:u.revision,fields:u.fields,locale:u.locale,collectionSlug:u.collectionSlug,globalSlug:u.globalSlug,route:u.route,authorization:f.context,request:e},m=Date.now();let g;try{const e=await fe(Promise.resolve(h.props(p)),a);g=await fe(r(h.component,e,p),a)}catch(e){return U(`fragment-render:${u.fragment}`,`fragment "${u.fragment}" did not render: ${e instanceof Error?e.message:String(e)}`),de(500,"render")}const v={html:g,boundary:{id:u.fragment,...void 0!==u.key?{key:u.key}:{}},revision:u.revision,metadata:{renderedAt:/* @__PURE__ */(new Date).toISOString(),renderer:i,durationMs:Date.now()-m}};return new Response(JSON.stringify(v),{status:200,headers:{...ue,"content-type":"application/json; charset=utf-8"}})}}(e,{render:pe,rendererName:"astro-container"});return({request:e})=>t(e)}export{G as AUTHORIZATION_LOCALS_KEY,Z as AUTHORIZATION_OUTCOME_LOCALS_KEY,q as NONCE_LOCALS_KEY,me as createFragmentEndpoint,K as createLivePreviewMiddleware,F as hasPreviewIntent,Q as isPreviewRequest,T as livePreview,J as renderLivePreviewScript};
1
+ function e(){try{const e=globalThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}function t(t,n){if(!e())return;const r=globalThis,i=r.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!i.has(t)){i.add(t);try{console.warn(`[payload-live-preview] ${n}`)}catch{}}}function n(e){"v1"===e.defaults&&t("defaults-v1","`defaults: 'v1'` is removed in 3.0: `pll migrate` writes the 1.x rows it stands for into your options, where they keep working (ADR 0026)."),void 0!==e.onUnboundChange&&t("on-unbound-change","`onUnboundChange` is removed in 3.0: name it `onUnfaithfulPatch`, where 'route' is 'escalate'; `pll migrate` renames it (ADR 0026).")}function r(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).")}var i=Object.freeze({strict:!0,previewSignals:Object.freeze(["query"])}),o=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),a=Object.freeze({strict:!1,previewSignals:Object.freeze(["query","fetch-dest","referer"])}),l=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"}),s=/* @__PURE__ */['(()=>{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(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function r(e,t,n,i){let r=e.onUnfaithfulPatch,l=t.reportedUnfaithful.has(n.element);if((l||"escalate"!==r)&&t.display.shortfall(t.activeUpdate,{kind:"unfaithful",field:n.fieldName}),!l&&(t.reportedUnfaithful.add(n.element),t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName),"ignore"!==r)){if("warn"===r){e.warn(`[live-preview] LP0411: "${n.fieldName}" ${i}`);return}e.log("LP0411",n.fieldName,i),t.unfaithfulPatches.push(n)}}function l(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}function a(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function s(e){let t=e.trim();return JSON.stringify(t.length>yi?`${t.slice(0,yi)}\\u2026`:t)}function o(){return function(){if(typ','eof 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 u(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}function d(e){if(++e.nodes>1e4)throw new Error("invalid or oversized field schema")}function c(e,t,n){if(d(t),n>64||t.active.has(e))throw new Error("invalid or oversized field schema");t.active.add(e)}function h(e){try{return f(e,{nodes:0,active:new WeakSet},0)}catch{return[]}}function f(e,t,n){if(!Array.isArray(e))return[];c(e,t,n);let i=[];for(let r of e){let e=p(r,t,n);e&&i.push(e)}return t.active.delete(e),i}function p(e,t,n){if(d(t),"object"!=typeof e||null===e)return;let i=e,r=i.name,l=i.type;if("string"!=typeof r||0===r.length||"string"!=typeof l||0===l.length)return;let a=f(i.fields,t,n+1),s=function(e,t,n){if("object"==typeof e&&null!==e&&!Array.isArray(e)){c(e,t,n);let i=[];for(let r in e){if(!Object.hasOwn(e,r))continue;d(t);let l=Reflect.get(e,r);"object"!=typeof l||null===l||["__proto__","constructor","prototype"].includes(r)||i.push({...l,slug:r,fields:f(l.fields,t,n+1)})}return t.active.delete(e),i}if(!Array.isArray(e))return[];c(e,t,n);let i=[];for(let r of e){if(d(t),"object"!=typeof r||null===r)continue;let e=r,l=e.slug;if("string"!=typeof l||0===l.length)continue;let a=f(e.fields,t,n+1);i.push({...e,slug:l,fields:a})}return t.active.delete(e),i}(i.blocks,t,n+1),o={...i,name:r,type:l},u=i.relationTo;if(Array.isArray(u)){let e=[];for(let n of u)d(t),e.push(n);o.relationTo=e}return a.length>0?o.fields=a:delete o.fields,s.length>0?o.blocks=s:delete o.blocks,o}function g(e,t){return void 0===e||t(e)}function m(e,t){return null==e||t(e)}function v(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}function y(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 Ti)(i>=ki[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 b(e,t){return e.generation===t.generation&&e.revision===t.revision}function w(e){return function(e){if(!1===e.enableA11y)return null;let t=e.root,n=void 0===t?void 0:function(e){return 9===e.nodeType}(t)?t:t.ownerDocument;return new Si(e.a11yLocale,n)}(e)}function S(e){if(typ','eof window>"u")return;let t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),Ci.sendReady(t,e)}function A(e,t,n,i){for(let r of e){if(Ri.has(r.type)){let e=r.fields;e&&A(e,i&&"tabs"===r.type?""===t?r.name:`${t}.${r.name}`:t,n,i);continue}let e=""===t?r.name:`${t}.${r.name}`;if(n.set(e,r),"group"===r.type)r.fields&&A(r.fields,e,n,i);else if("array"===r.type&&r.fields)A(r.fields,`${e}.*`,n,i);else if("blocks"===r.type&&r.blocks)for(let t of r.blocks)A(t.fields,`${e}.*.${t.slug}`,n,i)}}function k(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}function T(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function C(e){if("object"!=typeof e||null===e)return;let t=e.blockType;return"string"==typeof t?t:void 0}function R(e,t){return t.every(e=>void 0!==T(e))?function(e,t){let n=[],i=new Map;for(let t=0;t<e.length;t+=1){let n=T(e[t]);void 0!==n&&i.set(n,t)}let r=new Set;for(let l=0;l<t.length;l+=1){let a=t[l],s=T(a);if(void 0===s){n.push({kind:"insert",index:l,value:a});continue}let o=i.get(s);if(void 0===o){n.push({kind:"insert",index:l,value:a});continue}r.add(o);let u=e[o];C(u)===C(a)?(o!==l&&n.push({kind:"move",from:o,to:l,value:a}),$(u,a)||n.push({kind:"update",index:l,value:a})):n.push({kind:"replace",index:l,oldValue:u,value:a})}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)$(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 $(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)return!1;let t=e.trim().replace(Ei,"");if(0===t.length)return!1;if(t.startsWith("#")||t.startsWith("?")||Mi.test(t)||t.startsWith("/"))return!0;try{let e=new URL(t);return Fi.has(e.protocol)}catch{return Ni.test(t)&&!function(e){let t=Li.exec(e.replace(Oi,""))?.[1];return void 0!==t&&!Fi.has(`${t.toLowerCase()}:`)}(t)}}function N(e){let t=e.trim().replace(Ei,"");return/^https?:\\/\\//i.test(t)||Mi.test(t)}function M(e){return!e.startsWith("on")&&!xi.has(e)}function E(e){return Ui.add(e),e}function O(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 L(){return!0}function x(e){return e.closest(`[${ji}]`)}function P(e){let t=e.getAttribute(Bi);return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==x(e)?"fragment":null!==e.closest("head")?"route":"patch"}function U(e){return`global:${e}`}function I(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function j(e){return"string"==typeof e&&e.length>0}function W(e,t){return null!==t&&void 0!==e&&t.includes(e)}function B(e){let t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function D(e){return"object"==typeof e&&null!==e}function _(e){return Array.isArray(e)?"array":D(e)?"object":"scalar"}function z(e,t){return D(e)?e[t]:void 0}function V(e,t,n,i){let r=[],l=0,a=(e,t,n,s)=>{if(l+=1,i.covers(e))return;let o=O(n);if(void 0!==o&&o===O(t))return;if(!((void 0===t||_(t)===_(n))&&D(n)&&i.reachesBelow(e)&&s<Di)){r.push({path:e,value:n});return}let u=function(e,t){let n=new Set(Object.keys(t));if(D(e))for(let t of Object.keys(e))n.add(t);return[...n]}(t,n);0===u.length&&r.push({path:e,value:n});for(let i of u){if(l>=_i){r.push({path:e,value:n});return}a(`${e}.${i}`,z(t,i),z(n,i),s+1)}};return a(e,t,n,0),r}function q(e,t,n={}){let i=e=>!1===t||W(e,t),r=[];for(let[t,n]of e.entries())n.some(e=>i(e.owner))&&r.push(t);let l=e.rendered.filter(e=>void 0!==n[e.strategy]);return function(e,t){let n=new Set(e),i=[...t],r=(e,t)=>{let n=`${t}.`;for(let t of e)if(t.startsWith(n))return!0;return!1};return{covers:e=>n.has(e)||i.some(t=>t===e||e.startsWith(`${t}.`)),reachesBelow:e=>r(n,e)||r(i,e)}}(r,[...e.covers,...l].filter(e=>i(e.owner)).flatMap(e=>e.paths))}function H(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 G(e,t,n,i=q(e,n)){let r,l=i.covers,a=i.reachesBelow;return i=>{let s=H(i,t);return l(i)||s!==i&&l(s)||(r??(r=function(e,t){let n=new Set;for(let[i,r]of e.entries())for(let e of r)!1!==t&&!W(e.owner,t)||void 0!==e.locale&&n.add(`${i}_${e.locale}`);return n}(e,n)),r.has(i))?"whole":a(i)||s!==i&&a(s)?"below":"none"}}function K(e,t,n,i,r){return X(n)?!X(t)||function(e,t,n){let i=void 0===n?void 0:k(n,e);return void 0!==i&&!Vi.has(i.type)||!0===t.get(e)?.some(J)||function(e,t){let n=`${t}.`;for(let[t,i]of e.entries())if(t.startsWith(n))return!0;return!1}(t,e)}(e,i,r)?"keep":null==t?"ask":"own":"ask"}function J(e){return!Vi.has(e.fieldType)}function X(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function Q(e){return!0===e?.includes(".")}function Z(e,t){let n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;let i=B(e),r=B(t.data??{});return void 0!==i&&void 0!==r&&i!==r}function Y(e){return null!==e&&e.forceRender&&!e.completed}function ee(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function te(e,t){let n=t.element.ownerDocument.defaultView;return null===n?"no-element":e.reveal(`${t.owner??""} ${t.fieldName}`,t.element,n)}function ne(e){let t=e.getAttribute(Wi);return{kind:"fragment",id:e.getAttribute(ji)??"",key:null===t||0===t.length?void 0:t,code:"LP0801"}}function ie(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}function re(...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 le(e,t){let n={};for(let i of t)i!==e&&(n[i]=[e]);return n}function ae(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute(ar)||oe(e)||e.hasAttribute(lr))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function se(e){return"patch"===e.getAttribute(ir)}function oe(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(ir)}(e)&&!se(e)}function ue(e){return"astro-island"===e.tagName.toLowerCase()&&e.hasAttribute("ssr")}function de(e){return"astro-island"===e.tagName.toLowerCase()}function ce(e){let t="";for(let n of e.querySelectorAll("astro-slot, template[data-astro-template]"))n.parentElement?.closest("astro-island")===e&&(t+=`${n.getAttribute("name")??n.getAttribute("data-astro-template")??""}\\0${n.innerHTML}\\0`);return t}function he(e,t){if(!de(e)||!de(t))return!0;let n=ce(t);if(!sr.every(n=>e.getAttribute(n)===t.getAttribute(n))||(or.get(e)??ce(e))!==n||e.getAttribute("props")!==t.getAttribute("props")&&!function(e){let t=e.ownerDocument.defaultView?.customElements.get("astro-island");return void 0!==t&&e instanceof t&&Array.isArray(t.observedAttributes)&&t.observedAttributes.includes("props")}(e))return or.set(t,n),!1;or.set(e,n);let i=t.getAttribute("props");return i!==e.getAttribute("props")&&(e.setAttribute("ssr",""),null===i?e.removeAttribute("props"):e.setAttribute("props",i)),!0}function fe(e){return Array.from(e.querySelectorAll("astro-island"))}function pe(e){let t=e.ownerDocument.defaultView;if(void 0===t?.customElements.get("astro-island"))return"element";let n=e.getAttribute("client"),i=Reflect.get(t,"Astro");return null===n||"object"!=typeof i||null===i||void 0===Reflect.get(i,n)?"directive":void 0}function ge(e){let t=e.closest(Er)?.getAttribute(kr);return null==t||0===t.length?void 0:t}function me(e){return xr.has(e)||Lr.test(e)}function ve(e,t){return e.fieldName===t.fieldName&&e.locale===t.locale&&e.owner===t.owner&&e.strategyKind===t.strategyKind&&e.fragmentBoundary===t.fragmentBoundary}function ye(e){let t=e.getAttribute(cr);if(null!==t&&me(t))return t;if(e.hasAttribute(br))return"richText";if(e.hasAttribute(wr))return"html";if(e.hasAttribute(Ar))return"structural-array";if(e.hasAttribute(Sr))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 be(){return!0}function we(){throw new Error("invalid or oversized legacy population")}function Se(e){for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n<=31||127===n)return!0}return!1}function Ae(e,t){if("string"!=typeof e||0===e.length||e.length>t||"."===e||".."===e||e.includes("/")||e.includes("\\\\")||Se(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function ke(e){return Ae(e,128)&&!/[?#%]/u.test(e)&&!Vr.has(e)}function Te(e){return Number.isFinite(e)?String(e):Ae(e,512)?e:we()}function Ce(e,t){return Object.hasOwn(e,t)?Reflect.get(e,t):void 0}function Re(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0,enumerable:!0})}function $e(e){let t=e.length;for(;t>0&&47===e.charCodeAt(t-1);)t-=1;return e.slice(0,t)}function Fe(e){let t=new WeakSet,n=0,i=0;return function e(r,l){if(++n>Ir||l>Ur)return we();if("string"==typeof r)return i+=r.length,i>Dr&&we(),r;if(null==r||"boolean"==typeof r)return r;if("number"==typeof r)return Number.isFinite(r)?r:we();if(!Array.isArray(r)&&!v(r))return we();if(Array.isArray(r)){r.length>Ir&&we();for(let e=0;e<r.length;e+=1)Object.hasOwn(r,e)||we()}if(t.has(r))return we();t.add(r);let a=Array.isArray(r)?[]:{};for(let t of Object.keys(r))Re(a,t,e(Reflect.get(r,t),l+1));return t.delete(r),a}(e,0)}function Ne(e,t,n,i,r,l){function a(e,t,n,i){if(null==i||""===i)return;let l=v(i)?Ce(i,"id"):i,a=Te(l);if(0===r){Re(e,t,l);return}let s=JSON.stringify([n,a]);c.add(s),c.size>jr&&we();let o=d.get(n)??[];o.push({owner:e,key:t,id:a}),d.set(n,o)}function s(e,t,n){void 0!==n.hasMany&&"boolean"!=typeof n.hasMany&&we();let i=n.relationTo,r=Ce(e,t);if(Array.isArray(i)){0===i.length&&we();let e,t=v(r)?Ce(r,"relationTo"):void 0;for(let n of i)p(0),ke(n)||we(),n===t&&(e=n);if(null==r||""===r)return;(!v(r)||void 0===e)&&we(),a(r,"value",e,Ce(r,"value"))}else ke(i)||we(),a(e,t,i,r)}function o(e,t){if(p(t),Array.isArray(e)||v(e)){if(v(e)&&Object.hasOwn(e,"relationTo")&&Object.hasOwn(e,"value")){let t=Ce(e,"relationTo");ke(t)||we(),a(e,"value",t,Ce(e,"value"));return}for(let n of Object.keys(e))o(Reflect.get(e,n),t+1)}}if(!Number.isSafeInteger(r)||r<0||r>Ur)return we();void 0!==l&&("string"!=typeof l||l.length>128||Se(l))&&we();let u=Fe(e);if(!v(u))return we();let d=new Map,c=new Set,h=0,f=new WeakSet,p=e=>{(++h>Ir||e>Ur)&&we()};(function e(t,n,i){p(i),f.has(t)&&we(),f.add(t);for(let r of t){p(i),(!v(r)||!Ae(r.name,512)||Vr.has(r.name))&&we();let t=Ce(n,r.name);if("relationship"===r.type||"upload"===r.type)if(r.hasMany)if(null!=t&&!Array.isArray(t)&&we(),Array.isArray(t))for(let e=0;e<t.length;e+=1)s(t,e,r);else s(n,r.name,r);else s(n,r.name,r);else if("group"===r.type||"tabs"===r.type)null!=t&&!v(t)&&we(),v(t)&&r.fields&&e(r.fields,t,i+1);else if("row"===r.type||"collapsible"===r.type)r.fields&&e(r.fields,n,i+1);else if("array"===r.type||"blocks"===r.type){if(0===t?Re(n,r.name,[]):null!=t&&!Array.isArray(t)&&we(),Array.isArray(t))for(let n of t)if(v(n)||we(),"array"===r.type&&r.fields)e(r.fields,n,i+1);else if("blocks"===r.type){let t=Ce(n,"blockType"),l=r.blocks?.find(e=>(p(i),e.slug===t));void 0===l&&we(),e(l.fields,n,i+1)}}else"richText"===r.type&&o(t,i+1)}f.delete(t)})(t,u,0),d.size>25&&we();let g=[];if(0===d.size)return{doc:u,requests:g};let m=new URL(n);(!["http:","https:"].includes(m.protocol)||m.username||m.password||m.search||m.hash)&&we(),(!i.startsWith("/")||i.includes("\\\\")||/[%?#]/u.test(i)||Se(i))&&we(),i.split("/").some(e=>"."===e||".."===e)&&we();let y=`${$e(n)}${$e(i)}/`;for(let[e,t]of d){let n=[...new Set(t.map(e=>e.id))],i=0;for(;i<n.length;){let a=n[i];void 0===a&&we();let s=a.includes(","),o=[],u="";for(;i<n.length&&o.length<zr;){let t=n[i];if(void 0===t||o.length>0&&(s||t.includes(",")))break;let a=[...o,t],d=new URLSearchParams({depth:String(r),limit:String(a.length)});void 0!==l&&d.set("locale",l),d.set(s?"where[id][equals]":"where[id][in]",s?t:a.join(","));let c=`${y}${encodeURIComponent(e)}?${d}`;if(c.length>Br){0===o.length&&we();break}new URL(c).origin!==m.origin&&we(),o.push(t),i+=1,u=c}(0===o.length||g.length>=Wr)&&we();let d=new Set(o);g.push({url:u,ids:d,slots:t.filter(e=>d.has(e.id))})}}return{doc:u,requests:g}}async function Me(e,t,n){let i,r,l=!1,a=!1,s=Symbol(),o=new Promise(e=>{r=()=>{e(s)}}),u=()=>{(!n()||t.aborted)&&we()},d=()=>{if(void 0!==i&&!l){l=!0;try{Promise.resolve(i.cancel()).catch(()=>{})}catch{}}},c=()=>{r?.(),d()};t.addEventListener("abort",c,{once:!0});try{u();let t=e.body??null;if(u(),null===t){let t=e.json.bind(e);u();let n=await Promise.race([Promise.resolve().then(()=>(u(),t())),o]);return u(),n===s&&we(),n}let n=t.getReader.bind(t);u();let r=n();i=r,u();let l=[],d=0,c=0;for(;;){let e=Promise.resolve().then(()=>{u();let e=r.read.bind(r);return u(),e()}),t=await Promise.race([e,o]);if(u(),t===s&&we(),t.done)break;d+=t.value.byteLength,(++c>_r||d>Dr)&&we(),l.push(t.value)}a=!0;let h=new Uint8Array(d),f=0;for(let e of l)h.set(e,f),f+=e.byteLength;try{return JSON.parse((new TextDecoder).decode(h))}catch{return we()}}finally{t.removeEventListener("abort",c),a||d();try{i?.releaseLock()}catch{}}}function Ee(e,t){let n=Fe(t);v(n)||we();let i=Ce(n,"docs");(!Array.isArray(i)||i.length>zr)&&we();let r=new Map;for(let t of i){v(t)||we();let n=Te(Ce(t,"id"));(!e.ids.has(n)||r.has(n))&&we(),r.set(n,t)}r.size!==e.ids.size&&we();for(let t of e.slots)Re(t.owner,t.key,r.get(t.id))}function Oe(e,t){return e.length>0&&e.length<=t&&"."!==e&&".."!==e&&!e.includes("/")&&!e.includes("\\\\")&&!function(e){for(let t of e){let e=t.codePointAt(0)??0;if(e<=31||127===e)return!0}return!1}(e)}function Le(e){return Oe(e,128)&&!e.includes("?")&&!e.includes("#")}function xe(e){return"number"==typeof e?Number.isFinite(e):"string"==typeof e&&Oe(e,512)}function Pe(e){return e.has("schema-json")?Gr:e.has("document-events")||e.has("relationship-events")?Kr:Jr}function Ue(e){if("attributes"!==e.type||e.attributeName!==Xr||e.target.nodeType!==Qr)return null;let t=e.target;return"astro-island"!==t.tagName.toLowerCase()||t.hasAttribute(Xr)?null:t}function Ie(e){if(e.nodeType!==Qr)return!1;let t=e;return t.hasAttribute(dr)||t.matches(rr)||t.matches(Or)||null!==t.querySelector(`[${dr}], ${rr}, ${Or}`)}function je(){if(typ','eof window>"u")return;let e=window;return e[ll]??(e[ll]={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]})}function We(){let e=je();if(void 0===e||e.armed)return;e.armed=!0;let t=window,n=t.__REACT_DEVTOOLS_GLOBAL_HOOK__??(t.__REACT_DEVTOOLS_GLOBAL_HOOK__=function(){let e=new Map;return{supportsFiber:!0,renderers:e,inject:t=>{let n=e.size+1;return e.set(n,t),n}}}()),i=n.onCommitFiberRoot;n.onCommitFiberRoot=function(t,n,...r){try{i?.call(this,t,n,...r)}catch{}void 0===e.onCommit?e.commits.push(n):e.onCommit(n)}}function Be(e){e.committed=!0;let t=e.waiters;e.waiters=[];for(let e of t)e()}function De(e,t){let n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function _e(e,t,n){if(e.committed)return null;let i=null,r=()=>{null!==i&&clearTimeout(i),i=null,t("committed")};return e.waiters.push(r),i=setTimeout(()=>{i=null,De(e,r),t("timed-out")},n),()=>{null!==i&&clearTimeout(i),i=null,De(e,r)}}function ze(){if(typ','eof window>"u")return;let e=window;return e[ol]??(e[ol]={armed:!1,committed:!1,waiters:[]})}function Ve(e){return Object.prototype.hasOwnProperty.call(e,sl)?e[sl]:void 0}function qe(){let e=ze();if(void 0===e||e.armed)return;e.armed=!0;let t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,sl)&&Object.defineProperty(t,sl,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,sl,{value:e,writable:!0,configurable:!0,enumerable:!0});let t=ze();void 0===t||t.committed||null===this.querySelector(al)||function(e,t){let n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?Be(e):n.hook(ul,()=>{e.committed||Be(e)})}(t,e)}})}function He(e){let t=e.hydration;if(void 0===t){e.startNow();return}let n=dl[t](e.root,n=>{e.later(()=>{Ge(e,t,n)})});null!==n?(e.defer(n),e.hydrated("waiting")):Ge(e,t,"committed")}function Ge(e,t,n){e.hydrated(n),"timed-out"===n&&e.warn(`[live-preview] LP0607: no ${cl[t]} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}function Ke(e){return 9===e.nodeType}function Je(e){return e.body}function Xe(e,t=gl){if("string"!=typeof e)return!1;let n=e.trim();return!(n.length<t||vl.test(n)||ml.has(n.toLowerCase())||yl.test(n)||bl.test(n))}function Qe(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ze(e,t,n=gl){let i=new Map,r=(e,t,n)=>{i.set(e,i.has(e)?null:{field:t,media:n})};for(let[i,l]of Object.entries(e)){if(zi.has(i))continue;let e=H(i,t);if(Xe(l,n))r(l.trim(),e,!1);else if(Qe(l))if("string"==typeof l.url)r(l.url,e,!0);else if(!("id"in l)&&!("_id"in l))for(let[t,i]of Object.entries(l))zi.has(t)||!Xe(i,n)||r(i.trim(),`${e}.${t}`,!1)}return i}function Ye(e){if(e.namespaceURI!==Sl||wl.has(e.tagName)||e.hasAttribute(dr)||e.hasAttribute(pl)||e.hasAttribute(lr)||oe(e))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function et(e){let t;for(let n=e.firstChild;null!==n;n=n.nextSibling){if(1===n.nodeType)return;if(3!==n.nodeType)continue;let e=n.data.trim();if(0!==e.length){if(void 0!==t)return;t=e}}return t}function tt(e){return M(e)&&!e.startsWith("data-payload-")&&"value"!==e}function nt(e,t,n){let i=e.byElement.get(t);void 0===i&&(i={attributes:new Map},e.byElement.set(t,i));let r=e.byField.get(n.field);return void 0===r&&(r=new Set,e.byField.set(n.field,r)),r.add(t),i}function it(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(Ye(n))continue;let e=et(n),i=void 0===e?void 0:t.values.get(e);null!=i&&!i.media&&(nt(t,n,i).text=i.field);for(let e of n.getAttributeNames()){if(!tt(e))continue;let i=t.values.get(n.getAttribute(e)??"");null!=i&&(i.media&&("IMG"!==n.tagName||"src"!==e)||nt(t,n,i).attributes.set(e,i))}it(n,t)}}function rt(e,t,n){let i=e.tagName;if(void 0!==t){let r={[dr]:t};if("A"===i){let e=n.get("href");void 0===e?r[cr]="text":e!==t&&(r[fr]=e)}return{element:e,fieldName:t,matched:et(e)??"",stamps:r}}if("IMG"===i){let t=n.get("src");if(void 0!==t){let i=n.get("alt");return{element:e,fieldName:t,matched:e.getAttribute("src")??"",attribute:"src",stamps:{[dr]:t,...void 0!==i&&i!==t?{[gr]:i}:{}}}}}let r=n.entries().next();if(r.done)return;let[l,a]=r.value;return{element:e,fieldName:a,matched:e.getAttribute(l)??"",attribute:l,stamps:{[dr]:a,[hr]:l}}}function lt(e,t){let n={values:t,byElement:new Map,byField:new Map};t.size>0&&!Ye(e)&&it(e,n);let i=e=>1===n.byField.get(e)?.size,r=[];for(let[e,t]of n.byElement){let n=void 0!==t.text&&i(t.text)?t.text:void 0,l=new Map;for(let[e,n]of t.attributes)i(n.field)&&l.set(e,n.field);let a=rt(e,n,l);void 0!==a&&r.push(a)}return r}function at(e){return 9===e.nodeType?e.body:e}function st(e,t){for(let n=t.length-1;n>=0;n-=1){let i=t[n];if(void 0!==i){i.observed&&e.observers.unobserveElement(i.element);for(let e=i.attributes.length-1;e>=0;e-=1){let t=i.attributes[e];if(void 0===t)continue;let{name:n,before:r,written:l}=t;r===l||i.element.getAttribute(n)!==l||(null===r?i.element.removeAttribute(n):i.element.setAttribute(n,r))}i.cacheTouched&&(i.element.hasAttribute(dr)?e.cache.add(i.element):e.cache.remove(i.element))}}}function ot(e,t,n,i,r){let l=[],a=[],s=()=>(st(e,a),[]);for(let o of t){if(!r())return s();let{element:t}=o;if(t.hasAttribute(dr))continue;if(!r())return s();if(!1!==n&&!W(ge(t),n))continue;if(!r())return s();let u={element:t,attributes:[],cacheTouched:!1,observed:!1};a.push(u);for(let[e,n]of[...Object.entries(o.stamps),[$r,o.matched]]){let i=t.getAttribute(e);if(!r()||(u.attributes.push({name:e,before:i,written:n}),t.setAttribute(e,n),!r()))return s()}if(u.cacheTouched=!0,void 0!==e.cache.add(t)){if(!r()||(e.observers.observeElement(t),u.observed=!0,!r())||(e.log("autoBind",o.fieldName,"\\u2192",`<${t.tagName.toLowerCase()}>`,o.attribute??"text",JSON.stringify(o.matched),i),!r()))return s();l.push(o)}else st(e,[u]),a.pop()}return l}function ut(e,t,n,i=!1){if(i&&void 0!==n){let i=dt(e,`${t}_${n}`);if(void 0!==i)return i}let r=dt(e,t);if(void 0!==r)return r;if(t.includes(".")){let n=e,i=!0;for(let e of t.split(".")){if(Al.has(e)||null===n||"object"!=typeof n){i=!1;break}if(n=dt(n,e),void 0===n){i=!1;break}}if(i)return n}return void 0===n?void 0:dt(e,`${t}_${n}`)}function dt(e,t){if(!Al.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function ct(e,t,n,i){return ut(e,n,t.locale??i,void 0!==t.locale)}function ht(e,t,n,i){let r=O(t);if(void 0===r)return;let l=[e.hrefField,e.srcField,e.altField],a=r;for(let t of l){if(void 0===t||0===t.length)continue;let r=O(ct(n,e,t,i));if(void 0===r)return;a+=`|${t}=${r}`}return a}function ft(e,t,n,i){if(!e.scopeBindingsByOwner)return!1;let{message:r}=n,l=function(e){if(j(e.globalSlug))return[U(e.globalSlug)];if(!j(e.collectionSlug))return null;let t=I(e.collectionSlug);return j(e.documentId)?[t,I(e.collectionSlug,e.documentId)]:[t]}({globalSlug:"string"==typeof r.globalSlug?r.globalSlug:void 0,collectionSlug:"string"==typeof r.collectionSlug?r.collectionSlug:void 0,documentId:B(i)});return null===l&&!t.warnedUnattributableMessage&&(t.warnedUnattributableMessage=!0,e.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),l}function pt(e,t,n,i,r){!function(e,t,n){let i=0;for(let r of e)if(!n()||(r.dispatchEvent(new CustomEvent(nr,{detail:t,bubbles:!1})),i+=1,!n()))break}(n,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale,displayed:r},i)}function gt(e,t,n,i,r){let{warned:l,warn:a}=e;if(l.has(n)||t(n))return;l.add(n);let s=`data-payload-field="${H(n,i)}"`;a(""!==r?`[live-preview] LP0203: field "${n}" has a value and no <\\u2026 ${s}> on this page; editing it changes nothing here. Expected where the page shows part of the document: inspect().fidelity.fields lists these, onUnfaithfulPatch decides whether a server render is asked for.`:`[live-preview] LP0201: no <\\u2026 ${s}> for the empty field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)}function mt(e){let t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function vt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function yt(e){let t=function(){let e=function(){let e=globalThis,t=e[Cl];if(void 0!==t)return t;let n={};return e[Cl]=n,n}();if(void 0!==e.override)return e.override;if(void 0!==e.auto)return e.auto;let t=function(){let e=globalThis.trustedTypes;return"object"!=typeof e||null===e?void 0:"function"==typeof e.createPolicy?e:void 0}();try{e.auto=void 0===t?null:t.createPolicy(Tl,{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===t?e:t.createHTML(e)}function bt(e,t){for(let n of t.keyAttributes){let t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function wt(e,t,n){if(!kt(e,t))return t;let i=n.boundary??ae,r=i(e),l=i(t);if(r||l)return r&&l&&(n.retainBoundary?.(e,t)??1)?e:t;let a=Tt(e);return function(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||Rl.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=bt(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)),a=new Set,s=new Set,o=Array.from(t.childNodes),u=e.firstChild,d=0;for(let t=0;t<o.length;t+=1){let r=o[t],c=null,h=r instanceof Element?bt(r,n):void 0;if(void 0!==h&&s.has(h)&&(h=void 0),void 0!==h){s.add(h);let e=i.get(h);if(void 0!==e&&!a.has(e)&&(c=St(e,r,n)===e?e:null,null===c)){e.replaceWith(r),a.add(r),u=r.nextSibling;continue}}else{for(;d<l.length;){let i=l[d];if(d+=1,!a.has(i)){if(kt(i,r)){c=St(i,r,n)===i?i:null,null===c&&(e.replaceChild(r,i),a.add(r),u=r.nextSibling);break}if(i instanceof Element){let n=o[t+1];if(!(r instanceof Element)||void 0!==n&&kt(i,n)){d-=1;break}e.replaceChild(r,i),a.add(r),u=r.nextSibling;break}if(!(r instanceof Element)){e.replaceChild(r,i),a.add(r),u=r.nextSibling;break}}}if(null===c&&a.has(r))continue}let f=c??r;for(a.add(f);null!==u&&u!==f&&!a.has(u)&&At(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(let t of Array.from(e.childNodes))a.has(t)||t.remove()}(e,t,n),Ct(a),e}function St(e,t,n){return e instanceof Element&&t instanceof Element?wt(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function At(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function kt(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function Tt(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}function Ct(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{}}function Rt(e){Fl.has(e)||(Fl.add(e),function(e){try{console.warn(e)}catch{}}(`[live-preview] LP0409: the strict sanitizer removed \\`${e}\\` from written markup; the 1.x default (\\`sanitizerPolicy: \'compat\'\\`) kept it. ${function(e){return e.startsWith(Nl)?"A binding inside CMS content is refused by design \\u2014 an editor could otherwise aim a write at any element on the page (docs/security.md)":"id"===e||"name"===e?"CMS content that can name an element can shadow a global of that name \\u2014 DOM clobbering, refused by design (docs/security.md)":"Put it on an element the template owns, or set `sanitizerPolicy: \'compat\'` to keep every `data-*` as 1.x did"}(e)}.`))}function $t(e,t){return Ft(e,void 0,t)}function Ft(e,t,n){let i=n?.document??Nt();if(!i)throw new Error("sanitizeHtml needs a DOM");if(""===e)return"";let r=function(e,t){let n=e?.policy??t??zl;if(!e){let e=new Map;for(let[t,n]of Object.entries(Il))e.set(t,n);return{allowedTags:Ml,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:new Set}}let i=new Set(Ml);if(e.additionalAllowedTags?.forEach(e=>i.add(e)),!0===e.allowFormControls)for(let e of El)i.add(e);let r=new Map;for(let[e,t]of Object.entries(Il))r.set(e,t);for(let[t,n]of Object.entries(e.additionalAllowedAttributes??{})){let e=new Set(r.get(t));for(let t of n)e.add(t);r.set(t,e)}return{allowedTags:i,attrByTag:r,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t),l=e;for(let e=0;e<Wl;e+=1){let e=i.createElement("template");e.innerHTML=yt(l),Mt(e.content,r);let t=e.innerHTML;if(t===l)return t;l=t}return function(e,t){if(!function(){try{let e=glo','balThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}())return;let n=globalThis,i=n[$l]??(n[$l]=new Set);if(!i.has(e)){i.add(e);try{console.warn(`[payload-live-preview] ${t}`)}catch{}}}("sanitizer-unsettled",`sanitizeHtml: the output did not settle after ${String(Wl)} passes, so it returned an empty string (ADR 0016).`),""}function Nt(){if(!(typ','eof document>"u"))return document}function Mt(e,t){for(let n of Array.from(e.childNodes))n.nodeType===Bl?Et(n,t):n.nodeType===Dl&&n.remove()}function Et(e,t){let n=e.tagName.toLowerCase();!Ol.has(n)||t.allowFormControls&&El.has(n)?t.allowedTags.has(n)?(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("is"!==r){if("strict"===n.mode){if(n.templateMode&&_l.has(r))continue;if("id"===r||"name"===r||r.startsWith(Ul)){e.removeAttribute(t.name),("name"!==r||!0===i?.has(r))&&Rt(r);continue}if(r.startsWith(Pl)){n.allowedData.has(r)||(e.removeAttribute(t.name),Rt(r));continue}if(Ll.has(r)||r.startsWith(xl))continue}else if(Ll.has(r)||r.startsWith(xl)||r.startsWith(Pl))continue;i?.has(r)?(jl.has(r)&&!F(t.value)||"srcset"===r&&!Ot(t.value))&&e.removeAttribute(t.name):e.removeAttribute(t.name)}else e.setAttribute("is","")}}(e,n,t),"a"===n&&function(e){let t=e.getAttribute("href");null===t||!N(t)||(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),Mt(e,t)):(Mt(e,t),e.replaceWith(...e.childNodes)):e.remove()}function Ot(e){for(let t of e.split(",")){let e=t.trim();if(0===e.length)continue;let[n=e]=e.split(/\\s/,1);if(!F(n)||!F(e))return!1}return!0}function Lt(e){return e.replace(ql,e=>Vl[e])}function xt(e){return e.replace(Gl,e=>Hl[e])}function Pt(e){let t=new Set;for(let n of e)if("object"==typeof n&&null!==n)for(let e of Object.keys(n))t.add(e);return t}function Ut(e,t,n,i,r){let l="object"==typeof t&&null!==t?t:null;return e.replace(Kl,(e,a)=>null!==l&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(l,a)?Lt(i(Reflect.get(l,a))):null===l&&"value"===a?Lt(i(t)):"index"===a?String(n):null!==l&&!0===r?.has(a)?"":e)}function It(e){let t=e.children,n=t[0];if(void 0===n)return[];let i=[];for(let{name:e,value:r}of Array.from(n.attributes)){if(!M(e)||e.startsWith(Jl))continue;let n=!0;for(let i=1;i<t.length&&n;i+=1)n=t[i]?.getAttribute(e)===r;n&&i.push([e,r])}return i}function jt(e,t){for(let[n,i]of t)e.hasAttribute(n)||e.setAttribute(n,i)}function Wt(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 Bt(e){return null==e||""===e}function Dt(e,t){let n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function _t(e,t,n,i){return e.set(t,n),function(e,t){for(let n of e.keys()){if(e.size<=t)break;e.delete(n)}}(e,i),n}function zt(e){let t=Dt(ea,e);if(void 0!==t)return t;let n=new Set(Xl);for(let t of e.matchAll(Zl)){let e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}let i={};for(let e of n)i[e]=Ql;let r={additionalAllowedTags:[...n],additionalAllowedAttributes:i,allowFormControls:!0,templateMode:!0};return _t(ea,e,r,Yl)}function Vt(e){let t=Ht(e.container,e.patches,e);return null===t?null:Gt(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function qt(e,t){return t.hasAttribute(na)&&t.hasAttribute(ia)}function Ht(e,t,n){let i=function(e,t,n){let{template:i,nextItems:r,forceRender:l=!1,store:a,sanitizerPolicy:s}=n,o=a.get(e),u=It(e),d=Pt(r),c=Array.from(e.children),h=en(c,ta),f=new Set,p=[];for(let a=0;a<r.length;a+=1){let g=r[a],m=Yt(g),v=void 0===m?c[a]??null:tn(h,m)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);let y=t.replaces.has(a),b=l||t.renders.has(a)||null===v?nn(e.ownerDocument,i,g,a,s,u,d):void 0;if(null===b)return null;let w=void 0===b?[]:Kt(y?null:v,b,g,void 0===m?void 0:o?.get(m),n);if(null===w)return null;p.push([a,v,b,w,y])}return p}(e,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}}(t),n);return null===i?null:[e,i,n.nextItems]}function Gt(e,t,n){let[i,r,l]=e,a=new Set,s=!1,o=Tt(i);for(let[e,l,o,u,d]of r){let r=l;if(void 0!==o){let e=!(!n.morph||d||null===l)&&wt(l,o,{keyAttributes:[ta,na],boundary:ae,retainBoundary:he,retainChildrenOf:qt,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===l;if(!e)for(let[e,t]of u)null!==e&&(Xt(e,t),t.replaceWith(e));for(let[,,e]of u)void 0!==e&&Gt(e,t,n);e?s=!0:(null!==l&&(l.replaceWith(o),s=!0),r=o)}if(null===r)continue;let c=i.children[e]??null;r!==c&&(i.insertBefore(r,c),s=!0),a.add(r)}for(let e of Array.from(i.children))a.has(e)||(e.remove(),s=!0);Ct(o);let u=function(e,t){let n=t.get(e);return n||(n=new Map,t.set(e,n)),n}(i,t);u.clear();for(let e of l)Zt(u,e);return s}function Kt(e,t,n,i,r){let l=en(null===e?[]:Jt(e),na),a=[];for(let e of Jt(t)){let t=e.getAttribute(na);if(null===t)continue;let s,o=tn(l,t)??null,u=e.getAttribute(ia),d=u?o:null,c=d?.getAttribute(ia)??null;if(u){let l=Qt(n,t);if(void 0!==l||null!==d){let n=l??[],a=R(null===d?[]:Qt(i,t)??[],n),o=null!==d&&c!==u;if((a.length>0||o)&&(s=Ht(d??e,a,{template:u,nextItems:n,forceRender:o,store:r.store,sanitizerPolicy:r.sanitizerPolicy})??void 0,void 0===s))return null}}a.push([d,e,s])}return a}function Jt(e){return Array.from(e.querySelectorAll(`[${na}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(na))return!1;n=n.parentElement}return n===e})}function Xt(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 Qt(e,t){if("object"!=typeof e||null===e)return;let n=e[t];return Array.isArray(n)?n:void 0}function Zt(e,t){let n=Yt(t);void 0!==n&&e.set(n,t)}function Yt(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function en(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 a=n.get(l);void 0===a?n.set(l,[r]):a.push(r)}return n}function tn(e,t){return e.get(t)?.pop()}function nn(e,t,n,i,r,l,a){let s=Ft(Ut(t,n,i,Wt,a),r,zt(t)),o=e.createElement("template");o.innerHTML=yt(s);let u=o.content.firstElementChild;if(!u)return null;jt(u,l);let d=Yt(n);return void 0!==d&&u.setAttribute(ta,d),u}function rn(e,t,n){let i=new Set(t);return{boundaries:t,strategy:e,ownerKeys:n,covers:e=>void 0!==e.fragmentBoundary&&i.has(e.fragmentBoundary)}}function ln(e,t){return!1===t||W(ge(e),t)}function an(t,n,i,r,l){let a=t.transformValue;if(void 0===a)return i;try{let t=a(n.fieldName,i,{element:n.element,allFields:r},l),s=e(t);if(!l())return i;if(s)throw new TypeError(`Transform for "${n.fieldName}" returned a thenable; transforms must be synchronous`);return t}catch(e){if(!l())return i;let n=e instanceof Error?e:new Error(String(e));return t.emitter.emit("error",{error:n,context:"transform",code:"LP0602"}),i}}function sn(){if(typ','eof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function on(e){let t=e.trim();if(0!==t.length)try{let e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||!ha.test(e.origin)?void 0:e.origin}catch{return}}function un(e){let t=e.format;return"string"==typeof t&&ba.has(t)?t:"number"==typeof t?ya[t]:void 0}function dn(e){let t=e.indent;return"number"==typeof t&&t>0?t:0}function cn(e){return"rtl"===e.direction?\' dir="rtl"\':"ltr"===e.direction?\' dir="ltr"\':""}function hn(e){let t=un(e),n=dn(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 fn(e){return"object"==typeof e&&null!==e?e:void 0}function pn(e){return fn(e)}function gn(e,t){if(void 0===t||""===t||!e.startsWith("/"))return e;try{let n=new URL(t),i=new URL(e,n);return i.origin===n.origin?i.href:e}catch{return e}}function mn(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function vn(e){return"string"==typeof e&&e.length>0?e:void 0}function yn(e){let t=vn(e.title)??vn(e.name)??vn(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}function bn(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(let n of e.children)t+=bn(n);return t}function wn(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function Sn(e){return"string"==typeof e.mimeType?` type="${xt(e.mimeType)}"`:""}function An(e){return ka.get(e)}function kn(e,t,n,i){let r=fn(e.fields)??{},l="string"==typeof r.blockType?r.blockType:"",a=mn(l),s=""===a?i:`${i} ${i}--${a}`;if(""!==l){let e=An(l)??An(a);if(e)return e(r,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(l,s)}return`<${n} class="${s}"></${n}>`}function Tn(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}function Cn(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 Rn(e,t){let n=function(e){return Ra.get(e)??Ca[e]}(e.type);return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function $n(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+=$n(n);return t}function Fn(e="text"){let t=new WeakSet;return{name:e,render:E((e,n)=>{let i=e.element,r=function(e){return null==e?"":Cn(e)?function(e){return Cn(e)?e.root.children.map($n).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(Fa))return function(e,t,n){e.has(t)||(e.add(t),si(`[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=yt(function(e){return Lt(e).replace(/\\r\\n|\\r|\\n/g,"<br>")}(r)):i.textContent=r}else i.value=r})}}function Nn(e,t){let n=e.cloneNode(!1);n.innerHTML=yt(t);let i=function(e,t){let n=e.firstElementChild;if(null!==n?.nextElementSibling||t.children.length<2||!Ea.has(n.tagName)||n.hasAttribute(dr))return null;for(let e of t.children)if(e.tagName===n.tagName&&e.className===n.className)return null;return n}(e,n)??e,r=new Map,l=n.querySelectorAll(Ta);if(l.length>0&&null!==i.firstElementChild){let e=[];Mn(i,n,e);for(let[t,n]of e)t.replaceWith(n),n.matches(Ta)||r.set(t.className,!1);for(let e of l)null!==e.parentNode&&r.set(e.className,!0)}return i.replaceChildren(...n.childNodes),r}function Mn(e,t,n){if(e.children.length!==t.children.length)return;let i=e.firstElementChild,r=t.firstElementChild;for(;null!==i&&null!==r;)r.matches(Ta)?n.push([r,i]):Mn(i,r,n),i=i.nextElementSibling,r=r.nextElementSibling}function En(e,t,n,i){i&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);let r=i?Ma:Na;r.has(n)||(r.add(n),si(`[live-preview] ${i?`LP0413: no renderer for block "${n}", and the markup the server rendered for it is lost.`:`LP0410: no renderer for block "${n}"; keeping what the server rendered for it.`} Register one with registerBlockRenderer().`))}function On(e,t,n,i){if("string"!=typeof n||0===n.length)return{kind:"none"};let r=gn(n,i);return F(r)?{kind:"safe",url:r}:(xa.has(e)||(xa.add(e),si(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function Ln(e,t=e=>e){return{name:e,render(e,n,i){let r=e.element;if(Bt(n)){!function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(r);return}let l=Wt(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName){if("A"===r.tagName){let n=e.hrefField,a=void 0===n||0===n.length?t(l):ut(i.allFields,n,i.locale,void 0!==e.locale),s=On(r,e.fieldName,a);"safe"===s.kind?r.setAttribute("href",s.url):"unsafe"===s.kind&&r.removeAttribute("href")}r.textContent=l}else r.value=l}}}function xn(e){for(let t of ja)e.removeAttribute(t)}function Pn(e,t,n,i){e.src=t;let r=function(e,t){if(void 0===e?.sizes)return;let n=[];for(let i of Object.values(e.sizes)){if("string"!=typeof i.url||"number"!=typeof i.width)continue;let e=gn(i.url,t);F(e)&&n.push(`${Un(e)} ${String(i.width)}w`)}if(0!==n.length){if("number"==typeof e.width&&"string"==typeof e.url){let i=gn(e.url,t);F(i)&&n.push(`${Un(i)} ${String(e.width)}w`)}return n.join(", ")}}(n,i);void 0!==r?e.setAttribute("srcset",r):(e.removeAttribute("srcset"),e.removeAttribute("sizes"))}function Un(e){return e.replace(/[\\s,]/g,encodeURIComponent)}function In(e){"IMG"===e.tagName?xn(e):e.style.backgroundImage=""}function jn(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):xn(e)}function Wn(e){let t=fn(e);return void 0===t?Wt(e):yn(t)??""}function Bn(e,t){let n=e??"";if(null==t)return n;let i=Dn(t);return"{}"===i?n:`${n}|${i}`}function Dn(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Dn(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)}:${Dn(n)}`)}return`{${i.join(",")}}`}function _n(e){return{kind:"date",options:e}}function zn(e){return{kind:"number",options:e}}function Vn(e,t,n,i){if(void 0===t||""===t)return;let r=function(e){let t=e.indexOf(":"),n=-1===t?e:e.slice(0,t),i=-1===t?void 0:e.slice(t+1);switch(n){case"date":return void 0===i?_n({dateStyle:"medium"}):Ga.has(i)?_n({dateStyle:i}):void 0;case"time":return void 0===i?_n({timeStyle:"short"}):Ka.has(i)?_n({timeStyle:i}):void 0;case"datetime":return void 0===i?_n({dateStyle:"medium",timeStyle:"short"}):Ga.has(i)?_n({dateStyle:i,timeStyle:"short"===i?"short":"medium"}):void 0;case"number":return void 0===i?zn({}):Xa.test(i)?zn({minimumFractionDigits:Number(i),maximumFractionDigits:Number(i)}):void 0;case"currency":return void 0!==i&&Ja.test(i)?zn({style:"currency",currency:i.toUpperCase()}):void 0;case"percent":return void 0===i?zn({style:"percent"}):void 0;default:return}}(t);if(void 0!==r)return r.kind===e?r.options:void 0;!function(e,t,n){Qa.has(e)||(Qa.add(e),si(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, time, datetime (each also :short|medium|long|full), number, number:0-4, currency:XXX, percent.`))}(n,i,t)}function qn(e){return String(e).padStart(2,"0")}function Hn(){let e=new WeakMap,t=new WeakSet,n=new WeakMap,i=new WeakMap;return{name:"structural-array",render:E((r,l,a)=>{let s=Bt(l)?[]:l;if(!Array.isArray(s))return!1;let o=r.element,u=r.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,n){e.has(t)||(e.add(t),si(`[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,o,r.fieldName),!1;let d=e.get(o),c=Gn(o),h=d?.values??function(e){return e.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e})}(c),f=R(h,s),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)}(d,u,c);if(0===f.length&&!p)return e.set(o,{values:s.slice(),template:u,domSnapshot:c}),!1;!function(e,t,n,i,r){let l=r.map(Kn),a=new Set,s=l.find(e=>!(void 0===e||!a.has(e)&&(a.add(e),1)));if(void 0!==s&&Jn(e,t,n,s),l.some(e=>void 0===e)&&Xn(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(Kn).filter(e=>void 0!==e)),a=l.some(e=>void 0!==e&&r.has(e));r.size>0&&!a&&Xn(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,o,r.fieldName,d?.values,s);let g=Vt({template:u,container:o,patches:f,nextItems:s,store:i,forceRender:p,sanitizerPolicy:a.sanitizerPolicy,onDuplicateKey:(e,t)=>{Jn(n,e,r.fieldName,t)}});return null!==g&&(e.set(o,{values:s.slice(),template:u,domSnapshot:Gn(o)}),!!g&&void 0)})}}function Gn(e){return Array.from(e.children,e=>e.getAttribute(ta))}function Kn(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Jn(e,t,n,i){Xn(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${i}"; later ones pair by position. Make \\`id\\` unique per item.`)}function Xn(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),si(`[live-preview] ${i}`))}function Qn(){return typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__}var Zn=Object.defineProperty,Yn=e=>{throw TypeError(e)},ei=(e,t,n)=>((e,t,n)=>t in e?Zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),ti=(e,t,n)=>t.has(e)||Yn("Cannot "+n),ni=(e,t,n)=>(ti(e,t,"read from private field"),n?n.call(e):t.get(e)),ii=(e,t,n)=>t.has(e)?Yn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ri=(e,t,n,i)=>(ti(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),li=(e,t,n)=>(ti(e,t,"access private method"),n),ai=t((...e)=>console.error(...e)),si=t((...e)=>console.warn(...e)),oi=t((...e)=>console.debug(...e)),ui=class{constructor(){ii(this,hi);ii(this,di,new Map);ii(this,ci,new Map)}on(e,t){return li(this,hi,pi).call(this,ni(this,di),e,t)}once(e,t){return li(this,hi,pi).call(this,ni(this,ci),e,t)}off(e,t){li(this,hi,gi).call(this,ni(this,di),e,t),li(this,hi,gi).call(this,ni(this,ci),e,t)}async emit(e,t){await li(this,hi,fi).call(this,e,t)}async emitWhile(e,t,n){return li(this,hi,fi).call(this,e,t,n)}listenerCount(e){return(ni(this,di).get(e)?.size??0)+(ni(this,ci).get(e)?.size??0)}removeAllListeners(e){void 0!==e?(ni(this,di).delete(e),ni(this,ci).delete(e)):(ni(this,di).clear(),ni(this,ci).clear())}eventNames(){let e=new Set;for(let t of ni(this,di).keys())e.add(t);for(let t of ni(this,ci).keys())e.add(t);return[...e]}},di=new WeakMap,ci=new WeakMap,hi=new WeakSet,fi=async function(e,t,n){let i=()=>n?.()??!0;if(!i())return!1;let r=ni(this,di).get(e);if(r)for(let n of[...r])if(!i()||(await li(this,hi,mi).call(this,n,t,e),!i()))return!1;if(!i())return!1;let l=ni(this,ci).get(e);if(l&&l.size>0){let n=[...l];ni(this,ci).delete(e);for(let r of n)if(!i()||(await li(this,hi,mi).call(this,r,t,e),!i()))return!1}return i()},pi=function(e,t,n){let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(n),()=>{li(this,hi,gi).call(this,e,t,n)}},gi=function(e,t,n){let i=e.get(t);void 0!==i&&(i.delete(n),0===i.size&&e.delete(t))},mi=async function(e,t,n){try{await e(t)}catch(e){let t="string"==typeof n||"number"==typeof n?String(n):"<event>";ai(`[live-preview] LP0601: handler for "${t}" threw:`,e)}},vi=new Set(["date","number","checkbox"]),yi=40,bi="payload-live-preview-a11y",wi=new WeakMap,Si=class{constructor(e,t){ei(this,"german");ei(this,"document");ei(this,"lease",null);let n=t??(typ','eof document>"u"?null:document),i=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(i.length>0?i:o())),this.document=n}mount(){let e=this.document;if(null==e?.body)return null;this.lease??(this.lease=function(e){let t=wi.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},wi.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;u(t),e&&n.remove()}let i=e.getElementById(bi);return t.owned=null===i,null===i&&(i=e.createElement("div"),i.id=bi,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-atomic","true"),i.style.cssText="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`)}announcePartial(){this.say(this.german?"Vorschau teilweise aktualisiert":"Preview partly updated")}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&&u(e),e.owned&&n?.remove(),e.element=null,wi.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 r=setTimeout(()=>{n.timer===r&&n.element===t&&u(n)},1500);n.timer=r}},Ai=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],ki={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"}},Ti=Object.keys(ki),Ci=class{constructor(e,t){ei(this,"matcher");ei(this,"handlers");ei(this,"boundListener");ei(this,"attachedTarget");ei(this,"generation",0);ei(this,"revision",0);ei(this,"queueHead");ei(this,"queueTail");ei(this,"lastAccepted");ei(this,"replayedGeneration",0);ei(this,"latestAcceptedAttempt");this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1,n=i=>{if(!t||this.boundListener!==n)return;let r=this.generation;try{this.receive(i,r,e)}catch{let e;try{e=i.origin}catch{e=""}this.reportInvalid("shape",e,r)}};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)}replayLastAccepted(){let e=this.lastAccepted,t=this.generation,n=this.handlers.onReplay;if(void 0===n||void 0===e||e.generation>=t||this.replayedGeneration===t||!this.matchesOrigin(e.origin,t)||this.lastAccepted!==e)return!1;this.replayedGeneration=t;let i={generation:t,revision:this.revision+=1};return this.invokeHandler(t,n,structuredClone(e.message),e.origin,i),!0}forgetLastAccepted(){this.lastAccepted=void 0,this.replayedGeneration=0,this.latestAcceptedAttempt=void 0}static sendReady(e,t){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,n){let i=e.origin;if(!this.matchesOrigin(i,t)){this.reportInvalid("origin",i,t);return}if(!this.matchesSource(e,n)){this.reportInvalid("source",i,t);return}let r=e.data;if(function(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}(r))switch(r.type){case"payload-live-preview":if(!function(e){let t=e;return!(void 0!==t.data&&null!==t.data&&!v(t.data))&&m(t.fieldSchemaJSON,e=>Array.isArray(e))&&m(t.globalSlug,e=>"string"==typeof e)&&m(t.collectionSlug,e=>"string"==typeof e)&&m(t.locale,e=>"string"==typeof e)&&m(t.ready,e=>"boolean"==typeof e)&&m(t.previewToken,e=>"string"==typeof e)&&m(t.protocolVersion,e=>"number"==typeof e)}(r)){this.reportInvalid("shape",i,t);return}this.dispatchUpdate(function(e){let t={...e};for(let e of Ai)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);return Array.isArray(t.fieldSchemaJSON)?{...t,fieldSchemaJSON:h(t.fieldSchemaJSON)}:t}(r),i,t);return;case"payload-document-event":if(!function(e){let t=e;return g(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&g(t.slug,e=>"string"==typeof e)&&g(t.id,e=>"string"==typeof e||Number.isFinite(e))}(r)){this.reportInvalid("shape",i,t);return}this.invokeHandler(t,this.handlers.onDocumentEvent,r,i);return;case"payload-live-preview-focus":{let e=function(e){let t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(r);if(void 0===e){this.reportInvalid("shape",i,t);return}this.invokeHandler(t,this.handlers.onFocusField,e,i);return}default:this.reportInvalid("type",i,t)}else this.reportInvalid("shape",i,t)}dispatchUpdate(e,t,n){let i=v(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 a={generation:n,message:e,origin:t,messageRevision:r,verdict:void 0,next:void 0};this.enqueue(a);let s;try{s=l(e.previewToken,t)}catch{this.settleValidation(a,!1);return}"boolean"!=typeof s?Promise.resolve(s).then(e=>{this.settleValidation(a,!0===e)},()=>{this.settleValidation(a,!1)}):this.settleValidation(a,s)}settleValidation(e,t){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){let t=this.queueHead;if(void 0===t)return;if(this.matchesOrigin(t.origin,e)){if(void 0===t.verdict)return;this.dequeue(t)&&(t.verdict?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){if(void 0===i)this.invokeHandler(n,this.handlers.onUpdate,e,t);else{let r={};this.latestAcceptedAttempt=r;let l=function(e){let t={...e};delete t.previewToken;try{return structuredClone(t)}catch{return null}}(e);if(this.latestAcceptedAttempt!==r||!this.isCurrentGeneration(n))return;this.lastAccepted=null===l?void 0:{generation:n,message:l,origin:t},this.invokeHandler(n,this.handlers.onUpdate,e,t,i)}}reportInvalid(e,t,n){this.invokeHandler(n,this.handlers.onInvalid,e,t)}matchesSource(e,t){if("parent-or-opener"!==this.handlers.sourcePolicy)return!0;try{let n=e.source;if("object"!=typeof n||null===n)return!1;let i=t.parent;return i!==t&&n===i||n===t.opener}catch{return!1}}matchesOrigin(e,t){try{return!0===(this.isCurrentGeneration(t)&&this.matcher(e))&&this.isCurrentGeneration(t)}catch{return!1}}invokeHandler(t,n,...i){if(void 0!==n&&this.isCurrentGeneration(t))try{e(n(...i))}catch{}}isCurrentGeneration(e){return void 0!==this.attachedTarget&&this.generation===e}enqueue(e){void 0===this.queueTail?this.queueHead=e:this.queueTail.next=e,this.queueTail=e}dequeue(e){return this.queueHead===e&&(this.queueHead=e.next,void 0===this.queueHead&&(this.queueTail=void 0),!0)}resetQueue(){this.queueHead=void 0,this.queueTail=void 0}},Ri=new Set(["tabs","row","collapsible"]),$i={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"},Fi=new Set(["http:","https:","mailto:","tel:"]),Ni=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,Mi=/^[\\\\/]{2}/,Ei=/[\\t\\n\\r]/g,Oi=/[\\s\\u0000-\\u001f\\u180e\\u2000-\\u2029]/g,Li=/^([a-z][a-z0-9+.-]*):/i,xi=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Pi=new Set(["href","src","poster","cite","action","xlink:href","data"]),Ui=new WeakSet,Ii=class{constructor(){ei(this,"previous",null);ei(this,"lastFields");ei(this,"priorFields");ei(this,"keepValues",!1)}get previousFields(){return this.priorFields}get isBaseline(){return null===this.previous}diff(e,t,n=L){let i=this.previous,r=null===i,l=new Map,a=new Set,s=Object.entries(e);if(!n())return null;for(let[e,t]of s){let r=O(t);if(!n())return null;l.set(e,r),(null===i||void 0===r||i.get(e)!==r)&&a.add(e)}if(null!==i)for(let e of i.keys())l.has(e)||a.add(e);let o=new Set,u=Object.entries(t);if(!n())return null;for(let[e,t]of u)if(a.has(e))for(let e of t)if(o.add(e),!n())return null;return n()?(this.previous=l,this.priorFields=this.keepValues?this.lastFields:void 0,this.lastFields=this.keepValues?e:void 0,{changed:a,invalidated:o,baseline:r}):null}reset(){this.previous=null,this.lastFields=void 0,this.priorFields=void 0}},ji="data-payload-fragment",Wi="data-payload-fragment-key",Bi="data-payload-strategy",Di=8,_i=1024,zi=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),Vi=new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),qi={},Hi=class{constructor(){ei(this,"rawChanges",new Ii);ei(this,"resolved",null);ei(this,"resolvedLocale",null);ei(this,"trailing",null);ei(this,"openUntil",0);ei(this,"requestAttempt",0)}decide(e,t){let n=t.rawData;if(!function(e){let{cache:t,emitter:n}=e;if(t.islands.length>0||n.listenerCount("beforeUpdate")>0||n.listenerCount("afterUpdate")>0)return!0;for(let e of t.values())if(J(e)||e.fieldName.includes(".")||Q(e.hrefField)||Q(e.srcField)||Q(e.altField))return!0;return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${ji}]`)}(e))return t.forceRender&&(this.resolvedLocale=null),{merge:!1,fields:n};let{changed:i}=this.rawChanges.diff(n,qi),r=this.resolvedLocale!==t.locale,l=this.resolved;if(null===l)return this.resolved=n,{merge:!0,fields:n};let a={...l};t.forceRender&&(this.resolvedLocale=null);let s=t.forceRender||r;for(let r of i){let i=n[r];if(zi.has(r)){a[r]=i;continue}let o=K(r,l[r],i,e.cache,t.schemaIndex);"own"!==o&&(s=!0,this.resolvedLocale=null),"keep"!==o&&(a[r]=i)}return this.resolved=a,{merge:s,fields:a}}request(e,t,n){let i=++this.requestAttempt,r=Date.now();if(r>=this.openUntil)return this.openUntil=r+t,this.dropQueued(),this.requestAttempt!==i?{leading:!0,result:Promise.resolve({status:"superseded"})}:{leading:!0,result:e.merge(n)};let l=this.trailing,a=l?.pending??function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}(),s={request:n,pending:a,timer:null};if(this.trailing=s,this.openUntil=r+t,null!==l&&null!==l.timer&&clearTimeout(l.timer),this.trailing!==s)return{leading:!1,result:a.promise};let o=setTimeout(()=>{this.flush(e,s)},t);return this.trailing===s?s.timer=o:clearTimeout(o),{leading:!1,result:a.promise}}recordMerged(e,t){this.resolved=e,this.resolvedLocale=t}resetRawChanges(){this.rawChanges.reset()}destroy(){this.requestAttempt+=1,this.openUntil=0,this.dropQueued()}dropQueued(){let e=this.trailing;this.trailing=null,null!==e&&(null!==e.timer&&clearTimeout(e.timer),e.pending.settle({status:"superseded"}))}flush(e,t){this.trailing===t&&(this.trailing=null,t.timer=null,e.merge(t.request).then(t.pending.settle))}},Gi=class{constructor(){ei(this,"negotiation",y(void 0));ei(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=y(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}applyVersion(e,t){let n=this.negotiation;if(n.theirs===e)return;let i=y(e,this.observed);this.negotiation=i,i.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${i.negotiated}`)}},Ki=class{constructor(){ei(this,"lastIdentity")}inspect(e){let t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;let n=JSON.stringify([t.entitySlug,B(t),t.updatedAt]);return{identity:n,edit:n!==this.lastIdentity&&Z(t,e)?t:null}}commit(e){let t=e.identity!==this.lastIdentity;return this.lastIdentity=e.identity,t?e.edit:null}},Ji=class{constructor(){ii(this,Xi)}reveal(e,t,n){return e===ni(this,Xi)?"skipped-same":(ri(this,Xi,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:ee(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){ri(this,Xi,void 0)}},Xi=new WeakMap,Qi=class{constructor(){ei(this,"seen",new Map)}note(e,t,n){let i=O(n);if(void 0===i)return;let r=`${t.owner??""}\\0${t.locale??""}\\0${t.fieldName}`,l=this.seen.get(r);void 0!==l?l!==i&&(e.revealIdentities.push([r,i]),e.revealTarget??(e.revealTarget=t)):this.seen.set(r,i)}commit(e){for(let[t,n]of e.revealIdentities)this.seen.set(t,n);e.revealIdentities=[];let t=e.revealTarget;return e.revealTarget=void 0,t}},Zi=()=>{},Yi=class{constructor(){ei(this,"host",{outstanding:()=>!1,report:Zi,failed:Zi});ei(this,"entry",null);ei(this,"ended")}begin(e,t){let n=this.entry,i=null===n?void 0:this.view(n);null!==n&&(n.key=void 0),this.ended=void 0,this.entry={key:e,revision:t,shortfalls:[],seen:new Set,deferred:0,awaiting:0,reported:void 0,queued:!1},null!==n&&void 0!==i&&this.publish(n,"pending"===i.state?{...i,state:"superseded"}:i)}end(){let e=this.entry;if(null!==e){this.entry=null;try{this.ended=this.view(e)}finally{e.key=void 0}}}snapshot(){return null!==this.entry?this.view(this.entry):void 0===this.ended?void 0:{...this.ended,shortfalls:[...this.ended.shortfalls]}}shortfall(e,t){let n=this.entry;if(n?.key!==e)return;let i=JSON.stringify(t);n.seen.has(i)||(n.seen.add(i),n.shortfalls.push(t),this.requestSettle(n.key))}deferred(e,t){this.entry?.key===e&&(this.entry.deferred=t)}handIsland(e){let t=this.entry;if(t?.key!==e)return Zi;t.awaiting+=1;let n=!1;return()=>{n||this.entry!==t||(n=!0,t.awaiting-=1,this.settle(t))}}requestSettle(e){let t=this.entry;t?.key!==e||t.queued||(t.queued=!0,queueMicrotask(()=>{t.queued=!1;try{this.entry===t&&this.settle(t)}catch(e){this.host.failed(e)}}))}settle(e){let t=this.view(e);"pending"!==t.state&&this.publish(e,t)}publish(e,t){e.reported!==t.state&&(e.reported=t.state,this.host.report(t))}view(e){let t=void 0!==e.key&&this.host.outstanding(e.key)?"pending":e.shortfalls.length>0?"partial":e.awaiting>0?"unconfirmed":"current";return{revision:e.revision,state:t,shortfalls:[...e.shortfalls],deferred:e.deferred,awaitingIslands:e.awaiting}}},er=class{constructor(){ei(this,"started",!1);ei(this,"suspended",!1);ei(this,"deferredStart",null);ei(this,"hydration","idle");ei(this,"activeUpdate",null);ei(this,"locale");ei(this,"schema");ei(this,"schemaIndex");ei(this,"updateCount",0);ei(this,"supersededCount",0);ei(this,"completedCount",0);ei(this,"skippedUnchangedCount",0);ei(this,"lastFlush",null);ei(this,"absentFields",new Set);ei(this,"warnedOrphanFields",new Set);ei(this,"warnedStrategy",new WeakSet);ei(this,"warnedUnattributableMessage",!1);ei(this,"warnedVisibilityGate",!1);ei(this,"warnedFragmentFallback",!1);ei(this,"warnedIslandStart",!1);ei(this,"warnedEscalationUnavailable",!1);ei(this,"warnedProtocolShape",!1);ei(this,"reportedUnfaithful",new WeakSet);ei(this,"checkedServerFormat",new WeakSet);ei(this,"unfaithfulPatches",[]);ei(this,"unfaithfulCount",0);ei(this,"escalatedCount",0);ei(this,"unfaithfulFields",new Set);ei(this,"autoBindSearchMs");ei(this,"autoBindGuesses",null);ei(this,"warnedForeignSource",!1);ei(this,"lastAppliedIdentity",new WeakMap);ei(this,"navigationReplayPending",!1);ei(this,"navigationBindingReplay",!1);ei(this,"revealLedger",new Qi);ei(this,"display",new Yi);ei(this,"fragmentStats",{rendered:0,failed:0,superseded:0});ei(this,"routeStats",{refreshes:0,partial:0,failed:0,refused:0,loopStopped:0});ei(this,"fragmentControllers",new Map);ei(this,"routeController",null);ei(this,"routeRetry",null);ei(this,"routeRefreshOwed",!1);ei(this,"fragmentsOwed",new Set);ei(this,"readyTimers",[]);ei(this,"revealer",new Ji);ei(this,"changes",new Ii);ei(this,"merges",new Hi);ei(this,"protocol",new Gi);ei(this,"relationships",new Ki)}isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){this.display.requestSettle(e),!e.completed&&(e.completed=!0,e.countsAsUpdate&&(this.completedCount+=1))}forgetOwedWork(){this.routeRefreshOwed=!1,this.fragmentsOwed.clear()}supersedeStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(let[e,t]of this.fragmentControllers){for(let e of t)this.fragmentsOwed.add(e);e.abort()}this.fragmentControllers.clear()}abortStrategies(){this.supersedeStrategies();let e=this.routeController;this.routeController=null,e?.abort()}},tr=class{constructor(e,t){ei(this,"deps",e);ei(this,"state",t);ei(this,"instanceContext");this.instanceContext=function(e){let t={};for(let[n,i]of Object.entries(e))void 0!==i&&(t[n]=i);return t}({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,serverURL:e.serverURL,reportUnfaithful:(n,i)=>{r(e,t,n,i)}})}apply(e){let{deps:t,state:n}=this,i=n.activeUpdate;if(null===i||void 0===e.revision||!b(i.revision,e.revision)||!n.isCurrent(i))return!1;let{target:l,value:o}=e,u=void 0!==i.schemaIndex?k(i.schemaIndex,l.fieldName):void 0,d=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){let e=function(e){if(Object.prototype.hasOwnProperty.call($i,e))return $i[e]}(t);if(void 0!==e)return e}return e.fieldType}(l,u?.type);"text"===d&&!0!==l.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)}(o)&&(d="richText");let c;try{c=t.resolveRenderer(d,l)}catch(e){return this.fail(i,l.fieldName,e)}if(!n.isCurrent(i))return!1;let h=t.emitter.listenerCount("elementUpdate")>0,f=h?function(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:"IMG"===e.tagName?e.src:e.textContent}(l.element):void 0;if(!n.isCurrent(i))return!1;let p={allFields:e.allFields,locale:l.locale??i.locale,schema:u,...this.instanceContext};!0===l.hidesWhenEmpty&&l.element.toggleAttribute("hidden",function(e){return null==e||("string"==typeof e?0===e.trim().length:Array.isArray(e)&&0===e.length)}(o));try{if(void 0!==l.targetAttribute){if("blocked"===function(e,t,n){let i=t.toLowerCase().trim();if(0===i.length||!M(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 Pi.has(i)&&!F(r)?"blocked":(e.setAttribute(i,r),"applied")}(l.element,l.targetAttribute,o))return t.warn(`[live-preview] LP0401: refused to write "${l.fieldName}" into attribute "${l.targetAttribute}"`),n.display.shortfall(i,{kind:"write",field:l.fieldName,code:"LP0401"}),!1}else{if(void 0===c)return t.log("no renderer for",d),r(t,n,l,`has no renderer for "${d}"`),!1;{let e=function(e,t,n,i){if("ignore"===e.onUnfaithfulPatch||void 0!==n.format||!vi.has(i)||t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);let r=a(n.element);return r.trim().length>0?r:void 0}(t,n,l,d);if(!1===function(e,t,n,i){return e.render(t,n,i)}(c,l,o,p)&&function(e){return Ui.has(e.render)}(c))return r(t,n,l,`is a value ${c.name} cannot render`),!1;void 0!==e&&function(e,t,n){let i=a(t.element);i!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${s(n)}, the patch wrote ${s(i)} \\u2014 either an edit that arrived before the preview connected, or a template that formats this value differently. Set data-payload-format to match it.`)}(t,l,e)}}}catch(e){return this.fail(i,l.fieldName,e)}if(!n.isCurrent(i))return!1;h&&t.emitter.emitWhile("elementUpdate",{element:l.element,fieldName:l.fieldName,previousValue:f,nextValue:o,revision:i.revision.revision,receivedAt:i.receivedAt,source:"patch"},()=>n.isCurrent(i));let g=n.isCurrent(i);return g&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(l.element,e.valueIdentity):n.lastAppliedIdentity.delete(l.element)),g}fail(e,t,n){if(!this.state.isCurrent(e))return!1;this.state.display.shortfall(e,{kind:"write",field:t,code:"LP0603"});let i=n instanceof Error?n:new Error(String(n));return this.deps.emitter.emitWhile("error",{error:i,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}},nr="payload-live-preview:update",ir="data-payload-island",rr=`astro-island, [${ir}]`,lr="data-payload-owned",ar="data-payload-morph",sr=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],or=new WeakMap,ur=new WeakSet,dr="data-payload-field",cr="data-payload-type",hr="data-payload-attribute",fr="data-payload-href",pr="data-payload-src",gr="data-payload-alt",mr="data-payload-array-template",vr="data-payload-array-separator",yr="data-payload-locale",br="data-payload-richtext",wr="data-payload-html",Sr="data-payload-array",Ar="data-payload-structural",kr="data-payload-owner",Tr="data-payload-depends",Cr="data-payload-strategy",Rr="data-payload-boundary",$r="data-payload-guessed",Fr="data-payload-covers",Nr=[dr,cr,hr,fr,pr,gr,mr,vr,yr,br,wr,Sr,Ar,kr,Tr,Cr,Rr,"type"],Mr=`[${dr}]`,Er=`[${kr}]`,Or=`[${ji}], [${Cr}="route"]`,Lr=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,xr=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"]),Pr=class{constructor(e={}){ei(this,"entriesByField",new Map);ei(this,"entryByElement",new WeakMap);ei(this,"filter");ei(this,"count",0);ei(this,"dependencies",null);ei(this,"islandRoots",[]);ei(this,"ownersByIsland",new Map);ei(this,"navigationRoots",[]);ei(this,"coverDeclarations",[]);ei(this,"renderedDeclarations",[]);this.filter=e.filter??be}dependencyMap(){if(null!==this.dependencies)return this.dependencies;let e=[];for(let t of this.values())void 0!==t.dependsOn&&e.push(le(t.fieldName,t.dependsOn));return this.dependencies=re(...e),this.dependencies}get islands(){return this.islandRoots}get islandOwners(){return this.ownersByIsland}get covers(){return this.coverDeclarations}get rendered(){return this.renderedDeclarations}get navigationReplayRoots(){return this.navigationRoots}buildFromRoot(e){let t=performance.now();this.clear();let n=0;for(let t of e.querySelectorAll(Mr))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){let t=[];for(let n of e.querySelectorAll(rr))se(n)||t.push(n);return t}(e),this.ownersByIsland=new Map(this.islandRoots.map(e=>[e,ge(e)])),this.navigationRoots=[...e.querySelectorAll(Or)].filter(e=>this.filter(e)&&(e.hasAttribute(ji)||0===(e.getAttribute(dr)??"").length)),this.coverDeclarations=[...e.querySelectorAll(`[${Fr}]`)].filter(e=>this.filter(e)).map(e=>({paths:ie(e.getAttribute(Fr)),owner:ge(e)})),this.renderedDeclarations=[...e.querySelectorAll(`[${Tr}]`)].filter(e=>this.filter(e)).flatMap(e=>{let t=function(e){if((e.getAttribute(ji)??"").length>0)return"fragment";let t=e.getAttribute(Cr);return null!==t?"route"===t?"route":void 0:e.hasAttribute(dr)&&null!==e.closest("head")?"route":void 0}(e);return void 0===t?[]:[{strategy:t,paths:ie(e.getAttribute(Tr)),owner:ge(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=[],this.ownersByIsland=new Map,this.navigationRoots=[],this.coverDeclarations=[],this.renderedDeclarations=[]}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(dr);if(null===t||0===t.length)return;let n=e.getAttribute(cr),i=e.getAttribute(hr),r=e.getAttribute(fr),l=e.getAttribute(pr),a=e.getAttribute(gr),s=e.getAttribute(mr),o=e.getAttribute(vr),u=e.getAttribute(yr),d=e.getAttribute("data-payload-format"),c=ge(e),h=ie(e.getAttribute(Tr)),f=e.getAttribute(Cr),p=e.getAttribute($r),g=x(e);return{element:e,fieldName:t,fieldType:ye(e),explicitFieldType:null!==n&&me(n),strategyKind:P(e)??"unknown",...null!==g?{fragmentBoundary:g}:{},...null!==i&&i.length>0?{targetAttribute:i}:{},...null!==r&&r.length>0?{hrefField:r}:{},...null!==l&&l.length>0?{srcField:l}:{},...null!==a&&a.length>0?{altField:a}:{},...null!==s?{arrayTemplate:s}:{},...null!==o?{arraySeparator:o}:{},...null!==u&&u.length>0?{locale:u}:{},...null!==d&&d.length>0?{format:d}:{},...void 0!==c?{owner:c}:{},...h.length>0?{dependsOn:h}:{},...null!==f&&f.length>0?{strategy:f}:{},...e.hasAttribute(Rr)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}},Ur=64,Ir=1e4,jr=1e3,Wr=64,Br=8192,Dr=1048576,_r=1e4,zr=20,Vr=new Set(["__proto__","constructor","prototype"]),qr=class{constructor(e){ei(this,"serverURL");ei(this,"apiRoute");ei(this,"depth");ei(this,"fetchFn");ei(this,"log");ei(this,"inflight",null);ei(this,"attempt",0);ei(this,"destroyDepth",0);this.serverURL=function(e){let t=e.length;for(;e.endsWith("/",t);)t-=1;return e.slice(0,t)}(e.serverURL);let i=e.apiRoute??"/api";this.apiRoute=i.startsWith("/")?i:`/${i}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=t(e.log??n)}canMerge(e){try{let t=e.schema;return void 0!==t?(Ne(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale),!0):null!==this.endpointOf(e)}catch{return!1}}endpointOf(e){try{let t=e.globalSlug;if(t)return Le(t)?{path:`globals/${encodeURIComponent(t)}`,field:"globalType",value:t}:null;let n=e.collectionSlug??"",i=e.data.id;return Le(n)&&xe(i)?{path:`${encodeURIComponent(n)}/${encodeURIComponent(String(i))}`,field:"id",value:String(i)}:null}catch{return null}}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=!1,l=()=>this.attempt!==t;try{if(n?.abort(),l())return{status:"superseded"};let t=e.schema;if(r=void 0!==t,void 0!==t){let n=Ne(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale);if(l())return{status:"superseded"};if(0===n.requests.length)return{status:"merged",doc:n.doc};let r=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(l())return{status:"superseded"};if(void 0===r)return{status:"unavailable"};i=new AbortController,this.inflight=i;for(let e of n.requests){let t=await r(e.url,{method:"GET",credentials:"include",redirect:"error",signal:i.signal});if(l())return{status:"superseded"};let n=t.ok;if(l())return{status:"superseded"};if(!n){let e=t.status;return l()?{status:"superseded"}:(i.abort(),l()?{status:"superseded"}:(this.log("merge HTTP",e),l()?{status:"superseded"}:{status:"unavailable"}))}let a=await Me(t,i.signal,()=>!l());if(l())return{status:"superseded"};if(Ee(e,a),l())return{status:"superseded"}}return{status:"merged",doc:n.doc}}let a=this.endpointOf(e);if(l())return{status:"superseded"};if(null===a)return{status:"unavailable"};let s=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(l())return{status:"superseded"};if(void 0===s)return{status:"unavailable"};let o=JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,locale:e.locale});if(l())return{status:"superseded"};i=new AbortController,this.inflight=i;let u=`${this.serverURL}${this.apiRoute}/${a.path}`,d=await s(u,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:o,signal:i.signal});if(l())return{status:"superseded"};let c=d.ok;if(l())return{status:"superseded"};if(!c){let e=d.status;return l()?{status:"superseded"}:(this.log("merge HTTP",e,u),l()?{status:"superseded"}:{status:"unavailable"})}let h=d.json.bind(d);if(l())return{status:"superseded"};let f=await h();if(l())return{status:"superseded"};if(null===f||"object"!=typeof f||Array.isArray(f))return this.log("merge invalid",u),l()?{status:"superseded"}:{status:"unavailable"};let p=f,g=p[a.field],m=Object.hasOwn(p,a.field)&&("id"===a.field?!xe(g)||String(g)!==a.value:g!==a.value);return l()?{status:"superseded"}:m?(this.log("merge invalid",u),l()?{status:"superseded"}:{status:"unavailable"}):{status:"merged",doc:p}}catch(e){return l()||r&&(i?.abort(),l())?{status:"superseded"}:(this.log("merge exception",r?new Error("legacy population could not be resolved"):e),l()?{status:"superseded"}:{status:"unavailable"})}finally{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}}},Hr="2.1.1",Gr={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},Kr={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},Jr={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1},Xr="ssr",Qr=1,Zr=class{constructor(e,t={}){ei(this,"callbacks");ei(this,"debounceMs");ei(this,"rootMargin");ei(this,"visible",new Set);ei(this,"mutation",null);ei(this,"intersection",null);ei(this,"debounceTimer",null);ei(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:[...Nr,ir,Xr]})}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))return;for(let n of e){let e=Ue(n);if(null!==e&&(this.callbacks.onIslandHydrated?.(e),!this.isCurrentGeneration(t)))return}if(!function(e){for(let t of e){if("attributes"===t.type&&t.attributeName===ir||"attributes"===t.type&&null!==t.attributeName&&Nr.includes(t.attributeName)&&(t.attributeName===dr||t.attributeName===kr||t.target.nodeType===Qr&&t.target.hasAttribute(dr)))return!0;for(let e of t.addedNodes)if(Ie(e))return!0;for(let e of t.removedNodes)if(Ie(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}},Yr=class{constructor(e){ii(this,il);ii(this,el,[]);ii(this,tl);ii(this,nl,!1);ri(this,tl,e)}get closed(){return ni(this,nl)}own(e){ni(this,nl)?li(this,il,rl).call(this,e):ni(this,el).push(e)}close(){if(ni(this,nl))return;ri(this,nl,!0);let e=ni(this,el).splice(0).reverse();for(let t of e)li(this,il,rl).call(this,t)}},el=new WeakMap,tl=new WeakMap,nl=new WeakMap,il=new WeakSet,rl=function(e){try{e()}catch(e){ni(this,tl).call(this,"runtime cleanup failed:",e)}},ll="__livePreviewHydration",al="[data-payload-field]",sl="__vue_app__",ol="__livePreviewVueHydration",ul="app:suspense:resolve",dl={react:(e,t)=>function(e,t=5e3){We();let n=je();if(void 0===n)return null;if(void 0===n.onCommit){let e=e=>{!n.committed&&function(e){let t=e;return null!=t&&function(e){let t=e;return 9===t?.nodeType||null!=t?.querySelector?.(al)}(t.containerInfo)&&!function(e){let t=[];for(null!==e.current&&void 0!==e.current&&t.push(e.current);t.length>0;){let e=t.pop();if(void 0===e)continue;let n=e.memoizedState;if((13===e.tag||31===e.tag)&&"object"==typeof n&&null!==n&&"dehydrated"in n&&"object"==typeof n.dehydrated&&null!==n.dehydrated&&"nodeType"in n.dehydrated&&8===n.dehydrated.nodeType)return!0;null!==e.sibling&&void 0!==e.sibling&&t.push(e.sibling),null!==e.child&&void 0!==e.child&&t.push(e.child)}return!1}(t)}(e)&&Be(n)};n.onCommit=e;for(let t of n.commits.splice(0))e(t)}return _e(n,e,t)}(t),vue:function(e,t,n=5e3){qe();let i=ze();return void 0===i?null:(!i.committed&&function(e){for(let t=e.querySelector(al);null!==t;t=t.parentElement)if(void 0!==Ve(t))return!0;return!1}(e)&&Be(i),_e(i,t,n))},sveltekit:function(e,t,n=5e3){let i=e.ownerDocument??e,r=()=>null!==i.querySelector("#svelte-announcer");if(r()||!Object.keys(window).some(e=>e.startsWith("__sveltekit_")))return null;let l={committed:!1,waiters:[]},a=new MutationObserver(()=>{!l.committed&&r()&&Be(l)});a.observe(i,{childList:!0,subtree:!0});let s=_e(l,e=>{a.disconnect(),t(e)},n);return()=>{a.disconnect(),s?.()}}},cl={react:"React commit",vue:"Vue mount",sveltekit:"SvelteKit mount"},hl=class{constructor(e){ei(this,"timeoutMs");ei(this,"onTimeout");ei(this,"handle",null);ei(this,"lastKick",null);this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){this.lastKick=Date.now(),!(this.timeoutMs<=0)&&(this.stop(),this.arm(this.timeoutMs))}resume(){if(this.timeoutMs<=0||null!==this.handle||null===this.lastKick)return!1;let e=Math.max(0,Date.now()-this.lastKick),t=this.timeoutMs-e;return t<=0?(this.lastKick=null,this.onTimeout(),!0):(this.arm(Math.min(t,this.timeoutMs)),!1)}arm(e){let t=setTimeout(()=>{this.handle===t&&(this.handle=null,this.lastKick=null,this.onTimeout())},e);this.handle=t}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick??0}get pending(){return null!==this.handle}},fl=class{constructor(){ei(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)}},pl="data-payload-no-bind",gl=13,ml=new Set(["true","false","yes","no","on","off"]),vl=/^[\\d\\s.,:+/-]+$/u,yl=/^[a-z][a-z0-9_-]*$/u,bl=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,wl=new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]),Sl="http://www.w3.org/1999/xhtml",Al=new Set(["__proto__","prototype","constructor"]),kl=class{constructor(e,t,n){ei(this,"deps",e);ei(this,"state",t);ei(this,"host",n);ei(this,"awaitingHydration",new WeakSet);ei(this,"delivered",new WeakMap);ei(this,"confirmations",new WeakMap)}reapplyBindings(e){let t=this.currentTransaction();void 0!==t?.renderData&&this.host.schedule(t,t.renderData,e)}reapplyIslands(e,t=!1){let n=t?e.filter(e=>this.awaitingHydration.delete(e)):e,i=this.state.activeUpdate,r=t&&null!==i&&this.state.isCurrent(i)?i:this.currentTransaction();void 0!==r?.renderData&&this.dispatchIslands(r,r.renderData,n)}dispatchIslands(e,t,n){let i=ft(this.deps,this.state,e,t.fields),r=()=>!e.cancelled&&this.state.isCurrent(e);if(!r())return;let l=this.delivered.get(t);void 0===l&&(l=new WeakSet,this.delivered.set(t,l));for(let a of n){let n=ge(a);if(!r())return;if(!1!==i&&!W(n,i)){this.awaitingHydration.delete(a);continue}let s=this.confirmation(a,e);if(ue(a))this.awaitingHydration.add(a);else{if(this.awaitingHydration.delete(a),l.has(a))continue;l.add(a),pt(e,t,[a],r,s)}}}hasLateRouteBinding(e,t,n,i){for(let i of e){if((i.getAttribute(dr)??"").length>0||"route"!==i.getAttribute(Cr)||!1!==t&&!W(ge(i),t))continue;let e=ie(i.getAttribute(Tr));if(0===e.length||e.some(e=>n.touched.has(e)))return!0}for(let[r,l]of this.deps.cache.entries())for(let a of l){if(!e.has(a.element)||!1!==t&&!W(a.owner,t)||"route"!==(a.strategyKind??P(a.element)??"unknown"))continue;let l=ct(i.fields,a,r,n.locale);if(!this.state.isCurrent(n))return!1;if(void 0!==l)return!0}return!1}fieldsForElements(e,t){let n=new Set(t);for(let[t,i]of this.deps.cache.entries())i.some(t=>e.has(t.element))&&n.add(t);return n}unrunFragmentPlan(e,t,n){if(null===t)return null;let i=t.boundaries.filter(t=>!e.fragmentBoundariesRun.has(t)&&(void 0===n||[...n].some(e=>e===t||t.contains(e))));if(0===i.length)return null;let r=new Set(i);return{...t,boundaries:i,covers:e=>void 0!==e.fragmentBoundary&&r.has(e.fragmentBoundary)}}confirmation(e,t){let n=this.confirmations.get(e);if(n?.transaction===t)return n.displayed;let i=this.state.display.handIsland(t);return this.confirmations.set(e,{transaction:t,displayed:i}),i}currentTransaction(){let e=this.state.activeUpdate;return this.state.navigationBindingReplay&&null!==e&&this.state.isCurrent(e)?e:null}},Tl="payload-live-preview",Cl=Symbol.for("payload-live-preview.trusted-types"),Rl=new Set(["open","value","checked","selected"]),$l="__payloadLivePreviewDeprecationsWarned",Fl=new Set,Nl="data-payload-",Ml=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"]),El=new Set(["input","button","textarea","select","option","label"]),Ol=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),Ll=new Set(["id","class","lang","dir","title","role","tabindex"]),xl="aria-",Pl="data-",Ul="data-payload-",Il={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"])},jl=new Set(["href","src","cite","poster"]),Wl=6,Bl=1,Dl=8,_l=(Error,new Set(["id","name","data-payload-key","data-payload-morph","data-payload-nested-key","data-payload-nested-template"])),zl="strict",Vl=(Object.freeze({allowedTags:Ml,removeCompletely:Ol,globalAttributes:Ll,attributesByTag:Il,urlAttributes:jl}),Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"})),ql=/[&<>"\'/`=]/g,Hl=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),Gl=/[&<>"\']/g,Kl=/\\{\\{([\\s\\S]*?)\\}\\}/g,Jl="data-payload-",Xl=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],Ql=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],Zl=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\\b/gi,Yl=64,ea=new Map,ta="data-payload-key",na="data-payload-nested-key",ia="data-payload-nested-template",ra=class{constructor(e,t,n){ei(this,"deps",e);ei(this,"state",t);ei(this,"host",n)}planFragments(e,t){let{deps:n,state:i}=this,r=n.strategies.fragment;if(void 0===r)return null;let l=new Set(r.plan(n.root,e));for(let e of i.fragmentsOwed)n.root.contains(e)?l.add(e):i.fragmentsOwed.delete(e);return rn(r,[...l].filter(e=>ln(e,t)),t)}escalateUnfaithful(e,t,n,i){if(e.routeRefreshed){this.kept(e,n);return}let{fragment:r,route:l}=this.deps.strategies,a=void 0===r?void 0:function(e){let t=[];for(let n of e){let e=n.fragmentBoundary;if(void 0===e)return;t.includes(e)||t.push(e)}return t}(n),s=void 0===a||a.every(e=>ln(e,i))?a:void 0;void 0===r||void 0===s?void 0!==l?(this.state.escalatedCount+=n.length,this.refreshRoute(e,t,l)):(this.warnEscalationUnavailable(n.length),this.kept(e,n)):(this.state.escalatedCount+=n.length,e.pendingFragments+=s.length,this.runFragments(e,t,rn(r,s,i)))}kept(e,t){for(let n of t)this.state.display.shortfall(e,{kind:"unfaithful",field:n.fieldName})}warnEscalationUnavailable(e){let{deps:t,state:n}=this;n.warnedEscalationUnavailable||(n.warnedEscalationUnavailable=!0,t.warn(`[live-preview] LP0808: onUnfaithfulPatch: \'escalate\' has nowhere to go: ${String(e)} field(s) fell short and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, or onUnfaithfulPatch: \'warn\' to keep the patch and say so.`))}hasUnboundChange(e,t){let{deps:n,state:i}=this;if(e.baseline||e.routeRefreshed)return!1;let r=function(e,t,n,i,r,l){let a=q(e,i,l),s=G(e,n,i,a),o=[];for(let e of t){if(zi.has(e))continue;let t=s(e);if("none"===t&&o.push(e),"below"!==t||void 0===r)continue;let i=H(e,n),{previous:l,next:u}=r;for(let{path:t}of V(i,l[e],u[e],a))o.push(t)}return o}(n.cache,e.touched,e.locale,t,function(e,t,n){return"declared"===e&&void 0!==t&&void 0!==n?{previous:t,next:n}:void 0}(n.subfieldCoverage,i.changes.previousFields,e.renderData?.fields),n.strategies),a=0;for(let e of r)l(i,e)&&(a+=1);let[s]=r;if(void 0===s)return!1;if("escalate"!==n.onUnfaithfulPatch||void 0===n.strategies.route){"escalate"===n.onUnfaithfulPatch&&this.warnEscalationUnavailable(r.length);for(let t of r)i.display.shortfall(e,{kind:"unbound",field:t});return!1}return n.log("route","LP0807",`field "${s}" has no binding; refreshing the route`),i.escalatedCount+=a,!0}plansRoute(e,t,n){let i=e=>!1===n||W(e,n);if(e.plan(this.deps.root,t,{inScope:e=>i(ge(e))}))return!0;for(let[e,n]of this.deps.cache.entries())if(t.has(e)&&n.some(e=>"route"===e.strategyKind&&i(e.owner)))return!0;return!1}async runFragments(e,t,n){let{deps:i,state:r}=this,l=new AbortController,a=new Set(n.boundaries);for(let e of a)r.fragmentsOwed.delete(e);r.fragmentControllers.set(l,a);let s=t=>{a.delete(t)&&(e.pendingFragments-=1)},o=()=>r.isCurrent(e)&&!l.signal.aborted,u=e=>function(e,t,n){if(t.isConnected)return t;let i,r=t.getAttribute(ji),l=t.getAttribute(Wi);for(let t of e.querySelectorAll(`[${ji}]`))if(t.getAttribute(ji)===r&&t.getAttribute(Wi)===l&&n(t)){if(void 0!==i)return;i=t}return i}(i.root,e,e=>ln(e,n.ownerKeys)),{emitter:d}=i,{message:c}=e,h=e.revision.revision,f=e.receivedAt,p={root:i.root,revision:h,receivedAt:f,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof c.collectionSlug?c.collectionSlug:void 0,globalSlug:"string"==typeof c.globalSlug?c.globalSlug:void 0,signal:l.signal,isCurrent:o,log:(e,t)=>{i.log("fragment",e,t)},morph:(e,t)=>{let n=o()?u(e):void 0;void 0!==n&&function(e,t,n){let i=e.ownerDocument.createElement("template");i.innerHTML=yt(t);let r=e.cloneNode(!1);r.append(i.content);let l=fe(e);wt(e,r,{keyAttributes:[ta],boundary:ae,retainBoundary:he}),function(e){for(let t of e)t.isConnected||ur.has(t)||(ur.add(t),t.dispatchEvent(new CustomEvent("astro:unmount")))}(l);let a=new Set(l);for(let t of fe(e)){let e=a.has(t)?void 0:pe(t);void 0!==e&&n(t,e)}}(n,t,(e,t)=>{this.warnIslandStart(e,t)})},patch:i=>{let r=u(i);void 0!==r&&(r!==i&&this.host.rebuildCache(),this.patchFallback(e,t,r,n.ownerKeys,o))},rendered:(e,t,n)=>{s(e);let i=u(e)??e;d.emitWhile("fragmentRender",{element:i,id:t,key:n,status:"rendered",revision:h,receivedAt:f},o)},failed:(t,n,l,a,c)=>{s(t);let p=u(t)??t;r.display.shortfall(e,{kind:"fragment",id:n,key:l,code:a});let g=`fragment "${n}" fell back to patch: ${c}`;i.log("fragment",a,g),d.emitWhile("error",{error:new Error(g),context:"fragment",code:a},o),d.emitWhile("fragmentRender",{element:p,id:n,key:l,status:"failed",code:a,revision:h,receivedAt:f},o)}},g={rendered:0,failed:0,superseded:0};try{g=await n.strategy.render(p,n.boundaries)}catch(t){if(i.log("fragment","LP0801",t),o()){for(let t of n.boundaries)p.patch(t),r.display.shortfall(e,ne(t));g={rendered:0,failed:n.boundaries.length,superseded:0}}}r.fragmentStats.rendered+=g.rendered,r.fragmentStats.failed+=g.failed,r.fragmentStats.superseded+=g.superseded,r.fragmentControllers.delete(l);for(let e of a)s(e);o()&&(g.rendered>0&&this.host.restoreGuesses(e,t),0===e.pendingFragments&&0===i.scheduler.pendingCount&&r.complete(e),this.host.revealPending(e),o()&&(0===g.rendered||0===d.listenerCount("afterUpdate")||d.emitWhile("afterUpdate",{data:t,updatedCount:g.rendered,durationMs:Date.now()-f,revision:h,receivedAt:f,source:"fragment"},o)))}async refreshRoute(e,t,n){let{deps:i,state:r}=this;e.routeRefreshed?(r.routeStats.loopStopped+=1,i.log("route","LP0805",`revision ${String(e.revision.revision)} asked for a second refresh`)):(e.routeRefreshed=!0,await this.runRoute(e,t,n).catch(e=>{this.routeFailed(e)}))}routeFailed(e){this.deps.log("route refresh failed:",e)}armRouteRetry(e,t,n,i){let{state:r}=this;null!==r.routeRetry&&clearTimeout(r.routeRetry),r.routeRetry=setTimeout(()=>{r.routeRetry=null,r.isCurrent(e)&&this.runRoute(e,t,n).catch(e=>{this.routeFailed(e)})},i)}async runRoute(e,t,n){let{deps:i,state:r}=this,l=r.routeStats,a=new AbortController;r.routeController?.abort(),r.routeController=a;let s,o=()=>!a.signal.aborted;try{s=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:a.signal,isCurrent:o,log:(e,t)=>{i.log("route",e,t)},retryAfter:i=>{this.armRouteRetry(e,t,n,i)}})}catch(e){i.log("route","LP0801",e),s="failed"}if(!o())return;r.routeController=null;let u=r.activeUpdate;if(null===u)return;let d=u.renderData,c=()=>r.isCurrent(u);if("partial"===s?r.display.shortfall(u,{kind:"route-saved"}):("failed"===s||"superseded"===s||"refused"===s&&null===r.routeRetry)&&r.display.shortfall(u,{kind:"route-failed",outcome:s}),"refreshed"!==s&&"partial"!==s)"failed"===s?l.failed+=1:"refused"===s&&(l.refused+=1),void 0!==d&&this.host.reapply(u,d);else{if(l.refreshes+=1,"partial"===s&&(l.partial+=1),r.lastAppliedIdentity=new WeakMap,void 0!==d&&this.host.restoreGuesses(u,d),this.host.rebuildCache(),void 0===d||!c())return;this.host.reapply(u,d),i.emitter.listenerCount("afterUpdate")>0&&i.emitter.emitWhile("afterUpdate",{data:d,updatedCount:i.cache.elementCount,durationMs:Date.now()-u.receivedAt,revision:u.revision.revision,receivedAt:u.receivedAt,source:"route"},c)}}warnIslandStart(e,t){if(this.state.warnedIslandStart)return;this.state.warnedIslandStart=!0;let n="element"===t?"<astro-island>":`client:${e.getAttribute("client")??""}`;this.deps.warn(`[live-preview] LP0809: a fragment island cannot start: this page never loaded ${n}; render one on the page`)}warnFragmentFallback(e){!function(e,t,n){t.warnedFragmentFallback||(t.warnedFragmentFallback=!0,e.warn(`[live-preview] LP0806: "${n.fieldName}" asks for the fragment strategy but no handler is configured; patching instead`))}(this.deps,this.state,e)}warnUnsupportedStrategy(e){!function(e,t,n){t.warnedStrategy.has(n.element)||(t.warnedStrategy.add(n.element),e.warn(`[live-preview] LP0407: "${n.fieldName}" asks for strategy "${String(n.strategy)}"; only patch, fragment and route exist`))}(this.deps,this.state,e)}patchFallback(e,t,n,i,r){if(r())for(let[l,a]of this.deps.cache.entries())for(let s of a){if(s.fragmentBoundary!==n||!1!==i&&!W(s.owner,i))continue;let a=ct(t.fields,s,l,e.locale);void 0===a||!r()||this.deps.scheduler.schedule({target:s,value:this.host.transform(s,a,t.fields,r),allFields:t.fields,revision:e.revision,data:t})}}},la=new Set,aa={kind:"merge"},sa=class{constructor(e,t,n){ei(this,"deps",e);ei(this,"state",t);ei(this,"strategies");ei(this,"navigationReplay");t.changes.keepValues="declared"===e.subfieldCoverage,t.display.host=function(e,t){return{outstanding:n=>!n.completed||n.pendingFragments>0||null!==t.routeController||null!==t.routeRetry||e.scheduler.pendingCount>0,report:t=>{"partial"===t.state&&e.a11y?.announcePartial(),e.emitter.emit("revisionDisplay",t)},failed:t=>{e.log("revision display failed:",t)}}}(e,t),this.strategies=new ra(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,i,r)=>an(e,t,n,i,r),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}}),this.navigationReplay=new kl(e,t,{schedule:(e,t,n)=>{this.scheduleAllFields(e,t,n)}})}handleUpdate(e,t,n){let{deps:i,state:r}=this;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);let l=e.data;void 0!==l?void 0!==n&&this.acceptDataUpdate(e,l,t,n,!0):void 0!==e.protocolVersion&&r.protocol.applyVersion(e.protocolVersion,i.log)}handleReplay(e,t,n){let i=e.data;void 0!==i&&this.acceptDataUpdate(e,i,t,n,!1)}reapplyNavigationBindings(e){this.navigationReplay.reapplyBindings(e)}reapplyNavigationIslands(e,t=!1){this.navigationReplay.reapplyIslands(e,t)}acceptDataUpdate(e,t,n,i,r){let{deps:l,state:a}=this,s=r?a.relationships.inspect(e):null,o="string"==typeof e.locale?e.locale:a.locale,u=a.schema,d=a.schemaIndex;Array.isArray(e.fieldSchemaJSON)&&(u=e.fieldSchemaJSON,d=function(e,t=""){let n=new Map;return A(e,t,n,!1),A(e,t,n,!0),n}(e.fieldSchemaJSON));let c=a.activeUpdate;if(!a.isRunning()||null!==c&&c.revision.revision>i.revision)return;let h=null===s?null:a.relationships.commit(s),f=c,p={revision:i,message:e,rawData:t,locale:o,schema:u,schemaIndex:d,receivedAt:Date.now(),forceRender:null!==h||Y(f),countsAsUpdate:r,renderData:void 0,fragmentBoundariesRun:new WeakSet,touched:new Set,baseline:!1,invalidated:new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1};a.locale=o,a.schema=u,a.schemaIndex=d,null!==f&&!f.completed&&f.countsAsUpdate&&(a.supersededCount+=1),a.activeUpdate=p,r&&(a.updateCount+=1),a.display.begin(p,i.revision),a.isCurrent(p)&&(l.scheduler.acceptRevision(i),a.isCurrent(p)&&(a.supersedeStrategies(),a.isCurrent(p)&&(null!==h&&(l.emitter.emitWhile("relationshipUpdate",{detail:h,timestamp:Date.now()},()=>a.isCurrent(p)),!a.isCurrent(p))||r&&void 0!==e.protocolVersion&&(a.protocol.applyVersion(e.protocolVersion,l.log),!a.isCurrent(p))||r&&l.connection.markConnected()&&(l.a11y?.announceConnected(),l.emitter.emit("connect",{origin:n,timestamp:Date.now()}),!a.isCurrent(p)||(l.log("connection","disconnected","\\u2192","connected"),!a.isCurrent(p)))||this.processUpdate(p).catch(e=>{l.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 r=this.dataFor(e,i);t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:r,revision:e.revision.revision,receivedAt:e.receivedAt,source:"patch",cancel:()=>{e.cancelled=!0,t.scheduler.cancelRevision(e.revision)}},()=>!e.cancelled&&n.isCurrent(e))||e.cancelled||!n.isCurrent(e))||this.applyFields(e,r,!1)}dataFor(e,t){let{message:n}=e;return{fields:t,...void 0!==e.schema?{schema:e.schema}:{},..."string"==typeof n.globalSlug?{globalSlug:n.globalSlug}:{},..."string"==typeof n.collectionSlug?{collectionSlug:n.collectionSlug}:{},...void 0!==e.locale?{locale:e.locale}:{}}}applyFields(e,t,n){let{deps:i,state:r}=this;if(!r.isCurrent(e))return;if(r.changes.isBaseline&&!n&&"off"!==i.autoBind){{let n=ft(i,r,e,t.fields);!function(e,t,n,i,r,l){if(!l())return 0;let a=performance.now(),s=at(e.root),o=Ze(n,i);if(!l())return 0;let u=null===s?[]:lt(s,o);if(!l())return 0;let d=ot(e,u,r,"on the first message",l);if(!l())return 0;let c=function(e,t){let n=new Set;for(let{fieldName:e,stamps:i}of t){n.add(e);for(let e of[fr,gr]){let t=i[e];void 0!==t&&n.add(t)}}let i=new Map;for(let[t,r]of e)null!==r&&n.has(r.field)&&i.set(t,r);return{fields:n,values:i}}(o,d),h=performance.now()-a;l()&&(t.autoBindGuesses=c,t.autoBindSearchMs=h,d.length)}(i,r,t.fields,e.locale,n,()=>r.isCurrent(e))}if(!r.isCurrent(e))return}let l=re(i.dependencies,i.cache.dependencyMap());if(!r.isCurrent(e))return;let a=r.changes.diff(t.fields,l,()=>r.isCurrent(e));if(null===a)return;let s=!n&&r.navigationReplayPending;s&&(r.navigationReplayPending=!1,r.navigationBindingReplay=!0),e.baseline=a.baseline&&!s,e.invalidated=n?la:a.invalidated,e.touched=n?la:new Set([...a.changed,...a.invalidated]),e.renderData=t,this.scheduleAllFields(e,t)}async resolveIncomingFields(e){let{deps:t,state:n}=this,i=e.rawData;if(null===t.merger)return i;let r=n.merges.decide(t,e);if(!r.merge)return r.fields;let{message:l}=e,a=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:l.collectionSlug,globalSlug:l.globalSlug,data:i,...void 0===e.schema?{}:{schema:e.schema},locale:e.locale});if(!a.leading)return this.applyMerged(e,a.result).catch(e=>{t.log("update failed:",e)}),r.fields;let s=await a.result;return n.isCurrent(e)?"merged"===s.status?(n.merges.recordMerged(s.doc,e.locale),s.doc):"superseded"===s.status?null:(n.display.shortfall(e,aa),r.fields):null}async applyMerged(e,t){let{state:n}=this,i=await t;"unavailable"===i.status&&n.display.shortfall(e,aa),"merged"===i.status&&n.isCurrent(e)&&(n.merges.recordMerged(i.doc,e.locale),this.applyFields(e,this.dataFor(e,i.doc),!0))}scheduleAllFields(e,t,n){let{deps:i,state:r}=this;if(!r.isCurrent(e))return;let l=void 0!==n,a=()=>r.isCurrent(e),s=ft(i,r,e,t.fields);if(!a())return;let{touched:o}=e,u=i.strategies.route;if(l&&void 0!==u&&!e.routeRefreshed&&this.navigationReplay.hasLateRouteBinding(n,s,e,t)){a()&&this.strategies.refreshRoute(e,t,u);return}let d=!l&&this.strategies.hasUnboundChange(e,s),c=r.routeRefreshOwed;if(!l&&void 0!==u&&!e.routeRefreshed&&(d||c||this.strategies.plansRoute(u,o,s))&&a()){r.routeRefreshOwed=!1,this.strategies.refreshRoute(e,t,u);return}let h=l?this.navigationReplay.fieldsForElements(n,o):o,f=this.navigationReplay.unrunFragmentPlan(e,this.strategies.planFragments(h,s),n);if(!a())return;let p=i.skipUnchanged,g=0;for(let[o,u]of i.cache.entries()){if(!a())return;for(let d of u){if(void 0!==n&&!n.has(d.element)||!1!==s&&!W(d.owner,s))continue;if(!0===f?.covers(d)){if(i.revealEditedField){let n=ct(t.fields,d,o,e.locale);r.revealLedger.note(e,d,n)}continue}let u=d.strategyKind??P(d.element)??"unknown";if("unknown"===u){this.strategies.warnUnsupportedStrategy(d);continue}"fragment"===u&&null===f&&this.strategies.warnFragmentFallback(d);let c=ct(t.fields,d,o,e.locale);if(void 0===c){r.absentFields.add(o);continue}if(!l&&i.revealEditedField&&r.revealLedger.note(e,d,c),!a())return;let h=an(i,d,c,t.fields,a);if(!a())return;let m=p?ht(d,h,t.fields,e.locale):void 0,v=r.lastAppliedIdentity.get(d.element);if(!e.forceRender&&i.skipUnchanged&&void 0!==m&&v===m&&!e.invalidated.has(o)){r.skippedUnchangedCount+=1;continue}let y={target:d,value:h,allFields:t.fields,revision:e.revision,...l?{}:{data:t},valueIdentity:m};i.scheduler.schedule(y),g+=1}}if(l||function(e,t,n,i,r){let{cache:l,strategies:a}=e,s={cache:l,warned:t,warn:e.warn};if(0===l.fieldCount||!1!==r&&!function(e,t){for(let n of e.values())if(W(n.owner,t))return!0;return!1}(l,r))return;let o=function(e,t,n,i){let r=G(e,t,n,q(e,n,i));return e=>"none"!==r(e)}(l,i,r,a);for(let[e,t]of Object.entries(n)){if(zi.has(e))continue;if(mt(t)){gt(s,o,e,i,t);continue}if(!vt(t)||o(e))continue;let n=H(e,i);for(let[e,r]of Object.entries(t))!mt(r)||zi.has(e)||gt(s,o,`${n}.${e}`,i,r)}if("declared"!==e.subfieldCoverage)return;let u=function(e,t,n,i,r){let l=q(e,i,r),a=G(e,n,i,l),s=[];for(let[e,i]of Object.entries(t)){if(zi.has(e)||"below"!==a(e))continue;let t=H(e,n);s.push(...V(t,void 0,i,l))}return s}(l,n,i,r,a);for(let{path:e,value:t}of u)if(mt(t)&&gt(s,o,e,i,t),vt(t))for(let[n,r]of Object.entries(t))mt(r)&&gt(s,o,`${e}.${n}`,i,r)}(i,r.warnedOrphanFields,t.fields,e.locale,s),a()){if(null!==f&&f.boundaries.length>0){for(let t of f.boundaries)e.fragmentBoundariesRun.add(t);e.pendingFragments+=f.boundaries.length,this.strategies.runFragments(e,t,f)}l||!a()||0===g&&(0===e.pendingFragments&&0===i.scheduler.pendingCount&&(r.complete(e),this.revealPending(e)),this.notifyIslands(e,t))}}notifyIslands(e,t){0!==e.touched.size&&this.navigationReplay.dispatchIslands(e,t,this.deps.cache.islands)}restoreGuesses(e,t){let{deps:n,state:i}=this;if("off"!==n.autoBind&&null!==i.autoBindGuesses){let r=ft(n,i,e,t.fields);!function(e,t,n,i,r,l){if(!l())return 0;let a=t.autoBindGuesses,s=at(e.root);if(null===a||0===a.fields.size||null===s)return 0;let o=new Map(a.values);for(let[e,t]of Ze(n,i)){if(null===t||!a.fields.has(t.field))continue;let n=o.get(e);void 0===n?o.set(e,t):n?.field!==t.field&&o.set(e,null)}if(!l())return 0;let u=lt(s,o);l()&&ot(e,u,r,"after a server render",l).length}(n,i,t.fields,e.locale,r,()=>i.isCurrent(e))}}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{revision:i,data:r}=e;if(void 0===i)return;let l=n.activeUpdate;if(null===l||!n.isCurrent(l)||!b(l.revision,i))return;n.display.deferred(l,e.deferred),0===l.pendingFragments&&n.complete(l);let a=()=>n.isCurrent(l)&&b(l.revision,i),s=r??l.renderData;if(this.revealPending(l),!a())return;let o=n.unfaithfulPatches;if(o.length>0){if(n.unfaithfulPatches=[],void 0!==s){let e=ft(t,n,l,s.fields);this.strategies.escalateUnfaithful(l,s,o,e)}if(!a())return}void 0!==r&&(e.applied>0&&t.a11y?.announceUpdate(e.applied),a()&&(this.notifyIslands(l,r),a()&&0!==e.applied&&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"},a)))}revealPending(e){let t=this.state.revealLedger.commit(e);if(void 0!==t)try{te(this.state.revealer,t)}catch(e){this.deps.log("reveal",e)}}revealField(e){let t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":te(this.state.revealer,t)}},oa=class{constructor(e,t){ei(this,"apply");ei(this,"debounceMs");ei(this,"maxWaitMs");ei(this,"isVisible");ei(this,"gateThresholdValue");ei(this,"gateDisabled");ei(this,"getCacheSize");ei(this,"onFlush");ei(this,"scheduleFrame");ei(this,"cancelFrame");ei(this,"pending",new Map);ei(this,"replay",new Map);ei(this,"activeFlushes",new Set);ei(this,"debounceTimer",null);ei(this,"debounceToken",0);ei(this,"deadlineTimer",null);ei(this,"frameHandle",null);ei(this,"frameFallback",null);ei(this,"frameToken",0);ei(this,"windowUntil",0);ei(this,"activeRevision",null);ei(this,"activeRevisionCancelled",!1);ei(this,"destroying",!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(this.destroying||void 0!==e.revision&&(this.activeRevisionCancelled||null===this.activeRevision||!b(e.revision,this.activeRevision)))return;let t=this.pending.get(e.target.element);t?(t.value=e.value,t.allFields=e.allFields,t.revision=e.revision,t.data=e.data,t.valueIdentity=e.valueIdentity):this.pending.set(e.target.element,{target:e.target,value:e.value,allFields:e.allFields,revision:e.revision,data:e.data,valueIdentity:e.valueIdentity}),this.armDebounce()}acceptRevision(e){this.destroying||null!==this.activeRevision&&b(e,this.activeRevision)||null!==this.activeRevision&&function(e,t){return e.generation!==t.generation?e.generation-t.generation:e.revision-t.revision}(e,this.activeRevision)<0||(this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1,this.cancelScheduledWork())}cancelRevision(e){null===this.activeRevision||!b(e,this.activeRevision)||(this.clearWork(),this.activeRevisionCancelled=!0,this.cancelScheduledWork())}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(){if(!this.destroying){this.destroying=!0;try{this.clearWork(),this.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0,this.cancelScheduledWork()}finally{this.destroying=!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=Date.now(),t=e>=this.windowUntil;if(this.windowUntil=e+this.debounceMs,t){this.requestFrame();return}let n=this.debounceToken+=1,i=this.debounceTimer;if(this.debounceTimer=null,null!==i&&clearTimeout(i),this.debounceToken!==n)return;let r=setTimeout(()=>{this.debounceToken===n&&(this.debounceTimer=null,this.pending.size>0&&this.requestFrame())},this.debounceMs);this.debounceToken===n&&(this.debounceTimer=r),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,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1,i=()=>{if(this.frameToken!==e||n)return;n=!0;let t=this.frameHandle;this.frameHandle=null,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.flush()},r=this.scheduleFrame(i);n||this.frameToken!==e||(this.frameHandle=r,this.frameFallback=setTimeout(i,100))}clearFrameFallback(){clearTimeout(this.frameFallback??void 0),this.frameFallback=null}flush(){let e=performance.now();this.clearDeadline();let t=this.gateActive,n=this.pending;this.pending=new Map;let i,r=0,l=[],a=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),a+=1;continue}this.replay.delete(e.target.element),this.didApply(e)&&(r+=1,l.push(e.target.fieldName))}}}finally{this.activeFlushes.delete(n)}let s=this.statsFor(i,r,a,performance.now()-e,l);return this.onFlush?.(s),s}isCurrent(e){return void 0===e.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&b(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||!function(e){return Ui.has(e)}(this.apply)}retargetBuffer(e,t){let n=e.get(t.element);if(void 0!==n){if(!ve(n.target,t)){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?.revision?{revision:e.revision}:{},...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(),this.clearFrameFallback(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}},ua=[0,500,1e3,2e3],da=class{constructor(e){ei(this,"deps");ei(this,"state",new er);ei(this,"pipeline");ei(this,"writer");ei(this,"rootSentinel",null);ei(this,"scope",null);ei(this,"closingSession",!1);ei(this,"observedRoot",null);ei(this,"replayRetainedOnStart",!1);let{emitter:r,renderers:l}=e,a=void 0===e.log?n:t(e.log),s=void 0===e.warn?si:t(e.warn),o=e.root??(typ','eof document<"u"?document:void 0);if(void 0===o)throw new Error("LivePreviewRuntime: no document; pass options.root");let u=new Pr({filter:e=>!function(e){let t=e;for(;null!==t;){if(oe(t))return!0;t=t.parentElement}return!1}(e)}),d=new Zr({onStructuralChange:()=>{this.rebuildCache()},onIslandHydrated:e=>{this.pipeline.reapplyNavigationIslands([e],!0)},onVisibilityChange:(e,t)=>{t&&c.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),c=new oa(E(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=>d.isVisible(e),getCacheSize:()=>u.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),h=new Ci(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onReplay:(e,t,n)=>{this.pipeline.handleReplay(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],a),r.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})`);r.emit("error",{error:e,context:"token",code:"LP0502"})}("shape"===e||"type"===e)&&!this.state.warnedProtocolShape&&(this.state.warnedProtocolShape=!0,s(`[live-preview] LP0503: ${t} posted a message this runtime does not recognise (${"type"===e?"unknown message type":"unexpected shape"}); it was ignored. A newer Payload or a custom sender: check that the versions match.`)),"source"===e&&!this.state.warnedForeignSource&&(this.state.warnedForeignSource=!0,s(`[live-preview] LP0501: a message from ${t} was ignored because it did not come from the window that framed or opened this page. \\`eventSourcePolicy\\` is \'parent-or-opener\' by default since 2.0, where 1.x accepted any window on a trusted origin. Set \\`eventSourcePolicy: \'any\'\\` if the admin posts from elsewhere.`)),a("LP0501 message rejected:",e,t)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),f=e.dataMerge;this.deps={emitter:r,cache:u,observers:d,scheduler:c,bus:h,connection:new fl,heartbeat:new hl({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:l,resolveRenderer:e.resolveRenderer??(e=>l[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,root:o,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??S,onHeartbeatTimeout:e.onHeartbeatTimeout,log:a,warn:s,a11y:w(e),serverURL:f?.serverURL,merger:void 0===f?null:new qr({serverURL:f.serverURL,...void 0!==f.apiRoute?{apiRoute:f.apiRoute}:{},...void 0!==f.depth?{depth:f.depth}:{},...void 0!==f.fetchFn?{fetchFn:f.fetchFn}:{},log:a}),mergeWindowMs:e.debounceMs??50,scopeBindingsByOwner:!0===e.scopeBindingsByOwner,subfieldCoverage:e.subfieldCoverage??"descendant",lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:i(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new tr(this.deps,this.state),this.pipeline=new sa(this.deps,this.state,()=>{this.rebuildCache()})}start(){let{state:e}=this;if(e.isRunning()||this.closingSession)return!1;e.suspended&&(this.replayRetainedOnStart=!0),e.started=!0,e.suspended=!1,this.openScope();try{return function(e){"react"===e.hydration?We():"vue"===e.hydration&&qe();let{root:t}=e;if(!Ke(t)||"loading"!==t.readyState){He(e);return}let n=()=>{e.isRunning()&&e.later(()=>{He(e)})};t.addEventListener("DOMContentLoaded",n,{once:!0}),e.defer(()=>{t.removeEventListener("DOMContentLoaded",n)})}(this.startupHost()),!0}catch(e){throw this.rollbackFailedStart(),e}}startupHost(){let{state:e,deps:t}=this;return{root:t.root,hydration:t.hydration,isRunning:()=>e.isRunning(),defer:t=>{e.deferredStart=t,this.scope?.own(()=>{e.deferredStart===t&&(e.deferredStart=null,t())})},later:t=>{e.deferredStart=null;try{t()}catch(e){this.rollbackFailedStart(),this.reportError(e,"startup","LP0605")}},hydrated:t=>{e.hydration=t},warn:t.warn,startNow:()=>{this.startNow()}}}startNow(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=Ke(t.root)?Je(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()))return;let i=this.replayRetainedOnStart;this.replayRetainedOnStart=!1;let r=i&&t.heartbeat.resume();if(e.isRunning()&&(!i||r||(e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=new WeakMap,e.changes.reset(),e.navigationReplayPending=!0,t.bus.replayLastAccepted()||(e.navigationReplayPending=!1),e.isRunning())))for(let n of ua){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,this.replayRetainedOnStart=!1,t.bus.forgetLastAccepted(),n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}openScope(){let{state:e,deps:t}=this,n=new Yr(t.log);n.own(()=>{t.merger?.destroy(),e.merges.destroy()}),n.own(()=>{t.scheduler.destroy()}),n.own(()=>{t.observers.stop()}),n.own(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),n.own(()=>{e.abortStrategies()}),n.own(()=>{t.bus.detach()}),n.own(()=>{t.heartbeat.stop()}),n.own(()=>{for(let t of e.readyTimers)clearTimeout(t);e.readyTimers.length=0}),this.scope=n}release(){let{state:e,deps:t}=this;e.display.end(),e.activeUpdate=null,e.navigationBindingReplay=!1,e.started=!1;let n=this.scope;this.scope=null,this.closingSession=!0;try{n?.close()}finally{this.closingSession=!1}return t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release();try{this.deps.a11y?.detach()}catch(e){this.deps.log("runtime cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}navigationCommit(){let{state:e,deps:t}=this;!e.isRunning()||null!==e.deferredStart||(this.cancelActiveUpdate(!0),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!0),e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=new WeakMap,e.changes.reset(),e.isRunning()&&(t.bus.advanceGeneration(),e.navigationReplayPending=!0,this.followReplacedRoot()||this.rebuildCache(),e.isRunning()&&(t.bus.replayLastAccepted(),e.isRunning()&&this.sendReadyAfterStart())))}watchRootReplacement(){let{root:e}=this.deps;!Ke(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()||!Ke(e))return!1;let t=Je(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,a=t.lastFlush,s=[],o=new Set,u=[];for(let[e,t]of n.entries()){s.push(e);for(let n of t)void 0!==n.owner&&o.add(n.owner),void 0!==n.guessed&&u.push({field:e,matched:n.guessed,attribute:n.targetAttribute??("IMG"===n.element.tagName?"src":void 0)})}return{version:Hr,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:Pe(r.observed).name},revisions:{accepted:t.updateCount,superseded:t.supersededCount,completed:t.completedCount,skippedUnchanged:t.skippedUnchangedCount,active:null===l?void 0:l.revision.revision,display:t.display.snapshot()},bindings:{elements:n.elementCount,fields:n.fieldCount,fieldNames:s.sort(),absentFields:[...t.absentFields].sort(),orphanFields:[...t.warnedOrphanFields].sort(),ownerScoped:e.scopeBindingsByOwner,owners:[...o].sort(),guessed:u.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:e.autoBind,searchMs:t.autoBindSearchMs}},route:{handler:void 0!==e.strategies.route,...t.routeStats},fidelity:{mode:e.onUnfaithfulPatch,canEscalate:void 0!==e.strategies.fragment||void 0!==e.strategies.route,unfaithful:t.unfaithfulCount,escalated:t.escalatedCount,fields:[...t.unfaithfulFields].sort()},hydration:{mode:e.hydration??"off",state:t.hydration},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===a?void 0:{applied:a.applied,appliedFields:a.appliedFields,deferred:a.deferred,durationMs:a.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,i=t.cache.islandOwners,r=new Set(t.cache.navigationReplayRoots);for(let e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),!e.isRunning())return;let l=new Set(t.cache.navigationReplayRoots.filter(e=>!r.has(e)));for(let e of t.cache.values()){let i=n.get(e.element);void 0!==i&&ve(i,e)?t.scheduler.retarget(e):(t.scheduler.forget(e.element),l.add(e.element)),n.delete(e.element)}for(let e of n.values())t.scheduler.forget(e.element);l.size>0&&this.pipeline.reapplyNavigationBindings(l);let a=t.cache.islands.filter(e=>!i.has(e)||t.scopeBindingsByOwner&&i.get(e)!==t.cache.islandOwners.get(e));a.length>0&&this.pipeline.reapplyNavigationIslands(a)}onHeartbeatTimeout(){let{state:e,deps:t}=this;if(!e.isRunning()||(this.cancelActiveUpdate(!1),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!1),!e.isRunning()))return;t.bus.advanceGeneration(),t.bus.forgetLastAccepted(),e.navigationBindingReplay=!1;let n=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}e.isRunning()&&(n&&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())}cancelActiveUpdate(e){let{state:t,deps:n}=this,i=t.activeUpdate;t.display.end(),t.activeUpdate=null,null!==i&&(i.cancelled=!0,n.scheduler.cancelRevision(i.revision),e&&!i.completed&&i.countsAsUpdate&&(t.supersededCount+=1))}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}},ca=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,ha=/^https?:\\/\\/[^/?#\\s]+$/i,fa=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],pa=class{constructor(e={}){ii(this,ga);let t=new Set;for(let n of e.additionalOrigins??[]){let e=on(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){let t=e.referrer??(typ','eof 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(!(typ','eof process>"u"))return"production"}();if(void 0!==e)return"production"!==e;if(typ','eof window<"u"){let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}());ri(this,ga,[t,n,i,void 0!==n,void 0])}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==ni(this,ga)[4]?e===ni(this,ga)[4]:!!(ni(this,ga)[0].has(e)||0===ni(this,ga)[0].size&&void 0!==ni(this,ga)[1]&&e===ni(this,ga)[1]||ni(this,ga)[2]&&ca.test(e)))}lockOrigin(e){return!!this.matches(e)&&(ni(this,ga)[4]=e,!0)}unlockOrigin(){let e=ni(this,ga)[4];return ni(this,ga)[4]=void 0,e}get lockedOrigin(){return ni(this,ga)[4]}enumerate(){if(void 0!==ni(this,ga)[4])return[ni(this,ga)[4]];let e=new Set(ni(this,ga)[0]);if(0===ni(this,ga)[0].size&&void 0!==ni(this,ga)[1]&&e.add(ni(this,ga)[1]),ni(this,ga)[2])for(let t of fa)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return ni(this,ga)[3]}get isProductionUnconfigured(){return!(!sn()||ni(this,ga)[0].size>0||ni(this,ga)[2]||void 0!==ni(this,ga)[1])}get isReferrerOnlyTrust(){return!(ni(this,ga)[0].size>0||ni(this,ga)[2])&&void 0!==ni(this,ga)[1]}},ga=new WeakMap,ma="astro:page-load",va="astro:after-swap",ya={1:"left",2:"center",3:"right",4:"justify"},ba=new Set(["left","center","right","justify","start","end"]),wa=new Set(["h1","h2","h3","h4","h5","h6"]),Sa=\' target="_blank" rel="noopener noreferrer"\',Aa=(e,t)=>{let n=t.renderChildren(e.children??[]),i=fn(e.fields),r=function(e,t){if("internal"===t?.linkType)return function(e){let t=fn(fn(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="${Lt(e.title)}"`:"";return`<a href="${xt(r)}"${function(e,t,n){if(!0===t?.newTab||N(n))return Sa;let i="string"==typeof e.target?e.target:"";return""===i?"":"_blank"===i?Sa:` target="${Lt(i)}"`}(e,i,r)}${l}>${n}</a>`},ka=new Map,Ta=".lp-block:empty,.lp-inline-block:empty",Ca={text:e=>{let t=Lt("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${cn(e)}${hn(e)}>${n}</p>`},heading:(e,t)=>{let n="string"==typeof e.tag?e.tag.toLowerCase():"h2",i=wa.has(n)?n:"h2",r=t.renderChildren(e.children??[]);return`<${i}${cn(e)}${hn(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"\':"",a=t.renderChildren(e.children??[]);return`<${i}${cn(e)}${hn(e)}${r}${l}>${a}</${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"}"${hn(e)}>${n}</li>`;let i="number"==typeof e.value?` value="${Lt(String(e.value))}"`:"";return`<li${cn(e)}${hn(e)}${i}>${n}</li>`},link:Aa,autolink:Aa,quote:(e,t)=>{let n=t.renderChildren(e.children??[]);return`<blockquote${cn(e)}${hn(e)}>${n}</blockquote>`},code:e=>{let t=mn("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${Lt(bn(e))}</code></pre>`},"code-highlight":e=>{let t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${mn(e.highlightType)}"`:""}>${Lt(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\\t",upload:e=>{let t=pn(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${wn(e)}><source src="${xt(t)}"${Sn(e)}></video>`}(t,n):i.startsWith("audio/")?function(e,t){return`<audio controls><source src="${xt(t)}"${Sn(e)}></audio>`}(t,n):""===i||i.startsWith("image/")?function(e,t){let n="string"==typeof e.alt?Lt(e.alt):"";return`<img src="${xt(t)}" alt="${n}"${wn(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){let n="string"==typeof e.filename?Lt(e.filename):Lt(t);return`<a href="${xt(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{let t="string"==typeof e.relationTo?e.relationTo:"",n=fn(e.value),i=Lt((n&&yn(n))??`#${t}`),r=mn(t),l=""===r?\' class="lp-relation"\':` class="lp-relation lp-relation--${r}"`,a=n?.url;return"string"==typeof a&&F(a)?`<a href="${xt(a)}"${l}>${i}</a>`:`<span${l}>${i}</span>`},block:(e,t)=>kn(e,t,"div","lp-block"),inlineBlock:(e,t)=>kn(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${cn(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"\':""}${Tn("colspan",e.colSpan)}${Tn("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${i}>`}},Ra=new Map,$a=!1,Fa="data-payload-text",Na=new Set,Ma=new Set,Ea=new Set(["DIV","SECTION","ARTICLE"]),Oa={name:"richText",render:E((e,t,n)=>{let i=e.element;if(Bt(t)){i.textContent="";return}let r=n.sanitizerPolicy;if(void 0!==n.renderRichText){let l=n.renderRichText(t,{fieldName:e.fieldName,element:i,locale:n.locale});i.innerHTML=yt(Ft(l,r));return}if(Cn(t)){let l=new Map,a=Nn(i,Ft(function(e,t={}){if(!Cn(e))return"";let n=function(e){let t={renderChildren:e=>{let n="";for(let i of e)n+=Rn(i,t);return n},resolveAlignment:un,resolveIndent:dn,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==t.document?$t(n,{document:t.document}):!0===t.requireDocument||void 0!==Nt()?$t(n):(function(){if(!$a){$a=!0;try{console.warn(\'[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; pass { document } (linkedom, jsdom) per call. 3.0 throws here instead: opt in now with { requireDocument: true }. See "HTML sanitization" in docs/security.md.\')}catch{}}}(),n)}(t,{sanitize:!1,onUnrenderedBlock:(e,t)=>{l.set(t,e)}}),r));for(let[t,i]of a){let r=l.get(t);void 0!==r&&En(e,n,r,i)}return}if("string"!=typeof t)return!1;i.innerHTML=yt(Ft(t,r))})},La={name:"html",render(e,t,n){if(Bt(t)){e.element.textContent="";return}let i="string"==typeof t?t:Wt(t);e.element.innerHTML=yt(Ft(i,n.sanitizerPolicy))}},xa=new WeakSet,Pa=Ln("url"),Ua=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,Ia=Ln("email",function(e){let t=e.trim();return Ua.test(t)||!t.includes("@")?t:`mailto:${t}`}),ja=["src","srcset","sizes"],Wa={name:"image",render:E((e,t,n)=>{let i=e.element;if(Bt(t)){In(i);return}let r=void 0!==e.locale,{media:l,candidate:a}=function(e,t,n,i){let r=void 0!==e.srcField&&e.srcField.length>0?ut(n.allFields,e.srcField,n.locale,i):t,l=pn(r);return{media:l,candidate:void 0===l?r:l.url}}(e,t,n,r),s=On(i,e.fieldName,a,void 0===l?void 0:n.serverURL);if("none"===s.kind)return!1;if("unsafe"!==s.kind){if("IMG"===i.tagName){let t=i;Pn(t,s.url,l,n.serverURL);let a=function(e,t,n,i,r){if(void 0!==t&&t.length>0){let e=ut(n,t,i,r);return"string"==typeof e?e:void 0}return e?.alt}(l,e.altField,n.allFields,n.locale,r);void 0!==a&&(t.alt=a);return}i.style.backgroundImage=`url(\'${function(e){return e.replace(/[\'"()\\\\]/g,"\\\\$&")}(s.url)}\')`}else In(i)})},Ba={name:"upload",render:E((e,t,n)=>{let i=e.element;if(Bt(t)){jn(i);return}let r=pn(t);if(void 0===r)return!1;let l=On(i,e.fieldName,r.url,n.serverURL);if("none"===l.kind)return!1;if("unsafe"===l.kind){jn(i);return}let a=l.url;if("IMG"===i.tagName){let e=i;Pn(e,a,r,n.serverURL),void 0!==r.alt&&(e.alt=r.alt);return}if("A"===i.tagName){i.setAttribute("href",a),i.textContent=r.filename??a;return}let s=Lt(r.filename??a);i.innerHTML=yt(`<a href="${xt(a)}">${s}</a>`)})},Da={name:"relationship",render(e,t){let n=e.element;if(Bt(t))n.removeAttribute("href"),n.textContent="";else{if("A"===n.tagName&&!Array.isArray(t)){let i=On(n,e.fieldName,fn(t)?.url);"safe"===i.kind?n.setAttribute("href",i.url):"unsafe"===i.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(Wn).join(", "):Wn(t)}}},_a={name:"select",render(e,t,n){let i=e.element,r=Bt(t)?[]:function(e){return Array.isArray(e)?e.map(Wt):[Wt(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=fn(t);if(void 0!==n&&Wt(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)}},za=new Set(["","false","0","off","no"]),Va={name:"checkbox",render(e,t){let n=e.element,i=function(e){return"boolean"==typeof e?e:"string"==typeof e?!za.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}},qa=new Map,Ha=new Map,Ga=new Set(["short","medium","long","full"]),Ka=new Set(["short","medium","long","full"]),Ja=/^[A-Za-z]{3}$/u,Xa=/^[0-4]$/u,Qa=new WeakSet,Za={name:"date",render(e,t,n){let i=e.element;if(Bt(t)){"INPUT"===i.tagName?i.value="":(i.removeAttribute("datetime"),i.textContent="");return}let r="number"==typeof t?t:Wt(t),l=new Date(r),a=!Number.isNaN(l.getTime()),s=String(r);"INPUT"!==i.tagName?("TIME"===i.tagName&&i.setAttribute("datetime",a?l.toISOString():s),i.textContent=a?function(e,t,n){let i=t.locale??n.locale??o(),r=Vn("date",t.format,t.element,t.fieldName)??Ya;try{return function(e,t){let n=Bn(e,t);return Dt(Ha,n)??_t(Ha,n,new Intl.DateTimeFormat(e,t),64)}(i,r).format(e)}catch{return e.toISOString()}}(l,e,n):s):i.value=a?function(e,t){let n=`${String(t.getFullYear()).padStart(4,"0")}-${qn(t.getMonth()+1)}-${qn(t.getDate())}`,i=`${qn(t.getHours())}:${qn(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${i}`:"time"===e?i:t.toISOString()}(i.type,l):s}},Ya={dateStyle:"medium",timeStyle:"short"},es={name:"number",render(e,t,n){let i=e.element;if(Bt(t)){"INPUT"===i.tagName?i.value="":i.textContent="";return}let r="number"==typeof t?t:Number(Wt(t));Number.isNaN(r)?i.textContent=Wt(t):"INPUT"!==i.tagName?i.textContent=function(e,t,n){let i=t.locale??n.locale??o(),r=Vn("number",t.format,t.element,t.fieldName);try{return function(e,t){let n=Bn(e,t);return Dt(qa,n)??_t(qa,n,new Intl.NumberFormat(e,t),64)}(i,r).format(e)}catch{return String(e)}}(r,e,n):i.value=String(r)}},ts={name:"array",render:E((e,t,n)=>{let i=e.element;if(Bt(t)){i.textContent="";return}if(!Array.isArray(t))return!1;let r=e.arrayTemplate;if(void 0!==r&&r.length>0){let e=function(e,t){let n=Pt(t),i="";for(let r=0;r<t.length;r+=1)i+=Ut(e,t[r],r,Wt,n);return i}(r,t),l=n.sanitizerPolicy,a=zt(r),s=It(i);i.innerHTML=yt(Ft(e,l,a));for(let e of Array.from(i.children))jt(e,s);return}i.textContent=t.map(Wt).join(e.arraySeparator??", ")})},ns=new Map;!function(){if(typ','eof window>"u"||!sn()&&(typ','eof window>"u"||null==window.opener))return;let e=window.__livePreview,t=JSON.stringify(Qn());if(void 0!==e&&(void 0===e.configSignature||e.configSignature===t))return e.refresh(),e;let[n=[],r="",l="/api",a=1,s=!1,o=50,u=!0,d=0,c=!1,h=50,f="200px",p=!0,g=!1,m=!1,v=!0,y="parent-or-opener",b="strict",w,S=!1,A=!1,k,T,C="off",R,$,F=[],N="descendant"]=Qn(),M=function(e){let t=typeof __LIVE_PREVIEW_FRAGMENT__<"u"?__LIVE_PREVIEW_FRAGMENT__:void 0,n=t??(typeof __LIVE_PREVIEW_ROUTE__<"u"?__LIVE_PREVIEW_ROUTE__:void 0);if(void 0===n)return;let i=n.createRouteStrategy();return void 0===t||void 0===e||""===e?{route:i}:{fragment:t.createFragmentStrategy({endpoint:e}),route:i}}(w),E=new pa({additionalOrigins:n,enableReferrerDetection:!p,enableLocalhostMatching:!g});E.isProductionUnconfigured?si("[live-preview] LP0101: No trusted origin. Pass allowedOrigins to generateInlineScript() (or to the adapter) \\u2014 the runtime reads no environment variable in the browser."):E.isReferrerOnlyTrust&&si("[live-preview] LP0102: document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let O=new ui,L=function(){let e=[Oa,La,Pa,Ia,Wa,Ba,Da,_a,{..._a,name:"radio"},Va,Za,es,ts,{...ts,name:"blocks"}];return function(e=[]){let t={};for(let n of e)t[n.name]=n;for(let[e,n]of ns)t[e]=n;return Object.freeze(t)}([Fn("text"),Fn("textarea"),...e,Hn()])}(),x=new da({renderers:L,originMatcher:e=>E.matches(e),lockedOrigin:()=>E.lockedOrigin,readyTargets:()=>E.enumerate(),emitter:O,eventSourcePolicy:y,...""!==r?{dataMerge:{serverURL:r,apiRoute:l,depth:a}}:{},debounceMs:o,heartbeatMs:d,intersectionRootMargin:f,disableVisibilityGate:c,visibilityGateThreshold:h,enableA11y:u,scopeBindingsByOwner:m,subfieldCoverage:N,skipUnchanged:v,revealEditedField:S,onUnfaithfulPatch:i({onUnfaithfulPatch:T,onUnboundChange:k}),autoBind:C,...void 0!==R?{hydration:R}:{},sanitizerPolicy:b,...void 0!==M?{strategies:M}:{},onHeartbeatTimeout:()=>{E.unlockOrigin()},...s?{log:(...e)=>{oi("[live-preview]",...e)}}:{}});O.on("connect",e=>{E.lockOrigin(e.origin)}),x.start(),e?.destroy();let P=function(e,t={}){let n=t.windowTarget??globalThis.window,i=t.documentTarget??globalThis.document,r=[...new Set(t.softNavigationEvents??[])],l=()=>{e.suspend()},a=t=>{!0===t.persisted&&e.resume()},s=!1,o=()=>{s=!0},u=t=>{if(t.type===ma){if(!s)return;s=!1}void 0===e.refreshAfterNavigation?e.refreshCache():e.refreshAfterNavigation()},d=!1;n?.addEventListener("pagehide",l),n?.addEventListener("pageshow",a);for(let e of r)i?.addEventListener(e,u);let c=r.includes(ma);return c&&i?.addEventListener(va,o),()=>{if(!d){d=!0,n?.removeEventListener("pagehide",l),n?.removeEventListener("pageshow",a);for(let e of r)i?.removeEventListener(e,u);c&&i?.removeEventListener(va,o)}}}({suspend:()=>x.suspend(),resume:()=>x.start(),refreshCache:()=>{x.refreshCache()},refreshAfterNavigation:()=>{x.navigationCommit()}},{softNavigationEvents:F}),U=Object.freeze({version:Hr,configSignature:t,destroy:()=>{P(),x.destroy();let e=window;e.__livePreview===U&&delete e.__livePreview},refresh:()=>{x.refreshCache()},refreshAfterNavigation:()=>{x.navigationCommit()},enumerateOrigins:()=>E.enumerate(),inspect:()=>x.inspect()});try{Object.defineProperty(window,"__livePreview",{value:U,writable:!1,configurable:!0})}catch(e){throw P(),x.destroy(),e}}()})();'].join(""),u=/* @__PURE__ */['"use strict";var __LIVE_PREVIEW_FRAGMENT__=(()=>{var P=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var pe=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ge=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of me(t))!ye.call(e,o)&&o!==n&&P(e,o,{get:()=>t[o],enumerable:!(i=fe(t,o))||i.enumerable});return e};var he=e=>ge(P({},"__esModule",{value:!0}),e);var Ye={};pe(Ye,{createFragmentStrategy:()=>ce,createRouteStrategy:()=>ue});function k(e,t){let n=new AbortController,i=!1,o=()=>{n.abort()};e.addEventListener("abort",o,{once:!0});let r=setTimeout(()=>{i=!0,n.abort()},t);return{signal:n.signal,timedOut:()=>i,dispose:()=>{clearTimeout(r),e.removeEventListener("abort",o)}}}function R(e){return e instanceof Error?e.message:String(e)}var D="data-payload-island",Qe=`astro-island, [${D}]`,w="data-payload-owned",be="data-payload-morph";function F(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute(be)||z(e)||e.hasAttribute(w))return!0;let n=e.getAttribute("contenteditable");return n!==null&&n!=="false"}function Ee(e){return e.tagName.toLowerCase()==="astro-island"||e.hasAttribute(D)}function Se(e){return e.getAttribute(D)==="patch"}function z(e){return Ee(e)&&!Se(e)}function V(e){let t=e;for(;t!==null;){if(z(t))return!0;t=t.parentElement}return!1}var Re=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],v=new WeakMap,G=new WeakSet;function W(e){return e.tagName.toLowerCase()==="astro-island"}function q(e){let t="";for(let n of e.querySelectorAll("astro-slot, template[data-astro-template]")){if(n.parentElement?.closest("astro-island")!==e)continue;let i=n.getAttribute("name")??n.getAttribute("data-astro-template")??"";t+=`${i}\\0${n.innerHTML}\\0`}return t}function Ae(e){let t=e.ownerDocument.defaultView?.customElements.get("astro-island");return t!==void 0&&e instanceof t&&Array.isArray(t.observedAttributes)&&t.observedAttributes.includes("props")}function j(e,t){if(!W(e)||!W(t))return!0;let n=q(t);if(!(Re.every(r=>e.getAttribute(r)===t.getAttribute(r))&&(v.get(e)??q(e))===n&&(e.getAttribute("props")===t.getAttribute("props")||Ae(e))))return v.set(t,n),!1;v.set(e,n);let o=t.getAttribute("props");return o!==e.getAttribute("props")&&(e.setAttribute("ssr",""),o===null?e.removeAttribute("props"):e.setAttribute("props",o)),!0}function Y(e){return Array.from(e.querySelectorAll("astro-island"))}function X(e){for(let t of e)t.isConnected||G.has(t)||(G.add(t),t.dispatchEvent(new CustomEvent("astro:unmount")))}function O(e){if(e==null)return[];let t=new Set,n=[];for(let i of e.split(/[\\s,]+/)){let o=i.trim();o.length===0||t.has(o)||(t.add(o),n.push(o))}return n}var A="data-payload-fragment",I="data-payload-fragment-key";var Te="data-payload-depends";function _(e){let t=e.getAttribute(A);if(t===null||t.length===0)return null;let n=e.getAttribute(I);return{element:e,id:t,key:n===null||n.length===0?void 0:n,dependsOn:O(e.getAttribute(Te))}}function J(e,t){let n=[];for(let i of e.querySelectorAll(`[${A}]`)){let o=_(i);o===null||V(i)||o.dependsOn.length>0&&!o.dependsOn.some(r=>t.has(r))||n.push(o)}return n}var Q="x-payload-fragment-version";function B(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Z(e){if(!B(e))return null;let{html:t,boundary:n,revision:i,metadata:o}=e;return typeof t!="string"||!B(n)||typeof n.id!="string"||n.key!==void 0&&typeof n.key!="string"||typeof i!="number"||!B(o)||typeof o.renderedAt!="string"||typeof o.renderer!="string"?null:e}function ee(e){let t={};for(let[n,i]of Object.entries(e))i!==void 0&&(t[n]=i);return t}function L(e){return e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError")}function C(e){return e?.aborted===!0}function te(e){let t=0,n=[],i=()=>{let o=n.shift();o===void 0?t-=1:o.resume()};return async(o,r)=>{if(r!==void 0&&C(r))throw L(r);if(t<e)t+=1;else if(await new Promise((d,m)=>{let l=()=>{},u={resume:()=>{l(),d()}};if(n.push(u),r!==void 0){let s=()=>{let c=n.indexOf(u);c!==-1&&(n.splice(c,1),l(),m(L(r)))};l=()=>{r.removeEventListener("abort",s)},r.addEventListener("abort",s,{once:!0}),C(r)&&s()}}),r!==void 0&&C(r))throw i(),L(r);try{return await o()}finally{i()}}}var xe=5e3,ke=4,Fe=512*1024,T={status:"superseded"};function b(e,t){return{status:"failed",code:e,reason:t}}function Oe(e){let t=()=>{throw new TypeError(\'createFragmentStrategy: endpoint must be a same-origin path starting with "/"\')};if((typeof e!="string"||!e.startsWith("/")||e.startsWith("//")||e.includes("\\\\"))&&t(),typeof location<"u"){let n;try{n=new URL(e,location.href)}catch{n=void 0}n?.origin!==location.origin&&t()}return e}function Ie(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}async function Ne(e,t,n){let i=e.body;if(!Ie(i)){let u=await e.text();return new TextEncoder().encode(u).byteLength>t?null:u}let o=i.getReader(),r=()=>{o.cancel().catch(()=>{})};n.addEventListener("abort",r,{once:!0});let d=new TextDecoder,m="",l=0;try{for(;;){let{done:u,value:s}=await o.read();if(u)break;if(l+=s.byteLength,l>t)return r(),null;m+=d.decode(s,{stream:!0})}}finally{n.removeEventListener("abort",r),o.releaseLock()}return m+d.decode()}function ne(e){let t=Oe(e.endpoint),n=e.timeoutMs??xe,i=e.maxResponseBytes??Fe,o=te(Math.max(1,e.maxConcurrent??ke)),r=new Map,d=new WeakMap,m=0,l=s=>{let c=d.get(s);return c!==void 0?c:(m+=1,d.set(s,m),m)};async function u(s,c){let a=()=>s.signal.aborted;if(a())return T;let h=e.location??location,p=ee({fragment:c.id,key:c.key,route:h.pathname,search:h.search,revision:s.revision,locale:s.locale,collectionSlug:s.collectionSlug,globalSlug:s.globalSlug,fields:s.fields}),f=k(s.signal,n),y=E=>a()?T:f.timedOut()?b("LP0801",`timeout after ${String(n)} ms`):b("LP0801",R(E)),g,x=!1;try{try{g=await(e.fetch??fetch)(t,{method:"POST",credentials:"same-origin",headers:{...e.headers,accept:"application/json","content-type":"application/json",[Q]:String(1)},body:JSON.stringify(p),signal:f.signal})}catch(M){return y(M)}if(a())return T;if(g.status===401||g.status===403)return b("LP0803",`endpoint refused the preview (${String(g.status)})`);if(!g.ok)return b("LP0801",`endpoint answered ${String(g.status)}`);let E=g.headers.get("content-type")??"";if(!E.toLowerCase().startsWith("application/json"))return b("LP0802",`unexpected content type "${E}"`);if(Number(g.headers.get("content-length")??"0")>i)return b("LP0802","response exceeds the size limit");if(f.signal.aborted)return y(f.signal.reason);let N;try{x=!0,N=await Ne(g,i,f.signal)}catch(M){return y(M)}if(a())return T;if(f.timedOut())return b("LP0801",`timeout after ${String(n)} ms`);if(N===null)return b("LP0802","response exceeds the size limit");let $;try{$=JSON.parse(N)}catch{return b("LP0802","response is not JSON")}let S=Z($);return S===null?b("LP0802","response has the wrong shape"):S.boundary.id!==c.id||S.boundary.key!==c.key?b("LP0802","response is for another boundary"):S.revision!==s.revision?T:{status:"rendered",html:S.html,metadata:S.metadata}}finally{if(f.dispose(),g!==void 0&&!x)try{g.body?.cancel().catch(()=>{})}catch{}}}return(s,c)=>{let a=JSON.stringify([l(s.signal),c.id,c.key,s.revision]),h=r.get(a);if(h!==void 0)return h;let p=!1,f=o(()=>(p=!0,u(s,c)),s.signal).catch(g=>{if(!p&&s.signal.aborted)return T;throw g});r.set(a,f);let y=()=>{r.get(a)===f&&r.delete(a)};return f.then(y,y),f}}var Me=new Set(["open","value","checked","selected"]);function oe(e,t){for(let n of t.keyAttributes){let i=e.getAttribute(n);if(i!==null&&i.length>0)return`${n}=${i}`}}function H(e,t,n){if(!U(e,t))return t;let i=n.boundary??F,o=i(e),r=i(t);if(o||r)return!o||!r?t:n.retainBoundary?.(e,t)??!0?e:t;let d=Be(e);return Pe(e,t),n.retainChildrenOf?.(e,t)!==!0&&ve(e,t,n),Le(d),e}function Pe(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||Me.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)}function ve(e,t,n){let i=_e(e,n),o=new Set(i.values()),r=Array.from(e.childNodes).filter(c=>!o.has(c)),d=new Set,m=new Set,l=Array.from(t.childNodes),u=e.firstChild,s=0;for(let c=0;c<l.length;c+=1){let a=l[c],h=null,p=a instanceof Element?oe(a,n):void 0;if(p!==void 0&&m.has(p)&&(p=void 0),p!==void 0){m.add(p);let y=i.get(p);if(y!==void 0&&!d.has(y)&&(h=re(y,a,n)===y?y:null,h===null)){y.replaceWith(a),d.add(a),u=a.nextSibling;continue}}else{for(;s<r.length;){let y=r[s];if(s+=1,!d.has(y)){if(U(y,a)){h=re(y,a,n)===y?y:null,h===null&&(e.replaceChild(a,y),d.add(a),u=a.nextSibling);break}if(y instanceof Element){let g=l[c+1];if(!(a instanceof Element)||g!==void 0&&U(y,g)){s-=1;break}e.replaceChild(a,y),d.add(a),u=a.nextSibling;break}if(!(a instanceof Element)){e.replaceChild(a,y),d.add(a),u=a.nextSibling;break}}}if(h===null&&d.has(a))continue}let f=h??a;for(d.add(f);u!==null&&u!==f&&!d.has(u)&&De(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(let c of Array.from(e.childNodes))d.has(c)||c.remove()}function re(e,t,n){return e instanceof Element&&t instanceof Element?H(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function De(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function U(e,t){return e.nodeType!==t.nodeType?!1:e instanceof Element&&t instanceof Element?e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI:!0}function _e(e,t){let n=new Map,i;for(let o of Array.from(e.children)){let r=oe(o,t);if(r!==void 0){if(n.has(r)){i??(i=r.slice(r.indexOf("=")+1));continue}n.set(r,o)}}return i!==void 0&&t.onDuplicateKey?.(e,i),n}function Be(e){let t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement)||!e.contains(t))return null;let n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null;return{element:t,selection:n}}function Le(e){if(e===null)return;let{element:t,selection:n}=e;if(!(t.ownerDocument.activeElement===t||!t.isConnected))try{t.focus({preventScroll:!0});let[i,o]=n??[null,null];i!==null&&o!==null&&t.setSelectionRange(i,o)}catch{}}var ie="data-payload-key";var Ce="__livePreviewRouteRefresh";function Ue(){return typ','eof window>"u"?void 0:window}function ae(){return Ue()?.[Ce]}var le="data-payload-strategy",de="data-payload-field",He="data-payload-depends",Ke="x-payload-live-preview",$e=8e3,Ge="route refresh returned no promise; re-applied before the host committed (see LivePreviewRouteRefresh)",We=1e3;function qe(e){let t=e.getAttribute(le);return t!==null?t==="route":e.closest("head")!==null}function ze(e){let t=e.getAttribute(de),n=O(e.getAttribute(He));return t===null||t.length===0?n:[t,...n]}function se(e){return e.hasAttribute(w)?!1:e.tagName==="META"?e.hasAttribute("name")||e.hasAttribute("property"):e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"}function Ve(e,t){let n=Array.from(e.head.children).find(l=>l.tagName==="TITLE"),i=Array.from(t.head.children).find(l=>l.tagName==="TITLE");!n?.hasAttribute(w)&&!i?.hasAttribute(w)&&t.title!==e.title&&(e.title=t.title);let o=Array.from(e.head.children).filter(se),r=Array.from(t.head.children).filter(se),d=Math.min(o.length,r.length);o.slice(0,d).forEach((l,u)=>{let s=r[u];if(s===void 0)return;if(l.tagName===s.tagName){for(let a of Array.from(l.attributes))s.hasAttribute(a.name)||l.removeAttribute(a.name);for(let a of Array.from(s.attributes))l.getAttribute(a.name)!==a.value&&l.setAttribute(a.name,a.value);return}let c=e.importNode(s,!0);l.replaceWith(c),o[u]=c});let m=o.at(-1);for(let l of r.slice(o.length)){let u=e.importNode(l,!0);m===void 0?e.head.append(u):m.after(u),m=u}for(let l of o.slice(r.length))l.remove()}function ue(e={}){let t=e.timeoutMs??$e,n=e.minIntervalMs??We,i=-1/0,o=!1;return{plan(r,d,m){for(let l of r.querySelectorAll(`[${de}], [${le}="route"]`)){if(!qe(l)||m?.inScope(l)===!1)continue;let u=ze(l);if(u.length===0||u.some(s=>d.has(s)))return!0}return!1},async refresh(r){let d=Date.now(),m=n-(d-i);if(m>0)return r.retryAfter?.(m),r.log("LP0805",`route refresh for revision ${String(r.revision)} refused: the previous one was ${String(d-i)} ms ago`),"refused";i=d;let l=e.document??document,u=e.location??location,s=e.window??window,c=k(r.signal,t),a=h=>{if(r.signal.aborted)return"superseded";let p=c.timedOut()?`route refresh timed out after ${String(t)} ms`:R(h);return r.log("LP0801",p),"failed"};try{let h=ae();if(h!==void 0){try{let f=h();typeof f?.then!="function"&&!o&&(o=!0,r.log("LP0810",Ge)),await f}catch(f){return a(f)}return r.isCurrent()?"partial":"superseded"}let p;try{p=await(e.fetch??fetch)(u.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[Ke]:"route"},signal:c.signal})}catch(f){return a(f)}if(r.signal.aborted)return"superseded";if(!p.ok||!(p.headers.get("content-type")??"").includes("text/html"))return r.log("LP0802",`route answered ${String(p.status)} ${p.headers.get("content-type")??""}`),"failed";try{let f=await p.text();if(!r.isCurrent())return"superseded";let y=new DOMParser().parseFromString(f,"text/html"),g=s.scrollX,x=s.scrollY;Ve(l,y);let E=Y(l.body);return H(l.body,y.body,{boundary:F,retainBoundary:j,keyAttributes:[ie,I,A],retainChildrenOf:K=>K.hasAttribute(A)}),X(E),s.scrollTo(g,x),"partial"}catch(f){return a(f)}}finally{c.dispose()}}}}function je(e){return{plan:(t,n)=>J(t,n).map(i=>i.element),async render(t,n){let i={rendered:0,failed:0,superseded:0},o={revision:t.revision,receivedAt:t.receivedAt,fields:t.fields,locale:t.locale,collectionSlug:t.collectionSlug,globalSlug:t.globalSlug,signal:t.signal};return await Promise.all(n.map(async r=>{let d=_(r);if(d===null)return;let m;try{m=await e(o,d)}catch(l){m={status:"failed",code:"LP0801",reason:R(l)}}if(!t.isCurrent()||m.status==="superseded"){i.superseded+=1,t.log("LP0804",`fragment "${d.id}" for revision ${String(o.revision)} discarded as superseded`);return}if(m.status==="rendered"){t.morph(r,m.html),t.rendered(r,d.id,d.key),i.rendered+=1;return}t.failed(r,d.id,d.key,m.code,m.reason),t.isCurrent()&&t.patch(r),i.failed+=1})),i}}}function ce(e){return je(ne(e))}return he(Ye);})();'].join(""),d=/* @__PURE__ */['"use strict";var __LIVE_PREVIEW_ROUTE__=(()=>{var S=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var n in t)S(e,n,{get:t[n],enumerable:!0})},J=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of V(t))!j.call(e,r)&&r!==n&&S(e,r,{get:()=>t[r],enumerable:!(i=G(t,r))||i.enumerable});return e};var Q=e=>J(S({},"__esModule",{value:!0}),e);var Re={};X(Re,{createRouteStrategy:()=>W});var T="data-payload-island",xe=`astro-island, [${T}]`,E="data-payload-owned",Z="data-payload-morph";function h(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute(Z)||ne(e)||e.hasAttribute(E))return!0;let n=e.getAttribute("contenteditable");return n!==null&&n!=="false"}function ee(e){return e.tagName.toLowerCase()==="astro-island"||e.hasAttribute(T)}function te(e){return e.getAttribute(T)==="patch"}function ne(e){return ee(e)&&!te(e)}var re=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],R=new WeakMap,I=new WeakSet;function N(e){return e.tagName.toLowerCase()==="astro-island"}function M(e){let t="";for(let n of e.querySelectorAll("astro-slot, template[data-astro-template]")){if(n.parentElement?.closest("astro-island")!==e)continue;let i=n.getAttribute("name")??n.getAttribute("data-astro-template")??"";t+=`${i}\\0${n.innerHTML}\\0`}return t}function oe(e){let t=e.ownerDocument.defaultView?.customElements.get("astro-island");return t!==void 0&&e instanceof t&&Array.isArray(t.observedAttributes)&&t.observedAttributes.includes("props")}function v(e,t){if(!N(e)||!N(t))return!0;let n=M(t);if(!(re.every(o=>e.getAttribute(o)===t.getAttribute(o))&&(R.get(e)??M(e))===n&&(e.getAttribute("props")===t.getAttribute("props")||oe(e))))return R.set(t,n),!1;R.set(e,n);let r=t.getAttribute("props");return r!==e.getAttribute("props")&&(e.setAttribute("ssr",""),r===null?e.removeAttribute("props"):e.setAttribute("props",r)),!0}function D(e){return Array.from(e.querySelectorAll("astro-island"))}function P(e){for(let t of e)t.isConnected||I.has(t)||(I.add(t),t.dispatchEvent(new CustomEvent("astro:unmount")))}var ie=new Set(["open","value","checked","selected"]);function C(e,t){for(let n of t.keyAttributes){let i=e.getAttribute(n);if(i!==null&&i.length>0)return`${n}=${i}`}}function w(e,t,n){if(!x(e,t))return t;let i=n.boundary??h,r=i(e),o=i(t);if(r||o)return!r||!o?t:n.retainBoundary?.(e,t)??!0?e:t;let d=ue(e);return ae(e,t),n.retainChildrenOf?.(e,t)!==!0&&le(e,t,n),ce(d),e}function ae(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||ie.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)}function le(e,t,n){let i=de(e,n),r=new Set(i.values()),o=Array.from(e.childNodes).filter(f=>!r.has(f)),d=new Set,p=new Set,l=Array.from(t.childNodes),s=e.firstChild,c=0;for(let f=0;f<l.length;f+=1){let a=l[f],g=null,y=a instanceof Element?C(a,n):void 0;if(y!==void 0&&p.has(y)&&(y=void 0),y!==void 0){p.add(y);let u=i.get(y);if(u!==void 0&&!d.has(u)&&(g=B(u,a,n)===u?u:null,g===null)){u.replaceWith(a),d.add(a),s=a.nextSibling;continue}}else{for(;c<o.length;){let u=o[c];if(c+=1,!d.has(u)){if(x(u,a)){g=B(u,a,n)===u?u:null,g===null&&(e.replaceChild(a,u),d.add(a),s=a.nextSibling);break}if(u instanceof Element){let b=l[f+1];if(!(a instanceof Element)||b!==void 0&&x(u,b)){c-=1;break}e.replaceChild(a,u),d.add(a),s=a.nextSibling;break}if(!(a instanceof Element)){e.replaceChild(a,u),d.add(a),s=a.nextSibling;break}}}if(g===null&&d.has(a))continue}let m=g??a;for(d.add(m);s!==null&&s!==m&&!d.has(s)&&se(s);)s=s.nextSibling;m!==s&&e.insertBefore(m,s),s=m.nextSibling}for(let f of Array.from(e.childNodes))d.has(f)||f.remove()}function B(e,t,n){return e instanceof Element&&t instanceof Element?w(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function se(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function x(e,t){return e.nodeType!==t.nodeType?!1:e instanceof Element&&t instanceof Element?e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI:!0}function de(e,t){let n=new Map,i;for(let r of Array.from(e.children)){let o=C(r,t);if(o!==void 0){if(n.has(o)){i??(i=o.slice(o.indexOf("=")+1));continue}n.set(o,r)}}return i!==void 0&&t.onDuplicateKey?.(e,i),n}function ue(e){let t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement)||!e.contains(t))return null;let n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null;return{element:t,selection:n}}function ce(e){if(e===null)return;let{element:t,selection:n}=e;if(!(t.ownerDocument.activeElement===t||!t.isConnected))try{t.focus({preventScroll:!0});let[i,r]=n??[null,null];i!==null&&r!==null&&t.setSelectionRange(i,r)}catch{}}var O="data-payload-key";function _(e){if(e==null)return[];let t=new Set,n=[];for(let i of e.split(/[\\s,]+/)){let r=i.trim();r.length===0||t.has(r)||(t.add(r),n.push(r))}return n}var fe="__livePreviewRouteRefresh";function me(){return typ','eof window>"u"?void 0:window}function F(){return me()?.[fe]}var A="data-payload-fragment",k="data-payload-fragment-key";function L(e,t){let n=new AbortController,i=!1,r=()=>{n.abort()};e.addEventListener("abort",r,{once:!0});let o=setTimeout(()=>{i=!0,n.abort()},t);return{signal:n.signal,timedOut:()=>i,dispose:()=>{clearTimeout(o),e.removeEventListener("abort",r)}}}function U(e){return e instanceof Error?e.message:String(e)}var H="data-payload-strategy",$="data-payload-field",ye="data-payload-depends",pe="x-payload-live-preview",ge=8e3,Ee="route refresh returned no promise; re-applied before the host committed (see LivePreviewRouteRefresh)",be=1e3;function he(e){let t=e.getAttribute(H);return t!==null?t==="route":e.closest("head")!==null}function Ae(e){let t=e.getAttribute($),n=_(e.getAttribute(ye));return t===null||t.length===0?n:[t,...n]}function K(e){return e.hasAttribute(E)?!1:e.tagName==="META"?e.hasAttribute("name")||e.hasAttribute("property"):e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"}function Se(e,t){let n=Array.from(e.head.children).find(l=>l.tagName==="TITLE"),i=Array.from(t.head.children).find(l=>l.tagName==="TITLE");!n?.hasAttribute(E)&&!i?.hasAttribute(E)&&t.title!==e.title&&(e.title=t.title);let r=Array.from(e.head.children).filter(K),o=Array.from(t.head.children).filter(K),d=Math.min(r.length,o.length);r.slice(0,d).forEach((l,s)=>{let c=o[s];if(c===void 0)return;if(l.tagName===c.tagName){for(let a of Array.from(l.attributes))c.hasAttribute(a.name)||l.removeAttribute(a.name);for(let a of Array.from(c.attributes))l.getAttribute(a.name)!==a.value&&l.setAttribute(a.name,a.value);return}let f=e.importNode(c,!0);l.replaceWith(f),r[s]=f});let p=r.at(-1);for(let l of o.slice(r.length)){let s=e.importNode(l,!0);p===void 0?e.head.append(s):p.after(s),p=s}for(let l of r.slice(o.length))l.remove()}function W(e={}){let t=e.timeoutMs??ge,n=e.minIntervalMs??be,i=-1/0,r=!1;return{plan(o,d,p){for(let l of o.querySelectorAll(`[${$}], [${H}="route"]`)){if(!he(l)||p?.inScope(l)===!1)continue;let s=Ae(l);if(s.length===0||s.some(c=>d.has(c)))return!0}return!1},async refresh(o){let d=Date.now(),p=n-(d-i);if(p>0)return o.retryAfter?.(p),o.log("LP0805",`route refresh for revision ${String(o.revision)} refused: the previous one was ${String(d-i)} ms ago`),"refused";i=d;let l=e.document??document,s=e.location??location,c=e.window??window,f=L(o.signal,t),a=g=>{if(o.signal.aborted)return"superseded";let y=f.timedOut()?`route refresh timed out after ${String(t)} ms`:U(g);return o.log("LP0801",y),"failed"};try{let g=F();if(g!==void 0){try{let m=g();typeof m?.then!="function"&&!r&&(r=!0,o.log("LP0810",Ee)),await m}catch(m){return a(m)}return o.isCurrent()?"partial":"superseded"}let y;try{y=await(e.fetch??fetch)(s.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[pe]:"route"},signal:f.signal})}catch(m){return a(m)}if(o.signal.aborted)return"superseded";if(!y.ok||!(y.headers.get("content-type")??"").includes("text/html"))return o.log("LP0802",`route answered ${String(y.status)} ${y.headers.get("content-type")??""}`),"failed";try{let m=await y.text();if(!o.isCurrent())return"superseded";let u=new DOMParser().parseFromString(m,"text/html"),b=c.scrollX,q=c.scrollY;Se(l,u);let z=D(l.body);return w(l.body,u.body,{boundary:h,retainBoundary:v,keyAttributes:[O,k,A],retainChildrenOf:Y=>Y.hasAttribute(A)}),P(z),c.scrollTo(b,q),"partial"}catch(m){return a(m)}}finally{f.dispose()}}}}return Q(Re);})();'].join(""),c=/* @__PURE__ */['"use strict";(()=>{function o(){if(typ','eof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function t(){return typ','eof window>"u"?!1:window.opener!=null}function e(){return o()||t()}function i(){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()&&i();})();'].join(""),f=/* @__PURE__ */['"use strict";(()=>{function c(){if(typ','eof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function s(){return typ','eof window>"u"?!1:window.opener!=null}function r(){return c()||s()}var i="__livePreviewHydration";function f(){if(typ','eof window>"u")return;let e=window;return e[i]??(e[i]={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]})}function d(){let e=f();if(e===void 0||e.armed)return;e.armed=!0;let n=window,o=n.__REACT_DEVTOOLS_GLOBAL_HOOK__??(n.__REACT_DEVTOOLS_GLOBAL_HOOK__=m()),u=o.onCommitFiberRoot;o.onCommitFiberRoot=function(a,t,...l){try{u?.call(this,a,t,...l)}catch{}e.onCommit===void 0?e.commits.push(t):e.onCommit(t)}}function m(){let e=new Map;return{supportsFiber:!0,renderers:e,inject:n=>{let o=e.size+1;return e.set(o,n),o}}}function p(){let e=document.createElement("script");e.src=__LP_RUNTIME_SRC__,__LP_RUNTIME_INTEGRITY__!==""&&(e.integrity=__LP_RUNTIME_INTEGRITY__,e.crossOrigin="anonymous"),e.async=!0,document.head.appendChild(e)}d();r()&&p();})();'].join(""),h=["allowedOrigins","serverURL","apiRoute","mergeDepth","debug","debounceMs","enableA11y","heartbeatMs","disableVisibilityGate","visibilityGateThreshold","intersectionRootMargin","disableReferrerDetection","disableLocalhostMatching","scopeBindingsByOwner","skipUnchanged","eventSourcePolicy","sanitizerPolicy","fragmentEndpoint","revealEditedField","routeStrategy","onUnboundChange","onUnfaithfulPatch","autoBind","hydration","defaults","softNavigationEvents","subfieldCoverage"];function p(e,t){if(0===e.length)throw new Error(`[live-preview] ${t} is empty. Run \`npm run build:runtime\` before bundling.`)}function generateInlineScript(e={}){n({defaults:e.defaults,onUnboundChange:e.onUnboundChange});const t=function(e){const t=e.runtime;if(void 0===t)return p(s,"runtime.generated.ts"),s;if(p(t.source,`the ${t.profile} runtime`),null!=e.fragmentEndpoint||!0===e.routeStrategy)throw new Error(`[live-preview] the ${t.profile} runtime and the fragment or route strategy exclude each other: it carries no strategy runner, so the prelude would have nothing to talk to. Drop the runtime option, or drop \`fragmentEndpoint\`/\`routeStrategy\`.`);return t.source}(e);return[m(e),...g(e),t].join("\n")}function g(e){return null!=e.fragmentEndpoint?(p(u,"fragment.generated.ts"),[u]):!0===e.routeStrategy?(p(d,"route.generated.ts"),[d]):[]}function m(e){return`var __LIVE_PREVIEW_CONFIG__=${function(e){r(e);const t=function(e){const t=e.defaults??"v2";return"v1"===t?{...l,defaults:t}:{defaults:t}}(e),n=h.map(n=>e[n]??t[n]);for(;void 0===n.at(-1);)n.pop();return`[${n.map(e=>void 0===e?"":JSON.stringify(e)).join(",")}]`.replace(/</g,"\\u003C")}(e)};`}function v(e={},t){const n=function(e){return"react"===e.hydration?(p(f,"loader-react.generated.ts"),f):(p(c,"loader.generated.ts"),c)}(e);if(""===t.runtimeSrc)throw new Error("[live-preview] generateLoaderScript needs a runtimeSrc.");const r=e=>JSON.stringify(e).replace(/</gu,"\\u003C");return[m(e),`var __LP_RUNTIME_SRC__=${r(t.runtimeSrc)};`,`var __LP_RUNTIME_INTEGRITY__=${r(t.integrity??"")};`,...g(e),n].join("\n")}function y(e,t={}){return`<script${void 0!==t.nonce?` nonce="${function(e){if(!/^[A-Za-z0-9+/=_-]+$/.test(e))throw new RangeError("nonce contains characters CSP does not allow");return e}(t.nonce)}"`:""}>${e}<\/script>`}function b(e){let t=0,n=e.length;for(;t<n&&"/"===e[t];)t+=1;for(;n>t&&"/"===e[n-1];)n-=1;const r=e.slice(t,n);return""===r?"":`/${r}`}function w(e={}){const t=e.runtime,n=`runtime.${t?.contentHash??"74e41f109a0533ee"}.js`;return{fileName:n,urlPath:`${b(e.assetPath??"/payload-live-preview")}/${n}`,integrity:t?.integrity??"sha384-W7OQMeXqJO0f51HPKK4RLuo2Y5wALpz5MnEj+W4rWuiKVOqwSP/CvkhiN2CQ6H6H",source:t?.source??s}}var A="_payload-live-preview",S="authorizePreviewModule";function k(e){return JSON.stringify(e).replace(/</g,"\\u003C")}function C(e){const t=`payload-live-preview: ${S} "${e}" must export the authorizePreview hook as its default export (ADR 0024).`;return[`import authorizePreview from ${k(e)};`,`if (typeof authorizePreview !== "function") throw new Error(${k(t)});`]}function R(e){n({defaults:e.defaults,onUnboundChange:e.onUnboundChange});const t="v1"===e.defaults?a:i,r="v1"===e.defaults?l:o,s=e=>r[e]!==o[e]?r[e]:void 0;return{strict:e.strict??t.strict,previewSignals:e.previewSignals??t.previewSignals,skipUnchanged:e.skipUnchanged??s("skipUnchanged"),disableReferrerDetection:e.disableReferrerDetection??s("disableReferrerDetection"),disableLocalhostMatching:e.disableLocalhostMatching,eventSourcePolicy:e.eventSourcePolicy??s("eventSourcePolicy"),sanitizerPolicy:e.sanitizerPolicy??s("sanitizerPolicy")}}function T(e,t={}){r(e);const n=R(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!==n.skipUnchanged?{skipUnchanged:n.skipUnchanged}:{},...void 0!==e.scopeBindingsByOwner?{scopeBindingsByOwner:e.scopeBindingsByOwner}:{},...void 0!==n.disableReferrerDetection?{disableReferrerDetection:n.disableReferrerDetection}:{},...void 0!==n.disableLocalhostMatching?{disableLocalhostMatching:n.disableLocalhostMatching}:{},...void 0!==n.eventSourcePolicy?{eventSourcePolicy:n.eventSourcePolicy}:{},...void 0!==n.sanitizerPolicy?{sanitizerPolicy:n.sanitizerPolicy}:{},...void 0!==e.runtime?{runtime:e.runtime}:{},...void 0!==e.fragments?{fragmentEndpoint:e.fragments.endpoint}:{},...!0===e.routeStrategy&&void 0===e.fragments?{routeStrategy:!0}:{},...void 0!==e.onUnboundChange?{onUnboundChange:e.onUnboundChange}:{},...void 0!==e.onUnfaithfulPatch?{onUnfaithfulPatch:e.onUnfaithfulPatch}:{},...void 0!==e.autoBind?{autoBind:e.autoBind}:{},...void 0!==e.subfieldCoverage?{subfieldCoverage:e.subfieldCoverage}:{},...void 0!==t.hydration?{hydration:t.hydration}:{},...void 0!==t.softNavigationEvents?{softNavigationEvents:t.softNavigationEvents}:{}}}var E={softNavigationEvents:["astro:page-load"]};function $(e){return e.endsWith("/")?e.slice(0,-1):e}function P(e,t){return void 0===e?$(t):`${$(e)}/${n=t,n.startsWith("/")?n.slice(1):n}`;var n}function L(e,t,n){if(0===e.length||e.startsWith("data:"))return e;const r=new URL(e,"https://astro.build"),i=URL.canParse(e)||e.startsWith("/")?r.pathname:r.pathname.slice(1),o=`${r.search}${r.hash}`,a=i.replace(/\\/g,"/");if(void 0!==n&&""!==n){let e="string"==typeof n?n:void 0;if("string"!=typeof n){const t=n[function(e){const t=e.split(".").pop()??"";return t===e?"":t}(i)];e=void 0!==t&&""!==t?t:n.fallback}return P(e,a)+o}return void 0!==t&&""!==t?function(e){return e.startsWith("/")?e:`/${e}`}(P(t,a))+o:e}function x(e,t){return e.replace(new RegExp("(['\"`])@@PAYLOAD_LIVE_PREVIEW_ISLAND_MODULES@@\\1","g"),()=>JSON.stringify(JSON.stringify(t)))}function N(e){const t=Reflect.get(globalThis,"process"),n="object"==typeof t&&null!==t?Reflect.get(t,"getBuiltinModule"):void 0;return"function"==typeof n?n.call(t,e):void 0}var O="virtual:payload-live-preview/options",M=`\0${O}`;function F(e={}){let t,n;return{name:"payload-live-preview",hooks:{"astro:config:done":({config:e,buildOutput:n})=>{t="static"===(n??e.output)?void 0:e.build?.server},"astro:build:ssr":({manifest:e})=>{n=function(e){if(void 0===e.entryModules)return;const t={};for(const[n,r]of Object.entries(e.entryModules))t[n]=L(r,e.base,e.assetsPrefix);return t}(e)},"astro:build:done":async({logger:e})=>{if(void 0===t||void 0===n)return;const r=await async function(e,t){const n=N("node:fs/promises"),r=N("node:url");if(void 0===n||void 0===r)return 0;const i=r.fileURLToPath(e);let o=0;for(const e of await n.readdir(i,{recursive:!0})){if(!/\.(?:m|c)?js$/u.test(e))continue;const r=`${i.replace(/[\\/]$/u,"")}/${e}`,a=await n.readFile(r,"utf8"),l=x(a,t);l!==a&&(await n.writeFile(r,l),o+=1)}return o}(t,n);r>0&&e?.info(`island module table written into ${String(r)} server chunk(s)`)},"astro:config:setup":t=>{if("middleware"!==e.mode){if(void 0!==e.authorizePreviewModule)throw new Error("payload-live-preview: `authorizePreviewModule` applies to mode 'middleware'; inline and loader delivery run no server hook (ADR 0024).");!function(e){const t="loader"===e.mode?"loader":"inline";if(void 0!==e.authorizePreview)throw new Error(`payload-live-preview: \`authorizePreview\` cannot be used with mode '${t}' — inline and loader delivery run no server hook, so the function would never be called. Use mode 'middleware' with \`authorizePreviewModule\`, or register \`createLivePreviewMiddleware({ authorizePreview, ... })\` in src/middleware.ts (ADR 0024).`);if(void 0!==e.shouldInject)throw new Error(`payload-live-preview: \`shouldInject\` cannot be used with mode '${t}' — inline and loader delivery decide once, at build time, for every page, so the function would never be called. Use mode 'middleware' with \`previewQueryParams\` or \`previewSignals\`, or register \`createLivePreviewMiddleware({ shouldInject, ... })\` in src/middleware.ts.`)}(e),!1!==e.autoInject&&("loader"!==e.mode?t.injectScript("head-inline",generateInlineScript(T(e,E))):function(e,t){if(void 0===e.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 n=function(e="/",t){const n=e.replace(/^\/+|\/+$/gu,""),r=w({assetPath:""===n?`/${A}`:`/${n}/${A}`,...void 0!==t?{runtime:t}:{}});return{fileName:`${A}/${r.fileName}`,urlPath:r.urlPath,integrity:r.integrity,source:r.source}}(e.config?.base??"/",t.runtime);e.injectScript("head-inline",v(T(t,E),{runtimeSrc:n.urlPath,integrity:n.integrity})),e.updateConfig({vite:{plugins:[{name:"payload-live-preview:loader-asset",generateBundle(){this.emitFile({type:"asset",fileName:n.fileName,source:n.source})},configureServer(e){e.middlewares.use((e,t,r)=>{(e.url??"").split("?")[0]===n.urlPath?(t.statusCode=200,t.setHeader("Content-Type","text/javascript; charset=utf-8"),t.setHeader("Cache-Control","no-cache"),t.end(n.source)):r()})}}]}})}(t,e))}else!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.");const n=t.authorizePreviewModule;void 0!==n&&function(e){if(e.startsWith("../")||e.startsWith("..\\"))throw new Error(`payload-live-preview: ${S} "${e}" is outside the project; name a module inside it, relative to the project root (ADR 0024).`)}(n);if((t.strict??"v1"!==t.defaults)&&void 0===n)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. Name the module that exports it in `authorizePreviewModule` (ADR 0024), or register `createLivePreviewMiddleware({ authorizePreview, ... })` yourself in src/middleware.ts. `defaults: 'v1'` (or `strict: false`) runs intent-only middleware instead (ADR 0006 explains why intent is not authorization).");const{mode:r,shouldInject:i,authorizePreviewModule:o,...a}=t,l=JSON.stringify(a).replace(/</g,"\\u003C"),s=void 0===n?`export default ${l};`:[...C(n.startsWith("./")?n.slice(1):n),`export default { ...${l}, authorizePreview };`].join("\n");e.updateConfig({vite:{plugins:[{name:"payload-live-preview-options",resolveId:e=>e===O?M:void 0,load:e=>e===M?s:void 0}]}}),e.addMiddleware({entrypoint:"payload-live-preview/astro/middleware-entry",order:"pre"})}(t,e)}}}}function U(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Object.values(e).every(e=>"string"==typeof e)}var I=function(e){const t=new Map(U(e)?Object.entries(e):[]),n=U(e);return e=>{if(!n)return Promise.reject(new Error("payload-live-preview: this server build carries no island module table. Add livePreview() from 'payload-live-preview/astro' to the Astro integrations and run `astro build`; `astro dev` and a server build that does not bundle payload-live-preview are not supported (ADR 0021)."));const r=t.get(e);return void 0===r?Promise.reject(new Error(`payload-live-preview: the build emitted no client module for island specifier "${e}"; the island is not rendered rather than pointed at a source file.`)):Promise.resolve(r)}}(function(){try{return JSON.parse("@@PAYLOAD_LIVE_PREVIEW_ISLAND_MODULES@@")}catch{return}}()),j=/[\t\n\f\r ]+/;function _(e,t){const n=e.charCodeAt(t);return 9===n||10===n||12===n||13===n||32===n}function z(e){let t=0,n=e.length;for(;t<n&&_(e,t);)t+=1;for(;n>t&&_(e,n-1);)n-=1;return 0===t&&n===e.length?e:e.slice(t,n)}function D(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function buildFrameAncestors(e={}){const{self:t=!0,origins:n=[],allowNone:r=!1}=e,i=/* @__PURE__ */new Set,o=[];if(r&&!t&&0===n.length)return"'none'";t&&(o.push("'self'"),i.add("'self'"));for(const e of n){const t=e.trim();0===t.length||i.has(t)||(i.add(t),o.push(t))}return o.length>0?o.join(" "):"'none'"}function W(e,t){const n=/* @__PURE__ */new Map;for(const t of e.split(";")){const e=z(t);if(0===e.length)continue;const r=e.search(j),i=D(r<0?e:e.slice(0,r));if(n.has(i))continue;const o=r<0?"":z(e.slice(r));n.set(i,o)}for(const[e,r]of Object.entries(t)){const t=D(e),i="string"==typeof r?{value:r}:r,o=i.mode??"union",a=n.get(t);if("replace"===o||void 0===a||0===a.length){n.set(t,i.value);continue}const l=/* @__PURE__ */new Set,s=[];for(const e of[...a.split(j),...i.value.split(j)])0===e.length||l.has(e)||(l.add(e),s.push(e));const u=s.filter(e=>"'none'"!==e);n.set(t,(u.length>0?u:s).join(" "))}const r=[];for(const[e,t]of n)r.push(0===t.length?e:`${e} ${t}`);return r.join("; ")}var B=/<head(\s[^>]*)?>/i,q=/text\/html/i,V=/<meta\s+(?:[^>]*\s)?(?:charset\s*=|http-equiv\s*=\s*["']?content-type)[^>]*>/i;function H(e,t={}){const n=T(e,t);if("asset"!==e.delivery)return generateInlineScript(n);const r=w(e);return v(n,{runtimeSrc:r.urlPath,integrity:r.integrity})}var G=["preview","draft","livePreview"];function K(e,n={}){const r=new Set(n.signals??["query","fetch-dest","referer"]),i=n.queryParams??G;if(r.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.getAll(e).at(-1);if("true"===n||"1"===n)return!0}}if(r.has("fetch-dest")&&"iframe"===e.headers.get("sec-fetch-dest"))return!0;const o=n.adminOrigins;void 0!==o&&t("admin-origins","`hasPreviewIntent({ adminOrigins })` is removed in 3.0: name the option `allowedOrigins`; `pll migrate` renames it (ADR 0026).");const a=n.allowedOrigins??o??[],l=r.has("referer")?a:[];if(l.length>0){const t=e.headers.get("referer");if(null!==t)try{const e=new URL(t).origin;for(const t of l)try{if(new URL(t).origin===e)return!0}catch{}}catch{}}return!1}var J=class extends Error{name="PreviewConfigurationError"};function X(e){return{authorized:!1,outcome:e,context:null}}var Q="payload-live-preview.authorized-preview-context",Y=Symbol.for(Q);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[Y]&&Object.isFrozen(e)}function Z(e){return Object.freeze({...e,scope:Object.freeze({...e.scope,...void 0===e.scope.payload?{}:{payload:Object.freeze({...e.scope.payload,document:Object.freeze({...e.scope.payload.document})})}}),payloadHeaders:Object.freeze({...e.payloadHeaders}),[Y]:!0,[Q]:!0})}async function ee(e){let t;try{t=await e()}catch(e){if(function(e){return e instanceof J||e instanceof Error&&"PreviewConfigurationError"===e.name}(e))throw e;return X("unavailable")}return function(e){return isAuthorizedPreviewContext(e)?{authorized:!0,outcome:"authorized",context:e}:"object"==typeof e&&null!==e&&"authorized"in e?e.authorized&&isAuthorizedPreviewContext(e.context)?{authorized:!0,outcome:"authorized",context:e.context}:X(e.authorized?"invalid":e.outcome):X("invalid")}(t)}var te=" New in 2.0; `defaults: 'v1'` keeps the 1.x table while you migrate (docs/migration.md).";var ne=Object.freeze({isPreview:!1,authorization:null,outcome:void 0,inject:!1,cspMode:!1,exposeNonce:!1});function re(n,i={}){const o=R(n);r(n);const a="function"==typeof n.authorizePreview;o.strict?function(t){if("function"!=typeof t.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)."+te);const n=t.allowedOrigins??[];if(0===n.length)throw new Error("payload-live-preview: strict mode requires explicit, non-empty `allowedOrigins`."+te);if(!e())for(const e of n){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}".`+te)}if(!0===R(t).previewSignals?.includes("referer"))throw new Error("payload-live-preview: strict mode disables referrer trust; remove 'referer' from `previewSignals` (the 'v1' profile includes it).")}(n):a||t("intent-only-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.");const l=!1!==(s=n.manageCsp)&&("full"===s?"full":"frame-ancestors");var s;const u=n.autoInject??!0;let d;return{authorizes:a,async decide(e,t={}){if(a&&void 0===t.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 r=function(e,t){const n=R(t).previewSignals;return"always"===(t.inject??"preview-only")||K(e,{...void 0!==t.previewQueryParams?{queryParams:t.previewQueryParams}:{},...void 0!==n?{signals:n}:{},allowedOrigins:t.allowedOrigins??[]})}(e,n);if(!r)return ne;let i,o=null;if(void 0!==t.authorize){const e=await ee(t.authorize);if(i=e.outcome,!e.authorized)return{isPreview:r,authorization:null,outcome:i,inject:!1,cspMode:!1,exposeNonce:!1};o=e.context}return{isPreview:r,authorization:o,outcome:i,inject:u&&(t.shouldInject?.()??!0),cspMode:l,exposeNonce:!0}},scriptTag:e=>y((d??=H(n,i),d),{nonce:e}),csp:(e,t,r)=>function(e,t,n,r){const i={"frame-ancestors":buildFrameAncestors({self:!0,origins:[...e.allowedOrigins??[],...e.frameAncestorsExtra??[]]})};return"full"===r&&(i["script-src"]=function buildScriptSrcWithNonce(e,t={}){if(0===e.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");const{self:n=!0,extra:r=[],strictDynamic:i=!1}=t,o=[];n&&o.push("'self'"),o.push(`'nonce-${e}'`),i&&o.push("'strict-dynamic'");for(const e of r){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?W("",t):n.map(e=>W(e,t)).join(", ")}(n,i)}(n,t,e,r),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 ie="livePreviewNonce",oe="livePreviewAuthorization",ae="livePreviewAuthorizationOutcome";function le(e={}){const t=re(e,E);return async(n,r)=>{const i=t.nonce();if(!0===n.isPrerendered)return function(e,t){e.livePreviewNonce=t}(n.locals,i),r();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.livePreviewNonce=n),null!==t.authorization&&(e.livePreviewAuthorization=t.authorization),void 0!==t.outcome&&(e.livePreviewAuthorizationOutcome=t.outcome)}(n.locals,o,i);const a=await r();return o.isPreview?async function(e,t,n,r){return n.inject||!1!==n.cspMode?function(e,t,n,r){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=>{!function(e,t,n,r){const i=n.cspMode;if(!1!==i){const n=e.get("content-security-policy")??"";e.set("content-security-policy",t.csp(n,r,i))}!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(),r=n.split(",").map(e=>e.trim().toLowerCase());r.includes("*")||r.includes("cookie")||e.set("vary",0===n.length?"Cookie":`${n}, Cookie`)}(e)}(e,t,n,r)})}(n.inject?await async function(e,t){if(null===e.body)return e;if(!q.test(e.headers.get("content-type")??""))return e;const n=function(e,t){const n=B.exec(e);if(null===n)return;const r=n.index+n[0].length,i=e.indexOf("</head",r),o=V.exec(e.slice(r,-1===i?void 0:i)),a=null===o?r:r+o.index+o[0].length;return`${e.slice(0,a)}${t}${e.slice(a)}`}(await e.clone().text(),t);if(void 0===n)return e;const r=new Headers(e.headers);return r.delete("content-length"),r.delete("content-encoding"),r.delete("etag"),new Response(n,{status:e.status,statusText:e.statusText,headers:r})}(e,t.scriptTag(r)):e,t,n,r):e}(a,t,o,i):a}}function se(e={}){return function(e,t={}){return y(H(e,t),void 0!==e.nonce?{nonce:e.nonce}:{})}(e,E)}var ue=(e,n)=>(t("is-preview-request","`isPreviewRequest()` is removed in 3.0: call `hasPreviewIntent()`, which takes the same arguments; `pll migrate` renames it (ADR 0026)."),K(e,n));function de(e){let t;return()=>{if(void 0===t){const n=e();t=n,n.catch(()=>{t===n&&(t=void 0)})}return t}}var ce,fe="users",he=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,pe=/^[A-Za-z0-9._~-]+$/;function ge(e,t){let n;try{n=new URL(e)}catch{throw new J(`payload-live-preview: ${t} "${e}" is not an absolute URL`)}if("https:"!==n.protocol&&"http:"!==n.protocol)throw new J(`payload-live-preview: ${t} must be http(s), got "${n.protocol}"`);return n.origin}function me(){return ce??=new TextEncoder,ce}function ve(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}}function ye(e){return"string"==typeof e&&e.length>0&&"."!==e&&".."!==e&&!/[\s\p{Cc}\p{Cs}/\\?#%]/u.test(e)}function be(e){return"number"==typeof e?Number.isSafeInteger(e):ye(e)}function we(e){return void 0!==e.expiresAt&&Number.isFinite(e.expiresAt)&&e.expiresAt>Date.now()}function Ae(e,t){return e.kind===t.kind&&e.slug===t.slug&&("global"===e.kind||be(t.id)&&String(e.id)===String(t.id))}async function Se(e,n){switch(n.type){case"payload-session":return async function(e,t){const n=function(e){const t=e??"payload-token";if(!he.test(t))throw new J(`payload-live-preview: cookie name "${t}" is not a valid cookie-name token`);return t}(t.cookieName),r=ge(t.serverURL,"serverURL"),i=void 0===t.origin?void 0:ge(t.origin,"origin"),o=function(e,t,n=4096){if(null===e||0===e.length)return null;const r=`${t}=`,i=[];for(const t of e.split(";")){const e=t.trim();e.startsWith(r)&&i.push(e.slice(r.length))}if(1!==i.length)return null;const o=i[0]??"";return 0===o.length||o.length>n||!pe.test(o)?null:o}(e.headers.get("cookie"),n,t.maxCookieLength??4096);if(null===o)return X("missing-credential");const a=t.now??Date.now,l=Math.max(250,t.timeoutMs??3e3);if(!Number.isSafeInteger(l))return X("unavailable");const s=t.fetch??globalThis.fetch,u=encodeURIComponent(t.usersSlug??fe),d=`${n}=${o}`;let c={cookie:d};void 0!==i&&(c.origin=i);const f=new AbortController,h=()=>{f.abort(e.signal?.reason)},p=()=>f.signal.aborted;let g,m;e.signal?.addEventListener("abort",h,{once:!0}),!0===e.signal?.aborted&&h();try{if(p())return X("unavailable");g=setTimeout(()=>{f.abort(new DOMException("The operation timed out","TimeoutError"))},l);for(let e=0;e<2;e++){const t=await s(`${r}/api/${u}/me?depth=0`,{headers:{...c,accept:"application/json"},signal:f.signal});if(p())return X("unavailable");if(!t.ok)return X(401===t.status?"invalid":"unavailable");if(m=await t.json(),p())return X("unavailable");if(0!==e||void 0!==i||"object"!=typeof m||null===m||null!==m.user)break;c={cookie:d,origin:r}}}catch{return X("unavailable")}finally{void 0!==g&&clearTimeout(g),e.signal?.removeEventListener("abort",h)}const v=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 r=e.collection??n.collection;if(void 0!==r&&r!==t)return null;const i=n.id;return"string"==typeof i&&i.length>0?i:"number"==typeof i&&Number.isFinite(i)?String(i):null}(m,t.usersSlug??fe);if(null===v)return X("invalid");const y=function(e){const t=e.exp;return"number"!=typeof t||!Number.isFinite(t)||t<=0?void 0:t<1e11?1e3*t:t}(m);return void 0!==y&&y<=a()?X("expired"):{authorized:!0,outcome:"authorized",context:Z({strategy:"payload-session",subject:v,authorizedAt:a(),expiresAt:y,scope:{},payloadHeaders:c})}}(e,n);case"signed-token":return async function(e,n){const r=function(e){const t="string"==typeof e?me().encode(e):e;if(t.byteLength<32)throw new J(`payload-live-preview: the preview token secret must be at least ${String(32)} bytes`);return t}(n.secret),i=function(e){if(void 0!==e)return e;const t=globalThis.crypto;return"object"==typeof t?.subtle?t:void 0}(n.crypto);if(void 0===i)return X("unavailable");const o=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 r=n.searchParams.getAll(t?.param??"previewToken");return 1===r.length?r[0]??null:null}(e,n.transport);if(null===o||0===o.length)return X("missing-credential");if(o.length>4096)return X("invalid");const a=o.split(".");if(3!==a.length||"v1"!==a[0])return X("invalid");const l=a[1]??"",s=ve(l),u=ve(a[2]??"");if(void 0===s||32!==u?.byteLength)return X("invalid");let d;try{const e=await async function(e,t){return e.subtle.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}(i,r);d=await i.subtle.verify("HMAC",e,u,me().encode(`v1.${l}`))}catch{return X("unavailable")}if(!d)return X("invalid");const c=function(e){let t;try{t=JSON.parse((new TextDecoder).decode(e))}catch{return}if("object"!=typeof t||null===t)return;const n=t,r=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&&r("pth")&&r("loc")&&r("sub")?n:void 0}(s);if(void 0===c)return X("invalid");const f=(n.now??Date.now)();if(c.exp<=f||c.iat>c.exp)return X("expired");if(c.aud!==n.audience)return X("wrong-audience");if(c.pur!==(n.purpose??"live-preview"))return X("wrong-purpose");if(void 0!==c.pth){let t;try{t=new URL(e.url).pathname}catch{return X("invalid")}if(c.pth!==t)return X("wrong-path")}if(void 0!==c.loc){const t=n.locale?.(e);if(t!==c.loc)return X("wrong-locale")}if(void 0!==n.replay){let e;try{e=await async function(e,n,r){return"consume"in e?!0===await e.consume(n,r):(t("replay-is-used","A `signed-token` replay store with `isUsed` and `markUsed` is removed in 3.0: implement `consume(id, expiresAt)`, which checks and records in one step (ADR 0026)."),!await e.isUsed(n)&&(await e.markUsed(n,r),!0))}(n.replay,c.jti,c.exp)}catch{return X("unavailable")}if(!e)return X("replayed")}return{authorized:!0,outcome:"authorized",context:Z({strategy:"signed-token",subject:c.sub,authorizedAt:f,expiresAt:c.exp,scope:{audience:c.aud,...void 0!==c.pth?{path:c.pth}:{},...void 0!==c.loc?{locale:c.loc}:{}},payloadHeaders:{}})}}(e,n);case"verifier":return async function(e,t){let n;try{n=await t.verify(e)}catch{return X("unavailable")}if(null===n)return X("invalid");if(!(void 0===n.scope?.payload||function(e){if("object"!=typeof e||null===e)return!1;const t=e,n=t.document;return!(null===function(e,t="/api"){if("string"!=typeof e||"string"!=typeof t)return null;try{const n=new URL(e);if(!["http:","https:"].includes(n.protocol)||n.username||n.password||n.search||n.hash)return null;const r=e.replace(/^[a-z]+:\/\/[^/]+/iu,"").replace(/\/+$/,""),i=t.replace(/^\//,"").replace(/\/$/,"");return""!==r&&!r.slice(1).split("/").every(ye)||!i.split("/").every(ye)?null:`${n.origin}${n.pathname.replace(/\/+$/,"")}/${i}`}catch{return null}}(t.serverURL,t.apiRoute)||"number"!=typeof t.maxDepth||!Number.isSafeInteger(t.maxDepth)||t.maxDepth<0||"object"!=typeof n||null===n||!ye(n.slug))&&("global"===n.kind||"collection"===n.kind&&be(n.id))}(n.scope.payload)&&Number.isFinite(n.expiresAt)))return X("invalid");const r=(t.now??Date.now)();return void 0!==n.expiresAt&&n.expiresAt<=r?X("expired"):{authorized:!0,outcome:"authorized",context:Z({strategy:"verifier",subject:n.subject,authorizedAt:r,expiresAt:n.expiresAt,scope:n.scope??{},payloadHeaders:n.payloadHeaders??{}})}}(e,n)}}function ke(e,t,n,r){const i=t??n;if(!Number.isSafeInteger(i)||i<=0||i>r)throw new RangeError(`payload-live-preview: createFragmentEndpoint() limits.${e} must be a positive integer no greater than ${String(r)}.`);return i}var Ce="x-payload-fragment-version",Re=64;function Te(e,t,n){if(t>n||"object"!=typeof e||null===e)return t;let r=t;for(const i of Object.values(e))if(r=Math.max(r,Te(i,t+1,n)),r>n)break;return r}function Ee(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function $e(e,t=Re){if(!Number.isInteger(t)||t<0||t>Re)return null;if(!Ee(e))return null;const n=e.fragment;if("string"!=typeof n||!/^[a-z][a-z0-9-]{0,63}$/iu.test(n))return null;const r=e.key;if(void 0!==r&&("string"!=typeof r||r.length>128))return null;const i=e.route;if("string"!=typeof i||!i.startsWith("/")||i.length>2048)return null;const o=e.search;if("string"!=typeof o||o.length>4096||""!==o&&!o.startsWith("?"))return null;const a=e.revision;if("number"!=typeof a||!Number.isInteger(a)||a<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[s,u,d]=l,c=e.fields;return Ee(c)?Te(c,0,t)>t?"field-depth":{fragment:n,..."string"==typeof r?{key:r}:{},route:i,search:o,revision:a,...void 0!==s?{locale:s}:{},...void 0!==u?{collectionSlug:u}:{},...void 0!==d?{globalSlug:d}:{},fields:c}:null}var Pe=2147483647,Le={"cache-control":"private, no-store","x-content-type-options":"nosniff",vary:"Cookie",[Ce]:String(1)};function xe(e,t,n){return new Response(JSON.stringify({error:t,...void 0!==n?{maxDepth:n}:{}}),{status:e,headers:{...Le,"content-type":"application/json; charset=utf-8"}})}var Ne=class extends Error{name="EndpointStopped"};function Oe(e,t){if(null!==e&&!e.locked)try{Promise.resolve(e.cancel(t)).catch(()=>{})}catch{}}function Me(e){return e.aborted}function Fe(e,n){const r=function(e){const{authorize:t,authorizePreview:n}=e;if(void 0!==n&&void 0!==t)throw new Error("payload-live-preview: createFragmentEndpoint() takes `authorizePreview` or `authorize`, not both — pass the middleware hook as `authorizePreview`, or a strategy as `authorize`.");if(void 0!==n)return e=>ee(()=>n(e));if(void 0!==t)return e=>Se(e,t);throw new Error("payload-live-preview: createFragmentEndpoint() needs `authorizePreview` (the middleware hook) or `authorize` (a strategy); without one it would render drafts for anyone.")}(e),i=e.render??n.render,o=void 0===e.render?n.rendererName:"custom",a=new Set(e.allowedOrigins??[]),l=ke("bodyBytes",e.limits?.bodyBytes,65536,Number.MAX_SAFE_INTEGER),s=ke("timeoutMs",e.limits?.timeoutMs,5e3,Pe),u=void 0===e.limits?.totalTimeoutMs?void 0:ke("totalTimeoutMs",e.limits.totalTimeoutMs,0,Pe),{fieldDepth:d=Re}=e.limits??{};if(!Number.isInteger(d)||d<0||d>Re)throw new TypeError("createFragmentEndpoint: limits.fieldDepth must be an integer from 0 to 64");const c=e.registry;return async(e,f)=>{if("POST"!==e.method)return xe(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 r=e.headers.get("origin");return null===r||r===new URL(e.url).origin||t.has(r)}(e,a))return xe(403,"origin");if(!(e.headers.get("content-type")??"").toLowerCase().startsWith("application/json"))return xe(415,"content-type");const h=function(e,t){const n=new AbortController,r=void 0===t?void 0:performance.now()+t;let i,o;const a=new Promise(e=>{o=e}),l=e=>{void 0===i&&(i=e,n.abort(e),o?.(e))},s=()=>{l("request-aborted")};e.addEventListener("abort",s,{once:!0}),e.aborted&&s();const u=void 0===t?void 0:setTimeout(()=>{l("total-timeout")},t),d=()=>{if(void 0!==r&&performance.now()>=r&&l("total-timeout"),void 0!==i)throw new Ne(i)};return{signal:n.signal,reason:()=>i,run:async(e,t)=>{d();const n=void 0===t?void 0:setTimeout(()=>{l("phase-timeout")},t);try{const t=await Promise.race([Promise.resolve().then(()=>(d(),e())),a.then(e=>{throw new Ne(e)})]);return d(),t}catch(e){throw d(),e}finally{void 0!==n&&clearTimeout(n)}},dispose:()=>{void 0!==u&&clearTimeout(u),e.removeEventListener("abort",s)}}}(e.signal,u),p={started:!1,read:!1};try{const a=await h.run(()=>(p.started=!0,async function(e,t,n,r,i){const o=e.body;if(Me(t)||e.bodyUsed||!0===o?.locked)return Oe(o,"unreadable"),{kind:"unreadable"};if(function(e,t){const n=e.headers.get("content-length");if(null===n||!/^[0-9]+$/u.test(n))return!1;const r=n.replace(/^0+/u,"")||"0",i=String(t);return r.length>i.length||r.length===i.length&&r>i}(e,n))return{kind:"too-large"};if(null===o)return{kind:"parsed",value:null};let a,l,s;try{a=o.getReader()}catch{return Oe(o,"unreadable"),{kind:"unreadable"}}const u=new Promise(e=>{s=e}),d=e=>{if(void 0===l){l=e,s?.({kind:"stopped",reason:e});try{Promise.resolve(a.cancel(e)).catch(()=>{})}catch{}}},c=()=>{d("unreadable")};t.addEventListener("abort",c,{once:!0}),Me(t)&&c();const f=setTimeout(()=>{d("timed-out")},r),h=new TextDecoder;let p="",g=0,m=!1;try{for(;;){const e=Promise.resolve().then(()=>a.read()).then(e=>({kind:"read",result:e}),()=>({kind:"read-error"})),t=await Promise.race([e,u]);if("stopped"===t.kind)return{kind:t.reason};if("read-error"===t.kind)return m?{kind:"too-large"}:(d("unreadable"),{kind:"unreadable"});if(void 0!==l)return{kind:l};if(t.result.done){if(m)return{kind:"too-large"};break}if(!m){if(t.result.value.byteLength>n-g){if("drain"===i){m=!0;continue}return d("too-large"),{kind:"too-large"}}g+=t.result.value.byteLength;try{p+=h.decode(t.result.value,{stream:!0})}catch{return d("unreadable"),{kind:"unreadable"}}}}try{return p+=h.decode(),{kind:"parsed",value:JSON.parse(p)}}catch{return{kind:"parsed",value:null}}}finally{clearTimeout(f),t.removeEventListener("abort",c);try{a.releaseLock()}catch{}}}(e,h.signal,l,s,n.overLimitBody??"cancel")));if("parsed"!==a.kind)return"too-large"===a.kind?xe(413,"body"):"timed-out"===a.kind?xe(408,"body"):xe(400,"body");const u=$e(a.value,d);if("field-depth"===u)return xe(400,"field-depth",d);if(null===u)return xe(400,"shape");p.read=!0;const g=new URL(e.url).origin,m=new Request(`${g}${u.route}${u.search}`,{headers:e.headers,signal:h.signal}),v=await h.run(()=>r(m));if(!v.authorized||!function(e,t,n){const r=e.scope;if(void 0!==r.locale&&r.locale!==t.locale)return!1;if(void 0!==r.payload){if(!we(e)||void 0!==r.audience&&r.audience!==n.origin||void 0!==r.path&&r.path!==n.pathname)return!1;if(void 0!==t.collectionSlug&&void 0!==t.globalSlug)return!1;if(!Ae(r.payload.document,{kind:void 0===t.globalSlug?"collection":"global",slug:t.globalSlug??t.collectionSlug,id:t.fields.id}))return!1;if(!function(e,t){if("object"!=typeof t||null===t||Array.isArray(t))return!1;const n=t;return"global"===e.kind?!Object.hasOwn(n,"globalType")||n.globalType===e.slug:Object.hasOwn(n,"id")&&Ae(e,{kind:"collection",slug:e.slug,id:n.id})}(r.payload.document,t.fields))return!1}return!0}(v.context,u,new URL(m.url)))return xe(403,"unauthorized");const y=Object.prototype.hasOwnProperty.call(c,u.fragment)?c[u.fragment]:void 0;if(void 0===y)return xe(404,"fragment");const b={locals:f,id:u.fragment,key:u.key,revision:u.revision,fields:u.fields,locale:u.locale,collectionSlug:u.collectionSlug,globalSlug:u.globalSlug,route:u.route,authorization:v.context,signal:h.signal,request:e},w=Date.now();let A;try{const e=await h.run(()=>y.props(b),s);if(void 0!==b.authorization.scope.payload&&!we(b.authorization))return xe(403,"unauthorized");const t=e;if(A=await h.run(()=>i(y.component,t,b),s),void 0!==b.authorization.scope.payload&&!we(b.authorization))return xe(403,"unauthorized")}catch(e){if(e instanceof Ne)throw e;return t(`fragment-render:${u.fragment}`,`fragment "${u.fragment}" did not render: ${e instanceof Error?e.message:String(e)}`),xe(500,"render")}const S={html:A,boundary:{id:u.fragment,...void 0!==u.key?{key:u.key}:{}},revision:u.revision,metadata:{renderedAt:/* @__PURE__ */(new Date).toISOString(),renderer:o,durationMs:Date.now()-w}};return new Response(JSON.stringify(S),{status:200,headers:{...Le,"content-type":"application/json; charset=utf-8"}})}catch(t){if(!(t instanceof Ne))throw t;return p.started||Oe(e.body,"unreadable"),"total-timeout"===h.reason()?xe(504,"timeout"):"phase-timeout"===h.reason()?xe(500,"render"):xe(400,p.read?"request":"body")}finally{h.dispose()}}}var Ue=de(async()=>{const e="astro/container";try{const t=await(import(e));return await t.experimental_AstroContainer.create()}catch(e){throw function(e,t){const n=e.map(e=>`\`${e}\``).join(" and "),r=1===e.length;return new Error(`payload-live-preview: this fragment endpoint renders with ${n}, ${r?"an optional peer":"optional peers"} this package does not install. ${r?"Install it":"Install them"}, or pass your own \`render\`.`,{cause:t})}(["astro"],e)}}),Ie=de(async()=>(await(import("./FragmentBridge.astro"))).default),je=async(e,t)=>{const n=await Ue(),r=await Ie();return n.renderToString(r,{locals:{__payloadLivePreviewFragment:{component:e,props:t}}})};function _e(e){const t=Fe(e,{render:je,rendererName:"astro-container"});return({request:e,locals:n})=>t(e,n)}export{oe as AUTHORIZATION_LOCALS_KEY,ae as AUTHORIZATION_OUTCOME_LOCALS_KEY,ie as NONCE_LOCALS_KEY,_e as createFragmentEndpoint,le as createLivePreviewMiddleware,K as hasPreviewIntent,ue as isPreviewRequest,F as livePreview,se as renderLivePreviewScript,I as resolveIslandModule};
2
2
  //# sourceMappingURL=index.js.map