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