payload-live-preview 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/adapters/astro/index.d.ts +2 -2
- package/dist/adapters/astro/index.js +1 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/middleware-entry.js +1 -1
- package/dist/adapters/astro/middleware-entry.js.map +1 -1
- package/dist/adapters/nextjs/index.d.ts +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.d.ts +2 -2
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.d.ts +2 -2
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/{fragment-endpoint-DGGLIijM.d.ts → fragment-endpoint-CLRpNQ3n.d.ts} +4 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lean.cjs +1 -1
- package/dist/lean.cjs.map +1 -1
- package/dist/lean.js +1 -1
- package/dist/lean.js.map +1 -1
- package/dist/lexical.cjs +1 -1
- package/dist/lexical.cjs.map +1 -1
- package/dist/lexical.js +1 -1
- package/dist/lexical.js.map +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +4 -2
- package/dist/server.d.ts +4 -2
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/structural.cjs +2 -2
- package/dist/structural.cjs.map +1 -1
- package/dist/structural.js +1 -1
- package/dist/structural.js.map +1 -1
- package/package.json +6 -4
package/dist/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
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 e="payload-live-preview-a11y",t=/* @__PURE__ */new WeakMap;function n(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}var r=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 r=this.document;if(null==r?.body)return null;this.lease??=function(e){let n=t.get(e);return void 0===n&&(n={element:null,owned:!1,messageNode:null,refs:0,timer:null},t.set(e,n)),n.refs+=1,n}(r);const i=this.lease,s=i.element;if(s?.isConnected&&s.ownerDocument===r)return s;if(null!==s){const e=i.owned;n(i),e&&s.remove()}let o=r.getElementById(e);return i.owned=null===o,null===o&&(o=r.createElement("div"),o.id=e,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),o.setAttribute("aria-atomic","true"),o.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0",r.body.appendChild(o)),i.element=o,o}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`)}announcePartial(){this.say(this.german?"Vorschau teilweise aktualisiert":"Preview partly updated")}detach(){const e=this.lease,r=this.document;if(null===e||null===r)return;if(this.lease=null,e.refs-=1,e.refs>0)return;const i=e.element;null!==i&&n(e),e.owned&&i?.remove(),e.element=null,t.delete(r)}say(e){const t=this.mount(),r=this.lease;if(null===t||null===r)return;let i=r.messageNode;i?.parentNode!==t?(i?.remove(),i=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),r.messageNode=i,t.appendChild(i)):i.data=null===i.previousSibling?e:` ${e}`,null!==r.timer&&clearTimeout(r.timer);const s=setTimeout(()=>{r.timer===s&&r.element===t&&n(r)},1500);r.timer=s}};function i(e){if(++e.nodes>1e4)throw new Error("invalid or oversized field schema")}function s(e,t,n){if(i(t),n>64||t.active.has(e))throw new Error("invalid or oversized field schema");t.active.add(e)}function o(e){try{return a(e,{nodes:0,active:/* @__PURE__ */new WeakSet},0)}catch{return[]}}function a(e,t,n){if(!Array.isArray(e))return[];s(e,t,n);const r=[];for(const i of e){const e=l(i,t,n);e&&r.push(e)}return t.active.delete(e),r}function l(e,t,n){if(i(t),"object"!=typeof e||null===e)return;const r=e,o=r.name,l=r.type;if("string"!=typeof o||0===o.length)return;if("string"!=typeof l||0===l.length)return;const u=a(r.fields,t,n+1),d=function(e,t,n){if("object"==typeof e&&null!==e&&!Array.isArray(e)){s(e,t,n);const r=[];for(const s in e){if(!Object.hasOwn(e,s))continue;i(t);const o=Reflect.get(e,s);"object"!=typeof o||null===o||["__proto__","constructor","prototype"].includes(s)||r.push({...o,slug:s,fields:a(o.fields,t,n+1)})}return t.active.delete(e),r}if(!Array.isArray(e))return[];s(e,t,n);const r=[];for(const s of e){if(i(t),"object"!=typeof s||null===s)continue;const e=s,o=e.slug;if("string"!=typeof o||0===o.length)continue;const l=a(e.fields,t,n+1);r.push({...e,slug:o,fields:l})}return t.active.delete(e),r}(r.blocks,t,n+1),c={...r,name:o,type:l},h=r.relationTo;if(Array.isArray(h)){const e=[];for(const n of h)i(t),e.push(n);c.relationTo=e}return u.length>0?c.fields=u:delete c.fields,d.length>0?c.blocks=d:delete c.blocks,c}function u(e,t){return void 0===e||t(e)}function d(e,t){return null==e||t(e)}function c(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}var h=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],f={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"}},p=Object.keys(f);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),s=new Set(t),o=/* @__PURE__ */new Set;for(const e of p)(i>=f[e].since||s.has(e))&&o.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:i,capabilities:o,observed:s}}function g(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function m(e,t){return e.generation===t.generation&&e.revision===t.revision}var v=class{matcher;handlers;boundListener=void 0;attachedTarget=void 0;generation=0;revision=0;queueHead=void 0;queueTail=void 0;lastAccepted=void 0;replayedGeneration=0;latestAcceptedAttempt=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)}replayLastAccepted(){const e=this.lastAccepted,t=this.generation,n=this.handlers.onReplay;if(void 0===n||void 0===e||e.generation>=t||this.replayedGeneration===t)return!1;if(!this.matchesOrigin(e.origin,t)||this.lastAccepted!==e)return!1;this.replayedGeneration=t;const r={generation:t,revision:this.revision+=1};return this.invokeHandler(t,n,structuredClone(e.message),e.origin,r),!0}forgetLastAccepted(){this.lastAccepted=void 0,this.replayedGeneration=0,this.latestAcceptedAttempt=void 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&&!c(t.data))&&d(t.fieldSchemaJSON,e=>Array.isArray(e))&&d(t.globalSlug,e=>"string"==typeof e)&&d(t.collectionSlug,e=>"string"==typeof e)&&d(t.locale,e=>"string"==typeof e)&&d(t.ready,e=>"boolean"==typeof e)&&d(t.previewToken,e=>"string"==typeof e)&&d(t.protocolVersion,e=>"number"==typeof e)}(i)?void this.dispatchUpdate(function(e){const t={...e};for(const e of h)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);return Array.isArray(t.fieldSchemaJSON)?{...t,fieldSchemaJSON:o(t.fieldSchemaJSON)}:t}(i),r,t):void this.reportInvalid("shape",r,t);case"payload-document-event":return function(e){const t=e;return u(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&u(t.slug,e=>"string"==typeof e)&&u(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=c(e.data);if(!this.isCurrentGeneration(n))return;const i=r?{generation:n,revision:this.revision+=1}:void 0,s=this.handlers.validateToken;if(!this.isCurrentGeneration(n))return;if(void 0===s)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 o={generation:n,message:e,origin:t,messageRevision:i,verdict:void 0,next:void 0};let a;this.enqueue(o);try{a=s(e.previewToken,t)}catch{return void this.settleValidation(o,!1)}"boolean"!=typeof a?Promise.resolve(a).then(e=>{this.settleValidation(o,!0===e)},()=>{this.settleValidation(o,!1)}):this.settleValidation(o,a)}settleValidation(e,t){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){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){if(void 0===r)this.invokeHandler(n,this.handlers.onUpdate,e,t);else{const i={};this.latestAcceptedAttempt=i;const s=function(e){const t={...e};delete t.previewToken;try{return structuredClone(t)}catch{return null}}(e);if(this.latestAcceptedAttempt!==i||!this.isCurrentGeneration(n))return;this.lastAccepted=null===s?void 0:{generation:n,message:s,origin: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{g(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 y(e){return(...t)=>{try{g(e(...t))}catch{}}}function b(){}var w=y((...e)=>console.error(...e)),S=y((...e)=>console.warn(...e)),A=y((...e)=>console.debug(...e)),k={"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'"},R=/* @__PURE__ */new Set;function T(e){R.has(e)||(R.add(e),S(`[live-preview] LP0104: this page carries the lean runtime, which leaves out ${e} (${k[e]}). The elements are left as the server rendered them. Remove \`runtime: LEAN_RUNTIME\` to get the full runtime.`))}function C(e){return"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e){return!1!==e.enableA11y&&T("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 r(e.a11yLocale,n)}(e)}function $(e){if("undefined"==typeof window)return;const t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),v.sendReady(t,e)}function L(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}var N=/* @__PURE__ */new Set(["tabs","row","collapsible"]);function P(e,t,n,r){for(const i of e){if(N.has(i.type)){const e=i.fields;e&&P(e,r&&"tabs"===i.type?""===t?i.name:`${t}.${i.name}`:t,n,r);continue}const e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&P(i.fields,e,n,r);else if("array"===i.type&&i.fields)P(i.fields,`${e}.*`,n,r);else if("blocks"===i.type&&i.blocks)for(const t of i.blocks)P(t.fields,`${e}.*.${t.slug}`,n,r)}}function F(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 U(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function M(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function x(e,t){return t.every(e=>void 0!==U(e))?function(e,t){const n=[],r=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=U(e[t]);void 0!==n&&r.set(n,t)}const i=/* @__PURE__ */new Set;for(let s=0;s<t.length;s+=1){const o=t[s],a=U(o);if(void 0===a){n.push({kind:"insert",index:s,value:o});continue}const l=r.get(a);if(void 0===l){n.push({kind:"insert",index:s,value:o});continue}i.add(l);const u=e[l];M(u)===M(o)?(l!==s&&n.push({kind:"move",from:l,to:s,value:o}),E(u,o)||n.push({kind:"update",index:s,value:o})):n.push({kind:"replace",index:s,oldValue:u,value:o})}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)E(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 E(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),s=Object.keys(r);if(i.length!==s.length)return!1;for(const e of i)if(!Object.is(n[e],r[e]))return!1;return!0}var O={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:"]),D=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,_=/^[\\/]{2}/,B=/[\t\n\r]/g,j=/[\s\u0000-\u001f\u180e\u2000-\u2029]/g,z=/^([a-z][a-z0-9+.-]*):/i;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(B,"");if(0===t.length)return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(_.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return I.has(e.protocol)}catch{return D.test(t)&&!function(e){const t=z.exec(e.replace(j,""))?.[1];return void 0!==t&&!I.has(`${t.toLowerCase()}:`)}(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(B,"");return/^https?:\/\//i.test(t)||_.test(t)}var H=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),W=/* @__PURE__ */new Set(["href","src","poster","cite","action","xlink:href","data"]);function q(e){return!e.startsWith("on")&&!H.has(e)}function V(e){switch(typeof e){case"string":return e.length>65536?void 0:`s:${e}`;case"number":return`n:${Object.is(e,-0)?"-0":String(e)}`;case"boolean":return"b:"+(e?"1":"0");case"bigint":return`i:${String(e)}`;case"undefined":return"u";case"object":{if(null===e)return"z";let t;try{t=JSON.stringify(e)}catch{return}return t.length>65536?void 0:`o:${t}`}case"symbol":case"function":return}}function G(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function K(e,t,n,r,i){const s=e.onUnfaithfulPatch,o=t.reportedUnfaithful.get(n.element),a=V(i),l=Date.now(),u=void 0!==o&&("escalate"!==s||void 0===a||a===o.identity||l-o.at<1e3);if((u||"escalate"!==s)&&t.display.shortfall(t.activeUpdate,{kind:"unfaithful",field:n.fieldName}),!u){if(t.reportedUnfaithful.set(n.element,{identity:a,at:l}),void 0===o){if(t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName),"ignore"===s)return;if("warn"===s)return void e.warn(`[live-preview] LP0411: "${n.fieldName}" ${r}`)}e.log("LP0411",n.fieldName,r),t.unfaithfulPatches.push(n)}}function J(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}var Q=/* @__PURE__ */new Set(["date","number","checkbox"]);function X(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function Z(e){const t=e.trim();return JSON.stringify(t.length>40?`${t.slice(0,40)}…`:t)}var Y=/* @__PURE__ */new WeakSet;function ee(e){return Y.add(e),e}var te=class{previous=null;lastFields;priorFields;keepValues=!1;get previousFields(){return this.priorFields}get isBaseline(){return null===this.previous}diff(e,t,n=ne){const r=this.previous,i=null===r,s=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set,a=Object.entries(e);if(!n())return null;for(const[e,t]of a){const i=V(t);if(!n())return null;s.set(e,i),null!==r&&void 0!==i&&r.get(e)===i||o.add(e)}if(null!==r)for(const e of r.keys())s.has(e)||o.add(e);const l=/* @__PURE__ */new Set,u=Object.entries(t);if(!n())return null;for(const[e,t]of u)if(o.has(e))for(const e of t)if(l.add(e),!n())return null;return n()?(this.previous=s,this.priorFields=this.keepValues?this.lastFields:void 0,this.lastFields=this.keepValues?e:void 0,{changed:o,invalidated:l,baseline:i}):null}reset(){this.previous=null,this.lastFields=void 0,this.priorFields=void 0}};function ne(){return!0}var re=/* @__PURE__ */new Set(["__proto__","prototype","constructor"]);function ie(e,t,n,r=!1){if(r&&void 0!==n){const r=se(e,`${t}_${n}`);if(void 0!==r)return r}const i=se(e,t);if(void 0!==i)return i;if(t.includes(".")){let n=e,r=!0;for(const e of t.split(".")){if(re.has(e)||null===n||"object"!=typeof n){r=!1;break}if(n=se(n,e),void 0===n){r=!1;break}}if(r)return n}return void 0===n?void 0:se(e,`${t}_${n}`)}function se(e,t){if(!re.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function oe(e,t,n,r){return ie(e,n,t.locale??r,void 0!==t.locale)}function ae(e,t,n,r){const i=V(t);if(void 0===i)return;const s=[e.hrefField,e.srcField,e.altField];let o=JSON.stringify([e.format,e.locale??r])+i;for(const t of s){if(void 0===t||0===t.length)continue;const i=V(oe(n,e,t,r));if(void 0===i)return;o+=`|${t}=${i}`}return o}var le="data-payload-fragment",ue="data-payload-fragment-key";function de(e){return e.closest(`[${le}]`)}function ce(e,t,n){const r=new Set(t);return{boundaries:t,strategy:e,ownerKeys:n,covers:e=>void 0!==e.fragmentBoundary&&r.has(e.fragmentBoundary)}}function he(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==de(e)?"fragment":null!==e.closest("head")?"route":"patch"}function fe(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function pe(e){return"string"==typeof e&&e.length>0}function ge(e,t){return null!==t&&void 0!==e&&t.includes(e)}function me(e){const t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function ve(e){return"object"==typeof e&&null!==e}function ye(e){return Array.isArray(e)?"array":ve(e)?"object":"scalar"}function be(e,t){return ve(e)?e[t]:void 0}function we(e,t){return("string"==typeof t||"number"==typeof t)&&ve(e)&&!Array.isArray(e)&&e.id===t}function Se(e,t){if(!ve(e)||!ve(t))return we(e,t)||we(t,e)||V(e)===V(t);if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(n=>Object.hasOwn(e,n)&&Se(be(e,n),be(t,n)))}function Ae(e,t){const n=V(t),r=V(e);return void 0!==n&&n===r||!(!we(e,t)&&!we(t,e))||void 0!==n&&void 0!==r&&Se(e,t)}function ke(e,t,n){let r=t,i=n;for(const t of e.split("."))r=be(r,t),i=be(i,t);return!Ae(r,i)}function Re(e,t,n,r){const i=[];let s=0;const o=(e,t,n,a)=>{if(s+=1,r.covers(e)||Ae(t,n))return;if(!((void 0===t||ye(t)===ye(n))&&ve(n)&&r.reachesBelow(e)&&a<8))return void i.push({path:e,value:n});const l=function(e,t){const n=new Set(Object.keys(t));if(ve(e))for(const t of Object.keys(e))n.add(t);return[...n]}(t,n);0===l.length&&i.push({path:e,value:n});for(const r of l){if(s>=1024)return void i.push({path:e,value:n});o(`${e}.${r}`,be(t,r),be(n,r),a+1)}};return o(e,t,n,0),i}var Te=/* @__PURE__ */new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function Ce(e,t,n={}){const r=e=>!1===t||ge(e,t),i=[];for(const[t,n]of e.entries())n.some(e=>r(e.owner))&&i.push(t);const s=e.rendered.filter(e=>void 0!==n[e.strategy]);return function(e,t){const n=new Set(e),r=[...t],i=(e,t)=>{const n=`${t}.`;for(const t of e)if(t.startsWith(n))return!0;return!1};return{covers:e=>n.has(e)||r.some(t=>t===e||e.startsWith(`${t}.`)),reachesBelow:e=>i(n,e)||i(r,e)}}(i,[...e.covers,...s].filter(e=>r(e.owner)).flatMap(e=>e.paths))}function $e(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 Le(e,t,n,r=Ce(e,n)){let i;const s=r.covers,o=r.reachesBelow;return r=>{const a=$e(r,t);return s(r)||a!==r&&s(a)?"whole":(i??=function(e,t){const n=/* @__PURE__ */new Set;for(const[r,i]of e.entries())for(const e of i)(!1===t||ge(e.owner,t))&&void 0!==e.locale&&n.add(`${r}_${e.locale}`);return n}(e,n),i.has(r)?"whole":o(r)||a!==r&&o(a)?"below":"none")}}function Ne(e,t,n){return"declared"===e&&void 0!==t&&void 0!==n?{previous:t,next:n}:void 0}function Pe(e,t,n,r,i,s){const o=Ce(e,r,s),a=Le(e,n,r,o),l=[];for(const e of t){if(Te.has(e))continue;const t=a(e);if("none"===t&&l.push(e),"below"!==t||void 0===i)continue;const r=$e(e,n),{previous:s,next:u}=i;for(const{path:t}of Re(r,s[e],u[e],o))l.push(t)}return l}var Fe=/* @__PURE__ */new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),Ue=/* @__PURE__ */new Set(["root","paragraph","text","heading","quote","list","listitem","linebreak","tab","horizontalrule","code","code-highlight","table","tablerow","tablecell","link","autolink"]),Me={},xe=class{rawChanges=new te;resolved=null;resolvedLocale=null;trailing=null;openUntil=0;requestAttempt=0;decide(e,t){const n=t.rawData;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(Oe(e)||e.fieldName.includes("."))return!0;if(_e(e.hrefField)||_e(e.srcField)||_e(e.altField))return!0}return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${le}]`)}(e)&&!function(e,t,n){for(const r of e.values()){if("text"!==r.fieldType||!0===r.explicitFieldType)continue;const e=oe(t,r,r.fieldName,n);if(Ye(e)&&Ie(e.root))return!0}return!1}(e.cache,n,t.locale))return t.forceRender&&(this.resolvedLocale=null),{merge:!1,fields:n};const{changed:r}=this.rawChanges.diff(n,Me),i=this.resolvedLocale!==t.locale,s=this.resolved;if(null===s)return this.resolved=n,{merge:!0,fields:n};const o={...s};t.forceRender&&(this.resolvedLocale=null);let a=t.forceRender||i;for(const i of r){const r=n[i];if(Te.has(i)){o[i]=r;continue}const l=Ee(i,s[i],r,e.cache,t.schemaIndex);"own"!==l&&(a=!0,this.resolvedLocale=null),"keep"!==l&&(o[i]=r)}return this.resolved=o,{merge:a,fields:o}}request(e,t,n){const r=++this.requestAttempt,i=Date.now();if(i>=this.openUntil)return this.openUntil=i+t,this.dropQueued(),this.requestAttempt!==r?{leading:!0,result:Promise.resolve({status:"superseded"})}:{leading:!0,result:e.merge(n)};const s=this.trailing,o=s?.pending??function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}(),a={request:n,pending:o,timer:null};if(this.trailing=a,this.openUntil=i+t,null!==s&&null!==s.timer&&clearTimeout(s.timer),this.trailing!==a)return{leading:!1,result:o.promise};const l=setTimeout(()=>{this.flush(e,a)},t);return this.trailing===a?a.timer=l:clearTimeout(l),{leading:!1,result:o.promise}}recordMerged(e,t){this.resolved=e,this.resolvedLocale=t}resetRawChanges(){this.rawChanges.reset()}destroy(){this.requestAttempt+=1,this.openUntil=0,this.dropQueued()}dropQueued(){const e=this.trailing;this.trailing=null,null!==e&&(null!==e.timer&&clearTimeout(e.timer),e.pending.settle({status:"superseded"}))}flush(e,t){this.trailing===t&&(this.trailing=null,t.timer=null,e.merge(t.request).then(t.pending.settle))}};function Ee(e,t,n,r,i){return De(n)?!De(t)||function(e,t,n){const r=void 0===n?void 0:F(n,e);return void 0!==r&&!Fe.has(r.type)||!0===t.get(e)?.some(Oe)||function(e,t){const n=`${t}.`;for(const[t,r]of e.entries())if(t.startsWith(n))return!0;return!1}(t,e)}(e,r,i)?"keep":null==t?"ask":"own":"ask"}function Oe(e){return!Fe.has(e.fieldType)}function Ie(e){const t=[e],n=/* @__PURE__ */new Set;for(let e=t.pop();void 0!==e;e=t.pop()){if("object"!=typeof e||null===e||n.has(e))continue;n.add(e);const{type:r,fields:i,children:s}=e;if(!Ue.has(r))return!0;if("internal"===i?.linkType)return!0;if(Array.isArray(s))for(const e of s)t.push(e)}return!1}function De(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function _e(e){return!0===e?.includes(".")}var Be=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 je(e,t){const n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;const r=me(e),i=me(t.data??{});return void 0!==r&&void 0!==i&&r!==i}function ze(e){return null!==e&&e.forceRender&&!e.completed}var He=class{lastIdentity=void 0;inspect(e){const t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;const n=JSON.stringify([t.entitySlug,me(t),t.updatedAt]);return{identity:n,edit:n!==this.lastIdentity&&je(t,e)?t:null}}commit(e){const t=e.identity!==this.lastIdentity;return this.lastIdentity=e.identity,t?e.edit:null}};function We(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var qe=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:We(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){this.#e=void 0}};function Ve(e,t){const n=t.element.ownerDocument.defaultView;return null===n?"no-element":e.reveal(`${t.owner??""} ${t.fieldName}`,t.element,n)}var Ge=class{seen=/* @__PURE__ */new Map;note(e,t,n){const r=V(n);if(void 0===r)return;const i=`${t.owner??""}\0${t.locale??""}\0${t.fieldName}`,s=this.seen.get(i);void 0!==s?s!==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}},Ke=()=>{},Je=class{host={outstanding:()=>!1,report:Ke,failed:Ke};entry=null;ended;begin(e,t){const n=this.entry,r=null===n?void 0:this.view(n);null!==n&&(n.key=void 0),this.ended=void 0,this.entry={key:e,revision:t,shortfalls:[],seen:/* @__PURE__ */new Set,deferred:0,awaiting:0,reported:void 0,queued:!1},null!==n&&void 0!==r&&this.publish(n,"pending"===r.state?{...r,state:"superseded"}:r)}end(){const e=this.entry;if(null!==e){this.entry=null;try{this.ended=this.view(e)}finally{e.key=void 0}}}snapshot(){return null!==this.entry?this.view(this.entry):void 0===this.ended?void 0:{...this.ended,shortfalls:[...this.ended.shortfalls]}}shortfall(e,t){const n=this.entry;if(n?.key!==e)return;const r=JSON.stringify(t);n.seen.has(r)||(n.seen.add(r),n.shortfalls.push(t),this.requestSettle(n.key))}deferred(e,t){this.entry?.key===e&&(this.entry.deferred=t)}handIsland(e){const t=this.entry;if(t?.key!==e)return Ke;t.awaiting+=1;let n=!1;return()=>{n||this.entry!==t||(n=!0,t.awaiting-=1,this.settle(t))}}requestSettle(e){const t=this.entry;t?.key!==e||t.queued||(t.queued=!0,queueMicrotask(()=>{t.queued=!1;try{this.entry===t&&this.settle(t)}catch(e){this.host.failed(e)}}))}settle(e){const t=this.view(e);"pending"!==t.state&&this.publish(e,t)}publish(e,t){e.reported!==t.state&&(e.reported=t.state,this.host.report(t))}view(e){const t=void 0!==e.key&&this.host.outstanding(e.key)?"pending":e.shortfalls.length>0?"partial":e.awaiting>0?"unconfirmed":"current";return{revision:e.revision,state:t,shortfalls:[...e.shortfalls],deferred:e.deferred,awaitingIslands:e.awaiting}}};function Qe(e){const t=e.getAttribute(ue);return{kind:"fragment",id:e.getAttribute(le)??"",key:null===t||0===t.length?void 0:t,code:"LP0801"}}var Xe=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;warnedIslandStart=!1;warnedEscalationUnavailable=!1;warnedProtocolShape=!1;reportedUnfaithful=/* @__PURE__ */new WeakMap;checkedServerFormat=/* @__PURE__ */new WeakSet;unfaithfulPatches=[];unfaithfulCount=0;escalatedCount=0;unfaithfulFields=/* @__PURE__ */new Set;autoBindSearchMs=void 0;autoBindGuesses=null;warnedForeignSource=!1;lastAppliedIdentity=/* @__PURE__ */new WeakMap;navigationReplayPending=!1;navigationBindingReplay=!1;revealLedger=new Ge;display=new Je;fragmentStats={rendered:0,failed:0,superseded:0};routeStats={refreshes:0,partial:0,failed:0,refused:0,loopStopped:0};fragmentControllers=/* @__PURE__ */new Map;routeController=null;routeRetry=null;routeRefreshOwed=!1;routeAwaitsSave=!1;fragmentsOwed=/* @__PURE__ */new Set;readyTimers=[];revealer=new qe;changes=new te;merges=new xe;protocol=new Be;relationships=new He;isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){this.display.requestSettle(e),e.completed||(e.completed=!0,e.countsAsUpdate&&(this.completedCount+=1))}forgetOwedWork(){this.routeRefreshOwed=!1,this.routeAwaitsSave=!1,this.fragmentsOwed.clear()}supersedeStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(const[e,t]of this.fragmentControllers){for(const e of t)this.fragmentsOwed.add(e);e.abort()}this.fragmentControllers.clear()}abortStrategies(){this.supersedeStrategies();const e=this.routeController;this.routeController=null,e?.abort()}},Ze=class{constructor(e,t){this.deps=e,this.state=t,this.instanceContext=L({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,serverURL:e.serverURL,reportUnfaithful:(n,r)=>{K(e,t,n,r,this.writing)}})}deps;state;writing;instanceContext;apply(e){const{deps:t,state:n}=this,r=n.activeUpdate;if(null===r||void 0===e.revision||!m(r.revision,e.revision)||!n.isCurrent(r))return!1;const{target:i,value:s}=e,o=void 0!==r.schemaIndex?F(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(O,e))return O[e]}(t);if(void 0!==e)return e}return e.fieldType}(i,o?.type);"text"===l&&!0!==i.explicitFieldType&&Ye(s)&&(l="richText");try{a=t.resolveRenderer(l,i)}catch(e){return this.fail(r,i.fieldName,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:o,...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||et(e))}(s));try{if(void 0!==i.targetAttribute){if("blocked"===function(e,t,n){const r=t.toLowerCase().trim();if(0===r.length)return"blocked";if(!q(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 W.has(r)&&!isSafeUrl(i)?"blocked":(e.setAttribute(r,i),"applied")}(i.element,i.targetAttribute,s))return t.warn(`[live-preview] LP0401: refused to write "${i.fieldName}" into attribute "${i.targetAttribute}"`),n.display.shortfall(r,{kind:"write",field:i.fieldName,code:"LP0401"}),!1}else{if(void 0===a)return t.log("no renderer for",l),K(t,n,i,`has no renderer for "${l}"`,s),!1;{const e=function(e,t,n,r){if("ignore"===e.onUnfaithfulPatch)return;if(void 0!==n.format||!Q.has(r))return;if(t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);const i=X(n.element);return i.trim().length>0?i:void 0}(t,n,i,l);this.writing=s;const r=function(e,t,n,r){return e.render(t,n,r)}(a,i,s,h);if(!1===r&&function(e){return Y.has(e.render)}(a))return K(t,n,i,`is a value ${a.name} cannot render`,s),!1;void 0!==e&&function(e,t,n){const r=X(t.element);r!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${Z(n)}, the patch wrote ${Z(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,i.fieldName,e)}if(!n.isCurrent(r))return!1;u&&t.emitter.emitWhile("elementUpdate",{element:i.element,fieldName:i.fieldName,previousValue:d,nextValue:s,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,n){if(!this.state.isCurrent(e))return!1;this.state.display.shortfall(e,{kind:"write",field:t,code:"LP0603"});const r=n instanceof Error?n:new Error(String(n));return this.deps.emitter.emitWhile("error",{error:r,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}};function Ye(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)}function et(e){return!!Ye(e)&&e.root.children.every(e=>{const{type:t,children:n}=e??{};return"paragraph"===t&&(!Array.isArray(n)||0===n.length)})}function tt(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}function nt(...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 rt(e,t){const n={};for(const r of t)r!==e&&(n[r]=[e]);return n}var it="data-payload-island",st=`astro-island, [${it}]`,ot="data-payload-owned";function at(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute("data-payload-morph"))return!0;if(ut(e)||e.hasAttribute(ot))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function lt(e){return"patch"===e.getAttribute(it)}function ut(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(it)}(e)&&!lt(e)}function dt(e){return"astro-island"===e.tagName.toLowerCase()&&e.hasAttribute("ssr")}var ct=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],ht=/* @__PURE__ */new WeakMap,ft=/* @__PURE__ */new WeakSet;function pt(e){return"astro-island"===e.tagName.toLowerCase()}function gt(e){let t="";for(const n of e.querySelectorAll("astro-slot, template[data-astro-template]"))n.parentElement?.closest("astro-island")===e&&(t+=`${n.getAttribute("name")??n.getAttribute("data-astro-template")??""}\0${n.innerHTML}\0`);return t}function mt(e,t){if(!pt(e)||!pt(t))return!0;const n=gt(t);if(!ct.every(n=>e.getAttribute(n)===t.getAttribute(n))||(ht.get(e)??gt(e))!==n||e.getAttribute("props")!==t.getAttribute("props")&&!function(e){const t=e.ownerDocument.defaultView?.customElements.get("astro-island");return void 0!==t&&e instanceof t&&Array.isArray(t.observedAttributes)&&t.observedAttributes.includes("props")}(e))return ht.set(t,n),!1;ht.set(e,n);const r=t.getAttribute("props");return r!==e.getAttribute("props")&&(e.setAttribute("ssr",""),null===r?e.removeAttribute("props"):e.setAttribute("props",r)),!0}function vt(e){return Array.from(e.querySelectorAll("astro-island"))}function yt(e){const t=e.ownerDocument.defaultView;if(void 0===t?.customElements.get("astro-island"))return"element";const n=e.getAttribute("client"),r=Reflect.get(t,"Astro");return null===n||"object"!=typeof r||null===r||void 0===Reflect.get(r,n)?"directive":void 0}var bt="data-payload-field",wt="data-payload-type",St="data-payload-attribute",At="data-payload-href",kt="data-payload-src",Rt="data-payload-alt",Tt="data-payload-array-template",Ct="data-payload-array-separator",$t="data-payload-locale",Lt="data-payload-format",Nt="data-payload-richtext",Pt="data-payload-html",Ft="data-payload-array",Ut="data-payload-structural",Mt="data-payload-owner",xt="data-payload-depends",Et="data-payload-strategy",Ot="data-payload-boundary",It="data-payload-guessed",Dt="data-payload-covers",_t=[bt,wt,St,At,kt,Rt,Tt,Ct,$t,Lt,Nt,Pt,Ft,Ut,Mt,xt,Et,Ot,"type"],Bt=`[${bt}]`,jt=`[${Mt}]`,zt=`[${le}], [${Et}="route"]`;function Ht(e){const t=e.closest(jt)?.getAttribute(Mt);return null==t||0===t.length?void 0:t}var Wt=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,qt=/* @__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 Vt(e){return qt.has(e)||Wt.test(e)}function Gt(e,t){return e.fieldName===t.fieldName&&e.locale===t.locale&&e.owner===t.owner&&e.strategyKind===t.strategyKind&&e.fragmentBoundary===t.fragmentBoundary}var Kt=class{entriesByField=/* @__PURE__ */new Map;entryByElement=/* @__PURE__ */new WeakMap;filter;count=0;dependencies=null;islandRoots=[];ownersByIsland=/* @__PURE__ */new Map;navigationRoots=[];coverDeclarations=[];renderedDeclarations=[];constructor(e={}){this.filter=e.filter??Qt}dependencyMap(){if(null!==this.dependencies)return this.dependencies;const e=[];for(const t of this.values())void 0!==t.dependsOn&&e.push(rt(t.fieldName,t.dependsOn));return this.dependencies=nt(...e),this.dependencies}get islands(){return this.islandRoots}get islandOwners(){return this.ownersByIsland}get covers(){return this.coverDeclarations}get rendered(){return this.renderedDeclarations}get navigationReplayRoots(){return this.navigationRoots}buildFromRoot(e){const t=performance.now();this.clear();let n=0;for(const t of e.querySelectorAll(Bt))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){const t=[];for(const n of e.querySelectorAll(st))lt(n)||t.push(n);return t}(e),this.ownersByIsland=new Map(this.islandRoots.map(e=>[e,Ht(e)])),this.navigationRoots=[...e.querySelectorAll(zt)].filter(e=>this.filter(e)&&(e.hasAttribute(le)||0===(e.getAttribute(bt)??"").length)),this.coverDeclarations=[...e.querySelectorAll(`[${Dt}]`)].filter(e=>this.filter(e)).map(e=>({paths:tt(e.getAttribute(Dt)),owner:Ht(e)})),this.renderedDeclarations=[...e.querySelectorAll(`[${xt}]`)].filter(e=>this.filter(e)).flatMap(e=>{const t=function(e){if((e.getAttribute(le)??"").length>0)return"fragment";const t=e.getAttribute(Et);return null!==t?"route"===t?"route":void 0:e.hasAttribute(bt)&&null!==e.closest("head")?"route":void 0}(e);return void 0===t?[]:[{strategy:t,paths:tt(e.getAttribute(xt)),owner:Ht(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=[],this.ownersByIsland=/* @__PURE__ */new Map,this.navigationRoots=[],this.coverDeclarations=[],this.renderedDeclarations=[]}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(bt);if(null===t||0===t.length)return;const n=e.getAttribute(wt),r=e.getAttribute(St),i=e.getAttribute(At),s=e.getAttribute(kt),o=e.getAttribute(Rt),a=e.getAttribute(Tt),l=e.getAttribute(Ct),u=e.getAttribute($t),d=e.getAttribute(Lt),c=Ht(e),h=tt(e.getAttribute(xt)),f=e.getAttribute(Et),p=e.getAttribute(It),g=de(e);return{element:e,fieldName:t,fieldType:Jt(e),explicitFieldType:null!==n&&Vt(n),strategyKind:he(e)??"unknown",...null!==g?{fragmentBoundary:g}:{},...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==i&&i.length>0?{hrefField:i}:{},...null!==s&&s.length>0?{srcField:s}:{},...null!==o&&o.length>0?{altField:o}:{},...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(Ot)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}};function Jt(e){const t=e.getAttribute(wt);if(null!==t&&Vt(t))return t;if(e.hasAttribute(Nt))return"richText";if(e.hasAttribute(Pt))return"html";if(e.hasAttribute(Ut))return"structural-array";if(e.hasAttribute(Ft))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 Qt(){return!0}var Xt=1e4,Zt=1048576,Yt=/* @__PURE__ */new Set(["__proto__","constructor","prototype"]);function en(){throw new Error("invalid or oversized legacy population")}function tn(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n<=31||127===n)return!0}return!1}function nn(e,t){if("string"!=typeof e||0===e.length||e.length>t||"."===e||".."===e)return!1;if(e.includes("/")||e.includes("\\")||tn(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function rn(e){return nn(e,128)&&!/[?#%]/u.test(e)&&!Yt.has(e)}function sn(e){return Number.isFinite(e)?String(e):nn(e,512)?e:en()}function on(e,t){return Object.hasOwn(e,t)?Reflect.get(e,t):void 0}function an(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0,enumerable:!0})}function ln(e){let t=e.length;for(;t>0&&47===e.charCodeAt(t-1);)t-=1;return e.slice(0,t)}function un(e){const t=/* @__PURE__ */new WeakSet;let n=0,r=0;return function e(i,s){if(++n>Xt||s>64)return en();if("string"==typeof i)return r+=i.length,r>Zt&&en(),i;if(null==i||"boolean"==typeof i)return i;if("number"==typeof i)return Number.isFinite(i)?i:en();if(!Array.isArray(i)&&!c(i))return en();if(Array.isArray(i)){i.length>Xt&&en();for(let e=0;e<i.length;e+=1)Object.hasOwn(i,e)||en()}if(t.has(i))return en();t.add(i);const o=Array.isArray(i)?[]:{};for(const t of Object.keys(i))an(o,t,e(Reflect.get(i,t),s+1));return t.delete(i),o}(e,0)}function dn(e,t,n,r,i,s){if(!Number.isSafeInteger(i)||i<0||i>64)return en();void 0!==s&&("string"!=typeof s||s.length>128||tn(s))&&en();const o=un(e);if(!c(o))return en();const a=/* @__PURE__ */new Map,l=/* @__PURE__ */new Set;let u=0;const d=/* @__PURE__ */new WeakSet,h=e=>{(++u>Xt||e>64)&&en()};function f(e,t,n,r){if(null==r||""===r)return;const s=c(r)?on(r,"id"):r,o=sn(s);if(0===i)return void an(e,t,s);const u=JSON.stringify([n,o]);l.add(u),l.size>1e3&&en();const d=a.get(n)??[];d.push({owner:e,key:t,id:o}),a.set(n,d)}function p(e,t,n){void 0!==n.hasMany&&"boolean"!=typeof n.hasMany&&en();const r=n.relationTo,i=on(e,t);if(Array.isArray(r)){0===r.length&&en();const e=c(i)?on(i,"relationTo"):void 0;let t;for(const n of r)h(0),rn(n)||en(),n===e&&(t=n);if(null==i||""===i)return;c(i)&&void 0!==t||en(),f(i,"value",t,on(i,"value"))}else rn(r)||en(),f(e,t,r,i)}function g(e,t){if(h(t),Array.isArray(e)||c(e)){if(c(e)&&Object.hasOwn(e,"relationTo")&&Object.hasOwn(e,"value")){const t=on(e,"relationTo");return rn(t)||en(),void f(e,"value",t,on(e,"value"))}for(const n of Object.keys(e))g(Reflect.get(e,n),t+1)}}!function e(t,n,r){h(r),d.has(t)&&en(),d.add(t);for(const i of t){h(r),c(i)&&nn(i.name,512)&&!Yt.has(i.name)||en();const t=on(n,i.name);if("relationship"===i.type||"upload"===i.type)if(i.hasMany)if(null==t||Array.isArray(t)||en(),Array.isArray(t))for(let e=0;e<t.length;e+=1)p(t,e,i);else p(n,i.name,i);else p(n,i.name,i);else if("group"===i.type||"tabs"===i.type)null==t||c(t)||en(),c(t)&&i.fields&&e(i.fields,t,r+1);else if("row"===i.type||"collapsible"===i.type)i.fields&&e(i.fields,n,r+1);else if("array"===i.type||"blocks"===i.type){if(0===t?an(n,i.name,[]):null==t||Array.isArray(t)||en(),Array.isArray(t))for(const n of t)if(c(n)||en(),"array"===i.type&&i.fields)e(i.fields,n,r+1);else if("blocks"===i.type){const t=on(n,"blockType"),s=i.blocks?.find(e=>(h(r),e.slug===t));void 0===s&&en(),e(s.fields,n,r+1)}}else"richText"===i.type&&g(t,r+1)}d.delete(t)}(t,o,0),a.size>25&&en();const m=[];if(0===a.size)return{doc:o,requests:m};const v=new URL(n);(!["http:","https:"].includes(v.protocol)||v.username||v.password||v.search||v.hash)&&en(),(!r.startsWith("/")||r.includes("\\")||/[%?#]/u.test(r)||tn(r))&&en(),r.split("/").some(e=>"."===e||".."===e)&&en();const y=`${ln(n)}${ln(r)}/`;for(const[e,t]of a){const n=[...new Set(t.map(e=>e.id))];let r=0;for(;r<n.length;){const o=n[r];void 0===o&&en();const a=o.includes(","),l=[];let u="";for(;r<n.length&&l.length<20;){const t=n[r];if(void 0===t||l.length>0&&(a||t.includes(",")))break;const o=[...l,t],d=new URLSearchParams({depth:String(i),limit:String(o.length)});void 0!==s&&d.set("locale",s),d.set(a?"where[id][equals]":"where[id][in]",a?t:o.join(","));const c=`${y}${encodeURIComponent(e)}?${d}`;if(c.length>8192){0===l.length&&en();break}new URL(c).origin!==v.origin&&en(),l.push(t),r+=1,u=c}(0===l.length||m.length>=64)&&en();const d=new Set(l);m.push({url:u,ids:d,slots:t.filter(e=>d.has(e.id))})}}return{doc:o,requests:m}}async function cn(e,t,n){let r,i=!1,s=!1;const o=/* @__PURE__ */Symbol();let a;const l=new Promise(e=>{a=()=>{e(o)}}),u=()=>{n()&&!t.aborted||en()},d=()=>{if(void 0!==r&&!i){i=!0;try{Promise.resolve(r.cancel()).catch(()=>{})}catch{}}},c=()=>{a?.(),d()};t.addEventListener("abort",c,{once:!0});try{u();const t=e.body??null;if(u(),null===t){const t=e.json.bind(e);u();const n=await Promise.race([Promise.resolve().then(()=>(u(),t())),l]);return u(),n===o&&en(),n}const n=t.getReader.bind(t);u();const i=n();r=i,u();const a=[];let d=0,c=0;for(;;){const e=Promise.resolve().then(()=>{u();const e=i.read.bind(i);return u(),e()}),t=await Promise.race([e,l]);if(u(),t===o&&en(),t.done)break;d+=t.value.byteLength,(++c>1e4||d>Zt)&&en(),a.push(t.value)}s=!0;const h=new Uint8Array(d);let f=0;for(const e of a)h.set(e,f),f+=e.byteLength;try{return JSON.parse((new TextDecoder).decode(h))}catch{return en()}}finally{t.removeEventListener("abort",c),s||d();try{r?.releaseLock()}catch{}}}function hn(e,t){const n=un(t);c(n)||en();const r=on(n,"docs");(!Array.isArray(r)||r.length>20)&&en();const i=/* @__PURE__ */new Map;for(const t of r){c(t)||en();const n=sn(on(t,"id"));e.ids.has(n)&&!i.has(n)||en(),i.set(n,t)}i.size!==e.ids.size&&en();for(const t of e.slots)an(t.owner,t.key,i.get(t.id))}function fn(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 pn(e){return fn(e,128)&&!e.includes("?")&&!e.includes("#")}function gn(e){return"number"==typeof e?Number.isFinite(e):"string"==typeof e&&fn(e,512)}var mn=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=y(e.log??b)}canMerge(e){try{const t=e.schema;return void 0!==t?(dn(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale),!0):null!==this.endpointOf(e)}catch{return!1}}endpointOf(e){try{const t=e.globalSlug;if(t)return pn(t)?{path:`globals/${encodeURIComponent(t)}`,field:"globalType",value:t}:null;const n=e.collectionSlug??"",r=e.data.id;return pn(n)&&gn(r)?{path:`${encodeURIComponent(n)}/${encodeURIComponent(String(r))}`,field:"id",value:String(r)}:null}catch{return null}}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};const t=this.attempt+=1,n=this.inflight;this.inflight=null;let r=null,i=!1;const s=()=>this.attempt!==t;try{if(n?.abort(),s())return{status:"superseded"};const t=e.schema;if(i=void 0!==t,void 0!==t){const n=dn(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale);if(s())return{status:"superseded"};if(0===n.requests.length)return{status:"merged",doc:n.doc};const i=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(s())return{status:"superseded"};if(void 0===i)return{status:"unavailable"};r=new AbortController,this.inflight=r;for(const e of n.requests){const t=await i(e.url,{method:"GET",credentials:"include",redirect:"error",signal:r.signal});if(s())return{status:"superseded"};const n=t.ok;if(s())return{status:"superseded"};if(!n){const e=t.status;return s()?{status:"superseded"}:(r.abort(),s()?{status:"superseded"}:(this.log("merge HTTP",e),s()?{status:"superseded"}:{status:"unavailable"}))}const o=await cn(t,r.signal,()=>!s());if(s())return{status:"superseded"};if(hn(e,o),s())return{status:"superseded"}}return{status:"merged",doc:n.doc}}const o=this.endpointOf(e);if(s())return{status:"superseded"};if(null===o)return{status:"unavailable"};const a=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(s())return{status:"superseded"};if(void 0===a)return{status:"unavailable"};const l=JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,locale:e.locale});if(s())return{status:"superseded"};r=new AbortController,this.inflight=r;const u=`${this.serverURL}${this.apiRoute}/${o.path}`,d=await a(u,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:l,signal:r.signal});if(s())return{status:"superseded"};const c=d.ok;if(s())return{status:"superseded"};if(!c){const e=d.status;return s()?{status:"superseded"}:(this.log("merge HTTP",e,u),s()?{status:"superseded"}:{status:"unavailable"})}const h=d.json.bind(d);if(s())return{status:"superseded"};const f=await h();if(s())return{status:"superseded"};if(null===f||"object"!=typeof f||Array.isArray(f))return this.log("merge invalid",u),s()?{status:"superseded"}:{status:"unavailable"};const p=f,g=p[o.field],m=Object.hasOwn(p,o.field)&&("id"===o.field?!gn(g)||String(g)!==o.value:g!==o.value);return s()?{status:"superseded"}:m?(this.log("merge invalid",u),s()?{status:"superseded"}:{status:"unavailable"}):{status:"merged",doc:p}}catch(e){return s()||i&&(r?.abort(),s())?{status:"superseded"}:(this.log("merge exception",i?new Error("legacy population could not be resolved"):e),s()?{status:"superseded"}:{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}}},vn="2.2.1",yn={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},bn={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},wn={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1},Sn="ssr",An=[bt,Mt,Dt,xt],kn=`[${bt}], [${Dt}], ${st}, ${zt}`,Rn=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:[..._t,Dt,it,Sn]})}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))return;for(const n of e){const e=Tn(n);if(null!==e&&(this.callbacks.onIslandHydrated?.(e),!this.isCurrentGeneration(t)))return}if(!function(e){for(const t of e){if("attributes"===t.type&&t.attributeName===it)return!0;if("attributes"===t.type&&null!==t.attributeName){if(An.includes(t.attributeName))return!0;if(_t.includes(t.attributeName)&&1===t.target.nodeType&&t.target.hasAttribute(bt))return!0}for(const e of t.addedNodes)if(Cn(e))return!0;for(const e of t.removedNodes)if(Cn(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 Tn(e){if("attributes"!==e.type||e.attributeName!==Sn||1!==e.target.nodeType)return null;const t=e.target;return"astro-island"!==t.tagName.toLowerCase()||t.hasAttribute(Sn)?null:t}function Cn(e){if(1!==e.nodeType)return!1;const t=e;return t.matches(kn)||null!==t.querySelector(kn)}var $n=class{#t=[];#n;#r=!1;constructor(e){this.#n=e}get closed(){return this.#r}own(e){this.#r?this.#i(e):this.#t.push(e)}close(){if(this.#r)return;this.#r=!0;const e=this.#t.splice(0).reverse();for(const t of e)this.#i(t)}#i(e){try{e()}catch(e){this.#n("runtime cleanup failed:",e)}}},Ln="[data-payload-field]";function Nn(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydration??={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]}}function Pn(){const e=Nn();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{}void 0===e.onCommit?e.commits.push(n):e.onCommit(n)}}function Fn(e){e.committed=!0;const t=e.waiters;e.waiters=[];for(const e of t)e()}function Un(e,t){const n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function Mn(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,Un(e,i),t("timed-out")},n),()=>{null!==r&&clearTimeout(r),r=null,Un(e,i)}}var xn="__vue_app__";function En(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewVueHydration??={armed:!1,committed:!1,waiters:[]}}function On(e){return Object.prototype.hasOwnProperty.call(e,xn)?e[xn]:void 0}function In(){const e=En();if(void 0===e||e.armed)return;e.armed=!0;const t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,xn)&&Object.defineProperty(t,xn,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,xn,{value:e,writable:!0,configurable:!0,enumerable:!0});const t=En();void 0===t||t.committed||null===this.querySelector(Ln)||function(e,t){const n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?Fn(e):n.hook("app:suspense:resolve",()=>{e.committed||Fn(e)})}(t,e)}})}function Dn(e){const t=e.hydration;if(void 0===t)return void e.startNow();const n=_n[t](e.root,n=>{e.later(()=>{jn(e,t,n)})});null!==n?(e.defer(n),e.hydrated("waiting")):jn(e,t,"committed")}var _n={react:(e,t)=>function(e,t=5e3){Pn();const n=Nn();if(void 0===n)return null;if(void 0===n.onCommit){const e=e=>{!n.committed&&function(e){const t=e;return null!=t&&function(e){const t=e;return 9===t?.nodeType||null!=t?.querySelector?.(Ln)}(t.containerInfo)&&!function(e){const t=[];for(null!==e.current&&void 0!==e.current&&t.push(e.current);t.length>0;){const e=t.pop();if(void 0===e)continue;const n=e.memoizedState;if((13===e.tag||31===e.tag)&&"object"==typeof n&&null!==n&&"dehydrated"in n&&"object"==typeof n.dehydrated&&null!==n.dehydrated&&"nodeType"in n.dehydrated&&8===n.dehydrated.nodeType)return!0;null!==e.sibling&&void 0!==e.sibling&&t.push(e.sibling),null!==e.child&&void 0!==e.child&&t.push(e.child)}return!1}(t)}(e)&&Fn(n)};n.onCommit=e;for(const t of n.commits.splice(0))e(t)}return Mn(n,e,t)}(t),vue:function(e,t,n=5e3){In();const r=En();return void 0===r?null:(!r.committed&&function(e){for(let t=e.querySelector(Ln);null!==t;t=t.parentElement)if(void 0!==On(t))return!0;return!1}(e)&&Fn(r),Mn(r,t,n))},sveltekit:function(e,t,n=5e3){const r=e.ownerDocument??e,i=()=>null!==r.querySelector("#svelte-announcer");if(i()||!Object.keys(window).some(e=>e.startsWith("__sveltekit_")))return null;const s={committed:!1,waiters:[]},o=new MutationObserver(()=>{!s.committed&&i()&&Fn(s)});o.observe(r,{childList:!0,subtree:!0});const a=Mn(s,e=>{o.disconnect(),t(e)},n);return()=>{o.disconnect(),a?.()}}},Bn={react:"React commit",vue:"Vue mount",sveltekit:"SvelteKit mount"};function jn(e,t,n){e.hydrated(n),"timed-out"===n&&e.warn(`[live-preview] LP0607: no ${Bn[t]} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}function zn(e){return 9===e.nodeType}function Hn(e){return e.body}var Wn=class{timeoutMs;onTimeout;handle=null;lastKick=null;constructor(e){this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){this.lastKick=Date.now(),this.timeoutMs<=0||(this.stop(),this.arm(this.timeoutMs))}resume(){if(this.timeoutMs<=0||null!==this.handle||null===this.lastKick)return!1;const e=Math.max(0,Date.now()-this.lastKick),t=this.timeoutMs-e;return t<=0?(this.lastKick=null,this.onTimeout(),!0):(this.arm(Math.min(t,this.timeoutMs)),!1)}arm(e){const t=setTimeout(()=>{this.handle===t&&(this.handle=null,this.lastKick=null,this.onTimeout())},e);this.handle=t}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick??0}get pending(){return null!==this.handle}},qn=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)}},Vn=/* @__PURE__ */new Set(["true","false","yes","no","on","off"]),Gn=/^[\d\s.,:+/-]+$/u,Kn=/^[a-z][a-z0-9_-]*$/u,Jn=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,Qn=/* @__PURE__ */new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]);function Xn(e,t=13){if("string"!=typeof e)return!1;const n=e.trim();return!(n.length<t||Gn.test(n)||Vn.has(n.toLowerCase())||Kn.test(n)||Jn.test(n))}function Zn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Yn(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,s]of Object.entries(e)){if(Te.has(r))continue;const e=$e(r,t);if(Xn(s,n))i(s.trim(),e,!1);else if(Zn(s))if("string"==typeof s.url)i(s.url,e,!0);else if(!("id"in s)&&!("_id"in s))for(const[t,r]of Object.entries(s))!Te.has(t)&&Xn(r,n)&&i(r.trim(),`${e}.${t}`,!1)}return r}function er(e){if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||Qn.has(e.tagName))return!0;if(e.hasAttribute(bt)||e.hasAttribute("data-payload-no-bind")||e.hasAttribute(ot)||ut(e))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function tr(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 nr(e){return q(e)&&!e.startsWith("data-payload-")&&"value"!==e}function rr(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 ir(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(er(n))continue;const e=tr(n),r=void 0===e?void 0:t.values.get(e);null==r||r.media||(rr(t,n,r).text=r.field);for(const e of n.getAttributeNames()){if(!nr(e))continue;const r=t.values.get(n.getAttribute(e)??"");null!=r&&(!r.media||"IMG"===n.tagName&&"src"===e)&&rr(t,n,r).attributes.set(e,r)}ir(n,t)}}function sr(e,t,n){const r=e.tagName;if(void 0!==t){const i={[bt]:t};if("A"===r){const e=n.get("href");void 0===e?i[wt]="text":e!==t&&(i[At]=e)}return{element:e,fieldName:t,matched:tr(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:{[bt]:t,...void 0!==r&&r!==t?{[Rt]:r}:{}}}}}const i=n.entries().next();if(i.done)return;const[s,o]=i.value;return{element:e,fieldName:o,matched:e.getAttribute(s)??"",attribute:s,stamps:{[bt]:o,[St]:s}}}function or(e,t){const n={values:t,byElement:/* @__PURE__ */new Map,byField:/* @__PURE__ */new Map};t.size>0&&!er(e)&&ir(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,s=/* @__PURE__ */new Map;for(const[e,n]of t.attributes)r(n.field)&&s.set(e,n.field);const o=sr(e,n,s);void 0!==o&&i.push(o)}return i}function ar(e){return 9===e.nodeType?e.body:e}function lr(e,t){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(void 0!==r){r.observed&&e.observers.unobserveElement(r.element);for(let e=r.attributes.length-1;e>=0;e-=1){const t=r.attributes[e];if(void 0===t)continue;const{name:n,before:i,written:s}=t;i!==s&&r.element.getAttribute(n)===s&&(null===i?r.element.removeAttribute(n):r.element.setAttribute(n,i))}r.cacheTouched&&(r.element.hasAttribute(bt)?e.cache.add(r.element):e.cache.remove(r.element))}}}function ur(e,t,n,r,i){const s=[],o=[],a=()=>(lr(e,o),[]);for(const l of t){if(!i())return a();const{element:t}=l;if(t.hasAttribute(bt))continue;if(!i())return a();if(!1!==n&&!ge(Ht(t),n))continue;if(!i())return a();const u={element:t,attributes:[],cacheTouched:!1,observed:!1};o.push(u);for(const[e,n]of[...Object.entries(l.stamps),[It,l.matched]]){const r=t.getAttribute(e);if(!i())return a();if(u.attributes.push({name:e,before:r,written:n}),t.setAttribute(e,n),!i())return a()}if(u.cacheTouched=!0,void 0!==e.cache.add(t)){if(!i())return a();if(e.observers.observeElement(t),u.observed=!0,!i())return a();if(e.log("autoBind",l.fieldName,"→",`<${t.tagName.toLowerCase()}>`,l.attribute??"text",JSON.stringify(l.matched),r),!i())return a();s.push(l)}else lr(e,[u]),o.pop()}return s}function dr(e,t,n,r){if(!e.scopeBindingsByOwner)return!1;const{message:i}=n,s=function(e){if(pe(e.globalSlug))return[(t=e.globalSlug,`global:${t}`)];var t;if(!pe(e.collectionSlug))return null;const n=fe(e.collectionSlug);return pe(e.documentId)?[n,fe(e.collectionSlug,e.documentId)]:[n]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:me(r)});return null!==s||t.warnedUnattributableMessage||(t.warnedUnattributableMessage=!0,e.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),s}var cr=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;awaitingHydration=/* @__PURE__ */new WeakSet;delivered=/* @__PURE__ */new WeakMap;confirmations=/* @__PURE__ */new WeakMap;reapplyBindings(e){const t=this.currentTransaction();void 0!==t?.renderData&&this.host.schedule(t,t.renderData,e)}reapplyIslands(e,t=!1){const n=t?e.filter(e=>this.awaitingHydration.delete(e)):e,r=this.state.activeUpdate,i=t&&null!==r&&this.state.isCurrent(r)?r:this.currentTransaction();void 0!==i?.renderData&&this.dispatchIslands(i,i.renderData,n)}dispatchIslands(e,t,n){const r=dr(this.deps,this.state,e,t.fields),i=()=>!e.cancelled&&this.state.isCurrent(e);if(!i())return;let s=this.delivered.get(t);void 0===s&&(s=/* @__PURE__ */new WeakSet,this.delivered.set(t,s));for(const o of n){const n=Ht(o);if(!i())return;if(!1!==r&&!ge(n,r)){this.awaitingHydration.delete(o);continue}const a=this.confirmation(o,e);if(dt(o))this.awaitingHydration.add(o);else{if(this.awaitingHydration.delete(o),s.has(o))continue;s.add(o),hr(e,t,[o],i,a)}}}hasLateRouteBinding(e,t,n,r){for(const r of e){if((r.getAttribute(bt)??"").length>0||"route"!==r.getAttribute(Et))continue;if(!1!==t&&!ge(Ht(r),t))continue;const e=tt(r.getAttribute(xt));if(0===e.length||e.some(e=>n.touched.has(e)))return!0}for(const[i,s]of this.deps.cache.entries())for(const o of s){if(!e.has(o.element))continue;if(!1!==t&&!ge(o.owner,t))continue;if("route"!==(o.strategyKind??he(o.element)??"unknown"))continue;const s=oe(r.fields,o,i,n.locale);if(!this.state.isCurrent(n))return!1;if(void 0!==s)return!0}return!1}fieldsForElements(e,t){const n=new Set(t);for(const[t,r]of this.deps.cache.entries())r.some(t=>e.has(t.element))&&n.add(t);return n}unrunFragmentPlan(e,t,n){if(null===t)return null;const r=t.boundaries.filter(t=>!e.fragmentBoundariesRun.has(t)&&(void 0===n||[...n].some(e=>e===t||t.contains(e))));return ce(t.strategy,r,t.ownerKeys)}confirmation(e,t){const n=this.confirmations.get(e);if(n?.transaction===t)return n.displayed;const r=this.state.display.handIsland(t);return this.confirmations.set(e,{transaction:t,displayed:r}),r}currentTransaction(){const e=this.state.activeUpdate;return this.state.navigationBindingReplay&&null!==e&&this.state.isCurrent(e)?e:null}};function hr(e,t,n,r,i){!function(e,t,n){let r=0;for(const i of e){if(!n())break;if(i.dispatchEvent(new CustomEvent("payload-live-preview:update",{detail:t,bubbles:!1})),r+=1,!n())break}}(n,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale,displayed:i},r)}function fr(e,t,n,r,i){const{warned:s,warn:o}=e;if(s.has(n)||t(n))return;s.add(n);const a=`data-payload-field="${$e(n,r)}"`;o(""!==i?`[live-preview] LP0203: field "${n}" has a value and no <… ${a}> on this page; editing it changes nothing here. Expected where the page shows part of the document: inspect().fidelity.fields lists these, onUnfaithfulPatch decides whether a server render is asked for.`:`[live-preview] LP0201: no <… ${a}> for the empty field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)}function pr(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function gr(e){return Array.isArray(e.docs)&&"boolean"==typeof e.hasNextPage}function mr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var vr=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function yr(e){const t=function(){const e=function(){const e=globalThis,t=e[vr];if(void 0!==t)return t;const n={};return e[vr]=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 br=/* @__PURE__ */new Set(["open","value","checked","selected"]);function wr(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function Sr(e,t,n){if(!Rr(e,t))return t;const r=n.boundary??at,i=r(e),s=r(t);if(i||s)return i&&s&&(n.retainBoundary?.(e,t)??1)?e:t;const o=Tr(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||br.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=wr(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()),s=Array.from(e.childNodes).filter(e=>!i.has(e)),o=/* @__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?wr(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&&!o.has(e)&&(c=Ar(e,i,n)===e?e:null,null===c)){e.replaceWith(i),o.add(i),u=i.nextSibling;continue}}else{for(;d<s.length;){const r=s[d];if(d+=1,!o.has(r)){if(Rr(r,i)){c=Ar(r,i,n)===r?r:null,null===c&&(e.replaceChild(i,r),o.add(i),u=i.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(i instanceof Element)||void 0!==n&&Rr(r,n)){d-=1;break}e.replaceChild(i,r),o.add(i),u=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,r),o.add(i),u=i.nextSibling;break}}}if(null===c&&o.has(i))continue}const f=c??i;for(o.add(f);null!==u&&u!==f&&!o.has(u)&&kr(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(const t of Array.from(e.childNodes))o.has(t)||t.remove()}(e,t,n),Cr(o),e}function Ar(e,t,n){return e instanceof Element&&t instanceof Element?Sr(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function kr(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function Rr(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function Tr(e){const t=e.ownerDocument.activeElement;return t instanceof HTMLElement&&e.contains(t)?{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}:null}function Cr(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{}}var $r=/* @__PURE__ */new Set;function Lr(e){$r.has(e)||($r.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)":"Put it on an element the template owns, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var Nr=/* @__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"]),Pr=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),Fr=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),Ur=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),Mr="aria-",xr="data-",Er={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"])},Or=/* @__PURE__ */new Set(["href","src","cite","poster"]),Ir=class extends Error{name="SanitizerEnvironmentError"},Dr=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-morph","data-payload-nested-key","data-payload-nested-template"]),_r=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function sanitizeHtml(e,t){return Br(e,void 0,t)}function Br(e,t,n){const r=n?.document??Hr();if(!r)throw jr();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(Er))e.set(t,n);return{allowedTags:Nr,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(Nr);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of Pr)r.add(e);const i=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(Er))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);let s=e;for(let e=0;e<6;e+=1){const e=r.createElement("template");e.innerHTML=yr(s);const t=e.content;Wr(t,i);const n=zr(t);if(n===s)return n;s=n}return function(e,t){if(!function(){try{const e=globalThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}())return;const n=globalThis,r=n.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!r.has(e)){r.add(e);try{console.warn(`[payload-live-preview] ${t}`)}catch{}}}("sanitizer-unsettled",`sanitizeHtml: the output did not settle after ${String(6)} passes, so it returned an empty string (ADR 0016).`),""}function jr(){return"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new Ir("sanitizeHtml needs a DOM; pass one per call during SSR: { document } (linkedom, jsdom).")}function zr(e){const t=e.ownerDocument?.createElement("div");if(void 0===t)throw jr();const n=e.firstChild;if(t.append(e),t.firstChild!==n)throw jr();return t.innerHTML}function Hr(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[_r];if(e)return e}if("undefined"!=typeof document)return document}function Wr(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?qr(n,t):8===n.nodeType&&n.remove()}function qr(e,t){const n=e.tagName.toLowerCase();if(!Fr.has(n)||t.allowFormControls&&Pr.has(n)){if(!t.allowedTags.has(n))return Wr(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("is"!==i){if("strict"===n.mode){if(n.templateMode&&Dr.has(i))continue;if("id"===i||"name"===i||i.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===i&&!0!==r?.has(i)||Lr(i);continue}if(i.startsWith(xr)){n.allowedData.has(i)||(e.removeAttribute(t.name),Lr(i));continue}if(Ur.has(i)||i.startsWith(Mr))continue}else if(Ur.has(i)||i.startsWith(Mr)||i.startsWith(xr))continue;r?.has(i)?Or.has(i)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==i||Vr(t.value)||e.removeAttribute(t.name):e.removeAttribute(t.name)}else e.setAttribute("is","")}}(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),Wr(e,t)}else e.remove()}function Vr(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)||!isSafeUrl(e))return!1}return!0}var Gr=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}),Kr=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(Kr,e=>Gr[e])}var Jr=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'"}),Qr=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(Qr,e=>Jr[e])}var Xr=/\{\{([\s\S]*?)\}\}/g;function Zr(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 Yr(e,t,n,r,i){const s="object"==typeof t&&null!==t?t:null;return e.replace(Xr,(e,o)=>null!==s&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(s,o)?escapeHtml(r(Reflect.get(s,o))):null===s&&"value"===o?escapeHtml(r(t)):"index"===o?String(n):null!==s&&!0===i?.has(o)?"":e)}function ei(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(!q(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 ti(e,t){for(const[n,r]of t)e.hasAttribute(n)||e.setAttribute(n,r)}function ni(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 ri(e){return null==e||""===e}function ii(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function si(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 oi=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],ai=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],li=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,ui=/* @__PURE__ */new Map;function di(e){const t=ii(ui,e);if(void 0!==t)return t;const n=new Set(oi);for(const t of e.matchAll(li)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const r={};for(const e of n)r[e]=ai;const i={additionalAllowedTags:[...n],additionalAllowedAttributes:r,allowFormControls:!0,templateMode:!0};return si(ui,e,i,64)}var ci="data-payload-key",hi="data-payload-nested-key",fi="data-payload-nested-template";function pi(e){const t=mi(e.container,e.patches,e);return null===t?null:vi(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function gi(e,t){return t.hasAttribute(hi)&&t.hasAttribute(fi)}function mi(e,t,n){const r=function(e,t,n){const{template:r,nextItems:i,forceRender:s=!1,store:o,sanitizerPolicy:a}=n,l=o.get(e),u=ei(e),d=Zr(i),c=Array.from(e.children),h=Ri(c,ci),f=/* @__PURE__ */new Set,p=[];for(let o=0;o<i.length;o+=1){const g=i[o],m=ki(g);let v=void 0===m?c[o]??null:Ti(h,m)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);const y=t.replaces.has(o),b=s||t.renders.has(o)||null===v?Ci(e.ownerDocument,r,g,o,a,u,d):void 0;if(null===b)return null;const w=void 0===b?[]:yi(y?null:v,b,g,void 0===m?void 0:l?.get(m),n);if(null===w)return null;p.push([o,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 vi(e,t,n){const[r,i,s]=e,o=/* @__PURE__ */new Set;let a=!1;const l=Tr(r);for(const[e,s,l,u,d]of i){let i=s;if(void 0!==l){const e=!(!n.morph||d||null===s)&&Sr(s,l,{keyAttributes:[ci,hi],boundary:at,retainBoundary:mt,retainChildrenOf:gi,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===s;if(!e)for(const[e,t]of u)null!==e&&(wi(e,t),t.replaceWith(e));for(const[,,e]of u)void 0!==e&&vi(e,t,n);e?a=!0:(null!==s&&(s.replaceWith(l),a=!0),i=l)}if(null===i)continue;const c=r.children[e]??null;i!==c&&(r.insertBefore(i,c),a=!0),o.add(i)}for(const e of Array.from(r.children))o.has(e)||(e.remove(),a=!0);Cr(l);const u=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(r,t);u.clear();for(const e of s)Ai(u,e);return a}function yi(e,t,n,r,i){const s=Ri(null===e?[]:bi(e),hi),o=[];for(const e of bi(t)){const t=e.getAttribute(hi);if(null===t)continue;const a=Ti(s,t)??null,l=e.getAttribute(fi),u=l?a:null,d=u?.getAttribute(fi)??null;let c;if(l){const s=Si(n,t);if(void 0!==s||null!==u){const n=s??[],o=x(null===u?[]:Si(r,t)??[],n),a=null!==u&&d!==l;if((o.length>0||a)&&(c=mi(u??e,o,{template:l,nextItems:n,forceRender:a,store:i.store,sanitizerPolicy:i.sanitizerPolicy})??void 0,void 0===c))return null}}o.push([u,e,c])}return o}function bi(e){return Array.from(e.querySelectorAll(`[${hi}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(hi))return!1;n=n.parentElement}return n===e})}function wi(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 Si(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function Ai(e,t){const n=ki(t);void 0!==n&&e.set(n,t)}function ki(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Ri(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 s=i.getAttribute(t);if(null===s)continue;const o=n.get(s);void 0===o?n.set(s,[i]):o.push(i)}return n}function Ti(e,t){return e.get(t)?.pop()}function Ci(e,t,n,r,i,s,o){const a=Br(Yr(t,n,r,ni,o),i,di(t)),l=e.createElement("template");l.innerHTML=yr(a);const u=l.content.firstElementChild;if(!u)return null;ti(u,s);const d=ki(n);return void 0!==d&&u.setAttribute(ci,d),u}function $i(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 Li(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`))}function Ni(e,t,n){if(t.warnedEscalationUnavailable)return;t.warnedEscalationUnavailable=!0;const r=`[live-preview] LP0808: onUnfaithfulPatch: 'escalate' has nowhere to go: ${String(n)} field(s) fell short`,i="or onUnfaithfulPatch: 'warn' to keep the patch and say so.";e.warn(void 0===e.strategies.fragment?`${r} and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, ${i}`:`${r}, not all of them inside a data-payload-fragment boundary of this document, and no route strategy is configured. Cover them with a boundary or add the route strategy, ${i}`)}var Pi=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;planFragments(e,t){const{deps:n,state:r}=this,i=n.strategies.fragment;if(void 0===i)return null;const s=new Set(i.plan(n.root,e));for(const e of r.fragmentsOwed)n.root.contains(e)?s.add(e):r.fragmentsOwed.delete(e);return ce(i,[...s].filter(e=>Fi(e,t)),t)}escalateUnfaithful(e,t,n,r){if(e.routeRefreshed)return void this.kept(e,n);const{fragment:i,route:s}=this.deps.strategies,o=void 0===i?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),a=void 0===o||o.every(e=>Fi(e,r))?o:void 0;return void 0!==i&&void 0!==a?(this.state.escalatedCount+=n.length,e.pendingFragments+=a.length,void this.runFragments(e,t,ce(i,a,r))):void 0===s?(Ni(this.deps,this.state,n.length),void this.kept(e,n)):(this.state.escalatedCount+=n.length,void this.refreshRoute(e,t,s))}kept(e,t){for(const n of t)this.state.display.shortfall(e,{kind:"unfaithful",field:n.fieldName})}hasUnboundChange(e,t){const{deps:n,state:r}=this;if(e.baseline||e.routeRefreshed)return!1;const i=Pe(n.cache,e.touched,e.locale,t,this.subfields(e),n.strategies);let s=0;for(const e of i)J(r,e)&&(s+=1);const[o]=i;if(void 0===o)return!1;if("escalate"!==n.onUnfaithfulPatch||void 0===n.strategies.route){"escalate"===n.onUnfaithfulPatch&&Ni(n,r,i.length);for(const t of i)r.display.shortfall(e,{kind:"unbound",field:t});return!1}return e.navigated?(r.routeAwaitsSave=!0,r.display.shortfall(e,{kind:"route-saved"}),!1):(n.log("route","LP0807",`field "${o}" has no binding; refreshing the route`),r.escalatedCount+=s,!0)}subfields(e){const{previousFields:t}=this.state.changes;return Ne(this.deps.subfieldCoverage,t,e.renderData?.fields)}plansRoute(e,t,n){const r=e=>!1===n||ge(e,n),i=function(e,t,n){const r=e.rendered.flatMap(e=>"route"===e.strategy?e.paths:[]);for(const[t,n]of e.entries())n.some(e=>"route"===e.strategyKind)&&r.push(t);const i=new Set(t);for(const e of r){const[r=e]=e.split(".");t.has(r)&&(void 0===n||ke(e,n.previous,n.next))&&i.add(e)}return i}(this.deps.cache,t.touched,this.subfields(t));if(e.plan(this.deps.root,i,{inScope:e=>r(Ht(e))}))return!0;for(const[e,t]of this.deps.cache.entries())if(i.has(e)&&t.some(e=>"route"===e.strategyKind&&r(e.owner)))return!0;return!1}async runFragments(e,t,n){const{deps:r,state:i}=this,s=new AbortController,o=new Set(n.boundaries);for(const e of o)i.fragmentsOwed.delete(e);i.fragmentControllers.set(s,o);const a=t=>{o.delete(t)&&(e.pendingFragments-=1)},l=()=>i.isCurrent(e)&&!s.signal.aborted,u=e=>function(e,t,n){if(t.isConnected)return t;const r=t.getAttribute(le),i=t.getAttribute(ue);let s;for(const t of e.querySelectorAll(`[${le}]`))if(t.getAttribute(le)===r&&t.getAttribute(ue)===i&&n(t)){if(void 0!==s)return;s=t}return s}(r.root,e,e=>Fi(e,n.ownerKeys)),{emitter:d}=r,{message:c}=e,h=e.revision.revision,f=e.receivedAt,p={root:r.root,revision:h,receivedAt:f,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof c.collectionSlug?c.collectionSlug:void 0,globalSlug:"string"==typeof c.globalSlug?c.globalSlug:void 0,signal:s.signal,isCurrent:l,log:(e,t)=>{r.log("fragment",e,t)},morph:(e,t)=>{const n=l()?u(e):void 0;void 0!==n&&function(e,t,n){const r=e.ownerDocument.createElement("template");r.innerHTML=yr(t);const i=e.cloneNode(!1);i.append(r.content);const s=vt(e);Sr(e,i,{keyAttributes:[ci],boundary:at,retainBoundary:mt}),function(e){for(const t of e)t.isConnected||ft.has(t)||(ft.add(t),t.dispatchEvent(new CustomEvent("astro:unmount")))}(s);const o=new Set(s);for(const t of vt(e)){const e=o.has(t)?void 0:yt(t);void 0!==e&&n(t,e)}}(n,t,(e,t)=>{!function(e,t,n,r){if(t.warnedIslandStart)return;t.warnedIslandStart=!0;const i="element"===r?"<astro-island>":`client:${n.getAttribute("client")??""}`;e.warn(`[live-preview] LP0809: a fragment island cannot start: this page never loaded ${i}; render one on the page`)}(this.deps,this.state,e,t)})},patch:r=>{const i=u(r);void 0!==i&&(i!==r&&this.host.rebuildCache(),this.patchFallback(e,t,i,n.ownerKeys,l))},rendered:(e,t,n)=>{a(e);const r=u(e)??e;d.emitWhile("fragmentRender",{element:r,id:t,key:n,status:"rendered",revision:h,receivedAt:f},l)},failed:(t,n,s,o,c)=>{a(t);const p=u(t)??t;i.display.shortfall(e,{kind:"fragment",id:n,key:s,code:o});const g=`fragment "${n}" fell back to patch: ${c}`;r.log("fragment",o,g),d.emitWhile("error",{error:new Error(g),context:"fragment",code:o},l),d.emitWhile("fragmentRender",{element:p,id:n,key:s,status:"failed",code:o,revision:h,receivedAt:f},l)}};let g={rendered:0,failed:0,superseded:0};try{g=await n.strategy.render(p,n.boundaries)}catch(t){if(r.log("fragment","LP0801",t),l()){for(const t of n.boundaries)p.patch(t),i.display.shortfall(e,Qe(t));g={rendered:0,failed:n.boundaries.length,superseded:0}}}i.fragmentStats.rendered+=g.rendered,i.fragmentStats.failed+=g.failed,i.fragmentStats.superseded+=g.superseded,i.fragmentControllers.delete(s);for(const e of o)a(e);l()&&(g.rendered>0&&this.host.restoreGuesses(e,t),0===e.pendingFragments&&0===r.scheduler.pendingCount&&i.complete(e),this.host.revealPending(e),l()&&0!==g.rendered&&0!==d.listenerCount("afterUpdate")&&d.emitWhile("afterUpdate",{data:t,updatedCount:g.rendered,durationMs:Date.now()-f,revision:h,receivedAt:f,source:"fragment"},l))}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,!1).catch(e=>{this.routeFailed(e)})}refreshAfterSave(){const{deps:e,state:t}=this,{route:n}=e.strategies,r=t.activeUpdate;t.routeAwaitsSave&&void 0!==n&&void 0!==r?.renderData&&(e.log("route","document saved; refreshing the route"),this.runRoute(r,r.renderData,n,!0).catch(e=>{this.routeFailed(e)}))}routeFailed(e){this.deps.log("route refresh failed:",e)}armRouteRetry(e,t,n,r,i){const{state:s}=this;null!==s.routeRetry&&clearTimeout(s.routeRetry),s.routeRetry=setTimeout(()=>{s.routeRetry=null,s.isCurrent(e)&&this.runRoute(e,t,n,i).catch(e=>{this.routeFailed(e)})},r)}async runRoute(e,t,n,r){const{deps:i,state:s}=this,o=s.routeStats,a=new AbortController;s.routeController?.abort(),s.routeController=a;const l=()=>!a.signal.aborted;let u;try{u=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:a.signal,isCurrent:l,log:(e,t)=>{i.log("route",e,t)},retryAfter:i=>{this.armRouteRetry(e,t,n,i,r)}})}catch(e){i.log("route","LP0801",e),u="failed"}if(!l())return;s.routeController=null;const d=s.activeUpdate;if(null===d)return;const c=d.renderData,h=()=>s.isCurrent(d);if("partial"===u?s.display.shortfall(d,{kind:"route-saved"}):("failed"===u||"superseded"===u||"refused"===u&&null===s.routeRetry)&&s.display.shortfall(d,{kind:"route-failed",outcome:u}),"refreshed"===u||"partial"===u){if(o.refreshes+=1,"partial"===u&&(o.partial+=1),s.routeAwaitsSave="partial"===u&&!r,s.lastAppliedIdentity=/* @__PURE__ */new WeakMap,void 0!==c&&this.host.restoreGuesses(d,c),this.host.rebuildCache(),void 0===c||!h())return;return this.host.reapply(d,c),void(i.emitter.listenerCount("afterUpdate")>0&&i.emitter.emitWhile("afterUpdate",{data:c,updatedCount:i.cache.elementCount,durationMs:Date.now()-d.receivedAt,revision:d.revision.revision,receivedAt:d.receivedAt,source:"route"},h))}"failed"===u?o.failed+=1:"refused"===u&&(o.refused+=1),void 0!==c&&this.host.reapply(d,c)}warnFragmentFallback(e){$i(this.deps,this.state,e)}warnUnsupportedStrategy(e){Li(this.deps,this.state,e)}patchFallback(e,t,n,r,i){if(i())for(const[s,o]of this.deps.cache.entries())for(const a of o){if(a.fragmentBoundary!==n)continue;if(!1!==r&&!ge(a.owner,r))continue;const o=oe(t.fields,a,s,e.locale);void 0!==o&&i()&&this.deps.scheduler.schedule({target:a,value:this.host.transform(a,o,t.fields,i),allFields:t.fields,revision:e.revision,data:t})}}};function Fi(e,t){return!1===t||ge(Ht(e),t)}function Ui(e,t,n,r,i){const s=e.transformValue;if(void 0===s)return n;try{const e=s(t.fieldName,n,{element:t.element,allFields:r},i),o=g(e);if(!i())return n;if(o)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 Mi=/* @__PURE__ */new Set,xi={kind:"merge"},Ei=class{constructor(e,t,n){this.deps=e,this.state=t,t.changes.keepValues="declared"===e.subfieldCoverage,t.display.host=function(e,t){return{outstanding:n=>!n.completed||n.pendingFragments>0||null!==t.routeController||null!==t.routeRetry||e.scheduler.pendingCount>0,report:t=>{"partial"===t.state&&e.a11y?.announcePartial(),e.emitter.emit("revisionDisplay",t)},failed:t=>{e.log("revision display failed:",t)}}}(e,t),this.strategies="undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e,t){return{planFragments:()=>null,escalateUnfaithful:(e,n,r)=>{for(const{fieldName:n}of r)t.display.shortfall(e,{kind:"unfaithful",field:n})},hasUnboundChange:(n,r)=>{if(n.baseline)return!1;const i=Pe(e.cache,n.touched,n.locale,r,Ne(e.subfieldCoverage,t.changes.previousFields,n.renderData?.fields));for(const e of i)J(t,e),t.display.shortfall(n,{kind:"unbound",field:e});return!1},plansRoute:()=>!1,runFragments:()=>Promise.resolve(),refreshRoute:()=>(T("route refreshes"),Promise.resolve()),refreshAfterSave:()=>{},warnFragmentFallback:n=>{T("server-rendered fragments"),$i(e,t,n)},warnUnsupportedStrategy:n=>{Li(e,t,n)}}}(e,t):new Pi(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,r,i)=>Ui(e,t,n,r,i),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}}),this.navigationReplay=new cr(e,t,{schedule:(e,t,n)=>{this.scheduleAllFields(e,t,n)}})}deps;state;strategies;navigationReplay;handleUpdate(e,t,n){const{deps:r,state:i}=this;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);const s=e.data;void 0!==s?void 0!==n&&this.acceptDataUpdate(e,s,t,n,!0):void 0!==e.protocolVersion&&i.protocol.applyVersion(e.protocolVersion,r.log)}handleReplay(e,t,n){const r=e.data;void 0!==r&&this.acceptDataUpdate(e,r,t,n,!1)}reapplyNavigationBindings(e){this.navigationReplay.reapplyBindings(e)}reapplyNavigationIslands(e,t=!1){this.navigationReplay.reapplyIslands(e,t)}acceptDataUpdate(e,t,n,r,i){const{deps:s,state:o}=this,a=i?o.relationships.inspect(e):null,l="string"==typeof e.locale?e.locale:o.locale;let u=o.schema,d=o.schemaIndex;Array.isArray(e.fieldSchemaJSON)&&(u=e.fieldSchemaJSON,d=function(e,t=""){const n=/* @__PURE__ */new Map;return P(e,t,n,!1),P(e,t,n,!0),n}(e.fieldSchemaJSON));const c=o.activeUpdate;if(!o.isRunning()||null!==c&&c.revision.revision>r.revision)return;const h=null===a?null:o.relationships.commit(a),f=c,p={revision:r,message:e,rawData:t,locale:l,schema:u,schemaIndex:d,receivedAt:Date.now(),forceRender:null!==h||ze(f),countsAsUpdate:i,renderData:void 0,fragmentBoundariesRun:/* @__PURE__ */new WeakSet,touched:/* @__PURE__ */new Set,baseline:!1,navigated:!1,invalidated:/* @__PURE__ */new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1};if(o.locale=l,o.schema=u,o.schemaIndex=d,null!==f&&!f.completed&&f.countsAsUpdate&&(o.supersededCount+=1),o.activeUpdate=p,i&&(o.updateCount+=1),o.display.begin(p,r.revision),o.isCurrent(p)&&(s.scheduler.acceptRevision(r),o.isCurrent(p)&&(o.supersedeStrategies(),o.isCurrent(p)&&(null===h||(s.emitter.emitWhile("relationshipUpdate",{detail:h,timestamp:Date.now()},()=>o.isCurrent(p)),o.isCurrent(p)))&&(!i||void 0===e.protocolVersion||(o.protocol.applyVersion(e.protocolVersion,s.log),o.isCurrent(p)))))){if(i&&s.connection.markConnected()){if(s.a11y?.announceConnected(),s.emitter.emit("connect",{origin:n,timestamp:Date.now()}),!o.isCurrent(p))return;if(s.log("connection","disconnected","→","connected"),!o.isCurrent(p))return}this.processUpdate(p).catch(e=>{s.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;if(!i.isCurrent(e))return;if(i.changes.isBaseline&&!n&&"off"!==r.autoBind){if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)T("auto-binding");else{const n=dr(r,i,e,t.fields);!function(e,t,n,r,i,s){if(!s())return 0;const o=performance.now(),a=ar(e.root),l=Yn(n,r);if(!s())return 0;const u=null===a?[]:or(a,l);if(!s())return 0;const d=ur(e,u,i,"on the first message",s);if(!s())return 0;const c=function(e,t){const n=/* @__PURE__ */new Set;for(const{fieldName:e,stamps:r}of t){n.add(e);for(const e of[At,Rt]){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}}(l,d),h=performance.now()-o;s()&&(t.autoBindGuesses=c,t.autoBindSearchMs=h,d.length)}(r,i,t.fields,e.locale,n,()=>i.isCurrent(e))}if(!i.isCurrent(e))return}const s=nt(r.dependencies,r.cache.dependencyMap());if(!i.isCurrent(e))return;const o=i.changes.diff(t.fields,s,()=>i.isCurrent(e));if(null===o)return;const a=!n&&i.navigationReplayPending;a&&(i.navigationReplayPending=!1,i.navigationBindingReplay=!0),e.baseline=o.baseline&&!a,e.navigated=a,e.invalidated=n?Mi:o.invalidated,e.touched=n?Mi:/* @__PURE__ */new Set([...o.changed,...o.invalidated]),e.renderData=t,this.scheduleAllFields(e,t)}async resolveIncomingFields(e){const{deps:t,state:n}=this,r=e.rawData;if(null===t.merger)return r;const i=n.merges.decide(t,e);if(!i.merge)return i.fields;const{message:s}=e,o=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:s.collectionSlug,globalSlug:s.globalSlug,data:r,...void 0===e.schema?{}:{schema:e.schema},locale:e.locale});if(!o.leading)return this.applyMerged(e,o.result).catch(e=>{t.log("update failed:",e)}),i.fields;const a=await o.result;return n.isCurrent(e)?"merged"===a.status?(n.merges.recordMerged(a.doc,e.locale),a.doc):"superseded"===a.status?null:(n.display.shortfall(e,xi),i.fields):null}async applyMerged(e,t){const{state:n}=this,r=await t;"unavailable"===r.status&&n.display.shortfall(e,xi),"merged"===r.status&&n.isCurrent(e)&&(n.merges.recordMerged(r.doc,e.locale),this.applyFields(e,this.dataFor(e,r.doc),!0))}scheduleAllFields(e,t,n){const{deps:r,state:i}=this;if(!i.isCurrent(e))return;const s=void 0!==n,o=()=>i.isCurrent(e),a=dr(r,i,e,t.fields);if(!o())return;const{touched:l}=e,u=r.strategies.route;if(s&&void 0!==u&&!e.routeRefreshed&&this.navigationReplay.hasLateRouteBinding(n,a,e,t))return void(o()&&this.strategies.refreshRoute(e,t,u));const d=!s&&this.strategies.hasUnboundChange(e,a),c=i.routeRefreshOwed;if(!s&&void 0!==u&&!e.routeRefreshed&&(d||c||this.strategies.plansRoute(u,e,a))&&o())return i.routeRefreshOwed=!1,void this.strategies.refreshRoute(e,t,u);const h=s?this.navigationReplay.fieldsForElements(n,l):l,f=this.navigationReplay.unrunFragmentPlan(e,this.strategies.planFragments(h,a),n);if(!o())return;const p=r.skipUnchanged;let g=0;for(const[l,u]of r.cache.entries()){if(!o())return;for(const d of u){if(void 0!==n&&!n.has(d.element))continue;if(!1!==a&&!ge(d.owner,a))continue;if(!0===f?.covers(d)){if(r.revealEditedField){const n=oe(t.fields,d,l,e.locale);i.revealLedger.note(e,d,n)}continue}const u=d.strategyKind??he(d.element)??"unknown";if("unknown"===u){this.strategies.warnUnsupportedStrategy(d);continue}"fragment"===u&&null===f&&this.strategies.warnFragmentFallback(d);const c=oe(t.fields,d,l,e.locale);if(void 0===c){i.absentFields.add(l);continue}if(!s&&r.revealEditedField&&i.revealLedger.note(e,d,c),!o())return;const h=Ui(r,d,c,t.fields,o);if(!o())return;const m=p?ae(d,h,t.fields,e.locale):void 0,v=i.lastAppliedIdentity.get(d.element);if(!e.forceRender&&r.skipUnchanged&&void 0!==m&&v===m&&!e.invalidated.has(l)){i.skippedUnchangedCount+=1;continue}const y={target:d,value:h,allFields:t.fields,revision:e.revision,...s?{}:{data:t},valueIdentity:m};r.scheduler.schedule(y),g+=1}}if(s||function(e,t,n,r,i){const{cache:s,strategies:o}=e,a={warned:t,warn:e.warn};if(0===s.fieldCount)return;if(!1!==i&&!function(e,t){for(const n of e.values())if(ge(n.owner,t))return!0;return!1}(s,i))return;const l=function(e,t,n,r){const i=Le(e,t,n,Ce(e,n,r));return e=>"none"!==i(e)}(s,r,i,o);for(const[e,t]of Object.entries(n)){if(Te.has(e))continue;if(pr(t)){fr(a,l,e,r,t);continue}if(!mr(t)||l(e)||gr(t))continue;const n=$e(e,r);for(const[e,i]of Object.entries(t))pr(i)&&!Te.has(e)&&fr(a,l,`${n}.${e}`,r,i)}if("declared"!==e.subfieldCoverage)return;const u=function(e,t,n,r,i){const s=Ce(e,r,i),o=Le(e,n,r,s),a=[];for(const[e,r]of Object.entries(t)){if(Te.has(e)||"below"!==o(e))continue;const t=$e(e,n);a.push(...Re(t,void 0,r,s))}return a}(s,n,r,i,o);for(const{path:e,value:t}of u)if(pr(t)&&fr(a,l,e,r,t),mr(t)&&!gr(t))for(const[n,i]of Object.entries(t))pr(i)&&fr(a,l,`${e}.${n}`,r,i)}(r,i.warnedOrphanFields,e.rawData,e.locale,a),o()){if(null!==f&&f.boundaries.length>0){for(const t of f.boundaries)e.fragmentBoundariesRun.add(t);e.pendingFragments+=f.boundaries.length,this.strategies.runFragments(e,t,f)}!s&&o()&&0===g&&(0===e.pendingFragments&&0===r.scheduler.pendingCount&&(i.complete(e),this.revealPending(e)),this.notifyIslands(e,t))}}notifyIslands(e,t){0!==e.touched.size&&this.navigationReplay.dispatchIslands(e,t,this.deps.cache.islands)}restoreGuesses(e,t){const{deps:n,state:r}=this;if("off"!==n.autoBind&&null!==r.autoBindGuesses&&("undefined"==typeof __LEAN_BUILD__||!__LEAN_BUILD__)){const i=dr(n,r,e,t.fields);!function(e,t,n,r,i,s){if(!s())return 0;const o=t.autoBindGuesses,a=ar(e.root);if(null===o||0===o.fields.size||null===a)return 0;const l=new Map(o.values);for(const[e,t]of Yn(n,r)){if(null===t||!o.fields.has(t.field))continue;const n=l.get(e);void 0===n?l.set(e,t):n?.field!==t.field&&l.set(e,null)}if(!s())return 0;const u=or(a,l);s()&&ur(e,u,i,"after a server render",s).length}(n,r,t.fields,e.locale,i,()=>r.isCurrent(e))}}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 s=n.activeUpdate;if(null===s||!n.isCurrent(s)||!m(s.revision,r))return;n.display.deferred(s,e.deferred),0===s.pendingFragments&&n.complete(s);const o=()=>n.isCurrent(s)&&m(s.revision,r),a=i??s.renderData;if(this.revealPending(s),!o())return;const l=n.unfaithfulPatches;if(l.length>0){if(n.unfaithfulPatches=[],void 0!==a){const e=dr(t,n,s,a.fields);this.strategies.escalateUnfaithful(s,a,l,e)}if(!o())return}void 0!==i&&(e.applied>0&&t.a11y?.announceUpdate(e.applied),o()&&(this.notifyIslands(s,i),o()&&0!==e.applied&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:i,updatedCount:e.applied,durationMs:e.durationMs,revision:r.revision,receivedAt:s.receivedAt,source:"patch"},o)))}revealPending(e){const t=this.state.revealLedger.commit(e);if(void 0!==t)try{Ve(this.state.revealer,t)}catch(e){this.deps.log("reveal",e)}}revealField(e){const t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":Ve(this.state.revealer,t)}documentSaved(){this.strategies.refreshAfterSave()}},Oi=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;frameFallback=null;frameToken=0;windowUntil=0;activeRevision=null;activeRevisionCancelled=!1;destroying=!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(this.destroying)return;if(void 0!==e.revision){if(this.activeRevisionCancelled)return;if(null===this.activeRevision||!m(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;this.destroying||null!==this.activeRevision&&m(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.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1,this.cancelScheduledWork())}cancelRevision(e){null!==this.activeRevision&&m(e,this.activeRevision)&&(this.clearWork(),this.activeRevisionCancelled=!0,this.cancelScheduledWork())}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(){if(!this.destroying){this.destroying=!0;try{this.clearWork(),this.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0,this.cancelScheduledWork()}finally{this.destroying=!1}}}get pendingCount(){return this.pending.size}get replayCount(){return this.replay.size}get gateThreshold(){return this.gateThresholdValue}get gateActive(){return!this.gateDisabled&&this.getCacheSize()>this.gateThresholdValue}armDebounce(){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,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1;const r=()=>{if(this.frameToken!==e||n)return;n=!0;const t=this.frameHandle;this.frameHandle=null,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.flush()},i=this.scheduleFrame(r);n||this.frameToken!==e||(this.frameHandle=i,this.frameFallback=setTimeout(r,100))}clearFrameFallback(){clearTimeout(this.frameFallback??void 0),this.frameFallback=null}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 s,o=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)||Ii(e.target);this.isCurrent(e)&&(s??=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),o+=1))}}finally{this.activeFlushes.delete(n)}const a=this.statsFor(s,r,o,performance.now()-e,i);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&m(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||(t=this.apply,!Y.has(t));var t}retargetBuffer(e,t){const n=e.get(t.element);void 0!==n&&(Gt(n.target,t)?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(),this.clearFrameFallback(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}};function Ii(e){if(!0!==e.hidesWhenEmpty)return!1;const{element:t}=e;if(t.hasAttribute("hidden"))return!0;const n=t.getBoundingClientRect();return 0===n.width||0===n.height}var Di=[0,500,1e3,2e3],_i=class{deps;state=new Xe;pipeline;writer;rootSentinel=null;scope=null;closingSession=!1;observedRoot=null;replayRetainedOnStart=!1;constructor(e){const{emitter:t,renderers:n}=e,r=void 0===e.log?b:y(e.log),i=void 0===e.warn?S:y(e.warn),s=e.root??("undefined"!=typeof document?document:void 0);if(void 0===s)throw new Error("LivePreviewRuntime: no document; pass options.root");const o=new Kt({filter:e=>!function isInsideIsland(e){let t=e;for(;null!==t;){if(ut(t))return!0;t=t.parentElement}return!1}(e)}),a=new Rn({onStructuralChange:()=>{this.rebuildCache()},onIslandHydrated:e=>{this.pipeline.reapplyNavigationIslands([e],!0)},onVisibilityChange:(e,t)=>{t&&l.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),l=new Oi(ee(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:()=>o.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),u=new v(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onReplay:(e,t,n)=>{this.pipeline.handleReplay(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],r),t.emit("documentSave",{timestamp:Date.now()}),this.pipeline.documentSaved()},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:o,observers:a,scheduler:l,bus:u,connection:new qn,heartbeat:new Wn({...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:s,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:/* @__PURE__ */(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??$,onHeartbeatTimeout:e.onHeartbeatTimeout,log:r,warn:i,a11y:C(e),serverURL:d?.serverURL,merger:void 0===d?null:new mn({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,subfieldCoverage:e.subfieldCoverage??"descendant",lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:G(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new Ze(this.deps,this.state),this.pipeline=new Ei(this.deps,this.state,()=>{this.rebuildCache()})}start(){const{state:e}=this;if(e.isRunning()||this.closingSession)return!1;e.suspended&&(this.replayRetainedOnStart=!0),e.started=!0,e.suspended=!1,this.openScope();try{return function(e){"react"===e.hydration?Pn():"vue"===e.hydration&&In();const{root:t}=e;if(!zn(t)||"loading"!==t.readyState)return void Dn(e);const n=()=>{e.isRunning()&&e.later(()=>{Dn(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,this.scope?.own(()=>{e.deferredStart===t&&(e.deferredStart=null,t())})},later:t=>{e.deferredStart=null;try{t()}catch(e){this.rollbackFailedStart(),this.reportError(e,"startup","LP0605")}},hydrated:t=>{e.hydration=t},warn:t.warn,startNow:()=>{this.startNow()}}}startNow(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=zn(t.root)?Hn(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())return;if(t.bus.attach(),t.emitter.emitWhile("init",{timestamp:Date.now()},()=>e.isRunning()),!e.isRunning())return;const r=this.replayRetainedOnStart;this.replayRetainedOnStart=!1;const i=r&&t.heartbeat.resume();if(e.isRunning()&&(!r||i||(e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=/* @__PURE__ */new WeakMap,e.changes.reset(),e.navigationReplayPending=!0,t.bus.replayLastAccepted()||(e.navigationReplayPending=!1),e.isRunning())))for(const n of Di){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,this.replayRetainedOnStart=!1,t.bus.forgetLastAccepted(),n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}openScope(){const{state:e,deps:t}=this,n=new $n(t.log);n.own(()=>{t.merger?.destroy(),e.merges.destroy()}),n.own(()=>{t.scheduler.destroy()}),n.own(()=>{t.observers.stop()}),n.own(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),n.own(()=>{e.abortStrategies()}),n.own(()=>{t.bus.detach()}),n.own(()=>{t.heartbeat.stop()}),n.own(()=>{for(const t of e.readyTimers)clearTimeout(t);e.readyTimers.length=0}),this.scope=n}release(){const{state:e,deps:t}=this;e.display.end(),e.activeUpdate=null,e.navigationBindingReplay=!1,e.started=!1;const n=this.scope;this.scope=null,this.closingSession=!0;try{n?.close()}finally{this.closingSession=!1}return t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release();try{this.deps.a11y?.detach()}catch(e){this.deps.log("runtime cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}navigationCommit(){const{state:e,deps:t}=this;e.isRunning()&&null===e.deferredStart&&(this.cancelActiveUpdate(!0),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!0),e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=/* @__PURE__ */new WeakMap,e.changes.reset(),e.isRunning()&&(t.bus.advanceGeneration(),e.navigationReplayPending=!0,this.followReplacedRoot()||this.rebuildCache(),e.isRunning()&&(t.bus.replayLastAccepted(),e.isRunning()&&this.sendReadyAfterStart())))}watchRootReplacement(){const{root:e}=this.deps;zn(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()||!zn(e))return!1;const t=Hn(e);return null!==t&&t!==this.observedRoot&&(this.observedRoot=t,this.deps.observers.start(t),this.rebuildCache(),!0)}get status(){return this.deps.connection.status}get cache(){return this.deps.cache}get updateCount(){return this.state.updateCount}get protocol(){return this.state.protocol.negotiation}inspect(){return function(e,t){const{cache:n,scheduler:r}=e,i=t.protocol.negotiation,s=t.activeUpdate,o=t.lastFlush,a=[],l=/* @__PURE__ */new Set,u=[];for(const[e,t]of n.entries()){a.push(e);for(const n of t)void 0!==n.owner&&l.add(n.owner),void 0!==n.guessed&&u.push({field:e,matched:n.guessed,attribute:n.targetAttribute??("IMG"===n.element.tagName?"src":void 0)})}return{version:vn,started:t.started,status:e.connection.status,origins:{trusted:[...e.readyTargets()],locked:e.lockedOrigin()},protocol:{ours:i.ours,theirs:i.theirs,negotiated:i.negotiated,capabilities:[...i.capabilities].sort(),observed:[...i.observed].sort(),profile:(d=i.observed,d.has("schema-json")?yn:d.has("document-events")||d.has("relationship-events")?bn:wn).name},revisions:{accepted:t.updateCount,superseded:t.supersededCount,completed:t.completedCount,skippedUnchanged:t.skippedUnchangedCount,active:null===s?void 0:s.revision.revision,display:t.display.snapshot()},bindings:{elements:n.elementCount,fields:n.fieldCount,fieldNames:a.sort(),absentFields:[...t.absentFields].sort(),orphanFields:[...t.warnedOrphanFields].sort(),ownerScoped:e.scopeBindingsByOwner,owners:[...l].sort(),guessed:u.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:e.autoBind,searchMs:t.autoBindSearchMs}},route:{handler:void 0!==e.strategies.route,...t.routeStats},fidelity:{mode:e.onUnfaithfulPatch,canEscalate:void 0!==e.strategies.fragment||void 0!==e.strategies.route,unfaithful:t.unfaithfulCount,escalated:t.escalatedCount,fields:[...t.unfaithfulFields].sort()},hydration:{mode:e.hydration??"off",state:t.hydration},fragments:{handler:void 0!==e.strategies.fragment,inFlight:s?.pendingFragments??0,...t.fragmentStats},scheduler:{pending:r.pendingCount,deferred:r.replayCount,visibilityGateThreshold:r.gateThreshold,visibilityGateActive:r.gateActive,lastFlush:null===o?void 0:{applied:o.applied,appliedFields:o.appliedFields,deferred:o.deferred,durationMs:o.durationMs}},plugins:[],renderers:Object.keys(e.renderers).sort()};var d}(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,r=t.cache.islandOwners,i=new Set(t.cache.navigationReplayRoots);for(const e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),!e.isRunning())return;const s=new Set(t.cache.navigationReplayRoots.filter(e=>!i.has(e)));for(const e of t.cache.values()){const r=n.get(e.element);void 0!==r&&Gt(r,e)?t.scheduler.retarget(e):(t.scheduler.forget(e.element),s.add(e.element)),n.delete(e.element)}for(const e of n.values())t.scheduler.forget(e.element);s.size>0&&this.pipeline.reapplyNavigationBindings(s);const o=t.cache.islands.filter(e=>!r.has(e)||t.scopeBindingsByOwner&&r.get(e)!==t.cache.islandOwners.get(e));o.length>0&&this.pipeline.reapplyNavigationIslands(o)}onHeartbeatTimeout(){const{state:e,deps:t}=this;if(!e.isRunning())return;if(this.cancelActiveUpdate(!1),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!1),!e.isRunning())return;t.bus.advanceGeneration(),t.bus.forgetLastAccepted(),e.navigationBindingReplay=!1;const n=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}if(e.isRunning()){if(n&&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()}}cancelActiveUpdate(e){const{state:t,deps:n}=this,r=t.activeUpdate;t.display.end(),t.activeUpdate=null,null!==r&&(r.cancelled=!0,n.scheduler.cancelRevision(r.revision),e&&!r.completed&&r.countsAsUpdate&&(t.supersededCount+=1))}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}},EventEmitter=class{#s=/* @__PURE__ */new Map;#o=/* @__PURE__ */new Map;on(e,t){return this.#a(this.#s,e,t)}once(e,t){return this.#a(this.#o,e,t)}off(e,t){this.#l(this.#s,e,t),this.#l(this.#o,e,t)}async emit(e,t){await this.#u(e,t)}async emitWhile(e,t,n){return this.#u(e,t,n)}async#u(e,t,n){const r=()=>n?.()??!0;if(!r())return!1;const i=this.#s.get(e);if(i)for(const n of[...i]){if(!r())return!1;if(await this.#d(n,t,e),!r())return!1}if(!r())return!1;const s=this.#o.get(e);if(s&&s.size>0){const n=[...s];this.#o.delete(e);for(const i of n){if(!r())return!1;if(await this.#d(i,t,e),!r())return!1}}return r()}listenerCount(e){return(this.#s.get(e)?.size??0)+(this.#o.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#s.clear(),void this.#o.clear();this.#s.delete(e),this.#o.delete(e)}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#s.keys())e.add(t);for(const t of this.#o.keys())e.add(t);return[...e]}#a(e,t,n){let r=e.get(t);return r||(r=/* @__PURE__ */new Set,e.set(t,r)),r.add(n),()=>{this.#l(e,t,n)}}#l(e,t,n){const r=e.get(t);void 0!==r&&(r.delete(n),0===r.size&&e.delete(t))}async#d(e,t,n){try{await e(t)}catch(e){const t="string"==typeof n||"number"==typeof n?String(n):"<event>";w(`[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 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 Bi=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,ji=/^https?:\/\/[^/?#\s]+$/i,zi=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function Hi(){if("undefined"==typeof location)return;const e=location.ancestorOrigins;return e?.[0]}var OriginDetector=class{#c;constructor(e={}){const t=/* @__PURE__ */new Set;for(const n of e.additionalOrigins??[]){const e=Wi(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.#c=[t,n,r,void 0!==n,void 0,Hi()]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#c[4]?e===this.#c[4]:!!this.#c[0].has(e)||0===this.#c[0].size&&void 0!==this.#c[1]&&e===this.#c[1]||!(!this.#c[2]||!Bi.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#c[4]=e,!0)}unlockOrigin(){const e=this.#c[4];return this.#c[4]=void 0,e}get lockedOrigin(){return this.#c[4]}enumerate(){if(void 0!==this.#c[4])return[this.#c[4]];const e=new Set(this.#c[0]);0===this.#c[0].size&&void 0!==this.#c[1]&&e.add(this.#c[1]);const t=this.#c[5];if(this.#c[2]&&void 0!==t)Bi.test(t)&&e.add(t);else if(this.#c[2])for(const t of zi)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#c[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#c[0].size>0||this.#c[2]||void 0!==this.#c[1])}get isReferrerOnlyTrust(){return!(this.#c[0].size>0||this.#c[2]||void 0===this.#c[1])}};function Wi(e){const t=e.trim();if(0!==t.length)try{const e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return;if(!ji.test(e.origin))return;return e.origin}catch{return}}var qi=()=>{},Vi=class{#h;#n;#f=/* @__PURE__ */new Set;#c="staging";constructor(e,t){this.#h=e,this.#n=t}assertOpen(){if("closed"===this.#c)throw new Error(`Plugin context for "${this.#h}" is no longer active`)}get active(){return"active"===this.#c}eligible(){return"closed"!==this.#c}own(e){return this.assertOpen(),this.#p({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.#p(r);if("active"===this.#c)try{this.#g(r)}catch(e){throw this.#m(r),e}return i}counts(){const e={transform:0,renderer:0,subscription:0,cleanup:0};for(const t of this.#f)e[t.kind]+=1;return e}commit(){if("staging"!==this.#c)throw new Error(`Plugin context for "${this.#h}" cannot be committed`);this.#c="committing";try{for(const e of this.#f)this.#g(e);this.#c="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#c){this.#c="closed";for(const e of[...this.#f].reverse())this.#m(e);this.#f.clear()}}#p(e){return this.#f.add(e),()=>{this.#m(e)}}#g(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;const t=e.acquire();e.cleanup=t??qi}#m(e){if(e.disposed)return;e.disposed=!0,this.#f.delete(e);const t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{g(t())&&this.#n(`plugin "${this.#h}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#n(`plugin "${this.#h}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#n(`plugin "${this.#h}" cleanup failed:`,e)}}},Gi=class{#v;#y;#b=/* @__PURE__ */new Set;constructor(e,t){this.#v=e,this.#y=t}on(e,t){return this.#w("on",e,t)}once(e,t){return this.#w("once",e,t)}off(e,t){const n=t;for(const t of[...this.#b])t.event===e&&t.handler===n&&t.dispose()}emit(e,t){return this.#y.assertOpen(),this.#v.emit(e,t)}emitWhile(e,t,n){return this.#y.assertOpen(),this.#v.emitWhile(e,t,()=>{if(!this.#y.eligible())return!1;const e=n();return!!this.#y.eligible()&&e})}listenerCount(e){let t=0;for(const n of this.#b)n.event===e&&(t+=1);return t}removeAllListeners(e){for(const t of[...this.#b])void 0!==e&&t.event!==e||t.dispose()}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#b)e.add(t.event);return[...e]}#w(e,t,n){this.#y.assertOpen();const r=n,i=[...this.#b].find(n=>n.kind===e&&n.event===t&&n.handler===r);if(void 0!==i)return i.dispose;let s=qi,o=!0;const a=async t=>{this.#y.active&&o&&("once"===e&&s(),await n(t))},l={kind:e,event:t,handler:r,dispose:qi};return s=this.#y.stage("subscription",()=>this.#v[e](t,a),()=>{o=!1,this.#b.delete(l)}),l.dispose=s,this.#b.add(l),s}},Ki=class{#v;#S;#A;#k;#n;#R=/* @__PURE__ */new Map;#T=/* @__PURE__ */new Map;#C=/* @__PURE__ */new Map;#$=/* @__PURE__ */new Set;#L=/* @__PURE__ */new Map;#N=Promise.resolve();#P=0;constructor(e){this.#v=e.events,this.#S=e.config,this.#A=e.registerFieldRenderer,this.#n=y(e.log);const t=e.onTransformError;this.#k=void 0===t?void 0:y((...e)=>{const n=e[0];try{return t(n)}catch(e){return void this.#n("transform error reporter failed:",e)}})}register(e){return this.#P>0?this.#F(e,!1):this.#U(()=>this.#F(e,!0))}unregister(e){return this.#P>0?this.#M(e,!1):this.#U(async()=>{await this.#M(e,!0)})}destroyAll(){return this.#P>0?this.#x(!1):this.#U(async()=>{await this.#x(!0)})}applyTransforms(e,t,n,r){const i=this.#L.get(e);if(void 0===i||0===i.length)return t;let s=t;for(const o of[...i]){if(!o.active)continue;const{transform:i}=o;if(!1===r?.())return t;try{s=i(s,{fieldName:e,element:n.element,allFields:n.allFields});const o=g(s);if(!1===r?.())return t;if(o)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.#n(`transform for "${e}" failed:`,i),this.#k?.(i),t}}return s}list(){return[...this.#R.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.#T)e.push(t(n,void 0,"initializing",r.scope));for(const[n,r]of this.#R)e.push(t(n,r.plugin.version,"active",r.scope));for(const t of this.#C.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.#R.size}async#F(e,t){if(this.#R.has(e.name)||this.#T.has(e.name)||this.#C.has(e.name))return void this.#n(`plugin "${e.name}" already registered`);const n=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]??"=",s=[Number(r[2]),Number(r[3]),Number(r[4])],o=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,s);switch(i){case"=":return 0===o;case">":return o>0;case">=":return o>=0;case"<":return o<0;case"<=":return o<=0;case"~":return o>=0&&e[0]===s[0]&&e[1]===s[1];case"^":return!(o<0)&&(s[0]>0?e[0]===s[0]:s[1]>0?0===e[0]&&e[1]===s[1]:0===e[0]&&0===e[1]&&e[2]===s[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)}`}}}(e.compat,vn);if(void 0!==n)return void this.#E(e.name,n);const r=new Vi(e.name,this.#n),i=this.#O(e.name,r),s={scope:r,cancelled:!1};this.#T.set(e.name,s);try{if(await this.#I(()=>e.init(i),t),s.cancelled)return;r.commit()}catch(t){return r.close(),void(s.cancelled||this.#n(`plugin "${e.name}" init failed:`,t))}finally{this.#T.get(e.name)===s&&this.#T.delete(e.name)}this.#R.set(e.name,{plugin:e,scope:r}),this.#n(`plugin "${e.name}" registered`)}#E(e,t){const n=`plugin "${e}" refused: ${t}`;this.#n(n),this.#v.emit("error",{error:new Error(n),context:"plugin",code:"LP0103"})}#O(e,t){return{events:new Gi(this.#v,t),registerFieldRenderer:e=>{t.stage("renderer",()=>{const t=this.#A(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.#L.get(e);return void 0===t?this.#L.set(e,[r]):t.push(r),()=>{r.active=!1;const t=this.#L.get(e);if(void 0===t)return;const n=t.indexOf(r);n>=0&&t.splice(n,1),0===t.length&&this.#L.delete(e)}})},registerCleanup:e=>{t.own(e)},getConfig:()=>this.#S,log:(...t)=>{this.#n(`[${e}]`,...t)}}}#M(e,t){const n=this.#T.get(e);if(void 0!==n)return n.cancelled=!0,n.scope.close(),Promise.resolve();const r=this.#C.get(e);if(void 0!==r)return this.#$.has(e)?Promise.resolve():t?this.#D(r):r;const i=this.#R.get(e);if(void 0===i)return Promise.resolve();this.#R.delete(e),i.scope.close();const s=Promise.resolve().then(()=>this.#_(e,i.plugin,t));return this.#C.set(e,s),s.then(()=>{this.#C.get(e)===s&&this.#C.delete(e)}),s}async#_(e,t,n){if(void 0!==t.destroy){this.#$.add(e);try{await this.#I(()=>t.destroy?.(),n)}catch(t){this.#n(`plugin "${e}" destroy failed:`,t)}finally{this.#$.delete(e)}}}async#x(e){for(const e of this.#T.values())e.cancelled=!0,e.scope.close();const t=[...this.#R.keys()];for(const n of t)await this.#M(n,e)}async#I(e,t){t?await this.#D(Promise.resolve().then(e)):await e()}async#D(e){this.#P+=1;try{await e}finally{this.#P-=1}}#U(e){const t=this.#N.then(e);return this.#N=t.catch(e=>{this.#n("plugin manager mutation failed:",e)}),t}},Ji=class{#B;#j;#z=/* @__PURE__ */new Map;constructor(e){this.#B=e,this.#j={...e}}get renderers(){return this.#j}resolve(e){return this.#j[e]}register(e){const t=e.name,n={renderer:e},r=this.#z.get(t);void 0===r?this.#z.set(t,[n]):r.push(n),this.#j[t]=e;let i=!0;return()=>{if(!i)return;i=!1;const e=this.#z.get(t);if(void 0===e)return;const r=e.indexOf(n);if(r<0)return;const s=r===e.length-1;if(e.splice(r,1),0===e.length&&this.#z.delete(t),!s)return;const o=e.at(-1),a=o?.renderer??this.#B[t];void 0===a?Reflect.deleteProperty(this.#j,t):this.#j[t]=a}}},Qi={1:"left",2:"center",3:"right",4:"justify"},Xi=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function Zi(e){const t=e.format;return"string"==typeof t&&Xi.has(t)?t:"number"==typeof t?Qi[t]:void 0}function Yi(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function es(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function ts(e){const t=Zi(e),n=Yi(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 ns=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function rs(e){return"object"==typeof e&&null!==e?e:void 0}function is(e){return rs(e)}function ss(e,t){if(void 0===t||""===t||!e.startsWith("/"))return e;try{const n=new URL(t),r=new URL(e,n);return r.origin===n.origin?r.href:e}catch{return e}}function os(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function as(e){return"string"==typeof e&&e.length>0?e:void 0}function ls(e){const t=as(e.title)??as(e.name)??as(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}var us=' target="_blank" rel="noopener noreferrer"',ds=(e,t)=>{const n=t.renderChildren(e.children??[]),r=rs(e.fields),i=function(e,t){if("internal"===t?.linkType)return function(e){const t=rs(rs(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 s="string"==typeof e.title?` title="${escapeHtml(e.title)}"`:"";return`<a href="${escapeHtmlAttribute(i)}"${function(e,t,n){if(!0===t?.newTab||isExternalHttpUrl(n))return us;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?us:` target="${escapeHtml(r)}"`}(e,r,i)}${s}>${n}</a>`};function cs(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=cs(n);return t}function hs(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function fs(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var ps=/* @__PURE__ */new Map;function gs(e){return ps.get(e)}var ms=".lp-block:empty,.lp-inline-block:empty";function vs(e,t,n,r){const i=rs(e.fields)??{},s="string"==typeof i.blockType?i.blockType:"",o=os(s),a=""===o?r:`${r} ${r}--${o}`;if(""!==s){const e=gs(s)??gs(o);if(e)return e(i,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(s,a)}return`<${n} class="${a}"></${n}>`}function ys(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var bs={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${es(e)}${ts(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=ns.has(n)?n:"h2",i=t.renderChildren(e.children??[]);return`<${r}${es(e)}${ts(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)}"`:"",s="check"===n?' role="list"':"",o=t.renderChildren(e.children??[]);return`<${r}${es(e)}${ts(e)}${i}${s}>${o}</${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"}"${ts(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${es(e)}${ts(e)}${r}>${n}</li>`},link:ds,autolink:ds,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${es(e)}${ts(e)}>${n}</blockquote>`},code:e=>{const t=os("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(cs(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${os(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=is(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${hs(e)}><source src="${escapeHtmlAttribute(t)}"${fs(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${fs(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}"${hs(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=rs(e.value),r=escapeHtml((n&&ls(n))??`#${t}`),i=os(t),s=""===i?' class="lp-relation"':` class="lp-relation lp-relation--${i}"`,o=n?.url;return"string"==typeof o&&isSafeUrl(o)?`<a href="${escapeHtmlAttribute(o)}"${s}>${r}</a>`:`<span${s}>${r}</span>`},block:(e,t)=>vs(e,t,"div","lp-block"),inlineBlock:(e,t)=>vs(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${es(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"':""}${ys("colspan",e.colSpan)}${ys("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},ws=/* @__PURE__ */new Map,Ss=!1;function As(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 ks(e,t){const n=(r=e.type,ws.get(r)??bs[r]);var r;return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function Rs(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+=Rs(n);return t}function Ts(e="text"){const t=/* @__PURE__ */new WeakSet;return{name:e,render:/* @__PURE__ */ee((e,n)=>{const r=e.element,i=function(e){return null==e?"":As(e)?As(t=e)?t.root.children.map(Rs).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){if(r.textContent.trim()!==i.trim())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),S(`[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=yr(function(e){return escapeHtml(e).replace(/\r\n|\r|\n/g,"<br>")}(i)):r.textContent=i)}else r.value=i})}}var Cs=/* @__PURE__ */new Set,$s=/* @__PURE__ */new Set,Ls=/* @__PURE__ */new Set(["DIV","SECTION","ARTICLE"]),Ns={name:"richText",render:/* @__PURE__ */ee((e,t,n)=>{const r=e.element;if(ri(t))return void(r.textContent="");const i=n.sanitizerPolicy;if(void 0!==n.renderRichText){const s=n.renderRichText(t,{fieldName:e.fieldName,element:r,locale:n.locale});return void(r.innerHTML=yr(Br(s,i)))}if(As(t)){if(et(t))return void(r.textContent="");const s=/* @__PURE__ */new Map,o=function(e,t){const n=e.cloneNode(!1);n.innerHTML=yr(t);const r=function(e,t){const n=e.firstElementChild,r=1===t.children.length?t.firstElementChild:null;if(null!==n?.nextElementSibling||0===t.children.length)return null;if(!Ls.has(n.tagName)||n.hasAttribute(bt))return null;if(r?.tagName===n.tagName||!0===r?.matches(ms))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,s=n.querySelectorAll(ms);if(s.length>0&&null!==r.firstElementChild){const e=[];Ps(r,n,e);for(const[t,n]of e)t.replaceWith(n),n.matches(ms)||i.set(t.className,!1);for(const e of s)null!==e.parentNode&&i.set(e.className,!0)}return r.replaceChildren(...n.childNodes),i}(r,Br(function(e,t={}){if(!As(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=ks(r,t);return n},resolveAlignment:Zi,resolveIndent:Yi,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==t.document?sanitizeHtml(n,{document:t.document}):!0===t.requireDocument||void 0!==Hr()?sanitizeHtml(n):(function(){if(!Ss){Ss=!0;try{console.warn('[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; pass { document } (linkedom, jsdom) per call. 3.0 throws here instead: opt in now with { requireDocument: true }. See "HTML sanitization" in docs/security.md.')}catch{}}}(),n)}(t,{sanitize:!1,onUnrenderedBlock:(e,t)=>{s.set(t,e)}}),i));for(const[t,r]of o){const i=s.get(t);void 0!==i&&Fs(e,n,i,r)}return}if("string"!=typeof t)return!1;r.innerHTML=yr(Br(t,i))})};function Ps(e,t,n){const r=(e,t)=>{e.matches(ms)?n.push([e,t]):Ps(t,e,n)};let i=e.firstElementChild,s=t.firstElementChild;if(e.children.length===t.children.length){for(;null!==i&&null!==s;i=i.nextElementSibling)r(s,i),s=s.nextElementSibling;return}const o=/* @__PURE__ */new Set;for(const e of t.children)e.matches(ms)||o.add(e.tagName);const a=(e,t)=>e.matches(ms)?!o.has(t.tagName):e.tagName===t.tagName;let l=0;for(;null!==i&&null!==s&&a(s,i);l+=1)r(s,i),i=i.nextElementSibling,s=s.nextElementSibling;const u=Math.min(e.children.length,t.children.length);i=e.lastElementChild,s=t.lastElementChild;for(let e=l;e<u&&null!==i&&null!==s;e+=1){if(!a(s,i))return;r(s,i),i=i.previousElementSibling,s=s.previousElementSibling}}function Fs(e,t,n,r){r&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);const i=r?$s:Cs;i.has(n)||(i.add(n),S(`[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 Us={name:"html",render(e,t,n){if(ri(t))return void(e.element.textContent="");const r="string"==typeof t?t:ni(t);e.element.innerHTML=yr(Br(r,n.sanitizerPolicy))}},Ms=/* @__PURE__ */new WeakSet;function xs(e,t,n,r){if("string"!=typeof n||0===n.length)return{kind:"none"};const i=ss(n,r);return isSafeUrl(i)?{kind:"safe",url:i}:(Ms.has(e)||(Ms.add(e),S(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function Es(e,t=e=>e){return{name:e,render(e,n,r){const i=e.element;if(ri(n))return void function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(i);const s=ni(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName){if("A"===i.tagName){const n=e.hrefField,o=void 0===n||0===n.length?t(s):ie(r.allFields,n,r.locale,void 0!==e.locale),a=xs(i,e.fieldName,o);"safe"===a.kind?i.setAttribute("href",a.url):"unsafe"===a.kind&&i.removeAttribute("href")}i.textContent=s}else i.value=s}}}var Os=Es("url"),Is=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,Ds=Es("email",function(e){const t=e.trim();return Is.test(t)||!t.includes("@")?t:`mailto:${t}`}),_s=["src","srcset","sizes"],Bs=/* @__PURE__ */new WeakMap;function js(e){for(const t of _s)e.removeAttribute(t)}function zs(e,t,n,r){const i=function(e,t){const n=[];for(const[r,i]of Object.entries(e?.sizes??{})){if("string"!=typeof i.url||"number"!=typeof i.width)continue;const e=ss(i.url,t);isSafeUrl(e)&&n.push({...i,name:r,url:e,width:i.width})}return n}(n,r),s=e.getAttribute("src"),o=i.find(t=>null!==s&&function(e,t,n){try{return new URL(t,e.baseURI).href===new URL(n,e.baseURI).href}catch{return t===n}}(e,t.url,s))??i.find(t=>t.name===Bs.get(e));void 0===o?.name?Bs.delete(e):Bs.set(e,o.name),e.src=o?.url??t;const a=o??n,l=i.filter(e=>Hs(e,a));if(0===l.length)return e.removeAttribute("srcset"),void e.removeAttribute("sizes");if("number"==typeof n?.width&&"string"==typeof n.url){const e=ss(n.url,r),t={...n,url:e,width:n.width};isSafeUrl(e)&&Hs(t,a)&&l.push(t)}const u=/* @__PURE__ */new Set,d=[];for(const e of l)u.has(e.width)||(u.add(e.width),d.push(`${Ws(e.url)} ${String(e.width)}w`));const c=d.join(", ");e.setAttribute("srcset",c)}function Hs(e,t){if(void 0===t)return!0;if("string"==typeof e.mimeType&&"string"==typeof t.mimeType&&e.mimeType!==t.mimeType)return!1;const{width:n,height:r}=t;return"number"!=typeof n||"number"!=typeof r||"number"!=typeof e.width||"number"!=typeof e.height||Math.abs(e.width*r-e.height*n)<=Math.max(n,e.width)}function Ws(e){return e.replace(/[\s,]/g,encodeURIComponent)}var qs=/^\S*[/.:]\S*$/,Vs={name:"image",render:/* @__PURE__ */ee((e,t,n)=>{const r=e.element;if("IMG"===r.tagName&&e.altField===e.fieldName&&void 0===e.srcField&&("string"==typeof t||ri(t)))return void(r.alt=t??"");if(ri(t))return void Gs(r);const i=void 0!==e.locale,{media:s,candidate:o}=function(e,t,n,r){const i=void 0!==e.srcField&&e.srcField.length>0?ie(n.allFields,e.srcField,n.locale,r):t,s=is(i);return{media:s,candidate:void 0===s?i:s.url}}(e,t,n,i);if(void 0===s&&"string"==typeof o&&!qs.test(o.trim()))return!1;const a=xs(r,e.fieldName,o,void 0===s?void 0:n.serverURL);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===r.tagName){const t=r;zs(t,a.url,s,n.serverURL);const o=function(e,t,n,r,i){if(void 0!==t&&t.length>0){const e=ie(n,t,r,i);return"string"==typeof e?e:void 0}return e?.alt}(s,e.altField,n.allFields,n.locale,i);return void(void 0!==o&&(t.alt=o))}r.style.backgroundImage=`url('${function(e){return e.replace(/['"()\\]/g,"\\$&")}(a.url)}')`}else Gs(r)})};function Gs(e){"IMG"===e.tagName?js(e):e.style.backgroundImage=""}var Ks={name:"upload",render:/* @__PURE__ */ee((e,t,n)=>{const r=e.element;if(ri(t))return void Js(r);const i=is(t);if(void 0===i)return!1;const s=xs(r,e.fieldName,i.url,n.serverURL);if("none"===s.kind)return!1;if("unsafe"===s.kind)return void Js(r);const o=s.url;if("IMG"===r.tagName){const e=r;return zs(e,o,i,n.serverURL),void(void 0!==i.alt&&(e.alt=i.alt))}if("A"===r.tagName)return r.setAttribute("href",o),void(r.textContent=i.filename??o);const a=escapeHtml(i.filename??o);r.innerHTML=yr(`<a href="${escapeHtmlAttribute(o)}">${a}</a>`)})};function Js(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):js(e)}var Qs={name:"relationship",render(e,t){const n=e.element;if(ri(t))return n.removeAttribute("href"),void(n.textContent="");if("A"===n.tagName&&!Array.isArray(t)){const r=xs(n,e.fieldName,rs(t)?.url);"safe"===r.kind?n.setAttribute("href",r.url):"unsafe"===r.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(Xs).join(", "):Xs(t)}};function Xs(e){const t=rs(e);return void 0===t?ni(e):ls(t)??""}var Zs={name:"select",render(e,t,n){const r=e.element,i=ri(t)?[]:function(e){return Array.isArray(e)?e.map(ni):[ni(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=rs(t);if(void 0!==n&&ni(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)}},Ys=/* @__PURE__ */new Set(["","false","0","off","no"]),eo={name:"checkbox",render(e,t){const n=e.element,r=function(e){return"boolean"==typeof e?e:"string"==typeof e?!Ys.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}},to=/* @__PURE__ */new Map,no=/* @__PURE__ */new Map;function ro(e,t){const n=e??"";if(null==t)return n;const r=io(t);return"{}"===r?n:`${n}|${r}`}function io(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>io(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)}:${io(n)}`)}return`{${r.join(",")}}`}var so=/* @__PURE__ */new Set(["short","medium","long","full"]),oo=/* @__PURE__ */new Set(["short","medium","long","full"]),ao=/^[A-Za-z]{3}$/u,lo=/^[0-4]$/u;function uo(e){return{kind:"date",options:e}}function co(e){return{kind:"number",options:e}}var ho=/* @__PURE__ */new WeakSet;function fo(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?uo({dateStyle:"medium"}):so.has(r)?uo({dateStyle:r}):void 0;case"time":return void 0===r?uo({timeStyle:"short"}):oo.has(r)?uo({timeStyle:r}):void 0;case"datetime":return void 0===r?uo({dateStyle:"medium",timeStyle:"short"}):so.has(r)?uo({dateStyle:r,timeStyle:"short"===r?"short":"medium"}):void 0;case"number":if(void 0===r)return co({});if(!lo.test(r))return;return co({minimumFractionDigits:Number(r),maximumFractionDigits:Number(r)});case"currency":if(void 0===r||!ao.test(r))return;return co({style:"currency",currency:r.toUpperCase()});case"percent":return void 0===r?co({style:"percent"}):void 0;default:return}}(t);if(void 0!==i){if(i.kind===e)return i.options}else!function(e,t,n){ho.has(e)||(ho.add(e),S(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, time, datetime (each also :short|medium|long|full), number, number:0-4, currency:XXX, percent.`))}(n,r,t)}var po={name:"date",render(e,t,n){const r=e.element;if(ri(t))return void("INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent=""));const i="number"==typeof t?t:ni(t),s=new Date(i),o=!Number.isNaN(s.getTime()),a=String(i);"INPUT"!==r.tagName?("TIME"===r.tagName&&r.setAttribute("datetime",o?s.toISOString():a),r.textContent=o?function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=fo("date",t.format,t.element,t.fieldName)??go;try{return function(e,t){const n=ro(e,t);return ii(no,n)??si(no,n,new Intl.DateTimeFormat(e,t),64)}(r,i).format(e)}catch{return e.toISOString()}}(s,e,n):a):r.value=o?function(e,t){const n=`${String(t.getFullYear()).padStart(4,"0")}-${mo(t.getMonth()+1)}-${mo(t.getDate())}`,r=`${mo(t.getHours())}:${mo(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${r}`:"time"===e?r:t.toISOString()}(r.type,s):a}},go={dateStyle:"medium",timeStyle:"short"};function mo(e){return String(e).padStart(2,"0")}var vo={name:"number",render(e,t,n){const r=e.element;if(ri(t))return void("INPUT"===r.tagName?r.value="":r.textContent="");const i="number"==typeof t?t:Number(ni(t));Number.isNaN(i)?r.textContent=ni(t):"INPUT"!==r.tagName?r.textContent=function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=fo("number",t.format,t.element,t.fieldName);try{return function(e,t){const n=ro(e,t);return ii(to,n)??si(to,n,new Intl.NumberFormat(e,t),64)}(r,i).format(e)}catch{return String(e)}}(i,e,n):r.value=String(i)}},yo={name:"array",render:/* @__PURE__ */ee((e,t,n)=>{const r=e.element;if(ri(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=Zr(t);let r="";for(let i=0;i<t.length;i+=1)r+=Yr(e,t[i],i,ni,n);return r}(i,t),s=n.sanitizerPolicy,o=di(i),a=ei(r);r.innerHTML=yr(Br(e,s,o));for(const e of Array.from(r.children))ti(e,a);return}r.textContent=t.map(ni).join(e.arraySeparator??", ")})};function bo(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,n=/* @__PURE__ */new WeakMap,r=/* @__PURE__ */new WeakMap;return{name:"structural-array",render:/* @__PURE__ */ee((i,s,o)=>{const a=ri(s)?[]:s;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),S(`[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=wo(l),h=x(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 s=i.map(So),o=/* @__PURE__ */new Set,a=s.find(e=>!(void 0===e||!o.has(e)&&(o.add(e),1)));if(void 0!==a&&Ao(e,t,n,a),s.some(e=>void 0===e)&&ko(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(So).filter(e=>void 0!==e)),o=s.some(e=>void 0!==e&&i.has(e));i.size>0&&!o&&ko(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=pi({template:u,container:l,patches:h,nextItems:a,store:r,forceRender:f,sanitizerPolicy:o.sanitizerPolicy,onDuplicateKey:(e,t)=>{Ao(n,e,i.fieldName,t)}});return null!==p&&(e.set(l,{values:a.slice(),template:u,domSnapshot:wo(l)}),!!p&&void 0)})}}function wo(e){return Array.from(e.children,e=>e.getAttribute(ci))}function So(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Ao(e,t,n,r){ko(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${r}"; later ones pair by position. Make \`id\` unique per item.`)}function ko(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),S(`[live-preview] ${r}`))}var Ro=/* @__PURE__ */new Map;function To(e,t){return{name:e,render(){T(t)}}}var Co=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),$o=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"});function Lo(e){return void 0===e?void 0:!e}var LivePreviewClient=class{#H=new EventEmitter;#W;#q;#V;#R;#n;#G=!1;#K=!1;#J=!1;#Q=null;constructor(e={}){const t=function(e){const t="v1"===e.defaults?$o:Co;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.#n=r?(...e)=>{A("[live-preview]",...e)}:b,this.#W=new OriginDetector(L({additionalOrigins:t.allowedOrigins,enableReferrerDetection:Lo(t.disableReferrerDetection),enableLocalhostMatching:Lo(t.disableLocalhostMatching)})),this.#W.isProductionUnconfigured&&this.#n("no trusted origin could be detected — set allowedOrigins"),this.#q=new Ji(function(){const e=[Ns,Us,Os,Ds,Vs,Ks,Qs,Zs,{...Zs,name:"radio"},eo,po,vo,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[To("array","structural arrays"),To("blocks","structural arrays")]:[yo,{...yo,name:"blocks"}]];return function(e=[]){const t={};for(const n of e)t[n.name]=n;for(const[e,n]of Ro)t[e]=n;return Object.freeze(t)}([Ts("text"),Ts("textarea"),...e,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[]:[bo()]])}()),this.#R=new Ki({events:this.#H,config:Object.freeze({...t}),registerFieldRenderer:e=>this.#q.register(e),onTransformError:e=>{this.#H.emit("error",{error:e,context:"transform",code:"LP0602"})},log:this.#n}),this.#V=new _i(L({root:t.root,renderers:this.#q.renderers,resolveRenderer:(e,n)=>t.resolveRenderer?.(e,n)??this.#q.resolve(e),renderRichText:t.renderRichText,sanitizerPolicy:t.sanitizerPolicy,transformValue:(e,t,n,r)=>this.#R.applyTransforms(e,t,n,r),originMatcher:e=>this.#W.matches(e),readyTargets:()=>this.#W.enumerate(),emitter:this.#H,dataMerge:""===n?void 0:L({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,subfieldCoverage:t.subfieldCoverage,eventSourcePolicy:t.eventSourcePolicy,dependencies:t.dependencies,strategies:t.strategies,disableVisibilityGate:t.disableVisibilityGate,visibilityGateThreshold:t.visibilityGateThreshold,enableA11y:t.enableA11y,a11yLocale:t.a11yLocale,onHeartbeatTimeout:()=>{this.#W.unlockOrigin()},lockedOrigin:()=>this.#W.lockedOrigin,validateToken:t.validateToken,log:this.#n})),this.#H.on("connect",e=>{this.#W.lockOrigin(e.origin)}),!1!==t.autoStart&&this.start()}start(){if(this.#K)return!1;if(this.#G)return this.#V.start(),!0;if(!function isInPreviewContext(){return isInIframe()||function isInPopup(){return"undefined"!=typeof window&&null!=window.opener}()}())return!1;const e=this.#V.start();return e&&(this.#G=!0),e}suspend(){return!(this.#K||!this.#G)&&this.#V.suspend()}resume(){return!(this.#K||!this.#G)&&this.#V.start()}destroy(){if(null!==this.#Q)return this.#Q;let e,t;this.#K=!0;const n=new Promise((n,r)=>{e=n,t=r});this.#Q=n;const r=()=>{this.#H.removeAllListeners(),this.#J=!0};try{this.#V.destroy(),this.#R.destroyAll().finally(r).then(e,t)}catch(e){r(),t(e)}return n}async use(e){if(this.#K)throw new Error("LivePreviewClient: already destroyed");await this.#R.register(e)}async unuse(e){if(this.#J)throw new Error("LivePreviewClient: already destroyed");await this.#R.unregister(e)}refreshCache(){this.#V.refreshCache()}refreshAfterNavigation(){this.#V.navigationCommit()}get events(){return this.#H}get plugins(){return this.#R.list()}get status(){return this.#V.status}inspect(){return{...this.#V.inspect(),plugins:this.#R.snapshot()}}get updateCount(){return this.#V.updateCount}get destroyed(){return this.#K}};function initLivePreview(e={}){const t=new LivePreviewClient({...e,autoStart:!1});return t.start()?t:null}function No(e,t,n){if(0===t.length)return;const r={type:"payload-live-preview-focus",field:t};e.postMessage(r,n)}function Po(e,t){return n=>{const r=e();null!=r&&No(r,n,t)}}var Fo=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",UnboundField:"LP0203",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",EscalationUnavailable:"LP0808",IslandStartUnavailable:"LP0809",RouteRefreshUnconfirmed:"LP0810",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710"}),Uo="__livePreviewRouteRefresh";function registerRouteRefresh(e){const t="undefined"==typeof window?void 0:window;return void 0===t?()=>{}:(t[Uo]=e,()=>{t[Uo]===e&&(t[Uo]=void 0)})}export{Fo as DIAGNOSTIC_CODES,EventEmitter,LivePreviewClient,Po as createPreviewFocusReporter,initLivePreview,registerRouteRefresh,No as reportPreviewFocus};
|
|
1
|
+
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 e="payload-live-preview-a11y",t=/* @__PURE__ */new WeakMap;function n(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}var r=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 r=this.document;if(null==r?.body)return null;this.lease??=function(e){let n=t.get(e);return void 0===n&&(n={element:null,owned:!1,messageNode:null,refs:0,timer:null},t.set(e,n)),n.refs+=1,n}(r);const i=this.lease,s=i.element;if(s?.isConnected&&s.ownerDocument===r)return s;if(null!==s){const e=i.owned;n(i),e&&s.remove()}let o=r.getElementById(e);return i.owned=null===o,null===o&&(o=r.createElement("div"),o.id=e,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),o.setAttribute("aria-atomic","true"),o.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0",r.body.appendChild(o)),i.element=o,o}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`)}announcePartial(){this.say(this.german?"Vorschau teilweise aktualisiert":"Preview partly updated")}detach(){const e=this.lease,r=this.document;if(null===e||null===r)return;if(this.lease=null,e.refs-=1,e.refs>0)return;const i=e.element;null!==i&&n(e),e.owned&&i?.remove(),e.element=null,t.delete(r)}say(e){const t=this.mount(),r=this.lease;if(null===t||null===r)return;let i=r.messageNode;i?.parentNode!==t?(i?.remove(),i=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),r.messageNode=i,t.appendChild(i)):i.data=null===i.previousSibling?e:` ${e}`,null!==r.timer&&clearTimeout(r.timer);const s=setTimeout(()=>{r.timer===s&&r.element===t&&n(r)},1500);r.timer=s}};function i(e){if(++e.nodes>1e4)throw new Error("invalid or oversized field schema")}function s(e,t,n){if(i(t),n>64||t.active.has(e))throw new Error("invalid or oversized field schema");t.active.add(e)}function o(e){try{return a(e,{nodes:0,active:/* @__PURE__ */new WeakSet},0)}catch{return[]}}function a(e,t,n){if(!Array.isArray(e))return[];s(e,t,n);const r=[];for(const i of e){const e=l(i,t,n);e&&r.push(e)}return t.active.delete(e),r}function l(e,t,n){if(i(t),"object"!=typeof e||null===e)return;const r=e,o=r.name,l=r.type;if("string"!=typeof o||0===o.length)return;if("string"!=typeof l||0===l.length)return;const u=a(r.fields,t,n+1),d=function(e,t,n){if("object"==typeof e&&null!==e&&!Array.isArray(e)){s(e,t,n);const r=[];for(const s in e){if(!Object.hasOwn(e,s))continue;i(t);const o=Reflect.get(e,s);"object"!=typeof o||null===o||["__proto__","constructor","prototype"].includes(s)||r.push({...o,slug:s,fields:a(o.fields,t,n+1)})}return t.active.delete(e),r}if(!Array.isArray(e))return[];s(e,t,n);const r=[];for(const s of e){if(i(t),"object"!=typeof s||null===s)continue;const e=s,o=e.slug;if("string"!=typeof o||0===o.length)continue;const l=a(e.fields,t,n+1);r.push({...e,slug:o,fields:l})}return t.active.delete(e),r}(r.blocks,t,n+1),c={...r,name:o,type:l},h=r.relationTo;if(Array.isArray(h)){const e=[];for(const n of h)i(t),e.push(n);c.relationTo=e}return u.length>0?c.fields=u:delete c.fields,d.length>0?c.blocks=d:delete c.blocks,c}function u(e,t){return void 0===e||t(e)}function d(e,t){return null==e||t(e)}function c(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}var h=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],f={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"}},p=Object.keys(f);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),s=new Set(t),o=/* @__PURE__ */new Set;for(const e of p)(i>=f[e].since||s.has(e))&&o.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:i,capabilities:o,observed:s}}function g(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function m(e,t){return e.generation===t.generation&&e.revision===t.revision}var v=class{matcher;handlers;boundListener=void 0;attachedTarget=void 0;generation=0;revision=0;queueHead=void 0;queueTail=void 0;lastAccepted=void 0;replayedGeneration=0;latestAcceptedAttempt=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)}replayLastAccepted(){const e=this.lastAccepted,t=this.generation,n=this.handlers.onReplay;if(void 0===n||void 0===e||e.generation>=t||this.replayedGeneration===t)return!1;if(!this.matchesOrigin(e.origin,t)||this.lastAccepted!==e)return!1;this.replayedGeneration=t;const r={generation:t,revision:this.revision+=1};return this.invokeHandler(t,n,structuredClone(e.message),e.origin,r),!0}forgetLastAccepted(){this.lastAccepted=void 0,this.replayedGeneration=0,this.latestAcceptedAttempt=void 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&&!c(t.data))&&d(t.fieldSchemaJSON,e=>Array.isArray(e))&&d(t.globalSlug,e=>"string"==typeof e)&&d(t.collectionSlug,e=>"string"==typeof e)&&d(t.locale,e=>"string"==typeof e)&&d(t.ready,e=>"boolean"==typeof e)&&d(t.previewToken,e=>"string"==typeof e)&&d(t.protocolVersion,e=>"number"==typeof e)}(i)?void this.dispatchUpdate(function(e){const t={...e};for(const e of h)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);return Array.isArray(t.fieldSchemaJSON)?{...t,fieldSchemaJSON:o(t.fieldSchemaJSON)}:t}(i),r,t):void this.reportInvalid("shape",r,t);case"payload-document-event":return function(e){const t=e;return u(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&u(t.slug,e=>"string"==typeof e)&&u(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=c(e.data);if(!this.isCurrentGeneration(n))return;const i=r?{generation:n,revision:this.revision+=1}:void 0,s=this.handlers.validateToken;if(!this.isCurrentGeneration(n))return;if(void 0===s)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 o={generation:n,message:e,origin:t,messageRevision:i,verdict:void 0,next:void 0};let a;this.enqueue(o);try{a=s(e.previewToken,t)}catch{return void this.settleValidation(o,!1)}"boolean"!=typeof a?Promise.resolve(a).then(e=>{this.settleValidation(o,!0===e)},()=>{this.settleValidation(o,!1)}):this.settleValidation(o,a)}settleValidation(e,t){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){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){if(void 0===r)this.invokeHandler(n,this.handlers.onUpdate,e,t);else{const i={};this.latestAcceptedAttempt=i;const s=function(e){const t={...e};delete t.previewToken;try{return structuredClone(t)}catch{return null}}(e);if(this.latestAcceptedAttempt!==i||!this.isCurrentGeneration(n))return;this.lastAccepted=null===s?void 0:{generation:n,message:s,origin: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{g(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 y(e){return(...t)=>{try{g(e(...t))}catch{}}}function b(){}var w=y((...e)=>console.error(...e)),S=y((...e)=>console.warn(...e)),A=y((...e)=>console.debug(...e)),k={"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'"},R=/* @__PURE__ */new Set;function T(e){R.has(e)||(R.add(e),S(`[live-preview] LP0104: this page carries the lean runtime, which leaves out ${e} (${k[e]}). The elements are left as the server rendered them. Remove \`runtime: LEAN_RUNTIME\` to get the full runtime.`))}function C(e){return"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e){return!1!==e.enableA11y&&T("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 r(e.a11yLocale,n)}(e)}function $(e){if("undefined"==typeof window)return;const t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),v.sendReady(t,e)}function L(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}var N=/* @__PURE__ */new Set(["tabs","row","collapsible"]);function P(e,t,n,r){for(const i of e){if(N.has(i.type)){const e=i.fields;e&&P(e,r&&"tabs"===i.type?""===t?i.name:`${t}.${i.name}`:t,n,r);continue}const e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&P(i.fields,e,n,r);else if("array"===i.type&&i.fields)P(i.fields,`${e}.*`,n,r);else if("blocks"===i.type&&i.blocks)for(const t of i.blocks)P(t.fields,`${e}.*.${t.slug}`,n,r)}}function F(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 U(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function M(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function x(e,t){return t.every(e=>void 0!==U(e))?function(e,t){const n=[],r=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=U(e[t]);void 0!==n&&r.set(n,t)}const i=/* @__PURE__ */new Set;for(let s=0;s<t.length;s+=1){const o=t[s],a=U(o);if(void 0===a){n.push({kind:"insert",index:s,value:o});continue}const l=r.get(a);if(void 0===l){n.push({kind:"insert",index:s,value:o});continue}i.add(l);const u=e[l];M(u)===M(o)?(l!==s&&n.push({kind:"move",from:l,to:s,value:o}),E(u,o)||n.push({kind:"update",index:s,value:o})):n.push({kind:"replace",index:s,oldValue:u,value:o})}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)E(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 E(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),s=Object.keys(r);if(i.length!==s.length)return!1;for(const e of i)if(!Object.is(n[e],r[e]))return!1;return!0}var O={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:"]),D=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,_=/^[\\/]{2}/,B=/[\t\n\r]/g,j=/[\s\u0000-\u001f\u180e\u2000-\u2029]/g,z=/^([a-z][a-z0-9+.-]*):/i;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(B,"");if(0===t.length)return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(_.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return I.has(e.protocol)}catch{return D.test(t)&&!function(e){const t=z.exec(e.replace(j,""))?.[1];return void 0!==t&&!I.has(`${t.toLowerCase()}:`)}(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(B,"");return/^https?:\/\//i.test(t)||_.test(t)}var H=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),W=/* @__PURE__ */new Set(["href","src","poster","cite","action","xlink:href","data"]);function q(e){return!e.startsWith("on")&&!H.has(e)}function V(e){switch(typeof e){case"string":return e.length>65536?void 0:`s:${e}`;case"number":return`n:${Object.is(e,-0)?"-0":String(e)}`;case"boolean":return"b:"+(e?"1":"0");case"bigint":return`i:${String(e)}`;case"undefined":return"u";case"object":{if(null===e)return"z";let t;try{t=JSON.stringify(e)}catch{return}return t.length>65536?void 0:`o:${t}`}case"symbol":case"function":return}}function G(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function K(e,t,n,r,i){const s=e.onUnfaithfulPatch,o=t.reportedUnfaithful.get(n.element),a=V(i),l=Date.now(),u=void 0!==o&&("escalate"!==s||void 0===a||a===o.identity||l-o.at<1e3);if((u||"escalate"!==s)&&t.display.shortfall(t.activeUpdate,{kind:"unfaithful",field:n.fieldName}),!u){if(t.reportedUnfaithful.set(n.element,{identity:a,at:l}),void 0===o){if(t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName),"ignore"===s)return;if("warn"===s)return void e.warn(`[live-preview] LP0411: "${n.fieldName}" ${r}`)}e.log("LP0411",n.fieldName,r),t.unfaithfulPatches.push(n)}}function J(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}var Q=/* @__PURE__ */new Set(["date","number","checkbox"]);function X(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function Z(e){const t=e.trim();return JSON.stringify(t.length>40?`${t.slice(0,40)}…`:t)}var Y=/* @__PURE__ */new WeakSet;function ee(e){return Y.add(e),e}var te=class{previous=null;lastFields;priorFields;keepValues=!1;get previousFields(){return this.priorFields}get isBaseline(){return null===this.previous}diff(e,t,n=ne){const r=this.previous,i=null===r,s=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set,a=Object.entries(e);if(!n())return null;for(const[e,t]of a){const i=V(t);if(!n())return null;s.set(e,i),null!==r&&void 0!==i&&r.get(e)===i||o.add(e)}if(null!==r)for(const e of r.keys())s.has(e)||o.add(e);const l=/* @__PURE__ */new Set,u=Object.entries(t);if(!n())return null;for(const[e,t]of u)if(o.has(e))for(const e of t)if(l.add(e),!n())return null;return n()?(this.previous=s,this.priorFields=this.keepValues?this.lastFields:void 0,this.lastFields=this.keepValues?e:void 0,{changed:o,invalidated:l,baseline:i}):null}reset(){this.previous=null,this.lastFields=void 0,this.priorFields=void 0}};function ne(){return!0}var re=/* @__PURE__ */new Set(["__proto__","prototype","constructor"]);function ie(e,t,n,r=!1){if(r&&void 0!==n){const r=se(e,`${t}_${n}`);if(void 0!==r)return r}const i=se(e,t);if(void 0!==i)return i;if(t.includes(".")){let n=e,r=!0;for(const e of t.split(".")){if(re.has(e)||null===n||"object"!=typeof n){r=!1;break}if(n=se(n,e),void 0===n){r=!1;break}}if(r)return n}return void 0===n?void 0:se(e,`${t}_${n}`)}function se(e,t){if(!re.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function oe(e,t,n,r){return ie(e,n,t.locale??r,void 0!==t.locale)}function ae(e,t,n,r){const i=V(t);if(void 0===i)return;const s=[e.hrefField,e.srcField,e.altField];let o=JSON.stringify([e.format,e.locale??r])+i;for(const t of s){if(void 0===t||0===t.length)continue;const i=V(oe(n,e,t,r));if(void 0===i)return;o+=`|${t}=${i}`}return o}var le="data-payload-fragment",ue="data-payload-fragment-key";function de(e){return e.closest(`[${le}]`)}function ce(e,t,n){const r=new Set(t);return{boundaries:t,strategy:e,ownerKeys:n,covers:e=>void 0!==e.fragmentBoundary&&r.has(e.fragmentBoundary)}}function he(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==de(e)?"fragment":null!==e.closest("head")?"route":"patch"}function fe(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function pe(e){return"string"==typeof e&&e.length>0}function ge(e,t){return null!==t&&void 0!==e&&t.includes(e)}function me(e){const t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function ve(e){return"object"==typeof e&&null!==e}function ye(e){return Array.isArray(e)?"array":ve(e)?"object":"scalar"}function be(e,t){return ve(e)?e[t]:void 0}function we(e,t){return("string"==typeof t||"number"==typeof t)&&ve(e)&&!Array.isArray(e)&&e.id===t}function Se(e,t){if(!ve(e)||!ve(t))return we(e,t)||we(t,e)||V(e)===V(t);if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(n=>Object.hasOwn(e,n)&&Se(be(e,n),be(t,n)))}function Ae(e,t){const n=V(t),r=V(e);return void 0!==n&&n===r||!(!we(e,t)&&!we(t,e))||void 0!==n&&void 0!==r&&Se(e,t)}function ke(e,t,n){let r=t,i=n;for(const t of e.split("."))r=be(r,t),i=be(i,t);return!Ae(r,i)}function Re(e,t,n,r){const i=[];let s=0;const o=(e,t,n,a)=>{if(s+=1,r.covers(e)||Ae(t,n))return;if(!((void 0===t||ye(t)===ye(n))&&ve(n)&&r.reachesBelow(e)&&a<8))return void i.push({path:e,value:n});const l=function(e,t){const n=new Set(Object.keys(t));if(ve(e))for(const t of Object.keys(e))n.add(t);return[...n]}(t,n);0===l.length&&i.push({path:e,value:n});for(const r of l){if(s>=1024)return void i.push({path:e,value:n});o(`${e}.${r}`,be(t,r),be(n,r),a+1)}};return o(e,t,n,0),i}var Te=/* @__PURE__ */new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function Ce(e,t,n={}){const r=e=>!1===t||ge(e,t),i=[];for(const[t,n]of e.entries())n.some(e=>r(e.owner))&&i.push(t);const s=e.rendered.filter(e=>void 0!==n[e.strategy]);return function(e,t){const n=new Set(e),r=[...t],i=(e,t)=>{const n=`${t}.`;for(const t of e)if(t.startsWith(n))return!0;return!1};return{covers:e=>n.has(e)||r.some(t=>t===e||e.startsWith(`${t}.`)),reachesBelow:e=>i(n,e)||i(r,e)}}(i,[...e.covers,...s].filter(e=>r(e.owner)).flatMap(e=>e.paths))}function $e(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 Le(e,t,n,r=Ce(e,n)){let i;const s=r.covers,o=r.reachesBelow;return r=>{const a=$e(r,t);return s(r)||a!==r&&s(a)?"whole":(i??=function(e,t){const n=/* @__PURE__ */new Set;for(const[r,i]of e.entries())for(const e of i)(!1===t||ge(e.owner,t))&&void 0!==e.locale&&n.add(`${r}_${e.locale}`);return n}(e,n),i.has(r)?"whole":o(r)||a!==r&&o(a)?"below":"none")}}function Ne(e,t,n){return"declared"===e&&void 0!==t&&void 0!==n?{previous:t,next:n}:void 0}function Pe(e,t,n,r,i,s){const o=Ce(e,r,s),a=Le(e,n,r,o),l=[];for(const e of t){if(Te.has(e))continue;const t=a(e);if("none"===t&&l.push(e),"below"!==t||void 0===i)continue;const r=$e(e,n),{previous:s,next:u}=i;for(const{path:t}of Re(r,s[e],u[e],o))l.push(t)}return l}var Fe=/* @__PURE__ */new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),Ue=/* @__PURE__ */new Set(["root","paragraph","text","heading","quote","list","listitem","linebreak","tab","horizontalrule","code","code-highlight","table","tablerow","tablecell","link","autolink"]),Me={},xe=class{rawChanges=new te;resolved=null;resolvedLocale=null;trailing=null;openUntil=0;requestAttempt=0;decide(e,t){const n=t.rawData;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(Oe(e)||e.fieldName.includes("."))return!0;if(_e(e.hrefField)||_e(e.srcField)||_e(e.altField))return!0}return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${le}]`)}(e)&&!function(e,t,n){for(const r of e.values()){if("text"!==r.fieldType||!0===r.explicitFieldType)continue;const e=oe(t,r,r.fieldName,n);if(Ye(e)&&Ie(e.root))return!0}return!1}(e.cache,n,t.locale))return t.forceRender&&(this.resolvedLocale=null),{merge:!1,fields:n};const{changed:r}=this.rawChanges.diff(n,Me),i=this.resolvedLocale!==t.locale,s=this.resolved;if(null===s)return this.resolved=n,{merge:!0,fields:n};const o={...s};t.forceRender&&(this.resolvedLocale=null);let a=t.forceRender||i;for(const i of r){const r=n[i];if(Te.has(i)){o[i]=r;continue}const l=Ee(i,s[i],r,e.cache,t.schemaIndex);"own"!==l&&(a=!0,this.resolvedLocale=null),"keep"!==l&&(o[i]=r)}return this.resolved=o,{merge:a,fields:o}}request(e,t,n){const r=++this.requestAttempt,i=Date.now();if(i>=this.openUntil)return this.openUntil=i+t,this.dropQueued(),this.requestAttempt!==r?{leading:!0,result:Promise.resolve({status:"superseded"})}:{leading:!0,result:e.merge(n)};const s=this.trailing,o=s?.pending??function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}(),a={request:n,pending:o,timer:null};if(this.trailing=a,this.openUntil=i+t,null!==s&&null!==s.timer&&clearTimeout(s.timer),this.trailing!==a)return{leading:!1,result:o.promise};const l=setTimeout(()=>{this.flush(e,a)},t);return this.trailing===a?a.timer=l:clearTimeout(l),{leading:!1,result:o.promise}}recordMerged(e,t){this.resolved=e,this.resolvedLocale=t}resetRawChanges(){this.rawChanges.reset()}destroy(){this.requestAttempt+=1,this.openUntil=0,this.dropQueued()}dropQueued(){const e=this.trailing;this.trailing=null,null!==e&&(null!==e.timer&&clearTimeout(e.timer),e.pending.settle({status:"superseded"}))}flush(e,t){this.trailing===t&&(this.trailing=null,t.timer=null,e.merge(t.request).then(t.pending.settle))}};function Ee(e,t,n,r,i){return De(n)?!De(t)||function(e,t,n){const r=void 0===n?void 0:F(n,e);return void 0!==r&&!Fe.has(r.type)||!0===t.get(e)?.some(Oe)||function(e,t){const n=`${t}.`;for(const[t,r]of e.entries())if(t.startsWith(n))return!0;return!1}(t,e)}(e,r,i)?"keep":null==t?"ask":"own":"ask"}function Oe(e){return!Fe.has(e.fieldType)}function Ie(e){const t=[e],n=/* @__PURE__ */new Set;for(let e=t.pop();void 0!==e;e=t.pop()){if("object"!=typeof e||null===e||n.has(e))continue;n.add(e);const{type:r,fields:i,children:s}=e;if(!Ue.has(r))return!0;if("internal"===i?.linkType)return!0;if(Array.isArray(s))for(const e of s)t.push(e)}return!1}function De(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function _e(e){return!0===e?.includes(".")}var Be=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 je(e,t){const n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;const r=me(e),i=me(t.data??{});return void 0!==r&&void 0!==i&&r!==i}function ze(e){return null!==e&&e.forceRender&&!e.completed}var He=class{lastIdentity=void 0;inspect(e){const t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;const n=JSON.stringify([t.entitySlug,me(t),t.updatedAt]);return{identity:n,edit:n!==this.lastIdentity&&je(t,e)?t:null}}commit(e){const t=e.identity!==this.lastIdentity;return this.lastIdentity=e.identity,t?e.edit:null}};function We(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var qe=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:We(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){this.#e=void 0}};function Ve(e,t){const n=t.element.ownerDocument.defaultView;return null===n?"no-element":e.reveal(`${t.owner??""} ${t.fieldName}`,t.element,n)}var Ge=class{seen=/* @__PURE__ */new Map;note(e,t,n){const r=V(n);if(void 0===r)return;const i=`${t.owner??""}\0${t.locale??""}\0${t.fieldName}`,s=this.seen.get(i);void 0!==s?s!==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}},Ke=()=>{},Je=class{host={outstanding:()=>!1,report:Ke,failed:Ke};entry=null;ended;begin(e,t){const n=this.entry,r=null===n?void 0:this.view(n);null!==n&&(n.key=void 0),this.ended=void 0,this.entry={key:e,revision:t,shortfalls:[],seen:/* @__PURE__ */new Set,deferred:0,awaiting:0,reported:void 0,queued:!1},null!==n&&void 0!==r&&this.publish(n,"pending"===r.state?{...r,state:"superseded"}:r)}end(){const e=this.entry;if(null!==e){this.entry=null;try{this.ended=this.view(e)}finally{e.key=void 0}}}snapshot(){return null!==this.entry?this.view(this.entry):void 0===this.ended?void 0:{...this.ended,shortfalls:[...this.ended.shortfalls]}}shortfall(e,t){const n=this.entry;if(n?.key!==e)return;const r=JSON.stringify(t);n.seen.has(r)||(n.seen.add(r),n.shortfalls.push(t),this.requestSettle(n.key))}deferred(e,t){this.entry?.key===e&&(this.entry.deferred=t)}handIsland(e){const t=this.entry;if(t?.key!==e)return Ke;t.awaiting+=1;let n=!1;return()=>{n||this.entry!==t||(n=!0,t.awaiting-=1,this.settle(t))}}requestSettle(e){const t=this.entry;t?.key!==e||t.queued||(t.queued=!0,queueMicrotask(()=>{t.queued=!1;try{this.entry===t&&this.settle(t)}catch(e){this.host.failed(e)}}))}settle(e){const t=this.view(e);"pending"!==t.state&&this.publish(e,t)}publish(e,t){e.reported!==t.state&&(e.reported=t.state,this.host.report(t))}view(e){const t=void 0!==e.key&&this.host.outstanding(e.key)?"pending":e.shortfalls.length>0?"partial":e.awaiting>0?"unconfirmed":"current";return{revision:e.revision,state:t,shortfalls:[...e.shortfalls],deferred:e.deferred,awaitingIslands:e.awaiting}}};function Qe(e){const t=e.getAttribute(ue);return{kind:"fragment",id:e.getAttribute(le)??"",key:null===t||0===t.length?void 0:t,code:"LP0801"}}var Xe=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;warnedIslandStart=!1;warnedEscalationUnavailable=!1;warnedProtocolShape=!1;reportedUnfaithful=/* @__PURE__ */new WeakMap;checkedServerFormat=/* @__PURE__ */new WeakSet;unfaithfulPatches=[];unfaithfulCount=0;escalatedCount=0;unfaithfulFields=/* @__PURE__ */new Set;autoBindSearchMs=void 0;autoBindGuesses=null;warnedForeignSource=!1;lastAppliedIdentity=/* @__PURE__ */new WeakMap;navigationReplayPending=!1;navigationBindingReplay=!1;revealLedger=new Ge;display=new Je;fragmentStats={rendered:0,failed:0,superseded:0};routeStats={refreshes:0,partial:0,failed:0,refused:0,loopStopped:0};fragmentControllers=/* @__PURE__ */new Map;routeController=null;routeRetry=null;routeRefreshOwed=!1;routeAwaitsSave=!1;fragmentsOwed=/* @__PURE__ */new Set;readyTimers=[];revealer=new qe;changes=new te;merges=new xe;protocol=new Be;relationships=new He;isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){this.display.requestSettle(e),e.completed||(e.completed=!0,e.countsAsUpdate&&(this.completedCount+=1))}forgetOwedWork(){this.routeRefreshOwed=!1,this.routeAwaitsSave=!1,this.fragmentsOwed.clear()}supersedeStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(const[e,t]of this.fragmentControllers){for(const e of t)this.fragmentsOwed.add(e);e.abort()}this.fragmentControllers.clear()}abortStrategies(){this.supersedeStrategies();const e=this.routeController;this.routeController=null,e?.abort()}},Ze=class{constructor(e,t){this.deps=e,this.state=t,this.instanceContext=L({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,serverURL:e.serverURL,reportUnfaithful:(n,r)=>{K(e,t,n,r,this.writing)}})}deps;state;writing;instanceContext;apply(e){const{deps:t,state:n}=this,r=n.activeUpdate;if(null===r||void 0===e.revision||!m(r.revision,e.revision)||!n.isCurrent(r))return!1;const{target:i,value:s}=e,o=void 0!==r.schemaIndex?F(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(O,e))return O[e]}(t);if(void 0!==e)return e}return e.fieldType}(i,o?.type);"text"===l&&!0!==i.explicitFieldType&&Ye(s)&&(l="richText");try{a=t.resolveRenderer(l,i)}catch(e){return this.fail(r,i.fieldName,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:o,...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||et(e))}(s));try{if(void 0!==i.targetAttribute){if("blocked"===function(e,t,n){const r=t.toLowerCase().trim();if(0===r.length)return"blocked";if(!q(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 W.has(r)&&!isSafeUrl(i)?"blocked":(e.setAttribute(r,i),"applied")}(i.element,i.targetAttribute,s))return t.warn(`[live-preview] LP0401: refused to write "${i.fieldName}" into attribute "${i.targetAttribute}"`),n.display.shortfall(r,{kind:"write",field:i.fieldName,code:"LP0401"}),!1}else{if(void 0===a)return t.log("no renderer for",l),K(t,n,i,`has no renderer for "${l}"`,s),!1;{const e=function(e,t,n,r){if("ignore"===e.onUnfaithfulPatch)return;if(void 0!==n.format||!Q.has(r))return;if(t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);const i=X(n.element);return i.trim().length>0?i:void 0}(t,n,i,l);this.writing=s;const r=function(e,t,n,r){return e.render(t,n,r)}(a,i,s,h);if(!1===r&&function(e){return Y.has(e.render)}(a))return K(t,n,i,`is a value ${a.name} cannot render`,s),!1;void 0!==e&&function(e,t,n){const r=X(t.element);r!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${Z(n)}, the patch wrote ${Z(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,i.fieldName,e)}if(!n.isCurrent(r))return!1;u&&t.emitter.emitWhile("elementUpdate",{element:i.element,fieldName:i.fieldName,previousValue:d,nextValue:s,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,n){if(!this.state.isCurrent(e))return!1;this.state.display.shortfall(e,{kind:"write",field:t,code:"LP0603"});const r=n instanceof Error?n:new Error(String(n));return this.deps.emitter.emitWhile("error",{error:r,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}};function Ye(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)}function et(e){return!!Ye(e)&&e.root.children.every(e=>{const{type:t,children:n}=e??{};return"paragraph"===t&&(!Array.isArray(n)||0===n.length)})}function tt(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}function nt(...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 rt(e,t){const n={};for(const r of t)r!==e&&(n[r]=[e]);return n}var it="data-payload-island",st=`astro-island, [${it}]`,ot="data-payload-owned";function at(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute("data-payload-morph"))return!0;if(ut(e)||e.hasAttribute(ot))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function lt(e){return"patch"===e.getAttribute(it)}function ut(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(it)}(e)&&!lt(e)}function dt(e){return"astro-island"===e.tagName.toLowerCase()&&e.hasAttribute("ssr")}var ct=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],ht=/* @__PURE__ */new WeakMap,ft=/* @__PURE__ */new WeakSet;function pt(e){return"astro-island"===e.tagName.toLowerCase()}function gt(e){let t="";for(const n of e.querySelectorAll("astro-slot, template[data-astro-template]"))n.parentElement?.closest("astro-island")===e&&(t+=`${n.getAttribute("name")??n.getAttribute("data-astro-template")??""}\0${n.innerHTML}\0`);return t}function mt(e,t){if(!pt(e)||!pt(t))return!0;const n=gt(t);if(!ct.every(n=>e.getAttribute(n)===t.getAttribute(n))||(ht.get(e)??gt(e))!==n||e.getAttribute("props")!==t.getAttribute("props")&&!function(e){const t=e.ownerDocument.defaultView?.customElements.get("astro-island");return void 0!==t&&e instanceof t&&Array.isArray(t.observedAttributes)&&t.observedAttributes.includes("props")}(e))return ht.set(t,n),!1;ht.set(e,n);const r=t.getAttribute("props");return r!==e.getAttribute("props")&&(e.setAttribute("ssr",""),null===r?e.removeAttribute("props"):e.setAttribute("props",r)),!0}function vt(e){return Array.from(e.querySelectorAll("astro-island"))}function yt(e){const t=e.ownerDocument.defaultView;if(void 0===t?.customElements.get("astro-island"))return"element";const n=e.getAttribute("client"),r=Reflect.get(t,"Astro");return null===n||"object"!=typeof r||null===r||void 0===Reflect.get(r,n)?"directive":void 0}var bt="data-payload-field",wt="data-payload-type",St="data-payload-attribute",At="data-payload-href",kt="data-payload-src",Rt="data-payload-alt",Tt="data-payload-array-template",Ct="data-payload-array-separator",$t="data-payload-locale",Lt="data-payload-format",Nt="data-payload-richtext",Pt="data-payload-html",Ft="data-payload-array",Ut="data-payload-structural",Mt="data-payload-owner",xt="data-payload-depends",Et="data-payload-strategy",Ot="data-payload-boundary",It="data-payload-guessed",Dt="data-payload-covers",_t=[bt,wt,St,At,kt,Rt,Tt,Ct,$t,Lt,Nt,Pt,Ft,Ut,Mt,xt,Et,Ot,"type"],Bt=`[${bt}]`,jt=`[${Mt}]`,zt=`[${le}], [${Et}="route"]`;function Ht(e){const t=e.closest(jt)?.getAttribute(Mt);return null==t||0===t.length?void 0:t}var Wt=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,qt=/* @__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 Vt(e){return qt.has(e)||Wt.test(e)}function Gt(e,t){return e.fieldName===t.fieldName&&e.locale===t.locale&&e.owner===t.owner&&e.strategyKind===t.strategyKind&&e.fragmentBoundary===t.fragmentBoundary}var Kt=class{entriesByField=/* @__PURE__ */new Map;entryByElement=/* @__PURE__ */new WeakMap;filter;count=0;dependencies=null;islandRoots=[];ownersByIsland=/* @__PURE__ */new Map;navigationRoots=[];coverDeclarations=[];renderedDeclarations=[];constructor(e={}){this.filter=e.filter??Qt}dependencyMap(){if(null!==this.dependencies)return this.dependencies;const e=[];for(const t of this.values())void 0!==t.dependsOn&&e.push(rt(t.fieldName,t.dependsOn));return this.dependencies=nt(...e),this.dependencies}get islands(){return this.islandRoots}get islandOwners(){return this.ownersByIsland}get covers(){return this.coverDeclarations}get rendered(){return this.renderedDeclarations}get navigationReplayRoots(){return this.navigationRoots}buildFromRoot(e){const t=performance.now();this.clear();let n=0;for(const t of e.querySelectorAll(Bt))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){const t=[];for(const n of e.querySelectorAll(st))lt(n)||t.push(n);return t}(e),this.ownersByIsland=new Map(this.islandRoots.map(e=>[e,Ht(e)])),this.navigationRoots=[...e.querySelectorAll(zt)].filter(e=>this.filter(e)&&(e.hasAttribute(le)||0===(e.getAttribute(bt)??"").length)),this.coverDeclarations=[...e.querySelectorAll(`[${Dt}]`)].filter(e=>this.filter(e)).map(e=>({paths:tt(e.getAttribute(Dt)),owner:Ht(e)})),this.renderedDeclarations=[...e.querySelectorAll(`[${xt}]`)].filter(e=>this.filter(e)).flatMap(e=>{const t=function(e){if((e.getAttribute(le)??"").length>0)return"fragment";const t=e.getAttribute(Et);return null!==t?"route"===t?"route":void 0:e.hasAttribute(bt)&&null!==e.closest("head")?"route":void 0}(e);return void 0===t?[]:[{strategy:t,paths:tt(e.getAttribute(xt)),owner:Ht(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=[],this.ownersByIsland=/* @__PURE__ */new Map,this.navigationRoots=[],this.coverDeclarations=[],this.renderedDeclarations=[]}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(bt);if(null===t||0===t.length)return;const n=e.getAttribute(wt),r=e.getAttribute(St),i=e.getAttribute(At),s=e.getAttribute(kt),o=e.getAttribute(Rt),a=e.getAttribute(Tt),l=e.getAttribute(Ct),u=e.getAttribute($t),d=e.getAttribute(Lt),c=Ht(e),h=tt(e.getAttribute(xt)),f=e.getAttribute(Et),p=e.getAttribute(It),g=de(e);return{element:e,fieldName:t,fieldType:Jt(e),explicitFieldType:null!==n&&Vt(n),strategyKind:he(e)??"unknown",...null!==g?{fragmentBoundary:g}:{},...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==i&&i.length>0?{hrefField:i}:{},...null!==s&&s.length>0?{srcField:s}:{},...null!==o&&o.length>0?{altField:o}:{},...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(Ot)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}};function Jt(e){const t=e.getAttribute(wt);if(null!==t&&Vt(t))return t;if(e.hasAttribute(Nt))return"richText";if(e.hasAttribute(Pt))return"html";if(e.hasAttribute(Ut))return"structural-array";if(e.hasAttribute(Ft))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 Qt(){return!0}var Xt=1e4,Zt=1048576,Yt=/* @__PURE__ */new Set(["__proto__","constructor","prototype"]);function en(){throw new Error("invalid or oversized legacy population")}function tn(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n<=31||127===n)return!0}return!1}function nn(e,t){if("string"!=typeof e||0===e.length||e.length>t||"."===e||".."===e)return!1;if(e.includes("/")||e.includes("\\")||tn(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function rn(e){return nn(e,128)&&!/[?#%]/u.test(e)&&!Yt.has(e)}function sn(e){return Number.isFinite(e)?String(e):nn(e,512)?e:en()}function on(e,t){return Object.hasOwn(e,t)?Reflect.get(e,t):void 0}function an(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0,enumerable:!0})}function ln(e){let t=e.length;for(;t>0&&47===e.charCodeAt(t-1);)t-=1;return e.slice(0,t)}function un(e){const t=/* @__PURE__ */new WeakSet;let n=0,r=0;return function e(i,s){if(++n>Xt||s>64)return en();if("string"==typeof i)return r+=i.length,r>Zt&&en(),i;if(null==i||"boolean"==typeof i)return i;if("number"==typeof i)return Number.isFinite(i)?i:en();if(!Array.isArray(i)&&!c(i))return en();if(Array.isArray(i)){i.length>Xt&&en();for(let e=0;e<i.length;e+=1)Object.hasOwn(i,e)||en()}if(t.has(i))return en();t.add(i);const o=Array.isArray(i)?[]:{};for(const t of Object.keys(i))an(o,t,e(Reflect.get(i,t),s+1));return t.delete(i),o}(e,0)}function dn(e,t,n,r,i,s){if(!Number.isSafeInteger(i)||i<0||i>64)return en();void 0!==s&&("string"!=typeof s||s.length>128||tn(s))&&en();const o=un(e);if(!c(o))return en();const a=/* @__PURE__ */new Map,l=/* @__PURE__ */new Set;let u=0;const d=/* @__PURE__ */new WeakSet,h=e=>{(++u>Xt||e>64)&&en()};function f(e,t,n,r){if(null==r||""===r)return;const s=c(r)?on(r,"id"):r,o=sn(s);if(0===i)return void an(e,t,s);const u=JSON.stringify([n,o]);l.add(u),l.size>1e3&&en();const d=a.get(n)??[];d.push({owner:e,key:t,id:o}),a.set(n,d)}function p(e,t,n){void 0!==n.hasMany&&"boolean"!=typeof n.hasMany&&en();const r=n.relationTo,i=on(e,t);if(Array.isArray(r)){0===r.length&&en();const e=c(i)?on(i,"relationTo"):void 0;let t;for(const n of r)h(0),rn(n)||en(),n===e&&(t=n);if(null==i||""===i)return;c(i)&&void 0!==t||en(),f(i,"value",t,on(i,"value"))}else rn(r)||en(),f(e,t,r,i)}function g(e,t){if(h(t),Array.isArray(e)||c(e)){if(c(e)&&Object.hasOwn(e,"relationTo")&&Object.hasOwn(e,"value")){const t=on(e,"relationTo");return rn(t)||en(),void f(e,"value",t,on(e,"value"))}for(const n of Object.keys(e))g(Reflect.get(e,n),t+1)}}!function e(t,n,r){h(r),d.has(t)&&en(),d.add(t);for(const i of t){h(r),c(i)&&nn(i.name,512)&&!Yt.has(i.name)||en();const t=on(n,i.name);if("relationship"===i.type||"upload"===i.type)if(i.hasMany)if(null==t||Array.isArray(t)||en(),Array.isArray(t))for(let e=0;e<t.length;e+=1)p(t,e,i);else p(n,i.name,i);else p(n,i.name,i);else if("group"===i.type||"tabs"===i.type)null==t||c(t)||en(),c(t)&&i.fields&&e(i.fields,t,r+1);else if("row"===i.type||"collapsible"===i.type)i.fields&&e(i.fields,n,r+1);else if("array"===i.type||"blocks"===i.type){if(0===t?an(n,i.name,[]):null==t||Array.isArray(t)||en(),Array.isArray(t))for(const n of t)if(c(n)||en(),"array"===i.type&&i.fields)e(i.fields,n,r+1);else if("blocks"===i.type){const t=on(n,"blockType"),s=i.blocks?.find(e=>(h(r),e.slug===t));void 0===s&&en(),e(s.fields,n,r+1)}}else"richText"===i.type&&g(t,r+1)}d.delete(t)}(t,o,0),a.size>25&&en();const m=[];if(0===a.size)return{doc:o,requests:m};const v=new URL(n);(!["http:","https:"].includes(v.protocol)||v.username||v.password||v.search||v.hash)&&en(),(!r.startsWith("/")||r.includes("\\")||/[%?#]/u.test(r)||tn(r))&&en(),r.split("/").some(e=>"."===e||".."===e)&&en();const y=`${ln(n)}${ln(r)}/`;for(const[e,t]of a){const n=[...new Set(t.map(e=>e.id))];let r=0;for(;r<n.length;){const o=n[r];void 0===o&&en();const a=o.includes(","),l=[];let u="";for(;r<n.length&&l.length<20;){const t=n[r];if(void 0===t||l.length>0&&(a||t.includes(",")))break;const o=[...l,t],d=new URLSearchParams({depth:String(i),limit:String(o.length)});void 0!==s&&d.set("locale",s),d.set(a?"where[id][equals]":"where[id][in]",a?t:o.join(","));const c=`${y}${encodeURIComponent(e)}?${d}`;if(c.length>8192){0===l.length&&en();break}new URL(c).origin!==v.origin&&en(),l.push(t),r+=1,u=c}(0===l.length||m.length>=64)&&en();const d=new Set(l);m.push({url:u,ids:d,slots:t.filter(e=>d.has(e.id))})}}return{doc:o,requests:m}}async function cn(e,t,n){let r,i=!1,s=!1;const o=/* @__PURE__ */Symbol();let a;const l=new Promise(e=>{a=()=>{e(o)}}),u=()=>{n()&&!t.aborted||en()},d=()=>{if(void 0!==r&&!i){i=!0;try{Promise.resolve(r.cancel()).catch(()=>{})}catch{}}},c=()=>{a?.(),d()};t.addEventListener("abort",c,{once:!0});try{u();const t=e.body??null;if(u(),null===t){const t=e.json.bind(e);u();const n=await Promise.race([Promise.resolve().then(()=>(u(),t())),l]);return u(),n===o&&en(),n}const n=t.getReader.bind(t);u();const i=n();r=i,u();const a=[];let d=0,c=0;for(;;){const e=Promise.resolve().then(()=>{u();const e=i.read.bind(i);return u(),e()}),t=await Promise.race([e,l]);if(u(),t===o&&en(),t.done)break;d+=t.value.byteLength,(++c>1e4||d>Zt)&&en(),a.push(t.value)}s=!0;const h=new Uint8Array(d);let f=0;for(const e of a)h.set(e,f),f+=e.byteLength;try{return JSON.parse((new TextDecoder).decode(h))}catch{return en()}}finally{t.removeEventListener("abort",c),s||d();try{r?.releaseLock()}catch{}}}function hn(e,t){const n=un(t);c(n)||en();const r=on(n,"docs");(!Array.isArray(r)||r.length>20)&&en();const i=/* @__PURE__ */new Map;for(const t of r){c(t)||en();const n=sn(on(t,"id"));e.ids.has(n)&&!i.has(n)||en(),i.set(n,t)}i.size!==e.ids.size&&en();for(const t of e.slots)an(t.owner,t.key,i.get(t.id))}function fn(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 pn(e){return fn(e,128)&&!e.includes("?")&&!e.includes("#")}function gn(e){return"number"==typeof e?Number.isFinite(e):"string"==typeof e&&fn(e,512)}var mn=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=y(e.log??b)}canMerge(e){try{const t=e.schema;return void 0!==t?(dn(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale),!0):null!==this.endpointOf(e)}catch{return!1}}endpointOf(e){try{const t=e.globalSlug;if(t)return pn(t)?{path:`globals/${encodeURIComponent(t)}`,field:"globalType",value:t}:null;const n=e.collectionSlug??"",r=e.data.id;return pn(n)&&gn(r)?{path:`${encodeURIComponent(n)}/${encodeURIComponent(String(r))}`,field:"id",value:String(r)}:null}catch{return null}}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};const t=this.attempt+=1,n=this.inflight;this.inflight=null;let r=null,i=!1;const s=()=>this.attempt!==t;try{if(n?.abort(),s())return{status:"superseded"};const t=e.schema;if(i=void 0!==t,void 0!==t){const n=dn(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale);if(s())return{status:"superseded"};if(0===n.requests.length)return{status:"merged",doc:n.doc};const i=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(s())return{status:"superseded"};if(void 0===i)return{status:"unavailable"};r=new AbortController,this.inflight=r;for(const e of n.requests){const t=await i(e.url,{method:"GET",credentials:"include",redirect:"error",signal:r.signal});if(s())return{status:"superseded"};const n=t.ok;if(s())return{status:"superseded"};if(!n){const e=t.status;return s()?{status:"superseded"}:(r.abort(),s()?{status:"superseded"}:(this.log("merge HTTP",e),s()?{status:"superseded"}:{status:"unavailable"}))}const o=await cn(t,r.signal,()=>!s());if(s())return{status:"superseded"};if(hn(e,o),s())return{status:"superseded"}}return{status:"merged",doc:n.doc}}const o=this.endpointOf(e);if(s())return{status:"superseded"};if(null===o)return{status:"unavailable"};const a=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(s())return{status:"superseded"};if(void 0===a)return{status:"unavailable"};const l=JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,locale:e.locale});if(s())return{status:"superseded"};r=new AbortController,this.inflight=r;const u=`${this.serverURL}${this.apiRoute}/${o.path}`,d=await a(u,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:l,signal:r.signal});if(s())return{status:"superseded"};const c=d.ok;if(s())return{status:"superseded"};if(!c){const e=d.status;return s()?{status:"superseded"}:(this.log("merge HTTP",e,u),s()?{status:"superseded"}:{status:"unavailable"})}const h=d.json.bind(d);if(s())return{status:"superseded"};const f=await h();if(s())return{status:"superseded"};if(null===f||"object"!=typeof f||Array.isArray(f))return this.log("merge invalid",u),s()?{status:"superseded"}:{status:"unavailable"};const p=f,g=p[o.field],m=Object.hasOwn(p,o.field)&&("id"===o.field?!gn(g)||String(g)!==o.value:g!==o.value);return s()?{status:"superseded"}:m?(this.log("merge invalid",u),s()?{status:"superseded"}:{status:"unavailable"}):{status:"merged",doc:p}}catch(e){return s()||i&&(r?.abort(),s())?{status:"superseded"}:(this.log("merge exception",i?new Error("legacy population could not be resolved"):e),s()?{status:"superseded"}:{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}}},vn="2.2.2",yn={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},bn={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},wn={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1},Sn="ssr",An=[bt,Mt,Dt,xt],kn=`[${bt}], [${Dt}], ${st}, ${zt}`,Rn=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:[..._t,Dt,it,Sn]})}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))return;for(const n of e){const e=Tn(n);if(null!==e&&(this.callbacks.onIslandHydrated?.(e),!this.isCurrentGeneration(t)))return}if(!function(e){for(const t of e){if("attributes"===t.type&&t.attributeName===it)return!0;if("attributes"===t.type&&null!==t.attributeName){if(An.includes(t.attributeName))return!0;if(_t.includes(t.attributeName)&&1===t.target.nodeType&&t.target.hasAttribute(bt))return!0}for(const e of t.addedNodes)if(Cn(e))return!0;for(const e of t.removedNodes)if(Cn(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 Tn(e){if("attributes"!==e.type||e.attributeName!==Sn||1!==e.target.nodeType)return null;const t=e.target;return"astro-island"!==t.tagName.toLowerCase()||t.hasAttribute(Sn)?null:t}function Cn(e){if(1!==e.nodeType)return!1;const t=e;return t.matches(kn)||null!==t.querySelector(kn)}var $n=class{#t=[];#n;#r=!1;constructor(e){this.#n=e}get closed(){return this.#r}own(e){this.#r?this.#i(e):this.#t.push(e)}close(){if(this.#r)return;this.#r=!0;const e=this.#t.splice(0).reverse();for(const t of e)this.#i(t)}#i(e){try{e()}catch(e){this.#n("runtime cleanup failed:",e)}}},Ln="[data-payload-field]";function Nn(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydration??={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]}}function Pn(){const e=Nn();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{}void 0===e.onCommit?e.commits.push(n):e.onCommit(n)}}function Fn(e){e.committed=!0;const t=e.waiters;e.waiters=[];for(const e of t)e()}function Un(e,t){const n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function Mn(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,Un(e,i),t("timed-out")},n),()=>{null!==r&&clearTimeout(r),r=null,Un(e,i)}}var xn="__vue_app__";function En(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewVueHydration??={armed:!1,committed:!1,waiters:[]}}function On(e){return Object.prototype.hasOwnProperty.call(e,xn)?e[xn]:void 0}function In(){const e=En();if(void 0===e||e.armed)return;e.armed=!0;const t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,xn)&&Object.defineProperty(t,xn,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,xn,{value:e,writable:!0,configurable:!0,enumerable:!0});const t=En();void 0===t||t.committed||null===this.querySelector(Ln)||function(e,t){const n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?Fn(e):n.hook("app:suspense:resolve",()=>{e.committed||Fn(e)})}(t,e)}})}function Dn(e){const t=e.hydration;if(void 0===t)return void e.startNow();const n=_n[t](e.root,n=>{e.later(()=>{jn(e,t,n)})});null!==n?(e.defer(n),e.hydrated("waiting")):jn(e,t,"committed")}var _n={react:(e,t)=>function(e,t=5e3){Pn();const n=Nn();if(void 0===n)return null;if(void 0===n.onCommit){const e=e=>{!n.committed&&function(e){const t=e;return null!=t&&function(e){const t=e;return 9===t?.nodeType||null!=t?.querySelector?.(Ln)}(t.containerInfo)&&!function(e){const t=[];for(null!==e.current&&void 0!==e.current&&t.push(e.current);t.length>0;){const e=t.pop();if(void 0===e)continue;const n=e.memoizedState;if((13===e.tag||31===e.tag)&&"object"==typeof n&&null!==n&&"dehydrated"in n&&"object"==typeof n.dehydrated&&null!==n.dehydrated&&"nodeType"in n.dehydrated&&8===n.dehydrated.nodeType)return!0;null!==e.sibling&&void 0!==e.sibling&&t.push(e.sibling),null!==e.child&&void 0!==e.child&&t.push(e.child)}return!1}(t)}(e)&&Fn(n)};n.onCommit=e;for(const t of n.commits.splice(0))e(t)}return Mn(n,e,t)}(t),vue:function(e,t,n=5e3){In();const r=En();return void 0===r?null:(!r.committed&&function(e){for(let t=e.querySelector(Ln);null!==t;t=t.parentElement)if(void 0!==On(t))return!0;return!1}(e)&&Fn(r),Mn(r,t,n))},sveltekit:function(e,t,n=5e3){const r=e.ownerDocument??e,i=()=>null!==r.querySelector("#svelte-announcer");if(i()||!Object.keys(window).some(e=>e.startsWith("__sveltekit_")))return null;const s={committed:!1,waiters:[]},o=new MutationObserver(()=>{!s.committed&&i()&&Fn(s)});o.observe(r,{childList:!0,subtree:!0});const a=Mn(s,e=>{o.disconnect(),t(e)},n);return()=>{o.disconnect(),a?.()}}},Bn={react:"React commit",vue:"Vue mount",sveltekit:"SvelteKit mount"};function jn(e,t,n){e.hydrated(n),"timed-out"===n&&e.warn(`[live-preview] LP0607: no ${Bn[t]} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}function zn(e){return 9===e.nodeType}function Hn(e){return e.body}var Wn=class{timeoutMs;onTimeout;handle=null;lastKick=null;constructor(e){this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){this.lastKick=Date.now(),this.timeoutMs<=0||(this.stop(),this.arm(this.timeoutMs))}resume(){if(this.timeoutMs<=0||null!==this.handle||null===this.lastKick)return!1;const e=Math.max(0,Date.now()-this.lastKick),t=this.timeoutMs-e;return t<=0?(this.lastKick=null,this.onTimeout(),!0):(this.arm(Math.min(t,this.timeoutMs)),!1)}arm(e){const t=setTimeout(()=>{this.handle===t&&(this.handle=null,this.lastKick=null,this.onTimeout())},e);this.handle=t}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick??0}get pending(){return null!==this.handle}},qn=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)}},Vn=/* @__PURE__ */new Set(["true","false","yes","no","on","off"]),Gn=/^[\d\s.,:+/-]+$/u,Kn=/^[a-z][a-z0-9_-]*$/u,Jn=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,Qn=/* @__PURE__ */new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]);function Xn(e,t=13){if("string"!=typeof e)return!1;const n=e.trim();return!(n.length<t||Gn.test(n)||Vn.has(n.toLowerCase())||Kn.test(n)||Jn.test(n))}function Zn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Yn(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,s]of Object.entries(e)){if(Te.has(r))continue;const e=$e(r,t);if(Xn(s,n))i(s.trim(),e,!1);else if(Zn(s))if("string"==typeof s.url)i(s.url,e,!0);else if(!("id"in s)&&!("_id"in s))for(const[t,r]of Object.entries(s))!Te.has(t)&&Xn(r,n)&&i(r.trim(),`${e}.${t}`,!1)}return r}function er(e){if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||Qn.has(e.tagName))return!0;if(e.hasAttribute(bt)||e.hasAttribute("data-payload-no-bind")||e.hasAttribute(ot)||ut(e))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function tr(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 nr(e){return q(e)&&!e.startsWith("data-payload-")&&"value"!==e}function rr(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 ir(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(er(n))continue;const e=tr(n),r=void 0===e?void 0:t.values.get(e);null==r||r.media||(rr(t,n,r).text=r.field);for(const e of n.getAttributeNames()){if(!nr(e))continue;const r=t.values.get(n.getAttribute(e)??"");null!=r&&(!r.media||"IMG"===n.tagName&&"src"===e)&&rr(t,n,r).attributes.set(e,r)}ir(n,t)}}function sr(e,t,n){const r=e.tagName;if(void 0!==t){const i={[bt]:t};if("A"===r){const e=n.get("href");void 0===e?i[wt]="text":e!==t&&(i[At]=e)}return{element:e,fieldName:t,matched:tr(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:{[bt]:t,...void 0!==r&&r!==t?{[Rt]:r}:{}}}}}const i=n.entries().next();if(i.done)return;const[s,o]=i.value;return{element:e,fieldName:o,matched:e.getAttribute(s)??"",attribute:s,stamps:{[bt]:o,[St]:s}}}function or(e,t){const n={values:t,byElement:/* @__PURE__ */new Map,byField:/* @__PURE__ */new Map};t.size>0&&!er(e)&&ir(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,s=/* @__PURE__ */new Map;for(const[e,n]of t.attributes)r(n.field)&&s.set(e,n.field);const o=sr(e,n,s);void 0!==o&&i.push(o)}return i}function ar(e){return 9===e.nodeType?e.body:e}function lr(e,t){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(void 0!==r){r.observed&&e.observers.unobserveElement(r.element);for(let e=r.attributes.length-1;e>=0;e-=1){const t=r.attributes[e];if(void 0===t)continue;const{name:n,before:i,written:s}=t;i!==s&&r.element.getAttribute(n)===s&&(null===i?r.element.removeAttribute(n):r.element.setAttribute(n,i))}r.cacheTouched&&(r.element.hasAttribute(bt)?e.cache.add(r.element):e.cache.remove(r.element))}}}function ur(e,t,n,r,i){const s=[],o=[],a=()=>(lr(e,o),[]);for(const l of t){if(!i())return a();const{element:t}=l;if(t.hasAttribute(bt))continue;if(!i())return a();if(!1!==n&&!ge(Ht(t),n))continue;if(!i())return a();const u={element:t,attributes:[],cacheTouched:!1,observed:!1};o.push(u);for(const[e,n]of[...Object.entries(l.stamps),[It,l.matched]]){const r=t.getAttribute(e);if(!i())return a();if(u.attributes.push({name:e,before:r,written:n}),t.setAttribute(e,n),!i())return a()}if(u.cacheTouched=!0,void 0!==e.cache.add(t)){if(!i())return a();if(e.observers.observeElement(t),u.observed=!0,!i())return a();if(e.log("autoBind",l.fieldName,"→",`<${t.tagName.toLowerCase()}>`,l.attribute??"text",JSON.stringify(l.matched),r),!i())return a();s.push(l)}else lr(e,[u]),o.pop()}return s}function dr(e,t,n,r){if(!e.scopeBindingsByOwner)return!1;const{message:i}=n,s=function(e){if(pe(e.globalSlug))return[(t=e.globalSlug,`global:${t}`)];var t;if(!pe(e.collectionSlug))return null;const n=fe(e.collectionSlug);return pe(e.documentId)?[n,fe(e.collectionSlug,e.documentId)]:[n]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:me(r)});return null!==s||t.warnedUnattributableMessage||(t.warnedUnattributableMessage=!0,e.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),s}var cr=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;awaitingHydration=/* @__PURE__ */new WeakSet;delivered=/* @__PURE__ */new WeakMap;confirmations=/* @__PURE__ */new WeakMap;reapplyBindings(e){const t=this.currentTransaction();void 0!==t?.renderData&&this.host.schedule(t,t.renderData,e)}reapplyIslands(e,t=!1){const n=t?e.filter(e=>this.awaitingHydration.delete(e)):e,r=this.state.activeUpdate,i=t&&null!==r&&this.state.isCurrent(r)?r:this.currentTransaction();void 0!==i?.renderData&&this.dispatchIslands(i,i.renderData,n)}dispatchIslands(e,t,n){const r=dr(this.deps,this.state,e,t.fields),i=()=>!e.cancelled&&this.state.isCurrent(e);if(!i())return;let s=this.delivered.get(t);void 0===s&&(s=/* @__PURE__ */new WeakSet,this.delivered.set(t,s));for(const o of n){const n=Ht(o);if(!i())return;if(!1!==r&&!ge(n,r)){this.awaitingHydration.delete(o);continue}const a=this.confirmation(o,e);if(dt(o))this.awaitingHydration.add(o);else{if(this.awaitingHydration.delete(o),s.has(o))continue;s.add(o),hr(e,t,[o],i,a)}}}hasLateRouteBinding(e,t,n,r){for(const r of e){if((r.getAttribute(bt)??"").length>0||"route"!==r.getAttribute(Et))continue;if(!1!==t&&!ge(Ht(r),t))continue;const e=tt(r.getAttribute(xt));if(0===e.length||e.some(e=>n.touched.has(e)))return!0}for(const[i,s]of this.deps.cache.entries())for(const o of s){if(!e.has(o.element))continue;if(!1!==t&&!ge(o.owner,t))continue;if("route"!==(o.strategyKind??he(o.element)??"unknown"))continue;const s=oe(r.fields,o,i,n.locale);if(!this.state.isCurrent(n))return!1;if(void 0!==s)return!0}return!1}fieldsForElements(e,t){const n=new Set(t);for(const[t,r]of this.deps.cache.entries())r.some(t=>e.has(t.element))&&n.add(t);return n}unrunFragmentPlan(e,t,n){if(null===t)return null;const r=t.boundaries.filter(t=>!e.fragmentBoundariesRun.has(t)&&(void 0===n||[...n].some(e=>e===t||t.contains(e))));return ce(t.strategy,r,t.ownerKeys)}confirmation(e,t){const n=this.confirmations.get(e);if(n?.transaction===t)return n.displayed;const r=this.state.display.handIsland(t);return this.confirmations.set(e,{transaction:t,displayed:r}),r}currentTransaction(){const e=this.state.activeUpdate;return this.state.navigationBindingReplay&&null!==e&&this.state.isCurrent(e)?e:null}};function hr(e,t,n,r,i){!function(e,t,n){let r=0;for(const i of e){if(!n())break;if(i.dispatchEvent(new CustomEvent("payload-live-preview:update",{detail:t,bubbles:!1})),r+=1,!n())break}}(n,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale,displayed:i},r)}function fr(e,t,n,r,i){const{warned:s,warn:o}=e;if(s.has(n)||t(n))return;s.add(n);const a=`data-payload-field="${$e(n,r)}"`;o(""!==i?`[live-preview] LP0203: field "${n}" has a value and no <… ${a}> on this page; editing it changes nothing here. Expected where the page shows part of the document: inspect().fidelity.fields lists these, onUnfaithfulPatch decides whether a server render is asked for.`:`[live-preview] LP0201: no <… ${a}> for the empty field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)}function pr(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function gr(e){return Array.isArray(e.docs)&&"boolean"==typeof e.hasNextPage}function mr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var vr=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function yr(e){const t=function(){const e=function(){const e=globalThis,t=e[vr];if(void 0!==t)return t;const n={};return e[vr]=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 br=/* @__PURE__ */new Set(["open","value","checked","selected"]);function wr(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function Sr(e,t,n){if(!Rr(e,t))return t;const r=n.boundary??at,i=r(e),s=r(t);if(i||s)return i&&s&&(n.retainBoundary?.(e,t)??1)?e:t;const o=Tr(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||br.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=wr(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()),s=Array.from(e.childNodes).filter(e=>!i.has(e)),o=/* @__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?wr(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&&!o.has(e)&&(c=Ar(e,i,n)===e?e:null,null===c)){e.replaceWith(i),o.add(i),u=i.nextSibling;continue}}else{for(;d<s.length;){const r=s[d];if(d+=1,!o.has(r)){if(Rr(r,i)){c=Ar(r,i,n)===r?r:null,null===c&&(e.replaceChild(i,r),o.add(i),u=i.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(i instanceof Element)||void 0!==n&&Rr(r,n)){d-=1;break}e.replaceChild(i,r),o.add(i),u=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,r),o.add(i),u=i.nextSibling;break}}}if(null===c&&o.has(i))continue}const f=c??i;for(o.add(f);null!==u&&u!==f&&!o.has(u)&&kr(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(const t of Array.from(e.childNodes))o.has(t)||t.remove()}(e,t,n),Cr(o),e}function Ar(e,t,n){return e instanceof Element&&t instanceof Element?Sr(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function kr(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function Rr(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function Tr(e){const t=e.ownerDocument.activeElement;return t instanceof HTMLElement&&e.contains(t)?{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}:null}function Cr(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{}}var $r=/* @__PURE__ */new Set;function Lr(e){$r.has(e)||($r.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)":"Put it on an element the template owns, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var Nr=/* @__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"]),Pr=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),Fr=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),Ur=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),Mr="aria-",xr="data-",Er={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"])},Or=/* @__PURE__ */new Set(["href","src","cite","poster","action","formaction"]),Ir=class extends Error{name="SanitizerEnvironmentError"},Dr=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-morph","data-payload-nested-key","data-payload-nested-template"]),_r=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function sanitizeHtml(e,t){return Br(e,void 0,t)}function Br(e,t,n){const r=n?.document??Hr();if(!r)throw jr();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(Er))e.set(t,n);return{allowedTags:Nr,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(Nr);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of Pr)r.add(e);const i=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(Er))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);let s=e;for(let e=0;e<6;e+=1){const e=r.createElement("template");e.innerHTML=yr(s);const t=e.content;Wr(t,i);const n=zr(t);if(n===s)return n;s=n}return function(e,t){if(!function(){try{const e=globalThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}())return;const n=globalThis,r=n.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!r.has(e)){r.add(e);try{console.warn(`[payload-live-preview] ${t}`)}catch{}}}("sanitizer-unsettled",`sanitizeHtml: the output did not settle after ${String(6)} passes, so it returned an empty string (ADR 0016).`),""}function jr(){return"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new Ir("sanitizeHtml needs a DOM; pass one per call during SSR: { document } (linkedom, jsdom).")}function zr(e){const t=e.ownerDocument?.createElement("div");if(void 0===t)throw jr();const n=e.firstChild;if(t.append(e),t.firstChild!==n)throw jr();return t.innerHTML}function Hr(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[_r];if(e)return e}if("undefined"!=typeof document)return document}function Wr(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?qr(n,t):8===n.nodeType&&n.remove()}function qr(e,t){const n=e.tagName.toLowerCase();if(!Fr.has(n)||t.allowFormControls&&Pr.has(n)){if(!t.allowedTags.has(n))return Wr(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("is"!==i){if("strict"===n.mode){if(n.templateMode&&Dr.has(i))continue;if("id"===i||"name"===i||i.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===i&&!0!==r?.has(i)||Lr(i);continue}if(i.startsWith(xr)){n.allowedData.has(i)||(e.removeAttribute(t.name),Lr(i));continue}if(Ur.has(i)||i.startsWith(Mr))continue}else if(Ur.has(i)||i.startsWith(Mr)||i.startsWith(xr))continue;r?.has(i)?Or.has(i)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):("srcset"!==i||Vr(t.value))&&("ping"!==i||t.value.trim().split(/\s+/u).every(isSafeUrl))||e.removeAttribute(t.name):e.removeAttribute(t.name)}else e.setAttribute("is","")}}(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),Wr(e,t)}else e.remove()}function Vr(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)||!isSafeUrl(e))return!1}return!0}var Gr=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}),Kr=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(Kr,e=>Gr[e])}var Jr=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'"}),Qr=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(Qr,e=>Jr[e])}var Xr=/\{\{([\s\S]*?)\}\}/g;function Zr(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 Yr(e,t,n,r,i){const s="object"==typeof t&&null!==t?t:null;return e.replace(Xr,(e,o)=>null!==s&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(s,o)?escapeHtml(r(Reflect.get(s,o))):null===s&&"value"===o?escapeHtml(r(t)):"index"===o?String(n):null!==s&&!0===i?.has(o)?"":e)}function ei(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(!q(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 ti(e,t){for(const[n,r]of t)e.hasAttribute(n)||e.setAttribute(n,r)}function ni(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 ri(e){return null==e||""===e}function ii(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function si(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 oi=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],ai=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],li=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,ui=/* @__PURE__ */new Map;function di(e){const t=ii(ui,e);if(void 0!==t)return t;const n=new Set(oi);for(const t of e.matchAll(li)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const r={};for(const e of n)r[e]=ai;const i={additionalAllowedTags:[...n],additionalAllowedAttributes:r,allowFormControls:!0,templateMode:!0};return si(ui,e,i,64)}var ci="data-payload-key",hi="data-payload-nested-key",fi="data-payload-nested-template";function pi(e){const t=mi(e.container,e.patches,e);return null===t?null:vi(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function gi(e,t){return t.hasAttribute(hi)&&t.hasAttribute(fi)}function mi(e,t,n){const r=function(e,t,n){const{template:r,nextItems:i,forceRender:s=!1,store:o,sanitizerPolicy:a}=n,l=o.get(e),u=ei(e),d=Zr(i),c=Array.from(e.children),h=Ri(c,ci),f=/* @__PURE__ */new Set,p=[];for(let o=0;o<i.length;o+=1){const g=i[o],m=ki(g);let v=void 0===m?c[o]??null:Ti(h,m)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);const y=t.replaces.has(o),b=s||t.renders.has(o)||null===v?Ci(e.ownerDocument,r,g,o,a,u,d):void 0;if(null===b)return null;const w=void 0===b?[]:yi(y?null:v,b,g,void 0===m?void 0:l?.get(m),n);if(null===w)return null;p.push([o,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 vi(e,t,n){const[r,i,s]=e,o=/* @__PURE__ */new Set;let a=!1;const l=Tr(r);for(const[e,s,l,u,d]of i){let i=s;if(void 0!==l){const e=!(!n.morph||d||null===s)&&Sr(s,l,{keyAttributes:[ci,hi],boundary:at,retainBoundary:mt,retainChildrenOf:gi,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===s;if(!e)for(const[e,t]of u)null!==e&&(wi(e,t),t.replaceWith(e));for(const[,,e]of u)void 0!==e&&vi(e,t,n);e?a=!0:(null!==s&&(s.replaceWith(l),a=!0),i=l)}if(null===i)continue;const c=r.children[e]??null;i!==c&&(r.insertBefore(i,c),a=!0),o.add(i)}for(const e of Array.from(r.children))o.has(e)||(e.remove(),a=!0);Cr(l);const u=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(r,t);u.clear();for(const e of s)Ai(u,e);return a}function yi(e,t,n,r,i){const s=Ri(null===e?[]:bi(e),hi),o=[];for(const e of bi(t)){const t=e.getAttribute(hi);if(null===t)continue;const a=Ti(s,t)??null,l=e.getAttribute(fi),u=l?a:null,d=u?.getAttribute(fi)??null;let c;if(l){const s=Si(n,t);if(void 0!==s||null!==u){const n=s??[],o=x(null===u?[]:Si(r,t)??[],n),a=null!==u&&d!==l;if((o.length>0||a)&&(c=mi(u??e,o,{template:l,nextItems:n,forceRender:a,store:i.store,sanitizerPolicy:i.sanitizerPolicy})??void 0,void 0===c))return null}}o.push([u,e,c])}return o}function bi(e){return Array.from(e.querySelectorAll(`[${hi}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(hi))return!1;n=n.parentElement}return n===e})}function wi(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 Si(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function Ai(e,t){const n=ki(t);void 0!==n&&e.set(n,t)}function ki(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Ri(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 s=i.getAttribute(t);if(null===s)continue;const o=n.get(s);void 0===o?n.set(s,[i]):o.push(i)}return n}function Ti(e,t){return e.get(t)?.pop()}function Ci(e,t,n,r,i,s,o){const a=Br(Yr(t,n,r,ni,o),i,di(t)),l=e.createElement("template");l.innerHTML=yr(a);const u=l.content.firstElementChild;if(!u)return null;ti(u,s);const d=ki(n);return void 0!==d&&u.setAttribute(ci,d),u}function $i(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 Li(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`))}function Ni(e,t,n){if(t.warnedEscalationUnavailable)return;t.warnedEscalationUnavailable=!0;const r=`[live-preview] LP0808: onUnfaithfulPatch: 'escalate' has nowhere to go: ${String(n)} field(s) fell short`,i="or onUnfaithfulPatch: 'warn' to keep the patch and say so.";e.warn(void 0===e.strategies.fragment?`${r} and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, ${i}`:`${r}, not all of them inside a data-payload-fragment boundary of this document, and no route strategy is configured. Cover them with a boundary or add the route strategy, ${i}`)}var Pi=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;planFragments(e,t){const{deps:n,state:r}=this,i=n.strategies.fragment;if(void 0===i)return null;const s=new Set(i.plan(n.root,e));for(const e of r.fragmentsOwed)n.root.contains(e)?s.add(e):r.fragmentsOwed.delete(e);return ce(i,[...s].filter(e=>Fi(e,t)),t)}escalateUnfaithful(e,t,n,r){if(e.routeRefreshed)return void this.kept(e,n);const{fragment:i,route:s}=this.deps.strategies,o=void 0===i?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),a=void 0===o||o.every(e=>Fi(e,r))?o:void 0;return void 0!==i&&void 0!==a?(this.state.escalatedCount+=n.length,e.pendingFragments+=a.length,void this.runFragments(e,t,ce(i,a,r))):void 0===s?(Ni(this.deps,this.state,n.length),void this.kept(e,n)):(this.state.escalatedCount+=n.length,void this.refreshRoute(e,t,s))}kept(e,t){for(const n of t)this.state.display.shortfall(e,{kind:"unfaithful",field:n.fieldName})}hasUnboundChange(e,t){const{deps:n,state:r}=this;if(e.baseline||e.routeRefreshed)return!1;const i=Pe(n.cache,e.touched,e.locale,t,this.subfields(e),n.strategies);let s=0;for(const e of i)J(r,e)&&(s+=1);const[o]=i;if(void 0===o)return!1;if("escalate"!==n.onUnfaithfulPatch||void 0===n.strategies.route){"escalate"===n.onUnfaithfulPatch&&Ni(n,r,i.length);for(const t of i)r.display.shortfall(e,{kind:"unbound",field:t});return!1}return e.navigated?(r.routeAwaitsSave=!0,r.display.shortfall(e,{kind:"route-saved"}),!1):(n.log("route","LP0807",`field "${o}" has no binding; refreshing the route`),r.escalatedCount+=s,!0)}subfields(e){const{previousFields:t}=this.state.changes;return Ne(this.deps.subfieldCoverage,t,e.renderData?.fields)}plansRoute(e,t,n){const r=e=>!1===n||ge(e,n),i=function(e,t,n){const r=e.rendered.flatMap(e=>"route"===e.strategy?e.paths:[]);for(const[t,n]of e.entries())n.some(e=>"route"===e.strategyKind)&&r.push(t);const i=new Set(t);for(const e of r){const[r=e]=e.split(".");t.has(r)&&(void 0===n||ke(e,n.previous,n.next))&&i.add(e)}return i}(this.deps.cache,t.touched,this.subfields(t));if(e.plan(this.deps.root,i,{inScope:e=>r(Ht(e))}))return!0;for(const[e,t]of this.deps.cache.entries())if(i.has(e)&&t.some(e=>"route"===e.strategyKind&&r(e.owner)))return!0;return!1}async runFragments(e,t,n){const{deps:r,state:i}=this,s=new AbortController,o=new Set(n.boundaries);for(const e of o)i.fragmentsOwed.delete(e);i.fragmentControllers.set(s,o);const a=t=>{o.delete(t)&&(e.pendingFragments-=1)},l=()=>i.isCurrent(e)&&!s.signal.aborted,u=e=>function(e,t,n){if(t.isConnected)return t;const r=t.getAttribute(le),i=t.getAttribute(ue);let s;for(const t of e.querySelectorAll(`[${le}]`))if(t.getAttribute(le)===r&&t.getAttribute(ue)===i&&n(t)){if(void 0!==s)return;s=t}return s}(r.root,e,e=>Fi(e,n.ownerKeys)),{emitter:d}=r,{message:c}=e,h=e.revision.revision,f=e.receivedAt,p={root:r.root,revision:h,receivedAt:f,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof c.collectionSlug?c.collectionSlug:void 0,globalSlug:"string"==typeof c.globalSlug?c.globalSlug:void 0,signal:s.signal,isCurrent:l,log:(e,t)=>{r.log("fragment",e,t)},morph:(e,t)=>{const n=l()?u(e):void 0;void 0!==n&&function(e,t,n){const r=e.ownerDocument.createElement("template");r.innerHTML=yr(t);const i=e.cloneNode(!1);i.append(r.content);const s=vt(e);Sr(e,i,{keyAttributes:[ci],boundary:at,retainBoundary:mt}),function(e){for(const t of e)t.isConnected||ft.has(t)||(ft.add(t),t.dispatchEvent(new CustomEvent("astro:unmount")))}(s);const o=new Set(s);for(const t of vt(e)){const e=o.has(t)?void 0:yt(t);void 0!==e&&n(t,e)}}(n,t,(e,t)=>{!function(e,t,n,r){if(t.warnedIslandStart)return;t.warnedIslandStart=!0;const i="element"===r?"<astro-island>":`client:${n.getAttribute("client")??""}`;e.warn(`[live-preview] LP0809: a fragment island cannot start: this page never loaded ${i}; render one on the page`)}(this.deps,this.state,e,t)})},patch:r=>{const i=u(r);void 0!==i&&(i!==r&&this.host.rebuildCache(),this.patchFallback(e,t,i,n.ownerKeys,l))},rendered:(e,t,n)=>{a(e);const r=u(e)??e;d.emitWhile("fragmentRender",{element:r,id:t,key:n,status:"rendered",revision:h,receivedAt:f},l)},failed:(t,n,s,o,c)=>{a(t);const p=u(t)??t;i.display.shortfall(e,{kind:"fragment",id:n,key:s,code:o});const g=`fragment "${n}" fell back to patch: ${c}`;r.log("fragment",o,g),d.emitWhile("error",{error:new Error(g),context:"fragment",code:o},l),d.emitWhile("fragmentRender",{element:p,id:n,key:s,status:"failed",code:o,revision:h,receivedAt:f},l)}};let g={rendered:0,failed:0,superseded:0};try{g=await n.strategy.render(p,n.boundaries)}catch(t){if(r.log("fragment","LP0801",t),l()){for(const t of n.boundaries)p.patch(t),i.display.shortfall(e,Qe(t));g={rendered:0,failed:n.boundaries.length,superseded:0}}}i.fragmentStats.rendered+=g.rendered,i.fragmentStats.failed+=g.failed,i.fragmentStats.superseded+=g.superseded,i.fragmentControllers.delete(s);for(const e of o)a(e);l()&&(g.rendered>0&&this.host.restoreGuesses(e,t),0===e.pendingFragments&&0===r.scheduler.pendingCount&&i.complete(e),this.host.revealPending(e),l()&&0!==g.rendered&&0!==d.listenerCount("afterUpdate")&&d.emitWhile("afterUpdate",{data:t,updatedCount:g.rendered,durationMs:Date.now()-f,revision:h,receivedAt:f,source:"fragment"},l))}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,!1).catch(e=>{this.routeFailed(e)})}refreshAfterSave(){const{deps:e,state:t}=this,{route:n}=e.strategies,r=t.activeUpdate;t.routeAwaitsSave&&void 0!==n&&void 0!==r?.renderData&&(e.log("route","document saved; refreshing the route"),this.runRoute(r,r.renderData,n,!0).catch(e=>{this.routeFailed(e)}))}routeFailed(e){this.deps.log("route refresh failed:",e)}armRouteRetry(e,t,n,r,i){const{state:s}=this;null!==s.routeRetry&&clearTimeout(s.routeRetry),s.routeRetry=setTimeout(()=>{s.routeRetry=null,s.isCurrent(e)&&this.runRoute(e,t,n,i).catch(e=>{this.routeFailed(e)})},r)}async runRoute(e,t,n,r){const{deps:i,state:s}=this,o=s.routeStats,a=new AbortController;s.routeController?.abort(),s.routeController=a;const l=()=>!a.signal.aborted;let u;try{u=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:a.signal,isCurrent:l,log:(e,t)=>{i.log("route",e,t)},retryAfter:i=>{this.armRouteRetry(e,t,n,i,r)}})}catch(e){i.log("route","LP0801",e),u="failed"}if(!l())return;s.routeController=null;const d=s.activeUpdate;if(null===d)return;const c=d.renderData,h=()=>s.isCurrent(d);if("partial"===u?s.display.shortfall(d,{kind:"route-saved"}):("failed"===u||"superseded"===u||"refused"===u&&null===s.routeRetry)&&s.display.shortfall(d,{kind:"route-failed",outcome:u}),"refreshed"===u||"partial"===u){if(o.refreshes+=1,"partial"===u&&(o.partial+=1),s.routeAwaitsSave="partial"===u&&!r,s.lastAppliedIdentity=/* @__PURE__ */new WeakMap,void 0!==c&&this.host.restoreGuesses(d,c),this.host.rebuildCache(),void 0===c||!h())return;return this.host.reapply(d,c),void(i.emitter.listenerCount("afterUpdate")>0&&i.emitter.emitWhile("afterUpdate",{data:c,updatedCount:i.cache.elementCount,durationMs:Date.now()-d.receivedAt,revision:d.revision.revision,receivedAt:d.receivedAt,source:"route"},h))}"failed"===u?o.failed+=1:"refused"===u&&(o.refused+=1),void 0!==c&&this.host.reapply(d,c)}warnFragmentFallback(e){$i(this.deps,this.state,e)}warnUnsupportedStrategy(e){Li(this.deps,this.state,e)}patchFallback(e,t,n,r,i){if(i())for(const[s,o]of this.deps.cache.entries())for(const a of o){if(a.fragmentBoundary!==n)continue;if(!1!==r&&!ge(a.owner,r))continue;const o=oe(t.fields,a,s,e.locale);void 0!==o&&i()&&this.deps.scheduler.schedule({target:a,value:this.host.transform(a,o,t.fields,i),allFields:t.fields,revision:e.revision,data:t})}}};function Fi(e,t){return!1===t||ge(Ht(e),t)}function Ui(e,t,n,r,i){const s=e.transformValue;if(void 0===s)return n;try{const e=s(t.fieldName,n,{element:t.element,allFields:r},i),o=g(e);if(!i())return n;if(o)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 Mi=/* @__PURE__ */new Set,xi={kind:"merge"},Ei=class{constructor(e,t,n){this.deps=e,this.state=t,t.changes.keepValues="declared"===e.subfieldCoverage,t.display.host=function(e,t){return{outstanding:n=>!n.completed||n.pendingFragments>0||null!==t.routeController||null!==t.routeRetry||e.scheduler.pendingCount>0,report:t=>{"partial"===t.state&&e.a11y?.announcePartial(),e.emitter.emit("revisionDisplay",t)},failed:t=>{e.log("revision display failed:",t)}}}(e,t),this.strategies="undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e,t){return{planFragments:()=>null,escalateUnfaithful:(e,n,r)=>{for(const{fieldName:n}of r)t.display.shortfall(e,{kind:"unfaithful",field:n})},hasUnboundChange:(n,r)=>{if(n.baseline)return!1;const i=Pe(e.cache,n.touched,n.locale,r,Ne(e.subfieldCoverage,t.changes.previousFields,n.renderData?.fields));for(const e of i)J(t,e),t.display.shortfall(n,{kind:"unbound",field:e});return!1},plansRoute:()=>!1,runFragments:()=>Promise.resolve(),refreshRoute:()=>(T("route refreshes"),Promise.resolve()),refreshAfterSave:()=>{},warnFragmentFallback:n=>{T("server-rendered fragments"),$i(e,t,n)},warnUnsupportedStrategy:n=>{Li(e,t,n)}}}(e,t):new Pi(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,r,i)=>Ui(e,t,n,r,i),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}}),this.navigationReplay=new cr(e,t,{schedule:(e,t,n)=>{this.scheduleAllFields(e,t,n)}})}deps;state;strategies;navigationReplay;handleUpdate(e,t,n){const{deps:r,state:i}=this;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);const s=e.data;void 0!==s?void 0!==n&&this.acceptDataUpdate(e,s,t,n,!0):void 0!==e.protocolVersion&&i.protocol.applyVersion(e.protocolVersion,r.log)}handleReplay(e,t,n){const r=e.data;void 0!==r&&this.acceptDataUpdate(e,r,t,n,!1)}reapplyNavigationBindings(e){this.navigationReplay.reapplyBindings(e)}reapplyNavigationIslands(e,t=!1){this.navigationReplay.reapplyIslands(e,t)}acceptDataUpdate(e,t,n,r,i){const{deps:s,state:o}=this,a=i?o.relationships.inspect(e):null,l="string"==typeof e.locale?e.locale:o.locale;let u=o.schema,d=o.schemaIndex;Array.isArray(e.fieldSchemaJSON)&&(u=e.fieldSchemaJSON,d=function(e,t=""){const n=/* @__PURE__ */new Map;return P(e,t,n,!1),P(e,t,n,!0),n}(e.fieldSchemaJSON));const c=o.activeUpdate;if(!o.isRunning()||null!==c&&c.revision.revision>r.revision)return;const h=null===a?null:o.relationships.commit(a),f=c,p={revision:r,message:e,rawData:t,locale:l,schema:u,schemaIndex:d,receivedAt:Date.now(),forceRender:null!==h||ze(f),countsAsUpdate:i,renderData:void 0,fragmentBoundariesRun:/* @__PURE__ */new WeakSet,touched:/* @__PURE__ */new Set,baseline:!1,navigated:!1,invalidated:/* @__PURE__ */new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1};if(o.locale=l,o.schema=u,o.schemaIndex=d,null!==f&&!f.completed&&f.countsAsUpdate&&(o.supersededCount+=1),o.activeUpdate=p,i&&(o.updateCount+=1),o.display.begin(p,r.revision),o.isCurrent(p)&&(s.scheduler.acceptRevision(r),o.isCurrent(p)&&(o.supersedeStrategies(),o.isCurrent(p)&&(null===h||(s.emitter.emitWhile("relationshipUpdate",{detail:h,timestamp:Date.now()},()=>o.isCurrent(p)),o.isCurrent(p)))&&(!i||void 0===e.protocolVersion||(o.protocol.applyVersion(e.protocolVersion,s.log),o.isCurrent(p)))))){if(i&&s.connection.markConnected()){if(s.a11y?.announceConnected(),s.emitter.emit("connect",{origin:n,timestamp:Date.now()}),!o.isCurrent(p))return;if(s.log("connection","disconnected","→","connected"),!o.isCurrent(p))return}this.processUpdate(p).catch(e=>{s.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;if(!i.isCurrent(e))return;if(i.changes.isBaseline&&!n&&"off"!==r.autoBind){if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)T("auto-binding");else{const n=dr(r,i,e,t.fields);!function(e,t,n,r,i,s){if(!s())return 0;const o=performance.now(),a=ar(e.root),l=Yn(n,r);if(!s())return 0;const u=null===a?[]:or(a,l);if(!s())return 0;const d=ur(e,u,i,"on the first message",s);if(!s())return 0;const c=function(e,t){const n=/* @__PURE__ */new Set;for(const{fieldName:e,stamps:r}of t){n.add(e);for(const e of[At,Rt]){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}}(l,d),h=performance.now()-o;s()&&(t.autoBindGuesses=c,t.autoBindSearchMs=h,d.length)}(r,i,t.fields,e.locale,n,()=>i.isCurrent(e))}if(!i.isCurrent(e))return}const s=nt(r.dependencies,r.cache.dependencyMap());if(!i.isCurrent(e))return;const o=i.changes.diff(t.fields,s,()=>i.isCurrent(e));if(null===o)return;const a=!n&&i.navigationReplayPending;a&&(i.navigationReplayPending=!1,i.navigationBindingReplay=!0),e.baseline=o.baseline&&!a,e.navigated=a,e.invalidated=n?Mi:o.invalidated,e.touched=n?Mi:/* @__PURE__ */new Set([...o.changed,...o.invalidated]),e.renderData=t,this.scheduleAllFields(e,t)}async resolveIncomingFields(e){const{deps:t,state:n}=this,r=e.rawData;if(null===t.merger)return r;const i=n.merges.decide(t,e);if(!i.merge)return i.fields;const{message:s}=e,o=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:s.collectionSlug,globalSlug:s.globalSlug,data:r,...void 0===e.schema?{}:{schema:e.schema},locale:e.locale});if(!o.leading)return this.applyMerged(e,o.result).catch(e=>{t.log("update failed:",e)}),i.fields;const a=await o.result;return n.isCurrent(e)?"merged"===a.status?(n.merges.recordMerged(a.doc,e.locale),a.doc):"superseded"===a.status?null:(n.display.shortfall(e,xi),i.fields):null}async applyMerged(e,t){const{state:n}=this,r=await t;"unavailable"===r.status&&n.display.shortfall(e,xi),"merged"===r.status&&n.isCurrent(e)&&(n.merges.recordMerged(r.doc,e.locale),this.applyFields(e,this.dataFor(e,r.doc),!0))}scheduleAllFields(e,t,n){const{deps:r,state:i}=this;if(!i.isCurrent(e))return;const s=void 0!==n,o=()=>i.isCurrent(e),a=dr(r,i,e,t.fields);if(!o())return;const{touched:l}=e,u=r.strategies.route;if(s&&void 0!==u&&!e.routeRefreshed&&this.navigationReplay.hasLateRouteBinding(n,a,e,t))return void(o()&&this.strategies.refreshRoute(e,t,u));const d=!s&&this.strategies.hasUnboundChange(e,a),c=i.routeRefreshOwed;if(!s&&void 0!==u&&!e.routeRefreshed&&(d||c||this.strategies.plansRoute(u,e,a))&&o())return i.routeRefreshOwed=!1,void this.strategies.refreshRoute(e,t,u);const h=s?this.navigationReplay.fieldsForElements(n,l):l,f=this.navigationReplay.unrunFragmentPlan(e,this.strategies.planFragments(h,a),n);if(!o())return;const p=r.skipUnchanged;let g=0;for(const[l,u]of r.cache.entries()){if(!o())return;for(const d of u){if(void 0!==n&&!n.has(d.element))continue;if(!1!==a&&!ge(d.owner,a))continue;if(!0===f?.covers(d)){if(r.revealEditedField){const n=oe(t.fields,d,l,e.locale);i.revealLedger.note(e,d,n)}continue}const u=d.strategyKind??he(d.element)??"unknown";if("unknown"===u){this.strategies.warnUnsupportedStrategy(d);continue}"fragment"===u&&null===f&&this.strategies.warnFragmentFallback(d);const c=oe(t.fields,d,l,e.locale);if(void 0===c){i.absentFields.add(l);continue}if(!s&&r.revealEditedField&&i.revealLedger.note(e,d,c),!o())return;const h=Ui(r,d,c,t.fields,o);if(!o())return;const m=p?ae(d,h,t.fields,e.locale):void 0,v=i.lastAppliedIdentity.get(d.element);if(!e.forceRender&&r.skipUnchanged&&void 0!==m&&v===m&&!e.invalidated.has(l)){i.skippedUnchangedCount+=1;continue}const y={target:d,value:h,allFields:t.fields,revision:e.revision,...s?{}:{data:t},valueIdentity:m};r.scheduler.schedule(y),g+=1}}if(s||function(e,t,n,r,i){const{cache:s,strategies:o}=e,a={warned:t,warn:e.warn};if(0===s.fieldCount)return;if(!1!==i&&!function(e,t){for(const n of e.values())if(ge(n.owner,t))return!0;return!1}(s,i))return;const l=function(e,t,n,r){const i=Le(e,t,n,Ce(e,n,r));return e=>"none"!==i(e)}(s,r,i,o);for(const[e,t]of Object.entries(n)){if(Te.has(e))continue;if(pr(t)){fr(a,l,e,r,t);continue}if(!mr(t)||l(e)||gr(t))continue;const n=$e(e,r);for(const[e,i]of Object.entries(t))pr(i)&&!Te.has(e)&&fr(a,l,`${n}.${e}`,r,i)}if("declared"!==e.subfieldCoverage)return;const u=function(e,t,n,r,i){const s=Ce(e,r,i),o=Le(e,n,r,s),a=[];for(const[e,r]of Object.entries(t)){if(Te.has(e)||"below"!==o(e))continue;const t=$e(e,n);a.push(...Re(t,void 0,r,s))}return a}(s,n,r,i,o);for(const{path:e,value:t}of u)if(pr(t)&&fr(a,l,e,r,t),mr(t)&&!gr(t))for(const[n,i]of Object.entries(t))pr(i)&&fr(a,l,`${e}.${n}`,r,i)}(r,i.warnedOrphanFields,e.rawData,e.locale,a),o()){if(null!==f&&f.boundaries.length>0){for(const t of f.boundaries)e.fragmentBoundariesRun.add(t);e.pendingFragments+=f.boundaries.length,this.strategies.runFragments(e,t,f)}!s&&o()&&0===g&&(0===e.pendingFragments&&0===r.scheduler.pendingCount&&(i.complete(e),this.revealPending(e)),this.notifyIslands(e,t))}}notifyIslands(e,t){0!==e.touched.size&&this.navigationReplay.dispatchIslands(e,t,this.deps.cache.islands)}restoreGuesses(e,t){const{deps:n,state:r}=this;if("off"!==n.autoBind&&null!==r.autoBindGuesses&&("undefined"==typeof __LEAN_BUILD__||!__LEAN_BUILD__)){const i=dr(n,r,e,t.fields);!function(e,t,n,r,i,s){if(!s())return 0;const o=t.autoBindGuesses,a=ar(e.root);if(null===o||0===o.fields.size||null===a)return 0;const l=new Map(o.values);for(const[e,t]of Yn(n,r)){if(null===t||!o.fields.has(t.field))continue;const n=l.get(e);void 0===n?l.set(e,t):n?.field!==t.field&&l.set(e,null)}if(!s())return 0;const u=or(a,l);s()&&ur(e,u,i,"after a server render",s).length}(n,r,t.fields,e.locale,i,()=>r.isCurrent(e))}}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 s=n.activeUpdate;if(null===s||!n.isCurrent(s)||!m(s.revision,r))return;n.display.deferred(s,e.deferred),0===s.pendingFragments&&n.complete(s);const o=()=>n.isCurrent(s)&&m(s.revision,r),a=i??s.renderData;if(this.revealPending(s),!o())return;const l=n.unfaithfulPatches;if(l.length>0){if(n.unfaithfulPatches=[],void 0!==a){const e=dr(t,n,s,a.fields);this.strategies.escalateUnfaithful(s,a,l,e)}if(!o())return}void 0!==i&&(e.applied>0&&t.a11y?.announceUpdate(e.applied),o()&&(this.notifyIslands(s,i),o()&&0!==e.applied&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:i,updatedCount:e.applied,durationMs:e.durationMs,revision:r.revision,receivedAt:s.receivedAt,source:"patch"},o)))}revealPending(e){const t=this.state.revealLedger.commit(e);if(void 0!==t)try{Ve(this.state.revealer,t)}catch(e){this.deps.log("reveal",e)}}revealField(e){const t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":Ve(this.state.revealer,t)}documentSaved(){this.strategies.refreshAfterSave()}},Oi=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;frameFallback=null;frameToken=0;windowUntil=0;activeRevision=null;activeRevisionCancelled=!1;destroying=!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(this.destroying)return;if(void 0!==e.revision){if(this.activeRevisionCancelled)return;if(null===this.activeRevision||!m(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;this.destroying||null!==this.activeRevision&&m(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.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1,this.cancelScheduledWork())}cancelRevision(e){null!==this.activeRevision&&m(e,this.activeRevision)&&(this.clearWork(),this.activeRevisionCancelled=!0,this.cancelScheduledWork())}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(){if(!this.destroying){this.destroying=!0;try{this.clearWork(),this.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0,this.cancelScheduledWork()}finally{this.destroying=!1}}}get pendingCount(){return this.pending.size}get replayCount(){return this.replay.size}get gateThreshold(){return this.gateThresholdValue}get gateActive(){return!this.gateDisabled&&this.getCacheSize()>this.gateThresholdValue}armDebounce(){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,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1;const r=()=>{if(this.frameToken!==e||n)return;n=!0;const t=this.frameHandle;this.frameHandle=null,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.flush()},i=this.scheduleFrame(r);n||this.frameToken!==e||(this.frameHandle=i,this.frameFallback=setTimeout(r,100))}clearFrameFallback(){clearTimeout(this.frameFallback??void 0),this.frameFallback=null}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 s,o=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)||Ii(e.target);this.isCurrent(e)&&(s??=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),o+=1))}}finally{this.activeFlushes.delete(n)}const a=this.statsFor(s,r,o,performance.now()-e,i);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&m(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||(t=this.apply,!Y.has(t));var t}retargetBuffer(e,t){const n=e.get(t.element);void 0!==n&&(Gt(n.target,t)?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(),this.clearFrameFallback(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}};function Ii(e){if(!0!==e.hidesWhenEmpty)return!1;const{element:t}=e;if(t.hasAttribute("hidden"))return!0;const n=t.getBoundingClientRect();return 0===n.width||0===n.height}var Di=[0,500,1e3,2e3],_i=class{deps;state=new Xe;pipeline;writer;rootSentinel=null;scope=null;closingSession=!1;observedRoot=null;replayRetainedOnStart=!1;constructor(e){const{emitter:t,renderers:n}=e,r=void 0===e.log?b:y(e.log),i=void 0===e.warn?S:y(e.warn),s=e.root??("undefined"!=typeof document?document:void 0);if(void 0===s)throw new Error("LivePreviewRuntime: no document; pass options.root");const o=new Kt({filter:e=>!function isInsideIsland(e){let t=e;for(;null!==t;){if(ut(t))return!0;t=t.parentElement}return!1}(e)}),a=new Rn({onStructuralChange:()=>{this.rebuildCache()},onIslandHydrated:e=>{this.pipeline.reapplyNavigationIslands([e],!0)},onVisibilityChange:(e,t)=>{t&&l.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),l=new Oi(ee(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:()=>o.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),u=new v(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onReplay:(e,t,n)=>{this.pipeline.handleReplay(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],r),t.emit("documentSave",{timestamp:Date.now()}),this.pipeline.documentSaved()},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:o,observers:a,scheduler:l,bus:u,connection:new qn,heartbeat:new Wn({...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:s,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:/* @__PURE__ */(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??$,onHeartbeatTimeout:e.onHeartbeatTimeout,log:r,warn:i,a11y:C(e),serverURL:d?.serverURL,merger:void 0===d?null:new mn({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,subfieldCoverage:e.subfieldCoverage??"descendant",lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:G(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new Ze(this.deps,this.state),this.pipeline=new Ei(this.deps,this.state,()=>{this.rebuildCache()})}start(){const{state:e}=this;if(e.isRunning()||this.closingSession)return!1;e.suspended&&(this.replayRetainedOnStart=!0),e.started=!0,e.suspended=!1,this.openScope();try{return function(e){"react"===e.hydration?Pn():"vue"===e.hydration&&In();const{root:t}=e;if(!zn(t)||"loading"!==t.readyState)return void Dn(e);const n=()=>{e.isRunning()&&e.later(()=>{Dn(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,this.scope?.own(()=>{e.deferredStart===t&&(e.deferredStart=null,t())})},later:t=>{e.deferredStart=null;try{t()}catch(e){this.rollbackFailedStart(),this.reportError(e,"startup","LP0605")}},hydrated:t=>{e.hydration=t},warn:t.warn,startNow:()=>{this.startNow()}}}startNow(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=zn(t.root)?Hn(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())return;if(t.bus.attach(),t.emitter.emitWhile("init",{timestamp:Date.now()},()=>e.isRunning()),!e.isRunning())return;const r=this.replayRetainedOnStart;this.replayRetainedOnStart=!1;const i=r&&t.heartbeat.resume();if(e.isRunning()&&(!r||i||(e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=/* @__PURE__ */new WeakMap,e.changes.reset(),e.navigationReplayPending=!0,t.bus.replayLastAccepted()||(e.navigationReplayPending=!1),e.isRunning())))for(const n of Di){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,this.replayRetainedOnStart=!1,t.bus.forgetLastAccepted(),n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}openScope(){const{state:e,deps:t}=this,n=new $n(t.log);n.own(()=>{t.merger?.destroy(),e.merges.destroy()}),n.own(()=>{t.scheduler.destroy()}),n.own(()=>{t.observers.stop()}),n.own(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),n.own(()=>{e.abortStrategies()}),n.own(()=>{t.bus.detach()}),n.own(()=>{t.heartbeat.stop()}),n.own(()=>{for(const t of e.readyTimers)clearTimeout(t);e.readyTimers.length=0}),this.scope=n}release(){const{state:e,deps:t}=this;e.display.end(),e.activeUpdate=null,e.navigationBindingReplay=!1,e.started=!1;const n=this.scope;this.scope=null,this.closingSession=!0;try{n?.close()}finally{this.closingSession=!1}return t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release();try{this.deps.a11y?.detach()}catch(e){this.deps.log("runtime cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}navigationCommit(){const{state:e,deps:t}=this;e.isRunning()&&null===e.deferredStart&&(this.cancelActiveUpdate(!0),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!0),e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=/* @__PURE__ */new WeakMap,e.changes.reset(),e.isRunning()&&(t.bus.advanceGeneration(),e.navigationReplayPending=!0,this.followReplacedRoot()||this.rebuildCache(),e.isRunning()&&(t.bus.replayLastAccepted(),e.isRunning()&&this.sendReadyAfterStart())))}watchRootReplacement(){const{root:e}=this.deps;zn(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()||!zn(e))return!1;const t=Hn(e);return null!==t&&t!==this.observedRoot&&(this.observedRoot=t,this.deps.observers.start(t),this.rebuildCache(),!0)}get status(){return this.deps.connection.status}get cache(){return this.deps.cache}get updateCount(){return this.state.updateCount}get protocol(){return this.state.protocol.negotiation}inspect(){return function(e,t){const{cache:n,scheduler:r}=e,i=t.protocol.negotiation,s=t.activeUpdate,o=t.lastFlush,a=[],l=/* @__PURE__ */new Set,u=[];for(const[e,t]of n.entries()){a.push(e);for(const n of t)void 0!==n.owner&&l.add(n.owner),void 0!==n.guessed&&u.push({field:e,matched:n.guessed,attribute:n.targetAttribute??("IMG"===n.element.tagName?"src":void 0)})}return{version:vn,started:t.started,status:e.connection.status,origins:{trusted:[...e.readyTargets()],locked:e.lockedOrigin()},protocol:{ours:i.ours,theirs:i.theirs,negotiated:i.negotiated,capabilities:[...i.capabilities].sort(),observed:[...i.observed].sort(),profile:(d=i.observed,d.has("schema-json")?yn:d.has("document-events")||d.has("relationship-events")?bn:wn).name},revisions:{accepted:t.updateCount,superseded:t.supersededCount,completed:t.completedCount,skippedUnchanged:t.skippedUnchangedCount,active:null===s?void 0:s.revision.revision,display:t.display.snapshot()},bindings:{elements:n.elementCount,fields:n.fieldCount,fieldNames:a.sort(),absentFields:[...t.absentFields].sort(),orphanFields:[...t.warnedOrphanFields].sort(),ownerScoped:e.scopeBindingsByOwner,owners:[...l].sort(),guessed:u.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:e.autoBind,searchMs:t.autoBindSearchMs}},route:{handler:void 0!==e.strategies.route,...t.routeStats},fidelity:{mode:e.onUnfaithfulPatch,canEscalate:void 0!==e.strategies.fragment||void 0!==e.strategies.route,unfaithful:t.unfaithfulCount,escalated:t.escalatedCount,fields:[...t.unfaithfulFields].sort()},hydration:{mode:e.hydration??"off",state:t.hydration},fragments:{handler:void 0!==e.strategies.fragment,inFlight:s?.pendingFragments??0,...t.fragmentStats},scheduler:{pending:r.pendingCount,deferred:r.replayCount,visibilityGateThreshold:r.gateThreshold,visibilityGateActive:r.gateActive,lastFlush:null===o?void 0:{applied:o.applied,appliedFields:o.appliedFields,deferred:o.deferred,durationMs:o.durationMs}},plugins:[],renderers:Object.keys(e.renderers).sort()};var d}(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,r=t.cache.islandOwners,i=new Set(t.cache.navigationReplayRoots);for(const e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),!e.isRunning())return;const s=new Set(t.cache.navigationReplayRoots.filter(e=>!i.has(e)));for(const e of t.cache.values()){const r=n.get(e.element);void 0!==r&&Gt(r,e)?t.scheduler.retarget(e):(t.scheduler.forget(e.element),s.add(e.element)),n.delete(e.element)}for(const e of n.values())t.scheduler.forget(e.element);s.size>0&&this.pipeline.reapplyNavigationBindings(s);const o=t.cache.islands.filter(e=>!r.has(e)||t.scopeBindingsByOwner&&r.get(e)!==t.cache.islandOwners.get(e));o.length>0&&this.pipeline.reapplyNavigationIslands(o)}onHeartbeatTimeout(){const{state:e,deps:t}=this;if(!e.isRunning())return;if(this.cancelActiveUpdate(!1),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!1),!e.isRunning())return;t.bus.advanceGeneration(),t.bus.forgetLastAccepted(),e.navigationBindingReplay=!1;const n=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}if(e.isRunning()){if(n&&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()}}cancelActiveUpdate(e){const{state:t,deps:n}=this,r=t.activeUpdate;t.display.end(),t.activeUpdate=null,null!==r&&(r.cancelled=!0,n.scheduler.cancelRevision(r.revision),e&&!r.completed&&r.countsAsUpdate&&(t.supersededCount+=1))}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}},EventEmitter=class{#s=/* @__PURE__ */new Map;#o=/* @__PURE__ */new Map;on(e,t){return this.#a(this.#s,e,t)}once(e,t){return this.#a(this.#o,e,t)}off(e,t){this.#l(this.#s,e,t),this.#l(this.#o,e,t)}async emit(e,t){await this.#u(e,t)}async emitWhile(e,t,n){return this.#u(e,t,n)}async#u(e,t,n){const r=()=>n?.()??!0;if(!r())return!1;const i=this.#s.get(e);if(i)for(const n of[...i]){if(!r())return!1;if(await this.#d(n,t,e),!r())return!1}if(!r())return!1;const s=this.#o.get(e);if(s&&s.size>0){const n=[...s];this.#o.delete(e);for(const i of n){if(!r())return!1;if(await this.#d(i,t,e),!r())return!1}}return r()}listenerCount(e){return(this.#s.get(e)?.size??0)+(this.#o.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#s.clear(),void this.#o.clear();this.#s.delete(e),this.#o.delete(e)}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#s.keys())e.add(t);for(const t of this.#o.keys())e.add(t);return[...e]}#a(e,t,n){let r=e.get(t);return r||(r=/* @__PURE__ */new Set,e.set(t,r)),r.add(n),()=>{this.#l(e,t,n)}}#l(e,t,n){const r=e.get(t);void 0!==r&&(r.delete(n),0===r.size&&e.delete(t))}async#d(e,t,n){try{await e(t)}catch(e){const t="string"==typeof n||"number"==typeof n?String(n):"<event>";w(`[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 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 Bi=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,ji=/^https?:\/\/[^/?#\s]+$/i,zi=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function Hi(){if("undefined"==typeof location)return;const e=location.ancestorOrigins;return e?.[0]}var OriginDetector=class{#c;constructor(e={}){const t=/* @__PURE__ */new Set;for(const n of e.additionalOrigins??[]){const e=Wi(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.#c=[t,n,r,void 0!==n,void 0,Hi()]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#c[4]?e===this.#c[4]:!!this.#c[0].has(e)||0===this.#c[0].size&&void 0!==this.#c[1]&&e===this.#c[1]||!(!this.#c[2]||!Bi.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#c[4]=e,!0)}unlockOrigin(){const e=this.#c[4];return this.#c[4]=void 0,e}get lockedOrigin(){return this.#c[4]}enumerate(){if(void 0!==this.#c[4])return[this.#c[4]];const e=new Set(this.#c[0]);0===this.#c[0].size&&void 0!==this.#c[1]&&e.add(this.#c[1]);const t=this.#c[5];if(this.#c[2]&&void 0!==t)Bi.test(t)&&e.add(t);else if(this.#c[2])for(const t of zi)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#c[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#c[0].size>0||this.#c[2]||void 0!==this.#c[1])}get isReferrerOnlyTrust(){return!(this.#c[0].size>0||this.#c[2]||void 0===this.#c[1])}};function Wi(e){const t=e.trim();if(0!==t.length)try{const e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return;if(!ji.test(e.origin))return;return e.origin}catch{return}}var qi=()=>{},Vi=class{#h;#n;#f=/* @__PURE__ */new Set;#c="staging";constructor(e,t){this.#h=e,this.#n=t}assertOpen(){if("closed"===this.#c)throw new Error(`Plugin context for "${this.#h}" is no longer active`)}get active(){return"active"===this.#c}eligible(){return"closed"!==this.#c}own(e){return this.assertOpen(),this.#p({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.#p(r);if("active"===this.#c)try{this.#g(r)}catch(e){throw this.#m(r),e}return i}counts(){const e={transform:0,renderer:0,subscription:0,cleanup:0};for(const t of this.#f)e[t.kind]+=1;return e}commit(){if("staging"!==this.#c)throw new Error(`Plugin context for "${this.#h}" cannot be committed`);this.#c="committing";try{for(const e of this.#f)this.#g(e);this.#c="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#c){this.#c="closed";for(const e of[...this.#f].reverse())this.#m(e);this.#f.clear()}}#p(e){return this.#f.add(e),()=>{this.#m(e)}}#g(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;const t=e.acquire();e.cleanup=t??qi}#m(e){if(e.disposed)return;e.disposed=!0,this.#f.delete(e);const t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{g(t())&&this.#n(`plugin "${this.#h}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#n(`plugin "${this.#h}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#n(`plugin "${this.#h}" cleanup failed:`,e)}}},Gi=class{#v;#y;#b=/* @__PURE__ */new Set;constructor(e,t){this.#v=e,this.#y=t}on(e,t){return this.#w("on",e,t)}once(e,t){return this.#w("once",e,t)}off(e,t){const n=t;for(const t of[...this.#b])t.event===e&&t.handler===n&&t.dispose()}emit(e,t){return this.#y.assertOpen(),this.#v.emit(e,t)}emitWhile(e,t,n){return this.#y.assertOpen(),this.#v.emitWhile(e,t,()=>{if(!this.#y.eligible())return!1;const e=n();return!!this.#y.eligible()&&e})}listenerCount(e){let t=0;for(const n of this.#b)n.event===e&&(t+=1);return t}removeAllListeners(e){for(const t of[...this.#b])void 0!==e&&t.event!==e||t.dispose()}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#b)e.add(t.event);return[...e]}#w(e,t,n){this.#y.assertOpen();const r=n,i=[...this.#b].find(n=>n.kind===e&&n.event===t&&n.handler===r);if(void 0!==i)return i.dispose;let s=qi,o=!0;const a=async t=>{this.#y.active&&o&&("once"===e&&s(),await n(t))},l={kind:e,event:t,handler:r,dispose:qi};return s=this.#y.stage("subscription",()=>this.#v[e](t,a),()=>{o=!1,this.#b.delete(l)}),l.dispose=s,this.#b.add(l),s}},Ki=class{#v;#S;#A;#k;#n;#R=/* @__PURE__ */new Map;#T=/* @__PURE__ */new Map;#C=/* @__PURE__ */new Map;#$=/* @__PURE__ */new Set;#L=/* @__PURE__ */new Map;#N=Promise.resolve();#P=0;constructor(e){this.#v=e.events,this.#S=e.config,this.#A=e.registerFieldRenderer,this.#n=y(e.log);const t=e.onTransformError;this.#k=void 0===t?void 0:y((...e)=>{const n=e[0];try{return t(n)}catch(e){return void this.#n("transform error reporter failed:",e)}})}register(e){return this.#P>0?this.#F(e,!1):this.#U(()=>this.#F(e,!0))}unregister(e){return this.#P>0?this.#M(e,!1):this.#U(async()=>{await this.#M(e,!0)})}destroyAll(){return this.#P>0?this.#x(!1):this.#U(async()=>{await this.#x(!0)})}applyTransforms(e,t,n,r){const i=this.#L.get(e);if(void 0===i||0===i.length)return t;let s=t;for(const o of[...i]){if(!o.active)continue;const{transform:i}=o;if(!1===r?.())return t;try{s=i(s,{fieldName:e,element:n.element,allFields:n.allFields});const o=g(s);if(!1===r?.())return t;if(o)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.#n(`transform for "${e}" failed:`,i),this.#k?.(i),t}}return s}list(){return[...this.#R.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.#T)e.push(t(n,void 0,"initializing",r.scope));for(const[n,r]of this.#R)e.push(t(n,r.plugin.version,"active",r.scope));for(const t of this.#C.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.#R.size}async#F(e,t){if(this.#R.has(e.name)||this.#T.has(e.name)||this.#C.has(e.name))return void this.#n(`plugin "${e.name}" already registered`);const n=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]??"=",s=[Number(r[2]),Number(r[3]),Number(r[4])],o=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,s);switch(i){case"=":return 0===o;case">":return o>0;case">=":return o>=0;case"<":return o<0;case"<=":return o<=0;case"~":return o>=0&&e[0]===s[0]&&e[1]===s[1];case"^":return!(o<0)&&(s[0]>0?e[0]===s[0]:s[1]>0?0===e[0]&&e[1]===s[1]:0===e[0]&&0===e[1]&&e[2]===s[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)}`}}}(e.compat,vn);if(void 0!==n)return void this.#E(e.name,n);const r=new Vi(e.name,this.#n),i=this.#O(e.name,r),s={scope:r,cancelled:!1};this.#T.set(e.name,s);try{if(await this.#I(()=>e.init(i),t),s.cancelled)return;r.commit()}catch(t){return r.close(),void(s.cancelled||this.#n(`plugin "${e.name}" init failed:`,t))}finally{this.#T.get(e.name)===s&&this.#T.delete(e.name)}this.#R.set(e.name,{plugin:e,scope:r}),this.#n(`plugin "${e.name}" registered`)}#E(e,t){const n=`plugin "${e}" refused: ${t}`;this.#n(n),this.#v.emit("error",{error:new Error(n),context:"plugin",code:"LP0103"})}#O(e,t){return{events:new Gi(this.#v,t),registerFieldRenderer:e=>{t.stage("renderer",()=>{const t=this.#A(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.#L.get(e);return void 0===t?this.#L.set(e,[r]):t.push(r),()=>{r.active=!1;const t=this.#L.get(e);if(void 0===t)return;const n=t.indexOf(r);n>=0&&t.splice(n,1),0===t.length&&this.#L.delete(e)}})},registerCleanup:e=>{t.own(e)},getConfig:()=>this.#S,log:(...t)=>{this.#n(`[${e}]`,...t)}}}#M(e,t){const n=this.#T.get(e);if(void 0!==n)return n.cancelled=!0,n.scope.close(),Promise.resolve();const r=this.#C.get(e);if(void 0!==r)return this.#$.has(e)?Promise.resolve():t?this.#D(r):r;const i=this.#R.get(e);if(void 0===i)return Promise.resolve();this.#R.delete(e),i.scope.close();const s=Promise.resolve().then(()=>this.#_(e,i.plugin,t));return this.#C.set(e,s),s.then(()=>{this.#C.get(e)===s&&this.#C.delete(e)}),s}async#_(e,t,n){if(void 0!==t.destroy){this.#$.add(e);try{await this.#I(()=>t.destroy?.(),n)}catch(t){this.#n(`plugin "${e}" destroy failed:`,t)}finally{this.#$.delete(e)}}}async#x(e){for(const e of this.#T.values())e.cancelled=!0,e.scope.close();const t=[...this.#R.keys()];for(const n of t)await this.#M(n,e)}async#I(e,t){t?await this.#D(Promise.resolve().then(e)):await e()}async#D(e){this.#P+=1;try{await e}finally{this.#P-=1}}#U(e){const t=this.#N.then(e);return this.#N=t.catch(e=>{this.#n("plugin manager mutation failed:",e)}),t}},Ji=class{#B;#j;#z=/* @__PURE__ */new Map;constructor(e){this.#B=e,this.#j={...e}}get renderers(){return this.#j}resolve(e){return this.#j[e]}register(e){const t=e.name,n={renderer:e},r=this.#z.get(t);void 0===r?this.#z.set(t,[n]):r.push(n),this.#j[t]=e;let i=!0;return()=>{if(!i)return;i=!1;const e=this.#z.get(t);if(void 0===e)return;const r=e.indexOf(n);if(r<0)return;const s=r===e.length-1;if(e.splice(r,1),0===e.length&&this.#z.delete(t),!s)return;const o=e.at(-1),a=o?.renderer??this.#B[t];void 0===a?Reflect.deleteProperty(this.#j,t):this.#j[t]=a}}},Qi={1:"left",2:"center",3:"right",4:"justify"},Xi=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function Zi(e){const t=e.format;return"string"==typeof t&&Xi.has(t)?t:"number"==typeof t?Qi[t]:void 0}function Yi(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function es(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function ts(e){const t=Zi(e),n=Yi(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 ns=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function rs(e){return"object"==typeof e&&null!==e?e:void 0}function is(e){return rs(e)}function ss(e,t){if(void 0===t||""===t||!e.startsWith("/"))return e;try{const n=new URL(t),r=new URL(e,n);return r.origin===n.origin?r.href:e}catch{return e}}function os(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function as(e){return"string"==typeof e&&e.length>0?e:void 0}function ls(e){const t=as(e.title)??as(e.name)??as(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}var us=' target="_blank" rel="noopener noreferrer"',ds=(e,t)=>{const n=t.renderChildren(e.children??[]),r=rs(e.fields),i=function(e,t){if("internal"===t?.linkType)return function(e){const t=rs(rs(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 s="string"==typeof e.title?` title="${escapeHtml(e.title)}"`:"";return`<a href="${escapeHtmlAttribute(i)}"${function(e,t,n){if(!0===t?.newTab||isExternalHttpUrl(n))return us;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?us:` target="${escapeHtml(r)}"`}(e,r,i)}${s}>${n}</a>`};function cs(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=cs(n);return t}function hs(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function fs(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var ps=/* @__PURE__ */new Map;function gs(e){return ps.get(e)}var ms=".lp-block:empty,.lp-inline-block:empty";function vs(e,t,n,r){const i=rs(e.fields)??{},s="string"==typeof i.blockType?i.blockType:"",o=os(s),a=""===o?r:`${r} ${r}--${o}`;if(""!==s){const e=gs(s)??gs(o);if(e)return e(i,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(s,a)}return`<${n} class="${a}"></${n}>`}function ys(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var bs={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${es(e)}${ts(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=ns.has(n)?n:"h2",i=t.renderChildren(e.children??[]);return`<${r}${es(e)}${ts(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)}"`:"",s="check"===n?' role="list"':"",o=t.renderChildren(e.children??[]);return`<${r}${es(e)}${ts(e)}${i}${s}>${o}</${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"}"${ts(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${es(e)}${ts(e)}${r}>${n}</li>`},link:ds,autolink:ds,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${es(e)}${ts(e)}>${n}</blockquote>`},code:e=>{const t=os("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(cs(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${os(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=is(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${hs(e)}><source src="${escapeHtmlAttribute(t)}"${fs(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${fs(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}"${hs(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=rs(e.value),r=escapeHtml((n&&ls(n))??`#${t}`),i=os(t),s=""===i?' class="lp-relation"':` class="lp-relation lp-relation--${i}"`,o=n?.url;return"string"==typeof o&&isSafeUrl(o)?`<a href="${escapeHtmlAttribute(o)}"${s}>${r}</a>`:`<span${s}>${r}</span>`},block:(e,t)=>vs(e,t,"div","lp-block"),inlineBlock:(e,t)=>vs(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${es(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"':""}${ys("colspan",e.colSpan)}${ys("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},ws=/* @__PURE__ */new Map,Ss=!1;function As(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 ks(e,t){const n=(r=e.type,ws.get(r)??bs[r]);var r;return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function Rs(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+=Rs(n);return t}function Ts(e="text"){const t=/* @__PURE__ */new WeakSet;return{name:e,render:/* @__PURE__ */ee((e,n)=>{const r=e.element,i=function(e){return null==e?"":As(e)?As(t=e)?t.root.children.map(Rs).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){if(r.textContent.trim()!==i.trim())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),S(`[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=yr(function(e){return escapeHtml(e).replace(/\r\n|\r|\n/g,"<br>")}(i)):r.textContent=i)}else r.value=i})}}var Cs=/* @__PURE__ */new Set,$s=/* @__PURE__ */new Set,Ls=/* @__PURE__ */new Set(["DIV","SECTION","ARTICLE"]),Ns={name:"richText",render:/* @__PURE__ */ee((e,t,n)=>{const r=e.element;if(ri(t))return void(r.textContent="");const i=n.sanitizerPolicy;if(void 0!==n.renderRichText){const s=n.renderRichText(t,{fieldName:e.fieldName,element:r,locale:n.locale});return void(r.innerHTML=yr(Br(s,i)))}if(As(t)){if(et(t))return void(r.textContent="");const s=/* @__PURE__ */new Map,o=function(e,t){const n=e.cloneNode(!1);n.innerHTML=yr(t);const r=function(e,t){const n=e.firstElementChild,r=1===t.children.length?t.firstElementChild:null;if(null!==n?.nextElementSibling||0===t.children.length)return null;if(!Ls.has(n.tagName)||n.hasAttribute(bt))return null;if(r?.tagName===n.tagName||!0===r?.matches(ms))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,s=n.querySelectorAll(ms);if(s.length>0&&null!==r.firstElementChild){const e=[];Ps(r,n,e);for(const[t,n]of e)t.replaceWith(n),n.matches(ms)||i.set(t.className,!1);for(const e of s)null!==e.parentNode&&i.set(e.className,!0)}return r.replaceChildren(...n.childNodes),i}(r,Br(function(e,t={}){if(!As(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=ks(r,t);return n},resolveAlignment:Zi,resolveIndent:Yi,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==t.document?sanitizeHtml(n,{document:t.document}):!0===t.requireDocument||void 0!==Hr()?sanitizeHtml(n):(function(){if(!Ss){Ss=!0;try{console.warn('[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; pass { document } (linkedom, jsdom) per call. 3.0 throws here instead: opt in now with { requireDocument: true }. See "HTML sanitization" in docs/security.md.')}catch{}}}(),n)}(t,{sanitize:!1,onUnrenderedBlock:(e,t)=>{s.set(t,e)}}),i));for(const[t,r]of o){const i=s.get(t);void 0!==i&&Fs(e,n,i,r)}return}if("string"!=typeof t)return!1;r.innerHTML=yr(Br(t,i))})};function Ps(e,t,n){const r=(e,t)=>{e.matches(ms)?n.push([e,t]):Ps(t,e,n)};let i=e.firstElementChild,s=t.firstElementChild;if(e.children.length===t.children.length){for(;null!==i&&null!==s;i=i.nextElementSibling)r(s,i),s=s.nextElementSibling;return}const o=/* @__PURE__ */new Set;for(const e of t.children)e.matches(ms)||o.add(e.tagName);const a=(e,t)=>e.matches(ms)?!o.has(t.tagName):e.tagName===t.tagName;let l=0;for(;null!==i&&null!==s&&a(s,i);l+=1)r(s,i),i=i.nextElementSibling,s=s.nextElementSibling;const u=Math.min(e.children.length,t.children.length);i=e.lastElementChild,s=t.lastElementChild;for(let e=l;e<u&&null!==i&&null!==s;e+=1){if(!a(s,i))return;r(s,i),i=i.previousElementSibling,s=s.previousElementSibling}}function Fs(e,t,n,r){r&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);const i=r?$s:Cs;i.has(n)||(i.add(n),S(`[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 Us={name:"html",render(e,t,n){if(ri(t))return void(e.element.textContent="");const r="string"==typeof t?t:ni(t);e.element.innerHTML=yr(Br(r,n.sanitizerPolicy))}},Ms=/* @__PURE__ */new WeakSet;function xs(e,t,n,r){if("string"!=typeof n||0===n.length)return{kind:"none"};const i=ss(n,r);return isSafeUrl(i)?{kind:"safe",url:i}:(Ms.has(e)||(Ms.add(e),S(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function Es(e,t=e=>e){return{name:e,render(e,n,r){const i=e.element;if(ri(n))return void function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(i);const s=ni(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName){if("A"===i.tagName){const n=e.hrefField,o=void 0===n||0===n.length?t(s):ie(r.allFields,n,r.locale,void 0!==e.locale),a=xs(i,e.fieldName,o);"safe"===a.kind?i.setAttribute("href",a.url):"unsafe"===a.kind&&i.removeAttribute("href")}i.textContent=s}else i.value=s}}}var Os=Es("url"),Is=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,Ds=Es("email",function(e){const t=e.trim();return Is.test(t)||!t.includes("@")?t:`mailto:${t}`}),_s=["src","srcset","sizes"],Bs=/* @__PURE__ */new WeakMap;function js(e){for(const t of _s)e.removeAttribute(t)}function zs(e,t,n,r){const i=function(e,t){const n=[];for(const[r,i]of Object.entries(e?.sizes??{})){if("string"!=typeof i.url||"number"!=typeof i.width)continue;const e=ss(i.url,t);isSafeUrl(e)&&n.push({...i,name:r,url:e,width:i.width})}return n}(n,r),s=e.getAttribute("src"),o=i.find(t=>null!==s&&function(e,t,n){try{return new URL(t,e.baseURI).href===new URL(n,e.baseURI).href}catch{return t===n}}(e,t.url,s))??i.find(t=>t.name===Bs.get(e));void 0===o?.name?Bs.delete(e):Bs.set(e,o.name),e.src=o?.url??t;const a=o??n,l=i.filter(e=>Hs(e,a));if(0===l.length)return e.removeAttribute("srcset"),void e.removeAttribute("sizes");if("number"==typeof n?.width&&"string"==typeof n.url){const e=ss(n.url,r),t={...n,url:e,width:n.width};isSafeUrl(e)&&Hs(t,a)&&l.push(t)}const u=/* @__PURE__ */new Set,d=[];for(const e of l)u.has(e.width)||(u.add(e.width),d.push(`${Ws(e.url)} ${String(e.width)}w`));const c=d.join(", ");e.setAttribute("srcset",c)}function Hs(e,t){if(void 0===t)return!0;if("string"==typeof e.mimeType&&"string"==typeof t.mimeType&&e.mimeType!==t.mimeType)return!1;const{width:n,height:r}=t;return"number"!=typeof n||"number"!=typeof r||"number"!=typeof e.width||"number"!=typeof e.height||Math.abs(e.width*r-e.height*n)<=Math.max(n,e.width)}function Ws(e){return e.replace(/[\s,]/g,encodeURIComponent)}var qs=/^\S*[/.:]\S*$/,Vs={name:"image",render:/* @__PURE__ */ee((e,t,n)=>{const r=e.element;if("IMG"===r.tagName&&e.altField===e.fieldName&&void 0===e.srcField&&("string"==typeof t||ri(t)))return void(r.alt=t??"");if(ri(t))return void Gs(r);const i=void 0!==e.locale,{media:s,candidate:o}=function(e,t,n,r){const i=void 0!==e.srcField&&e.srcField.length>0?ie(n.allFields,e.srcField,n.locale,r):t,s=is(i);return{media:s,candidate:void 0===s?i:s.url}}(e,t,n,i);if(void 0===s&&"string"==typeof o&&!qs.test(o.trim()))return!1;const a=xs(r,e.fieldName,o,void 0===s?void 0:n.serverURL);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===r.tagName){const t=r;zs(t,a.url,s,n.serverURL);const o=function(e,t,n,r,i){if(void 0!==t&&t.length>0){const e=ie(n,t,r,i);return"string"==typeof e?e:void 0}return e?.alt}(s,e.altField,n.allFields,n.locale,i);return void(void 0!==o&&(t.alt=o))}r.style.backgroundImage=`url('${function(e){return e.replace(/['"()\\]/g,"\\$&")}(a.url)}')`}else Gs(r)})};function Gs(e){"IMG"===e.tagName?js(e):e.style.backgroundImage=""}var Ks={name:"upload",render:/* @__PURE__ */ee((e,t,n)=>{const r=e.element;if(ri(t))return void Js(r);const i=is(t);if(void 0===i)return!1;const s=xs(r,e.fieldName,i.url,n.serverURL);if("none"===s.kind)return!1;if("unsafe"===s.kind)return void Js(r);const o=s.url;if("IMG"===r.tagName){const e=r;return zs(e,o,i,n.serverURL),void(void 0!==i.alt&&(e.alt=i.alt))}if("A"===r.tagName)return r.setAttribute("href",o),void(r.textContent=i.filename??o);const a=escapeHtml(i.filename??o);r.innerHTML=yr(`<a href="${escapeHtmlAttribute(o)}">${a}</a>`)})};function Js(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):js(e)}var Qs={name:"relationship",render(e,t){const n=e.element;if(ri(t))return n.removeAttribute("href"),void(n.textContent="");if("A"===n.tagName&&!Array.isArray(t)){const r=xs(n,e.fieldName,rs(t)?.url);"safe"===r.kind?n.setAttribute("href",r.url):"unsafe"===r.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(Xs).join(", "):Xs(t)}};function Xs(e){const t=rs(e);return void 0===t?ni(e):ls(t)??""}var Zs={name:"select",render(e,t,n){const r=e.element,i=ri(t)?[]:function(e){return Array.isArray(e)?e.map(ni):[ni(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=rs(t);if(void 0!==n&&ni(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)}},Ys=/* @__PURE__ */new Set(["","false","0","off","no"]),eo={name:"checkbox",render(e,t){const n=e.element,r=function(e){return"boolean"==typeof e?e:"string"==typeof e?!Ys.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}},to=/* @__PURE__ */new Map,no=/* @__PURE__ */new Map;function ro(e,t){const n=e??"";if(null==t)return n;const r=io(t);return"{}"===r?n:`${n}|${r}`}function io(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>io(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)}:${io(n)}`)}return`{${r.join(",")}}`}var so=/* @__PURE__ */new Set(["short","medium","long","full"]),oo=/* @__PURE__ */new Set(["short","medium","long","full"]),ao=/^[A-Za-z]{3}$/u,lo=/^[0-4]$/u;function uo(e){return{kind:"date",options:e}}function co(e){return{kind:"number",options:e}}var ho=/* @__PURE__ */new WeakSet;function fo(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?uo({dateStyle:"medium"}):so.has(r)?uo({dateStyle:r}):void 0;case"time":return void 0===r?uo({timeStyle:"short"}):oo.has(r)?uo({timeStyle:r}):void 0;case"datetime":return void 0===r?uo({dateStyle:"medium",timeStyle:"short"}):so.has(r)?uo({dateStyle:r,timeStyle:"short"===r?"short":"medium"}):void 0;case"number":if(void 0===r)return co({});if(!lo.test(r))return;return co({minimumFractionDigits:Number(r),maximumFractionDigits:Number(r)});case"currency":if(void 0===r||!ao.test(r))return;return co({style:"currency",currency:r.toUpperCase()});case"percent":return void 0===r?co({style:"percent"}):void 0;default:return}}(t);if(void 0!==i){if(i.kind===e)return i.options}else!function(e,t,n){ho.has(e)||(ho.add(e),S(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, time, datetime (each also :short|medium|long|full), number, number:0-4, currency:XXX, percent.`))}(n,r,t)}var po={name:"date",render(e,t,n){const r=e.element;if(ri(t))return void("INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent=""));const i="number"==typeof t?t:ni(t),s=new Date(i),o=!Number.isNaN(s.getTime()),a=String(i);"INPUT"!==r.tagName?("TIME"===r.tagName&&r.setAttribute("datetime",o?s.toISOString():a),r.textContent=o?function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=fo("date",t.format,t.element,t.fieldName)??go;try{return function(e,t){const n=ro(e,t);return ii(no,n)??si(no,n,new Intl.DateTimeFormat(e,t),64)}(r,i).format(e)}catch{return e.toISOString()}}(s,e,n):a):r.value=o?function(e,t){const n=`${String(t.getFullYear()).padStart(4,"0")}-${mo(t.getMonth()+1)}-${mo(t.getDate())}`,r=`${mo(t.getHours())}:${mo(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${r}`:"time"===e?r:t.toISOString()}(r.type,s):a}},go={dateStyle:"medium",timeStyle:"short"};function mo(e){return String(e).padStart(2,"0")}var vo={name:"number",render(e,t,n){const r=e.element;if(ri(t))return void("INPUT"===r.tagName?r.value="":r.textContent="");const i="number"==typeof t?t:Number(ni(t));Number.isNaN(i)?r.textContent=ni(t):"INPUT"!==r.tagName?r.textContent=function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=fo("number",t.format,t.element,t.fieldName);try{return function(e,t){const n=ro(e,t);return ii(to,n)??si(to,n,new Intl.NumberFormat(e,t),64)}(r,i).format(e)}catch{return String(e)}}(i,e,n):r.value=String(i)}},yo={name:"array",render:/* @__PURE__ */ee((e,t,n)=>{const r=e.element;if(ri(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=Zr(t);let r="";for(let i=0;i<t.length;i+=1)r+=Yr(e,t[i],i,ni,n);return r}(i,t),s=n.sanitizerPolicy,o=di(i),a=ei(r);r.innerHTML=yr(Br(e,s,o));for(const e of Array.from(r.children))ti(e,a);return}r.textContent=t.map(ni).join(e.arraySeparator??", ")})};function bo(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,n=/* @__PURE__ */new WeakMap,r=/* @__PURE__ */new WeakMap;return{name:"structural-array",render:/* @__PURE__ */ee((i,s,o)=>{const a=ri(s)?[]:s;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),S(`[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=wo(l),h=x(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 s=i.map(So),o=/* @__PURE__ */new Set,a=s.find(e=>!(void 0===e||!o.has(e)&&(o.add(e),1)));if(void 0!==a&&Ao(e,t,n,a),s.some(e=>void 0===e)&&ko(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(So).filter(e=>void 0!==e)),o=s.some(e=>void 0!==e&&i.has(e));i.size>0&&!o&&ko(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=pi({template:u,container:l,patches:h,nextItems:a,store:r,forceRender:f,sanitizerPolicy:o.sanitizerPolicy,onDuplicateKey:(e,t)=>{Ao(n,e,i.fieldName,t)}});return null!==p&&(e.set(l,{values:a.slice(),template:u,domSnapshot:wo(l)}),!!p&&void 0)})}}function wo(e){return Array.from(e.children,e=>e.getAttribute(ci))}function So(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Ao(e,t,n,r){ko(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${r}"; later ones pair by position. Make \`id\` unique per item.`)}function ko(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),S(`[live-preview] ${r}`))}var Ro=/* @__PURE__ */new Map;function To(e,t){return{name:e,render(){T(t)}}}var Co=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),$o=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"});function Lo(e){return void 0===e?void 0:!e}var LivePreviewClient=class{#H=new EventEmitter;#W;#q;#V;#R;#n;#G=!1;#K=!1;#J=!1;#Q=null;constructor(e={}){const t=function(e){const t="v1"===e.defaults?$o:Co;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.#n=r?(...e)=>{A("[live-preview]",...e)}:b,this.#W=new OriginDetector(L({additionalOrigins:t.allowedOrigins,enableReferrerDetection:Lo(t.disableReferrerDetection),enableLocalhostMatching:Lo(t.disableLocalhostMatching)})),this.#W.isProductionUnconfigured&&this.#n("no trusted origin could be detected — set allowedOrigins"),this.#q=new Ji(function(){const e=[Ns,Us,Os,Ds,Vs,Ks,Qs,Zs,{...Zs,name:"radio"},eo,po,vo,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[To("array","structural arrays"),To("blocks","structural arrays")]:[yo,{...yo,name:"blocks"}]];return function(e=[]){const t={};for(const n of e)t[n.name]=n;for(const[e,n]of Ro)t[e]=n;return Object.freeze(t)}([Ts("text"),Ts("textarea"),...e,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[]:[bo()]])}()),this.#R=new Ki({events:this.#H,config:Object.freeze({...t}),registerFieldRenderer:e=>this.#q.register(e),onTransformError:e=>{this.#H.emit("error",{error:e,context:"transform",code:"LP0602"})},log:this.#n}),this.#V=new _i(L({root:t.root,renderers:this.#q.renderers,resolveRenderer:(e,n)=>t.resolveRenderer?.(e,n)??this.#q.resolve(e),renderRichText:t.renderRichText,sanitizerPolicy:t.sanitizerPolicy,transformValue:(e,t,n,r)=>this.#R.applyTransforms(e,t,n,r),originMatcher:e=>this.#W.matches(e),readyTargets:()=>this.#W.enumerate(),emitter:this.#H,dataMerge:""===n?void 0:L({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,subfieldCoverage:t.subfieldCoverage,eventSourcePolicy:t.eventSourcePolicy,dependencies:t.dependencies,strategies:t.strategies,disableVisibilityGate:t.disableVisibilityGate,visibilityGateThreshold:t.visibilityGateThreshold,enableA11y:t.enableA11y,a11yLocale:t.a11yLocale,onHeartbeatTimeout:()=>{this.#W.unlockOrigin()},lockedOrigin:()=>this.#W.lockedOrigin,validateToken:t.validateToken,log:this.#n})),this.#H.on("connect",e=>{this.#W.lockOrigin(e.origin)}),!1!==t.autoStart&&this.start()}start(){if(this.#K)return!1;if(this.#G)return this.#V.start(),!0;if(!function isInPreviewContext(){return isInIframe()||function isInPopup(){return"undefined"!=typeof window&&null!=window.opener}()}())return!1;const e=this.#V.start();return e&&(this.#G=!0),e}suspend(){return!(this.#K||!this.#G)&&this.#V.suspend()}resume(){return!(this.#K||!this.#G)&&this.#V.start()}destroy(){if(null!==this.#Q)return this.#Q;let e,t;this.#K=!0;const n=new Promise((n,r)=>{e=n,t=r});this.#Q=n;const r=()=>{this.#H.removeAllListeners(),this.#J=!0};try{this.#V.destroy(),this.#R.destroyAll().finally(r).then(e,t)}catch(e){r(),t(e)}return n}async use(e){if(this.#K)throw new Error("LivePreviewClient: already destroyed");await this.#R.register(e)}async unuse(e){if(this.#J)throw new Error("LivePreviewClient: already destroyed");await this.#R.unregister(e)}refreshCache(){this.#V.refreshCache()}refreshAfterNavigation(){this.#V.navigationCommit()}get events(){return this.#H}get plugins(){return this.#R.list()}get status(){return this.#V.status}inspect(){return{...this.#V.inspect(),plugins:this.#R.snapshot()}}get updateCount(){return this.#V.updateCount}get destroyed(){return this.#K}};function initLivePreview(e={}){const t=new LivePreviewClient({...e,autoStart:!1});return t.start()?t:null}function No(e,t,n){if(0===t.length)return;const r={type:"payload-live-preview-focus",field:t};e.postMessage(r,n)}function Po(e,t){return n=>{const r=e();null!=r&&No(r,n,t)}}var Fo=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",UnboundField:"LP0203",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",EscalationUnavailable:"LP0808",IslandStartUnavailable:"LP0809",RouteRefreshUnconfirmed:"LP0810",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710"}),Uo="__livePreviewRouteRefresh";function registerRouteRefresh(e){const t="undefined"==typeof window?void 0:window;return void 0===t?()=>{}:(t[Uo]=e,()=>{t[Uo]===e&&(t[Uo]=void 0)})}export{Fo as DIAGNOSTIC_CODES,EventEmitter,LivePreviewClient,Po as createPreviewFocusReporter,initLivePreview,registerRouteRefresh,No as reportPreviewFocus};
|
|
2
2
|
//# sourceMappingURL=client.js.map
|