@panphora/clayjs 1.9.1 → 1.10.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.
@@ -0,0 +1,38 @@
1
+ /* clay-router.js — clayjs satellite: URL-hash routing as tab-local attributes. https://clayjs.com */
2
+ (function () {
3
+ var clay = window.clay = window.clay || {};
4
+ clay.loaded = clay.loaded || {};
5
+
6
+ var script = document.currentScript;
7
+ if (!script || !script.src) {
8
+ console.error("clay-router: could not determine my own URL (load me with a classic <script src=...>, not type=\"module\")");
9
+ return;
10
+ }
11
+ var url = new URL(script.src, location.href);
12
+ // Query and fragment off first, then step out of the tarball's entries/ directory
13
+ // so package-path CDNs resolve src/. See clay.js for the full reason on both.
14
+ var path = url.href.split("#")[0].split("?")[0];
15
+ var base = path.slice(0, path.lastIndexOf("/"));
16
+ if (url.pathname.slice(0, url.pathname.lastIndexOf("/")).slice(-8) === "/entries") {
17
+ base = base.slice(0, -8);
18
+ }
19
+
20
+ // Mirror the hash onto <html> now, before the module loads, so a saved
21
+ // show-when:route-* rule is right at first paint. The module re-applies.
22
+ try {
23
+ var raw = location.hash.slice(1);
24
+ if (raw.indexOf("=") !== -1) {
25
+ new URLSearchParams(raw).forEach(function (value, name) {
26
+ if (/^[a-z][a-z0-9-]*$/.test(name) && name !== "active" && value) {
27
+ document.documentElement.setAttribute("route-" + name, value);
28
+ }
29
+ });
30
+ }
31
+ } catch (e) { /* the module applies it */ }
32
+
33
+ clay.loaded.router = import(base + "/src/route/route.js")
34
+ .then(function (m) { return m.default; })
35
+ .catch(function (err) { console.error("clay-router failed to load:", err); throw err; });
36
+ // Mark handled: see clay-ui.js.
37
+ clay.loaded.router.catch(function () {});
38
+ })();
package/entries/sap.js CHANGED
@@ -1,13 +1,13 @@
1
1
  // GENERATED — do not edit. Vendored from sapjs/dist/sap.min.js via sapjs
2
2
  // `npm run copy-to-clayjs`. Edit the sapjs source and re-run.
3
3
  (function () {
4
- var Sap=(()=>{var _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(`
4
+ var Sap=(()=>{var Ht=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var qe=(t,e)=>{for(var n in e)Ht(t,n,{get:e[n],enumerable:!0})},ze=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Fe(e))!Be.call(t,o)&&o!==n&&Ht(t,o,{get:()=>e[o],enumerable:!(r=Pe(e,o))||r.enumerable});return t};var He=t=>ze(Ht({},"__esModule",{value:!0}),t);var zr={};qe(zr,{Sap:()=>I,default:()=>qr,mount:()=>Oe,mountAll:()=>qt,runtime:()=>ut});function ee(t){let e=!1,n=new Set,r=[];function o(f){f&&(r.push(f),r.length>8&&r.shift())}function a(f,w){o(w),!f._broken&&(n.add(f),!e&&(e=!0,queueMicrotask(u)))}function u(){e=!1;let f=[...n];n.clear();for(let w of f)R(w)}function R(f){if(!f._broken){if(f._passes=(f._passes||0)+1,f._passes>50){f._broken=!0,f._breakerRing=r.slice(),t(f,{breaker:!0});return}f._resetArmed||(f._resetArmed=!0,setTimeout(()=>{f._passes=0,f._resetArmed=!1},0)),t(f)}}function k(f,w){o(w),R(f)}function y(f){f._broken=!1,f._passes=0}return{schedule:a,runNow:k,rearm:y,ring:r}}var je=0,re=new WeakMap;function xt(t,e="sap"){let n=t.getAttribute("data-id");if(n)return n;if(t.id)return t.id;let r=re.get(t);return r||(r=`${e}-${(je++).toString(36)}`,re.set(t,r)),r}function kt(t,e="row"){for(;;){let n=`${e}-${Math.random().toString(36).slice(2,8)}`;if(!t.getElementById(n)&&!t.querySelector(`[data-id="${n}"]`))return n}}function Ue(t){return t.hasAttribute("scope")||t.hasAttribute("items")||t.hasAttribute("detail")||t.hasAttribute("each")}function Ve(t){return t.hasAttribute("sap-ignore")||t.hasAttribute("template")}function Y(t,e){for(let r of t.children)n(r);function n(r){if(r.nodeType!==1||Ve(r))return;let o=Ue(r);if(e(r,o),!o)for(let a of r.children)n(a)}}function H(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 gt(t){for(let e=t;e&&e.nodeType===1;e=e.parentElement){if(e._sapEachRow)return e;if(e.hasAttribute("item")||e.hasAttribute("sap"))return null}return null}function $t(t){let e=t;for(;e;){if(e.hasAttribute("detail")||e.hasAttribute("item"))return e;e=e.parentElement}return null}function wt(t){let e=t;for(;e;){if(e.hasAttribute("detail"))return e;e=e.parentElement}return null}function ft(t,e){let n=null;return Y(t,r=>{!n&&r.getAttribute("bind")===e&&(n=r)}),n}function bt(t,e){let n=null;return Y(t,r=>{!n&&r.getAttribute("items")===e&&(n=r)}),n}function X(t){return[...t.children].filter(e=>e.hasAttribute("item")&&!e.hasAttribute("template"))}function _t(t){return[...t.children].find(e=>e.hasAttribute("item")&&e.hasAttribute("template"))||null}function q(t){let e=[];if(!t)return e;for(let n of t.trim().split(/\s+/)){if(!n)continue;let r=n,o,a=r.indexOf("=");a>=0&&(o=r.slice(a+1),r=r.slice(0,a));let u=r.split(":"),R=u[0],k="string",y=!1;for(let N of u.slice(1))N==="num"?k="num":N==="bool"?k="bool":N==="transient"&&(y=!0);let f=R,w=f.startsWith("data-")&&f.length>5?f.slice(5).replace(/-([a-z])/g,(N,W)=>W.toUpperCase()):f;e.push({name:w,attr:f,type:k,default:o,transient:y})}return e}function it(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 Nt(t,e){return e==="bool"?t?"true":"false":t==null?"":String(t)}function Tt(t,e){let n=e.attr||e.name,r=t._sapTransient||(t._sapTransient={});if(!(e.name in r)){let o=t.getAttribute(n);o==null&&(o=e.default!=null?e.default:e.type==="num"?"0":e.type==="bool"?"false":""),r[e.name]=it(o,e.type)}return t.hasAttribute(n)&&t.removeAttribute(n),r[e.name]}function jt(t,e,n){let r=e.attr||e.name;(t._sapTransient||(t._sapTransient={}))[e.name]=n,t.hasAttribute(r)&&t.removeAttribute(r)}function yt(t,e,n){let r=String(n).split("."),o=r[r.length-1];if(r.length===1){let R=Ye(e,o);return R||(t.getAttribute("items")===o?t:t.querySelector(`[items="${o}"]`))}let a=r[r.length-2],u=[...t.querySelectorAll(`[scope="${a}"]`)].find(R=>bt(R,o));return u?bt(u,o):null}function Ye(t,e){let n=H(t);for(;n;){if(n.getAttribute("items")===e)return n;let r=bt(n,e);if(r)return r;n=H(n.parentElement)}return null}function K(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 Lt(t,e){return Array.isArray(t)?e==null?t:t.map(n=>typeof e=="function"?e(n):n?.[e]):[]}function ne(t,e){return Lt(t,e).reduce((n,r)=>n+K(r),0)}function Ge(t,e){return Array.isArray(t)?e==null?t.length:t.reduce((n,r)=>n+(e(r)?1:0),0):0}function Xe(t,e){let n=Lt(t,e);return n.length?ne(t,e)/n.length:0}function Ke(t,e){let n=Lt(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,o)=>String(r)<=String(o)?r:o):0}function Je(t,e){let n=Lt(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,o)=>String(r)>=String(o)?r:o):0}function Qe(t,e,n){let r=K(t)===1?e:n??e+"s";return`${t} ${r}`}function Ze(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 Z(t){return typeof t=="number"?t:Number(t)}var At={usd:t=>"$"+Z(t).toLocaleString("en-US",{maximumFractionDigits:0}),usd2:t=>"$"+Z(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),pct:t=>Math.round(Z(t))+"%",pct1:t=>Z(t).toFixed(1)+"%",int:t=>Math.round(Z(t)).toLocaleString("en-US"),num:t=>Z(t).toLocaleString("en-US"),num2:t=>Z(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),compact:t=>Z(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=Z(t),n=Math.floor(e/100),r=n%10,o=Math.floor(n/10)%60;return`${Math.floor(n/600)}:${String(o).padStart(2,"0")}.${r}`}},tr=new Set(["usd","usd2","pct","pct1","int","num","num2","compact","clock"]);function oe(t,e){if(!t)return e==null?"":String(e);let n=At[t];if(typeof n!="function"){let r=new Error(`unknown format "${t}"`);throw r.sapCode="E22",r}if(tr.has(t)){let r=typeof e=="number"?e:Number(e);if(!Number.isFinite(r)){let o=new Error(`format "${t}" received ${typeof e=="string"?`"${e}"`:e}`);throw o.sapCode="E22",o}}return n(e)}function se(){return[At,K,ne,Ge,Xe,Ke,Je,Qe,Ze]}var er=["state","item","el","root","fmt","num","sum","count","avg","min","max","plural","days"],Rt=new Map,ie=/\bstate\.([a-z][a-z0-9_]*)/g,ae=/\bitem\.([a-z][a-z0-9_]*)/g;function rr(t){let e=new Set,n=new Set,r;for(ie.lastIndex=0;r=ie.exec(t);)e.add(r[1]);for(ae.lastIndex=0;r=ae.exec(t);)n.add(r[1]);return{state:e,item:n}}function P(t,e=!1){let n=(e?"!":"")+t,r=Rt.get(n);if(r)return r;Rt.size>512&&Rt.clear();try{let o=e?`"use strict";
5
+ ${t}`:`"use strict"; return (${t});`;r={fn:new Function(...er,o),src:t,statement:e,deps:rr(t),error:null}}catch(o){r={fn:null,src:t,statement:e,deps:{state:new Set,item:new Set},error:o}}return Rt.set(n,r),r}function G(t,e){if(t.error)throw t.error;return t.fn(e.state,e.item,e.el??null,e.root,...se())}function ue(t){let e=new Map;for(let u of t)e.set(u.name,u);let n=[],r=new Map,o=[];function a(u){let R=r.get(u.name);if(R!==1){if(R===0){let k=[...o.slice(o.indexOf(u.name)),u.name].join(" -> "),y=new Error(`calc: cycle: ${k}`);throw y.sapCode="E07",y.cycle=k,y}r.set(u.name,0),o.push(u.name);for(let k of u.entry.deps.state){let y=e.get(k);y&&y!==u&&a(y)}for(let k of u.entry.deps.item){let y=e.get(k);y&&y!==u&&a(y)}o.pop(),r.set(u.name,1),n.push(u)}}for(let u of t)a(u);return n}function ce(t){return(t.getAttribute("type")||"text").toLowerCase()}function lt(t){let e=t.tagName;if(e==="INPUT"){let n=ce(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 fe(t,e=t){let n=t.tagName;if(n==="INPUT"){let r=ce(t);r==="checkbox"||r==="radio"?e.checked?t.hasAttribute("checked")||t.setAttribute("checked",""):t.removeAttribute("checked"):e.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",e.value);return}if(n==="TEXTAREA"){let r=e.value.startsWith(`
6
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=[`
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(`
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);})();
7
+ `+e.value:e.value;t.textContent!==r&&(t.textContent=r),t.removeAttribute("data-value");return}if(n==="SELECT"){let r=t.options,o=e.options;for(let a=0;a<r.length;a++)o[a]&&o[a].selected?r[a].hasAttribute("selected")||r[a].setAttribute("selected",""):r[a].removeAttribute("selected")}}function Ct(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function j(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 Ut=["clay:mutation-ready","hyperclay:mutation-ready"],nr=["clay:sync-applied","hyperclay:livesync-applied"],or=["clay:ready","hyperclay:ready"];function vt(t,e,n){let r=null,o=a=>{r!==null&&r!==a.type||(r=a.type,queueMicrotask(()=>{r=null}),n(a))};for(let a of e)t.addEventListener(a,o);return()=>{for(let a of e)t.removeEventListener(a,o)}}function le(t){let e=typeof window<"u"&&window.clay&&window.clay.ready;e&&typeof e.then=="function"?e.then(()=>t(),()=>t()):t()}function Mt(t){let e=j("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function de(){let t=j("consent");return typeof t=="function"?t:null}function pe(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let n=j("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 me(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let a=!1;for(let u of t.apps())u.root.isConnected?t.runNow(u,"platform"):a=!0;a&&(t.pruneDisconnected(),t.remountIfPresent())};vt(document,nr,e);let n=!1,r=()=>{},o=()=>{if(n)return!0;let a=j("undo");if(!a||typeof a.on!="function")return!1;let u=a.on("undo",e);return typeof u!="function"?!1:typeof a.on("redo",e)!="function"?(u(),!1):(n=!0,r(),!0)};if(!o()){let a=vt(document,Ut,o),u=vt(document,or,o);r=()=>{a(),u()};let R=j("ready");R&&typeof R.then=="function"&&R.then(o,()=>{})}}function sr(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 ir(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 ar(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return ir(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 ur(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 o of t.options)o.selected=r.has(o.value);break}case"leaf":t.textContent=n==null?"":String(n);break;default:t.value=n==null?"":String(n)}}function he(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}Mt(t)||lt(t)}function cr(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function F(t){let e=sr(t);return{el:t,kind:e,read(){return ar(t,e)},write(n,r={}){ur(t,e,n),r.noMirror||he(t),r.silent||cr(t)},mirror(){he(t)}}}var Vt={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"},E40:{slug:"each-not-array",behavior:"ERR"},E41:{slug:"each-bad-key",behavior:"ERR"},E42:{slug:"each-template",behavior:"ERR"},E43:{slug:"bind-in-each-row",behavior:"ERR"},W03:{slug:"unknown-colon-attribute",behavior:"WARN"},W04:{slug:"expression-in-when",behavior:"WARN"},W30:{slug:"nonzero-mount-writes",behavior:"WARN"}},Dt=["disabled","readonly","required","checked","selected","multiple","open","inert","autofocus","novalidate","hidden"],Et=new Set(["title","style","hidden","lang","dir","translate","class","id","nonce","autofocus","tabindex","contenteditable","spellcheck","draggable","role","slot","part","name","value","type","itemscope","itemtype","itemid","itemprop","itemref"]),It=new Set(["sap","scope","items","item","template","bind","calc","text","show","attr","set","trigger","move","sort","detail","each","effect","invalid","confirm","transient","default","persist","sortable","editmode"]);function Wt(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 o=n.tagName.toLowerCase();if(n.hasAttribute("sap"))o+="[sap]";else if(n.parentElement){let a=[...n.parentElement.children].filter(u=>u.tagName===n.tagName);a.length>1&&(o+=`:nth-of-type(${a.indexOf(n)+1})`)}if(e.unshift(o),n.hasAttribute("sap"))break;n=n.parentElement,r++}return e.join(" > ")}function be(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 dt=class{constructor(e){this.appName=e,this.errors=[],this.warnings=[],this.halted=!1,this.haltReason=null}block(e,n,r={}){let o=(Vt[e]||{}).slug||"error",a={code:e,slug:o,el:Wt(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"},u=[`
8
+ `+(e[0]==="W"?"sap \u26A0 ":"sap \u2717 ")+e+" "+o];return u.push(` at ${a.el}${a.attr?` \u2014 ${a.attr}="${a.expr??""}"`:""}`),a.problem&&u.push(` problem: ${a.problem}`),a.didYouMean&&u.push(` did you mean: ${a.didYouMean}`),a.fix&&u.push(` fix: ${a.fix}`),console.error(u.join(`
9
+ `)),a}error(e,n,r={}){let o=this.block(e,n,r);return this.errors.push(o),o}warn(e,n,r={}){let o=this.block(e,n,r);return this.warnings.push(o),o}report(){return{ok:this.errors.length===0&&!this.halted,app:this.appName,halted:this.halted,haltReason:this.haltReason,errors:this.errors.slice(),warnings:this.warnings.slice()}}};function at(t,e){t&&t.getAttribute("sap-error")!==e&&t.setAttribute("sap-error",e)}function Ot(t){t&&t.hasAttribute("sap-error")&&t.removeAttribute("sap-error")}function St(t,e){let n=null,r=3;for(let o of e){let a=fr(t,o);a<r&&(r=a,n=o)}return n}function fr(t,e){let n=t.length,r=e.length,o=Array.from({length:n+1},(a,u)=>[u,...new Array(r).fill(0)]);for(let a=0;a<=r;a++)o[0][a]=a;for(let a=1;a<=n;a++)for(let u=1;u<=r;u++)o[a][u]=Math.min(o[a-1][u]+1,o[a][u-1]+1,o[a-1][u-1]+(t[a-1]===e[u-1]?0:1));return o[n][r]}var et=null,Ft=!1,pt=null;function ge(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 lr(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(r=>e(dr(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=j("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 dr(t){let e=[];for(let n of t)if(n.type==="attributes"){let r=n.target;r&&r.nodeType===1&&!Pt(r)&&e.push({type:"attribute",element:r})}else if(n.type==="characterData"){let r=n.target&&n.target.parentElement;r&&!Pt(r)&&e.push({type:"characterData",element:r})}else if(n.type==="childList"){for(let r of n.addedNodes)if(!(r.nodeType!==1||Pt(r))&&(e.push({type:"add",element:r}),r.querySelectorAll))for(let o of r.querySelectorAll("*"))Pt(o)||e.push({type:"add",element:o});for(let r of n.removedNodes)r.nodeType===1&&e.push({type:"remove",element:r,parent:n.target})}return e}function Pt(t){return!!(t.closest&&t.closest("[sap-ignore],[template]"))}function pr(t,e){t.pruneDisconnected();let n=new Set,r=!1;for(let o of e){let a=o.type==="remove"?o.parent:o.element,u=a&&t.appFor(a);u&&n.add(u),o.type==="add"&&o.element&&o.element.nodeType===1&&o.element.hasAttribute&&o.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(o.element))&&(r=!0)}r&&t.remountIfPresent();for(let o of n)o.root.isConnected&&t.schedule(o,"mutation")}function we(t){if(et)return et.suppress(t);let e=j("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function Yt(t,e){Ft=!0,et=t,t.subscribe(n=>pr(e,n))}function Gt(t){if(Ft||typeof window>"u"||typeof document>"u")return;let e=j("Mutation");if(e&&typeof e.onAnyChange=="function"){Yt(ge(e),t);return}typeof MutationObserver=="function"&&(Yt(lr(),t),pt=vt(document,Ut,function(){let r=j("Mutation");r&&(pt(),pt=null,et&&et.teardown(),Ft=!1,Yt(ge(r),t))}))}function ye(){if(et)try{et.teardown()}catch{}pt&&typeof document<"u"&&pt(),et=null,Ft=!1,pt=null}var Ee=new Set(Dt);function mt(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),at(t.root,"loop");return}we(()=>mr(t,e)),t._viewsChanged&&(t._viewsChanged=!1,t.root.dispatchEvent(new CustomEvent("sap:views-updated",{bubbles:!0})))}function mr(t,e){let n=t.root,r={},o=[],a=[],u=[],R=[],k=[],y=[],f=[],w=new Set;t.diag.errors=[];let N={root:r,state:r,item:null,ownerEl:n,projection:!1};function W(s,p){let h=p.attr||p.name,d=s.getAttribute(h);return d==null&&(d=p.default!=null?p.default:p.type==="num"?"0":p.type==="bool"?"false":"",k.push({el:s,name:p.name,attr:h,value:Nt(it(d,p.type),p.type)})),it(d,p.type)}function b(s,p){let h=q(s.getAttribute("state")||"");s._sapStateDecls=h;for(let d of h){if(d.type==="string"&&Ee.has(d.attr)&&typeof s[d.attr]=="boolean"){p[d.name]=s.hasAttribute(d.attr);continue}if(d.transient){p[d.name]=Tt(s,d);continue}p[d.name]=W(s,d)}}function g(s,p){if(!s.hasAttribute("bind"))return;let h=s.getAttribute("bind"),d=p.item||p.state,_=F(s);_.kind==="radio"?(h in d||(d[h]=""),s.checked&&(d[h]=s.value)):d[h]=_.read(),s.hasAttribute("transient")&&(s.removeAttribute("value"),s.removeAttribute("checked"))}function c(s,p){for(let h of s.attributes){let d=h.name,_=h.value;if(d.startsWith("calc:"))o.push({owner:p.item||p.state,ownerEl:p.ownerEl,name:d.slice(5),entry:P(_),el:s,ctx:p});else if(d==="text"||d.startsWith("text:"))a.push({el:s,kind:"text",fmt:d.includes(":")?d.slice(5):null,entry:P(_),ctx:p});else if(d==="show")a.push({el:s,kind:"show",entry:P(_),ctx:p});else if(d.startsWith("attr:"))a.push({el:s,kind:"attr",arg:d.slice(5),entry:P(_),ctx:p});else if(d.startsWith("class:"))a.push({el:s,kind:"class",arg:d.slice(6),entry:P(_),ctx:p});else if(d.startsWith("css:"))a.push({el:s,kind:"css",arg:d.slice(4),entry:P(_),ctx:p});else if(d==="effect")u.push({el:s,entry:P(_,!0),ctx:p});else if(d==="invalid")R.push({el:s,entry:P(_),ctx:p});else if(d.startsWith("show-when:")||d.startsWith("option:")){let D=d.slice(d.indexOf(":")+1);w.add(D),a.push({el:s,kind:"when",match:"show",field:D,values:_.split("|"),ctx:p})}else if(d.startsWith("hide-when:")){let D=d.slice(d.indexOf(":")+1);w.add(D),a.push({el:s,kind:"when",match:"hide",field:D,values:_.split("|"),ctx:p})}else if(d.startsWith("option-not:")){let D=d.slice(d.indexOf(":")+1);w.add(D),a.push({el:s,kind:"when",match:"show-not",field:D,values:_.split("|"),ctx:p})}}p.view&&s.hasAttribute("bind")&&t.diag.error("E43",s,{attr:"bind",expr:s.getAttribute("bind"),problem:"bind inside an each row; rows are read-only views of the data",fix:"change the record with set:, Sap(el), or a detail panel"}),p.projection&&s.hasAttribute("bind")&&a.push({el:s,kind:"projection",field:s.getAttribute("bind"),ctx:p})}function A(s,p,h){Object.defineProperty(s,"$key",{value:xt(p,"row"),enumerable:!1}),Object.defineProperty(s,"$index",{value:h,enumerable:!1}),Object.defineProperty(s,"$el",{value:p,enumerable:!1})}function x(s,p,h){b(s,p),s._sapScope=p,!h.projection&&s.hasAttribute("bind")&&g(s,h),c(s,h),s.hasAttribute("items")?O(s,p,h):E(s,p,h)}function E(s,p,h){Y(s,(d,_)=>{_?d.hasAttribute("scope")?$(d,p,h):d.hasAttribute("items")?(c(d,h),O(d,p,h)):d.hasAttribute("detail")?l(d,p,h):d.hasAttribute("each")&&(c(d,h),f.push({el:d,ctx:h})):(!h.projection&&!h.view&&g(d,h),c(d,h))})}function $(s,p,h){let d=s.getAttribute("scope"),_={};p[d]=_;let D={root:h.root,state:_,item:null,ownerEl:s,projection:h.projection};x(s,_,D)}function O(s,p,h){let d=s.getAttribute("items"),_=[];p[d]=_,s._sapList=_,X(s).forEach((D,ct)=>{let V={};A(V,D,ct);let tt={root:h.root,state:h.state,item:V,ownerEl:D,projection:h.projection};x(D,V,tt),_.push(V)})}function U(s,p){let h=String(s).split("."),d=p.state;for(let _ of h)d=d?.[_];if(d===void 0){d=p.root;for(let _ of h)d=d?.[_]}return d}function l(s,p,h){for(let d of q(s.getAttribute("state")||""))d.name in p||(p[d.name]=W(s,d));y.push({el:s,parentObj:p,ctx:h})}function i(s,p,h){s._sapScope=p;let d=s.getAttribute("detail")||"",_=/^([\w.]+)\s+by\s+(.+)$/.exec(d);if(!_){s.hidden=!0,s._sapDetailRow=null;return}let D=_[1],ct=_[2].trim(),V=U(D,h),tt;try{tt=G(P(ct),{state:p,item:h.item,el:s,root:h.root})}catch{tt=void 0}let Q=Array.isArray(V)?V.find(st=>st&&String(st.$key)===String(tt)):null;if(s._sapDetailRow=Q?Q.$el:null,!Q){s.hidden||(s.hidden=!0);return}s.hidden&&(s.hidden=!1);let ot={root:h.root,state:p,item:Q,ownerEl:Q.$el,projection:!0};c(s,ot),E(s,Q,ot)}function m(s,p){let h=[...s.children].find(B=>B.tagName==="TEMPLATE"),d=h&&h.content.children.length===1?h.content.firstElementChild:null;if(!d)return t.diag.error("E42",s,{attr:"each",problem:"each needs one <template> child with exactly one element root"}),0;let _=s.getAttribute("each"),D;try{D=G(P(_),{state:p.state,item:p.item,el:s,root:p.root})}catch(B){return t.diag.error("E24",s,{attr:"each",expr:_,problem:String(B.message)}),0}if(!Array.isArray(D))return t.diag.error("E40",s,{attr:"each",expr:_,problem:"each must evaluate to an array; the list keeps its last good rows"}),0;let ct=P(s.getAttribute("key")||"item.$key"),V=[],tt=new Set;for(let B of D){let z;try{z=G(ct,{state:p.state,item:B,el:s,root:p.root})}catch{z=void 0}let M=z==null?"":String(z);if(M===""||tt.has(M))return t.diag.error("E41",s,{attr:"key",expr:ct.src,problem:M===""?"an item has no key; the list keeps its last good rows":`duplicate key "${M}"; the list keeps its last good rows`}),0;tt.add(M),V.push(M)}let Q=s._sapEach||new Map,ot=new Map,st=0,zt=h;V.forEach((B,z)=>{let M=Q.get(B);if(!M||M.parentElement!==s){M=s.ownerDocument.importNode(d,!0);let ht=(M.getAttribute("clay")||"").split(/\s+/).filter(Boolean);ht.includes("editor-ui")||M.setAttribute("clay",[...ht,"editor-ui"].join(" ")),M._sapEachRow=!0,st++}M.getAttribute("data-key")!==B&&M.setAttribute("data-key",B),zt.nextElementSibling!==M&&(Ar(s,M,zt),st++),M._sapEachItem=D[z],ot.set(B,M),zt=M});for(let[B,z]of Q)ot.get(B)!==z&&z.parentElement===s&&(z.remove(),st++);return s._sapEach=ot,V.forEach((B,z)=>{let M=ot.get(B),ht={root:p.root,state:p.state,item:D[z],ownerEl:M,projection:!1,view:!0};c(M,ht),E(M,{},ht)}),st}x(n,r,N);for(let s=0;s<y.length;s++){let{el:p,parentObj:h,ctx:d}=y[s];i(p,h,d)}if(k.length&&w.size)for(let s of k)w.has(s.attr)&&s.el.getAttribute(s.attr)==null&&s.el.setAttribute(s.attr,s.value);let v=new Map;for(let s of o){let p=v.get(s.owner);p||(p={ownerEl:s.ownerEl,list:[]},v.set(s.owner,p)),p.list.push(s)}let S=[...v.values()].sort((s,p)=>ve(p.ownerEl)-ve(s.ownerEl));for(let s of S){let p;try{p=ue(s.list)}catch(h){t.diag.error("E07",s.list[0].el,{problem:h.message}),p=s.list}for(let h of p)try{h.owner[h.name]=G(h.entry,{state:h.ctx.state,item:h.ctx.item,el:h.el,root:h.ctx.root}),Ot(h.el)}catch(d){h.owner[h.name]=void 0,t.diag.error("E24",h.el,{attr:"calc:"+h.name,expr:h.entry.src,problem:String(d.message)}),at(h.el,d.sapCode||"E24")}}let T=0;for(let s=0;s<f.length;s++)T+=m(f[s].el,f[s].ctx);let L=0,C=T;for(let s of a){let p=gr(s,t);s.ctx.view?C+=p:L+=p}for(let s of u)wr(s,t);for(let s of R)yr(s);t._state=r,t._stats={fields:Object.keys(r).filter(s=>typeof r[s]!="function").length,calcs:o.length,paints:a.length,lists:v.size,writes:L,viewWrites:C},t._viewsChanged=C>0,t._lastPass={trigger:e.trigger||"refresh",writes:L},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${L}/${a.length}`)}function hr(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 Xt(t,e,n,r){let o=t;for(;o&&o.nodeType===1;){if(o.hasAttribute&&o.hasAttribute(e)){let a=n.includes(o.getAttribute(e));if(r?!a:a)return!0}o=o.parentElement}return!1}function br(t,e){if(t===t.ownerDocument.activeElement)return 0;let n=F(t),r=n.read(),o=e??"";return String(r)!==String(o)?(n.write(o,{silent:!0}),1):0}function gr(t,e){if(t.kind==="projection")return br(t.el,t.ctx.item?t.ctx.item[t.field]:"");if(t.kind==="when")return Ae(t,null);let n={state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root};try{let r=G(t.entry,n),o=Ae(t,r);return Ot(t.el),o}catch(r){return e.diag.error(r.sapCode==="E22"?"E22":"E24",t.el,{attr:hr(t),expr:t.entry&&t.entry.src,problem:String(r.message)}),at(t.el,r.sapCode||"E24"),0}}function Ae(t,e){let n=t.el;switch(t.kind){case"text":{let r=t.fmt!=null?oe(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=j("optionVisibility");if(r&&r._started)return n._sapWhen&&n.hidden?(n.hidden=!1,n._sapWhen=!1,1):0;let o;t.match==="hide"?o=!Xt(n,t.field,t.values,!1):t.match==="show-not"?o=Xt(n,t.field,t.values,!0):o=Xt(n,t.field,t.values,!1),n._sapWhen=!0;let a=!o;return n.hidden!==a?(n.hidden=a,1):0}case"attr":{let r=t.arg;if(Ee.has(r)){let a=n.hasAttribute(r);return e&&!a?(n.setAttribute(r,""),1):!e&&a?(n.removeAttribute(r),1):0}let o=typeof e=="boolean"?String(e):e==null?"":String(e);return n.getAttribute(r)!==o?(n.setAttribute(r,o),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 wr(t,e){try{G(t.entry,{state:t.ctx.state,item:t.ctx.item,el:t.el,root:t.ctx.root}),Ot(t.el)}catch(n){e.diag.error("E24",t.el,{attr:"effect",expr:t.entry&&t.entry.src,problem:String(n.message)}),at(t.el,"E24")}}function yr(t){let e="";try{let n=G(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 ve(t){let e=0,n=t;for(;n&&!(n.hasAttribute&&n.hasAttribute("sap"));)n=n.parentElement,e++;return e}function Ar(t,e,n){let r=n.nextSibling;if(e.isConnected&&t.moveBefore)try{t.moveBefore(e,r);return}catch{}t.insertBefore(e,r)}var vr=new Set(Dt),Se=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode"]),Er=new Set(["show-when","hide-when","option","option-not"]),Sr=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,xe=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 xr(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function Kt(t){return t.hasAttribute("bind")}function kr(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 o of r.children)n(o)}}}function Bt(t,e){let n=!1,r=(u,R,k)=>{e.error(u,R,k),n=!0},o=t.ownerDocument.createTreeWalker(t,4),a;for(;a=o.nextNode();)if(/\{\{.*\}\}/.test(a.nodeValue||"")){r("E02",a.parentElement||t,{problem:"moustaches in text content are not a Sap feature",fix:'move the expression onto the element: text="state.x"'});break}return kr(t,u=>{let R=u.closest&&u.closest("[detail]");for(let k of[...u.attributes]){let y=k.name,f=be(y);if(f){r("E01",u,{attr:y,expr:k.value,problem:`"${y}" is a foreign-dialect attribute; Sap has no ${y.split(/[:=]/)[0]} directive`,fix:f+" \u2014 or wrap the subtree in sap-ignore if intentional"});continue}if(y.includes(":")){let w=y.slice(0,y.indexOf(":"));if(Se.has(w)){if(Er.has(w)&&Sr.test(k.value)){let N=y.slice(y.indexOf(":")+1);e.warn("W04",u,{attr:y,expr:k.value,problem:`${w}: compares the "${N}" attribute against a literal value, not a JS expression`,fix:`use show="${k.value}" for an expression, or a literal like ${w}:${N}="overview"`})}}else{let N=St(w,[...Se]);e.warn("W03",u,{attr:y,problem:`unknown "${w}:" attribute`,didYouMean:N?`${N}:`:null})}}else if(!xe.has(y)&&!Et.has(y)&&!vr.has(y)&&!/^(data-|aria-|on)/.test(y)&&!(y in u)){let w=St(y,[...xe]);w&&e.warn("W03",u,{attr:y,problem:`unknown "${y}" attribute`,didYouMean:w})}y==="attr:hidden"&&e.warn("W03",u,{attr:y,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'}),(y==="attr:value"||y==="attr:checked"||y==="attr:selected")&&Kt(u)&&r("E30",u,{attr:y,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),y==="effect"&&Kt(u)&&/\b(value|checked)\s*=[^=]/.test(k.value)&&r("E30",u,{attr:y,expr:k.value,problem:"effect writes value/checked on a bound control (writes a stale value with no synthetic event)",fix:"write through onclick + Sap(this) instead"}),(y==="text"||y.startsWith("text:")||y==="show")&&xr(u)&&(y==="show"||r("E18",u,{attr:y,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(u.hasAttribute("state")){let k=q(u.getAttribute("state")),y=new Set;for(let f of k)f.name.includes("-")&&r("E08",u,{attr:"state",problem:`field "${f.name}" is not a valid identifier (the hyphen parses as subtraction)`,fix:`rename to ${f.name.replace(/-/g,"")}`}),y.has(f.name)&&r("E04",u,{attr:"state",problem:`field "${f.name}" is declared twice in one scope`}),y.add(f.name),It.has(f.attr)&&r("E05",u,{attr:"state",problem:`"${f.name}" is a reserved Sap word`}),Et.has(f.attr)&&r("E06",u,{attr:"state",problem:`"${f.name}" is a global HTML attribute name; pick another field name`}),f.name==="open"&&u.tagName==="DIALOG"&&r("E33",u,{attr:"state",problem:"dialog open is transient",fix:"use showModal() \u2014 declare state= only on <details> or popovers"})}if(Kt(u)){if(u.hasAttribute("-"),u.tagName==="INPUT"){let k=(u.getAttribute("type")||"text").toLowerCase();k==="file"&&r("E32",u,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),k==="password"&&!u.hasAttribute("transient")&&r("E31",u,{attr:"bind",problem:"a password must never serialize into a world-readable file",fix:"add transient to the password input"})}else if(u.tagName!=="SELECT"&&u.tagName!=="TEXTAREA"){let k=u.getAttribute("contenteditable");!(k!=null&&k!=="false")&&u.children.length>0&&r("E20",u,{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(u.hasAttribute("transient")&&u.hasAttribute("persist")&&r("E34",u,{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"}),u.hasAttribute("item")&&!u.hasAttribute("template")){let k=u.parentElement;(!k||!k.hasAttribute("items"))&&r("E10",u,{problem:"an [item] must be a direct child of an [items] list",fix:'wrap it in a container with items="name"'})}if(u.hasAttribute("items")&&R&&r("E17",u,{attr:"items",problem:"nested items inside a detail panel is a v1 mount error (nested collections ship in v1.1)"}),u.hasAttribute("items")){let k=t.querySelector(`[trigger-add="${u.getAttribute("items")}"]`);!_t(u)&&X(u).length===0&&k&&r("E17",u,{attr:"items",problem:`trigger-add targets items="${u.getAttribute("items")}" but it has no [item template] to clone`})}}),n&&(e.halted=!0,e.haltReason=e.errors[0]?e.errors[0].code:"halt",at(t,e.haltReason)),!n}var ke="sap-styles",$e="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",Jt=new WeakSet;function $r(t){if(Jt.has(t))return;let e=t.defaultView,n=e&&e.CSSStyleSheet;if(n&&"adoptedStyleSheets"in t)try{let r=new n;r.replaceSync($e),t.adoptedStyleSheets=[...t.adoptedStyleSheets,r],Jt.add(t);return}catch{}if(!t.getElementById(ke)){let r=t.createElement("style");r.id=ke,r.textContent=$e,(t.head||t.documentElement).appendChild(r)}Jt.add(t)}var _r=0;function _e(){return typeof performance<"u"&&performance.now?performance.now():0}function Qt(t){let e=t.id||t.getAttribute("sap")||`app-${_r++}`,n=new dt(e),r={root:t,name:e,diag:n,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Bt(t,n))return r.halted=!0,r;$r(t.ownerDocument);for(let u of t.querySelectorAll("textarea[data-value]"))Ct(u);let a=_e();return mt(r,{trigger:"mount"}),r._mountMs=_e()-a,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 Nr(t,e){let n=null;return Y(t,r=>{!n&&r.getAttribute("scope")===e&&(n=r)}),n}function Ne(t,e,n){let r=H(t)||e;for(;r;){for(let o of q(r.getAttribute("state")||""))if(o.name===n)return{el:r,decl:o};if(r.hasAttribute("sap"))break;r=H(r.parentElement)}return null}function Tr(t){return typeof t=="number"?"num":typeof t=="boolean"?"bool":"string"}function Te(t){function e(b){let g=t.appFor(b);if(!g)return null;let c=gt(b),A=c&&c._sapEachItem&&c._sapEachItem.$el;if(A&&A.isConnected)return{ctxEl:A,appRec:g,isRow:!0};let x=wt(b);if(x)return x._sapDetailRow?{ctxEl:x._sapDetailRow,appRec:g,isRow:!0}:{ctxEl:H(x.parentElement)||g.root,appRec:g,isRow:!1};let E=$t(b);if(E&&E.hasAttribute("item"))return{ctxEl:E,appRec:g,isRow:!0};let $=H(b)||g.root;return{ctxEl:$,appRec:g,isRow:$.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?W(c.ctxEl,c.appRec,c.isRow):null}function r(b,g,c){let A=ft(b,c);if(A)return F(A).read();let x=bt(b,c);if(x)return X(x).map(U=>W(U,g,!0));let E=Nr(b,c);if(E)return W(E,g,!1);let $=Ne(b,g.root,c);if($)return $.decl.transient?Tt($.el,$.decl):it($.el.getAttribute($.decl.attr||c),$.decl.type);let O=b._sapScope;return O?O[c]:void 0}function o(b,g,c,A,x){A.transient?jt(b,A,c):b.setAttribute(A.attr||g,Nt(c,A.type)),t.schedule(x,"set:"+g)}function a(b,g){let c=new Set,A=H(b)||g;for(;A;){for(let x of q(A.getAttribute("state")||""))c.add(x.name);if(A.hasAttribute("sap"))break;A=H(A.parentElement)}return Y(b,x=>{let E=x.getAttribute("bind");E&&c.add(E)}),c}function u(b,g,c,A){let x=ft(b,c);if(x){F(x).write(A);return}let E=b;for(;E;){for(let S of E.attributes)if(S.name==="calc:"+c){g.diag.error("E16",E,{attr:"calc:"+c,problem:`"${c}" is a computed field; computed fields are read-only`});return}if(E.hasAttribute("sap"))break;E=E.parentElement}let $=Ne(b,g.root,c);if($){o($.el,c,A,$.decl,g);return}let O=a(b,g.root);O.delete(c);let U=c.length>=4?St(c,[...O]):null;if(U){g.diag.error("E12",b,{key:c,problem:`unknown state key "${c}"`,didYouMean:U});return}if(It.has(c)||Et.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 l=g.root,i=Tr(A),m=l.getAttribute("state")||"",v=i==="string"?c:`${c}:${i}`;l.setAttribute("state",m?`${m} ${v}`:v),o(l,c,A,{name:c,type:i,transient:!1},g)}function R(b){let g=b.ownerDocument;b.querySelectorAll("[id]").forEach(c=>{c.id=kt(g)}),b.querySelectorAll("[sap-error]").forEach(c=>c.removeAttribute("sap-error")),b.removeAttribute("sap-error"),b.hasAttribute("data-id")?(b.removeAttribute("id"),b.setAttribute("data-id",kt(g))):b.id=kt(g)}function k(b,g,c){let A=yt(g.root,b,c);if(!A)return g.diag.error("E17",b,{problem:`cannot resolve a list named "${c}" from here`}),null;let x=_t(A);if(!x)return g.diag.error("E17",A,{problem:`items="${c}" has no [item template] to clone`}),null;let E=x.cloneNode(!0);return E.removeAttribute("template"),R(E),A.appendChild(E),t.schedule(g,"trigger-add:"+c),W(E,g,!0)}function y(b,g){Y(b,c=>{if(c.hasAttribute("bind")){let A=F(c),x=c.getAttribute("default");A.kind==="checkbox"||A.kind==="radio"?A.write(x!=null?x===""||x==="true"||c.value===x:c.hasAttribute("checked")):A.write(x??(c.getAttribute("value")||""))}});for(let c of q(b.getAttribute("state")||"")){let A=c.default!=null?c.default:c.type==="num"?"0":c.type==="bool"?"false":"";c.transient?jt(b,c,it(A,c.type)):b.setAttribute(c.attr,A)}t.schedule(g,"trigger-reset")}function f(b,g){if(!b.isConnected)throw new Error("stale row handle: $remove() on a removed row");b.remove(),t.schedule(g,"trigger-remove")}function w(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=yt(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?X(g).indexOf(b):-1}function W(b,g,c){let A={get $el(){return b},get $key(){return xt(b,c?"row":"scope")},get $index(){return N(b)},$add(E){return k(b,g,E)},$reset(){return y(b,g),x},$remove(){f(b,g)},$move(E){w(b,g,E)},get $appRec(){return g}},x=new Proxy(A,{get(E,$){return typeof $=="symbol"||$[0]==="$"?E[$]:r(b,g,$)},set(E,$,O){return typeof $=="string"&&$[0]==="$"?(E[$]=O,!0):(u(b,g,$,O),!0)},has(E,$){return typeof $=="string"&&$[0]==="$"?$ in E:r(b,g,$)!==void 0}});return x}return{Sap:n,contextElFor:e,readField:r,writeField:u,makeProxy:W}}var Lr=["trigger-add","trigger-remove","trigger-reset"];function Rr(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:")||Lr.includes(n))return!0}return!1}function Cr(t,e){let n=t,r=e.parentElement;for(;n&&n!==r;){if(n.nodeType===1&&Rr(n)&&!(n.tagName==="FORM"&&n.hasAttribute("trigger-add")))return n;n=n.parentElement}return null}function Le(t,e){let{Sap:n}=e;function r(l,i){let m=null,v=gt(l),S=wt(l);if(v)m=v._sapEachItem??null;else if(S&&S._sapDetailRow)m=S._sapDetailRow._sapScope||null;else{let C=$t(l);C&&C.hasAttribute("item")&&(m=C._sapScope||null)}return{state:(H(l)||i.root)._sapScope||i._state||{},item:m,el:l,root:i._state||{}}}function o(l,i,m){if(!l.hasAttribute("confirm")){m();return}let v=l.getAttribute("confirm"),S=v,T=P(v);if(!T.error)try{let s=G(T,r(l,i));(typeof s=="string"||typeof s=="number")&&(S=String(s))}catch{}let L=de();if(!L){window.confirm(S)&&m();return}if(l._sapGatePending)return;l._sapGatePending=!0;let C=()=>{l._sapGatePending=!1};L(S,()=>{C(),m()}).catch(C)}function a(l,i){for(let m of l.attributes){if(!m.name.startsWith("set:"))continue;let v=m.name.slice(4),S=P(m.value);if(S.error){i.diag.error("E08",l,{attr:m.name,expr:m.value,problem:String(S.error.message)});continue}let T;try{T=G(S,r(l,i))}catch(C){i.diag.error("E24",l,{attr:m.name,expr:m.value,problem:String(C.message)});continue}let L=n(l);L&&(L[v]=T)}}function u(l){let i=gt(l);if(!i)return l.closest("[item]");let m=i._sapEachItem&&i._sapEachItem.$el;return m&&m.nodeType===1&&m.hasAttribute("item")?m:null}function R(l,i){let m=u(l);if(!m)return;let v=X(m.parentElement),S=v.indexOf(m);i==="up"&&S>0?t.placeBefore(m,v[S-1]):i==="down"&&S<v.length-1&&t.placeBefore(v[S+1],m)}function k(l,i,m){if(i)return yt(m.root,l,i);let v=l;for(;v;){if(v.hasAttribute&&v.hasAttribute("items"))return v;v=v.parentElement}let S=H(l)||m.root,T=[];return Y(S,L=>{L.hasAttribute("items")&&T.push(L)}),T[0]||null}function y(l,i){let m=l==null||l==="",v=i==null||i==="";if(m&&v)return 0;if(m)return 1;if(v)return-1;let S=Number(l),T=Number(i);return!Number.isNaN(S)&&!Number.isNaN(T)?S-T:String(l)<String(i)?-1:String(l)>String(i)?1:0}function f(l,i,m,v){let S=k(l,m,v);if(!S){v.diag.error("E17",l,{attr:"sort:"+i,problem:`no items list resolvable for sort:${i}`});return}let T=X(S),L=h=>h._sapScope?h._sapScope[i]:void 0,C=[...T].sort((h,d)=>y(L(h),L(d))),p=C.every((h,d)=>h===T[d])?[...C].reverse():C;for(let h of p)t.moveInto(S,h);t.schedule(v,"sort:"+i)}function w(l){if(!l||l.hidden)return;let i=l.querySelector("[bind]:not([type=hidden]), [contenteditable]");i&&typeof i.focus=="function"&&i.focus()}function N(l,i){o(l,i,()=>{let m=n(l);for(let v of[...l.attributes]){let S=v.name;if(S==="trigger-remove")m&&m.$remove();else if(S==="trigger-reset")m&&m.$reset();else if(S==="trigger-add"){let T=m&&m.$add(v.value);T&&w(T.$el)}else S==="move:up"?(R(l,"up"),t.schedule(i,"move:up")):S==="move:down"?(R(l,"down"),t.schedule(i,"move:down")):S.startsWith("move:to")?m&&m.$move(v.value):S.startsWith("sort:")&&f(l,S.slice(5),v.value,i)}[...l.attributes].some(v=>v.name.startsWith("set:"))&&a(l,i)})}function W(l){let i=l.target;if(!i||i.nodeType!==1)return;let m=t.appFor(i);if(!m)return;let v=Cr(i,m.root);v&&N(v,m)}function b(l){let i=F(l),m=l.getAttribute("default");i.kind==="checkbox"?i.write(m===""||m==="true"):i.write(m??"")}function g(l,i,m){let v=n(l);if(!v)return;let S=v.$add(m);if(!S)return;let T=[];Y(l,L=>{L.hasAttribute("bind")&&T.push(L)});for(let L of T){let C=ft(S.$el,L.getAttribute("bind"));C&&F(C).write(F(L).read())}T.forEach(b),T.length?typeof T[0].focus=="function"&&T[0].focus():w(S.$el)}function c(l){let i=l.target;if(!i||!i.hasAttribute||!i.hasAttribute("trigger-add"))return;let m=t.appFor(i);m&&(l.preventDefault(),o(i,m,()=>g(i,m,i.getAttribute("trigger-add"))))}function A(l){let i=l.target,m=t.appFor(i);m&&setTimeout(()=>{i.querySelectorAll("[bind]").forEach(v=>{v.dispatchEvent(new Event("input",{bubbles:!0})),v.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(m,"reset")},0)}function x(l){let i=t.appFor(l.target);i&&t.schedule(i,"toggle")}function E(l){let i=l.target;if(!i||i.nodeType!==1)return;let m=t.appFor(i);if(!m)return;i.hasAttribute("persist")&&!Mt(i)&&lt(i);let v=wt(i);if(v&&v._sapDetailRow&&i.hasAttribute("bind")){let S=v._sapDetailRow,T=i.getAttribute("bind"),L=ft(S,T);if(L&&L!==i){F(L).write(F(i).read());return}if(!L&&q(S.getAttribute("state")||"").some(C=>C.name===T)){e.writeField(S,m,T,F(i).read());return}}t.schedule(m,l.type+" "+(i.id||i.tagName.toLowerCase()))}function $(l){let i=l.detail||{};for(let m of[i.from,i.to,l.target]){if(!m||m.nodeType!==1)continue;let v=t.appFor(m);v&&t.schedule(v,"sorted")}}function O(l){if(l.key!=="ArrowUp"&&l.key!=="ArrowDown")return;let i=l.target;if(!i||i.nodeType!==1||i.tagName!=="INPUT"||!i.hasAttribute("bind")||!i.hasAttribute("step"))return;let m=(i.getAttribute("type")||"text").toLowerCase();if(m!=="text"&&m!=="tel"&&m!=="search"||!t.appFor(i))return;l.preventDefault();let S=K(i.getAttribute("step"))||1,T=l.key==="ArrowUp"?1:-1,L=K(i.value)+S*(l.shiftKey?10:1)*T,C=i.getAttribute("min"),s=i.getAttribute("max");C!==null&&C!==""&&L<K(C)&&(L=K(C)),s!==null&&s!==""&&L>K(s)&&(L=K(s)),F(i).write(String(Number(L.toFixed(2))))}function U(l=document){l.addEventListener("click",W),l.addEventListener("submit",c),l.addEventListener("reset",A),l.addEventListener("toggle",x,!0),l.addEventListener("input",E),l.addEventListener("change",E),l.addEventListener("clay:sorted",$),l.addEventListener("keydown",O)}return{install:U}}var Re=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function Zt(t){return`${t.tagName.toLowerCase()}[sap]`}function Mr(t){let e=0;for(let n of t.querySelectorAll("*"))for(let r of n.attributes)if(Re.test(r.name)){e++;break}for(let n of t.attributes)if(Re.test(n.name)){e++;break}return e}function Ce(t){let e=[],n=r=>{for(let o of r.attributes){let a=o.name;(a.startsWith("calc:")||a==="text"||a.startsWith("text:")||a==="show"||a.startsWith("attr:")||a.startsWith("class:")||a.startsWith("css:")||a==="effect"||a==="invalid"||a.startsWith("set:")||a==="detail")&&e.push({el:r,attr:a,src:o.value})}};n(t);for(let r of t.querySelectorAll("*"))n(r);return e}function Me(t){function e(f){let w=f._stats||{},N=f.root;return{root:Zt(N),fields:w.fields||0,calcs:w.calcs||0,paints:w.paints||0,actions:Mr(N),lists:(N.hasAttribute("items")?1:0)+N.querySelectorAll("[items]").length,rows:N.querySelectorAll("[item]:not([template])").length,warnings:f.diag.warnings.length,errors:f.diag.errors.length,mountWrites:f._mountWrites||0,ms:Math.round((f._mountMs||0)*10)/10,passes:f._passes||0,lastPass:f._lastPass||null,ok:f.diag.errors.length===0&&!f.halted}}function n(){let f=t.apps().map(e);return{ok:f.every(w=>w.ok),apps:f}}function r(f){let w=e(f);return w.ok?`sap \u2713 ${w.root} \xB7 fields ${w.fields} \xB7 calcs ${w.calcs} \xB7 paints ${w.paints} \xB7 actions ${w.actions} \xB7 lists ${w.lists} \xB7 rows ${w.rows} \xB7 warnings ${w.warnings} \xB7 mount writes ${w.mountWrites} \xB7 ${w.ms}ms`:`sap \u2717 ${w.root} \xB7 errors ${w.errors} \xB7 warnings ${w.warnings} \xB7 ${w.ms}ms`}function o(){for(let f of t.apps()){let w=r(f);f.diag.errors.length||f.halted?console.error(w):console.log(w)}}function a(){let f=[],w=[];for(let N of t.apps())f.push(...N.diag.errors),w.push(...N.diag.warnings);return{ok:f.length===0,errors:f,warnings:w,counts:{errors:f.length,warnings:w.length}}}function u(f){return f?typeof f=="string"?document.querySelector(f):f.nodeType===1?f:null:null}function R(f,w){let N=u(f);if(!N)return console.warn("sap why: element not found"),null;let W=[`sap why <${N.tagName.toLowerCase()}> \u2014 ${Wt(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)W.push(` ${c.name}="${c.value}"`);let g=N;for(;g&&!g._sapScope;)g=g.parentElement;if(g&&g._sapScope){let c=g._sapScope,A=w?[w]:Object.keys(c);W.push(" reads:");for(let x of A){let E=c[x];typeof E!="function"&&W.push(` ${x} = ${JSON.stringify(Array.isArray(E)?`[${E.length} rows]`:E)}`)}}return W.push(" serialization: textContent and value/checked attributes save with the file; reads live from properties"),console.log(W.join(`
10
+ `)),null}function k(f){let w=f===void 0?!0:!!f;for(let N of t.apps())N._debug=w;return console.log(`sap debug ${w?"on":"off"} \u2014 per-pass headers will ${w?"":"no longer "}log`),w}function y(){let f=[],w=0;for(let c of t.apps()){let A=c.root,x=Zt(A);w++;let E=new dt(c.name);Bt(A,E);for(let i of E.errors)f.push({code:i.code,severity:"error",message:`${x}: ${i.code} ${i.slug} at ${i.el}`});for(let i of E.warnings)f.push({code:i.code,severity:"warn",message:`${x}: ${i.code} ${i.slug} at ${i.el}`});w++,mt(c,{trigger:"doctor-dryrun"});let $=c._stats?c._stats.writes:0;$>0&&f.push({code:"W30",severity:"warn",message:`${x}: dry recompute wrote ${$} cells on a quiet page; an element is stale or non-idempotent`}),w++;let O=Ce(A).map(i=>i.src).join(" \0 "),U=[];for(let i of[A,...A.querySelectorAll("[state]")])for(let m of q(i.getAttribute("state")||""))U.push(m.name);for(let i of U)new RegExp(`(state|item)\\.${i}\\b`).test(O)||f.push({code:"I33",severity:"info",message:`${x}: field "${i}" is declared but read nowhere (dead state)`});w++;let l=new Map;for(let i of A.querySelectorAll("[id]"))l.set(i.id,(l.get(i.id)||0)+1);for(let[i,m]of l)m>1&&f.push({code:"W32",severity:"warn",message:`${x}: duplicate id "${i}" (${m} elements) \u2014 clone/edit collision`});w++;for(let i of Ce(A))i.src.length>120&&f.push({code:"I33",severity:"info",message:`${x}: ${i.attr} expression is ${i.src.length} chars; consider a calc: field`});w++;for(let i of A.querySelectorAll("[text], [text\\:num]")){let m=i.textContent||"";/\.\d{5,}/.test(m)&&f.push({code:"I33",severity:"info",message:`${x}: ${Wt(i)} paints >4 decimals; consider text:FMT`})}}let N=f.filter(c=>c.severity==="error").length,W=f.filter(c=>c.severity==="warn").length,b=f.filter(c=>c.severity==="info").length;console.log(`sap doctor \xB7 ${t.apps().map(c=>Zt(c.root)).join(", ")} \xB7 errors ${N} \xB7 warnings ${W} \xB7 info ${b} \xB7 ${w} checks \xB7 0ms`);for(let c of f)(c.severity==="error"?console.error:c.severity==="warn"?console.warn:console.info)(` ${c.severity==="error"?"\u2717":c.severity==="warn"?"\u26A0":"\xB7"} ${c.message}`);return f}return{status:n,report:a,why:R,debug:k,doctor:y,greenLine:r,printGreenLines:o,REGISTRY:Vt}}var Dr="0.2.0",J=new Map,rt=[],te=ee(mt);function Ir(t){let e=t;for(;e;){if(e.nodeType===1&&e.hasAttribute&&e.hasAttribute("sap"))return J.get(e)||null;e=e.parentNode&&e.parentNode.host?e.parentNode.host:e.parentElement}return null}function Wr(){for(let t=rt.length-1;t>=0;t--){let e=rt[t];e.root.isConnected||(J.delete(e.root),rt.splice(t,1))}}function Or(t,e){if(t.moveBefore)try{t.moveBefore(e,null);return}catch{}t.appendChild(e)}function Pr(t,e){let n=e.parentElement;if(n){if(n.moveBefore)try{n.moveBefore(t,e);return}catch{}n.insertBefore(t,e)}}var ut={apps:()=>rt.slice(),appFor:Ir,isRegistered:t=>J.has(t),pruneDisconnected:Wr,schedule:(t,e)=>te.schedule(t,e),runNow:(t,e)=>te.runNow(t,e),moveInto:Or,placeBefore:Pr,remountIfPresent:()=>qt()},Ie=Te(ut),Fr=Le(ut,Ie),nt=Me(ut),De=!1;function We(){De||(De=!0,Fr.install(document),me(ut))}function qt(t=document){We(),Gt(ut);let e=t.querySelectorAll("[sap]"),n=[];for(let r of e){if(J.has(r))continue;let o=Qt(r);J.set(r,o),rt.push(o),n.push(o)}for(let r of n){let o=nt.greenLine(r);r.diag.errors.length||r.halted?console.error(o):console.log(o)}return n}function Oe(t){if(We(),Gt(ut),!t)return qt();let e=typeof t=="string"?document.querySelector(t):t;if(!e)return null;if(J.has(e))return J.get(e);let n=Qt(e);J.set(e,n),rt.push(n);let r=nt.greenLine(n);return n.diag.errors.length||n.halted?console.error(r):console.log(r),n}var I=Ie.Sap;I.version=Dr;I.refresh=function(){for(let e of rt)e.root.isConnected&&te.runNow(e,"refresh")};I.batch=pe;I.status=nt.status;I.report=nt.report;I.why=nt.why;I.debug=nt.debug;I.doctor=nt.doctor;I.greenLine=nt.greenLine;I.formats=At;I.serializeControlToAttributes=lt;I.finalizeControlForSave=fe;I.rehydrateControlFromAttributes=Ct;I.mount=Oe;I.config=function(e={}){return e.formats&&Object.assign(At,e.formats),I};I._registry=J;I._reset=function(){J.clear(),rt.length=0,ye()};function Br(){if(typeof document>"u")return;let t=()=>le(()=>qt());document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}Br();typeof window<"u"&&(window.Sap=I);var qr=I;return He(zr);})();
11
11
  if (typeof window !== 'undefined' && Sap && Sap.default) window.Sap = Sap.default;
12
12
  var sapDefault = Sap.default;
13
13
  window.clay = window.clay || {};
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@panphora/clayjs",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "type": "module",
5
- "description": "clayjs: malleable HTML files. Save lifecycle for self-saving HTML.",
5
+ "description": "clayjs: malleable documents. Save lifecycle for self-saving HTML.",
6
6
  "license": "MIT-0",
7
7
  "homepage": "https://clayjs.com",
8
8
  "repository": {
@@ -7,6 +7,7 @@
7
7
  "@panphora/clayjs/entries/clay-events.js",
8
8
  "@panphora/clayjs/entries/clay-internals.js",
9
9
  "@panphora/clayjs/entries/clay-options.js",
10
+ "@panphora/clayjs/entries/clay-router.js",
10
11
  "@panphora/clayjs/entries/clay-ui.js",
11
12
  "@panphora/clayjs/entries/clay-utils.js",
12
13
  "@panphora/clayjs/entries/sap.js",
@@ -19,6 +19,7 @@
19
19
  import { onSnapshot, addDocumentTransform } from "../core/snapshot.js";
20
20
  import { isEditMode } from "../core/is-edit-mode.js";
21
21
  import { FREEZE_SELECTOR } from "../lib/region-policy.js";
22
+ import { ROUTE_ACTIVE_ATTR } from "../lib/root-attrs.js";
22
23
  import Mutation from "../lib/mutation.js";
23
24
 
24
25
  const originals = new WeakMap();
@@ -29,10 +30,19 @@ function log(...args) {
29
30
  if (saveFreeze.debug) console.log('[save-freeze]', ...args);
30
31
  }
31
32
 
33
+ // The captured original is what the file keeps, so it must hold no router stamp:
34
+ // the router can mark a child route-active before this capture runs.
35
+ function authoredInnerHTML(el) {
36
+ if (!el.querySelector(`[${ROUTE_ACTIVE_ATTR}]`)) return el.innerHTML;
37
+ const copy = el.cloneNode(true);
38
+ for (const s of copy.querySelectorAll(`[${ROUTE_ACTIVE_ATTR}]`)) s.removeAttribute(ROUTE_ACTIVE_ATTR);
39
+ return copy.innerHTML;
40
+ }
41
+
32
42
  function capture(el) {
33
43
  if (!originals.has(el)) {
34
- originals.set(el, el.innerHTML);
35
- log('captured original', el.innerHTML.substring(0, 80) + '...');
44
+ originals.set(el, authoredInnerHTML(el));
45
+ log('captured original', originals.get(el).substring(0, 80) + '...');
36
46
  }
37
47
  }
38
48
 
@@ -41,7 +41,7 @@
41
41
  import { stripExtensionNoise } from '../lib/extension-noise.js';
42
42
  import { restoreAuthoredUrls } from '../lib/authored-url.js';
43
43
  import { STRIP_FROM_SAVE, STRIP_FROM_COMPARISON, STRIP_FROM_DIRTY_CHECK, NO_TRIGGER_AUTOSAVE_SELECTOR, SNAPSHOT_REMOVE_SELECTOR } from '../lib/region-policy.js';
44
- import { TAB_LOCAL_ROOT_ATTRS } from '../lib/root-attrs.js';
44
+ import { TAB_LOCAL_ROOT_ATTRS, stripRouteAttrs } from '../lib/root-attrs.js';
45
45
  import { createContentView } from '../lib/content-dom.js';
46
46
 
47
47
  // =============================================================================
@@ -277,6 +277,9 @@ export function captureSnapshot({ flushUndo = true, authored = true } = {}) {
277
277
  // snapshot so it never reaches a save, a comparison, or a live-sync broadcast.
278
278
  stripExtensionNoise(clone);
279
279
 
280
+ // Router state says where this tab is, not what the document holds.
281
+ stripRouteAttrs(clone);
282
+
280
283
  return clone;
281
284
  }
282
285
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * source-map.js — save the file, not a serialization of it.
3
3
  *
4
- * Every program that edits a malleable HTML file rewrites the whole file, because
4
+ * Every program that edits a malleable document rewrites the whole file, because
5
5
  * each one parses to a tree and serializes the tree back out, and a serializer does
6
6
  * not reproduce its input. A no-edit save through `clone.outerHTML` rewrites about
7
7
  * 88% of an authored document's lines: attributes reorder, quoting normalises, `&`
@@ -69,7 +69,7 @@
69
69
  import { EXTENSION_ATTR_PATTERN } from './extension-noise.js';
70
70
  import { resolveRegionPolicy, isInert, strictestPolicy, skipForPolicy } from './region-policy.js';
71
71
  import { isPolicyAttribute } from './region-capabilities.js';
72
- import { ROOT_LIBRARY_ATTRS } from './root-attrs.js';
72
+ import { ROOT_LIBRARY_ATTRS, ROUTE_ROOT_PREFIX, ROUTE_ACTIVE_ATTR } from './root-attrs.js';
73
73
 
74
74
  import { isUserDrivenNow, markUserDriven } from './user-gesture.js';
75
75
 
@@ -83,12 +83,15 @@ const dummyElem = document.createElement("div");
83
83
  // instead of body. The raw lane is deliberately unfiltered ("raw means raw"), so
84
84
  // without this every save would push a savestatus flip into undo's record stream
85
85
  // and Cmd+Z after a save would undo that instead of the user's edit.
86
+ // Router state (route-* on the root, route-active anywhere) is dropped here for the same reason.
86
87
  const ROOT_LIBRARY_ATTR_SET = new Set(ROOT_LIBRARY_ATTRS);
87
88
 
88
89
  function isLibraryRootAttr(record) {
89
- return record.type === 'attributes'
90
- && record.target === document.documentElement
91
- && ROOT_LIBRARY_ATTR_SET.has(record.attributeName);
90
+ if (record.type !== 'attributes') return false;
91
+ const name = record.attributeName;
92
+ if (name === ROUTE_ACTIVE_ATTR) return true;
93
+ return record.target === document.documentElement
94
+ && (ROOT_LIBRARY_ATTR_SET.has(name) || name.startsWith(ROUTE_ROOT_PREFIX));
92
95
  }
93
96
 
94
97
  function withoutLibraryNoise(records) {
@@ -127,6 +130,7 @@ const localMutation = {
127
130
  * Always pair with resume() in a try/finally block.
128
131
  */
129
132
  pause() {
133
+ if (this._pauseDepth === 0) this._deliverBeforePause();
130
134
  // Reference-counted so nested pauses (e.g. a programmatic pause wrapping a
131
135
  // live-sync morph that also pauses) only resume on the outermost release.
132
136
  this._pauseDepth++;
@@ -139,6 +143,26 @@ const localMutation = {
139
143
  this._log('Paused', this._pauseDepth);
140
144
  },
141
145
 
146
+ // Records the browser queued before this pause describe changes made outside
147
+ // it. Left in the queue, resume() would drain them as paused-time records and
148
+ // only non-pausable callbacks would see them, so autosave missed a change made
149
+ // just before a pause. Deliver them on a microtask, as the observer would have.
150
+ _deliverBeforePause() {
151
+ if (!this._observer) return;
152
+ const records = this._observer.takeRecords();
153
+ if (records.length) queueMicrotask(() => this._onRecords(records));
154
+ },
155
+
156
+ /**
157
+ * Hand the records the browser has queued to raw subscribers' buffers and to
158
+ * non-pausable callbacks only, as if they had happened inside a pause. For a
159
+ * caller whose writes and their undoing cancel out, so the page's change feed
160
+ * has nothing to see.
161
+ */
162
+ dropQueued() {
163
+ if (this._observer) this._drainBrowserQueue(this);
164
+ },
165
+
142
166
  /**
143
167
  * Resume mutation observation after a pause.
144
168
  */
@@ -0,0 +1,16 @@
1
+ export const PERSON_COLORS = Object.freeze(['#6b4fa8', '#2f6a9e', '#9a6a1c', '#a8463d', '#2f7a69', '#4f6178', '#3f7d3a', '#a2457a']);
2
+
3
+ export function colorIndexOf(id) {
4
+ let hash = 0;
5
+ for (const ch of String(id)) hash = (hash * 31 + ch.codePointAt(0)) >>> 0;
6
+ return hash % PERSON_COLORS.length;
7
+ }
8
+
9
+ export function personColor(id) {
10
+ return PERSON_COLORS[colorIndexOf(id)];
11
+ }
12
+
13
+ export function initialsOf(name) {
14
+ const letters = String(name).trim().split(/\s+/).filter(Boolean).slice(0, 2).map((word) => Array.from(word)[0]);
15
+ return letters.join("").toUpperCase() || "?";
16
+ }
@@ -116,3 +116,31 @@ export const TAB_LOCAL_ROOT_ATTRS = new Set([
116
116
  export function isTabLocalRootAttr(name, element) {
117
117
  return element === document.documentElement && TAB_LOCAL_ROOT_ATTRS.has(name);
118
118
  }
119
+
120
+ // Router state. The router mirrors each URL-hash param onto the root as
121
+ // route-<name>, and stamps route-active on the record a param selects. Both say
122
+ // where this tab is in the document, not what the document holds, so they are
123
+ // tab-local like the library's own root state: never saved, never dirty, never
124
+ // undone, never sent to or taken from a peer. route-* is reserved on the root
125
+ // only; route-active is reserved on every element.
126
+ export const ROUTE_ROOT_PREFIX = "route-";
127
+ export const ROUTE_ACTIVE_ATTR = "route-active";
128
+
129
+ /**
130
+ * True when `name` on `el` belongs to this tab rather than to the document:
131
+ * every tab-local root attribute, route-* on a root, and route-active anywhere.
132
+ * Works on the live root and on a snapshot clone's or parsed frame's root.
133
+ */
134
+ export function isTabLocalAttr(name, el) {
135
+ if (name === ROUTE_ACTIVE_ATTR) return true;
136
+ if (!el || el.localName !== "html" || el.parentElement) return false;
137
+ return TAB_LOCAL_ROOT_ATTRS.has(name) || name.startsWith(ROUTE_ROOT_PREFIX);
138
+ }
139
+
140
+ /** Remove router state from a snapshot clone: route-* on its root, route-active anywhere. */
141
+ export function stripRouteAttrs(root) {
142
+ for (const attr of [...root.attributes]) {
143
+ if (attr.name.startsWith(ROUTE_ROOT_PREFIX)) root.removeAttribute(attr.name);
144
+ }
145
+ for (const el of root.querySelectorAll(`[${ROUTE_ACTIVE_ATTR}]`)) el.removeAttribute(ROUTE_ACTIVE_ATTR);
146
+ }