tosijs 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- var{defineProperty:Xn,getOwnPropertyNames:De,getOwnPropertyDescriptor:Fe}=Object,Le=Object.prototype.hasOwnProperty;var Un=new WeakMap,Be=(n)=>{var e=Un.get(n),o;if(e)return e;if(e=Xn({},"__esModule",{value:!0}),n&&typeof n==="object"||typeof n==="function")De(n).map((i)=>!Le.call(e,i)&&Xn(e,i,{get:()=>n[i],enumerable:!(o=Fe(n,i))||o.enumerable}));return Un.set(n,e),e};var He=(n,e)=>{for(var o in e)Xn(n,o,{get:e[o],enumerable:!0,configurable:!0,set:(i)=>e[o]=()=>i})};var po={};He(po,{xinValue:()=>h,xinProxy:()=>bn,xinPath:()=>C,xin:()=>f,version:()=>hn,vars:()=>xn,varDefault:()=>N,updates:()=>Dn,unobserve:()=>J,touchElement:()=>fn,touch:()=>P,tosi:()=>Jn,throttle:()=>Q,svgElements:()=>yn,settings:()=>B,on:()=>$,observe:()=>_,mathML:()=>mn,makeComponent:()=>on,invertLuminance:()=>Ee,initVars:()=>Xe,hotReload:()=>ke,getListItem:()=>sn,getCssVar:()=>un,elements:()=>y,debounce:()=>an,css:()=>Y,boxedProxy:()=>en,boxed:()=>W,blueprintLoader:()=>ve,blueprint:()=>Ce,bindings:()=>R,bind:()=>b,StyleSheet:()=>ge,MoreMath:()=>me,Component:()=>L,Color:()=>a,BlueprintLoader:()=>wn,Blueprint:()=>tn});module.exports=Be(po);var B={debug:!1,perf:!1};function v(n){if(n==null||typeof n!=="object")return n;if(n instanceof Set)return new Set(n);else if(Array.isArray(n))return n.map(v);let e={};for(let o in n){let i=n[o];if(n!=null&&typeof n==="object")e[o]=v(i);else e[o]=i}return e}var En="-xin-data",H=`.${En}`,Sn="-xin-event",kn=`.${Sn}`,g="xinPath",z="xinValue",_n="xinSet",Gn="xinObserve",Zn="xinBind",qn="xinOn",C=(n)=>{return n&&n[g]||void 0};function h(n){return typeof n==="object"&&n!==null?n[z]||n:n}var O=new WeakMap,M=new WeakMap;var A=(n)=>{let e=n.cloneNode();if(e instanceof Element){let o=M.get(n),i=O.get(n);if(o!=null)M.set(e,v(o));if(i!=null)O.set(e,v(i))}for(let o of Array.from(n instanceof HTMLTemplateElement?n.content.childNodes:n.childNodes))if(o instanceof Element||o instanceof DocumentFragment)e.appendChild(A(o));else e.appendChild(o.cloneNode());return e},Z=new WeakMap,sn=(n)=>{let e=document.body.parentElement;while(n.parentElement!=null&&n.parentElement!==e){let o=Z.get(n);if(o!=null)return o;n=n.parentElement}return!1};var Qn=Symbol("observer should be removed"),cn=[],dn=[],Cn=!1,vn,Mn;class Kn{description;test;callback;constructor(n,e){let o=typeof e==="string"?`"${e}"`:`function ${e.name}`,i;if(typeof n==="string")this.test=(t)=>typeof t==="string"&&t!==""&&(n.startsWith(t)||t.startsWith(n)),i=`test = "${n}"`;else if(n instanceof RegExp)this.test=n.test.bind(n),i=`test = "${n.toString()}"`;else if(n instanceof Function)this.test=n,i=`test = function ${n.name}`;else throw Error("expect listener test to be a string, RegExp, or test function");if(this.description=`${i}, ${o}`,typeof e==="function")this.callback=e;else throw Error("expect callback to be a path or function");cn.push(this)}}var Dn=async()=>{if(vn===void 0)return;await vn},$e=()=>{if(B.perf)console.time("xin async update");let n=Array.from(dn);for(let e of n)cn.filter((o)=>{let i;try{i=o.test(e)}catch(t){throw Error(`Listener ${o.description} threw "${t}" at "${e}"`)}if(i===Qn)return J(o),!1;return i}).forEach((o)=>{let i;try{i=o.callback(e)}catch(t){console.error(`Listener ${o.description} threw "${t}" handling "${e}"`)}if(i===Qn)J(o)});if(dn.splice(0),Cn=!1,typeof Mn==="function")Mn();if(B.perf)console.timeEnd("xin async update")},P=(n)=>{let e=typeof n==="string"?n:C(n);if(e===void 0)throw console.error("touch was called on an invalid target",n),Error("touch was called on an invalid target");if(Cn===!1)vn=new Promise((o)=>{Mn=o}),Cn=setTimeout($e);if(dn.find((o)=>e.startsWith(o))==null)dn.push(e)},Fn=(n,e)=>{return new Kn(n,e)},J=(n)=>{let e=cn.indexOf(n);if(e>-1)cn.splice(e,1);else throw Error("unobserve failed, listener not found")};var Oe=(n)=>{try{return JSON.stringify(n)}catch(e){return"{has circular references}"}},Ln=(...n)=>Error(n.map(Oe).join(" "));var ze=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),Ae=0,Pe=()=>(parseInt("10000",36)+ ++Ae).toString(36).slice(-5),je=()=>ze()+Pe(),Hn=Symbol("delete"),ne=Symbol("new-object"),Bn=Symbol("automatic-index");function ee(n){if(n==="")return[];if(Array.isArray(n))return n;else{let e=[];while(n.length>0){let o=n.search(/\[[^\]]+\]/);if(o===-1){e.push(n.split("."));break}else{let i=n.slice(0,o);if(n=n.slice(o),i!=="")e.push(i.split("."));if(o=n.indexOf("]")+1,e.push(n.slice(1,o-1)),n.slice(o,o+1)===".")o+=1;n=n.slice(o)}}return e}}var D=new WeakMap;function oe(n,e){if(D.get(n)===void 0)D.set(n,{});if(D.get(n)[e]===void 0)D.get(n)[e]={};let o=D.get(n)[e];if(e==="_auto_")n.forEach((i,t)=>{if(i[Bn]===void 0)i[Bn]=je();o[i[Bn]+""]=t});else n.forEach((i,t)=>{o[V(i,e)+""]=t});return o}function We(n,e){if(D.get(n)===void 0||D.get(n)[e]===void 0)return oe(n,e);else return D.get(n)[e]}function Ie(n,e,o){o=o+"";let i=We(n,e)[o];if(i===void 0||V(n[i],e)+""!==o)i=oe(n,e)[o];return i}function Ye(n,e,o){if(n[e]===void 0&&o!==void 0)n[e]=o;return n[e]}function ie(n,e,o,i){let t=e!==""?Ie(n,e,o):o;if(i===Hn)return n.splice(t,1),D.delete(n),Symbol("deleted");else if(i===ne){if(e===""&&n[t]===void 0)n[t]={}}else if(i!==void 0)if(t!==void 0)n[t]=i;else if(e!==""&&V(i,e)+""===o+"")n.push(i),t=n.length-1;else throw Error(`byIdPath insert failed at [${e}=${o}]`);return n[t]}function Rn(n){if(!Array.isArray(n))throw Ln("setByPath failed: expected array, found",n)}function Nn(n){if(n==null||!(n instanceof Object))throw Ln("setByPath failed: expected Object, found",n)}function V(n,e){let o=ee(e),i=n,t,s,r,c;for(t=0,s=o.length;i!==void 0&&t<s;t++){let d=o[t];if(Array.isArray(d))for(r=0,c=d.length;i!==void 0&&r<c;r++){let l=d[r];i=i[l]}else if(i.length===0){if(i=i[Number(d.slice(1))],d[0]!=="=")return}else if(d.includes("=")){let[l,...p]=d.split("=");i=ie(i,l,p.join("="))}else r=parseInt(d,10),i=i[r]}return i}function te(n,e,o){let i=n;if(e==="")throw Error("setByPath cannot be used to set the root object");let t=ee(e);while(i!=null&&t.length>0){let s=t.shift();if(typeof s==="string"){let r=s.indexOf("=");if(r>-1){if(r===0)Nn(i);else Rn(i);let c=s.slice(0,r),d=s.slice(r+1);if(i=ie(i,c,d,t.length>0?ne:o),t.length===0)return!0}else{Rn(i);let c=parseInt(s,10);if(t.length>0)i=i[c];else{if(o!==Hn){if(i[c]===o)return!1;i[c]=o}else i.splice(c,1);return!0}}}else if(Array.isArray(s)&&s.length>0){Nn(i);while(s.length>0){let r=s.shift();if(s.length>0||t.length>0)i=Ye(i,r,s.length>0?{}:[]);else{if(o!==Hn){if(i[r]===o)return!1;i[r]=o}else{if(!Object.prototype.hasOwnProperty.call(i,r))return!1;delete i[r]}return!0}}}else throw Error(`setByPath failed, bad path ${e}`)}throw Error(`setByPath(${n}, ${e}, ${o}) failed`)}var Je=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],On={},Ve=!0,Ue=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,_e=(n)=>Ue.test(n),j=(n="",e="")=>{if(n==="")return e;else if(e.match(/^\d+$/)!==null||e.includes("="))return`${n}[${e}]`;else return`${n}.${e}`},Ge={string(n){return new String(n)},boolean(n){return new Boolean(n)},bigint(n){return n},symbol(n){return n},number(n){return new Number(n)}};function $n(n,e){let o=typeof n;if(n===void 0||o==="object"||o==="function")return n;else return new Proxy(Ge[typeof n](n),U(e,!0))}var U=(n,e)=>({get(o,i){switch(i){case g:return n;case z:return o.valueOf?o.valueOf():o;case _n:return(r)=>f[n]=r;case Gn:return(r)=>{let c=Fn(n,r);return()=>J(c)};case qn:return(r,c)=>$(r,c,h(o));case Zn:return(r,c,d)=>{b(r,n,c,d)}}if(typeof i==="symbol")return o[i];let t=i,s=t.match(/^([^.[]+)\.(.+)$/)??t.match(/^([^\]]+)(\[.+)/)??t.match(/^(\[[^\]]+\])\.(.+)$/)??t.match(/^(\[[^\]]+\])\[(.+)$/);if(s!==null){let[,r,c]=s,d=j(n,r),l=V(o,r);return l!==null&&typeof l==="object"?new Proxy(l,U(d,e))[c]:l}if(t.startsWith("[")&&t.endsWith("]"))t=t.substring(1,t.length-1);if(!Array.isArray(o)&&o[t]!==void 0||Array.isArray(o)&&t.includes("=")){let r;if(t.includes("=")){let[c,d]=t.split("=");r=o.find((l)=>`${V(l,c)}`===d)}else r=o[t];if(r instanceof Object){let c=j(n,t);return new Proxy(r instanceof Function?r.bind(o):r,U(c,e))}else return e?$n(r,j(n,t)):r}else if(Array.isArray(o)){let r=o[t];return typeof r==="function"?(...c)=>{let d=r.apply(o,c);if(Je.includes(t))P(n);return d}:typeof r==="object"?new Proxy(r,U(j(n,t),e)):e?$n(r,j(n,t)):r}else return e?$n(o[t],j(n,t)):o[t]},set(o,i,t){t=h(t);let s=i!==z?j(n,i):n;if(Ve&&!_e(s))throw Error(`setting invalid path ${s}`);if(h(f[s])!==t&&te(On,s,t))P(s);return!0}}),_=(n,e)=>{let o=typeof e==="function"?e:f[e];if(typeof o!=="function")throw Error(`observe expects a function or path to a function, ${e} is neither`);return Fn(n,o)},f=new Proxy(On,U("",!1)),W=new Proxy(On,U("",!0));var zn=(n,e)=>{let o=new Event(e);n.dispatchEvent(o)},se=(n)=>{if(n instanceof HTMLInputElement)return n.type;else if(n instanceof HTMLSelectElement&&n.hasAttribute("multiple"))return"multi-select";else return"other"},ce=(n,e)=>{switch(se(n)){case"radio":n.checked=n.value===e;break;case"checkbox":n.checked=!!e;break;case"date":n.valueAsDate=new Date(e);break;case"multi-select":for(let o of Array.from(n.querySelectorAll("option")))o.selected=e[o.value];break;default:n.value=e}},de=(n)=>{switch(se(n)){case"radio":{let e=n.parentElement?.querySelector(`[name="${n.name}"]:checked`);return e!=null?e.value:null}case"checkbox":return n.checked;case"date":return n.valueAsDate?.toISOString();case"multi-select":return Array.from(n.querySelectorAll("option")).reduce((e,o)=>{return e[o.value]=o.selected,e},{});default:return n.value}},{ResizeObserver:re}=globalThis,q=re!=null?new re((n)=>{for(let e of n){let o=e.target;zn(o,"resize")}}):{observe(){},unobserve(){}},An=(n,e,o=!0)=>{if(n!=null&&e!=null)if(typeof e==="string")n.textContent=e;else if(Array.isArray(e))e.forEach((i)=>{n.append(i instanceof Node&&o?A(i):i)});else if(e instanceof Node)n.append(o?A(e):e);else throw Error("expect text content or document node")};var an=(n,e=250)=>{let o;return(...i)=>{if(o!==void 0)clearTimeout(o);o=setTimeout(()=>{n(...i)},e)}},Q=(n,e=250)=>{let o,i=Date.now()-e,t=!1;return(...s)=>{if(clearTimeout(o),o=setTimeout(()=>{n(...s),i=Date.now()},e),!t&&Date.now()-i>=e){t=!0;try{n(...s),i=Date.now()}finally{t=!1}}}};var ln=Symbol("list-binding"),Ze=16,qe=100;function ae(n,e){let o=Array.from(n.querySelectorAll(H));if(n.matches(H))o.unshift(n);for(let i of o){let t=M.get(i);for(let s of t){if(s.path.startsWith("^"))s.path=`${e}${s.path.substring(1)}`;if(s.binding.toDOM!=null)s.binding.toDOM(i,f[s.path])}}}class le{boundElement;listTop;listBottom;template;options;itemToElement;_array=[];_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(n,e,o={}){if(this.boundElement=n,this.itemToElement=new WeakMap,n.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(n.children[0]instanceof HTMLTemplateElement){let i=n.children[0];if(i.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=A(i.content.children[0])}else this.template=n.children[0],this.template.remove();if(this.options=o,this.listTop=document.createElement("div"),this.listBottom=document.createElement("div"),this.listTop.classList.add("virtual-list-padding"),this.listBottom.classList.add("virtual-list-padding"),this.boundElement.append(this.listTop),this.boundElement.append(this.listBottom),o.virtual!=null)q.observe(this.boundElement),this._update=Q(()=>{this.update(this._array,!0)},Ze),this.boundElement.addEventListener("scroll",this._update),this.boundElement.addEventListener("resize",this._update)}visibleSlice(){let{virtual:n,hiddenProp:e,visibleProp:o}=this.options,i=this._array;if(e!==void 0)i=i.filter((d)=>d[e]!==!0);if(o!==void 0)i=i.filter((d)=>d[o]===!0);if(this.options.filter&&this.needle!==void 0)i=this.options.filter(i,this.needle);let t=0,s=i.length-1,r=0,c=0;if(n!=null&&this.boundElement instanceof HTMLElement){let d=this.boundElement.offsetWidth,l=this.boundElement.offsetHeight;if(n.visibleColumns==null)n.visibleColumns=n.width!=null?Math.max(1,Math.floor(d/n.width)):1;let p=Math.ceil(l/n.height)+(n.rowChunkSize||1),E=Math.ceil(i.length/n.visibleColumns),S=n.visibleColumns*p,m=Math.floor(this.boundElement.scrollTop/n.height);if(m>E-p+1)m=Math.max(0,E-p+1);if(n.rowChunkSize)m-=m%n.rowChunkSize;t=m*n.visibleColumns,s=t+S-1,r=m*n.height,c=Math.max((E-p)*n.height-r,0)}return{items:i,firstItem:t,lastItem:s,topBuffer:r,bottomBuffer:c}}needle;filter=Q((n)=>{if(this.needle!==n)this.needle=n,this.update(this._array)},qe);update(n,e){if(n==null)n=[];this._array=n;let{hiddenProp:o,visibleProp:i}=this.options,t=C(n),s=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",s.items.length===0);let r=this._previousSlice,{firstItem:c,lastItem:d,topBuffer:l,bottomBuffer:p}=s;if(o===void 0&&i===void 0&&e===!0&&r!=null&&c===r.firstItem&&d===r.lastItem)return;this._previousSlice=s;let E=0,S=0,m=0;for(let u of Array.from(this.boundElement.children)){if(u===this.listTop||u===this.listBottom)continue;let k=Z.get(u);if(k==null)u.remove();else{let w=s.items.indexOf(k);if(w<c||w>d)u.remove(),this.itemToElement.delete(k),Z.delete(u),E++}}this.listTop.style.height=String(l)+"px",this.listBottom.style.height=String(p)+"px";let x=[],{idPath:gn}=this.options;for(let u=c;u<=d;u++){let k=s.items[u];if(k===void 0)continue;let w=this.itemToElement.get(h(k));if(w==null){if(m++,w=A(this.template),typeof k==="object")this.itemToElement.set(h(k),w),Z.set(w,h(k));if(this.boundElement.insertBefore(w,this.listBottom),gn!=null){let Tn=k[gn],Me=`${t}[${gn}=${Tn}]`;ae(w,Me)}else{let Tn=`${t}[${u}]`;ae(w,Tn)}}x.push(w)}let rn=null;for(let u of x){if(u.previousElementSibling!==rn)if(S++,rn?.nextElementSibling!=null)this.boundElement.insertBefore(u,rn.nextElementSibling);else this.boundElement.insertBefore(u,this.listBottom);rn=u}if(B.perf)console.log(t,"updated",{removed:E,created:m,moved:S})}}var fe=(n,e,o)=>{let i=n[ln];if(i===void 0)i=new le(n,e,o),n[ln]=i;return i};var{document:K,MutationObserver:ue}=globalThis,fn=(n,e)=>{let o=M.get(n);if(o==null)return;for(let i of o){let{binding:t,options:s}=i,{path:r}=i,{toDOM:c}=t;if(c!=null){if(r.startsWith("^")){let d=sn(n);if(d!=null&&d[g]!=null)r=i.path=`${d[g]}${r.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${r}`,n,"is not part of a list"),Error(`Cannot resolve relative binding ${r}`)}if(e==null||r.startsWith(e))c(n,f[r],s)}}};if(ue!=null)new ue((e)=>{e.forEach((o)=>{Array.from(o.addedNodes).forEach((i)=>{if(i instanceof Element)Array.from(i.querySelectorAll(H)).forEach((t)=>fn(t))})})}).observe(K.body,{subtree:!0,childList:!0});_(()=>!0,(n)=>{let e=Array.from(K.querySelectorAll(H));for(let o of e)fn(o,n)});var pe=(n)=>{let e=n.target.closest(H);while(e!=null){let o=M.get(e);for(let i of o){let{binding:t,path:s}=i,{fromDOM:r}=t;if(r!=null){let c;try{c=r(e,i.options)}catch(d){throw console.error("Cannot get value from",e,"via",i),Error("Cannot obtain value fromDOM")}if(c!=null){let d=f[s];if(d==null)f[s]=c;else{let l=d[g]!=null?d[z]:d,p=c[g]!=null?c[z]:c;if(l!==p)f[s]=p}}}}e=e.parentElement.closest(H)}};if(globalThis.document!=null)K.body.addEventListener("change",pe,!0),K.body.addEventListener("input",pe,!0);function b(n,e,o,i){if(n instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let t;if(typeof e==="object"&&e[g]===void 0&&i===void 0){let{value:c}=e;t=typeof c==="string"?c:c[g],i=e,delete i.value}else t=typeof e==="string"?e:e[g];if(t==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:s}=o;n.classList?.add(En);let r=M.get(n);if(r==null)r=[],M.set(n,r);if(r.push({path:t,binding:o,options:i}),s!=null&&!t.startsWith("^"))P(t);if(i?.filter&&i?.needle)b(n,i.needle,{toDOM(c,d){console.log({needle:d}),c[ln]?.filter(d)}});return n}var ye=new Set,Qe=(n)=>{let e=n?.target.closest(kn),o=!1,i=new Proxy(n,{get(s,r){if(r==="stopPropagation")return()=>{n.stopPropagation(),o=!0};else{let c=s[r];return typeof c==="function"?c.bind(s):c}}}),t=new Set;while(!o&&e!=null){let r=O.get(e)[n.type]||t;for(let c of r){if(typeof c==="function")c(i);else{let d=f[c];if(typeof d==="function")d(i);else throw Error(`no event handler found at path ${c}`)}if(o)continue}e=e.parentElement!=null?e.parentElement.closest(kn):null}};function $(n,e,o){let i=O.get(n);if(n.classList.add(Sn),i==null)i={},O.set(n,i);if(!i[e])i[e]=new Set;if(i[e].add(o),!ye.has(e))ye.add(e),K.body.addEventListener(e,Qe,!0);return()=>{i[e].delete(o)}}var R={value:{toDOM:ce,fromDOM(n){return de(n)}},text:{toDOM(n,e){n.textContent=e}},enabled:{toDOM(n,e){n.disabled=!e}},disabled:{toDOM(n,e){n.disabled=Boolean(e)}},list:{toDOM(n,e,o){fe(n,e,o).update(e)}}};var Ke=180/Math.PI,Re=Math.PI/180;function T(n,e,o){return o<n?NaN:e<n?n:e>o?o:e}function F(n,e,o,i=!0){if(i)o=T(0,o,1);return o*(e-n)+n}var me={RADIANS_TO_DEGREES:Ke,DEGREES_TO_RADIANS:Re,clamp:T,lerp:F};function un(n,e=document.body){let o=getComputedStyle(e);if(n.endsWith(")")&&n.startsWith("var("))n=n.slice(4,-1);return o.getPropertyValue(n).trim()}var Ne=(n,e,o)=>{return(0.299*n+0.587*e+0.114*o)/255},I=(n)=>("00"+Math.round(Number(n)).toString(16)).slice(-2);class xe{h;s;l;constructor(n,e,o){n/=255,e/=255,o/=255;let i=Math.max(n,e,o),t=i-Math.min(n,e,o),s=t!==0?i===n?(e-o)/t:i===e?2+(o-n)/t:4+(n-e)/t:0;this.h=60*s<0?60*s+360:60*s,this.s=t!==0?i<=0.5?t/(2*i-t):t/(2-(2*i-t)):0,this.l=(2*i-t)/2}}var G=globalThis.document!==void 0?globalThis.document.createElement("span"):void 0;class a{r;g;b;a;static fromVar(n,e=document.body){return a.fromCss(un(n,e))}static fromCss(n){let e=n;if(G instanceof HTMLSpanElement)G.style.color="black",G.style.color=n,document.body.appendChild(G),e=getComputedStyle(G).color,G.remove();let[o,i,t,s]=e.match(/[\d.]+/g)||["0","0","0","0"],r=e.startsWith("color(srgb")?255:1;return new a(Number(o)*r,Number(i)*r,Number(t)*r,s==null?1:Number(s))}static fromHsl(n,e,o,i=1){let t,s,r;if(e===0)t=s=r=o;else{let d=(S,m,x)=>{if(x<0)x+=1;if(x>1)x-=1;if(x<0.16666666666666666)return S+(m-S)*6*x;if(x<0.5)return m;if(x<0.6666666666666666)return S+(m-S)*(0.6666666666666666-x)*6;return S},l=o<0.5?o*(1+e):o+e-o*e,p=2*o-l,E=(n%360+360)%360/360;t=d(p,l,E+0.3333333333333333),s=d(p,l,E),r=d(p,l,E-0.3333333333333333)}let c=new a(t*255,s*255,r*255,i);return c.hslCached={h:(n%360+360)%360,s:e,l:o},c}static black=new a(0,0,0);static white=new a(255,255,255);constructor(n,e,o,i=1){this.r=T(0,n,255),this.g=T(0,e,255),this.b=T(0,o,255),this.a=T(0,i,1)}get inverse(){return new a(255-this.r,255-this.g,255-this.b,this.a)}get inverseLuminance(){let{h:n,s:e,l:o}=this._hsl;return a.fromHsl(n,e,1-o,this.a)}get opaque(){return this.a===1?this:new a(this.r,this.g,this.b,1)}contrasting(n=1){return this.opaque.blend(this.brightness>0.5?a.black:a.white,n)}get rgb(){let{r:n,g:e,b:o}=this;return`rgb(${n.toFixed(0)},${e.toFixed(0)},${o.toFixed(0)})`}get rgba(){let{r:n,g:e,b:o,a:i}=this;return`rgba(${n.toFixed(0)},${e.toFixed(0)},${o.toFixed(0)},${i.toFixed(2)})`}get RGBA(){return[this.r/255,this.g/255,this.b/255,this.a]}get ARGB(){return[this.a,this.r/255,this.g/255,this.b/255]}hslCached;get _hsl(){if(this.hslCached==null)this.hslCached=new xe(this.r,this.g,this.b);return this.hslCached}get hsl(){let{h:n,s:e,l:o}=this._hsl;return`hsl(${n.toFixed(0)}deg ${(e*100).toFixed(0)}% ${(o*100).toFixed(0)}%)`}get hsla(){let{h:n,s:e,l:o}=this._hsl;return`hsl(${n.toFixed(0)}deg ${(e*100).toFixed(0)}% ${(o*100).toFixed(0)}% / ${(this.a*100).toFixed(0)}%)`}get mono(){let n=this.brightness*255;return new a(n,n,n)}get brightness(){return Ne(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+I(this.r)+I(this.g)+I(this.b):"#"+I(this.r)+I(this.g)+I(this.b)+I(Math.floor(255*this.a))}brighten(n){let{h:e,s:o,l:i}=this._hsl,t=T(0,i+n*(1-i),1);return a.fromHsl(e,o,t,this.a)}darken(n){let{h:e,s:o,l:i}=this._hsl,t=T(0,i*(1-n),1);return a.fromHsl(e,o,t,this.a)}saturate(n){let{h:e,s:o,l:i}=this._hsl,t=T(0,o+n*(1-o),1);return a.fromHsl(e,t,i,this.a)}desaturate(n){let{h:e,s:o,l:i}=this._hsl,t=T(0,o*(1-n),1);return a.fromHsl(e,t,i,this.a)}rotate(n){let{h:e,s:o,l:i}=this._hsl,t=(e+360+n)%360;return a.fromHsl(t,o,i,this.a)}opacity(n){let{h:e,s:o,l:i}=this._hsl;return a.fromHsl(e,o,i,n)}swatch(){return console.log(`%c %c ${this.html}, ${this.rgba}`,`background-color: ${this.html}`,"background-color: transparent"),this}blend(n,e){return new a(F(this.r,n.r,e),F(this.g,n.g,e),F(this.b,n.b,e),F(this.a,n.a,e))}static blendHue(n,e,o){let i=(e-n+720)%360;if(i<180)return n+o*i;else return n-(360-i)*o}mix(n,e){let o=this._hsl,i=n._hsl;return a.fromHsl(o.s===0?i.h:i.s===0?o.h:a.blendHue(o.h,i.h,e),F(o.s,i.s,e),F(o.l,i.l,e),F(this.a,n.a,e))}colorMix(n,e){return a.fromCss(`color-mix(in hsl, ${this.html}, ${n.html} ${(e*100).toFixed(0)}%)`)}}function X(n){return n.replace(/[A-Z]/g,(e)=>{return`-${e.toLocaleLowerCase()}`})}function he(n){return n.replace(/-([a-z])/g,(e,o)=>{return o.toLocaleUpperCase()})}var no="http://www.w3.org/1998/Math/MathML",eo="http://www.w3.org/2000/svg",pn={},be=(n,e,o)=>{let i=Wn(X(e),o);if(i.prop.startsWith("--"))n.style.setProperty(i.prop,i.value);else n.style[e]=i.value},oo=(n)=>{return{toDOM(e,o){be(e,n,o)}}},we=(n,e,o)=>{if(e==="style")if(typeof o==="object")for(let i of Object.keys(o))if(C(o[i]))b(n,o[i],oo(i));else be(n,i,o[i]);else n.setAttribute("style",o);else if(n[e]!==void 0){let{MathMLElement:i}=globalThis;if(n instanceof SVGElement||i!==void 0&&n instanceof i)n.setAttribute(e,o);else n[e]=o}else{let i=X(e);if(i==="class")o.split(" ").forEach((t)=>{n.classList.add(t)});else if(n[i]!==void 0)n[i]=o;else if(typeof o==="boolean")o?n.setAttribute(i,""):n.removeAttribute(i);else n.setAttribute(i,o)}},io=(n)=>{return{toDOM(e,o){we(e,n,o)}}},to=(n,e,o)=>{if(e==="apply")o(n);else if(e.match(/^on[A-Z]/)!=null){let i=e.substring(2).toLowerCase();$(n,i,o)}else if(e==="bind")if((typeof o.binding==="string"?R[o.binding]:o.binding)!==void 0&&o.value!==void 0)b(n,o.value,o.binding instanceof Function?{toDOM:o.binding}:o.binding);else throw Error("bad binding");else if(e.match(/^bind[A-Z]/)!=null){let i=e.substring(4,5).toLowerCase()+e.substring(5),t=R[i];if(t!==void 0)b(n,o,t);else throw Error(`${e} is not allowed, bindings.${i} is not defined`)}else if(C(o))b(n,o,io(e));else we(n,e,o)},Pn=(n,...e)=>{if(pn[n]===void 0){let[t,s]=n.split("|");if(s===void 0)pn[n]=globalThis.document.createElement(t);else pn[n]=globalThis.document.createElementNS(s,t)}let o=pn[n].cloneNode(),i={};for(let t of e)if(t instanceof Element||t instanceof DocumentFragment||typeof t==="string"||typeof t==="number")if(o instanceof HTMLTemplateElement)o.content.append(t);else o.append(t);else if(C(t))o.append(y.span({bindText:t}));else Object.assign(i,t);for(let t of Object.keys(i)){let s=i[t];to(o,t,s)}return o},jn=(...n)=>{let e=globalThis.document.createDocumentFragment();for(let o of n)e.append(o);return e},y=new Proxy({fragment:jn},{get(n,e){if(e=e.replace(/[A-Z]/g,(o)=>`-${o.toLocaleLowerCase()}`),n[e]===void 0)n[e]=(...o)=>Pn(e,...o);return n[e]},set(){throw Error("You may not add new properties to elements")}}),yn=new Proxy({fragment:jn},{get(n,e){if(n[e]===void 0)n[e]=(...o)=>Pn(`${e}|${eo}`,...o);return n[e]},set(){throw Error("You may not add new properties to elements")}}),mn=new Proxy({fragment:jn},{get(n,e){if(n[e]===void 0)n[e]=(...o)=>Pn(`${e}|${no}`,...o);return n[e]},set(){throw Error("You may not add new properties to elements")}});function ge(n,e){let o=y.style(Y(e));o.id=n,document.head.append(o)}var ro=["animation-iteration-count","flex","flex-base","flex-grow","flex-shrink","opacity","order","tab-size","widows","z-index","zoom"],Wn=(n,e)=>{if(typeof e==="number"&&!ro.includes(n))e=`${e}px`;if(n.startsWith("_"))if(n.startsWith("__"))n="--"+n.substring(2),e=`var(${n}-default, ${e})`;else n="--"+n.substring(1);return{prop:n,value:String(e)}},so=(n,e,o)=>{if(o===void 0)return"";if(o instanceof a)o=o.html;let i=Wn(e,o);return`${n} ${i.prop}: ${i.value};`},Te=(n,e,o="")=>{let i=X(n);if(typeof e==="object"&&!(e instanceof a)){let t=Object.keys(e).map((s)=>Te(s,e[s],`${o} `)).join(`
1
+ var{defineProperty:Xn,getOwnPropertyNames:De,getOwnPropertyDescriptor:Fe}=Object,Le=Object.prototype.hasOwnProperty;var Un=new WeakMap,Be=(n)=>{var e=Un.get(n),o;if(e)return e;if(e=Xn({},"__esModule",{value:!0}),n&&typeof n==="object"||typeof n==="function")De(n).map((i)=>!Le.call(e,i)&&Xn(e,i,{get:()=>n[i],enumerable:!(o=Fe(n,i))||o.enumerable}));return Un.set(n,e),e};var He=(n,e)=>{for(var o in e)Xn(n,o,{get:e[o],enumerable:!0,configurable:!0,set:(i)=>e[o]=()=>i})};var po={};He(po,{xinValue:()=>h,xinProxy:()=>bn,xinPath:()=>C,xin:()=>f,version:()=>hn,vars:()=>xn,varDefault:()=>N,updates:()=>Dn,unobserve:()=>J,touchElement:()=>fn,touch:()=>P,tosi:()=>Jn,throttle:()=>Q,svgElements:()=>yn,settings:()=>B,on:()=>$,observe:()=>_,mathML:()=>mn,makeComponent:()=>on,invertLuminance:()=>Se,initVars:()=>Xe,hotReload:()=>ke,getListItem:()=>sn,getCssVar:()=>un,elements:()=>y,debounce:()=>an,css:()=>Y,boxedProxy:()=>en,boxed:()=>W,blueprintLoader:()=>ve,blueprint:()=>Ce,bindings:()=>R,bind:()=>b,StyleSheet:()=>ge,MoreMath:()=>me,Component:()=>L,Color:()=>a,BlueprintLoader:()=>wn,Blueprint:()=>tn});module.exports=Be(po);var B={debug:!1,perf:!1};function v(n){if(n==null||typeof n!=="object")return n;if(n instanceof Set)return new Set(n);else if(Array.isArray(n))return n.map(v);let e={};for(let o in n){let i=n[o];if(n!=null&&typeof n==="object")e[o]=v(i);else e[o]=i}return e}var Sn="-xin-data",H=`.${Sn}`,En="-xin-event",kn=`.${En}`,g="xinPath",z="xinValue",_n="xinSet",Gn="xinObserve",Zn="xinBind",qn="xinOn",C=(n)=>{return n&&n[g]||void 0};function h(n){return typeof n==="object"&&n!==null?n[z]||n:n}var O=new WeakMap,M=new WeakMap;var A=(n)=>{let e=n.cloneNode();if(e instanceof Element){let o=M.get(n),i=O.get(n);if(o!=null)M.set(e,v(o));if(i!=null)O.set(e,v(i))}for(let o of Array.from(n instanceof HTMLTemplateElement?n.content.childNodes:n.childNodes))if(o instanceof Element||o instanceof DocumentFragment)e.appendChild(A(o));else e.appendChild(o.cloneNode());return e},Z=new WeakMap,sn=(n)=>{let e=document.body.parentElement;while(n.parentElement!=null&&n.parentElement!==e){let o=Z.get(n);if(o!=null)return o;n=n.parentElement}return!1};var Qn=Symbol("observer should be removed"),cn=[],dn=[],Cn=!1,vn,Mn;class Kn{description;test;callback;constructor(n,e){let o=typeof e==="string"?`"${e}"`:`function ${e.name}`,i;if(typeof n==="string")this.test=(t)=>typeof t==="string"&&t!==""&&(n.startsWith(t)||t.startsWith(n)),i=`test = "${n}"`;else if(n instanceof RegExp)this.test=n.test.bind(n),i=`test = "${n.toString()}"`;else if(n instanceof Function)this.test=n,i=`test = function ${n.name}`;else throw Error("expect listener test to be a string, RegExp, or test function");if(this.description=`${i}, ${o}`,typeof e==="function")this.callback=e;else throw Error("expect callback to be a path or function");cn.push(this)}}var Dn=async()=>{if(vn===void 0)return;await vn},$e=()=>{if(B.perf)console.time("xin async update");let n=Array.from(dn);for(let e of n)cn.filter((o)=>{let i;try{i=o.test(e)}catch(t){throw Error(`Listener ${o.description} threw "${t}" at "${e}"`)}if(i===Qn)return J(o),!1;return i}).forEach((o)=>{let i;try{i=o.callback(e)}catch(t){console.error(`Listener ${o.description} threw "${t}" handling "${e}"`)}if(i===Qn)J(o)});if(dn.splice(0),Cn=!1,typeof Mn==="function")Mn();if(B.perf)console.timeEnd("xin async update")},P=(n)=>{let e=typeof n==="string"?n:C(n);if(e===void 0)throw console.error("touch was called on an invalid target",n),Error("touch was called on an invalid target");if(Cn===!1)vn=new Promise((o)=>{Mn=o}),Cn=setTimeout($e);if(dn.find((o)=>e.startsWith(o))==null)dn.push(e)},Fn=(n,e)=>{return new Kn(n,e)},J=(n)=>{let e=cn.indexOf(n);if(e>-1)cn.splice(e,1);else throw Error("unobserve failed, listener not found")};var Oe=(n)=>{try{return JSON.stringify(n)}catch(e){return"{has circular references}"}},Ln=(...n)=>Error(n.map(Oe).join(" "));var ze=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),Ae=0,Pe=()=>(parseInt("10000",36)+ ++Ae).toString(36).slice(-5),je=()=>ze()+Pe(),Hn=Symbol("delete"),ne=Symbol("new-object"),Bn=Symbol("automatic-index");function ee(n){if(n==="")return[];if(Array.isArray(n))return n;else{let e=[];while(n.length>0){let o=n.search(/\[[^\]]+\]/);if(o===-1){e.push(n.split("."));break}else{let i=n.slice(0,o);if(n=n.slice(o),i!=="")e.push(i.split("."));if(o=n.indexOf("]")+1,e.push(n.slice(1,o-1)),n.slice(o,o+1)===".")o+=1;n=n.slice(o)}}return e}}var D=new WeakMap;function oe(n,e){if(D.get(n)===void 0)D.set(n,{});if(D.get(n)[e]===void 0)D.get(n)[e]={};let o=D.get(n)[e];if(e==="_auto_")n.forEach((i,t)=>{if(i[Bn]===void 0)i[Bn]=je();o[i[Bn]+""]=t});else n.forEach((i,t)=>{o[V(i,e)+""]=t});return o}function We(n,e){if(D.get(n)===void 0||D.get(n)[e]===void 0)return oe(n,e);else return D.get(n)[e]}function Ie(n,e,o){o=o+"";let i=We(n,e)[o];if(i===void 0||V(n[i],e)+""!==o)i=oe(n,e)[o];return i}function Ye(n,e,o){if(n[e]===void 0&&o!==void 0)n[e]=o;return n[e]}function ie(n,e,o,i){let t=e!==""?Ie(n,e,o):o;if(i===Hn)return n.splice(t,1),D.delete(n),Symbol("deleted");else if(i===ne){if(e===""&&n[t]===void 0)n[t]={}}else if(i!==void 0)if(t!==void 0)n[t]=i;else if(e!==""&&V(i,e)+""===o+"")n.push(i),t=n.length-1;else throw Error(`byIdPath insert failed at [${e}=${o}]`);return n[t]}function Rn(n){if(!Array.isArray(n))throw Ln("setByPath failed: expected array, found",n)}function Nn(n){if(n==null||!(n instanceof Object))throw Ln("setByPath failed: expected Object, found",n)}function V(n,e){let o=ee(e),i=n,t,s,r,c;for(t=0,s=o.length;i!==void 0&&t<s;t++){let d=o[t];if(Array.isArray(d))for(r=0,c=d.length;i!==void 0&&r<c;r++){let l=d[r];i=i[l]}else if(i.length===0){if(i=i[Number(d.slice(1))],d[0]!=="=")return}else if(d.includes("=")){let[l,...p]=d.split("=");i=ie(i,l,p.join("="))}else r=parseInt(d,10),i=i[r]}return i}function te(n,e,o){let i=n;if(e==="")throw Error("setByPath cannot be used to set the root object");let t=ee(e);while(i!=null&&t.length>0){let s=t.shift();if(typeof s==="string"){let r=s.indexOf("=");if(r>-1){if(r===0)Nn(i);else Rn(i);let c=s.slice(0,r),d=s.slice(r+1);if(i=ie(i,c,d,t.length>0?ne:o),t.length===0)return!0}else{Rn(i);let c=parseInt(s,10);if(t.length>0)i=i[c];else{if(o!==Hn){if(i[c]===o)return!1;i[c]=o}else i.splice(c,1);return!0}}}else if(Array.isArray(s)&&s.length>0){Nn(i);while(s.length>0){let r=s.shift();if(s.length>0||t.length>0)i=Ye(i,r,s.length>0?{}:[]);else{if(o!==Hn){if(i[r]===o)return!1;i[r]=o}else{if(!Object.prototype.hasOwnProperty.call(i,r))return!1;delete i[r]}return!0}}}else throw Error(`setByPath failed, bad path ${e}`)}throw Error(`setByPath(${n}, ${e}, ${o}) failed`)}var Je=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],On={},Ve=!0,Ue=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,_e=(n)=>Ue.test(n),j=(n="",e="")=>{if(n==="")return e;else if(e.match(/^\d+$/)!==null||e.includes("="))return`${n}[${e}]`;else return`${n}.${e}`},Ge={string(n){return new String(n)},boolean(n){return new Boolean(n)},bigint(n){return n},symbol(n){return n},number(n){return new Number(n)}};function $n(n,e){let o=typeof n;if(n===void 0||o==="object"||o==="function")return n;else return new Proxy(Ge[typeof n](n),U(e,!0))}var U=(n,e)=>({get(o,i){switch(i){case g:return n;case z:return o.valueOf?o.valueOf():o;case _n:return(r)=>f[n]=r;case Gn:return(r)=>{let c=Fn(n,r);return()=>J(c)};case qn:return(r,c)=>$(r,c,h(o));case Zn:return(r,c,d)=>{b(r,n,c,d)}}if(typeof i==="symbol")return o[i];let t=i,s=t.match(/^([^.[]+)\.(.+)$/)??t.match(/^([^\]]+)(\[.+)/)??t.match(/^(\[[^\]]+\])\.(.+)$/)??t.match(/^(\[[^\]]+\])\[(.+)$/);if(s!==null){let[,r,c]=s,d=j(n,r),l=V(o,r);return l!==null&&typeof l==="object"?new Proxy(l,U(d,e))[c]:l}if(t.startsWith("[")&&t.endsWith("]"))t=t.substring(1,t.length-1);if(!Array.isArray(o)&&o[t]!==void 0||Array.isArray(o)&&t.includes("=")){let r;if(t.includes("=")){let[c,d]=t.split("=");r=o.find((l)=>`${V(l,c)}`===d)}else r=o[t];if(r instanceof Object){let c=j(n,t);return new Proxy(r instanceof Function?r.bind(o):r,U(c,e))}else return e?$n(r,j(n,t)):r}else if(Array.isArray(o)){let r=o[t];return typeof r==="function"?(...c)=>{let d=r.apply(o,c);if(Je.includes(t))P(n);return d}:typeof r==="object"?new Proxy(r,U(j(n,t),e)):e?$n(r,j(n,t)):r}else return e?$n(o[t],j(n,t)):o[t]},set(o,i,t){t=h(t);let s=i!==z?j(n,i):n;if(Ve&&!_e(s))throw Error(`setting invalid path ${s}`);if(h(f[s])!==t&&te(On,s,t))P(s);return!0}}),_=(n,e)=>{let o=typeof e==="function"?e:f[e];if(typeof o!=="function")throw Error(`observe expects a function or path to a function, ${e} is neither`);return Fn(n,o)},f=new Proxy(On,U("",!1)),W=new Proxy(On,U("",!0));var zn=(n,e)=>{let o=new Event(e);n.dispatchEvent(o)},se=(n)=>{if(n instanceof HTMLInputElement)return n.type;else if(n instanceof HTMLSelectElement&&n.hasAttribute("multiple"))return"multi-select";else return"other"},ce=(n,e)=>{switch(se(n)){case"radio":n.checked=n.value===e;break;case"checkbox":n.checked=!!e;break;case"date":n.valueAsDate=new Date(e);break;case"multi-select":for(let o of Array.from(n.querySelectorAll("option")))o.selected=e[o.value];break;default:n.value=e}},de=(n)=>{switch(se(n)){case"radio":{let e=n.parentElement?.querySelector(`[name="${n.name}"]:checked`);return e!=null?e.value:null}case"checkbox":return n.checked;case"date":return n.valueAsDate?.toISOString();case"multi-select":return Array.from(n.querySelectorAll("option")).reduce((e,o)=>{return e[o.value]=o.selected,e},{});default:return n.value}},{ResizeObserver:re}=globalThis,q=re!=null?new re((n)=>{for(let e of n){let o=e.target;zn(o,"resize")}}):{observe(){},unobserve(){}},An=(n,e,o=!0)=>{if(n!=null&&e!=null)if(typeof e==="string")n.textContent=e;else if(Array.isArray(e))e.forEach((i)=>{n.append(i instanceof Node&&o?A(i):i)});else if(e instanceof Node)n.append(o?A(e):e);else throw Error("expect text content or document node")};var an=(n,e=250)=>{let o;return(...i)=>{if(o!==void 0)clearTimeout(o);o=setTimeout(()=>{n(...i)},e)}},Q=(n,e=250)=>{let o,i=Date.now()-e,t=!1;return(...s)=>{if(clearTimeout(o),o=setTimeout(()=>{n(...s),i=Date.now()},e),!t&&Date.now()-i>=e){t=!0;try{n(...s),i=Date.now()}finally{t=!1}}}};var ln=Symbol("list-binding"),Ze=16,qe=100;function ae(n,e){let o=Array.from(n.querySelectorAll(H));if(n.matches(H))o.unshift(n);for(let i of o){let t=M.get(i);for(let s of t){if(s.path.startsWith("^"))s.path=`${e}${s.path.substring(1)}`;if(s.binding.toDOM!=null)s.binding.toDOM(i,f[s.path])}}}class le{boundElement;listTop;listBottom;template;options;itemToElement;_array=[];_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(n,e,o={}){if(this.boundElement=n,this.itemToElement=new WeakMap,n.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(n.children[0]instanceof HTMLTemplateElement){let i=n.children[0];if(i.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=A(i.content.children[0])}else this.template=n.children[0],this.template.remove();if(this.options=o,this.listTop=document.createElement("div"),this.listBottom=document.createElement("div"),this.listTop.classList.add("virtual-list-padding"),this.listBottom.classList.add("virtual-list-padding"),this.boundElement.append(this.listTop),this.boundElement.append(this.listBottom),o.virtual!=null)q.observe(this.boundElement),this._update=Q(()=>{this.update(this._array,!0)},Ze),this.boundElement.addEventListener("scroll",this._update),this.boundElement.addEventListener("resize",this._update)}visibleSlice(){let{virtual:n,hiddenProp:e,visibleProp:o}=this.options,i=this._array;if(e!==void 0)i=i.filter((d)=>d[e]!==!0);if(o!==void 0)i=i.filter((d)=>d[o]===!0);if(this.options.filter&&this.needle!==void 0)i=this.options.filter(i,this.needle);let t=0,s=i.length-1,r=0,c=0;if(n!=null&&this.boundElement instanceof HTMLElement){let d=this.boundElement.offsetWidth,l=this.boundElement.offsetHeight;if(n.visibleColumns==null)n.visibleColumns=n.width!=null?Math.max(1,Math.floor(d/n.width)):1;let p=Math.ceil(l/n.height)+(n.rowChunkSize||1),S=Math.ceil(i.length/n.visibleColumns),E=n.visibleColumns*p,m=Math.floor(this.boundElement.scrollTop/n.height);if(m>S-p+1)m=Math.max(0,S-p+1);if(n.rowChunkSize)m-=m%n.rowChunkSize;t=m*n.visibleColumns,s=t+E-1,r=m*n.height,c=Math.max((S-p)*n.height-r,0)}return{items:i,firstItem:t,lastItem:s,topBuffer:r,bottomBuffer:c}}needle;filter=Q((n)=>{if(this.needle!==n)this.needle=n,this.update(this._array)},qe);update(n,e){if(n==null)n=[];this._array=n;let{hiddenProp:o,visibleProp:i}=this.options,t=C(n),s=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",s.items.length===0);let r=this._previousSlice,{firstItem:c,lastItem:d,topBuffer:l,bottomBuffer:p}=s;if(o===void 0&&i===void 0&&e===!0&&r!=null&&c===r.firstItem&&d===r.lastItem)return;this._previousSlice=s;let S=0,E=0,m=0;for(let u of Array.from(this.boundElement.children)){if(u===this.listTop||u===this.listBottom)continue;let k=Z.get(u);if(k==null)u.remove();else{let w=s.items.indexOf(k);if(w<c||w>d)u.remove(),this.itemToElement.delete(k),Z.delete(u),S++}}this.listTop.style.height=String(l)+"px",this.listBottom.style.height=String(p)+"px";let x=[],{idPath:gn}=this.options;for(let u=c;u<=d;u++){let k=s.items[u];if(k===void 0)continue;let w=this.itemToElement.get(h(k));if(w==null){if(m++,w=A(this.template),typeof k==="object")this.itemToElement.set(h(k),w),Z.set(w,h(k));if(this.boundElement.insertBefore(w,this.listBottom),gn!=null){let Tn=k[gn],Me=`${t}[${gn}=${Tn}]`;ae(w,Me)}else{let Tn=`${t}[${u}]`;ae(w,Tn)}}x.push(w)}let rn=null;for(let u of x){if(u.previousElementSibling!==rn)if(E++,rn?.nextElementSibling!=null)this.boundElement.insertBefore(u,rn.nextElementSibling);else this.boundElement.insertBefore(u,this.listBottom);rn=u}if(B.perf)console.log(t,"updated",{removed:S,created:m,moved:E})}}var fe=(n,e,o)=>{let i=n[ln];if(i===void 0)i=new le(n,e,o),n[ln]=i;return i};var{document:K,MutationObserver:ue}=globalThis,fn=(n,e)=>{let o=M.get(n);if(o==null)return;for(let i of o){let{binding:t,options:s}=i,{path:r}=i,{toDOM:c}=t;if(c!=null){if(r.startsWith("^")){let d=sn(n);if(d!=null&&d[g]!=null)r=i.path=`${d[g]}${r.substring(1)}`;else throw console.error(`Cannot resolve relative binding ${r}`,n,"is not part of a list"),Error(`Cannot resolve relative binding ${r}`)}if(e==null||r.startsWith(e))c(n,f[r],s)}}};if(ue!=null)new ue((e)=>{e.forEach((o)=>{Array.from(o.addedNodes).forEach((i)=>{if(i instanceof Element)Array.from(i.querySelectorAll(H)).forEach((t)=>fn(t))})})}).observe(K.body,{subtree:!0,childList:!0});_(()=>!0,(n)=>{let e=Array.from(K.querySelectorAll(H));for(let o of e)fn(o,n)});var pe=(n)=>{let e=n.target.closest(H);while(e!=null){let o=M.get(e);for(let i of o){let{binding:t,path:s}=i,{fromDOM:r}=t;if(r!=null){let c;try{c=r(e,i.options)}catch(d){throw console.error("Cannot get value from",e,"via",i),Error("Cannot obtain value fromDOM")}if(c!=null){let d=f[s];if(d==null)f[s]=c;else{let l=d[g]!=null?d[z]:d,p=c[g]!=null?c[z]:c;if(l!==p)f[s]=p}}}}e=e.parentElement.closest(H)}};if(globalThis.document!=null)K.body.addEventListener("change",pe,!0),K.body.addEventListener("input",pe,!0);function b(n,e,o,i){if(n instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let t;if(typeof e==="object"&&e[g]===void 0&&i===void 0){let{value:c}=e;t=typeof c==="string"?c:c[g],i=e,delete i.value}else t=typeof e==="string"?e:e[g];if(t==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:s}=o;n.classList?.add(Sn);let r=M.get(n);if(r==null)r=[],M.set(n,r);if(r.push({path:t,binding:o,options:i}),s!=null&&!t.startsWith("^"))P(t);if(i?.filter&&i?.needle)b(n,i.needle,{toDOM(c,d){console.log({needle:d}),c[ln]?.filter(d)}});return n}var ye=new Set,Qe=(n)=>{let e=n?.target.closest(kn),o=!1,i=new Proxy(n,{get(s,r){if(r==="stopPropagation")return()=>{n.stopPropagation(),o=!0};else{let c=s[r];return typeof c==="function"?c.bind(s):c}}}),t=new Set;while(!o&&e!=null){let r=O.get(e)[n.type]||t;for(let c of r){if(typeof c==="function")c(i);else{let d=f[c];if(typeof d==="function")d(i);else throw Error(`no event handler found at path ${c}`)}if(o)continue}e=e.parentElement!=null?e.parentElement.closest(kn):null}};function $(n,e,o){let i=O.get(n);if(n.classList.add(En),i==null)i={},O.set(n,i);if(!i[e])i[e]=new Set;if(i[e].add(o),!ye.has(e))ye.add(e),K.body.addEventListener(e,Qe,!0);return()=>{i[e].delete(o)}}var R={value:{toDOM:ce,fromDOM(n){return de(n)}},text:{toDOM(n,e){n.textContent=e}},enabled:{toDOM(n,e){n.disabled=!e}},disabled:{toDOM(n,e){n.disabled=Boolean(e)}},list:{toDOM(n,e,o){fe(n,e,o).update(e)}}};var Ke=180/Math.PI,Re=Math.PI/180;function T(n,e,o){return o<n?NaN:e<n?n:e>o?o:e}function F(n,e,o,i=!0){if(i)o=T(0,o,1);return o*(e-n)+n}var me={RADIANS_TO_DEGREES:Ke,DEGREES_TO_RADIANS:Re,clamp:T,lerp:F};function un(n,e=document.body){let o=getComputedStyle(e);if(n.endsWith(")")&&n.startsWith("var("))n=n.slice(4,-1);return o.getPropertyValue(n).trim()}var Ne=(n,e,o)=>{return(0.299*n+0.587*e+0.114*o)/255},I=(n)=>("00"+Math.round(Number(n)).toString(16)).slice(-2);class xe{h;s;l;constructor(n,e,o){n/=255,e/=255,o/=255;let i=Math.max(n,e,o),t=i-Math.min(n,e,o),s=t!==0?i===n?(e-o)/t:i===e?2+(o-n)/t:4+(n-e)/t:0;this.h=60*s<0?60*s+360:60*s,this.s=t!==0?i<=0.5?t/(2*i-t):t/(2-(2*i-t)):0,this.l=(2*i-t)/2}}var G=globalThis.document!==void 0?globalThis.document.createElement("span"):void 0;class a{r;g;b;a;static fromVar(n,e=document.body){return a.fromCss(un(n,e))}static fromCss(n){let e=n;if(G instanceof HTMLSpanElement)G.style.color="black",G.style.color=n,document.body.appendChild(G),e=getComputedStyle(G).color,G.remove();let[o,i,t,s]=e.match(/[\d.]+/g)||["0","0","0","0"],r=e.startsWith("color(srgb")?255:1;return new a(Number(o)*r,Number(i)*r,Number(t)*r,s==null?1:Number(s))}static fromHsl(n,e,o,i=1){let t,s,r;if(e===0)t=s=r=o;else{let d=(E,m,x)=>{if(x<0)x+=1;if(x>1)x-=1;if(x<0.16666666666666666)return E+(m-E)*6*x;if(x<0.5)return m;if(x<0.6666666666666666)return E+(m-E)*(0.6666666666666666-x)*6;return E},l=o<0.5?o*(1+e):o+e-o*e,p=2*o-l,S=(n%360+360)%360/360;t=d(p,l,S+0.3333333333333333),s=d(p,l,S),r=d(p,l,S-0.3333333333333333)}let c=new a(t*255,s*255,r*255,i);return c.hslCached={h:(n%360+360)%360,s:e,l:o},c}static black=new a(0,0,0);static white=new a(255,255,255);constructor(n,e,o,i=1){this.r=T(0,n,255),this.g=T(0,e,255),this.b=T(0,o,255),this.a=T(0,i,1)}get inverse(){return new a(255-this.r,255-this.g,255-this.b,this.a)}get inverseLuminance(){let{h:n,s:e,l:o}=this._hsl;return a.fromHsl(n,e,1-o,this.a)}get opaque(){return this.a===1?this:new a(this.r,this.g,this.b,1)}contrasting(n=1){return this.opaque.blend(this.brightness>0.5?a.black:a.white,n)}get rgb(){let{r:n,g:e,b:o}=this;return`rgb(${n.toFixed(0)},${e.toFixed(0)},${o.toFixed(0)})`}get rgba(){let{r:n,g:e,b:o,a:i}=this;return`rgba(${n.toFixed(0)},${e.toFixed(0)},${o.toFixed(0)},${i.toFixed(2)})`}get RGBA(){return[this.r/255,this.g/255,this.b/255,this.a]}get ARGB(){return[this.a,this.r/255,this.g/255,this.b/255]}hslCached;get _hsl(){if(this.hslCached==null)this.hslCached=new xe(this.r,this.g,this.b);return this.hslCached}get hsl(){let{h:n,s:e,l:o}=this._hsl;return`hsl(${n.toFixed(0)}deg ${(e*100).toFixed(0)}% ${(o*100).toFixed(0)}%)`}get hsla(){let{h:n,s:e,l:o}=this._hsl;return`hsl(${n.toFixed(0)}deg ${(e*100).toFixed(0)}% ${(o*100).toFixed(0)}% / ${(this.a*100).toFixed(0)}%)`}get mono(){let n=this.brightness*255;return new a(n,n,n)}get brightness(){return Ne(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+I(this.r)+I(this.g)+I(this.b):"#"+I(this.r)+I(this.g)+I(this.b)+I(Math.floor(255*this.a))}brighten(n){let{h:e,s:o,l:i}=this._hsl,t=T(0,i+n*(1-i),1);return a.fromHsl(e,o,t,this.a)}darken(n){let{h:e,s:o,l:i}=this._hsl,t=T(0,i*(1-n),1);return a.fromHsl(e,o,t,this.a)}saturate(n){let{h:e,s:o,l:i}=this._hsl,t=T(0,o+n*(1-o),1);return a.fromHsl(e,t,i,this.a)}desaturate(n){let{h:e,s:o,l:i}=this._hsl,t=T(0,o*(1-n),1);return a.fromHsl(e,t,i,this.a)}rotate(n){let{h:e,s:o,l:i}=this._hsl,t=(e+360+n)%360;return a.fromHsl(t,o,i,this.a)}opacity(n){let{h:e,s:o,l:i}=this._hsl;return a.fromHsl(e,o,i,n)}swatch(){return console.log(`%c %c ${this.html}, ${this.rgba}`,`background-color: ${this.html}`,"background-color: transparent"),this}blend(n,e){return new a(F(this.r,n.r,e),F(this.g,n.g,e),F(this.b,n.b,e),F(this.a,n.a,e))}static blendHue(n,e,o){let i=(e-n+720)%360;if(i<180)return n+o*i;else return n-(360-i)*o}mix(n,e){let o=this._hsl,i=n._hsl;return a.fromHsl(o.s===0?i.h:i.s===0?o.h:a.blendHue(o.h,i.h,e),F(o.s,i.s,e),F(o.l,i.l,e),F(this.a,n.a,e))}colorMix(n,e){return a.fromCss(`color-mix(in hsl, ${this.html}, ${n.html} ${(e*100).toFixed(0)}%)`)}}function X(n){return n.replace(/[A-Z]/g,(e)=>{return`-${e.toLocaleLowerCase()}`})}function he(n){return n.replace(/-([a-z])/g,(e,o)=>{return o.toLocaleUpperCase()})}var no="http://www.w3.org/1998/Math/MathML",eo="http://www.w3.org/2000/svg",pn={},be=(n,e,o)=>{let i=Wn(X(e),o);if(i.prop.startsWith("--"))n.style.setProperty(i.prop,i.value);else n.style[e]=i.value},oo=(n)=>{return{toDOM(e,o){be(e,n,o)}}},we=(n,e,o)=>{if(e==="style")if(typeof o==="object")for(let i of Object.keys(o))if(C(o[i]))b(n,o[i],oo(i));else be(n,i,o[i]);else n.setAttribute("style",o);else if(n[e]!==void 0){let{MathMLElement:i}=globalThis;if(n instanceof SVGElement||i!==void 0&&n instanceof i)n.setAttribute(e,o);else n[e]=o}else{let i=X(e);if(i==="class")o.split(" ").forEach((t)=>{n.classList.add(t)});else if(n[i]!==void 0)n[i]=o;else if(typeof o==="boolean")o?n.setAttribute(i,""):n.removeAttribute(i);else n.setAttribute(i,o)}},io=(n)=>{return{toDOM(e,o){we(e,n,o)}}},to=(n,e,o)=>{if(e==="apply")o(n);else if(e.match(/^on[A-Z]/)!=null){let i=e.substring(2).toLowerCase();$(n,i,o)}else if(e==="bind")if((typeof o.binding==="string"?R[o.binding]:o.binding)!==void 0&&o.value!==void 0)b(n,o.value,o.binding instanceof Function?{toDOM:o.binding}:o.binding);else throw Error("bad binding");else if(e.match(/^bind[A-Z]/)!=null){let i=e.substring(4,5).toLowerCase()+e.substring(5),t=R[i];if(t!==void 0)b(n,o,t);else throw Error(`${e} is not allowed, bindings.${i} is not defined`)}else if(C(o))b(n,o,io(e));else we(n,e,o)},Pn=(n,...e)=>{if(pn[n]===void 0){let[t,s]=n.split("|");if(s===void 0)pn[n]=globalThis.document.createElement(t);else pn[n]=globalThis.document.createElementNS(s,t)}let o=pn[n].cloneNode(),i={};for(let t of e)if(t instanceof Element||t instanceof DocumentFragment||typeof t==="string"||typeof t==="number")if(o instanceof HTMLTemplateElement)o.content.append(t);else o.append(t);else if(C(t))o.append(y.span({bindText:t}));else Object.assign(i,t);for(let t of Object.keys(i)){let s=i[t];to(o,t,s)}return o},jn=(...n)=>{let e=globalThis.document.createDocumentFragment();for(let o of n)e.append(o);return e},y=new Proxy({fragment:jn},{get(n,e){if(e=e.replace(/[A-Z]/g,(o)=>`-${o.toLocaleLowerCase()}`),n[e]===void 0)n[e]=(...o)=>Pn(e,...o);return n[e]},set(){throw Error("You may not add new properties to elements")}}),yn=new Proxy({fragment:jn},{get(n,e){if(n[e]===void 0)n[e]=(...o)=>Pn(`${e}|${eo}`,...o);return n[e]},set(){throw Error("You may not add new properties to elements")}}),mn=new Proxy({fragment:jn},{get(n,e){if(n[e]===void 0)n[e]=(...o)=>Pn(`${e}|${no}`,...o);return n[e]},set(){throw Error("You may not add new properties to elements")}});function ge(n,e){let o=y.style(Y(e));o.id=n,document.head.append(o)}var ro=["animation-iteration-count","flex","flex-base","flex-grow","flex-shrink","opacity","order","tab-size","widows","z-index","zoom"],Wn=(n,e)=>{if(typeof e==="number"&&!ro.includes(n))e=`${e}px`;if(n.startsWith("_"))if(n.startsWith("__"))n="--"+n.substring(2),e=`var(${n}-default, ${e})`;else n="--"+n.substring(1);return{prop:n,value:String(e)}},so=(n,e,o)=>{if(o===void 0)return"";if(o instanceof a)o=o.html;let i=Wn(e,o);return`${n} ${i.prop}: ${i.value};`},Te=(n,e,o="")=>{let i=X(n);if(typeof e==="object"&&!(e instanceof a)){let t=Object.keys(e).map((s)=>Te(s,e[s],`${o} `)).join(`
2
2
  `);return`${o} ${n} {
3
3
  ${t}
4
4
  ${o} }`}else return so(o,i,e)},Y=(n,e="")=>{return Object.keys(n).map((i)=>{let t=n[i];if(typeof t==="string"){if(i==="@import")return`@import url('${t}');`;throw Error("top-level string value only allowed for `@import`")}let s=Object.keys(t).map((r)=>Te(r,t[r])).join(`
@@ -6,8 +6,8 @@ ${o} }`}else return so(o,i,e)},Y=(n,e="")=>{return Object.keys(n).map((i)=>{let
6
6
  ${s}
7
7
  }`}).join(`
8
8
 
9
- `)},Xe=(n)=>{console.warn("initVars is deprecated. Just use _ and __ prefixes instead.");let e={};for(let o of Object.keys(n)){let i=n[o],t=X(o);e[`--${t}`]=typeof i==="number"&&i!==0?String(i)+"px":i}return e},Ee=(n)=>{let e={};for(let o of Object.keys(n)){let i=n[o];if(i instanceof a)e[o]=i.inverseLuminance;else if(typeof i==="string"&&i.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))e[o]=a.fromCss(i).inverseLuminance}return e},N=new Proxy({},{get(n,e){if(n[e]===void 0){let o="--"+X(e);n[e]=(i)=>`var(${o}, ${i})`}return n[e]}}),xn=new Proxy({},{get(n,e){if(e==="default")return N;if(n[e]==null){e=X(e);let[,o,,i,t,s]=e.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",e],r=`--${o}`;if(t!=null){let c=i==null?Number(t)/100:-Number(t)/100;switch(s){case"b":{let d=a.fromVar(r);n[e]=c>0?d.brighten(c).rgba:d.darken(-c).rgba}break;case"s":{let d=a.fromVar(r);n[e]=c>0?d.saturate(c).rgba:d.desaturate(-c).rgba}break;case"h":{let d=a.fromVar(r);n[e]=d.rotate(c*100).rgba}break;case"o":{let d=a.fromVar(r);n[e]=d.opacity(c).rgba}break;case"":n[e]=`calc(var(${r}) * ${c})`;break;default:throw console.error(s),Error(`Unrecognized method ${s} for css variable ${r}`)}}else n[e]=`var(${r})`}return n[e]}});var co=0;function In(){return`custom-elt${(co++).toString(36)}`}var Se=0,nn={};function ao(n,e){let o=nn[n],i=Y(e).replace(/:host\b/g,n);nn[n]=o?o+`
10
- `+i:i}function lo(n){if(nn[n])document.head.append(y.style({id:n+"-component"},nn[n]));delete nn[n]}class L extends HTMLElement{static elements=y;static _elementCreator;instanceId;styleNode;static styleSpec;static styleNode;content=y.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}static StyleNode(n){return console.warn("StyleNode is deprecated, just assign static styleSpec: XinStyleSheet to the class directly"),y.style(Y(n))}static elementCreator(n={}){if(this._elementCreator==null){let{tag:e,styleSpec:o}=n,i=n!=null?e:null;if(i==null)if(typeof this.name==="string"&&this.name!==""){if(i=X(this.name),i.startsWith("-"))i=i.slice(1)}else i=In();if(customElements.get(i)!=null)console.warn(`${i} is already defined`);if(i.match(/\w+(-\w+)+/)==null)console.warn(`${i} is not a legal tag for a custom-element`),i=In();while(customElements.get(i)!==void 0)i=In();if(this._tagName=i,o!==void 0)ao(i,o);window.customElements.define(i,this,n),this._elementCreator=y[i]}return this._elementCreator}initAttributes(...n){let e={},o={};new MutationObserver((t)=>{let s=!1;if(t.forEach((r)=>{s=!!(r.attributeName&&n.includes(he(r.attributeName)))}),s&&this.queueRender!==void 0)this.queueRender(!1)}).observe(this,{attributes:!0}),n.forEach((t)=>{e[t]=v(this[t]);let s=X(t);Object.defineProperty(this,t,{enumerable:!1,get(){if(typeof e[t]==="boolean")return this.hasAttribute(s);else if(this.hasAttribute(s))return typeof e[t]==="number"?parseFloat(this.getAttribute(s)):this.getAttribute(s);else if(o[t]!==void 0)return o[t];else return e[t]},set(r){if(typeof e[t]==="boolean"){if(r!==this[t]){if(r)this.setAttribute(s,"");else this.removeAttribute(s);this.queueRender()}}else if(typeof e[t]==="number"){if(r!==parseFloat(this[t]))this.setAttribute(s,r),this.queueRender()}else if(typeof r==="object"||`${r}`!==`${this[t]}`){if(r===null||r===void 0||typeof r==="object")this.removeAttribute(s);else this.setAttribute(s,r);this.queueRender(),o[t]=r}}})})}initValue(){let n=Object.getOwnPropertyDescriptor(this,"value");if(n===void 0||n.get!==void 0||n.set!==void 0)return;let e=this.hasAttribute("value")?this.getAttribute("value"):v(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return e},set(o){if(e!==o)e=o,this.queueRender(!0)}})}_parts;get parts(){let n=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(e,o){if(e[o]===void 0){let i=n.querySelector(`[part="${o}"]`);if(i==null)i=n.querySelector(o);if(i==null)throw Error(`elementRef "${o}" does not exist!`);i.removeAttribute("data-ref"),e[o]=i}return e[o]}});return this._parts}constructor(){super();Se+=1,this.initAttributes("hidden"),this.instanceId=`${this.tagName.toLocaleLowerCase()}-${Se}`,this._value=v(this.defaultValue)}connectedCallback(){if(lo(this.constructor.tagName),this.hydrate(),this.role!=null)this.setAttribute("role",this.role);if(this.onResize!==void 0){if(q.observe(this),this._onResize==null)this._onResize=this.onResize.bind(this);this.addEventListener("resize",this._onResize)}if(this.value!=null&&this.getAttribute("value")!=null)this._value=this.getAttribute("value");this.queueRender()}disconnectedCallback(){q.unobserve(this)}_changeQueued=!1;_renderQueued=!1;queueRender(n=!1){if(!this._hydrated)return;if(!this._changeQueued)this._changeQueued=n;if(!this._renderQueued)this._renderQueued=!0,requestAnimationFrame(()=>{if(this._changeQueued)zn(this,"change");this._changeQueued=!1,this._renderQueued=!1,this.render()})}_hydrated=!1;hydrate(){if(!this._hydrated){this.initValue();let n=typeof this.content!=="function",e=typeof this.content==="function"?this.content():this.content,{styleSpec:o}=this.constructor,{styleNode:i}=this.constructor;if(o)i=this.constructor.styleNode=y.style(Y(o)),delete this.constructor.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecrated, use static styleNode or statc styleSpec instead"),i=this.styleNode;if(i){let t=this.attachShadow({mode:"open"});t.appendChild(i.cloneNode(!0)),An(t,e,n)}else if(e!==null){let t=Array.from(this.childNodes);An(this,e,n),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let s=Array.from(this.querySelectorAll("slot"));if(s.length>0)s.forEach(Yn.replaceSlot);if(t.length>0){let r={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((c)=>{r[c.name]=c}),t.forEach((c)=>{let d=r[""],l=c instanceof Element?r[c.slot]:d;(l!==void 0?l:d).append(c)})}}this._hydrated=!0}}render(){}}class Yn extends L{name="";content=null;static replaceSlot(n){let e=document.createElement("xin-slot");if(n.name!=="")e.setAttribute("name",n.name);n.replaceWith(e)}constructor(){super();this.initAttributes("name")}}var gi=Yn.elementCreator({tag:"xin-slot"});var ke=(n=()=>!0)=>{let e=localStorage.getItem("xin-state");if(e!=null){let i=JSON.parse(e);for(let t of Object.keys(i).filter(n))if(f[t]!==void 0)Object.assign(f[t],i[t]);else f[t]=i[t]}let o=an(()=>{let i={},t=h(f);for(let s of Object.keys(t).filter(n))i[s]=t[s];localStorage.setItem("xin-state",JSON.stringify(i)),console.log("xin state saved to localStorage")},500);_(n,o)};var hn="1.0.6";function Jn(n){return Object.assign(W,n),W}function en(n){return console.warn("boxedProxy is deprecated, please use tosi() instead"),Jn(n)}function bn(n,e=!1){if(e)return console.warn("xinProxy(..., true) is deprecated; use tosi(...) instead"),en(n);return Object.keys(n).forEach((o)=>{f[o]=n[o]}),f}var fo={};async function on(n,e){let{type:o,styleSpec:i}=await e(n,{Color:a,Component:L,elements:y,svgElements:yn,mathML:mn,varDefault:N,vars:xn,xin:f,boxed:W,xinProxy:bn,boxedProxy:en,makeComponent:on,bind:b,on:$,version:hn}),t={type:o,creator:o.elementCreator({tag:n,styleSpec:i})};return fo[n]=t,t}var Vn={},uo=(n)=>import(n);class tn extends L{tag="anon-elt";src="";property="default";loaded;blueprintLoaded=(n)=>{};async packaged(){let{tag:n,src:e,property:o}=this,i=`${n}.${o}:${e}`;if(!this.loaded){if(Vn[i]===void 0)Vn[i]=uo(e).then((t)=>{let s=t[o];return on(n,s)});else console.log(`using cached ${n} with signature ${i}`);this.loaded=await Vn[i],this.blueprintLoaded(this.loaded)}return this.loaded}constructor(){super();this.initAttributes("tag","src","property")}}var Ce=tn.elementCreator({tag:"xin-blueprint",styleSpec:{":host":{display:"none"}}});class wn extends L{allLoaded=()=>{};constructor(){super()}async load(){let e=Array.from(this.querySelectorAll(tn.tagName)).filter((o)=>o.src).map((o)=>o.packaged());await Promise.all(e),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var ve=wn.elementCreator({tag:"xin-loader",styleSpec:{":host":{display:"none"}}});
9
+ `)},Xe=(n)=>{console.warn("initVars is deprecated. Just use _ and __ prefixes instead.");let e={};for(let o of Object.keys(n)){let i=n[o],t=X(o);e[`--${t}`]=typeof i==="number"&&i!==0?String(i)+"px":i}return e},Se=(n)=>{let e={};for(let o of Object.keys(n)){let i=n[o];if(i instanceof a)e[o]=i.inverseLuminance;else if(typeof i==="string"&&i.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))e[o]=a.fromCss(i).inverseLuminance}return e},N=new Proxy({},{get(n,e){if(n[e]===void 0){let o="--"+X(e);n[e]=(i)=>`var(${o}, ${i})`}return n[e]}}),xn=new Proxy({},{get(n,e){if(e==="default")return N;if(n[e]==null){e=X(e);let[,o,,i,t,s]=e.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",e],r=`--${o}`;if(t!=null){let c=i==null?Number(t)/100:-Number(t)/100;switch(s){case"b":{let d=a.fromVar(r);n[e]=c>0?d.brighten(c).rgba:d.darken(-c).rgba}break;case"s":{let d=a.fromVar(r);n[e]=c>0?d.saturate(c).rgba:d.desaturate(-c).rgba}break;case"h":{let d=a.fromVar(r);n[e]=d.rotate(c*100).rgba}break;case"o":{let d=a.fromVar(r);n[e]=d.opacity(c).rgba}break;case"":n[e]=`calc(var(${r}) * ${c})`;break;default:throw console.error(s),Error(`Unrecognized method ${s} for css variable ${r}`)}}else n[e]=`var(${r})`}return n[e]}});var co=0;function In(){return`custom-elt${(co++).toString(36)}`}var Ee=0,nn={};function ao(n,e){let o=nn[n],i=Y(e).replace(/:host\b/g,n);nn[n]=o?o+`
10
+ `+i:i}function lo(n){if(nn[n])document.head.append(y.style({id:n+"-component"},nn[n]));delete nn[n]}class L extends HTMLElement{static elements=y;static _elementCreator;instanceId;styleNode;static styleSpec;static styleNode;content=y.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}static StyleNode(n){return console.warn("StyleNode is deprecated, just assign static styleSpec: XinStyleSheet to the class directly"),y.style(Y(n))}static elementCreator(n={}){let e=this;if(e._elementCreator==null){let{tag:o,styleSpec:i}=n,t=n!=null?o:null;if(t==null)if(typeof e.name==="string"&&e.name!==""){if(t=X(e.name),t.startsWith("-"))t=t.slice(1)}else t=In();if(customElements.get(t)!=null)console.warn(`${t} is already defined`);if(t.match(/\w+(-\w+)+/)==null)console.warn(`${t} is not a legal tag for a custom-element`),t=In();while(customElements.get(t)!==void 0)t=In();if(e._tagName=t,i!==void 0)ao(t,i);window.customElements.define(t,this,n),e._elementCreator=y[t]}return e._elementCreator}initAttributes(...n){let e={},o={};new MutationObserver((t)=>{let s=!1;if(t.forEach((r)=>{s=!!(r.attributeName&&n.includes(he(r.attributeName)))}),s&&this.queueRender!==void 0)this.queueRender(!1)}).observe(this,{attributes:!0}),n.forEach((t)=>{e[t]=v(this[t]);let s=X(t);Object.defineProperty(this,t,{enumerable:!1,get(){if(typeof e[t]==="boolean")return this.hasAttribute(s);else if(this.hasAttribute(s))return typeof e[t]==="number"?parseFloat(this.getAttribute(s)):this.getAttribute(s);else if(o[t]!==void 0)return o[t];else return e[t]},set(r){if(typeof e[t]==="boolean"){if(r!==this[t]){if(r)this.setAttribute(s,"");else this.removeAttribute(s);this.queueRender()}}else if(typeof e[t]==="number"){if(r!==parseFloat(this[t]))this.setAttribute(s,r),this.queueRender()}else if(typeof r==="object"||`${r}`!==`${this[t]}`){if(r===null||r===void 0||typeof r==="object")this.removeAttribute(s);else this.setAttribute(s,r);this.queueRender(),o[t]=r}}})})}initValue(){let n=Object.getOwnPropertyDescriptor(this,"value");if(n===void 0||n.get!==void 0||n.set!==void 0)return;let e=this.hasAttribute("value")?this.getAttribute("value"):v(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return e},set(o){if(e!==o)e=o,this.queueRender(!0)}})}_parts;get parts(){let n=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(e,o){if(e[o]===void 0){let i=n.querySelector(`[part="${o}"]`);if(i==null)i=n.querySelector(o);if(i==null)throw Error(`elementRef "${o}" does not exist!`);i.removeAttribute("data-ref"),e[o]=i}return e[o]}});return this._parts}constructor(){super();Ee+=1,this.initAttributes("hidden"),this.instanceId=`${this.tagName.toLocaleLowerCase()}-${Ee}`,this._value=v(this.defaultValue)}connectedCallback(){if(lo(this.constructor.tagName),this.hydrate(),this.role!=null)this.setAttribute("role",this.role);if(this.onResize!==void 0){if(q.observe(this),this._onResize==null)this._onResize=this.onResize.bind(this);this.addEventListener("resize",this._onResize)}if(this.value!=null&&this.getAttribute("value")!=null)this._value=this.getAttribute("value");this.queueRender()}disconnectedCallback(){q.unobserve(this)}_changeQueued=!1;_renderQueued=!1;queueRender(n=!1){if(!this._hydrated)return;if(!this._changeQueued)this._changeQueued=n;if(!this._renderQueued)this._renderQueued=!0,requestAnimationFrame(()=>{if(this._changeQueued)zn(this,"change");this._changeQueued=!1,this._renderQueued=!1,this.render()})}_hydrated=!1;hydrate(){if(!this._hydrated){this.initValue();let n=typeof this.content!=="function",e=typeof this.content==="function"?this.content():this.content,{styleSpec:o}=this.constructor,{styleNode:i}=this.constructor;if(o)i=this.constructor.styleNode=y.style(Y(o)),delete this.constructor.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecrated, use static styleNode or statc styleSpec instead"),i=this.styleNode;if(i){let t=this.attachShadow({mode:"open"});t.appendChild(i.cloneNode(!0)),An(t,e,n)}else if(e!==null){let t=Array.from(this.childNodes);An(this,e,n),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let s=Array.from(this.querySelectorAll("slot"));if(s.length>0)s.forEach(Yn.replaceSlot);if(t.length>0){let r={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((c)=>{r[c.name]=c}),t.forEach((c)=>{let d=r[""],l=c instanceof Element?r[c.slot]:d;(l!==void 0?l:d).append(c)})}}this._hydrated=!0}}render(){}}class Yn extends L{name="";content=null;static replaceSlot(n){let e=document.createElement("xin-slot");if(n.name!=="")e.setAttribute("name",n.name);n.replaceWith(e)}constructor(){super();this.initAttributes("name")}}var gi=Yn.elementCreator({tag:"xin-slot"});var ke=(n=()=>!0)=>{let e=localStorage.getItem("xin-state");if(e!=null){let i=JSON.parse(e);for(let t of Object.keys(i).filter(n))if(f[t]!==void 0)Object.assign(f[t],i[t]);else f[t]=i[t]}let o=an(()=>{let i={},t=h(f);for(let s of Object.keys(t).filter(n))i[s]=t[s];localStorage.setItem("xin-state",JSON.stringify(i)),console.log("xin state saved to localStorage")},500);_(n,o)};var hn="1.0.8";function Jn(n){return Object.assign(W,n),W}function en(n){return console.warn("boxedProxy is deprecated, please use tosi() instead"),Jn(n)}function bn(n,e=!1){if(e)return console.warn("xinProxy(..., true) is deprecated; use tosi(...) instead"),en(n);return Object.keys(n).forEach((o)=>{f[o]=n[o]}),f}var fo={};async function on(n,e){let{type:o,styleSpec:i}=await e(n,{Color:a,Component:L,elements:y,svgElements:yn,mathML:mn,varDefault:N,vars:xn,xin:f,boxed:W,xinProxy:bn,boxedProxy:en,makeComponent:on,bind:b,on:$,version:hn}),t={type:o,creator:o.elementCreator({tag:n,styleSpec:i})};return fo[n]=t,t}var Vn={},uo=(n)=>import(n);class tn extends L{tag="anon-elt";src="";property="default";loaded;blueprintLoaded=(n)=>{};async packaged(){let{tag:n,src:e,property:o}=this,i=`${n}.${o}:${e}`;if(!this.loaded){if(Vn[i]===void 0)Vn[i]=uo(e).then((t)=>{let s=t[o];return on(n,s)});else console.log(`using cached ${n} with signature ${i}`);this.loaded=await Vn[i],this.blueprintLoaded(this.loaded)}return this.loaded}constructor(){super();this.initAttributes("tag","src","property")}}var Ce=tn.elementCreator({tag:"xin-blueprint",styleSpec:{":host":{display:"none"}}});class wn extends L{allLoaded=()=>{};constructor(){super()}async load(){let e=Array.from(this.querySelectorAll(tn.tagName)).filter((o)=>o.src).map((o)=>o.packaged());await Promise.all(e),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var ve=wn.elementCreator({tag:"xin-loader",styleSpec:{":host":{display:"none"}}});
11
11
 
12
- //# debugId=8676E5EB96D1E94064756E2164756E21
12
+ //# debugId=CF2215AB8694D4DF64756E2164756E21
13
13
  //# sourceMappingURL=main.js.map