@panphora/clayjs 1.11.2 → 1.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clay.standalone.js +5561 -5277
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +6 -6
- package/package.json +1 -1
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +21 -21
- package/src/vendor/richclay.vendor.js +15 -15
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 Q=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var Ee=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},Je=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Fe(t))!Ve.call(e,r)&&r!==n&&Q(e,r,{get:()=>t[r],enumerable:!(o=Ke(t,r))||o.enumerable});return e};var Ye=e=>Je(Q({},"__esModule",{value:!0}),e);var Mt={};Ee(Mt,{applyData:()=>ge,default:()=>Nt,engine:()=>Y,extractData:()=>ye});var G=["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"],ee=new Set(G),Te=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"]);var R={};Ee(R,{EmptyListInsert:()=>v,MAX_RULE_DEPTH:()=>j,MaxRuleDepthExceeded:()=>I,NoRulesTag:()=>te,RuleTargetReadOnly:()=>H,RulesParseError:()=>P,ShapeMismatch:()=>W,UnknownRulesVersion:()=>$,WriteRefused:()=>q,WriteRejected:()=>ne});var P=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},$=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},j=20,I=class extends Error{constructor(t){super(`rule depth exceeded ${j} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},W=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},v=class extends Error{constructor(t){super(`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}},H=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},q=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},te=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ne=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 S(e){let t=0,n=null,o=-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&&(o=r)}return o}function re(e){let t=S(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function M(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return oe(e,t,n,{depth:0,path:[]},o)}function oe(e,t,n,o,r){if(o.depth>j)throw new I(o.path);if(typeof n=="string")return Ge(e,t,n,o,r);if(Array.isArray(n)){let[s,l]=n,c=e.find(t,s,r);return Oe(r,o,c),c.map((i,f)=>oe(e,i,l,{depth:o.depth+1,path:[...o.path,f]},r))}if(typeof n=="object"&&n!==null){let s={};for(let[l,c]of Object.entries(n))s[l]=oe(e,t,c,{depth:o.depth+1,path:[...o.path,l]},r);return s}return null}function Ge(e,t,n,o,r){if(n.endsWith("[]")){let c=n.slice(0,-2),i=e.find(t,c,r);return Oe(r,o,i),i.map(f=>e.text(f))}if(n.startsWith("@"))return Ae(e,t,n.slice(1));let s=S(n);if(s!==-1){let c=n.slice(0,s),i=n.slice(s+1),f=c?e.find(t,c,r):[t];return f.length===0?null:Ae(e,f[0],i)}if(n===".")return e.text(t);let l=e.find(t,n,r);return l.length===0?null:e.text(l[0])}function Oe(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function Ae(e,t,n){if(ee.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}function Se(e,t,n,o){let r=e.length,s=t.length,l=new Array(r).fill(-1);if(o){let a=new Set;for(let m=0;m<r;m++){let g=o[m];!(g>=0&&g<s)||a.has(g)||(l[m]=g,a.add(g))}}if(r===0||s===0)return l;let c=e.map(a=>xe(a,n)),i=t.map(a=>xe(a,n)),f=new Array(s).fill(!1);for(let a of l)a>=0&&(f[a]=!0);let u=new Map;i.forEach((a,m)=>{f[m]||u.set(a,u.has(a)?-1:m)});let p=new Map;c.forEach((a,m)=>{l[m]>=0||p.set(a,(p.get(a)||0)+1)}),c.forEach((a,m)=>{if(l[m]>=0||p.get(a)!==1)return;let g=u.get(a);g===void 0||g===-1||f[g]||(l[m]=g,f[g]=!0)});let d=[];for(let a=0;a<r;a++)l[a]<0&&d.push(a);let w=[];for(let a=0;a<s;a++)f[a]||w.push(a);if(d.length===0||w.length===0)return l;let h=r*s+1,y=(a,m)=>Xe(e[a],t[m],n)*h+Math.abs(a-m);for(let[a,m]of Ze(d,w,y))l[a]=m;return l}var Re=e=>typeof e=="object"&&e!==null;function xe(e,t){if(!Re(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function Xe(e,t,n){if(!Re(n))return e===t?0:1;let o=Object.keys(n);if(o.length===0)return 0;let r=0;for(let s of o){let l=JSON.stringify(e?.[s]),c=JSON.stringify(t?.[s]);l!==c&&r++}return r}function Ze(e,t,n){return e.length<=t.length?be(e,t,n,!1):be(t,e,(o,r)=>n(r,o),!0)}function be(e,t,n,o){let r=e.length,s=t.length,l=[];for(let p=0;p<=r;p++)l.push(new Float64Array(s+1).fill(1/0));let c=[];for(let p=0;p<=r;p++)c.push(new Uint8Array(s+1));for(let p=0;p<=s;p++)l[r][p]=0;for(let p=r-1;p>=0;p--)for(let d=s-1;d>=0;d--){let w=n(e[p],t[d])+l[p+1][d+1],h=l[p][d+1];w<=h?(l[p][d]=w,c[p][d]=1):l[p][d]=h}let i=[],f=0,u=0;for(;f<r&&u<s;)c[f][u]&&(i.push(o?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return i}function se(e,t,n,o,r,s,l,c={}){let i=e.find(t,n,c);if(r.length===0){i.forEach(E=>e.remove(E)),ie(c,"onRowsApplied",s.path,[]);return}let f=r.length>i.length,u=i[0]||null;if(f&&!u&&(u=nt(e,t,n,c),!u))throw new v(s.path);let p=i.map(E=>tt(e,E,o,c)),d=null;if(f&&u){d=e.clone(u),c.templateAttr&&e.removeAttr(d,c.templateAttr);let E=e.stripIds(d);E>0&&console.warn(`[hyper-html-api] stripped ${E} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let w=Se(r,p,o,Qe(e,i,r,s,c)),h=i[0]||u,y=e.parent(h),a=i.length>0?Ne(e,y,h):0,m=rt(e,i),g=new Set,x=[],O=r.map((E,A)=>{let T=w[A];if(T>=0)return g.add(T),x.push(!1),i[T];x.push(!0);let N=e.clone(d);return e.stripIds(N),N});i.forEach((E,A)=>{g.has(A)||e.remove(E)}),m?O.forEach((E,A)=>{let T=a+A;e.children(y).findIndex(ze=>e.sameNode(ze,E))!==T&&e.insertAt(y,E,T)}):ot(e,O,x,y,a),et(e,O,o,r,s,l,c),ie(c,"onRowsApplied",s.path,O)}function ie(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Qe(e,t,n,o,r){let s=ie(r,"identifyRows",o.path,n);if(!Array.isArray(s))return null;let l=new Array(n.length).fill(-1),c=new Set;for(let i=0;i<n.length;i++)if(s[i]){for(let f=0;f<t.length;f++)if(!(c.has(f)||!e.sameNode(t[f],s[i]))){l[i]=f,c.add(f);break}}return l}function et(e,t,n,o,r,s,l){t.forEach((c,i)=>{if(n===null){let f=o[i],u=f==null?"":String(f);e.text(c)!==u&&e.text(c,u)}else{let f=s(e,c,n,o[i],{depth:r.depth+1,path:[...r.path,i]},l);f&&f!==c&&(t[i]=f)}})}function tt(e,t,n,o){return n===null?e.text(t):M(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Ne(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function nt(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let s=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let l of s)if(e.attr(l,o.templateAttr)!=null)return l;r=e.parent(r)}return null}function rt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=e.children(n),r=[];for(let s of t){let l=o.findIndex(c=>e.sameNode(c,s));if(l===-1)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,o,r){let s=null,l=r;for(let c=0;c<t.length;c++){if(!n[c]){s=t[c];continue}let i=s?e.parent(s):o;if(!i)continue;let f=s?Ne(e,i,s)+1:l++;e.insertAt(i,t[c],f),s=t[c]}}var Me=new Set(["checked","selected","disabled","readOnly","paused"]);function L(e,t,n,o,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(ce(n,o,[],s),s.length)throw new W(s);X(e,t,n,o,{depth:0,path:[]},r)}function X(e,t,n,o,r,s={}){if(r.depth>j)throw new I(r.path);if(o===void 0)return t;if(typeof n=="string")return it(e,t,n,o,r,s);if(Array.isArray(n)){let[l,c]=n;return se(e,t,l,c,o,r,X,s),t}if(typeof n=="object"&&n!==null){for(let[l,c]of Object.entries(n)){let i=X(e,t,c,o==null?o:o[l],{depth:r.depth+1,path:[...r.path,l]},s);i&&i!==t&&(t=i)}return t}return t}function it(e,t,n,o,r,s){if(n.endsWith("[]")){let i=n.slice(0,-2);return se(e,t,i,null,o,r,X,s),t}if(n.startsWith("@"))return Ie(e,t,n.slice(1),o);let l=S(n);if(l!==-1){let i=n.slice(0,l),f=n.slice(l+1),u=i?e.find(t,i,s):[t];return u.length===0||Ie(e,u[0],f,o),t}if(n===".")return Ce(e,t,o),t;let c=e.find(t,n,s);return c.length===0||Ce(e,c[0],o),t}function Ce(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Ie(e,t,n,o){if(_.has(n)){let s=e.prop(t,n);if(s===o||s!=null&&o!=null&&String(s)===String(o))return t;throw new H(n)}if(n==="outerHTML"){let s=o==null?"":String(o);return e.replaceWith(t,s)}if(Te.has(n)){let s=st(n,o);return e.prop(t,n)!==s&&e.prop(t,n,s),t}let r=o==null?"":String(o);return e.attr(t,n)!==r&&e.attr(t,n,r),t}function st(e,t){return t==null?Me.has(e)?!1:"":Me.has(e)?t==="false"?!1:!!t:t}function ce(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,s)=>{typeof r=="object"&&r!==null&&o.push({path:U([...n,s]),expected:"scalar",got:B(r)})}):o.push({path:U(n),expected:"array",got:B(t)});return}t!==null&&typeof t=="object"&&o.push({path:U(n),expected:"scalar",got:B(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:U(n),expected:"array",got:B(t)});return}let r=e[1];t.forEach((s,l)=>ce(r,s,[...n,l],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:U(n),expected:"object",got:B(t)});return}for(let[r,s]of Object.entries(e))ce(s,t[r],[...n,r],o)}}}function B(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function U(e){return e.join(".")}function le(e){try{return JSON.parse(e)}catch(t){throw new P(`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 p=!1,d=l+1;for(;d<r.length&&/\s/.test(r[d]);)d++;if(d<r.length&&/[a-zA-Z_]/.test(r[d])&&(p=!0),!p){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 p=c,d=l+1;for(;d<r.length&&r[d]!==p;)r[d]==="\\"&&d++,d++;s.push({type:t.STRING,value:r.substring(l+1,d),quoted:!0,sourceQuote:p}),l=d+1;continue}let i=l,f;for(;i<r.length&&!/[{},]/.test(r[i]);)if(r[i]===":"){let p=[":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 p){let h=w.substring(1);if(r.substring(i+1,i+1+h.length)===h){d=!0,i+=h.length;break}}if(!d)break}else if(r[i]==="["){for(i++;i<r.length&&r[i]!=="]";){if(r[i]==='"'||r[i]==="'"){let p=r[i];for(i++;i<r.length&&r[i]!==p;)r[i]==="\\"&&i++,i++}i++}i<r.length&&r[i]==="]"&&i++}else i++;f=r.substring(l,i);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=i}return s}function o(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 i=r[l+1];if(i&&(i.type==="}"||i.type==="]"))continue;s+=c.value;continue}if(c.type===t.STRING&&c.quoted){let i=c.value;c.sourceQuote==="'"&&(i=i.replace(/\\'/g,"'"),i=i.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),s+=`"${i}"`;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=o(r);return JSON.parse(s)}catch(r){throw new P("Invalid extraction rules syntax: "+r.message,r)}}var ct="1",Le=/^[a-zA-Z0-9_-]+$/;function k(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!Le.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Le})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{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!==ct)throw new $(l);return{rules:z(e.text(s)),tagNode:s}}var Pe=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"]})}),lt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),je=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function fe(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 ft(e,t){if(fe(e,t))return!0;for(let[n,o]of Object.entries(lt))if(o.includes(t)&&fe(e,n))return!0;return!1}function K(e){let t=Pe[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function ut(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=Pe[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>ft(n,r))||o.bundles.some(r=>fe(n,r)))return n;n=n.parentElement}return null}function ke(e,t){return!!ut(e,t)}var ue=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",...je],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),at=new Set(["textContent","innerText"]);function De(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 dt=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function _e(e,t,n=ue){if(!dt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>o.startsWith(r)))return`attribute "${o}" can run script`;if(n.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(n.urlAttributes.includes(o)&&t!=null){let r=o==="srcset"?String(t).split(",").map(s=>s.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let s of r){let l=De(s);if(l&&n.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${o}"`}}return null}function ae(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function ht(e,t){let n=ae(e,t)||"node",o=e.attr(t,"id");return o?`<${n}#${o}>`:`<${n}>`}function pt(e,t,n){let o=t;for(;o;){let r=ae(e,o);if(r&&n.refusedTargets.includes(r))return r;o=e.parent(o)}return null}function $e(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function mt(e,t){return ae(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:$e(e,t)}function Z(e,t=ue){let n=[],o=(i,f)=>(n.push({target:ht(e,i),reason:f}),!1),r=i=>{let f=pt(e,i,t);return f?o(i,`inside <${f}>, which is not content`):!0},s=i=>r(i)?$e(e,i)?o(i,"a text write here would delete the data rules tag"):!0:!1,l=(i,f,u)=>{if(!r(i))return!1;let p=_e(f,u,t);return p?o(i,p):!0};return{...e,text(i,f){if(f===void 0)return e.text(i);s(i)&&e.text(i,f)},attr(i,f,u){if(u===void 0)return e.attr(i,f);l(i,f,u)&&e.attr(i,f,u)},prop(i,f,u){if(u===void 0)return e.prop(i,f);if(t.refusedRuleForms.includes(f))return o(i,`"@${f}" writes HTML, only text is allowed`);if(at.has(f)){s(i)&&e.prop(i,f,u);return}l(i,f==="className"?"class":f,u)&&e.prop(i,f,u)},remove(i){if(mt(e,i)){o(i,"removing this would delete the data rules tag");return}e.remove(i)},replaceWith(i,f){return f===e.prop(i,"outerHTML")||o(i,'"@outerHTML" writes HTML, only text is allowed'),i},refusals:n,assertClean(){if(n.length)throw new q(n.slice())}}}function F(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function We(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function de(e,t,n,o,r={}){let s=[],l=[];function c(f,u,p){if(Array.isArray(f)){let[,d]=f;if(!Array.isArray(u)||!F(d))return;u.forEach((w,h)=>c(d,w,[...p,h]));return}if(!(!F(f)||!F(u)))for(let d of Object.keys(u))Object.prototype.hasOwnProperty.call(f,d)?c(f[d],u[d],[...p,d]):s.push(We([...p,d]))}function i(f,u,p,d){if(p!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let w=S(u),h=w===-1?u:u.slice(0,w);if(!h)return;e.find(f,h,r).length===0&&l.push({path:We(d),selector:h});return}if(!Array.isArray(u)&&F(u)&&F(p))for(let[w,h]of Object.entries(u))i(f,h,p[w],[...d,w])}}return c(n,o,[]),i(t,n,o,[]),{unknownKeys:s,unmatched:l}}function he(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return k(e,o,n)}return null}var gt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function ve(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("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),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)t.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function He(e,t,n,o){if(o)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 qe(e,t,n,o,r,s,l,c){if(e.nodeType===1&&((l?ke(e,n):He(e,o,s,!1))||r&&(l&&e!==s?e.matches(r):He(e,r,s,l))))return null;let i=t.importNode(e,!1);c.cloneToLive.set(i,e),c.liveToClone.set(e,i);let f=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,u=i.nodeType===1&&i.tagName==="TEMPLATE"?i.content:i;f!==e&&(c.cloneToLive.set(u,f),c.liveToClone.set(f,u));for(let p of f.childNodes||[]){let d=qe(p,t,n,o,r,s,l,c);d&&(u.appendChild(d),p.nodeType===1&&ve(p,d))}return e.nodeType===1&&ve(e,i),i}function V(e,{capability:t="data",exclude:n=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=r.implementation.createHTMLDocument(""),l=new WeakMap,c=new WeakMap,i=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let f=K(t),u=qe(i,s,t,f,n,i,o,{cloneToLive:l,liveToClone:c});e.nodeType===9&&u&&(s.replaceChild(u,s.documentElement),c.set(e,s),l.set(s,e));let p=d=>{if(gt.test(d))throw new Error(`Filtered content queries do not support stateful selector: ${d}`)};return{root:u,document:s,capability:t,selector:K(t),cloneToLive:l,liveToClone:c,original(d){return l.get(d)||null},cloneOf(d){return c.get(d)||null},query(d,w=u){return p(d),Array.from(w.querySelectorAll(d),h=>l.get(h)||h)},text(d=u){return(d===u?u:c.get(d))?.textContent||""},html(d=u){return(d===u?u:c.get(d))?.innerHTML??""},clone(d=u){let w=d===u?u:c.get(d);return w?s.importNode(w,!0):null}}}function Be(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function wt(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var b={semanticExclude:!0,find(e,t,n={}){let o=wt(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!Be(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(i=>!i.closest||!i.closest(c))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},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 o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.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(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function C(e,t={}){if(t.exclude===null)return b;let n=[K("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return b;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,c=null,i=()=>c||(c=V(s,{capability:"data",exclude:t.exclude||null})),f=h=>{let y=i();return h===e?y.cloneOf(e):y.cloneOf(h)||h},u=h=>c?.original(h)||h,p=(h,y)=>{i().liveToClone.set(h,y),i().cloneToLive.set(y,h);let a=h.childNodes||[],m=y.childNodes||[];for(let g=0;g<Math.min(a.length,m.length);g++)p(a[g],m[g])},d=(h,y,a,m)=>{let g=Array.from(h.childNodes).filter(T=>c.cloneOf(T)),O=g[0];for(;O&&g.includes(O);)O=O.nextSibling;for(let T of g)T.remove();if(a==="innerHTML"){let T=l.createElement("template");T.innerHTML=m;for(let N of Array.from(T.content.childNodes))h.insertBefore(N,O||null)}else h.insertBefore(l.createTextNode(m),O||null);let E=V(h,{capability:"data",exclude:t.exclude||null});y.replaceChildren(...Array.from(E.root?.childNodes||[]));let A=T=>{let N=E.original(T);N&&(c.liveToClone.set(N,T),c.cloneToLive.set(T,N));for(let we of Array.from(T.childNodes||[]))A(we)};for(let T of Array.from(y.childNodes))A(T)},w={...b,find(h,y,a={}){let m=f(h);if(!m?.querySelectorAll)return[];let g=i().query(y,m);a.includeRulesTag||(g=g.filter(E=>!Be(E)));let x=[];a.skip&&x.push(a.skip);let O=a.templateAttr===null?null:a.templateAttr||"cms-template";if(O&&x.push(`[${O}]`),x.length){let E=x.join(", ");g=g.filter(A=>!A.closest?.(E))}return g},parent(h){let y=f(h)?.parentElement;return y?u(y):null},children(h){return Array.from(f(h)?.children||[],u)},text(h,y){if(y===void 0){let g=u(h);return!g?.matches?.(n)&&!g?.querySelector?.(n)?b.text(g):(f(h)?.textContent||"").trim()}let a=u(h);if(!a?.matches?.(n)&&!a?.querySelector?.(n)&&!c){b.text(a,y);return}let m=i().cloneOf(a);m?d(a,m,"textContent",y):b.text(a,y)},attr(h,y,a){let m=u(h);if(a===void 0)return b.attr(m,y);b.attr(m,y,a);let g=c?.cloneOf(m);g&&(b.attr(g,y,a),V(m,{capability:"data",exclude:t.exclude||null}).root===null&&(g.remove(),c.liveToClone.delete(m),c.cloneToLive.delete(g)))},removeAttr(h,y){let a=u(h);b.removeAttr(a,y);let m=c?.cloneOf(a);m&&b.removeAttr(m,y)},prop(h,y,a){let m=u(h);if(a===void 0)return y==="innerHTML"||y==="outerHTML"||y==="textContent"||y==="innerText"?b.prop(f(m),y):b.prop(m,y);let g=y==="innerHTML"||y==="textContent"||y==="innerText",x=g?i().cloneOf(m):c?.cloneOf(m);x&&g?d(m,x,y,a):(b.prop(m,y,a),x&&b.prop(x,y,a))},clone(h){let y=f(h);return y===h?b.clone(h):l.importNode(y,!0)},insertAt(h,y,a){let m=u(h),x=w.children(m)[a]||(()=>{for(let A=m.children.length-1;A>=0;A--){let T=m.children[A];if(i().cloneOf(T))return T.nextElementSibling}return m.firstElementChild})(),O=u(y);m.insertBefore(O,x||null);let E=i().cloneOf(m);if(E){let A=i().cloneOf(O);A||(A=l.importNode(O,!0),p(O,A));let T=Array.from(E.children);E.insertBefore(A,T[a]||null)}},remove(h){let y=u(h),a=i().cloneOf(y);b.remove(y),a&&b.remove(a)},replaceWith(h,y){let a=u(h),m=i().cloneOf(a),g=b.replaceWith(a,y);if(m){let x=V(g,{capability:"data",exclude:t.exclude||null});if(!x.root)m.remove();else{m.replaceWith(x.root);let O=E=>{let A=x.original(E);A&&(c.liveToClone.set(A,E),c.cloneToLive.set(E,A));for(let T of Array.from(E.childNodes||[]))O(T)};O(x.root)}}return g}};return w}var J=b;var Y={extract:(e,t,n={})=>M(C(e,n),e,t,n),apply:(e,t,n,o={})=>L(C(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>k(J,e,t),findRules:(e,t)=>he(J,e,t),bind:(e,t,n={})=>{let o=he(J,e,t);if(!o){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{...o,get:()=>M(C(e,n),e,o.rules,n),set:r=>L(C(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:le,parseRelaxed:z,ruleAttrIndex:S,splitRule:re,errors:R,DOM_PROPERTIES:G},pe=e=>!!e&&typeof e.nodeType=="number";function Ue(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=k(J,t,"api");if(!n)throw new R.NoRulesTag("api");return n.rules}function Et(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 Tt(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 At(e,t){let n=[];for(;t!==e;){let o=t.parentNode;n.push(Array.prototype.indexOf.call(o.childNodes,t)),t=o}return n.reverse()}function Ot(e,t){return t.reduce((n,o)=>n.childNodes[o],e)}function D(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function xt(e,t){let n=D(e,"option"),o=D(t,"option");n.forEach((i,f)=>o[f].selected=i.selected);let r=D(e,"input"),s=D(t,"input");r.forEach((i,f)=>{let u=i.type.toLowerCase();u!=="file"&&(s[f].value=i.value),(u==="checkbox"||u==="radio")&&(s[f].checked=i.checked)});let l=D(e,"textarea"),c=D(t,"textarea");l.forEach((i,f)=>c[f].value=i.value)}function me(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:S(e);if(n===-1)return;let o=e.slice(n+1);if(_.has(o))throw new R.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>me(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,o]of Object.entries(e))me(o,t[n])}}function bt(e,t,n){let o={templateAttr:"cms-template"},r=Et(e),s=At(r,e),l=Tt(r);xt(r,l);let c=Ot(l,s),i=C(l,{...o,_write:!0}),f=de(i,c,t,n,o);if(f.unknownKeys.length||f.unmatched.length)throw new R.WriteRejected(f.unknownKeys,f.unmatched);let u=Z(i);L(u,c,t,n,o),u.assertClean(),me(t,n);let p=Z(C(r,{...o,_write:!0}));L(p,e,t,n,o),p.assertClean()}function St(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 ye(e,t){let n=pe(e)?e:document,o=pe(e)?t:e;return o===void 0?M(C(n),n,Ue(n)):Y.bind(n,o).get()}function ge(e,t,n){try{if(!pe(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=n===void 0?Ue(e):Y.bind(e,n).rules;bt(e,o,t)}catch(o){throw St(o)}return e}var Rt={engine:Y,extractData:ye,applyData:ge},Nt=Rt;return Ye(Mt);})();
|
|
5
|
+
var hyperHtmlApiData=(()=>{var te=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var Te=(e,t)=>{for(var n in t)te(e,n,{get:t[n],enumerable:!0})},Je=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Fe(t))!Ve.call(e,o)&&o!==n&&te(e,o,{get:()=>t[o],enumerable:!(r=Ke(t,o))||r.enumerable});return e};var Ye=e=>Je(te({},"__esModule",{value:!0}),e);var It={};Te(It,{applyData:()=>Ae,default:()=>Pt,engine:()=>G,extractData:()=>we});var X=["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"],ne=new Set(X),Ee=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"]);var R={};Te(R,{EmptyListInsert:()=>v,MAX_RULE_DEPTH:()=>j,MaxRuleDepthExceeded:()=>P,NoRulesTag:()=>re,RuleTargetReadOnly:()=>B,RulesParseError:()=>L,ShapeMismatch:()=>W,UnknownRulesVersion:()=>$,WriteRefused:()=>H,WriteRejected:()=>oe});var L=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},$=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},j=20,P=class extends Error{constructor(t){super(`rule depth exceeded ${j} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},W=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},v=class extends Error{constructor(t){super(`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}},re=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},oe=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 S(e){let t=0,n=null,r=-1;for(let o=0;o<e.length;o++){let s=e[o];s==="\\"?o++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:s==="@"&&t===0&&(r=o)}return r}function ie(e){let t=S(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function N(e,t,n,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.");return se(e,t,n,{depth:0,path:[]},r)}function se(e,t,n,r,o){if(r.depth>j)throw new P(r.path);if(typeof n=="string")return Ge(e,t,n,r,o);if(Array.isArray(n)){let[s,l]=n,c=e.find(t,s,o);return xe(o,r,c),c.map((i,f)=>se(e,i,l,{depth:r.depth+1,path:[...r.path,f]},o))}if(typeof n=="object"&&n!==null){let s={};for(let[l,c]of Object.entries(n))s[l]=se(e,t,c,{depth:r.depth+1,path:[...r.path,l]},o);return s}return null}function Ge(e,t,n,r,o){if(n.endsWith("[]")){let c=n.slice(0,-2),i=e.find(t,c,o);return xe(o,r,i),i.map(f=>e.text(f))}if(n.startsWith("@"))return Oe(e,t,n.slice(1));let s=S(n);if(s!==-1){let c=n.slice(0,s),i=n.slice(s+1),f=c?e.find(t,c,o):[t];return f.length===0?null:Oe(e,f[0],i)}if(n===".")return e.text(t);let l=e.find(t,n,o);return l.length===0?null:e.text(l[0])}function xe(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(r){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,r)}}function Oe(e,t,n){if(ne.has(n)){let o=e.prop(t,n);return o==null?null:String(o)}let r=e.attr(t,n);return r||null}function Re(e,t,n,r){let o=e.length,s=t.length,l=new Array(o).fill(-1);if(r){let d=new Set;for(let y=0;y<o;y++){let w=r[y];!(w>=0&&w<s)||d.has(w)||(l[y]=w,d.add(w))}}if(o===0||s===0)return l;let c=e.map(d=>be(d,n)),i=t.map(d=>be(d,n)),f=new Array(s).fill(!1);for(let d of l)d>=0&&(f[d]=!0);let u=new Map;i.forEach((d,y)=>{f[y]||u.set(d,u.has(d)?-1:y)});let m=new Map;c.forEach((d,y)=>{l[y]>=0||m.set(d,(m.get(d)||0)+1)}),c.forEach((d,y)=>{if(l[y]>=0||m.get(d)!==1)return;let w=u.get(d);w===void 0||w===-1||f[w]||(l[y]=w,f[w]=!0)});let h=[];for(let d=0;d<o;d++)l[d]<0&&h.push(d);let T=[];for(let d=0;d<s;d++)f[d]||T.push(d);if(h.length===0||T.length===0)return l;let a=o*s+1,p=Xe(e,t,n),g=(d,y)=>p(d,y)*a+Math.abs(d-y);for(let[d,y]of Ze(h,T,g))l[d]=y;return l}var Ce=e=>typeof e=="object"&&e!==null;function be(e,t){if(!Ce(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(r=>{let o=JSON.stringify(e?.[r]);return o===void 0?" undef":o}))}function Xe(e,t,n){if(!Ce(n))return(c,i)=>e[c]===t[i]?0:1;let r=Object.keys(n),o=c=>r.map(i=>JSON.stringify(c?.[i])),s=e.map(o),l=t.map(o);return(c,i)=>{let f=s[c],u=l[i],m=0;for(let h=0;h<r.length;h++)f[h]!==u[h]&&m++;return m}}function Ze(e,t,n){return e.length<=t.length?Se(e,t,n,!1):Se(t,e,(r,o)=>n(o,r),!0)}function Se(e,t,n,r){let o=e.length,s=t.length,l=[];for(let m=0;m<=o;m++)l.push(new Float64Array(s+1).fill(1/0));let c=[];for(let m=0;m<=o;m++)c.push(new Uint8Array(s+1));for(let m=0;m<=s;m++)l[o][m]=0;for(let m=o-1;m>=0;m--)for(let h=s-1;h>=0;h--){let T=n(e[m],t[h])+l[m+1][h+1],a=l[m][h+1];T<=a?(l[m][h]=T,c[m][h]=1):l[m][h]=a}let i=[],f=0,u=0;for(;f<o&&u<s;)c[f][u]&&(i.push(r?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return i}function le(e,t,n,r,o,s,l,c={}){let i=e.find(t,n,c);if(o.length===0){i.forEach(E=>e.remove(E)),ce(c,"onRowsApplied",s.path,[]);return}let f=o.length>i.length,u=i[0]||null;if(f&&!u&&(u=nt(e,t,n,c),!u))throw new v(s.path);let m=i.map(E=>tt(e,E,r,c)),h=null;if(f&&u){h=e.clone(u),c.templateAttr&&e.removeAttr(h,c.templateAttr);let E=e.stripIds(h);E>0&&console.warn(`[hyper-html-api] stripped ${E} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let T=Re(o,m,r,Qe(e,i,o,s,c)),a=i[0]||u,p=e.parent(a),g=i.length>0?Ne(e,p,a):0,d=ot(e,i),y=new Set,w=[],A=o.map((E,x)=>{let O=T[x];if(O>=0)return y.add(O),w.push(!1),i[O];w.push(!0);let C=e.clone(h);return e.stripIds(C),C});i.forEach((E,x)=>{y.has(x)||e.remove(E)}),d?rt(e,p,g,A,w):it(e,A,w,p,g),et(e,A,r,o,s,l,c),ce(c,"onRowsApplied",s.path,A)}function ce(e,t,n,r){if(typeof e[t]=="function")try{return e[t](n.slice(),r)}catch(o){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,o);return}}function Qe(e,t,n,r,o){let s=ce(o,"identifyRows",r.path,n);if(!Array.isArray(s))return null;let l=new Array(n.length).fill(-1),c=new Set,i=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!s[f])continue;let u=i.get(e.identity(s[f]));u===void 0||c.has(u)||(l[f]=u,c.add(u))}return l}function et(e,t,n,r,o,s,l){t.forEach((c,i)=>{if(n===null){let f=r[i],u=f==null?"":String(f);e.text(c)!==u&&e.text(c,u)}else{let f=s(e,c,n,r[i],{depth:o.depth+1,path:[...o.path,i]},l);f&&f!==c&&(t[i]=f)}})}function tt(e,t,n,r){return n===null?e.text(t):N(e,t,n,r.onRowsRead?{...r,onRowsRead:void 0}:r)}function Ne(e,t,n){let r=e.children(t);for(let o=0;o<r.length;o++)if(e.sameNode(r[o],n))return o;return-1}function nt(e,t,n,r){if(!r.templateAttr)return null;let o=t;for(;o;){let s=e.find(o,n,{includeRulesTag:!1,templateAttr:null});for(let l of s)if(e.attr(l,r.templateAttr)!=null)return l;o=e.parent(o)}return null}function rt(e,t,n,r,o){let s=e.children(t),l=s.map(i=>e.identity(i)),c=!1;r.forEach((i,f)=>{let u=e.identity(i),m=n+f;if(l[m]===u)return;if(!o[f]){let T=l.indexOf(u);T!==-1&&(l.splice(T,1),s.splice(T,1))}let h=Math.min(m,s.length);h<s.length?e.insertBefore(s[h],i):s.length?c?e.insertAfter(s[s.length-1],i):(e.insertAt(t,i,m),c=!0):e.insertAt(t,i,0),l.splice(h,0,u),s.splice(h,0,i)})}function ot(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let r=new Map(e.children(n).map((s,l)=>[e.identity(s),l])),o=[];for(let s of t){let l=r.get(e.identity(s));if(l===void 0)return!1;o.push(l)}return o.sort((s,l)=>s-l),o[o.length-1]-o[0]===o.length-1}function it(e,t,n,r,o){let s=null,l=o;for(let c=0;c<t.length;c++){if(!n[c]){s=t[c];continue}let i=s?e.parent(s):r;if(!i)continue;let f=s?Ne(e,i,s)+1:l++;e.insertAt(i,t[c],f),s=t[c]}}var Me=new Set(["checked","selected","disabled","readOnly","paused"]);function I(e,t,n,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"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(fe(n,r,[],s),s.length)throw new W(s);Z(e,t,n,r,{depth:0,path:[]},o)}function Z(e,t,n,r,o,s={}){if(o.depth>j)throw new P(o.path);if(r===void 0)return t;if(typeof n=="string")return st(e,t,n,r,o,s);if(Array.isArray(n)){let[l,c]=n;return le(e,t,l,c,r,o,Z,s),t}if(typeof n=="object"&&n!==null){for(let[l,c]of Object.entries(n)){let i=Z(e,t,c,r==null?r:r[l],{depth:o.depth+1,path:[...o.path,l]},s);i&&i!==t&&(t=i)}return t}return t}function st(e,t,n,r,o,s){if(n.endsWith("[]")){let i=n.slice(0,-2);return le(e,t,i,null,r,o,Z,s),t}if(n.startsWith("@"))return Ie(e,t,n.slice(1),r);let l=S(n);if(l!==-1){let i=n.slice(0,l),f=n.slice(l+1),u=i?e.find(t,i,s):[t];return u.length===0||Ie(e,u[0],f,r),t}if(n===".")return Pe(e,t,r),t;let c=e.find(t,n,s);return c.length===0||Pe(e,c[0],r),t}function Pe(e,t,n){let r=n==null?"":String(n);e.text(t)!==r&&e.text(t,r)}function Ie(e,t,n,r){if(_.has(n)){let s=e.prop(t,n);if(s===r||s!=null&&r!=null&&String(s)===String(r))return t;throw new B(n)}if(n==="outerHTML"){let s=r==null?"":String(r);return e.replaceWith(t,s)}if(Ee.has(n)){let s=ct(n,r);return e.prop(t,n)!==s&&e.prop(t,n,s),t}let o=r==null?"":String(r);return e.attr(t,n)!==o&&e.attr(t,n,o),t}function ct(e,t){return t==null?Me.has(e)?!1:"":Me.has(e)?t==="false"?!1:!!t:t}function fe(e,t,n,r){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((o,s)=>{typeof o=="object"&&o!==null&&r.push({path:U([...n,s]),expected:"scalar",got:q(o)})}):r.push({path:U(n),expected:"array",got:q(t)});return}t!==null&&typeof t=="object"&&r.push({path:U(n),expected:"scalar",got:q(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){r.push({path:U(n),expected:"array",got:q(t)});return}let o=e[1];t.forEach((s,l)=>fe(o,s,[...n,l],r));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){r.push({path:U(n),expected:"object",got:q(t)});return}for(let[o,s]of Object.entries(e))fe(s,t[o],[...n,o],r)}}}function q(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function U(e){return e.join(".")}function ue(e){try{return JSON.parse(e)}catch(t){throw new L(`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(o){let s=[],l=0;for(;l<o.length;){let c=o[l];if(/\s/.test(c)){l++;continue}if("{}".includes(c)){s.push({type:c,value:c}),l++;continue}if(c==="["){let m=!1,h=l+1;for(;h<o.length&&/\s/.test(o[h]);)h++;if(h<o.length&&/[a-zA-Z_]/.test(o[h])&&(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,h=l+1;for(;h<o.length&&o[h]!==m;)o[h]==="\\"&&h++,h++;s.push({type:t.STRING,value:o.substring(l+1,h),quoted:!0,sourceQuote:m}),l=h+1;continue}let i=l,f;for(;i<o.length&&!/[{},]/.test(o[i]);)if(o[i]===":"){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"],h=!1;for(let T of m){let a=T.substring(1);if(o.substring(i+1,i+1+a.length)===a){h=!0,i+=a.length;break}}if(!h)break}else if(o[i]==="["){for(i++;i<o.length&&o[i]!=="]";){if(o[i]==='"'||o[i]==="'"){let m=o[i];for(i++;i<o.length&&o[i]!==m;)o[i]==="\\"&&i++,i++}i++}i<o.length&&o[i]==="]"&&i++}else i++;f=o.substring(l,i);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=i}return s}function r(o){let s="";for(let l=0;l<o.length;l++){let c=o[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 i=o[l+1];if(i&&(i.type==="}"||i.type==="]"))continue;s+=c.value;continue}if(c.type===t.STRING&&c.quoted){let i=c.value;c.sourceQuote==="'"&&(i=i.replace(/\\'/g,"'"),i=i.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),s+=`"${i}"`;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 o=n(e),s=r(o);return JSON.parse(s)}catch(o){throw new L("Invalid extraction rules syntax: "+o.message,o)}}var lt="1",Le=/^[a-zA-Z0-9_-]+$/;function k(e,t,n){let r;if(n===void 0)r="script[data-rules-name]";else{if(typeof n!="string"||!Le.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Le})`);r=`script[data-rules-name~="${n}"]`}let o=e.find(t,r,{includeRulesTag:!0});if(o.length===0)return null;n!==void 0&&o.length>1&&console.warn(`hyper-html-api: ${o.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=o[0],l=e.attr(s,"data-rules-version");if(l!==lt)throw new $(l);return{rules:z(e.text(s)),tagNode:s}}var Q=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"]})}),ft=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),je=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 ae(e,t){if(K(e,t))return!0;for(let[n,r]of Object.entries(ft))if(r.includes(t)&&K(e,n))return!0;return!1}function F(e){let t=Q[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function ut(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=Q[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>ae(n,o))||r.bundles.some(o=>K(n,o)))return n;n=n.parentElement}return null}function ke(e,t){return!!ut(e,t)}var de=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",...je],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),at=new Set(["textContent","innerText"]);function De(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 dt=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function _e(e,t,n=de){if(!dt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let r=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(o=>r.startsWith(o)))return`attribute "${r}" can run script`;if(n.refusedAttributes.includes(r))return`attribute "${r}" is not content`;if(n.urlAttributes.includes(r)&&t!=null){let o=r==="srcset"?String(t).split(",").map(s=>s.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let s of o){let l=De(s);if(l&&n.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${r}"`}}return null}function he(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function ht(e,t){let n=he(e,t)||"node",r=e.attr(t,"id");return r?`<${n}#${r}>`:`<${n}>`}function pt(e,t,n){let r=t;for(;r;){let o=he(e,r);if(o&&n.refusedTargets.includes(o))return o;r=e.parent(r)}return null}function $e(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function mt(e,t){return he(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:$e(e,t)}function ee(e,t=de){let n=[],r=(i,f)=>(n.push({target:ht(e,i),reason:f}),!1),o=i=>{let f=pt(e,i,t);return f?r(i,`inside <${f}>, which is not content`):!0},s=i=>o(i)?$e(e,i)?r(i,"a text write here would delete the data rules tag"):!0:!1,l=(i,f,u)=>{if(!o(i))return!1;let m=_e(f,u,t);return m?r(i,m):!0};return{...e,text(i,f){if(f===void 0)return e.text(i);s(i)&&e.text(i,f)},attr(i,f,u){if(u===void 0)return e.attr(i,f);l(i,f,u)&&e.attr(i,f,u)},prop(i,f,u){if(u===void 0)return e.prop(i,f);if(t.refusedRuleForms.includes(f))return r(i,`"@${f}" writes HTML, only text is allowed`);if(at.has(f)){s(i)&&e.prop(i,f,u);return}l(i,f==="className"?"class":f,u)&&e.prop(i,f,u)},remove(i){if(mt(e,i)){r(i,"removing this would delete the data rules tag");return}e.remove(i)},replaceWith(i,f){return f===e.prop(i,"outerHTML")||r(i,'"@outerHTML" writes HTML, only text is allowed'),i},refusals:n,assertClean(){if(n.length)throw new H(n.slice())}}}function V(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function We(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function pe(e,t,n,r,o={}){let s=[],l=[];function c(f,u,m){if(Array.isArray(f)){let[,h]=f;if(!Array.isArray(u)||!V(h))return;u.forEach((T,a)=>c(h,T,[...m,a]));return}if(!(!V(f)||!V(u)))for(let h of Object.keys(u))Object.prototype.hasOwnProperty.call(f,h)?c(f[h],u[h],[...m,h]):s.push(We([...m,h]))}function i(f,u,m,h){if(m!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let T=S(u),a=T===-1?u:u.slice(0,T);if(!a)return;e.find(f,a,o).length===0&&l.push({path:We(h),selector:a});return}if(!Array.isArray(u)&&V(u)&&V(m))for(let[T,a]of Object.entries(u))i(f,a,m[T],[...h,T])}}return c(n,r,[]),i(t,n,r,[]),{unknownKeys:s,unmatched:l}}function me(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let r=t&&t.ownerDocument?t.ownerDocument:t;return k(e,r,n)}return null}var gt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function wt(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 ve(e,t,n,r){if(r)return!!e.closest?.(t);let o=e;for(;o?.nodeType===1;){if(o.matches(t))return!0;if(o===n)break;o=o.parentElement}return!1}function Be(e,t,n,r,o,s){return(s?ke(e,t):ve(e,n,o,!1))||!!(r&&(s&&e!==o?e.matches(r):ve(e,r,o,s)))}function At(e,t){let n=Q[t];return n.tokens.some(r=>ae(e,r))||n.bundles.some(r=>K(e,r))}var Tt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function He(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let o=e,s=t;if(e.nodeType===1){if(Tt.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);o=e.content,s=t.content,n.cloneToLive.set(s,o),n.liveToClone.set(o,s)}}else if(e.nodeType!==11)return;let l=s.firstChild;for(let c=o.firstChild;c&&l;c=c.nextSibling)He(c,l,n,r),l=l.nextSibling}function J(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:o=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=o||new WeakMap,i=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&l.documentElement.matches(n);let u=F(t),m=r?a=>At(a,t)||!!(n&&a.matches(n)):a=>Be(a,t,u,n,f,!1),h=null;if(f.nodeType!==1||!Be(f,t,u,n,f,r)){h=l.importNode(f,!0);let a={cloneToLive:c,liveToClone:i,dropped:[],controls:[]};He(f,h,a,m);for(let p of a.dropped)p.remove();for(let p=0;p<a.controls.length;p+=2)wt(a.controls[p],a.controls[p+1])}e.nodeType===9&&h&&(l.replaceChild(h,l.documentElement),i.set(e,l),c.set(l,e));let T=a=>{if(gt.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:h,document:l,capability:t,selector:F(t),cloneToLive:c,liveToClone:i,original(a){return c.get(a)||null},cloneOf(a){return i.get(a)||null},query(a,p=h){return T(a),Array.from(p.querySelectorAll(a),g=>c.get(g)||g)},text(a=h){return(a===h?h:i.get(a))?.textContent||""},html(a=h){return(a===h?h:i.get(a))?.innerHTML??""},clone(a=h){let p=a===h?h:i.get(a);return p?l.importNode(p,!0):null}}}function qe(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Et(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var b={semanticExclude:!0,find(e,t,n={}){let r=Et(e);if(!r||!r.querySelectorAll)return[];let o=Array.from(r.querySelectorAll(t));n.includeRulesTag||(o=o.filter(c=>!qe(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(", ");o=o.filter(i=>!i.closest||!i.closest(c))}return o},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let r=e?e[t]:void 0;return r!==void 0?r:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let r=e.children[n]||null;e.insertBefore(t,r)},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 r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function M(e,t={}){if(t.exclude===null)return b;let n=[F("data"),t.exclude].filter(Boolean).join(", "),r=e.nodeType===9?e:e.ownerDocument||e,o=e.nodeType===9?e.documentElement:e;if(!t._write&&!o?.matches?.(n)&&!o?.querySelector?.(n)&&!r?.querySelector?.(n))return b;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,c=null,i=()=>c||(c=J(s,{capability:"data",exclude:t.exclude||null})),f=a=>{let p=i();return a===e?p.cloneOf(e):p.cloneOf(a)||a},u=a=>c?.original(a)||a,m=(a,p)=>{i().liveToClone.set(a,p),i().cloneToLive.set(p,a);let g=a.childNodes||[],d=p.childNodes||[];for(let y=0;y<Math.min(g.length,d.length);y++)m(g[y],d[y])},h=(a,p,g,d)=>{let y=Array.from(a.childNodes).filter(O=>c.cloneOf(O)),A=y[0];for(;A&&y.includes(A);)A=A.nextSibling;for(let O of y)O.remove();if(g==="innerHTML"){let O=l.createElement("template");O.innerHTML=d;for(let C of Array.from(O.content.childNodes))a.insertBefore(C,A||null)}else a.insertBefore(l.createTextNode(d),A||null);let E=J(a,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(E.root?.childNodes||[]));let x=O=>{let C=E.original(O);C&&(c.liveToClone.set(C,O),c.cloneToLive.set(O,C));for(let ze of Array.from(O.childNodes||[]))x(ze)};for(let O of Array.from(p.childNodes))x(O)},T={...b,find(a,p,g={}){let d=f(a);if(!d?.querySelectorAll)return[];let y=i().query(p,d);g.includeRulesTag||(y=y.filter(E=>!qe(E)));let w=[];g.skip&&w.push(g.skip);let A=g.templateAttr===null?null:g.templateAttr||"cms-template";if(A&&w.push(`[${A}]`),w.length){let E=w.join(", ");y=y.filter(x=>!x.closest?.(E))}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)?b.text(y):(f(a)?.textContent||"").trim()}let g=u(a);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){b.text(g,p);return}let d=i().cloneOf(g);d?h(g,d,"textContent",p):b.text(g,p)},attr(a,p,g){let d=u(a);if(g===void 0)return b.attr(d,p);b.attr(d,p,g);let y=c?.cloneOf(d);y&&(b.attr(y,p,g),J(d,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(d),c.cloneToLive.delete(y)))},removeAttr(a,p){let g=u(a);b.removeAttr(g,p);let d=c?.cloneOf(g);d&&b.removeAttr(d,p)},prop(a,p,g){let d=u(a);if(g===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?b.prop(f(d),p):b.prop(d,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",w=y?i().cloneOf(d):c?.cloneOf(d);w&&y?h(d,w,p,g):(b.prop(d,p,g),w&&b.prop(w,p,g))},clone(a){let p=f(a);return p===a?b.clone(a):l.importNode(p,!0)},insertAt(a,p,g){let d=u(a),w=T.children(d)[g]||(()=>{for(let x=d.children.length-1;x>=0;x--){let O=d.children[x];if(i().cloneOf(O))return O.nextElementSibling}return d.firstElementChild})(),A=u(p);d.insertBefore(A,w||null);let E=i().cloneOf(d);if(E){let x=i().cloneOf(A);x||(x=l.importNode(A,!0),m(A,x));let O=Array.from(E.children);E.insertBefore(x,O[g]||null)}},insertBefore(a,p){let g=u(a),d=u(p);g.parentNode.insertBefore(d,g);let y=i().cloneOf(g.parentNode);if(y){let w=i().cloneOf(d);w||(w=l.importNode(d,!0),m(d,w));let A=i().cloneOf(g);A?A.before(w):y.appendChild(w)}},insertAfter(a,p){let g=u(a),d=u(p);g.parentNode.insertBefore(d,g.nextSibling);let y=i().cloneOf(g.parentNode);if(y){let w=i().cloneOf(d);w||(w=l.importNode(d,!0),m(d,w));let A=i().cloneOf(g);A?A.after(w):y.appendChild(w)}},identity(a){return u(a)||null},remove(a){let p=u(a),g=i().cloneOf(p);b.remove(p),g&&b.remove(g)},replaceWith(a,p){let g=u(a),d=i().cloneOf(g),y=b.replaceWith(g,p);if(d){let w=J(y,{capability:"data",exclude:t.exclude||null});if(!w.root)d.remove();else{d.replaceWith(w.root);let A=E=>{let x=w.original(E);x&&(c.liveToClone.set(x,E),c.cloneToLive.set(E,x));for(let O of Array.from(E.childNodes||[]))A(O)};A(w.root)}}return y}};return T}var Y=b;var G={extract:(e,t,n={})=>N(M(e,n),e,t,n),apply:(e,t,n,r={})=>I(M(e,{...r,_write:!0}),e,t,n,r),findRulesIn:(e,t)=>k(Y,e,t),findRules:(e,t)=>me(Y,e,t),bind:(e,t,n={})=>{let r=me(Y,e,t);if(!r){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}return{...r,get:()=>N(M(e,n),e,r.rules,n),set:o=>I(M(e,{...n,_write:!0}),e,r.rules,o,n)}},parseStrict:ue,parseRelaxed:z,ruleAttrIndex:S,splitRule:ie,errors:R,DOM_PROPERTIES:X},ye=e=>!!e&&typeof e.nodeType=="number";function Ue(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=k(Y,t,"api");if(!n)throw new R.NoRulesTag("api");return n.rules}function Ot(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 xt(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 r=t.parentNode;n.push(Array.prototype.indexOf.call(r.childNodes,t)),t=r}return n.reverse()}function St(e,t){return t.reduce((n,r)=>n.childNodes[r],e)}function D(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function Rt(e,t){let n=D(e,"option"),r=D(t,"option");n.forEach((i,f)=>r[f].selected=i.selected);let o=D(e,"input"),s=D(t,"input");o.forEach((i,f)=>{let u=i.type.toLowerCase();u!=="file"&&(s[f].value=i.value),(u==="checkbox"||u==="radio")&&(s[f].checked=i.checked)});let l=D(e,"textarea"),c=D(t,"textarea");l.forEach((i,f)=>c[f].value=i.value)}function ge(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:S(e);if(n===-1)return;let r=e.slice(n+1);if(_.has(r))throw new R.RuleTargetReadOnly(r);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>ge(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,r]of Object.entries(e))ge(r,t[n])}}function Ct(e,t,n){let r={templateAttr:"cms-template"},o=Ot(e),s=bt(o,e),l=xt(o);Rt(o,l);let c=St(l,s),i=M(l,{...r,_write:!0}),f=pe(i,c,t,n,r);if(f.unknownKeys.length||f.unmatched.length)throw new R.WriteRejected(f.unknownKeys,f.unmatched);let u=ee(i);I(u,c,t,n,r),u.assertClean(),ge(t,n);let m=ee(M(o,{...r,_write:!0}));I(m,e,t,n,r),m.assertClean()}function Nt(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 we(e,t){let n=ye(e)?e:document,r=ye(e)?t:e;return r===void 0?N(M(n),n,Ue(n)):G.bind(n,r).get()}function Ae(e,t,n){try{if(!ye(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let r=n===void 0?Ue(e):G.bind(e,n).rules;Ct(e,r,t)}catch(r){throw Nt(r)}return e}var Mt={engine:G,extractData:we,applyData:Ae},Pt=Mt;return Ye(It);})();
|
|
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
|
|
5
|
-
`+(e[0]==="W"?"sap \u26A0 ":"sap \u2717 ")+e+" "+
|
|
6
|
-
`)),s}error(e,n
|
|
7
|
-
${t}`:`"use strict"; return (${t});`;
|
|
4
|
+
var Sap=(()=>{var ne=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var xn=Object.getOwnPropertyNames;var Sn=Object.prototype.hasOwnProperty;var kn=(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 xn(e))!Sn.call(t,o)&&o!==r&&ne(t,o,{get:()=>e[o],enumerable:!(n=vn(e,o))||n.enumerable});return t};var _n=t=>$n(ne({},"__esModule",{value:!0}),t);var xr={};kn(xr,{Sap:()=>O,default:()=>vr,mount:()=>En,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}`),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=Tn(t,o);s<n&&(n=s,r=o)}return r}function Tn(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 Nn=new Set(bt),Ln={readonly:"readOnly",novalidate:"noValidate"},Cn=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}-${(Cn++).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 Rn(t){return t.hasAttribute("scope")||t.hasAttribute("items")||t.hasAttribute("detail")||t.hasAttribute("each")}function Dn(t){return t.tagName==="TEMPLATE"||t.hasAttribute("sap-ignore")||t.hasAttribute("template")}function et(t,e){for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(Dn(n))return;let o=Rn(n);if(e(n,o),!o)for(let s=n.firstElementChild;s;s=s.nextElementSibling)r(s)}}function J(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")&&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 Nn.has(e)&&typeof t[Ln[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=Mn(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 Mn(t,e){let r=J(t);for(;r;){if(r.getAttribute("items")===e)return r;let n=gt(r,e);if(n)return n;r=J(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}`}},Pn=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(Pn.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 In=["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 On(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 W(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(...In,o),src:t,statement:e,deps:On(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&&Fn(),Gt=!!pt&&t.getRootNode()===document,e}function Ve(t){Gt=t}function ue(){pt&&ce(pt.takeRecords())}function Fn(){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"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:W(o)});break;case"show":(e.paints||(e.paints=[])).push({kind:"show",entry:W(o)});break;case"effect":(e.effects||(e.effects=[])).push({entry:W(o,!0)});break;case"invalid":(e.invalids||(e.invalids=[])).push({entry:W(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:W(o)});break;case"text":(e.paints||(e.paints=[])).push({kind:"text",fmt:k,entry:W(o)});break;case"attr":(e.paints||(e.paints=[])).push({kind:"attr",arg:k,entry:W(o)});break;case"class":(e.paints||(e.paints=[])).push({kind:"class",arg:k,entry:W(o)});break;case"css":(e.paints||(e.paints=[])).push({kind:"css",arg:k,entry:W(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,Wn(e)?Bn():e}var Ut=null;function Bn(){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 Wn(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!==r&&(t.textContent=r),t.removeAttribute("data-value");return}if(n==="SELECT"){let r=t.options,i=e.options;for(let s=0;s<r.length;s++)i[s]&&i[s].selected?r[s].hasAttribute("selected")||r[s].setAttribute("selected",""):r[s].removeAttribute("selected")}}function qt(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,n=window.hyperclay;return t==="consent"?e?.confirm||n?.consent||null:e?.[t]||n?.[t]||null}var Zt=["clay:mutation-ready","hyperclay:mutation-ready"],wr=["clay:sync-applied","hyperclay:livesync-applied"],yr=["clay:ready","hyperclay:ready"],Ar=["clay:route"];function yt(t,e,n){let r=null,i=s=>{r!==null&&r!==s.type||(r=s.type,queueMicrotask(()=>{r=null}),n(s))};for(let s of e)t.addEventListener(s,i);return()=>{for(let s of e)t.removeEventListener(s,i)}}function Se(t){let e=typeof window<"u"&&window.clay&&window.clay.ready;e&&typeof e.then=="function"?e.then(()=>t(),()=>t()):t()}function Vt(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 xe(){let t=X("consent");return typeof t=="function"?t:null}function ke(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let n=X("undo");n&&n.flush&&n.flush();let r=e();if(r&&typeof r.then=="function")throw new Error("Sap.batch fn must be synchronous (it returned a promise)");return n&&n.commitCaptured&&n.commitCaptured(t),r}function $e(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())};yt(document,wr,e),yt(document,Ar,e);let n=!1,r=()=>{},i=()=>{if(n)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):(n=!0,r(),!0)};if(!i()){let s=yt(document,Zt,i),a=yt(document,yr,i);r=()=>{s(),a()};let R=X("ready");R&&typeof R.then=="function"&&R.then(i,()=>{})}}function Er(t){let e=t.tagName;if(e==="INPUT"){let n=(t.getAttribute("type")||"text").toLowerCase();return n==="checkbox"?"checkbox":n==="radio"?"radio":n==="number"||n==="range"?"number":n==="hidden"?"hidden":"text"}return e==="TEXTAREA"?"text":e==="SELECT"?t.multiple?"select-multiple":"select-one":"leaf"}function vr(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 Sr(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return vr(t);case"select-one":return t.value;case"select-multiple":return[...t.selectedOptions].map(n=>n.value);case"hidden":case"text":return t.value;case"leaf":return t.textContent;default:return t.value}}function xr(t,e,n){switch(e){case"checkbox":t.checked=!!n;break;case"radio":t.checked=String(t.value)===String(n);break;case"number":case"text":case"hidden":t.value=n==null?"":String(n);break;case"select-one":t.value=n==null?"":String(n);break;case"select-multiple":{let r=new Set((Array.isArray(n)?n:[n]).map(String));for(let i of t.options)i.selected=r.has(i.value);break}case"leaf":t.textContent=n==null?"":String(n);break;default:t.value=n==null?"":String(n)}}function _e(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}Vt(t)||wt(t)}function kr(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function P(t){let e=Er(t);return{el:t,kind:e,read(){return Sr(t,e)},write(n,r={}){xr(t,e,n),r.noMirror||_e(t),r.silent||kr(t)},mirror(){_e(t)}}}var ot=null,Ht=!1,At=null;function Te(t){let e=null;return{kind:"hub",subscribe(n){let r=t.onAnyChange({debounce:0,require:"observed"},n);typeof r=="function"&&(e=r)},suppress(n){t.pause();try{return n()}finally{t.resume()}},teardown(){if(e){try{e()}catch{}e=null}}}}function $r(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(r=>e(_r(r)));let n=typeof document<"u"&&document.body||typeof document<"u"&&document.documentElement;n&&t.observe(n,{childList:!0,subtree:!0,attributes:!0,characterData:!0})},suppress(e){let n=X("undo");n&&n.pause&&n.pause();try{return e()}finally{t&&t.takeRecords(),n&&n.resume&&n.resume()}},teardown(){t&&(t.disconnect(),t=null)}}}function _r(t){let e=[];for(let n of t)if(n.type==="attributes"){let r=n.target;r&&r.nodeType===1&&!zt(r)&&e.push({type:"attribute",element:r})}else if(n.type==="characterData"){let r=n.target&&n.target.parentElement;r&&!zt(r)&&e.push({type:"characterData",element:r})}else if(n.type==="childList"){for(let r of n.addedNodes)if(!(r.nodeType!==1||zt(r))&&(e.push({type:"add",element:r}),r.querySelectorAll))for(let i of r.querySelectorAll("*"))zt(i)||e.push({type:"add",element:i});for(let r of n.removedNodes)r.nodeType===1&&e.push({type:"remove",element:r,parent:n.target})}return e}function zt(t){return!!(t.closest&&t.closest("[sap-ignore],[template]"))}function Tr(t,e){t.pruneDisconnected();let n=new Set,r=!1;for(let i of e){let s=i.type==="remove"?i.parent:i.element,a=s&&t.appFor(s);a&&n.add(a),i.type==="add"&&i.element&&i.element.nodeType===1&&i.element.hasAttribute&&i.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(i.element))&&(r=!0)}r&&t.remountIfPresent();for(let i of n)i.root.isConnected&&t.schedule(i,"mutation")}function Ne(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 te(t,e){Ht=!0,ot=t,t.subscribe(n=>Tr(e,n))}function ee(t){if(Ht||typeof window>"u"||typeof document>"u")return;let e=X("Mutation");if(e&&typeof e.onAnyChange=="function"){te(Te(e),t);return}typeof MutationObserver=="function"&&(te($r(),t),At=yt(document,Zt,function(){let r=X("Mutation");r&&(At(),At=null,ot&&ot.teardown(),Ht=!1,te(Te(r),t))}))}function Le(){if(ot)try{ot.teardown()}catch{}At&&typeof document<"u"&&At(),ot=null,Ht=!1,At=null}var Nr=new Set(mt);function Et(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}Ne(()=>Lr(t,e)),t._viewsChanged&&(t._viewsChanged=!1,t.root.dispatchEvent(new CustomEvent("sap:views-updated",{bubbles:!0})))}function Lr(t,e){let n=t.root,r={},i=[],s=[],a=[],R=[],k=[],A=[],f=[],w=new Set;t.diag.errors=[];let N={root:r,state:r,item:null,ownerEl:n,projection:!1};function I(o,p){let l=p.attr||p.name,g=o.getAttribute(l);return g==null&&(g=$t(p),k.push({el:o,name:p.name,attr:l,value:Jt(ct(g,p.type),p.type)})),ct(g,p.type)}function W(o,p){let l=z(o.getAttribute("state")||"");o._sapStateDecls=l;for(let g of l){if(g.transient){p[g.name]=Pt(o,g);continue}if(gt(o,g)){p[g.name]=o.hasAttribute(g.attr);continue}p[g.name]=I(o,g)}}function h(o,p){if(!o.hasAttribute("bind"))return;let l=o.getAttribute("bind"),g=p.item||p.state,L=P(o);L.kind==="radio"?(l in g||(g[l]=""),o.checked&&(g[l]=o.value)):g[l]=L.read(),o.hasAttribute("transient")&&(o.removeAttribute("value"),o.removeAttribute("checked"))}function d(o,p){for(let l of o.attributes){let g=l.name,L=l.value;if(g.startsWith("calc:"))i.push({owner:p.item||p.state,ownerEl:p.ownerEl,name:g.slice(5),entry:H(L),el:o,ctx:p});else if(g==="text"||g.startsWith("text:"))s.push({el:o,kind:"text",fmt:g.includes(":")?g.slice(5):null,entry:H(L),ctx:p});else if(g==="show")s.push({el:o,kind:"show",entry:H(L),ctx:p});else if(g.startsWith("attr:"))s.push({el:o,kind:"attr",arg:g.slice(5),entry:H(L),ctx:p});else if(g.startsWith("class:"))s.push({el:o,kind:"class",arg:g.slice(6),entry:H(L),ctx:p});else if(g.startsWith("css:"))s.push({el:o,kind:"css",arg:g.slice(4),entry:H(L),ctx:p});else if(g==="effect")a.push({el:o,entry:H(L,!0),ctx:p});else if(g==="invalid")R.push({el:o,entry:H(L),ctx:p});else if(g.startsWith("show-when:")||g.startsWith("option:")){let C=g.slice(g.indexOf(":")+1);w.add(C),s.push({el:o,kind:"when",match:"show",field:C,values:L.split("|"),ctx:p})}else if(g.startsWith("hide-when:")){let C=g.slice(g.indexOf(":")+1);w.add(C),s.push({el:o,kind:"when",match:"hide",field:C,values:L.split("|"),ctx:p})}else if(g.startsWith("option-not:")){let C=g.slice(g.indexOf(":")+1);w.add(C),s.push({el:o,kind:"when",match:"show-not",field:C,values:L.split("|"),ctx:p})}}if(o.hasAttribute("bind")&&(p.view||p.projection)&&!Ot(o)){let l=o.getAttribute("bind");p.view?bt(de(p.item),l)?(o._sapViewBind="item",s.push({el:o,kind:"projection",field:l,ctx:p,from:"item"})):l in p.state||l in p.root?(o._sapViewBind="drawn",s.push({el:o,kind:"projection",field:l,ctx:p,from:"drawn"})):(o._sapViewBind=null,t.diag.error("E43",o,{attr:"bind",expr:l,problem:`bind="${l}" 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({el:o,kind:"projection",field:l,ctx:p})}}function m(o,p,l){Object.defineProperty(o,"$key",{value:Mt(p,"row"),enumerable:!1}),Object.defineProperty(o,"$index",{value:l,enumerable:!1}),Object.defineProperty(o,"$el",{value:p,enumerable:!1})}function y(o,p,l){W(o,p),o._sapScope=p,!l.projection&&o.hasAttribute("bind")&&h(o,l),d(o,l),o.hasAttribute("items")?$(o,p,l):E(o,p,l)}function E(o,p,l){K(o,(g,L)=>{L?g.hasAttribute("scope")?x(g,p,l):g.hasAttribute("items")?(d(g,l),$(g,p,l)):g.hasAttribute("detail")?B(g,p,l):g.hasAttribute("each")&&(d(g,l),f.push({el:g,ctx:l})):(!l.projection&&!l.view&&h(g,l),d(g,l))})}function x(o,p,l){let g=o.getAttribute("scope"),L={};p[g]=L;let C={root:l.root,state:L,item:null,ownerEl:o,projection:l.projection};y(o,L,C)}function $(o,p,l){let g=o.getAttribute("items"),L=[];p[g]=L,o._sapList=L,Z(o).forEach((C,Q)=>{let q={};m(q,C,Q);let rt={root:l.root,state:l.state,item:q,ownerEl:C,projection:l.projection};y(C,q,rt),L.push(q)})}function O(o,p){let l=String(o).split("."),g=C=>{for(let Q of l){if(C==null)return;C=Array.isArray(C)?C.flatMap(q=>q&&q[Q]!=null?q[Q]:[]):C[Q]}return C},L=g(p.state);return L===void 0?g(p.root):L}function B(o,p,l){for(let g of z(o.getAttribute("state")||""))g.name in p||(p[g.name]=gt(o,g)?o.hasAttribute(g.attr):I(o,g));A.push({el:o,parentObj:p,ctx:l})}function c(o,p,l){o._sapScope=p;let g=o.getAttribute("detail")||"",L=/^([\w.]+)\s+by\s+(.+)$/.exec(g);if(!L){o.hidden=!0,o._sapDetailRow=null;return}let C=L[1],Q=L[2].trim(),q=O(C,l),rt;try{rt=J(H(Q),{state:p,item:l.item,el:o,root:l.root})}catch{rt=void 0}let U=Array.isArray(q)&&rt!=null?q.find(V=>V&&typeof V=="object"&&V.$el&&String(V.$key)===String(rt)):null;if(o._sapDetailRow=U?U.$el:null,o.tagName==="DIALOG"){let V=U?String(U.$key):null;if(V!==o._sapDetailKey&&(o._sapDetailKey=V,o._sapDismissed=!1),!U){o._sapOpenedFor=null,o.open&&typeof o.close=="function"&&(o._sapEngineClose=!0,o.close());return}o.open?o._sapOpenedFor=V:(o._sapOpenedFor===V&&(o._sapDismissed=!0),o._sapOpenedFor=null,!o._sapDismissed&&o.isConnected&&typeof o.showModal=="function"&&(o.hidden&&(o.hidden=!1),o.showModal(),o._sapOpenedFor=V))}else{if(!U){o.hidden||(o.hidden=!0);return}o.hidden&&(o.hidden=!1)}let at={root:l.root,state:p,item:U,ownerEl:U.$el,projection:!0};d(o,at),E(o,U,at)}function u(o,p){for(let l=o.parentElement;l;l=l.parentElement)if(l._sapScope===p&&!l.hasAttribute("detail")||l.hasAttribute("sap"))return l;return n}function b(o,p){o._sapDrawnEl=u(o,p.state);let l=[...o.children].find(j=>j.tagName==="TEMPLATE"),g=l&&l.content.children.length===1?l.content.firstElementChild:null;if(!g)return t.diag.error("E42",o,{attr:"each",problem:"each needs one <template> child with exactly one element root"}),0;let L=o.getAttribute("each"),C;try{C=J(H(L),{state:p.state,item:p.item,el:o,root:p.root})}catch(j){return t.diag.error("E24",o,{attr:"each",expr:L,problem:String(j.message)}),0}if(!Array.isArray(C))return t.diag.error("E40",o,{attr:"each",expr:L,problem:"each must evaluate to an array; the list keeps its last good rows"}),0;let Q=H(o.getAttribute("key")||"item.$key"),q=[],rt=new Set;for(let j of C){let G;try{G=J(Q,{state:p.state,item:j,el:o,root:p.root})}catch{G=void 0}let M=G==null?"":String(G);if(M===""||rt.has(M))return t.diag.error("E41",o,{attr:"key",expr:Q.src,problem:M===""?"an item has no key; the list keeps its last good rows":`duplicate key "${M}"; the list keeps its last good rows`}),0;rt.add(M),q.push(M)}let U=o._sapEach||new Map,at=new Map,V=0,Gt=l;q.forEach((j,G)=>{let M=U.get(j);if(!M||M.parentElement!==o){M=o.ownerDocument.importNode(g,!0);let vt=(M.getAttribute("clay")||"").split(/\s+/).filter(Boolean);vt.includes("editor-ui")||M.setAttribute("clay",[...vt,"editor-ui"].join(" ")),M._sapEachRow=!0,V++}M.getAttribute("data-key")!==j&&M.setAttribute("data-key",j),Gt.nextElementSibling!==M&&(Ir(o,M,Gt),V++),M._sapEachItem=C[G],at.set(j,M),Gt=M});for(let[j,G]of U)at.get(j)!==G&&G.parentElement===o&&(G.remove(),V++);return o._sapEach=at,q.forEach((j,G)=>{let M=at.get(j),vt={root:p.root,state:p.state,item:C[G],ownerEl:M,projection:!1,view:!0};d(M,vt),E(M,{},vt)}),V}y(n,r,N);for(let o=0;o<A.length;o++){let{el:p,parentObj:l,ctx:g}=A[o];c(p,l,g)}if(k.length&&w.size)for(let o of k)w.has(o.attr)&&o.el.getAttribute(o.attr)==null&&o.el.setAttribute(o.attr,o.value);let v=new Map;for(let o of i){let p=v.get(o.owner);p||(p={ownerEl:o.ownerEl,list:[]},v.set(o.owner,p)),p.list.push(o)}let S=[...v.values()].sort((o,p)=>Ce(p.ownerEl)-Ce(o.ownerEl));for(let o of S){let p;try{p=Ae(o.list)}catch(l){t.diag.error("E07",o.list[0].el,{problem:l.message}),p=o.list}for(let l of p)try{l.owner[l.name]=J(l.entry,{state:l.ctx.state,item:l.ctx.item,el:l.el,root:l.ctx.root}),Ct(l.el)}catch(g){l.owner[l.name]=void 0,t.diag.error("E24",l.el,{attr:"calc:"+l.name,expr:l.entry.src,problem:String(g.message)}),ut(l.el,g.sapCode||"E24")}}let _=0;for(let o=0;o<f.length;o++)_+=b(f[o].el,f[o].ctx);let T=0,D=_;for(let o of s){let p=Dr(o,t);o.ctx.view?D+=p:T+=p}for(let o of a)Cr(o,t);for(let o of R)Mr(o);t._state=r,t._stats={fields:Object.keys(r).filter(o=>typeof r[o]!="function").length,calcs:i.length,paints:s.length,lists:v.size,writes:T,viewWrites:D},t._viewsChanged=D>0,t._lastPass={trigger:e.trigger||"refresh",writes:T},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${T}/${s.length}`)}function Rr(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 re(t,e,n,r){let i=t;for(;i&&i.nodeType===1;){if(i.hasAttribute&&i.hasAttribute(e)){let s=n.includes(i.getAttribute(e));if(r?!s:s)return!0}i=i.parentElement}return!1}function Re(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 n=P(t),r=n.read(),i=e??"";return String(r)!==String(i)?(n.write(i,{silent:!0}),1):0}function Dr(t,e){if(t.kind==="projection"){if(t.from==="drawn"){let r=t.field in t.ctx.state?t.ctx.state:t.ctx.root;return Re(t.el,r[t.field])}return Re(t.el,t.ctx.item?t.ctx.item[t.field]:"")}if(t.kind==="when")return De(t,null);let n={state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root};try{let r=J(t.entry,n),i=De(t,r);return Ct(t.el),i}catch(r){return e.diag.error(r.sapCode==="E22"?"E22":"E24",t.el,{attr:Rr(t),expr:t.entry&&t.entry.src,problem:String(r.message)}),ut(t.el,r.sapCode||"E24"),0}}function De(t,e){let n=t.el;switch(t.kind){case"text":{let r=t.fmt!=null?be(t.fmt,e):e==null?"":String(e);return n.textContent!==r?(n.textContent=r,1):0}case"show":{let r=!e;return n.hidden!==r?(n.hidden=r,1):0}case"when":{let r=X("optionVisibility");if(r&&r._started)return n._sapWhen&&n.hidden?(n.hidden=!1,n._sapWhen=!1,1):0;let i;t.match==="hide"?i=!re(n,t.field,t.values,!1):t.match==="show-not"?i=re(n,t.field,t.values,!0):i=re(n,t.field,t.values,!1),n._sapWhen=!0;let s=!i;return n.hidden!==s?(n.hidden=s,1):0}case"attr":{let r=t.arg;if((r==="checked"||r==="selected")&&typeof n[r]=="boolean"&&!n.hasAttribute("bind")&&!n.closest("select[bind]")){let s=0;return n[r]!==!!e&&(n[r]=!!e,s=1),!!e!==n.hasAttribute(r)&&(e?n.setAttribute(r,""):n.removeAttribute(r),s=1),s}if(Nr.has(r)){let s=n.hasAttribute(r);return e&&!s?(n.setAttribute(r,""),1):!e&&s?(n.removeAttribute(r),1):0}let i=typeof e=="boolean"?String(e):e==null?"":String(e);return n.getAttribute(r)!==i?(n.setAttribute(r,i),1):0}case"class":{let r=!!e;return n.classList.contains(t.arg)!==r?(n.classList.toggle(t.arg,r),1):0}case"css":{let r=e==null?"":String(e);return n.style.getPropertyValue("--"+t.arg)!==r?(n.style.setProperty("--"+t.arg,r),1):0}default:return 0}}function Cr(t,e){try{J(t.entry,{state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root}),Ct(t.el)}catch(n){e.diag.error("E24",t.el,{attr:"effect",expr:t.entry&&t.entry.src,problem:String(n.message)}),ut(t.el,"E24")}}function Mr(t){let e="";try{let n=J(t.entry,{state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root});e=typeof n=="string"?n:""}catch{e=""}typeof t.el.setCustomValidity=="function"&&t.el.setCustomValidity(e)}function Ce(t){let e=0,n=t;for(;n&&!(n.hasAttribute&&n.hasAttribute("sap"));)n=n.parentElement,e++;return e}function Ir(t,e,n){let r=n.nextSibling;if(e.isConnected&&t.moveBefore)try{t.moveBefore(e,r);return}catch{}t.insertBefore(e,r)}var Or=new Set(mt),Me=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode"]),Fr=new Set(["show-when","hide-when","option","option-not"]),Pr=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,Ie=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 Wr(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function ne(t){return t.hasAttribute("bind")}function Br(t,e){e(t);for(let r of t.children)n(r);function n(r){if(r.nodeType===1&&!r.hasAttribute("sap-ignore")){if(r.tagName==="TEMPLATE"){if(r.hasAttribute("items"))for(let i of r.content.children)n(i);return}e(r);for(let i of r.children)n(i)}}}function jt(t,e){let n=!1,r=(a,R,k)=>{e.error(a,R,k),n=!0},i=t.ownerDocument.createTreeWalker(t,4),s;for(;s=i.nextNode();)if(/\{\{.*\}\}/.test(s.nodeValue||"")){r("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 Br(t,a=>{let R=a.closest&&a.closest("[detail]");for(let k of[...a.attributes]){let A=k.name,f=ce(A);if(f){r("E01",a,{attr:A,expr:k.value,problem:`"${A}" is a foreign-dialect attribute; Sap has no ${A.split(/[:=]/)[0]} directive`,fix:f+" \u2014 or wrap the subtree in sap-ignore if intentional"});continue}if(A.includes(":")){let N=A.slice(0,A.indexOf(":"));if(Me.has(N)){if(Fr.has(N)&&Pr.test(k.value)){let I=A.slice(A.indexOf(":")+1);e.warn("W04",a,{attr:A,expr:k.value,problem:`${N}: compares the "${I}" attribute against a literal value, not a JS expression`,fix:`use show="${k.value}" for an expression, or a literal like ${N}:${I}="overview"`})}}else{let I=xt(N,[...Me]);e.warn("W03",a,{attr:A,problem:`unknown "${N}:" attribute`,didYouMean:I?`${I}:`:null})}}else if(!Ie.has(A)&&!St.has(A)&&!Or.has(A)&&!/^(data-|aria-|on)/.test(A)&&!(A in a)){let N=xt(A,[...Ie]);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=ne(a)||A==="attr:selected"&&a.tagName==="OPTION"&&!!a.closest("select[bind]");(A==="attr:value"||A==="attr:checked"||A==="attr:selected")&&w&&r("E30",a,{attr:A,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),A==="effect"&&ne(a)&&/\b(value|checked)\s*=[^=]/.test(k.value)&&r("E30",a,{attr:A,expr:k.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")&&Wr(a)&&(A==="show"||r("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 k=z(a.getAttribute("state")),A=new Set;for(let f of k){f.name.includes("-")&&r("E08",a,{attr:"state",problem:`field "${f.name}" is not a valid identifier (the hyphen parses as subtraction)`,fix:`rename to ${f.name.replace(/-/g,"")}`}),A.has(f.name)&&r("E04",a,{attr:"state",problem:`field "${f.name}" is declared twice in one scope`}),A.add(f.name),Rt.has(f.attr)&&r("E05",a,{attr:"state",problem:`"${f.name}" is a reserved Sap word`}),St.has(f.attr)&&r("E06",a,{attr:"state",problem:`"${f.name}" is a global HTML attribute name; pick another field name`}),f.name==="open"&&a.tagName==="DIALOG"&&r("E33",a,{attr:"state",problem:"dialog open is transient",fix:"use showModal() \u2014 declare state= only on <details> or popovers"});let w=Qt(a,f.attr);w&&(f.attr==="checked"||f.attr==="selected")&&r("E35",a,{attr:"state",problem:`"${f.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&&f.type==="num"&&r("E35",a,{attr:"state",problem:`"${f.attr}" is an HTML boolean attribute; it cannot hold a number`,fix:`declare it bare: state="${f.attr}"`}),f.transient&&(w||f.type==="presence")&&r("E35",a,{attr:"state",problem:`"${f.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(ne(a)){if(a.hasAttribute("-"),a.tagName==="INPUT"){let k=(a.getAttribute("type")||"text").toLowerCase();k==="file"&&r("E32",a,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),k==="password"&&!a.hasAttribute("transient")&&r("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 k=a.getAttribute("contenteditable");!(k!=null&&k!=="false")&&a.children.length>0&&r("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")&&r("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 k=a.parentElement;(!k||!k.hasAttribute("items"))&&r("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")&&R&&r("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 k=t.querySelector(`[trigger-add="${a.getAttribute("items")}"]`);!Ft(a)&&!Kt(t,a.getAttribute("items"))&&Z(a).length===0&&k&&r("E17",a,{attr:"items",problem:`trigger-add targets items="${a.getAttribute("items")}" but it has no [item template] to clone`})}}),n&&(e.halted=!0,e.haltReason=e.errors[0]?e.errors[0].code:"halt",ut(t,e.haltReason)),!n}var Oe="sap-styles",Fe="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",oe=new WeakSet;function qr(t){if(oe.has(t))return;let e=t.defaultView,n=e&&e.CSSStyleSheet;if(n&&"adoptedStyleSheets"in t)try{let r=new n;r.replaceSync(Fe),t.adoptedStyleSheets=[...t.adoptedStyleSheets,r],oe.add(t);return}catch{}if(!t.getElementById(Oe)){let r=t.createElement("style");r.id=Oe,r.textContent=Fe,(t.head||t.documentElement).appendChild(r)}oe.add(t)}var Vr=0;function Pe(){return typeof performance<"u"&&performance.now?performance.now():0}function ie(t){let e=t.id||t.getAttribute("sap")||`app-${Vr++}`,n=new pt(e),r={root:t,name:e,diag:n,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!jt(t,n))return r.halted=!0,r;qr(t.ownerDocument);for(let a of t.querySelectorAll("textarea[data-value]"))qt(a);let s=Pe();return Et(r,{trigger:"mount"}),r._mountMs=Pe()-s,r._mountWrites=r._stats?r._stats.writes:0,r._mountWrites>0&&n.warn("W30",t,{problem:`${r._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)"}),r}var zr=["for","form","list","headers","popovertarget","commandfor","anchor","aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"];function Hr(t,e){let n=null;return K(t,r=>{!n&&r.getAttribute("scope")===e&&(n=r)}),n}function We(t,e,n){let r=Y(t)||e;for(;r;){for(let i of z(r.getAttribute("state")||""))if(i.name===n)return{el:r,decl:i};if(r.hasAttribute("sap"))break;r=Y(r.parentElement)}return null}function jr(t){return typeof t=="number"?"num":typeof t=="boolean"?"bool":"string"}function Be(t){function e(h){let d=t.appFor(h);if(!d)return null;let m=ft(h),y=m&&m._sapEachItem&&m._sapEachItem.$el;if(y&&y.isConnected)return{ctxEl:y,appRec:d,isRow:!0};let E=kt(h);if(E)return E._sapDetailRow?{ctxEl:E._sapDetailRow,appRec:d,isRow:!0}:{ctxEl:Y(E.parentElement)||d.root,appRec:d,isRow:!1};let x=It(h);if(x&&x.hasAttribute("item"))return{ctxEl:x,appRec:d,isRow:!0};let $=Y(h)||d.root;return{ctxEl:$,appRec:d,isRow:$.hasAttribute("item")}}function n(h){let d=typeof h=="string"?document.querySelector(h):h;if(!d||d.nodeType!==1)return null;let m=e(d);return m?W(m.ctxEl,m.appRec,m.isRow):null}function r(h,d){let m=ft(h);if(!m)return n(h);let y=t.appFor(h),E=m._sapEachItem&&m._sapEachItem.$el;if(E&&E.nodeType===1&&E.hasAttribute("item")&&bt(E,d))return E.isConnected?W(E,y,!0):null;let x=m.parentElement&&m.parentElement._sapDrawnEl;return!x||!x.isConnected?null:W(x,y,x.hasAttribute("item"))}function i(h,d,m){let y=lt(h,m);if(y)return P(y).read();let E=ht(h,m);if(E)return Z(E).map(B=>W(B,d,!0));let x=Hr(h,m);if(x)return W(x,d,!1);let $=We(h,d.root,m);if($)return $.decl.transient?Pt($.el,$.decl):pe($.el,$.decl);let O=h._sapScope;return O?O[m]:void 0}function s(h,d,m,y,E){y.transient?Tt(h,y,m):_t(h,y,m),t.schedule(E,"set:"+d)}function a(h,d){let m=new Set,y=Y(h)||d;for(;y;){for(let E of z(y.getAttribute("state")||""))m.add(E.name);if(y.hasAttribute("sap"))break;y=Y(y.parentElement)}return K(h,E=>{let x=E.getAttribute("bind");x&&m.add(x)}),m}function R(h,d,m,y){let E=lt(h,m);if(E){P(E).write(y);return}let x=h;for(;x;){for(let S of x.attributes)if(S.name==="calc:"+m){d.diag.error("E16",x,{attr:"calc:"+m,problem:`"${m}" is a computed field; computed fields are read-only`});return}if(x.hasAttribute("sap"))break;x=x.parentElement}let $=We(h,d.root,m);if($){s($.el,m,y,$.decl,d);return}let O=a(h,d.root);O.delete(m);let B=m.length>=4?xt(m,[...O]):null;if(B){d.diag.error("E12",h,{key:m,problem:`unknown state key "${m}"`,didYouMean:B});return}if(Rt.has(m)||St.has(m)){d.diag.error("E15",h,{key:m,problem:`cannot write undeclared field "${m}" \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=jr(y),b=c.getAttribute("state")||"",v=u==="string"?m:`${m}:${u}`;c.setAttribute("state",b?`${b} ${v}`:v),s(c,m,y,{name:m,attr:m,type:u,transient:!1},d)}function k(h){let d=h.ownerDocument,m=new Map,y=(E,x)=>{let $=le(d),O=E.getAttribute(x);O&&x==="id"&&m.set(O,$),E.setAttribute(x,$)};h.querySelectorAll("[id]").forEach(E=>y(E,"id")),h.querySelectorAll("[data-id]").forEach(E=>y(E,"data-id")),h.querySelectorAll("[sap-error]").forEach(E=>E.removeAttribute("sap-error")),h.removeAttribute("sap-error"),h.hasAttribute("data-id")?(h.removeAttribute("id"),y(h,"data-id")):y(h,"id");for(let E of[h,...h.querySelectorAll("*")])for(let x of zr){let $=E.getAttribute(x);if($==null)continue;let O=$.split(/\s+/).map(B=>m.get(B)||B).join(" ");O!==$&&E.setAttribute(x,O)}}function A(h,d,m){let y=Nt(d.root,h,m);if(!y)return d.diag.error("E17",h,{problem:`cannot resolve a list named "${m}" from here`}),null;let E=Ft(y);if(!E)return d.diag.error("E17",y,{problem:`items="${m}" has no [item template] to clone`}),null;let x=y.ownerDocument.importNode(E,!0);return x.removeAttribute("template"),k(x),y.appendChild(x),t.schedule(d,"trigger-add:"+m),W(x,d,!0)}function f(h,d){K(h,m=>{if(m.hasAttribute("bind")){let y=P(m),E=m.getAttribute("default");y.kind==="checkbox"||y.kind==="radio"?y.write(E!=null?E===""||E==="true"||m.value===E:m.hasAttribute("checked")):y.write(E??(m.getAttribute("value")||""))}});for(let m of z(h.getAttribute("state")||"")){let y=me(h,m);m.transient?Tt(h,m,y):_t(h,m,y)}t.schedule(d,"trigger-reset")}function w(h,d){if(!h.isConnected)throw new Error("stale row handle: $remove() on a removed row");h.remove(),t.schedule(d,"trigger-remove")}function N(h,d,m){if(!h.isConnected)throw new Error("stale row handle: $move() on a removed row");let y=null;if(m&&m.nodeType===1?y=m:typeof m=="string"&&(y=Nt(d.root,h,m)),!y){d.diag.error("E17",h,{problem:`$move() cannot resolve target "${m}"`});return}t.moveInto(y,h),t.schedule(d,"trigger-move")}function I(h){let d=h.parentElement;return d?Z(d).indexOf(h):-1}function W(h,d,m){let y={get $el(){return h},get $key(){return Mt(h,m?"row":"scope")},get $index(){return I(h)},$add(x){return A(h,d,x)},$reset(){return f(h,d),E},$remove(){w(h,d)},$move(x){N(h,d,x)},get $appRec(){return d}},E=new Proxy(y,{get(x,$){return typeof $=="symbol"||$[0]==="$"?x[$]:i(h,d,$)},set(x,$,O){return typeof $=="string"&&$[0]==="$"?(x[$]=O,!0):(R(h,d,$,O),!0)},has(x,$){return typeof $=="string"&&$[0]==="$"?$ in x:i(h,d,$)!==void 0}});return E}return{Sap:n,contextElFor:e,readField:i,writeField:R,makeProxy:W,writeTargetFor:r}}var Ur=["trigger-add","trigger-remove","trigger-reset"];function Gr(t){if(t.nodeType!==1)return!1;for(let e of t.attributes){let n=e.name;if(n.startsWith("set:")||n.startsWith("move:")||n.startsWith("sort:")||Ur.includes(n))return!0}return!1}function Yr(t,e){let n=t,r=e.parentElement;for(;n&&n!==r;){if(n.nodeType===1&&Gr(n)&&!(n.tagName==="FORM"&&n.hasAttribute("trigger-add")))return n;n=n.parentElement}return null}function qe(t,e){let{Sap:n}=e;function r(c,u){let b=null,v=ft(c),S=kt(c);if(v)b=v._sapEachItem??null;else if(S&&S._sapDetailRow)b=S._sapDetailRow._sapScope||null;else{let D=It(c);D&&D.hasAttribute("item")&&(b=D._sapScope||null)}return{state:(Y(c)||u.root)._sapScope||u._state||{},item:b,el:c,root:u._state||{}}}function i(c,u,b){if(!c.hasAttribute("confirm")){b();return}let v=c.getAttribute("confirm"),S=v,_=H(v);if(!_.error)try{let o=J(_,r(c,u));(typeof o=="string"||typeof o=="number")&&(S=String(o))}catch{}let T=xe();if(!T){window.confirm(S)&&b();return}if(c._sapGatePending)return;c._sapGatePending=!0;let D=()=>{c._sapGatePending=!1};T(S,()=>{D(),b()}).catch(D)}function s(c,u){for(let b of c.attributes){if(!b.name.startsWith("set:"))continue;let v=b.name.slice(4),S=H(b.value);if(S.error){u.diag.error("E08",c,{attr:b.name,expr:b.value,problem:String(S.error.message)});continue}let _;try{_=J(S,r(c,u))}catch(D){u.diag.error("E24",c,{attr:b.name,expr:b.value,problem:String(D.message)});continue}let T=e.writeTargetFor(c,v);T&&(T[v]=_)}}function a(c){let u=ft(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 R(c,u){let b=a(c);if(!b)return;let v=Z(b.parentElement),S=v.indexOf(b);u==="up"&&S>0?t.placeBefore(b,v[S-1]):u==="down"&&S<v.length-1&&t.placeBefore(v[S+1],b)}function k(c,u,b){if(u)return Nt(b.root,c,u);let v=c;for(;v;){if(v.hasAttribute&&v.hasAttribute("items"))return v;v=v.parentElement}let S=Y(c)||b.root,_=[];return K(S,T=>{T.hasAttribute("items")&&_.push(T)}),_[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 S=Number(c),_=Number(u);return!Number.isNaN(S)&&!Number.isNaN(_)?S-_:String(c)<String(u)?-1:String(c)>String(u)?1:0}function f(c,u,b,v){let S=k(c,b,v);if(!S){v.diag.error("E17",c,{attr:"sort:"+u,problem:`no items list resolvable for sort:${u}`});return}let _=Z(S),T=l=>l._sapScope?l._sapScope[u]:void 0,D=[..._].sort((l,g)=>A(T(l),T(g))),p=D.every((l,g)=>l===_[g])?[...D].reverse():D;for(let l of p)t.moveInto(S,l);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){i(c,u,()=>{let b=n(c);for(let v of[...c.attributes]){let S=v.name;if(S==="trigger-remove")b&&b.$remove();else if(S==="trigger-reset")b&&b.$reset();else if(S==="trigger-add"){let _=b&&b.$add(v.value);_&&w(_.$el)}else S==="move:up"?(R(c,"up"),t.schedule(u,"move:up")):S==="move:down"?(R(c,"down"),t.schedule(u,"move:down")):S.startsWith("move:to")?b&&b.$move(v.value):S.startsWith("sort:")&&f(c,S.slice(5),v.value,u)}[...c.attributes].some(v=>v.name.startsWith("set:"))&&s(c,u)})}function I(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;let v=Yr(u,b.root);v&&N(v,b)}function W(c){let u=P(c),b=c.getAttribute("default");u.kind==="checkbox"?u.write(b===""||b==="true"):u.write(b??"")}function h(c,u,b){let v=n(c);if(!v)return;let S=v.$add(b);if(!S)return;let _=[];K(c,T=>{T.hasAttribute("bind")&&_.push(T)});for(let T of _){if(T.type==="radio"&&!T.checked)continue;let D=T.getAttribute("bind"),o=lt(S.$el,D);o?P(o).write(P(T).read()):bt(S.$el,D)&&(S[D]=P(T).read())}_.forEach(W),_.length?typeof _[0].focus=="function"&&_[0].focus():w(S.$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(),i(u,b,()=>h(u,b,u.getAttribute("trigger-add"))))}function m(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 S=z(u.getAttribute("state")||"").find(T=>T.name===b[1]);if(S){S.transient?Tt(u,S,""):_t(u,S,""),t.schedule(v,"close");return}let _=n(u.parentElement);_&&_[b[1]]!==""&&(_[b[1]]="")}function x(c){let u=c.target;if(!u||u.nodeType!==1)return;let b=t.appFor(u);if(!b)return;u.hasAttribute("persist")&&!Vt(u)&&wt(u);let v=u.hasAttribute("bind")&&Ot(u);if(!v&&u.hasAttribute("bind")&&ft(u)){let _=u.getAttribute("bind"),T=u._sapViewBind?e.writeTargetFor(u,_):null;T&&(T[_]=P(u).read());return}let S=kt(u);if(S&&S._sapDetailRow&&u.hasAttribute("bind")&&!v){let _=S._sapDetailRow,T=u.getAttribute("bind"),D=lt(_,T);if(D&&D!==u){P(D).write(P(u).read());return}if(!D&&z(_.getAttribute("state")||"").some(o=>o.name===T)){e.writeField(_,b,T,P(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 O(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 S=tt(u.getAttribute("step"))||1,_=c.key==="ArrowUp"?1:-1,T=tt(u.value)+S*(c.shiftKey?10:1)*_,D=u.getAttribute("min"),o=u.getAttribute("max");D!==null&&D!==""&&T<tt(D)&&(T=tt(D)),o!==null&&o!==""&&T>tt(o)&&(T=tt(o)),P(u).write(String(Number(T.toFixed(2))))}function B(c=document){c.addEventListener("click",I),c.addEventListener("submit",d),c.addEventListener("reset",m),c.addEventListener("toggle",y,!0),c.addEventListener("close",E,!0),c.addEventListener("input",x),c.addEventListener("change",x),c.addEventListener("clay:sorted",$),c.addEventListener("keydown",O)}return{install:B}}var Ve=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function se(t){return`${t.tagName.toLowerCase()}[sap]`}function Xr(t){let e=0;for(let n of t.querySelectorAll("*"))for(let r of n.attributes)if(Ve.test(r.name)){e++;break}for(let n of t.attributes)if(Ve.test(n.name)){e++;break}return e}function ze(t){let e=[],n=r=>{for(let i of r.attributes){let s=i.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:r,attr:s,src:i.value})}};n(t);for(let r of t.querySelectorAll("*"))n(r);return e}function He(t){function e(f){let w=f._stats||{},N=f.root;return{root:se(N),fields:w.fields||0,calcs:w.calcs||0,paints:w.paints||0,actions:Xr(N),lists:(N.hasAttribute("items")?1:0)+N.querySelectorAll("[items]").length,rows:N.querySelectorAll("[item]:not([template])").length,warnings:f.diag.warnings.length,errors:f.diag.errors.length,mountWrites:f._mountWrites||0,ms:Math.round((f._mountMs||0)*10)/10,passes:f._passes||0,lastPass:f._lastPass||null,ok:f.diag.errors.length===0&&!f.halted}}function n(){let f=t.apps().map(e);return{ok:f.every(w=>w.ok),apps:f}}function r(f){let w=e(f);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 i(){for(let f of t.apps()){let w=r(f);f.diag.errors.length||f.halted?console.error(w):console.log(w)}}function s(){let f=[],w=[];for(let N of t.apps())f.push(...N.diag.errors),w.push(...N.diag.warnings);return{ok:f.length===0,errors:f,warnings:w,counts:{errors:f.length,warnings:w.length}}}function a(f){return f?typeof f=="string"?document.querySelector(f):f.nodeType===1?f:null:null}function R(f,w){let N=a(f);if(!N)return console.warn("sap why: element not found"),null;let I=[`sap why <${N.tagName.toLowerCase()}> \u2014 ${Dt(N)}`],W=[...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 W)I.push(` ${d.name}="${d.value}"`);let h=N;for(;h&&!h._sapScope;)h=h.parentElement;if(h&&h._sapScope){let d=h._sapScope,m=w?[w]:Object.keys(d);I.push(" reads:");for(let y of m){let E=d[y];typeof E!="function"&&I.push(` ${y} = ${JSON.stringify(Array.isArray(E)?`[${E.length} rows]`:E)}`)}}return I.push(" serialization: textContent and value/checked attributes save with the file; reads live from properties"),console.log(I.join(`
|
|
10
|
-
`)),null}function
|
|
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]"))}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 q=i.firstElementChild;q;q=q.nextElementSibling){let Y=vt(q);if(!Y.item||Y.template)continue;let X={};p(X,q,I);let U={root:f.root,state:f.state,item:X,ownerEl:q,projection:f.projection};y(q,X,U),T.push(X),I++}}function H(i,h){let f=String(i).split("."),g=I=>{for(let q of f){if(I==null)return;I=Array.isArray(I)?I.flatMap(Y=>Y&&Y[q]!=null?Y[q]:[]):I[q]}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],q=T[2].trim(),Y=H(I,f),X;try{X=Et(W(q),{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(W(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 q=W(i.getAttribute("key")||"item.$key"),Y=[],X=new Set;for(let B of I){let K;try{K=dt(q,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:q.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=W(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=W(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 _=hn(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 hn(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 gn="0.5.1";var tt=new Map,it=[],Ae=Ee($t);function br(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 gr(){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 wr(t,e){if(t.moveBefore)try{t.moveBefore(e,null);return}catch{}t.appendChild(e)}function yr(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:br,isRegistered:t=>tt.has(t),pruneDisconnected:gr,schedule:(t,e)=>Ae.schedule(t,e),runNow:(t,e)=>Ae.runNow(t,e),moveInto:wr,placeBefore:yr,remountIfPresent:()=>te()},yn=dn(mt),Ar=pn(mt,yn),st=bn(mt),wn=!1;function An(){wn||(wn=!0,Ar.install(document),Xe(mt))}function te(t=document){An(),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 En(t){if(An(),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=yn.Sap;O.version=gn;O.refresh=function(){for(let e of it)e.root.isConnected&&Ae.runNow(e,"refresh")};O.batch=Ye;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=En;O.config=function(e={}){return e.formats&&Object.assign(At,e.formats),O};O._registry=tt;O._reset=function(){tt.clear(),it.length=0,en()};function Er(){if(typeof document>"u")return;let t=()=>Ue(()=>te());document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}Er();typeof window<"u"&&(window.Sap=O);var vr=O;return _n(xr);})();
|
|
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 || {};
|