payload-live-preview 2.1.2 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +191 -62
  2. package/dist/adapters/astro/index.d.ts +7 -7
  3. package/dist/adapters/astro/index.js +1 -1
  4. package/dist/adapters/astro/index.js.map +1 -1
  5. package/dist/adapters/astro/middleware-entry.d.ts +3 -3
  6. package/dist/adapters/astro/middleware-entry.js +1 -1
  7. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  8. package/dist/adapters/nextjs/index.d.ts +2 -2
  9. package/dist/adapters/nextjs/index.js +1 -1
  10. package/dist/adapters/nextjs/index.js.map +1 -1
  11. package/dist/adapters/nuxt/index.d.ts +4 -4
  12. package/dist/adapters/nuxt/index.js +1 -1
  13. package/dist/adapters/nuxt/index.js.map +1 -1
  14. package/dist/adapters/nuxt/module.d.ts +1 -1
  15. package/dist/adapters/react/index.d.ts +2 -2
  16. package/dist/adapters/react/index.js +1 -1
  17. package/dist/adapters/react/index.js.map +1 -1
  18. package/dist/adapters/sveltekit/index.d.ts +5 -5
  19. package/dist/adapters/sveltekit/index.js +1 -1
  20. package/dist/adapters/sveltekit/index.js.map +1 -1
  21. package/dist/adapters/vue/index.d.ts +2 -2
  22. package/dist/adapters/vue/index.js +1 -1
  23. package/dist/adapters/vue/index.js.map +1 -1
  24. package/dist/annotate.d.ts +22 -15
  25. package/dist/annotate.js +1 -1
  26. package/dist/annotate.js.map +1 -1
  27. package/dist/client.cjs +1 -1
  28. package/dist/client.cjs.map +1 -1
  29. package/dist/client.d.cts +114 -114
  30. package/dist/client.d.ts +114 -114
  31. package/dist/client.js +1 -1
  32. package/dist/client.js.map +1 -1
  33. package/dist/codegen-cli.js +1 -1
  34. package/dist/codegen-cli.js.map +1 -1
  35. package/dist/codegen.cjs +1 -1
  36. package/dist/codegen.cjs.map +1 -1
  37. package/dist/codegen.d.cts +14 -16
  38. package/dist/codegen.d.ts +14 -16
  39. package/dist/codegen.js +1 -1
  40. package/dist/codegen.js.map +1 -1
  41. package/dist/core.cjs +1 -1
  42. package/dist/core.cjs.map +1 -1
  43. package/dist/core.d.cts +178 -172
  44. package/dist/core.d.ts +178 -172
  45. package/dist/core.js +1 -1
  46. package/dist/core.js.map +1 -1
  47. package/dist/doctor-cli.d.ts +1 -1
  48. package/dist/doctor-cli.js +1 -1
  49. package/dist/doctor-cli.js.map +1 -1
  50. package/dist/doctor.d.ts +15 -2
  51. package/dist/doctor.js +1 -1
  52. package/dist/doctor.js.map +1 -1
  53. package/dist/{document-session-DWi9H3Qk.d.ts → document-session-Bkd181PV.d.ts} +3 -2
  54. package/dist/{fragment-endpoint-B2qcRw5T.d.ts → fragment-endpoint-DGGLIijM.d.ts} +1 -1
  55. package/dist/fragment.cjs.map +1 -1
  56. package/dist/fragment.d.cts +3 -3
  57. package/dist/fragment.d.ts +3 -3
  58. package/dist/fragment.js.map +1 -1
  59. package/dist/index.cjs +1 -1
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +183 -177
  62. package/dist/index.d.ts +183 -177
  63. package/dist/index.js +1 -1
  64. package/dist/index.js.map +1 -1
  65. package/dist/lean.cjs +1 -1
  66. package/dist/lean.cjs.map +1 -1
  67. package/dist/lean.js +1 -1
  68. package/dist/lean.js.map +1 -1
  69. package/dist/lexical.cjs +1 -1
  70. package/dist/lexical.cjs.map +1 -1
  71. package/dist/lexical.js +1 -1
  72. package/dist/lexical.js.map +1 -1
  73. package/dist/{locals-B1mF3aTb.d.ts → locals-zz2gi9dj.d.ts} +1 -1
  74. package/dist/{middleware-BGobLN9P.d.ts → middleware-CI-UTf6R.d.ts} +2 -2
  75. package/dist/{options-Cm8fC7dj.d.ts → options-CnYybG51.d.ts} +8 -0
  76. package/dist/plugins.cjs +1 -1
  77. package/dist/plugins.cjs.map +1 -1
  78. package/dist/plugins.d.cts +3 -3
  79. package/dist/plugins.d.ts +3 -3
  80. package/dist/plugins.js +1 -1
  81. package/dist/plugins.js.map +1 -1
  82. package/dist/{probe-DGPDsnbj.d.ts → probe-D-IHg9dF.d.ts} +3 -3
  83. package/dist/structural.cjs +2 -2
  84. package/dist/structural.cjs.map +1 -1
  85. package/dist/structural.d.cts +27 -27
  86. package/dist/structural.d.ts +27 -27
  87. package/dist/structural.js +2 -2
  88. package/dist/structural.js.map +1 -1
  89. package/package.json +11 -6
@@ -38,6 +38,33 @@ type PayloadFieldCondition = (data: unknown, siblingData: unknown) => boolean;
38
38
  */
39
39
  type SanitizerPolicyMode = 'compat' | 'strict';
40
40
 
41
+ /**
42
+ * One source → dependents map for `skipUnchanged`. Markup declares it the
43
+ * other way round (`data-payload-depends="price"` on the element bound to
44
+ * `priceLabel`) because an author names what a binding needs; the runtime
45
+ * option is keyed by source because the scheduler asks what changed.
46
+ * @internal
47
+ */
48
+ type DependencyMap = Readonly<Record<string, readonly string[]>>;
49
+ /**
50
+ * Field names from an attribute value. Separators are commas and
51
+ * whitespace; empty entries are dropped; order is kept, duplicates removed.
52
+ * @internal
53
+ */
54
+ declare function parseDependencyList(value: string | null | undefined): readonly string[];
55
+ /**
56
+ * Merge dependency maps (source → dependents). Later maps add to earlier
57
+ * ones; a dependent is listed once per source.
58
+ * @internal
59
+ */
60
+ declare function mergeDependencyMaps(...maps: readonly DependencyMap[]): DependencyMap;
61
+ /**
62
+ * The map an element's `data-payload-depends` contributes: every declared
63
+ * source points at this binding's field.
64
+ * @internal
65
+ */
66
+ declare function dependencyMapFromBinding(fieldName: string, dependsOn: readonly string[]): DependencyMap;
67
+
41
68
  /**
42
69
  * How a bound region is brought up to date: the runtime patches it, a server
43
70
  * renders a `data-payload-fragment` boundary from the unsaved form state, or
@@ -304,31 +331,4 @@ declare function isMorphCompatible(live: Element, rendered: Element, boundary?:
304
331
  */
305
332
  declare function morphElement(live: Element, rendered: Element, options: MorphOptions): Element;
306
333
 
307
- /**
308
- * One source → dependents map for `skipUnchanged`. Markup declares it the
309
- * other way round (`data-payload-depends="price"` on the element bound to
310
- * `priceLabel`) because an author names what a binding needs; the runtime
311
- * option is keyed by source because the scheduler asks what changed.
312
- * @internal
313
- */
314
- type DependencyMap = Readonly<Record<string, readonly string[]>>;
315
- /**
316
- * Field names from an attribute value. Separators are commas and
317
- * whitespace; empty entries are dropped; order is kept, duplicates removed.
318
- * @internal
319
- */
320
- declare function parseDependencyList(value: string | null | undefined): readonly string[];
321
- /**
322
- * Merge dependency maps (source → dependents). Later maps add to earlier
323
- * ones; a dependent is listed once per source.
324
- * @internal
325
- */
326
- declare function mergeDependencyMaps(...maps: readonly DependencyMap[]): DependencyMap;
327
- /**
328
- * The map an element's `data-payload-depends` contributes: every declared
329
- * source points at this binding's field.
330
- * @internal
331
- */
332
- declare function dependencyMapFromBinding(fieldName: string, dependsOn: readonly string[]): DependencyMap;
333
-
334
334
  export { type ArrayPatch, type CachedElement, type CustomRendererKey, type DependencyMap, type FieldRenderer, type FieldType, ISLAND_ATTRIBUTE, KEY_ATTRIBUTE, type MorphOptions, OWNED_ATTRIBUTE, type PayloadBlockSchema, type PayloadFieldCondition, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type RenderContext, type RendererKey, type RichTextRenderer, type SanitizerPolicyMode, type StructuralApplyOptions, type StructuralStore, type UpdateSource, applyStructuralPatches, createStructuralArrayRenderer, createStructuralStore, dependencyMapFromBinding, isMorphBoundary, isMorphCompatible, mergeDependencyMaps, morphElement, parseDependencyList, retainIslandBoundary };
@@ -38,6 +38,33 @@ type PayloadFieldCondition = (data: unknown, siblingData: unknown) => boolean;
38
38
  */
39
39
  type SanitizerPolicyMode = 'compat' | 'strict';
40
40
 
41
+ /**
42
+ * One source → dependents map for `skipUnchanged`. Markup declares it the
43
+ * other way round (`data-payload-depends="price"` on the element bound to
44
+ * `priceLabel`) because an author names what a binding needs; the runtime
45
+ * option is keyed by source because the scheduler asks what changed.
46
+ * @internal
47
+ */
48
+ type DependencyMap = Readonly<Record<string, readonly string[]>>;
49
+ /**
50
+ * Field names from an attribute value. Separators are commas and
51
+ * whitespace; empty entries are dropped; order is kept, duplicates removed.
52
+ * @internal
53
+ */
54
+ declare function parseDependencyList(value: string | null | undefined): readonly string[];
55
+ /**
56
+ * Merge dependency maps (source → dependents). Later maps add to earlier
57
+ * ones; a dependent is listed once per source.
58
+ * @internal
59
+ */
60
+ declare function mergeDependencyMaps(...maps: readonly DependencyMap[]): DependencyMap;
61
+ /**
62
+ * The map an element's `data-payload-depends` contributes: every declared
63
+ * source points at this binding's field.
64
+ * @internal
65
+ */
66
+ declare function dependencyMapFromBinding(fieldName: string, dependsOn: readonly string[]): DependencyMap;
67
+
41
68
  /**
42
69
  * How a bound region is brought up to date: the runtime patches it, a server
43
70
  * renders a `data-payload-fragment` boundary from the unsaved form state, or
@@ -304,31 +331,4 @@ declare function isMorphCompatible(live: Element, rendered: Element, boundary?:
304
331
  */
305
332
  declare function morphElement(live: Element, rendered: Element, options: MorphOptions): Element;
306
333
 
307
- /**
308
- * One source → dependents map for `skipUnchanged`. Markup declares it the
309
- * other way round (`data-payload-depends="price"` on the element bound to
310
- * `priceLabel`) because an author names what a binding needs; the runtime
311
- * option is keyed by source because the scheduler asks what changed.
312
- * @internal
313
- */
314
- type DependencyMap = Readonly<Record<string, readonly string[]>>;
315
- /**
316
- * Field names from an attribute value. Separators are commas and
317
- * whitespace; empty entries are dropped; order is kept, duplicates removed.
318
- * @internal
319
- */
320
- declare function parseDependencyList(value: string | null | undefined): readonly string[];
321
- /**
322
- * Merge dependency maps (source → dependents). Later maps add to earlier
323
- * ones; a dependent is listed once per source.
324
- * @internal
325
- */
326
- declare function mergeDependencyMaps(...maps: readonly DependencyMap[]): DependencyMap;
327
- /**
328
- * The map an element's `data-payload-depends` contributes: every declared
329
- * source points at this binding's field.
330
- * @internal
331
- */
332
- declare function dependencyMapFromBinding(fieldName: string, dependsOn: readonly string[]): DependencyMap;
333
-
334
334
  export { type ArrayPatch, type CachedElement, type CustomRendererKey, type DependencyMap, type FieldRenderer, type FieldType, ISLAND_ATTRIBUTE, KEY_ATTRIBUTE, type MorphOptions, OWNED_ATTRIBUTE, type PayloadBlockSchema, type PayloadFieldCondition, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type RenderContext, type RendererKey, type RichTextRenderer, type SanitizerPolicyMode, type StructuralApplyOptions, type StructuralStore, type UpdateSource, applyStructuralPatches, createStructuralArrayRenderer, createStructuralStore, dependencyMapFromBinding, isMorphBoundary, isMorphCompatible, mergeDependencyMaps, morphElement, parseDependencyList, retainIslandBoundary };
@@ -1,3 +1,3 @@
1
- var e,t=(e=(...e)=>console.warn(...e),(...t)=>{try{("object"==typeof(n=e(...t))&&null!==n||"function"==typeof n)&&"function"==typeof n.then&&Promise.resolve(n).catch(()=>{})}catch{}var n}),n=/* @__PURE__ */new WeakSet;function o(e){return n.add(e),e}var r=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function i(e){const t=function(){const e=function(){const e=globalThis,t=e[r];if(void 0!==t)return t;const n={};return e[r]=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 a=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),s=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,l=/^[\\/]{2}/,u=/[\t\n\r]/g,c=/[\s\u0000-\u001f\u180e\u2000-\u2029]/g,d=/^([a-z][a-z0-9+.-]*):/i;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(u,"");if(0===t.length)return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(l.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return a.has(e.protocol)}catch{return s.test(t)&&!function(e){const t=d.exec(e.replace(c,""))?.[1];return void 0!==t&&!a.has(`${t.toLowerCase()}:`)}(t)}}var f=/* @__PURE__ */new Set;function p(e){f.has(e)||(f.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 m=/* @__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"]),h=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),y=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),v=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),b="aria-",g="data-",w={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"])},A=/* @__PURE__ */new Set(["href","src","cite","poster"]),S=class extends Error{name="SanitizerEnvironmentError"},k=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-morph","data-payload-nested-key","data-payload-nested-template"]),x=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function L(e,t,n){const o=n?.document??function(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[x];if(e)return e}return"undefined"==typeof document?void 0:document}();if(!o)throw"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new S("sanitizeHtml needs a DOM; pass one per call during SSR: { document } (linkedom, jsdom).");if(""===e)return"";const r=function(e,t){const n=e?.policy??t??"strict";if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(w))e.set(t,n);return{allowedTags:m,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const o=new Set(m);if(e.additionalAllowedTags?.forEach(e=>o.add(e)),!0===e.allowFormControls)for(const e of h)o.add(e);const r=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(w))r.set(e,t);for(const[t,n]of Object.entries(e.additionalAllowedAttributes??{})){const e=new Set(r.get(t));for(const t of n)e.add(t);r.set(t,e)}return{allowedTags:o,attrByTag:r,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t);let a=e;for(let e=0;e<6;e+=1){const e=o.createElement("template");e.innerHTML=i(a),E(e.content,r);const t=e.innerHTML;if(t===a)return t;a=t}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,o=n.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!o.has(e)){o.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 E(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?M(n,t):8===n.nodeType&&n.remove()}function M(e,t){const n=e.tagName.toLowerCase();if(!y.has(n)||t.allowFormControls&&h.has(n)){if(!t.allowedTags.has(n))return E(e,t),void e.replaceWith(...e.childNodes);!function(e,t,n){const o=n.attrByTag.get(t);for(const t of Array.from(e.attributes)){const r=t.name.toLowerCase();if(r.startsWith("on")||"style"===r)e.removeAttribute(t.name);else if("is"!==r){if("strict"===n.mode){if(n.templateMode&&k.has(r))continue;if("id"===r||"name"===r||r.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===r&&!0!==o?.has(r)||p(r);continue}if(r.startsWith(g)){n.allowedData.has(r)||(e.removeAttribute(t.name),p(r));continue}if(v.has(r)||r.startsWith(b))continue}else if(v.has(r)||r.startsWith(b)||r.startsWith(g))continue;o?.has(r)?A.has(r)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==r||T(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&&function isExternalHttpUrl(e){const t=e.trim().replace(u,"");return/^https?:\/\//i.test(t)||l.test(t)}(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),E(e,t)}else e.remove()}function T(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 N=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),D=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(D,e=>N[e])}var _=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]);function C(e){return!e.startsWith("on")&&!_.has(e)}var z=/\{\{([\s\S]*?)\}\}/g;function j(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 W(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function P(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function I(e,t){return t.every(e=>void 0!==W(e))?function(e,t){const n=[],o=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=W(e[t]);void 0!==n&&o.set(n,t)}const r=/* @__PURE__ */new Set;for(let i=0;i<t.length;i+=1){const a=t[i],s=W(a);if(void 0===s){n.push({kind:"insert",index:i,value:a});continue}const l=o.get(s);if(void 0===l){n.push({kind:"insert",index:i,value:a});continue}r.add(l);const u=e[l];P(u)===P(a)?(l!==i&&n.push({kind:"move",from:l,to:i,value:a}),O(u,a)||n.push({kind:"update",index:i,value:a})):n.push({kind:"replace",index:i,oldValue:u,value:a})}for(let t=0;t<e.length;t+=1)r.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){const n=[],o=Math.min(e.length,t.length);for(let r=0;r<o;r+=1)O(e[r],t[r])||n.push({kind:"update",index:r,value:t[r]});if(t.length>e.length)for(let o=e.length;o<t.length;o+=1)n.push({kind:"insert",index:o,value:t[o]});if(e.length>t.length)for(let o=t.length;o<e.length;o+=1)n.push({kind:"remove",index:o,value:e[o]});return n}(e,t)}function O(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,o=t,r=Object.keys(n),i=Object.keys(o);if(r.length!==i.length)return!1;for(const e of r)if(!Object.is(n[e],o[e]))return!1;return!0}var $="data-payload-island",H="data-payload-owned";function U(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute("data-payload-morph"))return!0;if(function(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute($)}(e)&&!("patch"===e.getAttribute($))}(e)||e.hasAttribute(H))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}var R=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],B=/* @__PURE__ */new WeakMap;function q(e){return"astro-island"===e.tagName.toLowerCase()}function V(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 F(e,t){if(!q(e)||!q(t))return!0;const n=V(t);if(!R.every(n=>e.getAttribute(n)===t.getAttribute(n))||(B.get(e)??V(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 B.set(t,n),!1;B.set(e,n);const o=t.getAttribute("props");return o!==e.getAttribute("props")&&(e.setAttribute("ssr",""),null===o?e.removeAttribute("props"):e.setAttribute("props",o)),!0}var K=/* @__PURE__ */new Set(["open","value","checked","selected"]);function G(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function J(e,t,n=U){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!n(e)&&!n(t)}function X(e,t,n){if(!Y(e,t))return t;const o=n.boundary??U,r=o(e),i=o(t);if(r||i)return r&&i&&(n.retainBoundary?.(e,t)??1)?e:t;const a=ee(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||K.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 o=function(e,t){const n=/* @__PURE__ */new Map;let o;for(const r of Array.from(e.children)){const e=G(r,t);void 0!==e&&(n.has(e)?o??=e.slice(e.indexOf("=")+1):n.set(e,r))}return void 0!==o&&t.onDuplicateKey?.(e,o),n}(e,n),r=new Set(o.values()),i=Array.from(e.childNodes).filter(e=>!r.has(e)),a=/* @__PURE__ */new Set,s=/* @__PURE__ */new Set,l=Array.from(t.childNodes);let u=e.firstChild,c=0;for(let t=0;t<l.length;t+=1){const r=l[t];let d=null,f=r instanceof Element?G(r,n):void 0;if(void 0!==f&&s.has(f)&&(f=void 0),void 0!==f){s.add(f);const e=o.get(f);if(void 0!==e&&!a.has(e)&&(d=Z(e,r,n)===e?e:null,null===d)){e.replaceWith(r),a.add(r),u=r.nextSibling;continue}}else{for(;c<i.length;){const o=i[c];if(c+=1,!a.has(o)){if(Y(o,r)){d=Z(o,r,n)===o?o:null,null===d&&(e.replaceChild(r,o),a.add(r),u=r.nextSibling);break}if(o instanceof Element){const n=l[t+1];if(!(r instanceof Element)||void 0!==n&&Y(o,n)){c-=1;break}e.replaceChild(r,o),a.add(r),u=r.nextSibling;break}if(!(r instanceof Element)){e.replaceChild(r,o),a.add(r),u=r.nextSibling;break}}}if(null===d&&a.has(r))continue}const p=d??r;for(a.add(p);null!==u&&u!==p&&!a.has(u)&&Q(u);)u=u.nextSibling;p!==u&&e.insertBefore(p,u),u=p.nextSibling}for(const t of Array.from(e.childNodes))a.has(t)||t.remove()}(e,t,n),te(a),e}function Z(e,t,n){return e instanceof Element&&t instanceof Element?X(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function Q(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function Y(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function ee(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 te(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,o]=n??[null,null];null!==e&&null!==o&&t.setSelectionRange(e,o)}catch{}}var ne=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],oe=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],re=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,ie=/* @__PURE__ */new Map,ae="data-payload-key",se="data-payload-nested-key",le="data-payload-nested-template";function ue(){/* @__PURE__ */
2
- return new WeakMap}function ce(e){const t=fe(e.container,e.patches,e);return null===t?null:pe(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function de(e,t){return t.hasAttribute(se)&&t.hasAttribute(le)}function fe(e,t,n){const o=function(e,t,n){const{template:o,nextItems:r,forceRender:i=!1,store:a,sanitizerPolicy:s}=n,l=a.get(e),u=function(e){const t=e.children,n=t[0];if(void 0===n)return[];const o=[];for(const{name:e,value:r}of Array.from(n.attributes)){if(!C(e)||e.startsWith("data-payload-"))continue;let n=!0;for(let o=1;o<t.length&&n;o+=1)n=t[o]?.getAttribute(e)===r;n&&o.push([e,r])}return o}(e),c=function(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}(r),d=Array.from(e.children),f=we(d,ae),p=/* @__PURE__ */new Set,m=[];for(let a=0;a<r.length;a+=1){const h=r[a],y=ge(h);let v=void 0===y?d[a]??null:Ae(f,y)??null;null!==v&&p.has(v)&&(v=null),null!==v&&p.add(v);const b=t.replaces.has(a),g=i||t.renders.has(a)||null===v?Se(e.ownerDocument,o,h,a,s,u,c):void 0;if(null===g)return null;const w=void 0===g?[]:me(b?null:v,g,h,void 0===y?void 0:l?.get(y),n);if(null===w)return null;m.push([a,v,g,w,b])}return m}(e,function(e){const t=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set;for(const o of e)"insert"===o.kind||"update"===o.kind?t.add(o.index):"replace"===o.kind&&(t.add(o.index),n.add(o.index));return{renders:t,replaces:n}}(t),n);return null===o?null:[e,o,n.nextItems]}function pe(e,t,n){const[o,r,i]=e,a=/* @__PURE__ */new Set;let s=!1;const l=ee(o);for(const[e,i,l,u,c]of r){let r=i;if(void 0!==l){const e=!(!n.morph||c||null===i)&&X(i,l,{keyAttributes:[ae,se],boundary:U,retainBoundary:F,retainChildrenOf:de,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===i;if(!e)for(const[e,t]of u)null!==e&&(ye(e,t),t.replaceWith(e));for(const[,,e]of u)void 0!==e&&pe(e,t,n);e?s=!0:(null!==i&&(i.replaceWith(l),s=!0),r=l)}if(null===r)continue;const d=o.children[e]??null;r!==d&&(o.insertBefore(r,d),s=!0),a.add(r)}for(const e of Array.from(o.children))a.has(e)||(e.remove(),s=!0);te(l);const u=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(o,t);u.clear();for(const e of i)be(u,e);return s}function me(e,t,n,o,r){const i=we(null===e?[]:he(e),se),a=[];for(const e of he(t)){const t=e.getAttribute(se);if(null===t)continue;const s=Ae(i,t)??null,l=e.getAttribute(le),u=l?s:null,c=u?.getAttribute(le)??null;let d;if(l){const i=ve(n,t);if(void 0!==i||null!==u){const n=i??[],a=I(null===u?[]:ve(o,t)??[],n),s=null!==u&&c!==l;if((a.length>0||s)&&(d=fe(u??e,a,{template:l,nextItems:n,forceRender:s,store:r.store,sanitizerPolicy:r.sanitizerPolicy})??void 0,void 0===d))return null}}a.push([u,e,d])}return a}function he(e){return Array.from(e.querySelectorAll(`[${se}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(se))return!1;n=n.parentElement}return n===e})}function ye(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 ve(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function be(e,t){const n=ge(t);void 0!==n&&e.set(n,t)}function ge(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function we(e,t){const n=/* @__PURE__ */new Map;for(let o=e.length-1;o>=0;o-=1){const r=e[o];if(void 0===r)continue;const i=r.getAttribute(t);if(null===i)continue;const a=n.get(i);void 0===a?n.set(i,[r]):a.push(r)}return n}function Ae(e,t){return e.get(t)?.pop()}function Se(e,t,n,o,r,a,s){const l=L(function(e,t,n,o,r){const i="object"==typeof t&&null!==t?t:null;return e.replace(z,(e,a)=>null!==i&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(i,a)?escapeHtml(o(Reflect.get(i,a))):null===i&&"value"===a?escapeHtml(o(t)):"index"===a?String(n):null!==i&&!0===r?.has(a)?"":e)}(t,n,o,j,s),r,function(e){const t=function(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}(ie,e);if(void 0!==t)return t;const n=new Set(ne);for(const t of e.matchAll(re)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const o={};for(const e of n)o[e]=oe;return i=e,a={additionalAllowedTags:[...n],additionalAllowedAttributes:o,allowFormControls:!0,templateMode:!0},(r=ie).set(i,a),function(e){for(const t of e.keys()){if(e.size<=64)break;e.delete(t)}}(r),a;var r,i,a}(t)),u=e.createElement("template");u.innerHTML=i(l);const c=u.content.firstElementChild;if(!c)return null;!function(e,t){for(const[n,o]of t)e.hasAttribute(n)||e.setAttribute(n,o)}(c,a);const d=ge(n);return void 0!==d&&c.setAttribute(ae,d),c}function ke(){const e=/* @__PURE__ */new WeakMap,n=/* @__PURE__ */new WeakSet,r=/* @__PURE__ */new WeakMap,i=ue();return{name:"structural-array",render:/* @__PURE__ */o((o,a,s)=>{const l=function(e){return null==e||""===e}(a)?[]:a;if(!Array.isArray(l))return!1;const u=o.element,c=o.arrayTemplate;if(void 0===c||0===c.length)return function(e,n,o){e.has(n)||(e.add(n),t(`[live-preview] LP0403: Skipping structural update for "${o}": <${n.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(n,u,o.fieldName),!1;const d=e.get(u),f=xe(u),p=I(d?.values??f.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e}),l),m=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,c,f);if(0===p.length&&!m)return e.set(u,{values:l.slice(),template:c,domSnapshot:f}),!1;!function(e,t,n,o,r){const i=r.map(Le),a=/* @__PURE__ */new Set,s=i.find(e=>!(void 0===e||!a.has(e)&&(a.add(e),1)));if(void 0!==s&&Ee(e,t,n,s),i.some(e=>void 0===e)&&Me(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.`),o?.length===r.length&&r.length>1){const r=new Set(o.map(Le).filter(e=>void 0!==e)),a=i.some(e=>void 0!==e&&r.has(e));r.size>0&&!a&&Me(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.`)}}(r,u,o.fieldName,d?.values,l);const h=ce({template:c,container:u,patches:p,nextItems:l,store:i,forceRender:m,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{Ee(r,e,o.fieldName,t)}});return null!==h&&(e.set(u,{values:l.slice(),template:c,domSnapshot:xe(u)}),!!h&&void 0)})}}function xe(e){return Array.from(e.children,e=>e.getAttribute(ae))}function Le(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Ee(e,t,n,o){Me(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${o}"; later ones pair by position. Make \`id\` unique per item.`)}function Me(e,n,o,r){let i=e.get(n);void 0===i&&(i=/* @__PURE__ */new Set,e.set(n,i)),i.has(o)||(i.add(o),t(`[live-preview] ${r}`))}function Te(e){if(null==e)return[];const t=/* @__PURE__ */new Set,n=[];for(const o of e.split(/[\s,]+/)){const e=o.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}function Ne(...e){const t=/* @__PURE__ */new Map;for(const n of e)for(const[e,o]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=/* @__PURE__ */new Set,t.set(e,n));for(const e of o)n.add(e)}const n={};for(const[e,o]of t)n[e]=[...o];return n}function De(e,t){const n={};for(const o of t)o!==e&&(n[o]=[e]);return n}export{$ as ISLAND_ATTRIBUTE,ae as KEY_ATTRIBUTE,H as OWNED_ATTRIBUTE,ce as applyStructuralPatches,ke as createStructuralArrayRenderer,ue as createStructuralStore,De as dependencyMapFromBinding,U as isMorphBoundary,J as isMorphCompatible,Ne as mergeDependencyMaps,X as morphElement,Te as parseDependencyList,F as retainIslandBoundary};
1
+ var e,t=(e=(...e)=>console.warn(...e),(...t)=>{try{("object"==typeof(n=e(...t))&&null!==n||"function"==typeof n)&&"function"==typeof n.then&&Promise.resolve(n).catch(()=>{})}catch{}var n}),n=/* @__PURE__ */new WeakSet;function o(e){return n.add(e),e}var r=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function i(e){const t=function(){const e=function(){const e=globalThis,t=e[r];if(void 0!==t)return t;const n={};return e[r]=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 a=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),s=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,l=/^[\\/]{2}/,u=/[\t\n\r]/g,c=/[\s\u0000-\u001f\u180e\u2000-\u2029]/g,d=/^([a-z][a-z0-9+.-]*):/i;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(u,"");if(0===t.length)return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(l.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return a.has(e.protocol)}catch{return s.test(t)&&!function(e){const t=d.exec(e.replace(c,""))?.[1];return void 0!==t&&!a.has(`${t.toLowerCase()}:`)}(t)}}var f=/* @__PURE__ */new Set;function p(e){f.has(e)||(f.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 m=/* @__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"]),h=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),y=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),v=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),b="aria-",g="data-",w={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"])},A=/* @__PURE__ */new Set(["href","src","cite","poster"]),S=class extends Error{name="SanitizerEnvironmentError"},k=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-morph","data-payload-nested-key","data-payload-nested-template"]),x=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function L(e,t,n){const o=n?.document??function(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[x];if(e)return e}return"undefined"==typeof document?void 0:document}();if(!o)throw E();if(""===e)return"";const r=function(e,t){const n=e?.policy??t??"strict";if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(w))e.set(t,n);return{allowedTags:m,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const o=new Set(m);if(e.additionalAllowedTags?.forEach(e=>o.add(e)),!0===e.allowFormControls)for(const e of h)o.add(e);const r=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(w))r.set(e,t);for(const[t,n]of Object.entries(e.additionalAllowedAttributes??{})){const e=new Set(r.get(t));for(const t of n)e.add(t);r.set(t,e)}return{allowedTags:o,attrByTag:r,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t);let a=e;for(let e=0;e<6;e+=1){const e=o.createElement("template");e.innerHTML=i(a);const t=e.content;T(t,r);const n=M(t);if(n===a)return n;a=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,o=n.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!o.has(e)){o.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 E(){return"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new S("sanitizeHtml needs a DOM; pass one per call during SSR: { document } (linkedom, jsdom).")}function M(e){const t=e.ownerDocument?.createElement("div");if(void 0===t)throw E();const n=e.firstChild;if(t.append(e),t.firstChild!==n)throw E();return t.innerHTML}function T(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?N(n,t):8===n.nodeType&&n.remove()}function N(e,t){const n=e.tagName.toLowerCase();if(!y.has(n)||t.allowFormControls&&h.has(n)){if(!t.allowedTags.has(n))return T(e,t),void e.replaceWith(...e.childNodes);!function(e,t,n){const o=n.attrByTag.get(t);for(const t of Array.from(e.attributes)){const r=t.name.toLowerCase();if(r.startsWith("on")||"style"===r)e.removeAttribute(t.name);else if("is"!==r){if("strict"===n.mode){if(n.templateMode&&k.has(r))continue;if("id"===r||"name"===r||r.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===r&&!0!==o?.has(r)||p(r);continue}if(r.startsWith(g)){n.allowedData.has(r)||(e.removeAttribute(t.name),p(r));continue}if(v.has(r)||r.startsWith(b))continue}else if(v.has(r)||r.startsWith(b)||r.startsWith(g))continue;o?.has(r)?A.has(r)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==r||D(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&&function isExternalHttpUrl(e){const t=e.trim().replace(u,"");return/^https?:\/\//i.test(t)||l.test(t)}(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),T(e,t)}else e.remove()}function D(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 C=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),_=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(_,e=>C[e])}var z=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]);function j(e){return!e.startsWith("on")&&!z.has(e)}var W=/\{\{([\s\S]*?)\}\}/g;function P(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 I(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function O(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function $(e,t){return t.every(e=>void 0!==I(e))?function(e,t){const n=[],o=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=I(e[t]);void 0!==n&&o.set(n,t)}const r=/* @__PURE__ */new Set;for(let i=0;i<t.length;i+=1){const a=t[i],s=I(a);if(void 0===s){n.push({kind:"insert",index:i,value:a});continue}const l=o.get(s);if(void 0===l){n.push({kind:"insert",index:i,value:a});continue}r.add(l);const u=e[l];O(u)===O(a)?(l!==i&&n.push({kind:"move",from:l,to:i,value:a}),H(u,a)||n.push({kind:"update",index:i,value:a})):n.push({kind:"replace",index:i,oldValue:u,value:a})}for(let t=0;t<e.length;t+=1)r.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){const n=[],o=Math.min(e.length,t.length);for(let r=0;r<o;r+=1)H(e[r],t[r])||n.push({kind:"update",index:r,value:t[r]});if(t.length>e.length)for(let o=e.length;o<t.length;o+=1)n.push({kind:"insert",index:o,value:t[o]});if(e.length>t.length)for(let o=t.length;o<e.length;o+=1)n.push({kind:"remove",index:o,value:e[o]});return n}(e,t)}function H(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;const n=e,o=t,r=Object.keys(n),i=Object.keys(o);if(r.length!==i.length)return!1;for(const e of r)if(!Object.is(n[e],o[e]))return!1;return!0}var U="data-payload-island",R="data-payload-owned";function B(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute("data-payload-morph"))return!0;if(function(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(U)}(e)&&!("patch"===e.getAttribute(U))}(e)||e.hasAttribute(R))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}var q=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],V=/* @__PURE__ */new WeakMap;function F(e){return"astro-island"===e.tagName.toLowerCase()}function K(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 G(e,t){if(!F(e)||!F(t))return!0;const n=K(t);if(!q.every(n=>e.getAttribute(n)===t.getAttribute(n))||(V.get(e)??K(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 V.set(t,n),!1;V.set(e,n);const o=t.getAttribute("props");return o!==e.getAttribute("props")&&(e.setAttribute("ssr",""),null===o?e.removeAttribute("props"):e.setAttribute("props",o)),!0}var J=/* @__PURE__ */new Set(["open","value","checked","selected"]);function X(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function Z(e,t,n=B){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!n(e)&&!n(t)}function Q(e,t,n){if(!te(e,t))return t;const o=n.boundary??B,r=o(e),i=o(t);if(r||i)return r&&i&&(n.retainBoundary?.(e,t)??1)?e:t;const a=ne(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||J.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 o=function(e,t){const n=/* @__PURE__ */new Map;let o;for(const r of Array.from(e.children)){const e=X(r,t);void 0!==e&&(n.has(e)?o??=e.slice(e.indexOf("=")+1):n.set(e,r))}return void 0!==o&&t.onDuplicateKey?.(e,o),n}(e,n),r=new Set(o.values()),i=Array.from(e.childNodes).filter(e=>!r.has(e)),a=/* @__PURE__ */new Set,s=/* @__PURE__ */new Set,l=Array.from(t.childNodes);let u=e.firstChild,c=0;for(let t=0;t<l.length;t+=1){const r=l[t];let d=null,f=r instanceof Element?X(r,n):void 0;if(void 0!==f&&s.has(f)&&(f=void 0),void 0!==f){s.add(f);const e=o.get(f);if(void 0!==e&&!a.has(e)&&(d=Y(e,r,n)===e?e:null,null===d)){e.replaceWith(r),a.add(r),u=r.nextSibling;continue}}else{for(;c<i.length;){const o=i[c];if(c+=1,!a.has(o)){if(te(o,r)){d=Y(o,r,n)===o?o:null,null===d&&(e.replaceChild(r,o),a.add(r),u=r.nextSibling);break}if(o instanceof Element){const n=l[t+1];if(!(r instanceof Element)||void 0!==n&&te(o,n)){c-=1;break}e.replaceChild(r,o),a.add(r),u=r.nextSibling;break}if(!(r instanceof Element)){e.replaceChild(r,o),a.add(r),u=r.nextSibling;break}}}if(null===d&&a.has(r))continue}const p=d??r;for(a.add(p);null!==u&&u!==p&&!a.has(u)&&ee(u);)u=u.nextSibling;p!==u&&e.insertBefore(p,u),u=p.nextSibling}for(const t of Array.from(e.childNodes))a.has(t)||t.remove()}(e,t,n),oe(a),e}function Y(e,t,n){return e instanceof Element&&t instanceof Element?Q(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function ee(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function te(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function ne(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 oe(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,o]=n??[null,null];null!==e&&null!==o&&t.setSelectionRange(e,o)}catch{}}var re=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],ie=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],ae=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,se=/* @__PURE__ */new Map,le="data-payload-key",ue="data-payload-nested-key",ce="data-payload-nested-template";function de(){/* @__PURE__ */
2
+ return new WeakMap}function fe(e){const t=me(e.container,e.patches,e);return null===t?null:he(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function pe(e,t){return t.hasAttribute(ue)&&t.hasAttribute(ce)}function me(e,t,n){const o=function(e,t,n){const{template:o,nextItems:r,forceRender:i=!1,store:a,sanitizerPolicy:s}=n,l=a.get(e),u=function(e){const t=e.children,n=t[0];if(void 0===n)return[];const o=[];for(const{name:e,value:r}of Array.from(n.attributes)){if(!j(e)||e.startsWith("data-payload-"))continue;let n=!0;for(let o=1;o<t.length&&n;o+=1)n=t[o]?.getAttribute(e)===r;n&&o.push([e,r])}return o}(e),c=function(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}(r),d=Array.from(e.children),f=Se(d,le),p=/* @__PURE__ */new Set,m=[];for(let a=0;a<r.length;a+=1){const h=r[a],y=Ae(h);let v=void 0===y?d[a]??null:ke(f,y)??null;null!==v&&p.has(v)&&(v=null),null!==v&&p.add(v);const b=t.replaces.has(a),g=i||t.renders.has(a)||null===v?xe(e.ownerDocument,o,h,a,s,u,c):void 0;if(null===g)return null;const w=void 0===g?[]:ye(b?null:v,g,h,void 0===y?void 0:l?.get(y),n);if(null===w)return null;m.push([a,v,g,w,b])}return m}(e,function(e){const t=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set;for(const o of e)"insert"===o.kind||"update"===o.kind?t.add(o.index):"replace"===o.kind&&(t.add(o.index),n.add(o.index));return{renders:t,replaces:n}}(t),n);return null===o?null:[e,o,n.nextItems]}function he(e,t,n){const[o,r,i]=e,a=/* @__PURE__ */new Set;let s=!1;const l=ne(o);for(const[e,i,l,u,c]of r){let r=i;if(void 0!==l){const e=!(!n.morph||c||null===i)&&Q(i,l,{keyAttributes:[le,ue],boundary:B,retainBoundary:G,retainChildrenOf:pe,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===i;if(!e)for(const[e,t]of u)null!==e&&(be(e,t),t.replaceWith(e));for(const[,,e]of u)void 0!==e&&he(e,t,n);e?s=!0:(null!==i&&(i.replaceWith(l),s=!0),r=l)}if(null===r)continue;const d=o.children[e]??null;r!==d&&(o.insertBefore(r,d),s=!0),a.add(r)}for(const e of Array.from(o.children))a.has(e)||(e.remove(),s=!0);oe(l);const u=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(o,t);u.clear();for(const e of i)we(u,e);return s}function ye(e,t,n,o,r){const i=Se(null===e?[]:ve(e),ue),a=[];for(const e of ve(t)){const t=e.getAttribute(ue);if(null===t)continue;const s=ke(i,t)??null,l=e.getAttribute(ce),u=l?s:null,c=u?.getAttribute(ce)??null;let d;if(l){const i=ge(n,t);if(void 0!==i||null!==u){const n=i??[],a=$(null===u?[]:ge(o,t)??[],n),s=null!==u&&c!==l;if((a.length>0||s)&&(d=me(u??e,a,{template:l,nextItems:n,forceRender:s,store:r.store,sanitizerPolicy:r.sanitizerPolicy})??void 0,void 0===d))return null}}a.push([u,e,d])}return a}function ve(e){return Array.from(e.querySelectorAll(`[${ue}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(ue))return!1;n=n.parentElement}return n===e})}function be(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 ge(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function we(e,t){const n=Ae(t);void 0!==n&&e.set(n,t)}function Ae(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Se(e,t){const n=/* @__PURE__ */new Map;for(let o=e.length-1;o>=0;o-=1){const r=e[o];if(void 0===r)continue;const i=r.getAttribute(t);if(null===i)continue;const a=n.get(i);void 0===a?n.set(i,[r]):a.push(r)}return n}function ke(e,t){return e.get(t)?.pop()}function xe(e,t,n,o,r,a,s){const l=L(function(e,t,n,o,r){const i="object"==typeof t&&null!==t?t:null;return e.replace(W,(e,a)=>null!==i&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(i,a)?escapeHtml(o(Reflect.get(i,a))):null===i&&"value"===a?escapeHtml(o(t)):"index"===a?String(n):null!==i&&!0===r?.has(a)?"":e)}(t,n,o,P,s),r,function(e){const t=function(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}(se,e);if(void 0!==t)return t;const n=new Set(re);for(const t of e.matchAll(ae)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const o={};for(const e of n)o[e]=ie;return i=e,a={additionalAllowedTags:[...n],additionalAllowedAttributes:o,allowFormControls:!0,templateMode:!0},(r=se).set(i,a),function(e){for(const t of e.keys()){if(e.size<=64)break;e.delete(t)}}(r),a;var r,i,a}(t)),u=e.createElement("template");u.innerHTML=i(l);const c=u.content.firstElementChild;if(!c)return null;!function(e,t){for(const[n,o]of t)e.hasAttribute(n)||e.setAttribute(n,o)}(c,a);const d=Ae(n);return void 0!==d&&c.setAttribute(le,d),c}function Le(){const e=/* @__PURE__ */new WeakMap,n=/* @__PURE__ */new WeakSet,r=/* @__PURE__ */new WeakMap,i=de();return{name:"structural-array",render:/* @__PURE__ */o((o,a,s)=>{const l=function(e){return null==e||""===e}(a)?[]:a;if(!Array.isArray(l))return!1;const u=o.element,c=o.arrayTemplate;if(void 0===c||0===c.length)return function(e,n,o){e.has(n)||(e.add(n),t(`[live-preview] LP0403: Skipping structural update for "${o}": <${n.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(n,u,o.fieldName),!1;const d=e.get(u),f=Ee(u),p=$(d?.values??f.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e}),l),m=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,c,f);if(0===p.length&&!m)return e.set(u,{values:l.slice(),template:c,domSnapshot:f}),!1;!function(e,t,n,o,r){const i=r.map(Me),a=/* @__PURE__ */new Set,s=i.find(e=>!(void 0===e||!a.has(e)&&(a.add(e),1)));if(void 0!==s&&Te(e,t,n,s),i.some(e=>void 0===e)&&Ne(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.`),o?.length===r.length&&r.length>1){const r=new Set(o.map(Me).filter(e=>void 0!==e)),a=i.some(e=>void 0!==e&&r.has(e));r.size>0&&!a&&Ne(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.`)}}(r,u,o.fieldName,d?.values,l);const h=fe({template:c,container:u,patches:p,nextItems:l,store:i,forceRender:m,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{Te(r,e,o.fieldName,t)}});return null!==h&&(e.set(u,{values:l.slice(),template:c,domSnapshot:Ee(u)}),!!h&&void 0)})}}function Ee(e){return Array.from(e.children,e=>e.getAttribute(le))}function Me(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Te(e,t,n,o){Ne(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${o}"; later ones pair by position. Make \`id\` unique per item.`)}function Ne(e,n,o,r){let i=e.get(n);void 0===i&&(i=/* @__PURE__ */new Set,e.set(n,i)),i.has(o)||(i.add(o),t(`[live-preview] ${r}`))}function De(e){if(null==e)return[];const t=/* @__PURE__ */new Set,n=[];for(const o of e.split(/[\s,]+/)){const e=o.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}function Ce(...e){const t=/* @__PURE__ */new Map;for(const n of e)for(const[e,o]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=/* @__PURE__ */new Set,t.set(e,n));for(const e of o)n.add(e)}const n={};for(const[e,o]of t)n[e]=[...o];return n}function _e(e,t){const n={};for(const o of t)o!==e&&(n[o]=[e]);return n}export{U as ISLAND_ATTRIBUTE,le as KEY_ATTRIBUTE,R as OWNED_ATTRIBUTE,fe as applyStructuralPatches,Le as createStructuralArrayRenderer,de as createStructuralStore,_e as dependencyMapFromBinding,B as isMorphBoundary,Z as isMorphCompatible,Ce as mergeDependencyMaps,Q as morphElement,De as parseDependencyList,G as retainIslandBoundary};
3
3
  //# sourceMappingURL=structural.js.map