@adia-ai/web-modules 0.8.4 → 0.8.6

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.
@@ -1,4 +1,4 @@
1
- var S=Symbol("signal"),f=null,h=null,_=!1;function P(t){for(let e of t){if(e.disposed){t.delete(e);continue}e.dirty=!0,h||(h=new Set,_||queueMicrotask(q)),h.add(e)}}function q(){let t,e=0;for(;t=h;){if(++e>100){h=null,console.error("signals: drain loop exceeded 100 iterations");break}h=null;for(let n of t)if(!n.disposed&&n.dirty){n.dirty=!1;try{n.run()}catch(r){n.onError?n.onError(r):(n.disposed=!0,queueMicrotask(()=>{throw r}))}}}}function K(t){if(_){t();return}_=!0;try{t()}finally{_=!1,h&&q()}}function T(t){let e=f;f=null;try{return t()}finally{f=e}}function p(t){let e=new Set;return{[S]:!0,get value(){return f&&e.add(f),t},set value(n){Object.is(t,n)||(t=n,P(e))},peek(){return t}}}function O(t){let e=new Set,n,r=!0,i={dirty:!1,disposed:!1,run(){r=!0,P(e)}};return{[S]:!0,get value(){if(f&&e.add(f),r){let s=f;f=i;try{n=t(),r=!1}finally{f=s}}return n},peek(){return n}}}function m(t,e){let n={dirty:!1,disposed:!1,host:e?.host??null,onError:e?.onError??null,run(){let r=f;f=n;try{t()}finally{f=r}}};return n.run(),()=>{n.disposed=!0}}function k(t){return t!=null&&typeof t=="object"&&t[S]===!0}var[v,b]=[Symbol(),Symbol()];function V(t,...e){return{strings:t,values:e}}function X(t,...e){let n="";for(let i=0;i<t.length;i++)n+=t[i],i<e.length&&(n+=e[i]);let r=new CSSStyleSheet;return r.replaceSync(n),r}var I=new WeakMap;function Y(t){let e=0,n=0,r=0;for(;r<t.length;){if(e===0&&t.charCodeAt(r)===60&&t.charCodeAt(r+1)===33&&t.charCodeAt(r+2)===45&&t.charCodeAt(r+3)===45){let s=t.indexOf("-->",r+4);if(s===-1){n=0;break}r=s+3,n=0;continue}let i=t.charCodeAt(r);e?i===(e===1?39:34)&&(e=0):i===39?e=1:i===34?e=2:i===60?n=1:i===62&&(n=0),r++}return n===1}function J(t){let e=I.get(t);if(e)return e;let n="";for(let r=0;r<t.length;r++)n+=t[r],r<t.length-1&&(n+=Y(n)?`{{p:${r}}}`:`<!--p:${r}-->`);return e=document.createElement("template"),e.innerHTML=n,I.set(t,e),e}var R={classname:"className",innertext:"innerText",innerhtml:"innerHTML",outerhtml:"outerHTML",textcontent:"textContent",tabindex:"tabIndex",arialabel:"ariaLabel",ariadescribedby:"ariaDescribedBy",arialabelledby:"ariaLabelledBy",ariarole:"role",contenteditable:"contentEditable",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",colspan:"colSpan",rowspan:"rowSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",usemap:"useMap",ismap:"isMap",accesskey:"accessKey",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",defaultselected:"defaultSelected"};function B(t,e){if(R[e])return R[e];let n=Object.getOwnPropertyNames(t);for(let i=0;i<n.length;i++){let s=n[i];if(s!==e&&s.toLowerCase()===e)return s}let r=Object.getPrototypeOf(t);for(;r&&r!==Object.prototype;){let i=Object.getOwnPropertyNames(r);for(let s=0;s<i.length;s++){let l=i[s];if(l!==e&&l.toLowerCase()===e)return l}r=Object.getPrototypeOf(r)}return e}function g(t,e){let n=e._i;(!n||n.s!==t.strings)&&(n&&C(n.p),n=Q(t,e),e._i=n),ne(n.p,t.values)}function Q(t,e){let{strings:n}=t,i=J(n).content.cloneNode(!0),s=Z(e);s&&(i=ee(i,s));let l=te(i,t.values.length);return e.replaceChildren(i),{s:n,p:l}}var A="http://www.w3.org/2000/svg",y="http://www.w3.org/1998/Math/MathML",D="http://www.w3.org/1999/xhtml";function Z(t){if(!t||t.nodeType!==1)return null;if(t.namespaceURI===A)return A;if(t.namespaceURI===y)return y;if(typeof t.closest!="function")return null;let e=t.closest("svg, math, foreignObject, annotation-xml");if(!e)return null;let n=e.localName;if(n==="foreignobject"||n==="foreignObject")return null;if(n==="annotation-xml"){let r=(e.getAttribute("encoding")||"").toLowerCase();return r==="text/html"||r==="application/xhtml+xml"?null:y}return n==="svg"?A:n==="math"?y:null}function ee(t,e){let n=document.createDocumentFragment();return H(t,n,e),n}function H(t,e,n){for(let r of[...t.childNodes])if(r.nodeType===1){let s=document.createElementNS(n,r.localName);for(let o of r.attributes)o.namespaceURI?s.setAttributeNS(o.namespaceURI,o.name,o.value):s.setAttribute(o.name,o.value);e.appendChild(s);let l=r.localName,c=n;if(n===A&&(l==="foreignObject"||l==="foreignobject"))c=D;else if(n===y&&l==="annotation-xml"){let o=(r.getAttribute("encoding")||"").toLowerCase();(o==="text/html"||o==="application/xhtml+xml")&&(c=D)}H(r,s,c)}else e.appendChild(r.cloneNode(!0))}function te(t,e){let n=new Array(e),r=document.createTreeWalker(t,129),i;for(;i=r.nextNode();)if(i.nodeType===8){let s=i.data.match(/^p:(\d+)$/);if(s){let l=document.createTextNode("");i.replaceWith(l),r.currentNode=l,n[+s[1]]={t:"n",n:l,c:void 0,_fx:null}}}else if(i.nodeType===1)for(let s of[...i.attributes]){let l=s.value.match(/^\{\{p:(\d+)\}\}$/);if(!l){if(s.value.includes("{{p:")){let a=s.name,u=a==="class"?' class="${expression}" \u2190 full replacement (whole class string is the expression)\n .className=${expression} \u2190 writes to the className property (resolved camelCase since FB-55 fix)\n':a==="style"?' style="${expression}" \u2190 full replacement of the style string\n .style.cssText=${expression} \u2190 write CSS text via the style.cssText accessor\n':` ${a}="\${expression}" \u2190 full replacement (whole attr is the placeholder)
1
+ var S=Symbol("signal"),f=null,h=null,A=!1;function P(t){for(let e of t){if(e.disposed){t.delete(e);continue}e.dirty=!0,h||(h=new Set,A||queueMicrotask(I)),h.add(e)}}function I(){let t,e=0;for(;t=h;){if(++e>100){h=null,console.error("signals: drain loop exceeded 100 iterations");break}h=null;for(let n of t)if(!n.disposed&&n.dirty){n.dirty=!1;try{n.run()}catch(r){n.onError?n.onError(r):(n.disposed=!0,queueMicrotask(()=>{throw r}))}}}}function K(t){if(A){t();return}A=!0;try{t()}finally{A=!1,h&&I()}}function E(t){let e=f;f=null;try{return t()}finally{f=e}}function m(t){let e=new Set;return{[S]:!0,get value(){return f&&e.add(f),t},set value(n){Object.is(t,n)||(t=n,P(e))},peek(){return t}}}function T(t){let e=new Set,n,r=!0,i={dirty:!1,disposed:!1,run(){r=!0,P(e)}};return{[S]:!0,get value(){if(f&&e.add(f),r){let s=f;f=i;try{n=t(),r=!1}finally{f=s}}return n},peek(){return n}}}function p(t,e){let n={dirty:!1,disposed:!1,host:e?.host??null,onError:e?.onError??null,run(){let r=f;f=n;try{t()}finally{f=r}}};return n.run(),()=>{n.disposed=!0}}function k(t){return t!=null&&typeof t=="object"&&t[S]===!0}var[v,b]=[Symbol(),Symbol()];function X(t,...e){return{strings:t,values:e}}function Y(t,...e){let n="";for(let i=0;i<t.length;i++)n+=t[i],i<e.length&&(n+=e[i]);let r=new CSSStyleSheet;return r.replaceSync(n),r}var q=new WeakMap;function J(t){let e=0,n=0,r=0;for(;r<t.length;){if(e===0&&t.charCodeAt(r)===60&&t.charCodeAt(r+1)===33&&t.charCodeAt(r+2)===45&&t.charCodeAt(r+3)===45){let s=t.indexOf("-->",r+4);if(s===-1){n=0;break}r=s+3,n=0;continue}let i=t.charCodeAt(r);e?i===(e===1?39:34)&&(e=0):i===39?e=1:i===34?e=2:i===60?n=1:i===62&&(n=0),r++}return n===1}function Q(t){let e=q.get(t);if(e)return e;let n="";for(let r=0;r<t.length;r++)n+=t[r],r<t.length-1&&(n+=J(n)?`{{p:${r}}}`:`<!--p:${r}-->`);return e=document.createElement("template"),e.innerHTML=n,q.set(t,e),e}var R={classname:"className",innertext:"innerText",innerhtml:"innerHTML",outerhtml:"outerHTML",textcontent:"textContent",tabindex:"tabIndex",arialabel:"ariaLabel",ariadescribedby:"ariaDescribedBy",arialabelledby:"ariaLabelledBy",ariarole:"role",contenteditable:"contentEditable",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",colspan:"colSpan",rowspan:"rowSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",usemap:"useMap",ismap:"isMap",accesskey:"accessKey",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",defaultselected:"defaultSelected"};function B(t,e){if(R[e])return R[e];let n=Object.getOwnPropertyNames(t);for(let i=0;i<n.length;i++){let s=n[i];if(s!==e&&s.toLowerCase()===e)return s}let r=Object.getPrototypeOf(t);for(;r&&r!==Object.prototype;){let i=Object.getOwnPropertyNames(r);for(let s=0;s<i.length;s++){let l=i[s];if(l!==e&&l.toLowerCase()===e)return l}r=Object.getPrototypeOf(r)}return e}function g(t,e){let n=e._i;(!n||n.s!==t.strings)&&(n&&C(n.p),n=Z(t,e),e._i=n),re(n.p,t.values)}function Z(t,e){let{strings:n}=t,i=Q(n).content.cloneNode(!0),s=ee(e);s&&(i=te(i,s));let l=ne(i,t.values.length);return e.replaceChildren(i),{s:n,p:l}}var _="http://www.w3.org/2000/svg",y="http://www.w3.org/1998/Math/MathML",D="http://www.w3.org/1999/xhtml";function ee(t){if(!t||t.nodeType!==1)return null;if(t.namespaceURI===_)return _;if(t.namespaceURI===y)return y;if(typeof t.closest!="function")return null;let e=t.closest("svg, math, foreignObject, annotation-xml");if(!e)return null;let n=e.localName;if(n==="foreignobject"||n==="foreignObject")return null;if(n==="annotation-xml"){let r=(e.getAttribute("encoding")||"").toLowerCase();return r==="text/html"||r==="application/xhtml+xml"?null:y}return n==="svg"?_:n==="math"?y:null}function te(t,e){let n=document.createDocumentFragment();return H(t,n,e),n}function H(t,e,n){for(let r of[...t.childNodes])if(r.nodeType===1){let s=document.createElementNS(n,r.localName);for(let o of r.attributes)o.namespaceURI?s.setAttributeNS(o.namespaceURI,o.name,o.value):s.setAttribute(o.name,o.value);e.appendChild(s);let l=r.localName,c=n;if(n===_&&(l==="foreignObject"||l==="foreignobject"))c=D;else if(n===y&&l==="annotation-xml"){let o=(r.getAttribute("encoding")||"").toLowerCase();(o==="text/html"||o==="application/xhtml+xml")&&(c=D)}H(r,s,c)}else e.appendChild(r.cloneNode(!0))}function ne(t,e){let n=new Array(e),r=document.createTreeWalker(t,129),i;for(;i=r.nextNode();)if(i.nodeType===8){let s=i.data.match(/^p:(\d+)$/);if(s){let l=document.createTextNode("");i.replaceWith(l),r.currentNode=l,n[+s[1]]={t:"n",n:l,c:void 0,_fx:null}}}else if(i.nodeType===1)for(let s of[...i.attributes]){let l=s.value.match(/^\{\{p:(\d+)\}\}$/);if(!l){if(s.value.includes("{{p:")){let a=s.name,u=a==="class"?' class="${expression}" \u2190 full replacement (whole class string is the expression)\n .className=${expression} \u2190 writes to the className property (resolved camelCase since FB-55 fix)\n':a==="style"?' style="${expression}" \u2190 full replacement of the style string\n .style.cssText=${expression} \u2190 write CSS text via the style.cssText accessor\n':` ${a}="\${expression}" \u2190 full replacement (whole attr is the placeholder)
2
2
  .${a}=\${expression} \u2190 property assignment (preferred for objects/functions)
3
3
  `;console.warn(`[template] Partial attribute interpolation is not supported.
4
4
  Element: <${i.tagName.toLowerCase()}>
@@ -7,4 +7,4 @@ var S=Symbol("signal"),f=null,h=null,_=!1;function P(t){for(let e of t){if(e.dis
7
7
  `+u+" Compute the full attr value as a single expression and interpolate the whole.")}continue}let c=+l[1],o=s.name;o[0]==="@"?(i.removeAttribute(o),n[c]={t:"e",n:i,name:o.slice(1),c:void 0,_fx:null}):o[0]==="."?(i.removeAttribute(o),n[c]={t:"p",n:i,name:B(i,o.slice(1)),c:void 0,_fx:null,_resolved:!1}):o[0]==="?"?(i.removeAttribute(o),console.warn(`[template] Lit-style boolean attribute "${o}=" is not supported.
8
8
  Element: <${i.tagName.toLowerCase()}>
9
9
  Use .${o.slice(1)}=\${value} (property binding) instead \u2014 the primitive reflects the property to the DOM attribute for you.
10
- See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),n[c]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):n[c]={t:"a",n:i,name:o,c:void 0,_fx:null}}return n}function C(t){for(let e of t)e&&e._fx&&(e._fx(),e._fx=null)}function M(t){if(t.n.nodeType===1&&t.n[v])return t.n;let e=document.createElement("span");return e.style.display="contents",e.setAttribute("role","presentation"),e[v]=!0,t.n.replaceWith(e),t.n=e,e}var U=t=>t!=null&&typeof t=="object"&&t.strings,W=t=>typeof t=="function"||t!=null&&typeof t.handleEvent=="function";function j(t,e){if(e!==t.c){if(t.t==="n")if(e!=null&&e._directive)e._commit(M(t));else if(U(e))g(e,M(t));else if(Array.isArray(e)){let n=M(t);n.replaceChildren();for(let r of e)if(U(r)){let i=document.createElement("span");i.style.display="contents",i.setAttribute("role","presentation"),n.appendChild(i),g(r,i)}else n.appendChild(document.createTextNode(r??""))}else if(e instanceof Node)t.n.replaceWith(e),t.n=e;else if(t.n[v]){let n=document.createTextNode(e??"");t.n.replaceWith(n),t.n=n}else t.n.textContent=e??"";else if(t.t==="a")e==null||e===!1?t.n.removeAttribute(t.name):t.n.setAttribute(t.name,e===!0?"":e);else if(t.t==="p"){if(!t._resolved){let n=B(t.n,t.name);n!==t.name&&(t.name=n),t._resolved=!0}t.n[t.name]=e}else t.t==="e"&&(W(t.c)&&t.n.removeEventListener(t.name,t.c),W(e)&&t.n.addEventListener(t.name,e));t.c=e}}function ne(t,e){for(let n=0;n<t.length;n++){let r=t[n];if(!r)continue;let i=e[n],s=r.t!=="e"&&typeof i=="function",l=!s&&r.t!=="e"&&k(i);if(r._fx&&!s&&!l&&(r._fx(),r._fx=null),s){r._fx||(r._fx=m(()=>j(r,i())));continue}if(l){r._fx||(r._fx=m(()=>j(r,i.value)));continue}j(r,i)}}function re(t,e,n){return{_directive:!0,_commit(r){let i=r[b]||new Map,s=new Map,l=[];for(let o=0;o<t.length;o++){let a=e(t[o],o);if(s.has(a))continue;l.push(a);let u=n(t[o],o);if(i.has(a)){let d=i.get(a);g(u,d),s.set(a,d)}else{let d=document.createElement("span");d.style.display="contents",d.setAttribute("role","presentation"),g(u,d),s.set(a,d)}}for(let[o,a]of i)s.has(o)||(a._i&&C(a._i.p),a.remove());let c=null;for(let o=l.length-1;o>=0;o--){let a=s.get(l[o]);(a.nextSibling!==c||a.parentNode!==r)&&r.insertBefore(a,c),c=a}r[b]=s}}}var $=new Map,F=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function de(t){if(!t.name)throw new Error("Trait requires a name");if(!t.setup)throw new Error(`Trait "${t.name}" requires a setup function`);if(!t.category)throw new Error(`Trait "${t.name}" requires a category`);if(!F.has(t.category))throw new Error(`Trait "${t.name}" has unknown category "${t.category}". Known: ${[...F].join(", ")}`);if(!t.description)throw new Error(`Trait "${t.name}" requires a description`);let e=Object.freeze({name:t.name,category:t.category,description:t.description,attributes:Object.freeze(t.attributes||[]),events:Object.freeze(t.events||[]),config:Object.freeze(t.config||[])});function n(){let r=null;return{schema:e,connect(i,s){r=t.setup({host:i,...s||{}})},disconnect(i){r&&(r(),r=null);for(let s of e.attributes)i.hasAttribute(s)&&(console.warn(`Trait "${e.name}": attribute "${s}" still present after disconnect`),i.removeAttribute(s))}}}return n.schema=e,$.set(t.name,n),n}function z(t){return $.get(t)||null}function he(t){return $.get(t)?.schema||null}function me(){return[...$.keys()]}var L=Symbol(),w=Symbol();function ie(t,e){t[w]=new Map,t[L]=new Map;for(let[n,r]of Object.entries(e)){let i=r.attribute??n.toLowerCase(),s=r.type??String,l=Object.prototype.hasOwnProperty.call(t,n),c=l?t[n]:void 0;l&&delete t[n];let o=p(r.default??void 0);t[L].set(n,o),Object.defineProperty(t,n,{get(){return o.value},set(a){let u=o.peek();Object.is(u,a)||(t[w].set(n,u),o.value=a,r.reflect&&se(t,i,a,s))},configurable:!0}),l&&(o.value=c)}}function se(t,e,n,r){r===Boolean?n?t.setAttribute(e,""):t.removeAttribute(e):n==null?t.removeAttribute(e):t.setAttribute(e,String(n))}var oe=(t,e)=>e===Boolean?t!==null:e===Number?t===null?null:+t:t;function ae(t){if(Object.hasOwn(t,"_sa"))return;t._sa=!0;let e=t.styles;if(!e)return;let n=Array.isArray(e)?e:[e];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...n.filter(r=>!document.adoptedStyleSheets.includes(r))]}function G(t){if(Object.hasOwn(t,"_pp"))return;t._pp={};let e=t.parts;if(e)for(let[n,r]of Object.entries(e)){let i=document.createElement("template");i.innerHTML=r,t._pp[n]=i.content.firstElementChild}}var E=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let e=Object.entries(this.properties).map(([n,r])=>r.attribute??n.toLowerCase());return e.includes("traits")?e:[...e,"traits"]}#i=[];#n=[];#s=[];#t=null;#r=null;#e=null;#a=p(0);constructor(){super(),this.internals=this.attachInternals(),ie(this,this.constructor.properties)}connectedCallback(){let e=this.constructor;e._tag||(e._tag=this.localName),ae(e),G(e),T(()=>this.connected()),this.#i.push(m(()=>{for(let r of this[L].values())r.value;this.#a.value;let n=e.template(this);if(n&&g(n,this),this.render(),this[w].size){let r=new Map(this[w]);this[w].clear(),this.updated(r)}},{host:this.localName,onError:this.onError?n=>this.onError(n):null})),this.#e||(this.#e=new Set);for(let n of e.traits)this.#o(n);this.#c(),this.#t&&this.#l()}disconnectedCallback(){this._i&&C(this._i.p);for(let e of this.#i)e();this.#i.length=0;for(let e of this.#s)e.value=void 0;this.#s.length=0;for(let e of this.#n)e.disconnect(this);this.#n.length=0,this.#e?.clear(),this.#r?.(),this.#r=null,this.#t?.disconnect?.(this),this.disconnected()}#l(){let e=this.#t;e.connect?.(this),this.#r=e.subscribe?.(()=>{this.#a.value++})}get controller(){return this.#t}set controller(e){this.#r?.(),this.#r=null,this.#t?.disconnect?.(this),this.#t=e,e&&this.isConnected&&this.#l()}#o(e,{declarative:n=!1}={}){this.#e.add(e);let r=e();r.connect(this,{host:this,signal:p,computed:O,effect:m}),n&&(r._declarative=!0),this.#n.push(r)}addTrait(e){return this.#e||(this.#e=new Set),this.#e.has(e)?this:(this.#o(e),this)}#c(){let e=this.getAttribute("traits");if(e)for(let n of e.split(/\s+/).filter(Boolean)){let r=z(n);if(!r){console.warn(`<${this.localName}> traits="${n}" \u2014 trait not found. Did you forget to import it?`);continue}this.#e.has(r)||this.#o(r,{declarative:!0})}}#f(){if(!this.#e)return;let e=[];for(let n of this.#n)if(n._declarative){n.disconnect(this);for(let r of this.#e)if(r.schema?.name&&n.schema?.name===r.schema.name){this.#e.delete(r);break}}else e.push(n);this.#n.length=0,this.#n.push(...e),this.#c()}attributeChangedCallback(e,n,r){if(e==="traits"){this.isConnected&&this.#f();return}for(let[i,s]of Object.entries(this.constructor.properties))if((s.attribute??i.toLowerCase())===e){this[i]=oe(r,s.type??String);break}}static template=()=>null;static create(e={}){let n=this._tag??customElements.getName?.(this);if(!n)throw new Error("Component not registered");let r=document.createElement(n);for(let[i,s]of Object.entries(e))r[i]=s;return r}signal(e){let n=p(e);return this.#s.push(n),n}ensure(e){for(let s of this.children)if(s.getAttribute("slot")===e)return s;let n=this.#u(e);if(n)return n;G(this.constructor);let r=this.constructor._pp?.[e];if(!r)return null;let i=r.cloneNode(!0);return i._uiPart=!0,this.appendChild(i),i}drop(e){for(let r of this.children)if(r.getAttribute("slot")===e){r.remove();return}let n=this.#u(e);n&&n.remove()}#u(e){for(let n of this.querySelectorAll(`[slot="${e}"]`)){let r=n.parentElement,i=!0;for(;r&&r!==this;){if(r.localName.includes("-")){i=!1;break}r=r.parentElement}if(i&&r===this)return n}return null}reconcile(e,n,r,i){let s=e[b]||new Map,l=new Map,c=[];for(let a=0;a<n.length;a++){let u=n[a],d=r(u,a);if(l.has(d))continue;let x=s.get(d);x?i(u,a,x):x=i(u,a,null),l.set(d,x),c.push(d)}for(let[a,u]of s)l.has(a)||u.remove();let o=null;for(let a=c.length-1;a>=0;a--){let u=l.get(c[a]);(u.nextSibling!==o||u.parentNode!==e)&&e.insertBefore(u,o),o=u}e[b]=l}connected(){}render(){}disconnected(){}updated(e){}};var le="rounded borderless",N=class t extends E{static properties={mode:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("mode")||(this.mode=le),this.addEventListener("click",this.#n),this.#s()}#i(e){return this.querySelector(`admin-sidebar[slot="${e}"], admin-sidebar[name="${e}"]`)}#n=e=>{let n=e.target.closest("[data-sidebar-toggle]");if(n&&this.contains(n)){let i=n.getAttribute("data-sidebar-toggle"),s=this.#i(i);s&&typeof s.toggle!="function"&&this.#r("admin-sidebar",`slot="${i}"`,"Sidebar toggle"),s?.toggle?.();return}let r=e.target.closest("[data-command-trigger]");if(r&&this.contains(r)){e.stopPropagation();let i=this.querySelector("admin-command");if(!i)return;if(typeof i.show!="function"){this.#r("admin-command","","Command palette");return}i.show()}};#s(){let e=this.querySelector("admin-command"),n=this.querySelector("nav-ui");!e||!n||e.addEventListener("command-select",r=>{let i=n.querySelector(`nav-item-ui[value="${r.detail.value}"]`);i&&n.select(i)})}static#t=new WeakSet;#r(e,n,r){let i=n?this.querySelector(`${e}[${n}], ${e}[${n.replace("slot=","name=")}]`):this.querySelector(e);if(!i||t.#t.has(i))return;t.#t.add(i);let s=e==="admin-sidebar"?"shell/admin-sidebar":"shell/admin-command";console.warn(`[admin-shell] <${e}${n?" "+n:""}> is in the DOM but ${e==="admin-sidebar"?"AdminSidebar":"AdminCommand"} is NOT registered \u2014 ${r} will not work. Import the cluster barrel \`@adia-ai/web-modules/shell\` (which registers all shell elements), OR add \`@adia-ai/web-modules/${s}\` alongside \`@adia-ai/web-modules/shell/admin-shell\` on the per-component path. Closes FB-55 silent-failure trap.`)}};customElements.define("admin-shell",N);export{N as AdminShell};
10
+ See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),n[c]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):n[c]={t:"a",n:i,name:o,c:void 0,_fx:null}}return n}function C(t){for(let e of t)e&&e._fx&&(e._fx(),e._fx=null)}function M(t){if(t.n.nodeType===1&&t.n[v])return t.n;let e=document.createElement("span");return e.style.display="contents",e.setAttribute("role","presentation"),e[v]=!0,t.n.replaceWith(e),t.n=e,e}var U=t=>t!=null&&typeof t=="object"&&t.strings,V=t=>typeof t=="function"||t!=null&&typeof t.handleEvent=="function";function j(t,e){if(e!==t.c){if(t.t==="n")if(e!=null&&e._directive)e._commit(M(t));else if(U(e))g(e,M(t));else if(Array.isArray(e)){let n=M(t);n.replaceChildren();for(let r of e)if(U(r)){let i=document.createElement("span");i.style.display="contents",i.setAttribute("role","presentation"),n.appendChild(i),g(r,i)}else n.appendChild(document.createTextNode(r??""))}else if(e instanceof Node)t.n.replaceWith(e),t.n=e;else if(t.n[v]){let n=document.createTextNode(e??"");t.n.replaceWith(n),t.n=n}else t.n.textContent=e??"";else if(t.t==="a")e==null||e===!1?t.n.removeAttribute(t.name):t.n.setAttribute(t.name,e===!0?"":e);else if(t.t==="p"){if(!t._resolved){let n=B(t.n,t.name);n!==t.name&&(t.name=n),t._resolved=!0}t.n[t.name]=e}else t.t==="e"&&(V(t.c)&&t.n.removeEventListener(t.name,t.c),V(e)&&t.n.addEventListener(t.name,e));t.c=e}}function re(t,e){for(let n=0;n<t.length;n++){let r=t[n];if(!r)continue;let i=e[n],s=r.t!=="e"&&typeof i=="function",l=!s&&r.t!=="e"&&k(i);if(r._fx&&!s&&!l&&(r._fx(),r._fx=null),s){r._fx||(r._fx=p(()=>j(r,i())));continue}if(l){r._fx||(r._fx=p(()=>j(r,i.value)));continue}j(r,i)}}function ie(t,e,n){return{_directive:!0,_commit(r){let i=r[b]||new Map,s=new Map,l=[];for(let o=0;o<t.length;o++){let a=e(t[o],o);if(s.has(a))continue;l.push(a);let u=n(t[o],o);if(i.has(a)){let d=i.get(a);g(u,d),s.set(a,d)}else{let d=document.createElement("span");d.style.display="contents",d.setAttribute("role","presentation"),g(u,d),s.set(a,d)}}for(let[o,a]of i)s.has(o)||(a._i&&C(a._i.p),a.remove());let c=null;for(let o=l.length-1;o>=0;o--){let a=s.get(l[o]);(a.nextSibling!==c||a.parentNode!==r)&&r.insertBefore(a,c),c=a}r[b]=s}}}var N=new Map,W=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function he(t){if(!t.name)throw new Error("Trait requires a name");if(!t.setup)throw new Error(`Trait "${t.name}" requires a setup function`);if(!t.category)throw new Error(`Trait "${t.name}" requires a category`);if(!W.has(t.category))throw new Error(`Trait "${t.name}" has unknown category "${t.category}". Known: ${[...W].join(", ")}`);if(!t.description)throw new Error(`Trait "${t.name}" requires a description`);let e=Object.freeze({name:t.name,category:t.category,description:t.description,attributes:Object.freeze(t.attributes||[]),events:Object.freeze(t.events||[]),config:Object.freeze(t.config||[])});function n(){let r=null;return{schema:e,connect(i,s){r=t.setup({host:i,...s||{}})},disconnect(i){r&&(r(),r=null);for(let s of e.attributes)i.hasAttribute(s)&&(console.warn(`Trait "${e.name}": attribute "${s}" still present after disconnect`),i.removeAttribute(s))}}}return n.schema=e,N.set(t.name,n),n}function F(t){return N.get(t)||null}function pe(t){return N.get(t)?.schema||null}function me(){return[...N.keys()]}var L=Symbol(),w=Symbol();function se(t,e){t[w]=new Map,t[L]=new Map;for(let[n,r]of Object.entries(e)){let i=r.attribute??n.toLowerCase(),s=r.type??String,l=Object.prototype.hasOwnProperty.call(t,n),c=l?t[n]:void 0;l&&delete t[n];let o=m(r.default??void 0);t[L].set(n,o),Object.defineProperty(t,n,{get(){return o.value},set(a){let u=o.peek();Object.is(u,a)||(t[w].set(n,u),o.value=a,r.reflect&&ae(t,i,a,s))},configurable:!0}),l&&(o.value=c)}}var oe=Object.freeze({setFormValue(){},setValidity(){},checkValidity(){return!0},reportValidity(){return!0},get form(){return null},get labels(){return[]},get validity(){return{}},get validationMessage(){return""},get willValidate(){return!1}});function ae(t,e,n,r){r===Boolean?n?t.setAttribute(e,""):t.removeAttribute(e):n==null?t.removeAttribute(e):t.setAttribute(e,String(n))}var z=(t,e)=>e===Boolean?t!==null:e===Number?t===null?null:+t:t;function le(t){if(Object.hasOwn(t,"_sa"))return;t._sa=!0;let e=t.styles;if(!e||!("adoptedStyleSheets"in document))return;let n=Array.isArray(e)?e:[e];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...n.filter(r=>!document.adoptedStyleSheets.includes(r))]}function G(t){if(Object.hasOwn(t,"_pp"))return;t._pp={};let e=t.parts;if(e)for(let[n,r]of Object.entries(e)){let i=document.createElement("template");i.innerHTML=r,t._pp[n]=i.content.firstElementChild}}var O=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let e=Object.entries(this.properties).map(([n,r])=>r.attribute??n.toLowerCase());return e.includes("traits")?e:[...e,"traits"]}#i=[];#n=[];#s=[];#t=null;#r=null;#e=null;#a=m(0);constructor(){super(),this.internals=typeof this.attachInternals=="function"?this.attachInternals():oe,se(this,this.constructor.properties)}connectedCallback(){let e=this.constructor;e._tag||(e._tag=this.localName),le(e),G(e);for(let[n,r]of Object.entries(e.properties)){let i=r.attribute??n.toLowerCase();this.hasAttribute(i)&&(this[n]=z(this.getAttribute(i),r.type??String))}E(()=>this.connected()),this.#i.push(p(()=>{for(let r of this[L].values())r.value;this.#a.value;let n=e.template(this);if(n&&g(n,this),this.render(),this[w].size){let r=new Map(this[w]);this[w].clear(),this.updated(r)}},{host:this.localName,onError:this.onError?n=>this.onError(n):null})),this.#e||(this.#e=new Set);for(let n of e.traits)this.#o(n);this.#c(),this.#t&&this.#l()}disconnectedCallback(){this._i&&C(this._i.p);for(let e of this.#i)e();this.#i.length=0;for(let e of this.#s)e.value=void 0;this.#s.length=0;for(let e of this.#n)e.disconnect(this);this.#n.length=0,this.#e?.clear(),this.#r?.(),this.#r=null,this.#t?.disconnect?.(this),this.disconnected()}#l(){let e=this.#t;e.connect?.(this),this.#r=e.subscribe?.(()=>{this.#a.value++})}get controller(){return this.#t}set controller(e){this.#r?.(),this.#r=null,this.#t?.disconnect?.(this),this.#t=e,e&&this.isConnected&&this.#l()}#o(e,{declarative:n=!1}={}){this.#e.add(e);let r=e();r.connect(this,{host:this,signal:m,computed:T,effect:p}),n&&(r._declarative=!0),this.#n.push(r)}addTrait(e){return this.#e||(this.#e=new Set),this.#e.has(e)?this:(this.#o(e),this)}#c(){let e=this.getAttribute("traits");if(e)for(let n of e.split(/\s+/).filter(Boolean)){let r=F(n);if(!r){console.warn(`<${this.localName}> traits="${n}" \u2014 trait not found. Did you forget to import it?`);continue}this.#e.has(r)||this.#o(r,{declarative:!0})}}#f(){if(!this.#e)return;let e=[];for(let n of this.#n)if(n._declarative){n.disconnect(this);for(let r of this.#e)if(r.schema?.name&&n.schema?.name===r.schema.name){this.#e.delete(r);break}}else e.push(n);this.#n.length=0,this.#n.push(...e),this.#c()}attributeChangedCallback(e,n,r){if(e==="traits"){this.isConnected&&this.#f();return}for(let[i,s]of Object.entries(this.constructor.properties))if((s.attribute??i.toLowerCase())===e){this[i]=z(r,s.type??String);break}}static template=()=>null;static create(e={}){let n=this._tag??customElements.getName?.(this);if(!n)throw new Error("Component not registered");let r=document.createElement(n);for(let[i,s]of Object.entries(e))r[i]=s;return r}signal(e){let n=m(e);return this.#s.push(n),n}ensure(e){for(let s of this.children)if(s.getAttribute("slot")===e)return s;let n=this.#u(e);if(n)return n;G(this.constructor);let r=this.constructor._pp?.[e];if(!r)return null;let i=r.cloneNode(!0);return i._uiPart=!0,this.appendChild(i),i}drop(e){for(let r of this.children)if(r.getAttribute("slot")===e){r.remove();return}let n=this.#u(e);n&&n.remove()}#u(e){for(let n of this.querySelectorAll(`[slot="${e}"]`)){let r=n.parentElement,i=!0;for(;r&&r!==this;){if(r.localName.includes("-")){i=!1;break}r=r.parentElement}if(i&&r===this)return n}return null}reconcile(e,n,r,i){let s=e[b]||new Map,l=new Map,c=[];for(let a=0;a<n.length;a++){let u=n[a],d=r(u,a);if(l.has(d))continue;let x=s.get(d);x?i(u,a,x):x=i(u,a,null),l.set(d,x),c.push(d)}for(let[a,u]of s)l.has(a)||u.remove();let o=null;for(let a=c.length-1;a>=0;a--){let u=l.get(c[a]);(u.nextSibling!==o||u.parentNode!==e)&&e.insertBefore(u,o),o=u}e[b]=l}connected(){}render(){}disconnected(){}updated(e){}};var ce="rounded borderless",$=class t extends O{static properties={mode:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("mode")||(this.mode=ce),this.addEventListener("click",this.#n),this.#s()}#i(e){return this.querySelector(`admin-sidebar[slot="${e}"], admin-sidebar[name="${e}"]`)}#n=e=>{let n=e.target.closest("[data-sidebar-toggle]");if(n&&this.contains(n)){let i=n.getAttribute("data-sidebar-toggle"),s=this.#i(i);s&&typeof s.toggle!="function"&&this.#r("admin-sidebar",`slot="${i}"`,"Sidebar toggle"),s?.toggle?.();return}let r=e.target.closest("[data-command-trigger]");if(r&&this.contains(r)){e.stopPropagation();let i=this.querySelector("admin-command");if(!i)return;if(typeof i.show!="function"){this.#r("admin-command","","Command palette");return}i.show()}};#s(){let e=this.querySelector("admin-command"),n=this.querySelector("nav-ui");!e||!n||e.addEventListener("command-select",r=>{let i=n.querySelector(`nav-item-ui[value="${r.detail.value}"]`);i&&n.select(i)})}static#t=new WeakSet;#r(e,n,r){let i=n?this.querySelector(`${e}[${n}], ${e}[${n.replace("slot=","name=")}]`):this.querySelector(e);if(!i||t.#t.has(i))return;t.#t.add(i);let s=e==="admin-sidebar"?"shell/admin-sidebar":"shell/admin-command";console.warn(`[admin-shell] <${e}${n?" "+n:""}> is in the DOM but ${e==="admin-sidebar"?"AdminSidebar":"AdminCommand"} is NOT registered \u2014 ${r} will not work. Import the cluster barrel \`@adia-ai/web-modules/shell\` (which registers all shell elements), OR add \`@adia-ai/web-modules/${s}\` alongside \`@adia-ai/web-modules/shell/admin-shell\` on the per-component path. Closes FB-55 silent-failure trap.`)}};customElements.define("admin-shell",$);export{$ as AdminShell};
@@ -1,10 +1,10 @@
1
- var S=Symbol("signal"),f=null,h=null,_=!1;function P(t){for(let e of t){if(e.disposed){t.delete(e);continue}e.dirty=!0,h||(h=new Set,_||queueMicrotask(B)),h.add(e)}}function B(){let t,e=0;for(;t=h;){if(++e>100){h=null,console.error("signals: drain loop exceeded 100 iterations");break}h=null;for(let n of t)if(!n.disposed&&n.dirty){n.dirty=!1;try{n.run()}catch(r){n.onError?n.onError(r):(n.disposed=!0,queueMicrotask(()=>{throw r}))}}}}function F(t){if(_){t();return}_=!0;try{t()}finally{_=!1,h&&B()}}function O(t){let e=f;f=null;try{return t()}finally{f=e}}function m(t){let e=new Set;return{[S]:!0,get value(){return f&&e.add(f),t},set value(n){Object.is(t,n)||(t=n,P(e))},peek(){return t}}}function k(t){let e=new Set,n,r=!0,o={dirty:!1,disposed:!1,run(){r=!0,P(e)}};return{[S]:!0,get value(){if(f&&e.add(f),r){let i=f;f=o;try{n=t(),r=!1}finally{f=i}}return n},peek(){return n}}}function p(t,e){let n={dirty:!1,disposed:!1,host:e?.host??null,onError:e?.onError??null,run(){let r=f;f=n;try{t()}finally{f=r}}};return n.run(),()=>{n.disposed=!0}}function $(t){return t!=null&&typeof t=="object"&&t[S]===!0}var[M,y]=[Symbol(),Symbol()];function V(t,...e){return{strings:t,values:e}}function X(t,...e){let n="";for(let o=0;o<t.length;o++)n+=t[o],o<e.length&&(n+=e[o]);let r=new CSSStyleSheet;return r.replaceSync(n),r}var I=new WeakMap;function Y(t){let e=0,n=0,r=0;for(;r<t.length;){if(e===0&&t.charCodeAt(r)===60&&t.charCodeAt(r+1)===33&&t.charCodeAt(r+2)===45&&t.charCodeAt(r+3)===45){let i=t.indexOf("-->",r+4);if(i===-1){n=0;break}r=i+3,n=0;continue}let o=t.charCodeAt(r);e?o===(e===1?39:34)&&(e=0):o===39?e=1:o===34?e=2:o===60?n=1:o===62&&(n=0),r++}return n===1}function J(t){let e=I.get(t);if(e)return e;let n="";for(let r=0;r<t.length;r++)n+=t[r],r<t.length-1&&(n+=Y(n)?`{{p:${r}}}`:`<!--p:${r}-->`);return e=document.createElement("template"),e.innerHTML=n,I.set(t,e),e}var q={classname:"className",innertext:"innerText",innerhtml:"innerHTML",outerhtml:"outerHTML",textcontent:"textContent",tabindex:"tabIndex",arialabel:"ariaLabel",ariadescribedby:"ariaDescribedBy",arialabelledby:"ariaLabelledBy",ariarole:"role",contenteditable:"contentEditable",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",colspan:"colSpan",rowspan:"rowSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",usemap:"useMap",ismap:"isMap",accesskey:"accessKey",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",defaultselected:"defaultSelected"};function H(t,e){if(q[e])return q[e];let n=Object.getOwnPropertyNames(t);for(let o=0;o<n.length;o++){let i=n[o];if(i!==e&&i.toLowerCase()===e)return i}let r=Object.getPrototypeOf(t);for(;r&&r!==Object.prototype;){let o=Object.getOwnPropertyNames(r);for(let i=0;i<o.length;i++){let a=o[i];if(a!==e&&a.toLowerCase()===e)return a}r=Object.getPrototypeOf(r)}return e}function g(t,e){let n=e._i;(!n||n.s!==t.strings)&&(n&&C(n.p),n=Q(t,e),e._i=n),ne(n.p,t.values)}function Q(t,e){let{strings:n}=t,o=J(n).content.cloneNode(!0),i=Z(e);i&&(o=ee(o,i));let a=te(o,t.values.length);return e.replaceChildren(o),{s:n,p:a}}var A="http://www.w3.org/2000/svg",b="http://www.w3.org/1998/Math/MathML",R="http://www.w3.org/1999/xhtml";function Z(t){if(!t||t.nodeType!==1)return null;if(t.namespaceURI===A)return A;if(t.namespaceURI===b)return b;if(typeof t.closest!="function")return null;let e=t.closest("svg, math, foreignObject, annotation-xml");if(!e)return null;let n=e.localName;if(n==="foreignobject"||n==="foreignObject")return null;if(n==="annotation-xml"){let r=(e.getAttribute("encoding")||"").toLowerCase();return r==="text/html"||r==="application/xhtml+xml"?null:b}return n==="svg"?A:n==="math"?b:null}function ee(t,e){let n=document.createDocumentFragment();return U(t,n,e),n}function U(t,e,n){for(let r of[...t.childNodes])if(r.nodeType===1){let i=document.createElementNS(n,r.localName);for(let s of r.attributes)s.namespaceURI?i.setAttributeNS(s.namespaceURI,s.name,s.value):i.setAttribute(s.name,s.value);e.appendChild(i);let a=r.localName,c=n;if(n===A&&(a==="foreignObject"||a==="foreignobject"))c=R;else if(n===b&&a==="annotation-xml"){let s=(r.getAttribute("encoding")||"").toLowerCase();(s==="text/html"||s==="application/xhtml+xml")&&(c=R)}U(r,i,c)}else e.appendChild(r.cloneNode(!0))}function te(t,e){let n=new Array(e),r=document.createTreeWalker(t,129),o;for(;o=r.nextNode();)if(o.nodeType===8){let i=o.data.match(/^p:(\d+)$/);if(i){let a=document.createTextNode("");o.replaceWith(a),r.currentNode=a,n[+i[1]]={t:"n",n:a,c:void 0,_fx:null}}}else if(o.nodeType===1)for(let i of[...o.attributes]){let a=i.value.match(/^\{\{p:(\d+)\}\}$/);if(!a){if(i.value.includes("{{p:")){let l=i.name,u=l==="class"?' class="${expression}" \u2190 full replacement (whole class string is the expression)\n .className=${expression} \u2190 writes to the className property (resolved camelCase since FB-55 fix)\n':l==="style"?' style="${expression}" \u2190 full replacement of the style string\n .style.cssText=${expression} \u2190 write CSS text via the style.cssText accessor\n':` ${l}="\${expression}" \u2190 full replacement (whole attr is the placeholder)
1
+ var S=Symbol("signal"),f=null,h=null,_=!1;function P(t){for(let e of t){if(e.disposed){t.delete(e);continue}e.dirty=!0,h||(h=new Set,_||queueMicrotask(I)),h.add(e)}}function I(){let t,e=0;for(;t=h;){if(++e>100){h=null,console.error("signals: drain loop exceeded 100 iterations");break}h=null;for(let n of t)if(!n.disposed&&n.dirty){n.dirty=!1;try{n.run()}catch(r){n.onError?n.onError(r):(n.disposed=!0,queueMicrotask(()=>{throw r}))}}}}function K(t){if(_){t();return}_=!0;try{t()}finally{_=!1,h&&I()}}function E(t){let e=f;f=null;try{return t()}finally{f=e}}function m(t){let e=new Set;return{[S]:!0,get value(){return f&&e.add(f),t},set value(n){Object.is(t,n)||(t=n,P(e))},peek(){return t}}}function k(t){let e=new Set,n,r=!0,i={dirty:!1,disposed:!1,run(){r=!0,P(e)}};return{[S]:!0,get value(){if(f&&e.add(f),r){let o=f;f=i;try{n=t(),r=!1}finally{f=o}}return n},peek(){return n}}}function p(t,e){let n={dirty:!1,disposed:!1,host:e?.host??null,onError:e?.onError??null,run(){let r=f;f=n;try{t()}finally{f=r}}};return n.run(),()=>{n.disposed=!0}}function j(t){return t!=null&&typeof t=="object"&&t[S]===!0}var[M,y]=[Symbol(),Symbol()];function X(t,...e){return{strings:t,values:e}}function Y(t,...e){let n="";for(let i=0;i<t.length;i++)n+=t[i],i<e.length&&(n+=e[i]);let r=new CSSStyleSheet;return r.replaceSync(n),r}var B=new WeakMap;function J(t){let e=0,n=0,r=0;for(;r<t.length;){if(e===0&&t.charCodeAt(r)===60&&t.charCodeAt(r+1)===33&&t.charCodeAt(r+2)===45&&t.charCodeAt(r+3)===45){let o=t.indexOf("-->",r+4);if(o===-1){n=0;break}r=o+3,n=0;continue}let i=t.charCodeAt(r);e?i===(e===1?39:34)&&(e=0):i===39?e=1:i===34?e=2:i===60?n=1:i===62&&(n=0),r++}return n===1}function Q(t){let e=B.get(t);if(e)return e;let n="";for(let r=0;r<t.length;r++)n+=t[r],r<t.length-1&&(n+=J(n)?`{{p:${r}}}`:`<!--p:${r}-->`);return e=document.createElement("template"),e.innerHTML=n,B.set(t,e),e}var q={classname:"className",innertext:"innerText",innerhtml:"innerHTML",outerhtml:"outerHTML",textcontent:"textContent",tabindex:"tabIndex",arialabel:"ariaLabel",ariadescribedby:"ariaDescribedBy",arialabelledby:"ariaLabelledBy",ariarole:"role",contenteditable:"contentEditable",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",colspan:"colSpan",rowspan:"rowSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",usemap:"useMap",ismap:"isMap",accesskey:"accessKey",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",defaultselected:"defaultSelected"};function H(t,e){if(q[e])return q[e];let n=Object.getOwnPropertyNames(t);for(let i=0;i<n.length;i++){let o=n[i];if(o!==e&&o.toLowerCase()===e)return o}let r=Object.getPrototypeOf(t);for(;r&&r!==Object.prototype;){let i=Object.getOwnPropertyNames(r);for(let o=0;o<i.length;o++){let a=i[o];if(a!==e&&a.toLowerCase()===e)return a}r=Object.getPrototypeOf(r)}return e}function g(t,e){let n=e._i;(!n||n.s!==t.strings)&&(n&&C(n.p),n=Z(t,e),e._i=n),re(n.p,t.values)}function Z(t,e){let{strings:n}=t,i=Q(n).content.cloneNode(!0),o=ee(e);o&&(i=te(i,o));let a=ne(i,t.values.length);return e.replaceChildren(i),{s:n,p:a}}var A="http://www.w3.org/2000/svg",b="http://www.w3.org/1998/Math/MathML",R="http://www.w3.org/1999/xhtml";function ee(t){if(!t||t.nodeType!==1)return null;if(t.namespaceURI===A)return A;if(t.namespaceURI===b)return b;if(typeof t.closest!="function")return null;let e=t.closest("svg, math, foreignObject, annotation-xml");if(!e)return null;let n=e.localName;if(n==="foreignobject"||n==="foreignObject")return null;if(n==="annotation-xml"){let r=(e.getAttribute("encoding")||"").toLowerCase();return r==="text/html"||r==="application/xhtml+xml"?null:b}return n==="svg"?A:n==="math"?b:null}function te(t,e){let n=document.createDocumentFragment();return V(t,n,e),n}function V(t,e,n){for(let r of[...t.childNodes])if(r.nodeType===1){let o=document.createElementNS(n,r.localName);for(let s of r.attributes)s.namespaceURI?o.setAttributeNS(s.namespaceURI,s.name,s.value):o.setAttribute(s.name,s.value);e.appendChild(o);let a=r.localName,c=n;if(n===A&&(a==="foreignObject"||a==="foreignobject"))c=R;else if(n===b&&a==="annotation-xml"){let s=(r.getAttribute("encoding")||"").toLowerCase();(s==="text/html"||s==="application/xhtml+xml")&&(c=R)}V(r,o,c)}else e.appendChild(r.cloneNode(!0))}function ne(t,e){let n=new Array(e),r=document.createTreeWalker(t,129),i;for(;i=r.nextNode();)if(i.nodeType===8){let o=i.data.match(/^p:(\d+)$/);if(o){let a=document.createTextNode("");i.replaceWith(a),r.currentNode=a,n[+o[1]]={t:"n",n:a,c:void 0,_fx:null}}}else if(i.nodeType===1)for(let o of[...i.attributes]){let a=o.value.match(/^\{\{p:(\d+)\}\}$/);if(!a){if(o.value.includes("{{p:")){let l=o.name,u=l==="class"?' class="${expression}" \u2190 full replacement (whole class string is the expression)\n .className=${expression} \u2190 writes to the className property (resolved camelCase since FB-55 fix)\n':l==="style"?' style="${expression}" \u2190 full replacement of the style string\n .style.cssText=${expression} \u2190 write CSS text via the style.cssText accessor\n':` ${l}="\${expression}" \u2190 full replacement (whole attr is the placeholder)
2
2
  .${l}=\${expression} \u2190 property assignment (preferred for objects/functions)
3
3
  `;console.warn(`[template] Partial attribute interpolation is not supported.
4
- Element: <${o.tagName.toLowerCase()}>
5
- Attribute: ${l}="${i.value.slice(0,80)}${i.value.length>80?"\u2026":""}"
4
+ Element: <${i.tagName.toLowerCase()}>
5
+ Attribute: ${l}="${o.value.slice(0,80)}${o.value.length>80?"\u2026":""}"
6
6
  Use one of:
7
- `+u+" Compute the full attr value as a single expression and interpolate the whole.")}continue}let c=+a[1],s=i.name;s[0]==="@"?(o.removeAttribute(s),n[c]={t:"e",n:o,name:s.slice(1),c:void 0,_fx:null}):s[0]==="."?(o.removeAttribute(s),n[c]={t:"p",n:o,name:H(o,s.slice(1)),c:void 0,_fx:null,_resolved:!1}):s[0]==="?"?(o.removeAttribute(s),console.warn(`[template] Lit-style boolean attribute "${s}=" is not supported.
8
- Element: <${o.tagName.toLowerCase()}>
7
+ `+u+" Compute the full attr value as a single expression and interpolate the whole.")}continue}let c=+a[1],s=o.name;s[0]==="@"?(i.removeAttribute(s),n[c]={t:"e",n:i,name:s.slice(1),c:void 0,_fx:null}):s[0]==="."?(i.removeAttribute(s),n[c]={t:"p",n:i,name:H(i,s.slice(1)),c:void 0,_fx:null,_resolved:!1}):s[0]==="?"?(i.removeAttribute(s),console.warn(`[template] Lit-style boolean attribute "${s}=" is not supported.
8
+ Element: <${i.tagName.toLowerCase()}>
9
9
  Use .${s.slice(1)}=\${value} (property binding) instead \u2014 the primitive reflects the property to the DOM attribute for you.
10
- See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),n[c]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):n[c]={t:"a",n:o,name:s,c:void 0,_fx:null}}return n}function C(t){for(let e of t)e&&e._fx&&(e._fx(),e._fx=null)}function j(t){if(t.n.nodeType===1&&t.n[M])return t.n;let e=document.createElement("span");return e.style.display="contents",e.setAttribute("role","presentation"),e[M]=!0,t.n.replaceWith(e),t.n=e,e}var W=t=>t!=null&&typeof t=="object"&&t.strings,D=t=>typeof t=="function"||t!=null&&typeof t.handleEvent=="function";function v(t,e){if(e!==t.c){if(t.t==="n")if(e!=null&&e._directive)e._commit(j(t));else if(W(e))g(e,j(t));else if(Array.isArray(e)){let n=j(t);n.replaceChildren();for(let r of e)if(W(r)){let o=document.createElement("span");o.style.display="contents",o.setAttribute("role","presentation"),n.appendChild(o),g(r,o)}else n.appendChild(document.createTextNode(r??""))}else if(e instanceof Node)t.n.replaceWith(e),t.n=e;else if(t.n[M]){let n=document.createTextNode(e??"");t.n.replaceWith(n),t.n=n}else t.n.textContent=e??"";else if(t.t==="a")e==null||e===!1?t.n.removeAttribute(t.name):t.n.setAttribute(t.name,e===!0?"":e);else if(t.t==="p"){if(!t._resolved){let n=H(t.n,t.name);n!==t.name&&(t.name=n),t._resolved=!0}t.n[t.name]=e}else t.t==="e"&&(D(t.c)&&t.n.removeEventListener(t.name,t.c),D(e)&&t.n.addEventListener(t.name,e));t.c=e}}function ne(t,e){for(let n=0;n<t.length;n++){let r=t[n];if(!r)continue;let o=e[n],i=r.t!=="e"&&typeof o=="function",a=!i&&r.t!=="e"&&$(o);if(r._fx&&!i&&!a&&(r._fx(),r._fx=null),i){r._fx||(r._fx=p(()=>v(r,o())));continue}if(a){r._fx||(r._fx=p(()=>v(r,o.value)));continue}v(r,o)}}function re(t,e,n){return{_directive:!0,_commit(r){let o=r[y]||new Map,i=new Map,a=[];for(let s=0;s<t.length;s++){let l=e(t[s],s);if(i.has(l))continue;a.push(l);let u=n(t[s],s);if(o.has(l)){let d=o.get(l);g(u,d),i.set(l,d)}else{let d=document.createElement("span");d.style.display="contents",d.setAttribute("role","presentation"),g(u,d),i.set(l,d)}}for(let[s,l]of o)i.has(s)||(l._i&&C(l._i.p),l.remove());let c=null;for(let s=a.length-1;s>=0;s--){let l=i.get(a[s]);(l.nextSibling!==c||l.parentNode!==r)&&r.insertBefore(l,c),c=l}r[y]=i}}}var N=new Map,z=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function fe(t){if(!t.name)throw new Error("Trait requires a name");if(!t.setup)throw new Error(`Trait "${t.name}" requires a setup function`);if(!t.category)throw new Error(`Trait "${t.name}" requires a category`);if(!z.has(t.category))throw new Error(`Trait "${t.name}" has unknown category "${t.category}". Known: ${[...z].join(", ")}`);if(!t.description)throw new Error(`Trait "${t.name}" requires a description`);let e=Object.freeze({name:t.name,category:t.category,description:t.description,attributes:Object.freeze(t.attributes||[]),events:Object.freeze(t.events||[]),config:Object.freeze(t.config||[])});function n(){let r=null;return{schema:e,connect(o,i){r=t.setup({host:o,...i||{}})},disconnect(o){r&&(r(),r=null);for(let i of e.attributes)o.hasAttribute(i)&&(console.warn(`Trait "${e.name}": attribute "${i}" still present after disconnect`),o.removeAttribute(i))}}}return n.schema=e,N.set(t.name,n),n}function G(t){return N.get(t)||null}function de(t){return N.get(t)?.schema||null}function he(){return[...N.keys()]}var L=Symbol(),x=Symbol();function oe(t,e){t[x]=new Map,t[L]=new Map;for(let[n,r]of Object.entries(e)){let o=r.attribute??n.toLowerCase(),i=r.type??String,a=Object.prototype.hasOwnProperty.call(t,n),c=a?t[n]:void 0;a&&delete t[n];let s=m(r.default??void 0);t[L].set(n,s),Object.defineProperty(t,n,{get(){return s.value},set(l){let u=s.peek();Object.is(u,l)||(t[x].set(n,u),s.value=l,r.reflect&&ie(t,o,l,i))},configurable:!0}),a&&(s.value=c)}}function ie(t,e,n,r){r===Boolean?n?t.setAttribute(e,""):t.removeAttribute(e):n==null?t.removeAttribute(e):t.setAttribute(e,String(n))}var se=(t,e)=>e===Boolean?t!==null:e===Number?t===null?null:+t:t;function le(t){if(Object.hasOwn(t,"_sa"))return;t._sa=!0;let e=t.styles;if(!e)return;let n=Array.isArray(e)?e:[e];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...n.filter(r=>!document.adoptedStyleSheets.includes(r))]}function K(t){if(Object.hasOwn(t,"_pp"))return;t._pp={};let e=t.parts;if(e)for(let[n,r]of Object.entries(e)){let o=document.createElement("template");o.innerHTML=r,t._pp[n]=o.content.firstElementChild}}var T=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let e=Object.entries(this.properties).map(([n,r])=>r.attribute??n.toLowerCase());return e.includes("traits")?e:[...e,"traits"]}#o=[];#t=[];#i=[];#n=null;#r=null;#e=null;#l=m(0);constructor(){super(),this.internals=this.attachInternals(),oe(this,this.constructor.properties)}connectedCallback(){let e=this.constructor;e._tag||(e._tag=this.localName),le(e),K(e),O(()=>this.connected()),this.#o.push(p(()=>{for(let r of this[L].values())r.value;this.#l.value;let n=e.template(this);if(n&&g(n,this),this.render(),this[x].size){let r=new Map(this[x]);this[x].clear(),this.updated(r)}},{host:this.localName,onError:this.onError?n=>this.onError(n):null})),this.#e||(this.#e=new Set);for(let n of e.traits)this.#s(n);this.#c(),this.#n&&this.#a()}disconnectedCallback(){this._i&&C(this._i.p);for(let e of this.#o)e();this.#o.length=0;for(let e of this.#i)e.value=void 0;this.#i.length=0;for(let e of this.#t)e.disconnect(this);this.#t.length=0,this.#e?.clear(),this.#r?.(),this.#r=null,this.#n?.disconnect?.(this),this.disconnected()}#a(){let e=this.#n;e.connect?.(this),this.#r=e.subscribe?.(()=>{this.#l.value++})}get controller(){return this.#n}set controller(e){this.#r?.(),this.#r=null,this.#n?.disconnect?.(this),this.#n=e,e&&this.isConnected&&this.#a()}#s(e,{declarative:n=!1}={}){this.#e.add(e);let r=e();r.connect(this,{host:this,signal:m,computed:k,effect:p}),n&&(r._declarative=!0),this.#t.push(r)}addTrait(e){return this.#e||(this.#e=new Set),this.#e.has(e)?this:(this.#s(e),this)}#c(){let e=this.getAttribute("traits");if(e)for(let n of e.split(/\s+/).filter(Boolean)){let r=G(n);if(!r){console.warn(`<${this.localName}> traits="${n}" \u2014 trait not found. Did you forget to import it?`);continue}this.#e.has(r)||this.#s(r,{declarative:!0})}}#f(){if(!this.#e)return;let e=[];for(let n of this.#t)if(n._declarative){n.disconnect(this);for(let r of this.#e)if(r.schema?.name&&n.schema?.name===r.schema.name){this.#e.delete(r);break}}else e.push(n);this.#t.length=0,this.#t.push(...e),this.#c()}attributeChangedCallback(e,n,r){if(e==="traits"){this.isConnected&&this.#f();return}for(let[o,i]of Object.entries(this.constructor.properties))if((i.attribute??o.toLowerCase())===e){this[o]=se(r,i.type??String);break}}static template=()=>null;static create(e={}){let n=this._tag??customElements.getName?.(this);if(!n)throw new Error("Component not registered");let r=document.createElement(n);for(let[o,i]of Object.entries(e))r[o]=i;return r}signal(e){let n=m(e);return this.#i.push(n),n}ensure(e){for(let i of this.children)if(i.getAttribute("slot")===e)return i;let n=this.#u(e);if(n)return n;K(this.constructor);let r=this.constructor._pp?.[e];if(!r)return null;let o=r.cloneNode(!0);return o._uiPart=!0,this.appendChild(o),o}drop(e){for(let r of this.children)if(r.getAttribute("slot")===e){r.remove();return}let n=this.#u(e);n&&n.remove()}#u(e){for(let n of this.querySelectorAll(`[slot="${e}"]`)){let r=n.parentElement,o=!0;for(;r&&r!==this;){if(r.localName.includes("-")){o=!1;break}r=r.parentElement}if(o&&r===this)return n}return null}reconcile(e,n,r,o){let i=e[y]||new Map,a=new Map,c=[];for(let l=0;l<n.length;l++){let u=n[l],d=r(u,l);if(a.has(d))continue;let w=i.get(d);w?o(u,l,w):w=o(u,l,null),a.set(d,w),c.push(d)}for(let[l,u]of i)a.has(l)||u.remove();let s=null;for(let l=c.length-1;l>=0;l--){let u=a.get(c[l]);(u.nextSibling!==s||u.parentNode!==e)&&e.insertBefore(u,s),s=u}e[y]=a}connected(){}render(){}disconnected(){}updated(e){}};var E=class extends T{static properties={centered:{type:Boolean,default:!1,reflect:!0},"full-bleed":{type:Boolean,default:!1,reflect:!0}};static template=()=>null};customElements.get("simple-shell")||customElements.define("simple-shell",E);export{E as SimpleShell};
10
+ See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),n[c]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):n[c]={t:"a",n:i,name:s,c:void 0,_fx:null}}return n}function C(t){for(let e of t)e&&e._fx&&(e._fx(),e._fx=null)}function $(t){if(t.n.nodeType===1&&t.n[M])return t.n;let e=document.createElement("span");return e.style.display="contents",e.setAttribute("role","presentation"),e[M]=!0,t.n.replaceWith(e),t.n=e,e}var U=t=>t!=null&&typeof t=="object"&&t.strings,W=t=>typeof t=="function"||t!=null&&typeof t.handleEvent=="function";function v(t,e){if(e!==t.c){if(t.t==="n")if(e!=null&&e._directive)e._commit($(t));else if(U(e))g(e,$(t));else if(Array.isArray(e)){let n=$(t);n.replaceChildren();for(let r of e)if(U(r)){let i=document.createElement("span");i.style.display="contents",i.setAttribute("role","presentation"),n.appendChild(i),g(r,i)}else n.appendChild(document.createTextNode(r??""))}else if(e instanceof Node)t.n.replaceWith(e),t.n=e;else if(t.n[M]){let n=document.createTextNode(e??"");t.n.replaceWith(n),t.n=n}else t.n.textContent=e??"";else if(t.t==="a")e==null||e===!1?t.n.removeAttribute(t.name):t.n.setAttribute(t.name,e===!0?"":e);else if(t.t==="p"){if(!t._resolved){let n=H(t.n,t.name);n!==t.name&&(t.name=n),t._resolved=!0}t.n[t.name]=e}else t.t==="e"&&(W(t.c)&&t.n.removeEventListener(t.name,t.c),W(e)&&t.n.addEventListener(t.name,e));t.c=e}}function re(t,e){for(let n=0;n<t.length;n++){let r=t[n];if(!r)continue;let i=e[n],o=r.t!=="e"&&typeof i=="function",a=!o&&r.t!=="e"&&j(i);if(r._fx&&!o&&!a&&(r._fx(),r._fx=null),o){r._fx||(r._fx=p(()=>v(r,i())));continue}if(a){r._fx||(r._fx=p(()=>v(r,i.value)));continue}v(r,i)}}function ie(t,e,n){return{_directive:!0,_commit(r){let i=r[y]||new Map,o=new Map,a=[];for(let s=0;s<t.length;s++){let l=e(t[s],s);if(o.has(l))continue;a.push(l);let u=n(t[s],s);if(i.has(l)){let d=i.get(l);g(u,d),o.set(l,d)}else{let d=document.createElement("span");d.style.display="contents",d.setAttribute("role","presentation"),g(u,d),o.set(l,d)}}for(let[s,l]of i)o.has(s)||(l._i&&C(l._i.p),l.remove());let c=null;for(let s=a.length-1;s>=0;s--){let l=o.get(a[s]);(l.nextSibling!==c||l.parentNode!==r)&&r.insertBefore(l,c),c=l}r[y]=o}}}var N=new Map,z=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function de(t){if(!t.name)throw new Error("Trait requires a name");if(!t.setup)throw new Error(`Trait "${t.name}" requires a setup function`);if(!t.category)throw new Error(`Trait "${t.name}" requires a category`);if(!z.has(t.category))throw new Error(`Trait "${t.name}" has unknown category "${t.category}". Known: ${[...z].join(", ")}`);if(!t.description)throw new Error(`Trait "${t.name}" requires a description`);let e=Object.freeze({name:t.name,category:t.category,description:t.description,attributes:Object.freeze(t.attributes||[]),events:Object.freeze(t.events||[]),config:Object.freeze(t.config||[])});function n(){let r=null;return{schema:e,connect(i,o){r=t.setup({host:i,...o||{}})},disconnect(i){r&&(r(),r=null);for(let o of e.attributes)i.hasAttribute(o)&&(console.warn(`Trait "${e.name}": attribute "${o}" still present after disconnect`),i.removeAttribute(o))}}}return n.schema=e,N.set(t.name,n),n}function D(t){return N.get(t)||null}function he(t){return N.get(t)?.schema||null}function pe(){return[...N.keys()]}var L=Symbol(),x=Symbol();function oe(t,e){t[x]=new Map,t[L]=new Map;for(let[n,r]of Object.entries(e)){let i=r.attribute??n.toLowerCase(),o=r.type??String,a=Object.prototype.hasOwnProperty.call(t,n),c=a?t[n]:void 0;a&&delete t[n];let s=m(r.default??void 0);t[L].set(n,s),Object.defineProperty(t,n,{get(){return s.value},set(l){let u=s.peek();Object.is(u,l)||(t[x].set(n,u),s.value=l,r.reflect&&le(t,i,l,o))},configurable:!0}),a&&(s.value=c)}}var se=Object.freeze({setFormValue(){},setValidity(){},checkValidity(){return!0},reportValidity(){return!0},get form(){return null},get labels(){return[]},get validity(){return{}},get validationMessage(){return""},get willValidate(){return!1}});function le(t,e,n,r){r===Boolean?n?t.setAttribute(e,""):t.removeAttribute(e):n==null?t.removeAttribute(e):t.setAttribute(e,String(n))}var F=(t,e)=>e===Boolean?t!==null:e===Number?t===null?null:+t:t;function ae(t){if(Object.hasOwn(t,"_sa"))return;t._sa=!0;let e=t.styles;if(!e||!("adoptedStyleSheets"in document))return;let n=Array.isArray(e)?e:[e];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...n.filter(r=>!document.adoptedStyleSheets.includes(r))]}function G(t){if(Object.hasOwn(t,"_pp"))return;t._pp={};let e=t.parts;if(e)for(let[n,r]of Object.entries(e)){let i=document.createElement("template");i.innerHTML=r,t._pp[n]=i.content.firstElementChild}}var O=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let e=Object.entries(this.properties).map(([n,r])=>r.attribute??n.toLowerCase());return e.includes("traits")?e:[...e,"traits"]}#i=[];#t=[];#o=[];#n=null;#r=null;#e=null;#l=m(0);constructor(){super(),this.internals=typeof this.attachInternals=="function"?this.attachInternals():se,oe(this,this.constructor.properties)}connectedCallback(){let e=this.constructor;e._tag||(e._tag=this.localName),ae(e),G(e);for(let[n,r]of Object.entries(e.properties)){let i=r.attribute??n.toLowerCase();this.hasAttribute(i)&&(this[n]=F(this.getAttribute(i),r.type??String))}E(()=>this.connected()),this.#i.push(p(()=>{for(let r of this[L].values())r.value;this.#l.value;let n=e.template(this);if(n&&g(n,this),this.render(),this[x].size){let r=new Map(this[x]);this[x].clear(),this.updated(r)}},{host:this.localName,onError:this.onError?n=>this.onError(n):null})),this.#e||(this.#e=new Set);for(let n of e.traits)this.#s(n);this.#c(),this.#n&&this.#a()}disconnectedCallback(){this._i&&C(this._i.p);for(let e of this.#i)e();this.#i.length=0;for(let e of this.#o)e.value=void 0;this.#o.length=0;for(let e of this.#t)e.disconnect(this);this.#t.length=0,this.#e?.clear(),this.#r?.(),this.#r=null,this.#n?.disconnect?.(this),this.disconnected()}#a(){let e=this.#n;e.connect?.(this),this.#r=e.subscribe?.(()=>{this.#l.value++})}get controller(){return this.#n}set controller(e){this.#r?.(),this.#r=null,this.#n?.disconnect?.(this),this.#n=e,e&&this.isConnected&&this.#a()}#s(e,{declarative:n=!1}={}){this.#e.add(e);let r=e();r.connect(this,{host:this,signal:m,computed:k,effect:p}),n&&(r._declarative=!0),this.#t.push(r)}addTrait(e){return this.#e||(this.#e=new Set),this.#e.has(e)?this:(this.#s(e),this)}#c(){let e=this.getAttribute("traits");if(e)for(let n of e.split(/\s+/).filter(Boolean)){let r=D(n);if(!r){console.warn(`<${this.localName}> traits="${n}" \u2014 trait not found. Did you forget to import it?`);continue}this.#e.has(r)||this.#s(r,{declarative:!0})}}#f(){if(!this.#e)return;let e=[];for(let n of this.#t)if(n._declarative){n.disconnect(this);for(let r of this.#e)if(r.schema?.name&&n.schema?.name===r.schema.name){this.#e.delete(r);break}}else e.push(n);this.#t.length=0,this.#t.push(...e),this.#c()}attributeChangedCallback(e,n,r){if(e==="traits"){this.isConnected&&this.#f();return}for(let[i,o]of Object.entries(this.constructor.properties))if((o.attribute??i.toLowerCase())===e){this[i]=F(r,o.type??String);break}}static template=()=>null;static create(e={}){let n=this._tag??customElements.getName?.(this);if(!n)throw new Error("Component not registered");let r=document.createElement(n);for(let[i,o]of Object.entries(e))r[i]=o;return r}signal(e){let n=m(e);return this.#o.push(n),n}ensure(e){for(let o of this.children)if(o.getAttribute("slot")===e)return o;let n=this.#u(e);if(n)return n;G(this.constructor);let r=this.constructor._pp?.[e];if(!r)return null;let i=r.cloneNode(!0);return i._uiPart=!0,this.appendChild(i),i}drop(e){for(let r of this.children)if(r.getAttribute("slot")===e){r.remove();return}let n=this.#u(e);n&&n.remove()}#u(e){for(let n of this.querySelectorAll(`[slot="${e}"]`)){let r=n.parentElement,i=!0;for(;r&&r!==this;){if(r.localName.includes("-")){i=!1;break}r=r.parentElement}if(i&&r===this)return n}return null}reconcile(e,n,r,i){let o=e[y]||new Map,a=new Map,c=[];for(let l=0;l<n.length;l++){let u=n[l],d=r(u,l);if(a.has(d))continue;let w=o.get(d);w?i(u,l,w):w=i(u,l,null),a.set(d,w),c.push(d)}for(let[l,u]of o)a.has(l)||u.remove();let s=null;for(let l=c.length-1;l>=0;l--){let u=a.get(c[l]);(u.nextSibling!==s||u.parentNode!==e)&&e.insertBefore(u,s),s=u}e[y]=a}connected(){}render(){}disconnected(){}updated(e){}};var T=class extends O{static properties={centered:{type:Boolean,default:!1,reflect:!0},"full-bleed":{type:Boolean,default:!1,reflect:!0}};static template=()=>null};customElements.get("simple-shell")||customElements.define("simple-shell",T);export{T as SimpleShell};
@@ -92,6 +92,8 @@ class EditorCanvas extends UIElement {
92
92
  }
93
93
 
94
94
  #setupChildObserver() {
95
+ // gh#285 — SSR DOM shims (linkedom) have no MutationObserver global.
96
+ if (typeof MutationObserver === 'undefined') return;
95
97
  this.#childObserver = new MutationObserver(() => {
96
98
  this.#syncEmptyFromChildren();
97
99
  });
@@ -113,18 +113,21 @@ class EditorSidebar extends UIElement {
113
113
  // intrinsic-size lookup doesn't propagate through to <pane-ui>'s
114
114
  // explicit width — the pane then overflows out of the sidebar and
115
115
  // visually overlaps the canvas.
116
- this.#ro = new ResizeObserver((entries) => {
117
- // §FB-49: skip samples while the host is not in layout — catches both
118
- // explicit display:none and small-nonzero transients during the
119
- // display-flip transition (e.g. 48px when pane re-enters layout).
120
- if (getComputedStyle(this).display === 'none') return;
121
- this.#syncCollapsed();
122
- // Use offsetWidth so the sidebar wraps the full pane border-box
123
- // (contentRect would be 1px short on side="leading|trailing").
124
- const w = this.#pane.offsetWidth;
125
- if (w > 0) this.style.width = `${w}px`;
126
- });
127
- this.#ro.observe(this.#pane);
116
+ // gh#285 SSR DOM shims (linkedom) have no ResizeObserver global.
117
+ if (typeof ResizeObserver !== 'undefined') {
118
+ this.#ro = new ResizeObserver((entries) => {
119
+ // §FB-49: skip samples while the host is not in layout — catches both
120
+ // explicit display:none and small-nonzero transients during the
121
+ // display-flip transition (e.g. 48px when pane re-enters layout).
122
+ if (getComputedStyle(this).display === 'none') return;
123
+ this.#syncCollapsed();
124
+ // Use offsetWidth so the sidebar wraps the full pane border-box
125
+ // (contentRect would be 1px short on side="leading|trailing").
126
+ const w = this.#pane.offsetWidth;
127
+ if (w > 0) this.style.width = `${w}px`;
128
+ });
129
+ this.#ro.observe(this.#pane);
130
+ }
128
131
 
129
132
  // Track resize via pointerdown on resize-handle children of the pane
130
133
  // (pane-ui's drag-handle is internal; we listen on the pane and let
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adia-ai/web-modules",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "AdiaUI composite custom elements \u2014 shell, chat, editor, runtime clusters built from @adia-ai/web-components primitives. Subpath exports per cluster.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -84,10 +84,6 @@
84
84
  "types": "./css-module.d.ts",
85
85
  "default": "./shell/*/*.css"
86
86
  },
87
- "./shell/*/*.css": {
88
- "types": "./css-module.d.ts",
89
- "default": "./shell/*/*.css"
90
- },
91
87
  "./shell/*/css/*.css": {
92
88
  "types": "./css-module.d.ts",
93
89
  "default": "./shell/*/css/*.css"
@@ -111,10 +107,6 @@
111
107
  "types": "./css-module.d.ts",
112
108
  "default": "./chat/*/*.css"
113
109
  },
114
- "./chat/*/*.css": {
115
- "types": "./css-module.d.ts",
116
- "default": "./chat/*/*.css"
117
- },
118
110
  "./chat/*/css/*.css": {
119
111
  "types": "./css-module.d.ts",
120
112
  "default": "./chat/*/css/*.css"
@@ -143,10 +135,6 @@
143
135
  "types": "./css-module.d.ts",
144
136
  "default": "./editor/*/*.css"
145
137
  },
146
- "./editor/*/*.css": {
147
- "types": "./css-module.d.ts",
148
- "default": "./editor/*/*.css"
149
- },
150
138
  "./editor/*/css/*.css": {
151
139
  "types": "./css-module.d.ts",
152
140
  "default": "./editor/*/css/*.css"
@@ -170,10 +158,6 @@
170
158
  "types": "./css-module.d.ts",
171
159
  "default": "./simple/*/*.css"
172
160
  },
173
- "./simple/*/*.css": {
174
- "types": "./css-module.d.ts",
175
- "default": "./simple/*/*.css"
176
- },
177
161
  "./simple/*/css/*.css": {
178
162
  "types": "./css-module.d.ts",
179
163
  "default": "./simple/*/css/*.css"
@@ -192,10 +176,6 @@
192
176
  "types": "./css-module.d.ts",
193
177
  "default": "./runtime/*/*.css"
194
178
  },
195
- "./runtime/*/*.css": {
196
- "types": "./css-module.d.ts",
197
- "default": "./runtime/*/*.css"
198
- },
199
179
  "./runtime/*/css/*.css": {
200
180
  "types": "./css-module.d.ts",
201
181
  "default": "./runtime/*/css/*.css"
@@ -214,10 +194,6 @@
214
194
  "types": "./css-module.d.ts",
215
195
  "default": "./theme/*/*.css"
216
196
  },
217
- "./theme/*/*.css": {
218
- "types": "./css-module.d.ts",
219
- "default": "./theme/*/*.css"
220
- },
221
197
  "./theme/*/css/*.css": {
222
198
  "types": "./css-module.d.ts",
223
199
  "default": "./theme/*/css/*.css"
@@ -144,8 +144,21 @@ class AdminSidebar extends UIElement {
144
144
 
145
145
  // ── Reflect [collapsed] from current measured width ──
146
146
 
147
+ /**
148
+ * A zero rect means "unknown," not "collapsed" — linkedom/SSR shims
149
+ * have no layout engine and always return 0×0, and a real browser can
150
+ * connect an element before its first layout pass (a `display:none`
151
+ * ancestor, e.g.). Snapping collapsed on a bogus zero-width read used
152
+ * to require every SSR consumer to fake a viewport-sized rect just to
153
+ * keep the sidebar expanded server-side (gh#286). Deriving state from
154
+ * a real width stays synchronous; deriving it from a real ZERO is the
155
+ * bug — that path now leaves whatever state connected() already
156
+ * restored (persisted width, or the default) until the ResizeObserver
157
+ * below fires with genuine layout.
158
+ */
147
159
  #syncCollapsedFromWidth() {
148
160
  const w = this.getBoundingClientRect().width;
161
+ if (w === 0) return;
149
162
  this.collapsed = w <= SNAP_THRESHOLD;
150
163
  }
151
164
 
@@ -219,14 +232,22 @@ class AdminSidebar extends UIElement {
219
232
  this.#resizeCleanups.push(() => handle.removeEventListener('pointerdown', onPointerDown));
220
233
  }
221
234
 
222
- // ── Child ResizeObserver — flips select-ui placement in narrow mode ──
235
+ // ── Host ResizeObserver — flips select-ui placement in narrow mode AND
236
+ // is the deferred [collapsed] correction for gh#286: its first tick
237
+ // fires with genuine layout (SSR hydration's first client paint, or
238
+ // a browser connect that started inside display:none), so a
239
+ // zero-width connect() that left #syncCollapsedFromWidth a no-op
240
+ // gets resolved here instead of staying wrong forever. ──
223
241
 
224
242
  #setupChildResizeObserver() {
243
+ // gh#285 — SSR DOM shims (linkedom) have no ResizeObserver global.
244
+ if (typeof ResizeObserver === 'undefined') return;
225
245
  this.#childRO = new ResizeObserver((entries) => {
226
246
  for (const entry of entries) {
227
- const narrow = entry.contentBoxSize[0].inlineSize <= SNAP_THRESHOLD;
247
+ const w = entry.contentBoxSize[0].inlineSize;
248
+ if (w > 0) this.collapsed = w <= SNAP_THRESHOLD;
228
249
  for (const sel of this.querySelectorAll('select-ui')) {
229
- sel.setAttribute('placement', narrow ? 'right' : 'bottom-start');
250
+ sel.setAttribute('placement', w <= SNAP_THRESHOLD ? 'right' : 'bottom-start');
230
251
  }
231
252
  }
232
253
  });
@@ -120,4 +120,54 @@ describe('admin-sidebar', () => {
120
120
  const removedTypes = removeSpy.mock.calls.map((args) => args[0]);
121
121
  expect(removedTypes).toContain('pointerdown');
122
122
  });
123
+
124
+ // gh#286 — a zero rect (linkedom/SSR shims have no layout engine; a
125
+ // browser can also connect an element before its first layout, e.g.
126
+ // inside a display:none ancestor) must NOT snap the sidebar collapsed.
127
+ describe('gh#286 — zero-rect connect does not force collapse', () => {
128
+ it('stays at the connect() default (expanded) when the rect is 0×0', () => {
129
+ HTMLElement.prototype.getBoundingClientRect = () => ({ width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0, x: 0, y: 0 });
130
+ const sb = mount('<admin-sidebar slot="leading"></admin-sidebar>');
131
+ expect(sb.collapsed).toBe(false);
132
+ });
133
+
134
+ it('keeps a persisted expanded width instead of overriding it with a bogus collapse', () => {
135
+ // First mount at a real expanded width — persists 240px.
136
+ const sb1 = mount('<admin-sidebar slot="leading" collapsible></admin-sidebar>');
137
+ sb1.getBoundingClientRect = () => ({ width: 240 });
138
+ sb1.style.width = '240px';
139
+ sb1.collapse();
140
+ sb1.expand();
141
+ sb1.remove();
142
+
143
+ // Re-mount under a zero-rect environment (the SSR case) — the
144
+ // restored width from storage should survive; connected() must not
145
+ // overwrite it back to collapsed just because the rect read 0.
146
+ HTMLElement.prototype.getBoundingClientRect = () => ({ width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0, x: 0, y: 0 });
147
+ const sb2 = mount('<admin-sidebar slot="leading" collapsible></admin-sidebar>');
148
+ expect(sb2.collapsed).toBe(false);
149
+ });
150
+
151
+ it('the ResizeObserver first tick self-corrects once real layout exists', () => {
152
+ let observedCallback;
153
+ globalThis.ResizeObserver = class {
154
+ constructor(cb) { observedCallback = cb; }
155
+ observe() {}
156
+ unobserve() {}
157
+ disconnect() {}
158
+ };
159
+ HTMLElement.prototype.getBoundingClientRect = () => ({ width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0, x: 0, y: 0 });
160
+ const sb = mount('<admin-sidebar slot="leading"></admin-sidebar>');
161
+ expect(sb.collapsed).toBe(false); // still unresolved right after connect
162
+
163
+ // Simulate the observer's first real tick (e.g. SSR hydration's
164
+ // first client paint) reporting an actually-narrow layout.
165
+ observedCallback([{ contentBoxSize: [{ inlineSize: 60 }] }]);
166
+ expect(sb.collapsed).toBe(true);
167
+
168
+ // And the inverse — a real wide layout expands it.
169
+ observedCallback([{ contentBoxSize: [{ inlineSize: 240 }] }]);
170
+ expect(sb.collapsed).toBe(false);
171
+ });
172
+ });
123
173
  });