@lipsjs/lips 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lips.js +12 -3
- package/dist/lips.js.map +3 -3
- package/dist/lips.min.js +7 -7
- package/dist/lips.min.js.map +3 -3
- package/dist/lynx.min.js +8 -8
- package/dist/lynx.min.js.map +5 -4
- package/dist/parts.min.js +7 -7
- package/dist/parts.min.js.map +3 -3
- package/dist/precompile.min.js +13 -13
- package/dist/precompile.min.js.map +5 -4
- package/dist/runtime.min.js +3 -3
- package/dist/runtime.min.js.map +3 -3
- package/dist/types/ir/facade.d.ts +9 -1
- package/dist/types/lynx/components.d.ts +3 -3
- package/dist/types/parts/combobox.d.ts +7 -0
- package/dist/types/plugins.d.ts +15 -0
- package/dist/types/precompile.d.ts +30 -1
- package/dist/types/types.d.ts +11 -0
- package/package.json +1 -1
package/dist/runtime.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var Zt=["===","!==","...","=>","==","!=","<=",">=","&&","||","??","?.","++","--","+=","-=","*=","/=","%=","+","-","*","/","%","<",">","!","?",":",".",",","(",")","[","]","{","}","="];function Qt(t,e){let n=[],r=0,i=(c)=>/[A-Za-z_$]/.test(c),a=(c)=>/[A-Za-z0-9_$]/.test(c);while(r<t.length){let c=t[r];if(/\s/.test(c)){r++;continue}if(/[0-9]/.test(c)||c==="."&&/[0-9]/.test(t[r+1])){let s=r;while(r<t.length&&/[0-9]/.test(t[r]))r++;if(t[r]==="."){r++;while(r<t.length&&/[0-9]/.test(t[r]))r++}if(t[r]==="e"||t[r]==="E"){if(r++,t[r]==="+"||t[r]==="-")r++;while(r<t.length&&/[0-9]/.test(t[r]))r++}n.push({t:"num",value:t.slice(s,r),start:s,end:r});continue}if(c==="'"||c==='"'){let s=r;r++;let l="",o=!1;while(r<t.length){let u=t[r];if(u==="\\"){let f=t[r+1],d={n:`
|
|
2
|
-
`,t:"\t",r:"\r",b:"\b",f:"\f",v:"\v","0":"\x00"};if(f==="u"){let h=t.slice(r+2,r+6);l+=String.fromCharCode(parseInt(h,16)||0),r+=6}else l+=d[f]??f,r+=2;continue}if(u===c){o=!0,r++;break}l+=u,r++}if(!o)e.push({code:"LIPS-E001",message:"Unterminated string literal",loc:{offset:s,length:r-s}});n.push({t:"str",value:l,start:s,end:r});continue}if(i(c)){let s=r;while(r<t.length&&a(t[r]))r++;n.push({t:"id",value:t.slice(s,r),start:s,end:r});continue}let p=Zt.find((s)=>t.startsWith(s,r));if(p==="?."&&/[0-9]/.test(t[r+2]??""))p="?";if(p){n.push({t:"punct",value:p,start:r,end:r+p.length}),r+=p.length;continue}e.push({code:"LIPS-E002",message:`Unexpected character '${c}'`,loc:{offset:r,length:1}}),r++}return n.push({t:"eof",value:"",start:t.length,end:t.length}),n}class Ct{tokens;diagnostics;pos=0;constructor(t,e){this.tokens=t;this.diagnostics=e}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}next(){return this.tokens[this.pos++]??this.tokens[this.tokens.length-1]}at(t){let e=this.peek();return e.t==="punct"&&e.value===t}eat(t){if(this.at(t))return this.pos++,!0;return!1}error(t,e,n=this.peek()){return this.diagnostics.push({code:t,message:e,loc:{offset:n.start,length:Math.max(1,n.end-n.start)}}),{t:"error"}}expect(t,e){if(!this.eat(t))this.error(e,`Expected '${t}'`)}parse(){let t=this.assign();if(this.peek().t!=="eof")this.error("LIPS-E003",`Unexpected token '${this.peek().value}' after expression`);return t}isArrowAhead(){let t=this.peek();if(t.t==="id"){let e=this.peek(1);return e.t==="punct"&&e.value==="=>"}if(t.t==="punct"&&t.value==="("){let e=0,n=0;while(!0){let r=this.peek(n);if(r.t==="eof")return!1;if(r.t==="punct"&&r.value==="(")e++;if(r.t==="punct"&&r.value===")"){if(e--,e===0){let i=this.peek(n+1);return i.t==="punct"&&i.value==="=>"}}n++}}return!1}assign(){if(this.isArrowAhead()){let n=[];if(this.peek().t==="id")n.push(this.next().value);else{this.expect("(","LIPS-E004");while(!this.at(")")&&this.peek().t!=="eof"){let r=this.next();if(r.t!=="id")return this.error("LIPS-E005","Invalid arrow parameter",r);if(n.push(r.value),!this.eat(","))break}this.expect(")","LIPS-E004")}return this.expect("=>","LIPS-E004"),{t:"arrow",params:n,body:this.assign()}}let t=this.conditional(),e=this.peek();if(e.t==="punct"&&["=","+=","-=","*=","/=","%="].includes(e.value)){if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid assignment target",e);return this.next(),{t:"assign",op:e.value,target:t,value:this.assign()}}return t}conditional(){let t=this.nullish();if(this.eat("?")){let e=this.assign();return this.expect(":","LIPS-E007"),{t:"cond",test:t,cons:e,alt:this.assign()}}return t}nullish(){let t=this.or();while(this.at("??"))this.next(),t={t:"logic",op:"??",l:t,r:this.or()};return t}or(){let t=this.and();while(this.at("||"))this.next(),t={t:"logic",op:"||",l:t,r:this.and()};return t}and(){let t=this.equality();while(this.at("&&"))this.next(),t={t:"logic",op:"&&",l:t,r:this.equality()};return t}equality(){let t=this.relational();while(["===","!==","==","!="].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.relational()};return t}relational(){let t=this.additive();while(["<=",">=","<",">"].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.additive()};return t}additive(){let t=this.multiplicative();while(this.at("+")||this.at("-"))t={t:"bin",op:this.next().value,l:t,r:this.multiplicative()};return t}multiplicative(){let t=this.unary();while(this.at("*")||this.at("/")||this.at("%"))t={t:"bin",op:this.next().value,l:t,r:this.unary()};return t}unary(){if(this.at("!")||this.at("-")||this.at("+"))return{t:"unary",op:this.next().value,arg:this.unary()};if(this.at("++")||this.at("--")){let t=this.next().value,e=this.unary();if(e.t!=="id"&&e.t!=="member")return this.error("LIPS-E006","Invalid update target");return{t:"update",op:t,arg:e,prefix:!0}}return this.postfix()}postfix(){let t=this.callMember();if(this.at("++")||this.at("--")){let e=this.next().value;if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid update target");t={t:"update",op:e,arg:t,prefix:!1}}return t}callMember(){let t=this.primary();while(!0)if(this.eat(".")){let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!1,at:e.start}}else if(this.eat("?."))if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!0};else if(this.eat("[")){let e=this.peek().start,n=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:n,computed:!0,optional:!0,at:e}}else{let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!0,at:e.start}}else if(this.eat("[")){let e=this.peek().start,n=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:n,computed:!0,optional:!1,at:e}}else if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!1};else break;return t}argList(){this.expect("(","LIPS-E010");let t=[];while(!this.at(")")&&this.peek().t!=="eof")if(t.push(this.assign()),!this.eat(","))break;return this.expect(")","LIPS-E010"),t}primary(){let t=this.peek();if(t.t==="num")return this.next(),{t:"lit",v:parseFloat(t.value)};if(t.t==="str")return this.next(),{t:"lit",v:t.value};if(t.t==="id")switch(this.next(),t.value){case"true":return{t:"lit",v:!0};case"false":return{t:"lit",v:!1};case"null":return{t:"lit",v:null};case"undefined":return{t:"lit",v:void 0};case"NaN":return{t:"lit",v:NaN};case"Infinity":return{t:"lit",v:1/0};default:return{t:"id",name:t.value,at:t.start}}if(this.eat("(")){let e=this.assign();return this.expect(")","LIPS-E010"),e}if(this.eat("[")){let e=[];while(!this.at("]")&&this.peek().t!=="eof"){let n=this.eat("...");if(e.push({spread:n||void 0,value:this.assign()}),!this.eat(","))break}return this.expect("]","LIPS-E009"),{t:"arr",items:e}}if(this.eat("{")){let e=[];while(!this.at("}")&&this.peek().t!=="eof"){if(this.eat("..."))e.push({spread:!0,value:this.assign()});else{let n=this.next();if(n.t!=="id"&&n.t!=="str"&&n.t!=="num")return this.error("LIPS-E011","Invalid object key",n);if(this.eat(":"))e.push({key:String(n.value),value:this.assign(),at:n.start});else if(n.t==="id")e.push({key:n.value,value:{t:"id",name:n.value,at:n.start},at:n.start});else return this.error("LIPS-E011","Invalid shorthand property",n)}if(!this.eat(","))break}return this.expect("}","LIPS-E011"),{t:"obj",props:e}}return this.next(),this.error("LIPS-E012",t.t==="eof"?"Unexpected end of expression":`Unexpected token '${t.value}'`,t)}}function pt(t){let e=[],n=Qt(t,e);return{ast:new Ct(n,e).parse(),diagnostics:e}}function lt(t){let e=[],n=0,r=0;for(let i=0;i<t.length;i++){let a=t[i];if(a==="'"||a==='"'||a==="`"){i++;while(i<t.length&&t[i]!==a){if(t[i]==="\\")i++;i++}continue}if(a==="("||a==="["||a==="{")n++;else if(a===")"||a==="]"||a==="}")n--;else if(a===","&&n===0)e.push(t.slice(r,i)),r=i+1}return e.push(t.slice(r)),e.map((i)=>i.trim()).filter(Boolean)}var wt={__proto__:null,static:"__static",arguments:"__args__"};function b(t){switch(t.t){case"lit":if(typeof t.v==="string")return JSON.stringify(t.v);if(t.v===void 0)return"undefined";if(Number.isNaN(t.v))return"NaN";return String(t.v);case"id":return wt[t.name]??t.name;case"member":{let e=Rt(t.obj);if(t.computed)return`${e}${t.optional?"?.":""}[${b(t.prop)}]`;return`${e}${t.optional?"?.":"."}${t.prop}`}case"call":return`${Rt(t.callee)}${t.optional?"?.":""}(${t.args.map(b).join(",")})`;case"unary":return`(${t.op}(${b(t.arg)}))`;case"update":return t.prefix?`(${t.op}${ct(t.arg)})`:`(${ct(t.arg)}${t.op})`;case"bin":return`((${b(t.l)})${t.op}(${b(t.r)}))`;case"logic":return`((${b(t.l)})${t.op}(${b(t.r)}))`;case"cond":return`((${b(t.test)})?(${b(t.cons)}):(${b(t.alt)}))`;case"assign":return`(${ct(t.target)}${t.op}(${b(t.value)}))`;case"arrow":return`((${t.params.join(",")})=>(${b(t.body)}))`;case"arr":return`[${t.items.map((e)=>(e.spread?"...":"")+b(e.value)).join(",")}]`;case"obj":return`({${t.props.map((e)=>e.spread?`...${b(e.value)}`:`${JSON.stringify(e.key)}:${b(e.value)}`).join(",")}})`;case"error":return"undefined"}}var Rt=(t)=>t.t==="member"||t.t==="call"||t.t==="id"?b(t):`(${b(t)})`;function ct(t){if(t.t==="id")return wt[t.name]??t.name;if(t.t==="member"){let e=b(t.obj);return t.computed?`${e}[${b(t.prop)}]`:`${e}.${t.prop}`}return b(t)}var It=new Map,te=["state","input","context","__static","self"];function Tt(t,e=[]){let n=`${e.join(",")}\x00${t}`,r=It.get(n);if(r)return r;let{ast:i,diagnostics:a}=pt(t);if(a.length)console.warn(`[lips-ir] expression diagnostics for "${t}":`,a);let c=`return (${b(i)});`,p=[...te,"__args__",...e],s=Function(...p,c),l={source:t,run(o){let u=o.scope||{};return s(o.state,o.input,o.context,o.static,o.self,o.arguments,...e.map((f)=>u[f]))}};return It.set(n,l),l}var kt={__proto__:null,Math,JSON,Object,Array,String,Number,Boolean,Date,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,console},V=Symbol("lips.ended");function Ot(t,e){let n=e.scope||Object.create(null),r=(s,l)=>{for(let o of l)if(s in o)return o[s];if(s in n)return n[s];switch(s){case"state":return e.state;case"input":return e.input;case"context":return e.context;case"static":return e.static;case"self":return e.self;case"arguments":return e.arguments}if(s in kt)return kt[s];return},i=(s,l,o)=>{for(let u of o)if(s in u)return u[s]=l,l;return n[s]=l,l},a=(s,l)=>{switch(s.t){case"lit":return s.v;case"id":return r(s.name,l);case"member":case"call":{let o=c(s,l);return o===V?void 0:o}case"unary":{let o=a(s.arg,l);switch(s.op){case"!":return!o;case"-":return-o;case"+":return+o}}case"update":{let o=a(s.arg,l),u=s.op==="++"?o+1:o-1;return p(s.arg,u,l),s.prefix?u:o}case"bin":{let o=a(s.l,l),u=a(s.r,l);switch(s.op){case"+":return o+u;case"-":return o-u;case"*":return o*u;case"/":return o/u;case"%":return o%u;case"<":return o<u;case">":return o>u;case"<=":return o<=u;case">=":return o>=u;case"==":return o==u;case"!=":return o!=u;case"===":return o===u;case"!==":return o!==u}return}case"logic":{let o=a(s.l,l);switch(s.op){case"&&":return o?a(s.r,l):o;case"||":return o?o:a(s.r,l);case"??":return o!=null?o:a(s.r,l)}}case"cond":return a(s.test,l)?a(s.cons,l):a(s.alt,l);case"assign":{let o=a(s.value,l);if(s.op!=="="){let u=a(s.target,l);switch(s.op){case"+=":o=u+o;break;case"-=":o=u-o;break;case"*=":o=u*o;break;case"/=":o=u/o;break;case"%=":o=u%o;break}}return p(s.target,o,l)}case"arrow":return(...o)=>{let u=Object.create(null);return s.params.forEach((f,d)=>u[f]=o[d]),a(s.body,[u,...l])};case"arr":{let o=[];for(let u of s.items){let f=a(u.value,l);u.spread?o.push(...f):o.push(f)}return o}case"obj":{let o={};for(let u of s.props)if(u.spread)Object.assign(o,a(u.value,l));else o[u.key]=a(u.value,l);return o}case"error":return}},c=(s,l)=>{if(s.t!=="member"&&s.t!=="call")return a(s,l);let o=s.t==="member"?s:s.callee.t==="member"?s.callee:null,u,f;if(o){if(u=c(o.obj,l),u===V||o.optional&&u==null)return V;if(f=u[o.computed?a(o.prop,l):o.prop],s===o)return f}else if((f=c(s.callee,l))===V)return V;let d=s;return d.optional&&f==null?V:Reflect.apply(f,u,d.args.map((h)=>a(h,l)))},p=(s,l,o)=>{if(s.t==="id")return i(s.name,l,o);if(s.t==="member"){let u=a(s.obj,o),f=s.computed?a(s.prop,o):s.prop;if(u!=null)u[f]=l;return l}return l};return a(t,[])}var P=null,J=0,X=new Set;function ee(){while(X.size){let t=[...X];X.clear(),J++;try{for(let e of t)!e.disposed&&e.run()}finally{J--}}}function ne(t){J++;try{return t()}finally{J--,!J&&ee()}}function I(t){let e=new Set,n=()=>{if(J){for(let c of e)X.add(c);return}for(let c of[...e])!c.disposed&&c.run()};return[()=>{if(P&&!P.disposed)e.add(P),P.deps.add(e);return t},(c)=>{if(Object.is(c,t))return;t=c,n()},()=>n()]}function A(t){let e={deps:new Set,disposed:!1,run(){if(e.disposed)return;for(let r of e.deps)r.delete(e);e.deps.clear();let n=P;P=e;try{t()}finally{P=n}}};return e.run(),{dispose(){e.disposed=!0;for(let n of e.deps)n.delete(e);e.deps.clear()}}}function k(t){let e=P;P=null;try{return t()}finally{P=e}}var jt=Symbol("lips.reactive"),Y=Symbol("lips.collection"),Pt=new WeakMap,ft=(t)=>t!==null&&typeof t==="object"&&(Array.isArray(t)||Object.getPrototypeOf(t)===Object.prototype),Z=(t)=>t instanceof Map||t instanceof Set||!!(t&&typeof t==="object"&&t[Y]),re=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"]),se=new Set(["set","delete","clear","add"]),ut=Symbol("lips.keys"),Lt=new WeakMap;function Nt(t,e){let n=t[Y];if(n)return n.notify.add(e),t;let r=Pt.get(t);if(r)return r[Y].notify.add(e),r;let i={raw:t,notify:new Set([e])},a=()=>i.notify.forEach((p)=>p()),c=new Proxy(t,{get(p,s){if(s===Y)return i;let l=p[s];if(typeof l!=="function")return l;if(typeof s==="string"&&se.has(s))return(...f)=>{let d=l.apply(p,f);return a(),d};let o=(f)=>ft(f)?dt(f,a):Z(f)?Nt(f,a):f,u=p instanceof Map;if(s==="get")return(f)=>o(p.get(f));if(s==="forEach")return(f,d)=>p.forEach((h,g)=>f.call(d,o(h),g,c));if(s==="values"||!u&&(s==="keys"||s===Symbol.iterator))return function*(){for(let f of p.values())yield o(f)};if(s==="entries"||u&&s===Symbol.iterator)return u?function*(){for(let[f,d]of p.entries())yield[f,o(d)]}:function*(){for(let f of p.values())yield[o(f),o(f)]};return l.bind(p)}});return Pt.set(t,c),c}function ie(t){let e=Lt.get(t);if(e)return e;let n=new Map,r=(o)=>{let u=n.get(o);if(!u)u=I(0),n.set(o,u);u[0]()},i=(o)=>n.get(o)?.[2](),a=new Map,c=(o)=>{let u=a.get(o);if(!u)u=()=>i(o),a.set(o,u);return u},p=()=>ne(()=>{for(let o of n.values())o[2]()}),s=!1,l=new Proxy(t,{get(o,u){let f=o[u];if(typeof u==="symbol")return f;if(Array.isArray(o)&&re.has(u)&&typeof f==="function")return(...d)=>{s=!0;try{return f.apply(o,d)}finally{s=!1,p()}};if(typeof f==="function")return f;return r(u),ft(f)||Z(f)?dt(f,c(u)):f},set(o,u,f){let d=u in o,h=o[u];if(o[u]=f,s)return!0;if(!Object.is(h,f))i(u);if(!d)i(ut),Array.isArray(o)&&i("length");return!0},deleteProperty(o,u){let f=u in o;if(delete o[u],!s&&f)i(u),i(ut);return!0},has(o,u){return typeof u!=="symbol"&&r(u),u in o},ownKeys(o){return r(ut),Reflect.ownKeys(o)}});return Lt.set(t,l),l}function dt(t,e){if(Z(t))return Nt(t,e);if(!ft(t))return t;return ie(t)}function T(t,e=!1){if(t[jt])return t;let n=new Map,[r,,i]=I(0),a=(c,p)=>{let s=n.get(c);if(!s)s=I(p),n.set(c,s);return s};return new Proxy(t,{get(c,p){if(p===jt)return!0;if(typeof p==="string"){let s=a(p,c[p]);return e?dt(s[0](),s[2]):s[0]()}return c[p]},set(c,p,s){let l=p in c,o=c[p];if(c[p]=s,typeof p!=="string")return!0;l||i();let u=a(p,s);return Object.is(o,s)&&Z(s)?u[2]():u[1](s),!0},has(c,p){return p in c},ownKeys(c){return r(),Reflect.ownKeys(c)},deleteProperty(c,p){let s=p in c;return delete c[p],typeof p==="string"&&n.get(p)?.[1](void 0),s&&i(),!0}})}var Mt=new WeakMap,_t=(t)=>t!==null,oe={__proto__:null,value:(t)=>t??"",checked:_t,selected:_t},ht={clone(t){let e=Mt.get(t);if(!e)e=document.createElement("template"),e.innerHTML=t.html,Mt.set(t,e);return e.content.cloneNode(!0)},fragment:()=>document.createDocumentFragment(),element:(t)=>document.createElement(t),text:(t)=>document.createTextNode(t),marker:(t)=>document.createComment(t),child:(t,e)=>t.childNodes[e],next:(t)=>t.nextSibling,range(t,e){let n=[];for(let r=t;r;r=r.nextSibling)if(n.push(r),r===e)break;return n},insert:(t,e,n)=>{t.insertBefore(e,n)},insertAfter(t,e){let n=t.parentNode;if(!n)return;let r=t;for(let i of e)n.insertBefore(i,r.nextSibling),r=i},remove:(t)=>t.remove(),isElement:(t)=>t.nodeType===1,connected:(t)=>t.isConnected,precedes:(t,e)=>!!(t.compareDocumentPosition(e)&4),attr(t,e,n){n===null?t.removeAttribute(e):t.setAttribute(e,n);let r=oe[e];r&&e in t&&(t[e]=r(n))},setText:(t,e)=>{t.data=e},content:(t,e)=>{t.textContent=e},html:(t,e)=>{t.innerHTML=e},styleVar:(t,e,n)=>n===null?t.style.removeProperty(e):t.style.setProperty(e,n),scope:(t,e)=>{t.hasAttribute("rel")||t.setAttribute("rel",e)},listen(t,e,n){let r=e.split(".")[0],i=e.includes(".outside"),a=i?document:t,c=i||e.includes(".capture"),p=!i&&e.includes(".stop"),s=(l)=>i&&t.contains(l.target)||(p&&l.stopPropagation(),n(l));return a.addEventListener(r,s,c),()=>a.removeEventListener(r,s,c)},keepFocus(){let t=document.activeElement;return()=>{t&&t.isConnected&&t!==document.activeElement&&t.focus()}}};function q(t){let e=t.split("-"),n=[];while(e.length)n.push(e.join("-")),e.pop(),e[e.length-1]?.length===1&&e.pop();return n}function Q(t,e){let n=new Map(Object.entries(t.names).map(([r,i])=>[r.toLowerCase(),i]));for(let r of q(e.toLowerCase()))if(n.has(r))return n.get(r);return t.names[t.default]??""}var N=(t,e)=>t==null?t:("e"in t)?{$:e[t.e]}:t,gt=(t,e)=>({...t,e:e[t.e]});function tt(t,e){switch(t.t){case"macro":return{t:t.t,name:t.name,args:t.args,sets:t.sets.map((n)=>("spread"in n)?{spread:e[n.spread]}:{name:n.name,ci:N(n.ci,e)}),block:M(t.block,e)};case"if":return{t:t.t,branches:t.branches.map((n)=>({when:n.when==null?null:e[n.when],block:M(n.block,e)}))};case"for":return{t:t.t,args:t.args,of:t.of===void 0?void 0:e[t.of],from:N(t.from,e),to:N(t.to,e),by:N(t.by,e),block:M(t.block,e)};case"switch":return{t:t.t,on:e[t.on],cases:t.cases.map((n)=>({is:n.is===null?null:N(n.is,e),block:M(n.block,e)}))};case"async":return{t:t.t,awaitE:e[t.awaitE],then:t.then&&{args:t.then.args,block:M(t.then.block,e)},catch:t.catch&&{args:t.catch.args,block:M(t.catch.block,e)},loading:t.loading&&M(t.loading,e)};case"let":return{t:t.t,const:t.const,vars:Object.fromEntries(Object.entries(t.vars).map(([n,r])=>[n,N(r,e)]))};case"log":return{t:t.t,e:e[t.e]};case"provide":return{t:t.t,vars:Object.fromEntries(Object.entries(t.vars).map(([n,r])=>[n,N(r,e)])),lang:N(t.lang,e),block:M(t.block,e)};case"comp":case"dynamic":return{t:t.t,name:t.t==="comp"?t.name:void 0,tag:t.t==="dynamic"?e[t.tag]:void 0,inputs:Object.fromEntries(Object.entries(t.inputs).map(([n,r])=>[n,N(r,e)])),spreads:t.spreads.map((n)=>e[n]),events:t.events.map((n)=>({name:n.name,e:e[n.e]})),contents:t.contents&&{args:t.contents.args,block:M(t.contents.block,e)}}}}var M=(t,e)=>({html:t.html,scope:t.scope,binds:t.binds.map((n)=>gt(n,e)),blocks:t.blocks.map((n)=>tt(n,e))}),At=(t,e,n,r)=>t.t===n.t&&JSON.stringify(tt(t,e))===JSON.stringify(tt(n,r)),$t=(t,e,n,r)=>JSON.stringify(t.map((i)=>gt(i,e)))===JSON.stringify(n.map((i)=>gt(i,r))),Ht=(t,e,n,r)=>{let i=(a,c)=>JSON.stringify(a.blocks.filter((p)=>p.t==="let").map((p)=>tt(p,c)));return i(t,e)===i(n,r)};function O(t,e=new WeakMap){if(t===null||typeof t!=="object")return t;let n=t;if(e.has(n))return e.get(n);if(Array.isArray(n)){let a=[];e.set(n,a);for(let c of n)a.push(O(c,e));return a}if(n instanceof Map){let a=new Map;return e.set(n,a),n.forEach((c,p)=>a.set(O(p,e),O(c,e))),a}if(n instanceof Set){let a=new Set;return e.set(n,a),n.forEach((c)=>a.add(O(c,e))),a}if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(ArrayBuffer.isView(n))return new n.constructor(n);let r=Object.getPrototypeOf(n);if(r!==Object.prototype&&r!==null)return t;let i=Object.create(r);e.set(n,i);for(let a of Reflect.ownKeys(n)){let c=Object.getOwnPropertyDescriptor(n,a);"value"in c&&(c.value=O(c.value,e)),Object.defineProperty(i,a,c)}return i}var Wt=Symbol("lips.slot"),ae=(t)=>!!t&&typeof t==="object"&&t[Wt]===!0;function Vt(t,e,n){if(!e||typeof t.onInput!=="function")return()=>{};let r=!0,i=!1,a=!0,{dispose:c}=A(()=>{for(let p of Object.keys(e))e[p];if(r){r=!1;return}if(i)return;i=!0,Promise.resolve().then(()=>{if(i=!1,!a)return;k(()=>{try{t.onInput(e)}catch(p){n.onError(p)}})})});return()=>{a=!1,c()}}function Jt(t){let e=!1,n=!1,r=(i)=>typeof t.onError==="function"?t.onError(i):console.error("[lips:ir]",i);return{onError:r,ready(){n=!0},notifyUpdate(){if(!n||e)return;e=!0,Promise.resolve().then(()=>{e=!1;try{typeof t.onUpdate==="function"&&t.onUpdate(),typeof t.onRender==="function"&&t.onRender()}catch(i){r(i)}})}}}var z=[];function yt(){let t=!0;while(t){t=!1;for(let e of[...z].reverse()){if(!e.live())continue;let n=z.indexOf(e);if(n<0)continue;z.splice(n,1),e.fn(),t=!0}}}var Bt=new Map;function ce(t){let e=Bt.get(t);if(!e)e=pt(t).ast,Bt.set(t,e);return e}var G=(t)=>t.join(",");function Ft(t,e,n){let r=e;for(let i of n)r=t.child(r,i);return r}var D=(t,e)=>t.range(e.start,e.end),Dt=(t,e,n,r)=>r===e||t.precedes(e,r)&&t.precedes(r,n);function Kt(t,e){e.gen++;for(let r of e.wiring)r();e.wiring=[];let n=t.fragment();for(let r of D(t,e.inst))t.insert(n,r,null)}function L(t,e,n){return t.insertAfter(e,D(t,n)),z.length&&t.connected(e)&&yt(),n}var mt=(t,e)=>D(t,e).filter((n)=>t.isElement(n));function qt(t,e,n){for(let r of mt(t,e))t.scope(r,n)}function pe(t,e,n,r,i=""){for(let a of e)t.styleVar(a,n,r===null||r===void 0||r===!1?null:r+i)}function Gt(t,e,n,r,i){qt(t,n,r);let a=i.css?e.createStylesheet?.(r,i.css):void 0;return a?()=>a.clear():void 0}function le(t){for(let e of t.bindHandles)e.dispose();for(let e of t.childHandles)e.dispose()}function C(t,e){if(!e)return;le(e);for(let n of D(t,e))t.remove(n,!0)}var Ut=(t,e,n,r)=>{let i=t.self.refs||={},a="",c=()=>{i[a]===e&&delete i[a]},p=r(()=>{c(),i[a=String(n())]=e});return()=>{p.dispose(),c()}},et=(t,e,n,r)=>t.attr(e,n,r==null||r===!1&&!n.startsWith("aria-")?null:r===!0&&!n.startsWith("aria-")?"":String(r)),F=(t,e,n)=>Object.defineProperty(t,e,{get:n,enumerable:!0,configurable:!0}),ue=Symbol.for("lips.self"),zt=Symbol("lips.ctx.layer");function fe(t,e,n,r){for(let i=t;i;i=Object.getPrototypeOf(i)){let c=i[zt]?.get(e);if(c){c(n);return}}r?.(e,n)}function Xt(t,e){let n=new Map,r=(s,...l)=>n.get(s)?.forEach((o)=>o(...l)),i,a=()=>null;return{proto:{[ue]:!0,get node(){let s=a();return s?mt(t,s):[]},get lang(){return e()},pick:(s)=>Q(s,e()),emit:r,emitLocal:r,on(s,l){return n.set(s,[...n.get(s)||[],l]),i},once(s,l){let o=(...u)=>{i.off(s,o),l(...u)};return i.on(s,o)},off(s,l){if(!l)n.delete(s);else{let o=(n.get(s)||[]).filter((u)=>u!==l);o.length?n.set(s,o):n.delete(s)}return i}},bind:(s,l)=>(i=s,a=l,s)}}class nt{ir;options;hooks;live;constructor(t,e,n,r=[]){this.ir=t;this.options=e;this.hooks=n;this.live=r;this.h=e.host||ht}h;pool=null;salvaged=[];withSalvage(t,e){let n=this.pool;this.pool=t;try{return e()}finally{this.pool=n;for(let r of t)!r.claimed&&r.teardown()}}claim(t,e){let n=this.pool?.find((r)=>!r.claimed&&r.name===t&&r.key===e);if(!n)return;return n.claimed=!0,this.salvaged.push(t),n}keyOf(t,e,n){let r=t.key;return r===void 0?void 0:("lit"in r)?r.lit:k(()=>this.runner(r.e,n)(e))}guarded(t){let e=!0;return A(()=>{try{t()}catch(n){this.hooks?this.hooks.onError(n):console.error("[lips:ir]",n)}e?e=!1:this.hooks?.notifyUpdate()})}bindStyle(t,e,n){if(!t.binds.length)return()=>{};let r=mt(this.h,e),i=t.binds.map((a)=>{let c=this.srcRunner(t.exprs[a.e],[]);return this.guarded(()=>pe(this.h,r,a.prop,c(n),a.u))});return()=>{for(let a of i)a.dispose()}}runner(t,e){return this.srcRunner(this.ir.exprs[t],e)}srcRunner(t,e){if(this.options.guard)return this.options.guard.run(t);if(this.options.mode==="interpreted"){let r=ce(t);return(i)=>Ot(r,i)}let n=Tt(t,e);return(r)=>n.run(r)}renderBlock(t,e){let n=this.h,r=n.clone(t),i=new Map,a=t.binds.map((d)=>{let h=Ft(n,r,d.p);return i.set(G(d.p),h),h}),c=t.blocks.map((d)=>{let h=Ft(n,r,d.p);return i.set(G(d.p),h),h}),p=n.marker("^"),s=n.marker("$");n.insert(r,s,null),n.insert(r,p,n.child(r,0));let l=Object.create(e.scope??null),o={...e,scope:l},u={start:p,end:s,block:t,exprs:this.ir.exprs,penv:e,benv:o,pathNodes:i,bindHandles:[],childHandles:[]};t.blocks.forEach((d,h)=>{if(d.t!=="let")return;let g=[];for(let[m,x]of Object.entries(d.vars))if("lit"in x){let[E]=I(x.lit);F(l,m,E)}else{let[E,v]=I(void 0);F(l,m,E);let y=this.runner(x.e,t.scope);g.push(this.guarded(()=>v(y(o))).dispose)}u.childHandles[h]={child:d,exprs:this.ir.exprs,anchor:c[h],dispose:()=>g.forEach((m)=>m())}});let f=(d)=>d.t==="attr"&&d.name==="value";return u.bindHandles=t.binds.map((d,h)=>f(d)?null:this.bindOne(d,a[h],o,t.scope)),t.blocks.forEach((d,h)=>{if(d.t==="let")return;u.childHandles[h]={child:d,exprs:this.ir.exprs,anchor:c[h],dispose:this.execBlock(d,c[h],o,t.scope)}}),t.binds.forEach((d,h)=>{if(f(d))u.bindHandles[h]=this.bindOne(d,a[h],o,t.scope)}),u}bindOne(t,e,n,r,i){let a=this.h;switch(t.t){case"text":{let c=i??a.text("");!i&&a.insertAfter(e,[c]);let p=this.runner(t.e,r),s=t.i18n?this.options.i18n:void 0,l=this.guarded(()=>{let o=p(n),u=o==null?"":String(o);a.setText(c,s?s.translate(u,t.ik,n.lang?.()):u)});return{bind:t,node:e,textNode:c,dispose:l.dispose}}case"attr":{let c=this.runner(t.e,r),p=t.i18n?this.options.i18n:void 0,s=this.guarded(()=>{let l=c(n);et(a,e,t.name,p&&l!=null?p.translate(String(l),t.ik,n.lang?.()):l)});return{bind:t,node:e,dispose:s.dispose}}case"prop":{let c=this.runner(t.e,r);if(t.name==="ref")return{bind:t,node:e,dispose:Ut(n,e,()=>c(n),(s)=>this.guarded(s))};if(t.name==="format"){let s=t.ref||"",l=this.guarded(()=>{let o=c(n),u=this.options.i18n?.format(s,o,n.lang?.());a.content(e,u==null?"":String(u))});return{bind:t,node:e,dispose:l.dispose}}let p=this.guarded(()=>{let s=c(n),l=s==null?"":String(s);t.name==="html"&&a.html?a.html(e,l):a.content(e,l)});return{bind:t,node:e,dispose:p.dispose}}case"event":{let c=this.eventDispatcher(this.ir.exprs[t.e],r,n);return{bind:t,node:e,dispose:a.listen(e,t.name,c)}}case"spread":{let c=this.runner(t.e,r),p=new Set,s=this.guarded(()=>{let l=c(n)||{},o=new Set(Object.keys(l));for(let u of p)!o.has(u)&&a.attr(e,u,null);for(let u of o)et(a,e,u,l[u]);p=o});return{bind:t,node:e,dispose:s.dispose}}}}swapBlock(t,e,n,r){if(t.block.html!==e.html||JSON.stringify(t.block.scope)!==JSON.stringify(e.scope)||!Ht(t.block,t.exprs,e,this.ir.exprs))return this.rebuild(t,e,n,r);if(!$t(t.block.binds,t.exprs,e.binds,this.ir.exprs)){let i=e.binds.map((p)=>t.pathNodes.get(G(p.p)));if(i.some((p)=>!p))return this.rebuild(t,e,n,r);let a=new Map;t.bindHandles.forEach((p)=>p.textNode&&a.set(G(p.bind.p),p.textNode)),t.bindHandles.forEach((p)=>p.dispose());let c=new Set;t.bindHandles=e.binds.map((p,s)=>{let l=G(p.p),o=p.t==="text"?a.get(l):void 0;return o&&c.add(l),this.bindOne(p,i[s],t.benv,e.scope,o)}),a.forEach((p,s)=>!c.has(s)&&this.h.remove(p,!0)),n.push({kind:"binds",path:r})}for(let i=0;i<e.blocks.length;i++){let a=e.blocks[i],c=t.childHandles[i];if(a.t==="let")continue;if(c&&At(c.child,c.exprs,a,this.ir.exprs))continue;let p=this.live.filter((s)=>Dt(this.h,c.anchor,t.childHandles[i+1]?.anchor??t.end,s.anchor));for(let s of p)Kt(this.h,s);c?.dispose(),t.childHandles[i]={child:a,exprs:this.ir.exprs,anchor:c.anchor,dispose:this.withSalvage(p,()=>this.execBlock(a,c.anchor,t.benv,e.scope))},n.push({kind:"block",path:`${r}/${i}`})}return t.block=e,t.exprs=this.ir.exprs,t}rebuild(t,e,n,r){let i=this.live.filter((c)=>Dt(this.h,t.start,t.end,c.anchor));for(let c of i)Kt(this.h,c);let a=this.withSalvage(i,()=>this.renderBlock(e,t.penv));return L(this.h,t.end,a),C(this.h,t),n.push({kind:"skeleton",path:r}),a}execBlock(t,e,n,r){let i=this.h,a=[];switch(t.t){case"if":{let c=t.branches.map((o)=>o.when!=null?this.runner(o.when,r):null),p=null,s=-2,l=this.guarded(()=>{let o=-1;for(let u=0;u<t.branches.length;u++){let f=c[u];if(!f||f(n)){o=u;break}}if(o===s)return;s=o,k(()=>{if(C(i,p),p=null,o>=0)p=L(i,e,this.renderBlock(t.branches[o].block,n))})});a.push(()=>{l.dispose(),C(i,p)});break}case"switch":{let c=this.runner(t.on,r),p=t.cases.map((u)=>u.is&&("e"in u.is)?this.runner(u.is.e,r):null),s=null,l=-2,o=this.guarded(()=>{let u=c(n),f=-1,d=-1;for(let h=0;h<t.cases.length;h++){let g=t.cases[h];if(g.is===null){d=h;continue}let m="lit"in g.is?g.is.lit:p[h](n);if(Array.isArray(m)?m.includes(u):m===u){f=h;break}}if(f===-1)f=d;if(f===l)return;l=f,k(()=>{if(C(i,s),s=null,f>=0)s=L(i,e,this.renderBlock(t.cases[f].block,n))})});a.push(()=>{o.dispose(),C(i,s)});break}case"macro":{let c=Object.create(n.scope??null),p=T({}),s={};for(let f of t.args)s[f]=I(void 0),F(c,f,s[f][0]);let l=t.sets.map((f)=>{if("spread"in f)return{kind:"spread",run:this.runner(f.spread,r)};if("lit"in f.ci){let h=f.ci.lit;return{kind:"value",name:f.name,value:()=>h}}let d=this.runner(f.ci.e,r);return{kind:"value",name:f.name,value:()=>d(n)}}),o=new Set;a.push(this.guarded(()=>{let f={};for(let d of l)if(d.kind==="spread"){let h=d.run(n);if(h&&typeof h==="object")for(let[g,m]of h instanceof Map?h:Object.entries(h))f[g]=m}else f[d.name]=d.value();k(()=>{for(let h of t.args)s[h][1](f[h]);let d=new Set(Object.keys(f));for(let h of o)!d.has(h)&&delete p[h];for(let h of d)p[h]=f[h];o=d})}).dispose);let u=L(i,e,this.renderBlock(t.block,{...n,arguments:p,scope:c}));a.push(()=>C(i,u));break}case"for":this.execFor(t,e,n,r,a);break;case"async":{let c=this.runner(t.awaitE,r),p=null,s=0,l=(u,f)=>{if(C(i,p),p=null,!u)return;let d="block"in u,h=Object.create(n.scope??null);if(d&&u.args[0]!==void 0){let[g]=I(f);F(h,u.args[0],g)}p=L(i,e,this.renderBlock(d?u.block:u,{...n,scope:h}))},o=this.guarded(()=>{let u;try{u=c(n)}catch(d){u=Promise.reject(d)}let f=++s;k(()=>{t.loading?l(t.loading):l(void 0),Promise.resolve(u).then((d)=>f===s&&k(()=>l(t.then,d)),(d)=>f===s&&k(()=>l(t.catch,d)))})});a.push(()=>{s++,o.dispose(),C(i,p)});break}case"provide":{let c=Object.create(n.context??null),p=new Map;Object.defineProperty(c,zt,{value:p});for(let[o,u]of Object.entries(t.vars)){let[f,d]=I("lit"in u?u.lit:void 0);if(F(c,o,f),p.set(o,d),"lit"in u)continue;let h=this.runner(u.e,r);a.push(this.guarded(()=>d(h(n))).dispose)}let s=n.lang;if(t.lang)if("lit"in t.lang){let o=String(t.lang.lit);s=()=>o}else{let[o,u]=I(void 0),f=this.runner(t.lang.e,r);a.push(this.guarded(()=>u(f(n))).dispose),s=()=>o()??n.lang?.()}let l=L(i,e,this.renderBlock(t.block,{...n,context:c,lang:s}));a.push(()=>C(i,l));break}case"log":{let c=lt(this.ir.exprs[t.e]).map((p)=>this.srcRunner(p,r));a.push(this.guarded(()=>console.log(...c.map((p)=>p(n)))).dispose);break}case"comp":{let c=this.options.components?.[t.name];c?this.execComponent(c,t,e,n,r,a,t.name):this.execElement(t,e,n,r,a);break}case"dynamic":{let c=this.runner(t.tag,r),p=[],s=Symbol("init"),l=this.guarded(()=>{let o=c(n);if(o===s)return;s=o,k(()=>{for(let f of p)f();if(p=[],o==null)return;if(ae(o)){let f={};for(let[h,g]of Object.entries(t.inputs)){let m="lit"in g?void 0:this.runner(g.e,r);f[h]=m?()=>m(n):()=>g.lit}let d=L(i,e,o.render(f,n));p.push(()=>C(i,d));return}let u=typeof o==="string"?this.options.components?.[o]:o&&typeof o==="object"?o.ir?o:this.options.resolveTemplate?.(o):void 0;if(u)this.execComponent(u,t,e,n,r,p,typeof o==="string"?o:"#dynamic");else if(typeof o==="string")this.execElement({...t,name:o},e,n,r,p)})});a.push(()=>{l.dispose();for(let o of p)o()});break}}return()=>a.forEach((c)=>c())}execFor(t,e,n,r,i){let a=this.h,c=t.of!==void 0?this.runner(t.of,r):null,p=t.by&&"e"in t.by?this.runner(t.by.e,r):null,s=t.by&&"lit"in t.by?String(t.by.lit).split("."):null,l=(g,m)=>g===void 0?void 0:("lit"in g)?g.lit:this.runner(g.e,r)(m),o=[],u=0,f=new Map,d=()=>{if(c===null){let x=Number(l(t.from,n)??0),E=Number(l(t.to,n)??x),v=x<=E,y=[];for(let R=x;v?R<=E:R>=E;v?R++:R--)y.push({key:R,values:[R]});return y}let g=c(n),m=(x,E,v)=>{if(p){let y=p(n);return typeof y==="function"?y(x,v):E}if(s)return s.reduce((y,R)=>y?.[R],x);return E};if(Array.isArray(g))return g.map((x,E)=>({key:m(x,E,E),values:[x,E]}));if(g instanceof Map)return[...g.entries()].map(([x,E],v)=>({key:x,values:[x,E,v]}));if(g instanceof Set)return[...g].map((x,E)=>({key:m(x,x,E),values:[x,E]}));if(g&&typeof g==="object")return Object.entries(g).map(([x,E],v)=>({key:x,values:[x,E,v]}));return[]},h=this.guarded(()=>{let g=d();k(()=>{let m=new Set,x=[],E=++u;for(let y of g){let R=y.key;if(m.has(R))console.warn(`<for> duplicate key '${String(R)}' — falling back to positional identity`),R=`#dup:${x.length}`;m.add(R);let K=f.get(R);if(K)K.sigs.forEach(([H,_,U],w)=>{let j=y.values[w];Object.is(H(),j)&&typeof j==="object"&&j!==null?U():_(j)}),K.pass=E,x.push(K);else{let H=Object.create(n.scope??null),_=y.values.map((j)=>I(j));t.args.forEach((j,S)=>_[S]&&F(H,j,_[S][0]));let U=this.renderBlock(t.block,{...n,scope:H}),w={key:R,sigs:_,inst:U,pass:E};f.set(R,w),x.push(w)}}for(let y of o)if(y.pass!==E)f.delete(y.key),C(a,y.inst);let v=e;for(let y of x){if(a.next(v)!==y.inst.start)L(a,v,y.inst);v=y.inst.end}o=x})});i.push(()=>{h.dispose();for(let g of o)C(a,g.inst);o=[],f.clear()})}wireInputs(t,e,n,r,i,a){for(let[c,p]of Object.entries(t.inputs))if(a?.add(c),"lit"in p)r[c]=p.lit;else{let s=this.runner(p.e,n);i.push(this.guarded(()=>r[c]=s(e)).dispose)}for(let c of t.spreads){let p=this.runner(c,n);i.push(this.guarded(()=>{let s=p(e)||{};k(()=>Object.entries(s).forEach(([l,o])=>{a?.add(l),r[l]=o}))}).dispose)}}wireEvents(t,e,n,r,i){t?.forEach((a)=>{let c=this.eventDispatcher(this.ir.exprs[a.e],n,e);r.on(a.name,c),i.push(()=>r.off(a.name,c))})}slotRenderer(t,e){let n=this;return{[Wt]:!0,args:t.args,render(r,i){let a=Object.create(e.scope??null);return t.args.forEach((c)=>F(a,c,r?.[c]??(()=>{return}))),n.renderBlock(t.block,i?{...e,scope:a,context:i.context,lang:i.lang}:{...e,scope:a})}}}adoptComponent(t,e,n,r,i,a){let c=[],p=new Set;if(this.wireInputs(e,r,i,t.input,c,p),e.contents)t.input.renderer=this.slotRenderer(e.contents,r),p.add("renderer");for(let l of Object.keys(t.input))!p.has(l)&&delete t.input[l];this.wireEvents(e.events,r,i,t.self,c),t.wiring=c,t.anchor=n;let s=t.gen;L(this.h,n,t.inst),a.push(()=>{if(s!==t.gen)return;for(let l of t.wiring)l();t.wiring=[],t.teardown()})}execComponent(t,e,n,r,i,a,c){let p=this.pool?.length?this.claim(c,this.keyOf(e.inputs,r,i)):void 0;if(p)return this.adoptComponent(p,e,n,r,i,a);let s=T({}),l=[];if(this.wireInputs(e,r,i,s,l),e.contents)s.renderer=this.slotRenderer(e.contents,r);let o=T(O(t.state||{}),t.deep??!1),u=O(t.statics??{}),f=null,d=this,h=Xt(this.h,()=>r.lang?.()??d.options.i18n?.lang()??""),g=h.bind(Object.assign(Object.create(h.proto),{...this.options.expose||{},state:o,input:s,static:u,context:r.context,refs:{},setContext(S,B){let W=(ot,at)=>fe(r.context,ot,at,d.options.expose?.setContext);typeof S==="string"?W(S,B):Object.entries(S||{}).forEach(([ot,at])=>W(ot,at))}}),()=>f);t.handlers&&Object.entries(t.handlers).forEach(([S,B])=>g[S]=B.bind(g)),this.wireEvents(e.events,r,i,g,l);let m=Jt(g);try{typeof g.onCreate==="function"&&g.onCreate()}catch(S){m.onError(S)}try{Object.keys(s).length&&typeof g.onInput==="function"&&g.onInput(s)}catch(S){m.onError(S)}let x=Vt(g,s,m),E={state:o,input:s,context:r.context,lang:r.lang,static:u,self:g,scope:void 0},v=new nt(t.ir,this.options,m),y=v.renderBlock(t.ir.root,E);f=y;let R=t.stylesheet?Gt(this.h,this.options,y,t.stylesheet.nsp||t.nsp||"lips",t.stylesheet):void 0,K=t.stylesheet?v.bindStyle(t.stylesheet,y,E):void 0;L(this.h,n,y),m.ready();try{typeof g.onMount==="function"&&g.onMount(),typeof g.onRender==="function"&&g.onRender(),g.emit("component:mount")}catch(S){m.onError(S)}let H;if(t.context?.length&&typeof g.onContext==="function"){let S=!0,{dispose:B}=A(()=>{for(let W of t.context)E.context?.[W];if(S){S=!1;return}k(()=>{try{g.onContext()}catch(W){m.onError(W)}})});H=B}let _=!1;z.push({live:()=>this.h.connected(y.start),fn:()=>{_=!0;try{typeof g.onAttach==="function"&&g.onAttach(),g.emit("component:attached")}catch(S){m.onError(S)}}}),this.h.connected(y.start)&&yt();let U=!1,w={name:c,key:s.key,self:g,input:s,inst:y,anchor:n,wiring:l,gen:0,claimed:!1,teardown:()=>{if(U)return;U=!0;let S=this.live.indexOf(w);S>-1&&this.live.splice(S,1),H?.(),x(),K?.(),R?.(),C(this.h,y);try{if(_)typeof g.onDetach==="function"&&g.onDetach(),g.emit("component:detached");typeof g.onDestroy==="function"&&g.onDestroy(),g.emit("component:destroy")}catch(B){m.onError(B)}}};this.live.push(w);let j=w.gen;a.push(()=>{if(j!==w.gen)return;for(let S of w.wiring)S();w.wiring=[],w.teardown()})}execElement(t,e,n,r,i){let a=this.h,c=a.element(t.name);for(let[p,s]of Object.entries(t.inputs))if(p==="@ref"){let l="lit"in s?()=>s.lit:this.runner(s.e,r);i.push(Ut(n,c,()=>l(n),(o)=>this.guarded(o)))}else if(p[0]==="@")i.push(this.contentOf(c,p,s,n,r));else if("lit"in s)et(a,c,p,s.lit);else{let l=this.runner(s.e,r);i.push(this.guarded(()=>et(a,c,p,l(n))).dispose)}for(let p of t.events)i.push(a.listen(c,p.name,this.eventDispatcher(this.ir.exprs[p.e],r,n)));if(t.contents){let p=this.renderBlock(t.contents.block,n);for(let s of D(a,p))a.insert(c,s,null);i.push(()=>C(a,p))}a.insertAfter(e,[c]),i.push(()=>a.remove(c,!0))}contentOf(t,e,n,r,i){let a=this.h;if(e==="@format"){let{ref:p,e:s}="lit"in n?n.lit:{},l=s===void 0?()=>({}):this.runner(s,i);return this.guarded(()=>{let o=this.options.i18n?.format(p||"",l(r),r.lang?.());a.content(t,o==null?"":String(o))}).dispose}let c="lit"in n?()=>n.lit:this.runner(n.e,i);return this.guarded(()=>{let p=c(r),s=p==null?"":String(p);e==="@html"&&a.html?a.html(t,s):a.content(t,s)}).dispose}eventDispatcher(t,e,n){let r=lt(t),i=/^[A-Za-z_$][\w$]*$/.test(r[0]||"")&&!e.includes(r[0]);return(...a)=>k(()=>{let c=(l)=>{if(i&&n.self&&!this.options.guard?.self(l)&&typeof n.self[l]==="function")return n.self[l];try{return this.srcRunner(l,e)(n)}catch(o){return}};if(!r.length)return;let p=c(r[0]);if(typeof p!=="function")return;let s=(l)=>this.hooks?this.hooks.onError(l):console.error("[lips:ir]",l);try{let l=r.slice(1).map((u)=>this.srcRunner(u,e)(n)),o=p(...l,...a);o&&typeof o.then==="function"&&o.then(void 0,s)}catch(l){s(l)}})}}function xt(t,e={},n={}){let r=n.host||ht,i=T(e.state||{},e.deep??!1),a=T(e.input||{},e.deep??!1),c=e.static||{},p=null,s=Xt(r,()=>n.i18n?.lang()??""),l=s.bind(Object.assign(Object.create(s.proto),{state:i,input:a,static:c,refs:{},...n.expose||{},...e.expose||{}}),()=>p);e.handlers&&Object.entries(e.handlers).forEach(([v,y])=>l[v]=y.bind(l));let o={state:i,input:a,context:e.context,static:c,self:l,scope:void 0},u=Jt(l);try{typeof l.onCreate==="function"&&l.onCreate()}catch(v){u.onError(v)}try{Object.keys(a).length&&typeof l.onInput==="function"&&l.onInput(a)}catch(v){u.onError(v)}let f=Vt(l,a,u),d=new nt(t,n,u),h=d.renderBlock(t.root,o);p=h,u.ready();let g=e.stylesheet?Gt(r,n,h,e.stylesheet.nsp||e.nsp||"lips",e.stylesheet):void 0,m=e.stylesheet?d.bindStyle(e.stylesheet,h,o):void 0;try{typeof l.onMount==="function"&&l.onMount(),typeof l.onRender==="function"&&l.onRender()}catch(v){u.onError(v)}let x=!1,E=()=>{if(x)return;x=!0;try{typeof l.onAttach==="function"&&l.onAttach(),l.emit("component:attached")}catch(v){u.onError(v)}};return{state:i,self:l,get nodes(){return D(r,h)},mount(v){for(let y of D(r,h))r.insert(v,y,null);if(r.connected(h.start))E(),yt()},swap(v){let y=[],R=r.keepFocus?.();if(d=new nt(v,n,u,d.live),h=d.swapBlock(h,v.root,y,"root"),p=h,e.stylesheet)qt(r,h,e.stylesheet.nsp||e.nsp||"lips"),m?.(),m=d.bindStyle(e.stylesheet,h,o);return R?.(),{changes:y,salvaged:d.salvaged}},dispose(){f(),m?.(),g?.(),C(r,h);try{if(x)typeof l.onDetach==="function"&&l.onDetach(),l.emit("component:detached");typeof l.onDestroy==="function"&&l.onDestroy()}catch(v){u.onError(v)}}}}class rt{options={emit:!0};__events={};__once_events={};constructor(t){if(t)this.options=t}on(t,e){if(!Array.isArray(this.__events[t]))this.__events[t]=[];return this.__events[t].push(e),this}once(t,e){if(!Array.isArray(this.__once_events[t]))this.__once_events[t]=[];return this.__once_events[t].push(e),this}off(t,e){if(e){if(Array.isArray(this.__events[t]))this.__events[t]=this.__events[t].filter((n)=>n!==e),!this.__events[t].length&&delete this.__events[t];if(Array.isArray(this.__once_events[t]))this.__once_events[t]=this.__once_events[t].filter((n)=>n!==e),!this.__once_events[t].length&&delete this.__once_events[t]}else delete this.__events[t],delete this.__once_events[t];return this}emit(t,...e){if(!this.options.emit)return;let n=(i)=>{if(!i||typeof i!=="object")return i;if(typeof i.toJSON==="function")return i.toJSON();if(Array.isArray(i))return i.map(n);if(i.constructor===Object||i.constructor===void 0){let a={};for(let c in i)a[c]=n(i[c]);return a}return i},r=e.map(n);this.__events[t]?.forEach((i)=>i(...r)),this.__once_events[t]?.forEach((i)=>i(...r)),delete this.__once_events[t]}}class st{nsp;settings;constructor(t,e){if(typeof t!=="string"||!t)throw Error("Undefined or invalid stylesheet namespace");this.nsp=t,this.settings=e||{},this.settings.sheet&&this.load(this.settings)}get rel(){return`${this.settings.meta?"@":""}${this.nsp}`}get styleElement(){return document.head.querySelector(`style[rel="${this.rel.replace(/["\\]/g,"\\$&")}"]`)}load(t){if(this.settings=t,!t.sheet)return;let e=this.styleElement;if(e)return e.setAttribute("dindex",String(Number(e.getAttribute("dindex")||0)+1)),e;let n=document.createElement("style");return n.setAttribute("rel",this.rel),n.setAttribute("dindex","0"),n.textContent=t.sheet,t.meta?document.head.prepend(n):document.head.appendChild(n),n}clear(){let t=this.styleElement;if(!t)return;let e=Number(t.getAttribute("dindex")||0);e<=0?t.remove():t.setAttribute("dindex",String(e-1))}}var de="en-US";class it{engine;currentLang;DICTIONARIES={};functions;onMissing;onError;onChange;loader;loading=new Map;formatters=new Map;constructor(t,e){this.engine=e;this.currentLang=t||typeof navigator<"u"&&navigator.language||de,this.functions={...e?.functions}}set lang(t){if(this.currentLang===t)return;this.currentLang=t}get lang(){return this.currentLang}setDictionary(t,e){if(!this.engine)throw Error(`[lips:i18n] <${t}> dictionary without a MessageFormat engine — pass \`messageFormat\` from '@lipsjs/lips/i18n' to new Lips()`);this.DICTIONARIES[t.toLowerCase()]=e,this.formatters.clear(),this.onChange?.()}has(t){return q(t.toLowerCase()).some((e)=>!!this.DICTIONARIES[e])}setLoader(t){return this.loader=t,this}load(t){return Promise.all(q(t).map((e)=>{let n=e.toLowerCase();if(this.DICTIONARIES[n]||!this.loader)return;let r=this.loading.get(n);if(!r)r=this.loader(e).then((i)=>{i&&this.setDictionary(e,i)}).catch((i)=>console.warn(`[lips:i18n] <${e}> dictionary failed to load —`,i)),this.loading.set(n,r);return r})).then(()=>{})}message(t,e){let n=`${e}
|
|
3
|
-
${t}`;if(this.formatters.has(n))return this.formatters.get(n);let r;for(let i of q(e.toLowerCase())){let a=this.DICTIONARIES[i];if(!a||!Object.prototype.hasOwnProperty.call(a,t))continue;try{r=new this.engine.MessageFormat(e,a[t],{functions:this.functions})}catch(c){this.onError?.(c,t,e),r=null}break}return r!==void 0&&this.formatters.set(n,r),r}translate(t,e,n){let r=e||this.currentLang,i=n||t,a=this.message(i,r);if(a)t=a.format(void 0,(c)=>this.onError?.(c,i,r));else if(a===void 0&&n)this.onMissing?.(n,r);return{text:t,lang:r}}format(t,e,n){let r=n||this.currentLang,i=this.message(t,r);if(i)return i.format(e,(a)=>this.onError?.(a,t,r));i===void 0&&this.onMissing?.(t,r)}pick(t,e){return Q(t,e||this.currentLang)}}var vt=null;var Et=null;var he;var ge={};var ye=null;var me=["state","input","static","context","emit","on","once","off","node","lang","setContext","setLanguage","destroy","appendTo","prependTo","replaceWith","render","swap"],xe=new Set(me);function St(t){if(!t)return;for(let e of Object.keys(t))if(xe.has(e))throw Error(`Handler <${e}> is a reserved component member name`);return t}class Yt extends rt{lips;template;state;instance;contextWatcher;destroyed=!1;constructor(t,e,n,r,i,a){super();this.lips=t;this.template=n;let c=St(n.handler);this.state=T(O(n.state||{}),!0);let p=T({...r},!0),s=(o,...u)=>super.emit(o,...u);this.instance=xt(i,{state:this.state,input:p,context:t.getContext(),static:O(n.static??n._static),handlers:c,deep:!0,stylesheet:t.styleFor(e,n),nsp:e,expose:{emit(o,...u){this.emitLocal?.(o,...u),s(o,...u)},context:t.getContext()}},a);let l=n.watchContext;if(l?.length&&typeof c?.onContext==="function")this.contextWatcher=t.watchContext(l,()=>{try{c.onContext.call(this.instance.self)}catch(o){console.error("[lips:ir]",o)}});this.emit("component:mount")}emit(t,...e){return this.instance?.self?.emitLocal?.(t,...e),super.emit(t,...e)}get node(){return this.instance.nodes.filter((t)=>t.nodeType===1)}appendTo(t){let e=typeof t==="string"?document.querySelector(t):t;return e&&this.instance.mount(e),this}swap(t){return this.instance.swap(t)}destroy(){if(this.destroyed)return;this.destroyed=!0,this.contextWatcher?.(),this.instance.dispose(),this.emit("component:destroy")}}class
|
|
2
|
+
`,t:"\t",r:"\r",b:"\b",f:"\f",v:"\v","0":"\x00"};if(f==="u"){let h=t.slice(r+2,r+6);l+=String.fromCharCode(parseInt(h,16)||0),r+=6}else l+=d[f]??f,r+=2;continue}if(u===c){o=!0,r++;break}l+=u,r++}if(!o)e.push({code:"LIPS-E001",message:"Unterminated string literal",loc:{offset:s,length:r-s}});n.push({t:"str",value:l,start:s,end:r});continue}if(i(c)){let s=r;while(r<t.length&&a(t[r]))r++;n.push({t:"id",value:t.slice(s,r),start:s,end:r});continue}let p=Zt.find((s)=>t.startsWith(s,r));if(p==="?."&&/[0-9]/.test(t[r+2]??""))p="?";if(p){n.push({t:"punct",value:p,start:r,end:r+p.length}),r+=p.length;continue}e.push({code:"LIPS-E002",message:`Unexpected character '${c}'`,loc:{offset:r,length:1}}),r++}return n.push({t:"eof",value:"",start:t.length,end:t.length}),n}class Ct{tokens;diagnostics;pos=0;constructor(t,e){this.tokens=t;this.diagnostics=e}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}next(){return this.tokens[this.pos++]??this.tokens[this.tokens.length-1]}at(t){let e=this.peek();return e.t==="punct"&&e.value===t}eat(t){if(this.at(t))return this.pos++,!0;return!1}error(t,e,n=this.peek()){return this.diagnostics.push({code:t,message:e,loc:{offset:n.start,length:Math.max(1,n.end-n.start)}}),{t:"error"}}expect(t,e){if(!this.eat(t))this.error(e,`Expected '${t}'`)}parse(){let t=this.assign();if(this.peek().t!=="eof")this.error("LIPS-E003",`Unexpected token '${this.peek().value}' after expression`);return t}isArrowAhead(){let t=this.peek();if(t.t==="id"){let e=this.peek(1);return e.t==="punct"&&e.value==="=>"}if(t.t==="punct"&&t.value==="("){let e=0,n=0;while(!0){let r=this.peek(n);if(r.t==="eof")return!1;if(r.t==="punct"&&r.value==="(")e++;if(r.t==="punct"&&r.value===")"){if(e--,e===0){let i=this.peek(n+1);return i.t==="punct"&&i.value==="=>"}}n++}}return!1}assign(){if(this.isArrowAhead()){let n=[];if(this.peek().t==="id")n.push(this.next().value);else{this.expect("(","LIPS-E004");while(!this.at(")")&&this.peek().t!=="eof"){let r=this.next();if(r.t!=="id")return this.error("LIPS-E005","Invalid arrow parameter",r);if(n.push(r.value),!this.eat(","))break}this.expect(")","LIPS-E004")}return this.expect("=>","LIPS-E004"),{t:"arrow",params:n,body:this.assign()}}let t=this.conditional(),e=this.peek();if(e.t==="punct"&&["=","+=","-=","*=","/=","%="].includes(e.value)){if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid assignment target",e);return this.next(),{t:"assign",op:e.value,target:t,value:this.assign()}}return t}conditional(){let t=this.nullish();if(this.eat("?")){let e=this.assign();return this.expect(":","LIPS-E007"),{t:"cond",test:t,cons:e,alt:this.assign()}}return t}nullish(){let t=this.or();while(this.at("??"))this.next(),t={t:"logic",op:"??",l:t,r:this.or()};return t}or(){let t=this.and();while(this.at("||"))this.next(),t={t:"logic",op:"||",l:t,r:this.and()};return t}and(){let t=this.equality();while(this.at("&&"))this.next(),t={t:"logic",op:"&&",l:t,r:this.equality()};return t}equality(){let t=this.relational();while(["===","!==","==","!="].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.relational()};return t}relational(){let t=this.additive();while(["<=",">=","<",">"].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.additive()};return t}additive(){let t=this.multiplicative();while(this.at("+")||this.at("-"))t={t:"bin",op:this.next().value,l:t,r:this.multiplicative()};return t}multiplicative(){let t=this.unary();while(this.at("*")||this.at("/")||this.at("%"))t={t:"bin",op:this.next().value,l:t,r:this.unary()};return t}unary(){if(this.at("!")||this.at("-")||this.at("+"))return{t:"unary",op:this.next().value,arg:this.unary()};if(this.at("++")||this.at("--")){let t=this.next().value,e=this.unary();if(e.t!=="id"&&e.t!=="member")return this.error("LIPS-E006","Invalid update target");return{t:"update",op:t,arg:e,prefix:!0}}return this.postfix()}postfix(){let t=this.callMember();if(this.at("++")||this.at("--")){let e=this.next().value;if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid update target");t={t:"update",op:e,arg:t,prefix:!1}}return t}callMember(){let t=this.primary();while(!0)if(this.eat(".")){let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!1,at:e.start}}else if(this.eat("?."))if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!0};else if(this.eat("[")){let e=this.peek().start,n=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:n,computed:!0,optional:!0,at:e}}else{let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!0,at:e.start}}else if(this.eat("[")){let e=this.peek().start,n=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:n,computed:!0,optional:!1,at:e}}else if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!1};else break;return t}argList(){this.expect("(","LIPS-E010");let t=[];while(!this.at(")")&&this.peek().t!=="eof")if(t.push(this.assign()),!this.eat(","))break;return this.expect(")","LIPS-E010"),t}primary(){let t=this.peek();if(t.t==="num")return this.next(),{t:"lit",v:parseFloat(t.value)};if(t.t==="str")return this.next(),{t:"lit",v:t.value};if(t.t==="id")switch(this.next(),t.value){case"true":return{t:"lit",v:!0};case"false":return{t:"lit",v:!1};case"null":return{t:"lit",v:null};case"undefined":return{t:"lit",v:void 0};case"NaN":return{t:"lit",v:NaN};case"Infinity":return{t:"lit",v:1/0};default:return{t:"id",name:t.value,at:t.start}}if(this.eat("(")){let e=this.assign();return this.expect(")","LIPS-E010"),e}if(this.eat("[")){let e=[];while(!this.at("]")&&this.peek().t!=="eof"){let n=this.eat("...");if(e.push({spread:n||void 0,value:this.assign()}),!this.eat(","))break}return this.expect("]","LIPS-E009"),{t:"arr",items:e}}if(this.eat("{")){let e=[];while(!this.at("}")&&this.peek().t!=="eof"){if(this.eat("..."))e.push({spread:!0,value:this.assign()});else{let n=this.next();if(n.t!=="id"&&n.t!=="str"&&n.t!=="num")return this.error("LIPS-E011","Invalid object key",n);if(this.eat(":"))e.push({key:String(n.value),value:this.assign(),at:n.start});else if(n.t==="id")e.push({key:n.value,value:{t:"id",name:n.value,at:n.start},at:n.start});else return this.error("LIPS-E011","Invalid shorthand property",n)}if(!this.eat(","))break}return this.expect("}","LIPS-E011"),{t:"obj",props:e}}return this.next(),this.error("LIPS-E012",t.t==="eof"?"Unexpected end of expression":`Unexpected token '${t.value}'`,t)}}function pt(t){let e=[],n=Qt(t,e);return{ast:new Ct(n,e).parse(),diagnostics:e}}function lt(t){let e=[],n=0,r=0;for(let i=0;i<t.length;i++){let a=t[i];if(a==="'"||a==='"'||a==="`"){i++;while(i<t.length&&t[i]!==a){if(t[i]==="\\")i++;i++}continue}if(a==="("||a==="["||a==="{")n++;else if(a===")"||a==="]"||a==="}")n--;else if(a===","&&n===0)e.push(t.slice(r,i)),r=i+1}return e.push(t.slice(r)),e.map((i)=>i.trim()).filter(Boolean)}var wt={__proto__:null,static:"__static",arguments:"__args__"};function R(t){switch(t.t){case"lit":if(typeof t.v==="string")return JSON.stringify(t.v);if(t.v===void 0)return"undefined";if(Number.isNaN(t.v))return"NaN";return String(t.v);case"id":return wt[t.name]??t.name;case"member":{let e=bt(t.obj);if(t.computed)return`${e}${t.optional?"?.":""}[${R(t.prop)}]`;return`${e}${t.optional?"?.":"."}${t.prop}`}case"call":return`${bt(t.callee)}${t.optional?"?.":""}(${t.args.map(R).join(",")})`;case"unary":return`(${t.op}(${R(t.arg)}))`;case"update":return t.prefix?`(${t.op}${ct(t.arg)})`:`(${ct(t.arg)}${t.op})`;case"bin":return`((${R(t.l)})${t.op}(${R(t.r)}))`;case"logic":return`((${R(t.l)})${t.op}(${R(t.r)}))`;case"cond":return`((${R(t.test)})?(${R(t.cons)}):(${R(t.alt)}))`;case"assign":return`(${ct(t.target)}${t.op}(${R(t.value)}))`;case"arrow":return`((${t.params.join(",")})=>(${R(t.body)}))`;case"arr":return`[${t.items.map((e)=>(e.spread?"...":"")+R(e.value)).join(",")}]`;case"obj":return`({${t.props.map((e)=>e.spread?`...${R(e.value)}`:`${JSON.stringify(e.key)}:${R(e.value)}`).join(",")}})`;case"error":return"undefined"}}var bt=(t)=>t.t==="member"||t.t==="call"||t.t==="id"?R(t):`(${R(t)})`;function ct(t){if(t.t==="id")return wt[t.name]??t.name;if(t.t==="member"){let e=R(t.obj);return t.computed?`${e}[${R(t.prop)}]`:`${e}.${t.prop}`}return R(t)}var It=new Map,te=["state","input","context","__static","self"];function Tt(t,e=[]){let n=`${e.join(",")}\x00${t}`,r=It.get(n);if(r)return r;let{ast:i,diagnostics:a}=pt(t);if(a.length)console.warn(`[lips-ir] expression diagnostics for "${t}":`,a);let c=`return (${R(i)});`,p=[...te,"__args__",...e],s=Function(...p,c),l={source:t,run(o){let u=o.scope||{};return s(o.state,o.input,o.context,o.static,o.self,o.arguments,...e.map((f)=>u[f]))}};return It.set(n,l),l}var kt={__proto__:null,Math,JSON,Object,Array,String,Number,Boolean,Date,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,console},V=Symbol("lips.ended");function Ot(t,e){let n=e.scope||Object.create(null),r=(s,l)=>{for(let o of l)if(s in o)return o[s];if(s in n)return n[s];switch(s){case"state":return e.state;case"input":return e.input;case"context":return e.context;case"static":return e.static;case"self":return e.self;case"arguments":return e.arguments}if(s in kt)return kt[s];return},i=(s,l,o)=>{for(let u of o)if(s in u)return u[s]=l,l;return n[s]=l,l},a=(s,l)=>{switch(s.t){case"lit":return s.v;case"id":return r(s.name,l);case"member":case"call":{let o=c(s,l);return o===V?void 0:o}case"unary":{let o=a(s.arg,l);switch(s.op){case"!":return!o;case"-":return-o;case"+":return+o}}case"update":{let o=a(s.arg,l),u=s.op==="++"?o+1:o-1;return p(s.arg,u,l),s.prefix?u:o}case"bin":{let o=a(s.l,l),u=a(s.r,l);switch(s.op){case"+":return o+u;case"-":return o-u;case"*":return o*u;case"/":return o/u;case"%":return o%u;case"<":return o<u;case">":return o>u;case"<=":return o<=u;case">=":return o>=u;case"==":return o==u;case"!=":return o!=u;case"===":return o===u;case"!==":return o!==u}return}case"logic":{let o=a(s.l,l);switch(s.op){case"&&":return o?a(s.r,l):o;case"||":return o?o:a(s.r,l);case"??":return o!=null?o:a(s.r,l)}}case"cond":return a(s.test,l)?a(s.cons,l):a(s.alt,l);case"assign":{let o=a(s.value,l);if(s.op!=="="){let u=a(s.target,l);switch(s.op){case"+=":o=u+o;break;case"-=":o=u-o;break;case"*=":o=u*o;break;case"/=":o=u/o;break;case"%=":o=u%o;break}}return p(s.target,o,l)}case"arrow":return(...o)=>{let u=Object.create(null);return s.params.forEach((f,d)=>u[f]=o[d]),a(s.body,[u,...l])};case"arr":{let o=[];for(let u of s.items){let f=a(u.value,l);u.spread?o.push(...f):o.push(f)}return o}case"obj":{let o={};for(let u of s.props)if(u.spread)Object.assign(o,a(u.value,l));else o[u.key]=a(u.value,l);return o}case"error":return}},c=(s,l)=>{if(s.t!=="member"&&s.t!=="call")return a(s,l);let o=s.t==="member"?s:s.callee.t==="member"?s.callee:null,u,f;if(o){if(u=c(o.obj,l),u===V||o.optional&&u==null)return V;if(f=u[o.computed?a(o.prop,l):o.prop],s===o)return f}else if((f=c(s.callee,l))===V)return V;let d=s;return d.optional&&f==null?V:Reflect.apply(f,u,d.args.map((h)=>a(h,l)))},p=(s,l,o)=>{if(s.t==="id")return i(s.name,l,o);if(s.t==="member"){let u=a(s.obj,o),f=s.computed?a(s.prop,o):s.prop;if(u!=null)u[f]=l;return l}return l};return a(t,[])}var P=null,J=0,X=new Set;function ee(){while(X.size){let t=[...X];X.clear(),J++;try{for(let e of t)!e.disposed&&e.run()}finally{J--}}}function ne(t){J++;try{return t()}finally{J--,!J&&ee()}}function I(t){let e=new Set,n=()=>{if(J){for(let c of e)X.add(c);return}for(let c of[...e])!c.disposed&&c.run()};return[()=>{if(P&&!P.disposed)e.add(P),P.deps.add(e);return t},(c)=>{if(Object.is(c,t))return;t=c,n()},()=>n()]}function A(t){let e={deps:new Set,disposed:!1,run(){if(e.disposed)return;for(let r of e.deps)r.delete(e);e.deps.clear();let n=P;P=e;try{t()}finally{P=n}}};return e.run(),{dispose(){e.disposed=!0;for(let n of e.deps)n.delete(e);e.deps.clear()}}}function k(t){let e=P;P=null;try{return t()}finally{P=e}}var jt=Symbol("lips.reactive"),Y=Symbol("lips.collection"),Pt=new WeakMap,ft=(t)=>t!==null&&typeof t==="object"&&(Array.isArray(t)||Object.getPrototypeOf(t)===Object.prototype),Z=(t)=>t instanceof Map||t instanceof Set||!!(t&&typeof t==="object"&&t[Y]),re=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"]),se=new Set(["set","delete","clear","add"]),ut=Symbol("lips.keys"),Lt=new WeakMap;function Mt(t,e){let n=t[Y];if(n)return n.notify.add(e),t;let r=Pt.get(t);if(r)return r[Y].notify.add(e),r;let i={raw:t,notify:new Set([e])},a=()=>i.notify.forEach((p)=>p()),c=new Proxy(t,{get(p,s){if(s===Y)return i;let l=p[s];if(typeof l!=="function")return l;if(typeof s==="string"&&se.has(s))return(...f)=>{let d=l.apply(p,f);return a(),d};let o=(f)=>ft(f)?dt(f,a):Z(f)?Mt(f,a):f,u=p instanceof Map;if(s==="get")return(f)=>o(p.get(f));if(s==="forEach")return(f,d)=>p.forEach((h,g)=>f.call(d,o(h),g,c));if(s==="values"||!u&&(s==="keys"||s===Symbol.iterator))return function*(){for(let f of p.values())yield o(f)};if(s==="entries"||u&&s===Symbol.iterator)return u?function*(){for(let[f,d]of p.entries())yield[f,o(d)]}:function*(){for(let f of p.values())yield[o(f),o(f)]};return l.bind(p)}});return Pt.set(t,c),c}function ie(t){let e=Lt.get(t);if(e)return e;let n=new Map,r=(o)=>{let u=n.get(o);if(!u)u=I(0),n.set(o,u);u[0]()},i=(o)=>n.get(o)?.[2](),a=new Map,c=(o)=>{let u=a.get(o);if(!u)u=()=>i(o),a.set(o,u);return u},p=()=>ne(()=>{for(let o of n.values())o[2]()}),s=!1,l=new Proxy(t,{get(o,u){let f=o[u];if(typeof u==="symbol")return f;if(Array.isArray(o)&&re.has(u)&&typeof f==="function")return(...d)=>{s=!0;try{return f.apply(o,d)}finally{s=!1,p()}};if(typeof f==="function")return f;return r(u),ft(f)||Z(f)?dt(f,c(u)):f},set(o,u,f){let d=u in o,h=o[u];if(o[u]=f,s)return!0;if(!Object.is(h,f))i(u);if(!d)i(ut),Array.isArray(o)&&i("length");return!0},deleteProperty(o,u){let f=u in o;if(delete o[u],!s&&f)i(u),i(ut);return!0},has(o,u){return typeof u!=="symbol"&&r(u),u in o},ownKeys(o){return r(ut),Reflect.ownKeys(o)}});return Lt.set(t,l),l}function dt(t,e){if(Z(t))return Mt(t,e);if(!ft(t))return t;return ie(t)}function T(t,e=!1){if(t[jt])return t;let n=new Map,[r,,i]=I(0),a=(c,p)=>{let s=n.get(c);if(!s)s=I(p),n.set(c,s);return s};return new Proxy(t,{get(c,p){if(p===jt)return!0;if(typeof p==="string"){let s=a(p,c[p]);return e?dt(s[0](),s[2]):s[0]()}return c[p]},set(c,p,s){let l=p in c,o=c[p];if(c[p]=s,typeof p!=="string")return!0;l||i();let u=a(p,s);return Object.is(o,s)&&Z(s)?u[2]():u[1](s),!0},has(c,p){return p in c},ownKeys(c){return r(),Reflect.ownKeys(c)},deleteProperty(c,p){let s=p in c;return delete c[p],typeof p==="string"&&n.get(p)?.[1](void 0),s&&i(),!0}})}var Nt=new WeakMap,_t=(t)=>t!==null,oe={__proto__:null,value:(t)=>t??"",checked:_t,selected:_t},ht={clone(t){let e=Nt.get(t);if(!e)e=document.createElement("template"),e.innerHTML=t.html,Nt.set(t,e);return e.content.cloneNode(!0)},fragment:()=>document.createDocumentFragment(),element:(t)=>document.createElement(t),text:(t)=>document.createTextNode(t),marker:(t)=>document.createComment(t),child:(t,e)=>t.childNodes[e],next:(t)=>t.nextSibling,range(t,e){let n=[];for(let r=t;r;r=r.nextSibling)if(n.push(r),r===e)break;return n},insert:(t,e,n)=>{t.insertBefore(e,n)},insertAfter(t,e){let n=t.parentNode;if(!n)return;let r=t;for(let i of e)n.insertBefore(i,r.nextSibling),r=i},remove:(t)=>t.remove(),isElement:(t)=>t.nodeType===1,connected:(t)=>t.isConnected,precedes:(t,e)=>!!(t.compareDocumentPosition(e)&4),attr(t,e,n){n===null?t.removeAttribute(e):t.setAttribute(e,n);let r=oe[e];r&&e in t&&(t[e]=r(n))},setText:(t,e)=>{t.data=e},content:(t,e)=>{t.textContent=e},html:(t,e)=>{t.innerHTML=e},styleVar:(t,e,n)=>n===null?t.style.removeProperty(e):t.style.setProperty(e,n),scope:(t,e)=>{t.hasAttribute("rel")||t.setAttribute("rel",e)},listen(t,e,n){let r=e.split(".")[0],i=e.includes(".outside"),a=i?document:t,c=i||e.includes(".capture"),p=!i&&e.includes(".stop"),s=(l)=>i&&t.contains(l.target)||(p&&l.stopPropagation(),n(l));return a.addEventListener(r,s,c),()=>a.removeEventListener(r,s,c)},keepFocus(){let t=document.activeElement;return()=>{t&&t.isConnected&&t!==document.activeElement&&t.focus()}}};function q(t){let e=t.split("-"),n=[];while(e.length)n.push(e.join("-")),e.pop(),e[e.length-1]?.length===1&&e.pop();return n}function Q(t,e){let n=new Map(Object.entries(t.names).map(([r,i])=>[r.toLowerCase(),i]));for(let r of q(e.toLowerCase()))if(n.has(r))return n.get(r);return t.names[t.default]??""}var M=(t,e)=>t==null?t:("e"in t)?{$:e[t.e]}:t,gt=(t,e)=>({...t,e:e[t.e]});function tt(t,e){switch(t.t){case"macro":return{t:t.t,name:t.name,args:t.args,sets:t.sets.map((n)=>("spread"in n)?{spread:e[n.spread]}:{name:n.name,ci:M(n.ci,e)}),block:N(t.block,e)};case"if":return{t:t.t,branches:t.branches.map((n)=>({when:n.when==null?null:e[n.when],block:N(n.block,e)}))};case"for":return{t:t.t,args:t.args,of:t.of===void 0?void 0:e[t.of],from:M(t.from,e),to:M(t.to,e),by:M(t.by,e),block:N(t.block,e)};case"switch":return{t:t.t,on:e[t.on],cases:t.cases.map((n)=>({is:n.is===null?null:M(n.is,e),block:N(n.block,e)}))};case"async":return{t:t.t,awaitE:e[t.awaitE],then:t.then&&{args:t.then.args,block:N(t.then.block,e)},catch:t.catch&&{args:t.catch.args,block:N(t.catch.block,e)},loading:t.loading&&N(t.loading,e)};case"let":return{t:t.t,const:t.const,vars:Object.fromEntries(Object.entries(t.vars).map(([n,r])=>[n,M(r,e)]))};case"log":return{t:t.t,e:e[t.e]};case"provide":return{t:t.t,vars:Object.fromEntries(Object.entries(t.vars).map(([n,r])=>[n,M(r,e)])),lang:M(t.lang,e),block:N(t.block,e)};case"comp":case"dynamic":return{t:t.t,name:t.t==="comp"?t.name:void 0,tag:t.t==="dynamic"?e[t.tag]:void 0,inputs:Object.fromEntries(Object.entries(t.inputs).map(([n,r])=>[n,M(r,e)])),spreads:t.spreads.map((n)=>e[n]),events:t.events.map((n)=>({name:n.name,e:e[n.e]})),contents:t.contents&&{args:t.contents.args,block:N(t.contents.block,e)}}}}var N=(t,e)=>({html:t.html,scope:t.scope,binds:t.binds.map((n)=>gt(n,e)),blocks:t.blocks.map((n)=>tt(n,e))}),At=(t,e,n,r)=>t.t===n.t&&JSON.stringify(tt(t,e))===JSON.stringify(tt(n,r)),$t=(t,e,n,r)=>JSON.stringify(t.map((i)=>gt(i,e)))===JSON.stringify(n.map((i)=>gt(i,r))),Ht=(t,e,n,r)=>{let i=(a,c)=>JSON.stringify(a.blocks.filter((p)=>p.t==="let").map((p)=>tt(p,c)));return i(t,e)===i(n,r)};function O(t,e=new WeakMap){if(t===null||typeof t!=="object")return t;let n=t;if(e.has(n))return e.get(n);if(Array.isArray(n)){let a=[];e.set(n,a);for(let c of n)a.push(O(c,e));return a}if(n instanceof Map){let a=new Map;return e.set(n,a),n.forEach((c,p)=>a.set(O(p,e),O(c,e))),a}if(n instanceof Set){let a=new Set;return e.set(n,a),n.forEach((c)=>a.add(O(c,e))),a}if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(ArrayBuffer.isView(n))return new n.constructor(n);let r=Object.getPrototypeOf(n);if(r!==Object.prototype&&r!==null)return t;let i=Object.create(r);e.set(n,i);for(let a of Reflect.ownKeys(n)){let c=Object.getOwnPropertyDescriptor(n,a);"value"in c&&(c.value=O(c.value,e)),Object.defineProperty(i,a,c)}return i}var Wt=Symbol("lips.slot"),ae=(t)=>!!t&&typeof t==="object"&&t[Wt]===!0;function Vt(t,e,n){if(!e||typeof t.onInput!=="function")return()=>{};let r=!0,i=!1,a=!0,{dispose:c}=A(()=>{for(let p of Object.keys(e))e[p];if(r){r=!1;return}if(i)return;i=!0,Promise.resolve().then(()=>{if(i=!1,!a)return;k(()=>{try{t.onInput(e)}catch(p){n.onError(p)}})})});return()=>{a=!1,c()}}function Jt(t){let e=!1,n=!1,r=(i)=>typeof t.onError==="function"?t.onError(i):console.error("[lips:ir]",i);return{onError:r,ready(){n=!0},notifyUpdate(){if(!n||e)return;e=!0,Promise.resolve().then(()=>{e=!1;try{typeof t.onUpdate==="function"&&t.onUpdate(),typeof t.onRender==="function"&&t.onRender()}catch(i){r(i)}})}}}var z=[];function yt(){let t=!0;while(t){t=!1;for(let e of[...z].reverse()){if(!e.live())continue;let n=z.indexOf(e);if(n<0)continue;z.splice(n,1),e.fn(),t=!0}}}var Ft=new Map;function ce(t){let e=Ft.get(t);if(!e)e=pt(t).ast,Ft.set(t,e);return e}var G=(t)=>t.join(",");function Bt(t,e,n){let r=e;for(let i of n)r=t.child(r,i);return r}var D=(t,e)=>t.range(e.start,e.end),Dt=(t,e,n,r)=>r===e||t.precedes(e,r)&&t.precedes(r,n);function Kt(t,e){e.gen++;for(let r of e.wiring)r();e.wiring=[];let n=t.fragment();for(let r of D(t,e.inst))t.insert(n,r,null)}function L(t,e,n){return t.insertAfter(e,D(t,n)),z.length&&t.connected(e)&&yt(),n}var mt=(t,e)=>D(t,e).filter((n)=>t.isElement(n));function qt(t,e,n){for(let r of mt(t,e))t.scope(r,n)}function pe(t,e,n,r,i=""){for(let a of e)t.styleVar(a,n,r===null||r===void 0||r===!1?null:r+i)}function Gt(t,e,n,r,i){qt(t,n,r);let a=i.css?e.createStylesheet?.(r,i.css):void 0;return a?()=>a.clear():void 0}function le(t){for(let e of t.bindHandles)e.dispose();for(let e of t.childHandles)e.dispose()}function C(t,e){if(!e)return;le(e);for(let n of D(t,e))t.remove(n,!0)}var Ut=(t,e,n,r)=>{let i=t.self.refs||={},a="",c=()=>{i[a]===e&&delete i[a]},p=r(()=>{c(),i[a=String(n())]=e});return()=>{p.dispose(),c()}},et=(t,e,n,r)=>t.attr(e,n,r==null||r===!1&&!n.startsWith("aria-")?null:r===!0&&!n.startsWith("aria-")?"":String(r)),B=(t,e,n)=>Object.defineProperty(t,e,{get:n,enumerable:!0,configurable:!0}),ue=Symbol.for("lips.self"),zt=Symbol("lips.ctx.layer");function fe(t,e,n,r){for(let i=t;i;i=Object.getPrototypeOf(i)){let c=i[zt]?.get(e);if(c){c(n);return}}r?.(e,n)}function Xt(t,e){let n=new Map,r=(s,...l)=>n.get(s)?.forEach((o)=>o(...l)),i,a=()=>null;return{proto:{[ue]:!0,get node(){let s=a();return s?mt(t,s):[]},get lang(){return e()},pick:(s)=>Q(s,e()),emit:r,emitLocal:r,on(s,l){return n.set(s,[...n.get(s)||[],l]),i},once(s,l){let o=(...u)=>{i.off(s,o),l(...u)};return i.on(s,o)},off(s,l){if(!l)n.delete(s);else{let o=(n.get(s)||[]).filter((u)=>u!==l);o.length?n.set(s,o):n.delete(s)}return i}},bind:(s,l)=>(i=s,a=l,s)}}class nt{ir;options;hooks;live;constructor(t,e,n,r=[]){this.ir=t;this.options=e;this.hooks=n;this.live=r;this.h=e.host||ht}h;pool=null;salvaged=[];withSalvage(t,e){let n=this.pool;this.pool=t;try{return e()}finally{this.pool=n;for(let r of t)!r.claimed&&r.teardown()}}claim(t,e){let n=this.pool?.find((r)=>!r.claimed&&r.name===t&&r.key===e);if(!n)return;return n.claimed=!0,this.salvaged.push(t),n}keyOf(t,e,n){let r=t.key;return r===void 0?void 0:("lit"in r)?r.lit:k(()=>this.runner(r.e,n)(e))}guarded(t){let e=!0;return A(()=>{try{t()}catch(n){this.hooks?this.hooks.onError(n):console.error("[lips:ir]",n)}e?e=!1:this.hooks?.notifyUpdate()})}bindStyle(t,e,n){if(!t.binds.length)return()=>{};let r=mt(this.h,e),i=t.binds.map((a)=>{let c=this.srcRunner(t.exprs[a.e],[]);return this.guarded(()=>pe(this.h,r,a.prop,c(n),a.u))});return()=>{for(let a of i)a.dispose()}}runner(t,e){return this.srcRunner(this.ir.exprs[t],e)}srcRunner(t,e){if(this.options.guard)return this.options.guard.run(t);if(this.options.mode==="interpreted"){let r=ce(t);return(i)=>Ot(r,i)}let n=Tt(t,e);return(r)=>n.run(r)}renderBlock(t,e){let n=this.h,r=n.clone(t),i=new Map,a=t.binds.map((d)=>{let h=Bt(n,r,d.p);return i.set(G(d.p),h),h}),c=t.blocks.map((d)=>{let h=Bt(n,r,d.p);return i.set(G(d.p),h),h}),p=n.marker("^"),s=n.marker("$");n.insert(r,s,null),n.insert(r,p,n.child(r,0));let l=Object.create(e.scope??null),o={...e,scope:l},u={start:p,end:s,block:t,exprs:this.ir.exprs,penv:e,benv:o,pathNodes:i,bindHandles:[],childHandles:[]};t.blocks.forEach((d,h)=>{if(d.t!=="let")return;let g=[];for(let[m,x]of Object.entries(d.vars))if("lit"in x){let[E]=I(x.lit);B(l,m,E)}else{let[E,v]=I(void 0);B(l,m,E);let y=this.runner(x.e,t.scope);g.push(this.guarded(()=>v(y(o))).dispose)}u.childHandles[h]={child:d,exprs:this.ir.exprs,anchor:c[h],dispose:()=>g.forEach((m)=>m())}});let f=(d)=>d.t==="attr"&&d.name==="value";return u.bindHandles=t.binds.map((d,h)=>f(d)?null:this.bindOne(d,a[h],o,t.scope)),t.blocks.forEach((d,h)=>{if(d.t==="let")return;u.childHandles[h]={child:d,exprs:this.ir.exprs,anchor:c[h],dispose:this.execBlock(d,c[h],o,t.scope)}}),t.binds.forEach((d,h)=>{if(f(d))u.bindHandles[h]=this.bindOne(d,a[h],o,t.scope)}),u}bindOne(t,e,n,r,i){let a=this.h;switch(t.t){case"text":{let c=i??a.text("");!i&&a.insertAfter(e,[c]);let p=this.runner(t.e,r),s=t.i18n?this.options.i18n:void 0,l=this.guarded(()=>{let o=p(n),u=o==null?"":String(o);a.setText(c,s?s.translate(u,t.ik,n.lang?.()):u)});return{bind:t,node:e,textNode:c,dispose:l.dispose}}case"attr":{let c=this.runner(t.e,r),p=t.i18n?this.options.i18n:void 0,s=this.guarded(()=>{let l=c(n);et(a,e,t.name,p&&l!=null?p.translate(String(l),t.ik,n.lang?.()):l)});return{bind:t,node:e,dispose:s.dispose}}case"prop":{let c=this.runner(t.e,r);if(t.name==="ref")return{bind:t,node:e,dispose:Ut(n,e,()=>c(n),(s)=>this.guarded(s))};if(t.name==="format"){let s=t.ref||"",l=this.guarded(()=>{let o=c(n),u=this.options.i18n?.format(s,o,n.lang?.());a.content(e,u==null?"":String(u))});return{bind:t,node:e,dispose:l.dispose}}let p=this.guarded(()=>{let s=c(n),l=s==null?"":String(s);t.name==="html"&&a.html?a.html(e,l):a.content(e,l)});return{bind:t,node:e,dispose:p.dispose}}case"event":{let c=this.eventDispatcher(this.ir.exprs[t.e],r,n);return{bind:t,node:e,dispose:a.listen(e,t.name,c)}}case"spread":{let c=this.runner(t.e,r),p=new Set,s=this.guarded(()=>{let l=c(n)||{},o=new Set(Object.keys(l));for(let u of p)!o.has(u)&&a.attr(e,u,null);for(let u of o)et(a,e,u,l[u]);p=o});return{bind:t,node:e,dispose:s.dispose}}}}swapBlock(t,e,n,r){if(t.block.html!==e.html||JSON.stringify(t.block.scope)!==JSON.stringify(e.scope)||!Ht(t.block,t.exprs,e,this.ir.exprs))return this.rebuild(t,e,n,r);if(!$t(t.block.binds,t.exprs,e.binds,this.ir.exprs)){let i=e.binds.map((p)=>t.pathNodes.get(G(p.p)));if(i.some((p)=>!p))return this.rebuild(t,e,n,r);let a=new Map;t.bindHandles.forEach((p)=>p.textNode&&a.set(G(p.bind.p),p.textNode)),t.bindHandles.forEach((p)=>p.dispose());let c=new Set;t.bindHandles=e.binds.map((p,s)=>{let l=G(p.p),o=p.t==="text"?a.get(l):void 0;return o&&c.add(l),this.bindOne(p,i[s],t.benv,e.scope,o)}),a.forEach((p,s)=>!c.has(s)&&this.h.remove(p,!0)),n.push({kind:"binds",path:r})}for(let i=0;i<e.blocks.length;i++){let a=e.blocks[i],c=t.childHandles[i];if(a.t==="let")continue;if(c&&At(c.child,c.exprs,a,this.ir.exprs))continue;let p=this.live.filter((s)=>Dt(this.h,c.anchor,t.childHandles[i+1]?.anchor??t.end,s.anchor));for(let s of p)Kt(this.h,s);c?.dispose(),t.childHandles[i]={child:a,exprs:this.ir.exprs,anchor:c.anchor,dispose:this.withSalvage(p,()=>this.execBlock(a,c.anchor,t.benv,e.scope))},n.push({kind:"block",path:`${r}/${i}`})}return t.block=e,t.exprs=this.ir.exprs,t}rebuild(t,e,n,r){let i=this.live.filter((c)=>Dt(this.h,t.start,t.end,c.anchor));for(let c of i)Kt(this.h,c);let a=this.withSalvage(i,()=>this.renderBlock(e,t.penv));return L(this.h,t.end,a),C(this.h,t),n.push({kind:"skeleton",path:r}),a}execBlock(t,e,n,r){let i=this.h,a=[];switch(t.t){case"if":{let c=t.branches.map((o)=>o.when!=null?this.runner(o.when,r):null),p=null,s=-2,l=this.guarded(()=>{let o=-1;for(let u=0;u<t.branches.length;u++){let f=c[u];if(!f||f(n)){o=u;break}}if(o===s)return;s=o,k(()=>{if(C(i,p),p=null,o>=0)p=L(i,e,this.renderBlock(t.branches[o].block,n))})});a.push(()=>{l.dispose(),C(i,p)});break}case"switch":{let c=this.runner(t.on,r),p=t.cases.map((u)=>u.is&&("e"in u.is)?this.runner(u.is.e,r):null),s=null,l=-2,o=this.guarded(()=>{let u=c(n),f=-1,d=-1;for(let h=0;h<t.cases.length;h++){let g=t.cases[h];if(g.is===null){d=h;continue}let m="lit"in g.is?g.is.lit:p[h](n);if(Array.isArray(m)?m.includes(u):m===u){f=h;break}}if(f===-1)f=d;if(f===l)return;l=f,k(()=>{if(C(i,s),s=null,f>=0)s=L(i,e,this.renderBlock(t.cases[f].block,n))})});a.push(()=>{o.dispose(),C(i,s)});break}case"macro":{let c=Object.create(n.scope??null),p=T({}),s={};for(let f of t.args)s[f]=I(void 0),B(c,f,s[f][0]);let l=t.sets.map((f)=>{if("spread"in f)return{kind:"spread",run:this.runner(f.spread,r)};if("lit"in f.ci){let h=f.ci.lit;return{kind:"value",name:f.name,value:()=>h}}let d=this.runner(f.ci.e,r);return{kind:"value",name:f.name,value:()=>d(n)}}),o=new Set;a.push(this.guarded(()=>{let f={};for(let d of l)if(d.kind==="spread"){let h=d.run(n);if(h&&typeof h==="object")for(let[g,m]of h instanceof Map?h:Object.entries(h))f[g]=m}else f[d.name]=d.value();k(()=>{for(let h of t.args)s[h][1](f[h]);let d=new Set(Object.keys(f));for(let h of o)!d.has(h)&&delete p[h];for(let h of d)p[h]=f[h];o=d})}).dispose);let u=L(i,e,this.renderBlock(t.block,{...n,arguments:p,scope:c}));a.push(()=>C(i,u));break}case"for":this.execFor(t,e,n,r,a);break;case"async":{let c=this.runner(t.awaitE,r),p=null,s=0,l=(u,f)=>{if(C(i,p),p=null,!u)return;let d="block"in u,h=Object.create(n.scope??null);if(d&&u.args[0]!==void 0){let[g]=I(f);B(h,u.args[0],g)}p=L(i,e,this.renderBlock(d?u.block:u,{...n,scope:h}))},o=this.guarded(()=>{let u;try{u=c(n)}catch(d){u=Promise.reject(d)}let f=++s;k(()=>{t.loading?l(t.loading):l(void 0),Promise.resolve(u).then((d)=>f===s&&k(()=>l(t.then,d)),(d)=>f===s&&k(()=>l(t.catch,d)))})});a.push(()=>{s++,o.dispose(),C(i,p)});break}case"provide":{let c=Object.create(n.context??null),p=new Map;Object.defineProperty(c,zt,{value:p});for(let[o,u]of Object.entries(t.vars)){let[f,d]=I("lit"in u?u.lit:void 0);if(B(c,o,f),p.set(o,d),"lit"in u)continue;let h=this.runner(u.e,r);a.push(this.guarded(()=>d(h(n))).dispose)}let s=n.lang;if(t.lang)if("lit"in t.lang){let o=String(t.lang.lit);s=()=>o}else{let[o,u]=I(void 0),f=this.runner(t.lang.e,r);a.push(this.guarded(()=>u(f(n))).dispose),s=()=>o()??n.lang?.()}let l=L(i,e,this.renderBlock(t.block,{...n,context:c,lang:s}));a.push(()=>C(i,l));break}case"log":{let c=lt(this.ir.exprs[t.e]).map((p)=>this.srcRunner(p,r));a.push(this.guarded(()=>console.log(...c.map((p)=>p(n)))).dispose);break}case"comp":{let c=this.options.components?.[t.name];c?this.execComponent(c,t,e,n,r,a,t.name):this.execElement(t,e,n,r,a);break}case"dynamic":{let c=this.runner(t.tag,r),p=[],s=Symbol("init"),l=this.guarded(()=>{let o=c(n);if(o===s)return;s=o,k(()=>{for(let f of p)f();if(p=[],o==null)return;if(ae(o)){let f={};for(let[h,g]of Object.entries(t.inputs)){let m="lit"in g?void 0:this.runner(g.e,r);f[h]=m?()=>m(n):()=>g.lit}let d=L(i,e,o.render(f,n));p.push(()=>C(i,d));return}let u=typeof o==="string"?this.options.components?.[o]:o&&typeof o==="object"?o.ir?o:this.options.resolveTemplate?.(o):void 0;if(u)this.execComponent(u,t,e,n,r,p,typeof o==="string"?o:"#dynamic");else if(typeof o==="string")this.execElement({...t,name:o},e,n,r,p)})});a.push(()=>{l.dispose();for(let o of p)o()});break}}return()=>a.forEach((c)=>c())}execFor(t,e,n,r,i){let a=this.h,c=t.of!==void 0?this.runner(t.of,r):null,p=t.by&&"e"in t.by?this.runner(t.by.e,r):null,s=t.by&&"lit"in t.by?String(t.by.lit).split("."):null,l=(g,m)=>g===void 0?void 0:("lit"in g)?g.lit:this.runner(g.e,r)(m),o=[],u=0,f=new Map,d=()=>{if(c===null){let x=Number(l(t.from,n)??0),E=Number(l(t.to,n)??x),v=x<=E,y=[];for(let b=x;v?b<=E:b>=E;v?b++:b--)y.push({key:b,values:[b]});return y}let g=c(n),m=(x,E,v)=>{if(p){let y=p(n);return typeof y==="function"?y(x,v):E}if(s)return s.reduce((y,b)=>y?.[b],x);return E};if(Array.isArray(g))return g.map((x,E)=>({key:m(x,E,E),values:[x,E]}));if(g instanceof Map)return[...g.entries()].map(([x,E],v)=>({key:x,values:[x,E,v]}));if(g instanceof Set)return[...g].map((x,E)=>({key:m(x,x,E),values:[x,E]}));if(g&&typeof g==="object")return Object.entries(g).map(([x,E],v)=>({key:x,values:[x,E,v]}));return[]},h=this.guarded(()=>{let g=d();k(()=>{let m=new Set,x=[],E=++u;for(let y of g){let b=y.key;if(m.has(b))console.warn(`<for> duplicate key '${String(b)}' — falling back to positional identity`),b=`#dup:${x.length}`;m.add(b);let K=f.get(b);if(K)K.sigs.forEach(([H,_,U],w)=>{let j=y.values[w];Object.is(H(),j)&&typeof j==="object"&&j!==null?U():_(j)}),K.pass=E,x.push(K);else{let H=Object.create(n.scope??null),_=y.values.map((j)=>I(j));t.args.forEach((j,S)=>_[S]&&B(H,j,_[S][0]));let U=this.renderBlock(t.block,{...n,scope:H}),w={key:b,sigs:_,inst:U,pass:E};f.set(b,w),x.push(w)}}for(let y of o)if(y.pass!==E)f.delete(y.key),C(a,y.inst);let v=e;for(let y of x){if(a.next(v)!==y.inst.start)L(a,v,y.inst);v=y.inst.end}o=x})});i.push(()=>{h.dispose();for(let g of o)C(a,g.inst);o=[],f.clear()})}wireInputs(t,e,n,r,i,a){for(let[c,p]of Object.entries(t.inputs))if(a?.add(c),"lit"in p)r[c]=p.lit;else{let s=this.runner(p.e,n);i.push(this.guarded(()=>r[c]=s(e)).dispose)}for(let c of t.spreads){let p=this.runner(c,n);i.push(this.guarded(()=>{let s=p(e)||{};k(()=>Object.entries(s).forEach(([l,o])=>{a?.add(l),r[l]=o}))}).dispose)}}wireEvents(t,e,n,r,i){t?.forEach((a)=>{let c=this.eventDispatcher(this.ir.exprs[a.e],n,e);r.on(a.name,c),i.push(()=>r.off(a.name,c))})}slotRenderer(t,e){let n=this;return{[Wt]:!0,args:t.args,render(r,i){let a=Object.create(e.scope??null);return t.args.forEach((c)=>B(a,c,r?.[c]??(()=>{return}))),n.renderBlock(t.block,i?{...e,scope:a,context:i.context,lang:i.lang}:{...e,scope:a})}}}adoptComponent(t,e,n,r,i,a){let c=[],p=new Set;if(this.wireInputs(e,r,i,t.input,c,p),e.contents)t.input.renderer=this.slotRenderer(e.contents,r),p.add("renderer");for(let l of Object.keys(t.input))!p.has(l)&&delete t.input[l];this.wireEvents(e.events,r,i,t.self,c),t.wiring=c,t.anchor=n;let s=t.gen;L(this.h,n,t.inst),a.push(()=>{if(s!==t.gen)return;for(let l of t.wiring)l();t.wiring=[],t.teardown()})}execComponent(t,e,n,r,i,a,c){let p=this.pool?.length?this.claim(c,this.keyOf(e.inputs,r,i)):void 0;if(p)return this.adoptComponent(p,e,n,r,i,a);let s=T({}),l=[];if(this.wireInputs(e,r,i,s,l),e.contents)s.renderer=this.slotRenderer(e.contents,r);let o=T(O(t.state||{}),t.deep??!1),u=O(t.statics??{}),f=null,d=this,h=Xt(this.h,()=>r.lang?.()??d.options.i18n?.lang()??""),g=h.bind(Object.assign(Object.create(h.proto),{...this.options.expose||{},state:o,input:s,static:u,context:r.context,refs:{},setContext(S,F){let W=(ot,at)=>fe(r.context,ot,at,d.options.expose?.setContext);typeof S==="string"?W(S,F):Object.entries(S||{}).forEach(([ot,at])=>W(ot,at))}}),()=>f);t.handlers&&Object.entries(t.handlers).forEach(([S,F])=>g[S]=F.bind(g)),this.wireEvents(e.events,r,i,g,l);let m=Jt(g);try{typeof g.onCreate==="function"&&g.onCreate()}catch(S){m.onError(S)}try{Object.keys(s).length&&typeof g.onInput==="function"&&g.onInput(s)}catch(S){m.onError(S)}let x=Vt(g,s,m),E={state:o,input:s,context:r.context,lang:r.lang,static:u,self:g,scope:void 0},v=new nt(t.ir,this.options,m),y=v.renderBlock(t.ir.root,E);f=y;let b=t.stylesheet?Gt(this.h,this.options,y,t.stylesheet.nsp||t.nsp||"lips",t.stylesheet):void 0,K=t.stylesheet?v.bindStyle(t.stylesheet,y,E):void 0;L(this.h,n,y),m.ready();try{typeof g.onMount==="function"&&g.onMount(),typeof g.onRender==="function"&&g.onRender(),g.emit("component:mount")}catch(S){m.onError(S)}let H;if(t.context?.length&&typeof g.onContext==="function"){let S=!0,{dispose:F}=A(()=>{for(let W of t.context)E.context?.[W];if(S){S=!1;return}k(()=>{try{g.onContext()}catch(W){m.onError(W)}})});H=F}let _=!1;z.push({live:()=>this.h.connected(y.start),fn:()=>{_=!0;try{typeof g.onAttach==="function"&&g.onAttach(),g.emit("component:attached")}catch(S){m.onError(S)}}}),this.h.connected(y.start)&&yt();let U=!1,w={name:c,key:s.key,self:g,input:s,inst:y,anchor:n,wiring:l,gen:0,claimed:!1,teardown:()=>{if(U)return;U=!0;let S=this.live.indexOf(w);S>-1&&this.live.splice(S,1),H?.(),x(),K?.(),b?.(),C(this.h,y);try{if(_)typeof g.onDetach==="function"&&g.onDetach(),g.emit("component:detached");typeof g.onDestroy==="function"&&g.onDestroy(),g.emit("component:destroy")}catch(F){m.onError(F)}}};this.live.push(w);let j=w.gen;a.push(()=>{if(j!==w.gen)return;for(let S of w.wiring)S();w.wiring=[],w.teardown()})}execElement(t,e,n,r,i){let a=this.h,c=a.element(t.name);for(let[p,s]of Object.entries(t.inputs))if(p==="@ref"){let l="lit"in s?()=>s.lit:this.runner(s.e,r);i.push(Ut(n,c,()=>l(n),(o)=>this.guarded(o)))}else if(p[0]==="@")i.push(this.contentOf(c,p,s,n,r));else if("lit"in s)et(a,c,p,s.lit);else{let l=this.runner(s.e,r);i.push(this.guarded(()=>et(a,c,p,l(n))).dispose)}for(let p of t.events)i.push(a.listen(c,p.name,this.eventDispatcher(this.ir.exprs[p.e],r,n)));if(t.contents){let p=this.renderBlock(t.contents.block,n);for(let s of D(a,p))a.insert(c,s,null);i.push(()=>C(a,p))}a.insertAfter(e,[c]),i.push(()=>a.remove(c,!0))}contentOf(t,e,n,r,i){let a=this.h;if(e==="@format"){let{ref:p,e:s}="lit"in n?n.lit:{},l=s===void 0?()=>({}):this.runner(s,i);return this.guarded(()=>{let o=this.options.i18n?.format(p||"",l(r),r.lang?.());a.content(t,o==null?"":String(o))}).dispose}let c="lit"in n?()=>n.lit:this.runner(n.e,i);return this.guarded(()=>{let p=c(r),s=p==null?"":String(p);e==="@html"&&a.html?a.html(t,s):a.content(t,s)}).dispose}eventDispatcher(t,e,n){let r=lt(t),i=/^[A-Za-z_$][\w$]*$/.test(r[0]||"")&&!e.includes(r[0]);return(...a)=>k(()=>{let c=(l)=>{if(i&&n.self&&!this.options.guard?.self(l)&&typeof n.self[l]==="function")return n.self[l];try{return this.srcRunner(l,e)(n)}catch(o){return}};if(!r.length)return;let p=c(r[0]);if(typeof p!=="function")return;let s=(l)=>this.hooks?this.hooks.onError(l):console.error("[lips:ir]",l);try{let l=r.slice(1).map((u)=>this.srcRunner(u,e)(n)),o=p(...l,...a);o&&typeof o.then==="function"&&o.then(void 0,s)}catch(l){s(l)}})}}function xt(t,e={},n={}){let r=n.host||ht,i=T(e.state||{},e.deep??!1),a=T(e.input||{},e.deep??!1),c=e.static||{},p=null,s=Xt(r,()=>n.i18n?.lang()??""),l=s.bind(Object.assign(Object.create(s.proto),{state:i,input:a,static:c,refs:{},...n.expose||{},...e.expose||{}}),()=>p);e.handlers&&Object.entries(e.handlers).forEach(([v,y])=>l[v]=y.bind(l));let o={state:i,input:a,context:e.context,static:c,self:l,scope:void 0},u=Jt(l);try{typeof l.onCreate==="function"&&l.onCreate()}catch(v){u.onError(v)}try{Object.keys(a).length&&typeof l.onInput==="function"&&l.onInput(a)}catch(v){u.onError(v)}let f=Vt(l,a,u),d=new nt(t,n,u),h=d.renderBlock(t.root,o);p=h,u.ready();let g=e.stylesheet?Gt(r,n,h,e.stylesheet.nsp||e.nsp||"lips",e.stylesheet):void 0,m=e.stylesheet?d.bindStyle(e.stylesheet,h,o):void 0;try{typeof l.onMount==="function"&&l.onMount(),typeof l.onRender==="function"&&l.onRender()}catch(v){u.onError(v)}let x=!1,E=()=>{if(x)return;x=!0;try{typeof l.onAttach==="function"&&l.onAttach(),l.emit("component:attached")}catch(v){u.onError(v)}};return{state:i,self:l,get nodes(){return D(r,h)},mount(v){for(let y of D(r,h))r.insert(v,y,null);if(r.connected(h.start))E(),yt()},swap(v){let y=[],b=r.keepFocus?.();if(d=new nt(v,n,u,d.live),h=d.swapBlock(h,v.root,y,"root"),p=h,e.stylesheet)qt(r,h,e.stylesheet.nsp||e.nsp||"lips"),m?.(),m=d.bindStyle(e.stylesheet,h,o);return b?.(),{changes:y,salvaged:d.salvaged}},dispose(){f(),m?.(),g?.(),C(r,h);try{if(x)typeof l.onDetach==="function"&&l.onDetach(),l.emit("component:detached");typeof l.onDestroy==="function"&&l.onDestroy()}catch(v){u.onError(v)}}}}class rt{options={emit:!0};__events={};__once_events={};constructor(t){if(t)this.options=t}on(t,e){if(!Array.isArray(this.__events[t]))this.__events[t]=[];return this.__events[t].push(e),this}once(t,e){if(!Array.isArray(this.__once_events[t]))this.__once_events[t]=[];return this.__once_events[t].push(e),this}off(t,e){if(e){if(Array.isArray(this.__events[t]))this.__events[t]=this.__events[t].filter((n)=>n!==e),!this.__events[t].length&&delete this.__events[t];if(Array.isArray(this.__once_events[t]))this.__once_events[t]=this.__once_events[t].filter((n)=>n!==e),!this.__once_events[t].length&&delete this.__once_events[t]}else delete this.__events[t],delete this.__once_events[t];return this}emit(t,...e){if(!this.options.emit)return;let n=(i)=>{if(!i||typeof i!=="object")return i;if(typeof i.toJSON==="function")return i.toJSON();if(Array.isArray(i))return i.map(n);if(i.constructor===Object||i.constructor===void 0){let a={};for(let c in i)a[c]=n(i[c]);return a}return i},r=e.map(n);this.__events[t]?.forEach((i)=>i(...r)),this.__once_events[t]?.forEach((i)=>i(...r)),delete this.__once_events[t]}}class st{nsp;settings;constructor(t,e){if(typeof t!=="string"||!t)throw Error("Undefined or invalid stylesheet namespace");this.nsp=t,this.settings=e||{},this.settings.sheet&&this.load(this.settings)}get rel(){return`${this.settings.meta?"@":""}${this.nsp}`}get styleElement(){return document.head.querySelector(`style[rel="${this.rel.replace(/["\\]/g,"\\$&")}"]`)}load(t){if(this.settings=t,!t.sheet)return;let e=this.styleElement;if(e)return e.setAttribute("dindex",String(Number(e.getAttribute("dindex")||0)+1)),e;let n=document.createElement("style");return n.setAttribute("rel",this.rel),n.setAttribute("dindex","0"),n.textContent=t.sheet,t.meta?document.head.prepend(n):document.head.appendChild(n),n}clear(){let t=this.styleElement;if(!t)return;let e=Number(t.getAttribute("dindex")||0);e<=0?t.remove():t.setAttribute("dindex",String(e-1))}}var de="en-US";class it{engine;currentLang;DICTIONARIES={};functions;onMissing;onError;onChange;loader;loading=new Map;formatters=new Map;constructor(t,e){this.engine=e;this.currentLang=t||typeof navigator<"u"&&navigator.language||de,this.functions={...e?.functions}}set lang(t){if(this.currentLang===t)return;this.currentLang=t}get lang(){return this.currentLang}setDictionary(t,e){if(!this.engine)throw Error(`[lips:i18n] <${t}> dictionary without a MessageFormat engine — pass \`messageFormat\` from '@lipsjs/lips/i18n' to new Lips()`);this.DICTIONARIES[t.toLowerCase()]=e,this.formatters.clear(),this.onChange?.()}has(t){return q(t.toLowerCase()).some((e)=>!!this.DICTIONARIES[e])}setLoader(t){return this.loader=t,this}load(t){return Promise.all(q(t).map((e)=>{let n=e.toLowerCase();if(this.DICTIONARIES[n]||!this.loader)return;let r=this.loading.get(n);if(!r)r=this.loader(e).then((i)=>{i&&this.setDictionary(e,i)}).catch((i)=>console.warn(`[lips:i18n] <${e}> dictionary failed to load —`,i)),this.loading.set(n,r);return r})).then(()=>{})}message(t,e){let n=`${e}
|
|
3
|
+
${t}`;if(this.formatters.has(n))return this.formatters.get(n);let r;for(let i of q(e.toLowerCase())){let a=this.DICTIONARIES[i];if(!a||!Object.prototype.hasOwnProperty.call(a,t))continue;try{r=new this.engine.MessageFormat(e,a[t],{functions:this.functions})}catch(c){this.onError?.(c,t,e),r=null}break}return r!==void 0&&this.formatters.set(n,r),r}translate(t,e,n){let r=e||this.currentLang,i=n||t,a=this.message(i,r);if(a)t=a.format(void 0,(c)=>this.onError?.(c,i,r));else if(a===void 0&&n)this.onMissing?.(n,r);return{text:t,lang:r}}format(t,e,n){let r=n||this.currentLang,i=this.message(t,r);if(i)return i.format(e,(a)=>this.onError?.(a,t,r));i===void 0&&this.onMissing?.(t,r)}pick(t,e){return Q(t,e||this.currentLang)}}var vt=null;var Et=null;var he;var ge={};var ye=null;var me=["state","input","static","context","emit","on","once","off","node","lang","setContext","setLanguage","destroy","appendTo","prependTo","replaceWith","render","swap"],xe=new Set(me);function St(t){if(!t)return;for(let e of Object.keys(t))if(xe.has(e))throw Error(`Handler <${e}> is a reserved component member name`);return t}class Yt extends rt{lips;template;state;instance;contextWatcher;destroyed=!1;constructor(t,e,n,r,i,a){super();this.lips=t;this.template=n;let c=St(n.handler);this.state=T(O(n.state||{}),!0);let p=T({...r},!0),s=(o,...u)=>super.emit(o,...u);this.instance=xt(i,{state:this.state,input:p,context:t.getContext(),static:O(n.static??n._static),handlers:c,deep:!0,stylesheet:t.styleFor(e,n),nsp:e,expose:{emit(o,...u){this.emitLocal?.(o,...u),s(o,...u)},context:t.getContext()}},a);let l=n.watchContext;if(l?.length&&typeof c?.onContext==="function")this.contextWatcher=t.watchContext(l,()=>{try{c.onContext.call(this.instance.self)}catch(o){console.error("[lips:ir]",o)}});this.emit("component:mount")}emit(t,...e){return this.instance?.self?.emitLocal?.(t,...e),super.emit(t,...e)}get node(){return this.instance.nodes.filter((t)=>t.nodeType===1)}appendTo(t){let e=typeof t==="string"?document.querySelector(t):t;return e&&this.instance.mount(e),this}swap(t){return this.instance.swap(t)}destroy(){if(this.destroyed)return;this.destroyed=!0,this.contextWatcher?.(),this.instance.dispose(),this.emit("component:destroy")}}class Rt{config;debug;store=new Map;plugins=new Map;irCache=new WeakMap;defCache=new WeakMap;styleCache=new WeakMap;context;__root;u;i18n;getLang;setLang;getRev;componentsProxy;constructor(t){this.config=t;if(this.u=t?.untrusted,this.debug=!!t?.debug,this.context=T({...t?.context||{}},!0),this.i18n=new it(t?.lang,t?.messageFormat??he),this.debug)this.i18n.onMissing=(c,p)=>console.warn(`[lips:i18n] no <${p}> entry for key "${c}"`),this.i18n.onError=(c,p,s)=>console.warn(`[lips:i18n] <${s}> message "${p}" —`,c);let[e,n]=I(this.i18n.lang);this.getLang=e,this.setLang=n;let[r,i]=I(0);this.getRev=r,this.i18n.onChange=()=>i(r()+1),vt&&Object.entries(ge).forEach(([c,p])=>this.register(c,p));let a=this;this.componentsProxy=new Proxy({},{get(c,p){let s=a.store.get(p);return s?a.defFor(p,s):void 0},has(c,p){return a.store.has(p)}})}register(t,e){let n=ye?.(t);if(n)throw Error(`[lips] <${t}> is ${n}: the compiler reads the tag as one, so a component of that name never renders. Register it under another name`);return St(e.handler),this.store.set(t,e),this}use(t,e){let n=this.plugins.get(t.name);if(n&&n!==t)throw Error(`[lips] two plugins named <${t.name}>: one is installed already`);if(n)return this;this.plugins.set(t.name,t),t.requires?.forEach((r)=>this.use(r));for(let[r,i]of Object.entries(t.components||{})){let a=this.built(r,i),c=this.store.get(r);if(c&&c!==a)throw Error(`[lips] <${r}> of plugin <${t.name}> is registered already, by something else`);this.register(r,a)}return t.install?.(this,e),this}built(t,e){let n=!e.ir&&this.config?.precompiled?.[t];if(!n)return e;let r=this.withIR.get(e);return!r&&this.withIR.set(e,r={...e,...n}),r}withIR=new WeakMap;unregister(t){return this.store.delete(t),this}has(t){return this.store.has(t)}compile(t){if(t.ir)return t.ir;let e=this.irCache.get(t);if(!e){if(!vt)throw Error("This build has no template compiler — templates must be precompiled to `ir` "+'(import from "@lipsjs/lips" instead of "@lipsjs/lips/runtime")');let n=vt(t.default||"",{macros:t.macros,check:this.u?.check});n.diagnostics.length&&console.warn("[lips:ir] template diagnostics —",n.diagnostics),e=n.ir,this.irCache.set(t,e)}return e}styleFor(t,e){if(e.style)return e.style;if(!e.stylesheet)return;if(!Et){console.warn(`[lips:ir] <${t}> stylesheet skipped — this build has no style compiler. `+'Precompile it to StyleIR, or import "@lipsjs/lips" instead of "@lipsjs/lips/runtime".');return}let n=this.styleCache.get(e);if(!n){let r=(this.u?this.u.style(Et):Et)(e.stylesheet,{nsp:t,layer:this.config?.styleLayer,preprocess:this.config?.stylePreprocessor});r.diagnostics.length&&console.warn("[lips:ir] style diagnostics —",r.diagnostics),n=r.ir,this.styleCache.set(e,n)}return n}unnamed(t){let e=this.anonymous.get(t);return!e&&this.anonymous.set(t,e=`dynamic-${++this.anonymousCount}`),e}anonymous=new WeakMap;anonymousCount=0;defFor(t,e){let n=this.defCache.get(e);if(!n)n={ir:this.compile(e),state:e.state,statics:e.static??e._static,context:e.watchContext,stylesheet:this.styleFor(t,e),nsp:t,handlers:St(e.handler),deep:!0},this.defCache.set(e,n);return n}render(t,e,n){let r={mode:this.config?.mode,components:this.componentsProxy,resolveTemplate:(i)=>i&&(typeof i.default==="string"||i.ir)?this.defFor(i.name||this.unnamed(i),i):void 0,expose:{setContext:(i,a)=>this.setContext(i,a),setLanguage:(i)=>this.setLanguage(i)},createStylesheet:(i,a)=>{let c=new st(i,{sheet:a});return{clear:()=>c.clear()}},i18n:{translate:(i,a,c)=>{let p=this.getLang();return this.getRev(),this.i18n.translate(i,c||p,a).text},format:(i,a,c)=>{let p=this.getLang();return this.getRev(),this.i18n.format(i,a,c||p)??""},lang:()=>this.getLang()}};return new Yt(this,t,e,n,this.compile(e),this.u?this.u.runtime(r):r)}root(t,e){let n=this.render("__ROOT__",t);return this.__root=n,n.appendTo(e),n}setLanguage(t){return this.i18n.lang=t,this.setLang(t),this.i18n.load(t),this}getLanguage(){return this.getLang()}useTranslator(t,e){let n=!0,{dispose:r}=A(()=>{let i=this.getLang();if(n){n=!1;return}(t==="*"||Array.isArray(t)&&t.includes(i))&&e(i)});return r}get ctx(){return this.context}getContext(){return this.context}setContext(t,e){typeof t==="string"?this.ctx[t]=e:Object.entries(t).forEach(([n,r])=>this.ctx[n]=r)}watchContext(t,e){let n=!0,{dispose:r}=A(()=>{t.forEach((i)=>this.ctx[i]),n?n=!1:e()});return r}useContext(t,e){return this.watchContext(t,()=>e(Object.fromEntries(t.map((n)=>[n,this.ctx[n]]))))}dispose(){this.__root?.destroy()}}function ve(t){return t?t:(e)=>e}var Ye=Rt;export{ve as component,Ye as default,A as effect,T as reactive,xt as renderIR,I as signal,k as untrack};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=DB03A5057C8E2F2B64756E2164756E21
|