@panphora/clayjs 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 K=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var n in t)K(e,n,{get:t[n],enumerable:!0})},De=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of je(t))!Pe.call(e,r)&&r!==n&&K(e,r,{get:()=>t[r],enumerable:!(o=Ie(t,r))||o.enumerable});return e};var Le=e=>De(K({},"__esModule",{value:!0}),e);var tt={};fe(tt,{applyData:()=>se,default:()=>et,engine:()=>z,extractData:()=>le});var F=["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"],G=new Set(F),ue=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),X=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var V={};fe(V,{EmptyListInsert:()=>k,MAX_RULE_DEPTH:()=>j,MaxRuleDepthExceeded:()=>C,RuleTargetReadOnly:()=>$,RulesParseError:()=>I,ShapeMismatch:()=>v,UnknownRulesVersion:()=>_});var I=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,C=class extends Error{constructor(t){super(`rule depth exceeded ${j} 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}},k=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}},$=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function b(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}function Y(e){let t=b(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function N(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Q(e,t,n,{depth:0,path:[]},o)}function Q(e,t,n,o,r){if(o.depth>j)throw new C(o.path);if(typeof n=="string")return _e(e,t,n,o,r);if(Array.isArray(n)){let[i,c]=n,l=e.find(t,i,r);return de(r,o,l),l.map((s,u)=>Q(e,s,c,{depth:o.depth+1,path:[...o.path,u]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[c,l]of Object.entries(n))i[c]=Q(e,t,l,{depth:o.depth+1,path:[...o.path,c]},r);return i}return null}function _e(e,t,n,o,r){if(n.endsWith("[]")){let l=n.slice(0,-2),s=e.find(t,l,r);return de(r,o,s),s.map(u=>e.text(u))}if(n.startsWith("@"))return ae(e,t,n.slice(1));let i=b(n);if(i!==-1){let l=n.slice(0,i),s=n.slice(i+1),u=l?e.find(t,l,r):[t];return u.length===0?null:ae(e,u[0],s)}if(n===".")return e.text(t);let c=e.find(t,n,r);return c.length===0?null:e.text(c[0])}function de(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function ae(e,t,n){if(G.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}function me(e,t,n,o){let r=e.length,i=t.length,c=new Array(r).fill(-1);if(o){let f=new Set;for(let h=0;h<r;h++){let y=o[h];!(y>=0&&y<i)||f.has(y)||(c[h]=y,f.add(y))}}if(r===0||i===0)return c;let l=e.map(f=>he(f,n)),s=t.map(f=>he(f,n)),u=new Array(i).fill(!1);for(let f of c)f>=0&&(u[f]=!0);let a=new Map;s.forEach((f,h)=>{u[h]||a.set(f,a.has(f)?-1:h)});let g=new Map;l.forEach((f,h)=>{c[h]>=0||g.set(f,(g.get(f)||0)+1)}),l.forEach((f,h)=>{if(c[h]>=0||g.get(f)!==1)return;let y=a.get(f);y===void 0||y===-1||u[y]||(c[h]=y,u[y]=!0)});let d=[];for(let f=0;f<r;f++)c[f]<0&&d.push(f);let x=[];for(let f=0;f<i;f++)u[f]||x.push(f);if(d.length===0||x.length===0)return c;let m=r*i+1,p=(f,h)=>ve(e[f],t[h],n)*m+Math.abs(f-h);for(let[f,h]of ke(d,x,p))c[f]=h;return c}var ye=e=>typeof e=="object"&&e!==null;function he(e,t){if(!ye(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function ve(e,t,n){if(!ye(n))return e===t?0:1;let o=Object.keys(n);if(o.length===0)return 0;let r=0;for(let i of o){let c=JSON.stringify(e?.[i]),l=JSON.stringify(t?.[i]);c!==l&&r++}return r}function ke(e,t,n){return e.length<=t.length?pe(e,t,n,!1):pe(t,e,(o,r)=>n(r,o),!0)}function pe(e,t,n,o){let r=e.length,i=t.length,c=[];for(let g=0;g<=r;g++)c.push(new Float64Array(i+1).fill(1/0));let l=[];for(let g=0;g<=r;g++)l.push(new Uint8Array(i+1));for(let g=0;g<=i;g++)c[r][g]=0;for(let g=r-1;g>=0;g--)for(let d=i-1;d>=0;d--){let x=n(e[g],t[d])+c[g+1][d+1],m=c[g][d+1];x<=m?(c[g][d]=x,l[g][d]=1):c[g][d]=m}let s=[],u=0,a=0;for(;u<r&&a<i;)l[u][a]&&(s.push(o?[t[a],e[u]]:[e[u],t[a]]),u++),a++;return s}function ee(e,t,n,o,r,i,c,l={}){let s=e.find(t,n,l);if(r.length===0){s.forEach(E=>e.remove(E)),Z(l,"onRowsApplied",i.path,[]);return}let u=r.length>s.length,a=s[0]||null;if(u&&!a&&(a=Be(e,t,n,l),!a))throw new k(i.path);let g=s.map(E=>We(e,E,o,l)),d=null;if(u&&a){d=e.clone(a),l.templateAttr&&e.removeAttr(d,l.templateAttr);let E=e.stripIds(d);E>0&&console.warn(`[hyper-html-api] stripped ${E} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let x=me(r,g,o,$e(e,s,r,i,l)),m=s[0]||a,p=e.parent(m),f=s.length>0?ge(e,p,m):0,h=qe(e,s),y=new Set,A=[],O=r.map((E,w)=>{let T=x[w];if(T>=0)return y.add(T),A.push(!1),s[T];A.push(!0);let S=e.clone(d);return e.stripIds(S),S});s.forEach((E,w)=>{y.has(w)||e.remove(E)}),h?O.forEach((E,w)=>{let T=f+w;e.children(p).findIndex(Me=>e.sameNode(Me,E))!==T&&e.insertAt(p,E,T)}):Ue(e,O,A,p,f),He(e,O,o,r,i,c,l),Z(l,"onRowsApplied",i.path,O)}function Z(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function $e(e,t,n,o,r){let i=Z(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let c=new Array(n.length).fill(-1),l=new Set;for(let s=0;s<n.length;s++)if(i[s]){for(let u=0;u<t.length;u++)if(!(l.has(u)||!e.sameNode(t[u],i[s]))){c[s]=u,l.add(u);break}}return c}function He(e,t,n,o,r,i,c){t.forEach((l,s)=>{if(n===null){let u=o[s],a=u==null?"":String(u);e.text(l)!==a&&e.text(l,a)}else{let u=i(e,l,n,o[s],{depth:r.depth+1,path:[...r.path,s]},c);u&&u!==l&&(t[s]=u)}})}function We(e,t,n,o){return n===null?e.text(t):N(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function ge(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Be(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let i=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let c of i)if(e.attr(c,o.templateAttr)!=null)return c;r=e.parent(r)}return null}function qe(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=e.children(n),r=[];for(let i of t){let c=o.findIndex(l=>e.sameNode(l,i));if(c===-1)return!1;r.push(c)}return r.sort((i,c)=>i-c),r[r.length-1]-r[0]===r.length-1}function Ue(e,t,n,o,r){let i=null,c=r;for(let l=0;l<t.length;l++){if(!n[l]){i=t[l];continue}let s=i?e.parent(i):o;if(!s)continue;let u=i?ge(e,s,i)+1:c++;e.insertAt(s,t[l],u),i=t[l]}}var Ee=new Set(["checked","selected","disabled","readOnly","paused"]);function P(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let i=[];if(te(n,o,[],i),i.length)throw new v(i);J(e,t,n,o,{depth:0,path:[]},r)}function J(e,t,n,o,r,i={}){if(r.depth>j)throw new C(r.path);if(o===void 0)return t;if(typeof n=="string")return ze(e,t,n,o,r,i);if(Array.isArray(n)){let[c,l]=n;return ee(e,t,c,l,o,r,J,i),t}if(typeof n=="object"&&n!==null){for(let[c,l]of Object.entries(n)){let s=J(e,t,l,o==null?o:o[c],{depth:r.depth+1,path:[...r.path,c]},i);s&&s!==t&&(t=s)}return t}return t}function ze(e,t,n,o,r,i){if(n.endsWith("[]")){let s=n.slice(0,-2);return ee(e,t,s,null,o,r,J,i),t}if(n.startsWith("@"))return we(e,t,n.slice(1),o);let c=b(n);if(c!==-1){let s=n.slice(0,c),u=n.slice(c+1),a=s?e.find(t,s,i):[t];return a.length===0||we(e,a[0],u,o),t}if(n===".")return Te(e,t,o),t;let l=e.find(t,n,i);return l.length===0||Te(e,l[0],o),t}function Te(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function we(e,t,n,o){if(X.has(n))throw new $(n);if(n==="outerHTML"){let i=o==null?"":String(o);return e.replaceWith(t,i)}if(ue.has(n)){let i=Fe(n,o);return e.prop(t,n)!==i&&e.prop(t,n,i),t}let r=o==null?"":String(o);return e.attr(t,n)!==r&&e.attr(t,n,r),t}function Fe(e,t){return t==null?Ee.has(e)?!1:"":Ee.has(e)?t==="false"?!1:!!t:t}function te(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:W([...n,i]),expected:"scalar",got:H(r)})}):o.push({path:W(n),expected:"array",got:H(t)});return}t!==null&&typeof t=="object"&&o.push({path:W(n),expected:"scalar",got:H(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:W(n),expected:"array",got:H(t)});return}let r=e[1];t.forEach((i,c)=>te(r,i,[...n,c],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:W(n),expected:"object",got:H(t)});return}for(let[r,i]of Object.entries(e))te(i,t[r],[...n,r],o)}}}function H(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function W(e){return e.join(".")}function ne(e){try{return JSON.parse(e)}catch(t){throw new I(`Invalid strict JSON: ${t.message}`,t)}}function B(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 i=[],c=0;for(;c<r.length;){let l=r[c];if(/\s/.test(l)){c++;continue}if("{}".includes(l)){i.push({type:l,value:l}),c++;continue}if(l==="["){let g=!1,d=c+1;for(;d<r.length&&/\s/.test(r[d]);)d++;if(d<r.length&&/[a-zA-Z_]/.test(r[d])&&(g=!0),!g){i.push({type:l,value:l}),c++;continue}}if(l==="]"){i.push({type:l,value:l}),c++;continue}if(l===":"){i.push({type:t.COLON,value:l}),c++;continue}if(l===","){i.push({type:t.COMMA,value:l}),c++;continue}if(l==='"'||l==="'"){let g=l,d=c+1;for(;d<r.length&&r[d]!==g;)r[d]==="\\"&&d++,d++;i.push({type:t.STRING,value:r.substring(c+1,d),quoted:!0,sourceQuote:g}),c=d+1;continue}let s=c,u;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let g=[":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 x of g){let m=x.substring(1);if(r.substring(s+1,s+1+m.length)===m){d=!0,s+=m.length;break}}if(!d)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let g=r[s];for(s++;s<r.length&&r[s]!==g;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;u=r.substring(c,s);let a=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?a=t.NUMBER:u==="true"||u==="false"||u==="null"?a=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(a=t.SELECTOR),i.push({type:a,value:u,quoted:!1}),c=s}return i}function o(r){let i="";for(let c=0;c<r.length;c++){let l=r[c];if("{}".includes(l.type)||"[]".includes(l.type)){i+=l.value;continue}if(l.type===t.COLON){i+=l.value;continue}if(l.type===t.COMMA){let s=r[c+1];if(s&&(s.type==="}"||s.type==="]"))continue;i+=l.value;continue}if(l.type===t.STRING&&l.quoted){let s=l.value;l.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(u,a)=>a.length%2===0?a+'\\"':u)),i+=`"${s}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){i+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){i+=`"${l.value}"`;continue}i+=`"${l.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new I("Invalid extraction rules syntax: "+r.message,r)}}var Ve="1",Oe=/^[a-zA-Z0-9_-]+$/;function D(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!Oe.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Oe})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],c=e.attr(i,"data-rules-version");if(c!==Ve)throw new _(c);return{rules:B(e.text(i)),tagNode:i}}function re(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return D(e,o,n)}return null}var Ae=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"]})}),Ke=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Dt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function oe(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 Ge(e,t){if(oe(e,t))return!0;for(let[n,o]of Object.entries(Ke))if(o.includes(t)&&oe(e,n))return!0;return!1}function q(e){let t=Ae[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Xe(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=Ae[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Ge(n,r))||o.bundles.some(r=>oe(n,r)))return n;n=n.parentElement}return null}function xe(e,t){return!!Xe(e,t)}var Ye=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Re(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)t.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Se(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function be(e,t,n,o,r,i,c,l){if(e.nodeType===1&&((c?xe(e,n):Se(e,o,i,!1))||r&&Se(e,r,i,c)))return null;let s=t.importNode(e,!1);l.cloneToLive.set(s,e),l.liveToClone.set(e,s);let u=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,a=s.nodeType===1&&s.tagName==="TEMPLATE"?s.content:s;u!==e&&(l.cloneToLive.set(a,u),l.liveToClone.set(u,a));for(let g of u.childNodes||[]){let d=be(g,t,n,o,r,i,c,l);d&&(a.appendChild(d),g.nodeType===1&&Re(g,d))}return e.nodeType===1&&Re(e,s),s}function U(e,{capability:t="data",exclude:n=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=r.implementation.createHTMLDocument(""),c=new WeakMap,l=new WeakMap,s=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let u=q(t),a=be(s,i,t,u,n,s,o,{cloneToLive:c,liveToClone:l});e.nodeType===9&&a&&(i.replaceChild(a,i.documentElement),l.set(e,i),c.set(i,e));let g=d=>{if(Ye.test(d))throw new Error(`Filtered content queries do not support stateful selector: ${d}`)};return{root:a,document:i,capability:t,selector:q(t),cloneToLive:c,liveToClone:l,original(d){return c.get(d)||null},cloneOf(d){return l.get(d)||null},query(d,x=a){return g(d),Array.from(x.querySelectorAll(d),m=>c.get(m)||m)},text(d=a){return(d===a?a:l.get(d))?.textContent||""},html(d=a){return(d===a?a:l.get(d))?.innerHTML??""},clone(d=a){let x=d===a?a:l.get(d);return x?i.importNode(x,!0):null}}}function Ne(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Qe(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var R={semanticExclude:!0,find(e,t,n={}){let o=Qe(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!Ne(l)));let i=[];n.skip&&i.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&i.push("["+c+"]"),i.length){let l=i.join(", ");r=r.filter(s=>!s.closest||!s.closest(l))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function M(e,t={}){if(t.exclude===null)return R;let n=[q("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return R;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,l=null,s=()=>l||(l=U(i,{capability:"data",exclude:t.exclude||null})),u=m=>{let p=s();return m===e?p.cloneOf(e):p.cloneOf(m)||m},a=m=>l?.original(m)||m,g=(m,p)=>{s().liveToClone.set(m,p),s().cloneToLive.set(p,m);let f=m.childNodes||[],h=p.childNodes||[];for(let y=0;y<Math.min(f.length,h.length);y++)g(f[y],h[y])},d=(m,p,f,h)=>{let y=Array.from(m.childNodes).filter(T=>l.cloneOf(T)),O=y[0];for(;O&&y.includes(O);)O=O.nextSibling;for(let T of y)T.remove();if(f==="innerHTML"){let T=c.createElement("template");T.innerHTML=h;for(let S of Array.from(T.content.childNodes))m.insertBefore(S,O||null)}else m.insertBefore(c.createTextNode(h),O||null);let E=U(m,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(E.root?.childNodes||[]));let w=T=>{let S=E.original(T);S&&(l.liveToClone.set(S,T),l.cloneToLive.set(T,S));for(let ce of Array.from(T.childNodes||[]))w(ce)};for(let T of Array.from(p.childNodes))w(T)},x={...R,find(m,p,f={}){let h=u(m);if(!h?.querySelectorAll)return[];let y=s().query(p,h);f.includeRulesTag||(y=y.filter(E=>!Ne(E)));let A=[];f.skip&&A.push(f.skip);let O=f.templateAttr===null?null:f.templateAttr||"cms-template";if(O&&A.push(`[${O}]`),A.length){let E=A.join(", ");y=y.filter(w=>!w.closest?.(E))}return y},parent(m){let p=u(m)?.parentElement;return p?a(p):null},children(m){return Array.from(u(m)?.children||[],a)},text(m,p){if(p===void 0){let y=a(m);return!y?.matches?.(n)&&!y?.querySelector?.(n)?R.text(y):(u(m)?.textContent||"").trim()}let f=a(m);if(!f?.matches?.(n)&&!f?.querySelector?.(n)&&!l){R.text(f,p);return}let h=s().cloneOf(f);h?d(f,h,"textContent",p):R.text(f,p)},attr(m,p,f){let h=a(m);if(f===void 0)return R.attr(h,p);R.attr(h,p,f);let y=l?.cloneOf(h);y&&(R.attr(y,p,f),U(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(h),l.cloneToLive.delete(y)))},removeAttr(m,p){let f=a(m);R.removeAttr(f,p);let h=l?.cloneOf(f);h&&R.removeAttr(h,p)},prop(m,p,f){let h=a(m);if(f===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?R.prop(u(h),p):R.prop(h,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",A=y?s().cloneOf(h):l?.cloneOf(h);A&&y?d(h,A,p,f):(R.prop(h,p,f),A&&R.prop(A,p,f))},clone(m){let p=u(m);return p===m?R.clone(m):c.importNode(p,!0)},insertAt(m,p,f){let h=a(m),A=x.children(h)[f]||(()=>{for(let w=h.children.length-1;w>=0;w--){let T=h.children[w];if(s().cloneOf(T))return T.nextElementSibling}return h.firstElementChild})(),O=a(p);h.insertBefore(O,A||null);let E=s().cloneOf(h);if(E){let w=s().cloneOf(O);w||(w=c.importNode(O,!0),g(O,w));let T=Array.from(E.children);E.insertBefore(w,T[f]||null)}},remove(m){let p=a(m),f=s().cloneOf(p);R.remove(p),f&&R.remove(f)},replaceWith(m,p){let f=a(m),h=s().cloneOf(f),y=R.replaceWith(f,p);if(h){let A=U(y,{capability:"data",exclude:t.exclude||null});if(!A.root)h.remove();else{h.replaceWith(A.root);let O=E=>{let w=A.original(E);w&&(l.liveToClone.set(w,E),l.cloneToLive.set(E,w));for(let T of Array.from(E.childNodes||[]))O(T)};O(A.root)}}return y}};return x}var L=R;var z={extract:(e,t,n={})=>N(M(e,n),e,t,n),apply:(e,t,n,o={})=>P(M(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>D(L,e,t),findRules:(e,t)=>re(L,e,t),bind:(e,t,n={})=>{let o=re(L,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>N(M(e,n),e,o.rules,n),set:r=>P(M(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:ne,parseRelaxed:B,ruleAttrIndex:b,splitRule:Y,errors:V,DOM_PROPERTIES:F},ie=e=>!!e&&typeof e.nodeType=="number";function Ce(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=L.find(t,"script[data-rules-name]",{includeRulesTag:!0});if(n.length===0)throw new Error('hyper-html-api: no rules tag found. Add <script type="application/json" data-rules-name="\u2026" data-rules-version="1"> or pass rules.');if(n.length>1)throw new Error('hyper-html-api: multiple rules tags found; pass a name, e.g. extractData("api").');return D(L,t).rules}function le(e,t){let n=ie(e)?e:document,o=ie(e)?t:e;return o===void 0?N(M(n),n,Ce(n)):z.bind(n,o).get()}function se(e,t,n){if(!ie(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");return n===void 0?P(M(e),e,Ce(e),t):z.bind(e,n).set(t),e}var Ze={engine:z,extractData:le,applyData:se},et=Ze;return Le(tt);})();
5
+ var hyperHtmlApiData=(()=>{var Y=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var _e=Object.prototype.hasOwnProperty;var de=(e,t)=>{for(var n in t)Y(e,n,{get:t[n],enumerable:!0})},$e=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of De(t))!_e.call(e,r)&&r!==n&&Y(e,r,{get:()=>t[r],enumerable:!(o=ke(t,r))||o.enumerable});return e};var We=e=>$e(Y({},"__esModule",{value:!0}),e);var st={};de(st,{applyData:()=>ue,default:()=>it,engine:()=>z,extractData:()=>fe});var F=["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"],X=new Set(F),he=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),G=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var V={};de(V,{EmptyListInsert:()=>$,MAX_RULE_DEPTH:()=>I,MaxRuleDepthExceeded:()=>N,NoRulesTag:()=>Z,RuleTargetReadOnly:()=>W,RulesParseError:()=>L,ShapeMismatch:()=>_,UnknownRulesVersion:()=>D,WriteRefused:()=>K,WriteRejected:()=>Q});var L=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},D=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},I=20,N=class extends Error{constructor(t){super(`rule depth exceeded ${I} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},_=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},$=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}},W=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},K=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},Z=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Q=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 R(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}function ee(e){let t=R(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function C(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return te(e,t,n,{depth:0,path:[]},o)}function te(e,t,n,o,r){if(o.depth>I)throw new N(o.path);if(typeof n=="string")return ve(e,t,n,o,r);if(Array.isArray(n)){let[i,c]=n,s=e.find(t,i,r);return me(r,o,s),s.map((l,u)=>te(e,l,c,{depth:o.depth+1,path:[...o.path,u]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[c,s]of Object.entries(n))i[c]=te(e,t,s,{depth:o.depth+1,path:[...o.path,c]},r);return i}return null}function ve(e,t,n,o,r){if(n.endsWith("[]")){let s=n.slice(0,-2),l=e.find(t,s,r);return me(r,o,l),l.map(u=>e.text(u))}if(n.startsWith("@"))return pe(e,t,n.slice(1));let i=R(n);if(i!==-1){let s=n.slice(0,i),l=n.slice(i+1),u=s?e.find(t,s,r):[t];return u.length===0?null:pe(e,u[0],l)}if(n===".")return e.text(t);let c=e.find(t,n,r);return c.length===0?null:e.text(c[0])}function me(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function pe(e,t,n){if(X.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}function we(e,t,n,o){let r=e.length,i=t.length,c=new Array(r).fill(-1);if(o){let f=new Set;for(let h=0;h<r;h++){let y=o[h];!(y>=0&&y<i)||f.has(y)||(c[h]=y,f.add(y))}}if(r===0||i===0)return c;let s=e.map(f=>ye(f,n)),l=t.map(f=>ye(f,n)),u=new Array(i).fill(!1);for(let f of c)f>=0&&(u[f]=!0);let a=new Map;l.forEach((f,h)=>{u[h]||a.set(f,a.has(f)?-1:h)});let g=new Map;s.forEach((f,h)=>{c[h]>=0||g.set(f,(g.get(f)||0)+1)}),s.forEach((f,h)=>{if(c[h]>=0||g.get(f)!==1)return;let y=a.get(f);y===void 0||y===-1||u[y]||(c[h]=y,u[y]=!0)});let d=[];for(let f=0;f<r;f++)c[f]<0&&d.push(f);let O=[];for(let f=0;f<i;f++)u[f]||O.push(f);if(d.length===0||O.length===0)return c;let m=r*i+1,p=(f,h)=>He(e[f],t[h],n)*m+Math.abs(f-h);for(let[f,h]of Be(d,O,p))c[f]=h;return c}var Ee=e=>typeof e=="object"&&e!==null;function ye(e,t){if(!Ee(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function He(e,t,n){if(!Ee(n))return e===t?0:1;let o=Object.keys(n);if(o.length===0)return 0;let r=0;for(let i of o){let c=JSON.stringify(e?.[i]),s=JSON.stringify(t?.[i]);c!==s&&r++}return r}function Be(e,t,n){return e.length<=t.length?ge(e,t,n,!1):ge(t,e,(o,r)=>n(r,o),!0)}function ge(e,t,n,o){let r=e.length,i=t.length,c=[];for(let g=0;g<=r;g++)c.push(new Float64Array(i+1).fill(1/0));let s=[];for(let g=0;g<=r;g++)s.push(new Uint8Array(i+1));for(let g=0;g<=i;g++)c[r][g]=0;for(let g=r-1;g>=0;g--)for(let d=i-1;d>=0;d--){let O=n(e[g],t[d])+c[g+1][d+1],m=c[g][d+1];O<=m?(c[g][d]=O,s[g][d]=1):c[g][d]=m}let l=[],u=0,a=0;for(;u<r&&a<i;)s[u][a]&&(l.push(o?[t[a],e[u]]:[e[u],t[a]]),u++),a++;return l}function re(e,t,n,o,r,i,c,s={}){let l=e.find(t,n,s);if(r.length===0){l.forEach(w=>e.remove(w)),ne(s,"onRowsApplied",i.path,[]);return}let u=r.length>l.length,a=l[0]||null;if(u&&!a&&(a=Fe(e,t,n,s),!a))throw new $(i.path);let g=l.map(w=>ze(e,w,o,s)),d=null;if(u&&a){d=e.clone(a),s.templateAttr&&e.removeAttr(d,s.templateAttr);let w=e.stripIds(d);w>0&&console.warn(`[hyper-html-api] stripped ${w} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let O=we(r,g,o,qe(e,l,r,i,s)),m=l[0]||a,p=e.parent(m),f=l.length>0?Te(e,p,m):0,h=Ke(e,l),y=new Set,x=[],A=r.map((w,T)=>{let E=O[T];if(E>=0)return y.add(E),x.push(!1),l[E];x.push(!0);let S=e.clone(d);return e.stripIds(S),S});l.forEach((w,T)=>{y.has(T)||e.remove(w)}),h?A.forEach((w,T)=>{let E=f+T;e.children(p).findIndex(Pe=>e.sameNode(Pe,w))!==E&&e.insertAt(p,w,E)}):Ve(e,A,x,p,f),Ue(e,A,o,r,i,c,s),ne(s,"onRowsApplied",i.path,A)}function ne(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function qe(e,t,n,o,r){let i=ne(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let c=new Array(n.length).fill(-1),s=new Set;for(let l=0;l<n.length;l++)if(i[l]){for(let u=0;u<t.length;u++)if(!(s.has(u)||!e.sameNode(t[u],i[l]))){c[l]=u,s.add(u);break}}return c}function Ue(e,t,n,o,r,i,c){t.forEach((s,l)=>{if(n===null){let u=o[l],a=u==null?"":String(u);e.text(s)!==a&&e.text(s,a)}else{let u=i(e,s,n,o[l],{depth:r.depth+1,path:[...r.path,l]},c);u&&u!==s&&(t[l]=u)}})}function ze(e,t,n,o){return n===null?e.text(t):C(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Te(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Fe(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let i=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let c of i)if(e.attr(c,o.templateAttr)!=null)return c;r=e.parent(r)}return null}function Ke(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=e.children(n),r=[];for(let i of t){let c=o.findIndex(s=>e.sameNode(s,i));if(c===-1)return!1;r.push(c)}return r.sort((i,c)=>i-c),r[r.length-1]-r[0]===r.length-1}function Ve(e,t,n,o,r){let i=null,c=r;for(let s=0;s<t.length;s++){if(!n[s]){i=t[s];continue}let l=i?e.parent(i):o;if(!l)continue;let u=i?Te(e,l,i)+1:c++;e.insertAt(l,t[s],u),i=t[s]}}var Ae=new Set(["checked","selected","disabled","readOnly","paused"]);function j(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let i=[];if(oe(n,o,[],i),i.length)throw new _(i);J(e,t,n,o,{depth:0,path:[]},r)}function J(e,t,n,o,r,i={}){if(r.depth>I)throw new N(r.path);if(o===void 0)return t;if(typeof n=="string")return Je(e,t,n,o,r,i);if(Array.isArray(n)){let[c,s]=n;return re(e,t,c,s,o,r,J,i),t}if(typeof n=="object"&&n!==null){for(let[c,s]of Object.entries(n)){let l=J(e,t,s,o==null?o:o[c],{depth:r.depth+1,path:[...r.path,c]},i);l&&l!==t&&(t=l)}return t}return t}function Je(e,t,n,o,r,i){if(n.endsWith("[]")){let l=n.slice(0,-2);return re(e,t,l,null,o,r,J,i),t}if(n.startsWith("@"))return Oe(e,t,n.slice(1),o);let c=R(n);if(c!==-1){let l=n.slice(0,c),u=n.slice(c+1),a=l?e.find(t,l,i):[t];return a.length===0||Oe(e,a[0],u,o),t}if(n===".")return xe(e,t,o),t;let s=e.find(t,n,i);return s.length===0||xe(e,s[0],o),t}function xe(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Oe(e,t,n,o){if(G.has(n)){let i=e.prop(t,n);if(i===o||i!=null&&o!=null&&String(i)===String(o))return t;throw new W(n)}if(n==="outerHTML"){let i=o==null?"":String(o);return e.replaceWith(t,i)}if(he.has(n)){let i=Ye(n,o);return e.prop(t,n)!==i&&e.prop(t,n,i),t}let r=o==null?"":String(o);return e.attr(t,n)!==r&&e.attr(t,n,r),t}function Ye(e,t){return t==null?Ae.has(e)?!1:"":Ae.has(e)?t==="false"?!1:!!t:t}function oe(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:H([...n,i]),expected:"scalar",got:v(r)})}):o.push({path:H(n),expected:"array",got:v(t)});return}t!==null&&typeof t=="object"&&o.push({path:H(n),expected:"scalar",got:v(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:H(n),expected:"array",got:v(t)});return}let r=e[1];t.forEach((i,c)=>oe(r,i,[...n,c],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:H(n),expected:"object",got:v(t)});return}for(let[r,i]of Object.entries(e))oe(i,t[r],[...n,r],o)}}}function v(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function H(e){return e.join(".")}function ie(e){try{return JSON.parse(e)}catch(t){throw new L(`Invalid strict JSON: ${t.message}`,t)}}function B(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 i=[],c=0;for(;c<r.length;){let s=r[c];if(/\s/.test(s)){c++;continue}if("{}".includes(s)){i.push({type:s,value:s}),c++;continue}if(s==="["){let g=!1,d=c+1;for(;d<r.length&&/\s/.test(r[d]);)d++;if(d<r.length&&/[a-zA-Z_]/.test(r[d])&&(g=!0),!g){i.push({type:s,value:s}),c++;continue}}if(s==="]"){i.push({type:s,value:s}),c++;continue}if(s===":"){i.push({type:t.COLON,value:s}),c++;continue}if(s===","){i.push({type:t.COMMA,value:s}),c++;continue}if(s==='"'||s==="'"){let g=s,d=c+1;for(;d<r.length&&r[d]!==g;)r[d]==="\\"&&d++,d++;i.push({type:t.STRING,value:r.substring(c+1,d),quoted:!0,sourceQuote:g}),c=d+1;continue}let l=c,u;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[l]===":"){let g=[":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 O of g){let m=O.substring(1);if(r.substring(l+1,l+1+m.length)===m){d=!0,l+=m.length;break}}if(!d)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let g=r[l];for(l++;l<r.length&&r[l]!==g;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;u=r.substring(c,l);let a=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?a=t.NUMBER:u==="true"||u==="false"||u==="null"?a=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(a=t.SELECTOR),i.push({type:a,value:u,quoted:!1}),c=l}return i}function o(r){let i="";for(let c=0;c<r.length;c++){let s=r[c];if("{}".includes(s.type)||"[]".includes(s.type)){i+=s.value;continue}if(s.type===t.COLON){i+=s.value;continue}if(s.type===t.COMMA){let l=r[c+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=s.value;continue}if(s.type===t.STRING&&s.quoted){let l=s.value;s.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(u,a)=>a.length%2===0?a+'\\"':u)),i+=`"${l}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){i+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){i+=`"${s.value}"`;continue}i+=`"${s.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new L("Invalid extraction rules syntax: "+r.message,r)}}var Xe="1",be=/^[a-zA-Z0-9_-]+$/;function P(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!be.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${be})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],c=e.attr(i,"data-rules-version");if(c!==Xe)throw new D(c);return{rules:B(e.text(i)),tagNode:i}}var Se=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"]})}),Ge=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Re=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function se(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 Ze(e,t){if(se(e,t))return!0;for(let[n,o]of Object.entries(Ge))if(o.includes(t)&&se(e,n))return!0;return!1}function q(e){let t=Se[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Qe(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=Se[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Ze(n,r))||o.bundles.some(r=>se(n,r)))return n;n=n.parentElement}return null}function Ce(e,t){return!!Qe(e,t)}var et=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",...Re],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]});function le(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return P(e,o,n)}return null}var nt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Ne(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)t.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Me(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Le(e,t,n,o,r,i,c,s){if(e.nodeType===1&&((c?Ce(e,n):Me(e,o,i,!1))||r&&Me(e,r,i,c)))return null;let l=t.importNode(e,!1);s.cloneToLive.set(l,e),s.liveToClone.set(e,l);let u=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,a=l.nodeType===1&&l.tagName==="TEMPLATE"?l.content:l;u!==e&&(s.cloneToLive.set(a,u),s.liveToClone.set(u,a));for(let g of u.childNodes||[]){let d=Le(g,t,n,o,r,i,c,s);d&&(a.appendChild(d),g.nodeType===1&&Ne(g,d))}return e.nodeType===1&&Ne(e,l),l}function U(e,{capability:t="data",exclude:n=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=r.implementation.createHTMLDocument(""),c=new WeakMap,s=new WeakMap,l=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let u=q(t),a=Le(l,i,t,u,n,l,o,{cloneToLive:c,liveToClone:s});e.nodeType===9&&a&&(i.replaceChild(a,i.documentElement),s.set(e,i),c.set(i,e));let g=d=>{if(nt.test(d))throw new Error(`Filtered content queries do not support stateful selector: ${d}`)};return{root:a,document:i,capability:t,selector:q(t),cloneToLive:c,liveToClone:s,original(d){return c.get(d)||null},cloneOf(d){return s.get(d)||null},query(d,O=a){return g(d),Array.from(O.querySelectorAll(d),m=>c.get(m)||m)},text(d=a){return(d===a?a:s.get(d))?.textContent||""},html(d=a){return(d===a?a:s.get(d))?.innerHTML??""},clone(d=a){let O=d===a?a:s.get(d);return O?i.importNode(O,!0):null}}}function Ie(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function rt(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var b={semanticExclude:!0,find(e,t,n={}){let o=rt(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(s=>!Ie(s)));let i=[];n.skip&&i.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&i.push("["+c+"]"),i.length){let s=i.join(", ");r=r.filter(l=>!l.closest||!l.closest(s))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function M(e,t={}){if(t.exclude===null)return b;let n=[q("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return b;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,s=null,l=()=>s||(s=U(i,{capability:"data",exclude:t.exclude||null})),u=m=>{let p=l();return m===e?p.cloneOf(e):p.cloneOf(m)||m},a=m=>s?.original(m)||m,g=(m,p)=>{l().liveToClone.set(m,p),l().cloneToLive.set(p,m);let f=m.childNodes||[],h=p.childNodes||[];for(let y=0;y<Math.min(f.length,h.length);y++)g(f[y],h[y])},d=(m,p,f,h)=>{let y=Array.from(m.childNodes).filter(E=>s.cloneOf(E)),A=y[0];for(;A&&y.includes(A);)A=A.nextSibling;for(let E of y)E.remove();if(f==="innerHTML"){let E=c.createElement("template");E.innerHTML=h;for(let S of Array.from(E.content.childNodes))m.insertBefore(S,A||null)}else m.insertBefore(c.createTextNode(h),A||null);let w=U(m,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(w.root?.childNodes||[]));let T=E=>{let S=w.original(E);S&&(s.liveToClone.set(S,E),s.cloneToLive.set(E,S));for(let ae of Array.from(E.childNodes||[]))T(ae)};for(let E of Array.from(p.childNodes))T(E)},O={...b,find(m,p,f={}){let h=u(m);if(!h?.querySelectorAll)return[];let y=l().query(p,h);f.includeRulesTag||(y=y.filter(w=>!Ie(w)));let x=[];f.skip&&x.push(f.skip);let A=f.templateAttr===null?null:f.templateAttr||"cms-template";if(A&&x.push(`[${A}]`),x.length){let w=x.join(", ");y=y.filter(T=>!T.closest?.(w))}return y},parent(m){let p=u(m)?.parentElement;return p?a(p):null},children(m){return Array.from(u(m)?.children||[],a)},text(m,p){if(p===void 0){let y=a(m);return!y?.matches?.(n)&&!y?.querySelector?.(n)?b.text(y):(u(m)?.textContent||"").trim()}let f=a(m);if(!f?.matches?.(n)&&!f?.querySelector?.(n)&&!s){b.text(f,p);return}let h=l().cloneOf(f);h?d(f,h,"textContent",p):b.text(f,p)},attr(m,p,f){let h=a(m);if(f===void 0)return b.attr(h,p);b.attr(h,p,f);let y=s?.cloneOf(h);y&&(b.attr(y,p,f),U(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),s.liveToClone.delete(h),s.cloneToLive.delete(y)))},removeAttr(m,p){let f=a(m);b.removeAttr(f,p);let h=s?.cloneOf(f);h&&b.removeAttr(h,p)},prop(m,p,f){let h=a(m);if(f===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?b.prop(u(h),p):b.prop(h,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",x=y?l().cloneOf(h):s?.cloneOf(h);x&&y?d(h,x,p,f):(b.prop(h,p,f),x&&b.prop(x,p,f))},clone(m){let p=u(m);return p===m?b.clone(m):c.importNode(p,!0)},insertAt(m,p,f){let h=a(m),x=O.children(h)[f]||(()=>{for(let T=h.children.length-1;T>=0;T--){let E=h.children[T];if(l().cloneOf(E))return E.nextElementSibling}return h.firstElementChild})(),A=a(p);h.insertBefore(A,x||null);let w=l().cloneOf(h);if(w){let T=l().cloneOf(A);T||(T=c.importNode(A,!0),g(A,T));let E=Array.from(w.children);w.insertBefore(T,E[f]||null)}},remove(m){let p=a(m),f=l().cloneOf(p);b.remove(p),f&&b.remove(f)},replaceWith(m,p){let f=a(m),h=l().cloneOf(f),y=b.replaceWith(f,p);if(h){let x=U(y,{capability:"data",exclude:t.exclude||null});if(!x.root)h.remove();else{h.replaceWith(x.root);let A=w=>{let T=x.original(w);T&&(s.liveToClone.set(T,w),s.cloneToLive.set(w,T));for(let E of Array.from(w.childNodes||[]))A(E)};A(x.root)}}return y}};return O}var k=b;var z={extract:(e,t,n={})=>C(M(e,n),e,t,n),apply:(e,t,n,o={})=>j(M(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>P(k,e,t),findRules:(e,t)=>le(k,e,t),bind:(e,t,n={})=>{let o=le(k,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>C(M(e,n),e,o.rules,n),set:r=>j(M(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:ie,parseRelaxed:B,ruleAttrIndex:R,splitRule:ee,errors:V,DOM_PROPERTIES:F},ce=e=>!!e&&typeof e.nodeType=="number";function je(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=k.find(t,"script[data-rules-name]",{includeRulesTag:!0});if(n.length===0)throw new Error('hyper-html-api: no rules tag found. Add <script type="application/json" data-rules-name="\u2026" data-rules-version="1"> or pass rules.');if(n.length>1)throw new Error('hyper-html-api: multiple rules tags found; pass a name, e.g. extractData("api").');return P(k,t).rules}function fe(e,t){let n=ce(e)?e:document,o=ce(e)?t:e;return o===void 0?C(M(n),n,je(n)):z.bind(n,o).get()}function ue(e,t,n){if(!ce(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");return n===void 0?j(M(e),e,je(e),t):z.bind(e,n).set(t),e}var ot={engine:z,extractData:fe,applyData:ue},it=ot;return We(st);})();
6
6
  window.clay = window.clay || {};
7
7
  window.clay.extractData = hyperHtmlApiData.extractData;
8
8
  // clayjs-level sugar: applyData(data) writes into the whole document, matching
package/entries/sap.js CHANGED
@@ -1,11 +1,13 @@
1
1
  // GENERATED — do not edit. Vendored from sapjs/dist/sap.min.js via sapjs
2
2
  // `npm run copy-to-clayjs`. Edit the sapjs source and re-run.
3
3
  (function () {
4
- var Sap=(()=>{var _t=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var ke=(t,e)=>{for(var n in e)_t(t,n,{get:e[n],enumerable:!0})},Ne=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xe(e))!$e.call(t,s)&&s!==n&&_t(t,s,{get:()=>e[s],enumerable:!(r=Se(e,s))||r.enumerable});return t};var Te=t=>Ne(_t({},"__esModule",{value:!0}),t);var Nn={};ke(Nn,{Sap:()=>_,default:()=>kn,mount:()=>Ee,mountAll:()=>pt,runtime:()=>K});function zt(t){let e=!1,n=new Set,r=[];function s(l){l&&(r.push(l),r.length>8&&r.shift())}function i(l,y){s(y),!l._broken&&(n.add(l),!e&&(e=!0,queueMicrotask(a)))}function a(){e=!1;let l=[...n];n.clear();for(let y of l)k(y)}function k(l){if(!l._broken){if(l._passes=(l._passes||0)+1,l._passes>50){l._broken=!0,l._breakerRing=r.slice(),t(l,{breaker:!0});return}l._resetArmed||(l._resetArmed=!0,setTimeout(()=>{l._passes=0,l._resetArmed=!1},0)),t(l)}}function E(l,y){s(y),k(l)}function w(l){l._broken=!1,l._passes=0}return{schedule:i,runNow:E,rearm:w,ring:r}}var _e=0;function Z(t,e="sap"){return t.id||(t.id=`${e}-${(_e++).toString(36)}`),t.id}function Le(t){return t.hasAttribute("scope")||t.hasAttribute("items")||t.hasAttribute("detail")}function Ce(t){return t.hasAttribute("sap-ignore")||t.hasAttribute("template")}function F(t,e){for(let r of t.children)n(r);function n(r){if(r.nodeType!==1||Ce(r))return;let s=Le(r);if(e(r,s),!s)for(let i of r.children)n(i)}}function I(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 mt(t){let e=t;for(;e;){if(e.hasAttribute("detail")||e.hasAttribute("item"))return e;e=e.parentElement}return null}function at(t){let e=t;for(;e;){if(e.hasAttribute("detail"))return e;e=e.parentElement}return null}function tt(t,e){let n=null;return F(t,r=>{!n&&r.getAttribute("bind")===e&&(n=r)}),n}function it(t,e){let n=null;return F(t,r=>{!n&&r.getAttribute("items")===e&&(n=r)}),n}function O(t){return[...t.children].filter(e=>e.hasAttribute("item")&&!e.hasAttribute("template"))}function ht(t){return[...t.children].find(e=>e.hasAttribute("item")&&e.hasAttribute("template"))||null}function P(t){let e=[];if(!t)return e;for(let n of t.trim().split(/\s+/)){if(!n)continue;let r=n,s,i=r.indexOf("=");i>=0&&(s=r.slice(i+1),r=r.slice(0,i));let a=r.split(":"),k=a[0],E="string",w=!1;for(let l of a.slice(1))l==="num"?E="num":l==="bool"?E="bool":l==="transient"&&(w=!0);e.push({name:k,type:E,default:s,transient:w})}return e}function G(t,e){if(e==="num"){if(t==null||t==="")return 0;let n=Number(t);return Number.isNaN(n)?0:n}return e==="bool"?t==="true"||t===""||t==="1":t??""}function bt(t,e){return e==="bool"?t?"true":"false":t==null?"":String(t)}function gt(t,e){let n=t._sapTransient||(t._sapTransient={});if(!(e.name in n)){let r=t.getAttribute(e.name);r==null&&(r=e.default!=null?e.default:e.type==="num"?"0":e.type==="bool"?"false":""),n[e.name]=G(r,e.type)}return t.hasAttribute(e.name)&&t.removeAttribute(e.name),n[e.name]}function Lt(t,e,n){(t._sapTransient||(t._sapTransient={}))[e.name]=n,t.hasAttribute(e.name)&&t.removeAttribute(e.name)}function ut(t,e,n){let r=String(n).split("."),s=r[r.length-1];if(r.length===1){let k=Re(e,s);return k||(t.getAttribute("items")===s?t:t.querySelector(`[items="${s}"]`))}let i=r[r.length-2],a=[...t.querySelectorAll(`[scope="${i}"]`)].find(k=>it(k,s));return a?it(a,s):null}function Re(t,e){let n=I(t);for(;n;){if(n.getAttribute("items")===e)return n;let r=it(n,e);if(r)return r;n=I(n.parentElement)}return null}function B(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 yt(t,e){return Array.isArray(t)?e==null?t:t.map(n=>typeof e=="function"?e(n):n?.[e]):[]}function Ht(t,e){return yt(t,e).reduce((n,r)=>n+B(r),0)}function Me(t,e){return Array.isArray(t)?e==null?t.length:t.reduce((n,r)=>n+(e(r)?1:0),0):0}function De(t,e){let n=yt(t,e);return n.length?Ht(t,e)/n.length:0}function Ie(t,e){let n=yt(t,e).filter(r=>r!=null&&r!=="");return n.length?n.every(r=>typeof r=="number"||!Number.isNaN(Number(r)))?Math.min(...n.map(Number)):n.reduce((r,s)=>String(r)<=String(s)?r:s):0}function We(t,e){let n=yt(t,e).filter(r=>r!=null&&r!=="");return n.length?n.every(r=>typeof r=="number"||!Number.isNaN(Number(r)))?Math.max(...n.map(Number)):n.reduce((r,s)=>String(r)>=String(s)?r:s):0}function Fe(t,e,n){let r=B(t)===1?e:n??e+"s";return`${t} ${r}`}function Pe(t,e){let n=new Date(t),r=new Date(e);return Number.isNaN(+n)||Number.isNaN(+r)?0:Math.round((r-n)/864e5)}function H(t){return typeof t=="number"?t:Number(t)}var ct={usd:t=>"$"+H(t).toLocaleString("en-US",{maximumFractionDigits:0}),usd2:t=>"$"+H(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),pct:t=>Math.round(H(t))+"%",pct1:t=>H(t).toFixed(1)+"%",int:t=>Math.round(H(t)).toLocaleString("en-US"),num:t=>H(t).toLocaleString("en-US"),num2:t=>H(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),compact:t=>H(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=H(t),n=Math.floor(e/100),r=n%10,s=Math.floor(n/10)%60;return`${Math.floor(n/600)}:${String(s).padStart(2,"0")}.${r}`}},Oe=new Set(["usd","usd2","pct","pct1","int","num","num2","compact","clock"]);function Ut(t,e){if(!t)return e==null?"":String(e);let n=ct[t];if(typeof n!="function"){let r=new Error(`unknown format "${t}"`);throw r.sapCode="E22",r}if(Oe.has(t)){let r=typeof e=="number"?e:Number(e);if(!Number.isFinite(r)){let s=new Error(`format "${t}" received ${typeof e=="string"?`"${e}"`:e}`);throw s.sapCode="E22",s}}return n(e)}function jt(){return[ct,B,Ht,Me,De,Ie,We,Fe,Pe]}var Be=["state","item","el","root","fmt","num","sum","count","avg","min","max","plural","days"],wt=new Map,Vt=/\bstate\.([a-z][a-z0-9_]*)/g,Yt=/\bitem\.([a-z][a-z0-9_]*)/g;function qe(t){let e=new Set,n=new Set,r;for(Vt.lastIndex=0;r=Vt.exec(t);)e.add(r[1]);for(Yt.lastIndex=0;r=Yt.exec(t);)n.add(r[1]);return{state:e,item:n}}function D(t,e=!1){let n=(e?"!":"")+t,r=wt.get(n);if(r)return r;wt.size>512&&wt.clear();try{let s=e?`"use strict";
5
- ${t}`:`"use strict"; return (${t});`;r={fn:new Function(...Be,s),src:t,statement:e,deps:qe(t),error:null}}catch(s){r={fn:null,src:t,statement:e,deps:{state:new Set,item:new Set},error:s}}return wt.set(n,r),r}function U(t,e){if(t.error)throw t.error;return t.fn(e.state,e.item,e.el??null,e.root,...jt())}function Gt(t){let e=new Map;for(let a of t)e.set(a.name,a);let n=[],r=new Map,s=[];function i(a){let k=r.get(a.name);if(k!==1){if(k===0){let E=[...s.slice(s.indexOf(a.name)),a.name].join(" -> "),w=new Error(`calc: cycle: ${E}`);throw w.sapCode="E07",w.cycle=E,w}r.set(a.name,0),s.push(a.name);for(let E of a.entry.deps.state){let w=e.get(E);w&&w!==a&&i(w)}for(let E of a.entry.deps.item){let w=e.get(E);w&&w!==a&&i(w)}s.pop(),r.set(a.name,1),n.push(a)}}for(let a of t)i(a);return n}function Xt(t){return(t.getAttribute("type")||"text").toLowerCase()}function et(t){let e=t.tagName;if(e==="INPUT"){let n=Xt(t);n==="checkbox"||n==="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 n=t.options;for(let r=0;r<n.length;r++)n[r].selected?n[r].setAttribute("selected",""):n[r].removeAttribute("selected")}}function Kt(t,e=t){let n=t.tagName;if(n==="INPUT"){let r=Xt(t);r==="checkbox"||r==="radio"?e.checked?t.setAttribute("checked",""):t.removeAttribute("checked"):t.setAttribute("value",e.value);return}if(n==="TEXTAREA"){t.textContent=e.value,t.removeAttribute("data-value");return}if(n==="SELECT"){let r=t.options,s=e.options;for(let i=0;i<r.length;i++)s[i]&&s[i].selected?r[i].setAttribute("selected",""):r[i].removeAttribute("selected")}}function At(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function W(t){if(typeof window>"u")return null;let e=window.clay,n=window.hyperclay;return t==="consent"?e?.confirm||n?.consent||null:e?.[t]||n?.[t]||null}var Ct=["clay:mutation-ready","hyperclay:mutation-ready"],ze=["clay:sync-applied","hyperclay:livesync-applied"],He=["clay:ready","hyperclay:ready"];function ft(t,e,n){let r=null,s=i=>{r!==null&&r!==i.type||(r=i.type,queueMicrotask(()=>{r=null}),n(i))};for(let i of e)t.addEventListener(i,s);return()=>{for(let i of e)t.removeEventListener(i,s)}}function vt(t){let e=W("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function Jt(){let t=W("consent");return typeof t=="function"?t:null}function Qt(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let n=W("undo");n&&n.flush&&n.flush();let r=e();if(r&&typeof r.then=="function")throw new Error("Sap.batch fn must be synchronous (it returned a promise)");return n&&n.commitCaptured&&n.commitCaptured(t),r}function Zt(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let i=!1;for(let a of t.apps())a.root.isConnected?t.runNow(a,"platform"):i=!0;i&&(t.pruneDisconnected(),t.remountIfPresent())};ft(document,ze,e);let n=!1,r=()=>{},s=()=>{if(n)return!0;let i=W("undo");if(!i||typeof i.on!="function")return!1;let a=i.on("undo",e);return typeof a!="function"?!1:typeof i.on("redo",e)!="function"?(a(),!1):(n=!0,r(),!0)};if(!s()){let i=ft(document,Ct,s),a=ft(document,He,s);r=()=>{i(),a()};let k=W("ready");k&&typeof k.then=="function"&&k.then(s,()=>{})}}function Ue(t){let e=t.tagName;if(e==="INPUT"){let n=(t.getAttribute("type")||"text").toLowerCase();return n==="checkbox"?"checkbox":n==="radio"?"radio":n==="number"||n==="range"?"number":n==="hidden"?"hidden":"text"}return e==="TEXTAREA"?"text":e==="SELECT"?t.multiple?"select-multiple":"select-one":"leaf"}function je(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 Ve(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return je(t);case"select-one":return t.value;case"select-multiple":return[...t.selectedOptions].map(n=>n.value);case"hidden":case"text":return t.value;case"leaf":return t.textContent;default:return t.value}}function Ye(t,e,n){switch(e){case"checkbox":t.checked=!!n;break;case"radio":t.checked=String(t.value)===String(n);break;case"number":case"text":case"hidden":t.value=n==null?"":String(n);break;case"select-one":t.value=n==null?"":String(n);break;case"select-multiple":{let r=new Set((Array.isArray(n)?n:[n]).map(String));for(let s of t.options)s.selected=r.has(s.value);break}case"leaf":t.textContent=n==null?"":String(n);break;default:t.value=n==null?"":String(n)}}function te(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}vt(t)||et(t)}function Ge(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function M(t){let e=Ue(t);return{el:t,kind:e,read(){return Ve(t,e)},write(n,r={}){Ye(t,e,n),r.noMirror||te(t),r.silent||Ge(t)},mirror(){te(t)}}}var Rt={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"},W03:{slug:"unknown-colon-attribute",behavior:"WARN"},W04:{slug:"expression-in-when",behavior:"WARN"},W30:{slug:"nonzero-mount-writes",behavior:"WARN"}},Et=["disabled","readonly","required","checked","selected","multiple","open","inert","autofocus","novalidate","hidden"],lt=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"]),St=new Set(["sap","scope","items","item","template","bind","calc","text","show","attr","set","trigger","move","sort","detail","effect","invalid","confirm","transient","default","persist","sortable","editmode"]);function xt(t){if(!t||t.nodeType!==1)return"?";if(t.id)return`${t.tagName.toLowerCase()}#${t.id}`;let e=[],n=t,r=0;for(;n&&n.nodeType===1&&r<4;){let s=n.tagName.toLowerCase();if(n.hasAttribute("sap"))s+="[sap]";else if(n.parentElement){let i=[...n.parentElement.children].filter(a=>a.tagName===n.tagName);i.length>1&&(s+=`:nth-of-type(${i.indexOf(n)+1})`)}if(e.unshift(s),n.hasAttribute("sap"))break;n=n.parentElement,r++}return e.join(" > ")}function ee(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 nt=class{constructor(e){this.appName=e,this.errors=[],this.warnings=[],this.halted=!1,this.haltReason=null}block(e,n,r={}){let s=(Rt[e]||{}).slug||"error",i={code:e,slug:s,el:xt(n),attr:r.attr||null,expr:r.expr||null,key:r.key||null,problem:r.problem||"",didYouMean:r.didYouMean||null,fix:r.fix||null,phase:r.phase||"runtime"},a=[`
4
+ var Sap=(()=>{var _t=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var ke=(t,e)=>{for(var r in e)_t(t,r,{get:e[r],enumerable:!0})},Ne=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xe(e))!$e.call(t,s)&&s!==r&&_t(t,s,{get:()=>e[s],enumerable:!(n=Se(e,s))||n.enumerable});return t};var Te=t=>Ne(_t({},"__esModule",{value:!0}),t);var Nn={};ke(Nn,{Sap:()=>_,default:()=>kn,mount:()=>Ee,mountAll:()=>pt,runtime:()=>K});function zt(t){let e=!1,r=new Set,n=[];function s(l){l&&(n.push(l),n.length>8&&n.shift())}function i(l,y){s(y),!l._broken&&(r.add(l),!e&&(e=!0,queueMicrotask(a)))}function a(){e=!1;let l=[...r];r.clear();for(let y of l)k(y)}function k(l){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)}}function E(l,y){s(y),k(l)}function w(l){l._broken=!1,l._passes=0}return{schedule:i,runNow:E,rearm:w,ring:n}}var _e=0;function Z(t,e="sap"){return t.id||(t.id=`${e}-${(_e++).toString(36)}`),t.id}function Le(t){return t.hasAttribute("scope")||t.hasAttribute("items")||t.hasAttribute("detail")}function Ce(t){return t.hasAttribute("sap-ignore")||t.hasAttribute("template")}function F(t,e){for(let n of t.children)r(n);function r(n){if(n.nodeType!==1||Ce(n))return;let s=Le(n);if(e(n,s),!s)for(let i of n.children)r(i)}}function I(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 mt(t){let e=t;for(;e;){if(e.hasAttribute("detail")||e.hasAttribute("item"))return e;e=e.parentElement}return null}function at(t){let e=t;for(;e;){if(e.hasAttribute("detail"))return e;e=e.parentElement}return null}function tt(t,e){let r=null;return F(t,n=>{!r&&n.getAttribute("bind")===e&&(r=n)}),r}function it(t,e){let r=null;return F(t,n=>{!r&&n.getAttribute("items")===e&&(r=n)}),r}function O(t){return[...t.children].filter(e=>e.hasAttribute("item")&&!e.hasAttribute("template"))}function ht(t){return[...t.children].find(e=>e.hasAttribute("item")&&e.hasAttribute("template"))||null}function P(t){let e=[];if(!t)return e;for(let r of t.trim().split(/\s+/)){if(!r)continue;let n=r,s,i=n.indexOf("=");i>=0&&(s=n.slice(i+1),n=n.slice(0,i));let a=n.split(":"),k=a[0],E="string",w=!1;for(let l of a.slice(1))l==="num"?E="num":l==="bool"?E="bool":l==="transient"&&(w=!0);e.push({name:k,type:E,default:s,transient:w})}return e}function G(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 bt(t,e){return e==="bool"?t?"true":"false":t==null?"":String(t)}function gt(t,e){let r=t._sapTransient||(t._sapTransient={});if(!(e.name in r)){let n=t.getAttribute(e.name);n==null&&(n=e.default!=null?e.default:e.type==="num"?"0":e.type==="bool"?"false":""),r[e.name]=G(n,e.type)}return t.hasAttribute(e.name)&&t.removeAttribute(e.name),r[e.name]}function Lt(t,e,r){(t._sapTransient||(t._sapTransient={}))[e.name]=r,t.hasAttribute(e.name)&&t.removeAttribute(e.name)}function ut(t,e,r){let n=String(r).split("."),s=n[n.length-1];if(n.length===1){let k=Re(e,s);return k||(t.getAttribute("items")===s?t:t.querySelector(`[items="${s}"]`))}let i=n[n.length-2],a=[...t.querySelectorAll(`[scope="${i}"]`)].find(k=>it(k,s));return a?it(a,s):null}function Re(t,e){let r=I(t);for(;r;){if(r.getAttribute("items")===e)return r;let n=it(r,e);if(n)return n;r=I(r.parentElement)}return null}function B(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 yt(t,e){return Array.isArray(t)?e==null?t:t.map(r=>typeof e=="function"?e(r):r?.[e]):[]}function Ht(t,e){return yt(t,e).reduce((r,n)=>r+B(n),0)}function Me(t,e){return Array.isArray(t)?e==null?t.length:t.reduce((r,n)=>r+(e(n)?1:0),0):0}function De(t,e){let r=yt(t,e);return r.length?Ht(t,e)/r.length:0}function Ie(t,e){let r=yt(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,s)=>String(n)<=String(s)?n:s):0}function We(t,e){let r=yt(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,s)=>String(n)>=String(s)?n:s):0}function Fe(t,e,r){let n=B(t)===1?e:r??e+"s";return`${t} ${n}`}function Pe(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 H(t){return typeof t=="number"?t:Number(t)}var ct={usd:t=>"$"+H(t).toLocaleString("en-US",{maximumFractionDigits:0}),usd2:t=>"$"+H(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),pct:t=>Math.round(H(t))+"%",pct1:t=>H(t).toFixed(1)+"%",int:t=>Math.round(H(t)).toLocaleString("en-US"),num:t=>H(t).toLocaleString("en-US"),num2:t=>H(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),compact:t=>H(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=H(t),r=Math.floor(e/100),n=r%10,s=Math.floor(r/10)%60;return`${Math.floor(r/600)}:${String(s).padStart(2,"0")}.${n}`}},Oe=new Set(["usd","usd2","pct","pct1","int","num","num2","compact","clock"]);function Ut(t,e){if(!t)return e==null?"":String(e);let r=ct[t];if(typeof r!="function"){let n=new Error(`unknown format "${t}"`);throw n.sapCode="E22",n}if(Oe.has(t)){let n=typeof e=="number"?e:Number(e);if(!Number.isFinite(n)){let s=new Error(`format "${t}" received ${typeof e=="string"?`"${e}"`:e}`);throw s.sapCode="E22",s}}return r(e)}function jt(){return[ct,B,Ht,Me,De,Ie,We,Fe,Pe]}var Be=["state","item","el","root","fmt","num","sum","count","avg","min","max","plural","days"],wt=new Map,Vt=/\bstate\.([a-z][a-z0-9_]*)/g,Yt=/\bitem\.([a-z][a-z0-9_]*)/g;function qe(t){let e=new Set,r=new Set,n;for(Vt.lastIndex=0;n=Vt.exec(t);)e.add(n[1]);for(Yt.lastIndex=0;n=Yt.exec(t);)r.add(n[1]);return{state:e,item:r}}function D(t,e=!1){let r=(e?"!":"")+t,n=wt.get(r);if(n)return n;wt.size>512&&wt.clear();try{let s=e?`"use strict";
5
+ ${t}`:`"use strict"; return (${t});`;n={fn:new Function(...Be,s),src:t,statement:e,deps:qe(t),error:null}}catch(s){n={fn:null,src:t,statement:e,deps:{state:new Set,item:new Set},error:s}}return wt.set(r,n),n}function U(t,e){if(t.error)throw t.error;return t.fn(e.state,e.item,e.el??null,e.root,...jt())}function Gt(t){let e=new Map;for(let a of t)e.set(a.name,a);let r=[],n=new Map,s=[];function i(a){let k=n.get(a.name);if(k!==1){if(k===0){let E=[...s.slice(s.indexOf(a.name)),a.name].join(" -> "),w=new Error(`calc: cycle: ${E}`);throw w.sapCode="E07",w.cycle=E,w}n.set(a.name,0),s.push(a.name);for(let E of a.entry.deps.state){let w=e.get(E);w&&w!==a&&i(w)}for(let E of a.entry.deps.item){let w=e.get(E);w&&w!==a&&i(w)}s.pop(),n.set(a.name,1),r.push(a)}}for(let a of t)i(a);return r}function Xt(t){return(t.getAttribute("type")||"text").toLowerCase()}function et(t){let e=t.tagName;if(e==="INPUT"){let r=Xt(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 Kt(t,e=t){let r=t.tagName;if(r==="INPUT"){let n=Xt(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(`
6
+ `)?`
7
+ `+e.value:e.value;t.textContent!==n&&(t.textContent=n),t.removeAttribute("data-value");return}if(r==="SELECT"){let n=t.options,s=e.options;for(let i=0;i<n.length;i++)s[i]&&s[i].selected?n[i].hasAttribute("selected")||n[i].setAttribute("selected",""):n[i].removeAttribute("selected")}}function At(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function W(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 Ct=["clay:mutation-ready","hyperclay:mutation-ready"],ze=["clay:sync-applied","hyperclay:livesync-applied"],He=["clay:ready","hyperclay:ready"];function ft(t,e,r){let n=null,s=i=>{n!==null&&n!==i.type||(n=i.type,queueMicrotask(()=>{n=null}),r(i))};for(let i of e)t.addEventListener(i,s);return()=>{for(let i of e)t.removeEventListener(i,s)}}function vt(t){let e=W("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function Jt(){let t=W("consent");return typeof t=="function"?t:null}function Qt(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let r=W("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 Zt(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let i=!1;for(let a of t.apps())a.root.isConnected?t.runNow(a,"platform"):i=!0;i&&(t.pruneDisconnected(),t.remountIfPresent())};ft(document,ze,e);let r=!1,n=()=>{},s=()=>{if(r)return!0;let i=W("undo");if(!i||typeof i.on!="function")return!1;let a=i.on("undo",e);return typeof a!="function"?!1:typeof i.on("redo",e)!="function"?(a(),!1):(r=!0,n(),!0)};if(!s()){let i=ft(document,Ct,s),a=ft(document,He,s);n=()=>{i(),a()};let k=W("ready");k&&typeof k.then=="function"&&k.then(s,()=>{})}}function Ue(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 je(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 Ve(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return je(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 Ye(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 s of t.options)s.selected=n.has(s.value);break}case"leaf":t.textContent=r==null?"":String(r);break;default:t.value=r==null?"":String(r)}}function te(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}vt(t)||et(t)}function Ge(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function M(t){let e=Ue(t);return{el:t,kind:e,read(){return Ve(t,e)},write(r,n={}){Ye(t,e,r),n.noMirror||te(t),n.silent||Ge(t)},mirror(){te(t)}}}var Rt={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"},W03:{slug:"unknown-colon-attribute",behavior:"WARN"},W04:{slug:"expression-in-when",behavior:"WARN"},W30:{slug:"nonzero-mount-writes",behavior:"WARN"}},Et=["disabled","readonly","required","checked","selected","multiple","open","inert","autofocus","novalidate","hidden"],lt=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"]),St=new Set(["sap","scope","items","item","template","bind","calc","text","show","attr","set","trigger","move","sort","detail","effect","invalid","confirm","transient","default","persist","sortable","editmode"]);function xt(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 s=r.tagName.toLowerCase();if(r.hasAttribute("sap"))s+="[sap]";else if(r.parentElement){let i=[...r.parentElement.children].filter(a=>a.tagName===r.tagName);i.length>1&&(s+=`:nth-of-type(${i.indexOf(r)+1})`)}if(e.unshift(s),r.hasAttribute("sap"))break;r=r.parentElement,n++}return e.join(" > ")}function ee(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 nt=class{constructor(e){this.appName=e,this.errors=[],this.warnings=[],this.halted=!1,this.haltReason=null}block(e,r,n={}){let s=(Rt[e]||{}).slug||"error",i={code:e,slug:s,el:xt(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=[`
6
8
  `+(e[0]==="W"?"sap \u26A0 ":"sap \u2717 ")+e+" "+s];return a.push(` at ${i.el}${i.attr?` \u2014 ${i.attr}="${i.expr??""}"`:""}`),i.problem&&a.push(` problem: ${i.problem}`),i.didYouMean&&a.push(` did you mean: ${i.didYouMean}`),i.fix&&a.push(` fix: ${i.fix}`),console.error(a.join(`
7
- `)),i}error(e,n,r={}){let s=this.block(e,n,r);return this.errors.push(s),s}warn(e,n,r={}){let s=this.block(e,n,r);return this.warnings.push(s),s}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 X(t,e){t&&t.getAttribute("sap-error")!==e&&t.setAttribute("sap-error",e)}function $t(t){t&&t.hasAttribute("sap-error")&&t.removeAttribute("sap-error")}function dt(t,e){let n=null,r=3;for(let s of e){let i=Xe(t,s);i<r&&(r=i,n=s)}return n}function Xe(t,e){let n=t.length,r=e.length,s=Array.from({length:n+1},(i,a)=>[a,...new Array(r).fill(0)]);for(let i=0;i<=r;i++)s[0][i]=i;for(let i=1;i<=n;i++)for(let a=1;a<=r;a++)s[i][a]=Math.min(s[i-1][a]+1,s[i][a-1]+1,s[i-1][a-1]+(t[i-1]===e[a-1]?0:1));return s[n][r]}var j=null,Nt=!1,rt=null;function ne(t){let e=null;return{kind:"hub",subscribe(n){let r=t.onAnyChange({debounce:0,require:"observed"},n);typeof r=="function"&&(e=r)},suppress(n){t.pause();try{return n()}finally{t.resume()}},teardown(){if(e){try{e()}catch{}e=null}}}}function Ke(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(r=>e(Je(r)));let n=typeof document<"u"&&document.body||typeof document<"u"&&document.documentElement;n&&t.observe(n,{childList:!0,subtree:!0,attributes:!0,characterData:!0})},suppress(e){let n=W("undo");n&&n.pause&&n.pause();try{return e()}finally{t&&t.takeRecords(),n&&n.resume&&n.resume()}},teardown(){t&&(t.disconnect(),t=null)}}}function Je(t){let e=[];for(let n of t)if(n.type==="attributes"){let r=n.target;r&&r.nodeType===1&&!kt(r)&&e.push({type:"attribute",element:r})}else if(n.type==="characterData"){let r=n.target&&n.target.parentElement;r&&!kt(r)&&e.push({type:"characterData",element:r})}else if(n.type==="childList"){for(let r of n.addedNodes)if(!(r.nodeType!==1||kt(r))&&(e.push({type:"add",element:r}),r.querySelectorAll))for(let s of r.querySelectorAll("*"))kt(s)||e.push({type:"add",element:s});for(let r of n.removedNodes)r.nodeType===1&&e.push({type:"remove",element:r,parent:n.target})}return e}function kt(t){return!!(t.closest&&t.closest("[sap-ignore],[template]"))}function Qe(t,e){t.pruneDisconnected();let n=new Set,r=!1;for(let s of e){let i=s.type==="remove"?s.parent:s.element,a=i&&t.appFor(i);a&&n.add(a),s.type==="add"&&s.element&&s.element.nodeType===1&&s.element.hasAttribute&&s.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(s.element))&&(r=!0)}r&&t.remountIfPresent();for(let s of n)s.root.isConnected&&t.schedule(s,"mutation")}function re(t){if(j)return j.suppress(t);let e=W("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function Mt(t,e){Nt=!0,j=t,t.subscribe(n=>Qe(e,n))}function Dt(t){if(Nt||typeof window>"u"||typeof document>"u")return;let e=W("Mutation");if(e&&typeof e.onAnyChange=="function"){Mt(ne(e),t);return}typeof MutationObserver=="function"&&(Mt(Ke(),t),rt=ft(document,Ct,function(){let r=W("Mutation");r&&(rt(),rt=null,j&&j.teardown(),Nt=!1,Mt(ne(r),t))}))}function oe(){if(j)try{j.teardown()}catch{}rt&&typeof document<"u"&&rt(),j=null,Nt=!1,rt=null}var ae=new Set(Et);function ot(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),X(t.root,"loop");return}re(()=>Ze(t,e))}function Ze(t,e){let n=t.root,r={},s=[],i=[],a=[],k=[],E=[],w=new Set;t.diag.errors=[];let l={root:r,state:r,item:null,ownerEl:n,projection:!1};function y(o,u){let h=o.getAttribute(u.name);return h==null&&(h=u.default!=null?u.default:u.type==="num"?"0":u.type==="bool"?"false":"",E.push({el:o,name:u.name,value:bt(G(h,u.type),u.type)})),G(h,u.type)}function N(o,u){let h=P(o.getAttribute("state")||"");o._sapStateDecls=h;for(let p of h){if(p.type==="string"&&ae.has(p.name)&&typeof o[p.name]=="boolean"){u[p.name]=o.hasAttribute(p.name);continue}if(p.transient){u[p.name]=gt(o,p);continue}u[p.name]=y(o,p)}}function L(o,u){if(!o.hasAttribute("bind"))return;let h=o.getAttribute("bind"),p=u.item||u.state,v=M(o);v.kind==="radio"?(h in p||(p[h]=""),o.checked&&(p[h]=o.value)):p[h]=v.read(),o.hasAttribute("transient")&&(o.removeAttribute("value"),o.removeAttribute("checked"))}function b(o,u){for(let h of o.attributes){let p=h.name,v=h.value;if(p.startsWith("calc:"))s.push({owner:u.item||u.state,ownerEl:u.ownerEl,name:p.slice(5),entry:D(v),el:o,ctx:u});else if(p==="text"||p.startsWith("text:"))i.push({el:o,kind:"text",fmt:p.includes(":")?p.slice(5):null,entry:D(v),ctx:u});else if(p==="show")i.push({el:o,kind:"show",entry:D(v),ctx:u});else if(p.startsWith("attr:"))i.push({el:o,kind:"attr",arg:p.slice(5),entry:D(v),ctx:u});else if(p.startsWith("class:"))i.push({el:o,kind:"class",arg:p.slice(6),entry:D(v),ctx:u});else if(p.startsWith("css:"))i.push({el:o,kind:"css",arg:p.slice(4),entry:D(v),ctx:u});else if(p==="effect")a.push({el:o,entry:D(v,!0),ctx:u});else if(p==="invalid")k.push({el:o,entry:D(v),ctx:u});else if(p.startsWith("show-when:")||p.startsWith("option:")){let T=p.slice(p.indexOf(":")+1);w.add(T),i.push({el:o,kind:"when",match:"show",field:T,values:v.split("|"),ctx:u})}else if(p.startsWith("hide-when:")){let T=p.slice(p.indexOf(":")+1);w.add(T),i.push({el:o,kind:"when",match:"hide",field:T,values:v.split("|"),ctx:u})}else if(p.startsWith("option-not:")){let T=p.slice(p.indexOf(":")+1);w.add(T),i.push({el:o,kind:"when",match:"show-not",field:T,values:v.split("|"),ctx:u})}}u.projection&&o.hasAttribute("bind")&&i.push({el:o,kind:"projection",field:o.getAttribute("bind"),ctx:u})}function g(o,u,h){Z(u,"row"),Object.defineProperty(o,"$key",{value:u.id,enumerable:!1}),Object.defineProperty(o,"$index",{value:h,enumerable:!1}),Object.defineProperty(o,"$el",{value:u,enumerable:!1})}function c(o,u,h){N(o,u),o._sapScope=u,!h.projection&&o.hasAttribute("bind")&&L(o,h),b(o,h),o.hasAttribute("items")?x(o,u,h):A(o,u,h)}function A(o,u,h){F(o,(p,v)=>{v?p.hasAttribute("scope")?S(p,u,h):p.hasAttribute("items")?(b(p,h),x(p,u,h)):p.hasAttribute("detail")&&R(p,u,h):(h.projection||L(p,h),b(p,h))})}function S(o,u,h){let p=o.getAttribute("scope"),v={};u[p]=v;let T={root:h.root,state:v,item:null,ownerEl:o,projection:h.projection};c(o,v,T)}function x(o,u,h){let p=o.getAttribute("items"),v=[];u[p]=v,o._sapList=v,O(o).forEach((T,st)=>{let C={};g(C,T,st);let z={root:h.root,state:h.state,item:C,ownerEl:T,projection:h.projection};c(T,C,z),v.push(C)})}function $(o,u){let h=String(o).split("."),p=u.state;for(let v of h)p=p?.[v];if(p===void 0){p=u.root;for(let v of h)p=p?.[v]}return p}function R(o,u,h){for(let Q of P(o.getAttribute("state")||""))Q.name in u||(u[Q.name]=y(o,Q));o._sapScope=u;let p=o.getAttribute("detail")||"",v=/^([\w.]+)\s+by\s+(.+)$/.exec(p);if(!v){o.hidden=!0,o._sapDetailRow=null;return}let T=v[1],st=v[2].trim(),C=$(T,h),z;try{z=U(D(st),{state:u,item:h.item,el:o,root:h.root})}catch{z=void 0}let J=Array.isArray(C)?C.find(Q=>Q&&String(Q.$key)===String(z)):null;if(o._sapDetailRow=J?J.$el:null,!J){o.hidden||(o.hidden=!0);return}o.hidden&&(o.hidden=!1);let qt={root:h.root,state:u,item:J,ownerEl:J.$el,projection:!0};b(o,qt),A(o,J,qt)}if(c(n,r,l),E.length&&w.size)for(let o of E)w.has(o.name)&&o.el.getAttribute(o.name)==null&&o.el.setAttribute(o.name,o.value);let m=new Map;for(let o of s){let u=m.get(o.owner);u||(u={ownerEl:o.ownerEl,list:[]},m.set(o.owner,u)),u.list.push(o)}let d=[...m.values()].sort((o,u)=>ie(u.ownerEl)-ie(o.ownerEl));for(let o of d){let u;try{u=Gt(o.list)}catch(h){t.diag.error("E07",o.list[0].el,{problem:h.message}),u=o.list}for(let h of u)try{h.owner[h.name]=U(h.entry,{state:h.ctx.state,item:h.ctx.item,el:h.el,root:h.ctx.root}),$t(h.el)}catch(p){h.owner[h.name]=void 0,t.diag.error("E24",h.el,{attr:"calc:"+h.name,expr:h.entry.src,problem:String(p.message)}),X(h.el,p.sapCode||"E24")}}let f=0;for(let o of i)f+=nn(o,t);for(let o of a)rn(o,t);for(let o of k)on(o);t._state=r,t._stats={fields:Object.keys(r).filter(o=>typeof r[o]!="function").length,calcs:s.length,paints:i.length,lists:m.size,writes:f},t._lastPass={trigger:e.trigger||"refresh",writes:f},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${f}/${i.length}`)}function tn(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 It(t,e,n,r){let s=t;for(;s&&s.nodeType===1;){if(s.hasAttribute&&s.hasAttribute(e)){let i=n.includes(s.getAttribute(e));if(r?!i:i)return!0}s=s.parentElement}return!1}function en(t,e){if(t===t.ownerDocument.activeElement)return 0;let n=M(t),r=n.read(),s=e??"";return String(r)!==String(s)?(n.write(s,{silent:!0}),1):0}function nn(t,e){if(t.kind==="projection")return en(t.el,t.ctx.item?t.ctx.item[t.field]:"");if(t.kind==="when")return se(t,null);let n={state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root};try{let r=U(t.entry,n),s=se(t,r);return $t(t.el),s}catch(r){return e.diag.error(r.sapCode==="E22"?"E22":"E24",t.el,{attr:tn(t),expr:t.entry&&t.entry.src,problem:String(r.message)}),X(t.el,r.sapCode||"E24"),0}}function se(t,e){let n=t.el;switch(t.kind){case"text":{let r=t.fmt!=null?Ut(t.fmt,e):e==null?"":String(e);return n.textContent!==r?(n.textContent=r,1):0}case"show":{let r=!e;return n.hidden!==r?(n.hidden=r,1):0}case"when":{let r=W("optionVisibility");if(r&&r._started)return n._sapWhen&&n.hidden?(n.hidden=!1,n._sapWhen=!1,1):0;let s;t.match==="hide"?s=!It(n,t.field,t.values,!1):t.match==="show-not"?s=It(n,t.field,t.values,!0):s=It(n,t.field,t.values,!1),n._sapWhen=!0;let i=!s;return n.hidden!==i?(n.hidden=i,1):0}case"attr":{let r=t.arg;if(ae.has(r)){let i=n.hasAttribute(r);return e&&!i?(n.setAttribute(r,""),1):!e&&i?(n.removeAttribute(r),1):0}let s=typeof e=="boolean"?String(e):e==null?"":String(e);return n.getAttribute(r)!==s?(n.setAttribute(r,s),1):0}case"class":{let r=!!e;return n.classList.contains(t.arg)!==r?(n.classList.toggle(t.arg,r),1):0}case"css":{let r=e==null?"":String(e);return n.style.getPropertyValue("--"+t.arg)!==r?(n.style.setProperty("--"+t.arg,r),1):0}default:return 0}}function rn(t,e){try{U(t.entry,{state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root}),$t(t.el)}catch(n){e.diag.error("E24",t.el,{attr:"effect",expr:t.entry&&t.entry.src,problem:String(n.message)}),X(t.el,"E24")}}function on(t){let e="";try{let n=U(t.entry,{state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root});e=typeof n=="string"?n:""}catch{e=""}typeof t.el.setCustomValidity=="function"&&t.el.setCustomValidity(e)}function ie(t){let e=0,n=t;for(;n&&!(n.hasAttribute&&n.hasAttribute("sap"));)n=n.parentElement,e++;return e}var sn=new Set(Et),ue=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode"]),an=new Set(["show-when","hide-when","option","option-not"]),un=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,ce=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 cn(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function Wt(t){return t.hasAttribute("bind")}function fn(t,e){e(t);for(let r of t.children)n(r);function n(r){if(r.nodeType===1&&!((r.hasAttribute("sap-ignore")||r.hasAttribute("template"))&&r.hasAttribute("sap-ignore"))){e(r);for(let s of r.children)n(s)}}}function Tt(t,e){let n=!1,r=(a,k,E)=>{e.error(a,k,E),n=!0},s=t.ownerDocument.createTreeWalker(t,4),i;for(;i=s.nextNode();)if(/\{\{.*\}\}/.test(i.nodeValue||"")){r("E02",i.parentElement||t,{problem:"moustaches in text content are not a Sap feature",fix:'move the expression onto the element: text="state.x"'});break}return fn(t,a=>{let k=a.closest&&a.closest("[detail]");for(let E of[...a.attributes]){let w=E.name,l=ee(w);if(l){r("E01",a,{attr:w,expr:E.value,problem:`"${w}" is a foreign-dialect attribute; Sap has no ${w.split(/[:=]/)[0]} directive`,fix:l+" \u2014 or wrap the subtree in sap-ignore if intentional"});continue}if(w.includes(":")){let y=w.slice(0,w.indexOf(":"));if(ue.has(y)){if(an.has(y)&&un.test(E.value)){let N=w.slice(w.indexOf(":")+1);e.warn("W04",a,{attr:w,expr:E.value,problem:`${y}: compares the "${N}" attribute against a literal value, not a JS expression`,fix:`use show="${E.value}" for an expression, or a literal like ${y}:${N}="overview"`})}}else{let N=dt(y,[...ue]);e.warn("W03",a,{attr:w,problem:`unknown "${y}:" attribute`,didYouMean:N?`${N}:`:null})}}else if(!ce.has(w)&&!lt.has(w)&&!sn.has(w)&&!/^(data-|aria-|on)/.test(w)&&!(w in a)){let y=dt(w,[...ce]);y&&e.warn("W03",a,{attr:w,problem:`unknown "${w}" attribute`,didYouMean:y})}w==="attr:hidden"&&e.warn("W03",a,{attr:w,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'}),(w==="attr:value"||w==="attr:checked"||w==="attr:selected")&&Wt(a)&&r("E30",a,{attr:w,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),w==="effect"&&Wt(a)&&/\b(value|checked)\s*=[^=]/.test(E.value)&&r("E30",a,{attr:w,expr:E.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"}),(w==="text"||w.startsWith("text:")||w==="show")&&cn(a)&&(w==="show"||r("E18",a,{attr:w,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(a.hasAttribute("state")){let E=P(a.getAttribute("state")),w=new Set;for(let l of E)l.name.includes("-")&&r("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,"")}`}),w.has(l.name)&&r("E04",a,{attr:"state",problem:`field "${l.name}" is declared twice in one scope`}),w.add(l.name),St.has(l.name)&&r("E05",a,{attr:"state",problem:`"${l.name}" is a reserved Sap word`}),lt.has(l.name)&&r("E06",a,{attr:"state",problem:`"${l.name}" is a global HTML attribute name; pick another field name`}),l.name==="open"&&a.tagName==="DIALOG"&&r("E33",a,{attr:"state",problem:"dialog open is transient",fix:"use showModal() \u2014 declare state= only on <details> or popovers"})}if(Wt(a)){if(a.hasAttribute("-"),a.tagName==="INPUT"){let E=(a.getAttribute("type")||"text").toLowerCase();E==="file"&&r("E32",a,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),E==="password"&&!a.hasAttribute("transient")&&r("E31",a,{attr:"bind",problem:"a password must never serialize into a world-readable file",fix:"add transient to the password input"})}else if(a.tagName!=="SELECT"&&a.tagName!=="TEXTAREA"){let E=a.getAttribute("contenteditable");!(E!=null&&E!=="false")&&a.children.length>0&&r("E20",a,{attr:"bind",problem:"bind on a container element is not a control; a write would overwrite its children",fix:"bind a control (input/select/textarea), a contenteditable, or an empty text leaf"})}}if(a.hasAttribute("transient")&&a.hasAttribute("persist")&&r("E34",a,{problem:"transient and persist are opposite: persist forces the live value into the saved bytes, leaking exactly what transient drops",fix:"remove one \u2014 transient to keep it out of the file, or persist to save it"}),a.hasAttribute("item")&&!a.hasAttribute("template")){let E=a.parentElement;(!E||!E.hasAttribute("items"))&&r("E10",a,{problem:"an [item] must be a direct child of an [items] list",fix:'wrap it in a container with items="name"'})}if(a.hasAttribute("items")&&k&&r("E17",a,{attr:"items",problem:"nested items inside a detail panel is a v1 mount error (nested collections ship in v1.1)"}),a.hasAttribute("items")){let E=t.querySelector(`[trigger-add="${a.getAttribute("items")}"]`);!ht(a)&&O(a).length===0&&E&&r("E17",a,{attr:"items",problem:`trigger-add targets items="${a.getAttribute("items")}" but it has no [item template] to clone`})}}),n&&(e.halted=!0,e.haltReason=e.errors[0]?e.errors[0].code:"halt",X(t,e.haltReason)),!n}var fe="sap-styles",le="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",Ft=new WeakSet;function ln(t){if(Ft.has(t))return;let e=t.defaultView,n=e&&e.CSSStyleSheet;if(n&&"adoptedStyleSheets"in t)try{let r=new n;r.replaceSync(le),t.adoptedStyleSheets=[...t.adoptedStyleSheets,r],Ft.add(t);return}catch{}if(!t.getElementById(fe)){let r=t.createElement("style");r.id=fe,r.textContent=le,(t.head||t.documentElement).appendChild(r)}Ft.add(t)}var dn=0;function de(){return typeof performance<"u"&&performance.now?performance.now():0}function Pt(t){let e=t.id||t.getAttribute("sap")||`app-${dn++}`,n=new nt(e),r={root:t,name:e,diag:n,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Tt(t,n))return r.halted=!0,r;ln(t.ownerDocument);for(let a of t.querySelectorAll("textarea[data-value]"))At(a);let i=de();return ot(r,{trigger:"mount"}),r._mountMs=de()-i,r._mountWrites=r._stats?r._stats.writes:0,r._mountWrites>0&&n.warn("W30",t,{problem:`${r._mountWrites} paint(s) ran at mount; the saved file was out of sync with its declared state`,fix:"re-save once so the file mounts clean (a settled file writes nothing)"}),r}function pn(t,e){let n=null;return F(t,r=>{!n&&r.getAttribute("scope")===e&&(n=r)}),n}function pe(t,e,n){let r=I(t)||e;for(;r;){for(let s of P(r.getAttribute("state")||""))if(s.name===n)return{el:r,decl:s};if(r.hasAttribute("sap"))break;r=I(r.parentElement)}return null}function mn(t){return typeof t=="number"?"num":typeof t=="boolean"?"bool":"string"}function me(t){function e(b){let g=t.appFor(b);if(!g)return null;let c=at(b);if(c)return c._sapDetailRow?{ctxEl:c._sapDetailRow,appRec:g,isRow:!0}:{ctxEl:I(c.parentElement)||g.root,appRec:g,isRow:!1};let A=mt(b);if(A&&A.hasAttribute("item"))return{ctxEl:A,appRec:g,isRow:!0};let S=I(b)||g.root;return{ctxEl:S,appRec:g,isRow:S.hasAttribute("item")}}function n(b){let g=typeof b=="string"?document.querySelector(b):b;if(!g||g.nodeType!==1)return null;let c=e(g);return c?L(c.ctxEl,c.appRec,c.isRow):null}function r(b,g,c){let A=tt(b,c);if(A)return M(A).read();let S=it(b,c);if(S)return O(S).map(m=>L(m,g,!0));let x=pn(b,c);if(x)return L(x,g,!1);let $=pe(b,g.root,c);if($)return $.decl.transient?gt($.el,$.decl):G($.el.getAttribute(c),$.decl.type);let R=b._sapScope;return R?R[c]:void 0}function s(b,g,c,A,S){A.transient?Lt(b,A,c):b.setAttribute(g,bt(c,A.type)),t.schedule(S,"set:"+g)}function i(b,g){let c=new Set,A=I(b)||g;for(;A;){for(let S of P(A.getAttribute("state")||""))c.add(S.name);if(A.hasAttribute("sap"))break;A=I(A.parentElement)}return F(b,S=>{let x=S.getAttribute("bind");x&&c.add(x)}),c}function a(b,g,c,A){let S=tt(b,c);if(S){M(S).write(A);return}let x=b;for(;x;){for(let h of x.attributes)if(h.name==="calc:"+c){g.diag.error("E16",x,{attr:"calc:"+c,problem:`"${c}" is a computed field; computed fields are read-only`});return}if(x.hasAttribute("sap"))break;x=x.parentElement}let $=pe(b,g.root,c);if($){s($.el,c,A,$.decl,g);return}let R=i(b,g.root);R.delete(c);let m=c.length>=4?dt(c,[...R]):null;if(m){g.diag.error("E12",b,{key:c,problem:`unknown state key "${c}"`,didYouMean:m});return}if(St.has(c)||lt.has(c)){g.diag.error("E15",b,{key:c,problem:`cannot write undeclared field "${c}" \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 d=g.root,f=mn(A),o=d.getAttribute("state")||"",u=f==="string"?c:`${c}:${f}`;d.setAttribute("state",o?`${o} ${u}`:u),s(d,c,A,{name:c,type:f,transient:!1},g)}function k(b){let g=c=>{c.id&&(c.id="",Z(c,"row")),c.hasAttribute("sap-error")&&c.removeAttribute("sap-error")};b.id="",Z(b,"row"),b.querySelectorAll("[id]").forEach(g)}function E(b,g,c){let A=ut(g.root,b,c);if(!A)return g.diag.error("E17",b,{problem:`cannot resolve a list named "${c}" from here`}),null;let S=ht(A);if(!S)return g.diag.error("E17",A,{problem:`items="${c}" has no [item template] to clone`}),null;let x=S.cloneNode(!0);return x.removeAttribute("template"),k(x),A.appendChild(x),t.schedule(g,"trigger-add:"+c),L(x,g,!0)}function w(b,g){F(b,c=>{if(c.hasAttribute("bind")){let A=M(c),S=c.getAttribute("default");A.kind==="checkbox"||A.kind==="radio"?A.write(S!=null?S===""||S==="true"||c.value===S:c.hasAttribute("checked")):A.write(S??(c.getAttribute("value")||""))}});for(let c of P(b.getAttribute("state")||"")){let A=c.default!=null?c.default:c.type==="num"?"0":c.type==="bool"?"false":"";c.transient?Lt(b,c,G(A,c.type)):b.setAttribute(c.name,A)}t.schedule(g,"trigger-reset")}function l(b,g){if(!b.isConnected)throw new Error("stale row handle: $remove() on a removed row");b.remove(),t.schedule(g,"trigger-remove")}function y(b,g,c){if(!b.isConnected)throw new Error("stale row handle: $move() on a removed row");let A=null;if(c&&c.nodeType===1?A=c:typeof c=="string"&&(A=ut(g.root,b,c)),!A){g.diag.error("E17",b,{problem:`$move() cannot resolve target "${c}"`});return}t.moveInto(A,b),t.schedule(g,"trigger-move")}function N(b){let g=b.parentElement;return g?O(g).indexOf(b):-1}function L(b,g,c){let A={get $el(){return b},get $key(){return Z(b,c?"row":"scope")},get $index(){return N(b)},$add(x){return E(b,g,x)},$reset(){return w(b,g),S},$remove(){l(b,g)},$move(x){y(b,g,x)},get $appRec(){return g}},S=new Proxy(A,{get(x,$){return typeof $=="symbol"||$[0]==="$"?x[$]:r(b,g,$)},set(x,$,R){return typeof $=="string"&&$[0]==="$"?(x[$]=R,!0):(a(b,g,$,R),!0)},has(x,$){return typeof $=="string"&&$[0]==="$"?$ in x:r(b,g,$)!==void 0}});return S}return{Sap:n,contextElFor:e,readField:r,writeField:a,makeProxy:L}}var hn=["trigger-add","trigger-remove","trigger-reset"];function bn(t){if(t.nodeType!==1)return!1;for(let e of t.attributes){let n=e.name;if(n.startsWith("set:")||n.startsWith("move:")||n.startsWith("sort:")||hn.includes(n))return!0}return!1}function gn(t,e){let n=t,r=e.parentElement;for(;n&&n!==r;){if(n.nodeType===1&&bn(n)&&!(n.tagName==="FORM"&&n.hasAttribute("trigger-add")))return n;n=n.parentElement}return null}function he(t,e){let{Sap:n}=e;function r(m,d){let f=null,o=at(m);if(o&&o._sapDetailRow)f=o._sapDetailRow._sapScope||null;else{let p=mt(m);p&&p.hasAttribute("item")&&(f=p._sapScope||null)}return{state:(I(m)||d.root)._sapScope||d._state||{},item:f,el:m,root:d._state||{}}}function s(m,d,f){if(!m.hasAttribute("confirm")){f();return}let o=m.getAttribute("confirm"),u=o,h=D(o);if(!h.error)try{let T=U(h,r(m,d));(typeof T=="string"||typeof T=="number")&&(u=String(T))}catch{}let p=Jt();if(!p){window.confirm(u)&&f();return}if(m._sapGatePending)return;m._sapGatePending=!0;let v=()=>{m._sapGatePending=!1};p(u,()=>{v(),f()}).catch(v)}function i(m,d){for(let f of m.attributes){if(!f.name.startsWith("set:"))continue;let o=f.name.slice(4),u=D(f.value);if(u.error){d.diag.error("E08",m,{attr:f.name,expr:f.value,problem:String(u.error.message)});continue}let h;try{h=U(u,r(m,d))}catch(v){d.diag.error("E24",m,{attr:f.name,expr:f.value,problem:String(v.message)});continue}let p=n(m);p&&(p[o]=h)}}function a(m,d){let f=m.closest("[item]");if(!f)return;let o=O(f.parentElement),u=o.indexOf(f);d==="up"&&u>0?t.placeBefore(f,o[u-1]):d==="down"&&u<o.length-1&&t.placeBefore(o[u+1],f)}function k(m,d,f){if(d)return ut(f.root,m,d);let o=m;for(;o;){if(o.hasAttribute&&o.hasAttribute("items"))return o;o=o.parentElement}let u=I(m)||f.root,h=[];return F(u,p=>{p.hasAttribute("items")&&h.push(p)}),h[0]||null}function E(m,d){let f=m==null||m==="",o=d==null||d==="";if(f&&o)return 0;if(f)return 1;if(o)return-1;let u=Number(m),h=Number(d);return!Number.isNaN(u)&&!Number.isNaN(h)?u-h:String(m)<String(d)?-1:String(m)>String(d)?1:0}function w(m,d,f,o){let u=k(m,f,o);if(!u){o.diag.error("E17",m,{attr:"sort:"+d,problem:`no items list resolvable for sort:${d}`});return}let h=O(u),p=C=>C._sapScope?C._sapScope[d]:void 0,v=[...h].sort((C,z)=>E(p(C),p(z))),st=v.every((C,z)=>C===h[z])?[...v].reverse():v;for(let C of st)t.moveInto(u,C);t.schedule(o,"sort:"+d)}function l(m){if(!m||m.hidden)return;let d=m.querySelector("[bind]:not([type=hidden]), [contenteditable]");d&&typeof d.focus=="function"&&d.focus()}function y(m,d){s(m,d,()=>{let f=n(m);for(let o of[...m.attributes]){let u=o.name;if(u==="trigger-remove")f&&f.$remove();else if(u==="trigger-reset")f&&f.$reset();else if(u==="trigger-add"){let h=f&&f.$add(o.value);h&&l(h.$el)}else u==="move:up"?(a(m,"up"),t.schedule(d,"move:up")):u==="move:down"?(a(m,"down"),t.schedule(d,"move:down")):u.startsWith("move:to")?f&&f.$move(o.value):u.startsWith("sort:")&&w(m,u.slice(5),o.value,d)}[...m.attributes].some(o=>o.name.startsWith("set:"))&&i(m,d)})}function N(m){let d=m.target;if(!d||d.nodeType!==1)return;let f=t.appFor(d);if(!f)return;let o=gn(d,f.root);o&&y(o,f)}function L(m){let d=M(m),f=m.getAttribute("default");d.kind==="checkbox"?d.write(f===""||f==="true"):d.write(f??"")}function b(m,d,f){let o=n(m);if(!o)return;let u=o.$add(f);if(!u)return;let h=[];F(m,p=>{p.hasAttribute("bind")&&h.push(p)});for(let p of h){let v=tt(u.$el,p.getAttribute("bind"));v&&M(v).write(M(p).read())}h.forEach(L),h.length?typeof h[0].focus=="function"&&h[0].focus():l(u.$el)}function g(m){let d=m.target;if(!d||!d.hasAttribute||!d.hasAttribute("trigger-add"))return;let f=t.appFor(d);f&&(m.preventDefault(),s(d,f,()=>b(d,f,d.getAttribute("trigger-add"))))}function c(m){let d=m.target,f=t.appFor(d);f&&setTimeout(()=>{d.querySelectorAll("[bind]").forEach(o=>{o.dispatchEvent(new Event("input",{bubbles:!0})),o.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(f,"reset")},0)}function A(m){let d=t.appFor(m.target);d&&t.schedule(d,"toggle")}function S(m){let d=m.target;if(!d||d.nodeType!==1)return;let f=t.appFor(d);if(!f)return;d.hasAttribute("persist")&&!vt(d)&&et(d);let o=at(d);if(o&&o._sapDetailRow&&d.hasAttribute("bind")){let u=tt(o._sapDetailRow,d.getAttribute("bind"));if(u&&u!==d){M(u).write(M(d).read());return}}t.schedule(f,m.type+" "+(d.id||d.tagName.toLowerCase()))}function x(m){let d=m.detail||{};for(let f of[d.from,d.to,m.target]){if(!f||f.nodeType!==1)continue;let o=t.appFor(f);o&&t.schedule(o,"sorted")}}function $(m){if(m.key!=="ArrowUp"&&m.key!=="ArrowDown")return;let d=m.target;if(!d||d.nodeType!==1||d.tagName!=="INPUT"||!d.hasAttribute("bind")||!d.hasAttribute("step"))return;let f=(d.getAttribute("type")||"text").toLowerCase();if(f!=="text"&&f!=="tel"&&f!=="search"||!t.appFor(d))return;m.preventDefault();let u=B(d.getAttribute("step"))||1,h=m.key==="ArrowUp"?1:-1,p=B(d.value)+u*(m.shiftKey?10:1)*h,v=d.getAttribute("min"),T=d.getAttribute("max");v!==null&&v!==""&&p<B(v)&&(p=B(v)),T!==null&&T!==""&&p>B(T)&&(p=B(T)),M(d).write(String(Number(p.toFixed(2))))}function R(m=document){m.addEventListener("click",N),m.addEventListener("submit",g),m.addEventListener("reset",c),m.addEventListener("toggle",A,!0),m.addEventListener("input",S),m.addEventListener("change",S),m.addEventListener("clay:sorted",x),m.addEventListener("keydown",$)}return{install:R}}var be=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function Ot(t){return`${t.tagName.toLowerCase()}[sap]`}function yn(t){let e=0;for(let n of t.querySelectorAll("*"))for(let r of n.attributes)if(be.test(r.name)){e++;break}for(let n of t.attributes)if(be.test(n.name)){e++;break}return e}function ge(t){let e=[],n=r=>{for(let s of r.attributes){let i=s.name;(i.startsWith("calc:")||i==="text"||i.startsWith("text:")||i==="show"||i.startsWith("attr:")||i.startsWith("class:")||i.startsWith("css:")||i==="effect"||i==="invalid"||i.startsWith("set:")||i==="detail")&&e.push({el:r,attr:i,src:s.value})}};n(t);for(let r of t.querySelectorAll("*"))n(r);return e}function ye(t){function e(l){let y=l._stats||{},N=l.root;return{root:Ot(N),fields:y.fields||0,calcs:y.calcs||0,paints:y.paints||0,actions:yn(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 n(){let l=t.apps().map(e);return{ok:l.every(y=>y.ok),apps:l}}function r(l){let y=e(l);return y.ok?`sap \u2713 ${y.root} \xB7 fields ${y.fields} \xB7 calcs ${y.calcs} \xB7 paints ${y.paints} \xB7 actions ${y.actions} \xB7 lists ${y.lists} \xB7 rows ${y.rows} \xB7 warnings ${y.warnings} \xB7 mount writes ${y.mountWrites} \xB7 ${y.ms}ms`:`sap \u2717 ${y.root} \xB7 errors ${y.errors} \xB7 warnings ${y.warnings} \xB7 ${y.ms}ms`}function s(){for(let l of t.apps()){let y=r(l);l.diag.errors.length||l.halted?console.error(y):console.log(y)}}function i(){let l=[],y=[];for(let N of t.apps())l.push(...N.diag.errors),y.push(...N.diag.warnings);return{ok:l.length===0,errors:l,warnings:y,counts:{errors:l.length,warnings:y.length}}}function a(l){return l?typeof l=="string"?document.querySelector(l):l.nodeType===1?l:null:null}function k(l,y){let N=a(l);if(!N)return console.warn("sap why: element not found"),null;let L=[`sap why <${N.tagName.toLowerCase()}> \u2014 ${xt(N)}`],b=[...N.attributes].filter(c=>/^(bind|text|show|effect|invalid|detail|calc:|text:|attr:|class:|css:|set:|state|items|scope)/.test(c.name));for(let c of b)L.push(` ${c.name}="${c.value}"`);let g=N;for(;g&&!g._sapScope;)g=g.parentElement;if(g&&g._sapScope){let c=g._sapScope,A=y?[y]:Object.keys(c);L.push(" reads:");for(let S of A){let x=c[S];typeof x!="function"&&L.push(` ${S} = ${JSON.stringify(Array.isArray(x)?`[${x.length} rows]`:x)}`)}}return L.push(" serialization: textContent and value/checked attributes save with the file; reads live from properties"),console.log(L.join(`
8
- `)),null}function E(l){let y=l===void 0?!0:!!l;for(let N of t.apps())N._debug=y;return console.log(`sap debug ${y?"on":"off"} \u2014 per-pass headers will ${y?"":"no longer "}log`),y}function w(){let l=[],y=0;for(let c of t.apps()){let A=c.root,S=Ot(A);y++;let x=new nt(c.name);Tt(A,x);for(let f of x.errors)l.push({code:f.code,severity:"error",message:`${S}: ${f.code} ${f.slug} at ${f.el}`});for(let f of x.warnings)l.push({code:f.code,severity:"warn",message:`${S}: ${f.code} ${f.slug} at ${f.el}`});y++,ot(c,{trigger:"doctor-dryrun"});let $=c._stats?c._stats.writes:0;$>0&&l.push({code:"W30",severity:"warn",message:`${S}: dry recompute wrote ${$} cells on a quiet page; an element is stale or non-idempotent`}),y++;let R=ge(A).map(f=>f.src).join(" \0 "),m=[];for(let f of[A,...A.querySelectorAll("[state]")])for(let o of P(f.getAttribute("state")||""))m.push(o.name);for(let f of m)new RegExp(`(state|item)\\.${f}\\b`).test(R)||l.push({code:"I33",severity:"info",message:`${S}: field "${f}" is declared but read nowhere (dead state)`});y++;let d=new Map;for(let f of A.querySelectorAll("[id]"))d.set(f.id,(d.get(f.id)||0)+1);for(let[f,o]of d)o>1&&l.push({code:"W32",severity:"warn",message:`${S}: duplicate id "${f}" (${o} elements) \u2014 clone/edit collision`});y++;for(let f of ge(A))f.src.length>120&&l.push({code:"I33",severity:"info",message:`${S}: ${f.attr} expression is ${f.src.length} chars; consider a calc: field`});y++;for(let f of A.querySelectorAll("[text], [text\\:num]")){let o=f.textContent||"";/\.\d{5,}/.test(o)&&l.push({code:"I33",severity:"info",message:`${S}: ${xt(f)} paints >4 decimals; consider text:FMT`})}}let N=l.filter(c=>c.severity==="error").length,L=l.filter(c=>c.severity==="warn").length,b=l.filter(c=>c.severity==="info").length;console.log(`sap doctor \xB7 ${t.apps().map(c=>Ot(c.root)).join(", ")} \xB7 errors ${N} \xB7 warnings ${L} \xB7 info ${b} \xB7 ${y} checks \xB7 0ms`);for(let c of l)(c.severity==="error"?console.error:c.severity==="warn"?console.warn:console.info)(` ${c.severity==="error"?"\u2717":c.severity==="warn"?"\u26A0":"\xB7"} ${c.message}`);return l}return{status:n,report:i,why:k,debug:E,doctor:w,greenLine:r,printGreenLines:s,REGISTRY:Rt}}var wn="0.2.0",q=new Map,V=[],Bt=zt(ot);function An(t){let e=t;for(;e;){if(e.nodeType===1&&e.hasAttribute&&e.hasAttribute("sap"))return q.get(e)||null;e=e.parentNode&&e.parentNode.host?e.parentNode.host:e.parentElement}return null}function vn(){for(let t=V.length-1;t>=0;t--){let e=V[t];e.root.isConnected||(q.delete(e.root),V.splice(t,1))}}function En(t,e){if(t.moveBefore)try{t.moveBefore(e,null);return}catch{}t.appendChild(e)}function Sn(t,e){let n=e.parentElement;if(n){if(n.moveBefore)try{n.moveBefore(t,e);return}catch{}n.insertBefore(t,e)}}var K={apps:()=>V.slice(),appFor:An,isRegistered:t=>q.has(t),pruneDisconnected:vn,schedule:(t,e)=>Bt.schedule(t,e),runNow:(t,e)=>Bt.runNow(t,e),moveInto:En,placeBefore:Sn,remountIfPresent:()=>pt()},Ae=me(K),xn=he(K,Ae),Y=ye(K),we=!1;function ve(){we||(we=!0,xn.install(document),Zt(K))}function pt(t=document){ve(),Dt(K);let e=t.querySelectorAll("[sap]"),n=[];for(let r of e){if(q.has(r))continue;let s=Pt(r);q.set(r,s),V.push(s),n.push(s)}for(let r of n){let s=Y.greenLine(r);r.diag.errors.length||r.halted?console.error(s):console.log(s)}return n}function Ee(t){if(ve(),Dt(K),!t)return pt();let e=typeof t=="string"?document.querySelector(t):t;if(!e)return null;if(q.has(e))return q.get(e);let n=Pt(e);q.set(e,n),V.push(n);let r=Y.greenLine(n);return n.diag.errors.length||n.halted?console.error(r):console.log(r),n}var _=Ae.Sap;_.version=wn;_.refresh=function(){for(let e of V)e.root.isConnected&&Bt.runNow(e,"refresh")};_.batch=Qt;_.status=Y.status;_.report=Y.report;_.why=Y.why;_.debug=Y.debug;_.doctor=Y.doctor;_.greenLine=Y.greenLine;_.formats=ct;_.serializeControlToAttributes=et;_.finalizeControlForSave=Kt;_.rehydrateControlFromAttributes=At;_.mount=Ee;_.config=function(e={}){return e.formats&&Object.assign(ct,e.formats),_};_._registry=q;_._reset=function(){q.clear(),V.length=0,oe()};function $n(){typeof document>"u"||(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>pt()):pt())}$n();typeof window<"u"&&(window.Sap=_);var kn=_;return Te(Nn);})();
9
+ `)),i}error(e,r,n={}){let s=this.block(e,r,n);return this.errors.push(s),s}warn(e,r,n={}){let s=this.block(e,r,n);return this.warnings.push(s),s}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 X(t,e){t&&t.getAttribute("sap-error")!==e&&t.setAttribute("sap-error",e)}function $t(t){t&&t.hasAttribute("sap-error")&&t.removeAttribute("sap-error")}function dt(t,e){let r=null,n=3;for(let s of e){let i=Xe(t,s);i<n&&(n=i,r=s)}return r}function Xe(t,e){let r=t.length,n=e.length,s=Array.from({length:r+1},(i,a)=>[a,...new Array(n).fill(0)]);for(let i=0;i<=n;i++)s[0][i]=i;for(let i=1;i<=r;i++)for(let a=1;a<=n;a++)s[i][a]=Math.min(s[i-1][a]+1,s[i][a-1]+1,s[i-1][a-1]+(t[i-1]===e[a-1]?0:1));return s[r][n]}var j=null,Nt=!1,rt=null;function ne(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 Ke(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(n=>e(Je(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=W("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 Je(t){let e=[];for(let r of t)if(r.type==="attributes"){let n=r.target;n&&n.nodeType===1&&!kt(n)&&e.push({type:"attribute",element:n})}else if(r.type==="characterData"){let n=r.target&&r.target.parentElement;n&&!kt(n)&&e.push({type:"characterData",element:n})}else if(r.type==="childList"){for(let n of r.addedNodes)if(!(n.nodeType!==1||kt(n))&&(e.push({type:"add",element:n}),n.querySelectorAll))for(let s of n.querySelectorAll("*"))kt(s)||e.push({type:"add",element:s});for(let n of r.removedNodes)n.nodeType===1&&e.push({type:"remove",element:n,parent:r.target})}return e}function kt(t){return!!(t.closest&&t.closest("[sap-ignore],[template]"))}function Qe(t,e){t.pruneDisconnected();let r=new Set,n=!1;for(let s of e){let i=s.type==="remove"?s.parent:s.element,a=i&&t.appFor(i);a&&r.add(a),s.type==="add"&&s.element&&s.element.nodeType===1&&s.element.hasAttribute&&s.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(s.element))&&(n=!0)}n&&t.remountIfPresent();for(let s of r)s.root.isConnected&&t.schedule(s,"mutation")}function re(t){if(j)return j.suppress(t);let e=W("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function Mt(t,e){Nt=!0,j=t,t.subscribe(r=>Qe(e,r))}function Dt(t){if(Nt||typeof window>"u"||typeof document>"u")return;let e=W("Mutation");if(e&&typeof e.onAnyChange=="function"){Mt(ne(e),t);return}typeof MutationObserver=="function"&&(Mt(Ke(),t),rt=ft(document,Ct,function(){let n=W("Mutation");n&&(rt(),rt=null,j&&j.teardown(),Nt=!1,Mt(ne(n),t))}))}function oe(){if(j)try{j.teardown()}catch{}rt&&typeof document<"u"&&rt(),j=null,Nt=!1,rt=null}var ae=new Set(Et);function ot(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),X(t.root,"loop");return}re(()=>Ze(t,e))}function Ze(t,e){let r=t.root,n={},s=[],i=[],a=[],k=[],E=[],w=new Set;t.diag.errors=[];let l={root:n,state:n,item:null,ownerEl:r,projection:!1};function y(o,u){let h=o.getAttribute(u.name);return h==null&&(h=u.default!=null?u.default:u.type==="num"?"0":u.type==="bool"?"false":"",E.push({el:o,name:u.name,value:bt(G(h,u.type),u.type)})),G(h,u.type)}function N(o,u){let h=P(o.getAttribute("state")||"");o._sapStateDecls=h;for(let p of h){if(p.type==="string"&&ae.has(p.name)&&typeof o[p.name]=="boolean"){u[p.name]=o.hasAttribute(p.name);continue}if(p.transient){u[p.name]=gt(o,p);continue}u[p.name]=y(o,p)}}function L(o,u){if(!o.hasAttribute("bind"))return;let h=o.getAttribute("bind"),p=u.item||u.state,v=M(o);v.kind==="radio"?(h in p||(p[h]=""),o.checked&&(p[h]=o.value)):p[h]=v.read(),o.hasAttribute("transient")&&(o.removeAttribute("value"),o.removeAttribute("checked"))}function b(o,u){for(let h of o.attributes){let p=h.name,v=h.value;if(p.startsWith("calc:"))s.push({owner:u.item||u.state,ownerEl:u.ownerEl,name:p.slice(5),entry:D(v),el:o,ctx:u});else if(p==="text"||p.startsWith("text:"))i.push({el:o,kind:"text",fmt:p.includes(":")?p.slice(5):null,entry:D(v),ctx:u});else if(p==="show")i.push({el:o,kind:"show",entry:D(v),ctx:u});else if(p.startsWith("attr:"))i.push({el:o,kind:"attr",arg:p.slice(5),entry:D(v),ctx:u});else if(p.startsWith("class:"))i.push({el:o,kind:"class",arg:p.slice(6),entry:D(v),ctx:u});else if(p.startsWith("css:"))i.push({el:o,kind:"css",arg:p.slice(4),entry:D(v),ctx:u});else if(p==="effect")a.push({el:o,entry:D(v,!0),ctx:u});else if(p==="invalid")k.push({el:o,entry:D(v),ctx:u});else if(p.startsWith("show-when:")||p.startsWith("option:")){let T=p.slice(p.indexOf(":")+1);w.add(T),i.push({el:o,kind:"when",match:"show",field:T,values:v.split("|"),ctx:u})}else if(p.startsWith("hide-when:")){let T=p.slice(p.indexOf(":")+1);w.add(T),i.push({el:o,kind:"when",match:"hide",field:T,values:v.split("|"),ctx:u})}else if(p.startsWith("option-not:")){let T=p.slice(p.indexOf(":")+1);w.add(T),i.push({el:o,kind:"when",match:"show-not",field:T,values:v.split("|"),ctx:u})}}u.projection&&o.hasAttribute("bind")&&i.push({el:o,kind:"projection",field:o.getAttribute("bind"),ctx:u})}function g(o,u,h){Z(u,"row"),Object.defineProperty(o,"$key",{value:u.id,enumerable:!1}),Object.defineProperty(o,"$index",{value:h,enumerable:!1}),Object.defineProperty(o,"$el",{value:u,enumerable:!1})}function c(o,u,h){N(o,u),o._sapScope=u,!h.projection&&o.hasAttribute("bind")&&L(o,h),b(o,h),o.hasAttribute("items")?x(o,u,h):A(o,u,h)}function A(o,u,h){F(o,(p,v)=>{v?p.hasAttribute("scope")?S(p,u,h):p.hasAttribute("items")?(b(p,h),x(p,u,h)):p.hasAttribute("detail")&&R(p,u,h):(h.projection||L(p,h),b(p,h))})}function S(o,u,h){let p=o.getAttribute("scope"),v={};u[p]=v;let T={root:h.root,state:v,item:null,ownerEl:o,projection:h.projection};c(o,v,T)}function x(o,u,h){let p=o.getAttribute("items"),v=[];u[p]=v,o._sapList=v,O(o).forEach((T,st)=>{let C={};g(C,T,st);let z={root:h.root,state:h.state,item:C,ownerEl:T,projection:h.projection};c(T,C,z),v.push(C)})}function $(o,u){let h=String(o).split("."),p=u.state;for(let v of h)p=p?.[v];if(p===void 0){p=u.root;for(let v of h)p=p?.[v]}return p}function R(o,u,h){for(let Q of P(o.getAttribute("state")||""))Q.name in u||(u[Q.name]=y(o,Q));o._sapScope=u;let p=o.getAttribute("detail")||"",v=/^([\w.]+)\s+by\s+(.+)$/.exec(p);if(!v){o.hidden=!0,o._sapDetailRow=null;return}let T=v[1],st=v[2].trim(),C=$(T,h),z;try{z=U(D(st),{state:u,item:h.item,el:o,root:h.root})}catch{z=void 0}let J=Array.isArray(C)?C.find(Q=>Q&&String(Q.$key)===String(z)):null;if(o._sapDetailRow=J?J.$el:null,!J){o.hidden||(o.hidden=!0);return}o.hidden&&(o.hidden=!1);let qt={root:h.root,state:u,item:J,ownerEl:J.$el,projection:!0};b(o,qt),A(o,J,qt)}if(c(r,n,l),E.length&&w.size)for(let o of E)w.has(o.name)&&o.el.getAttribute(o.name)==null&&o.el.setAttribute(o.name,o.value);let m=new Map;for(let o of s){let u=m.get(o.owner);u||(u={ownerEl:o.ownerEl,list:[]},m.set(o.owner,u)),u.list.push(o)}let d=[...m.values()].sort((o,u)=>ie(u.ownerEl)-ie(o.ownerEl));for(let o of d){let u;try{u=Gt(o.list)}catch(h){t.diag.error("E07",o.list[0].el,{problem:h.message}),u=o.list}for(let h of u)try{h.owner[h.name]=U(h.entry,{state:h.ctx.state,item:h.ctx.item,el:h.el,root:h.ctx.root}),$t(h.el)}catch(p){h.owner[h.name]=void 0,t.diag.error("E24",h.el,{attr:"calc:"+h.name,expr:h.entry.src,problem:String(p.message)}),X(h.el,p.sapCode||"E24")}}let f=0;for(let o of i)f+=nn(o,t);for(let o of a)rn(o,t);for(let o of k)on(o);t._state=n,t._stats={fields:Object.keys(n).filter(o=>typeof n[o]!="function").length,calcs:s.length,paints:i.length,lists:m.size,writes:f},t._lastPass={trigger:e.trigger||"refresh",writes:f},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${f}/${i.length}`)}function tn(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 It(t,e,r,n){let s=t;for(;s&&s.nodeType===1;){if(s.hasAttribute&&s.hasAttribute(e)){let i=r.includes(s.getAttribute(e));if(n?!i:i)return!0}s=s.parentElement}return!1}function en(t,e){if(t===t.ownerDocument.activeElement)return 0;let r=M(t),n=r.read(),s=e??"";return String(n)!==String(s)?(r.write(s,{silent:!0}),1):0}function nn(t,e){if(t.kind==="projection")return en(t.el,t.ctx.item?t.ctx.item[t.field]:"");if(t.kind==="when")return se(t,null);let r={state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root};try{let n=U(t.entry,r),s=se(t,n);return $t(t.el),s}catch(n){return e.diag.error(n.sapCode==="E22"?"E22":"E24",t.el,{attr:tn(t),expr:t.entry&&t.entry.src,problem:String(n.message)}),X(t.el,n.sapCode||"E24"),0}}function se(t,e){let r=t.el;switch(t.kind){case"text":{let n=t.fmt!=null?Ut(t.fmt,e):e==null?"":String(e);return r.textContent!==n?(r.textContent=n,1):0}case"show":{let n=!e;return r.hidden!==n?(r.hidden=n,1):0}case"when":{let n=W("optionVisibility");if(n&&n._started)return r._sapWhen&&r.hidden?(r.hidden=!1,r._sapWhen=!1,1):0;let s;t.match==="hide"?s=!It(r,t.field,t.values,!1):t.match==="show-not"?s=It(r,t.field,t.values,!0):s=It(r,t.field,t.values,!1),r._sapWhen=!0;let i=!s;return r.hidden!==i?(r.hidden=i,1):0}case"attr":{let n=t.arg;if(ae.has(n)){let i=r.hasAttribute(n);return e&&!i?(r.setAttribute(n,""),1):!e&&i?(r.removeAttribute(n),1):0}let s=typeof e=="boolean"?String(e):e==null?"":String(e);return r.getAttribute(n)!==s?(r.setAttribute(n,s),1):0}case"class":{let n=!!e;return r.classList.contains(t.arg)!==n?(r.classList.toggle(t.arg,n),1):0}case"css":{let n=e==null?"":String(e);return r.style.getPropertyValue("--"+t.arg)!==n?(r.style.setProperty("--"+t.arg,n),1):0}default:return 0}}function rn(t,e){try{U(t.entry,{state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root}),$t(t.el)}catch(r){e.diag.error("E24",t.el,{attr:"effect",expr:t.entry&&t.entry.src,problem:String(r.message)}),X(t.el,"E24")}}function on(t){let e="";try{let r=U(t.entry,{state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root});e=typeof r=="string"?r:""}catch{e=""}typeof t.el.setCustomValidity=="function"&&t.el.setCustomValidity(e)}function ie(t){let e=0,r=t;for(;r&&!(r.hasAttribute&&r.hasAttribute("sap"));)r=r.parentElement,e++;return e}var sn=new Set(Et),ue=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode"]),an=new Set(["show-when","hide-when","option","option-not"]),un=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,ce=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 cn(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function Wt(t){return t.hasAttribute("bind")}function fn(t,e){e(t);for(let n of t.children)r(n);function r(n){if(n.nodeType===1&&!((n.hasAttribute("sap-ignore")||n.hasAttribute("template"))&&n.hasAttribute("sap-ignore"))){e(n);for(let s of n.children)r(s)}}}function Tt(t,e){let r=!1,n=(a,k,E)=>{e.error(a,k,E),r=!0},s=t.ownerDocument.createTreeWalker(t,4),i;for(;i=s.nextNode();)if(/\{\{.*\}\}/.test(i.nodeValue||"")){n("E02",i.parentElement||t,{problem:"moustaches in text content are not a Sap feature",fix:'move the expression onto the element: text="state.x"'});break}return fn(t,a=>{let k=a.closest&&a.closest("[detail]");for(let E of[...a.attributes]){let w=E.name,l=ee(w);if(l){n("E01",a,{attr:w,expr:E.value,problem:`"${w}" is a foreign-dialect attribute; Sap has no ${w.split(/[:=]/)[0]} directive`,fix:l+" \u2014 or wrap the subtree in sap-ignore if intentional"});continue}if(w.includes(":")){let y=w.slice(0,w.indexOf(":"));if(ue.has(y)){if(an.has(y)&&un.test(E.value)){let N=w.slice(w.indexOf(":")+1);e.warn("W04",a,{attr:w,expr:E.value,problem:`${y}: compares the "${N}" attribute against a literal value, not a JS expression`,fix:`use show="${E.value}" for an expression, or a literal like ${y}:${N}="overview"`})}}else{let N=dt(y,[...ue]);e.warn("W03",a,{attr:w,problem:`unknown "${y}:" attribute`,didYouMean:N?`${N}:`:null})}}else if(!ce.has(w)&&!lt.has(w)&&!sn.has(w)&&!/^(data-|aria-|on)/.test(w)&&!(w in a)){let y=dt(w,[...ce]);y&&e.warn("W03",a,{attr:w,problem:`unknown "${w}" attribute`,didYouMean:y})}w==="attr:hidden"&&e.warn("W03",a,{attr:w,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'}),(w==="attr:value"||w==="attr:checked"||w==="attr:selected")&&Wt(a)&&n("E30",a,{attr:w,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),w==="effect"&&Wt(a)&&/\b(value|checked)\s*=[^=]/.test(E.value)&&n("E30",a,{attr:w,expr:E.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"}),(w==="text"||w.startsWith("text:")||w==="show")&&cn(a)&&(w==="show"||n("E18",a,{attr:w,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(a.hasAttribute("state")){let E=P(a.getAttribute("state")),w=new Set;for(let l of E)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,"")}`}),w.has(l.name)&&n("E04",a,{attr:"state",problem:`field "${l.name}" is declared twice in one scope`}),w.add(l.name),St.has(l.name)&&n("E05",a,{attr:"state",problem:`"${l.name}" is a reserved Sap word`}),lt.has(l.name)&&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"})}if(Wt(a)){if(a.hasAttribute("-"),a.tagName==="INPUT"){let E=(a.getAttribute("type")||"text").toLowerCase();E==="file"&&n("E32",a,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),E==="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 E=a.getAttribute("contenteditable");!(E!=null&&E!=="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.hasAttribute("item")&&!a.hasAttribute("template")){let E=a.parentElement;(!E||!E.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 E=t.querySelector(`[trigger-add="${a.getAttribute("items")}"]`);!ht(a)&&O(a).length===0&&E&&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",X(t,e.haltReason)),!r}var fe="sap-styles",le="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",Ft=new WeakSet;function ln(t){if(Ft.has(t))return;let e=t.defaultView,r=e&&e.CSSStyleSheet;if(r&&"adoptedStyleSheets"in t)try{let n=new r;n.replaceSync(le),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],Ft.add(t);return}catch{}if(!t.getElementById(fe)){let n=t.createElement("style");n.id=fe,n.textContent=le,(t.head||t.documentElement).appendChild(n)}Ft.add(t)}var dn=0;function de(){return typeof performance<"u"&&performance.now?performance.now():0}function Pt(t){let e=t.id||t.getAttribute("sap")||`app-${dn++}`,r=new nt(e),n={root:t,name:e,diag:r,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Tt(t,r))return n.halted=!0,n;ln(t.ownerDocument);for(let a of t.querySelectorAll("textarea[data-value]"))At(a);let i=de();return ot(n,{trigger:"mount"}),n._mountMs=de()-i,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}function pn(t,e){let r=null;return F(t,n=>{!r&&n.getAttribute("scope")===e&&(r=n)}),r}function pe(t,e,r){let n=I(t)||e;for(;n;){for(let s of P(n.getAttribute("state")||""))if(s.name===r)return{el:n,decl:s};if(n.hasAttribute("sap"))break;n=I(n.parentElement)}return null}function mn(t){return typeof t=="number"?"num":typeof t=="boolean"?"bool":"string"}function me(t){function e(b){let g=t.appFor(b);if(!g)return null;let c=at(b);if(c)return c._sapDetailRow?{ctxEl:c._sapDetailRow,appRec:g,isRow:!0}:{ctxEl:I(c.parentElement)||g.root,appRec:g,isRow:!1};let A=mt(b);if(A&&A.hasAttribute("item"))return{ctxEl:A,appRec:g,isRow:!0};let S=I(b)||g.root;return{ctxEl:S,appRec:g,isRow:S.hasAttribute("item")}}function r(b){let g=typeof b=="string"?document.querySelector(b):b;if(!g||g.nodeType!==1)return null;let c=e(g);return c?L(c.ctxEl,c.appRec,c.isRow):null}function n(b,g,c){let A=tt(b,c);if(A)return M(A).read();let S=it(b,c);if(S)return O(S).map(m=>L(m,g,!0));let x=pn(b,c);if(x)return L(x,g,!1);let $=pe(b,g.root,c);if($)return $.decl.transient?gt($.el,$.decl):G($.el.getAttribute(c),$.decl.type);let R=b._sapScope;return R?R[c]:void 0}function s(b,g,c,A,S){A.transient?Lt(b,A,c):b.setAttribute(g,bt(c,A.type)),t.schedule(S,"set:"+g)}function i(b,g){let c=new Set,A=I(b)||g;for(;A;){for(let S of P(A.getAttribute("state")||""))c.add(S.name);if(A.hasAttribute("sap"))break;A=I(A.parentElement)}return F(b,S=>{let x=S.getAttribute("bind");x&&c.add(x)}),c}function a(b,g,c,A){let S=tt(b,c);if(S){M(S).write(A);return}let x=b;for(;x;){for(let h of x.attributes)if(h.name==="calc:"+c){g.diag.error("E16",x,{attr:"calc:"+c,problem:`"${c}" is a computed field; computed fields are read-only`});return}if(x.hasAttribute("sap"))break;x=x.parentElement}let $=pe(b,g.root,c);if($){s($.el,c,A,$.decl,g);return}let R=i(b,g.root);R.delete(c);let m=c.length>=4?dt(c,[...R]):null;if(m){g.diag.error("E12",b,{key:c,problem:`unknown state key "${c}"`,didYouMean:m});return}if(St.has(c)||lt.has(c)){g.diag.error("E15",b,{key:c,problem:`cannot write undeclared field "${c}" \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 d=g.root,f=mn(A),o=d.getAttribute("state")||"",u=f==="string"?c:`${c}:${f}`;d.setAttribute("state",o?`${o} ${u}`:u),s(d,c,A,{name:c,type:f,transient:!1},g)}function k(b){let g=c=>{c.id&&(c.id="",Z(c,"row")),c.hasAttribute("sap-error")&&c.removeAttribute("sap-error")};b.id="",Z(b,"row"),b.querySelectorAll("[id]").forEach(g)}function E(b,g,c){let A=ut(g.root,b,c);if(!A)return g.diag.error("E17",b,{problem:`cannot resolve a list named "${c}" from here`}),null;let S=ht(A);if(!S)return g.diag.error("E17",A,{problem:`items="${c}" has no [item template] to clone`}),null;let x=S.cloneNode(!0);return x.removeAttribute("template"),k(x),A.appendChild(x),t.schedule(g,"trigger-add:"+c),L(x,g,!0)}function w(b,g){F(b,c=>{if(c.hasAttribute("bind")){let A=M(c),S=c.getAttribute("default");A.kind==="checkbox"||A.kind==="radio"?A.write(S!=null?S===""||S==="true"||c.value===S:c.hasAttribute("checked")):A.write(S??(c.getAttribute("value")||""))}});for(let c of P(b.getAttribute("state")||"")){let A=c.default!=null?c.default:c.type==="num"?"0":c.type==="bool"?"false":"";c.transient?Lt(b,c,G(A,c.type)):b.setAttribute(c.name,A)}t.schedule(g,"trigger-reset")}function l(b,g){if(!b.isConnected)throw new Error("stale row handle: $remove() on a removed row");b.remove(),t.schedule(g,"trigger-remove")}function y(b,g,c){if(!b.isConnected)throw new Error("stale row handle: $move() on a removed row");let A=null;if(c&&c.nodeType===1?A=c:typeof c=="string"&&(A=ut(g.root,b,c)),!A){g.diag.error("E17",b,{problem:`$move() cannot resolve target "${c}"`});return}t.moveInto(A,b),t.schedule(g,"trigger-move")}function N(b){let g=b.parentElement;return g?O(g).indexOf(b):-1}function L(b,g,c){let A={get $el(){return b},get $key(){return Z(b,c?"row":"scope")},get $index(){return N(b)},$add(x){return E(b,g,x)},$reset(){return w(b,g),S},$remove(){l(b,g)},$move(x){y(b,g,x)},get $appRec(){return g}},S=new Proxy(A,{get(x,$){return typeof $=="symbol"||$[0]==="$"?x[$]:n(b,g,$)},set(x,$,R){return typeof $=="string"&&$[0]==="$"?(x[$]=R,!0):(a(b,g,$,R),!0)},has(x,$){return typeof $=="string"&&$[0]==="$"?$ in x:n(b,g,$)!==void 0}});return S}return{Sap:r,contextElFor:e,readField:n,writeField:a,makeProxy:L}}var hn=["trigger-add","trigger-remove","trigger-reset"];function bn(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:")||hn.includes(r))return!0}return!1}function gn(t,e){let r=t,n=e.parentElement;for(;r&&r!==n;){if(r.nodeType===1&&bn(r)&&!(r.tagName==="FORM"&&r.hasAttribute("trigger-add")))return r;r=r.parentElement}return null}function he(t,e){let{Sap:r}=e;function n(m,d){let f=null,o=at(m);if(o&&o._sapDetailRow)f=o._sapDetailRow._sapScope||null;else{let p=mt(m);p&&p.hasAttribute("item")&&(f=p._sapScope||null)}return{state:(I(m)||d.root)._sapScope||d._state||{},item:f,el:m,root:d._state||{}}}function s(m,d,f){if(!m.hasAttribute("confirm")){f();return}let o=m.getAttribute("confirm"),u=o,h=D(o);if(!h.error)try{let T=U(h,n(m,d));(typeof T=="string"||typeof T=="number")&&(u=String(T))}catch{}let p=Jt();if(!p){window.confirm(u)&&f();return}if(m._sapGatePending)return;m._sapGatePending=!0;let v=()=>{m._sapGatePending=!1};p(u,()=>{v(),f()}).catch(v)}function i(m,d){for(let f of m.attributes){if(!f.name.startsWith("set:"))continue;let o=f.name.slice(4),u=D(f.value);if(u.error){d.diag.error("E08",m,{attr:f.name,expr:f.value,problem:String(u.error.message)});continue}let h;try{h=U(u,n(m,d))}catch(v){d.diag.error("E24",m,{attr:f.name,expr:f.value,problem:String(v.message)});continue}let p=r(m);p&&(p[o]=h)}}function a(m,d){let f=m.closest("[item]");if(!f)return;let o=O(f.parentElement),u=o.indexOf(f);d==="up"&&u>0?t.placeBefore(f,o[u-1]):d==="down"&&u<o.length-1&&t.placeBefore(o[u+1],f)}function k(m,d,f){if(d)return ut(f.root,m,d);let o=m;for(;o;){if(o.hasAttribute&&o.hasAttribute("items"))return o;o=o.parentElement}let u=I(m)||f.root,h=[];return F(u,p=>{p.hasAttribute("items")&&h.push(p)}),h[0]||null}function E(m,d){let f=m==null||m==="",o=d==null||d==="";if(f&&o)return 0;if(f)return 1;if(o)return-1;let u=Number(m),h=Number(d);return!Number.isNaN(u)&&!Number.isNaN(h)?u-h:String(m)<String(d)?-1:String(m)>String(d)?1:0}function w(m,d,f,o){let u=k(m,f,o);if(!u){o.diag.error("E17",m,{attr:"sort:"+d,problem:`no items list resolvable for sort:${d}`});return}let h=O(u),p=C=>C._sapScope?C._sapScope[d]:void 0,v=[...h].sort((C,z)=>E(p(C),p(z))),st=v.every((C,z)=>C===h[z])?[...v].reverse():v;for(let C of st)t.moveInto(u,C);t.schedule(o,"sort:"+d)}function l(m){if(!m||m.hidden)return;let d=m.querySelector("[bind]:not([type=hidden]), [contenteditable]");d&&typeof d.focus=="function"&&d.focus()}function y(m,d){s(m,d,()=>{let f=r(m);for(let o of[...m.attributes]){let u=o.name;if(u==="trigger-remove")f&&f.$remove();else if(u==="trigger-reset")f&&f.$reset();else if(u==="trigger-add"){let h=f&&f.$add(o.value);h&&l(h.$el)}else u==="move:up"?(a(m,"up"),t.schedule(d,"move:up")):u==="move:down"?(a(m,"down"),t.schedule(d,"move:down")):u.startsWith("move:to")?f&&f.$move(o.value):u.startsWith("sort:")&&w(m,u.slice(5),o.value,d)}[...m.attributes].some(o=>o.name.startsWith("set:"))&&i(m,d)})}function N(m){let d=m.target;if(!d||d.nodeType!==1)return;let f=t.appFor(d);if(!f)return;let o=gn(d,f.root);o&&y(o,f)}function L(m){let d=M(m),f=m.getAttribute("default");d.kind==="checkbox"?d.write(f===""||f==="true"):d.write(f??"")}function b(m,d,f){let o=r(m);if(!o)return;let u=o.$add(f);if(!u)return;let h=[];F(m,p=>{p.hasAttribute("bind")&&h.push(p)});for(let p of h){let v=tt(u.$el,p.getAttribute("bind"));v&&M(v).write(M(p).read())}h.forEach(L),h.length?typeof h[0].focus=="function"&&h[0].focus():l(u.$el)}function g(m){let d=m.target;if(!d||!d.hasAttribute||!d.hasAttribute("trigger-add"))return;let f=t.appFor(d);f&&(m.preventDefault(),s(d,f,()=>b(d,f,d.getAttribute("trigger-add"))))}function c(m){let d=m.target,f=t.appFor(d);f&&setTimeout(()=>{d.querySelectorAll("[bind]").forEach(o=>{o.dispatchEvent(new Event("input",{bubbles:!0})),o.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(f,"reset")},0)}function A(m){let d=t.appFor(m.target);d&&t.schedule(d,"toggle")}function S(m){let d=m.target;if(!d||d.nodeType!==1)return;let f=t.appFor(d);if(!f)return;d.hasAttribute("persist")&&!vt(d)&&et(d);let o=at(d);if(o&&o._sapDetailRow&&d.hasAttribute("bind")){let u=tt(o._sapDetailRow,d.getAttribute("bind"));if(u&&u!==d){M(u).write(M(d).read());return}}t.schedule(f,m.type+" "+(d.id||d.tagName.toLowerCase()))}function x(m){let d=m.detail||{};for(let f of[d.from,d.to,m.target]){if(!f||f.nodeType!==1)continue;let o=t.appFor(f);o&&t.schedule(o,"sorted")}}function $(m){if(m.key!=="ArrowUp"&&m.key!=="ArrowDown")return;let d=m.target;if(!d||d.nodeType!==1||d.tagName!=="INPUT"||!d.hasAttribute("bind")||!d.hasAttribute("step"))return;let f=(d.getAttribute("type")||"text").toLowerCase();if(f!=="text"&&f!=="tel"&&f!=="search"||!t.appFor(d))return;m.preventDefault();let u=B(d.getAttribute("step"))||1,h=m.key==="ArrowUp"?1:-1,p=B(d.value)+u*(m.shiftKey?10:1)*h,v=d.getAttribute("min"),T=d.getAttribute("max");v!==null&&v!==""&&p<B(v)&&(p=B(v)),T!==null&&T!==""&&p>B(T)&&(p=B(T)),M(d).write(String(Number(p.toFixed(2))))}function R(m=document){m.addEventListener("click",N),m.addEventListener("submit",g),m.addEventListener("reset",c),m.addEventListener("toggle",A,!0),m.addEventListener("input",S),m.addEventListener("change",S),m.addEventListener("clay:sorted",x),m.addEventListener("keydown",$)}return{install:R}}var be=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function Ot(t){return`${t.tagName.toLowerCase()}[sap]`}function yn(t){let e=0;for(let r of t.querySelectorAll("*"))for(let n of r.attributes)if(be.test(n.name)){e++;break}for(let r of t.attributes)if(be.test(r.name)){e++;break}return e}function ge(t){let e=[],r=n=>{for(let s of n.attributes){let i=s.name;(i.startsWith("calc:")||i==="text"||i.startsWith("text:")||i==="show"||i.startsWith("attr:")||i.startsWith("class:")||i.startsWith("css:")||i==="effect"||i==="invalid"||i.startsWith("set:")||i==="detail")&&e.push({el:n,attr:i,src:s.value})}};r(t);for(let n of t.querySelectorAll("*"))r(n);return e}function ye(t){function e(l){let y=l._stats||{},N=l.root;return{root:Ot(N),fields:y.fields||0,calcs:y.calcs||0,paints:y.paints||0,actions:yn(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(y=>y.ok),apps:l}}function n(l){let y=e(l);return y.ok?`sap \u2713 ${y.root} \xB7 fields ${y.fields} \xB7 calcs ${y.calcs} \xB7 paints ${y.paints} \xB7 actions ${y.actions} \xB7 lists ${y.lists} \xB7 rows ${y.rows} \xB7 warnings ${y.warnings} \xB7 mount writes ${y.mountWrites} \xB7 ${y.ms}ms`:`sap \u2717 ${y.root} \xB7 errors ${y.errors} \xB7 warnings ${y.warnings} \xB7 ${y.ms}ms`}function s(){for(let l of t.apps()){let y=n(l);l.diag.errors.length||l.halted?console.error(y):console.log(y)}}function i(){let l=[],y=[];for(let N of t.apps())l.push(...N.diag.errors),y.push(...N.diag.warnings);return{ok:l.length===0,errors:l,warnings:y,counts:{errors:l.length,warnings:y.length}}}function a(l){return l?typeof l=="string"?document.querySelector(l):l.nodeType===1?l:null:null}function k(l,y){let N=a(l);if(!N)return console.warn("sap why: element not found"),null;let L=[`sap why <${N.tagName.toLowerCase()}> \u2014 ${xt(N)}`],b=[...N.attributes].filter(c=>/^(bind|text|show|effect|invalid|detail|calc:|text:|attr:|class:|css:|set:|state|items|scope)/.test(c.name));for(let c of b)L.push(` ${c.name}="${c.value}"`);let g=N;for(;g&&!g._sapScope;)g=g.parentElement;if(g&&g._sapScope){let c=g._sapScope,A=y?[y]:Object.keys(c);L.push(" reads:");for(let S of A){let x=c[S];typeof x!="function"&&L.push(` ${S} = ${JSON.stringify(Array.isArray(x)?`[${x.length} rows]`:x)}`)}}return L.push(" serialization: textContent and value/checked attributes save with the file; reads live from properties"),console.log(L.join(`
10
+ `)),null}function E(l){let y=l===void 0?!0:!!l;for(let N of t.apps())N._debug=y;return console.log(`sap debug ${y?"on":"off"} \u2014 per-pass headers will ${y?"":"no longer "}log`),y}function w(){let l=[],y=0;for(let c of t.apps()){let A=c.root,S=Ot(A);y++;let x=new nt(c.name);Tt(A,x);for(let f of x.errors)l.push({code:f.code,severity:"error",message:`${S}: ${f.code} ${f.slug} at ${f.el}`});for(let f of x.warnings)l.push({code:f.code,severity:"warn",message:`${S}: ${f.code} ${f.slug} at ${f.el}`});y++,ot(c,{trigger:"doctor-dryrun"});let $=c._stats?c._stats.writes:0;$>0&&l.push({code:"W30",severity:"warn",message:`${S}: dry recompute wrote ${$} cells on a quiet page; an element is stale or non-idempotent`}),y++;let R=ge(A).map(f=>f.src).join(" \0 "),m=[];for(let f of[A,...A.querySelectorAll("[state]")])for(let o of P(f.getAttribute("state")||""))m.push(o.name);for(let f of m)new RegExp(`(state|item)\\.${f}\\b`).test(R)||l.push({code:"I33",severity:"info",message:`${S}: field "${f}" is declared but read nowhere (dead state)`});y++;let d=new Map;for(let f of A.querySelectorAll("[id]"))d.set(f.id,(d.get(f.id)||0)+1);for(let[f,o]of d)o>1&&l.push({code:"W32",severity:"warn",message:`${S}: duplicate id "${f}" (${o} elements) \u2014 clone/edit collision`});y++;for(let f of ge(A))f.src.length>120&&l.push({code:"I33",severity:"info",message:`${S}: ${f.attr} expression is ${f.src.length} chars; consider a calc: field`});y++;for(let f of A.querySelectorAll("[text], [text\\:num]")){let o=f.textContent||"";/\.\d{5,}/.test(o)&&l.push({code:"I33",severity:"info",message:`${S}: ${xt(f)} paints >4 decimals; consider text:FMT`})}}let N=l.filter(c=>c.severity==="error").length,L=l.filter(c=>c.severity==="warn").length,b=l.filter(c=>c.severity==="info").length;console.log(`sap doctor \xB7 ${t.apps().map(c=>Ot(c.root)).join(", ")} \xB7 errors ${N} \xB7 warnings ${L} \xB7 info ${b} \xB7 ${y} checks \xB7 0ms`);for(let c of l)(c.severity==="error"?console.error:c.severity==="warn"?console.warn:console.info)(` ${c.severity==="error"?"\u2717":c.severity==="warn"?"\u26A0":"\xB7"} ${c.message}`);return l}return{status:r,report:i,why:k,debug:E,doctor:w,greenLine:n,printGreenLines:s,REGISTRY:Rt}}var wn="0.2.0",q=new Map,V=[],Bt=zt(ot);function An(t){let e=t;for(;e;){if(e.nodeType===1&&e.hasAttribute&&e.hasAttribute("sap"))return q.get(e)||null;e=e.parentNode&&e.parentNode.host?e.parentNode.host:e.parentElement}return null}function vn(){for(let t=V.length-1;t>=0;t--){let e=V[t];e.root.isConnected||(q.delete(e.root),V.splice(t,1))}}function En(t,e){if(t.moveBefore)try{t.moveBefore(e,null);return}catch{}t.appendChild(e)}function Sn(t,e){let r=e.parentElement;if(r){if(r.moveBefore)try{r.moveBefore(t,e);return}catch{}r.insertBefore(t,e)}}var K={apps:()=>V.slice(),appFor:An,isRegistered:t=>q.has(t),pruneDisconnected:vn,schedule:(t,e)=>Bt.schedule(t,e),runNow:(t,e)=>Bt.runNow(t,e),moveInto:En,placeBefore:Sn,remountIfPresent:()=>pt()},Ae=me(K),xn=he(K,Ae),Y=ye(K),we=!1;function ve(){we||(we=!0,xn.install(document),Zt(K))}function pt(t=document){ve(),Dt(K);let e=t.querySelectorAll("[sap]"),r=[];for(let n of e){if(q.has(n))continue;let s=Pt(n);q.set(n,s),V.push(s),r.push(s)}for(let n of r){let s=Y.greenLine(n);n.diag.errors.length||n.halted?console.error(s):console.log(s)}return r}function Ee(t){if(ve(),Dt(K),!t)return pt();let e=typeof t=="string"?document.querySelector(t):t;if(!e)return null;if(q.has(e))return q.get(e);let r=Pt(e);q.set(e,r),V.push(r);let n=Y.greenLine(r);return r.diag.errors.length||r.halted?console.error(n):console.log(n),r}var _=Ae.Sap;_.version=wn;_.refresh=function(){for(let e of V)e.root.isConnected&&Bt.runNow(e,"refresh")};_.batch=Qt;_.status=Y.status;_.report=Y.report;_.why=Y.why;_.debug=Y.debug;_.doctor=Y.doctor;_.greenLine=Y.greenLine;_.formats=ct;_.serializeControlToAttributes=et;_.finalizeControlForSave=Kt;_.rehydrateControlFromAttributes=At;_.mount=Ee;_.config=function(e={}){return e.formats&&Object.assign(ct,e.formats),_};_._registry=q;_._reset=function(){q.clear(),V.length=0,oe()};function $n(){typeof document>"u"||(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>pt()):pt())}$n();typeof window<"u"&&(window.Sap=_);var kn=_;return Te(Nn);})();
9
11
  if (typeof window !== 'undefined' && Sap && Sap.default) window.Sap = Sap.default;
10
12
  var sapDefault = Sap.default;
11
13
  window.clay = window.clay || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panphora/clayjs",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "description": "clayjs: malleable HTML files. Save lifecycle for self-saving HTML.",
6
6
  "license": "MIT-0",
@@ -27,7 +27,10 @@ export function enableContentEditableForAdminOnPageLoad () {
27
27
  export function enableContentEditable(root = document) {
28
28
  root.querySelectorAll(SELECTOR).forEach(el => {
29
29
  const val = el.getAttribute("inert-contenteditable");
30
- el.setAttribute("contenteditable", ["", "false", "plaintext-only"].includes(val) ? val : "true");
30
+ // Keywords match ASCII case-insensitively, so `FALSE` means false. The author's own
31
+ // spelling is what gets written, so the save transform puts it back unchanged.
32
+ const keyword = val === null ? null : val.toLowerCase();
33
+ el.setAttribute("contenteditable", ["", "true", "false", "plaintext-only"].includes(keyword) ? val : "true");
31
34
  el.removeAttribute("inert-contenteditable");
32
35
  });
33
36
  }
@@ -1,18 +1,27 @@
1
1
  import { isEditMode, isOwner } from "./is-edit-mode.js";
2
2
  import onDomReady from "../lib/dom-ready.js";
3
- import { addDocumentTransform } from "./snapshot.js";
3
+ import { addDocumentTransform, originalSnapshotNode } from "./snapshot.js";
4
4
 
5
5
  export const SELECTOR_DISABLED = '[viewmode\\:disabled]';
6
6
  export const SELECTOR_READONLY = '[viewmode\\:readonly]';
7
7
 
8
+ const BOOLEANS = [[SELECTOR_DISABLED, 'disabled'], [SELECTOR_READONLY, 'readonly']];
9
+
10
+ // What the author wrote for `disabled` / `readonly` on each live element, from before
11
+ // edit mode removed it. A boolean attribute means the same whatever its value, so this
12
+ // is only about handing the file back its own spelling (`disabled="disabled"`).
13
+ const authored = new WeakMap();
14
+
8
15
  export function disableAdminInputsBeforeSave() {
9
16
  addDocumentTransform(docElem => {
10
- docElem.querySelectorAll(SELECTOR_DISABLED).forEach(input => {
11
- input.setAttribute('disabled', '');
12
- });
13
- docElem.querySelectorAll(SELECTOR_READONLY).forEach(input => {
14
- input.setAttribute('readonly', '');
15
- });
17
+ for (const [selector, name] of BOOLEANS) {
18
+ docElem.querySelectorAll(selector).forEach(input => {
19
+ if (input.hasAttribute(name)) return;
20
+ const live = originalSnapshotNode(input);
21
+ const spelled = live && authored.get(live);
22
+ input.setAttribute(name, spelled && spelled[name] !== undefined ? spelled[name] : '');
23
+ });
24
+ }
16
25
  });
17
26
  }
18
27
 
@@ -27,12 +36,13 @@ export function enableAdminInputsOnPageLoad() {
27
36
  // `root` lets scoped live sync activate a parsed incoming document the same
28
37
  // way boot activates the live one.
29
38
  export function enableAdminInputs(root = document) {
30
- root.querySelectorAll(SELECTOR_DISABLED).forEach(input => {
31
- input.removeAttribute('disabled');
32
- });
33
- root.querySelectorAll(SELECTOR_READONLY).forEach(input => {
34
- input.removeAttribute('readonly');
35
- });
39
+ for (const [selector, name] of BOOLEANS) {
40
+ root.querySelectorAll(selector).forEach(input => {
41
+ const value = input.getAttribute(name);
42
+ if (value !== null) authored.set(input, { ...(authored.get(input) || {}), [name]: value });
43
+ input.removeAttribute(name);
44
+ });
45
+ }
36
46
  }
37
47
 
38
48
  export function disableAdminInputs() {
@@ -8,6 +8,11 @@ export function disableOnClickBeforeSave () {
8
8
  addDocumentTransform(docElem => {
9
9
  docElem.querySelectorAll(SELECTOR).forEach(resource => {
10
10
  const originalValue = resource.getAttribute("onclick");
11
+ // Only an element edit mode activated has an onclick to put back. One whose
12
+ // inert-onclick was empty or missing was never activated, so its authored
13
+ // attributes are already right, and `setAttribute(name, null)` would store the
14
+ // string "null" in the file.
15
+ if (originalValue === null) return;
11
16
  resource.setAttribute("inert-onclick", originalValue);
12
17
  resource.removeAttribute("onclick");
13
18
  });
@@ -16,6 +16,7 @@ import { savePageThrottled } from "./save.js";
16
16
  import { markUserDriven } from "../lib/user-gesture.js";
17
17
  import { resolveRegionPolicy, skipForPolicy } from "../lib/region-policy.js";
18
18
  import { PERSIST, AUTOSAVE } from "../lib/attr-aliases.js";
19
+ import { setAutosaveActive } from "../lib/autosave-state.js";
19
20
 
20
21
  /**
21
22
  * Initialize auto-save on DOM changes
@@ -65,6 +66,7 @@ function initSaveOnPersistInput() {
65
66
  function init() {
66
67
  if (!document.documentElement.matches(AUTOSAVE)) return;
67
68
  if (!isEditMode) return;
69
+ setAutosaveActive(true);
68
70
  // initUserGesture moved to save.js's init: gesture provenance belongs to every
69
71
  // editable page, not only the ones with <html autosave>.
70
72
  initSavePageOnChange();
@@ -3,6 +3,8 @@ import query from "../lib/query.js";
3
3
  import { hasSaveToken, servedStaleToken } from "./host-attrs.js";
4
4
 
5
5
  // Edit-mode precedence: an explicit ?editmode=true|false URL param wins, then an
6
+ // authored `viewonly` attribute on <html> (a tool page that must never save its
7
+ // runtime state, even on a host that hands it a save token), then an
6
8
  // opt-in window.clayEditMode global (with the legacy window.__hyperclayEditMode
7
9
  // still honored as a fallback for older standalone embedders — htmlclay itself
8
10
  // uses its injected save token plus the admin cookie, not this global), then
@@ -32,9 +34,12 @@ if (typeof window !== "undefined") {
32
34
  // explicit ?editmode=true outranks it, because that is a person at the keyboard asking
33
35
  // for it this load, not a decision baked into the document by an author who could not
34
36
  // have known. stale-host-notice.js puts the reason on the page.
37
+ const isViewOnlyDocument =
38
+ typeof document !== "undefined" && document.documentElement.hasAttribute("viewonly");
39
+
35
40
  const isEditMode = query.editmode
36
- ? query.editmode === "true" // takes precedence over the global, token and cookie
37
- : servedStaleToken()
41
+ ? query.editmode === "true" // takes precedence over viewonly, the global, token and cookie
42
+ : isViewOnlyDocument || servedStaleToken()
38
43
  ? false
39
44
  : forcedEditMode != null
40
45
  ? forcedEditMode