@panphora/clayjs 1.12.1 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/clay.standalone.js +3544 -3167
- package/docs/guide.md +1847 -0
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +6 -6
- package/package.json +14 -1
- package/packed-contract.json +1 -1
- package/src/lib/unsaved-state.js +11 -2
- package/src/live/checkpoint.js +7 -0
- package/src/live/fast-lane.js +24 -10
- package/src/live/local-lane.js +14 -7
- package/src/live/moves.js +11 -0
- package/src/live/server-lane.js +2 -1
- package/src/live/store.js +32 -1
- package/src/loader-logic.js +5 -1
- package/src/loader.js +2 -0
- package/src/page/binding.js +647 -0
- package/src/page/inline.js +113 -0
- package/src/page/model.js +241 -0
- package/src/page/replay.js +578 -0
- package/src/page/schema.js +157 -0
- package/src/plugins/live.js +49 -2
- package/src/plugins/message.js +159 -0
- package/src/plugins/visitor-drafts/prompt-style.js +5 -16
- package/src/plugins/visitor-drafts/prompt.js +6 -41
- package/src/plugins/visitor-drafts/source.js +0 -5
- package/src/plugins/visitor-drafts.js +2 -2
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +20 -20
- package/src/vendor/prosemirror.vendor.js +12 -0
package/entries/clay-data.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// hyper-html-api/dist/hyper-html-api.engine.min.js via hyper-html-api
|
|
3
3
|
// `npm run copy-to-clayjs`. Edit the hyper-html-api source and re-run.
|
|
4
4
|
(function () {
|
|
5
|
-
var hyperHtmlApiData=(()=>{var re=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var Se=(e,t)=>{for(var n in t)re(e,n,{get:t[n],enumerable:!0})},it=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of nt(t))!rt.call(e,r)&&r!==n&&re(e,r,{get:()=>t[r],enumerable:!(i=tt(t,r))||i.enumerable});return e};var ot=e=>it(re({},"__esModule",{value:!0}),e);var Vt={};Se(Vt,{applyData:()=>xe,default:()=>Ft,engine:()=>X,extractData:()=>Oe});var Y=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Z=new Set(Y),ie=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),$=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),be=new Set(["checked","selected","disabled","readOnly","paused"]);function oe(e,t){return t==null?be.has(e)?!1:"":be.has(e)?t==="false"?!1:!!t:t}var R={};Se(R,{EmptyListInsert:()=>N,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>P,NoRulesTag:()=>se,RuleTargetReadOnly:()=>B,RulesParseError:()=>k,ShapeMismatch:()=>v,UnknownRulesVersion:()=>W,WriteNotRoundTripped:()=>Q,WriteRefused:()=>H,WriteRejected:()=>le});var k=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},W=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},L=20,P=class extends Error{constructor(t){super(`rule depth exceeded ${L} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},v=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},N=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},B=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},H=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function st(e){return e.reduce((n,i)=>typeof i=="number"?`${n}[${i}]`:n?`${n}.${i}`:String(i),"")||"(root)"}var Q=class extends Error{constructor(t){super(`write did not round-trip at "${st(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},se=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},le=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function b(e){let t=0,n=null,i=-1;for(let r=0;r<e.length;r++){let s=e[r];s==="\\"?r++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:s==="@"&&t===0&&(i=r)}return i}function ce(e){let t=b(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function fe(e){let t=0,n=null,i=-1,r=!1;for(let s=0;s<e.length;s++){let l=e[s];l==="\\"?s++:n?l===n&&(n=null):l==='"'||l==="'"?n=l:l==="["||l==="("?t++:l==="]"||l===")"?t>0&&t--:t===0&&l===">"?i=s:t===0&&l===","&&(r=!0)}return r||i===-1||!lt(e,i+1)?null:e.slice(0,i).trim()||null}function lt(e,t){let n=t,i=e.replace(/\s+$/,"").length;for(;n<i&&/\s/.test(e[n]);)n++;let r=0,s=null;for(;n<i;n++){let l=e[n];if(l==="\\")n++;else if(s)l===s&&(s=null);else if(l==='"'||l==="'")s=l;else if(l==="["||l==="(")r++;else if(l==="]"||l===")")r>0&&r--;else if(r===0&&(l==="+"||l==="~"||/\s/.test(l)))return!1}return!0}function C(e,t,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return ue(e,t,n,{depth:0,path:[]},i)}function ue(e,t,n,i,r){if(i.depth>L)throw new P(i.path);if(typeof n=="string")return ct(e,t,n,i,r);if(Array.isArray(n)){let[s,l]=n,c=e.find(t,s,r);return Ne(r,i,c),c.map((o,f)=>ue(e,o,l,{depth:i.depth+1,path:[...i.path,f]},r))}if(typeof n=="object"&&n!==null){let s={};for(let[l,c]of Object.entries(n))s[l]=ue(e,t,c,{depth:i.depth+1,path:[...i.path,l]},r);return s}return null}function ct(e,t,n,i,r){if(n.endsWith("[]")){let c=n.slice(0,-2),o=e.find(t,c,r);return Ne(r,i,o),o.map(f=>e.text(f))}if(n.startsWith("@"))return Re(e,t,n.slice(1));let s=b(n);if(s!==-1){let c=n.slice(0,s),o=n.slice(s+1),f=c?e.find(t,c,r):[t];return f.length===0?null:Re(e,f[0],o)}if(n===".")return e.text(t);let l=e.find(t,n,r);return l.length===0?null:e.text(l[0])}function Ne(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(i){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,i)}}function Re(e,t,n){if(Z.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let i=e.attr(t,n);return i??null}function Pe(e,t,n,i){let r=e.length,s=t.length,l=new Array(r).fill(-1);if(i){let h=new Set;for(let y=0;y<r;y++){let A=i[y];!(A>=0&&A<s)||h.has(A)||(l[y]=A,h.add(A))}}if(r===0||s===0)return l;let c=e.map(h=>Ce(h,n)),o=t.map(h=>Ce(h,n)),f=new Array(s).fill(!1);for(let h of l)h>=0&&(f[h]=!0);let u=new Map;o.forEach((h,y)=>{f[y]||u.set(h,u.has(h)?-1:y)});let m=new Map;c.forEach((h,y)=>{l[y]>=0||m.set(h,(m.get(h)||0)+1)}),c.forEach((h,y)=>{if(l[y]>=0||m.get(h)!==1)return;let A=u.get(h);A===void 0||A===-1||f[A]||(l[y]=A,f[A]=!0)});let d=[];for(let h=0;h<r;h++)l[h]<0&&d.push(h);let w=[];for(let h=0;h<s;h++)f[h]||w.push(h);if(d.length===0||w.length===0)return l;let a=r*s+1,p=ft(e,t,n),g=(h,y)=>p(h,y)*a+Math.abs(h-y);for(let[h,y]of ut(d,w,g))l[h]=y;return l}var Ie=e=>typeof e=="object"&&e!==null;function Ce(e,t){if(!Ie(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(i=>{let r=JSON.stringify(e?.[i]);return r===void 0?" undef":r}))}function ft(e,t,n){if(!Ie(n))return(c,o)=>e[c]===t[o]?0:1;let i=Object.keys(n),r=c=>i.map(o=>JSON.stringify(c?.[o])),s=e.map(r),l=t.map(r);return(c,o)=>{let f=s[c],u=l[o],m=0;for(let d=0;d<i.length;d++)f[d]!==u[d]&&m++;return m}}function ut(e,t,n){return e.length<=t.length?Me(e,t,n,!1):Me(t,e,(i,r)=>n(r,i),!0)}function Me(e,t,n,i){let r=e.length,s=t.length,l=[];for(let m=0;m<=r;m++)l.push(new Float64Array(s+1).fill(1/0));let c=[];for(let m=0;m<=r;m++)c.push(new Uint8Array(s+1));for(let m=0;m<=s;m++)l[r][m]=0;for(let m=r-1;m>=0;m--)for(let d=s-1;d>=0;d--){let w=n(e[m],t[d])+l[m+1][d+1],a=l[m][d+1];w<=a?(l[m][d]=w,c[m][d]=1):l[m][d]=a}let o=[],f=0,u=0;for(;f<r&&u<s;)c[f][u]&&(o.push(i?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return o}function he(e,t,n,i,r,s,l,c={}){let o=e.find(t,n,c);if(r.length===0){o.forEach(T=>e.remove(T)),ae(c,"onRowsApplied",s.path,[]);return}let f=r.length>o.length,u=o[0]||null;if(f&&!u&&(u=pt(e,t,n,c),!u))throw new N(s.path);let m=o.map(T=>dt(e,T,i,c)),d=null;if(f&&u){d=e.clone(u),c.templateAttr&&e.removeAttr(d,c.templateAttr);let T=e.stripIds(d);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let w=Pe(r,m,i,at(e,o,r,s,c)),a=o.length>0?e.parent(o[0]):At(e,t,n,u,s,c),p=o.length>0?De(e,a,o[0]):0,g=Et(e,o),h=new Set,y=[],A=r.map((T,S)=>{let O=w[S];if(O>=0)return h.add(O),y.push(!1),o[O];y.push(!0);let E=e.clone(d);return e.stripIds(E),E});o.forEach((T,S)=>{h.has(S)||e.remove(T)}),g?wt(e,a,p,A,y):Ot(e,A,y,a,p),ht(e,A,i,r,s,l,c),ae(c,"onRowsApplied",s.path,A)}function ae(e,t,n,i){if(typeof e[t]=="function")try{return e[t](n.slice(),i)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function at(e,t,n,i,r){let s=ae(r,"identifyRows",i.path,n);if(!Array.isArray(s))return null;let l=new Array(n.length).fill(-1),c=new Set,o=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!s[f])continue;let u=o.get(e.identity(s[f]));u===void 0||c.has(u)||(l[f]=u,c.add(u))}return l}function ht(e,t,n,i,r,s,l){t.forEach((c,o)=>{if(n===null){let f=i[o],u=f==null?"":String(f);e.text(c)!==u&&e.text(c,u)}else{let f=s(e,c,n,i[o],{depth:r.depth+1,path:[...r.path,o]},l);f&&f!==c&&(t[o]=f)}})}function dt(e,t,n,i){return n===null?e.text(t):C(e,t,n,i.onRowsRead?{...i,onRowsRead:void 0}:i)}function De(e,t,n){let i=e.children(t);for(let r=0;r<i.length;r++)if(e.sameNode(i[r],n))return r;return-1}function pt(e,t,n,i){if(!i.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),s=new RegExp(":not\\(\\["+i.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),l=n.replace(/^\s*:scope\s*>\s*/,"").replace(s,""),c=r?mt(l):0,o=fe(l),f=t;for(;f;){let u=e.find(f,l,{includeRulesTag:!1,templateAttr:null});for(let m of u)if(e.attr(m,i.templateAttr)!=null&&!(r&&!gt(e,t,m,c))&&!(o&&!e.matches(e.parent(m),o)))return m;f=e.parent(f)}return null}function mt(e){let t=0,n=null,i=1;for(let r=0;r<e.length;r++){let s=e[r];if(s==="\\")r++;else if(n)s===n&&(n=null);else if(s==='"'||s==="'")n=s;else if(s==="["||s==="(")t++;else if(s==="]"||s===")")t>0&&t--;else if(t===0&&s===">")i++;else{if(t===0&&(s==="+"||s==="~"))return null;if(t===0&&/\s/.test(s)){if(!yt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return i}function yt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let i=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return ke(i)||ke(r)}function ke(e){return e===">"||e==="+"||e==="~"}function gt(e,t,n,i){if(i===null)return!0;let r=n;for(let o=0;o<i;o++)if(r=e.parent(r),!r)return!1;let s=e.prop(t,"tagName");if(!s)return!0;let l=e.prop(r,"tagName");if(!l||String(l).toLowerCase()!==String(s).toLowerCase())return!1;let c=new Set(Le(e,r));return Le(e,t).every(o=>c.has(o))}function Le(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function At(e,t,n,i,r,s){let l=e.parent(i);if(l&&Tt(e,t,l)&&!_e(e,l,s))return l;let c=fe(n);if(!c)throw new N(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let f=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,s)).filter(u=>!_e(e,u,s));if(f.length===0)throw new N(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(f.length>1)throw new N(r.path,`"${c}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function Tt(e,t,n){let i=n;for(;i;){if(e.sameNode(i,t))return!0;i=e.parent(i)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var je=["no-data","editor-ui"];function _e(e,t,n){let i=t;for(;i;){if(n.templateAttr&&e.attr(i,n.templateAttr)!=null||je.some(s=>e.attr(i,s)!=null))return!0;let r=e.attr(i,"clay");if(r&&r.split(/\s+/).some(s=>je.includes(s)))return!0;i=e.parent(i)}return!1}function wt(e,t,n,i,r){let s=e.children(t),l=s.map(o=>e.identity(o)),c=!1;i.forEach((o,f)=>{let u=e.identity(o),m=n+f;if(l[m]===u)return;if(!r[f]){let w=l.indexOf(u);w!==-1&&(l.splice(w,1),s.splice(w,1))}let d=Math.min(m,s.length);d<s.length?e.insertBefore(s[d],o):s.length?c?e.insertAfter(s[s.length-1],o):(e.insertAt(t,o,m),c=!0):e.insertAt(t,o,0),l.splice(d,0,u),s.splice(d,0,o)})}function Et(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let i=new Map(e.children(n).map((s,l)=>[e.identity(s),l])),r=[];for(let s of t){let l=i.get(e.identity(s));if(l===void 0)return!1;r.push(l)}return r.sort((s,l)=>s-l),r[r.length-1]-r[0]===r.length-1}function Ot(e,t,n,i,r){let s=null,l=r;for(let c=0;c<t.length;c++){if(!n[c]){s=t[c];continue}let o=s?e.parent(s):i;if(!o)continue;let f=s?De(e,o,s)+1:l++;e.insertAt(o,t[c],f),s=t[c]}}function I(e,t,n,i,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let s=[];if(de(n,i,[],s),s.length)throw new v(s);ee(e,t,n,i,{depth:0,path:[]},r)}function ee(e,t,n,i,r,s={}){if(r.depth>L)throw new P(r.path);if(i===void 0)return t;if(typeof n=="string")return xt(e,t,n,i,r,s);if(Array.isArray(n)){let[l,c]=n;return he(e,t,l,c,i,r,ee,s),t}if(typeof n=="object"&&n!==null){for(let[l,c]of Object.entries(n)){let o=ee(e,t,c,i==null?i:i[l],{depth:r.depth+1,path:[...r.path,l]},s);o&&o!==t&&(t=o)}return t}return t}function xt(e,t,n,i,r,s){if(n.endsWith("[]")){let o=n.slice(0,-2);return he(e,t,o,null,i,r,ee,s),t}if(n.startsWith("@"))return We(e,t,n.slice(1),i);let l=b(n);if(l!==-1){let o=n.slice(0,l),f=n.slice(l+1),u=o?e.find(t,o,s):[t];return u.length===0||We(e,u[0],f,i),t}if(n===".")return $e(e,t,i),t;let c=e.find(t,n,s);return c.length===0||$e(e,c[0],i),t}function $e(e,t,n){let i=n==null?"":String(n);e.text(t)!==i&&e.text(t,i)}function We(e,t,n,i){if($.has(n)){let r=e.prop(t,n);if(r===i||r!=null&&i!=null&&String(r)===String(i))return t;throw new B(n)}if(n==="outerHTML"){let r=i==null?"":String(i);return e.replaceWith(t,r)}if(ie.has(n)){let r=oe(n,i);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(i==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(i);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function de(e,t,n,i){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,s)=>{typeof r=="object"&&r!==null&&i.push({path:U([...n,s]),expected:"scalar",got:q(r)})}):i.push({path:U(n),expected:"array",got:q(t)});return}t!==null&&typeof t=="object"&&i.push({path:U(n),expected:"scalar",got:q(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:U(n),expected:"array",got:q(t)});return}let r=e[1];t.forEach((s,l)=>de(r,s,[...n,l],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:U(n),expected:"object",got:q(t)});return}for(let[r,s]of Object.entries(e))de(s,t[r],[...n,r],i)}}}function q(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function U(e){return e.join(".")}function pe(e){try{return JSON.parse(e)}catch(t){throw new k(`Invalid strict JSON: ${t.message}`,t)}}function z(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let s=[],l=0;for(;l<r.length;){let c=r[l];if(/\s/.test(c)){l++;continue}if("{}".includes(c)){s.push({type:c,value:c}),l++;continue}if(c==="["){let m=!1,d=l+1;for(;d<r.length&&/\s/.test(r[d]);)d++;if(d<r.length&&/[a-zA-Z_]/.test(r[d])&&(m=!0),!m){s.push({type:c,value:c}),l++;continue}}if(c==="]"){s.push({type:c,value:c}),l++;continue}if(c===":"){s.push({type:t.COLON,value:c}),l++;continue}if(c===","){s.push({type:t.COMMA,value:c}),l++;continue}if(c==='"'||c==="'"){let m=c,d=l+1;for(;d<r.length&&r[d]!==m;)r[d]==="\\"&&d++,d++;s.push({type:t.STRING,value:r.substring(l+1,d),quoted:!0,sourceQuote:m}),l=d+1;continue}let o=l,f;for(;o<r.length&&!/[{},]/.test(r[o]);)if(r[o]===":"){let m=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let w of m){let a=w.substring(1);if(r.substring(o+1,o+1+a.length)===a){d=!0,o+=a.length;break}}if(!d)break}else if(r[o]==="["){for(o++;o<r.length&&r[o]!=="]";){if(r[o]==='"'||r[o]==="'"){let m=r[o];for(o++;o<r.length&&r[o]!==m;)r[o]==="\\"&&o++,o++}o++}o<r.length&&r[o]==="]"&&o++}else o++;f=r.substring(l,o);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(f)?u=t.NUMBER:f==="true"||f==="false"||f==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(f)&&(u=t.SELECTOR),s.push({type:u,value:f,quoted:!1}),l=o}return s}function i(r){let s="";for(let l=0;l<r.length;l++){let c=r[l];if("{}".includes(c.type)||"[]".includes(c.type)){s+=c.value;continue}if(c.type===t.COLON){s+=c.value;continue}if(c.type===t.COMMA){let o=r[l+1];if(o&&(o.type==="}"||o.type==="]"))continue;s+=c.value;continue}if(c.type===t.STRING&&c.quoted){let o=c.value;c.sourceQuote==="'"&&(o=o.replace(/\\'/g,"'"),o=o.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),s+=`"${o}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){s+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){s+=`"${c.value}"`;continue}s+=`"${c.value}"`}return s}try{let r=n(e),s=i(r);return JSON.parse(s)}catch(r){throw new k("Invalid extraction rules syntax: "+r.message,r)}}var St="1",ve=/^[a-zA-Z0-9_-]+$/;function j(e,t,n){let i;if(n===void 0)i="script[data-rules-name]";else{if(typeof n!="string"||!ve.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${ve})`);i=`script[data-rules-name~="${n}"]`}let r=e.find(t,i,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=r[0],l=e.attr(s,"data-rules-version");if(l!==St)throw new W(l);return{rules:z(e.text(s)),tagNode:s}}var te=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),bt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Be=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function K(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function me(e,t){if(K(e,t))return!0;for(let[n,i]of Object.entries(bt))if(i.includes(t)&&K(e,n))return!0;return!1}function F(e){let t=te[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Rt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=te[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>me(n,r))||i.bundles.some(r=>K(n,r)))return n;n=n.parentElement}return null}function He(e,t){return!!Rt(e,t)}var ye=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Be],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),Nt=new Set(["textContent","innerText"]);function qe(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var Ct=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function Ue(e,t,n=ye){if(!Ct.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let i=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>i.startsWith(r)))return`attribute "${i}" can run script`;if(n.refusedAttributes.includes(i))return`attribute "${i}" is not content`;if(n.urlAttributes.includes(i)&&t!=null){let r=i==="srcset"?String(t).split(",").map(s=>s.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let s of r){let l=qe(s);if(l&&n.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${i}"`}}return null}function ge(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function Mt(e,t){let n=ge(e,t)||"node",i=e.attr(t,"id");return i?`<${n}#${i}>`:`<${n}>`}function Pt(e,t,n){let i=t;for(;i;){let r=ge(e,i);if(r&&n.refusedTargets.includes(r))return r;i=e.parent(i)}return null}function ze(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function It(e,t){return ge(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ze(e,t)}function ne(e,t=ye){let n=[],i=(o,f)=>(n.push({target:Mt(e,o),reason:f}),!1),r=o=>{let f=Pt(e,o,t);return f?i(o,`inside <${f}>, which is not content`):!0},s=o=>r(o)?ze(e,o)?i(o,"a text write here would delete the data rules tag"):!0:!1,l=(o,f,u)=>{if(!r(o))return!1;let m=Ue(f,u,t);return m?i(o,m):!0};return{...e,text(o,f){if(f===void 0)return e.text(o);s(o)&&e.text(o,f)},attr(o,f,u){if(u===void 0)return e.attr(o,f);l(o,f,u)&&e.attr(o,f,u)},removeAttr(o,f){l(o,f,null)&&e.removeAttr(o,f)},prop(o,f,u){if(u===void 0)return e.prop(o,f);if(t.refusedRuleForms.includes(f))return i(o,`"@${f}" writes HTML, only text is allowed`);if(Nt.has(f)){s(o)&&e.prop(o,f,u);return}l(o,f==="className"?"class":f,u)&&e.prop(o,f,u)},remove(o){if(It(e,o)){i(o,"removing this would delete the data rules tag");return}e.remove(o)},replaceWith(o,f){return f===e.prop(o,"outerHTML")||i(o,'"@outerHTML" writes HTML, only text is allowed'),o},refusals:n,assertClean(){if(n.length)throw new H(n.slice())}}}function V(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ke(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function Ae(e,t,n,i,r={}){let s=[],l=[];function c(f,u,m){if(Array.isArray(f)){let[,d]=f;if(!Array.isArray(u)||!V(d))return;u.forEach((w,a)=>c(d,w,[...m,a]));return}if(!(!V(f)||!V(u)))for(let d of Object.keys(u))Object.prototype.hasOwnProperty.call(f,d)?c(f[d],u[d],[...m,d]):s.push(Ke([...m,d]))}function o(f,u,m,d){if(m!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let w=b(u),a=w===-1?u:u.slice(0,w);if(!a)return;e.find(f,a,r).length===0&&l.push({path:Ke(d),selector:a});return}if(!Array.isArray(u)&&V(u)&&V(m))for(let[w,a]of Object.entries(u))o(f,a,m[w],[...d,w])}}return c(n,i,[]),o(t,n,i,[]),{unknownKeys:s,unmatched:l}}function Te(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return j(e,i,n)}return null}var Lt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function jt(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Fe(e,t,n,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Ve(e,t,n,i,r,s){return(s?He(e,t):Fe(e,n,r,!1))||!!(i&&(s&&e!==r?e.matches(i):Fe(e,i,r,s)))}function _t(e,t){let n=te[t];return n.tokens.some(i=>me(e,i))||n.bundles.some(i=>K(e,i))}var Dt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Je(e,t,n,i){if(e.nodeType===1&&i(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,s=t;if(e.nodeType===1){if(Dt.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,s=t.content,n.cloneToLive.set(s,r),n.liveToClone.set(r,s)}}else if(e.nodeType!==11)return;let l=s.firstChild;for(let c=r.firstChild;c&&l;c=c.nextSibling)Je(c,l,n,i),l=l.nextSibling}function J(e,{capability:t="data",exclude:n=null,inherit:i=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let l=s.implementation.createHTMLDocument(""),c=r||new WeakMap,o=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&l.documentElement.matches(n);let u=F(t),m=i?a=>_t(a,t)||!!(n&&a.matches(n)):a=>Ve(a,t,u,n,f,!1),d=null;if(f.nodeType!==1||!Ve(f,t,u,n,f,i)){d=l.importNode(f,!0);let a={cloneToLive:c,liveToClone:o,dropped:[],controls:[]};Je(f,d,a,m);for(let p of a.dropped)p.remove();for(let p=0;p<a.controls.length;p+=2)jt(a.controls[p],a.controls[p+1])}e.nodeType===9&&d&&(l.replaceChild(d,l.documentElement),o.set(e,l),c.set(l,e));let w=a=>{if(Lt.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:d,document:l,capability:t,selector:F(t),cloneToLive:c,liveToClone:o,original(a){return c.get(a)||null},cloneOf(a){return o.get(a)||null},query(a,p=d){return w(a),Array.from(p.querySelectorAll(a),g=>c.get(g)||g)},text(a=d){return(a===d?d:o.get(a))?.textContent||""},html(a=d){return(a===d?d:o.get(a))?.innerHTML??""},clone(a=d){let p=a===d?d:o.get(a);return p?l.importNode(p,!0):null}}}function Xe(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function $t(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Ge(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function Ye(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Ze(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let i=n.type;i!=="file"&&i!=="checkbox"&&i!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var x={semanticExclude:!0,find(e,t,n={}){let i=$t(e);if(!i||!i.querySelectorAll)return[];let r=Array.from(i.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!Xe(c)));let s=[];n.skip&&s.push(n.skip);let l=n.templateAttr===null?null:n.templateAttr||"cms-template";if(l&&s.push("["+l+"]"),s.length){let c=s.join(", ");r=r.filter(o=>!o.closest||!o.closest(c))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Ye(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Ge(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Ge(e,t,null)},prop(e,t,n){if(n===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return Ze(t),t},insertAt(e,t,n){let i=e.children[n]||null;e.insertBefore(t,i)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let i=e.ownerDocument.createElement("template");i.innerHTML=t;let r=i.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function M(e,t={}){if(t.exclude===null)return x;let n=[F("data"),t.exclude].filter(Boolean).join(", "),i=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!i?.querySelector?.(n))return x;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,c=null,o=()=>c||(c=J(s,{capability:"data",exclude:t.exclude||null})),f=a=>{let p=o();return a===e?p.cloneOf(e):p.cloneOf(a)||a},u=a=>c?.original(a)||a,m=(a,p)=>{o().liveToClone.set(a,p),o().cloneToLive.set(p,a);let g=a.childNodes||[],h=p.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)m(g[y],h[y])},d=(a,p,g,h)=>{let y=Array.from(a.childNodes).filter(E=>c.cloneOf(E)),T=y[0];for(;T&&y.includes(T);)T=T.nextSibling;for(let E of y)E.remove();if(g==="innerHTML"){let E=l.createElement("template");E.innerHTML=h;for(let D of Array.from(E.content.childNodes))a.insertBefore(D,T||null)}else a.insertBefore(l.createTextNode(h),T||null),Ye(a,h);let S=J(a,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(S.root?.childNodes||[]));let O=E=>{let D=S.original(E);D&&(c.liveToClone.set(D,E),c.cloneToLive.set(E,D));for(let et of Array.from(E.childNodes||[]))O(et)};for(let E of Array.from(p.childNodes))O(E)},w={...x,find(a,p,g={}){let h=f(a);if(!h?.querySelectorAll)return[];let y=o().query(p,h);g.includeRulesTag||(y=y.filter(S=>!Xe(S)));let A=[];g.skip&&A.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&A.push(`[${T}]`),A.length){let S=A.join(", ");y=y.filter(O=>!O.closest?.(S))}return y},parent(a){let p=f(a)?.parentElement;return p?u(p):null},children(a){return Array.from(f(a)?.children||[],u)},text(a,p){if(p===void 0){let y=u(a);return!y?.matches?.(n)&&!y?.querySelector?.(n)?x.text(y):(f(a)?.textContent||"").trim()}let g=u(a);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){x.text(g,p);return}let h=o().cloneOf(g);h?d(g,h,"textContent",p):x.text(g,p)},attr(a,p,g){let h=u(a);if(g===void 0)return x.attr(h,p);x.attr(h,p,g);let y=c?.cloneOf(h);y&&(x.attr(y,p,g),J(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(h),c.cloneToLive.delete(y)))},removeAttr(a,p){let g=u(a);x.removeAttr(g,p);let h=c?.cloneOf(g);h&&x.removeAttr(h,p)},prop(a,p,g){let h=u(a);if(g===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?x.prop(f(h),p):x.prop(h,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",A=y?o().cloneOf(h):c?.cloneOf(h);A&&y?d(h,A,p,g):(x.prop(h,p,g),A&&x.prop(A,p,g))},clone(a){let p=f(a);if(p===a)return x.clone(a);let g=l.importNode(p,!0);return Ze(g),g},insertAt(a,p,g){let h=u(a),A=w.children(h)[g]||(()=>{for(let O=h.children.length-1;O>=0;O--){let E=h.children[O];if(o().cloneOf(E))return E.nextElementSibling}return h.firstElementChild})(),T=u(p);h.insertBefore(T,A||null);let S=o().cloneOf(h);if(S){let O=o().cloneOf(T);O||(O=l.importNode(T,!0),m(T,O));let E=Array.from(S.children);S.insertBefore(O,E[g]||null)}},insertBefore(a,p){let g=u(a),h=u(p);g.parentNode.insertBefore(h,g);let y=o().cloneOf(g.parentNode);if(y){let A=o().cloneOf(h);A||(A=l.importNode(h,!0),m(h,A));let T=o().cloneOf(g);T?T.before(A):y.appendChild(A)}},insertAfter(a,p){let g=u(a),h=u(p);g.parentNode.insertBefore(h,g.nextSibling);let y=o().cloneOf(g.parentNode);if(y){let A=o().cloneOf(h);A||(A=l.importNode(h,!0),m(h,A));let T=o().cloneOf(g);T?T.after(A):y.appendChild(A)}},identity(a){return u(a)||null},remove(a){let p=u(a),g=o().cloneOf(p);x.remove(p),g&&x.remove(g)},replaceWith(a,p){let g=u(a),h=o().cloneOf(g),y=x.replaceWith(g,p);if(h){let A=J(y,{capability:"data",exclude:t.exclude||null});if(!A.root)h.remove();else{h.replaceWith(A.root);let T=S=>{let O=A.original(S);O&&(c.liveToClone.set(O,S),c.cloneToLive.set(S,O));for(let E of Array.from(S.childNodes||[]))T(E)};T(A.root)}}return y}};return w}var G=x;var X={extract:(e,t,n={})=>C(M(e,n),e,t,n),apply:(e,t,n,i={})=>I(M(e,{...i,_write:!0}),e,t,n,i),findRulesIn:(e,t)=>j(G,e,t),findRules:(e,t)=>Te(G,e,t),bind:(e,t,n={})=>{let i=Te(G,e,t);if(!i){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...i,get:()=>C(M(e,n),e,i.rules,n),set:r=>I(M(e,{...n,_write:!0}),e,i.rules,r,n)}},parseStrict:pe,parseRelaxed:z,ruleAttrIndex:b,splitRule:ce,errors:R,DOM_PROPERTIES:Y},we=e=>!!e&&typeof e.nodeType=="number";function Qe(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=j(G,t,"api");if(!n)throw new R.NoRulesTag("api");return n.rules}function Wt(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function vt(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function Bt(e,t){let n=[];for(;t!==e;){let i=t.parentNode;n.push(Array.prototype.indexOf.call(i.childNodes,t)),t=i}return n.reverse()}function Ht(e,t){return t.reduce((n,i)=>n.childNodes[i],e)}function _(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function qt(e,t){let n=_(e,"option"),i=_(t,"option");n.forEach((o,f)=>i[f].selected=o.selected);let r=_(e,"input"),s=_(t,"input");r.forEach((o,f)=>{let u=o.type.toLowerCase();u!=="file"&&(s[f].value=o.value),(u==="checkbox"||u==="radio")&&(s[f].checked=o.checked)});let l=_(e,"textarea"),c=_(t,"textarea");l.forEach((o,f)=>c[f].value=o.value)}function Ee(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:b(e);if(n===-1)return;let i=e.slice(n+1);if($.has(i))throw new R.RuleTargetReadOnly(i);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>Ee(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,i]of Object.entries(e))Ee(i,t[n])}}function Ut(e,t,n){let i={templateAttr:"cms-template"},r=Wt(e),s=Bt(r,e),l=vt(r);qt(r,l);let c=Ht(l,s),o=M(l,{...i,_write:!0}),f=Ae(o,c,t,n,i);if(f.unknownKeys.length||f.unmatched.length)throw new R.WriteRejected(f.unknownKeys,f.unmatched);let u=ne(o);I(u,c,t,n,i),u.assertClean(),Ee(t,n);let m=ne(M(r,{...i,_write:!0}));I(m,e,t,n,i),m.assertClean()}function zt(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof R.WriteRefused?e.details=e.refusals:e instanceof R.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof R.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function Oe(e,t){let n=we(e)?e:document,i=we(e)?t:e;return i===void 0?C(M(n),n,Qe(n)):X.bind(n,i).get()}function xe(e,t,n){try{if(!we(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let i=n===void 0?Qe(e):X.bind(e,n).rules;Ut(e,i,t)}catch(i){throw zt(i)}return e}var Kt={engine:X,extractData:Oe,applyData:xe},Ft=Kt;return ot(Vt);})();
|
|
5
|
+
var hyperHtmlApiData=(()=>{var re=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var Se=(e,t)=>{for(var n in t)re(e,n,{get:t[n],enumerable:!0})},it=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of nt(t))!rt.call(e,r)&&r!==n&&re(e,r,{get:()=>t[r],enumerable:!(i=tt(t,r))||i.enumerable});return e};var ot=e=>it(re({},"__esModule",{value:!0}),e);var Vt={};Se(Vt,{applyData:()=>xe,default:()=>Ft,engine:()=>G,extractData:()=>Oe});var Y=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Z=new Set(Y),ie=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),$=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),be=new Set(["checked","selected","disabled","readOnly","paused"]);function oe(e,t){return t==null?be.has(e)?!1:"":be.has(e)?t==="false"?!1:!!t:t}var R={};Se(R,{EmptyListInsert:()=>N,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>P,NoRulesTag:()=>se,RuleTargetReadOnly:()=>B,RulesParseError:()=>k,ShapeMismatch:()=>v,UnknownRulesVersion:()=>W,WriteNotRoundTripped:()=>Q,WriteRefused:()=>H,WriteRejected:()=>le});var k=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},W=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},L=20,P=class extends Error{constructor(t){super(`rule depth exceeded ${L} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},v=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},N=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},B=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},H=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function st(e){return e.reduce((n,i)=>typeof i=="number"?`${n}[${i}]`:n?`${n}.${i}`:String(i),"")||"(root)"}var Q=class extends Error{constructor(t){super(`write did not round-trip at "${st(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},se=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},le=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function b(e){let t=0,n=null,i=-1;for(let r=0;r<e.length;r++){let s=e[r];s==="\\"?r++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:s==="@"&&t===0&&(i=r)}return i}function ce(e){let t=b(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function fe(e){let t=0,n=null,i=-1,r=!1;for(let s=0;s<e.length;s++){let l=e[s];l==="\\"?s++:n?l===n&&(n=null):l==='"'||l==="'"?n=l:l==="["||l==="("?t++:l==="]"||l===")"?t>0&&t--:t===0&&l===">"?i=s:t===0&&l===","&&(r=!0)}return r||i===-1||!lt(e,i+1)?null:e.slice(0,i).trim()||null}function lt(e,t){let n=t,i=e.replace(/\s+$/,"").length;for(;n<i&&/\s/.test(e[n]);)n++;let r=0,s=null;for(;n<i;n++){let l=e[n];if(l==="\\")n++;else if(s)l===s&&(s=null);else if(l==='"'||l==="'")s=l;else if(l==="["||l==="(")r++;else if(l==="]"||l===")")r>0&&r--;else if(r===0&&(l==="+"||l==="~"||/\s/.test(l)))return!1}return!0}function C(e,t,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return ue(e,t,n,{depth:0,path:[]},i)}function ue(e,t,n,i,r){if(i.depth>L)throw new P(i.path);if(typeof n=="string")return ct(e,t,n,i,r);if(Array.isArray(n)){let[s,l]=n,c=e.find(t,s,r);return Ne(r,i,c),c.map((o,f)=>ue(e,o,l,{depth:i.depth+1,path:[...i.path,f]},r))}if(typeof n=="object"&&n!==null){let s={};for(let[l,c]of Object.entries(n))s[l]=ue(e,t,c,{depth:i.depth+1,path:[...i.path,l]},r);return s}return null}function ct(e,t,n,i,r){if(n.endsWith("[]")){let c=n.slice(0,-2),o=e.find(t,c,r);return Ne(r,i,o),o.map(f=>e.text(f))}if(n.startsWith("@"))return Re(e,t,n.slice(1));let s=b(n);if(s!==-1){let c=n.slice(0,s),o=n.slice(s+1),f=c?e.find(t,c,r):[t];return f.length===0?null:Re(e,f[0],o)}if(n===".")return e.text(t);let l=e.find(t,n,r);return l.length===0?null:e.text(l[0])}function Ne(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(i){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,i)}}function Re(e,t,n){if(Z.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let i=e.attr(t,n);return i??null}function Pe(e,t,n,i){let r=e.length,s=t.length,l=new Array(r).fill(-1);if(i){let h=new Set;for(let y=0;y<r;y++){let A=i[y];!(A>=0&&A<s)||h.has(A)||(l[y]=A,h.add(A))}}if(r===0||s===0)return l;let c=e.map(h=>Ce(h,n)),o=t.map(h=>Ce(h,n)),f=new Array(s).fill(!1);for(let h of l)h>=0&&(f[h]=!0);let u=new Map;o.forEach((h,y)=>{f[y]||u.set(h,u.has(h)?-1:y)});let m=new Map;c.forEach((h,y)=>{l[y]>=0||m.set(h,(m.get(h)||0)+1)}),c.forEach((h,y)=>{if(l[y]>=0||m.get(h)!==1)return;let A=u.get(h);A===void 0||A===-1||f[A]||(l[y]=A,f[A]=!0)});let d=[];for(let h=0;h<r;h++)l[h]<0&&d.push(h);let w=[];for(let h=0;h<s;h++)f[h]||w.push(h);if(d.length===0||w.length===0)return l;let a=r*s+1,p=ft(e,t,n),g=(h,y)=>p(h,y)*a+Math.abs(h-y);for(let[h,y]of ut(d,w,g))l[h]=y;return l}var Ie=e=>typeof e=="object"&&e!==null;function Ce(e,t){if(!Ie(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(i=>{let r=JSON.stringify(e?.[i]);return r===void 0?" undef":r}))}function ft(e,t,n){if(!Ie(n))return(c,o)=>e[c]===t[o]?0:1;let i=Object.keys(n),r=c=>i.map(o=>JSON.stringify(c?.[o])),s=e.map(r),l=t.map(r);return(c,o)=>{let f=s[c],u=l[o],m=0;for(let d=0;d<i.length;d++)f[d]!==u[d]&&m++;return m}}function ut(e,t,n){return e.length<=t.length?Me(e,t,n,!1):Me(t,e,(i,r)=>n(r,i),!0)}function Me(e,t,n,i){let r=e.length,s=t.length,l=[];for(let m=0;m<=r;m++)l.push(new Float64Array(s+1).fill(1/0));let c=[];for(let m=0;m<=r;m++)c.push(new Uint8Array(s+1));for(let m=0;m<=s;m++)l[r][m]=0;for(let m=r-1;m>=0;m--)for(let d=s-1;d>=0;d--){let w=n(e[m],t[d])+l[m+1][d+1],a=l[m][d+1];w<=a?(l[m][d]=w,c[m][d]=1):l[m][d]=a}let o=[],f=0,u=0;for(;f<r&&u<s;)c[f][u]&&(o.push(i?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return o}function he(e,t,n,i,r,s,l,c={}){let o=e.find(t,n,c);if(r.length===0){o.forEach(T=>e.remove(T)),ae(c,"onRowsApplied",s.path,[]);return}let f=r.length>o.length,u=o[0]||null;if(f&&!u&&(u=pt(e,t,n,c),!u))throw new N(s.path);let m=o.map(T=>dt(e,T,i,c)),d=null;if(f&&u){d=e.clone(u),c.templateAttr&&e.removeAttr(d,c.templateAttr);let T=e.stripIds(d);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let w=Pe(r,m,i,at(e,o,r,s,c)),a=o.length>0?e.parent(o[0]):At(e,t,n,u,s,c),p=o.length>0?De(e,a,o[0]):0,g=Et(e,o),h=new Set,y=[],A=r.map((T,S)=>{let O=w[S];if(O>=0)return h.add(O),y.push(!1),o[O];y.push(!0);let E=e.clone(d);return e.stripIds(E),E});o.forEach((T,S)=>{h.has(S)||e.remove(T)}),g?wt(e,a,p,A,y):Ot(e,A,y,a,p),ht(e,A,i,r,s,l,c),ae(c,"onRowsApplied",s.path,A)}function ae(e,t,n,i){if(typeof e[t]=="function")try{return e[t](n.slice(),i)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function at(e,t,n,i,r){let s=ae(r,"identifyRows",i.path,n);if(!Array.isArray(s))return null;let l=new Array(n.length).fill(-1),c=new Set,o=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!s[f])continue;let u=o.get(e.identity(s[f]));u===void 0||c.has(u)||(l[f]=u,c.add(u))}return l}function ht(e,t,n,i,r,s,l){t.forEach((c,o)=>{if(n===null){let f=i[o],u=f==null?"":String(f);e.text(c)!==u&&e.text(c,u)}else{let f=s(e,c,n,i[o],{depth:r.depth+1,path:[...r.path,o]},l);f&&f!==c&&(t[o]=f)}})}function dt(e,t,n,i){return n===null?e.text(t):C(e,t,n,i.onRowsRead?{...i,onRowsRead:void 0}:i)}function De(e,t,n){let i=e.children(t);for(let r=0;r<i.length;r++)if(e.sameNode(i[r],n))return r;return-1}function pt(e,t,n,i){if(!i.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),s=new RegExp(":not\\(\\["+i.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),l=n.replace(/^\s*:scope\s*>\s*/,"").replace(s,""),c=r?mt(l):0,o=fe(l),f=t;for(;f;){let u=e.find(f,l,{includeRulesTag:!1,templateAttr:null});for(let m of u)if(e.attr(m,i.templateAttr)!=null&&!(r&&!gt(e,t,m,c))&&!(o&&!e.matches(e.parent(m),o)))return m;f=e.parent(f)}return null}function mt(e){let t=0,n=null,i=1;for(let r=0;r<e.length;r++){let s=e[r];if(s==="\\")r++;else if(n)s===n&&(n=null);else if(s==='"'||s==="'")n=s;else if(s==="["||s==="(")t++;else if(s==="]"||s===")")t>0&&t--;else if(t===0&&s===">")i++;else{if(t===0&&(s==="+"||s==="~"))return null;if(t===0&&/\s/.test(s)){if(!yt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return i}function yt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let i=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return ke(i)||ke(r)}function ke(e){return e===">"||e==="+"||e==="~"}function gt(e,t,n,i){if(i===null)return!0;let r=n;for(let o=0;o<i;o++)if(r=e.parent(r),!r)return!1;let s=e.prop(t,"tagName");if(!s)return!0;let l=e.prop(r,"tagName");if(!l||String(l).toLowerCase()!==String(s).toLowerCase())return!1;let c=new Set(Le(e,r));return Le(e,t).every(o=>c.has(o))}function Le(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function At(e,t,n,i,r,s){let l=e.parent(i);if(l&&Tt(e,t,l)&&!_e(e,l,s))return l;let c=fe(n);if(!c)throw new N(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let f=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,s)).filter(u=>!_e(e,u,s));if(f.length===0)throw new N(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(f.length>1)throw new N(r.path,`"${c}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function Tt(e,t,n){let i=n;for(;i;){if(e.sameNode(i,t))return!0;i=e.parent(i)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var je=["no-data","editor-ui"];function _e(e,t,n){let i=t;for(;i;){if(n.templateAttr&&e.attr(i,n.templateAttr)!=null||je.some(s=>e.attr(i,s)!=null))return!0;let r=e.attr(i,"clay");if(r&&r.split(/\s+/).some(s=>je.includes(s)))return!0;i=e.parent(i)}return!1}function wt(e,t,n,i,r){let s=e.children(t),l=s.map(o=>e.identity(o)),c=!1;i.forEach((o,f)=>{let u=e.identity(o),m=n+f;if(l[m]===u)return;if(!r[f]){let w=l.indexOf(u);w!==-1&&(l.splice(w,1),s.splice(w,1))}let d=Math.min(m,s.length);d<s.length?e.insertBefore(s[d],o):s.length?c?e.insertAfter(s[s.length-1],o):(e.insertAt(t,o,m),c=!0):e.insertAt(t,o,0),l.splice(d,0,u),s.splice(d,0,o)})}function Et(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let i=new Map(e.children(n).map((s,l)=>[e.identity(s),l])),r=[];for(let s of t){let l=i.get(e.identity(s));if(l===void 0)return!1;r.push(l)}return r.sort((s,l)=>s-l),r[r.length-1]-r[0]===r.length-1}function Ot(e,t,n,i,r){let s=null,l=r;for(let c=0;c<t.length;c++){if(!n[c]){s=t[c];continue}let o=s?e.parent(s):i;if(!o)continue;let f=s?De(e,o,s)+1:l++;e.insertAt(o,t[c],f),s=t[c]}}function I(e,t,n,i,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let s=[];if(de(n,i,[],s),s.length)throw new v(s);ee(e,t,n,i,{depth:0,path:[]},r)}function ee(e,t,n,i,r,s={}){if(r.depth>L)throw new P(r.path);if(i===void 0)return t;if(typeof n=="string")return xt(e,t,n,i,r,s);if(Array.isArray(n)){let[l,c]=n;return he(e,t,l,c,i,r,ee,s),t}if(typeof n=="object"&&n!==null){for(let[l,c]of Object.entries(n)){let o=ee(e,t,c,i==null?i:i[l],{depth:r.depth+1,path:[...r.path,l]},s);o&&o!==t&&(t=o)}return t}return t}function xt(e,t,n,i,r,s){if(n.endsWith("[]")){let o=n.slice(0,-2);return he(e,t,o,null,i,r,ee,s),t}if(n.startsWith("@"))return We(e,t,n.slice(1),i);let l=b(n);if(l!==-1){let o=n.slice(0,l),f=n.slice(l+1),u=o?e.find(t,o,s):[t];return u.length===0||We(e,u[0],f,i),t}if(n===".")return $e(e,t,i),t;let c=e.find(t,n,s);return c.length===0||$e(e,c[0],i),t}function $e(e,t,n){let i=n==null?"":String(n);e.text(t)!==i&&e.text(t,i)}function We(e,t,n,i){if($.has(n)){let r=e.prop(t,n);if(r===i||r!=null&&i!=null&&String(r)===String(i))return t;throw new B(n)}if(n==="outerHTML"){let r=i==null?"":String(i);return e.replaceWith(t,r)}if(ie.has(n)){let r=oe(n,i);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(i==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(i);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function de(e,t,n,i){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,s)=>{typeof r=="object"&&r!==null&&i.push({path:U([...n,s]),expected:"scalar",got:q(r)})}):i.push({path:U(n),expected:"array",got:q(t)});return}t!==null&&typeof t=="object"&&i.push({path:U(n),expected:"scalar",got:q(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:U(n),expected:"array",got:q(t)});return}let r=e[1];t.forEach((s,l)=>de(r,s,[...n,l],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:U(n),expected:"object",got:q(t)});return}for(let[r,s]of Object.entries(e))de(s,t[r],[...n,r],i)}}}function q(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function U(e){return e.join(".")}function pe(e){try{return JSON.parse(e)}catch(t){throw new k(`Invalid strict JSON: ${t.message}`,t)}}function z(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let s=[],l=0;for(;l<r.length;){let c=r[l];if(/\s/.test(c)){l++;continue}if("{}".includes(c)){s.push({type:c,value:c}),l++;continue}if(c==="["){let m=!1,d=l+1;for(;d<r.length&&/\s/.test(r[d]);)d++;if(d<r.length&&/[a-zA-Z_]/.test(r[d])&&(m=!0),!m){s.push({type:c,value:c}),l++;continue}}if(c==="]"){s.push({type:c,value:c}),l++;continue}if(c===":"){s.push({type:t.COLON,value:c}),l++;continue}if(c===","){s.push({type:t.COMMA,value:c}),l++;continue}if(c==='"'||c==="'"){let m=c,d=l+1;for(;d<r.length&&r[d]!==m;)r[d]==="\\"&&d++,d++;s.push({type:t.STRING,value:r.substring(l+1,d),quoted:!0,sourceQuote:m}),l=d+1;continue}let o=l,f;for(;o<r.length&&!/[{},]/.test(r[o]);)if(r[o]===":"){let m=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let w of m){let a=w.substring(1);if(r.substring(o+1,o+1+a.length)===a){d=!0,o+=a.length;break}}if(!d)break}else if(r[o]==="["){for(o++;o<r.length&&r[o]!=="]";){if(r[o]==='"'||r[o]==="'"){let m=r[o];for(o++;o<r.length&&r[o]!==m;)r[o]==="\\"&&o++,o++}o++}o<r.length&&r[o]==="]"&&o++}else o++;f=r.substring(l,o);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(f)?u=t.NUMBER:f==="true"||f==="false"||f==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(f)&&(u=t.SELECTOR),s.push({type:u,value:f,quoted:!1}),l=o}return s}function i(r){let s="";for(let l=0;l<r.length;l++){let c=r[l];if("{}".includes(c.type)||"[]".includes(c.type)){s+=c.value;continue}if(c.type===t.COLON){s+=c.value;continue}if(c.type===t.COMMA){let o=r[l+1];if(o&&(o.type==="}"||o.type==="]"))continue;s+=c.value;continue}if(c.type===t.STRING&&c.quoted){let o=c.value;c.sourceQuote==="'"&&(o=o.replace(/\\'/g,"'"),o=o.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),s+=`"${o}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){s+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){s+=`"${c.value}"`;continue}s+=`"${c.value}"`}return s}try{let r=n(e),s=i(r);return JSON.parse(s)}catch(r){throw new k("Invalid extraction rules syntax: "+r.message,r)}}var St="1",ve=/^[a-zA-Z0-9_-]+$/;function j(e,t,n){let i;if(n===void 0)i="script[data-rules-name]";else{if(typeof n!="string"||!ve.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${ve})`);i=`script[data-rules-name~="${n}"]`}let r=e.find(t,i,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=r[0],l=e.attr(s,"data-rules-version");if(l!==St)throw new W(l);return{rules:z(e.text(s)),tagNode:s}}var te=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),bt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Be=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function K(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function me(e,t){if(K(e,t))return!0;for(let[n,i]of Object.entries(bt))if(i.includes(t)&&K(e,n))return!0;return!1}function F(e){let t=te[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Rt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=te[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>me(n,r))||i.bundles.some(r=>K(n,r)))return n;n=n.parentElement}return null}function He(e,t){return!!Rt(e,t)}var ye=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Be],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),Nt=new Set(["textContent","innerText"]);function qe(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var Ct=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function Ue(e,t,n=ye){if(!Ct.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let i=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>i.startsWith(r)))return`attribute "${i}" can run script`;if(n.refusedAttributes.includes(i))return`attribute "${i}" is not content`;if(n.urlAttributes.includes(i)&&t!=null){let r=i==="srcset"?String(t).split(",").map(s=>s.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let s of r){let l=qe(s);if(l&&n.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${i}"`}}return null}function ge(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function Mt(e,t){let n=ge(e,t)||"node",i=e.attr(t,"id");return i?`<${n}#${i}>`:`<${n}>`}function Pt(e,t,n){let i=t;for(;i;){let r=ge(e,i);if(r&&n.refusedTargets.includes(r))return r;i=e.parent(i)}return null}function ze(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function It(e,t){return ge(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ze(e,t)}function ne(e,t=ye){let n=[],i=(o,f)=>(n.push({target:Mt(e,o),reason:f}),!1),r=o=>{let f=Pt(e,o,t);return f?i(o,`inside <${f}>, which is not content`):!0},s=o=>r(o)?ze(e,o)?i(o,"a text write here would delete the data rules tag"):!0:!1,l=(o,f,u)=>{if(!r(o))return!1;let m=Ue(f,u,t);return m?i(o,m):!0};return{...e,text(o,f){if(f===void 0)return e.text(o);s(o)&&e.text(o,f)},attr(o,f,u){if(u===void 0)return e.attr(o,f);l(o,f,u)&&e.attr(o,f,u)},removeAttr(o,f){l(o,f,null)&&e.removeAttr(o,f)},prop(o,f,u){if(u===void 0)return e.prop(o,f);if(t.refusedRuleForms.includes(f))return i(o,`"@${f}" writes HTML, only text is allowed`);if(Nt.has(f)){s(o)&&e.prop(o,f,u);return}l(o,f==="className"?"class":f,u)&&e.prop(o,f,u)},remove(o){if(It(e,o)){i(o,"removing this would delete the data rules tag");return}e.remove(o)},replaceWith(o,f){return f===e.prop(o,"outerHTML")||i(o,'"@outerHTML" writes HTML, only text is allowed'),o},refusals:n,assertClean(){if(n.length)throw new H(n.slice())}}}function V(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ke(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function Ae(e,t,n,i,r={}){let s=[],l=[];function c(f,u,m){if(Array.isArray(f)){let[,d]=f;if(!Array.isArray(u)||!V(d))return;u.forEach((w,a)=>c(d,w,[...m,a]));return}if(!(!V(f)||!V(u)))for(let d of Object.keys(u))Object.prototype.hasOwnProperty.call(f,d)?c(f[d],u[d],[...m,d]):s.push(Ke([...m,d]))}function o(f,u,m,d){if(m!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let w=b(u),a=w===-1?u:u.slice(0,w);if(!a)return;e.find(f,a,r).length===0&&l.push({path:Ke(d),selector:a});return}if(!Array.isArray(u)&&V(u)&&V(m))for(let[w,a]of Object.entries(u))o(f,a,m[w],[...d,w])}}return c(n,i,[]),o(t,n,i,[]),{unknownKeys:s,unmatched:l}}function Te(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return j(e,i,n)}return null}var Lt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function jt(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Fe(e,t,n,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Ve(e,t,n,i,r,s){return(s?He(e,t):Fe(e,n,r,!1))||!!(i&&(s&&e!==r?e.matches(i):Fe(e,i,r,s)))}function _t(e,t){let n=te[t];return n.tokens.some(i=>me(e,i))||n.bundles.some(i=>K(e,i))}var Dt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Je(e,t,n,i){if(e.nodeType===1&&i(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,s=t;if(e.nodeType===1){if(Dt.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,s=t.content,n.cloneToLive.set(s,r),n.liveToClone.set(r,s)}}else if(e.nodeType!==11)return;let l=s.firstChild;for(let c=r.firstChild;c&&l;c=c.nextSibling)Je(c,l,n,i),l=l.nextSibling}function J(e,{capability:t="data",exclude:n=null,inherit:i=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let l=s.implementation.createHTMLDocument(""),c=r||new WeakMap,o=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&l.documentElement.matches(n);let u=F(t),m=i?a=>_t(a,t)||!!(n&&a.matches(n)):a=>Ve(a,t,u,n,f,!1),d=null;if(f.nodeType!==1||!Ve(f,t,u,n,f,i)){d=l.importNode(f,!0);let a={cloneToLive:c,liveToClone:o,dropped:[],controls:[]};Je(f,d,a,m);for(let p of a.dropped)p.remove();for(let p=0;p<a.controls.length;p+=2)jt(a.controls[p],a.controls[p+1])}e.nodeType===9&&d&&(l.replaceChild(d,l.documentElement),o.set(e,l),c.set(l,e));let w=a=>{if(Lt.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:d,document:l,capability:t,selector:F(t),cloneToLive:c,liveToClone:o,original(a){return c.get(a)||null},cloneOf(a){return o.get(a)||null},query(a,p=d){return w(a),Array.from(p.querySelectorAll(a),g=>c.get(g)||g)},text(a=d){return(a===d?d:o.get(a))?.textContent||""},html(a=d){return(a===d?d:o.get(a))?.innerHTML??""},clone(a=d){let p=a===d?d:o.get(a);return p?l.importNode(p,!0):null}}}function Ge(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function $t(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Xe(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function Ye(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Ze(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let i=n.type;i!=="file"&&i!=="checkbox"&&i!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var x={semanticExclude:!0,find(e,t,n={}){let i=$t(e);if(!i||!i.querySelectorAll)return[];let r=Array.from(i.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!Ge(c)));let s=[];n.skip&&s.push(n.skip);let l=n.templateAttr===null?null:n.templateAttr||"cms-template";if(l&&s.push("["+l+"]"),s.length){let c=s.join(", ");r=r.filter(o=>!o.closest||!o.closest(c))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Ye(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Xe(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Xe(e,t,null)},prop(e,t,n){if(n===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return Ze(t),t},insertAt(e,t,n){let i=e.children[n]||null;e.insertBefore(t,i)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let i=e.ownerDocument.createElement("template");i.innerHTML=t;let r=i.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function M(e,t={}){if(t.exclude===null)return x;let n=[F("data"),t.exclude].filter(Boolean).join(", "),i=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!i?.querySelector?.(n))return x;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,c=null,o=()=>c||(c=J(s,{capability:"data",exclude:t.exclude||null})),f=a=>{let p=o();return a===e?p.cloneOf(e):p.cloneOf(a)||a},u=a=>c?.original(a)||a,m=(a,p)=>{o().liveToClone.set(a,p),o().cloneToLive.set(p,a);let g=a.childNodes||[],h=p.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)m(g[y],h[y])},d=(a,p,g,h)=>{let y=Array.from(a.childNodes).filter(E=>c.cloneOf(E)),T=y[0];for(;T&&y.includes(T);)T=T.nextSibling;for(let E of y)E.remove();if(g==="innerHTML"){let E=l.createElement("template");E.innerHTML=h;for(let D of Array.from(E.content.childNodes))a.insertBefore(D,T||null)}else a.insertBefore(l.createTextNode(h),T||null),Ye(a,h);let S=J(a,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(S.root?.childNodes||[]));let O=E=>{let D=S.original(E);D&&(c.liveToClone.set(D,E),c.cloneToLive.set(E,D));for(let et of Array.from(E.childNodes||[]))O(et)};for(let E of Array.from(p.childNodes))O(E)},w={...x,find(a,p,g={}){let h=f(a);if(!h?.querySelectorAll)return[];let y=o().query(p,h);g.includeRulesTag||(y=y.filter(S=>!Ge(S)));let A=[];g.skip&&A.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&A.push(`[${T}]`),A.length){let S=A.join(", ");y=y.filter(O=>!O.closest?.(S))}return y},parent(a){let p=f(a)?.parentElement;return p?u(p):null},children(a){return Array.from(f(a)?.children||[],u)},text(a,p){if(p===void 0){let y=u(a);return!y?.matches?.(n)&&!y?.querySelector?.(n)?x.text(y):(f(a)?.textContent||"").trim()}let g=u(a);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){x.text(g,p);return}let h=o().cloneOf(g);h?d(g,h,"textContent",p):x.text(g,p)},attr(a,p,g){let h=u(a);if(g===void 0)return x.attr(h,p);x.attr(h,p,g);let y=c?.cloneOf(h);y&&(x.attr(y,p,g),J(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(h),c.cloneToLive.delete(y)))},removeAttr(a,p){let g=u(a);x.removeAttr(g,p);let h=c?.cloneOf(g);h&&x.removeAttr(h,p)},prop(a,p,g){let h=u(a);if(g===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?x.prop(f(h),p):x.prop(h,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",A=y?o().cloneOf(h):c?.cloneOf(h);A&&y?d(h,A,p,g):(x.prop(h,p,g),A&&x.prop(A,p,g))},clone(a){let p=f(a);if(p===a)return x.clone(a);let g=l.importNode(p,!0);return Ze(g),g},insertAt(a,p,g){let h=u(a),A=w.children(h)[g]||(()=>{for(let O=h.children.length-1;O>=0;O--){let E=h.children[O];if(o().cloneOf(E))return E.nextElementSibling}return h.firstElementChild})(),T=u(p);h.insertBefore(T,A||null);let S=o().cloneOf(h);if(S){let O=o().cloneOf(T);O||(O=l.importNode(T,!0),m(T,O));let E=Array.from(S.children);S.insertBefore(O,E[g]||null)}},insertBefore(a,p){let g=u(a),h=u(p);g.parentNode.insertBefore(h,g);let y=o().cloneOf(g.parentNode);if(y){let A=o().cloneOf(h);A||(A=l.importNode(h,!0),m(h,A));let T=o().cloneOf(g);T?T.before(A):y.appendChild(A)}},insertAfter(a,p){let g=u(a),h=u(p);g.parentNode.insertBefore(h,g.nextSibling);let y=o().cloneOf(g.parentNode);if(y){let A=o().cloneOf(h);A||(A=l.importNode(h,!0),m(h,A));let T=o().cloneOf(g);T?T.after(A):y.appendChild(A)}},identity(a){return u(a)||null},remove(a){let p=u(a),g=o().cloneOf(p);x.remove(p),g&&x.remove(g)},replaceWith(a,p){let g=u(a),h=o().cloneOf(g),y=x.replaceWith(g,p);if(h){let A=J(y,{capability:"data",exclude:t.exclude||null});if(!A.root)h.remove();else{h.replaceWith(A.root);let T=S=>{let O=A.original(S);O&&(c.liveToClone.set(O,S),c.cloneToLive.set(S,O));for(let E of Array.from(S.childNodes||[]))T(E)};T(A.root)}}return y}};return w}var X=x;var G={extract:(e,t,n={})=>C(M(e,n),e,t,n),apply:(e,t,n,i={})=>I(M(e,{...i,_write:!0}),e,t,n,i),findRulesIn:(e,t)=>j(X,e,t),findRules:(e,t)=>Te(X,e,t),bind:(e,t,n={})=>{let i=Te(X,e,t);if(!i){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...i,get:()=>C(M(e,n),e,i.rules,n),set:r=>I(M(e,{...n,_write:!0}),e,i.rules,r,n)}},parseStrict:pe,parseRelaxed:z,ruleAttrIndex:b,splitRule:ce,errors:R,DOM_PROPERTIES:Y},we=e=>!!e&&typeof e.nodeType=="number";function Qe(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=j(X,t,"api");if(!n)throw new R.NoRulesTag("api");return n.rules}function Wt(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function vt(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function Bt(e,t){let n=[];for(;t!==e;){let i=t.parentNode;n.push(Array.prototype.indexOf.call(i.childNodes,t)),t=i}return n.reverse()}function Ht(e,t){return t.reduce((n,i)=>n.childNodes[i],e)}function _(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function qt(e,t){let n=_(e,"option"),i=_(t,"option");n.forEach((o,f)=>i[f].selected=o.selected);let r=_(e,"input"),s=_(t,"input");r.forEach((o,f)=>{let u=o.type.toLowerCase();u!=="file"&&(s[f].value=o.value),(u==="checkbox"||u==="radio")&&(s[f].checked=o.checked)});let l=_(e,"textarea"),c=_(t,"textarea");l.forEach((o,f)=>c[f].value=o.value)}function Ee(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:b(e);if(n===-1)return;let i=e.slice(n+1);if($.has(i))throw new R.RuleTargetReadOnly(i);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>Ee(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,i]of Object.entries(e))Ee(i,t[n])}}function Ut(e,t,n){let i={templateAttr:"cms-template"},r=Wt(e),s=Bt(r,e),l=vt(r);qt(r,l);let c=Ht(l,s),o=M(l,{...i,_write:!0}),f=Ae(o,c,t,n,i);if(f.unknownKeys.length||f.unmatched.length)throw new R.WriteRejected(f.unknownKeys,f.unmatched);let u=ne(o);I(u,c,t,n,i),u.assertClean(),Ee(t,n);let m=ne(M(r,{...i,_write:!0}));I(m,e,t,n,i),m.assertClean()}function zt(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof R.WriteRefused?e.details=e.refusals:e instanceof R.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof R.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function Oe(e,t){let n=we(e)?e:document,i=we(e)?t:e;return i===void 0?C(M(n),n,Qe(n)):G.bind(n,i).get()}function xe(e,t,n){try{if(!we(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let i=n===void 0?Qe(e):G.bind(e,n).rules;Ut(e,i,t)}catch(i){throw zt(i)}return e}var Kt={engine:G,extractData:Oe,applyData:xe},Ft=Kt;return ot(Vt);})();
|
|
6
6
|
window.clay = window.clay || {};
|
|
7
7
|
window.clay.extractData = hyperHtmlApiData.extractData;
|
|
8
8
|
window.clay.applyData = function (values, optionsOrSource, source) {
|
package/entries/sap.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// GENERATED — do not edit. Vendored from sapjs/dist/sap.min.js via sapjs
|
|
2
2
|
// `npm run copy-to-clayjs`. Edit the sapjs source and re-run.
|
|
3
3
|
(function () {
|
|
4
|
-
var Sap=(()=>{var ne=Object.defineProperty;var
|
|
5
|
-
`+(e[0]==="W"?"sap \u26A0 ":"sap \u2717 ")+e+" "+o];return a.push(` at ${s.el}${s.attr?` \u2014 ${s.attr}="${s.expr??""}"`:""}`),s.problem&&a.push(` problem: ${s.problem}`),s.didYouMean&&a.push(` did you mean: ${s.didYouMean}`),s.fix&&a.push(` fix: ${s.fix}`),console.error(a.join(`
|
|
6
|
-
`)),s}error(e,r,n={}){let o=this.block(e,r,n);return this.errors.push(o),o}warn(e,r,n={}){let o=this.block(e,r,n);return this.warnings.push(o),o}report(){return{ok:this.errors.length===0&&!this.halted,app:this.appName,halted:this.halted,haltReason:this.haltReason,errors:this.errors.slice(),warnings:this.warnings.slice()}}};function ut(t,e){t&&t.getAttribute("sap-error")!==e&&t.setAttribute("sap-error",e)}function Ft(t){t&&t.hasAttribute("sap-error")&&t.removeAttribute("sap-error")}function Nt(t,e){let r=null,n=3;for(let o of e){let s=
|
|
7
|
-
${t}`:`"use strict"; return (${t});`;n={fn:new Function(...
|
|
4
|
+
var Sap=(()=>{var ne=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var kn=Object.prototype.hasOwnProperty;var $n=(t,e)=>{for(var r in e)ne(t,r,{get:e[r],enumerable:!0})},_n=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Sn(e))!kn.call(t,o)&&o!==r&&ne(t,o,{get:()=>e[o],enumerable:!(n=xn(e,o))||n.enumerable});return t};var Tn=t=>_n(ne({},"__esModule",{value:!0}),t);var Sr={};$n(Sr,{Sap:()=>O,default:()=>xr,mount:()=>vn,mountAll:()=>te,runtime:()=>mt});function Ee(t){let e=!1,r=new Set,n=[];function o(l){l&&(n.push(l),n.length>8&&n.shift())}function s(l,w){o(w),!l._broken&&(r.add(l),!e&&(e=!0,queueMicrotask(a)))}function a(){e=!1;let l=[...r];r.clear();for(let w of l)k(w)}function k(l,w=!1){if(!l._broken){if(l._passes=(l._passes||0)+1,l._passes>50){l._broken=!0,l._breakerRing=n.slice(),t(l,{breaker:!0});return}l._resetArmed||(l._resetArmed=!0,setTimeout(()=>{l._passes=0,l._resetArmed=!1},0)),t(l,w?{full:!0}:{})}}function $(l,w){o(w),k(l,!0)}function A(l){l._broken=!1,l._passes=0}return{schedule:s,runNow:$,rearm:A,ring:n}}var re={E01:{slug:"foreign-dialect",behavior:"HALT"},E02:{slug:"moustaches-in-text",behavior:"HALT"},E04:{slug:"duplicate-declaration",behavior:"HALT"},E05:{slug:"reserved-name",behavior:"HALT"},E06:{slug:"global-html-name",behavior:"HALT"},E07:{slug:"calc-cycle",behavior:"ERR"},E08:{slug:"expression-syntax",behavior:"HALT"},E10:{slug:"orphan-item",behavior:"HALT"},E12:{slug:"unknown-state-key",behavior:"ERR"},E15:{slug:"write-to-undeclared-key",behavior:"ERR"},E16:{slug:"write-to-computed-field",behavior:"ERR"},E17:{slug:"unresolvable-action-target",behavior:"HALT"},E18:{slug:"paint-on-form-control",behavior:"HALT"},E20:{slug:"bind-on-non-control",behavior:"HALT"},E22:{slug:"format-type",behavior:"ERR"},E24:{slug:"runtime-expression-throw",behavior:"ERR"},E26:{slug:"circuit-breaker",behavior:"HALT"},E30:{slug:"attr-on-bound-control",behavior:"HALT"},E31:{slug:"password-without-transient",behavior:"HALT"},E32:{slug:"file-bind",behavior:"HALT"},E33:{slug:"dialog-state-open",behavior:"HALT"},E34:{slug:"transient-persist-collision",behavior:"HALT"},E35:{slug:"presence-state-misuse",behavior:"HALT"},E40:{slug:"each-not-array",behavior:"ERR"},E41:{slug:"each-bad-key",behavior:"ERR"},E42:{slug:"each-template",behavior:"ERR"},E43:{slug:"bind-in-each-row",behavior:"ERR"},W03:{slug:"unknown-colon-attribute",behavior:"WARN"},W04:{slug:"expression-in-when",behavior:"WARN"},W30:{slug:"nonzero-mount-writes",behavior:"WARN"},W31:{slug:"detail-dialog-saved-open",behavior:"WARN"}},bt=["disabled","readonly","required","checked","selected","multiple","open","inert","autofocus","novalidate","hidden"],Tt=new Set(["title","style","hidden","lang","dir","translate","class","id","nonce","autofocus","tabindex","contenteditable","spellcheck","draggable","role","slot","part","name","value","type","itemscope","itemtype","itemid","itemprop","itemref"]),It=new Set(["sap","scope","items","item","template","bind","calc","text","show","attr","set","trigger","move","sort","detail","each","effect","invalid","confirm","transient","default","persist","sortable","editmode"]);function Ot(t){if(!t||t.nodeType!==1)return"?";if(t.id)return`${t.tagName.toLowerCase()}#${t.id}`;let e=[],r=t,n=0;for(;r&&r.nodeType===1&&n<4;){let o=r.tagName.toLowerCase();if(r.hasAttribute("sap"))o+="[sap]";else if(r.parentElement){let s=0,a=0;for(let k=r.parentElement.firstElementChild;k;k=k.nextElementSibling)k.tagName===r.tagName&&(s++,k===r&&(a=s));s>1&&(o+=`:nth-of-type(${a})`)}if(e.unshift(o),r.hasAttribute("sap"))break;r=r.parentElement,n++}return e.join(" > ")}function ve(t){let e=t.toLowerCase();return/^x-text$|^x-html$/.test(e)?'use text="state.x" (Sap paints text only)':/^x-show$|^v-show$|^v-if$/.test(e)?'use show="expr" (toggles native hidden)':/^x-model$|^v-model$/.test(e)?'use bind="field"':/^@|^x-on:|^v-on:|^on:/.test(e)?"use native onclick + Sap(this) (no event directive)":/^:|^x-bind:class$|^v-bind:class$/.test(e)?'use class:NAME="expr" or attr:NAME="expr"':/^x-for$|^v-for$/.test(e)?'use items="name" on the container and item template on the row':/^x-data$/.test(e)?"declare state with state= / bind / items (no JS state object)":/^x-init$/.test(e)?"use a <script> or onclick + Sap(this)":/^bind:/.test(e)?'use bind="field"; one-way paint is attr:NAME="expr"':/^x-/.test(e)||/^v-/.test(e)?"this is a foreign-dialect attribute; Sap has no x-/v- attributes":null}var ht=class{constructor(e){this.appName=e,this.errors=[],this.warnings=[],this.halted=!1,this.haltReason=null}block(e,r,n={}){let o=(re[e]||{}).slug||"error",s={code:e,slug:o,el:Ot(r),attr:n.attr||null,expr:n.expr||null,key:n.key||null,problem:n.problem||"",didYouMean:n.didYouMean||null,fix:n.fix||null,phase:n.phase||"runtime"},a=[`
|
|
5
|
+
`+(e[0]==="W"?"sap \u26A0 ":"sap \u2717 ")+e+" "+o];return a.push(` at ${s.el}${s.attr?` \u2014 ${s.attr}="${s.expr??""}"`:""}`),s.problem&&a.push(` problem: ${s.problem}`),s.didYouMean&&a.push(` did you mean: ${s.didYouMean}`),s.fix&&a.push(` fix: ${s.fix}`),(e[0]==="W"?console.warn:console.error)(a.join(`
|
|
6
|
+
`)),s}error(e,r,n={}){let o=this.block(e,r,n);return this.errors.push(o),o}warn(e,r,n={}){let o=this.block(e,r,n);return this.warnings.push(o),o}report(){return{ok:this.errors.length===0&&!this.halted,app:this.appName,halted:this.halted,haltReason:this.haltReason,errors:this.errors.slice(),warnings:this.warnings.slice()}}};function ut(t,e){t&&t.getAttribute("sap-error")!==e&&t.setAttribute("sap-error",e)}function Ft(t){t&&t.hasAttribute("sap-error")&&t.removeAttribute("sap-error")}function Nt(t,e){let r=null,n=3;for(let o of e){let s=Nn(t,o);s<n&&(n=s,r=o)}return r}function Nn(t,e){let r=t.length,n=e.length,o=Array.from({length:r+1},(s,a)=>[a,...new Array(n).fill(0)]);for(let s=0;s<=n;s++)o[0][s]=s;for(let s=1;s<=r;s++)for(let a=1;a<=n;a++)o[s][a]=Math.min(o[s-1][a]+1,o[s][a-1]+1,o[s-1][a-1]+(t[s-1]===e[a-1]?0:1));return o[r][n]}var Ln=new Set(bt),Cn={readonly:"readOnly",novalidate:"noValidate"},Rn=0,xe=new WeakMap;function Bt(t,e="sap"){let r=t.getAttribute("data-id");if(r)return r;if(t.id)return t.id;let n=xe.get(t);return n||(n=`${e}-${(Rn++).toString(36)}`,xe.set(t,n)),n}function Se(t,e="row"){for(;;){let r=`${e}-${Math.random().toString(36).slice(2,8)}`;if(!t.getElementById(r)&&!t.querySelector(`[data-id="${r}"]`))return r}}function Dn(t){return t.hasAttribute("scope")||t.hasAttribute("items")||t.hasAttribute("detail")||t.hasAttribute("each")}function Mn(t){return t.tagName==="TEMPLATE"||t.hasAttribute("sap-ignore")||t.hasAttribute("template")||t.hasAttribute("cms-template")}function et(t,e){for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(Mn(n))return;let o=Dn(n);if(e(n,o),!o)for(let s=n.firstElementChild;s;s=s.nextElementSibling)r(s)}}function Q(t){let e=t;for(;e;){if(e.hasAttribute("sap")||e.hasAttribute("scope")||e.hasAttribute("item")||e.hasAttribute("detail"))return e;e=e.parentElement}return null}function lt(t){for(let e=t;e&&e.nodeType===1;e=e.parentElement){if(e._sapEachRow)return e;if(e.hasAttribute("item")||e.hasAttribute("sap"))return null}return null}function Wt(t){let e=t;for(;e;){if(e.hasAttribute("detail")||e.hasAttribute("item"))return e;e=e.parentElement}return null}function Lt(t){let e=t;for(;e;){if(e.hasAttribute("detail"))return e;e=e.parentElement}return null}function ft(t,e){if(t.hasAttribute("item")&&t.getAttribute("bind")===e)return t;let r=null;return et(t,n=>{!r&&n.getAttribute("bind")===e&&(r=n)}),r}function gt(t,e){let r=null;return et(t,n=>{!r&&n.getAttribute("items")===e&&(r=n)}),r}function wt(t,e){return!t||t.nodeType!==1||!t.hasAttribute("item")?!1:ft(t,e)||gt(t,e)?!0:V(t.getAttribute("state")||"").some(r=>r.name===e)}function ke(t){let e=t&&t.$el;return e&&e.nodeType===1&&e.isConnected&&e.hasAttribute("item")?e:null}function qt(t){return!!t.closest("form[trigger-add]")}function rt(t){let e=[];for(let r=t.firstElementChild;r;r=r.nextElementSibling)r.hasAttribute("item")&&!r.hasAttribute("template")&&!r.hasAttribute("cms-template")&&e.push(r);return e}function oe(t,e){if(!t||!e)return null;let r=[...t.querySelectorAll(`template[items="${e}"]`)].find(o=>o.closest("[sap]")===t),n=r&&r.content.firstElementChild;return n&&n.hasAttribute("item")?n:null}function Vt(t){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(e.hasAttribute("item")&&e.hasAttribute("template"))return e;return oe(t.closest("[sap]"),t.getAttribute("items"))}function V(t){let e=[];if(!t)return e;for(let r of t.trim().split(/\s+/)){if(!r)continue;let n=r,o,s=n.indexOf("=");s>=0&&(o=n.slice(s+1),n=n.slice(0,s));let a=n.split(":"),k=a[0],$="string",A=!1;for(let N of a.slice(1))N==="num"?$="num":N==="bool"?$="bool":N==="presence"?$="presence":N==="transient"&&(A=!0);let l=k,w=l.startsWith("data-")&&l.length>5?l.slice(5).replace(/-([a-z])/g,(N,P)=>P.toUpperCase()):l;e.push({name:w,attr:l,type:$,default:o,transient:A})}return e}function ct(t,e){if(e==="num"){if(t==null||t==="")return 0;let r=Number(t);return Number.isNaN(r)?0:r}return e==="bool"?t==="true"||t===""||t==="1":t??""}function ie(t,e){return e==="bool"?t?"true":"false":t==null?"":String(t)}function se(t,e){return Ln.has(e)&&typeof t[Cn[e]||e]=="boolean"}function yt(t,e){return e.type==="presence"||e.type!=="num"&&se(t,e.attr||e.name)}function Ct(t){return t.default!=null?t.default:t.type==="num"?"0":t.type==="bool"?"false":""}function $e(t,e){let r=e.attr||e.name;if(yt(t,e))return t.hasAttribute(r);let n=t.getAttribute(r);return ct(n??Ct(e),e.type)}function _e(t,e){return yt(t,e)?e.default!=null?ct(e.default,"bool"):!1:ct(Ct(e),e.type)}function Rt(t,e,r){let n=e.attr||e.name;if(yt(t,e)){r?t.hasAttribute(n)||t.setAttribute(n,""):t.hasAttribute(n)&&t.removeAttribute(n);return}t.setAttribute(n,ie(r,e.type))}function zt(t,e){let r=e.attr||e.name,n=t._sapTransient||(t._sapTransient={});if(!(e.name in n)){let o=t.getAttribute(r);o==null&&(o=Ct(e)),n[e.name]=ct(o,e.type)}return t.hasAttribute(r)&&t.removeAttribute(r),n[e.name]}function Dt(t,e,r){let n=e.attr||e.name;(t._sapTransient||(t._sapTransient={}))[e.name]=r,t.hasAttribute(n)&&t.removeAttribute(n)}function Mt(t,e,r){let n=String(r).split("."),o=n[n.length-1];if(n.length===1){let k=Pn(e,o);return k||(t.getAttribute("items")===o?t:t.querySelector(`[items="${o}"]:not(template)`))}let s=n[n.length-2],a=[...t.querySelectorAll(`[scope="${s}"]`)].find(k=>gt(k,o));return a?gt(a,o):null}function Pn(t,e){let r=Q(t);for(;r;){if(r.getAttribute("items")===e)return r;let n=gt(r,e);if(n)return n;r=Q(r.parentElement)}return null}function Z(t){if(typeof t=="number")return t;if(t==null||t==="")return 0;let e=Number(typeof t=="string"?t.replace(/[$,%\s]/g,""):t);return Number.isNaN(e)?0:e}function Ht(t,e){return Array.isArray(t)?e==null?t:t.map(r=>typeof e=="function"?e(r):r?.[e]):[]}function ae(t,e){return Ht(t,e).reduce((r,n)=>r+Z(n),0)}function Te(t,e){return Array.isArray(t)?e==null?t.length:t.reduce((r,n)=>r+(e(n)?1:0),0):0}function Ne(t,e){let r=Ht(t,e);return r.length?ae(t,e)/r.length:0}function Le(t,e){let r=Ht(t,e).filter(n=>n!=null&&n!=="");return r.length?r.every(n=>typeof n=="number"||!Number.isNaN(Number(n)))?Math.min(...r.map(Number)):r.reduce((n,o)=>String(n)<=String(o)?n:o):0}function Ce(t,e){let r=Ht(t,e).filter(n=>n!=null&&n!=="");return r.length?r.every(n=>typeof n=="number"||!Number.isNaN(Number(n)))?Math.max(...r.map(Number)):r.reduce((n,o)=>String(n)>=String(o)?n:o):0}function Re(t,e,r){let n=Z(t)===1?e:r??e+"s";return`${t} ${n}`}function De(t,e){let r=new Date(t),n=new Date(e);return Number.isNaN(+r)||Number.isNaN(+n)?0:Math.round((n-r)/864e5)}function nt(t){return typeof t=="number"?t:Number(t)}var At={usd:t=>"$"+nt(t).toLocaleString("en-US",{maximumFractionDigits:0}),usd2:t=>"$"+nt(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),pct:t=>Math.round(nt(t))+"%",pct1:t=>nt(t).toFixed(1)+"%",int:t=>Math.round(nt(t)).toLocaleString("en-US"),num:t=>nt(t).toLocaleString("en-US"),num2:t=>nt(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),compact:t=>nt(t).toLocaleString("en-US",{notation:"compact"}),date:t=>{let e=new Date(t);return Number.isNaN(+e)?String(t):e.toLocaleDateString("en-US")},clock:t=>{let e=nt(t),r=Math.floor(e/100),n=r%10,o=Math.floor(r/10)%60;return`${Math.floor(r/600)}:${String(o).padStart(2,"0")}.${n}`}},In=new Set(["usd","usd2","pct","pct1","int","num","num2","compact","clock"]);function Me(t,e){if(!t)return e==null?"":String(e);let r=At[t];if(typeof r!="function"){let n=new Error(`unknown format "${t}"`);throw n.sapCode="E22",n}if(In.has(t)){let n=typeof e=="number"?e:Number(e);if(!Number.isFinite(n)){let o=new Error(`format "${t}" received ${typeof e=="string"?`"${e}"`:e}`);throw o.sapCode="E22",o}}return r(e)}var On=["state","item","el","root","fmt","num","sum","count","avg","min","max","plural","days"],jt=new Map,Pe=/\bstate\.([a-z][a-z0-9_]*)/g,Ie=/\bitem\.([a-z][a-z0-9_]*)/g;function Fn(t){let e=new Set,r=new Set,n;for(Pe.lastIndex=0;n=Pe.exec(t);)e.add(n[1]);for(Ie.lastIndex=0;n=Ie.exec(t);)r.add(n[1]);return{state:e,item:r}}function q(t,e=!1){let r=(e?"!":"")+t,n=jt.get(r);if(n)return n;jt.size>512&&jt.clear();try{let o=e?`"use strict";
|
|
7
|
+
${t}`:`"use strict"; return (${t});`;n={fn:new Function(...On,o),src:t,statement:e,deps:Fn(t),error:null}}catch(o){n={fn:null,src:t,statement:e,deps:{state:new Set,item:new Set},error:o}}return jt.set(r,n),n}function Et(t,e){return dt(t,e.state,e.item,e.el??null,e.root)}function dt(t,e,r,n,o){if(t.error)throw t.error;return t.fn(e,r,n,o,At,Z,ae,Te,Ne,Le,Ce,Re,De)}function Oe(t){let e=new Map;for(let a of t)e.set(a.name,a);let r=[],n=new Map,o=[];function s(a){let k=n.get(a.name);if(k!==1){if(k===0){let $=[...o.slice(o.indexOf(a.name)),a.name].join(" -> "),A=new Error(`calc: cycle: ${$}`);throw A.sapCode="E07",A.cycle=$,A}n.set(a.name,0),o.push(a.name);for(let $ of a.entry.deps.state){let A=e.get($);A&&A!==a&&s(A)}for(let $ of a.entry.deps.item){let A=e.get($);A&&A!==a&&s(A)}o.pop(),n.set(a.name,1),r.push(a)}}for(let a of t)s(a);return r}var Pt=0,pt=null,Be=!0,Gt=!1;function We(){Pt++}function qe(t){let e=Gt;return pt?ce(pt.takeRecords()):Be&&Bn(),Gt=!!pt&&t.getRootNode()===document,e}function Ve(t){Gt=t}function ue(){pt&&ce(pt.takeRecords())}function Bn(){if(typeof document>"u"||typeof MutationObserver!="function"){Be=!1;return}pt=new MutationObserver(ce),pt.observe(document,{attributes:!0,childList:!0,subtree:!0})}function ce(t){for(let e of t)if(e.type==="attributes")e.target._sapPlan&&(e.target._sapPlan=null);else for(let r of e.addedNodes)r.nodeType===1&&ze(r)}function ze(t){t._sapPlan&&(t._sapPlan=null);for(let e=t.firstElementChild;e;e=e.nextElementSibling)ze(e)}function vt(t){if(!Gt)return Fe(t);let e=t._sapPlan;return e&&e.gen===Pt?e:t._sapPlan=Fe(t)}function Fe(t){let e={gen:Pt,inert:t.tagName==="TEMPLATE",template:!1,item:!1,scope:!1,items:!1,detail:!1,each:!1,boundary:null,bind:null,transient:!1,decls:null,calcs:null,paints:null,effects:null,invalids:null};for(let r of t.attributes){let n=r.name,o=r.value,s=n.indexOf(":");if(s<0){switch(n){case"sap-ignore":e.inert=!0;break;case"cms-template":e.inert=!0;break;case"template":e.inert=!0,e.template=!0;break;case"item":e.item=!0;break;case"scope":e.scope=!0;break;case"items":e.items=!0;break;case"detail":e.detail=!0;break;case"each":e.each=!0;break;case"bind":e.bind=o;break;case"transient":e.transient=!0;break;case"state":e.decls=V(o);break;case"text":(e.paints||(e.paints=[])).push({kind:"text",fmt:null,entry:q(o)});break;case"show":(e.paints||(e.paints=[])).push({kind:"show",entry:q(o)});break;case"effect":(e.effects||(e.effects=[])).push({entry:q(o,!0)});break;case"invalid":(e.invalids||(e.invalids=[])).push({entry:q(o)});break}continue}let a=n.slice(0,s),k=n.slice(s+1);switch(a){case"calc":(e.calcs||(e.calcs=[])).push({name:k,entry:q(o)});break;case"text":(e.paints||(e.paints=[])).push({kind:"text",fmt:k,entry:q(o)});break;case"attr":(e.paints||(e.paints=[])).push({kind:"attr",arg:k,entry:q(o)});break;case"class":(e.paints||(e.paints=[])).push({kind:"class",arg:k,entry:q(o)});break;case"css":(e.paints||(e.paints=[])).push({kind:"css",arg:k,entry:q(o)});break;case"show-when":case"option":(e.paints||(e.paints=[])).push({kind:"when",match:"show",field:k,values:o.split("|")});break;case"hide-when":(e.paints||(e.paints=[])).push({kind:"when",match:"hide",field:k,values:o.split("|")});break;case"option-not":(e.paints||(e.paints=[])).push({kind:"when",match:"show-not",field:k,values:o.split("|")});break}}return e.boundary=e.scope?"scope":e.items?"items":e.detail?"detail":e.each?"each":null,qn(e)?Wn():e}var Ut=null;function Wn(){return(!Ut||Ut.gen!==Pt)&&(Ut=Object.freeze({gen:Pt,inert:!1,template:!1,item:!1,scope:!1,items:!1,detail:!1,each:!1,boundary:null,bind:null,transient:!1,decls:null,calcs:null,paints:null,effects:null,invalids:null})),Ut}function qn(t){return!t.inert&&!t.item&&t.boundary===null&&t.bind===null&&!t.transient&&!t.decls&&!t.calcs&&!t.paints&&!t.effects&&!t.invalids}function He(t){return(t.getAttribute("type")||"text").toLowerCase()}function xt(t){let e=t.tagName;if(e==="INPUT"){let r=He(t);r==="checkbox"||r==="radio"?t.checked?t.setAttribute("checked",""):t.removeAttribute("checked"):t.setAttribute("value",t.value);return}if(e==="TEXTAREA"){t.setAttribute("data-value",t.value);return}if(e==="SELECT"){let r=t.options;for(let n=0;n<r.length;n++)r[n].selected?r[n].setAttribute("selected",""):r[n].removeAttribute("selected")}}function je(t,e=t){let r=t.tagName;if(r==="INPUT"){let n=He(t);n==="checkbox"||n==="radio"?e.checked?t.hasAttribute("checked")||t.setAttribute("checked",""):t.removeAttribute("checked"):e.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",e.value);return}if(r==="TEXTAREA"){let n=e.value.startsWith(`
|
|
8
8
|
`)?`
|
|
9
|
-
`+e.value:e.value;t.textContent!==n&&(t.textContent=n),t.removeAttribute("data-value");return}if(r==="SELECT"){let n=t.options,o=e.options;for(let s=0;s<n.length;s++)o[s]&&o[s].selected?n[s].hasAttribute("selected")||n[s].setAttribute("selected",""):n[s].removeAttribute("selected")}}function Yt(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function Q(t){if(typeof window>"u")return null;let e=window.clay,r=window.hyperclay;return t==="consent"?e?.confirm||r?.consent||null:e?.[t]||r?.[t]||null}var le=["clay:mutation-ready","hyperclay:mutation-ready"],qn=["clay:sync-applied","hyperclay:livesync-applied"],Vn=["clay:ready","hyperclay:ready"],zn=["clay:route"];function St(t,e,r){let n=null,o=s=>{n!==null&&n!==s.type||(n=s.type,queueMicrotask(()=>{n=null}),r(s))};for(let s of e)t.addEventListener(s,o);return()=>{for(let s of e)t.removeEventListener(s,o)}}function Ue(t){let e=typeof window<"u"&&window.clay&&window.clay.ready;e&&typeof e.then=="function"?e.then(()=>t(),()=>t()):t()}function Xt(t){let e=Q("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function Ge(){let t=Q("consent");return typeof t=="function"?t:null}function Ye(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let r=Q("undo");r&&r.flush&&r.flush();let n=e();if(n&&typeof n.then=="function")throw new Error("Sap.batch fn must be synchronous (it returned a promise)");return r&&r.commitCaptured&&r.commitCaptured(t),n}function Xe(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let s=!1;for(let a of t.apps())a.root.isConnected?t.runNow(a,"platform"):s=!0;s&&(t.pruneDisconnected(),t.remountIfPresent())};St(document,qn,e),St(document,zn,e);let r=!1,n=()=>{},o=()=>{if(r)return!0;let s=Q("undo");if(!s||typeof s.on!="function")return!1;let a=s.on("undo",e);return typeof a!="function"?!1:typeof s.on("redo",e)!="function"?(a(),!1):(r=!0,n(),!0)};if(!o()){let s=St(document,le,o),a=St(document,Vn,o);n=()=>{s(),a()};let k=Q("ready");k&&typeof k.then=="function"&&k.then(o,()=>{})}}function Kt(t){let e=t.tagName;if(e==="INPUT"){let r=(t.getAttribute("type")||"text").toLowerCase();return r==="checkbox"?"checkbox":r==="radio"?"radio":r==="number"||r==="range"?"number":r==="hidden"?"hidden":"text"}return e==="TEXTAREA"?"text":e==="SELECT"?t.multiple?"select-multiple":"select-one":"leaf"}function Hn(t){if(t.validity&&t.validity.badInput)return t.hasAttribute("value")?Number(t.getAttribute("value"))||0:t._sapLastGood??0;if(t.value==="")return 0;let e=Number(t.value);return Number.isNaN(e)?t._sapLastGood??0:(t._sapLastGood=e,e)}function Ke(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return Hn(t);case"select-one":return t.value;case"select-multiple":return[...t.selectedOptions].map(r=>r.value);case"hidden":case"text":return t.value;case"leaf":return t.textContent;default:return t.value}}function Je(t,e,r){switch(e){case"checkbox":t.checked=!!r;break;case"radio":t.checked=String(t.value)===String(r);break;case"number":case"text":case"hidden":t.value=r==null?"":String(r);break;case"select-one":t.value=r==null?"":String(r);break;case"select-multiple":{let n=new Set((Array.isArray(r)?r:[r]).map(String));for(let o of t.options)o.selected=n.has(o.value);break}case"leaf":t.textContent=r==null?"":String(r);break;default:t.value=r==null?"":String(r)}}function fe(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}Xt(t)||xt(t)}function jn(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function de(t,e){return Ke(t,e)}function Qe(t,e,r){Je(t,e,r),fe(t)}function G(t){let e=Kt(t);return{el:t,kind:e,read(){return Ke(t,e)},write(r,n={}){Je(t,e,r),n.noMirror||fe(t),n.silent||jn(t)},mirror(){fe(t)}}}var ot=null,Qt=!1,kt=null;function Ze(t){let e=null;return{kind:"hub",subscribe(r){let n=t.onAnyChange({debounce:0,require:"observed"},r);typeof n=="function"&&(e=n)},suppress(r){t.pause();try{return r()}finally{t.resume()}},teardown(){if(e){try{e()}catch{}e=null}}}}function Un(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(n=>e(Gn(n)));let r=typeof document<"u"&&document.body||typeof document<"u"&&document.documentElement;r&&t.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0})},suppress(e){let r=Q("undo");r&&r.pause&&r.pause();try{return e()}finally{t&&t.takeRecords(),r&&r.resume&&r.resume()}},teardown(){t&&(t.disconnect(),t=null)}}}function Gn(t){let e=[];for(let r of t)if(r.type==="attributes"){let n=r.target;n&&n.nodeType===1&&!Jt(n)&&e.push({type:"attribute",element:n})}else if(r.type==="characterData"){let n=r.target&&r.target.parentElement;n&&!Jt(n)&&e.push({type:"characterData",element:n})}else if(r.type==="childList"){for(let n of r.addedNodes)if(!(n.nodeType!==1||Jt(n))&&(e.push({type:"add",element:n}),n.querySelectorAll))for(let o of n.querySelectorAll("*"))Jt(o)||e.push({type:"add",element:o});for(let n of r.removedNodes)n.nodeType===1&&e.push({type:"remove",element:n,parent:r.target})}return e}function Jt(t){return!!(t.closest&&t.closest("[sap-ignore],[template],[cms-template]"))}function Yn(t,e){t.pruneDisconnected();let r=new Set,n=!1;for(let o of e){let s=o.type==="remove"?o.parent:o.element,a=s&&t.appFor(s);a&&r.add(a),o.type==="add"&&o.element&&o.element.nodeType===1&&o.element.hasAttribute&&o.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(o.element))&&(n=!0)}n&&t.remountIfPresent();for(let o of r)o.root.isConnected&&t.schedule(o,"mutation")}function tn(t){if(ot)return ot.suppress(t);let e=Q("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function pe(t,e){Qt=!0,ot=t,t.subscribe(r=>Yn(e,r))}function me(t){if(Qt||typeof window>"u"||typeof document>"u")return;let e=Q("Mutation");if(e&&typeof e.onAnyChange=="function"){pe(Ze(e),t);return}typeof MutationObserver=="function"&&(pe(Un(),t),kt=St(document,le,function(){let n=Q("Mutation");n&&(kt(),kt=null,ot&&ot.teardown(),Qt=!1,pe(Ze(n),t))}))}function en(){if(ot)try{ot.teardown()}catch{}kt&&typeof document<"u"&&kt(),ot=null,Qt=!1,kt=null}var Xn=new Set(bt);function $t(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),ut(t.root,"loop");return}e.full&&We();let r=qe(t.root);try{tn(()=>Kn(t,e))}finally{Ve(r)}t._viewsChanged&&(t._viewsChanged=!1,t.root.dispatchEvent(new CustomEvent("sap:views-updated",{bubbles:!0})))}function Kn(t,e){let r=t.root,n={},o=[],s=[],a=[],k=[],$=[],A=[],l=[],w=new Set;t.diag.errors=[];let N={root:n,state:n,item:null,ownerEl:r,projection:!1};function P(i,h){let f=h.attr||h.name,g=i.getAttribute(f);return g==null&&(g=Ct(h),$.push({el:i,name:h.name,attr:f,value:ie(ct(g,h.type),h.type)})),ct(g,h.type)}function z(i,h,f){let g=h.decls;if(g)for(let T of g){if(T.transient){f[T.name]=zt(i,T);continue}if(yt(i,T)){f[T.name]=i.hasAttribute(T.attr);continue}f[T.name]=P(i,T)}}function m(i,h,f){let g=h.bind,T=f.item||f.state,I=Kt(i);I==="radio"?(g in T||(T[g]=""),i.checked&&(T[g]=i.value)):T[g]=de(i,I),h.transient&&(i.removeAttribute("value"),i.removeAttribute("checked"))}function d(i,h,f){if(h.calcs){let g=f.item||f.state;for(let T of h.calcs)o.push({owner:g,ownerEl:f.ownerEl,name:T.name,entry:T.entry,def:T,el:i,ctx:f})}if(h.paints)for(let g of h.paints)g.kind==="when"&&w.add(g.field),s.push({def:g,el:i,ctx:f});if(h.effects)for(let g of h.effects)a.push({def:g,el:i,ctx:f});if(h.invalids)for(let g of h.invalids)k.push({def:g,el:i,ctx:f});if(h.bind!=null&&(f.view||f.projection)&&!qt(i)){let g=h.bind;f.view?wt(ke(f.item),g)?(i._sapViewBind="item",s.push({def:{kind:"projection",field:g,from:"item"},el:i,ctx:f})):g in f.state||g in f.root?(i._sapViewBind="drawn",s.push({def:{kind:"projection",field:g,from:"drawn"},el:i,ctx:f})):(i._sapViewBind=null,t.diag.error("E43",i,{attr:"bind",expr:g,problem:`bind="${g}" inside an each row matches no field of the row's record or of the scope the row is drawn in`,fix:"bind a field the record owns (bind, state= or items= on the [item]), or declare it with state= where the list is drawn"})):s.push({def:{kind:"projection",field:g,from:null},el:i,ctx:f})}}function p(i,h,f){Object.defineProperty(i,"$key",{value:Bt(h,"row"),enumerable:!1}),Object.defineProperty(i,"$index",{value:f,enumerable:!1}),Object.defineProperty(i,"$el",{value:h,enumerable:!1})}function y(i,h,f){let g=vt(i);z(i,g,h),i._sapScope=h,!f.projection&&g.bind!=null&&m(i,g,f),d(i,g,f),g.items?M(i,h,f):E(i,h,f)}function E(i,h,f){for(let g=i.firstElementChild;g;g=g.nextElementSibling)S(g,h,f)}function S(i,h,f){let g=vt(i);if(!g.inert){if(g.boundary){g.boundary==="scope"?_(i,h,f):g.boundary==="items"?(d(i,g,f),M(i,h,f)):g.boundary==="detail"?c(i,h,f):(d(i,g,f),l.push({el:i,ctx:f}));return}!f.projection&&!f.view&&g.bind!=null&&m(i,g,f),d(i,g,f);for(let T=i.firstElementChild;T;T=T.nextElementSibling)S(T,h,f)}}function _(i,h,f){let g=i.getAttribute("scope"),T={};h[g]=T;let I={root:f.root,state:T,item:null,ownerEl:i,projection:f.projection};y(i,T,I)}function M(i,h,f){let g=i.getAttribute("items"),T=[];h[g]=T,i._sapList=T;let I=0;for(let W=i.firstElementChild;W;W=W.nextElementSibling){let Y=vt(W);if(!Y.item||Y.template||W.hasAttribute("cms-template"))continue;let X={};p(X,W,I);let U={root:f.root,state:f.state,item:X,ownerEl:W,projection:f.projection};y(W,X,U),T.push(X),I++}}function H(i,h){let f=String(i).split("."),g=I=>{for(let W of f){if(I==null)return;I=Array.isArray(I)?I.flatMap(Y=>Y&&Y[W]!=null?Y[W]:[]):I[W]}return I},T=g(h.state);return T===void 0?g(h.root):T}function c(i,h,f){for(let g of V(i.getAttribute("state")||""))g.name in h||(h[g.name]=yt(i,g)?i.hasAttribute(g.attr):P(i,g));A.push({el:i,parentObj:h,ctx:f})}function u(i,h,f){i._sapScope=h;let g=i.getAttribute("detail")||"",T=/^([\w.]+)\s+by\s+(.+)$/.exec(g);if(!T){i.hidden=!0,i._sapDetailRow=null;return}let I=T[1],W=T[2].trim(),Y=H(I,f),X;try{X=Et(q(W),{state:h,item:f.item,el:i,root:f.root})}catch{X=void 0}let U=Array.isArray(Y)&&X!=null?Y.find(j=>j&&typeof j=="object"&&j.$el&&String(j.$key)===String(X)):null;if(i._sapDetailRow=U?U.$el:null,i.tagName==="DIALOG"){let j=U?String(U.$key):null;if(j!==i._sapDetailKey&&(i._sapDetailKey=j,i._sapDismissed=!1),!U){i._sapOpenedFor=null,i.open&&typeof i.close=="function"&&(i._sapEngineClose=!0,i.close());return}i.open?i._sapOpenedFor=j:(i._sapOpenedFor===j&&(i._sapDismissed=!0),i._sapOpenedFor=null,!i._sapDismissed&&i.isConnected&&typeof i.showModal=="function"&&(i.hidden&&(i.hidden=!1),i.showModal(),i._sapOpenedFor=j))}else{if(!U){i.hidden||(i.hidden=!0);return}i.hidden&&(i.hidden=!1)}ue();let at={root:f.root,state:h,item:U,ownerEl:U.$el,projection:!0};d(i,vt(i),at),E(i,U,at)}function b(i,h){for(let f=i.parentElement;f;f=f.parentElement)if(f._sapScope===h&&!f.hasAttribute("detail")||f.hasAttribute("sap"))return f;return r}function v(i,h){i._sapDrawnEl=b(i,h.state);let f=null;for(let B=i.firstElementChild;B;B=B.nextElementSibling)if(B.tagName==="TEMPLATE"){f=B;break}let g=f&&f.content.children.length===1?f.content.firstElementChild:null;if(!g)return t.diag.error("E42",i,{attr:"each",problem:"each needs one <template> child with exactly one element root"}),0;let T=i.getAttribute("each"),I;try{I=Et(q(T),{state:h.state,item:h.item,el:i,root:h.root})}catch(B){return t.diag.error("E24",i,{attr:"each",expr:T,problem:String(B.message)}),0}if(!Array.isArray(I))return t.diag.error("E40",i,{attr:"each",expr:T,problem:"each must evaluate to an array; the list keeps its last good rows"}),0;let W=q(i.getAttribute("key")||"item.$key"),Y=[],X=new Set;for(let B of I){let K;try{K=dt(W,h.state,B,i,h.root)}catch{K=void 0}let D=K==null?"":String(K);if(D===""||X.has(D))return t.diag.error("E41",i,{attr:"key",expr:W.src,problem:D===""?"an item has no key; the list keeps its last good rows":`duplicate key "${D}"; the list keeps its last good rows`}),0;X.add(D),Y.push(D)}let U=i._sapEach||new Map,at=new Map,j=0,ee=f;Y.forEach((B,K)=>{let D=U.get(B);if(!D||D.parentElement!==i){D=i.ownerDocument.importNode(g,!0);let _t=(D.getAttribute("clay")||"").split(/\s+/).filter(Boolean);_t.includes("editor-ui")||D.setAttribute("clay",[..._t,"editor-ui"].join(" ")),D._sapEachRow=!0,j++}D.getAttribute("data-key")!==B&&D.setAttribute("data-key",B),ee.nextElementSibling!==D&&(er(i,D,ee),j++),D._sapEachItem=I[K],at.set(B,D),ee=D});for(let[B,K]of U)at.get(B)!==K&&K.parentElement===i&&(K.remove(),j++);return i._sapEach=at,ue(),Y.forEach((B,K)=>{let D=at.get(B),_t={root:h.root,state:h.state,item:I[K],ownerEl:D,projection:!1,view:!0};d(D,vt(D),_t),E(D,{},_t)}),j}y(r,n,N);for(let i=0;i<A.length;i++){let{el:h,parentObj:f,ctx:g}=A[i];u(h,f,g)}if($.length&&w.size)for(let i of $)w.has(i.attr)&&i.el.getAttribute(i.attr)==null&&i.el.setAttribute(i.attr,i.value);let x=new Map;for(let i of o){let h=x.get(i.owner);h||(h={ownerEl:i.ownerEl,list:[]},x.set(i.owner,h)),h.list.push(i)}let L=[...x.values()].sort((i,h)=>on(h.ownerEl)-on(i.ownerEl));for(let i of L){let h;try{h=Oe(i.list)}catch(f){t.diag.error("E07",i.list[0].el,{problem:f.message}),h=i.list}for(let f of h)try{f.owner[f.name]=dt(f.entry,f.ctx.state,f.ctx.item,f.el,f.ctx.root),Ft(f.el)}catch(g){f.owner[f.name]=void 0,t.diag.error("E24",f.el,{attr:"calc:"+f.name,expr:f.entry.src,problem:String(g.message)}),ut(f.el,g.sapCode||"E24")}}let C=0;for(let i=0;i<l.length;i++)C+=v(l[i].el,l[i].ctx);let R=0,F=C;for(let i of s){let h=Qn(i,t);i.ctx.view?F+=h:R+=h}for(let i of a)Zn(i,t);for(let i of k)tr(i);t._state=n,t._stats={fields:Object.keys(n).filter(i=>typeof n[i]!="function").length,calcs:o.length,paints:s.length,lists:x.size,writes:R,viewWrites:F},t._viewsChanged=F>0,t._lastPass={trigger:e.trigger||"refresh",writes:R},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${R}/${s.length}`)}function Jn(t){return t.kind==="text"?t.fmt?"text:"+t.fmt:"text":t.kind==="attr"?"attr:"+t.arg:t.kind==="class"?"class:"+t.arg:t.kind==="css"?"css:"+t.arg:t.kind==="when"?(t.match==="hide"?"hide-when:":t.match==="show-not"?"option-not:":"show-when:")+t.field:t.kind}function he(t,e,r,n){let o=t;for(;o&&o.nodeType===1;){if(o.hasAttribute&&o.hasAttribute(e)){let s=r.includes(o.getAttribute(e));if(n?!s:s)return!0}o=o.parentElement}return!1}function nn(t,e){if(t===t.ownerDocument.activeElement)return 0;if(t.type==="radio"){let s=e!=null&&String(t.value)===String(e);return t.checked===s?0:(t.checked=s,1)}let r=Kt(t),n=de(t,r),o=e??"";return String(n)!==String(o)?(Qe(t,r,o),1):0}function Qn(t,e){let r=t.def,n=t.el;if(r.kind==="projection"){if(r.from==="drawn"){let o=r.field in t.ctx.state?t.ctx.state:t.ctx.root;return nn(n,o[r.field])}return nn(n,t.ctx.item?t.ctx.item[r.field]:"")}if(r.kind==="when")return rn(r,n,null);try{let o=dt(r.entry,t.ctx.state,t.ctx.item,n,t.ctx.root),s=rn(r,n,o);return Ft(n),s}catch(o){return e.diag.error(o.sapCode==="E22"?"E22":"E24",n,{attr:Jn(r),expr:r.entry&&r.entry.src,problem:String(o.message)}),ut(n,o.sapCode||"E24"),0}}function rn(t,e,r){switch(t.kind){case"text":{let n=t.fmt!=null?Me(t.fmt,r):r==null?"":String(r);return e.textContent!==n?(e.textContent=n,1):0}case"show":{let n=!r;return e.hidden!==n?(e.hidden=n,1):0}case"when":{let n=Q("optionVisibility");if(n&&n._started)return e._sapWhen&&e.hidden?(e.hidden=!1,e._sapWhen=!1,1):0;let o;t.match==="hide"?o=!he(e,t.field,t.values,!1):t.match==="show-not"?o=he(e,t.field,t.values,!0):o=he(e,t.field,t.values,!1),e._sapWhen=!0;let s=!o;return e.hidden!==s?(e.hidden=s,1):0}case"attr":{let n=t.arg;if((n==="checked"||n==="selected")&&typeof e[n]=="boolean"&&!e.hasAttribute("bind")&&!e.closest("select[bind]")){let s=0;return e[n]!==!!r&&(e[n]=!!r,s=1),!!r!==e.hasAttribute(n)&&(r?e.setAttribute(n,""):e.removeAttribute(n),s=1),s}if(Xn.has(n)){let s=e.hasAttribute(n);return r&&!s?(e.setAttribute(n,""),1):!r&&s?(e.removeAttribute(n),1):0}let o=typeof r=="boolean"?String(r):r==null?"":String(r);return e.getAttribute(n)!==o?(e.setAttribute(n,o),1):0}case"class":{let n=!!r;return e.classList.contains(t.arg)!==n?(e.classList.toggle(t.arg,n),1):0}case"css":{let n=r==null?"":String(r);return e.style.getPropertyValue("--"+t.arg)!==n?(e.style.setProperty("--"+t.arg,n),1):0}default:return 0}}function Zn(t,e){try{dt(t.def.entry,t.ctx.state,t.ctx.item,t.el,t.ctx.root),Ft(t.el)}catch(r){e.diag.error("E24",t.el,{attr:"effect",expr:t.def.entry&&t.def.entry.src,problem:String(r.message)}),ut(t.el,"E24")}}function tr(t){let e="";try{let r=dt(t.def.entry,t.ctx.state,t.ctx.item,t.el,t.ctx.root);e=typeof r=="string"?r:""}catch{e=""}typeof t.el.setCustomValidity=="function"&&t.el.setCustomValidity(e)}function on(t){let e=0,r=t;for(;r&&!(r.hasAttribute&&r.hasAttribute("sap"));)r=r.parentElement,e++;return e}function er(t,e,r){let n=r.nextSibling;if(e.isConnected&&t.moveBefore)try{t.moveBefore(e,n);return}catch{}t.insertBefore(e,n)}var nr=new Set(bt),sn=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode"]),rr=new Set(["show-when","hide-when","option","option-not"]),or=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,an=new Set(["sap","scope","items","item","template","bind","show","effect","invalid","detail","state","transient","confirm","default","persist","sortable","trigger-add","trigger-remove","trigger-reset","sap-ignore","sap-error","no-save","no-watch","no-undo","no-trigger-autosave","freeze","mutations-ignore","save-remove","save-ignore","save-freeze"]);function ir(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function be(t){return t.hasAttribute("bind")}function sr(t,e){e(t);for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(!n.hasAttribute("sap-ignore")){if(n.tagName==="TEMPLATE"){if(n.hasAttribute("items"))for(let o=n.content.firstElementChild;o;o=o.nextElementSibling)r(o);return}e(n);for(let o=n.firstElementChild;o;o=o.nextElementSibling)r(o)}}}function Zt(t,e){let r=!1,n=(a,k,$)=>{e.error(a,k,$),r=!0},o=t.ownerDocument.createTreeWalker(t,4),s;for(;s=o.nextNode();)if(/\{\{.*\}\}/.test(s.nodeValue||"")){n("E02",s.parentElement||t,{problem:"moustaches in text content are not a Sap feature",fix:'move the expression onto the element: text="state.x"'});break}return sr(t,a=>{let k=a.closest&&a.closest("[detail]");for(let $ of[...a.attributes]){let A=$.name,l=ve(A);if(l){n("E01",a,{attr:A,expr:$.value,problem:`"${A}" is a foreign-dialect attribute; Sap has no ${A.split(/[:=]/)[0]} directive`,fix:l+" \u2014 or wrap the subtree in sap-ignore if intentional"});continue}if(A.includes(":")){let N=A.slice(0,A.indexOf(":"));if(sn.has(N)){if(rr.has(N)&&or.test($.value)){let P=A.slice(A.indexOf(":")+1);e.warn("W04",a,{attr:A,expr:$.value,problem:`${N}: compares the "${P}" attribute against a literal value, not a JS expression`,fix:`use show="${$.value}" for an expression, or a literal like ${N}:${P}="overview"`})}}else{let P=Nt(N,[...sn]);e.warn("W03",a,{attr:A,problem:`unknown "${N}:" attribute`,didYouMean:P?`${P}:`:null})}}else if(!an.has(A)&&!Tt.has(A)&&!nr.has(A)&&!/^(data-|aria-|on)/.test(A)&&!(A in a)){let N=Nt(A,[...an]);N&&e.warn("W03",a,{attr:A,problem:`unknown "${A}" attribute`,didYouMean:N})}A==="attr:hidden"&&e.warn("W03",a,{attr:A,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'});let w=be(a)||A==="attr:selected"&&a.tagName==="OPTION"&&!!a.closest("select[bind]");(A==="attr:value"||A==="attr:checked"||A==="attr:selected")&&w&&n("E30",a,{attr:A,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),A==="effect"&&be(a)&&/\b(value|checked)\s*=[^=]/.test($.value)&&n("E30",a,{attr:A,expr:$.value,problem:"effect writes value/checked on a bound control (writes a stale value with no synthetic event)",fix:"write through onclick + Sap(this) instead"}),(A==="text"||A.startsWith("text:")||A==="show")&&ir(a)&&(A==="show"||n("E18",a,{attr:A,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(a.hasAttribute("state")){let $=V(a.getAttribute("state")),A=new Set;for(let l of $){l.name.includes("-")&&n("E08",a,{attr:"state",problem:`field "${l.name}" is not a valid identifier (the hyphen parses as subtraction)`,fix:`rename to ${l.name.replace(/-/g,"")}`}),A.has(l.name)&&n("E04",a,{attr:"state",problem:`field "${l.name}" is declared twice in one scope`}),A.add(l.name),It.has(l.attr)&&n("E05",a,{attr:"state",problem:`"${l.name}" is a reserved Sap word`}),Tt.has(l.attr)&&n("E06",a,{attr:"state",problem:`"${l.name}" is a global HTML attribute name; pick another field name`}),l.name==="open"&&a.tagName==="DIALOG"&&n("E33",a,{attr:"state",problem:"dialog open is transient",fix:"use showModal() \u2014 declare state= only on <details> or popovers"});let w=se(a,l.attr);w&&(l.attr==="checked"||l.attr==="selected")&&n("E35",a,{attr:"state",problem:`"${l.attr}" on a form control is the control's own state, not a declared field`,fix:'bind the control instead, e.g. <input type="checkbox" bind="done">'}),w&&l.type==="num"&&n("E35",a,{attr:"state",problem:`"${l.attr}" is an HTML boolean attribute; it cannot hold a number`,fix:`declare it bare: state="${l.attr}"`}),l.transient&&(w||l.type==="presence")&&n("E35",a,{attr:"state",problem:`"${l.name}" is carried by attribute presence, which transient would strip`,fix:"declare a separate name:bool:transient field and paint the attribute from it"})}}if(be(a)){if(a.hasAttribute("-"),a.tagName==="INPUT"){let $=(a.getAttribute("type")||"text").toLowerCase();$==="file"&&n("E32",a,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),$==="password"&&!a.hasAttribute("transient")&&n("E31",a,{attr:"bind",problem:"a password must never serialize into a world-readable file",fix:"add transient to the password input"})}else if(a.tagName!=="SELECT"&&a.tagName!=="TEXTAREA"){let $=a.getAttribute("contenteditable");!($!=null&&$!=="false")&&a.children.length>0&&n("E20",a,{attr:"bind",problem:"bind on a container element is not a control; a write would overwrite its children",fix:"bind a control (input/select/textarea), a contenteditable, or an empty text leaf"})}}if(a.hasAttribute("transient")&&a.hasAttribute("persist")&&n("E34",a,{problem:"transient and persist are opposite: persist forces the live value into the saved bytes, leaking exactly what transient drops",fix:"remove one \u2014 transient to keep it out of the file, or persist to save it"}),a.tagName==="DIALOG"&&a.hasAttribute("detail")&&!(a.parentElement&&a.parentElement.closest('[clay~="freeze"], [freeze], [save-freeze]'))&&e.warn("W31",a,{attr:"detail",problem:"a detail dialog writes open when it opens, and that attribute would be saved into the file",fix:'wrap the dialog in an element with clay="freeze" (not editor-ui, which removes it from the file), and make its key field transient'}),a.hasAttribute("item")&&!a.hasAttribute("template")&&a.parentNode&&a.parentNode.nodeType===1){let $=a.parentElement;(!$||!$.hasAttribute("items"))&&n("E10",a,{problem:"an [item] must be a direct child of an [items] list",fix:'wrap it in a container with items="name"'})}if(a.hasAttribute("items")&&k&&n("E17",a,{attr:"items",problem:"nested items inside a detail panel is a v1 mount error (nested collections ship in v1.1)"}),a.hasAttribute("items")){let $=t.querySelector(`[trigger-add="${a.getAttribute("items")}"]`);!Vt(a)&&!oe(t,a.getAttribute("items"))&&rt(a).length===0&&$&&n("E17",a,{attr:"items",problem:`trigger-add targets items="${a.getAttribute("items")}" but it has no [item template] to clone`})}}),r&&(e.halted=!0,e.haltReason=e.errors[0]?e.errors[0].code:"halt",ut(t,e.haltReason)),!r}var un="sap-styles",cn="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",ge=new WeakSet;function ar(t){if(ge.has(t))return;let e=t.defaultView,r=e&&e.CSSStyleSheet;if(r&&"adoptedStyleSheets"in t)try{let n=new r;n.replaceSync(cn),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],ge.add(t);return}catch{}if(!t.getElementById(un)){let n=t.createElement("style");n.id=un,n.textContent=cn,(t.head||t.documentElement).appendChild(n)}ge.add(t)}var ur=0;function ln(){return typeof performance<"u"&&performance.now?performance.now():0}function we(t){let e=t.id||t.getAttribute("sap")||`app-${ur++}`,r=new ht(e),n={root:t,name:e,diag:r,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Zt(t,r))return n.halted=!0,n;ar(t.ownerDocument);for(let a of t.querySelectorAll("textarea[data-value]"))Yt(a);let s=ln();return $t(n,{trigger:"mount",full:!0}),n._mountMs=ln()-s,n._mountWrites=n._stats?n._stats.writes:0,n._mountWrites>0&&r.warn("W30",t,{problem:`${n._mountWrites} paint(s) ran at mount; the saved file was out of sync with its declared state`,fix:"re-save once so the file mounts clean (a settled file writes nothing)"}),n}var cr=["for","form","list","headers","popovertarget","commandfor","anchor","aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"];function lr(t,e){let r=null;return et(t,n=>{!r&&n.getAttribute("scope")===e&&(r=n)}),r}function fn(t,e,r){let n=J(t)||e;for(;n;){for(let o of V(n.getAttribute("state")||""))if(o.name===r)return{el:n,decl:o};if(n.hasAttribute("sap"))break;n=J(n.parentElement)}return null}function fr(t){return typeof t=="number"?"num":typeof t=="boolean"?"bool":"string"}function dn(t){function e(m){let d=t.appFor(m);if(!d)return null;let p=lt(m),y=p&&p._sapEachItem&&p._sapEachItem.$el;if(y&&y.isConnected)return{ctxEl:y,appRec:d,isRow:!0};let E=Lt(m);if(E)return E._sapDetailRow?{ctxEl:E._sapDetailRow,appRec:d,isRow:!0}:{ctxEl:J(E.parentElement)||d.root,appRec:d,isRow:!1};let S=Wt(m);if(S&&S.hasAttribute("item"))return{ctxEl:S,appRec:d,isRow:!0};let _=J(m)||d.root;return{ctxEl:_,appRec:d,isRow:_.hasAttribute("item")}}function r(m){let d=typeof m=="string"?document.querySelector(m):m;if(!d||d.nodeType!==1)return null;let p=e(d);return p?z(p.ctxEl,p.appRec,p.isRow):null}function n(m,d){let p=lt(m);if(!p)return r(m);let y=t.appFor(m),E=p._sapEachItem&&p._sapEachItem.$el;if(E&&E.nodeType===1&&E.hasAttribute("item")&&wt(E,d))return E.isConnected?z(E,y,!0):null;let S=p.parentElement&&p.parentElement._sapDrawnEl;return!S||!S.isConnected?null:z(S,y,S.hasAttribute("item"))}function o(m,d,p){let y=ft(m,p);if(y)return G(y).read();let E=gt(m,p);if(E)return rt(E).map(H=>z(H,d,!0));let S=lr(m,p);if(S)return z(S,d,!1);let _=fn(m,d.root,p);if(_)return _.decl.transient?zt(_.el,_.decl):$e(_.el,_.decl);let M=m._sapScope;return M?M[p]:void 0}function s(m,d,p,y,E){y.transient?Dt(m,y,p):Rt(m,y,p),t.schedule(E,"set:"+d)}function a(m,d){let p=new Set,y=J(m)||d;for(;y;){for(let E of V(y.getAttribute("state")||""))p.add(E.name);if(y.hasAttribute("sap"))break;y=J(y.parentElement)}return et(m,E=>{let S=E.getAttribute("bind");S&&p.add(S)}),p}function k(m,d,p,y){let E=ft(m,p);if(E){G(E).write(y);return}let S=m;for(;S;){for(let x of S.attributes)if(x.name==="calc:"+p){d.diag.error("E16",S,{attr:"calc:"+p,problem:`"${p}" is a computed field; computed fields are read-only`});return}if(S.hasAttribute("sap"))break;S=S.parentElement}let _=fn(m,d.root,p);if(_){s(_.el,p,y,_.decl,d);return}let M=a(m,d.root);M.delete(p);let H=p.length>=4?Nt(p,[...M]):null;if(H){d.diag.error("E12",m,{key:p,problem:`unknown state key "${p}"`,didYouMean:H});return}if(It.has(p)||Tt.has(p)){d.diag.error("E15",m,{key:p,problem:`cannot write undeclared field "${p}" \u2014 it is a reserved/global name and cannot become state`,fix:"pick a different field name, or declare it explicitly in a state= attribute"});return}let c=d.root,u=fr(y),b=c.getAttribute("state")||"",v=u==="string"?p:`${p}:${u}`;c.setAttribute("state",b?`${b} ${v}`:v),s(c,p,y,{name:p,attr:p,type:u,transient:!1},d)}function $(m){let d=m.ownerDocument,p=new Map,y=(E,S)=>{let _=Se(d),M=E.getAttribute(S);M&&S==="id"&&p.set(M,_),E.setAttribute(S,_)};m.querySelectorAll("[id]").forEach(E=>y(E,"id")),m.querySelectorAll("[data-id]").forEach(E=>y(E,"data-id")),m.querySelectorAll("[sap-error]").forEach(E=>E.removeAttribute("sap-error")),m.removeAttribute("sap-error"),m.hasAttribute("data-id")?(m.removeAttribute("id"),y(m,"data-id")):y(m,"id");for(let E of[m,...m.querySelectorAll("*")])for(let S of cr){let _=E.getAttribute(S);if(_==null)continue;let M=_.split(/\s+/).map(H=>p.get(H)||H).join(" ");M!==_&&E.setAttribute(S,M)}}function A(m,d,p){let y=Mt(d.root,m,p);if(!y)return d.diag.error("E17",m,{problem:`cannot resolve a list named "${p}" from here`}),null;let E=Vt(y);if(!E)return d.diag.error("E17",y,{problem:`items="${p}" has no [item template] to clone`}),null;let S=y.ownerDocument.importNode(E,!0);return S.removeAttribute("template"),$(S),y.appendChild(S),t.schedule(d,"trigger-add:"+p),z(S,d,!0)}function l(m,d){et(m,p=>{if(p.hasAttribute("bind")){let y=G(p),E=p.getAttribute("default");y.kind==="checkbox"||y.kind==="radio"?y.write(E!=null?E===""||E==="true"||p.value===E:p.hasAttribute("checked")):y.write(E??(p.getAttribute("value")||""))}});for(let p of V(m.getAttribute("state")||"")){let y=_e(m,p);p.transient?Dt(m,p,y):Rt(m,p,y)}t.schedule(d,"trigger-reset")}function w(m,d){if(!m.isConnected)throw new Error("stale row handle: $remove() on a removed row");m.remove(),t.schedule(d,"trigger-remove")}function N(m,d,p){if(!m.isConnected)throw new Error("stale row handle: $move() on a removed row");let y=null;if(p&&p.nodeType===1?y=p:typeof p=="string"&&(y=Mt(d.root,m,p)),!y){d.diag.error("E17",m,{problem:`$move() cannot resolve target "${p}"`});return}t.moveInto(y,m),t.schedule(d,"trigger-move")}function P(m){let d=m.parentElement;return d?rt(d).indexOf(m):-1}function z(m,d,p){let y={get $el(){return m},get $key(){return Bt(m,p?"row":"scope")},get $index(){return P(m)},$add(S){return A(m,d,S)},$reset(){return l(m,d),E},$remove(){w(m,d)},$move(S){N(m,d,S)},get $appRec(){return d}},E=new Proxy(y,{get(S,_){return typeof _=="symbol"||_[0]==="$"?S[_]:o(m,d,_)},set(S,_,M){return typeof _=="string"&&_[0]==="$"?(S[_]=M,!0):(k(m,d,_,M),!0)},has(S,_){return typeof _=="string"&&_[0]==="$"?_ in S:o(m,d,_)!==void 0}});return E}return{Sap:r,contextElFor:e,readField:o,writeField:k,makeProxy:z,writeTargetFor:n}}var dr=["trigger-add","trigger-remove","trigger-reset"];function pr(t){if(t.nodeType!==1)return!1;for(let e of t.attributes){let r=e.name;if(r.startsWith("set:")||r.startsWith("move:")||r.startsWith("sort:")||dr.includes(r))return!0}return!1}function mr(t,e){let r=t,n=e.parentElement;for(;r&&r!==n;){if(r.nodeType===1&&pr(r)&&!(r.tagName==="FORM"&&r.hasAttribute("trigger-add")))return r;r=r.parentElement}return null}function pn(t,e){let{Sap:r}=e;function n(c,u){let b=null,v=lt(c),x=Lt(c);if(v)b=v._sapEachItem??null;else if(x&&x._sapDetailRow)b=x._sapDetailRow._sapScope||null;else{let R=Wt(c);R&&R.hasAttribute("item")&&(b=R._sapScope||null)}return{state:(J(c)||u.root)._sapScope||u._state||{},item:b,el:c,root:u._state||{}}}function o(c,u,b){if(!c.hasAttribute("confirm")){b();return}let v=c.getAttribute("confirm"),x=v,L=q(v);if(!L.error)try{let F=Et(L,n(c,u));(typeof F=="string"||typeof F=="number")&&(x=String(F))}catch{}let C=Ge();if(!C){window.confirm(x)&&b();return}if(c._sapGatePending)return;c._sapGatePending=!0;let R=()=>{c._sapGatePending=!1};C(x,()=>{R(),b()}).catch(R)}function s(c,u){for(let b of c.attributes){if(!b.name.startsWith("set:"))continue;let v=b.name.slice(4),x=q(b.value);if(x.error){u.diag.error("E08",c,{attr:b.name,expr:b.value,problem:String(x.error.message)});continue}let L;try{L=Et(x,n(c,u))}catch(R){u.diag.error("E24",c,{attr:b.name,expr:b.value,problem:String(R.message)});continue}let C=e.writeTargetFor(c,v);C&&(C[v]=L)}}function a(c){let u=lt(c);if(!u)return c.closest("[item]");let b=u._sapEachItem&&u._sapEachItem.$el;return b&&b.nodeType===1&&b.hasAttribute("item")?b:null}function k(c,u){let b=a(c);if(!b)return;let v=rt(b.parentElement),x=v.indexOf(b);u==="up"&&x>0?t.placeBefore(b,v[x-1]):u==="down"&&x<v.length-1&&t.placeBefore(v[x+1],b)}function $(c,u,b){if(u)return Mt(b.root,c,u);let v=c;for(;v;){if(v.hasAttribute&&v.hasAttribute("items"))return v;v=v.parentElement}let x=J(c)||b.root,L=[];return et(x,C=>{C.hasAttribute("items")&&L.push(C)}),L[0]||null}function A(c,u){let b=c==null||c==="",v=u==null||u==="";if(b&&v)return 0;if(b)return 1;if(v)return-1;let x=Number(c),L=Number(u);return!Number.isNaN(x)&&!Number.isNaN(L)?x-L:String(c)<String(u)?-1:String(c)>String(u)?1:0}function l(c,u,b,v){let x=$(c,b,v);if(!x){v.diag.error("E17",c,{attr:"sort:"+u,problem:`no items list resolvable for sort:${u}`});return}let L=rt(x),C=h=>h._sapScope?h._sapScope[u]:void 0,R=[...L].sort((h,f)=>A(C(h),C(f))),i=R.every((h,f)=>h===L[f])?[...R].reverse():R;for(let h of i)t.moveInto(x,h);t.schedule(v,"sort:"+u)}function w(c){if(!c||c.hidden)return;let u=c.querySelector("[bind]:not([type=hidden]), [contenteditable]");u&&typeof u.focus=="function"&&u.focus()}function N(c,u){o(c,u,()=>{let b=r(c);for(let v of[...c.attributes]){let x=v.name;if(x==="trigger-remove")b&&b.$remove();else if(x==="trigger-reset")b&&b.$reset();else if(x==="trigger-add"){let L=b&&b.$add(v.value);L&&w(L.$el)}else x==="move:up"?(k(c,"up"),t.schedule(u,"move:up")):x==="move:down"?(k(c,"down"),t.schedule(u,"move:down")):x.startsWith("move:to")?b&&b.$move(v.value):x.startsWith("sort:")&&l(c,x.slice(5),v.value,u)}[...c.attributes].some(v=>v.name.startsWith("set:"))&&s(c,u)})}function P(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;let v=mr(u,b.root);v&&N(v,b)}function z(c){let u=G(c),b=c.getAttribute("default");u.kind==="checkbox"?u.write(b===""||b==="true"):u.write(b??"")}function m(c,u,b){let v=r(c);if(!v)return;let x=v.$add(b);if(!x)return;let L=[];et(c,C=>{C.hasAttribute("bind")&&L.push(C)});for(let C of L){if(C.type==="radio"&&!C.checked)continue;let R=C.getAttribute("bind"),F=ft(x.$el,R);F?G(F).write(G(C).read()):wt(x.$el,R)&&(x[R]=G(C).read())}L.forEach(z),L.length?typeof L[0].focus=="function"&&L[0].focus():w(x.$el)}function d(c){let u=c.target;if(!u||!u.hasAttribute||!u.hasAttribute("trigger-add"))return;let b=t.appFor(u);b&&(c.preventDefault(),o(u,b,()=>m(u,b,u.getAttribute("trigger-add"))))}function p(c){let u=c.target,b=t.appFor(u);b&&setTimeout(()=>{u.querySelectorAll("[bind]").forEach(v=>{v.dispatchEvent(new Event("input",{bubbles:!0})),v.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(b,"reset")},0)}function y(c){let u=t.appFor(c.target);u&&t.schedule(u,"toggle")}function E(c){let u=c.target;if(!u||u.tagName!=="DIALOG"||!u.hasAttribute("detail"))return;if(u._sapEngineClose){u._sapEngineClose=!1;return}if(u.open)return;let b=/^[\w.]+\s+by\s+state\.(\w+)\s*$/.exec(u.getAttribute("detail")||""),v=t.appFor(u);if(!b||!v)return;let x=V(u.getAttribute("state")||"").find(C=>C.name===b[1]);if(x){x.transient?Dt(u,x,""):Rt(u,x,""),t.schedule(v,"close");return}let L=r(u.parentElement);L&&L[b[1]]!==""&&(L[b[1]]="")}function S(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;u.hasAttribute("persist")&&!Xt(u)&&xt(u);let v=u.hasAttribute("bind")&&qt(u);if(!v&&u.hasAttribute("bind")&<(u)){let L=u.getAttribute("bind"),C=u._sapViewBind?e.writeTargetFor(u,L):null;C&&(C[L]=G(u).read());return}let x=Lt(u);if(x&&x._sapDetailRow&&u.hasAttribute("bind")&&!v){let L=x._sapDetailRow,C=u.getAttribute("bind"),R=ft(L,C);if(R&&R!==u){G(R).write(G(u).read());return}if(!R&&V(L.getAttribute("state")||"").some(F=>F.name===C)){e.writeField(L,b,C,G(u).read());return}}t.schedule(b,c.type+" "+(u.id||u.tagName.toLowerCase()))}function _(c){let u=c.detail||{};for(let b of[u.from,u.to,c.target]){if(!b||b.nodeType!==1)continue;let v=t.appFor(b);v&&t.schedule(v,"sorted")}}function M(c){if(c.key!=="ArrowUp"&&c.key!=="ArrowDown")return;let u=c.target;if(!u||u.nodeType!==1||u.tagName!=="INPUT"||!u.hasAttribute("bind")||!u.hasAttribute("step"))return;let b=(u.getAttribute("type")||"text").toLowerCase();if(b!=="text"&&b!=="tel"&&b!=="search"||!t.appFor(u))return;c.preventDefault();let x=Z(u.getAttribute("step"))||1,L=c.key==="ArrowUp"?1:-1,C=Z(u.value)+x*(c.shiftKey?10:1)*L,R=u.getAttribute("min"),F=u.getAttribute("max");R!==null&&R!==""&&C<Z(R)&&(C=Z(R)),F!==null&&F!==""&&C>Z(F)&&(C=Z(F)),G(u).write(String(Number(C.toFixed(2))))}function H(c=document){c.addEventListener("click",P),c.addEventListener("submit",d),c.addEventListener("reset",p),c.addEventListener("toggle",y,!0),c.addEventListener("close",E,!0),c.addEventListener("input",S),c.addEventListener("change",S),c.addEventListener("clay:sorted",_),c.addEventListener("keydown",M)}return{install:H}}var mn=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function ye(t){return`${t.tagName.toLowerCase()}[sap]`}function hr(t){let e=0;for(let r of t.querySelectorAll("*"))for(let n of r.attributes)if(mn.test(n.name)){e++;break}for(let r of t.attributes)if(mn.test(r.name)){e++;break}return e}function hn(t){let e=[],r=n=>{for(let o of n.attributes){let s=o.name;(s.startsWith("calc:")||s==="text"||s.startsWith("text:")||s==="show"||s.startsWith("attr:")||s.startsWith("class:")||s.startsWith("css:")||s==="effect"||s==="invalid"||s.startsWith("set:")||s==="detail")&&e.push({el:n,attr:s,src:o.value})}};r(t);for(let n of t.querySelectorAll("*"))r(n);return e}function bn(t){function e(l){let w=l._stats||{},N=l.root;return{root:ye(N),fields:w.fields||0,calcs:w.calcs||0,paints:w.paints||0,actions:hr(N),lists:(N.hasAttribute("items")?1:0)+N.querySelectorAll("[items]").length,rows:N.querySelectorAll("[item]:not([template])").length,warnings:l.diag.warnings.length,errors:l.diag.errors.length,mountWrites:l._mountWrites||0,ms:Math.round((l._mountMs||0)*10)/10,passes:l._passes||0,lastPass:l._lastPass||null,ok:l.diag.errors.length===0&&!l.halted}}function r(){let l=t.apps().map(e);return{ok:l.every(w=>w.ok),apps:l}}function n(l){let w=e(l);return w.ok?`sap \u2713 ${w.root} \xB7 fields ${w.fields} \xB7 calcs ${w.calcs} \xB7 paints ${w.paints} \xB7 actions ${w.actions} \xB7 lists ${w.lists} \xB7 rows ${w.rows} \xB7 warnings ${w.warnings} \xB7 mount writes ${w.mountWrites} \xB7 ${w.ms}ms`:`sap \u2717 ${w.root} \xB7 errors ${w.errors} \xB7 warnings ${w.warnings} \xB7 ${w.ms}ms`}function o(){for(let l of t.apps()){let w=n(l);l.diag.errors.length||l.halted?console.error(w):console.log(w)}}function s(){let l=[],w=[];for(let N of t.apps())l.push(...N.diag.errors),w.push(...N.diag.warnings);return{ok:l.length===0,errors:l,warnings:w,counts:{errors:l.length,warnings:w.length}}}function a(l){return l?typeof l=="string"?document.querySelector(l):l.nodeType===1?l:null:null}function k(l,w){let N=a(l);if(!N)return console.warn("sap why: element not found"),null;let P=[`sap why <${N.tagName.toLowerCase()}> \u2014 ${Ot(N)}`],z=[...N.attributes].filter(d=>/^(bind|text|show|effect|invalid|detail|calc:|text:|attr:|class:|css:|set:|state|items|scope)/.test(d.name));for(let d of z)P.push(` ${d.name}="${d.value}"`);let m=N;for(;m&&!m._sapScope;)m=m.parentElement;if(m&&m._sapScope){let d=m._sapScope,p=w?[w]:Object.keys(d);P.push(" reads:");for(let y of p){let E=d[y];typeof E!="function"&&P.push(` ${y} = ${JSON.stringify(Array.isArray(E)?`[${E.length} rows]`:E)}`)}}return P.push(" serialization: textContent and value/checked attributes save with the file; reads live from properties"),console.log(P.join(`
|
|
10
|
-
`)),null}function $(l){let w=l===void 0?!0:!!l;for(let N of t.apps())N._debug=w;return console.log(`sap debug ${w?"on":"off"} \u2014 per-pass headers will ${w?"":"no longer "}log`),w}function A(){let l=[],w=0;for(let d of t.apps()){let p=d.root,y=ye(p);w++;let E=new ht(d.name);Zt(p,E);for(let c of E.errors)l.push({code:c.code,severity:"error",message:`${y}: ${c.code} ${c.slug} at ${c.el}`});for(let c of E.warnings)l.push({code:c.code,severity:"warn",message:`${y}: ${c.code} ${c.slug} at ${c.el}`});w++,$t(d,{trigger:"doctor-dryrun"});let S=d._stats?d._stats.writes:0;S>0&&l.push({code:"W30",severity:"warn",message:`${y}: dry recompute wrote ${S} cells on a quiet page; an element is stale or non-idempotent`}),w++;let _=
|
|
9
|
+
`+e.value:e.value;t.textContent!==n&&(t.textContent=n),t.removeAttribute("data-value");return}if(r==="SELECT"){let n=t.options,o=e.options;for(let s=0;s<n.length;s++)o[s]&&o[s].selected?n[s].hasAttribute("selected")||n[s].setAttribute("selected",""):n[s].removeAttribute("selected")}}function Yt(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function X(t){if(typeof window>"u")return null;let e=window.clay,r=window.hyperclay;return t==="consent"?e?.confirm||r?.consent||null:e?.[t]||r?.[t]||null}function Ue(){let t=X("visitorDrafts");return!!(t&&typeof t.restored=="function"&&t.restored()?.restored)}var le=["clay:mutation-ready","hyperclay:mutation-ready"],Vn=["clay:sync-applied","hyperclay:livesync-applied"],zn=["clay:ready","hyperclay:ready"],Hn=["clay:route"];function St(t,e,r){let n=null,o=s=>{n!==null&&n!==s.type||(n=s.type,queueMicrotask(()=>{n=null}),r(s))};for(let s of e)t.addEventListener(s,o);return()=>{for(let s of e)t.removeEventListener(s,o)}}function Ge(t){let e=typeof window<"u"&&window.clay&&window.clay.ready;e&&typeof e.then=="function"?e.then(()=>t(),()=>t()):t()}function Xt(t){let e=X("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function Ye(){let t=X("consent");return typeof t=="function"?t:null}function Xe(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let r=X("undo");r&&r.flush&&r.flush();let n=e();if(n&&typeof n.then=="function")throw new Error("Sap.batch fn must be synchronous (it returned a promise)");return r&&r.commitCaptured&&r.commitCaptured(t),n}function Ke(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let s=!1;for(let a of t.apps())a.root.isConnected?t.runNow(a,"platform"):s=!0;s&&(t.pruneDisconnected(),t.remountIfPresent())};St(document,Vn,e),St(document,Hn,e);let r=!1,n=()=>{},o=()=>{if(r)return!0;let s=X("undo");if(!s||typeof s.on!="function")return!1;let a=s.on("undo",e);return typeof a!="function"?!1:typeof s.on("redo",e)!="function"?(a(),!1):(r=!0,n(),!0)};if(!o()){let s=St(document,le,o),a=St(document,zn,o);n=()=>{s(),a()};let k=X("ready");k&&typeof k.then=="function"&&k.then(o,()=>{})}}function Kt(t){let e=t.tagName;if(e==="INPUT"){let r=(t.getAttribute("type")||"text").toLowerCase();return r==="checkbox"?"checkbox":r==="radio"?"radio":r==="number"||r==="range"?"number":r==="hidden"?"hidden":"text"}return e==="TEXTAREA"?"text":e==="SELECT"?t.multiple?"select-multiple":"select-one":"leaf"}function jn(t){if(t.validity&&t.validity.badInput)return t.hasAttribute("value")?Number(t.getAttribute("value"))||0:t._sapLastGood??0;if(t.value==="")return 0;let e=Number(t.value);return Number.isNaN(e)?t._sapLastGood??0:(t._sapLastGood=e,e)}function Je(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return jn(t);case"select-one":return t.value;case"select-multiple":return[...t.selectedOptions].map(r=>r.value);case"hidden":case"text":return t.value;case"leaf":return t.textContent;default:return t.value}}function Qe(t,e,r){switch(e){case"checkbox":t.checked=!!r;break;case"radio":t.checked=String(t.value)===String(r);break;case"number":case"text":case"hidden":t.value=r==null?"":String(r);break;case"select-one":t.value=r==null?"":String(r);break;case"select-multiple":{let n=new Set((Array.isArray(r)?r:[r]).map(String));for(let o of t.options)o.selected=n.has(o.value);break}case"leaf":t.textContent=r==null?"":String(r);break;default:t.value=r==null?"":String(r)}}function fe(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}Xt(t)||xt(t)}function Un(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function de(t,e){return Je(t,e)}function Ze(t,e,r){Qe(t,e,r),fe(t)}function G(t){let e=Kt(t);return{el:t,kind:e,read(){return Je(t,e)},write(r,n={}){Qe(t,e,r),n.noMirror||fe(t),n.silent||Un(t)},mirror(){fe(t)}}}var ot=null,Qt=!1,kt=null;function tn(t){let e=null;return{kind:"hub",subscribe(r){let n=t.onAnyChange({debounce:0,require:"observed"},r);typeof n=="function"&&(e=n)},suppress(r){t.pause();try{return r()}finally{t.resume()}},teardown(){if(e){try{e()}catch{}e=null}}}}function Gn(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(n=>e(Yn(n)));let r=typeof document<"u"&&document.body||typeof document<"u"&&document.documentElement;r&&t.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0})},suppress(e){let r=X("undo");r&&r.pause&&r.pause();try{return e()}finally{t&&t.takeRecords(),r&&r.resume&&r.resume()}},teardown(){t&&(t.disconnect(),t=null)}}}function Yn(t){let e=[];for(let r of t)if(r.type==="attributes"){let n=r.target;n&&n.nodeType===1&&!Jt(n)&&e.push({type:"attribute",element:n})}else if(r.type==="characterData"){let n=r.target&&r.target.parentElement;n&&!Jt(n)&&e.push({type:"characterData",element:n})}else if(r.type==="childList"){for(let n of r.addedNodes)if(!(n.nodeType!==1||Jt(n))&&(e.push({type:"add",element:n}),n.querySelectorAll))for(let o of n.querySelectorAll("*"))Jt(o)||e.push({type:"add",element:o});for(let n of r.removedNodes)n.nodeType===1&&e.push({type:"remove",element:n,parent:r.target})}return e}function Jt(t){return!!(t.closest&&t.closest("[sap-ignore],[template],[cms-template]"))}function Xn(t,e){t.pruneDisconnected();let r=new Set,n=!1;for(let o of e){let s=o.type==="remove"?o.parent:o.element,a=s&&t.appFor(s);a&&r.add(a),o.type==="add"&&o.element&&o.element.nodeType===1&&o.element.hasAttribute&&o.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(o.element))&&(n=!0)}n&&t.remountIfPresent();for(let o of r)o.root.isConnected&&t.schedule(o,"mutation")}function en(t){if(ot)return ot.suppress(t);let e=X("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function pe(t,e){Qt=!0,ot=t,t.subscribe(r=>Xn(e,r))}function me(t){if(Qt||typeof window>"u"||typeof document>"u")return;let e=X("Mutation");if(e&&typeof e.onAnyChange=="function"){pe(tn(e),t);return}typeof MutationObserver=="function"&&(pe(Gn(),t),kt=St(document,le,function(){let n=X("Mutation");n&&(kt(),kt=null,ot&&ot.teardown(),Qt=!1,pe(tn(n),t))}))}function nn(){if(ot)try{ot.teardown()}catch{}kt&&typeof document<"u"&&kt(),ot=null,Qt=!1,kt=null}var Kn=new Set(bt);function $t(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),ut(t.root,"loop");return}e.full&&We();let r=qe(t.root);try{en(()=>Jn(t,e))}finally{Ve(r)}t._viewsChanged&&(t._viewsChanged=!1,t.root.dispatchEvent(new CustomEvent("sap:views-updated",{bubbles:!0})))}function Jn(t,e){let r=t.root,n={},o=[],s=[],a=[],k=[],$=[],A=[],l=[],w=new Set;t.diag.errors=[];let N={root:n,state:n,item:null,ownerEl:r,projection:!1};function P(i,h){let f=h.attr||h.name,g=i.getAttribute(f);return g==null&&(g=Ct(h),$.push({el:i,name:h.name,attr:f,value:ie(ct(g,h.type),h.type)})),ct(g,h.type)}function z(i,h,f){let g=h.decls;if(g)for(let T of g){if(T.transient){f[T.name]=zt(i,T);continue}if(yt(i,T)){f[T.name]=i.hasAttribute(T.attr);continue}f[T.name]=P(i,T)}}function m(i,h,f){let g=h.bind,T=f.item||f.state,I=Kt(i);I==="radio"?(g in T||(T[g]=""),i.checked&&(T[g]=i.value)):T[g]=de(i,I),h.transient&&(i.removeAttribute("value"),i.removeAttribute("checked"))}function d(i,h,f){if(h.calcs){let g=f.item||f.state;for(let T of h.calcs)o.push({owner:g,ownerEl:f.ownerEl,name:T.name,entry:T.entry,def:T,el:i,ctx:f})}if(h.paints)for(let g of h.paints)g.kind==="when"&&w.add(g.field),s.push({def:g,el:i,ctx:f});if(h.effects)for(let g of h.effects)a.push({def:g,el:i,ctx:f});if(h.invalids)for(let g of h.invalids)k.push({def:g,el:i,ctx:f});if(h.bind!=null&&(f.view||f.projection)&&!qt(i)){let g=h.bind;f.view?wt(ke(f.item),g)?(i._sapViewBind="item",s.push({def:{kind:"projection",field:g,from:"item"},el:i,ctx:f})):g in f.state||g in f.root?(i._sapViewBind="drawn",s.push({def:{kind:"projection",field:g,from:"drawn"},el:i,ctx:f})):(i._sapViewBind=null,t.diag.error("E43",i,{attr:"bind",expr:g,problem:`bind="${g}" inside an each row matches no field of the row's record or of the scope the row is drawn in`,fix:"bind a field the record owns (bind, state= or items= on the [item]), or declare it with state= where the list is drawn"})):s.push({def:{kind:"projection",field:g,from:null},el:i,ctx:f})}}function p(i,h,f){Object.defineProperty(i,"$key",{value:Bt(h,"row"),enumerable:!1}),Object.defineProperty(i,"$index",{value:f,enumerable:!1}),Object.defineProperty(i,"$el",{value:h,enumerable:!1})}function y(i,h,f){let g=vt(i);z(i,g,h),i._sapScope=h,!f.projection&&g.bind!=null&&m(i,g,f),d(i,g,f),g.items?M(i,h,f):E(i,h,f)}function E(i,h,f){for(let g=i.firstElementChild;g;g=g.nextElementSibling)S(g,h,f)}function S(i,h,f){let g=vt(i);if(!g.inert){if(g.boundary){g.boundary==="scope"?_(i,h,f):g.boundary==="items"?(d(i,g,f),M(i,h,f)):g.boundary==="detail"?c(i,h,f):(d(i,g,f),l.push({el:i,ctx:f}));return}!f.projection&&!f.view&&g.bind!=null&&m(i,g,f),d(i,g,f);for(let T=i.firstElementChild;T;T=T.nextElementSibling)S(T,h,f)}}function _(i,h,f){let g=i.getAttribute("scope"),T={};h[g]=T;let I={root:f.root,state:T,item:null,ownerEl:i,projection:f.projection};y(i,T,I)}function M(i,h,f){let g=i.getAttribute("items"),T=[];h[g]=T,i._sapList=T;let I=0;for(let W=i.firstElementChild;W;W=W.nextElementSibling){let Y=vt(W);if(!Y.item||Y.template||W.hasAttribute("cms-template"))continue;let K={};p(K,W,I);let U={root:f.root,state:f.state,item:K,ownerEl:W,projection:f.projection};y(W,K,U),T.push(K),I++}}function H(i,h){let f=String(i).split("."),g=I=>{for(let W of f){if(I==null)return;I=Array.isArray(I)?I.flatMap(Y=>Y&&Y[W]!=null?Y[W]:[]):I[W]}return I},T=g(h.state);return T===void 0?g(h.root):T}function c(i,h,f){for(let g of V(i.getAttribute("state")||""))g.name in h||(h[g.name]=yt(i,g)?i.hasAttribute(g.attr):P(i,g));A.push({el:i,parentObj:h,ctx:f})}function u(i,h,f){i._sapScope=h;let g=i.getAttribute("detail")||"",T=/^([\w.]+)\s+by\s+(.+)$/.exec(g);if(!T){i.hidden=!0,i._sapDetailRow=null;return}let I=T[1],W=T[2].trim(),Y=H(I,f),K;try{K=Et(q(W),{state:h,item:f.item,el:i,root:f.root})}catch{K=void 0}let U=Array.isArray(Y)&&K!=null?Y.find(j=>j&&typeof j=="object"&&j.$el&&String(j.$key)===String(K)):null;if(i._sapDetailRow=U?U.$el:null,i.tagName==="DIALOG"){let j=U?String(U.$key):null;if(j!==i._sapDetailKey&&(i._sapDetailKey=j,i._sapDismissed=!1),!U){i._sapOpenedFor=null,i.open&&typeof i.close=="function"&&(i._sapEngineClose=!0,i.close());return}i.open?i._sapOpenedFor=j:(i._sapOpenedFor===j&&(i._sapDismissed=!0),i._sapOpenedFor=null,!i._sapDismissed&&i.isConnected&&typeof i.showModal=="function"&&(i.hidden&&(i.hidden=!1),i.showModal(),i._sapOpenedFor=j))}else{if(!U){i.hidden||(i.hidden=!0);return}i.hidden&&(i.hidden=!1)}ue();let at={root:f.root,state:h,item:U,ownerEl:U.$el,projection:!0};d(i,vt(i),at),E(i,U,at)}function b(i,h){for(let f=i.parentElement;f;f=f.parentElement)if(f._sapScope===h&&!f.hasAttribute("detail")||f.hasAttribute("sap"))return f;return r}function v(i,h){i._sapDrawnEl=b(i,h.state);let f=null;for(let B=i.firstElementChild;B;B=B.nextElementSibling)if(B.tagName==="TEMPLATE"){f=B;break}let g=f&&f.content.children.length===1?f.content.firstElementChild:null;if(!g)return t.diag.error("E42",i,{attr:"each",problem:"each needs one <template> child with exactly one element root"}),0;let T=i.getAttribute("each"),I;try{I=Et(q(T),{state:h.state,item:h.item,el:i,root:h.root})}catch(B){return t.diag.error("E24",i,{attr:"each",expr:T,problem:String(B.message)}),0}if(!Array.isArray(I))return t.diag.error("E40",i,{attr:"each",expr:T,problem:"each must evaluate to an array; the list keeps its last good rows"}),0;let W=q(i.getAttribute("key")||"item.$key"),Y=[],K=new Set;for(let B of I){let J;try{J=dt(W,h.state,B,i,h.root)}catch{J=void 0}let D=J==null?"":String(J);if(D===""||K.has(D))return t.diag.error("E41",i,{attr:"key",expr:W.src,problem:D===""?"an item has no key; the list keeps its last good rows":`duplicate key "${D}"; the list keeps its last good rows`}),0;K.add(D),Y.push(D)}let U=i._sapEach||new Map,at=new Map,j=0,ee=f;Y.forEach((B,J)=>{let D=U.get(B);if(!D||D.parentElement!==i){D=i.ownerDocument.importNode(g,!0);let _t=(D.getAttribute("clay")||"").split(/\s+/).filter(Boolean);_t.includes("editor-ui")||D.setAttribute("clay",[..._t,"editor-ui"].join(" ")),D._sapEachRow=!0,j++}D.getAttribute("data-key")!==B&&D.setAttribute("data-key",B),ee.nextElementSibling!==D&&(nr(i,D,ee),j++),D._sapEachItem=I[J],at.set(B,D),ee=D});for(let[B,J]of U)at.get(B)!==J&&J.parentElement===i&&(J.remove(),j++);return i._sapEach=at,ue(),Y.forEach((B,J)=>{let D=at.get(B),_t={root:h.root,state:h.state,item:I[J],ownerEl:D,projection:!1,view:!0};d(D,vt(D),_t),E(D,{},_t)}),j}y(r,n,N);for(let i=0;i<A.length;i++){let{el:h,parentObj:f,ctx:g}=A[i];u(h,f,g)}if($.length&&w.size)for(let i of $)w.has(i.attr)&&i.el.getAttribute(i.attr)==null&&i.el.setAttribute(i.attr,i.value);let x=new Map;for(let i of o){let h=x.get(i.owner);h||(h={ownerEl:i.ownerEl,list:[]},x.set(i.owner,h)),h.list.push(i)}let L=[...x.values()].sort((i,h)=>sn(h.ownerEl)-sn(i.ownerEl));for(let i of L){let h;try{h=Oe(i.list)}catch(f){t.diag.error("E07",i.list[0].el,{problem:f.message}),h=i.list}for(let f of h)try{f.owner[f.name]=dt(f.entry,f.ctx.state,f.ctx.item,f.el,f.ctx.root),Ft(f.el)}catch(g){f.owner[f.name]=void 0,t.diag.error("E24",f.el,{attr:"calc:"+f.name,expr:f.entry.src,problem:String(g.message)}),ut(f.el,g.sapCode||"E24")}}let C=0;for(let i=0;i<l.length;i++)C+=v(l[i].el,l[i].ctx);let R=0,F=C;for(let i of s){let h=Zn(i,t);i.ctx.view?F+=h:R+=h}for(let i of a)tr(i,t);for(let i of k)er(i);t._state=n,t._stats={fields:Object.keys(n).filter(i=>typeof n[i]!="function").length,calcs:o.length,paints:s.length,lists:x.size,writes:R,viewWrites:F},t._viewsChanged=F>0,t._lastPass={trigger:e.trigger||"refresh",writes:R},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${R}/${s.length}`)}function Qn(t){return t.kind==="text"?t.fmt?"text:"+t.fmt:"text":t.kind==="attr"?"attr:"+t.arg:t.kind==="class"?"class:"+t.arg:t.kind==="css"?"css:"+t.arg:t.kind==="when"?(t.match==="hide"?"hide-when:":t.match==="show-not"?"option-not:":"show-when:")+t.field:t.kind}function he(t,e,r,n){let o=t;for(;o&&o.nodeType===1;){if(o.hasAttribute&&o.hasAttribute(e)){let s=r.includes(o.getAttribute(e));if(n?!s:s)return!0}o=o.parentElement}return!1}function rn(t,e){if(t===t.ownerDocument.activeElement)return 0;if(t.type==="radio"){let s=e!=null&&String(t.value)===String(e);return t.checked===s?0:(t.checked=s,1)}let r=Kt(t),n=de(t,r),o=e??"";return String(n)!==String(o)?(Ze(t,r,o),1):0}function Zn(t,e){let r=t.def,n=t.el;if(r.kind==="projection"){if(r.from==="drawn"){let o=r.field in t.ctx.state?t.ctx.state:t.ctx.root;return rn(n,o[r.field])}return rn(n,t.ctx.item?t.ctx.item[r.field]:"")}if(r.kind==="when")return on(r,n,null);try{let o=dt(r.entry,t.ctx.state,t.ctx.item,n,t.ctx.root),s=on(r,n,o);return Ft(n),s}catch(o){return e.diag.error(o.sapCode==="E22"?"E22":"E24",n,{attr:Qn(r),expr:r.entry&&r.entry.src,problem:String(o.message)}),ut(n,o.sapCode||"E24"),0}}function on(t,e,r){switch(t.kind){case"text":{let n=t.fmt!=null?Me(t.fmt,r):r==null?"":String(r);return e.textContent!==n?(e.textContent=n,1):0}case"show":{let n=!r;return e.hidden!==n?(e.hidden=n,1):0}case"when":{let n=X("optionVisibility");if(n&&n._started)return e._sapWhen&&e.hidden?(e.hidden=!1,e._sapWhen=!1,1):0;let o;t.match==="hide"?o=!he(e,t.field,t.values,!1):t.match==="show-not"?o=he(e,t.field,t.values,!0):o=he(e,t.field,t.values,!1),e._sapWhen=!0;let s=!o;return e.hidden!==s?(e.hidden=s,1):0}case"attr":{let n=t.arg;if((n==="checked"||n==="selected")&&typeof e[n]=="boolean"&&!e.hasAttribute("bind")&&!e.closest("select[bind]")){let s=0;return e[n]!==!!r&&(e[n]=!!r,s=1),!!r!==e.hasAttribute(n)&&(r?e.setAttribute(n,""):e.removeAttribute(n),s=1),s}if(Kn.has(n)){let s=e.hasAttribute(n);return r&&!s?(e.setAttribute(n,""),1):!r&&s?(e.removeAttribute(n),1):0}let o=typeof r=="boolean"?String(r):r==null?"":String(r);return e.getAttribute(n)!==o?(e.setAttribute(n,o),1):0}case"class":{let n=!!r;return e.classList.contains(t.arg)!==n?(e.classList.toggle(t.arg,n),1):0}case"css":{let n=r==null?"":String(r);return e.style.getPropertyValue("--"+t.arg)!==n?(e.style.setProperty("--"+t.arg,n),1):0}default:return 0}}function tr(t,e){try{dt(t.def.entry,t.ctx.state,t.ctx.item,t.el,t.ctx.root),Ft(t.el)}catch(r){e.diag.error("E24",t.el,{attr:"effect",expr:t.def.entry&&t.def.entry.src,problem:String(r.message)}),ut(t.el,"E24")}}function er(t){let e="";try{let r=dt(t.def.entry,t.ctx.state,t.ctx.item,t.el,t.ctx.root);e=typeof r=="string"?r:""}catch{e=""}typeof t.el.setCustomValidity=="function"&&t.el.setCustomValidity(e)}function sn(t){let e=0,r=t;for(;r&&!(r.hasAttribute&&r.hasAttribute("sap"));)r=r.parentElement,e++;return e}function nr(t,e,r){let n=r.nextSibling;if(e.isConnected&&t.moveBefore)try{t.moveBefore(e,n);return}catch{}t.insertBefore(e,n)}var rr=new Set(bt),an=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode"]),or=new Set(["show-when","hide-when","option","option-not"]),ir=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,un=new Set(["sap","scope","items","item","template","bind","show","effect","invalid","detail","state","transient","confirm","default","persist","sortable","trigger-add","trigger-remove","trigger-reset","sap-ignore","sap-error","no-save","no-watch","no-undo","no-trigger-autosave","freeze","mutations-ignore","save-remove","save-ignore","save-freeze"]);function sr(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function be(t){return t.hasAttribute("bind")}function ar(t,e){e(t);for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(!n.hasAttribute("sap-ignore")){if(n.tagName==="TEMPLATE"){if(n.hasAttribute("items"))for(let o=n.content.firstElementChild;o;o=o.nextElementSibling)r(o);return}e(n);for(let o=n.firstElementChild;o;o=o.nextElementSibling)r(o)}}}function Zt(t,e){let r=!1,n=(a,k,$)=>{e.error(a,k,$),r=!0},o=t.ownerDocument.createTreeWalker(t,4),s;for(;s=o.nextNode();)if(/\{\{.*\}\}/.test(s.nodeValue||"")){n("E02",s.parentElement||t,{problem:"moustaches in text content are not a Sap feature",fix:'move the expression onto the element: text="state.x"'});break}return ar(t,a=>{let k=a.closest&&a.closest("[detail]");for(let $ of[...a.attributes]){let A=$.name,l=ve(A);if(l){n("E01",a,{attr:A,expr:$.value,problem:`"${A}" is a foreign-dialect attribute; Sap has no ${A.split(/[:=]/)[0]} directive`,fix:l+" \u2014 or wrap the subtree in sap-ignore if intentional"});continue}if(A.includes(":")){let N=A.slice(0,A.indexOf(":"));if(an.has(N)){if(or.has(N)&&ir.test($.value)){let P=A.slice(A.indexOf(":")+1);e.warn("W04",a,{attr:A,expr:$.value,problem:`${N}: compares the "${P}" attribute against a literal value, not a JS expression`,fix:`use show="${$.value}" for an expression, or a literal like ${N}:${P}="overview"`})}}else{let P=Nt(N,[...an]);e.warn("W03",a,{attr:A,problem:`unknown "${N}:" attribute`,didYouMean:P?`${P}:`:null})}}else if(!un.has(A)&&!Tt.has(A)&&!rr.has(A)&&!/^(data-|aria-|on)/.test(A)&&!(A in a)){let N=Nt(A,[...un]);N&&e.warn("W03",a,{attr:A,problem:`unknown "${A}" attribute`,didYouMean:N})}A==="attr:hidden"&&e.warn("W03",a,{attr:A,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'});let w=be(a)||A==="attr:selected"&&a.tagName==="OPTION"&&!!a.closest("select[bind]");(A==="attr:value"||A==="attr:checked"||A==="attr:selected")&&w&&n("E30",a,{attr:A,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),A==="effect"&&be(a)&&/\b(value|checked)\s*=[^=]/.test($.value)&&n("E30",a,{attr:A,expr:$.value,problem:"effect writes value/checked on a bound control (writes a stale value with no synthetic event)",fix:"write through onclick + Sap(this) instead"}),(A==="text"||A.startsWith("text:")||A==="show")&&sr(a)&&(A==="show"||n("E18",a,{attr:A,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(a.hasAttribute("state")){let $=V(a.getAttribute("state")),A=new Set;for(let l of $){l.name.includes("-")&&n("E08",a,{attr:"state",problem:`field "${l.name}" is not a valid identifier (the hyphen parses as subtraction)`,fix:`rename to ${l.name.replace(/-/g,"")}`}),A.has(l.name)&&n("E04",a,{attr:"state",problem:`field "${l.name}" is declared twice in one scope`}),A.add(l.name),It.has(l.attr)&&n("E05",a,{attr:"state",problem:`"${l.name}" is a reserved Sap word`}),Tt.has(l.attr)&&n("E06",a,{attr:"state",problem:`"${l.name}" is a global HTML attribute name; pick another field name`}),l.name==="open"&&a.tagName==="DIALOG"&&n("E33",a,{attr:"state",problem:"dialog open is transient",fix:"use showModal() \u2014 declare state= only on <details> or popovers"});let w=se(a,l.attr);w&&(l.attr==="checked"||l.attr==="selected")&&n("E35",a,{attr:"state",problem:`"${l.attr}" on a form control is the control's own state, not a declared field`,fix:'bind the control instead, e.g. <input type="checkbox" bind="done">'}),w&&l.type==="num"&&n("E35",a,{attr:"state",problem:`"${l.attr}" is an HTML boolean attribute; it cannot hold a number`,fix:`declare it bare: state="${l.attr}"`}),l.transient&&(w||l.type==="presence")&&n("E35",a,{attr:"state",problem:`"${l.name}" is carried by attribute presence, which transient would strip`,fix:"declare a separate name:bool:transient field and paint the attribute from it"})}}if(be(a)){if(a.hasAttribute("-"),a.tagName==="INPUT"){let $=(a.getAttribute("type")||"text").toLowerCase();$==="file"&&n("E32",a,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),$==="password"&&!a.hasAttribute("transient")&&n("E31",a,{attr:"bind",problem:"a password must never serialize into a world-readable file",fix:"add transient to the password input"})}else if(a.tagName!=="SELECT"&&a.tagName!=="TEXTAREA"){let $=a.getAttribute("contenteditable");!($!=null&&$!=="false")&&a.children.length>0&&n("E20",a,{attr:"bind",problem:"bind on a container element is not a control; a write would overwrite its children",fix:"bind a control (input/select/textarea), a contenteditable, or an empty text leaf"})}}if(a.hasAttribute("transient")&&a.hasAttribute("persist")&&n("E34",a,{problem:"transient and persist are opposite: persist forces the live value into the saved bytes, leaking exactly what transient drops",fix:"remove one \u2014 transient to keep it out of the file, or persist to save it"}),a.tagName==="DIALOG"&&a.hasAttribute("detail")&&!(a.parentElement&&a.parentElement.closest('[clay~="freeze"], [freeze], [save-freeze]'))&&e.warn("W31",a,{attr:"detail",problem:"a detail dialog writes open when it opens, and that attribute would be saved into the file",fix:'wrap the dialog in an element with clay="freeze" (not editor-ui, which removes it from the file), and make its key field transient'}),a.hasAttribute("item")&&!a.hasAttribute("template")&&a.parentNode&&a.parentNode.nodeType===1){let $=a.parentElement;(!$||!$.hasAttribute("items"))&&n("E10",a,{problem:"an [item] must be a direct child of an [items] list",fix:'wrap it in a container with items="name"'})}if(a.hasAttribute("items")&&k&&n("E17",a,{attr:"items",problem:"nested items inside a detail panel is a v1 mount error (nested collections ship in v1.1)"}),a.hasAttribute("items")){let $=t.querySelector(`[trigger-add="${a.getAttribute("items")}"]`);!Vt(a)&&!oe(t,a.getAttribute("items"))&&rt(a).length===0&&$&&n("E17",a,{attr:"items",problem:`trigger-add targets items="${a.getAttribute("items")}" but it has no [item template] to clone`})}}),r&&(e.halted=!0,e.haltReason=e.errors[0]?e.errors[0].code:"halt",ut(t,e.haltReason)),!r}var cn="sap-styles",ln="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",ge=new WeakSet;function ur(t){if(ge.has(t))return;let e=t.defaultView,r=e&&e.CSSStyleSheet;if(r&&"adoptedStyleSheets"in t)try{let n=new r;n.replaceSync(ln),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],ge.add(t);return}catch{}if(!t.getElementById(cn)){let n=t.createElement("style");n.id=cn,n.textContent=ln,(t.head||t.documentElement).appendChild(n)}ge.add(t)}var cr=0;function fn(){return typeof performance<"u"&&performance.now?performance.now():0}function we(t){let e=t.id||t.getAttribute("sap")||`app-${cr++}`,r=new ht(e),n={root:t,name:e,diag:r,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Zt(t,r))return n.halted=!0,n;ur(t.ownerDocument);for(let a of t.querySelectorAll("textarea[data-value]"))Yt(a);let s=fn();return $t(n,{trigger:"mount",full:!0}),n._mountMs=fn()-s,n._mountWrites=n._stats?n._stats.writes:0,n._mountWrites>0&&!Ue()&&r.warn("W30",t,{problem:`${n._mountWrites} paint(s) ran at mount; the saved file was out of sync with its declared state`,fix:"re-save once so the file mounts clean (a settled file writes nothing)"}),n}var lr=["for","form","list","headers","popovertarget","commandfor","anchor","aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"];function fr(t,e){let r=null;return et(t,n=>{!r&&n.getAttribute("scope")===e&&(r=n)}),r}function dn(t,e,r){let n=Q(t)||e;for(;n;){for(let o of V(n.getAttribute("state")||""))if(o.name===r)return{el:n,decl:o};if(n.hasAttribute("sap"))break;n=Q(n.parentElement)}return null}function dr(t){return typeof t=="number"?"num":typeof t=="boolean"?"bool":"string"}function pn(t){function e(m){let d=t.appFor(m);if(!d)return null;let p=lt(m),y=p&&p._sapEachItem&&p._sapEachItem.$el;if(y&&y.isConnected)return{ctxEl:y,appRec:d,isRow:!0};let E=Lt(m);if(E)return E._sapDetailRow?{ctxEl:E._sapDetailRow,appRec:d,isRow:!0}:{ctxEl:Q(E.parentElement)||d.root,appRec:d,isRow:!1};let S=Wt(m);if(S&&S.hasAttribute("item"))return{ctxEl:S,appRec:d,isRow:!0};let _=Q(m)||d.root;return{ctxEl:_,appRec:d,isRow:_.hasAttribute("item")}}function r(m){let d=typeof m=="string"?document.querySelector(m):m;if(!d||d.nodeType!==1)return null;let p=e(d);return p?z(p.ctxEl,p.appRec,p.isRow):null}function n(m,d){let p=lt(m);if(!p)return r(m);let y=t.appFor(m),E=p._sapEachItem&&p._sapEachItem.$el;if(E&&E.nodeType===1&&E.hasAttribute("item")&&wt(E,d))return E.isConnected?z(E,y,!0):null;let S=p.parentElement&&p.parentElement._sapDrawnEl;return!S||!S.isConnected?null:z(S,y,S.hasAttribute("item"))}function o(m,d,p){let y=ft(m,p);if(y)return G(y).read();let E=gt(m,p);if(E)return rt(E).map(H=>z(H,d,!0));let S=fr(m,p);if(S)return z(S,d,!1);let _=dn(m,d.root,p);if(_)return _.decl.transient?zt(_.el,_.decl):$e(_.el,_.decl);let M=m._sapScope;return M?M[p]:void 0}function s(m,d,p,y,E){y.transient?Dt(m,y,p):Rt(m,y,p),t.schedule(E,"set:"+d)}function a(m,d){let p=new Set,y=Q(m)||d;for(;y;){for(let E of V(y.getAttribute("state")||""))p.add(E.name);if(y.hasAttribute("sap"))break;y=Q(y.parentElement)}return et(m,E=>{let S=E.getAttribute("bind");S&&p.add(S)}),p}function k(m,d,p,y){let E=ft(m,p);if(E){G(E).write(y);return}let S=m;for(;S;){for(let x of S.attributes)if(x.name==="calc:"+p){d.diag.error("E16",S,{attr:"calc:"+p,problem:`"${p}" is a computed field; computed fields are read-only`});return}if(S.hasAttribute("sap"))break;S=S.parentElement}let _=dn(m,d.root,p);if(_){s(_.el,p,y,_.decl,d);return}let M=a(m,d.root);M.delete(p);let H=p.length>=4?Nt(p,[...M]):null;if(H){d.diag.error("E12",m,{key:p,problem:`unknown state key "${p}"`,didYouMean:H});return}if(It.has(p)||Tt.has(p)){d.diag.error("E15",m,{key:p,problem:`cannot write undeclared field "${p}" \u2014 it is a reserved/global name and cannot become state`,fix:"pick a different field name, or declare it explicitly in a state= attribute"});return}let c=d.root,u=dr(y),b=c.getAttribute("state")||"",v=u==="string"?p:`${p}:${u}`;c.setAttribute("state",b?`${b} ${v}`:v),s(c,p,y,{name:p,attr:p,type:u,transient:!1},d)}function $(m){let d=m.ownerDocument,p=new Map,y=(E,S)=>{let _=Se(d),M=E.getAttribute(S);M&&S==="id"&&p.set(M,_),E.setAttribute(S,_)};m.querySelectorAll("[id]").forEach(E=>y(E,"id")),m.querySelectorAll("[data-id]").forEach(E=>y(E,"data-id")),m.querySelectorAll("[sap-error]").forEach(E=>E.removeAttribute("sap-error")),m.removeAttribute("sap-error"),m.hasAttribute("data-id")?(m.removeAttribute("id"),y(m,"data-id")):y(m,"id");for(let E of[m,...m.querySelectorAll("*")])for(let S of lr){let _=E.getAttribute(S);if(_==null)continue;let M=_.split(/\s+/).map(H=>p.get(H)||H).join(" ");M!==_&&E.setAttribute(S,M)}}function A(m,d,p){let y=Mt(d.root,m,p);if(!y)return d.diag.error("E17",m,{problem:`cannot resolve a list named "${p}" from here`}),null;let E=Vt(y);if(!E)return d.diag.error("E17",y,{problem:`items="${p}" has no [item template] to clone`}),null;let S=y.ownerDocument.importNode(E,!0);return S.removeAttribute("template"),$(S),y.appendChild(S),t.schedule(d,"trigger-add:"+p),z(S,d,!0)}function l(m,d){et(m,p=>{if(p.hasAttribute("bind")){let y=G(p),E=p.getAttribute("default");y.kind==="checkbox"||y.kind==="radio"?y.write(E!=null?E===""||E==="true"||p.value===E:p.hasAttribute("checked")):y.write(E??(p.getAttribute("value")||""))}});for(let p of V(m.getAttribute("state")||"")){let y=_e(m,p);p.transient?Dt(m,p,y):Rt(m,p,y)}t.schedule(d,"trigger-reset")}function w(m,d){if(!m.isConnected)throw new Error("stale row handle: $remove() on a removed row");m.remove(),t.schedule(d,"trigger-remove")}function N(m,d,p){if(!m.isConnected)throw new Error("stale row handle: $move() on a removed row");let y=null;if(p&&p.nodeType===1?y=p:typeof p=="string"&&(y=Mt(d.root,m,p)),!y){d.diag.error("E17",m,{problem:`$move() cannot resolve target "${p}"`});return}t.moveInto(y,m),t.schedule(d,"trigger-move")}function P(m){let d=m.parentElement;return d?rt(d).indexOf(m):-1}function z(m,d,p){let y={get $el(){return m},get $key(){return Bt(m,p?"row":"scope")},get $index(){return P(m)},$add(S){return A(m,d,S)},$reset(){return l(m,d),E},$remove(){w(m,d)},$move(S){N(m,d,S)},get $appRec(){return d}},E=new Proxy(y,{get(S,_){return typeof _=="symbol"||_[0]==="$"?S[_]:o(m,d,_)},set(S,_,M){return typeof _=="string"&&_[0]==="$"?(S[_]=M,!0):(k(m,d,_,M),!0)},has(S,_){return typeof _=="string"&&_[0]==="$"?_ in S:o(m,d,_)!==void 0}});return E}return{Sap:r,contextElFor:e,readField:o,writeField:k,makeProxy:z,writeTargetFor:n}}var pr=["trigger-add","trigger-remove","trigger-reset"];function mr(t){if(t.nodeType!==1)return!1;for(let e of t.attributes){let r=e.name;if(r.startsWith("set:")||r.startsWith("move:")||r.startsWith("sort:")||pr.includes(r))return!0}return!1}function hr(t,e){let r=t,n=e.parentElement;for(;r&&r!==n;){if(r.nodeType===1&&mr(r)&&!(r.tagName==="FORM"&&r.hasAttribute("trigger-add")))return r;r=r.parentElement}return null}function mn(t,e){let{Sap:r}=e;function n(c,u){let b=null,v=lt(c),x=Lt(c);if(v)b=v._sapEachItem??null;else if(x&&x._sapDetailRow)b=x._sapDetailRow._sapScope||null;else{let R=Wt(c);R&&R.hasAttribute("item")&&(b=R._sapScope||null)}return{state:(Q(c)||u.root)._sapScope||u._state||{},item:b,el:c,root:u._state||{}}}function o(c,u,b){if(!c.hasAttribute("confirm")){b();return}let v=c.getAttribute("confirm"),x=v,L=q(v);if(!L.error)try{let F=Et(L,n(c,u));(typeof F=="string"||typeof F=="number")&&(x=String(F))}catch{}let C=Ye();if(!C){window.confirm(x)&&b();return}if(c._sapGatePending)return;c._sapGatePending=!0;let R=()=>{c._sapGatePending=!1};C(x,()=>{R(),b()}).catch(R)}function s(c,u){for(let b of c.attributes){if(!b.name.startsWith("set:"))continue;let v=b.name.slice(4),x=q(b.value);if(x.error){u.diag.error("E08",c,{attr:b.name,expr:b.value,problem:String(x.error.message)});continue}let L;try{L=Et(x,n(c,u))}catch(R){u.diag.error("E24",c,{attr:b.name,expr:b.value,problem:String(R.message)});continue}let C=e.writeTargetFor(c,v);C&&(C[v]=L)}}function a(c){let u=lt(c);if(!u)return c.closest("[item]");let b=u._sapEachItem&&u._sapEachItem.$el;return b&&b.nodeType===1&&b.hasAttribute("item")?b:null}function k(c,u){let b=a(c);if(!b)return;let v=rt(b.parentElement),x=v.indexOf(b);u==="up"&&x>0?t.placeBefore(b,v[x-1]):u==="down"&&x<v.length-1&&t.placeBefore(v[x+1],b)}function $(c,u,b){if(u)return Mt(b.root,c,u);let v=c;for(;v;){if(v.hasAttribute&&v.hasAttribute("items"))return v;v=v.parentElement}let x=Q(c)||b.root,L=[];return et(x,C=>{C.hasAttribute("items")&&L.push(C)}),L[0]||null}function A(c,u){let b=c==null||c==="",v=u==null||u==="";if(b&&v)return 0;if(b)return 1;if(v)return-1;let x=Number(c),L=Number(u);return!Number.isNaN(x)&&!Number.isNaN(L)?x-L:String(c)<String(u)?-1:String(c)>String(u)?1:0}function l(c,u,b,v){let x=$(c,b,v);if(!x){v.diag.error("E17",c,{attr:"sort:"+u,problem:`no items list resolvable for sort:${u}`});return}let L=rt(x),C=h=>h._sapScope?h._sapScope[u]:void 0,R=[...L].sort((h,f)=>A(C(h),C(f))),i=R.every((h,f)=>h===L[f])?[...R].reverse():R;for(let h of i)t.moveInto(x,h);t.schedule(v,"sort:"+u)}function w(c){if(!c||c.hidden)return;let u=c.querySelector("[bind]:not([type=hidden]), [contenteditable]");u&&typeof u.focus=="function"&&u.focus()}function N(c,u){o(c,u,()=>{let b=r(c);for(let v of[...c.attributes]){let x=v.name;if(x==="trigger-remove")b&&b.$remove();else if(x==="trigger-reset")b&&b.$reset();else if(x==="trigger-add"){let L=b&&b.$add(v.value);L&&w(L.$el)}else x==="move:up"?(k(c,"up"),t.schedule(u,"move:up")):x==="move:down"?(k(c,"down"),t.schedule(u,"move:down")):x.startsWith("move:to")?b&&b.$move(v.value):x.startsWith("sort:")&&l(c,x.slice(5),v.value,u)}[...c.attributes].some(v=>v.name.startsWith("set:"))&&s(c,u)})}function P(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;let v=hr(u,b.root);v&&N(v,b)}function z(c){let u=G(c),b=c.getAttribute("default");u.kind==="checkbox"?u.write(b===""||b==="true"):u.write(b??"")}function m(c,u,b){let v=r(c);if(!v)return;let x=v.$add(b);if(!x)return;let L=[];et(c,C=>{C.hasAttribute("bind")&&L.push(C)});for(let C of L){if(C.type==="radio"&&!C.checked)continue;let R=C.getAttribute("bind"),F=ft(x.$el,R);F?G(F).write(G(C).read()):wt(x.$el,R)&&(x[R]=G(C).read())}L.forEach(z),L.length?typeof L[0].focus=="function"&&L[0].focus():w(x.$el)}function d(c){let u=c.target;if(!u||!u.hasAttribute||!u.hasAttribute("trigger-add"))return;let b=t.appFor(u);b&&(c.preventDefault(),o(u,b,()=>m(u,b,u.getAttribute("trigger-add"))))}function p(c){let u=c.target,b=t.appFor(u);b&&setTimeout(()=>{u.querySelectorAll("[bind]").forEach(v=>{v.dispatchEvent(new Event("input",{bubbles:!0})),v.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(b,"reset")},0)}function y(c){let u=t.appFor(c.target);u&&t.schedule(u,"toggle")}function E(c){let u=c.target;if(!u||u.tagName!=="DIALOG"||!u.hasAttribute("detail"))return;if(u._sapEngineClose){u._sapEngineClose=!1;return}if(u.open)return;let b=/^[\w.]+\s+by\s+state\.(\w+)\s*$/.exec(u.getAttribute("detail")||""),v=t.appFor(u);if(!b||!v)return;let x=V(u.getAttribute("state")||"").find(C=>C.name===b[1]);if(x){x.transient?Dt(u,x,""):Rt(u,x,""),t.schedule(v,"close");return}let L=r(u.parentElement);L&&L[b[1]]!==""&&(L[b[1]]="")}function S(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;u.hasAttribute("persist")&&!Xt(u)&&xt(u);let v=u.hasAttribute("bind")&&qt(u);if(!v&&u.hasAttribute("bind")&<(u)){let L=u.getAttribute("bind"),C=u._sapViewBind?e.writeTargetFor(u,L):null;C&&(C[L]=G(u).read());return}let x=Lt(u);if(x&&x._sapDetailRow&&u.hasAttribute("bind")&&!v){let L=x._sapDetailRow,C=u.getAttribute("bind"),R=ft(L,C);if(R&&R!==u){G(R).write(G(u).read());return}if(!R&&V(L.getAttribute("state")||"").some(F=>F.name===C)){e.writeField(L,b,C,G(u).read());return}}t.schedule(b,c.type+" "+(u.id||u.tagName.toLowerCase()))}function _(c){let u=c.detail||{};for(let b of[u.from,u.to,c.target]){if(!b||b.nodeType!==1)continue;let v=t.appFor(b);v&&t.schedule(v,"sorted")}}function M(c){if(c.key!=="ArrowUp"&&c.key!=="ArrowDown")return;let u=c.target;if(!u||u.nodeType!==1||u.tagName!=="INPUT"||!u.hasAttribute("bind")||!u.hasAttribute("step"))return;let b=(u.getAttribute("type")||"text").toLowerCase();if(b!=="text"&&b!=="tel"&&b!=="search"||!t.appFor(u))return;c.preventDefault();let x=Z(u.getAttribute("step"))||1,L=c.key==="ArrowUp"?1:-1,C=Z(u.value)+x*(c.shiftKey?10:1)*L,R=u.getAttribute("min"),F=u.getAttribute("max");R!==null&&R!==""&&C<Z(R)&&(C=Z(R)),F!==null&&F!==""&&C>Z(F)&&(C=Z(F)),G(u).write(String(Number(C.toFixed(2))))}function H(c=document){c.addEventListener("click",P),c.addEventListener("submit",d),c.addEventListener("reset",p),c.addEventListener("toggle",y,!0),c.addEventListener("close",E,!0),c.addEventListener("input",S),c.addEventListener("change",S),c.addEventListener("clay:sorted",_),c.addEventListener("keydown",M)}return{install:H}}var hn=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function ye(t){return`${t.tagName.toLowerCase()}[sap]`}function br(t){let e=0;for(let r of t.querySelectorAll("*"))for(let n of r.attributes)if(hn.test(n.name)){e++;break}for(let r of t.attributes)if(hn.test(r.name)){e++;break}return e}function bn(t){let e=[],r=n=>{for(let o of n.attributes){let s=o.name;(s.startsWith("calc:")||s==="text"||s.startsWith("text:")||s==="show"||s.startsWith("attr:")||s.startsWith("class:")||s.startsWith("css:")||s==="effect"||s==="invalid"||s.startsWith("set:")||s==="detail")&&e.push({el:n,attr:s,src:o.value})}};r(t);for(let n of t.querySelectorAll("*"))r(n);return e}function gn(t){function e(l){let w=l._stats||{},N=l.root;return{root:ye(N),fields:w.fields||0,calcs:w.calcs||0,paints:w.paints||0,actions:br(N),lists:(N.hasAttribute("items")?1:0)+N.querySelectorAll("[items]").length,rows:N.querySelectorAll("[item]:not([template])").length,warnings:l.diag.warnings.length,errors:l.diag.errors.length,mountWrites:l._mountWrites||0,ms:Math.round((l._mountMs||0)*10)/10,passes:l._passes||0,lastPass:l._lastPass||null,ok:l.diag.errors.length===0&&!l.halted}}function r(){let l=t.apps().map(e);return{ok:l.every(w=>w.ok),apps:l}}function n(l){let w=e(l);return w.ok?`sap \u2713 ${w.root} \xB7 fields ${w.fields} \xB7 calcs ${w.calcs} \xB7 paints ${w.paints} \xB7 actions ${w.actions} \xB7 lists ${w.lists} \xB7 rows ${w.rows} \xB7 warnings ${w.warnings} \xB7 mount writes ${w.mountWrites} \xB7 ${w.ms}ms`:`sap \u2717 ${w.root} \xB7 errors ${w.errors} \xB7 warnings ${w.warnings} \xB7 ${w.ms}ms`}function o(){for(let l of t.apps()){let w=n(l);l.diag.errors.length||l.halted?console.error(w):console.log(w)}}function s(){let l=[],w=[];for(let N of t.apps())l.push(...N.diag.errors),w.push(...N.diag.warnings);return{ok:l.length===0,errors:l,warnings:w,counts:{errors:l.length,warnings:w.length}}}function a(l){return l?typeof l=="string"?document.querySelector(l):l.nodeType===1?l:null:null}function k(l,w){let N=a(l);if(!N)return console.warn("sap why: element not found"),null;let P=[`sap why <${N.tagName.toLowerCase()}> \u2014 ${Ot(N)}`],z=[...N.attributes].filter(d=>/^(bind|text|show|effect|invalid|detail|calc:|text:|attr:|class:|css:|set:|state|items|scope)/.test(d.name));for(let d of z)P.push(` ${d.name}="${d.value}"`);let m=N;for(;m&&!m._sapScope;)m=m.parentElement;if(m&&m._sapScope){let d=m._sapScope,p=w?[w]:Object.keys(d);P.push(" reads:");for(let y of p){let E=d[y];typeof E!="function"&&P.push(` ${y} = ${JSON.stringify(Array.isArray(E)?`[${E.length} rows]`:E)}`)}}return P.push(" serialization: textContent and value/checked attributes save with the file; reads live from properties"),console.log(P.join(`
|
|
10
|
+
`)),null}function $(l){let w=l===void 0?!0:!!l;for(let N of t.apps())N._debug=w;return console.log(`sap debug ${w?"on":"off"} \u2014 per-pass headers will ${w?"":"no longer "}log`),w}function A(){let l=[],w=0;for(let d of t.apps()){let p=d.root,y=ye(p);w++;let E=new ht(d.name);Zt(p,E);for(let c of E.errors)l.push({code:c.code,severity:"error",message:`${y}: ${c.code} ${c.slug} at ${c.el}`});for(let c of E.warnings)l.push({code:c.code,severity:"warn",message:`${y}: ${c.code} ${c.slug} at ${c.el}`});w++,$t(d,{trigger:"doctor-dryrun"});let S=d._stats?d._stats.writes:0;S>0&&l.push({code:"W30",severity:"warn",message:`${y}: dry recompute wrote ${S} cells on a quiet page; an element is stale or non-idempotent`}),w++;let _=bn(p).map(c=>c.src).join(" \0 "),M=[];for(let c of[p,...p.querySelectorAll("[state]")])for(let u of V(c.getAttribute("state")||""))M.push(u.name);for(let c of M)new RegExp(`(state|item)\\.${c}\\b`).test(_)||l.push({code:"I33",severity:"info",message:`${y}: field "${c}" is declared but read nowhere (dead state)`});w++;let H=new Map;for(let c of p.querySelectorAll("[id]"))H.set(c.id,(H.get(c.id)||0)+1);for(let[c,u]of H)u>1&&l.push({code:"W32",severity:"warn",message:`${y}: duplicate id "${c}" (${u} elements) \u2014 clone/edit collision`});w++;for(let c of bn(p))c.src.length>120&&l.push({code:"I33",severity:"info",message:`${y}: ${c.attr} expression is ${c.src.length} chars; consider a calc: field`});w++;for(let c of p.querySelectorAll("[text], [text\\:num]")){let u=c.textContent||"";/\.\d{5,}/.test(u)&&l.push({code:"I33",severity:"info",message:`${y}: ${Ot(c)} paints >4 decimals; consider text:FMT`})}}let N=l.filter(d=>d.severity==="error").length,P=l.filter(d=>d.severity==="warn").length,z=l.filter(d=>d.severity==="info").length;console.log(`sap doctor \xB7 ${t.apps().map(d=>ye(d.root)).join(", ")} \xB7 errors ${N} \xB7 warnings ${P} \xB7 info ${z} \xB7 ${w} checks \xB7 0ms`);for(let d of l)(d.severity==="error"?console.error:d.severity==="warn"?console.warn:console.info)(` ${d.severity==="error"?"\u2717":d.severity==="warn"?"\u26A0":"\xB7"} ${d.message}`);return l}return{status:r,report:s,why:k,debug:$,doctor:A,greenLine:n,printGreenLines:o,REGISTRY:re}}var wn="0.5.2";var tt=new Map,it=[],Ae=Ee($t);function gr(t){let e=t;for(;e;){if(e.nodeType===1&&e.hasAttribute&&e.hasAttribute("sap"))return tt.get(e)||null;e=e.parentNode&&e.parentNode.host?e.parentNode.host:e.parentElement}return null}function wr(){for(let t=it.length-1;t>=0;t--){let e=it[t];e.root.isConnected||(tt.delete(e.root),it.splice(t,1))}}function yr(t,e){if(t.moveBefore)try{t.moveBefore(e,null);return}catch{}t.appendChild(e)}function Ar(t,e){let r=e.parentElement;if(r){if(r.moveBefore)try{r.moveBefore(t,e);return}catch{}r.insertBefore(t,e)}}var mt={apps:()=>it.slice(),appFor:gr,isRegistered:t=>tt.has(t),pruneDisconnected:wr,schedule:(t,e)=>Ae.schedule(t,e),runNow:(t,e)=>Ae.runNow(t,e),moveInto:yr,placeBefore:Ar,remountIfPresent:()=>te()},An=pn(mt),Er=mn(mt,An),st=gn(mt),yn=!1;function En(){yn||(yn=!0,Er.install(document),Ke(mt))}function te(t=document){En(),me(mt);let e=t.querySelectorAll("[sap]"),r=[];for(let n of e){if(tt.has(n))continue;let o=we(n);tt.set(n,o),it.push(o),r.push(o)}for(let n of r){let o=st.greenLine(n);n.diag.errors.length||n.halted?console.error(o):console.log(o)}return r}function vn(t){if(En(),me(mt),!t)return te();let e=typeof t=="string"?document.querySelector(t):t;if(!e)return null;if(tt.has(e))return tt.get(e);let r=we(e);tt.set(e,r),it.push(r);let n=st.greenLine(r);return r.diag.errors.length||r.halted?console.error(n):console.log(n),r}var O=An.Sap;O.version=wn;O.refresh=function(){for(let e of it)e.root.isConnected&&Ae.runNow(e,"refresh")};O.batch=Xe;O.status=st.status;O.report=st.report;O.why=st.why;O.debug=st.debug;O.doctor=st.doctor;O.greenLine=st.greenLine;O.formats=At;O.serializeControlToAttributes=xt;O.finalizeControlForSave=je;O.rehydrateControlFromAttributes=Yt;O.mount=vn;O.config=function(e={}){return e.formats&&Object.assign(At,e.formats),O};O._registry=tt;O._reset=function(){tt.clear(),it.length=0,nn()};function vr(){if(typeof document>"u")return;let t=()=>Ge(()=>te());document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}vr();typeof window<"u"&&(window.Sap=O);var xr=O;return Tn(Sr);})();
|
|
11
11
|
if (typeof window !== 'undefined' && Sap && Sap.default) window.Sap = Sap.default;
|
|
12
12
|
var sapDefault = Sap.default;
|
|
13
13
|
window.clay = window.clay || {};
|