payload-live-preview 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +11 -8
  2. package/dist/adapters/astro/index.js +1 -1
  3. package/dist/adapters/astro/index.js.map +1 -1
  4. package/dist/adapters/astro/middleware-entry.js +1 -1
  5. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  6. package/dist/adapters/nextjs/index.js +1 -1
  7. package/dist/adapters/nextjs/index.js.map +1 -1
  8. package/dist/adapters/nuxt/index.js +1 -1
  9. package/dist/adapters/nuxt/index.js.map +1 -1
  10. package/dist/adapters/sveltekit/index.js +1 -1
  11. package/dist/adapters/sveltekit/index.js.map +1 -1
  12. package/dist/client.cjs +1 -1
  13. package/dist/client.cjs.map +1 -1
  14. package/dist/client.js +1 -1
  15. package/dist/client.js.map +1 -1
  16. package/dist/core.cjs +1 -1
  17. package/dist/core.cjs.map +1 -1
  18. package/dist/core.d.cts +3 -2
  19. package/dist/core.d.ts +3 -2
  20. package/dist/core.js +1 -1
  21. package/dist/core.js.map +1 -1
  22. package/dist/doctor-cli.d.ts +1 -1
  23. package/dist/doctor-cli.js +1 -1
  24. package/dist/doctor-cli.js.map +1 -1
  25. package/dist/doctor.d.ts +2 -2
  26. package/dist/doctor.js +1 -1
  27. package/dist/doctor.js.map +1 -1
  28. package/dist/fragment.cjs.map +1 -1
  29. package/dist/fragment.js.map +1 -1
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +3 -2
  33. package/dist/index.d.ts +3 -2
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/lean.cjs +1 -1
  37. package/dist/lean.cjs.map +1 -1
  38. package/dist/lean.js +1 -1
  39. package/dist/lean.js.map +1 -1
  40. package/dist/lexical.cjs +1 -1
  41. package/dist/lexical.cjs.map +1 -1
  42. package/dist/lexical.js +1 -1
  43. package/dist/lexical.js.map +1 -1
  44. package/dist/plugins.cjs +1 -1
  45. package/dist/plugins.cjs.map +1 -1
  46. package/dist/plugins.js +1 -1
  47. package/dist/plugins.js.map +1 -1
  48. package/dist/{probe-DqaItcwX.d.ts → probe-DX_4wsBu.d.ts} +6 -0
  49. package/dist/server.cjs +1 -1
  50. package/dist/server.cjs.map +1 -1
  51. package/dist/server.js +1 -1
  52. package/dist/server.js.map +1 -1
  53. package/dist/structural.cjs +2 -2
  54. package/dist/structural.cjs.map +1 -1
  55. package/dist/structural.js +2 -2
  56. package/dist/structural.js.map +1 -1
  57. package/package.json +1 -1
package/dist/core.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e="2.0.2";function detectInitialLocale(){return function(){if("undefined"==typeof document)return;const e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}()??function(){if("undefined"==typeof navigator)return;const e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}()??"en"}var t="payload-live-preview-a11y",n=/* @__PURE__ */new WeakMap;function r(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}var i=class{german;document;lease=null;constructor(e,t){const n=t??("undefined"==typeof document?null:document),r=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(r.length>0?r:detectInitialLocale())),this.document=n}mount(){const e=this.document;if(null==e?.body)return null;this.lease??=function(e){let t=n.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},n.set(e,t)),t.refs+=1,t}(e);const i=this.lease,o=i.element;if(o?.isConnected&&o.ownerDocument===e)return o;if(null!==o){const e=i.owned;r(i),e&&o.remove()}let s=e.getElementById(t);return i.owned=null===s,null===s&&(s=e.createElement("div"),s.id=t,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),s.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(s)),i.element=s,s}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?"Änderung":"Änderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}detach(){const e=this.lease,t=this.document;if(null===e||null===t)return;if(this.lease=null,e.refs-=1,e.refs>0)return;const i=e.element;null!==i&&r(e),e.owned&&i?.remove(),e.element=null,n.delete(t)}say(e){const 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);const o=setTimeout(()=>{n.timer===o&&n.element===t&&r(n)},1500);n.timer=o}};function o(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const e=s(n);e&&t.push(e)}return t}function s(e){if("object"!=typeof e||null===e)return;const t=e,n=t.name,r=t.type;if("string"!=typeof n||0===n.length)return;if("string"!=typeof r||0===r.length)return;const i=o(t.fields),s=function(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if("object"!=typeof n||null===n)continue;const e=n,r=e.slug;if("string"!=typeof r||0===r.length)continue;const i=o(e.fields);t.push({...e,slug:r,fields:i})}return t}(t.blocks),a={...t,name:n,type:r};return i.length>0?a.fields=i:delete a.fields,s.length>0?a.blocks=s:delete a.blocks,a}function a(e,t){return void 0===e||t(e)}function l(e,t){return null==e||t(e)}function u(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}var c=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],d={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"}},h=Object.keys(d);function negotiateProtocol(e,t=[]){const n="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,r=n??1,i=Math.min(4,r),o=new Set(t),s=/* @__PURE__ */new Set;for(const e of h)(i>=d[e].since||o.has(e))&&s.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:i,capabilities:s,observed:o}}function f(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function p(e,t){return e.generation===t.generation&&e.revision===t.revision}var m=class{matcher;handlers;boundListener=void 0;attachedTarget=void 0;generation=0;revision=0;queueHead=void 0;queueTail=void 0;constructor(e,t){this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1;const n=r=>{if(!t||this.boundListener!==n)return;const i=this.generation;try{this.receive(r,i,e)}catch{let e;try{e=r.origin}catch{e=""}this.reportInvalid("shape",e,i)}};this.generation+=1,this.resetQueue(),this.attachedTarget=e,this.boundListener=n;try{e.addEventListener("message",n)}catch(t){this.boundListener===n&&(this.attachedTarget=void 0,this.boundListener=void 0,this.resetQueue());try{e.removeEventListener("message",n)}catch{}throw t}if(this.boundListener===n)t=!0;else try{e.removeEventListener("message",n)}catch{}}detach(){const 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){const n={type:"payload-live-preview",ready:!0,protocolVersion:4};for(const r of e)for(const e of t)try{r.postMessage(n,e)}catch{}}receive(e,t,n){const r=e.origin;if(!this.matchesOrigin(r,t))return void this.reportInvalid("origin",r,t);if(!this.matchesSource(e,n))return void this.reportInvalid("source",r,t);const i=e.data;var s;if("object"==typeof(s=i)&&null!==s&&"type"in s&&"string"==typeof s.type)switch(i.type){case"payload-live-preview":return function(e){const t=e;return!(void 0!==t.data&&null!==t.data&&!u(t.data))&&l(t.fieldSchemaJSON,e=>Array.isArray(e))&&l(t.globalSlug,e=>"string"==typeof e)&&l(t.collectionSlug,e=>"string"==typeof e)&&l(t.locale,e=>"string"==typeof e)&&l(t.ready,e=>"boolean"==typeof e)&&l(t.previewToken,e=>"string"==typeof e)&&l(t.protocolVersion,e=>"number"==typeof e)}(i)?void this.dispatchUpdate(function(e){const t={...e};for(const e of c)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=o(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(i),r,t):void this.reportInvalid("shape",r,t);case"payload-document-event":return function(e){const t=e;return a(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&a(t.slug,e=>"string"==typeof e)&&a(t.id,e=>"string"==typeof e||Number.isFinite(e))}(i)?void this.invokeHandler(t,this.handlers.onDocumentEvent,i,r):void this.reportInvalid("shape",r,t);case"payload-live-preview-focus":{const e=function(e){const t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(i);return void 0===e?void this.reportInvalid("shape",r,t):void this.invokeHandler(t,this.handlers.onFocusField,e,r)}default:this.reportInvalid("type",r,t)}else this.reportInvalid("shape",r,t)}dispatchUpdate(e,t,n){const r=u(e.data);if(!this.isCurrentGeneration(n))return;const i=r?{generation:n,revision:this.revision+=1}:void 0,o=this.handlers.validateToken;if(!this.isCurrentGeneration(n))return;if(void 0===o)return void this.commitUpdate(e,t,n,i);if(!0===e.ready&&void 0===e.data)return void this.commitUpdate(e,t,n,void 0);const s={generation:n,message:e,origin:t,messageRevision:i,verdict:void 0,next:void 0};let a;this.enqueue(s);try{a=o(e.previewToken,t)}catch{return void this.settleValidation(s,!1)}"boolean"!=typeof a?Promise.resolve(a).then(e=>{this.settleValidation(s,!0===e)},()=>{this.settleValidation(s,!1)}):this.settleValidation(s,a)}settleValidation(e,t){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){const 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,r){void 0===r?this.invokeHandler(n,this.handlers.onUpdate,e,t):this.invokeHandler(n,this.handlers.onUpdate,e,t,r)}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{const n=e.source;if("object"!=typeof n||null===n)return!1;const r=t.parent;return r!==t&&n===r||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(e,t,...n){if(void 0!==t&&this.isCurrentGeneration(e))try{f(t(...n))}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}};function g(e){return(...t)=>{try{f(e(...t))}catch{}}}function v(){}var y=g((...e)=>console.error(...e)),b=g((...e)=>console.warn(...e)),w=g((...e)=>console.debug(...e)),S={"structural arrays":'data-payload-type="array" and keyed lists',"array templates":"data-payload-array-template","server-rendered fragments":"data-payload-fragment boundaries","route refreshes":'data-payload-strategy="route" and bindings in <head>',"screen-reader announcements":"the aria-live region","auto-binding":"autoBind: 'unique'"},A=/* @__PURE__ */new Set;function k(e){A.has(e)||(A.add(e),b(`[live-preview] LP0104: this page carries the lean runtime, which leaves out ${e} (${S[e]}). The elements are left as the server rendered them. Remove \`runtime: LEAN_RUNTIME\` to get the full runtime.`))}function T(e){return"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e){return!1!==e.enableA11y&&k("screen-reader announcements"),null}(e):function(e){if(!1===e.enableA11y)return null;const t=e.root,n=void 0===t?void 0:function(e){return 9===e.nodeType}(t)?t:t.ownerDocument;return new i(e.a11yLocale,n)}(e)}function C(e){if("undefined"==typeof window)return;const t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),m.sendReady(t,e)}function R(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}var P=/* @__PURE__ */new Set(["tabs","row","collapsible"]);function $(e,t=""){const n=/* @__PURE__ */new Map;return N(e,t,n),n}function N(e,t,n){for(const r of e){if(P.has(r.type)){r.fields&&N(r.fields,t,n);continue}const e=""===t?r.name:`${t}.${r.name}`;if(n.set(e,r),"group"===r.type)r.fields&&N(r.fields,e,n);else if("array"===r.type&&r.fields)N(r.fields,`${e}.*`,n);else if("blocks"===r.type&&r.blocks)for(const t of r.blocks)N(t.fields,`${e}.*.${t.slug}`,n)}}function x(e,t){if(e.has(t))return e.get(t);const n=t.replace(/\.\d+(?=\.|$)/g,".*");return e.has(n)?e.get(n):void 0}function L(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function F(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function E(e,t){return t.every(e=>void 0!==L(e))?function(e,t){const n=[],r=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=L(e[t]);void 0!==n&&r.set(n,t)}const i=/* @__PURE__ */new Set;for(let o=0;o<t.length;o+=1){const s=t[o],a=L(s);if(void 0===a){n.push({kind:"insert",index:o,value:s});continue}const l=r.get(a);if(void 0===l){n.push({kind:"insert",index:o,value:s});continue}i.add(l);const u=e[l];F(u)===F(s)?(l!==o&&n.push({kind:"move",from:l,to:o,value:s}),U(u,s)||n.push({kind:"update",index:o,value:s})):n.push({kind:"replace",index:o,oldValue:u,value:s})}for(let t=0;t<e.length;t+=1)i.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){const n=[],r=Math.min(e.length,t.length);for(let i=0;i<r;i+=1)U(e[i],t[i])||n.push({kind:"update",index:i,value:t[i]});if(t.length>e.length)for(let r=e.length;r<t.length;r+=1)n.push({kind:"insert",index:r,value:t[r]});if(e.length>t.length)for(let r=t.length;r<e.length;r+=1)n.push({kind:"remove",index:r,value:e[r]});return n}(e,t)}function U(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;const n=e,r=t,i=Object.keys(n),o=Object.keys(r);if(i.length!==o.length)return!1;for(const e of i)if(!Object.is(n[e],r[e]))return!1;return!0}var M={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"},I=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),O=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,_=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,D=/^[\\/]{2}/,z=/[\t\n\r]/g;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(z,"");if(0===t.length)return!1;if(O.test(t))return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(D.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return I.has(e.protocol)}catch{return _.test(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(z,"");return/^https?:\/\//i.test(t)||D.test(t)}var B=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),j=/* @__PURE__ */new Set(["href","src","poster","cite","action","xlink:href","data"]);function H(e){return!e.startsWith("on")&&!B.has(e)}function W(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function V(e,t,n,r){if(t.reportedUnfaithful.has(n.element))return;t.reportedUnfaithful.add(n.element),t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName);const i=e.onUnfaithfulPatch;"ignore"!==i&&("warn"!==i?(e.log("LP0411",n.fieldName,r),t.unfaithfulPatches.push(n)):e.warn(`[live-preview] LP0411: "${n.fieldName}" ${r}`))}function q(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}var G=/* @__PURE__ */new Set(["date","number","checkbox"]);function K(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function J(e){const t=e.trim();return JSON.stringify(t.length>40?`${t.slice(0,40)}…`:t)}var Q=/* @__PURE__ */new WeakSet;function X(e){return Q.add(e),e}function Y(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}}var Z=class{previous=null;diff(e,t){const n=this.previous,r=null===n,i=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set;for(const[t,r]of Object.entries(e)){const e=Y(r);i.set(t,e),null!==n&&void 0!==e&&n.get(t)===e||o.add(t)}if(null!==n)for(const e of n.keys())i.has(e)||o.add(e);this.previous=i;const s=/* @__PURE__ */new Set;for(const[e,n]of Object.entries(t))if(o.has(e))for(const e of n)s.add(e);return{changed:o,invalidated:s,baseline:r}}reset(){this.previous=null}},ee="data-payload-fragment";function te(e){return e.closest(`[${ee}]`)}function ne(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==te(e)?"fragment":null!==e.closest("head")?"route":"patch"}function re(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function ie(e){return"string"==typeof e&&e.length>0}function oe(e,t){return null!==t&&void 0!==e&&t.includes(e)}function se(e){const t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}var ae=/* @__PURE__ */new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function le(e,t,n){const r=e.get(t);return void 0!==r&&(!1===n||r.some(e=>oe(e.owner,n)))}function ue(e,t,n){const r=`${t}.`;for(const[t,i]of e.entries())if(t.startsWith(r)){if(!1===n)return!0;if(i.some(e=>oe(e.owner,n)))return!0}return!1}function ce(e,t){if(void 0===t||0===t.length)return e;const n=`_${t}`;return e.endsWith(n)?e.slice(0,-n.length):e}function de(e,t,n){let r;return i=>{if(le(e,i,n))return!0;const o=ce(i,t);return!(o===i||!le(e,o,n))||!!ue(e,i,n)||!(o===i||!ue(e,o,n))||(r??=function(e,t){const n=/* @__PURE__ */new Set;for(const[r,i]of e.entries())for(const e of i)(!1===t||oe(e.owner,t))&&void 0!==e.locale&&n.add(`${r}_${e.locale}`);return n}(e,n),r.has(i))}}function he(e,t,n,r){const i=de(e,n,r),o=[];for(const e of t)ae.has(e)||i(e)||o.push(e);return o}var fe=/* @__PURE__ */new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),pe={},me=class{rawChanges=new Z;resolved=null;queued=null;pending=null;timer=null;openUntil=0;decide(e,t){const n=t.message.data??{},{changed:r}=this.rawChanges.diff(n,pe);if(!function(e){const{cache:t,emitter:n}=e;if(t.islands.length>0)return!0;if(n.listenerCount("beforeUpdate")>0||n.listenerCount("afterUpdate")>0)return!0;for(const e of t.values()){if(ve(e)||e.fieldName.includes("."))return!0;if(be(e.hrefField)||be(e.srcField)||be(e.altField))return!0}return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${ee}]`)}(e))return{merge:!1,fields:n};const i=this.resolved;if(null===i)return this.resolved=n,{merge:!0,fields:n};const o={...i};let s=t.forceRender;for(const a of r){const r=n[a];if(ae.has(a)){o[a]=r;continue}const l=ge(a,i[a],r,e.cache,t.schemaIndex);"own"!==l&&(s=!0),"keep"!==l&&(o[a]=r)}return this.resolved=o,{merge:s,fields:o}}request(e,t,n){const r=Date.now();return r>=this.openUntil?(this.dropQueued(),this.openUntil=r+t,{leading:!0,result:e.merge(n)}):(this.queued=n,this.openUntil=r+t,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){const 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"})})}};function ge(e,t,n,r,i){return ye(n)?!ye(t)||function(e,t,n){const r=void 0===n?void 0:x(n,e);return void 0!==r&&!fe.has(r.type)||!0===t.get(e)?.some(ve)||ue(t,e,!1)}(e,r,i)?"keep":null==t?"ask":"own":"ask"}function ve(e){return!fe.has(e.fieldType)}function ye(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function be(e){return!0===e?.includes(".")}var we=class{negotiation=negotiateProtocol(void 0);observed=/* @__PURE__ */new Set;observe(e,t){const n=e.filter(e=>!this.observed.has(e));if(0!==n.length){for(const e of n)this.observed.add(e);this.negotiation=negotiateProtocol(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}applyVersion(e,t){const n=this.negotiation;if(n.theirs===e)return;const r=negotiateProtocol(e,this.observed);this.negotiation=r,r.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${r.negotiated}`)}};function Se(e){return null!==e&&e.forceRender&&!e.completed}var Ae=class{lastIdentity=void 0;edit(e){const t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;const n=JSON.stringify([t.entitySlug,se(t),t.updatedAt]),r=n!==this.lastIdentity;return this.lastIdentity=n,r&&function(e,t){const n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;const r=se(e),i=se(t.data??{});return void 0!==r&&void 0!==i&&r!==i}(t,e)?t:null}};function ke(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Te=class{#e;reveal(e,t,n){return e===this.#e?"skipped-same":(this.#e=e,function(e,t){return function(e,t){const n=e.getBoundingClientRect(),r=n.bottom>0&&n.top<t.innerHeight,i=n.right>0&&n.left<t.innerWidth;return r&&i}(e,t)?"already-visible":(e.scrollIntoView({behavior:ke(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){this.#e=void 0}},Ce=class{seen=/* @__PURE__ */new Map;note(e,t,n){const r=Y(n);if(void 0===r)return;const i=`${t.owner??""}\0${t.locale??""}\0${t.fieldName}`,o=this.seen.get(i);void 0!==o?o!==r&&(e.revealIdentities.push([i,r]),e.revealTarget??=t):this.seen.set(i,r)}commit(e){for(const[t,n]of e.revealIdentities)this.seen.set(t,n);e.revealIdentities=[];const t=e.revealTarget;return e.revealTarget=void 0,t}},Re=class{started=!1;suspended=!1;deferredStart=null;hydration="idle";activeUpdate=null;locale=void 0;schema=void 0;schemaIndex=void 0;updateCount=0;supersededCount=0;completedCount=0;skippedUnchangedCount=0;lastFlush=null;absentFields=/* @__PURE__ */new Set;warnedOrphanFields=/* @__PURE__ */new Set;warnedStrategy=/* @__PURE__ */new WeakSet;warnedUnattributableMessage=!1;warnedVisibilityGate=!1;warnedFragmentFallback=!1;warnedProtocolShape=!1;reportedUnfaithful=/* @__PURE__ */new WeakSet;checkedServerFormat=/* @__PURE__ */new WeakSet;unfaithfulPatches=[];unfaithfulCount=0;escalatedCount=0;unfaithfulFields=/* @__PURE__ */new Set;autoBindSearchMs=void 0;autoBindGuesses=null;warnedForeignSource=!1;lastAppliedIdentity=/* @__PURE__ */new WeakMap;revealLedger=new Ce;fragmentStats={rendered:0,failed:0,superseded:0};routeStats={refreshes:0,failed:0,refused:0,loopStopped:0};fragmentController=null;routeController=null;routeRetry=null;readyTimers=[];revealer=new Te;changes=new Z;merges=new me;protocol=new we;relationships=new Ae;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);for(const e of["fragmentController","routeController"]){const t=this[e];null!==t&&(this[e]=null,t.abort())}}},Pe=class{constructor(e,t){this.deps=e,this.state=t,this.instanceContext=R({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,reportUnfaithful:(n,r)=>{V(e,t,n,r)}})}deps;state;instanceContext;apply(e){const{deps:t,state:n}=this,r=n.activeUpdate;if(null===r||void 0===e.revision||!p(r.revision,e.revision)||!n.isCurrent(r))return!1;const{target:i,value:o}=e,s=void 0!==r.schemaIndex?x(r.schemaIndex,i.fieldName):void 0;let a,l=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){const e=function(e){if(Object.prototype.hasOwnProperty.call(M,e))return M[e]}(t);if(void 0!==e)return e}return e.fieldType}(i,s?.type);"text"===l&&!0!==i.explicitFieldType&&function(e){if("object"!=typeof e||null===e||!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&Array.isArray(t.children)}(o)&&(l="richText");try{a=t.resolveRenderer(l,i)}catch(e){return this.fail(r,e)}if(!n.isCurrent(r))return!1;const u=t.emitter.listenerCount("elementUpdate")>0,c=u?"INPUT"===(d=i.element).tagName||"TEXTAREA"===d.tagName?d.value:"IMG"===d.tagName?d.src:d.textContent:void 0;var d;if(!n.isCurrent(r))return!1;const h={allFields:e.allFields,locale:i.locale??r.locale,schema:s,...this.instanceContext};!0===i.hidesWhenEmpty&&i.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!==i.targetAttribute){if("blocked"===function(e,t,n){const r=t.toLowerCase().trim();if(0===r.length)return"blocked";if(!H(r))return"blocked";if(null==n)return e.removeAttribute(r),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";const i=String(n);return j.has(r)&&!isSafeUrl(i)?"blocked":(e.setAttribute(r,i),"applied")}(i.element,i.targetAttribute,o))return t.warn(`[live-preview] LP0401: refused to write "${i.fieldName}" into attribute "${i.targetAttribute}"`),!1}else{if(void 0===a)return t.log("no renderer for",l),V(t,n,i,`has no renderer for "${l}"`),!1;{const e=function(e,t,n,r){if("ignore"===e.onUnfaithfulPatch)return;if(void 0!==n.format||!G.has(r))return;if(t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);const i=K(n.element);return i.trim().length>0?i:void 0}(t,n,i,l),r=function(e,t,n,r){return e.render(t,n,r)}(a,i,o,h);if(!1===r&&function(e){return Q.has(e.render)}(a))return V(t,n,i,`is a value ${a.name} cannot render`),!1;void 0!==e&&function(e,t,n){const r=K(t.element);r!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${J(n)}, the patch wrote ${J(r)} — 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,i,e)}}}catch(e){return this.fail(r,e)}if(!n.isCurrent(r))return!1;u&&t.emitter.emitWhile("elementUpdate",{element:i.element,fieldName:i.fieldName,previousValue:c,nextValue:o,revision:r.revision.revision,receivedAt:r.receivedAt,source:"patch"},()=>n.isCurrent(r));const f=n.isCurrent(r);return f&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(i.element,e.valueIdentity):n.lastAppliedIdentity.delete(i.element)),f}fail(e,t){if(!this.state.isCurrent(e))return!1;const 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}};function $e(...e){const t=/* @__PURE__ */new Map;for(const n of e)for(const[e,r]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=/* @__PURE__ */new Set,t.set(e,n));for(const e of r)n.add(e)}const n={};for(const[e,r]of t)n[e]=[...r];return n}function Ne(e,t){const n={};for(const r of t)r!==e&&(n[r]=[e]);return n}var xe="payload-live-preview:update",Le="data-payload-island",Fe=`astro-island, [${Le}]`;function Ee(e){return"patch"===e.getAttribute(Le)}function Ue(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(Le)}(e)&&!Ee(e)}function isInsideIsland(e){let t=e;for(;null!==t;){if(Ue(t))return!0;t=t.parentElement}return!1}var Me="data-payload-field",Ie="data-payload-type",Oe="data-payload-attribute",_e="data-payload-href",De="data-payload-src",ze="data-payload-alt",Be="data-payload-array-template",je="data-payload-array-separator",He="data-payload-locale",We="data-payload-richtext",Ve="data-payload-html",qe="data-payload-array",Ge="data-payload-structural",Ke="data-payload-owner",Je="data-payload-depends",Qe="data-payload-strategy",Xe="data-payload-boundary",Ye="data-payload-guessed",Ze=[Me,Ie,Oe,_e,De,ze,Be,je,He,We,Ve,qe,Ge,Ke,Je,Qe,Xe,"type"],et=`[${Me}]`,tt=`[${Ke}]`;function nt(e){const t=e.closest(tt)?.getAttribute(Ke);return null==t||0===t.length?void 0:t}var rt=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,it=/* @__PURE__ */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"]);function ot(e){return it.has(e)||rt.test(e)}var st=class{entriesByField=/* @__PURE__ */new Map;entryByElement=/* @__PURE__ */new WeakMap;filter;count=0;dependencies=null;islandRoots=[];constructor(e={}){this.filter=e.filter??lt}dependencyMap(){if(null!==this.dependencies)return this.dependencies;const e=[];for(const t of this.values())void 0!==t.dependsOn&&e.push(Ne(t.fieldName,t.dependsOn));return this.dependencies=$e(...e),this.dependencies}get islands(){return this.islandRoots}buildFromRoot(e){const t=performance.now();this.clear();let n=0;for(const t of e.querySelectorAll(et))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){const t=[];for(const n of e.querySelectorAll(Fe))Ee(n)||t.push(n);return t}(e),{elementCount:n,fieldCount:this.entriesByField.size,durationMs:performance.now()-t}}add(e){const 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){const 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(const e of this.entriesByField.values())yield*e}has(e){return this.entryByElement.has(e)}clear(){this.entriesByField.clear(),this.entryByElement=/* @__PURE__ */new WeakMap,this.count=0,this.dependencies=null,this.islandRoots=[]}replaceEntry(e,t){if(e.fieldName!==t.fieldName)return!1;const n=this.entriesByField.get(e.fieldName),r=void 0===n?-1:n.indexOf(e);return!(void 0===n||r<0||(n[r]=t,0))}removeEntry(e,t){this.entryByElement.delete(e);const n=this.entriesByField.get(t.fieldName),r=void 0===n?-1:n.indexOf(t);return!(void 0===n||r<0||(n.splice(r,1),0===n.length&&this.entriesByField.delete(t.fieldName),this.count-=1,0))}append(e){const t=this.entriesByField.get(e.fieldName);t?t.push(e):this.entriesByField.set(e.fieldName,[e]),this.count+=1}resolveBinding(e){const t=e.getAttribute(Me);if(null===t||0===t.length)return;const n=e.getAttribute(Ie),r=e.getAttribute(Oe),i=e.getAttribute(_e),o=e.getAttribute(De),s=e.getAttribute(ze),a=e.getAttribute(Be),l=e.getAttribute(je),u=e.getAttribute(He),c=e.getAttribute("data-payload-format"),d=nt(e),h=function(e){if(null==e)return[];const t=/* @__PURE__ */new Set,n=[];for(const r of e.split(/[\s,]+/)){const e=r.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}(e.getAttribute(Je)),f=e.getAttribute(Qe),p=e.getAttribute(Ye),m=te(e);return{element:e,fieldName:t,fieldType:at(e),explicitFieldType:null!==n&&ot(n),strategyKind:ne(e)??"unknown",...null!==m?{fragmentBoundary:m}:{},...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==i&&i.length>0?{hrefField:i}:{},...null!==o&&o.length>0?{srcField:o}:{},...null!==s&&s.length>0?{altField:s}:{},...null!==a?{arrayTemplate:a}:{},...null!==l?{arraySeparator:l}:{},...null!==u&&u.length>0?{locale:u}:{},...null!==c&&c.length>0?{format:c}:{},...void 0!==d?{owner:d}:{},...h.length>0?{dependsOn:h}:{},...null!==f&&f.length>0?{strategy:f}:{},...e.hasAttribute(Xe)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}};function at(e){const t=e.getAttribute(Ie);if(null!==t&&ot(t))return t;if(e.hasAttribute(We))return"richText";if(e.hasAttribute(Ve))return"html";if(e.hasAttribute(Ge))return"structural-array";if(e.hasAttribute(qe))return"array";if("IMG"===e.tagName)return"image";if("A"===e.tagName)return"url";if("TIME"===e.tagName)return"date";if("INPUT"===e.tagName){const t=e.type;if("checkbox"===t)return"checkbox";if("number"===t)return"number";if("date"===t||"datetime-local"===t)return"date"}return"text"}function lt(){return!0}function ut(e,t){return e.length>0&&e.length<=t&&"."!==e&&".."!==e&&!e.includes("/")&&!e.includes("\\")&&!function(e){for(const t of e){const e=t.codePointAt(0)??0;if(e<=31||127===e)return!0}return!1}(e)}function ct(e){return ut(e,128)&&!e.includes("?")&&!e.includes("#")}var dt=class{serverURL;apiRoute;depth;fetchFn;log;inflight=null;attempt=0;destroyDepth=0;constructor(e){this.serverURL=function(e){let t=e.length;for(;e.endsWith("/",t);)t-=1;return e.slice(0,t)}(e.serverURL);const t=e.apiRoute??"/api";this.apiRoute=t.startsWith("/")?t:`/${t}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=g(e.log??v)}canMerge(e){return null!==this.endpointOf(e)}endpointOf(e){try{const n=e.globalSlug;if(n)return ct(n)?`globals/${encodeURIComponent(n)}`:null;const r=e.collectionSlug??"",i=e.data.id;return ct(r)&&("number"==typeof(t=i)?Number.isFinite(t):"string"==typeof t&&ut(t,512))?`${encodeURIComponent(r)}/${encodeURIComponent(String(i))}`:null}catch{return null}var t}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};const t=this.attempt+=1,n=this.inflight;this.inflight=null;let r=null;const i=()=>this.attempt!==t;try{if(n?.abort(),i())return{status:"superseded"};const t=this.endpointOf(e);if(null===t)return i()?{status:"superseded"}:{status:"unavailable"};const o=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===o)return{status:"unavailable"};r=new AbortController,this.inflight=r;const s=`${this.serverURL}${this.apiRoute}/${t}`,a=await o(s,{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:r.signal});if(i())return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,s),{status:"unavailable"};const l=await a.json();return i()?{status:"superseded"}:null===l||"object"!=typeof l||Array.isArray(l)?(this.log("merge invalid",s),{status:"unavailable"}):{status:"merged",doc:l}}catch(e){return i()?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{this.inflight===r&&(this.inflight=null)}}destroy(){this.attempt+=1;const e=this.inflight;this.inflight=null,this.destroyDepth+=1;try{e?.abort()}finally{this.destroyDepth-=1}}},ht={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},ft={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},pt={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1};function detectProtocolProfile(e){return e.has("schema-json")?ht:e.has("document-events")||e.has("relationship-events")?ft:pt}var mt=class{callbacks;debounceMs;rootMargin;visible=/* @__PURE__ */new Set;mutation=null;intersection=null;debounceTimer=null;generation=0;constructor(e,t={}){this.callbacks=e,this.debounceMs=t.mutationDebounceMs??100,this.rootMargin=t.intersectionRootMargin??"200px"}start(e){const t=this.generation;this.stop();const n=t+1;if(this.generation!==n)return;let r=null,i=null;try{r=new MutationObserver(e=>{this.handleMutations(e,n)}),i=new IntersectionObserver(e=>{this.handleIntersection(e,n)},{rootMargin:this.rootMargin,threshold:0}),r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...Ze]})}catch(e){throw r?.disconnect(),i?.disconnect(),e}if(this.generation!==n)return r.disconnect(),void i.disconnect();this.mutation=r,this.intersection=i}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;const 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(const t of e){if("attributes"===t.type&&null!==t.attributeName&&Ze.includes(t.attributeName)&&(t.attributeName===Me||t.attributeName===Ke||1===t.target.nodeType&&t.target.hasAttribute(Me)))return!0;for(const e of t.addedNodes)if(gt(e))return!0;for(const e of t.removedNodes)if(gt(e))return!0}return!1}(e))return;null!==this.debounceTimer&&clearTimeout(this.debounceTimer);const n=setTimeout(()=>{this.isCurrentGeneration(t)&&this.debounceTimer===n&&(this.debounceTimer=null,this.callbacks.onStructuralChange())},this.debounceMs);this.debounceTimer=n}handleIntersection(e,t){for(const n of e){if(!this.isCurrentGeneration(t))return;const{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}};function gt(e){if(1!==e.nodeType)return!1;const t=e;return t.hasAttribute(Me)||null!==t.querySelector(`[${Me}]`)}var vt="[data-payload-field]";function yt(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydration??={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]}}function bt(){const e=yt();if(void 0===e||e.armed)return;e.armed=!0;const t=window,n=t.__REACT_DEVTOOLS_GLOBAL_HOOK__??=function(){const e=/* @__PURE__ */new Map;return{supportsFiber:!0,renderers:e,inject:t=>{const n=e.size+1;return e.set(n,t),n}}}(),r=n.onCommitFiberRoot;n.onCommitFiberRoot=function(t,n,...i){try{r?.call(this,t,n,...i)}catch{}const o=n?.containerInfo;void 0===e.onCommit?e.commits.push(o):e.onCommit(o)}}function wt(e){e.committed=!0;const t=e.waiters;e.waiters=[];for(const e of t)e()}function St(e,t){const n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function At(e,t,n){if(e.committed)return null;let r=null;const i=()=>{null!==r&&clearTimeout(r),r=null,t("committed")};return e.waiters.push(i),r=setTimeout(()=>{r=null,St(e,i),t("timed-out")},n),()=>{null!==r&&clearTimeout(r),r=null,St(e,i)}}var kt="__vue_app__";function Tt(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewVueHydration??={armed:!1,committed:!1,waiters:[]}}function Ct(e){return Object.prototype.hasOwnProperty.call(e,kt)?e[kt]:void 0}function Rt(){const e=Tt();if(void 0===e||e.armed)return;e.armed=!0;const t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,kt)&&Object.defineProperty(t,kt,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,kt,{value:e,writable:!0,configurable:!0,enumerable:!0});const t=Tt();void 0===t||t.committed||null===this.querySelector(vt)||function(e,t){const n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?wt(e):n.hook("app:suspense:resolve",()=>{e.committed||wt(e)})}(t,e)}})}function Pt(e){if(void 0===e.hydration)return void e.startNow();const t=t=>{e.later(()=>{$t(e,t)})},n="react"===e.hydration?function(e,t=5e3){bt();const n=yt();if(void 0===n)return null;if(void 0===n.onCommit){const e=e=>{!n.committed&&function(e){const t=e;return 9===t?.nodeType||null!=t?.querySelector?.(vt)}(e)&&wt(n)};n.onCommit=e;for(const t of n.commits.splice(0))e(t)}return At(n,e,t)}(t):function(e,t,n=5e3){Rt();const r=Tt();return void 0===r?null:(!r.committed&&function(e){for(let t=e.querySelector(vt);null!==t;t=t.parentElement)if(void 0!==Ct(t))return!0;return!1}(e)&&wt(r),At(r,t,n))}(e.root,t);null!==n?(e.defer(n),e.hydrated("waiting")):$t(e,"committed")}function $t(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()}var Nt=class{timeoutMs;onTimeout;handle=null;lastKick=0;constructor(e){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);const 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}},xt=class{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)}},Lt=/* @__PURE__ */new Set(["true","false","yes","no","on","off"]),Ft=/^[\d\s.,:+/-]+$/u,Et=/^[a-z][a-z0-9_-]*$/u,Ut=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,Mt=/* @__PURE__ */new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]);function It(e,t=13){if("string"!=typeof e)return!1;const n=e.trim();return!(n.length<t||Ft.test(n)||Lt.has(n.toLowerCase())||Et.test(n)||Ut.test(n))}function Ot(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function _t(e,t,n=13){const r=/* @__PURE__ */new Map,i=(e,t,n)=>{r.set(e,r.has(e)?null:{field:t,media:n})};for(const[r,o]of Object.entries(e)){if(ae.has(r))continue;const e=ce(r,t);if(It(o,n))i(o.trim(),e,!1);else if(Ot(o))if("string"==typeof o.url)i(o.url,e,!0);else if(!("id"in o)&&!("_id"in o))for(const[t,r]of Object.entries(o))!ae.has(t)&&It(r,n)&&i(r.trim(),`${e}.${t}`,!1)}return r}function Dt(e){if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||Mt.has(e.tagName))return!0;if(e.hasAttribute(Me)||e.hasAttribute("data-payload-no-bind")||e.hasAttribute("data-payload-owned")||Ue(e))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function zt(e){let t;for(let n=e.firstChild;null!==n;n=n.nextSibling){if(1===n.nodeType)return;if(3!==n.nodeType)continue;const e=n.data.trim();if(0!==e.length){if(void 0!==t)return;t=e}}return t}function Bt(e){return H(e)&&!e.startsWith("data-payload-")&&"value"!==e}function jt(e,t,n){let r=e.byElement.get(t);void 0===r&&(r={attributes:/* @__PURE__ */new Map},e.byElement.set(t,r));let i=e.byField.get(n.field);return void 0===i&&(i=/* @__PURE__ */new Set,e.byField.set(n.field,i)),i.add(t),r}function Ht(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(Dt(n))continue;const e=zt(n),r=void 0===e?void 0:t.values.get(e);null==r||r.media||(jt(t,n,r).text=r.field);for(const e of n.getAttributeNames()){if(!Bt(e))continue;const r=t.values.get(n.getAttribute(e)??"");null!=r&&(!r.media||"IMG"===n.tagName&&"src"===e)&&jt(t,n,r).attributes.set(e,r)}Ht(n,t)}}function Wt(e,t,n){const r=e.tagName;if(void 0!==t){const i={[Me]:t};if("A"===r){const e=n.get("href");void 0===e?i[Ie]="text":e!==t&&(i[_e]=e)}return{element:e,fieldName:t,matched:zt(e)??"",stamps:i}}if("IMG"===r){const t=n.get("src");if(void 0!==t){const r=n.get("alt");return{element:e,fieldName:t,matched:e.getAttribute("src")??"",attribute:"src",stamps:{[Me]:t,...void 0!==r&&r!==t?{[ze]:r}:{}}}}}const i=n.entries().next();if(i.done)return;const[o,s]=i.value;return{element:e,fieldName:s,matched:e.getAttribute(o)??"",attribute:o,stamps:{[Me]:s,[Oe]:o}}}function Vt(e,t){const n={values:t,byElement:/* @__PURE__ */new Map,byField:/* @__PURE__ */new Map};t.size>0&&!Dt(e)&&Ht(e,n);const r=e=>1===n.byField.get(e)?.size,i=[];for(const[e,t]of n.byElement){const n=void 0!==t.text&&r(t.text)?t.text:void 0,o=/* @__PURE__ */new Map;for(const[e,n]of t.attributes)r(n.field)&&o.set(e,n.field);const s=Wt(e,n,o);void 0!==s&&i.push(s)}return i}function qt(e){return 9===e.nodeType?e.body:e}function Gt(e,t,n,r){const i=[];for(const o of t){const{element:t}=o;if(!t.hasAttribute(Me)&&(!1===n||oe(nt(t),n))){for(const[e,n]of Object.entries(o.stamps))t.setAttribute(e,n);if(t.setAttribute(Ye,o.matched),void 0!==e.cache.add(t))e.observers.observeElement(t),e.log("autoBind",o.fieldName,"→",`<${t.tagName.toLowerCase()}>`,o.attribute??"text",JSON.stringify(o.matched),r),i.push(o);else{for(const e of Object.keys(o.stamps))t.removeAttribute(e);t.removeAttribute(Ye)}}}return i}var Kt,Jt=/* @__PURE__ */new Set(["__proto__","prototype","constructor"]);function Qt(e,t,n,r=!1){if(r&&void 0!==n){const r=Xt(e,`${t}_${n}`);if(void 0!==r)return r}const i=Xt(e,t);if(void 0!==i)return i;if(t.includes(".")){let n=e,r=!0;for(const e of t.split(".")){if(Jt.has(e)||null===n||"object"!=typeof n){r=!1;break}if(n=Xt(n,e),void 0===n){r=!1;break}}if(r)return n}return void 0===n?void 0:Xt(e,`${t}_${n}`)}function Xt(e,t){if(!Jt.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Yt(e,t,n,r){return Qt(e,n,t.locale??r,void 0!==t.locale)}function Zt(e,t,n,r){const i=Y(t);if(void 0===i)return;const o=[e.hrefField,e.srcField,e.altField];let s=i;for(const t of o){if(void 0===t||0===t.length)continue;const i=Y(Yt(n,e,t,r));if(void 0===i)return;s+=`|${t}=${i}`}return s}function en(e,t,n,r){const{warned:i,warn:o}=e;i.has(n)||t(n)||(i.add(n),o(`[live-preview] LP0201: no <… data-payload-field="${ce(n,r)}"> for field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`))}function tn(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function nn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function rn(e){const t=function(){if(void 0!==Kt)return Kt;const e=function(){const e=globalThis.trustedTypes;if("object"==typeof e&&null!==e)return"function"==typeof e.createPolicy?e:void 0}();try{Kt=void 0===e?null:e.createPolicy("payload-live-preview",{createHTML:e=>e})}catch{Kt=null}return Kt}();return null===t?e:t.createHTML(e)}var on=/* @__PURE__ */new Set(["open","value","checked","selected"]);function sn(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function an(e){if(e.tagName.toLowerCase().includes("-"))return!0;if(e.hasAttribute(Le)||e.hasAttribute("data-payload-owned"))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function ln(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!an(e)&&!an(t)}(e,t))return t;const r=function(e){const t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement&&e.contains(t)))return null;return{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}}(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||on.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(const 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){const r=function(e,t){const n=/* @__PURE__ */new Map;let r;for(const i of Array.from(e.children)){const e=sn(i,t);void 0!==e&&(n.has(e)?r??=e.slice(e.indexOf("=")+1):n.set(e,i))}return void 0!==r&&t.onDuplicateKey?.(e,r),n}(e,n),i=new Set(r.values()),o=Array.from(e.childNodes).filter(e=>!i.has(e)),s=/* @__PURE__ */new Set,a=/* @__PURE__ */new Set,l=Array.from(t.childNodes);let u=e.firstChild,c=0;for(let t=0;t<l.length;t+=1){const i=l[t];let d=null,h=i instanceof Element?sn(i,n):void 0;if(void 0!==h&&a.has(h)&&(h=void 0),void 0!==h){a.add(h);const e=r.get(h);if(void 0!==e&&!s.has(e)&&(d=un(e,i,n)===e?e:null,null===d)){e.replaceWith(i),s.add(i),u=i.nextSibling;continue}}else{for(;c<o.length;){const r=o[c];if(c+=1,!s.has(r)){if(dn(r,i)){d=un(r,i,n)===r?r:null,null===d&&(e.replaceChild(i,r),s.add(i),u=i.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(i instanceof Element)||void 0!==n&&dn(r,n)){c-=1;break}e.replaceChild(i,r),s.add(i),u=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,r),s.add(i),u=i.nextSibling;break}}}if(null===d&&s.has(i))continue}const f=d??i;for(s.add(f);null!==u&&u!==f&&!s.has(u)&&cn(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(const t of Array.from(e.childNodes))s.has(t)||t.remove()}(e,t,n),function(e){if(null===e)return;const{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});const[e,r]=n??[null,null];null!==e&&null!==r&&t.setSelectionRange(e,r)}catch{}}(r),e}function un(e,t,n){return e instanceof Element&&t instanceof Element?an(e)&&an(t)?e:ln(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function cn(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function dn(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}var hn=/* @__PURE__ */new Set;function fn(e){hn.has(e)||(hn.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("data-payload-")?"A binding inside CMS content is refused by design — 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 — 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)}.`))}var pn=/* @__PURE__ */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"]),mn=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),gn=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),vn=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),yn="aria-",bn="data-",wn={a:/* @__PURE__ */new Set(["href","target","rel","download","hreflang","type"]),img:/* @__PURE__ */new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:/* @__PURE__ */new Set([]),source:/* @__PURE__ */new Set(["src","srcset","sizes","type","media"]),audio:/* @__PURE__ */new Set(["src","controls","autoplay","loop","muted","preload"]),video:/* @__PURE__ */new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:/* @__PURE__ */new Set(["datetime"]),abbr:/* @__PURE__ */new Set(["title"]),q:/* @__PURE__ */new Set(["cite"]),blockquote:/* @__PURE__ */new Set(["cite"]),table:/* @__PURE__ */new Set(["summary"]),th:/* @__PURE__ */new Set(["colspan","rowspan","scope","headers","abbr"]),td:/* @__PURE__ */new Set(["colspan","rowspan","headers"]),col:/* @__PURE__ */new Set(["span"]),colgroup:/* @__PURE__ */new Set(["span"]),ol:/* @__PURE__ */new Set(["start","reversed","type"]),li:/* @__PURE__ */new Set(["value"]),code:/* @__PURE__ */new Set(["class"]),pre:/* @__PURE__ */new Set(["class"])},Sn=/* @__PURE__ */new Set(["href","src","cite","poster"]),An=class extends Error{name="SanitizerEnvironmentError"},kn=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"]),Tn=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function sanitizeHtml(e,t){return Cn(e,void 0,t)}function Cn(e,t,n){const r=Rn();if(!r)throw"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new An("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===e)return"";const i=function(e,t){const n=e?.policy??t??"strict";if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(wn))e.set(t,n);return{allowedTags:pn,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(pn);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of mn)r.add(e);const i=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(wn))i.set(e,t);for(const[t,n]of Object.entries(e.additionalAllowedAttributes??{})){const e=new Set(i.get(t));for(const t of n)e.add(t);i.set(t,e)}return{allowedTags:r,attrByTag:i,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t),o=r.createElement("template");return o.innerHTML=rn(e),Pn(o.content,i),o.innerHTML}function Rn(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[Tn];if(e)return e}if("undefined"!=typeof document)return document}function Pn(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?$n(n,t):8===n.nodeType&&n.remove()}function $n(e,t){const n=e.tagName.toLowerCase();if(!gn.has(n)||t.allowFormControls&&mn.has(n)){if(!t.allowedTags.has(n))return Pn(e,t),void e.replaceWith(...e.childNodes);!function(e,t,n){const r=n.attrByTag.get(t);for(const t of Array.from(e.attributes)){const i=t.name.toLowerCase();if(i.startsWith("on")||"style"===i)e.removeAttribute(t.name);else{if("strict"===n.mode){if(n.templateMode&&kn.has(i))continue;if("id"===i||"name"===i||i.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===i&&!0!==r?.has(i)||fn(i);continue}if(i.startsWith(bn)){n.allowedData.has(i)||(e.removeAttribute(t.name),fn(i));continue}if(vn.has(i)||i.startsWith(yn))continue}else if(vn.has(i)||i.startsWith(yn)||i.startsWith(bn))continue;r?.has(i)?Sn.has(i)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==i||Nn(t.value)||e.removeAttribute(t.name):e.removeAttribute(t.name)}}}(e,n,t),"a"===n&&function(e){const t=e.getAttribute("href");null!==t&&isExternalHttpUrl(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),Pn(e,t)}else e.remove()}function Nn(e){for(const t of e.split(",")){const e=t.trim();if(0===e.length)continue;const[n=e]=e.split(/\s/,1);if(!isSafeUrl(n))return!1}return!0}var xn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),Ln=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(Ln,e=>xn[e])}var Fn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}),En=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(En,e=>Fn[e])}var Un=/\{\{([\s\S]*?)\}\}/g;function Mn(e){const t=/* @__PURE__ */new Set;for(const n of e)if("object"==typeof n&&null!==n)for(const e of Object.keys(n))t.add(e);return t}function In(e,t,n,r,i){const o="object"==typeof t&&null!==t?t:null;return e.replace(Un,(e,s)=>null!==o&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(o,s)?escapeHtml(r(Reflect.get(o,s))):null===o&&"value"===s?escapeHtml(r(t)):"index"===s?String(n):null!==o&&!0===i?.has(s)?"":e)}function On(e){const t=e.children,n=t[0];if(void 0===n)return[];const r=[];for(const{name:e,value:i}of Array.from(n.attributes)){if(!H(e)||e.startsWith("data-payload-"))continue;let n=!0;for(let r=1;r<t.length&&n;r+=1)n=t[r]?.getAttribute(e)===i;n&&r.push([e,i])}return r}function _n(e,t){for(const[n,r]of t)e.hasAttribute(n)||e.setAttribute(n,r)}function Dn(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 zn(e){return null==e||""===e}function Bn(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function jn(e,t,n,r){return e.set(t,n),function(e,t){for(const n of e.keys()){if(e.size<=t)break;e.delete(n)}}(e,r),n}var Hn=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],Wn=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],Vn=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,qn=/* @__PURE__ */new Map;function Gn(e){const t=Bn(qn,e);if(void 0!==t)return t;const n=new Set(Hn);for(const t of e.matchAll(Vn)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const r={};for(const e of n)r[e]=Wn;const i={additionalAllowedTags:[...n],additionalAllowedAttributes:r,allowFormControls:!0,templateMode:!0};return jn(qn,e,i,64)}var Kn="data-payload-key",Jn="data-payload-nested-key",Qn="data-payload-nested-template";function Xn(e){const t=Zn(e.container,e.patches,e);return null===t?null:er(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function Yn(e,t){return t.hasAttribute(Jn)&&t.hasAttribute(Qn)}function Zn(e,t,n){const r=function(e,t,n){const{template:r,nextItems:i,forceRender:o=!1,store:s,sanitizerPolicy:a}=n,l=s.get(e),u=On(e),c=Mn(i),d=Array.from(e.children),h=ar(d,Kn),f=/* @__PURE__ */new Set,p=[];for(let s=0;s<i.length;s+=1){const m=i[s],g=sr(m);let v=void 0===g?d[s]??null:lr(h,g)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);const y=t.replaces.has(s),b=o||t.renders.has(s)||null===v?ur(e.ownerDocument,r,m,s,a,u,c):void 0;if(null===b)return null;const w=void 0===b?[]:tr(y?null:v,b,m,void 0===g?void 0:l?.get(g),n);if(null===w)return null;p.push([s,v,b,w,y])}return p}(e,function(e){const t=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set;for(const r of e)"insert"===r.kind||"update"===r.kind?t.add(r.index):"replace"===r.kind&&(t.add(r.index),n.add(r.index));return{renders:t,replaces:n}}(t),n);return null===r?null:[e,r,n.nextItems]}function er(e,t,n){const[r,i,o]=e,s=/* @__PURE__ */new Set;let a=!1;for(const[e,o,l,u,c]of i){let i=o;if(void 0!==l){const e=!(!n.morph||c||null===o)&&ln(o,l,{keyAttributes:[Kn,Jn],retainChildrenOf:Yn,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===o;if(!e)for(const[e,t]of u)null!==e&&(rr(e,t),t.replaceWith(e));for(const[,,e]of u)void 0!==e&&er(e,t,n);e?a=!0:(null!==o&&(o.replaceWith(l),a=!0),i=l)}if(null===i)continue;const d=r.children[e]??null;i!==d&&(r.insertBefore(i,d),a=!0),s.add(i)}for(const e of Array.from(r.children))s.has(e)||(e.remove(),a=!0);const l=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(r,t);l.clear();for(const e of o)or(l,e);return a}function tr(e,t,n,r,i){const o=ar(null===e?[]:nr(e),Jn),s=[];for(const e of nr(t)){const t=e.getAttribute(Jn);if(null===t)continue;const a=lr(o,t)??null,l=e.getAttribute(Qn),u=l?a:null,c=u?.getAttribute(Qn)??null;let d;if(l){const o=ir(n,t);if(void 0!==o||null!==u){const n=o??[],s=E(null===u?[]:ir(r,t)??[],n),a=null!==u&&c!==l;if((s.length>0||a)&&(d=Zn(u??e,s,{template:l,nextItems:n,forceRender:a,store:i.store,sanitizerPolicy:i.sanitizerPolicy})??void 0,void 0===d))return null}}s.push([u,e,d])}return s}function nr(e){return Array.from(e.querySelectorAll(`[${Jn}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Jn))return!1;n=n.parentElement}return n===e})}function rr(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||e.removeAttribute(n.name);for(const n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function ir(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function or(e,t){const n=sr(t);void 0!==n&&e.set(n,t)}function sr(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function ar(e,t){const n=/* @__PURE__ */new Map;for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(void 0===i)continue;const o=i.getAttribute(t);if(null===o)continue;const s=n.get(o);void 0===s?n.set(o,[i]):s.push(i)}return n}function lr(e,t){return e.get(t)?.pop()}function ur(e,t,n,r,i,o,s){const a=Cn(In(t,n,r,Dn,s),i,Gn(t)),l=e.createElement("template");l.innerHTML=rn(a);const u=l.content.firstElementChild;if(!u)return null;_n(u,o);const c=sr(n);return void 0!==c&&u.setAttribute(Kn,c),u}function cr(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`))}function dr(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`))}var hr=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;planFragments(e){const t=this.deps.strategies.fragment;return void 0===t?null:fr(t,t.plan(this.deps.root,e))}escalateUnfaithful(e,t,n){if(e.routeRefreshed)return;const{fragment:r,route:i}=this.deps.strategies,o=void 0===r?void 0:function(e){const t=[];for(const n of e){const e=n.fragmentBoundary;if(void 0===e)return;t.includes(e)||t.push(e)}return t}(n);if(void 0!==r&&void 0!==o)return this.state.escalatedCount+=n.length,e.pendingFragments+=o.length,void this.runFragments(e,t,fr(r,o));void 0!==i&&(this.state.escalatedCount+=n.length,this.refreshRoute(e,t,i))}hasUnboundChange(e,t){const{deps:n,state:r}=this;if(e.baseline||e.routeRefreshed)return!1;const i=he(n.cache,e.touched,e.locale,t);let o=0;for(const e of i)q(r,e)&&(o+=1);const[s]=i;return void 0!==s&&"escalate"===n.onUnfaithfulPatch&&void 0!==n.strategies.route&&(n.log("route","LP0807",`field "${s}" has no binding; refreshing the route`),r.escalatedCount+=o,!0)}hasRouteBinding(e){for(const[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){const{deps:r,state:i}=this,o=new AbortController;i.fragmentController=o;const s=()=>i.isCurrent(e)&&!o.signal.aborted,{emitter:a}=r,{message:l}=e,u=e.revision.revision,c=e.receivedAt,d={root:r.root,revision:u,receivedAt:c,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof l.collectionSlug?l.collectionSlug:void 0,globalSlug:"string"==typeof l.globalSlug?l.globalSlug:void 0,signal:o.signal,isCurrent:s,log:(e,t)=>{r.log("fragment",e,t)},morph:(e,t)=>{!function(e,t){const n=e.ownerDocument.createElement("template");n.innerHTML=rn(t);const r=e.cloneNode(!1);r.append(n.content),ln(e,r,{keyAttributes:[Kn]})}(e,t)},patch:n=>{this.patchFallback(e,t,n)},rendered:(t,n,r)=>{e.pendingFragments-=1,a.emitWhile("fragmentRender",{element:t,id:n,key:r,status:"rendered",revision:u,receivedAt:c},s)},failed:(t,n,i,o,l)=>{e.pendingFragments-=1;const d=`fragment "${n}" fell back to patch: ${l}`;r.log("fragment",o,d),a.emitWhile("error",{error:new Error(d),context:"fragment",code:o},s),a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"failed",code:o,revision:u,receivedAt:c},s)}};let h={rendered:0,failed:0,superseded:0};try{h=await n.strategy.render(d,n.boundaries)}catch(i){if(r.log("fragment","LP0801",i),s()){for(const r of n.boundaries)this.patchFallback(e,t,r);h={rendered:0,failed:n.boundaries.length,superseded:0}}}i.fragmentStats.rendered+=h.rendered,i.fragmentStats.failed+=h.failed,i.fragmentStats.superseded+=h.superseded,s()&&(i.fragmentController===o&&(i.fragmentController=null),e.pendingFragments=0,h.rendered>0&&this.host.restoreGuesses(e,t),0===r.scheduler.pendingCount&&i.complete(e),this.host.revealPending(e),s()&&0!==h.rendered&&0!==a.listenerCount("afterUpdate")&&a.emitWhile("afterUpdate",{data:t,updatedCount:h.rendered,durationMs:Date.now()-c,revision:u,receivedAt:c,source:"fragment"},s))}async refreshRoute(e,t,n){const{deps:r,state:i}=this;if(e.routeRefreshed)return i.routeStats.loopStopped+=1,void r.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,r){const{state:i}=this;null!==i.routeRetry&&clearTimeout(i.routeRetry),i.routeRetry=setTimeout(()=>{i.routeRetry=null,i.isCurrent(e)&&this.runRoute(e,t,n)},r)}async runRoute(e,t,n){const{deps:r,state:i}=this,o=i.routeStats,s=new AbortController;i.routeController=s;const a=()=>i.isCurrent(e)&&!s.signal.aborted;let l;try{l=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:s.signal,isCurrent:a,log:(e,t)=>{r.log("route",e,t)},retryAfter:r=>{this.armRouteRetry(e,t,n,r)}})}catch(e){r.log("route","LP0801",e),l="failed"}if(a()){if(i.routeController===s&&(i.routeController=null),"refreshed"===l){if(o.refreshes+=1,i.lastAppliedIdentity=/* @__PURE__ */new WeakMap,this.host.restoreGuesses(e,t),this.host.rebuildCache(),!a())return;return this.host.reapply(e,t),void(r.emitter.listenerCount("afterUpdate")>0&&r.emitter.emitWhile("afterUpdate",{data:t,updatedCount:r.cache.elementCount,durationMs:Date.now()-e.receivedAt,revision:e.revision.revision,receivedAt:e.receivedAt,source:"route"},a))}"failed"===l?o.failed+=1:"refused"===l&&(o.refused+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){cr(this.deps,this.state,e)}warnUnsupportedStrategy(e){dr(this.deps,this.state,e)}patchFallback(e,t,n){for(const[r,i]of this.deps.cache.entries())for(const o of i){if(o.fragmentBoundary!==n)continue;const i=Yt(t.fields,o,r,e.locale);void 0!==i&&this.deps.scheduler.schedule({target:o,value:this.host.transform(o,i,t.fields,()=>!0),allFields:t.fields,revision:e.revision,data:t})}}};function fr(e,t){const n=new Set(t);return{boundaries:t,strategy:e,covers:e=>void 0!==e.fragmentBoundary&&n.has(e.fragmentBoundary)}}function pr(e,t,n,r,i){const o=e.transformValue;if(void 0===o)return n;try{const e=o(t.fieldName,n,{element:t.element,allFields:r},i),s=f(e);if(!i())return n;if(s)throw new TypeError(`Transform for "${t.fieldName}" returned a thenable; transforms must be synchronous`);return e}catch(t){if(!i())return n;const r=t instanceof Error?t:new Error(String(t));return e.emitter.emit("error",{error:r,context:"transform",code:"LP0602"}),n}}var mr=/* @__PURE__ */new Set,gr=class{constructor(e,t,n){this.deps=e,this.state=t,this.strategies="undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e,t){return{planFragments:()=>null,escalateUnfaithful:()=>{},hasUnboundChange:(n,r)=>{if(n.baseline)return!1;const i=he(e.cache,n.touched,n.locale,r);for(const e of i)q(t,e);return!1},hasRouteBinding:()=>!1,runFragments:()=>Promise.resolve(),refreshRoute:()=>(k("route refreshes"),Promise.resolve()),warnFragmentFallback:n=>{k("server-rendered fragments"),cr(e,t,n)},warnUnsupportedStrategy:n=>{dr(e,t,n)}}}(e,t):new hr(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,r,i)=>pr(e,t,n,r,i),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}})}deps;state;strategies;handleUpdate(e,t,n){const{deps:r,state:i}=this;if(r.heartbeat.kick(),i.protocol.observe(function(e){const 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),r.log),void 0===e.data)return void(void 0!==e.protocolVersion&&i.protocol.applyVersion(e.protocolVersion,r.log));if(void 0===n)return;const o=i.relationships.edit(e);null!==o&&r.emitter.emit("relationshipUpdate",{detail:o,timestamp:Date.now()}),"string"==typeof e.locale&&(i.locale=e.locale),Array.isArray(e.fieldSchemaJSON)&&(i.schema=e.fieldSchemaJSON,i.schemaIndex=$(e.fieldSchemaJSON));const s={revision:n,message:e,locale:i.locale,schema:i.schema,schemaIndex:i.schemaIndex,receivedAt:Date.now(),forceRender:null!==o||Se(i.activeUpdate),touched:/* @__PURE__ */new Set,baseline:!1,invalidated:/* @__PURE__ */new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},a=i.activeUpdate;if(i.abortStrategies(),null===a||a.completed||(i.supersededCount+=1),i.activeUpdate=s,r.scheduler.acceptRevision(n),i.updateCount+=1,void 0===e.protocolVersion||(i.protocol.applyVersion(e.protocolVersion,r.log),i.isCurrent(s))){if(r.connection.markConnected()){if(r.a11y?.announceConnected(),r.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!i.isCurrent(s))return;if(r.log("connection","disconnected","→","connected"),!i.isCurrent(s))return}this.processUpdate(s).catch(e=>{r.log("update failed:",e)})}}async processUpdate(e){const{deps:t,state:n}=this,r=await this.resolveIncomingFields(e);if(null===r||!n.isCurrent(e))return;const i=this.dataFor(e,r);t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:i,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,i,!1)}dataFor(e,t){const{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){const{deps:r,state:i}=this,o=$e(r.dependencies,r.cache.dependencyMap()),s=i.changes.diff(t.fields,o);if(s.baseline&&!n&&"off"!==r.autoBind)if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)k("auto-binding");else{const n=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,r,i){const o=performance.now(),s=qt(e.root),a=_t(n,r),l=null===s?[]:Gt(e,Vt(s,a),i,"on the first message");t.autoBindGuesses=function(e,t){const n=/* @__PURE__ */new Set;for(const{fieldName:e,stamps:r}of t){n.add(e);for(const e of[_e,ze]){const t=r[e];void 0!==t&&n.add(t)}}const r=/* @__PURE__ */new Map;for(const[t,i]of e)null!==i&&n.has(i.field)&&r.set(t,i);return{fields:n,values:r}}(a,l),t.autoBindSearchMs=performance.now()-o,l.length}(r,i,t.fields,e.locale,n)}e.baseline=s.baseline,e.invalidated=n?mr:s.invalidated,e.touched=n?mr:/* @__PURE__ */new Set([...s.changed,...s.invalidated]),this.scheduleAllFields(e,t)}async resolveIncomingFields(e){const{deps:t,state:n}=this,r=e.message.data??{};if(null===t.merger)return r;if("admin"===detectProtocolProfile(n.protocol.observed).populatesRelationships)return r;const i=n.merges.decide(t,e);if(!i.merge)return i.fields;const{message:o}=e,s=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:o.collectionSlug,globalSlug:o.globalSlug,data:r,locale:e.locale});if(!s.leading)return this.applyMerged(e,s.result).catch(e=>{t.log("update failed:",e)}),i.fields;const a=await s.result;return n.isCurrent(e)?"merged"===a.status?(n.merges.recordMerged(a.doc),a.doc):"superseded"===a.status?null:i.fields:null}async applyMerged(e,t){const{state:n}=this,r=await t;"merged"===r.status&&n.isCurrent(e)&&(n.merges.recordMerged(r.doc),this.applyFields(e,this.dataFor(e,r.doc),!0))}scheduleAllFields(e,t){const{deps:n,state:r}=this;if(!r.isCurrent(e))return;const i=()=>r.isCurrent(e),o=this.ownerKeysForUpdate(e,t.fields),{touched:s}=e,a=n.strategies.route,l=this.strategies.hasUnboundChange(e,o);if(void 0!==a&&!e.routeRefreshed&&(l||a.plan(n.root,s)||this.strategies.hasRouteBinding(s)))return void this.strategies.refreshRoute(e,t,a);const u=this.strategies.planFragments(s),c=n.skipUnchanged;let d=0;for(const[s,a]of n.cache.entries()){if(!i())return;for(const l of a){if(!1!==o&&!oe(l.owner,o))continue;if(!0===u?.covers(l)){if(n.revealEditedField){const n=Yt(t.fields,l,s,e.locale);r.revealLedger.note(e,l,n)}continue}const a=l.strategyKind??ne(l.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(l);continue}"fragment"===a&&null===u&&this.strategies.warnFragmentFallback(l);const h=Yt(t.fields,l,s,e.locale);if(void 0===h){r.absentFields.add(s);continue}if(n.revealEditedField&&r.revealLedger.note(e,l,h),!i())return;const f=pr(n,l,h,t.fields,i);if(!i())return;const p=c?Zt(l,f,t.fields,e.locale):void 0,m=r.lastAppliedIdentity.get(l.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&m===p&&!e.invalidated.has(s)){r.skippedUnchangedCount+=1;continue}const g={target:l,value:f,allFields:t.fields,revision:e.revision,data:t,valueIdentity:p};n.scheduler.schedule(g),d+=1}}(function(e,t,n,r){const{cache:i}=e;if(0===i.fieldCount)return;if(!1!==r&&!function(e,t){for(const n of e.values())if(oe(n.owner,t))return!0;return!1}(i,r))return;const o=de(i,n,r);for(const[r,i]of Object.entries(t)){if(ae.has(r))continue;if(tn(i)){en(e,o,r,n);continue}if(!nn(i)||o(r))continue;const t=ce(r,n);for(const[r,s]of Object.entries(i))tn(s)&&!ae.has(r)&&en(e,o,`${t}.${r}`,n)}})({cache:n.cache,warned:r.warnedOrphanFields,warn:n.warn},t.fields,e.locale,o),null!==u&&u.boundaries.length>0&&(e.pendingFragments=u.boundaries.length,this.strategies.runFragments(e,t,u)),0===d&&0===e.pendingFragments&&(r.complete(e),this.revealPending(e))}restoreGuesses(e,t){const{deps:n,state:r}=this;if("off"!==n.autoBind&&null!==r.autoBindGuesses&&("undefined"==typeof __LEAN_BUILD__||!__LEAN_BUILD__)){const i=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,r,i){const o=t.autoBindGuesses,s=qt(e.root);if(null===o||0===o.fields.size||null===s)return 0;const a=new Map(o.values);for(const[e,t]of _t(n,r)){if(null===t||!o.fields.has(t.field))continue;const n=a.get(e);void 0===n?a.set(e,t):n?.field!==t.field&&a.set(e,null)}Gt(e,Vt(s,a),i,"after a server render").length}(n,r,t.fields,e.locale,i)}}ownerKeysForUpdate(e,t){const{deps:n,state:r}=this;if(!n.scopeBindingsByOwner)return!1;const{message:i}=e,o=function(e){if(ie(e.globalSlug))return[(t=e.globalSlug,`global:${t}`)];var t;if(!ie(e.collectionSlug))return null;const n=re(e.collectionSlug);return ie(e.documentId)?[n,re(e.collectionSlug,e.documentId)]:[n]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:se(t)});return null!==o||r.warnedUnattributableMessage||(r.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),o}onFlush(e){const{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`));const{revision:r,data:i}=e;if(void 0===r)return;const o=n.activeUpdate;if(null===o||!n.isCurrent(o)||!p(o.revision,r))return;0===o.pendingFragments&&n.complete(o);const s=()=>n.isCurrent(o)&&p(o.revision,r);if(this.revealPending(o),!s())return;const a=n.unfaithfulPatches;a.length>0&&(n.unfaithfulPatches=[],void 0!==i&&this.strategies.escalateUnfaithful(o,i,a),!s())||0!==e.applied&&void 0!==i&&(t.a11y?.announceUpdate(e.applied),s()&&(function(e,t){for(const n of e)n.dispatchEvent(new CustomEvent(xe,{detail:t,bubbles:!1}));e.length}(t.cache.islands,{fields:i.fields,revision:r.revision,receivedAt:o.receivedAt,locale:o.locale}),s()&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:i,updatedCount:e.applied,durationMs:e.durationMs,revision:r.revision,receivedAt:o.receivedAt,source:"patch"},s)))}revealPending(e){const t=this.state.revealLedger.commit(e);if(void 0!==t)try{this.revealBinding(t)}catch(e){this.deps.log("reveal",e)}}revealField(e){const t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":this.revealBinding(t)}revealBinding(e){const{element:t}=e,n=t.ownerDocument.defaultView;if(null===n)return"no-element";const r=`${e.owner??""} ${e.fieldName}`;return this.state.revealer.reveal(r,t,n)}},vr=class{apply;debounceMs;maxWaitMs;isVisible;gateThresholdValue;gateDisabled;getCacheSize;onFlush;scheduleFrame;cancelFrame;pending=/* @__PURE__ */new Map;replay=/* @__PURE__ */new Map;activeFlushes=/* @__PURE__ */new Set;debounceTimer=null;debounceToken=0;deadlineTimer=null;frameHandle=null;frameToken=0;windowUntil=0;activeRevision=null;activeRevisionCancelled=!1;constructor(e,t){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){if(this.activeRevisionCancelled)return;if(null===this.activeRevision||!p(e.revision,this.activeRevision))return}const 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){var t,n;null!==this.activeRevision&&p(e,this.activeRevision)||null!==this.activeRevision&&(t=e,n=this.activeRevision,(t.generation!==n.generation?t.generation-n.generation:t.revision-n.revision)<0)||(this.cancelScheduledWork(),this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1)}cancelRevision(e){null!==this.activeRevision&&p(e,this.activeRevision)&&(this.cancelScheduledWork(),this.clearWork(),this.activeRevisionCancelled=!0)}flushNow(){return this.cancelScheduledWork(),this.flush()}notifyVisible(e){const t=this.replay.get(e);if(!t)return;if(this.replay.delete(e),!this.isCurrent(t))return;const n=performance.now(),r=this.didApply(t)?1:0;this.onFlush?.(this.statsFor(t,r,0,performance.now()-n,1===r?[t.target.fieldName]:[]))}retarget(e){this.retargetBuffer(this.pending,e),this.retargetBuffer(this.replay,e);for(const t of this.activeFlushes)this.retargetBuffer(t,e)}forget(e){this.pending.delete(e),this.replay.delete(e);for(const 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(){const e=Date.now(),t=e>=this.windowUntil;if(this.windowUntil=e+this.debounceMs,t)return void this.requestFrame();const n=this.debounceToken+=1,r=this.debounceTimer;if(this.debounceTimer=null,null!==r&&clearTimeout(r),this.debounceToken!==n)return;const i=setTimeout(()=>{this.debounceToken===n&&(this.debounceTimer=null,this.pending.size>0&&this.requestFrame())},this.debounceMs);this.debounceToken===n&&(this.debounceTimer=i),null===this.deadlineTimer&&this.maxWaitMs>this.debounceMs&&(this.deadlineTimer=setTimeout(()=>{this.deadlineTimer=null,this.pending.size>0&&this.requestFrame()},this.maxWaitMs))}requestFrame(){const e=this.frameToken+=1,t=this.frameHandle;if(this.frameHandle=null,null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1;const r=this.scheduleFrame(()=>{this.frameToken===e&&(n=!0,this.frameHandle=null,this.flush())});n||this.frameToken!==e||(this.frameHandle=r)}flush(){const e=performance.now();this.clearDeadline();const t=this.gateActive,n=this.pending;this.pending=/* @__PURE__ */new Map;let r=0;const i=[];let o,s=0;this.activeFlushes.add(n);try{for(const e of n.values()){if(!this.isCurrent(e))continue;const n=!t||this.isVisible(e.target.element);this.isCurrent(e)&&(o??=e,n?(this.replay.delete(e.target.element),this.didApply(e)&&(r+=1,i.push(e.target.fieldName))):(this.replay.set(e.target.element,e),s+=1))}}finally{this.activeFlushes.delete(n)}const a=this.statsFor(o,r,s,performance.now()-e,i);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&p(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||(t=this.apply,!Q.has(t));var t}retargetBuffer(e,t){const n=e.get(t.element);void 0!==n&&(n.target.fieldName===t.fieldName&&n.target.locale===t.locale?n.target=t:e.delete(t.element))}clearWork(){this.pending.clear(),this.replay.clear();for(const e of this.activeFlushes)e.clear()}statsFor(e,t,n,r,i){return{applied:t,appliedFields:i,deferred:n,durationMs:r,...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(){const 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)}},yr=[0,500,1e3,2e3],br=class{deps;state=new Re;pipeline;writer;rootSentinel=null;observedRoot=null;constructor(e){const{emitter:t,renderers:n}=e,r=void 0===e.log?v:g(e.log),i=void 0===e.warn?b:g(e.warn),o=e.root??("undefined"!=typeof document?document:void 0);if(void 0===o)throw new Error("LivePreviewRuntime: no document; pass options.root");const s=new st({filter:e=>!isInsideIsland(e)}),a=new mt({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&l.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),l=new vr(X(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=>a.isVisible(e),getCacheSize:()=>s.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),u=new m(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],r),t.emit("documentSave",{timestamp:Date.now()})},onFocusField:e=>{this.deps.revealEditedField&&this.pipeline.revealField(e)},onInvalid:(e,n)=>{if("token"===e){const e=new Error(`Preview token rejected (origin: ${n})`);t.emit("error",{error:e,context:"token",code:"LP0502"})}"shape"!==e&&"type"!==e||this.state.warnedProtocolShape||(this.state.warnedProtocolShape=!0,i(`[live-preview] LP0503: ${n} 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,i(`[live-preview] LP0501: a message from ${n} 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.`)),r("LP0501 message rejected:",e,n)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),c=e.dataMerge;this.deps={emitter:t,cache:s,observers:a,scheduler:l,bus:u,connection:new xt,heartbeat:new Nt({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:n,resolveRenderer:e.resolveRenderer??(e=>n[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,root:o,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:/* @__PURE__ */(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??C,onHeartbeatTimeout:e.onHeartbeatTimeout,log:r,warn:i,a11y:T(e),merger:void 0===c?null:new dt({serverURL:c.serverURL,...void 0!==c.apiRoute?{apiRoute:c.apiRoute}:{},...void 0!==c.depth?{depth:c.depth}:{},...void 0!==c.fetchFn?{fetchFn:c.fetchFn}:{},log:r}),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:W(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new Pe(this.deps,this.state),this.pipeline=new gr(this.deps,this.state,()=>{this.rebuildCache()})}start(){const{state:e}=this;if(e.isRunning())return!1;e.started=!0,e.suspended=!1;try{return function(e){"react"===e.hydration?bt():"vue"===e.hydration&&Rt();const{root:t}=e;if(!function(e){return 9===e.nodeType}(t)||"loading"!==t.readyState)return void Pt(e);const n=()=>{e.isRunning()&&e.later(()=>{Pt(e)})};t.addEventListener("DOMContentLoaded",n,{once:!0}),e.defer(()=>{t.removeEventListener("DOMContentLoaded",n)})}(this.startupHost()),!0}catch(e){throw this.rollbackFailedStart(),e}}startupHost(){const{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(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=wr(t.root)?Sr(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(const n of yr){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;const e=this.release();return this.state.suspended=!0,e&&this.deps.emitter.emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0}destroy(){const{state:e,deps:t}=this;if(!e.isRunning()&&!e.suspended)return;const 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(){const{state:e,deps:t}=this;e.activeUpdate=null,e.started=!1;const n=e.deferredStart;e.deferredStart=null,null!==n&&this.runCleanup(n);for(const 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(){const{root:e}=this.deps;wr(e)&&"undefined"!=typeof MutationObserver&&(this.rootSentinel?.disconnect(),this.rootSentinel=new MutationObserver(()=>{this.followReplacedRoot()}),this.rootSentinel.observe(e.documentElement,{childList:!0}))}followReplacedRoot(){const{root:e}=this.deps;if(!this.state.isRunning()||!wr(e))return!1;const t=Sr(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(t,n){const{cache:r,scheduler:i}=t,o=n.protocol.negotiation,s=n.activeUpdate,a=n.lastFlush,l=[],u=/* @__PURE__ */new Set,c=[];for(const[e,t]of r.entries()){l.push(e);for(const n of t)void 0!==n.owner&&u.add(n.owner),void 0!==n.guessed&&c.push({field:e,matched:n.guessed,attribute:n.targetAttribute??("IMG"===n.element.tagName?"src":void 0)})}return{version:e,started:n.started,status:t.connection.status,origins:{trusted:[...t.readyTargets()],locked:t.lockedOrigin()},protocol:{ours:o.ours,theirs:o.theirs,negotiated:o.negotiated,capabilities:[...o.capabilities].sort(),observed:[...o.observed].sort(),profile:detectProtocolProfile(o.observed).name},revisions:{accepted:n.updateCount,superseded:n.supersededCount,completed:n.completedCount,skippedUnchanged:n.skippedUnchangedCount,active:null===s?void 0:s.revision.revision},bindings:{elements:r.elementCount,fields:r.fieldCount,fieldNames:l.sort(),absentFields:[...n.absentFields].sort(),orphanFields:[...n.warnedOrphanFields].sort(),ownerScoped:t.scopeBindingsByOwner,owners:[...u].sort(),guessed:c.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:t.autoBind,searchMs:n.autoBindSearchMs}},route:{handler:void 0!==t.strategies.route,...n.routeStats},fidelity:{mode:t.onUnfaithfulPatch,unfaithful:n.unfaithfulCount,escalated:n.escalatedCount,fields:[...n.unfaithfulFields].sort()},hydration:{mode:t.hydration??"off",state:n.hydration},fragments:{handler:void 0!==t.strategies.fragment,inFlight:s?.pendingFragments??0,...n.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(t.renderers).sort()}}(this.deps,this.state)}buildCacheAndObserve(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=t.cache.buildFromRoot(t.root);if(t.log("cache",n),e.isRunning()&&(t.emitter.emitWhile("cacheRefresh",n,()=>e.isRunning()),e.isRunning()))for(const n of t.cache.values()){if(!e.isRunning())return;t.observers.observeElement(n.element)}}rebuildCache(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=/* @__PURE__ */new Map;for(const e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),e.isRunning()){for(const e of t.cache.values()){const r=n.get(e.element);r?.fieldName===e.fieldName?t.scheduler.retarget(e):t.scheduler.forget(e.element),n.delete(e.element)}for(const e of n.values())t.scheduler.forget(e.element)}}onHeartbeatTimeout(){const{state:e,deps:t}=this;if(!e.isRunning())return;t.bus.advanceGeneration();const n=e.activeUpdate;e.activeUpdate=null,null!==n&&t.scheduler.cancelRevision(n.revision),t.merger?.destroy(),e.merges.destroy();const r=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}if(e.isRunning()){if(r&&this.isIdleDisconnected()){if(t.a11y?.announceDisconnected(),t.emitter.emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.isIdleDisconnected()),!e.isRunning())return;if(this.isIdleDisconnected()&&t.log("connection","connected","→","disconnected"),!e.isRunning())return}this.sendReadyAfterStart()}}sendReadyAfterStart(){try{this.deps.sendReady(this.deps.readyTargets())}catch(e){this.reportError(e,"ready","LP0606")}}reportError(e,t,n){const r=e instanceof Error?e:new Error(String(e));this.deps.emitter.emit("error",{error:r,context:t,code:n})}isIdleDisconnected(){return this.state.isRunning()&&"disconnected"===this.deps.connection.status&&null===this.state.activeUpdate}};function wr(e){return 9===e.nodeType}function Sr(e){return e.body}var EventEmitter=class{#t=/* @__PURE__ */new Map;#n=/* @__PURE__ */new Map;on(e,t){return this.#r(this.#t,e,t)}once(e,t){return this.#r(this.#n,e,t)}off(e,t){this.#i(this.#t,e,t),this.#i(this.#n,e,t)}async emit(e,t){await this.#o(e,t)}async emitWhile(e,t,n){return this.#o(e,t,n)}async#o(e,t,n){const r=()=>n?.()??!0;if(!r())return!1;const i=this.#t.get(e);if(i)for(const n of[...i]){if(!r())return!1;if(await this.#s(n,t,e),!r())return!1}if(!r())return!1;const o=this.#n.get(e);if(o&&o.size>0){const n=[...o];this.#n.delete(e);for(const i of n){if(!r())return!1;if(await this.#s(i,t,e),!r())return!1}}return r()}listenerCount(e){return(this.#t.get(e)?.size??0)+(this.#n.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#t.clear(),void this.#n.clear();this.#t.delete(e),this.#n.delete(e)}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#t.keys())e.add(t);for(const t of this.#n.keys())e.add(t);return[...e]}#r(e,t,n){let r=e.get(t);return r||(r=/* @__PURE__ */new Set,e.set(t,r)),r.add(n),()=>{this.#i(e,t,n)}}#i(e,t,n){const r=e.get(t);void 0!==r&&(r.delete(n),0===r.size&&e.delete(t))}async#s(e,t,n){try{await e(t)}catch(e){const t="string"==typeof n||"number"==typeof n?String(n):"<event>";y(`[live-preview] LP0601: handler for "${t}" threw:`,e)}}};function isInIframe(){if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch{return!0}}function isInPopup(){return"undefined"!=typeof window&&null!=window.opener}function isInPreviewContext(){return isInIframe()||isInPopup()}function isDevMode(){const e=function(){if("undefined"==typeof process)return;const e=process.env.NODE_ENV;return"string"==typeof e?e:void 0}();if(void 0!==e)return"production"!==e;if("undefined"!=typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}var Ar=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,kr=/^https?:\/\/[^/?#\s]+$/i,Tr=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],OriginDetector=class{#a;constructor(e={}){const t=/* @__PURE__ */new Set;for(const n of e.additionalOrigins??[]){const e=Cr(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){const t=e.referrer??("undefined"!=typeof document?document.referrer:"");if(t.length>0)try{const e=new URL(t).origin;e&&"null"!==e&&(n=e)}catch{}}const r=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??isDevMode());this.#a=[t,n,r,void 0!==n,void 0]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#a[4]?e===this.#a[4]:!!this.#a[0].has(e)||0===this.#a[0].size&&void 0!==this.#a[1]&&e===this.#a[1]||!(!this.#a[2]||!Ar.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#a[4]=e,!0)}unlockOrigin(){const e=this.#a[4];return this.#a[4]=void 0,e}get lockedOrigin(){return this.#a[4]}enumerate(){if(void 0!==this.#a[4])return[this.#a[4]];const e=new Set(this.#a[0]);if(0===this.#a[0].size&&void 0!==this.#a[1]&&e.add(this.#a[1]),this.#a[2])for(const t of Tr)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#a[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#a[0].size>0||this.#a[2]||void 0!==this.#a[1])}get isReferrerOnlyTrust(){return!(this.#a[0].size>0||this.#a[2]||void 0===this.#a[1])}};function Cr(e){const t=e.trim();if(0!==t.length)try{const e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return;if(!kr.test(e.origin))return;return e.origin}catch{return}}var Rr=()=>{},Pr=class{#l;#u;#c=/* @__PURE__ */new Set;#a="staging";constructor(e,t){this.#l=e,this.#u=t}assertOpen(){if("closed"===this.#a)throw new Error(`Plugin context for "${this.#l}" is no longer active`)}get active(){return"active"===this.#a}eligible(){return"closed"!==this.#a}own(e){return this.assertOpen(),this.#d({kind:"cleanup",acquire:void 0,finalize:void 0,cleanup:e,disposed:!1})}stage(e,t,n){this.assertOpen();const r={kind:e,acquire:t,finalize:n,cleanup:void 0,disposed:!1},i=this.#d(r);if("active"===this.#a)try{this.#h(r)}catch(e){throw this.#f(r),e}return i}counts(){const e={transform:0,renderer:0,subscription:0,cleanup:0};for(const t of this.#c)e[t.kind]+=1;return e}commit(){if("staging"!==this.#a)throw new Error(`Plugin context for "${this.#l}" cannot be committed`);this.#a="committing";try{for(const e of this.#c)this.#h(e);this.#a="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#a){this.#a="closed";for(const e of[...this.#c].reverse())this.#f(e);this.#c.clear()}}#d(e){return this.#c.add(e),()=>{this.#f(e)}}#h(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;const t=e.acquire();e.cleanup=t??Rr}#f(e){if(e.disposed)return;e.disposed=!0,this.#c.delete(e);const t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{f(t())&&this.#u(`plugin "${this.#l}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#u(`plugin "${this.#l}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#u(`plugin "${this.#l}" cleanup failed:`,e)}}},$r=class{#p;#m;#g=/* @__PURE__ */new Set;constructor(e,t){this.#p=e,this.#m=t}on(e,t){return this.#v("on",e,t)}once(e,t){return this.#v("once",e,t)}off(e,t){const n=t;for(const t of[...this.#g])t.event===e&&t.handler===n&&t.dispose()}emit(e,t){return this.#m.assertOpen(),this.#p.emit(e,t)}emitWhile(e,t,n){return this.#m.assertOpen(),this.#p.emitWhile(e,t,()=>{if(!this.#m.eligible())return!1;const e=n();return!!this.#m.eligible()&&e})}listenerCount(e){let t=0;for(const n of this.#g)n.event===e&&(t+=1);return t}removeAllListeners(e){for(const t of[...this.#g])void 0!==e&&t.event!==e||t.dispose()}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#g)e.add(t.event);return[...e]}#v(e,t,n){this.#m.assertOpen();const r=n,i=[...this.#g].find(n=>n.kind===e&&n.event===t&&n.handler===r);if(void 0!==i)return i.dispose;let o=Rr,s=!0;const a=async t=>{this.#m.active&&s&&("once"===e&&o(),await n(t))},l={kind:e,event:t,handler:r,dispose:Rr};return o=this.#m.stage("subscription",()=>this.#p[e](t,a),()=>{s=!1,this.#g.delete(l)}),l.dispose=o,this.#g.add(l),o}},Nr=class{#p;#y;#b;#w;#u;#S=/* @__PURE__ */new Map;#A=/* @__PURE__ */new Map;#k=/* @__PURE__ */new Map;#T=/* @__PURE__ */new Set;#C=/* @__PURE__ */new Map;#R=Promise.resolve();#P=0;constructor(e){this.#p=e.events,this.#y=e.config,this.#b=e.registerFieldRenderer,this.#u=g(e.log);const t=e.onTransformError;this.#w=void 0===t?void 0:g((...e)=>{const n=e[0];try{return t(n)}catch(e){return void this.#u("transform error reporter failed:",e)}})}register(e){return this.#P>0?this.#$(e,!1):this.#N(()=>this.#$(e,!0))}unregister(e){return this.#P>0?this.#x(e,!1):this.#N(async()=>{await this.#x(e,!0)})}destroyAll(){return this.#P>0?this.#L(!1):this.#N(async()=>{await this.#L(!0)})}applyTransforms(e,t,n,r){const i=this.#C.get(e);if(void 0===i||0===i.length)return t;let o=t;for(const s of[...i]){if(!s.active)continue;const{transform:i}=s;if(!1===r?.())return t;try{o=i(o,{fieldName:e,element:n.element,allFields:n.allFields});const s=f(o);if(!1===r?.())return t;if(s)throw new TypeError(`Transform for "${e}" returned a Promise/thenable; transforms must be synchronous`)}catch(n){if(!1===r?.())return t;const i=n instanceof Error?n:new Error(String(n));return this.#u(`transform for "${e}" failed:`,i),this.#w?.(i),t}}return o}list(){return[...this.#S.keys()]}snapshot(){const e=[],t=(e,t,n,r)=>{const i=r.counts();return{name:e,version:t,state:n,registrations:{transforms:i.transform,renderers:i.renderer,subscriptions:i.subscription,cleanups:i.cleanup}}};for(const[n,r]of this.#A)e.push(t(n,void 0,"initializing",r.scope));for(const[n,r]of this.#S)e.push(t(n,r.plugin.version,"active",r.scope));for(const t of this.#k.keys())e.push({name:t,version:void 0,state:"tearing-down",registrations:{transforms:0,renderers:0,subscriptions:0,cleanups:0}});return e}get size(){return this.#S.size}async#$(t,n){if(this.#S.has(t.name)||this.#A.has(t.name)||this.#k.has(t.name))return void this.#u(`plugin "${t.name}" already registered`);const r=function(e,t){if(void 0!==e){if(void 0!==e.runtime&&!function(e,t){const n=function(e){const t=/^v?(\d+)\.(\d+)\.(\d+)/.exec(e.trim());if(null!==t)return[Number(t[1]),Number(t[2]),Number(t[3])]}(e);return void 0!==n&&t.split("||").some(e=>{const r=e.trim().split(/\s+/).filter(e=>e.length>0);return 0===r.length?""===e.trim()&&""===t.trim():r.every(e=>function(e,t){const n=t.trim();if(""===n||"*"===n)return!0;const r=/^(\^|~|>=|<=|>|<|=)?\s*v?(\d+)\.(\d+)\.(\d+)/.exec(n);if(null===r)return!1;const i=r[1]??"=",o=[Number(r[2]),Number(r[3]),Number(r[4])],s=function(e,t){for(let n=0;n<3;n+=1){const r=(e[n]??0)-(t[n]??0);if(0!==r)return r}return 0}(e,o);switch(i){case"=":return 0===s;case">":return s>0;case">=":return s>=0;case"<":return s<0;case"<=":return s<=0;case"~":return s>=0&&e[0]===o[0]&&e[1]===o[1];case"^":return!(s<0)&&(o[0]>0?e[0]===o[0]:o[1]>0?0===e[0]&&e[1]===o[1]:0===e[0]&&0===e[1]&&e[2]===o[2]);default:return!1}}(n,e))})}(t,e.runtime))return`declares runtime ${e.runtime}, this runtime is ${t}`;if(void 0!==e.protocol){if(!Number.isInteger(e.protocol)||e.protocol<1)return`declares an invalid protocol version ${String(e.protocol)}`;if(e.protocol<4)return`declares protocol ${String(e.protocol)}, this runtime speaks ${String(4)}`}}}(t.compat,e);if(void 0!==r)return void this.#F(t.name,r);const i=new Pr(t.name,this.#u),o=this.#E(t.name,i),s={scope:i,cancelled:!1};this.#A.set(t.name,s);try{if(await this.#U(()=>t.init(o),n),s.cancelled)return;i.commit()}catch(e){return i.close(),void(s.cancelled||this.#u(`plugin "${t.name}" init failed:`,e))}finally{this.#A.get(t.name)===s&&this.#A.delete(t.name)}this.#S.set(t.name,{plugin:t,scope:i}),this.#u(`plugin "${t.name}" registered`)}#F(e,t){const n=`plugin "${e}" refused: ${t}`;this.#u(n),this.#p.emit("error",{error:new Error(n),context:"plugin",code:"LP0103"})}#E(e,t){return{events:new $r(this.#p,t),registerFieldRenderer:e=>{t.stage("renderer",()=>{const t=this.#b(e);return"function"==typeof t?t:void 0})},registerTransform:(e,n)=>{const r={transform:n,active:!1};t.stage("transform",()=>{r.active=!0;const t=this.#C.get(e);return void 0===t?this.#C.set(e,[r]):t.push(r),()=>{r.active=!1;const t=this.#C.get(e);if(void 0===t)return;const n=t.indexOf(r);n>=0&&t.splice(n,1),0===t.length&&this.#C.delete(e)}})},registerCleanup:e=>{t.own(e)},getConfig:()=>this.#y,log:(...t)=>{this.#u(`[${e}]`,...t)}}}#x(e,t){const n=this.#A.get(e);if(void 0!==n)return n.cancelled=!0,n.scope.close(),Promise.resolve();const r=this.#k.get(e);if(void 0!==r)return this.#T.has(e)?Promise.resolve():t?this.#M(r):r;const i=this.#S.get(e);if(void 0===i)return Promise.resolve();this.#S.delete(e),i.scope.close();const o=Promise.resolve().then(()=>this.#I(e,i.plugin,t));return this.#k.set(e,o),o.then(()=>{this.#k.get(e)===o&&this.#k.delete(e)}),o}async#I(e,t,n){if(void 0!==t.destroy){this.#T.add(e);try{await this.#U(()=>t.destroy?.(),n)}catch(t){this.#u(`plugin "${e}" destroy failed:`,t)}finally{this.#T.delete(e)}}}async#L(e){for(const e of this.#A.values())e.cancelled=!0,e.scope.close();const t=[...this.#S.keys()];for(const n of t)await this.#x(n,e)}async#U(e,t){t?await this.#M(Promise.resolve().then(e)):await e()}async#M(e){this.#P+=1;try{await e}finally{this.#P-=1}}#N(e){const t=this.#R.then(e);return this.#R=t.catch(e=>{this.#u("plugin manager mutation failed:",e)}),t}},xr=class{#O;#_;#D=/* @__PURE__ */new Map;constructor(e){this.#O=e,this.#_={...e}}get renderers(){return this.#_}resolve(e){return this.#_[e]}register(e){const t=e.name,n={renderer:e},r=this.#D.get(t);void 0===r?this.#D.set(t,[n]):r.push(n),this.#_[t]=e;let i=!0;return()=>{if(!i)return;i=!1;const e=this.#D.get(t);if(void 0===e)return;const r=e.indexOf(n);if(r<0)return;const o=r===e.length-1;if(e.splice(r,1),0===e.length&&this.#D.delete(t),!o)return;const s=e.at(-1),a=s?.renderer??this.#O[t];void 0===a?Reflect.deleteProperty(this.#_,t):this.#_[t]=a}}},Lr={1:"left",2:"center",3:"right",4:"justify"},Fr=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function Er(e){const t=e.format;return"string"==typeof t&&Fr.has(t)?t:"number"==typeof t?Lr[t]:void 0}function Ur(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function Mr(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function Ir(e){const t=Er(e),n=Ur(e),r=[];return void 0!==t&&r.push(`lp-align-${t}`),n>0&&r.push(`lp-indent-${String(n)}`),0===r.length?"":` class="${r.join(" ")}"`}var Or=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function _r(e){return"object"==typeof e&&null!==e?e:void 0}function Dr(e){return _r(e)}function zr(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function Br(e){return"string"==typeof e&&e.length>0?e:void 0}function jr(e){const t=Br(e.title)??Br(e.name)??Br(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}var Hr=' target="_blank" rel="noopener noreferrer"',Wr=(e,t)=>{const n=t.renderChildren(e.children??[]),r=_r(e.fields),i=function(e,t){if("internal"===t?.linkType)return function(e){const t=_r(_r(e)?.value),n=t?.url;if("string"==typeof n&&n.length>0)return n;const r=t?.slug;return"string"==typeof r&&r.length>0?`/${r}`:void 0}(t.doc);const n=t?.url??e.url;return"string"==typeof n&&n.length>0?n:void 0}(e,r);if(void 0===i||!isSafeUrl(i))return n;const o="string"==typeof e.title?` title="${escapeHtml(e.title)}"`:"";return`<a href="${escapeHtmlAttribute(i)}"${function(e,t,n){if(!0===t?.newTab||isExternalHttpUrl(n))return Hr;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?Hr:` target="${escapeHtml(r)}"`}(e,r,i)}${o}>${n}</a>`};function Vr(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=Vr(n);return t}function qr(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function Gr(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var Kr=/* @__PURE__ */new Map;function Jr(e){return Kr.get(e)}var Qr=".lp-block:empty,.lp-inline-block:empty";function Xr(e,t,n,r){const i=_r(e.fields)??{},o="string"==typeof i.blockType?i.blockType:"",s=zr(o),a=""===s?r:`${r} ${r}--${s}`;if(""!==o){const e=Jr(o)??Jr(s);if(e)return e(i,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(o,a)}return`<${n} class="${a}"></${n}>`}function Yr(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var Zr={text:e=>{let t=escapeHtml("string"==typeof e.text?e.text:"");const 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)=>{const n=t.renderChildren(e.children??[]);return`<p${Mr(e)}${Ir(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=Or.has(n)?n:"h2",i=t.renderChildren(e.children??[]);return`<${r}${Mr(e)}${Ir(e)}>${i}</${r}>`},list:(e,t)=>{const n="string"==typeof e.listType?e.listType:"bullet",r="number"===n?"ol":"ul",i="number"===n&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",o="check"===n?' role="list"':"",s=t.renderChildren(e.children??[]);return`<${r}${Mr(e)}${Ir(e)}${i}${o}>${s}</${r}>`},listitem:(e,t)=>{const n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${Ir(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${Mr(e)}${Ir(e)}${r}>${n}</li>`},link:Wr,autolink:Wr,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${Mr(e)}${Ir(e)}>${n}</blockquote>`},code:e=>{const t=zr("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(Vr(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${zr(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=Dr(e.value);if(void 0===t)return"";const n=t.url;if("string"!=typeof n||!isSafeUrl(n))return"";const r="string"==typeof t.mimeType?t.mimeType:"";return r.startsWith("video/")?function(e,t){return`<video controls${qr(e)}><source src="${escapeHtmlAttribute(t)}"${Gr(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${Gr(e)}></audio>`}(t,n):""===r||r.startsWith("image/")?function(e,t){const n="string"==typeof e.alt?escapeHtml(e.alt):"";return`<img src="${escapeHtmlAttribute(t)}" alt="${n}"${qr(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){const n="string"==typeof e.filename?escapeHtml(e.filename):escapeHtml(t);return`<a href="${escapeHtmlAttribute(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{const t="string"==typeof e.relationTo?e.relationTo:"",n=_r(e.value),r=escapeHtml((n&&jr(n))??`#${t}`),i=zr(t),o=""===i?' class="lp-relation"':` class="lp-relation lp-relation--${i}"`,s=n?.url;return"string"==typeof s&&isSafeUrl(s)?`<a href="${escapeHtmlAttribute(s)}"${o}>${r}</a>`:`<span${o}>${r}</span>`},block:(e,t)=>Xr(e,t,"div","lp-block"),inlineBlock:(e,t)=>Xr(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${Mr(e)}><tbody>${t.renderChildren(e.children??[])}</tbody></table>`,tablerow:(e,t)=>`<tr>${t.renderChildren(e.children??[])}</tr>`,tablecell:(e,t)=>{const n="number"==typeof e.headerState?e.headerState:0,r=3&n?"th":"td";return`<${r}${1===n?' scope="col"':2===n?' scope="row"':""}${Yr("colspan",e.colSpan)}${Yr("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},ei=/* @__PURE__ */new Map,ti=!1;function ni(e){if("object"!=typeof e||null===e)return!1;if(!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function ri(e,t){const n=(r=e.type,ei.get(r)??Zr[r]);var r;return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function ii(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\n";if(void 0===e.children)return"";let t="";for(const n of e.children)t+=ii(n);return t}function oi(e="text"){const t=/* @__PURE__ */new WeakSet;return{name:e,render:/* @__PURE__ */X((e,n)=>{const r=e.element,i=function(e){return null==e?"":ni(e)?ni(t=e)?t.root.children.map(ii).join("\n").trim():"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);var t}(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName)return function(e){return null!==e.querySelector(":scope > :not(br)")}(r)&&!r.hasAttribute("data-payload-text")?(function(e,t,n){e.has(t)||(e.add(t),b(`[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,r,e.fieldName),!1):void(i.includes("\n")||i.includes("\r")?r.innerHTML=rn(function(e){return escapeHtml(e).replace(/\r\n|\r|\n/g,"<br>")}(i)):r.textContent=i);r.value=i})}}var si=/* @__PURE__ */new Set,ai=/* @__PURE__ */new Set,li=/* @__PURE__ */new Set(["DIV","SECTION","ARTICLE"]),ui={name:"richText",render:/* @__PURE__ */X((e,t,n)=>{const r=e.element;if(zn(t))return void(r.textContent="");const i=n.sanitizerPolicy;if(void 0!==n.renderRichText){const o=n.renderRichText(t,{fieldName:e.fieldName,element:r,locale:n.locale});return void(r.innerHTML=rn(Cn(o,i)))}if(ni(t)){const o=/* @__PURE__ */new Map,s=function(e,t){const n=e.cloneNode(!1);n.innerHTML=rn(t);const r=function(e,t){const n=e.firstElementChild;if(null!==n?.nextElementSibling||t.children.length<2)return null;if(!li.has(n.tagName)||n.hasAttribute(Me))return null;for(const e of t.children)if(e.tagName===n.tagName&&e.className===n.className)return null;return n}(e,n)??e,i=/* @__PURE__ */new Map,o=n.querySelectorAll(Qr);if(o.length>0&&null!==r.firstElementChild){const e=[];ci(r,n,e);for(const[t,n]of e)t.replaceWith(n),n.matches(Qr)||i.set(t.className,!1);for(const e of o)null!==e.parentNode&&i.set(e.className,!0)}return r.replaceChildren(...n.childNodes),i}(r,Cn(function(e,t={}){if(!ni(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=ri(r,t);return n},resolveAlignment:Er,resolveIndent:Ur,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==Rn()?sanitizeHtml(n):(function(){if(!ti){ti=!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)=>{o.set(t,e)}}),i));for(const[t,r]of s){const i=o.get(t);void 0!==i&&di(e,n,i,r)}return}if("string"!=typeof t)return!1;r.innerHTML=rn(Cn(t,i))})};function ci(e,t,n){if(e.children.length!==t.children.length)return;let r=e.firstElementChild,i=t.firstElementChild;for(;null!==r&&null!==i;)i.matches(Qr)?n.push([i,r]):ci(r,i,n),r=r.nextElementSibling,i=i.nextElementSibling}function di(e,t,n,r){r&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);const i=r?ai:si;i.has(n)||(i.add(n),b(`[live-preview] ${r?`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().`))}var hi={name:"html",render(e,t,n){if(zn(t))return void(e.element.textContent="");const r="string"==typeof t?t:Dn(t);e.element.innerHTML=rn(Cn(r,n.sanitizerPolicy))}},fi=/* @__PURE__ */new WeakSet;function pi(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:isSafeUrl(n)?{kind:"safe",url:n}:(fi.has(e)||(fi.add(e),b(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function mi(e,t=e=>e){return{name:e,render(e,n,r){const i=e.element;if(zn(n))return void function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(i);const o=Dn(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName){if("A"===i.tagName){const n=e.hrefField,s=void 0===n||0===n.length?t(o):Qt(r.allFields,n,r.locale,void 0!==e.locale),a=pi(i,e.fieldName,s);"safe"===a.kind?i.setAttribute("href",a.url):"unsafe"===a.kind&&i.removeAttribute("href")}i.textContent=o}else i.value=o}}}var gi=mi("url"),vi=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,yi=mi("email",function(e){const t=e.trim();return vi.test(t)||!t.includes("@")?t:`mailto:${t}`}),bi=["src","srcset","sizes"];function wi(e){for(const t of bi)e.removeAttribute(t)}function Si(e,t,n){e.src=t;const r=function(e){if(void 0===e?.sizes)return;const t=[];for(const n of Object.values(e.sizes))"string"==typeof n.url&&"number"==typeof n.width&&isSafeUrl(n.url)&&t.push(`${Ai(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&isSafeUrl(e.url)&&t.push(`${Ai(e.url)} ${String(e.width)}w`),t.join(", ")):void 0}(n);if(void 0===r)return e.removeAttribute("srcset"),void e.removeAttribute("sizes");e.setAttribute("srcset",r)}function Ai(e){return e.replace(/[\s,]/g,encodeURIComponent)}var ki={name:"image",render:/* @__PURE__ */X((e,t,n)=>{const r=e.element;if(zn(t))return void Ti(r);const i=void 0!==e.locale,{media:o,candidate:s}=function(e,t,n,r){const i=void 0!==e.srcField&&e.srcField.length>0?Qt(n.allFields,e.srcField,n.locale,r):t,o=Dr(i);return{media:o,candidate:void 0===o?i:o.url}}(e,t,n,i),a=pi(r,e.fieldName,s);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===r.tagName){const t=r;Si(t,a.url,o);const s=function(e,t,n,r,i){if(void 0!==t&&t.length>0){const e=Qt(n,t,r,i);return"string"==typeof e?e:void 0}return e?.alt}(o,e.altField,n.allFields,n.locale,i);return void(void 0!==s&&(t.alt=s))}r.style.backgroundImage=`url('${function(e){return e.replace(/['"()\\]/g,"\\$&")}(a.url)}')`}else Ti(r)})};function Ti(e){"IMG"===e.tagName?wi(e):e.style.backgroundImage=""}var Ci={name:"upload",render:/* @__PURE__ */X((e,t)=>{const n=e.element;if(zn(t))return void Ri(n);const r=Dr(t);if(void 0===r)return!1;const i=pi(n,e.fieldName,r.url);if("none"===i.kind)return!1;if("unsafe"===i.kind)return void Ri(n);const o=i.url;if("IMG"===n.tagName){const e=n;return Si(e,o,r),void(void 0!==r.alt&&(e.alt=r.alt))}if("A"===n.tagName)return n.setAttribute("href",o),void(n.textContent=r.filename??o);const s=escapeHtml(r.filename??o);n.innerHTML=rn(`<a href="${escapeHtmlAttribute(o)}">${s}</a>`)})};function Ri(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):wi(e)}var Pi={name:"relationship",render(e,t){const n=e.element;if(zn(t))return n.removeAttribute("href"),void(n.textContent="");if("A"===n.tagName&&!Array.isArray(t)){const r=pi(n,e.fieldName,_r(t)?.url);"safe"===r.kind?n.setAttribute("href",r.url):"unsafe"===r.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map($i).join(", "):$i(t)}};function $i(e){const t=_r(e);return void 0===t?Dn(e):jr(t)??""}var Ni={name:"select",render(e,t,n){const r=e.element,i=zn(t)?[]:function(e){return Array.isArray(e)?e.map(Dn):[Dn(e)]}(t);if("SELECT"!==r.tagName){if("INPUT"===r.tagName&&"radio"===r.type){const e=r;return void(e.checked=i.includes(e.value))}r.textContent=i.map(e=>function(e,t){const n=t.schema?.options;if(!Array.isArray(n))return e;for(const t of n){const n=_r(t);if(void 0!==n&&Dn(n.value)===e)return"string"==typeof n.label?n.label:e}return e}(e,n)).join(", ")}else!function(e,t){if(e.multiple)for(const n of Array.from(e.options))n.selected=t.includes(n.value);else e.value=t[0]??""}(r,i)}},xi=/* @__PURE__ */new Set(["","false","0","off","no"]),Li={name:"checkbox",render(e,t){const n=e.element,r=function(e){return"boolean"==typeof e?e:"string"==typeof e?!xi.has(e.trim().toLowerCase()):"number"==typeof e?0!==e:null!=e}(t);"INPUT"!==n.tagName||"checkbox"!==n.type?n.hasAttribute("aria-checked")?n.setAttribute("aria-checked",r?"true":"false"):n.textContent=r?"true":"false":n.checked=r}},Fi=/* @__PURE__ */new Map,Ei=/* @__PURE__ */new Map;function Ui(e,t){const n=e??"";if(null==t)return n;const r=Mi(t);return"{}"===r?n:`${n}|${r}`}function Mi(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Mi(e)).join(",")}]`;const t=e,n=Object.keys(t).sort(),r=[];for(const e of n){const n=t[e];void 0!==n&&r.push(`${JSON.stringify(e)}:${Mi(n)}`)}return`{${r.join(",")}}`}var Ii=/* @__PURE__ */new Set(["short","medium","long","full"]),Oi=/* @__PURE__ */new Set(["short","medium","long","full"]),_i=/^[A-Za-z]{3}$/u,Di=/^[0-4]$/u;function zi(e){return{kind:"date",options:e}}function Bi(e){return{kind:"number",options:e}}var ji=/* @__PURE__ */new WeakSet;function Hi(e,t,n,r){if(void 0===t||""===t)return;const i=function(e){const t=e.indexOf(":"),n=-1===t?e:e.slice(0,t),r=-1===t?void 0:e.slice(t+1);switch(n){case"date":return void 0===r?zi({dateStyle:"medium"}):Ii.has(r)?zi({dateStyle:r}):void 0;case"time":return void 0===r?zi({timeStyle:"short"}):Oi.has(r)?zi({timeStyle:r}):void 0;case"datetime":return void 0===r?zi({dateStyle:"medium",timeStyle:"short"}):Ii.has(r)?zi({dateStyle:r,timeStyle:"short"===r?"short":"medium"}):void 0;case"number":if(void 0===r)return Bi({});if(!Di.test(r))return;return Bi({minimumFractionDigits:Number(r),maximumFractionDigits:Number(r)});case"currency":if(void 0===r||!_i.test(r))return;return Bi({style:"currency",currency:r.toUpperCase()});case"percent":return void 0===r?Bi({style:"percent"}):void 0;default:return}}(t);if(void 0!==i){if(i.kind===e)return i.options}else!function(e,t,n){ji.has(e)||(ji.add(e),b(`[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,r,t)}var Wi={name:"date",render(e,t,n){const r=e.element;if(zn(t))return void("INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent=""));const i="number"==typeof t?t:Dn(t),o=new Date(i),s=!Number.isNaN(o.getTime()),a=String(i);"INPUT"!==r.tagName?("TIME"===r.tagName&&r.setAttribute("datetime",s?o.toISOString():a),r.textContent=s?function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Hi("date",t.format,t.element,t.fieldName)??Vi;try{return function(e,t){const n=Ui(e,t);return Bn(Ei,n)??jn(Ei,n,new Intl.DateTimeFormat(e,t),64)}(r,i).format(e)}catch{return e.toISOString()}}(o,e,n):a):r.value=s?function(e,t){const n=`${String(t.getFullYear()).padStart(4,"0")}-${qi(t.getMonth()+1)}-${qi(t.getDate())}`,r=`${qi(t.getHours())}:${qi(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${r}`:"time"===e?r:t.toISOString()}(r.type,o):a}},Vi={dateStyle:"medium",timeStyle:"short"};function qi(e){return String(e).padStart(2,"0")}var Gi={name:"number",render(e,t,n){const r=e.element;if(zn(t))return void("INPUT"===r.tagName?r.value="":r.textContent="");const i="number"==typeof t?t:Number(Dn(t));Number.isNaN(i)?r.textContent=Dn(t):"INPUT"!==r.tagName?r.textContent=function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Hi("number",t.format,t.element,t.fieldName);try{return function(e,t){const n=Ui(e,t);return Bn(Fi,n)??jn(Fi,n,new Intl.NumberFormat(e,t),64)}(r,i).format(e)}catch{return String(e)}}(i,e,n):r.value=String(i)}},Ki={name:"array",render:/* @__PURE__ */X((e,t,n)=>{const r=e.element;if(zn(t))return void(r.textContent="");if(!Array.isArray(t))return!1;const i=e.arrayTemplate;if(void 0!==i&&i.length>0){const e=function(e,t){const n=Mn(t);let r="";for(let i=0;i<t.length;i+=1)r+=In(e,t[i],i,Dn,n);return r}(i,t),o=n.sanitizerPolicy,s=Gn(i),a=On(r);r.innerHTML=rn(Cn(e,o,s));for(const e of Array.from(r.children))_n(e,a);return}r.textContent=t.map(Dn).join(e.arraySeparator??", ")})};function Ji(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,n=/* @__PURE__ */new WeakMap,r=/* @__PURE__ */new WeakMap;return{name:"structural-array",render:/* @__PURE__ */X((i,o,s)=>{const a=zn(o)?[]:o;if(!Array.isArray(a))return!1;const l=i.element,u=i.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,n){e.has(t)||(e.add(t),b(`[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,l,i.fieldName),!1;const c=e.get(l),d=Qi(l),h=E(c?.values??d.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e}),a),f=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)}(c,u,d);if(0===h.length&&!f)return e.set(l,{values:a.slice(),template:u,domSnapshot:d}),!1;!function(e,t,n,r,i){const o=i.map(Xi),s=/* @__PURE__ */new Set,a=o.find(e=>!(void 0===e||!s.has(e)&&(s.add(e),1)));if(void 0!==a&&Yi(e,t,n,a),o.some(e=>void 0===e)&&Zi(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.`),r?.length===i.length&&i.length>1){const i=new Set(r.map(Xi).filter(e=>void 0!==e)),s=o.some(e=>void 0!==e&&i.has(e));i.size>0&&!s&&Zi(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,l,i.fieldName,c?.values,a);const p=Xn({template:u,container:l,patches:h,nextItems:a,store:r,forceRender:f,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{Yi(n,e,i.fieldName,t)}});return null!==p&&(e.set(l,{values:a.slice(),template:u,domSnapshot:Qi(l)}),!!p&&void 0)})}}function Qi(e){return Array.from(e.children,e=>e.getAttribute(Kn))}function Xi(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Yi(e,t,n,r){Zi(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${r}"; later ones pair by position. Make \`id\` unique per item.`)}function Zi(e,t,n,r){let i=e.get(t);void 0===i&&(i=/* @__PURE__ */new Set,e.set(t,i)),i.has(n)||(i.add(n),b(`[live-preview] ${r}`))}var eo=/* @__PURE__ */new Map;function to(e,t){return{name:e,render(){k(t)}}}var no=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),ro=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"});function io(e){return void 0===e?void 0:!e}var oo,LivePreviewClient=class{#z=new EventEmitter;#B;#j;#H;#S;#u;#W=!1;#V=!1;#q=!1;#G=null;constructor(e={}){const t=function(e){const t="v1"===e.defaults?ro:no;return{...e,skipUnchanged:e.skipUnchanged??t.skipUnchanged,disableReferrerDetection:e.disableReferrerDetection??t.disableReferrerDetection,eventSourcePolicy:e.eventSourcePolicy??t.eventSourcePolicy,sanitizerPolicy:e.sanitizerPolicy??t.sanitizerPolicy}}(e),n=t.serverURL??"";!function(e){if("v1"!==e.defaults&&""!==(e.serverURL??"")&&null==e.mergeDepth)throw new Error("payload-live-preview: `serverURL` needs an explicit `mergeDepth` under the 2.0 defaults — choose the population depth deliberately (0 for none), or pass `defaults: 'v1'` to keep the 1.x default of 1 while migrating (ADR 0007, entry 10).")}({defaults:e.defaults,serverURL:n,mergeDepth:t.mergeDepth});const r=t.debug??isDevMode();this.#u=r?(...e)=>{w("[live-preview]",...e)}:v,this.#B=new OriginDetector(R({additionalOrigins:t.allowedOrigins,enableReferrerDetection:io(t.disableReferrerDetection),enableLocalhostMatching:io(t.disableLocalhostMatching)})),this.#B.isProductionUnconfigured&&this.#u("no trusted origin could be detected — set allowedOrigins"),this.#j=new xr(function(){const e=[ui,hi,gi,yi,ki,Ci,Pi,Ni,{...Ni,name:"radio"},Li,Wi,Gi,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[to("array","structural arrays"),to("blocks","structural arrays")]:[Ki,{...Ki,name:"blocks"}]];return function(e=[]){const t={};for(const n of e)t[n.name]=n;for(const[e,n]of eo)t[e]=n;return Object.freeze(t)}([oi("text"),oi("textarea"),...e,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[]:[Ji()]])}()),this.#S=new Nr({events:this.#z,config:Object.freeze({...t}),registerFieldRenderer:e=>this.#j.register(e),onTransformError:e=>{this.#z.emit("error",{error:e,context:"transform",code:"LP0602"})},log:this.#u}),this.#H=new br(R({root:t.root,renderers:this.#j.renderers,resolveRenderer:(e,n)=>t.resolveRenderer?.(e,n)??this.#j.resolve(e),renderRichText:t.renderRichText,sanitizerPolicy:t.sanitizerPolicy,transformValue:(e,t,n,r)=>this.#S.applyTransforms(e,t,n,r),originMatcher:e=>this.#B.matches(e),readyTargets:()=>this.#B.enumerate(),emitter:this.#z,dataMerge:""===n?void 0:R({serverURL:n,apiRoute:t.apiRoute,depth:t.mergeDepth,fetchFn:t.mergeFetch}),debounceMs:t.debounceMs,heartbeatMs:t.heartbeatMs,intersectionRootMargin:t.intersectionRootMargin,scopeBindingsByOwner:t.scopeBindingsByOwner,skipUnchanged:t.skipUnchanged,revealEditedField:t.revealEditedField,autoBind:t.autoBind,eventSourcePolicy:t.eventSourcePolicy,dependencies:t.dependencies,strategies:t.strategies,disableVisibilityGate:t.disableVisibilityGate,visibilityGateThreshold:t.visibilityGateThreshold,enableA11y:t.enableA11y,a11yLocale:t.a11yLocale,onHeartbeatTimeout:()=>{this.#B.unlockOrigin()},lockedOrigin:()=>this.#B.lockedOrigin,validateToken:t.validateToken,log:this.#u})),this.#z.on("connect",e=>{this.#B.lockOrigin(e.origin)}),!1!==t.autoStart&&this.start()}start(){if(this.#V)return!1;if(this.#W)return this.#H.start(),!0;if(!isInPreviewContext())return!1;const e=this.#H.start();return e&&(this.#W=!0),e}suspend(){return!(this.#V||!this.#W)&&this.#H.suspend()}resume(){return!(this.#V||!this.#W)&&this.#H.start()}destroy(){if(null!==this.#G)return this.#G;let e,t;this.#V=!0;const n=new Promise((n,r)=>{e=n,t=r});this.#G=n;const r=()=>{this.#z.removeAllListeners(),this.#q=!0};try{this.#H.destroy(),this.#S.destroyAll().finally(r).then(e,t)}catch(e){r(),t(e)}return n}async use(e){if(this.#V)throw new Error("LivePreviewClient: already destroyed");await this.#S.register(e)}async unuse(e){if(this.#q)throw new Error("LivePreviewClient: already destroyed");await this.#S.unregister(e)}refreshCache(){this.#H.refreshCache()}get events(){return this.#z}get plugins(){return this.#S.list()}get status(){return this.#H.status}inspect(){return{...this.#H.inspect(),plugins:this.#S.snapshot()}}get updateCount(){return this.#H.updateCount}get destroyed(){return this.#V}},so="payload-live-preview.authorized-preview-context",ao=Symbol.for(so);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[ao]&&Object.isFrozen(e)}var lo="__livePreviewRouteRefresh",uo=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",StructuralItemUnkeyed:"LP0404",StructuralDuplicateKey:"LP0405",StructuralUnstableKeys:"LP0406",UnsupportedStrategy:"LP0407",UnknownValueFormat:"LP0408",SanitizerDroppedAttribute:"LP0409",UnrenderedBlockKept:"LP0410",UnfaithfulPatch:"LP0411",ServerFormatReplaced:"LP0412",UnrenderedBlockLost:"LP0413",MessageRejected:"LP0501",TokenRejected:"LP0502",ProtocolShapeUnknown:"LP0503",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",HydrationWaitTimedOut:"LP0607",AuditRuntimeMissing:"LP0701",AuditNoFrameAncestors:"LP0702",AuditFrameOptionsBlocks:"LP0703",AuditBindingsExposed:"LP0704",AuditGateThresholdExceeded:"LP0705",AuditUnownedBindings:"LP0706",AuditNoBindings:"LP0707",AuditNotAPage:"LP0708",FragmentRequestFailed:"LP0801",FragmentResponseInvalid:"LP0802",FragmentUnauthorized:"LP0803",FragmentSuperseded:"LP0804",RouteRefreshLoop:"LP0805",FragmentStrategyUnavailable:"LP0806",UnboundChangeRefresh:"LP0807",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710"});function bind(e,t){return co(e,t)}function bindByPath(e,t){const n=function(e){const t=[],n=new Proxy({},{get(e,r){if("symbol"!=typeof r)return/^\d+$/.test(r)||t.push(r),n}});try{e(n)}catch{}return t}(e);if(0===n.length)throw new Error("bindByPath: the picker did not read any field — return data.<field> instead of a constant");return co(n.join("."),t)}function co(e,t){if(0===e.length)throw new Error("bind: field name must be a non-empty string");const n={"data-payload-field":e};return void 0!==t?.attribute&&(n["data-payload-attribute"]=t.attribute),void 0!==t?.type&&(n["data-payload-type"]=t.type),!0===t?.richtext&&(n["data-payload-richtext"]=""),!0===t?.html&&(n["data-payload-html"]=""),void 0!==t?.locale&&(n["data-payload-locale"]=t.locale),void 0!==t?.alt&&(n["data-payload-alt"]=t.alt),void 0!==t?.href&&(n["data-payload-href"]=t.href),void 0!==t?.arrayTemplate&&(n["data-payload-array-template"]=t.arrayTemplate),n}var ho=/^[a-z][a-z0-9-]{0,63}$/u,fo=Object.freeze({});exports.AUTHORIZED_PREVIEW_BRAND_KEY=so,exports.CAPABILITY_DECLARATIONS=d,exports.CAPABILITY_DOCUMENTATION={basic:{gates:"data updates are applied to bound elements",fallback:"none — every peer has it"},"schema-json":{gates:"field typing from fieldSchemaJSON (Payload 2.x) and the payload-2 profile",fallback:"field types come from DOM heuristics and Lexical auto-detection"},locale:{gates:"locale-aware field resolution (`title_de` before `title`) and the locale on island events",fallback:"bindings resolve the unsuffixed field value"},"preview-token":{gates:"per-message token validation (library extension)",fallback:"messages carry no token; validateToken cannot be satisfied"},"nested-arrays":{gates:"keyed array diffs below the top level",fallback:"array updates replace the whole array"},"recursive-diffs":{gates:"recursive object diffs",fallback:"nested objects re-render as a unit"},"document-events":{gates:"the `documentSave` runtime event, the document-save plugin and the payload-3 profile",fallback:"no documentSave event; a save is not distinguishable from an edit"},"relationship-events":{gates:"the `relationshipUpdate` runtime event and an unconditional re-render of the update that carries it",fallback:"a related document edited in a drawer shows up on the next data update only"}},exports.CORE_ENTRY=!0,exports.DIAGNOSTIC_CODES=uo,exports.EventEmitter=EventEmitter,exports.ISLAND_EVENT=xe,exports.LIBRARY_PROTOCOL_VERSION=4,exports.LivePreviewClient=LivePreviewClient,exports.OriginDetector=OriginDetector,exports.PROTOCOL_CAPABILITIES=h,exports.VERSION=e,exports.bind=bind,exports.bindByPath=bindByPath,exports.buildFrameAncestors=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'"},exports.buildScriptSrcWithNonce=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(" ")},exports.createPreviewBindings=function createPreviewBindings(e){const t=isAuthorizedPreviewContext(e.authorization),n=void 0!==e.owner&&e.owner.length>0?e.owner:void 0;return Object.freeze({authorized:t,bind:(e,n)=>t?bind(e,n):fo,bindByPath:(e,n)=>t?bindByPath(e,n):fo,owner:()=>t&&void 0!==n?{"data-payload-owner":n}:fo,boundary:(e,n={})=>{const r=function(e,t){if(!ho.test(e))throw new RangeError(`createPreviewBindings().boundary(): "${e}" is not a registry id — lowercase, starting with a letter, then letters, digits or hyphens (max 64). The runtime would post it and the endpoint would refuse it.`);const n=t.key;if(void 0!==n&&(0===n.length||n.length>128))throw new RangeError(`createPreviewBindings().boundary(): the key for "${e}" must be 1 to ${String(128)} characters.`);const r=t.dependsOn??[];return{"data-payload-fragment":e,...void 0!==n?{"data-payload-fragment-key":n}:{},...r.length>0?{"data-payload-depends":r.join(",")}:{}}}(e,n);return t?r:fo}})},exports.detectInitialLocale=detectInitialLocale,exports.detectProtocolProfile=detectProtocolProfile,exports.escapeHtml=escapeHtml,exports.escapeHtmlAttribute=escapeHtmlAttribute,exports.generateCspNonce=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(){if(oo?.getRandomValues)return oo;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)},exports.hasCapability=function hasCapability(e,t){return e.capabilities.has(t)},exports.initLivePreview=function initLivePreview(e={}){const t=new LivePreviewClient({...e,autoStart:!1});return t.start()?t:null},exports.isAuthorizedPreviewContext=isAuthorizedPreviewContext,exports.isDevMode=isDevMode,exports.isExternalHttpUrl=isExternalHttpUrl,exports.isInIframe=isInIframe,exports.isInPopup=isInPopup,exports.isInPreviewContext=isInPreviewContext,exports.isInsideIsland=isInsideIsland,exports.isSafeUrl=isSafeUrl,exports.negotiateProtocol=negotiateProtocol,exports.registerRouteRefresh=function registerRouteRefresh(e){const t="undefined"==typeof window?void 0:window;return void 0===t?()=>{}:(t[lo]=e,()=>{t[lo]===e&&(t[lo]=void 0)})},exports.sanitizeHtml=sanitizeHtml,exports.setCspCrypto=function setCspCrypto(e){oo=e??void 0},exports.setSanitizerDocument=function setSanitizerDocument(e){globalThis[Tn]=e??void 0};
1
+ "use strict";var e="2.0.3";function detectInitialLocale(){return function(){if("undefined"==typeof document)return;const e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}()??function(){if("undefined"==typeof navigator)return;const e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}()??"en"}var t="payload-live-preview-a11y",n=/* @__PURE__ */new WeakMap;function r(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}var i=class{german;document;lease=null;constructor(e,t){const n=t??("undefined"==typeof document?null:document),r=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(r.length>0?r:detectInitialLocale())),this.document=n}mount(){const e=this.document;if(null==e?.body)return null;this.lease??=function(e){let t=n.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},n.set(e,t)),t.refs+=1,t}(e);const i=this.lease,o=i.element;if(o?.isConnected&&o.ownerDocument===e)return o;if(null!==o){const e=i.owned;r(i),e&&o.remove()}let s=e.getElementById(t);return i.owned=null===s,null===s&&(s=e.createElement("div"),s.id=t,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),s.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(s)),i.element=s,s}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?"Änderung":"Änderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}detach(){const e=this.lease,t=this.document;if(null===e||null===t)return;if(this.lease=null,e.refs-=1,e.refs>0)return;const i=e.element;null!==i&&r(e),e.owned&&i?.remove(),e.element=null,n.delete(t)}say(e){const 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);const o=setTimeout(()=>{n.timer===o&&n.element===t&&r(n)},1500);n.timer=o}};function o(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const e=s(n);e&&t.push(e)}return t}function s(e){if("object"!=typeof e||null===e)return;const t=e,n=t.name,r=t.type;if("string"!=typeof n||0===n.length)return;if("string"!=typeof r||0===r.length)return;const i=o(t.fields),s=function(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if("object"!=typeof n||null===n)continue;const e=n,r=e.slug;if("string"!=typeof r||0===r.length)continue;const i=o(e.fields);t.push({...e,slug:r,fields:i})}return t}(t.blocks),a={...t,name:n,type:r};return i.length>0?a.fields=i:delete a.fields,s.length>0?a.blocks=s:delete a.blocks,a}function a(e,t){return void 0===e||t(e)}function l(e,t){return null==e||t(e)}function u(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}var d=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],c={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"}},h=Object.keys(c);function negotiateProtocol(e,t=[]){const n="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,r=n??1,i=Math.min(4,r),o=new Set(t),s=/* @__PURE__ */new Set;for(const e of h)(i>=c[e].since||o.has(e))&&s.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:i,capabilities:s,observed:o}}function f(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function p(e,t){return e.generation===t.generation&&e.revision===t.revision}var m=class{matcher;handlers;boundListener=void 0;attachedTarget=void 0;generation=0;revision=0;queueHead=void 0;queueTail=void 0;constructor(e,t){this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1;const n=r=>{if(!t||this.boundListener!==n)return;const i=this.generation;try{this.receive(r,i,e)}catch{let e;try{e=r.origin}catch{e=""}this.reportInvalid("shape",e,i)}};this.generation+=1,this.resetQueue(),this.attachedTarget=e,this.boundListener=n;try{e.addEventListener("message",n)}catch(t){this.boundListener===n&&(this.attachedTarget=void 0,this.boundListener=void 0,this.resetQueue());try{e.removeEventListener("message",n)}catch{}throw t}if(this.boundListener===n)t=!0;else try{e.removeEventListener("message",n)}catch{}}detach(){const 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){const n={type:"payload-live-preview",ready:!0,protocolVersion:4};for(const r of e)for(const e of t)try{r.postMessage(n,e)}catch{}}receive(e,t,n){const r=e.origin;if(!this.matchesOrigin(r,t))return void this.reportInvalid("origin",r,t);if(!this.matchesSource(e,n))return void this.reportInvalid("source",r,t);const i=e.data;var s;if("object"==typeof(s=i)&&null!==s&&"type"in s&&"string"==typeof s.type)switch(i.type){case"payload-live-preview":return function(e){const t=e;return!(void 0!==t.data&&null!==t.data&&!u(t.data))&&l(t.fieldSchemaJSON,e=>Array.isArray(e))&&l(t.globalSlug,e=>"string"==typeof e)&&l(t.collectionSlug,e=>"string"==typeof e)&&l(t.locale,e=>"string"==typeof e)&&l(t.ready,e=>"boolean"==typeof e)&&l(t.previewToken,e=>"string"==typeof e)&&l(t.protocolVersion,e=>"number"==typeof e)}(i)?void this.dispatchUpdate(function(e){const t={...e};for(const e of d)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=o(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(i),r,t):void this.reportInvalid("shape",r,t);case"payload-document-event":return function(e){const t=e;return a(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&a(t.slug,e=>"string"==typeof e)&&a(t.id,e=>"string"==typeof e||Number.isFinite(e))}(i)?void this.invokeHandler(t,this.handlers.onDocumentEvent,i,r):void this.reportInvalid("shape",r,t);case"payload-live-preview-focus":{const e=function(e){const t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(i);return void 0===e?void this.reportInvalid("shape",r,t):void this.invokeHandler(t,this.handlers.onFocusField,e,r)}default:this.reportInvalid("type",r,t)}else this.reportInvalid("shape",r,t)}dispatchUpdate(e,t,n){const r=u(e.data);if(!this.isCurrentGeneration(n))return;const i=r?{generation:n,revision:this.revision+=1}:void 0,o=this.handlers.validateToken;if(!this.isCurrentGeneration(n))return;if(void 0===o)return void this.commitUpdate(e,t,n,i);if(!0===e.ready&&void 0===e.data)return void this.commitUpdate(e,t,n,void 0);const s={generation:n,message:e,origin:t,messageRevision:i,verdict:void 0,next:void 0};let a;this.enqueue(s);try{a=o(e.previewToken,t)}catch{return void this.settleValidation(s,!1)}"boolean"!=typeof a?Promise.resolve(a).then(e=>{this.settleValidation(s,!0===e)},()=>{this.settleValidation(s,!1)}):this.settleValidation(s,a)}settleValidation(e,t){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){const 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,r){void 0===r?this.invokeHandler(n,this.handlers.onUpdate,e,t):this.invokeHandler(n,this.handlers.onUpdate,e,t,r)}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{const n=e.source;if("object"!=typeof n||null===n)return!1;const r=t.parent;return r!==t&&n===r||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(e,t,...n){if(void 0!==t&&this.isCurrentGeneration(e))try{f(t(...n))}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}};function g(e){return(...t)=>{try{f(e(...t))}catch{}}}function v(){}var y=g((...e)=>console.error(...e)),b=g((...e)=>console.warn(...e)),w=g((...e)=>console.debug(...e)),S={"structural arrays":'data-payload-type="array" and keyed lists',"array templates":"data-payload-array-template","server-rendered fragments":"data-payload-fragment boundaries","route refreshes":'data-payload-strategy="route" and bindings in <head>',"screen-reader announcements":"the aria-live region","auto-binding":"autoBind: 'unique'"},A=/* @__PURE__ */new Set;function k(e){A.has(e)||(A.add(e),b(`[live-preview] LP0104: this page carries the lean runtime, which leaves out ${e} (${S[e]}). The elements are left as the server rendered them. Remove \`runtime: LEAN_RUNTIME\` to get the full runtime.`))}function T(e){return"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e){return!1!==e.enableA11y&&k("screen-reader announcements"),null}(e):function(e){if(!1===e.enableA11y)return null;const t=e.root,n=void 0===t?void 0:function(e){return 9===e.nodeType}(t)?t:t.ownerDocument;return new i(e.a11yLocale,n)}(e)}function C(e){if("undefined"==typeof window)return;const t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),m.sendReady(t,e)}function R(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}var P=/* @__PURE__ */new Set(["tabs","row","collapsible"]);function $(e,t=""){const n=/* @__PURE__ */new Map;return N(e,t,n),n}function N(e,t,n){for(const r of e){if(P.has(r.type)){r.fields&&N(r.fields,t,n);continue}const e=""===t?r.name:`${t}.${r.name}`;if(n.set(e,r),"group"===r.type)r.fields&&N(r.fields,e,n);else if("array"===r.type&&r.fields)N(r.fields,`${e}.*`,n);else if("blocks"===r.type&&r.blocks)for(const t of r.blocks)N(t.fields,`${e}.*.${t.slug}`,n)}}function x(e,t){if(e.has(t))return e.get(t);const n=t.replace(/\.\d+(?=\.|$)/g,".*");return e.has(n)?e.get(n):void 0}function L(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function F(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function E(e,t){return t.every(e=>void 0!==L(e))?function(e,t){const n=[],r=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=L(e[t]);void 0!==n&&r.set(n,t)}const i=/* @__PURE__ */new Set;for(let o=0;o<t.length;o+=1){const s=t[o],a=L(s);if(void 0===a){n.push({kind:"insert",index:o,value:s});continue}const l=r.get(a);if(void 0===l){n.push({kind:"insert",index:o,value:s});continue}i.add(l);const u=e[l];F(u)===F(s)?(l!==o&&n.push({kind:"move",from:l,to:o,value:s}),U(u,s)||n.push({kind:"update",index:o,value:s})):n.push({kind:"replace",index:o,oldValue:u,value:s})}for(let t=0;t<e.length;t+=1)i.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){const n=[],r=Math.min(e.length,t.length);for(let i=0;i<r;i+=1)U(e[i],t[i])||n.push({kind:"update",index:i,value:t[i]});if(t.length>e.length)for(let r=e.length;r<t.length;r+=1)n.push({kind:"insert",index:r,value:t[r]});if(e.length>t.length)for(let r=t.length;r<e.length;r+=1)n.push({kind:"remove",index:r,value:e[r]});return n}(e,t)}function U(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;const n=e,r=t,i=Object.keys(n),o=Object.keys(r);if(i.length!==o.length)return!1;for(const e of i)if(!Object.is(n[e],r[e]))return!1;return!0}var 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"},M=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),O=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,_=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,D=/^[\\/]{2}/,z=/[\t\n\r]/g;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(z,"");if(0===t.length)return!1;if(O.test(t))return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(D.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return M.has(e.protocol)}catch{return _.test(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(z,"");return/^https?:\/\//i.test(t)||D.test(t)}var B=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),j=/* @__PURE__ */new Set(["href","src","poster","cite","action","xlink:href","data"]);function H(e){return!e.startsWith("on")&&!B.has(e)}function W(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function V(e,t,n,r){if(t.reportedUnfaithful.has(n.element))return;t.reportedUnfaithful.add(n.element),t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName);const i=e.onUnfaithfulPatch;"ignore"!==i&&("warn"!==i?(e.log("LP0411",n.fieldName,r),t.unfaithfulPatches.push(n)):e.warn(`[live-preview] LP0411: "${n.fieldName}" ${r}`))}function q(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}var G=/* @__PURE__ */new Set(["date","number","checkbox"]);function K(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function J(e){const t=e.trim();return JSON.stringify(t.length>40?`${t.slice(0,40)}…`:t)}var Q=/* @__PURE__ */new WeakSet;function X(e){return Q.add(e),e}function Y(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}}var Z=class{previous=null;diff(e,t){const n=this.previous,r=null===n,i=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set;for(const[t,r]of Object.entries(e)){const e=Y(r);i.set(t,e),null!==n&&void 0!==e&&n.get(t)===e||o.add(t)}if(null!==n)for(const e of n.keys())i.has(e)||o.add(e);this.previous=i;const s=/* @__PURE__ */new Set;for(const[e,n]of Object.entries(t))if(o.has(e))for(const e of n)s.add(e);return{changed:o,invalidated:s,baseline:r}}reset(){this.previous=null}},ee="data-payload-fragment";function te(e){return e.closest(`[${ee}]`)}function ne(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==te(e)?"fragment":null!==e.closest("head")?"route":"patch"}function re(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function ie(e){return"string"==typeof e&&e.length>0}function oe(e,t){return null!==t&&void 0!==e&&t.includes(e)}function se(e){const t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}var ae=/* @__PURE__ */new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function le(e,t,n){const r=e.get(t);return void 0!==r&&(!1===n||r.some(e=>oe(e.owner,n)))}function ue(e,t,n){const r=`${t}.`;for(const[t,i]of e.entries())if(t.startsWith(r)){if(!1===n)return!0;if(i.some(e=>oe(e.owner,n)))return!0}return!1}function de(e,t){if(void 0===t||0===t.length)return e;const n=`_${t}`;return e.endsWith(n)?e.slice(0,-n.length):e}function ce(e,t,n){let r;return i=>{if(le(e,i,n))return!0;const o=de(i,t);return!(o===i||!le(e,o,n))||!!ue(e,i,n)||!(o===i||!ue(e,o,n))||(r??=function(e,t){const n=/* @__PURE__ */new Set;for(const[r,i]of e.entries())for(const e of i)(!1===t||oe(e.owner,t))&&void 0!==e.locale&&n.add(`${r}_${e.locale}`);return n}(e,n),r.has(i))}}function he(e,t,n,r){const i=ce(e,n,r),o=[];for(const e of t)ae.has(e)||i(e)||o.push(e);return o}var fe=/* @__PURE__ */new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),pe={},me=class{rawChanges=new Z;resolved=null;queued=null;pending=null;timer=null;openUntil=0;decide(e,t){const n=t.message.data??{},{changed:r}=this.rawChanges.diff(n,pe);if(!function(e){const{cache:t,emitter:n}=e;if(t.islands.length>0)return!0;if(n.listenerCount("beforeUpdate")>0||n.listenerCount("afterUpdate")>0)return!0;for(const e of t.values()){if(ve(e)||e.fieldName.includes("."))return!0;if(be(e.hrefField)||be(e.srcField)||be(e.altField))return!0}return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${ee}]`)}(e))return{merge:!1,fields:n};const i=this.resolved;if(null===i)return this.resolved=n,{merge:!0,fields:n};const o={...i};let s=t.forceRender;for(const a of r){const r=n[a];if(ae.has(a)){o[a]=r;continue}const l=ge(a,i[a],r,e.cache,t.schemaIndex);"own"!==l&&(s=!0),"keep"!==l&&(o[a]=r)}return this.resolved=o,{merge:s,fields:o}}request(e,t,n){const r=Date.now();return r>=this.openUntil?(this.dropQueued(),this.openUntil=r+t,{leading:!0,result:e.merge(n)}):(this.queued=n,this.openUntil=r+t,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){const 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"})})}};function ge(e,t,n,r,i){return ye(n)?!ye(t)||function(e,t,n){const r=void 0===n?void 0:x(n,e);return void 0!==r&&!fe.has(r.type)||!0===t.get(e)?.some(ve)||ue(t,e,!1)}(e,r,i)?"keep":null==t?"ask":"own":"ask"}function ve(e){return!fe.has(e.fieldType)}function ye(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function be(e){return!0===e?.includes(".")}var we=class{negotiation=negotiateProtocol(void 0);observed=/* @__PURE__ */new Set;observe(e,t){const n=e.filter(e=>!this.observed.has(e));if(0!==n.length){for(const e of n)this.observed.add(e);this.negotiation=negotiateProtocol(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}applyVersion(e,t){const n=this.negotiation;if(n.theirs===e)return;const r=negotiateProtocol(e,this.observed);this.negotiation=r,r.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${r.negotiated}`)}};function Se(e){return null!==e&&e.forceRender&&!e.completed}var Ae=class{lastIdentity=void 0;edit(e){const t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;const n=JSON.stringify([t.entitySlug,se(t),t.updatedAt]),r=n!==this.lastIdentity;return this.lastIdentity=n,r&&function(e,t){const n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;const r=se(e),i=se(t.data??{});return void 0!==r&&void 0!==i&&r!==i}(t,e)?t:null}};function ke(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Te=class{#e;reveal(e,t,n){return e===this.#e?"skipped-same":(this.#e=e,function(e,t){return function(e,t){const n=e.getBoundingClientRect(),r=n.bottom>0&&n.top<t.innerHeight,i=n.right>0&&n.left<t.innerWidth;return r&&i}(e,t)?"already-visible":(e.scrollIntoView({behavior:ke(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){this.#e=void 0}},Ce=class{seen=/* @__PURE__ */new Map;note(e,t,n){const r=Y(n);if(void 0===r)return;const i=`${t.owner??""}\0${t.locale??""}\0${t.fieldName}`,o=this.seen.get(i);void 0!==o?o!==r&&(e.revealIdentities.push([i,r]),e.revealTarget??=t):this.seen.set(i,r)}commit(e){for(const[t,n]of e.revealIdentities)this.seen.set(t,n);e.revealIdentities=[];const t=e.revealTarget;return e.revealTarget=void 0,t}},Re=class{started=!1;suspended=!1;deferredStart=null;hydration="idle";activeUpdate=null;locale=void 0;schema=void 0;schemaIndex=void 0;updateCount=0;supersededCount=0;completedCount=0;skippedUnchangedCount=0;lastFlush=null;absentFields=/* @__PURE__ */new Set;warnedOrphanFields=/* @__PURE__ */new Set;warnedStrategy=/* @__PURE__ */new WeakSet;warnedUnattributableMessage=!1;warnedVisibilityGate=!1;warnedFragmentFallback=!1;warnedProtocolShape=!1;reportedUnfaithful=/* @__PURE__ */new WeakSet;checkedServerFormat=/* @__PURE__ */new WeakSet;unfaithfulPatches=[];unfaithfulCount=0;escalatedCount=0;unfaithfulFields=/* @__PURE__ */new Set;autoBindSearchMs=void 0;autoBindGuesses=null;warnedForeignSource=!1;lastAppliedIdentity=/* @__PURE__ */new WeakMap;revealLedger=new Ce;fragmentStats={rendered:0,failed:0,superseded:0};routeStats={refreshes:0,failed:0,refused:0,loopStopped:0};fragmentController=null;routeController=null;routeRetry=null;routeRefreshOwed=!1;readyTimers=[];revealer=new Te;changes=new Z;merges=new me;protocol=new we;relationships=new Ae;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(const e of["fragmentController","routeController"]){const t=this[e];null!==t&&(this[e]=null,t.abort())}}},Pe=class{constructor(e,t){this.deps=e,this.state=t,this.instanceContext=R({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,reportUnfaithful:(n,r)=>{V(e,t,n,r)}})}deps;state;instanceContext;apply(e){const{deps:t,state:n}=this,r=n.activeUpdate;if(null===r||void 0===e.revision||!p(r.revision,e.revision)||!n.isCurrent(r))return!1;const{target:i,value:o}=e,s=void 0!==r.schemaIndex?x(r.schemaIndex,i.fieldName):void 0;let a,l=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){const e=function(e){if(Object.prototype.hasOwnProperty.call(I,e))return I[e]}(t);if(void 0!==e)return e}return e.fieldType}(i,s?.type);"text"===l&&!0!==i.explicitFieldType&&function(e){if("object"!=typeof e||null===e||!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&Array.isArray(t.children)}(o)&&(l="richText");try{a=t.resolveRenderer(l,i)}catch(e){return this.fail(r,e)}if(!n.isCurrent(r))return!1;const u=t.emitter.listenerCount("elementUpdate")>0,d=u?"INPUT"===(c=i.element).tagName||"TEXTAREA"===c.tagName?c.value:"IMG"===c.tagName?c.src:c.textContent:void 0;var c;if(!n.isCurrent(r))return!1;const h={allFields:e.allFields,locale:i.locale??r.locale,schema:s,...this.instanceContext};!0===i.hidesWhenEmpty&&i.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!==i.targetAttribute){if("blocked"===function(e,t,n){const r=t.toLowerCase().trim();if(0===r.length)return"blocked";if(!H(r))return"blocked";if(null==n)return e.removeAttribute(r),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";const i=String(n);return j.has(r)&&!isSafeUrl(i)?"blocked":(e.setAttribute(r,i),"applied")}(i.element,i.targetAttribute,o))return t.warn(`[live-preview] LP0401: refused to write "${i.fieldName}" into attribute "${i.targetAttribute}"`),!1}else{if(void 0===a)return t.log("no renderer for",l),V(t,n,i,`has no renderer for "${l}"`),!1;{const e=function(e,t,n,r){if("ignore"===e.onUnfaithfulPatch)return;if(void 0!==n.format||!G.has(r))return;if(t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);const i=K(n.element);return i.trim().length>0?i:void 0}(t,n,i,l),r=function(e,t,n,r){return e.render(t,n,r)}(a,i,o,h);if(!1===r&&function(e){return Q.has(e.render)}(a))return V(t,n,i,`is a value ${a.name} cannot render`),!1;void 0!==e&&function(e,t,n){const r=K(t.element);r!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${J(n)}, the patch wrote ${J(r)} — 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,i,e)}}}catch(e){return this.fail(r,e)}if(!n.isCurrent(r))return!1;u&&t.emitter.emitWhile("elementUpdate",{element:i.element,fieldName:i.fieldName,previousValue:d,nextValue:o,revision:r.revision.revision,receivedAt:r.receivedAt,source:"patch"},()=>n.isCurrent(r));const f=n.isCurrent(r);return f&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(i.element,e.valueIdentity):n.lastAppliedIdentity.delete(i.element)),f}fail(e,t){if(!this.state.isCurrent(e))return!1;const 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}};function $e(...e){const t=/* @__PURE__ */new Map;for(const n of e)for(const[e,r]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=/* @__PURE__ */new Set,t.set(e,n));for(const e of r)n.add(e)}const n={};for(const[e,r]of t)n[e]=[...r];return n}function Ne(e,t){const n={};for(const r of t)r!==e&&(n[r]=[e]);return n}var xe="payload-live-preview:update",Le="data-payload-island",Fe=`astro-island, [${Le}]`;function Ee(e){return"patch"===e.getAttribute(Le)}function Ue(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(Le)}(e)&&!Ee(e)}function isInsideIsland(e){let t=e;for(;null!==t;){if(Ue(t))return!0;t=t.parentElement}return!1}var Ie="data-payload-field",Me="data-payload-type",Oe="data-payload-attribute",_e="data-payload-href",De="data-payload-src",ze="data-payload-alt",Be="data-payload-array-template",je="data-payload-array-separator",He="data-payload-locale",We="data-payload-richtext",Ve="data-payload-html",qe="data-payload-array",Ge="data-payload-structural",Ke="data-payload-owner",Je="data-payload-depends",Qe="data-payload-strategy",Xe="data-payload-boundary",Ye="data-payload-guessed",Ze=[Ie,Me,Oe,_e,De,ze,Be,je,He,We,Ve,qe,Ge,Ke,Je,Qe,Xe,"type"],et=`[${Ie}]`,tt=`[${Ke}]`;function nt(e){const t=e.closest(tt)?.getAttribute(Ke);return null==t||0===t.length?void 0:t}var rt=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,it=/* @__PURE__ */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"]);function ot(e){return it.has(e)||rt.test(e)}var st=class{entriesByField=/* @__PURE__ */new Map;entryByElement=/* @__PURE__ */new WeakMap;filter;count=0;dependencies=null;islandRoots=[];constructor(e={}){this.filter=e.filter??lt}dependencyMap(){if(null!==this.dependencies)return this.dependencies;const e=[];for(const t of this.values())void 0!==t.dependsOn&&e.push(Ne(t.fieldName,t.dependsOn));return this.dependencies=$e(...e),this.dependencies}get islands(){return this.islandRoots}buildFromRoot(e){const t=performance.now();this.clear();let n=0;for(const t of e.querySelectorAll(et))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){const t=[];for(const n of e.querySelectorAll(Fe))Ee(n)||t.push(n);return t}(e),{elementCount:n,fieldCount:this.entriesByField.size,durationMs:performance.now()-t}}add(e){const 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){const 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(const e of this.entriesByField.values())yield*e}has(e){return this.entryByElement.has(e)}clear(){this.entriesByField.clear(),this.entryByElement=/* @__PURE__ */new WeakMap,this.count=0,this.dependencies=null,this.islandRoots=[]}replaceEntry(e,t){if(e.fieldName!==t.fieldName)return!1;const n=this.entriesByField.get(e.fieldName),r=void 0===n?-1:n.indexOf(e);return!(void 0===n||r<0||(n[r]=t,0))}removeEntry(e,t){this.entryByElement.delete(e);const n=this.entriesByField.get(t.fieldName),r=void 0===n?-1:n.indexOf(t);return!(void 0===n||r<0||(n.splice(r,1),0===n.length&&this.entriesByField.delete(t.fieldName),this.count-=1,0))}append(e){const t=this.entriesByField.get(e.fieldName);t?t.push(e):this.entriesByField.set(e.fieldName,[e]),this.count+=1}resolveBinding(e){const t=e.getAttribute(Ie);if(null===t||0===t.length)return;const n=e.getAttribute(Me),r=e.getAttribute(Oe),i=e.getAttribute(_e),o=e.getAttribute(De),s=e.getAttribute(ze),a=e.getAttribute(Be),l=e.getAttribute(je),u=e.getAttribute(He),d=e.getAttribute("data-payload-format"),c=nt(e),h=function(e){if(null==e)return[];const t=/* @__PURE__ */new Set,n=[];for(const r of e.split(/[\s,]+/)){const e=r.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}(e.getAttribute(Je)),f=e.getAttribute(Qe),p=e.getAttribute(Ye),m=te(e);return{element:e,fieldName:t,fieldType:at(e),explicitFieldType:null!==n&&ot(n),strategyKind:ne(e)??"unknown",...null!==m?{fragmentBoundary:m}:{},...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==i&&i.length>0?{hrefField:i}:{},...null!==o&&o.length>0?{srcField:o}:{},...null!==s&&s.length>0?{altField:s}:{},...null!==a?{arrayTemplate:a}:{},...null!==l?{arraySeparator:l}:{},...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(Xe)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}};function at(e){const t=e.getAttribute(Me);if(null!==t&&ot(t))return t;if(e.hasAttribute(We))return"richText";if(e.hasAttribute(Ve))return"html";if(e.hasAttribute(Ge))return"structural-array";if(e.hasAttribute(qe))return"array";if("IMG"===e.tagName)return"image";if("A"===e.tagName)return"url";if("TIME"===e.tagName)return"date";if("INPUT"===e.tagName){const t=e.type;if("checkbox"===t)return"checkbox";if("number"===t)return"number";if("date"===t||"datetime-local"===t)return"date"}return"text"}function lt(){return!0}function ut(e,t){return e.length>0&&e.length<=t&&"."!==e&&".."!==e&&!e.includes("/")&&!e.includes("\\")&&!function(e){for(const t of e){const e=t.codePointAt(0)??0;if(e<=31||127===e)return!0}return!1}(e)}function dt(e){return ut(e,128)&&!e.includes("?")&&!e.includes("#")}var ct=class{serverURL;apiRoute;depth;fetchFn;log;inflight=null;attempt=0;destroyDepth=0;constructor(e){this.serverURL=function(e){let t=e.length;for(;e.endsWith("/",t);)t-=1;return e.slice(0,t)}(e.serverURL);const t=e.apiRoute??"/api";this.apiRoute=t.startsWith("/")?t:`/${t}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=g(e.log??v)}canMerge(e){return null!==this.endpointOf(e)}endpointOf(e){try{const n=e.globalSlug;if(n)return dt(n)?`globals/${encodeURIComponent(n)}`:null;const r=e.collectionSlug??"",i=e.data.id;return dt(r)&&("number"==typeof(t=i)?Number.isFinite(t):"string"==typeof t&&ut(t,512))?`${encodeURIComponent(r)}/${encodeURIComponent(String(i))}`:null}catch{return null}var t}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};const t=this.attempt+=1,n=this.inflight;this.inflight=null;let r=null;const i=()=>this.attempt!==t;try{if(n?.abort(),i())return{status:"superseded"};const t=this.endpointOf(e);if(null===t)return i()?{status:"superseded"}:{status:"unavailable"};const o=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===o)return{status:"unavailable"};r=new AbortController,this.inflight=r;const s=`${this.serverURL}${this.apiRoute}/${t}`,a=await o(s,{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:r.signal});if(i())return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,s),{status:"unavailable"};const l=await a.json();return i()?{status:"superseded"}:null===l||"object"!=typeof l||Array.isArray(l)?(this.log("merge invalid",s),{status:"unavailable"}):{status:"merged",doc:l}}catch(e){return i()?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{this.inflight===r&&(this.inflight=null)}}destroy(){this.attempt+=1;const e=this.inflight;this.inflight=null,this.destroyDepth+=1;try{e?.abort()}finally{this.destroyDepth-=1}}},ht={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},ft={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},pt={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1};function detectProtocolProfile(e){return e.has("schema-json")?ht:e.has("document-events")||e.has("relationship-events")?ft:pt}var mt=class{callbacks;debounceMs;rootMargin;visible=/* @__PURE__ */new Set;mutation=null;intersection=null;debounceTimer=null;generation=0;constructor(e,t={}){this.callbacks=e,this.debounceMs=t.mutationDebounceMs??100,this.rootMargin=t.intersectionRootMargin??"200px"}start(e){const t=this.generation;this.stop();const n=t+1;if(this.generation!==n)return;let r=null,i=null;try{r=new MutationObserver(e=>{this.handleMutations(e,n)}),i=new IntersectionObserver(e=>{this.handleIntersection(e,n)},{rootMargin:this.rootMargin,threshold:0}),r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...Ze]})}catch(e){throw r?.disconnect(),i?.disconnect(),e}if(this.generation!==n)return r.disconnect(),void i.disconnect();this.mutation=r,this.intersection=i}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;const 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(const t of e){if("attributes"===t.type&&null!==t.attributeName&&Ze.includes(t.attributeName)&&(t.attributeName===Ie||t.attributeName===Ke||1===t.target.nodeType&&t.target.hasAttribute(Ie)))return!0;for(const e of t.addedNodes)if(gt(e))return!0;for(const e of t.removedNodes)if(gt(e))return!0}return!1}(e))return;null!==this.debounceTimer&&clearTimeout(this.debounceTimer);const n=setTimeout(()=>{this.isCurrentGeneration(t)&&this.debounceTimer===n&&(this.debounceTimer=null,this.callbacks.onStructuralChange())},this.debounceMs);this.debounceTimer=n}handleIntersection(e,t){for(const n of e){if(!this.isCurrentGeneration(t))return;const{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}};function gt(e){if(1!==e.nodeType)return!1;const t=e;return t.hasAttribute(Ie)||null!==t.querySelector(`[${Ie}]`)}var vt="[data-payload-field]";function yt(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydration??={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]}}function bt(){const e=yt();if(void 0===e||e.armed)return;e.armed=!0;const t=window,n=t.__REACT_DEVTOOLS_GLOBAL_HOOK__??=function(){const e=/* @__PURE__ */new Map;return{supportsFiber:!0,renderers:e,inject:t=>{const n=e.size+1;return e.set(n,t),n}}}(),r=n.onCommitFiberRoot;n.onCommitFiberRoot=function(t,n,...i){try{r?.call(this,t,n,...i)}catch{}const o=n?.containerInfo;void 0===e.onCommit?e.commits.push(o):e.onCommit(o)}}function wt(e){e.committed=!0;const t=e.waiters;e.waiters=[];for(const e of t)e()}function St(e,t){const n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function At(e,t,n){if(e.committed)return null;let r=null;const i=()=>{null!==r&&clearTimeout(r),r=null,t("committed")};return e.waiters.push(i),r=setTimeout(()=>{r=null,St(e,i),t("timed-out")},n),()=>{null!==r&&clearTimeout(r),r=null,St(e,i)}}var kt="__vue_app__";function Tt(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewVueHydration??={armed:!1,committed:!1,waiters:[]}}function Ct(e){return Object.prototype.hasOwnProperty.call(e,kt)?e[kt]:void 0}function Rt(){const e=Tt();if(void 0===e||e.armed)return;e.armed=!0;const t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,kt)&&Object.defineProperty(t,kt,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,kt,{value:e,writable:!0,configurable:!0,enumerable:!0});const t=Tt();void 0===t||t.committed||null===this.querySelector(vt)||function(e,t){const n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?wt(e):n.hook("app:suspense:resolve",()=>{e.committed||wt(e)})}(t,e)}})}function Pt(e){if(void 0===e.hydration)return void e.startNow();const t=t=>{e.later(()=>{$t(e,t)})},n="react"===e.hydration?function(e,t=5e3){bt();const n=yt();if(void 0===n)return null;if(void 0===n.onCommit){const e=e=>{!n.committed&&function(e){const t=e;return 9===t?.nodeType||null!=t?.querySelector?.(vt)}(e)&&wt(n)};n.onCommit=e;for(const t of n.commits.splice(0))e(t)}return At(n,e,t)}(t):function(e,t,n=5e3){Rt();const r=Tt();return void 0===r?null:(!r.committed&&function(e){for(let t=e.querySelector(vt);null!==t;t=t.parentElement)if(void 0!==Ct(t))return!0;return!1}(e)&&wt(r),At(r,t,n))}(e.root,t);null!==n?(e.defer(n),e.hydrated("waiting")):$t(e,"committed")}function $t(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()}var Nt=class{timeoutMs;onTimeout;handle=null;lastKick=0;constructor(e){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);const 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}},xt=class{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)}},Lt=/* @__PURE__ */new Set(["true","false","yes","no","on","off"]),Ft=/^[\d\s.,:+/-]+$/u,Et=/^[a-z][a-z0-9_-]*$/u,Ut=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,It=/* @__PURE__ */new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]);function Mt(e,t=13){if("string"!=typeof e)return!1;const n=e.trim();return!(n.length<t||Ft.test(n)||Lt.has(n.toLowerCase())||Et.test(n)||Ut.test(n))}function Ot(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function _t(e,t,n=13){const r=/* @__PURE__ */new Map,i=(e,t,n)=>{r.set(e,r.has(e)?null:{field:t,media:n})};for(const[r,o]of Object.entries(e)){if(ae.has(r))continue;const e=de(r,t);if(Mt(o,n))i(o.trim(),e,!1);else if(Ot(o))if("string"==typeof o.url)i(o.url,e,!0);else if(!("id"in o)&&!("_id"in o))for(const[t,r]of Object.entries(o))!ae.has(t)&&Mt(r,n)&&i(r.trim(),`${e}.${t}`,!1)}return r}function Dt(e){if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||It.has(e.tagName))return!0;if(e.hasAttribute(Ie)||e.hasAttribute("data-payload-no-bind")||e.hasAttribute("data-payload-owned")||Ue(e))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function zt(e){let t;for(let n=e.firstChild;null!==n;n=n.nextSibling){if(1===n.nodeType)return;if(3!==n.nodeType)continue;const e=n.data.trim();if(0!==e.length){if(void 0!==t)return;t=e}}return t}function Bt(e){return H(e)&&!e.startsWith("data-payload-")&&"value"!==e}function jt(e,t,n){let r=e.byElement.get(t);void 0===r&&(r={attributes:/* @__PURE__ */new Map},e.byElement.set(t,r));let i=e.byField.get(n.field);return void 0===i&&(i=/* @__PURE__ */new Set,e.byField.set(n.field,i)),i.add(t),r}function Ht(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(Dt(n))continue;const e=zt(n),r=void 0===e?void 0:t.values.get(e);null==r||r.media||(jt(t,n,r).text=r.field);for(const e of n.getAttributeNames()){if(!Bt(e))continue;const r=t.values.get(n.getAttribute(e)??"");null!=r&&(!r.media||"IMG"===n.tagName&&"src"===e)&&jt(t,n,r).attributes.set(e,r)}Ht(n,t)}}function Wt(e,t,n){const r=e.tagName;if(void 0!==t){const i={[Ie]:t};if("A"===r){const e=n.get("href");void 0===e?i[Me]="text":e!==t&&(i[_e]=e)}return{element:e,fieldName:t,matched:zt(e)??"",stamps:i}}if("IMG"===r){const t=n.get("src");if(void 0!==t){const r=n.get("alt");return{element:e,fieldName:t,matched:e.getAttribute("src")??"",attribute:"src",stamps:{[Ie]:t,...void 0!==r&&r!==t?{[ze]:r}:{}}}}}const i=n.entries().next();if(i.done)return;const[o,s]=i.value;return{element:e,fieldName:s,matched:e.getAttribute(o)??"",attribute:o,stamps:{[Ie]:s,[Oe]:o}}}function Vt(e,t){const n={values:t,byElement:/* @__PURE__ */new Map,byField:/* @__PURE__ */new Map};t.size>0&&!Dt(e)&&Ht(e,n);const r=e=>1===n.byField.get(e)?.size,i=[];for(const[e,t]of n.byElement){const n=void 0!==t.text&&r(t.text)?t.text:void 0,o=/* @__PURE__ */new Map;for(const[e,n]of t.attributes)r(n.field)&&o.set(e,n.field);const s=Wt(e,n,o);void 0!==s&&i.push(s)}return i}function qt(e){return 9===e.nodeType?e.body:e}function Gt(e,t,n,r){const i=[];for(const o of t){const{element:t}=o;if(!t.hasAttribute(Ie)&&(!1===n||oe(nt(t),n))){for(const[e,n]of Object.entries(o.stamps))t.setAttribute(e,n);if(t.setAttribute(Ye,o.matched),void 0!==e.cache.add(t))e.observers.observeElement(t),e.log("autoBind",o.fieldName,"→",`<${t.tagName.toLowerCase()}>`,o.attribute??"text",JSON.stringify(o.matched),r),i.push(o);else{for(const e of Object.keys(o.stamps))t.removeAttribute(e);t.removeAttribute(Ye)}}}return i}var Kt=/* @__PURE__ */new Set(["__proto__","prototype","constructor"]);function Jt(e,t,n,r=!1){if(r&&void 0!==n){const r=Qt(e,`${t}_${n}`);if(void 0!==r)return r}const i=Qt(e,t);if(void 0!==i)return i;if(t.includes(".")){let n=e,r=!0;for(const e of t.split(".")){if(Kt.has(e)||null===n||"object"!=typeof n){r=!1;break}if(n=Qt(n,e),void 0===n){r=!1;break}}if(r)return n}return void 0===n?void 0:Qt(e,`${t}_${n}`)}function Qt(e,t){if(!Kt.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Xt(e,t,n,r){return Jt(e,n,t.locale??r,void 0!==t.locale)}function Yt(e,t,n,r){const i=Y(t);if(void 0===i)return;const o=[e.hrefField,e.srcField,e.altField];let s=i;for(const t of o){if(void 0===t||0===t.length)continue;const i=Y(Xt(n,e,t,r));if(void 0===i)return;s+=`|${t}=${i}`}return s}function Zt(e,t,n,r){const{warned:i,warn:o}=e;i.has(n)||t(n)||(i.add(n),o(`[live-preview] LP0201: no <… data-payload-field="${de(n,r)}"> for field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`))}function en(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function tn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var nn=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function rn(e){const t=function(){const e=function(){const e=globalThis,t=e[nn];if(void 0!==t)return t;const n={};return e[nn]=n,n}();if(void 0!==e.override)return e.override;if(void 0!==e.auto)return e.auto;const t=function(){const e=globalThis.trustedTypes;if("object"==typeof e&&null!==e)return"function"==typeof e.createPolicy?e:void 0}();try{e.auto=void 0===t?null:t.createPolicy("payload-live-preview",{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===t?e:t.createHTML(e)}var on=/* @__PURE__ */new Set(["open","value","checked","selected"]);function sn(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function an(e){if(e.tagName.toLowerCase().includes("-"))return!0;if(e.hasAttribute(Le)||e.hasAttribute("data-payload-owned"))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function ln(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!an(e)&&!an(t)}(e,t))return t;const r=function(e){const t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement&&e.contains(t)))return null;return{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}}(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||on.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(const 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){const r=function(e,t){const n=/* @__PURE__ */new Map;let r;for(const i of Array.from(e.children)){const e=sn(i,t);void 0!==e&&(n.has(e)?r??=e.slice(e.indexOf("=")+1):n.set(e,i))}return void 0!==r&&t.onDuplicateKey?.(e,r),n}(e,n),i=new Set(r.values()),o=Array.from(e.childNodes).filter(e=>!i.has(e)),s=/* @__PURE__ */new Set,a=/* @__PURE__ */new Set,l=Array.from(t.childNodes);let u=e.firstChild,d=0;for(let t=0;t<l.length;t+=1){const i=l[t];let c=null,h=i instanceof Element?sn(i,n):void 0;if(void 0!==h&&a.has(h)&&(h=void 0),void 0!==h){a.add(h);const e=r.get(h);if(void 0!==e&&!s.has(e)&&(c=un(e,i,n)===e?e:null,null===c)){e.replaceWith(i),s.add(i),u=i.nextSibling;continue}}else{for(;d<o.length;){const r=o[d];if(d+=1,!s.has(r)){if(cn(r,i)){c=un(r,i,n)===r?r:null,null===c&&(e.replaceChild(i,r),s.add(i),u=i.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(i instanceof Element)||void 0!==n&&cn(r,n)){d-=1;break}e.replaceChild(i,r),s.add(i),u=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,r),s.add(i),u=i.nextSibling;break}}}if(null===c&&s.has(i))continue}const f=c??i;for(s.add(f);null!==u&&u!==f&&!s.has(u)&&dn(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(const t of Array.from(e.childNodes))s.has(t)||t.remove()}(e,t,n),function(e){if(null===e)return;const{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});const[e,r]=n??[null,null];null!==e&&null!==r&&t.setSelectionRange(e,r)}catch{}}(r),e}function un(e,t,n){return e instanceof Element&&t instanceof Element?an(e)&&an(t)?e:ln(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function dn(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function cn(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}var hn=/* @__PURE__ */new Set;function fn(e){hn.has(e)||(hn.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("data-payload-")?"A binding inside CMS content is refused by design — 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 — 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)}.`))}var pn=/* @__PURE__ */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"]),mn=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),gn=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),vn=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),yn="aria-",bn="data-",wn={a:/* @__PURE__ */new Set(["href","target","rel","download","hreflang","type"]),img:/* @__PURE__ */new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:/* @__PURE__ */new Set([]),source:/* @__PURE__ */new Set(["src","srcset","sizes","type","media"]),audio:/* @__PURE__ */new Set(["src","controls","autoplay","loop","muted","preload"]),video:/* @__PURE__ */new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:/* @__PURE__ */new Set(["datetime"]),abbr:/* @__PURE__ */new Set(["title"]),q:/* @__PURE__ */new Set(["cite"]),blockquote:/* @__PURE__ */new Set(["cite"]),table:/* @__PURE__ */new Set(["summary"]),th:/* @__PURE__ */new Set(["colspan","rowspan","scope","headers","abbr"]),td:/* @__PURE__ */new Set(["colspan","rowspan","headers"]),col:/* @__PURE__ */new Set(["span"]),colgroup:/* @__PURE__ */new Set(["span"]),ol:/* @__PURE__ */new Set(["start","reversed","type"]),li:/* @__PURE__ */new Set(["value"]),code:/* @__PURE__ */new Set(["class"]),pre:/* @__PURE__ */new Set(["class"])},Sn=/* @__PURE__ */new Set(["href","src","cite","poster"]),An=class extends Error{name="SanitizerEnvironmentError"},kn=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"]),Tn=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function sanitizeHtml(e,t){return Cn(e,void 0,t)}function Cn(e,t,n){const r=Rn();if(!r)throw"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new An("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===e)return"";const i=function(e,t){const n=e?.policy??t??"strict";if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(wn))e.set(t,n);return{allowedTags:pn,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(pn);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of mn)r.add(e);const i=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(wn))i.set(e,t);for(const[t,n]of Object.entries(e.additionalAllowedAttributes??{})){const e=new Set(i.get(t));for(const t of n)e.add(t);i.set(t,e)}return{allowedTags:r,attrByTag:i,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t),o=r.createElement("template");return o.innerHTML=rn(e),Pn(o.content,i),o.innerHTML}function Rn(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[Tn];if(e)return e}if("undefined"!=typeof document)return document}function Pn(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?$n(n,t):8===n.nodeType&&n.remove()}function $n(e,t){const n=e.tagName.toLowerCase();if(!gn.has(n)||t.allowFormControls&&mn.has(n)){if(!t.allowedTags.has(n))return Pn(e,t),void e.replaceWith(...e.childNodes);!function(e,t,n){const r=n.attrByTag.get(t);for(const t of Array.from(e.attributes)){const i=t.name.toLowerCase();if(i.startsWith("on")||"style"===i)e.removeAttribute(t.name);else{if("strict"===n.mode){if(n.templateMode&&kn.has(i))continue;if("id"===i||"name"===i||i.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===i&&!0!==r?.has(i)||fn(i);continue}if(i.startsWith(bn)){n.allowedData.has(i)||(e.removeAttribute(t.name),fn(i));continue}if(vn.has(i)||i.startsWith(yn))continue}else if(vn.has(i)||i.startsWith(yn)||i.startsWith(bn))continue;r?.has(i)?Sn.has(i)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==i||Nn(t.value)||e.removeAttribute(t.name):e.removeAttribute(t.name)}}}(e,n,t),"a"===n&&function(e){const t=e.getAttribute("href");null!==t&&isExternalHttpUrl(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),Pn(e,t)}else e.remove()}function Nn(e){for(const t of e.split(",")){const e=t.trim();if(0===e.length)continue;const[n=e]=e.split(/\s/,1);if(!isSafeUrl(n))return!1}return!0}var xn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),Ln=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(Ln,e=>xn[e])}var Fn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}),En=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(En,e=>Fn[e])}var Un=/\{\{([\s\S]*?)\}\}/g;function In(e){const t=/* @__PURE__ */new Set;for(const n of e)if("object"==typeof n&&null!==n)for(const e of Object.keys(n))t.add(e);return t}function Mn(e,t,n,r,i){const o="object"==typeof t&&null!==t?t:null;return e.replace(Un,(e,s)=>null!==o&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(o,s)?escapeHtml(r(Reflect.get(o,s))):null===o&&"value"===s?escapeHtml(r(t)):"index"===s?String(n):null!==o&&!0===i?.has(s)?"":e)}function On(e){const t=e.children,n=t[0];if(void 0===n)return[];const r=[];for(const{name:e,value:i}of Array.from(n.attributes)){if(!H(e)||e.startsWith("data-payload-"))continue;let n=!0;for(let r=1;r<t.length&&n;r+=1)n=t[r]?.getAttribute(e)===i;n&&r.push([e,i])}return r}function _n(e,t){for(const[n,r]of t)e.hasAttribute(n)||e.setAttribute(n,r)}function Dn(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 zn(e){return null==e||""===e}function Bn(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function jn(e,t,n,r){return e.set(t,n),function(e,t){for(const n of e.keys()){if(e.size<=t)break;e.delete(n)}}(e,r),n}var Hn=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],Wn=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],Vn=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,qn=/* @__PURE__ */new Map;function Gn(e){const t=Bn(qn,e);if(void 0!==t)return t;const n=new Set(Hn);for(const t of e.matchAll(Vn)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const r={};for(const e of n)r[e]=Wn;const i={additionalAllowedTags:[...n],additionalAllowedAttributes:r,allowFormControls:!0,templateMode:!0};return jn(qn,e,i,64)}var Kn="data-payload-key",Jn="data-payload-nested-key",Qn="data-payload-nested-template";function Xn(e){const t=Zn(e.container,e.patches,e);return null===t?null:er(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function Yn(e,t){return t.hasAttribute(Jn)&&t.hasAttribute(Qn)}function Zn(e,t,n){const r=function(e,t,n){const{template:r,nextItems:i,forceRender:o=!1,store:s,sanitizerPolicy:a}=n,l=s.get(e),u=On(e),d=In(i),c=Array.from(e.children),h=ar(c,Kn),f=/* @__PURE__ */new Set,p=[];for(let s=0;s<i.length;s+=1){const m=i[s],g=sr(m);let v=void 0===g?c[s]??null:lr(h,g)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);const y=t.replaces.has(s),b=o||t.renders.has(s)||null===v?ur(e.ownerDocument,r,m,s,a,u,d):void 0;if(null===b)return null;const w=void 0===b?[]:tr(y?null:v,b,m,void 0===g?void 0:l?.get(g),n);if(null===w)return null;p.push([s,v,b,w,y])}return p}(e,function(e){const t=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set;for(const r of e)"insert"===r.kind||"update"===r.kind?t.add(r.index):"replace"===r.kind&&(t.add(r.index),n.add(r.index));return{renders:t,replaces:n}}(t),n);return null===r?null:[e,r,n.nextItems]}function er(e,t,n){const[r,i,o]=e,s=/* @__PURE__ */new Set;let a=!1;for(const[e,o,l,u,d]of i){let i=o;if(void 0!==l){const e=!(!n.morph||d||null===o)&&ln(o,l,{keyAttributes:[Kn,Jn],retainChildrenOf:Yn,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===o;if(!e)for(const[e,t]of u)null!==e&&(rr(e,t),t.replaceWith(e));for(const[,,e]of u)void 0!==e&&er(e,t,n);e?a=!0:(null!==o&&(o.replaceWith(l),a=!0),i=l)}if(null===i)continue;const c=r.children[e]??null;i!==c&&(r.insertBefore(i,c),a=!0),s.add(i)}for(const e of Array.from(r.children))s.has(e)||(e.remove(),a=!0);const l=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(r,t);l.clear();for(const e of o)or(l,e);return a}function tr(e,t,n,r,i){const o=ar(null===e?[]:nr(e),Jn),s=[];for(const e of nr(t)){const t=e.getAttribute(Jn);if(null===t)continue;const a=lr(o,t)??null,l=e.getAttribute(Qn),u=l?a:null,d=u?.getAttribute(Qn)??null;let c;if(l){const o=ir(n,t);if(void 0!==o||null!==u){const n=o??[],s=E(null===u?[]:ir(r,t)??[],n),a=null!==u&&d!==l;if((s.length>0||a)&&(c=Zn(u??e,s,{template:l,nextItems:n,forceRender:a,store:i.store,sanitizerPolicy:i.sanitizerPolicy})??void 0,void 0===c))return null}}s.push([u,e,c])}return s}function nr(e){return Array.from(e.querySelectorAll(`[${Jn}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Jn))return!1;n=n.parentElement}return n===e})}function rr(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||e.removeAttribute(n.name);for(const n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function ir(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function or(e,t){const n=sr(t);void 0!==n&&e.set(n,t)}function sr(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function ar(e,t){const n=/* @__PURE__ */new Map;for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(void 0===i)continue;const o=i.getAttribute(t);if(null===o)continue;const s=n.get(o);void 0===s?n.set(o,[i]):s.push(i)}return n}function lr(e,t){return e.get(t)?.pop()}function ur(e,t,n,r,i,o,s){const a=Cn(Mn(t,n,r,Dn,s),i,Gn(t)),l=e.createElement("template");l.innerHTML=rn(a);const u=l.content.firstElementChild;if(!u)return null;_n(u,o);const d=sr(n);return void 0!==d&&u.setAttribute(Kn,d),u}function dr(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`))}function cr(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`))}var hr=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;planFragments(e){const t=this.deps.strategies.fragment;return void 0===t?null:fr(t,t.plan(this.deps.root,e))}escalateUnfaithful(e,t,n){if(e.routeRefreshed)return;const{fragment:r,route:i}=this.deps.strategies,o=void 0===r?void 0:function(e){const t=[];for(const n of e){const e=n.fragmentBoundary;if(void 0===e)return;t.includes(e)||t.push(e)}return t}(n);if(void 0!==r&&void 0!==o)return this.state.escalatedCount+=n.length,e.pendingFragments+=o.length,void this.runFragments(e,t,fr(r,o));void 0!==i&&(this.state.escalatedCount+=n.length,this.refreshRoute(e,t,i))}hasUnboundChange(e,t){const{deps:n,state:r}=this;if(e.baseline||e.routeRefreshed)return!1;const i=he(n.cache,e.touched,e.locale,t);let o=0;for(const e of i)q(r,e)&&(o+=1);const[s]=i;return void 0!==s&&"escalate"===n.onUnfaithfulPatch&&void 0!==n.strategies.route&&(n.log("route","LP0807",`field "${s}" has no binding; refreshing the route`),r.escalatedCount+=o,!0)}hasRouteBinding(e){for(const[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){const{deps:r,state:i}=this,o=new AbortController;i.fragmentController=o;const s=()=>i.isCurrent(e)&&!o.signal.aborted,{emitter:a}=r,{message:l}=e,u=e.revision.revision,d=e.receivedAt,c={root:r.root,revision:u,receivedAt:d,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof l.collectionSlug?l.collectionSlug:void 0,globalSlug:"string"==typeof l.globalSlug?l.globalSlug:void 0,signal:o.signal,isCurrent:s,log:(e,t)=>{r.log("fragment",e,t)},morph:(e,t)=>{!function(e,t){const n=e.ownerDocument.createElement("template");n.innerHTML=rn(t);const r=e.cloneNode(!1);r.append(n.content),ln(e,r,{keyAttributes:[Kn]})}(e,t)},patch:n=>{this.patchFallback(e,t,n)},rendered:(t,n,r)=>{e.pendingFragments-=1,a.emitWhile("fragmentRender",{element:t,id:n,key:r,status:"rendered",revision:u,receivedAt:d},s)},failed:(t,n,i,o,l)=>{e.pendingFragments-=1;const c=`fragment "${n}" fell back to patch: ${l}`;r.log("fragment",o,c),a.emitWhile("error",{error:new Error(c),context:"fragment",code:o},s),a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"failed",code:o,revision:u,receivedAt:d},s)}};let h={rendered:0,failed:0,superseded:0};try{h=await n.strategy.render(c,n.boundaries)}catch(i){if(r.log("fragment","LP0801",i),s()){for(const r of n.boundaries)this.patchFallback(e,t,r);h={rendered:0,failed:n.boundaries.length,superseded:0}}}i.fragmentStats.rendered+=h.rendered,i.fragmentStats.failed+=h.failed,i.fragmentStats.superseded+=h.superseded,s()&&(i.fragmentController===o&&(i.fragmentController=null),e.pendingFragments=0,h.rendered>0&&this.host.restoreGuesses(e,t),0===r.scheduler.pendingCount&&i.complete(e),this.host.revealPending(e),s()&&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"},s))}async refreshRoute(e,t,n){const{deps:r,state:i}=this;if(e.routeRefreshed)return i.routeStats.loopStopped+=1,void r.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,r){const{state:i}=this;null!==i.routeRetry&&clearTimeout(i.routeRetry),i.routeRetry=setTimeout(()=>{i.routeRetry=null,i.isCurrent(e)&&this.runRoute(e,t,n)},r)}async runRoute(e,t,n){const{deps:r,state:i}=this,o=i.routeStats,s=new AbortController;i.routeController=s;const a=()=>i.isCurrent(e)&&!s.signal.aborted;let l;try{l=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:s.signal,isCurrent:a,log:(e,t)=>{r.log("route",e,t)},retryAfter:r=>{this.armRouteRetry(e,t,n,r)}})}catch(e){r.log("route","LP0801",e),l="failed"}if(a()){if(i.routeController===s&&(i.routeController=null),"refreshed"===l){if(o.refreshes+=1,i.lastAppliedIdentity=/* @__PURE__ */new WeakMap,this.host.restoreGuesses(e,t),this.host.rebuildCache(),!a())return;return this.host.reapply(e,t),void(r.emitter.listenerCount("afterUpdate")>0&&r.emitter.emitWhile("afterUpdate",{data:t,updatedCount:r.cache.elementCount,durationMs:Date.now()-e.receivedAt,revision:e.revision.revision,receivedAt:e.receivedAt,source:"route"},a))}"failed"===l?o.failed+=1:"refused"===l&&(o.refused+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){dr(this.deps,this.state,e)}warnUnsupportedStrategy(e){cr(this.deps,this.state,e)}patchFallback(e,t,n){for(const[r,i]of this.deps.cache.entries())for(const o of i){if(o.fragmentBoundary!==n)continue;const i=Xt(t.fields,o,r,e.locale);void 0!==i&&this.deps.scheduler.schedule({target:o,value:this.host.transform(o,i,t.fields,()=>!0),allFields:t.fields,revision:e.revision,data:t})}}};function fr(e,t){const n=new Set(t);return{boundaries:t,strategy:e,covers:e=>void 0!==e.fragmentBoundary&&n.has(e.fragmentBoundary)}}function pr(e,t,n,r,i){const o=e.transformValue;if(void 0===o)return n;try{const e=o(t.fieldName,n,{element:t.element,allFields:r},i),s=f(e);if(!i())return n;if(s)throw new TypeError(`Transform for "${t.fieldName}" returned a thenable; transforms must be synchronous`);return e}catch(t){if(!i())return n;const r=t instanceof Error?t:new Error(String(t));return e.emitter.emit("error",{error:r,context:"transform",code:"LP0602"}),n}}var mr=/* @__PURE__ */new Set,gr=class{constructor(e,t,n){this.deps=e,this.state=t,this.strategies="undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e,t){return{planFragments:()=>null,escalateUnfaithful:()=>{},hasUnboundChange:(n,r)=>{if(n.baseline)return!1;const i=he(e.cache,n.touched,n.locale,r);for(const e of i)q(t,e);return!1},hasRouteBinding:()=>!1,runFragments:()=>Promise.resolve(),refreshRoute:()=>(k("route refreshes"),Promise.resolve()),warnFragmentFallback:n=>{k("server-rendered fragments"),dr(e,t,n)},warnUnsupportedStrategy:n=>{cr(e,t,n)}}}(e,t):new hr(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,r,i)=>pr(e,t,n,r,i),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}})}deps;state;strategies;handleUpdate(e,t,n){const{deps:r,state:i}=this;if(r.heartbeat.kick(),i.protocol.observe(function(e){const 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),r.log),void 0===e.data)return void(void 0!==e.protocolVersion&&i.protocol.applyVersion(e.protocolVersion,r.log));if(void 0===n)return;const o=i.relationships.edit(e);null!==o&&r.emitter.emit("relationshipUpdate",{detail:o,timestamp:Date.now()}),"string"==typeof e.locale&&(i.locale=e.locale),Array.isArray(e.fieldSchemaJSON)&&(i.schema=e.fieldSchemaJSON,i.schemaIndex=$(e.fieldSchemaJSON));const s={revision:n,message:e,locale:i.locale,schema:i.schema,schemaIndex:i.schemaIndex,receivedAt:Date.now(),forceRender:null!==o||Se(i.activeUpdate),touched:/* @__PURE__ */new Set,baseline:!1,invalidated:/* @__PURE__ */new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},a=i.activeUpdate;if(i.abortStrategies(),null===a||a.completed||(i.supersededCount+=1),i.activeUpdate=s,r.scheduler.acceptRevision(n),i.updateCount+=1,void 0===e.protocolVersion||(i.protocol.applyVersion(e.protocolVersion,r.log),i.isCurrent(s))){if(r.connection.markConnected()){if(r.a11y?.announceConnected(),r.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!i.isCurrent(s))return;if(r.log("connection","disconnected","→","connected"),!i.isCurrent(s))return}this.processUpdate(s).catch(e=>{r.log("update failed:",e)})}}async processUpdate(e){const{deps:t,state:n}=this,r=await this.resolveIncomingFields(e);if(null===r||!n.isCurrent(e))return;const i=this.dataFor(e,r);t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:i,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,i,!1)}dataFor(e,t){const{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){const{deps:r,state:i}=this,o=$e(r.dependencies,r.cache.dependencyMap()),s=i.changes.diff(t.fields,o);if(s.baseline&&!n&&"off"!==r.autoBind)if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)k("auto-binding");else{const n=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,r,i){const o=performance.now(),s=qt(e.root),a=_t(n,r),l=null===s?[]:Gt(e,Vt(s,a),i,"on the first message");t.autoBindGuesses=function(e,t){const n=/* @__PURE__ */new Set;for(const{fieldName:e,stamps:r}of t){n.add(e);for(const e of[_e,ze]){const t=r[e];void 0!==t&&n.add(t)}}const r=/* @__PURE__ */new Map;for(const[t,i]of e)null!==i&&n.has(i.field)&&r.set(t,i);return{fields:n,values:r}}(a,l),t.autoBindSearchMs=performance.now()-o,l.length}(r,i,t.fields,e.locale,n)}e.baseline=s.baseline,e.invalidated=n?mr:s.invalidated,e.touched=n?mr:/* @__PURE__ */new Set([...s.changed,...s.invalidated]),this.scheduleAllFields(e,t)}async resolveIncomingFields(e){const{deps:t,state:n}=this,r=e.message.data??{};if(null===t.merger)return r;if("admin"===detectProtocolProfile(n.protocol.observed).populatesRelationships)return r;const i=n.merges.decide(t,e);if(!i.merge)return i.fields;const{message:o}=e,s=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:o.collectionSlug,globalSlug:o.globalSlug,data:r,locale:e.locale});if(!s.leading)return this.applyMerged(e,s.result).catch(e=>{t.log("update failed:",e)}),i.fields;const a=await s.result;return n.isCurrent(e)?"merged"===a.status?(n.merges.recordMerged(a.doc),a.doc):"superseded"===a.status?null:i.fields:null}async applyMerged(e,t){const{state:n}=this,r=await t;"merged"===r.status&&n.isCurrent(e)&&(n.merges.recordMerged(r.doc),this.applyFields(e,this.dataFor(e,r.doc),!0))}scheduleAllFields(e,t){const{deps:n,state:r}=this;if(!r.isCurrent(e))return;const i=()=>r.isCurrent(e),o=this.ownerKeysForUpdate(e,t.fields),{touched:s}=e,a=n.strategies.route,l=this.strategies.hasUnboundChange(e,o),u=r.routeRefreshOwed;if(void 0!==a&&!e.routeRefreshed&&(l||u||a.plan(n.root,s)||this.strategies.hasRouteBinding(s)))return r.routeRefreshOwed=!1,void this.strategies.refreshRoute(e,t,a);const d=this.strategies.planFragments(s),c=n.skipUnchanged;let h=0;for(const[s,a]of n.cache.entries()){if(!i())return;for(const l of a){if(!1!==o&&!oe(l.owner,o))continue;if(!0===d?.covers(l)){if(n.revealEditedField){const n=Xt(t.fields,l,s,e.locale);r.revealLedger.note(e,l,n)}continue}const a=l.strategyKind??ne(l.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(l);continue}"fragment"===a&&null===d&&this.strategies.warnFragmentFallback(l);const u=Xt(t.fields,l,s,e.locale);if(void 0===u){r.absentFields.add(s);continue}if(n.revealEditedField&&r.revealLedger.note(e,l,u),!i())return;const f=pr(n,l,u,t.fields,i);if(!i())return;const p=c?Yt(l,f,t.fields,e.locale):void 0,m=r.lastAppliedIdentity.get(l.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&m===p&&!e.invalidated.has(s)){r.skippedUnchangedCount+=1;continue}const g={target:l,value:f,allFields:t.fields,revision:e.revision,data:t,valueIdentity:p};n.scheduler.schedule(g),h+=1}}(function(e,t,n,r){const{cache:i}=e;if(0===i.fieldCount)return;if(!1!==r&&!function(e,t){for(const n of e.values())if(oe(n.owner,t))return!0;return!1}(i,r))return;const o=ce(i,n,r);for(const[r,i]of Object.entries(t)){if(ae.has(r))continue;if(en(i)){Zt(e,o,r,n);continue}if(!tn(i)||o(r))continue;const t=de(r,n);for(const[r,s]of Object.entries(i))en(s)&&!ae.has(r)&&Zt(e,o,`${t}.${r}`,n)}})({cache:n.cache,warned:r.warnedOrphanFields,warn:n.warn},t.fields,e.locale,o),null!==d&&d.boundaries.length>0&&(e.pendingFragments=d.boundaries.length,this.strategies.runFragments(e,t,d)),0===h&&0===e.pendingFragments&&(r.complete(e),this.revealPending(e),this.notifyIslands(e,t))}notifyIslands(e,t){0!==e.touched.size&&function(e,t){for(const n of e)n.dispatchEvent(new CustomEvent(xe,{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){const{deps:n,state:r}=this;if("off"!==n.autoBind&&null!==r.autoBindGuesses&&("undefined"==typeof __LEAN_BUILD__||!__LEAN_BUILD__)){const i=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,r,i){const o=t.autoBindGuesses,s=qt(e.root);if(null===o||0===o.fields.size||null===s)return 0;const a=new Map(o.values);for(const[e,t]of _t(n,r)){if(null===t||!o.fields.has(t.field))continue;const n=a.get(e);void 0===n?a.set(e,t):n?.field!==t.field&&a.set(e,null)}Gt(e,Vt(s,a),i,"after a server render").length}(n,r,t.fields,e.locale,i)}}ownerKeysForUpdate(e,t){const{deps:n,state:r}=this;if(!n.scopeBindingsByOwner)return!1;const{message:i}=e,o=function(e){if(ie(e.globalSlug))return[(t=e.globalSlug,`global:${t}`)];var t;if(!ie(e.collectionSlug))return null;const n=re(e.collectionSlug);return ie(e.documentId)?[n,re(e.collectionSlug,e.documentId)]:[n]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:se(t)});return null!==o||r.warnedUnattributableMessage||(r.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),o}onFlush(e){const{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`));const{revision:r,data:i}=e;if(void 0===r)return;const o=n.activeUpdate;if(null===o||!n.isCurrent(o)||!p(o.revision,r))return;0===o.pendingFragments&&n.complete(o);const s=()=>n.isCurrent(o)&&p(o.revision,r);if(this.revealPending(o),!s())return;const a=n.unfaithfulPatches;a.length>0&&(n.unfaithfulPatches=[],void 0!==i&&this.strategies.escalateUnfaithful(o,i,a),!s())||void 0!==i&&(e.applied>0&&t.a11y?.announceUpdate(e.applied),s()&&(this.notifyIslands(o,i),s()&&0!==e.applied&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:i,updatedCount:e.applied,durationMs:e.durationMs,revision:r.revision,receivedAt:o.receivedAt,source:"patch"},s)))}revealPending(e){const t=this.state.revealLedger.commit(e);if(void 0!==t)try{this.revealBinding(t)}catch(e){this.deps.log("reveal",e)}}revealField(e){const t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":this.revealBinding(t)}revealBinding(e){const{element:t}=e,n=t.ownerDocument.defaultView;if(null===n)return"no-element";const r=`${e.owner??""} ${e.fieldName}`;return this.state.revealer.reveal(r,t,n)}},vr=class{apply;debounceMs;maxWaitMs;isVisible;gateThresholdValue;gateDisabled;getCacheSize;onFlush;scheduleFrame;cancelFrame;pending=/* @__PURE__ */new Map;replay=/* @__PURE__ */new Map;activeFlushes=/* @__PURE__ */new Set;debounceTimer=null;debounceToken=0;deadlineTimer=null;frameHandle=null;frameToken=0;windowUntil=0;activeRevision=null;activeRevisionCancelled=!1;constructor(e,t){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){if(this.activeRevisionCancelled)return;if(null===this.activeRevision||!p(e.revision,this.activeRevision))return}const 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){var t,n;null!==this.activeRevision&&p(e,this.activeRevision)||null!==this.activeRevision&&(t=e,n=this.activeRevision,(t.generation!==n.generation?t.generation-n.generation:t.revision-n.revision)<0)||(this.cancelScheduledWork(),this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1)}cancelRevision(e){null!==this.activeRevision&&p(e,this.activeRevision)&&(this.cancelScheduledWork(),this.clearWork(),this.activeRevisionCancelled=!0)}flushNow(){return this.cancelScheduledWork(),this.flush()}notifyVisible(e){const t=this.replay.get(e);if(!t)return;if(this.replay.delete(e),!this.isCurrent(t))return;const n=performance.now(),r=this.didApply(t)?1:0;this.onFlush?.(this.statsFor(t,r,0,performance.now()-n,1===r?[t.target.fieldName]:[]))}retarget(e){this.retargetBuffer(this.pending,e),this.retargetBuffer(this.replay,e);for(const t of this.activeFlushes)this.retargetBuffer(t,e)}forget(e){this.pending.delete(e),this.replay.delete(e);for(const 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(){const e=Date.now(),t=e>=this.windowUntil;if(this.windowUntil=e+this.debounceMs,t)return void this.requestFrame();const n=this.debounceToken+=1,r=this.debounceTimer;if(this.debounceTimer=null,null!==r&&clearTimeout(r),this.debounceToken!==n)return;const i=setTimeout(()=>{this.debounceToken===n&&(this.debounceTimer=null,this.pending.size>0&&this.requestFrame())},this.debounceMs);this.debounceToken===n&&(this.debounceTimer=i),null===this.deadlineTimer&&this.maxWaitMs>this.debounceMs&&(this.deadlineTimer=setTimeout(()=>{this.deadlineTimer=null,this.pending.size>0&&this.requestFrame()},this.maxWaitMs))}requestFrame(){const e=this.frameToken+=1,t=this.frameHandle;if(this.frameHandle=null,null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1;const r=this.scheduleFrame(()=>{this.frameToken===e&&(n=!0,this.frameHandle=null,this.flush())});n||this.frameToken!==e||(this.frameHandle=r)}flush(){const e=performance.now();this.clearDeadline();const t=this.gateActive,n=this.pending;this.pending=/* @__PURE__ */new Map;let r=0;const i=[];let o,s=0;this.activeFlushes.add(n);try{for(const e of n.values()){if(!this.isCurrent(e))continue;const n=!t||this.isVisible(e.target.element);this.isCurrent(e)&&(o??=e,n?(this.replay.delete(e.target.element),this.didApply(e)&&(r+=1,i.push(e.target.fieldName))):(this.replay.set(e.target.element,e),s+=1))}}finally{this.activeFlushes.delete(n)}const a=this.statsFor(o,r,s,performance.now()-e,i);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&p(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||(t=this.apply,!Q.has(t));var t}retargetBuffer(e,t){const n=e.get(t.element);void 0!==n&&(n.target.fieldName===t.fieldName&&n.target.locale===t.locale?n.target=t:e.delete(t.element))}clearWork(){this.pending.clear(),this.replay.clear();for(const e of this.activeFlushes)e.clear()}statsFor(e,t,n,r,i){return{applied:t,appliedFields:i,deferred:n,durationMs:r,...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(){const 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)}},yr=[0,500,1e3,2e3],br=class{deps;state=new Re;pipeline;writer;rootSentinel=null;observedRoot=null;constructor(e){const{emitter:t,renderers:n}=e,r=void 0===e.log?v:g(e.log),i=void 0===e.warn?b:g(e.warn),o=e.root??("undefined"!=typeof document?document:void 0);if(void 0===o)throw new Error("LivePreviewRuntime: no document; pass options.root");const s=new st({filter:e=>!isInsideIsland(e)}),a=new mt({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&l.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),l=new vr(X(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=>a.isVisible(e),getCacheSize:()=>s.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),u=new m(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],r),t.emit("documentSave",{timestamp:Date.now()})},onFocusField:e=>{this.deps.revealEditedField&&this.pipeline.revealField(e)},onInvalid:(e,n)=>{if("token"===e){const e=new Error(`Preview token rejected (origin: ${n})`);t.emit("error",{error:e,context:"token",code:"LP0502"})}"shape"!==e&&"type"!==e||this.state.warnedProtocolShape||(this.state.warnedProtocolShape=!0,i(`[live-preview] LP0503: ${n} 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,i(`[live-preview] LP0501: a message from ${n} 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.`)),r("LP0501 message rejected:",e,n)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),d=e.dataMerge;this.deps={emitter:t,cache:s,observers:a,scheduler:l,bus:u,connection:new xt,heartbeat:new Nt({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:n,resolveRenderer:e.resolveRenderer??(e=>n[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,root:o,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:/* @__PURE__ */(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??C,onHeartbeatTimeout:e.onHeartbeatTimeout,log:r,warn:i,a11y:T(e),merger:void 0===d?null:new ct({serverURL:d.serverURL,...void 0!==d.apiRoute?{apiRoute:d.apiRoute}:{},...void 0!==d.depth?{depth:d.depth}:{},...void 0!==d.fetchFn?{fetchFn:d.fetchFn}:{},log:r}),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:W(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new Pe(this.deps,this.state),this.pipeline=new gr(this.deps,this.state,()=>{this.rebuildCache()})}start(){const{state:e}=this;if(e.isRunning())return!1;e.started=!0,e.suspended=!1;try{return function(e){"react"===e.hydration?bt():"vue"===e.hydration&&Rt();const{root:t}=e;if(!function(e){return 9===e.nodeType}(t)||"loading"!==t.readyState)return void Pt(e);const n=()=>{e.isRunning()&&e.later(()=>{Pt(e)})};t.addEventListener("DOMContentLoaded",n,{once:!0}),e.defer(()=>{t.removeEventListener("DOMContentLoaded",n)})}(this.startupHost()),!0}catch(e){throw this.rollbackFailedStart(),e}}startupHost(){const{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(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=wr(t.root)?Sr(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(const n of yr){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;const e=this.release();return this.state.suspended=!0,e&&this.deps.emitter.emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0}destroy(){const{state:e,deps:t}=this;if(!e.isRunning()&&!e.suspended)return;const 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(){const{state:e,deps:t}=this;e.activeUpdate=null,e.started=!1;const n=e.deferredStart;e.deferredStart=null,null!==n&&this.runCleanup(n);for(const 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(){const{root:e}=this.deps;wr(e)&&"undefined"!=typeof MutationObserver&&(this.rootSentinel?.disconnect(),this.rootSentinel=new MutationObserver(()=>{this.followReplacedRoot()}),this.rootSentinel.observe(e.documentElement,{childList:!0}))}followReplacedRoot(){const{root:e}=this.deps;if(!this.state.isRunning()||!wr(e))return!1;const t=Sr(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(t,n){const{cache:r,scheduler:i}=t,o=n.protocol.negotiation,s=n.activeUpdate,a=n.lastFlush,l=[],u=/* @__PURE__ */new Set,d=[];for(const[e,t]of r.entries()){l.push(e);for(const n of t)void 0!==n.owner&&u.add(n.owner),void 0!==n.guessed&&d.push({field:e,matched:n.guessed,attribute:n.targetAttribute??("IMG"===n.element.tagName?"src":void 0)})}return{version:e,started:n.started,status:t.connection.status,origins:{trusted:[...t.readyTargets()],locked:t.lockedOrigin()},protocol:{ours:o.ours,theirs:o.theirs,negotiated:o.negotiated,capabilities:[...o.capabilities].sort(),observed:[...o.observed].sort(),profile:detectProtocolProfile(o.observed).name},revisions:{accepted:n.updateCount,superseded:n.supersededCount,completed:n.completedCount,skippedUnchanged:n.skippedUnchangedCount,active:null===s?void 0:s.revision.revision},bindings:{elements:r.elementCount,fields:r.fieldCount,fieldNames:l.sort(),absentFields:[...n.absentFields].sort(),orphanFields:[...n.warnedOrphanFields].sort(),ownerScoped:t.scopeBindingsByOwner,owners:[...u].sort(),guessed:d.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:t.autoBind,searchMs:n.autoBindSearchMs}},route:{handler:void 0!==t.strategies.route,...n.routeStats},fidelity:{mode:t.onUnfaithfulPatch,unfaithful:n.unfaithfulCount,escalated:n.escalatedCount,fields:[...n.unfaithfulFields].sort()},hydration:{mode:t.hydration??"off",state:n.hydration},fragments:{handler:void 0!==t.strategies.fragment,inFlight:s?.pendingFragments??0,...n.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(t.renderers).sort()}}(this.deps,this.state)}buildCacheAndObserve(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=t.cache.buildFromRoot(t.root);if(t.log("cache",n),e.isRunning()&&(t.emitter.emitWhile("cacheRefresh",n,()=>e.isRunning()),e.isRunning()))for(const n of t.cache.values()){if(!e.isRunning())return;t.observers.observeElement(n.element)}}rebuildCache(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=/* @__PURE__ */new Map;for(const e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),e.isRunning()){for(const e of t.cache.values()){const r=n.get(e.element);r?.fieldName===e.fieldName?t.scheduler.retarget(e):t.scheduler.forget(e.element),n.delete(e.element)}for(const e of n.values())t.scheduler.forget(e.element)}}onHeartbeatTimeout(){const{state:e,deps:t}=this;if(!e.isRunning())return;t.bus.advanceGeneration();const n=e.activeUpdate;e.activeUpdate=null,null!==n&&t.scheduler.cancelRevision(n.revision),t.merger?.destroy(),e.merges.destroy();const r=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}if(e.isRunning()){if(r&&this.isIdleDisconnected()){if(t.a11y?.announceDisconnected(),t.emitter.emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.isIdleDisconnected()),!e.isRunning())return;if(this.isIdleDisconnected()&&t.log("connection","connected","→","disconnected"),!e.isRunning())return}this.sendReadyAfterStart()}}sendReadyAfterStart(){try{this.deps.sendReady(this.deps.readyTargets())}catch(e){this.reportError(e,"ready","LP0606")}}reportError(e,t,n){const r=e instanceof Error?e:new Error(String(e));this.deps.emitter.emit("error",{error:r,context:t,code:n})}isIdleDisconnected(){return this.state.isRunning()&&"disconnected"===this.deps.connection.status&&null===this.state.activeUpdate}};function wr(e){return 9===e.nodeType}function Sr(e){return e.body}var EventEmitter=class{#t=/* @__PURE__ */new Map;#n=/* @__PURE__ */new Map;on(e,t){return this.#r(this.#t,e,t)}once(e,t){return this.#r(this.#n,e,t)}off(e,t){this.#i(this.#t,e,t),this.#i(this.#n,e,t)}async emit(e,t){await this.#o(e,t)}async emitWhile(e,t,n){return this.#o(e,t,n)}async#o(e,t,n){const r=()=>n?.()??!0;if(!r())return!1;const i=this.#t.get(e);if(i)for(const n of[...i]){if(!r())return!1;if(await this.#s(n,t,e),!r())return!1}if(!r())return!1;const o=this.#n.get(e);if(o&&o.size>0){const n=[...o];this.#n.delete(e);for(const i of n){if(!r())return!1;if(await this.#s(i,t,e),!r())return!1}}return r()}listenerCount(e){return(this.#t.get(e)?.size??0)+(this.#n.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#t.clear(),void this.#n.clear();this.#t.delete(e),this.#n.delete(e)}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#t.keys())e.add(t);for(const t of this.#n.keys())e.add(t);return[...e]}#r(e,t,n){let r=e.get(t);return r||(r=/* @__PURE__ */new Set,e.set(t,r)),r.add(n),()=>{this.#i(e,t,n)}}#i(e,t,n){const r=e.get(t);void 0!==r&&(r.delete(n),0===r.size&&e.delete(t))}async#s(e,t,n){try{await e(t)}catch(e){const t="string"==typeof n||"number"==typeof n?String(n):"<event>";y(`[live-preview] LP0601: handler for "${t}" threw:`,e)}}};function isInIframe(){if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch{return!0}}function isInPopup(){return"undefined"!=typeof window&&null!=window.opener}function isInPreviewContext(){return isInIframe()||isInPopup()}function isDevMode(){const e=function(){if("undefined"==typeof process)return;const e=process.env.NODE_ENV;return"string"==typeof e?e:void 0}();if(void 0!==e)return"production"!==e;if("undefined"!=typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}var Ar=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,kr=/^https?:\/\/[^/?#\s]+$/i,Tr=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],OriginDetector=class{#a;constructor(e={}){const t=/* @__PURE__ */new Set;for(const n of e.additionalOrigins??[]){const e=Cr(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){const t=e.referrer??("undefined"!=typeof document?document.referrer:"");if(t.length>0)try{const e=new URL(t).origin;e&&"null"!==e&&(n=e)}catch{}}const r=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??isDevMode());this.#a=[t,n,r,void 0!==n,void 0]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#a[4]?e===this.#a[4]:!!this.#a[0].has(e)||0===this.#a[0].size&&void 0!==this.#a[1]&&e===this.#a[1]||!(!this.#a[2]||!Ar.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#a[4]=e,!0)}unlockOrigin(){const e=this.#a[4];return this.#a[4]=void 0,e}get lockedOrigin(){return this.#a[4]}enumerate(){if(void 0!==this.#a[4])return[this.#a[4]];const e=new Set(this.#a[0]);if(0===this.#a[0].size&&void 0!==this.#a[1]&&e.add(this.#a[1]),this.#a[2])for(const t of Tr)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#a[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#a[0].size>0||this.#a[2]||void 0!==this.#a[1])}get isReferrerOnlyTrust(){return!(this.#a[0].size>0||this.#a[2]||void 0===this.#a[1])}};function Cr(e){const t=e.trim();if(0!==t.length)try{const e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return;if(!kr.test(e.origin))return;return e.origin}catch{return}}var Rr=()=>{},Pr=class{#l;#u;#d=/* @__PURE__ */new Set;#a="staging";constructor(e,t){this.#l=e,this.#u=t}assertOpen(){if("closed"===this.#a)throw new Error(`Plugin context for "${this.#l}" is no longer active`)}get active(){return"active"===this.#a}eligible(){return"closed"!==this.#a}own(e){return this.assertOpen(),this.#c({kind:"cleanup",acquire:void 0,finalize:void 0,cleanup:e,disposed:!1})}stage(e,t,n){this.assertOpen();const r={kind:e,acquire:t,finalize:n,cleanup:void 0,disposed:!1},i=this.#c(r);if("active"===this.#a)try{this.#h(r)}catch(e){throw this.#f(r),e}return i}counts(){const e={transform:0,renderer:0,subscription:0,cleanup:0};for(const t of this.#d)e[t.kind]+=1;return e}commit(){if("staging"!==this.#a)throw new Error(`Plugin context for "${this.#l}" cannot be committed`);this.#a="committing";try{for(const e of this.#d)this.#h(e);this.#a="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#a){this.#a="closed";for(const e of[...this.#d].reverse())this.#f(e);this.#d.clear()}}#c(e){return this.#d.add(e),()=>{this.#f(e)}}#h(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;const t=e.acquire();e.cleanup=t??Rr}#f(e){if(e.disposed)return;e.disposed=!0,this.#d.delete(e);const t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{f(t())&&this.#u(`plugin "${this.#l}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#u(`plugin "${this.#l}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#u(`plugin "${this.#l}" cleanup failed:`,e)}}},$r=class{#p;#m;#g=/* @__PURE__ */new Set;constructor(e,t){this.#p=e,this.#m=t}on(e,t){return this.#v("on",e,t)}once(e,t){return this.#v("once",e,t)}off(e,t){const n=t;for(const t of[...this.#g])t.event===e&&t.handler===n&&t.dispose()}emit(e,t){return this.#m.assertOpen(),this.#p.emit(e,t)}emitWhile(e,t,n){return this.#m.assertOpen(),this.#p.emitWhile(e,t,()=>{if(!this.#m.eligible())return!1;const e=n();return!!this.#m.eligible()&&e})}listenerCount(e){let t=0;for(const n of this.#g)n.event===e&&(t+=1);return t}removeAllListeners(e){for(const t of[...this.#g])void 0!==e&&t.event!==e||t.dispose()}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#g)e.add(t.event);return[...e]}#v(e,t,n){this.#m.assertOpen();const r=n,i=[...this.#g].find(n=>n.kind===e&&n.event===t&&n.handler===r);if(void 0!==i)return i.dispose;let o=Rr,s=!0;const a=async t=>{this.#m.active&&s&&("once"===e&&o(),await n(t))},l={kind:e,event:t,handler:r,dispose:Rr};return o=this.#m.stage("subscription",()=>this.#p[e](t,a),()=>{s=!1,this.#g.delete(l)}),l.dispose=o,this.#g.add(l),o}},Nr=class{#p;#y;#b;#w;#u;#S=/* @__PURE__ */new Map;#A=/* @__PURE__ */new Map;#k=/* @__PURE__ */new Map;#T=/* @__PURE__ */new Set;#C=/* @__PURE__ */new Map;#R=Promise.resolve();#P=0;constructor(e){this.#p=e.events,this.#y=e.config,this.#b=e.registerFieldRenderer,this.#u=g(e.log);const t=e.onTransformError;this.#w=void 0===t?void 0:g((...e)=>{const n=e[0];try{return t(n)}catch(e){return void this.#u("transform error reporter failed:",e)}})}register(e){return this.#P>0?this.#$(e,!1):this.#N(()=>this.#$(e,!0))}unregister(e){return this.#P>0?this.#x(e,!1):this.#N(async()=>{await this.#x(e,!0)})}destroyAll(){return this.#P>0?this.#L(!1):this.#N(async()=>{await this.#L(!0)})}applyTransforms(e,t,n,r){const i=this.#C.get(e);if(void 0===i||0===i.length)return t;let o=t;for(const s of[...i]){if(!s.active)continue;const{transform:i}=s;if(!1===r?.())return t;try{o=i(o,{fieldName:e,element:n.element,allFields:n.allFields});const s=f(o);if(!1===r?.())return t;if(s)throw new TypeError(`Transform for "${e}" returned a Promise/thenable; transforms must be synchronous`)}catch(n){if(!1===r?.())return t;const i=n instanceof Error?n:new Error(String(n));return this.#u(`transform for "${e}" failed:`,i),this.#w?.(i),t}}return o}list(){return[...this.#S.keys()]}snapshot(){const e=[],t=(e,t,n,r)=>{const i=r.counts();return{name:e,version:t,state:n,registrations:{transforms:i.transform,renderers:i.renderer,subscriptions:i.subscription,cleanups:i.cleanup}}};for(const[n,r]of this.#A)e.push(t(n,void 0,"initializing",r.scope));for(const[n,r]of this.#S)e.push(t(n,r.plugin.version,"active",r.scope));for(const t of this.#k.keys())e.push({name:t,version:void 0,state:"tearing-down",registrations:{transforms:0,renderers:0,subscriptions:0,cleanups:0}});return e}get size(){return this.#S.size}async#$(t,n){if(this.#S.has(t.name)||this.#A.has(t.name)||this.#k.has(t.name))return void this.#u(`plugin "${t.name}" already registered`);const r=function(e,t){if(void 0!==e){if(void 0!==e.runtime&&!function(e,t){const n=function(e){const t=/^v?(\d+)\.(\d+)\.(\d+)/.exec(e.trim());if(null!==t)return[Number(t[1]),Number(t[2]),Number(t[3])]}(e);return void 0!==n&&t.split("||").some(e=>{const r=e.trim().split(/\s+/).filter(e=>e.length>0);return 0===r.length?""===e.trim()&&""===t.trim():r.every(e=>function(e,t){const n=t.trim();if(""===n||"*"===n)return!0;const r=/^(\^|~|>=|<=|>|<|=)?\s*v?(\d+)\.(\d+)\.(\d+)/.exec(n);if(null===r)return!1;const i=r[1]??"=",o=[Number(r[2]),Number(r[3]),Number(r[4])],s=function(e,t){for(let n=0;n<3;n+=1){const r=(e[n]??0)-(t[n]??0);if(0!==r)return r}return 0}(e,o);switch(i){case"=":return 0===s;case">":return s>0;case">=":return s>=0;case"<":return s<0;case"<=":return s<=0;case"~":return s>=0&&e[0]===o[0]&&e[1]===o[1];case"^":return!(s<0)&&(o[0]>0?e[0]===o[0]:o[1]>0?0===e[0]&&e[1]===o[1]:0===e[0]&&0===e[1]&&e[2]===o[2]);default:return!1}}(n,e))})}(t,e.runtime))return`declares runtime ${e.runtime}, this runtime is ${t}`;if(void 0!==e.protocol){if(!Number.isInteger(e.protocol)||e.protocol<1)return`declares an invalid protocol version ${String(e.protocol)}`;if(e.protocol<4)return`declares protocol ${String(e.protocol)}, this runtime speaks ${String(4)}`}}}(t.compat,e);if(void 0!==r)return void this.#F(t.name,r);const i=new Pr(t.name,this.#u),o=this.#E(t.name,i),s={scope:i,cancelled:!1};this.#A.set(t.name,s);try{if(await this.#U(()=>t.init(o),n),s.cancelled)return;i.commit()}catch(e){return i.close(),void(s.cancelled||this.#u(`plugin "${t.name}" init failed:`,e))}finally{this.#A.get(t.name)===s&&this.#A.delete(t.name)}this.#S.set(t.name,{plugin:t,scope:i}),this.#u(`plugin "${t.name}" registered`)}#F(e,t){const n=`plugin "${e}" refused: ${t}`;this.#u(n),this.#p.emit("error",{error:new Error(n),context:"plugin",code:"LP0103"})}#E(e,t){return{events:new $r(this.#p,t),registerFieldRenderer:e=>{t.stage("renderer",()=>{const t=this.#b(e);return"function"==typeof t?t:void 0})},registerTransform:(e,n)=>{const r={transform:n,active:!1};t.stage("transform",()=>{r.active=!0;const t=this.#C.get(e);return void 0===t?this.#C.set(e,[r]):t.push(r),()=>{r.active=!1;const t=this.#C.get(e);if(void 0===t)return;const n=t.indexOf(r);n>=0&&t.splice(n,1),0===t.length&&this.#C.delete(e)}})},registerCleanup:e=>{t.own(e)},getConfig:()=>this.#y,log:(...t)=>{this.#u(`[${e}]`,...t)}}}#x(e,t){const n=this.#A.get(e);if(void 0!==n)return n.cancelled=!0,n.scope.close(),Promise.resolve();const r=this.#k.get(e);if(void 0!==r)return this.#T.has(e)?Promise.resolve():t?this.#I(r):r;const i=this.#S.get(e);if(void 0===i)return Promise.resolve();this.#S.delete(e),i.scope.close();const o=Promise.resolve().then(()=>this.#M(e,i.plugin,t));return this.#k.set(e,o),o.then(()=>{this.#k.get(e)===o&&this.#k.delete(e)}),o}async#M(e,t,n){if(void 0!==t.destroy){this.#T.add(e);try{await this.#U(()=>t.destroy?.(),n)}catch(t){this.#u(`plugin "${e}" destroy failed:`,t)}finally{this.#T.delete(e)}}}async#L(e){for(const e of this.#A.values())e.cancelled=!0,e.scope.close();const t=[...this.#S.keys()];for(const n of t)await this.#x(n,e)}async#U(e,t){t?await this.#I(Promise.resolve().then(e)):await e()}async#I(e){this.#P+=1;try{await e}finally{this.#P-=1}}#N(e){const t=this.#R.then(e);return this.#R=t.catch(e=>{this.#u("plugin manager mutation failed:",e)}),t}},xr=class{#O;#_;#D=/* @__PURE__ */new Map;constructor(e){this.#O=e,this.#_={...e}}get renderers(){return this.#_}resolve(e){return this.#_[e]}register(e){const t=e.name,n={renderer:e},r=this.#D.get(t);void 0===r?this.#D.set(t,[n]):r.push(n),this.#_[t]=e;let i=!0;return()=>{if(!i)return;i=!1;const e=this.#D.get(t);if(void 0===e)return;const r=e.indexOf(n);if(r<0)return;const o=r===e.length-1;if(e.splice(r,1),0===e.length&&this.#D.delete(t),!o)return;const s=e.at(-1),a=s?.renderer??this.#O[t];void 0===a?Reflect.deleteProperty(this.#_,t):this.#_[t]=a}}},Lr={1:"left",2:"center",3:"right",4:"justify"},Fr=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function Er(e){const t=e.format;return"string"==typeof t&&Fr.has(t)?t:"number"==typeof t?Lr[t]:void 0}function Ur(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function Ir(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function Mr(e){const t=Er(e),n=Ur(e),r=[];return void 0!==t&&r.push(`lp-align-${t}`),n>0&&r.push(`lp-indent-${String(n)}`),0===r.length?"":` class="${r.join(" ")}"`}var Or=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function _r(e){return"object"==typeof e&&null!==e?e:void 0}function Dr(e){return _r(e)}function zr(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function Br(e){return"string"==typeof e&&e.length>0?e:void 0}function jr(e){const t=Br(e.title)??Br(e.name)??Br(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}var Hr=' target="_blank" rel="noopener noreferrer"',Wr=(e,t)=>{const n=t.renderChildren(e.children??[]),r=_r(e.fields),i=function(e,t){if("internal"===t?.linkType)return function(e){const t=_r(_r(e)?.value),n=t?.url;if("string"==typeof n&&n.length>0)return n;const r=t?.slug;return"string"==typeof r&&r.length>0?`/${r}`:void 0}(t.doc);const n=t?.url??e.url;return"string"==typeof n&&n.length>0?n:void 0}(e,r);if(void 0===i||!isSafeUrl(i))return n;const o="string"==typeof e.title?` title="${escapeHtml(e.title)}"`:"";return`<a href="${escapeHtmlAttribute(i)}"${function(e,t,n){if(!0===t?.newTab||isExternalHttpUrl(n))return Hr;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?Hr:` target="${escapeHtml(r)}"`}(e,r,i)}${o}>${n}</a>`};function Vr(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=Vr(n);return t}function qr(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function Gr(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var Kr=/* @__PURE__ */new Map;function Jr(e){return Kr.get(e)}var Qr=".lp-block:empty,.lp-inline-block:empty";function Xr(e,t,n,r){const i=_r(e.fields)??{},o="string"==typeof i.blockType?i.blockType:"",s=zr(o),a=""===s?r:`${r} ${r}--${s}`;if(""!==o){const e=Jr(o)??Jr(s);if(e)return e(i,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(o,a)}return`<${n} class="${a}"></${n}>`}function Yr(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var Zr={text:e=>{let t=escapeHtml("string"==typeof e.text?e.text:"");const 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)=>{const n=t.renderChildren(e.children??[]);return`<p${Ir(e)}${Mr(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=Or.has(n)?n:"h2",i=t.renderChildren(e.children??[]);return`<${r}${Ir(e)}${Mr(e)}>${i}</${r}>`},list:(e,t)=>{const n="string"==typeof e.listType?e.listType:"bullet",r="number"===n?"ol":"ul",i="number"===n&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",o="check"===n?' role="list"':"",s=t.renderChildren(e.children??[]);return`<${r}${Ir(e)}${Mr(e)}${i}${o}>${s}</${r}>`},listitem:(e,t)=>{const n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${Mr(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${Ir(e)}${Mr(e)}${r}>${n}</li>`},link:Wr,autolink:Wr,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${Ir(e)}${Mr(e)}>${n}</blockquote>`},code:e=>{const t=zr("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(Vr(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${zr(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=Dr(e.value);if(void 0===t)return"";const n=t.url;if("string"!=typeof n||!isSafeUrl(n))return"";const r="string"==typeof t.mimeType?t.mimeType:"";return r.startsWith("video/")?function(e,t){return`<video controls${qr(e)}><source src="${escapeHtmlAttribute(t)}"${Gr(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${Gr(e)}></audio>`}(t,n):""===r||r.startsWith("image/")?function(e,t){const n="string"==typeof e.alt?escapeHtml(e.alt):"";return`<img src="${escapeHtmlAttribute(t)}" alt="${n}"${qr(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){const n="string"==typeof e.filename?escapeHtml(e.filename):escapeHtml(t);return`<a href="${escapeHtmlAttribute(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{const t="string"==typeof e.relationTo?e.relationTo:"",n=_r(e.value),r=escapeHtml((n&&jr(n))??`#${t}`),i=zr(t),o=""===i?' class="lp-relation"':` class="lp-relation lp-relation--${i}"`,s=n?.url;return"string"==typeof s&&isSafeUrl(s)?`<a href="${escapeHtmlAttribute(s)}"${o}>${r}</a>`:`<span${o}>${r}</span>`},block:(e,t)=>Xr(e,t,"div","lp-block"),inlineBlock:(e,t)=>Xr(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${Ir(e)}><tbody>${t.renderChildren(e.children??[])}</tbody></table>`,tablerow:(e,t)=>`<tr>${t.renderChildren(e.children??[])}</tr>`,tablecell:(e,t)=>{const n="number"==typeof e.headerState?e.headerState:0,r=3&n?"th":"td";return`<${r}${1===n?' scope="col"':2===n?' scope="row"':""}${Yr("colspan",e.colSpan)}${Yr("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},ei=/* @__PURE__ */new Map,ti=!1;function ni(e){if("object"!=typeof e||null===e)return!1;if(!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function ri(e,t){const n=(r=e.type,ei.get(r)??Zr[r]);var r;return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function ii(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\n";if(void 0===e.children)return"";let t="";for(const n of e.children)t+=ii(n);return t}function oi(e="text"){const t=/* @__PURE__ */new WeakSet;return{name:e,render:/* @__PURE__ */X((e,n)=>{const r=e.element,i=function(e){return null==e?"":ni(e)?ni(t=e)?t.root.children.map(ii).join("\n").trim():"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);var t}(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName)return function(e){return null!==e.querySelector(":scope > :not(br)")}(r)&&!r.hasAttribute("data-payload-text")?(function(e,t,n){e.has(t)||(e.add(t),b(`[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,r,e.fieldName),!1):void(i.includes("\n")||i.includes("\r")?r.innerHTML=rn(function(e){return escapeHtml(e).replace(/\r\n|\r|\n/g,"<br>")}(i)):r.textContent=i);r.value=i})}}var si=/* @__PURE__ */new Set,ai=/* @__PURE__ */new Set,li=/* @__PURE__ */new Set(["DIV","SECTION","ARTICLE"]),ui={name:"richText",render:/* @__PURE__ */X((e,t,n)=>{const r=e.element;if(zn(t))return void(r.textContent="");const i=n.sanitizerPolicy;if(void 0!==n.renderRichText){const o=n.renderRichText(t,{fieldName:e.fieldName,element:r,locale:n.locale});return void(r.innerHTML=rn(Cn(o,i)))}if(ni(t)){const o=/* @__PURE__ */new Map,s=function(e,t){const n=e.cloneNode(!1);n.innerHTML=rn(t);const r=function(e,t){const n=e.firstElementChild;if(null!==n?.nextElementSibling||t.children.length<2)return null;if(!li.has(n.tagName)||n.hasAttribute(Ie))return null;for(const e of t.children)if(e.tagName===n.tagName&&e.className===n.className)return null;return n}(e,n)??e,i=/* @__PURE__ */new Map,o=n.querySelectorAll(Qr);if(o.length>0&&null!==r.firstElementChild){const e=[];di(r,n,e);for(const[t,n]of e)t.replaceWith(n),n.matches(Qr)||i.set(t.className,!1);for(const e of o)null!==e.parentNode&&i.set(e.className,!0)}return r.replaceChildren(...n.childNodes),i}(r,Cn(function(e,t={}){if(!ni(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=ri(r,t);return n},resolveAlignment:Er,resolveIndent:Ur,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==Rn()?sanitizeHtml(n):(function(){if(!ti){ti=!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)=>{o.set(t,e)}}),i));for(const[t,r]of s){const i=o.get(t);void 0!==i&&ci(e,n,i,r)}return}if("string"!=typeof t)return!1;r.innerHTML=rn(Cn(t,i))})};function di(e,t,n){if(e.children.length!==t.children.length)return;let r=e.firstElementChild,i=t.firstElementChild;for(;null!==r&&null!==i;)i.matches(Qr)?n.push([i,r]):di(r,i,n),r=r.nextElementSibling,i=i.nextElementSibling}function ci(e,t,n,r){r&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);const i=r?ai:si;i.has(n)||(i.add(n),b(`[live-preview] ${r?`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().`))}var hi={name:"html",render(e,t,n){if(zn(t))return void(e.element.textContent="");const r="string"==typeof t?t:Dn(t);e.element.innerHTML=rn(Cn(r,n.sanitizerPolicy))}},fi=/* @__PURE__ */new WeakSet;function pi(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:isSafeUrl(n)?{kind:"safe",url:n}:(fi.has(e)||(fi.add(e),b(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function mi(e,t=e=>e){return{name:e,render(e,n,r){const i=e.element;if(zn(n))return void function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(i);const o=Dn(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName){if("A"===i.tagName){const n=e.hrefField,s=void 0===n||0===n.length?t(o):Jt(r.allFields,n,r.locale,void 0!==e.locale),a=pi(i,e.fieldName,s);"safe"===a.kind?i.setAttribute("href",a.url):"unsafe"===a.kind&&i.removeAttribute("href")}i.textContent=o}else i.value=o}}}var gi=mi("url"),vi=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,yi=mi("email",function(e){const t=e.trim();return vi.test(t)||!t.includes("@")?t:`mailto:${t}`}),bi=["src","srcset","sizes"];function wi(e){for(const t of bi)e.removeAttribute(t)}function Si(e,t,n){e.src=t;const r=function(e){if(void 0===e?.sizes)return;const t=[];for(const n of Object.values(e.sizes))"string"==typeof n.url&&"number"==typeof n.width&&isSafeUrl(n.url)&&t.push(`${Ai(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&isSafeUrl(e.url)&&t.push(`${Ai(e.url)} ${String(e.width)}w`),t.join(", ")):void 0}(n);if(void 0===r)return e.removeAttribute("srcset"),void e.removeAttribute("sizes");e.setAttribute("srcset",r)}function Ai(e){return e.replace(/[\s,]/g,encodeURIComponent)}var ki={name:"image",render:/* @__PURE__ */X((e,t,n)=>{const r=e.element;if(zn(t))return void Ti(r);const i=void 0!==e.locale,{media:o,candidate:s}=function(e,t,n,r){const i=void 0!==e.srcField&&e.srcField.length>0?Jt(n.allFields,e.srcField,n.locale,r):t,o=Dr(i);return{media:o,candidate:void 0===o?i:o.url}}(e,t,n,i),a=pi(r,e.fieldName,s);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===r.tagName){const t=r;Si(t,a.url,o);const s=function(e,t,n,r,i){if(void 0!==t&&t.length>0){const e=Jt(n,t,r,i);return"string"==typeof e?e:void 0}return e?.alt}(o,e.altField,n.allFields,n.locale,i);return void(void 0!==s&&(t.alt=s))}r.style.backgroundImage=`url('${function(e){return e.replace(/['"()\\]/g,"\\$&")}(a.url)}')`}else Ti(r)})};function Ti(e){"IMG"===e.tagName?wi(e):e.style.backgroundImage=""}var Ci={name:"upload",render:/* @__PURE__ */X((e,t)=>{const n=e.element;if(zn(t))return void Ri(n);const r=Dr(t);if(void 0===r)return!1;const i=pi(n,e.fieldName,r.url);if("none"===i.kind)return!1;if("unsafe"===i.kind)return void Ri(n);const o=i.url;if("IMG"===n.tagName){const e=n;return Si(e,o,r),void(void 0!==r.alt&&(e.alt=r.alt))}if("A"===n.tagName)return n.setAttribute("href",o),void(n.textContent=r.filename??o);const s=escapeHtml(r.filename??o);n.innerHTML=rn(`<a href="${escapeHtmlAttribute(o)}">${s}</a>`)})};function Ri(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):wi(e)}var Pi={name:"relationship",render(e,t){const n=e.element;if(zn(t))return n.removeAttribute("href"),void(n.textContent="");if("A"===n.tagName&&!Array.isArray(t)){const r=pi(n,e.fieldName,_r(t)?.url);"safe"===r.kind?n.setAttribute("href",r.url):"unsafe"===r.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map($i).join(", "):$i(t)}};function $i(e){const t=_r(e);return void 0===t?Dn(e):jr(t)??""}var Ni={name:"select",render(e,t,n){const r=e.element,i=zn(t)?[]:function(e){return Array.isArray(e)?e.map(Dn):[Dn(e)]}(t);if("SELECT"!==r.tagName){if("INPUT"===r.tagName&&"radio"===r.type){const e=r;return void(e.checked=i.includes(e.value))}r.textContent=i.map(e=>function(e,t){const n=t.schema?.options;if(!Array.isArray(n))return e;for(const t of n){const n=_r(t);if(void 0!==n&&Dn(n.value)===e)return"string"==typeof n.label?n.label:e}return e}(e,n)).join(", ")}else!function(e,t){if(e.multiple)for(const n of Array.from(e.options))n.selected=t.includes(n.value);else e.value=t[0]??""}(r,i)}},xi=/* @__PURE__ */new Set(["","false","0","off","no"]),Li={name:"checkbox",render(e,t){const n=e.element,r=function(e){return"boolean"==typeof e?e:"string"==typeof e?!xi.has(e.trim().toLowerCase()):"number"==typeof e?0!==e:null!=e}(t);"INPUT"!==n.tagName||"checkbox"!==n.type?n.hasAttribute("aria-checked")?n.setAttribute("aria-checked",r?"true":"false"):n.textContent=r?"true":"false":n.checked=r}},Fi=/* @__PURE__ */new Map,Ei=/* @__PURE__ */new Map;function Ui(e,t){const n=e??"";if(null==t)return n;const r=Ii(t);return"{}"===r?n:`${n}|${r}`}function Ii(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Ii(e)).join(",")}]`;const t=e,n=Object.keys(t).sort(),r=[];for(const e of n){const n=t[e];void 0!==n&&r.push(`${JSON.stringify(e)}:${Ii(n)}`)}return`{${r.join(",")}}`}var Mi=/* @__PURE__ */new Set(["short","medium","long","full"]),Oi=/* @__PURE__ */new Set(["short","medium","long","full"]),_i=/^[A-Za-z]{3}$/u,Di=/^[0-4]$/u;function zi(e){return{kind:"date",options:e}}function Bi(e){return{kind:"number",options:e}}var ji=/* @__PURE__ */new WeakSet;function Hi(e,t,n,r){if(void 0===t||""===t)return;const i=function(e){const t=e.indexOf(":"),n=-1===t?e:e.slice(0,t),r=-1===t?void 0:e.slice(t+1);switch(n){case"date":return void 0===r?zi({dateStyle:"medium"}):Mi.has(r)?zi({dateStyle:r}):void 0;case"time":return void 0===r?zi({timeStyle:"short"}):Oi.has(r)?zi({timeStyle:r}):void 0;case"datetime":return void 0===r?zi({dateStyle:"medium",timeStyle:"short"}):Mi.has(r)?zi({dateStyle:r,timeStyle:"short"===r?"short":"medium"}):void 0;case"number":if(void 0===r)return Bi({});if(!Di.test(r))return;return Bi({minimumFractionDigits:Number(r),maximumFractionDigits:Number(r)});case"currency":if(void 0===r||!_i.test(r))return;return Bi({style:"currency",currency:r.toUpperCase()});case"percent":return void 0===r?Bi({style:"percent"}):void 0;default:return}}(t);if(void 0!==i){if(i.kind===e)return i.options}else!function(e,t,n){ji.has(e)||(ji.add(e),b(`[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,r,t)}var Wi={name:"date",render(e,t,n){const r=e.element;if(zn(t))return void("INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent=""));const i="number"==typeof t?t:Dn(t),o=new Date(i),s=!Number.isNaN(o.getTime()),a=String(i);"INPUT"!==r.tagName?("TIME"===r.tagName&&r.setAttribute("datetime",s?o.toISOString():a),r.textContent=s?function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Hi("date",t.format,t.element,t.fieldName)??Vi;try{return function(e,t){const n=Ui(e,t);return Bn(Ei,n)??jn(Ei,n,new Intl.DateTimeFormat(e,t),64)}(r,i).format(e)}catch{return e.toISOString()}}(o,e,n):a):r.value=s?function(e,t){const n=`${String(t.getFullYear()).padStart(4,"0")}-${qi(t.getMonth()+1)}-${qi(t.getDate())}`,r=`${qi(t.getHours())}:${qi(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${r}`:"time"===e?r:t.toISOString()}(r.type,o):a}},Vi={dateStyle:"medium",timeStyle:"short"};function qi(e){return String(e).padStart(2,"0")}var Gi={name:"number",render(e,t,n){const r=e.element;if(zn(t))return void("INPUT"===r.tagName?r.value="":r.textContent="");const i="number"==typeof t?t:Number(Dn(t));Number.isNaN(i)?r.textContent=Dn(t):"INPUT"!==r.tagName?r.textContent=function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Hi("number",t.format,t.element,t.fieldName);try{return function(e,t){const n=Ui(e,t);return Bn(Fi,n)??jn(Fi,n,new Intl.NumberFormat(e,t),64)}(r,i).format(e)}catch{return String(e)}}(i,e,n):r.value=String(i)}},Ki={name:"array",render:/* @__PURE__ */X((e,t,n)=>{const r=e.element;if(zn(t))return void(r.textContent="");if(!Array.isArray(t))return!1;const i=e.arrayTemplate;if(void 0!==i&&i.length>0){const e=function(e,t){const n=In(t);let r="";for(let i=0;i<t.length;i+=1)r+=Mn(e,t[i],i,Dn,n);return r}(i,t),o=n.sanitizerPolicy,s=Gn(i),a=On(r);r.innerHTML=rn(Cn(e,o,s));for(const e of Array.from(r.children))_n(e,a);return}r.textContent=t.map(Dn).join(e.arraySeparator??", ")})};function Ji(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,n=/* @__PURE__ */new WeakMap,r=/* @__PURE__ */new WeakMap;return{name:"structural-array",render:/* @__PURE__ */X((i,o,s)=>{const a=zn(o)?[]:o;if(!Array.isArray(a))return!1;const l=i.element,u=i.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,n){e.has(t)||(e.add(t),b(`[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,l,i.fieldName),!1;const d=e.get(l),c=Qi(l),h=E(d?.values??c.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e}),a),f=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===h.length&&!f)return e.set(l,{values:a.slice(),template:u,domSnapshot:c}),!1;!function(e,t,n,r,i){const o=i.map(Xi),s=/* @__PURE__ */new Set,a=o.find(e=>!(void 0===e||!s.has(e)&&(s.add(e),1)));if(void 0!==a&&Yi(e,t,n,a),o.some(e=>void 0===e)&&Zi(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.`),r?.length===i.length&&i.length>1){const i=new Set(r.map(Xi).filter(e=>void 0!==e)),s=o.some(e=>void 0!==e&&i.has(e));i.size>0&&!s&&Zi(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,l,i.fieldName,d?.values,a);const p=Xn({template:u,container:l,patches:h,nextItems:a,store:r,forceRender:f,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{Yi(n,e,i.fieldName,t)}});return null!==p&&(e.set(l,{values:a.slice(),template:u,domSnapshot:Qi(l)}),!!p&&void 0)})}}function Qi(e){return Array.from(e.children,e=>e.getAttribute(Kn))}function Xi(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Yi(e,t,n,r){Zi(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${r}"; later ones pair by position. Make \`id\` unique per item.`)}function Zi(e,t,n,r){let i=e.get(t);void 0===i&&(i=/* @__PURE__ */new Set,e.set(t,i)),i.has(n)||(i.add(n),b(`[live-preview] ${r}`))}var eo=/* @__PURE__ */new Map;function to(e,t){return{name:e,render(){k(t)}}}var no=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),ro=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"});function io(e){return void 0===e?void 0:!e}var oo,LivePreviewClient=class{#z=new EventEmitter;#B;#j;#H;#S;#u;#W=!1;#V=!1;#q=!1;#G=null;constructor(e={}){const t=function(e){const t="v1"===e.defaults?ro:no;return{...e,skipUnchanged:e.skipUnchanged??t.skipUnchanged,disableReferrerDetection:e.disableReferrerDetection??t.disableReferrerDetection,eventSourcePolicy:e.eventSourcePolicy??t.eventSourcePolicy,sanitizerPolicy:e.sanitizerPolicy??t.sanitizerPolicy}}(e),n=t.serverURL??"";!function(e){if("v1"!==e.defaults&&""!==(e.serverURL??"")&&null==e.mergeDepth)throw new Error("payload-live-preview: `serverURL` needs an explicit `mergeDepth` under the 2.0 defaults — choose the population depth deliberately (0 for none), or pass `defaults: 'v1'` to keep the 1.x default of 1 while migrating (ADR 0007, entry 10).")}({defaults:e.defaults,serverURL:n,mergeDepth:t.mergeDepth});const r=t.debug??isDevMode();this.#u=r?(...e)=>{w("[live-preview]",...e)}:v,this.#B=new OriginDetector(R({additionalOrigins:t.allowedOrigins,enableReferrerDetection:io(t.disableReferrerDetection),enableLocalhostMatching:io(t.disableLocalhostMatching)})),this.#B.isProductionUnconfigured&&this.#u("no trusted origin could be detected — set allowedOrigins"),this.#j=new xr(function(){const e=[ui,hi,gi,yi,ki,Ci,Pi,Ni,{...Ni,name:"radio"},Li,Wi,Gi,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[to("array","structural arrays"),to("blocks","structural arrays")]:[Ki,{...Ki,name:"blocks"}]];return function(e=[]){const t={};for(const n of e)t[n.name]=n;for(const[e,n]of eo)t[e]=n;return Object.freeze(t)}([oi("text"),oi("textarea"),...e,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[]:[Ji()]])}()),this.#S=new Nr({events:this.#z,config:Object.freeze({...t}),registerFieldRenderer:e=>this.#j.register(e),onTransformError:e=>{this.#z.emit("error",{error:e,context:"transform",code:"LP0602"})},log:this.#u}),this.#H=new br(R({root:t.root,renderers:this.#j.renderers,resolveRenderer:(e,n)=>t.resolveRenderer?.(e,n)??this.#j.resolve(e),renderRichText:t.renderRichText,sanitizerPolicy:t.sanitizerPolicy,transformValue:(e,t,n,r)=>this.#S.applyTransforms(e,t,n,r),originMatcher:e=>this.#B.matches(e),readyTargets:()=>this.#B.enumerate(),emitter:this.#z,dataMerge:""===n?void 0:R({serverURL:n,apiRoute:t.apiRoute,depth:t.mergeDepth,fetchFn:t.mergeFetch}),debounceMs:t.debounceMs,heartbeatMs:t.heartbeatMs,intersectionRootMargin:t.intersectionRootMargin,scopeBindingsByOwner:t.scopeBindingsByOwner,skipUnchanged:t.skipUnchanged,revealEditedField:t.revealEditedField,autoBind:t.autoBind,eventSourcePolicy:t.eventSourcePolicy,dependencies:t.dependencies,strategies:t.strategies,disableVisibilityGate:t.disableVisibilityGate,visibilityGateThreshold:t.visibilityGateThreshold,enableA11y:t.enableA11y,a11yLocale:t.a11yLocale,onHeartbeatTimeout:()=>{this.#B.unlockOrigin()},lockedOrigin:()=>this.#B.lockedOrigin,validateToken:t.validateToken,log:this.#u})),this.#z.on("connect",e=>{this.#B.lockOrigin(e.origin)}),!1!==t.autoStart&&this.start()}start(){if(this.#V)return!1;if(this.#W)return this.#H.start(),!0;if(!isInPreviewContext())return!1;const e=this.#H.start();return e&&(this.#W=!0),e}suspend(){return!(this.#V||!this.#W)&&this.#H.suspend()}resume(){return!(this.#V||!this.#W)&&this.#H.start()}destroy(){if(null!==this.#G)return this.#G;let e,t;this.#V=!0;const n=new Promise((n,r)=>{e=n,t=r});this.#G=n;const r=()=>{this.#z.removeAllListeners(),this.#q=!0};try{this.#H.destroy(),this.#S.destroyAll().finally(r).then(e,t)}catch(e){r(),t(e)}return n}async use(e){if(this.#V)throw new Error("LivePreviewClient: already destroyed");await this.#S.register(e)}async unuse(e){if(this.#q)throw new Error("LivePreviewClient: already destroyed");await this.#S.unregister(e)}refreshCache(){this.#H.refreshCache()}get events(){return this.#z}get plugins(){return this.#S.list()}get status(){return this.#H.status}inspect(){return{...this.#H.inspect(),plugins:this.#S.snapshot()}}get updateCount(){return this.#H.updateCount}get destroyed(){return this.#V}},so="payload-live-preview.authorized-preview-context",ao=Symbol.for(so);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[ao]&&Object.isFrozen(e)}var lo="__livePreviewRouteRefresh",uo=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",StructuralItemUnkeyed:"LP0404",StructuralDuplicateKey:"LP0405",StructuralUnstableKeys:"LP0406",UnsupportedStrategy:"LP0407",UnknownValueFormat:"LP0408",SanitizerDroppedAttribute:"LP0409",UnrenderedBlockKept:"LP0410",UnfaithfulPatch:"LP0411",ServerFormatReplaced:"LP0412",UnrenderedBlockLost:"LP0413",MessageRejected:"LP0501",TokenRejected:"LP0502",ProtocolShapeUnknown:"LP0503",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",HydrationWaitTimedOut:"LP0607",AuditRuntimeMissing:"LP0701",AuditNoFrameAncestors:"LP0702",AuditFrameOptionsBlocks:"LP0703",AuditBindingsExposed:"LP0704",AuditGateThresholdExceeded:"LP0705",AuditUnownedBindings:"LP0706",AuditNoBindings:"LP0707",AuditNotAPage:"LP0708",FragmentRequestFailed:"LP0801",FragmentResponseInvalid:"LP0802",FragmentUnauthorized:"LP0803",FragmentSuperseded:"LP0804",RouteRefreshLoop:"LP0805",FragmentStrategyUnavailable:"LP0806",UnboundChangeRefresh:"LP0807",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710"});function bind(e,t){return co(e,t)}function bindByPath(e,t){const n=function(e){const t=[],n=new Proxy({},{get(e,r){if("symbol"!=typeof r)return/^\d+$/.test(r)||t.push(r),n}});try{e(n)}catch{}return t}(e);if(0===n.length)throw new Error("bindByPath: the picker did not read any field — return data.<field> instead of a constant");return co(n.join("."),t)}function co(e,t){if(0===e.length)throw new Error("bind: field name must be a non-empty string");const n={"data-payload-field":e};return void 0!==t?.attribute&&(n["data-payload-attribute"]=t.attribute),void 0!==t?.type&&(n["data-payload-type"]=t.type),!0===t?.richtext&&(n["data-payload-richtext"]=""),!0===t?.html&&(n["data-payload-html"]=""),void 0!==t?.locale&&(n["data-payload-locale"]=t.locale),void 0!==t?.alt&&(n["data-payload-alt"]=t.alt),void 0!==t?.href&&(n["data-payload-href"]=t.href),void 0!==t?.arrayTemplate&&(n["data-payload-array-template"]=t.arrayTemplate),n}var ho=/^[a-z][a-z0-9-]{0,63}$/u,fo=Object.freeze({});exports.AUTHORIZED_PREVIEW_BRAND_KEY=so,exports.CAPABILITY_DECLARATIONS=c,exports.CAPABILITY_DOCUMENTATION={basic:{gates:"data updates are applied to bound elements",fallback:"none — every peer has it"},"schema-json":{gates:"field typing from fieldSchemaJSON (Payload 2.x) and the payload-2 profile",fallback:"field types come from DOM heuristics and Lexical auto-detection"},locale:{gates:"locale-aware field resolution (`title_de` before `title`) and the locale on island events",fallback:"bindings resolve the unsuffixed field value"},"preview-token":{gates:"per-message token validation (library extension)",fallback:"messages carry no token; validateToken cannot be satisfied"},"nested-arrays":{gates:"keyed array diffs below the top level",fallback:"array updates replace the whole array"},"recursive-diffs":{gates:"recursive object diffs",fallback:"nested objects re-render as a unit"},"document-events":{gates:"the `documentSave` runtime event, the document-save plugin and the payload-3 profile",fallback:"no documentSave event; a save is not distinguishable from an edit"},"relationship-events":{gates:"the `relationshipUpdate` runtime event and an unconditional re-render of the update that carries it",fallback:"a related document edited in a drawer shows up on the next data update only"}},exports.CORE_ENTRY=!0,exports.DIAGNOSTIC_CODES=uo,exports.EventEmitter=EventEmitter,exports.ISLAND_EVENT=xe,exports.LIBRARY_PROTOCOL_VERSION=4,exports.LivePreviewClient=LivePreviewClient,exports.OriginDetector=OriginDetector,exports.PROTOCOL_CAPABILITIES=h,exports.VERSION=e,exports.bind=bind,exports.bindByPath=bindByPath,exports.buildFrameAncestors=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'"},exports.buildScriptSrcWithNonce=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(" ")},exports.createPreviewBindings=function createPreviewBindings(e){const t=isAuthorizedPreviewContext(e.authorization),n=void 0!==e.owner&&e.owner.length>0?e.owner:void 0;return Object.freeze({authorized:t,bind:(e,n)=>t?bind(e,n):fo,bindByPath:(e,n)=>t?bindByPath(e,n):fo,owner:()=>t&&void 0!==n?{"data-payload-owner":n}:fo,boundary:(e,n={})=>{const r=function(e,t){if(!ho.test(e))throw new RangeError(`createPreviewBindings().boundary(): "${e}" is not a registry id — lowercase, starting with a letter, then letters, digits or hyphens (max 64). The runtime would post it and the endpoint would refuse it.`);const n=t.key;if(void 0!==n&&(0===n.length||n.length>128))throw new RangeError(`createPreviewBindings().boundary(): the key for "${e}" must be 1 to ${String(128)} characters.`);const r=t.dependsOn??[];return{"data-payload-fragment":e,...void 0!==n?{"data-payload-fragment-key":n}:{},...r.length>0?{"data-payload-depends":r.join(",")}:{}}}(e,n);return t?r:fo}})},exports.detectInitialLocale=detectInitialLocale,exports.detectProtocolProfile=detectProtocolProfile,exports.escapeHtml=escapeHtml,exports.escapeHtmlAttribute=escapeHtmlAttribute,exports.generateCspNonce=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(){if(oo?.getRandomValues)return oo;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)},exports.hasCapability=function hasCapability(e,t){return e.capabilities.has(t)},exports.initLivePreview=function initLivePreview(e={}){const t=new LivePreviewClient({...e,autoStart:!1});return t.start()?t:null},exports.isAuthorizedPreviewContext=isAuthorizedPreviewContext,exports.isDevMode=isDevMode,exports.isExternalHttpUrl=isExternalHttpUrl,exports.isInIframe=isInIframe,exports.isInPopup=isInPopup,exports.isInPreviewContext=isInPreviewContext,exports.isInsideIsland=isInsideIsland,exports.isSafeUrl=isSafeUrl,exports.negotiateProtocol=negotiateProtocol,exports.registerRouteRefresh=function registerRouteRefresh(e){const t="undefined"==typeof window?void 0:window;return void 0===t?()=>{}:(t[lo]=e,()=>{t[lo]===e&&(t[lo]=void 0)})},exports.sanitizeHtml=sanitizeHtml,exports.setCspCrypto=function setCspCrypto(e){oo=e??void 0},exports.setSanitizerDocument=function setSanitizerDocument(e){globalThis[Tn]=e??void 0};
2
2
  //# sourceMappingURL=core.cjs.map