@adia-ai/web-modules 0.8.4 → 0.8.5

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,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(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(o){n.onError?n.onError(o):(n.disposed=!0,queueMicrotask(()=>{throw o}))}}}}function K(t){if(_){t();return}_=!0;try{t()}finally{_=!1,h&&q()}}function M(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 O(t){let e=new Set,n,o=!0,r={dirty:!1,disposed:!1,run(){o=!0,P(e)}};return{[S]:!0,get value(){if(f&&e.add(f),o){let s=f;f=r;try{n=t(),o=!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 o=f;f=n;try{t()}finally{f=o}}};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 r=0;r<t.length;r++)n+=t[r],r<e.length&&(n+=e[r]);let o=new CSSStyleSheet;return o.replaceSync(n),o}var I=new WeakMap;function Y(t){let e=0,n=0,o=0;for(;o<t.length;){if(e===0&&t.charCodeAt(o)===60&&t.charCodeAt(o+1)===33&&t.charCodeAt(o+2)===45&&t.charCodeAt(o+3)===45){let s=t.indexOf("-->",o+4);if(s===-1){n=0;break}o=s+3,n=0;continue}let r=t.charCodeAt(o);e?r===(e===1?39:34)&&(e=0):r===39?e=1:r===34?e=2:r===60?n=1:r===62&&(n=0),o++}return n===1}function J(t){let e=I.get(t);if(e)return e;let n="";for(let o=0;o<t.length;o++)n+=t[o],o<t.length-1&&(n+=Y(n)?`{{p:${o}}}`:`<!--p:${o}-->`);return e=document.createElement("template"),e.innerHTML=n,I.set(t,e),e}var B={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(B[e])return B[e];let n=Object.getOwnPropertyNames(t);for(let r=0;r<n.length;r++){let s=n[r];if(s!==e&&s.toLowerCase()===e)return s}let o=Object.getPrototypeOf(t);for(;o&&o!==Object.prototype;){let r=Object.getOwnPropertyNames(o);for(let s=0;s<r.length;s++){let a=r[s];if(a!==e&&a.toLowerCase()===e)return a}o=Object.getPrototypeOf(o)}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,r=J(n).content.cloneNode(!0),s=Z(e);s&&(r=ee(r,s));let a=te(r,t.values.length);return e.replaceChildren(r),{s:n,p:a}}var A="http://www.w3.org/2000/svg",y="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===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 o=(e.getAttribute("encoding")||"").toLowerCase();return o==="text/html"||o==="application/xhtml+xml"?null:y}return n==="svg"?A:n==="math"?y:null}function ee(t,e){let n=document.createDocumentFragment();return U(t,n,e),n}function U(t,e,n){for(let o of[...t.childNodes])if(o.nodeType===1){let s=document.createElementNS(n,o.localName);for(let i of o.attributes)i.namespaceURI?s.setAttributeNS(i.namespaceURI,i.name,i.value):s.setAttribute(i.name,i.value);e.appendChild(s);let a=o.localName,c=n;if(n===A&&(a==="foreignObject"||a==="foreignobject"))c=R;else if(n===y&&a==="annotation-xml"){let i=(o.getAttribute("encoding")||"").toLowerCase();(i==="text/html"||i==="application/xhtml+xml")&&(c=R)}U(o,s,c)}else e.appendChild(o.cloneNode(!0))}function te(t,e){let n=new Array(e),o=document.createTreeWalker(t,129),r;for(;r=o.nextNode();)if(r.nodeType===8){let s=r.data.match(/^p:(\d+)$/);if(s){let a=document.createTextNode("");r.replaceWith(a),o.currentNode=a,n[+s[1]]={t:"n",n:a,c:void 0,_fx:null}}}else if(r.nodeType===1)for(let s of[...r.attributes]){let a=s.value.match(/^\{\{p:(\d+)\}\}$/);if(!a){if(s.value.includes("{{p:")){let l=s.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(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 G(t){if(_){t();return}_=!0;try{t()}finally{_=!1,h&&q()}}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 M(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 k(t){return t!=null&&typeof t=="object"&&t[S]===!0}var[v,y]=[Symbol(),Symbol()];function K(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 B={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(B[e])return B[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&&N(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 V(t,n,e),n}function V(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)}V(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)
2
2
  .${l}=\${expression} \u2190 property assignment (preferred for objects/functions)
3
3
  `;console.warn(`[template] Partial attribute interpolation is not supported.
4
- Element: <${r.tagName.toLowerCase()}>
5
- Attribute: ${l}="${s.value.slice(0,80)}${s.value.length>80?"\u2026":""}"
4
+ Element: <${o.tagName.toLowerCase()}>
5
+ Attribute: ${l}="${i.value.slice(0,80)}${i.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],i=s.name;i[0]==="@"?(r.removeAttribute(i),n[c]={t:"e",n:r,name:i.slice(1),c:void 0,_fx:null}):i[0]==="."?(r.removeAttribute(i),n[c]={t:"p",n:r,name:H(r,i.slice(1)),c:void 0,_fx:null,_resolved:!1}):i[0]==="?"?(r.removeAttribute(i),console.warn(`[template] Lit-style boolean attribute "${i}=" is not supported.
8
- Element: <${r.tagName.toLowerCase()}>
9
- Use .${i.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:r,name:i,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[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 W=t=>t!=null&&typeof t=="object"&&t.strings,D=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($(t));else if(W(e))g(e,$(t));else if(Array.isArray(e)){let n=$(t);n.replaceChildren();for(let o of e)if(W(o)){let r=document.createElement("span");r.style.display="contents",r.setAttribute("role","presentation"),n.appendChild(r),g(o,r)}else n.appendChild(document.createTextNode(o??""))}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=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 o=t[n];if(!o)continue;let r=e[n],s=o.t!=="e"&&typeof r=="function",a=!s&&o.t!=="e"&&k(r);if(o._fx&&!s&&!a&&(o._fx(),o._fx=null),s){o._fx||(o._fx=p(()=>j(o,r())));continue}if(a){o._fx||(o._fx=p(()=>j(o,r.value)));continue}j(o,r)}}function oe(t,e,n){return{_directive:!0,_commit(o){let r=o[b]||new Map,s=new Map,a=[];for(let i=0;i<t.length;i++){let l=e(t[i],i);if(s.has(l))continue;a.push(l);let u=n(t[i],i);if(r.has(l)){let d=r.get(l);g(u,d),s.set(l,d)}else{let d=document.createElement("span");d.style.display="contents",d.setAttribute("role","presentation"),g(u,d),s.set(l,d)}}for(let[i,l]of r)s.has(i)||(l._i&&C(l._i.p),l.remove());let c=null;for(let i=a.length-1;i>=0;i--){let l=s.get(a[i]);(l.nextSibling!==c||l.parentNode!==o)&&o.insertBefore(l,c),c=l}o[b]=s}}}var N=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 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(!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 o=null;return{schema:e,connect(r,s){o=t.setup({host:r,...s||{}})},disconnect(r){o&&(o(),o=null);for(let s of e.attributes)r.hasAttribute(s)&&(console.warn(`Trait "${e.name}": attribute "${s}" still present after disconnect`),r.removeAttribute(s))}}}return n.schema=e,N.set(t.name,n),n}function z(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 re(t,e){t[x]=new Map,t[L]=new Map;for(let[n,o]of Object.entries(e)){let r=o.attribute??n.toLowerCase(),s=o.type??String,a=Object.prototype.hasOwnProperty.call(t,n),c=a?t[n]:void 0;a&&delete t[n];let i=m(o.default??void 0);t[L].set(n,i),Object.defineProperty(t,n,{get(){return i.value},set(l){let u=i.peek();Object.is(u,l)||(t[x].set(n,u),i.value=l,o.reflect&&se(t,r,l,s))},configurable:!0}),a&&(i.value=c)}}function se(t,e,n,o){o===Boolean?n?t.setAttribute(e,""):t.removeAttribute(e):n==null?t.removeAttribute(e):t.setAttribute(e,String(n))}var ie=(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(o=>!document.adoptedStyleSheets.includes(o))]}function G(t){if(Object.hasOwn(t,"_pp"))return;t._pp={};let e=t.parts;if(e)for(let[n,o]of Object.entries(e)){let r=document.createElement("template");r.innerHTML=o,t._pp[n]=r.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,o])=>o.attribute??n.toLowerCase());return e.includes("traits")?e:[...e,"traits"]}#r=[];#e=[];#n=[];#o=null;#s=null;#t=null;#l=m(0);constructor(){super(),this.internals=this.attachInternals(),re(this,this.constructor.properties)}connectedCallback(){let e=this.constructor;e._tag||(e._tag=this.localName),le(e),G(e),M(()=>this.connected()),this.#r.push(p(()=>{for(let o of this[L].values())o.value;this.#l.value;let n=e.template(this);if(n&&g(n,this),this.render(),this[x].size){let o=new Map(this[x]);this[x].clear(),this.updated(o)}},{host:this.localName,onError:this.onError?n=>this.onError(n):null})),this.#t||(this.#t=new Set);for(let n of e.traits)this.#i(n);this.#c(),this.#o&&this.#a()}disconnectedCallback(){this._i&&C(this._i.p);for(let e of this.#r)e();this.#r.length=0;for(let e of this.#n)e.value=void 0;this.#n.length=0;for(let e of this.#e)e.disconnect(this);this.#e.length=0,this.#t?.clear(),this.#s?.(),this.#s=null,this.#o?.disconnect?.(this),this.disconnected()}#a(){let e=this.#o;e.connect?.(this),this.#s=e.subscribe?.(()=>{this.#l.value++})}get controller(){return this.#o}set controller(e){this.#s?.(),this.#s=null,this.#o?.disconnect?.(this),this.#o=e,e&&this.isConnected&&this.#a()}#i(e,{declarative:n=!1}={}){this.#t.add(e);let o=e();o.connect(this,{host:this,signal:m,computed:O,effect:p}),n&&(o._declarative=!0),this.#e.push(o)}addTrait(e){return this.#t||(this.#t=new Set),this.#t.has(e)?this:(this.#i(e),this)}#c(){let e=this.getAttribute("traits");if(e)for(let n of e.split(/\s+/).filter(Boolean)){let o=z(n);if(!o){console.warn(`<${this.localName}> traits="${n}" \u2014 trait not found. Did you forget to import it?`);continue}this.#t.has(o)||this.#i(o,{declarative:!0})}}#f(){if(!this.#t)return;let e=[];for(let n of this.#e)if(n._declarative){n.disconnect(this);for(let o of this.#t)if(o.schema?.name&&n.schema?.name===o.schema.name){this.#t.delete(o);break}}else e.push(n);this.#e.length=0,this.#e.push(...e),this.#c()}attributeChangedCallback(e,n,o){if(e==="traits"){this.isConnected&&this.#f();return}for(let[r,s]of Object.entries(this.constructor.properties))if((s.attribute??r.toLowerCase())===e){this[r]=ie(o,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 o=document.createElement(n);for(let[r,s]of Object.entries(e))o[r]=s;return o}signal(e){let n=m(e);return this.#n.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 o=this.constructor._pp?.[e];if(!o)return null;let r=o.cloneNode(!0);return r._uiPart=!0,this.appendChild(r),r}drop(e){for(let o of this.children)if(o.getAttribute("slot")===e){o.remove();return}let n=this.#u(e);n&&n.remove()}#u(e){for(let n of this.querySelectorAll(`[slot="${e}"]`)){let o=n.parentElement,r=!0;for(;o&&o!==this;){if(o.localName.includes("-")){r=!1;break}o=o.parentElement}if(r&&o===this)return n}return null}reconcile(e,n,o,r){let s=e[b]||new Map,a=new Map,c=[];for(let l=0;l<n.length;l++){let u=n[l],d=o(u,l);if(a.has(d))continue;let w=s.get(d);w?r(u,l,w):w=r(u,l,null),a.set(d,w),c.push(d)}for(let[l,u]of s)a.has(l)||u.remove();let i=null;for(let l=c.length-1;l>=0;l--){let u=a.get(c[l]);(u.nextSibling!==i||u.parentNode!==e)&&e.insertBefore(u,i),i=u}e[b]=a}connected(){}render(){}disconnected(){}updated(e){}};var T=class extends E{static properties={focusMode:{type:Boolean,default:!1,reflect:!0,attribute:"focus-mode"}};static template=()=>null;#r=null;#e=null;#n=null;connected(){this.#r=this.querySelector("editor-toolbar"),this.#e=this.querySelector("editor-canvas"),this.#o(),this.#n=e=>{let n=e?.detail?.name;n&&(n==="toggle-focus"||n==="full-screen")&&this.toggleFocusMode()},this.addEventListener("toolbar-action",this.#n)}disconnected(){this.#n&&this.removeEventListener("toolbar-action",this.#n),this.#n=null}toggleFocusMode(){this.focusMode=!this.focusMode,this.#r?.tagName?.toLowerCase()==="editor-toolbar"&&(this.#r.fullScreen=this.focusMode),this.#e?.tagName?.toLowerCase()==="editor-canvas"&&(this.focusMode?this.#e.focus?.():this.#e.blur?.()),this.dispatchEvent(new CustomEvent("editor-mode-change",{bubbles:!0,detail:{focusMode:this.focusMode}}))}#o(){for(let e of this.querySelectorAll("select-ui[data-options]"))try{let n=JSON.parse(e.getAttribute("data-options"));e.options=n}catch{}}};customElements.define("editor-shell",T);export{T as EditorShell};
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()}>
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 N(t){for(let e of t)e&&e._fx&&(e._fx(),e._fx=null)}function $(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 F=t=>t!=null&&typeof t=="object"&&t.strings,U=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($(t));else if(F(e))g(e,$(t));else if(Array.isArray(e)){let n=$(t);n.replaceChildren();for(let r of e)if(F(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[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=H(t.n,t.name);n!==t.name&&(t.name=n),t._resolved=!0}t.n[t.name]=e}else t.t==="e"&&(U(t.c)&&t.n.removeEventListener(t.name,t.c),U(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"&&k(o);if(r._fx&&!i&&!a&&(r._fx(),r._fx=null),i){r._fx||(r._fx=p(()=>j(r,o())));continue}if(a){r._fx||(r._fx=p(()=>j(r,o.value)));continue}j(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&&N(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 C=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 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(!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(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,C.set(t.name,n),n}function z(t){return C.get(t)||null}function he(t){return C.get(t)?.schema||null}function pe(){return[...C.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&&se(t,o,l,i))},configurable:!0}),a&&(s.value=c)}}var ie=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 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 le=(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 D(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 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"]}#o=[];#e=[];#n=[];#r=null;#i=null;#t=null;#l=m(0);constructor(){super(),this.internals=typeof this.attachInternals=="function"?this.attachInternals():ie,oe(this,this.constructor.properties)}connectedCallback(){let e=this.constructor;e._tag||(e._tag=this.localName),ae(e),D(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.#t||(this.#t=new Set);for(let n of e.traits)this.#s(n);this.#c(),this.#r&&this.#a()}disconnectedCallback(){this._i&&N(this._i.p);for(let e of this.#o)e();this.#o.length=0;for(let e of this.#n)e.value=void 0;this.#n.length=0;for(let e of this.#e)e.disconnect(this);this.#e.length=0,this.#t?.clear(),this.#i?.(),this.#i=null,this.#r?.disconnect?.(this),this.disconnected()}#a(){let e=this.#r;e.connect?.(this),this.#i=e.subscribe?.(()=>{this.#l.value++})}get controller(){return this.#r}set controller(e){this.#i?.(),this.#i=null,this.#r?.disconnect?.(this),this.#r=e,e&&this.isConnected&&this.#a()}#s(e,{declarative:n=!1}={}){this.#t.add(e);let r=e();r.connect(this,{host:this,signal:m,computed:M,effect:p}),n&&(r._declarative=!0),this.#e.push(r)}addTrait(e){return this.#t||(this.#t=new Set),this.#t.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=z(n);if(!r){console.warn(`<${this.localName}> traits="${n}" \u2014 trait not found. Did you forget to import it?`);continue}this.#t.has(r)||this.#s(r,{declarative:!0})}}#f(){if(!this.#t)return;let e=[];for(let n of this.#e)if(n._declarative){n.disconnect(this);for(let r of this.#t)if(r.schema?.name&&n.schema?.name===r.schema.name){this.#t.delete(r);break}}else e.push(n);this.#e.length=0,this.#e.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]=le(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.#n.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;D(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 T=class extends E{static properties={focusMode:{type:Boolean,default:!1,reflect:!0,attribute:"focus-mode"}};static template=()=>null;#o=null;#e=null;#n=null;connected(){this.#o=this.querySelector("editor-toolbar"),this.#e=this.querySelector("editor-canvas"),this.#r(),this.#n=e=>{let n=e?.detail?.name;n&&(n==="toggle-focus"||n==="full-screen")&&this.toggleFocusMode()},this.addEventListener("toolbar-action",this.#n)}disconnected(){this.#n&&this.removeEventListener("toolbar-action",this.#n),this.#n=null}toggleFocusMode(){this.focusMode=!this.focusMode,this.#o?.tagName?.toLowerCase()==="editor-toolbar"&&(this.#o.fullScreen=this.focusMode),this.#e?.tagName?.toLowerCase()==="editor-canvas"&&(this.focusMode?this.#e.focus?.():this.#e.blur?.()),this.dispatchEvent(new CustomEvent("editor-mode-change",{bubbles:!0,detail:{focusMode:this.focusMode}}))}#r(){for(let e of this.querySelectorAll("select-ui[data-options]"))try{let n=JSON.parse(e.getAttribute("data-options"));e.options=n}catch{}}};customElements.define("editor-shell",T);export{T as EditorShell};