payload-live-preview 2.0.1 → 2.0.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.
Files changed (76) hide show
  1. package/README.md +36 -31
  2. package/dist/adapters/astro/RichText.astro +1 -1
  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.js +1 -1
  6. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  7. package/dist/adapters/nextjs/index.js +1 -1
  8. package/dist/adapters/nextjs/index.js.map +1 -1
  9. package/dist/adapters/nuxt/index.js +1 -1
  10. package/dist/adapters/nuxt/index.js.map +1 -1
  11. package/dist/adapters/nuxt/module.d.ts +12 -4
  12. package/dist/adapters/nuxt/module.js.map +1 -1
  13. package/dist/adapters/react/index.d.ts +6 -5
  14. package/dist/adapters/react/index.js.map +1 -1
  15. package/dist/adapters/sveltekit/index.js +1 -1
  16. package/dist/adapters/sveltekit/index.js.map +1 -1
  17. package/dist/adapters/vue/index.d.ts +3 -3
  18. package/dist/adapters/vue/index.js.map +1 -1
  19. package/dist/annotate.js +1 -1
  20. package/dist/annotate.js.map +1 -1
  21. package/dist/client.cjs +1 -1
  22. package/dist/client.cjs.map +1 -1
  23. package/dist/client.js +1 -1
  24. package/dist/client.js.map +1 -1
  25. package/dist/codegen-astro.d.ts +4 -1
  26. package/dist/codegen-astro.js.map +1 -1
  27. package/dist/codegen-cli.js +1 -1
  28. package/dist/codegen-cli.js.map +1 -1
  29. package/dist/codegen.cjs +1 -1
  30. package/dist/codegen.cjs.map +1 -1
  31. package/dist/codegen.js +1 -1
  32. package/dist/codegen.js.map +1 -1
  33. package/dist/core.cjs +1 -1
  34. package/dist/core.cjs.map +1 -1
  35. package/dist/core.d.cts +1 -1
  36. package/dist/core.d.ts +1 -1
  37. package/dist/core.js +1 -1
  38. package/dist/core.js.map +1 -1
  39. package/dist/doctor-cli.d.ts +1 -1
  40. package/dist/doctor-cli.js +1 -1
  41. package/dist/doctor-cli.js.map +1 -1
  42. package/dist/doctor.d.ts +2 -2
  43. package/dist/doctor.js +1 -1
  44. package/dist/doctor.js.map +1 -1
  45. package/dist/fragment.cjs.map +1 -1
  46. package/dist/fragment.d.cts +6 -3
  47. package/dist/fragment.d.ts +6 -3
  48. package/dist/fragment.js.map +1 -1
  49. package/dist/index.cjs +1 -1
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +8 -8
  52. package/dist/index.d.ts +8 -8
  53. package/dist/index.js +1 -1
  54. package/dist/index.js.map +1 -1
  55. package/dist/lean.cjs +1 -1
  56. package/dist/lean.cjs.map +1 -1
  57. package/dist/lean.d.cts +3 -3
  58. package/dist/lean.d.ts +3 -3
  59. package/dist/lean.js +1 -1
  60. package/dist/lean.js.map +1 -1
  61. package/dist/lexical.cjs +1 -1
  62. package/dist/lexical.cjs.map +1 -1
  63. package/dist/lexical.d.cts +11 -1
  64. package/dist/lexical.d.ts +11 -1
  65. package/dist/lexical.js +1 -1
  66. package/dist/lexical.js.map +1 -1
  67. package/dist/plugins.cjs +1 -1
  68. package/dist/plugins.cjs.map +1 -1
  69. package/dist/plugins.js +1 -1
  70. package/dist/plugins.js.map +1 -1
  71. package/dist/{probe-wmvfVEsI.d.ts → probe-DqaItcwX.d.ts} +2 -1
  72. package/dist/structural.cjs +2 -2
  73. package/dist/structural.cjs.map +1 -1
  74. package/dist/structural.js +2 -2
  75. package/dist/structural.js.map +1 -1
  76. package/package.json +2 -3
@@ -172,7 +172,8 @@ interface RunDoctorOptions {
172
172
  /**
173
173
  * Headers sent with the preview probe only, never with the visitor probe: the
174
174
  * credentials a preview behind `authorizePreview` needs, such as a Payload
175
- * session `Cookie` or an `x-preview-token`. Without them a gated page answers
175
+ * session `Cookie`, or an `x-preview-token` where the token strategy reads a
176
+ * header (a token in the URL is passed in `url` instead). Without them a gated page answers
176
177
  * the audit the way it answers any stranger. Their values never reach the report.
177
178
  */
178
179
  readonly previewHeaders?: Readonly<Record<string, string>> | undefined;
@@ -1,3 +1,3 @@
1
- "use strict";var e,t,n=(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}),o=/* @__PURE__ */new WeakSet;function r(e){return o.add(e),e}function i(e){const n=function(){if(void 0!==t)return t;const e=function(){const e=globalThis.trustedTypes;if("object"==typeof e&&null!==e)return"function"==typeof e.createPolicy?e:void 0}();try{t=void 0===e?null:e.createPolicy("payload-live-preview",{createHTML:e=>e})}catch{t=null}return t}();return null===n?e:n.createHTML(e)}var a=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),s=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,l=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,c=/^[\\/]{2}/,u=/[\t\n\r]/g;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(u,"");if(0===t.length)return!1;if(s.test(t))return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(c.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return a.has(e.protocol)}catch{return l.test(t)}}var d=/* @__PURE__ */new Set;function f(e){d.has(e)||(d.add(e),function(e){try{console.warn(e)}catch{}}(`[live-preview] LP0409: the strict sanitizer removed \`${e}\` from written markup; the 1.x default (\`sanitizerPolicy: 'compat'\`) kept it. ${function(e){return e.startsWith("data-payload-")?"A binding inside CMS content is refused by design — an editor could otherwise aim a write at any element on the page (docs/security.md)":"id"===e||"name"===e?"CMS content that can name an element can shadow a global of that name — DOM clobbering, refused by design (docs/security.md)":"List it in `allowedDataAttributes` if the page needs it, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var p=/* @__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"]),m=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),h=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),y=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),v="aria-",g="data-",b={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"])},w=/* @__PURE__ */new Set(["href","src","cite","poster"]),S=class extends Error{name="SanitizerEnvironmentError"},A=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"]);function x(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?k(n,t):8===n.nodeType&&n.remove()}function k(e,t){const n=e.tagName.toLowerCase();if(!h.has(n)||t.allowFormControls&&m.has(n)){if(!t.allowedTags.has(n))return x(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("strict"===n.mode){if(n.templateMode&&A.has(r))continue;if("id"===r||"name"===r||r.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===r&&!0!==o?.has(r)||f(r);continue}if(r.startsWith(g)){n.allowedData.has(r)||(e.removeAttribute(t.name),f(r));continue}if(y.has(r)||r.startsWith(v))continue}else if(y.has(r)||r.startsWith(v)||r.startsWith(g))continue;o?.has(r)?w.has(r)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==r||E(t.value)||e.removeAttribute(t.name):e.removeAttribute(t.name)}}}(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)||c.test(t)}(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),x(e,t)}else e.remove()}function E(e){for(const t of e.split(",")){const e=t.trim();if(0===e.length)continue;const[n=e]=e.split(/\s/,1);if(!isSafeUrl(n))return!1}return!0}var T=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),L=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(L,e=>T[e])}var M=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]);function D(e){return!e.startsWith("on")&&!M.has(e)}var N=/\{\{([\s\S]*?)\}\}/g;function _(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 j(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function C(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 c=e[l];j(c)===j(a)?(l!==i&&n.push({kind:"move",from:l,to:i,value:a}),W(c,a)||n.push({kind:"update",index:i,value:a})):n.push({kind:"replace",index:i,oldValue:c,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)W(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 W(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 z="data-payload-island",O="data-payload-owned",P=/* @__PURE__ */new Set(["open","value","checked","selected"]);function U(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function R(e){if(e.tagName.toLowerCase().includes("-"))return!0;if(e.hasAttribute(z)||e.hasAttribute(O))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function B(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!R(e)&&!R(t)}function H(e,t,n){if(!B(e,t))return t;const o=function(e){const t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement&&e.contains(t)))return null;return{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}}(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||P.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=U(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 c=e.firstChild,u=0;for(let t=0;t<l.length;t+=1){const r=l[t];let d=null,f=r instanceof Element?U(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=$(e,r,n)===e?e:null,null===d)){e.replaceWith(r),a.add(r),c=r.nextSibling;continue}}else{for(;u<i.length;){const o=i[u];if(u+=1,!a.has(o)){if(F(o,r)){d=$(o,r,n)===o?o:null,null===d&&(e.replaceChild(r,o),a.add(r),c=r.nextSibling);break}if(o instanceof Element){const n=l[t+1];if(!(r instanceof Element)||void 0!==n&&F(o,n)){u-=1;break}e.replaceChild(r,o),a.add(r),c=r.nextSibling;break}if(!(r instanceof Element)){e.replaceChild(r,o),a.add(r),c=r.nextSibling;break}}}if(null===d&&a.has(r))continue}const p=d??r;for(a.add(p);null!==c&&c!==p&&!a.has(c)&&q(c);)c=c.nextSibling;p!==c&&e.insertBefore(p,c),c=p.nextSibling}for(const t of Array.from(e.childNodes))a.has(t)||t.remove()}(e,t,n),function(e){if(null===e)return;const{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});const[e,o]=n??[null,null];null!==e&&null!==o&&t.setSelectionRange(e,o)}catch{}}(o),e}function $(e,t,n){return e instanceof Element&&t instanceof Element?R(e)&&R(t)?e:H(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 F(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}var K=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],V=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],G=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,J=/* @__PURE__ */new Map,X="data-payload-key",Y="data-payload-nested-key",Z="data-payload-nested-template";function Q(){/* @__PURE__ */
2
- return new WeakMap}function ee(e){const t=ne(e.container,e.patches,e);return null===t?null:oe(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function te(e,t){return t.hasAttribute(Y)&&t.hasAttribute(Z)}function ne(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),c=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(!D(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),u=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=ue(d,X),p=/* @__PURE__ */new Set,m=[];for(let a=0;a<r.length;a+=1){const h=r[a],y=ce(h);let v=void 0===y?d[a]??null:de(f,y)??null;null!==v&&p.has(v)&&(v=null),null!==v&&p.add(v);const g=t.replaces.has(a),b=i||t.renders.has(a)||null===v?fe(e.ownerDocument,o,h,a,s,c,u):void 0;if(null===b)return null;const w=void 0===b?[]:re(g?null:v,b,h,void 0===y?void 0:l?.get(y),n);if(null===w)return null;m.push([a,v,b,w,g])}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 oe(e,t,n){const[o,r,i]=e,a=/* @__PURE__ */new Set;let s=!1;for(const[e,i,l,c,u]of r){let r=i;if(void 0!==l){const e=!(!n.morph||u||null===i)&&H(i,l,{keyAttributes:[X,Y],retainChildrenOf:te,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===i;if(!e)for(const[e,t]of c)null!==e&&(ae(e,t),t.replaceWith(e));for(const[,,e]of c)void 0!==e&&oe(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);const l=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(o,t);l.clear();for(const e of i)le(l,e);return s}function re(e,t,n,o,r){const i=ue(null===e?[]:ie(e),Y),a=[];for(const e of ie(t)){const t=e.getAttribute(Y);if(null===t)continue;const s=de(i,t)??null,l=e.getAttribute(Z),c=l?s:null,u=c?.getAttribute(Z)??null;let d;if(l){const i=se(n,t);if(void 0!==i||null!==c){const n=i??[],a=C(null===c?[]:se(o,t)??[],n),s=null!==c&&u!==l;if((a.length>0||s)&&(d=ne(c??e,a,{template:l,nextItems:n,forceRender:s,store:r.store,sanitizerPolicy:r.sanitizerPolicy})??void 0,void 0===d))return null}}a.push([c,e,d])}return a}function ie(e){return Array.from(e.querySelectorAll(`[${Y}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Y))return!1;n=n.parentElement}return n===e})}function ae(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 se(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function le(e,t){const n=ce(t);void 0!==n&&e.set(n,t)}function ce(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function ue(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 de(e,t){return e.get(t)?.pop()}function fe(e,t,n,o,r,a,s){const l=function(e,t,n){const o=("undefined"==typeof __INLINE_BUILD__||__INLINE_BUILD__,"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; provide one with setSanitizerDocument() during SSR.");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(b))e.set(t,n);return{allowedTags:p,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const o=new Set(p);if(e.additionalAllowedTags?.forEach(e=>o.add(e)),!0===e.allowFormControls)for(const e of m)o.add(e);const r=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(b))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),a=o.createElement("template");return a.innerHTML=i(e),x(a.content,r),a.innerHTML}(function(e,t,n,o,r){const i="object"==typeof t&&null!==t?t:null;return e.replace(N,(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,_,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}(J,e);if(void 0!==t)return t;const n=new Set(K);for(const t of e.matchAll(G)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const o={};for(const e of n)o[e]=V;return i=e,a={additionalAllowedTags:[...n],additionalAllowedAttributes:o,allowFormControls:!0,templateMode:!0},(r=J).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)),c=e.createElement("template");c.innerHTML=i(l);const u=c.content.firstElementChild;if(!u)return null;!function(e,t){for(const[n,o]of t)e.hasAttribute(n)||e.setAttribute(n,o)}(u,a);const d=ce(n);return void 0!==d&&u.setAttribute(X,d),u}function pe(e){return Array.from(e.children,e=>e.getAttribute(X))}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 he(e,t,n,o){ye(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${o}"; later ones pair by position. Make \`id\` unique per item.`)}function ye(e,t,o,r){let i=e.get(t);void 0===i&&(i=/* @__PURE__ */new Set,e.set(t,i)),i.has(o)||(i.add(o),n(`[live-preview] ${r}`))}exports.ISLAND_ATTRIBUTE=z,exports.KEY_ATTRIBUTE=X,exports.OWNED_ATTRIBUTE=O,exports.applyStructuralPatches=ee,exports.createStructuralArrayRenderer=function(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,o=/* @__PURE__ */new WeakMap,i=Q();return{name:"structural-array",render:/* @__PURE__ */r((r,a,s)=>{const l=function(e){return null==e||""===e}(a)?[]:a;if(!Array.isArray(l))return!1;const c=r.element,u=r.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,o){e.has(t)||(e.add(t),n(`[live-preview] LP0403: Skipping structural update for "${o}": <${t.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(t,c,r.fieldName),!1;const d=e.get(c),f=pe(c),p=C(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,u,f);if(0===p.length&&!m)return e.set(c,{values:l.slice(),template:u,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&&he(e,t,n,s),i.some(e=>void 0===e)&&ye(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&&ye(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.`)}}(o,c,r.fieldName,d?.values,l);const h=ee({template:u,container:c,patches:p,nextItems:l,store:i,forceRender:m,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{he(o,e,r.fieldName,t)}});return null!==h&&(e.set(c,{values:l.slice(),template:u,domSnapshot:pe(c)}),!!h&&void 0)})}},exports.createStructuralStore=Q,exports.dependencyMapFromBinding=function(e,t){const n={};for(const o of t)o!==e&&(n[o]=[e]);return n},exports.isMorphBoundary=R,exports.isMorphCompatible=B,exports.mergeDependencyMaps=function(...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},exports.morphElement=H,exports.parseDependencyList=function(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};
1
+ "use strict";var e,t,n=(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}),o=/* @__PURE__ */new WeakSet;function r(e){return o.add(e),e}function i(e){const n=function(){if(void 0!==t)return t;const e=function(){const e=globalThis.trustedTypes;if("object"==typeof e&&null!==e)return"function"==typeof e.createPolicy?e:void 0}();try{t=void 0===e?null:e.createPolicy("payload-live-preview",{createHTML:e=>e})}catch{t=null}return t}();return null===n?e:n.createHTML(e)}var a=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),s=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,l=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,c=/^[\\/]{2}/,u=/[\t\n\r]/g;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(u,"");if(0===t.length)return!1;if(s.test(t))return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(c.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return a.has(e.protocol)}catch{return l.test(t)}}var d=/* @__PURE__ */new Set;function f(e){d.has(e)||(d.add(e),function(e){try{console.warn(e)}catch{}}(`[live-preview] LP0409: the strict sanitizer removed \`${e}\` from written markup; the 1.x default (\`sanitizerPolicy: 'compat'\`) kept it. ${function(e){return e.startsWith("data-payload-")?"A binding inside CMS content is refused by design — an editor could otherwise aim a write at any element on the page (docs/security.md)":"id"===e||"name"===e?"CMS content that can name an element can shadow a global of that name — DOM clobbering, refused by design (docs/security.md)":"List it in `allowedDataAttributes` if the page needs it, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var p=/* @__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"]),m=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),h=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),y=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),v="aria-",b="data-",g={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"])},w=/* @__PURE__ */new Set(["href","src","cite","poster"]),S=class extends Error{name="SanitizerEnvironmentError"},A=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"]),x=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function k(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?T(n,t):8===n.nodeType&&n.remove()}function T(e,t){const n=e.tagName.toLowerCase();if(!h.has(n)||t.allowFormControls&&m.has(n)){if(!t.allowedTags.has(n))return k(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("strict"===n.mode){if(n.templateMode&&A.has(r))continue;if("id"===r||"name"===r||r.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===r&&!0!==o?.has(r)||f(r);continue}if(r.startsWith(b)){n.allowedData.has(r)||(e.removeAttribute(t.name),f(r));continue}if(y.has(r)||r.startsWith(v))continue}else if(y.has(r)||r.startsWith(v)||r.startsWith(b))continue;o?.has(r)?w.has(r)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==r||E(t.value)||e.removeAttribute(t.name):e.removeAttribute(t.name)}}}(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)||c.test(t)}(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),k(e,t)}else e.remove()}function E(e){for(const t of e.split(",")){const e=t.trim();if(0===e.length)continue;const[n=e]=e.split(/\s/,1);if(!isSafeUrl(n))return!1}return!0}var L=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),M=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(M,e=>L[e])}var D=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]);function N(e){return!e.startsWith("on")&&!D.has(e)}var _=/\{\{([\s\S]*?)\}\}/g;function I(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 j(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function C(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function z(e,t){return t.every(e=>void 0!==j(e))?function(e,t){const n=[],o=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=j(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=j(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 c=e[l];C(c)===C(a)?(l!==i&&n.push({kind:"move",from:l,to:i,value:a}),W(c,a)||n.push({kind:"update",index:i,value:a})):n.push({kind:"replace",index:i,oldValue:c,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)W(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 W(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 O="data-payload-island",P="data-payload-owned",U=/* @__PURE__ */new Set(["open","value","checked","selected"]);function R(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function B(e){if(e.tagName.toLowerCase().includes("-"))return!0;if(e.hasAttribute(O)||e.hasAttribute(P))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function H(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!B(e)&&!B(t)}function $(e,t,n){if(!H(e,t))return t;const o=function(e){const t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement&&e.contains(t)))return null;return{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}}(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||U.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=R(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 c=e.firstChild,u=0;for(let t=0;t<l.length;t+=1){const r=l[t];let d=null,f=r instanceof Element?R(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=q(e,r,n)===e?e:null,null===d)){e.replaceWith(r),a.add(r),c=r.nextSibling;continue}}else{for(;u<i.length;){const o=i[u];if(u+=1,!a.has(o)){if(K(o,r)){d=q(o,r,n)===o?o:null,null===d&&(e.replaceChild(r,o),a.add(r),c=r.nextSibling);break}if(o instanceof Element){const n=l[t+1];if(!(r instanceof Element)||void 0!==n&&K(o,n)){u-=1;break}e.replaceChild(r,o),a.add(r),c=r.nextSibling;break}if(!(r instanceof Element)){e.replaceChild(r,o),a.add(r),c=r.nextSibling;break}}}if(null===d&&a.has(r))continue}const p=d??r;for(a.add(p);null!==c&&c!==p&&!a.has(c)&&F(c);)c=c.nextSibling;p!==c&&e.insertBefore(p,c),c=p.nextSibling}for(const t of Array.from(e.childNodes))a.has(t)||t.remove()}(e,t,n),function(e){if(null===e)return;const{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});const[e,o]=n??[null,null];null!==e&&null!==o&&t.setSelectionRange(e,o)}catch{}}(o),e}function q(e,t,n){return e instanceof Element&&t instanceof Element?B(e)&&B(t)?e:$(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function F(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function K(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}var V=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],G=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],J=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,X=/* @__PURE__ */new Map,Y="data-payload-key",Z="data-payload-nested-key",Q="data-payload-nested-template";function ee(){/* @__PURE__ */
2
+ return new WeakMap}function te(e){const t=oe(e.container,e.patches,e);return null===t?null:re(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function ne(e,t){return t.hasAttribute(Z)&&t.hasAttribute(Q)}function oe(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),c=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(!N(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),u=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=de(d,Y),p=/* @__PURE__ */new Set,m=[];for(let a=0;a<r.length;a+=1){const h=r[a],y=ue(h);let v=void 0===y?d[a]??null:fe(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?pe(e.ownerDocument,o,h,a,s,c,u):void 0;if(null===g)return null;const w=void 0===g?[]:ie(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 re(e,t,n){const[o,r,i]=e,a=/* @__PURE__ */new Set;let s=!1;for(const[e,i,l,c,u]of r){let r=i;if(void 0!==l){const e=!(!n.morph||u||null===i)&&$(i,l,{keyAttributes:[Y,Z],retainChildrenOf:ne,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===i;if(!e)for(const[e,t]of c)null!==e&&(se(e,t),t.replaceWith(e));for(const[,,e]of c)void 0!==e&&re(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);const l=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(o,t);l.clear();for(const e of i)ce(l,e);return s}function ie(e,t,n,o,r){const i=de(null===e?[]:ae(e),Z),a=[];for(const e of ae(t)){const t=e.getAttribute(Z);if(null===t)continue;const s=fe(i,t)??null,l=e.getAttribute(Q),c=l?s:null,u=c?.getAttribute(Q)??null;let d;if(l){const i=le(n,t);if(void 0!==i||null!==c){const n=i??[],a=z(null===c?[]:le(o,t)??[],n),s=null!==c&&u!==l;if((a.length>0||s)&&(d=oe(c??e,a,{template:l,nextItems:n,forceRender:s,store:r.store,sanitizerPolicy:r.sanitizerPolicy})??void 0,void 0===d))return null}}a.push([c,e,d])}return a}function ae(e){return Array.from(e.querySelectorAll(`[${Z}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Z))return!1;n=n.parentElement}return n===e})}function se(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 le(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function ce(e,t){const n=ue(t);void 0!==n&&e.set(n,t)}function ue(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function de(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 fe(e,t){return e.get(t)?.pop()}function pe(e,t,n,o,r,a,s){const l=function(e,t,n){const o=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; provide one with setSanitizerDocument() during SSR.");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(g))e.set(t,n);return{allowedTags:p,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const o=new Set(p);if(e.additionalAllowedTags?.forEach(e=>o.add(e)),!0===e.allowFormControls)for(const e of m)o.add(e);const r=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(g))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),a=o.createElement("template");return a.innerHTML=i(e),k(a.content,r),a.innerHTML}(function(e,t,n,o,r){const i="object"==typeof t&&null!==t?t:null;return e.replace(_,(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,I,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}(X,e);if(void 0!==t)return t;const n=new Set(V);for(const t of e.matchAll(J)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const o={};for(const e of n)o[e]=G;return i=e,a={additionalAllowedTags:[...n],additionalAllowedAttributes:o,allowFormControls:!0,templateMode:!0},(r=X).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)),c=e.createElement("template");c.innerHTML=i(l);const u=c.content.firstElementChild;if(!u)return null;!function(e,t){for(const[n,o]of t)e.hasAttribute(n)||e.setAttribute(n,o)}(u,a);const d=ue(n);return void 0!==d&&u.setAttribute(Y,d),u}function me(e){return Array.from(e.children,e=>e.getAttribute(Y))}function he(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function ye(e,t,n,o){ve(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${o}"; later ones pair by position. Make \`id\` unique per item.`)}function ve(e,t,o,r){let i=e.get(t);void 0===i&&(i=/* @__PURE__ */new Set,e.set(t,i)),i.has(o)||(i.add(o),n(`[live-preview] ${r}`))}exports.ISLAND_ATTRIBUTE=O,exports.KEY_ATTRIBUTE=Y,exports.OWNED_ATTRIBUTE=P,exports.applyStructuralPatches=te,exports.createStructuralArrayRenderer=function(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,o=/* @__PURE__ */new WeakMap,i=ee();return{name:"structural-array",render:/* @__PURE__ */r((r,a,s)=>{const l=function(e){return null==e||""===e}(a)?[]:a;if(!Array.isArray(l))return!1;const c=r.element,u=r.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,o){e.has(t)||(e.add(t),n(`[live-preview] LP0403: Skipping structural update for "${o}": <${t.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(t,c,r.fieldName),!1;const d=e.get(c),f=me(c),p=z(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,u,f);if(0===p.length&&!m)return e.set(c,{values:l.slice(),template:u,domSnapshot:f}),!1;!function(e,t,n,o,r){const i=r.map(he),a=/* @__PURE__ */new Set,s=i.find(e=>!(void 0===e||!a.has(e)&&(a.add(e),1)));if(void 0!==s&&ye(e,t,n,s),i.some(e=>void 0===e)&&ve(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(he).filter(e=>void 0!==e)),a=i.some(e=>void 0!==e&&r.has(e));r.size>0&&!a&&ve(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.`)}}(o,c,r.fieldName,d?.values,l);const h=te({template:u,container:c,patches:p,nextItems:l,store:i,forceRender:m,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{ye(o,e,r.fieldName,t)}});return null!==h&&(e.set(c,{values:l.slice(),template:u,domSnapshot:me(c)}),!!h&&void 0)})}},exports.createStructuralStore=ee,exports.dependencyMapFromBinding=function(e,t){const n={};for(const o of t)o!==e&&(n[o]=[e]);return n},exports.isMorphBoundary=B,exports.isMorphCompatible=H,exports.mergeDependencyMaps=function(...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},exports.morphElement=$,exports.parseDependencyList=function(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};
3
3
  //# sourceMappingURL=structural.cjs.map