@lipsjs/lips 0.3.1 → 0.5.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/README.md +122 -9
- package/dist/lips.js +917 -669
- package/dist/lips.js.map +15 -12
- package/dist/lips.min.js +12 -12
- package/dist/lips.min.js.map +15 -12
- package/dist/lynx-background.min.js +3 -0
- package/dist/lynx-background.min.js.map +13 -0
- package/dist/lynx-main.min.js +3 -0
- package/dist/lynx-main.min.js.map +11 -0
- package/dist/lynx-plugin.mjs +1487 -0
- package/dist/lynx.min.js +8 -8
- package/dist/lynx.min.js.map +12 -10
- package/dist/mf2.min.js.map +1 -1
- package/dist/parts.min.js +100 -0
- package/dist/parts.min.js.map +19 -0
- package/dist/precompile.min.js +15 -15
- package/dist/precompile.min.js.map +8 -7
- package/dist/runtime.min.js +4 -4
- package/dist/runtime.min.js.map +11 -9
- package/dist/stylis.min.js.map +1 -1
- package/dist/types/component.d.ts +32 -0
- package/dist/types/ir/compiler.d.ts +2 -4
- package/dist/types/ir/facade.d.ts +63 -12
- package/dist/types/ir/host.d.ts +9 -1
- package/dist/types/ir/initial.d.ts +16 -0
- package/dist/types/ir/router.d.ts +2 -0
- package/dist/types/ir/tags.d.ts +16 -0
- package/dist/types/lips.d.ts +7 -7
- package/dist/types/lynx/a11y.d.ts +1 -0
- package/dist/types/lynx/background.d.ts +52 -3
- package/dist/types/lynx/components.d.ts +28 -0
- package/dist/types/lynx/main.d.ts +9 -5
- package/dist/types/lynx/plugin.d.ts +8 -0
- package/dist/types/lynx/protocol.d.ts +55 -4
- package/dist/types/lynx/style.d.ts +7 -0
- package/dist/types/lynx/template.d.ts +6 -0
- package/dist/types/lynx.d.ts +1 -0
- package/dist/types/parts/combobox.d.ts +40 -0
- package/dist/types/parts/date.d.ts +75 -0
- package/dist/types/parts/dialog.d.ts +42 -0
- package/dist/types/parts/icon.d.ts +31 -0
- package/dist/types/parts/layer.d.ts +28 -0
- package/dist/types/parts/list.d.ts +45 -0
- package/dist/types/parts/menu.d.ts +44 -0
- package/dist/types/parts/popover.d.ts +81 -0
- package/dist/types/parts/reveal.d.ts +24 -0
- package/dist/types/parts/toast.d.ts +36 -0
- package/dist/types/parts.d.ts +24 -0
- package/dist/types/precompile.d.ts +8 -11
- package/dist/types/runtime.d.ts +1 -0
- package/dist/types/types.d.ts +188 -57
- package/dist/untrusted.min.js +4 -4
- package/dist/untrusted.min.js.map +7 -7
- package/package.json +24 -3
- package/dist/types/i18n/formatters.d.ts +0 -3
package/dist/precompile.min.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)this.lineStarts.push(s+1)}let e=0,r=this.lineStarts.length-1;while(e<r){let s=e+r+1>>1;this.lineStarts[s]<=t?e=s:r=s-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,r,s,i=1,n){let{line:a,col:o}=this.locate(s);this.diagnostics.push({code:t,severity:e,message:r,hint:n,loc:{line:a,col:o,offset:s,length:i}})}eof(){return this.pos>=this.src.length}peek(t=0){return this.src[this.pos+t]}startsWith(t){return this.src.startsWith(t,this.pos)}skipSpace(){while(!this.eof()&&/\s/.test(this.src[this.pos]))this.pos++}scanBalanced(t,e){let r=this.pos,s=0;while(!this.eof()){let i=this.src[this.pos];if(i==="'"||i==='"'||i==="`"){this.pos++;while(!this.eof()&&this.src[this.pos]!==i){if(this.src[this.pos]==="\\")this.pos++;this.pos++}this.pos++;continue}if(s===0&&i===t){let n=this.src.slice(r,this.pos);return this.pos++,{content:n,loc:{offset:r,length:n.length}}}if(i==="("||i==="["||i==="{")s++;else if(i===")"||i==="]"||i==="}"){if(s===0&&i!==t){this.report(e,"error",`Unbalanced '${i}'`,this.pos),this.pos++;continue}s--}this.pos++}return this.report(e,"error",`Unterminated — expected '${t}'`,r,this.pos-r),null}parse(){let t=[];while(!this.eof())if(t.push(...this.parseNodes([])),this.startsWith("</")){let e=this.pos;this.pos+=2;while(!this.eof()&&this.peek()!==">")this.pos++;!this.eof()&&this.pos++,this.report("LIPS-P005","error",`Stray closing tag ${this.src.slice(e,this.pos)}`,e,this.pos-e)}return{root:{t:"fragment",children:t,loc:{offset:0,length:this.src.length}},diagnostics:this.diagnostics}}parseNodes(t){let e=[];while(!this.eof()){if(this.startsWith("</"))break;let r=this.pos;if(this.peek()==="<"&&this.peek(1)!==void 0){let s=this.parseTag(t);s&&e.push(s)}else{let s=this.parseText(t);s&&e.push(s)}if(this.pos===r)this.pos++}return e}parseText(t){let e=this.pos,r=[],s="";while(!this.eof()&&this.peek()!=="<"){if(this.peek()==="{"){this.pos++;let o=this.scanBalanced("}","LIPS-P007");if(o)s&&r.push(s),s="",r.push({expr:o.content.trim(),loc:o.loc});continue}s+=this.peek(),this.pos++}s&&r.push(s);let i={offset:e,length:this.pos-e};if(r.some((o)=>typeof o!=="string"))return{t:"interp",parts:r.map((o)=>typeof o==="string"?
|
|
1
|
+
var bt=(t,e,r)=>()=>{if(t)try{e=t(t=0)}catch(s){r=[s]}if(r)throw r[0];return e};function St(t,e){return t.replace(yt,(r,s,i,n,a)=>{if(n===void 0){let o=s!==void 0?parseInt(s,10):parseInt(i,16);return o>0&&o<=1114111?String.fromCodePoint(o):r}if(n in Q)return Q[n];return e?.(n,a),r})}class U{src;pos=0;lineStarts=null;diagnostics=[];constructor(t){this.src=t}locate(t){if(!this.lineStarts){this.lineStarts=[0];for(let s=0;s<this.src.length;s++)if(this.src[s]===`
|
|
2
|
+
`)this.lineStarts.push(s+1)}let e=0,r=this.lineStarts.length-1;while(e<r){let s=e+r+1>>1;this.lineStarts[s]<=t?e=s:r=s-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,r,s,i=1,n){let{line:a,col:o}=this.locate(s);this.diagnostics.push({code:t,severity:e,message:r,hint:n,loc:{line:a,col:o,offset:s,length:i}})}decode(t,e){return St(t,(r,s)=>this.report("LIPS-P013","warning",`&${r}; is not decoded`,e+s,r.length+2,"Write the character, or its number: ©"))}eof(){return this.pos>=this.src.length}peek(t=0){return this.src[this.pos+t]}startsWith(t){return this.src.startsWith(t,this.pos)}skipSpace(){while(!this.eof()&&/\s/.test(this.src[this.pos]))this.pos++}scanBalanced(t,e){let r=this.pos,s=0;while(!this.eof()){let i=this.src[this.pos];if(i==="'"||i==='"'||i==="`"){this.pos++;while(!this.eof()&&this.src[this.pos]!==i){if(this.src[this.pos]==="\\")this.pos++;this.pos++}this.pos++;continue}if(s===0&&i===t){let n=this.src.slice(r,this.pos);return this.pos++,{content:n,loc:{offset:r,length:n.length}}}if(i==="("||i==="["||i==="{")s++;else if(i===")"||i==="]"||i==="}"){if(s===0&&i!==t){this.report(e,"error",`Unbalanced '${i}'`,this.pos),this.pos++;continue}s--}this.pos++}return this.report(e,"error",`Unterminated — expected '${t}'`,r,this.pos-r),null}parse(){let t=[];while(!this.eof())if(t.push(...this.parseNodes([])),this.startsWith("</")){let e=this.pos;this.pos+=2;while(!this.eof()&&this.peek()!==">")this.pos++;!this.eof()&&this.pos++,this.report("LIPS-P005","error",`Stray closing tag ${this.src.slice(e,this.pos)}`,e,this.pos-e)}return{root:{t:"fragment",children:t,loc:{offset:0,length:this.src.length}},diagnostics:this.diagnostics}}parseNodes(t){let e=[];while(!this.eof()){if(this.startsWith("</"))break;let r=this.pos;if(this.peek()==="<"&&this.peek(1)!==void 0){let s=this.parseTag(t);s&&e.push(s)}else{let s=this.parseText(t);s&&e.push(s)}if(this.pos===r)this.pos++}return e}parseText(t){let e=this.pos,r=[],s="";while(!this.eof()&&this.peek()!=="<"){if(this.peek()==="{"){this.pos++;let o=this.scanBalanced("}","LIPS-P007");if(o)s&&r.push(s),s="",r.push({expr:o.content.trim(),loc:o.loc});continue}s+=this.peek(),this.pos++}s&&r.push(s);let i={offset:e,length:this.pos-e};if(r.some((o)=>typeof o!=="string"))return{t:"interp",parts:r.map((o)=>typeof o==="string"?this.decode(o,e):o),loc:i};let n=r.length?r[0]:"",a=t.some((o)=>kt.has(o));if(!n||!a&&!n.trim())return null;return{t:"text",value:this.decode(n,e),loc:i}}parseTag(t){let e=this.pos;if(this.startsWith("<!--")){let n=this.src.indexOf("-->",this.pos+4);if(n===-1)return this.report("LIPS-P003","error","Unterminated comment",e,this.src.length-e),this.pos=this.src.length,null;let a=this.src.slice(this.pos+4,n);return this.pos=n+3,{t:"comment",value:a,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<>")){this.pos+=2;let n=[];while(!0)if(n.push(...this.parseNodes([...t,"#fragment"])),this.closeStatus("#fragment",e,t)!=="stray")break;return{t:"fragment",children:n,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<{")){this.pos+=2;let n=this.scanBalanced("}","LIPS-P008");if(!n)return null;let a={t:"element",tag:"#dynamic",dynamicTag:{expr:n.content.trim(),loc:n.loc},attrs:[],children:[],selfClosed:!1,loc:{offset:e,length:0}};return this.finishTag(a,t,e),a}this.pos++;let r=this.pos;while(!this.eof()&&/[A-Za-z0-9_-]/.test(this.peek()))this.pos++;let s=this.src.slice(r,this.pos);if(!s||!/^[A-Za-z]/.test(s))return this.report("LIPS-P002","error","Invalid tag name",e,this.pos-e+1),{t:"text",value:"<",loc:{offset:e,length:1}};let i={t:"element",tag:s.toLowerCase(),attrs:[],children:[],selfClosed:!1,loc:{offset:e,length:0}};if(this.peek()==="(")if(Y.has(i.tag)){this.pos++;let n=this.scanBalanced(")","LIPS-P012");n&&(i.head={expr:n.content.trim(),loc:n.loc})}else this.report("LIPS-P011","error",`Head expression is not allowed on <${i.tag}>`,this.pos,1,`Only ${[...Y].map((n)=>`<${n}(…)>`).join(", ")} take a head`);return this.finishTag(i,t,e),i}finishTag(t,e,r){if(this.parseAttrs(t),t.selfClosed||xt.has(t.tag)){t.selfClosed=!0,t.loc={offset:r,length:this.pos-r};return}let s=t.tag==="#dynamic"?"#dynamic":t.tag;t.children=[];while(!0)if(t.children.push(...this.parseNodes([...e,s])),this.closeStatus(s,r,e)!=="stray")break;t.loc={offset:r,length:this.pos-r}}closeStatus(t,e,r){if(this.eof())return this.report("LIPS-P006","error",`Unclosed <${t==="#fragment"?"":t}> — reached end of template`,e,1,`Add </${t==="#fragment"||t==="#dynamic"?"":t}>`),"eof";if(!this.startsWith("</"))return"closed";let s=this.pos;if(this.pos+=2,this.peek()===">"){if(this.pos++,t!=="#fragment"&&t!=="#dynamic")this.report("LIPS-P004","warning",`Generic '</>' closes <${t}>`,s,3,`Prefer </${t}>`);return"closed"}let i=this.pos;while(!this.eof()&&/[A-Za-z0-9_-]/.test(this.peek()))this.pos++;let n=this.src.slice(i,this.pos).toLowerCase();if(this.skipSpace(),this.peek()===">"?this.pos++:this.report("LIPS-P001","error","Malformed closing tag",s,this.pos-s),n===t)return"closed";if(r.includes(n))return this.report("LIPS-P004","warning",`</${n}> auto-closes <${t}>`,s,this.pos-s,`Add the missing </${t}> before </${n}>`),this.pos=s,"ancestor";return this.report("LIPS-P005","error",`Stray closing tag </${n}> — <${t}> is open`,s,this.pos-s),"stray"}parseAttrs(t){while(!0){if(this.skipSpace(),this.eof()){this.report("LIPS-P001","error","Unexpected end of template inside tag",t.loc.offset);return}if(this.startsWith("/>")){this.pos+=2,t.selfClosed=!0;return}if(this.peek()===">"){this.pos++;return}let e=this.pos;if(this.startsWith("...")){this.pos+=3;let n=this.readUnquotedValue();t.attrs.push({k:"spread",source:n,loc:{offset:e,length:this.pos-e}});continue}if(this.peek()==="["){this.pos++;let n=this.scanBalanced("]","LIPS-P009");if(n){let a=n.content.split(",").map((o)=>o.trim()).filter(Boolean);t.attrs.push({k:"args",names:a,loc:{offset:e,length:this.pos-e}})}continue}let r=!1;if(this.peek()==="!")r=!0,this.pos++;let s=this.pos;while(!this.eof()&&/[^\s=/>()]/.test(this.peek()))this.pos++;let i=this.src.slice(s,this.pos);if(!i){this.report("LIPS-P009","error",`Invalid attribute syntax at '${this.peek()}'`,this.pos),this.pos++;continue}if(this.peek()==="("){this.pos++;let n=this.scanBalanced(")","LIPS-P010"),a=n?n.content.trim():"",o={offset:e,length:this.pos-e};i.startsWith("on-")?t.attrs.push({k:"event",name:i.slice(3),source:a,loc:o}):t.attrs.push({k:"fn",name:i,source:a,loc:o});continue}if(this.peek()==="="){this.pos++,this.parseAttrValue(t,i,e);continue}t.attrs.push({k:"bool",name:i,value:!r,loc:{offset:e,length:this.pos-e}})}}parseAttrValue(t,e,r){let s=this.peek();if(s==='"'||s==="'"){this.pos++;let n=this.pos,a=[],o="";while(!this.eof()&&this.peek()!==s){if(this.peek()==="{"){this.pos++;let p=this.scanBalanced("}","LIPS-P007");if(p)o&&a.push(o),o="",a.push({expr:p.content.trim(),loc:p.loc});continue}o+=this.peek(),this.pos++}o&&a.push(o),this.eof()?this.report("LIPS-P010","error",`Unterminated value for '${e}'`,n,this.pos-n):this.pos++;let l={offset:r,length:this.pos-r};a.some((p)=>typeof p!=="string")?t.attrs.push({k:"interp",name:e,parts:a.map((p)=>typeof p==="string"?this.decode(p,n):p),loc:l}):t.attrs.push({k:"literal",name:e,value:this.decode(a[0]??"",n),loc:l});return}if(s==="{"){this.pos++;let n=this.scanBalanced("}","LIPS-P007");t.attrs.push({k:"expr",name:e,source:n?n.content.trim():"",loc:{offset:r,length:this.pos-r}});return}let i=this.readUnquotedValue();i?t.attrs.push({k:"expr",name:e,source:i,loc:{offset:r,length:this.pos-r}}):this.report("LIPS-P010","error",`Missing value for attribute '${e}'`,r)}readUnquotedValue(){let t=this.pos,e=0;while(!this.eof()){let r=this.peek();if(r==="'"||r==='"'||r==="`"){this.pos++;while(!this.eof()&&this.peek()!==r){if(this.peek()==="\\")this.pos++;this.pos++}this.pos++;continue}if(e===0){if(/\s/.test(r)||r===">")break;if(r==="/"&&this.peek(1)===">")break}if(r==="("||r==="["||r==="{")e++;else if(r===")"||r==="]"||r==="}")e--;this.pos++}return this.src.slice(t,this.pos).trim()}}function W(t){return new U(t||"").parse()}function X(t){let e=vt(t||""),r=(t||"").slice(0,e).trimEnd(),s=(t||"").slice(e),i=new U(s).parse(),n=r?r.split(`
|
|
3
3
|
`).length+(/\n\s*\n$/.test(t.slice(0,e))?1:0):0;return i.diagnostics.forEach((a)=>{a.loc.line+=r?t.slice(0,e).split(`
|
|
4
|
-
`).length-1:0,a.loc.offset+=e}),{script:r,...i}}function
|
|
4
|
+
`).length-1:0,a.loc.offset+=e}),{script:r,...i}}function vt(t){let e=0,r=!0;for(let s=0;s<t.length;s++){let i=t[s];if(i==="'"||i==='"'||i==="`"){let n=i;s++;while(s<t.length&&t[s]!==n){if(t[s]==="\\")s++;s++}r=!1;continue}if(i==="/"&&t[s+1]==="/"){while(s<t.length&&t[s]!==`
|
|
5
5
|
`)s++;r=!0;continue}if(i==="/"&&t[s+1]==="*"){let n=t.indexOf("*/",s+2);s=n===-1?t.length:n+1;continue}if(i===`
|
|
6
|
-
`){r=!0;continue}if(r&&e===0&&i==="<"&&/[A-Za-z{>!]/.test(t[s+1]||""))return s;if(i==="("||i==="["||i==="{")e++;else if(i===")"||i==="]"||i==="}")e=Math.max(0,e-1);if(!/\s/.test(i))r=!1}return 0}var kt,
|
|
7
|
-
`,t:"\t",r:"\r",b:"\b",f:"\f",v:"\v","0":"\x00"};if(E==="u"){let
|
|
8
|
-
`)this.lineStarts.push(s+1)}let e=0,r=this.lineStarts.length-1;while(e<r){let s=e+r+1>>1;this.lineStarts[s]<=t?e=s:r=s-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,r,s,i=1,n){let{line:a,col:o}=this.locate(s);this.diagnostics.push({code:t,severity:e,message:r,hint:n,loc:{line:a,col:o,offset:s,length:i}})}expr(t,e){let r=this.exprIndex.get(t);if(r!==void 0)return r;let{diagnostics:s}=_(t);for(let n of s){let a=(e?.offset??0)+n.loc.offset;this.report(n.code,"error",n.message,a,n.loc.length)}let i=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,i),i}synth(t){let e=this.exprIndex.get(t);if(e!==void 0)return e;let r=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,r),r}concat(t){t.filter((r)=>typeof r!=="string").forEach((r)=>{let{diagnostics:s}=_(r.expr);for(let i of s)this.report(i.code,"error",i.message,r.loc.offset+i.loc.offset,i.loc.length)});let e=t.map((r)=>typeof r==="string"?JSON.stringify(r):`((${r.expr})??"")`).join("+");return this.synth(e)}compInput(t){switch(t.k){case"literal":return{lit:t.value};case"bool":return{lit:t.value};case"expr":return{e:this.expr(t.source,t.loc)};case"interp":return{e:this.concat(t.parts)}}}compile(t){return{v:1,exprs:this.exprs,root:this.block(t,[])}}block(t,e){let r={html:"",scope:[...e],binds:[],blocks:[]},s=[],i=this.tree,n=[],a=(o,l,p,d=!1,v)=>{let E=0,k=!1,x=()=>(s.push($t),i&&p.push(0),k=!1,[...l,E++]);for(let I=0;I<o.length;I++){let u=o[I];switch(u.t){case"text":{if(d){let g={t:"text",p:x(),e:this.synth(JSON.stringify(u.value)),i18n:1};if(v)g.ik=v;r.binds.push(g);break}if(s.push(Ct(u.value)),i&&(k?p[p.length-1]+=u.value:p.push(u.value)),!k)E++;k=!0;break}case"comment":{if(i)break;let g=u.value.replace(/--/g,"- -");s.push(`<!--${/^-?>/.test(g)?" "+g:g}-->`),k=!1,E++;break}case"interp":{let g={t:"text",p:x(),e:this.concat(u.parts)};if(d)g.i18n=1;if(d&&v)g.ik=v;r.binds.push(g);break}case"fragment":{o=[...o.slice(0,I),...u.children,...o.slice(I+1)],I--;break}case"element":{if(Rt.has(u.tag)){if(this.controlBlock(u,o,I,x(),r,e),u.tag==="if"){let g=I+1;while(g<o.length){let R=o[g];if(R.t==="element"&&(R.tag==="else-if"||R.tag==="else"))g++;else break}o=[...o.slice(0,I+1),...o.slice(g)]}break}if(wt.has(u.tag)){this.report("LIPS-C002","error",`<${u.tag}> is only valid inside its parent construct`,u.loc.offset,u.loc.length);break}if(u.tag==="#dynamic"){r.blocks.push(this.compLike(u,x(),e,"dynamic"));break}if(this.macros.has(u.tag)){let g=this.macroCall(u,x(),e);g&&r.blocks.push(g);break}if(!Lt.has(u.tag)){r.blocks.push(this.compLike(u,x(),e,"comp"));break}this.emitElement(u,l,E++,s,r,a,p),k=!1;break}}}};if(a(t,[],n),r.html=s.join(""),i)r.nodes=n;return r}emitElement(t,e,r,s,i,n,a){let o=[...e,r],l=`<${t.tag}`,p=[t.tag],d={},v=(c,b)=>{Object.prototype.hasOwnProperty.call(d,c)||(d[c]=b)};this.tree&&a.push(p);let E=t.attrs.filter((c)=>("name"in c)),k=E.some((c)=>c.name==="i18n"&&(c.k==="bool"&&c.value||c.k==="literal")),x=(c)=>k&&(c==="title"||c==="placeholder"),I=(c)=>{let b=E.find((w)=>w.name===c&&w.k==="literal");return b&&"value"in b&&b.value?String(b.value):void 0},u=I("i18n"),g=(c)=>I(`i18n-${c}`);!k&&E.some((c)=>c.name.startsWith("i18n-"))&&this.report("LIPS-C014","warning",`i18n-* key on <${t.tag}> without the 'i18n' marker — the attribute will not be translated`,t.loc.offset,t.loc.length);for(let c of t.attrs){if(this.tree&&"name"in c&&c.name==="@html"){this.report("LIPS-C021","error",`@html on <${t.tag}>: the 'tree' target has no HTML parser`,c.loc.offset,c.loc.length,"Write the markup in the template, or use @text");continue}if("name"in c&&c.name==="style"){let b=At(c);if(b&&rt(b)){this.report("LIPS-C019","error",`style= on <${t.tag}> takes CSS text, not an object literal`,c.loc.offset,c.loc.length,'Write the declarations as CSS — style="border: 2px solid gray; margin: 3rem" — '+`and interpolate values into it where they vary: style="margin: {state.gap}rem". Styles that need pseudo-classes, media queries or keyframes belong in the component's stylesheet.`);continue}}if(this.quotedEvent(t.tag,c))continue;switch(c.k){case"literal":if(c.name==="@format"){i.binds.push(this.formatBind(o,c));break}if(c.name.startsWith("@")){i.binds.push({t:"prop",p:o,name:c.name.slice(1),e:this.synth(JSON.stringify(c.value))});break}if(c.name==="i18n"||c.name.startsWith("i18n-"))break;if(x(c.name)){let b={t:"attr",p:o,name:c.name,e:this.synth(JSON.stringify(c.value)),i18n:1},w=g(c.name);if(w)b.ik=w;i.binds.push(b);break}l+=` ${c.name}="${Tt(c.value)}"`,v(c.name,c.value);break;case"bool":if(c.name!=="i18n"&&c.value)l+=` ${c.name}`,v(c.name,"");break;case"expr":{if(c.name==="@format"){i.binds.push(this.formatBind(o,c));break}if(c.name.startsWith("@")){i.binds.push({t:"prop",p:o,name:c.name.slice(1),e:this.expr(c.source,c.loc)});break}let b={t:"attr",p:o,name:c.name,e:this.expr(c.source,c.loc)};if(x(c.name)){b.i18n=1;let w=g(c.name);if(w)b.ik=w}i.binds.push(b);break}case"interp":{if(c.name==="@format"){i.binds.push(this.formatBind(o,c));break}if(c.name.startsWith("@")){i.binds.push({t:"prop",p:o,name:c.name.slice(1),e:this.concat(c.parts)});break}let b={t:"attr",p:o,name:c.name,e:this.concat(c.parts)};if(x(c.name)){b.i18n=1;let w=g(c.name);if(w)b.ik=w}i.binds.push(b);break}case"event":i.binds.push({t:"event",p:o,name:c.name,e:this.synth(c.source)});break;case"spread":i.binds.push({t:"spread",p:o,e:this.expr(c.source,c.loc)});break;case"fn":this.report("LIPS-C007","warning",`Callable attribute '${c.name}(…)' has no meaning on <${t.tag}>`,c.loc.offset,c.loc.length);break;case"args":this.report("LIPS-C008","warning",`Iterator arguments are not applicable to <${t.tag}>`,c.loc.offset,c.loc.length);break}}if(Object.keys(d).length&&(p[1]=d),Nt.has(t.tag)){s.push(l+">");return}s.push(l+">");let N=u,j=t.children.filter((c)=>c.t==="text"||c.t==="interp");if(N&&(j.length>1||j.some((c)=>c.t==="interp")))this.report("LIPS-C015","error",`<${t.tag} i18n="${N}"> keys text that is not a single fixed string. Use @format="${N}, { … }" for interpolated text.`,t.loc.offset,t.loc.length),N=void 0;let f=[];if(t.children.length&&n(t.children,o,f,k,N),f.length)p[1]=d,p[2]=f;s.push(`</${t.tag}>`)}formatBind(t,e){let r=e.k==="literal"?e.value:e.k==="expr"?e.source:e.parts.map((a)=>typeof a==="string"?a:`{${a.expr}}`).join(""),s=r.indexOf(",");if(s===-1)return this.report("LIPS-C012","error",'@format expects "reference, { params }"',e.loc.offset,e.loc.length),{t:"prop",p:t,name:"format",e:this.synth("({})"),ref:r.trim()};let i=r.slice(0,s).trim(),n=r.slice(s+1).trim();return{t:"prop",p:t,name:"format",e:this.expr(n,e.loc),ref:i}}attrsOf(t){let e=new Map,r=[];for(let s of t.attrs)if(s.k==="args")r.push(...s.names);else if("name"in s)e.set(s.name,s);return{byName:e,args:r}}controlBlock(t,e,r,s,i,n){switch(t.tag){case"if":{let a=[{when:t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),block:this.block(t.children,n)}];for(let o=r+1;o<e.length;o++){let l=e[o];if(l.t!=="element")break;if(l.tag==="else-if")a.push({when:l.head?this.expr(l.head.expr,l.head.loc):this.missingHead(l),block:this.block(l.children,n)});else if(l.tag==="else"){a.push({when:null,block:this.block(l.children,n)});break}else break}i.blocks.push({t:"if",p:s,branches:a});break}case"else-if":case"else":this.report("LIPS-C001","error",`<${t.tag}> without a preceding <if>`,t.loc.offset,t.loc.length);break;case"for":{let{byName:a,args:o}=this.attrsOf(t),l=a.get("in"),p=a.get("from"),d=a.get("to"),v=a.get("by");if(!l&&!p){this.report("LIPS-C004","error","<for> requires 'in' or 'from'/'to'",t.loc.offset,t.loc.length);break}let E={t:"for",p:s,args:o,block:this.block(t.children,[...n,...o])};if(l&&l.k==="expr")E.of=this.expr(l.source,l.loc);if(p)E.from=this.numInput(p);if(d)E.to=this.numInput(d);if(v&&(v.k==="literal"||v.k==="expr"))E.by=v.k==="literal"?{lit:v.value}:{e:this.expr(v.source,v.loc)};i.blocks.push(E);break}case"switch":{let a=t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),o=[];for(let l of t.children){if(l.t!=="element")continue;if(l.tag==="case"){let{byName:p}=this.attrsOf(l),d=p.get("is");if(!d||d.k!=="literal"&&d.k!=="expr"){this.report("LIPS-C004","error","<case> requires an 'is' attribute",l.loc.offset,l.loc.length);continue}o.push({is:d.k==="literal"?{lit:d.value}:{e:this.expr(d.source,d.loc)},block:this.block(l.children,n)})}else if(l.tag==="default")o.push({is:null,block:this.block(l.children,n)});else this.report("LIPS-C003","error","Only <case>/<default> are valid inside <switch>",l.loc.offset,l.loc.length)}i.blocks.push({t:"switch",p:s,on:a,cases:o});break}case"async":{let a=t.attrs.find((l)=>l.k==="fn"&&l.name==="await");if(!a){this.report("LIPS-C004","error","<async> requires await(…)",t.loc.offset,t.loc.length);break}let o={t:"async",p:s,awaitE:this.expr(a.source,a.loc)};for(let l of t.children){if(l.t!=="element")continue;let{args:p}=this.attrsOf(l);if(l.tag==="then")o.then={args:p,block:this.block(l.children,[...n,...p])};else if(l.tag==="catch")o.catch={args:p,block:this.block(l.children,[...n,...p])};else if(l.tag==="loading")o.loading=this.block(l.children,n);else this.report("LIPS-C003","error","Only <then>/<catch>/<loading> are valid inside <async>",l.loc.offset,l.loc.length)}i.blocks.push(o);break}case"let":case"const":{let a={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C013","error",`Spread is not supported on <${t.tag}> — scope names must be known at compile time`,o.loc.offset,o.loc.length,`Assign it to one variable: <${t.tag} obj={ ${o.source} }/> and read obj.<key>`);continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")a[o.name]=this.compInput(o),!i.scope.includes(o.name)&&i.scope.push(o.name),!n.includes(o.name)&&n.push(o.name)}i.blocks.push({t:"let",p:s,const:t.tag==="const",vars:a});break}case"log":i.blocks.push({t:"log",p:s,e:t.head?this.synth(t.head.expr):this.missingHead(t)});break;case"context":{let a={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C016","error","Spread is not supported on <context> — provided keys must be known at compile time",o.loc.offset,o.loc.length,"Provide them one by one: <context a=obj.a b=obj.b>");continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")a[o.name]=this.compInput(o)}if(!Object.keys(a).length)this.report("LIPS-C017","warning","<context> provides nothing — it renders its children unchanged",t.loc.offset,t.loc.length);i.blocks.push({t:"provide",p:s,vars:a,block:this.block(t.children,n)});break}case"i18n":{let{byName:a}=this.attrsOf(t),o=a.get("lang");if(!o){this.report("LIPS-C018","error","<i18n> requires a 'lang' attribute: <i18n lang=state.docLang>",t.loc.offset,t.loc.length);break}i.blocks.push({t:"provide",p:s,vars:{},lang:this.compInput(o),block:this.block(t.children,n)});break}}}missingHead(t){return this.report("LIPS-C004","error",`<${t.tag}> requires a head expression: <${t.tag}( … )>`,t.loc.offset,t.loc.length),this.synth("undefined")}numInput(t){if(t.k==="literal")return{lit:st(t.value)?Number(t.value):t.value};if(t.k==="expr")return st(t.source)?{lit:Number(t.source)}:{e:this.expr(t.source,t.loc)};return{lit:void 0}}macroCall(t,e,r){let s=this.macros.get(t.tag);if(this.macroStack.includes(s.name))return this.report("LIPS-C009","error",`Recursive macro <${s.name}> (${[...this.macroStack,s.name].join(" → ")})`,t.loc.offset,t.loc.length),null;let i=[];for(let a of t.attrs)if(a.k==="literal"||a.k==="expr"||a.k==="interp"||a.k==="bool")i.push({name:a.name,ci:this.compInput(a)});else if(a.k==="spread")i.push({spread:this.expr(a.source,a.loc)});this.macroStack.push(s.name);let n=this.block(s.children,[...r,...s.argv]);return this.macroStack.pop(),{t:"macro",p:e,name:s.name,sets:i,args:s.argv,block:n}}quotedEvent(t,e){if(!("name"in e)||!e.name.startsWith("on-"))return!1;return this.report("LIPS-C020","error",`${e.name}="…" on <${t}> wires no listener`,e.loc.offset,e.loc.length,`Handlers use the instruction form: ${e.name}( … ). `+"Quoted, it is an ordinary attribute — the handler never runs and the source is emitted into the DOM."),!0}compLike(t,e,r,s){let i={},n=[],a=[],o=[];for(let p of t.attrs){if(p.k!=="event"&&this.quotedEvent(t.tag,p))continue;switch(p.k){case"literal":case"bool":case"expr":case"interp":i[p.name]=this.compInput(p);break;case"event":a.push({name:p.name,e:this.synth(p.source)});break;case"spread":n.push(this.expr(p.source,p.loc));break;case"args":o=[...o,...p.names];break;case"fn":i[p.name]={e:this.expr(p.source,p.loc)};break}}let l=t.children.length?{args:o,block:this.block(t.children,[...r,...o])}:void 0;return s==="comp"?{t:"comp",p:e,name:t.tag,inputs:i,spreads:n,events:a,contents:l}:{t:"dynamic",p:e,tag:this.expr(t.dynamicTag.expr,t.dynamicTag.loc),inputs:i,spreads:n,events:a,contents:l}}}function Ot(t,e,r){let s=new Map;if(!t?.trim())return s;let i=M(t);e.push(...i.diagnostics),r?.(i.root.children,e,t);for(let n of i.root.children){if(n.t!=="element")continue;if(n.tag!=="macro"){e.push({code:"LIPS-C010",severity:"warning",message:`Only <macro> definitions are allowed in the macros source — ignoring <${n.tag}>`,loc:{line:1,col:1,offset:n.loc.offset,length:n.loc.length}});continue}let a="",o=[];for(let l of n.attrs)if(l.k==="args")o.push(...l.names);else if(l.k==="literal"&&l.name==="name")a=l.value;if(!a){e.push({code:"LIPS-C011",severity:"error",message:"<macro> requires a name attribute",loc:{line:1,col:1,offset:n.loc.offset,length:n.loc.length}});continue}s.set(a.toLowerCase(),{name:a,argv:o,children:n.children})}return s}function z(t,e){let r=[],s=Ot(e?.macros||"",r,e?.check),i=M(t);e?.check?.(i.root.children,r,t),e?.transform?.(i.root.children,r);let n=new it(t,s,e?.target==="tree");return{ir:n.compile(i.root.children),diagnostics:[...r,...i.diagnostics,...n.diagnostics]}}var _t=null;var jt=/^[-\w]+$/,ct=/^(%|[a-zA-Z]+)/,nt=["<number>","0"];function U(t,e){let r=t[e];e++;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===r)return e+1;e++}return e}function pt(t,e){let r=t.indexOf("*/",e+2);return r<0?t.length:r+2}function Bt(t,e){let r=t.indexOf(`
|
|
9
|
-
`,e+2);return r<0?t.length:r}var
|
|
10
|
-
`)s++,i=n;return{line:s,col:e-i,offset:e,length:r}}function
|
|
11
|
-
`}else if(
|
|
12
|
-
const __lips_ir__ = ${
|
|
6
|
+
`){r=!0;continue}if(r&&e===0&&i==="<"&&/[A-Za-z{>!]/.test(t[s+1]||""))return s;if(i==="("||i==="["||i==="{")e++;else if(i===")"||i==="]"||i==="}")e=Math.max(0,e-1);if(!/\s/.test(i))r=!1}return 0}var xt,kt,Y,Q,yt;var H=bt(()=>{xt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),kt=new Set(["pre","textarea"]),Y=new Set(["if","else-if","switch","log"]),Q={__proto__:null,amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},yt=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|([A-Za-z][A-Za-z0-9]*));/g});H();var Et=["===","!==","...","=>","==","!=","<=",">=","&&","||","??","?.","++","--","+=","-=","*=","/=","%=","+","-","*","/","%","<",">","!","?",":",".",",","(",")","[","]","{","}","="];function It(t,e){let r=[],s=0,i=(a)=>/[A-Za-z_$]/.test(a),n=(a)=>/[A-Za-z0-9_$]/.test(a);while(s<t.length){let a=t[s];if(/\s/.test(a)){s++;continue}if(/[0-9]/.test(a)||a==="."&&/[0-9]/.test(t[s+1])){let l=s;while(s<t.length&&/[0-9]/.test(t[s]))s++;if(t[s]==="."){s++;while(s<t.length&&/[0-9]/.test(t[s]))s++}if(t[s]==="e"||t[s]==="E"){if(s++,t[s]==="+"||t[s]==="-")s++;while(s<t.length&&/[0-9]/.test(t[s]))s++}r.push({t:"num",value:t.slice(l,s),start:l,end:s});continue}if(a==="'"||a==='"'){let l=s;s++;let p="",b=!1;while(s<t.length){let k=t[s];if(k==="\\"){let E=t[s+1],d={n:`
|
|
7
|
+
`,t:"\t",r:"\r",b:"\b",f:"\f",v:"\v","0":"\x00"};if(E==="u"){let y=t.slice(s+2,s+6);p+=String.fromCharCode(parseInt(y,16)||0),s+=6}else p+=d[E]??E,s+=2;continue}if(k===a){b=!0,s++;break}p+=k,s++}if(!b)e.push({code:"LIPS-E001",message:"Unterminated string literal",loc:{offset:l,length:s-l}});r.push({t:"str",value:p,start:l,end:s});continue}if(i(a)){let l=s;while(s<t.length&&n(t[s]))s++;r.push({t:"id",value:t.slice(l,s),start:l,end:s});continue}let o=Et.find((l)=>t.startsWith(l,s));if(o==="?."&&/[0-9]/.test(t[s+2]??""))o="?";if(o){r.push({t:"punct",value:o,start:s,end:s+o.length}),s+=o.length;continue}e.push({code:"LIPS-E002",message:`Unexpected character '${a}'`,loc:{offset:s,length:1}}),s++}return r.push({t:"eof",value:"",start:t.length,end:t.length}),r}class tt{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,r=this.peek()){return this.diagnostics.push({code:t,message:e,loc:{offset:r.start,length:Math.max(1,r.end-r.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,r=0;while(!0){let s=this.peek(r);if(s.t==="eof")return!1;if(s.t==="punct"&&s.value==="(")e++;if(s.t==="punct"&&s.value===")"){if(e--,e===0){let i=this.peek(r+1);return i.t==="punct"&&i.value==="=>"}}r++}}return!1}assign(){if(this.isArrowAhead()){let r=[];if(this.peek().t==="id")r.push(this.next().value);else{this.expect("(","LIPS-E004");while(!this.at(")")&&this.peek().t!=="eof"){let s=this.next();if(s.t!=="id")return this.error("LIPS-E005","Invalid arrow parameter",s);if(r.push(s.value),!this.eat(","))break}this.expect(")","LIPS-E004")}return this.expect("=>","LIPS-E004"),{t:"arrow",params:r,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,r=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:r,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,r=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:r,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 r=this.eat("...");if(e.push({spread:r||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 r=this.next();if(r.t!=="id"&&r.t!=="str"&&r.t!=="num")return this.error("LIPS-E011","Invalid object key",r);if(this.eat(":"))e.push({key:String(r.value),value:this.assign(),at:r.start});else if(r.t==="id")e.push({key:r.value,value:{t:"id",name:r.value,at:r.start},at:r.start});else return this.error("LIPS-E011","Invalid shorthand property",r)}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 _(t){let e=[],r=It(t,e);return{ast:new tt(r,e).parse(),diagnostics:e}}function et(t){let e=new Set,r=(s,i)=>{switch(s.t){case"id":!i.has(s.name)&&e.add(s.name);return;case"member":r(s.obj,i),typeof s.prop!=="string"&&r(s.prop,i);return;case"call":r(s.callee,i),s.args.forEach((n)=>r(n,i));return;case"unary":case"update":r(s.arg,i);return;case"bin":case"logic":r(s.l,i),r(s.r,i);return;case"cond":r(s.test,i),r(s.cons,i),r(s.alt,i);return;case"assign":r(s.target,i),r(s.value,i);return;case"arrow":r(s.body,new Set([...i,...s.params]));return;case"arr":s.items.forEach((n)=>r(n.value,i));return;case"obj":s.props.forEach((n)=>r(n.value,i));return}};return r(t,new Set),[...e]}var Xt=Symbol("lips.ended");var st=new Set(["if","else-if","else","for","switch","async","let","const","log","context","i18n"]),rt=new Set(["case","default","then","catch","loading"]),it=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","svg","circle","clippath","defs","ellipse","foreignobject","g","image","line","lineargradient","marker","mask","path","pattern","polygon","polyline","radialgradient","rect","stop","symbol","text","tspan","use"]);var Pt="<!--$-->",$t=new Set(["stop","capture","outside"]),wt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Rt=(t)=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),Lt=(t)=>t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<"),nt=(t)=>t!==""&&!isNaN(Number(t)),ot=(t)=>{let e=t.trim(),r=0;for(let s=0;s<e.length;s++){let i=e[s];if(i==="'"||i==='"'||i==="`"){s++;while(s<e.length&&e[s]!==i){if(e[s]==="\\")s++;s++}continue}if(i==="("||i==="["||i==="{")r++;else if(i===")"||i==="]"||i==="}"){if(r--,r===0&&e[0]==="{"&&s===e.length-1)return ot(e.slice(1,-1))}else if(r===0){if(i==="?")return!1;if(i===":")return!0}}return!1},Ct=(t)=>{if(t.k==="expr")return t.source;if(t.k!=="interp")return"";let e=t.parts.filter((r)=>typeof r!=="string");return e.length===1&&t.parts.every((r)=>typeof r!=="string"||!r.trim())?e[0].expr:""};class at{src;macros;tree;exprs=[];exprIndex=new Map;lineStarts=null;macroStack=[];diagnostics=[];constructor(t,e=new Map,r=!1){this.src=t;this.macros=e;this.tree=r}locate(t){if(!this.lineStarts){this.lineStarts=[0];for(let s=0;s<this.src.length;s++)if(this.src[s]===`
|
|
8
|
+
`)this.lineStarts.push(s+1)}let e=0,r=this.lineStarts.length-1;while(e<r){let s=e+r+1>>1;this.lineStarts[s]<=t?e=s:r=s-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,r,s,i=1,n){let{line:a,col:o}=this.locate(s);this.diagnostics.push({code:t,severity:e,message:r,hint:n,loc:{line:a,col:o,offset:s,length:i}})}expr(t,e){let r=this.exprIndex.get(t);if(r!==void 0)return r;let{diagnostics:s}=_(t);for(let n of s){let a=(e?.offset??0)+n.loc.offset;this.report(n.code,"error",n.message,a,n.loc.length)}let i=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,i),i}synth(t){let e=this.exprIndex.get(t);if(e!==void 0)return e;let r=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,r),r}concat(t){t.filter((r)=>typeof r!=="string").forEach((r)=>{let{diagnostics:s}=_(r.expr);for(let i of s)this.report(i.code,"error",i.message,r.loc.offset+i.loc.offset,i.loc.length)});let e=t.map((r)=>typeof r==="string"?JSON.stringify(r):`((${r.expr})??"")`).join("+");return this.synth(e)}compInput(t){switch(t.k){case"literal":return{lit:t.value};case"bool":return{lit:t.value};case"expr":return{e:this.expr(t.source,t.loc)};case"interp":return{e:this.concat(t.parts)}}}compile(t){return{v:1,exprs:this.exprs,root:this.block(t,[])}}block(t,e){let r={html:"",scope:[...e],binds:[],blocks:[]},s=[],i=this.tree,n=[],a=(o,l,p,b=!1,k)=>{let E=0,d=!1,y=()=>(s.push(Pt),i&&p.push(0),d=!1,[...l,E++]);for(let I=0;I<o.length;I++){let m=o[I];switch(m.t){case"text":{if(b){let u={t:"text",p:y(),e:this.synth(JSON.stringify(m.value)),i18n:1};if(k)u.ik=k;r.binds.push(u);break}if(s.push(Rt(m.value)),i&&(d?p[p.length-1]+=m.value:p.push(m.value)),!d)E++;d=!0;break}case"comment":{if(i)break;let u=m.value.replace(/--/g,"- -");s.push(`<!--${/^-?>/.test(u)?" "+u:u}-->`),d=!1,E++;break}case"interp":{let u={t:"text",p:y(),e:this.concat(m.parts)};if(b)u.i18n=1;if(b&&k)u.ik=k;r.binds.push(u);break}case"fragment":{o=[...o.slice(0,I),...m.children,...o.slice(I+1)],I--;break}case"element":{if(st.has(m.tag)){if(this.controlBlock(m,o,I,y(),r,e),m.tag==="if"){let u=I+1;while(u<o.length){let R=o[u];if(R.t==="element"&&(R.tag==="else-if"||R.tag==="else"))u++;else break}o=[...o.slice(0,I+1),...o.slice(u)]}break}if(rt.has(m.tag)){this.report("LIPS-C002","error",`<${m.tag}> is only valid inside its parent construct`,m.loc.offset,m.loc.length);break}if(m.tag==="#dynamic"){r.blocks.push(this.compLike(m,y(),e,"dynamic"));break}if(this.macros.has(m.tag)){let u=this.macroCall(m,y(),e);u&&r.blocks.push(u);break}if(!it.has(m.tag)){r.blocks.push(this.compLike(m,y(),e,"comp"));break}this.emitElement(m,l,E++,s,r,a,p),d=!1;break}}}};if(a(t,[],n),r.html=s.join(""),i)r.nodes=n;return r}emitElement(t,e,r,s,i,n,a){let o=[...e,r],l=`<${t.tag}`,p=[t.tag],b={},k=(c,x)=>{Object.prototype.hasOwnProperty.call(b,c)||(b[c]=x)};this.tree&&a.push(p);let E=t.attrs.filter((c)=>("name"in c)),d=E.some((c)=>c.name==="i18n"&&(c.k==="bool"&&c.value||c.k==="literal")),y=(c)=>d&&(c==="title"||c==="placeholder"),I=(c)=>{let x=E.find((L)=>L.name===c&&L.k==="literal");return x&&"value"in x&&x.value?String(x.value):void 0},m=I("i18n"),u=(c)=>I(`i18n-${c}`);!d&&E.some((c)=>c.name.startsWith("i18n-"))&&this.report("LIPS-C014","warning",`i18n-* key on <${t.tag}> without the 'i18n' marker — the attribute will not be translated`,t.loc.offset,t.loc.length);for(let c of t.attrs){if(this.tree&&"name"in c&&c.name==="@html"){this.report("LIPS-C021","error",`@html on <${t.tag}>: the 'tree' target has no HTML parser`,c.loc.offset,c.loc.length,"Write the markup in the template, or use @text");continue}if("name"in c&&c.name==="style"){let x=Ct(c);if(x&&ot(x)){this.report("LIPS-C019","error",`style= on <${t.tag}> takes CSS text, not an object literal`,c.loc.offset,c.loc.length,'Write the declarations as CSS — style="border: 2px solid gray; margin: 3rem" — '+`and interpolate values into it where they vary: style="margin: {state.gap}rem". Styles that need pseudo-classes, media queries or keyframes belong in the component's stylesheet.`);continue}}if(this.quotedEvent(t.tag,c))continue;switch(c.k){case"literal":if(c.name==="@format"){i.binds.push(this.formatBind(o,c));break}if(c.name.startsWith("@")){i.binds.push({t:"prop",p:o,name:c.name.slice(1),e:this.synth(JSON.stringify(c.value))});break}if(c.name==="i18n"||c.name.startsWith("i18n-"))break;if(y(c.name)){let x={t:"attr",p:o,name:c.name,e:this.synth(JSON.stringify(c.value)),i18n:1},L=u(c.name);if(L)x.ik=L;i.binds.push(x);break}l+=` ${c.name}="${Lt(c.value)}"`,k(c.name,c.value);break;case"bool":if(c.name!=="i18n"&&c.value)l+=` ${c.name}`,k(c.name,"");break;case"expr":{if(c.name==="@format"){i.binds.push(this.formatBind(o,c));break}if(c.name.startsWith("@")){i.binds.push({t:"prop",p:o,name:c.name.slice(1),e:this.expr(c.source,c.loc)});break}let x={t:"attr",p:o,name:c.name,e:this.expr(c.source,c.loc)};if(y(c.name)){x.i18n=1;let L=u(c.name);if(L)x.ik=L}i.binds.push(x);break}case"interp":{if(c.name==="@format"){i.binds.push(this.formatBind(o,c));break}if(c.name.startsWith("@")){i.binds.push({t:"prop",p:o,name:c.name.slice(1),e:this.concat(c.parts)});break}let x={t:"attr",p:o,name:c.name,e:this.concat(c.parts)};if(y(c.name)){x.i18n=1;let L=u(c.name);if(L)x.ik=L}i.binds.push(x);break}case"event":this.modifiers(c),i.binds.push({t:"event",p:o,name:c.name,e:this.synth(c.source)});break;case"spread":i.binds.push({t:"spread",p:o,e:this.expr(c.source,c.loc)});break;case"fn":this.report("LIPS-C007","warning",`Callable attribute '${c.name}(…)' has no meaning on <${t.tag}>`,c.loc.offset,c.loc.length);break;case"args":this.report("LIPS-C008","warning",`Iterator arguments are not applicable to <${t.tag}>`,c.loc.offset,c.loc.length);break}}if(Object.keys(b).length&&(p[1]=b),wt.has(t.tag)){s.push(l+">");return}s.push(l+">");let w=m,j=t.children.filter((c)=>c.t==="text"||c.t==="interp");if(w&&(j.length>1||j.some((c)=>c.t==="interp")))this.report("LIPS-C015","error",`<${t.tag} i18n="${w}"> keys text that is not a single fixed string. Use @format="${w}, { … }" for interpolated text.`,t.loc.offset,t.loc.length),w=void 0;let f=[];if(t.children.length&&n(t.children,o,f,d,w),f.length)p[1]=b,p[2]=f;s.push(`</${t.tag}>`)}formatBind(t,e){let r=e.k==="literal"?e.value:e.k==="expr"?e.source:e.parts.map((a)=>typeof a==="string"?a:`{${a.expr}}`).join(""),s=r.indexOf(",");if(s===-1)return this.report("LIPS-C012","error",'@format expects "reference, { params }"',e.loc.offset,e.loc.length),{t:"prop",p:t,name:"format",e:this.synth("({})"),ref:r.trim()};let i=r.slice(0,s).trim(),n=r.slice(s+1).trim();return{t:"prop",p:t,name:"format",e:this.expr(n,e.loc),ref:i}}attrsOf(t){let e=new Map,r=[];for(let s of t.attrs)if(s.k==="args")r.push(...s.names);else if("name"in s)e.set(s.name,s);return{byName:e,args:r}}controlBlock(t,e,r,s,i,n){switch(t.tag){case"if":{let a=[{when:t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),block:this.block(t.children,n)}];for(let o=r+1;o<e.length;o++){let l=e[o];if(l.t!=="element")break;if(l.tag==="else-if")a.push({when:l.head?this.expr(l.head.expr,l.head.loc):this.missingHead(l),block:this.block(l.children,n)});else if(l.tag==="else"){a.push({when:null,block:this.block(l.children,n)});break}else break}i.blocks.push({t:"if",p:s,branches:a});break}case"else-if":case"else":this.report("LIPS-C001","error",`<${t.tag}> without a preceding <if>`,t.loc.offset,t.loc.length);break;case"for":{let{byName:a,args:o}=this.attrsOf(t),l=a.get("in"),p=a.get("from"),b=a.get("to"),k=a.get("by");if(!l&&!p){this.report("LIPS-C004","error","<for> requires 'in' or 'from'/'to'",t.loc.offset,t.loc.length);break}let E={t:"for",p:s,args:o,block:this.block(t.children,[...n,...o])};if(l){let d=this.valueOf(l);d===void 0?this.report("LIPS-C004","error","<for in=…> takes an expression: in=state.items",l.loc.offset,l.loc.length):E.of=this.expr(d,l.loc)}if(p)E.from=this.numInput(p);if(b)E.to=this.numInput(b);if(k){let d=k.k==="literal"?void 0:this.valueOf(k);k.k==="literal"?E.by={lit:k.value}:d===void 0?this.report("LIPS-C004","error","<for by=…> takes a key path or an expression",k.loc.offset,k.loc.length):E.by={e:this.expr(d,k.loc)}}i.blocks.push(E);break}case"switch":{let a=t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),o=[];for(let l of t.children){if(l.t!=="element")continue;if(l.tag==="case"){let{byName:p}=this.attrsOf(l),b=p.get("is");if(!b||b.k!=="literal"&&b.k!=="expr"){this.report("LIPS-C004","error","<case> requires an 'is' attribute",l.loc.offset,l.loc.length);continue}o.push({is:b.k==="literal"?{lit:b.value}:{e:this.expr(b.source,b.loc)},block:this.block(l.children,n)})}else if(l.tag==="default")o.push({is:null,block:this.block(l.children,n)});else this.report("LIPS-C003","error","Only <case>/<default> are valid inside <switch>",l.loc.offset,l.loc.length)}i.blocks.push({t:"switch",p:s,on:a,cases:o});break}case"async":{let a=t.attrs.find((l)=>l.k==="fn"&&l.name==="await");if(!a){this.report("LIPS-C004","error","<async> requires await(…)",t.loc.offset,t.loc.length);break}let o={t:"async",p:s,awaitE:this.expr(a.source,a.loc)};for(let l of t.children){if(l.t!=="element")continue;let{args:p}=this.attrsOf(l);if(l.tag==="then")o.then={args:p,block:this.block(l.children,[...n,...p])};else if(l.tag==="catch")o.catch={args:p,block:this.block(l.children,[...n,...p])};else if(l.tag==="loading")o.loading=this.block(l.children,n);else this.report("LIPS-C003","error","Only <then>/<catch>/<loading> are valid inside <async>",l.loc.offset,l.loc.length)}i.blocks.push(o);break}case"let":case"const":{let a={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C013","error",`Spread is not supported on <${t.tag}> — scope names must be known at compile time`,o.loc.offset,o.loc.length,`Assign it to one variable: <${t.tag} obj={ ${o.source} }/> and read obj.<key>`);continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")a[o.name]=this.compInput(o),!i.scope.includes(o.name)&&i.scope.push(o.name),!n.includes(o.name)&&n.push(o.name)}i.blocks.push({t:"let",p:s,const:t.tag==="const",vars:a});break}case"log":i.blocks.push({t:"log",p:s,e:t.head?this.synth(t.head.expr):this.missingHead(t)});break;case"context":{let a={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C016","error","Spread is not supported on <context> — provided keys must be known at compile time",o.loc.offset,o.loc.length,"Provide them one by one: <context a=obj.a b=obj.b>");continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")a[o.name]=this.compInput(o)}if(!Object.keys(a).length)this.report("LIPS-C017","warning","<context> provides nothing — it renders its children unchanged",t.loc.offset,t.loc.length);i.blocks.push({t:"provide",p:s,vars:a,block:this.block(t.children,n)});break}case"i18n":{let{byName:a}=this.attrsOf(t),o=a.get("lang");if(!o){this.report("LIPS-C018","error","<i18n> requires a 'lang' attribute: <i18n lang=state.docLang>",t.loc.offset,t.loc.length);break}i.blocks.push({t:"provide",p:s,vars:{},lang:this.compInput(o),block:this.block(t.children,n)});break}}}missingHead(t){return this.report("LIPS-C004","error",`<${t.tag}> requires a head expression: <${t.tag}( … )>`,t.loc.offset,t.loc.length),this.synth("undefined")}numInput(t){if(t.k==="literal")return{lit:nt(t.value)?Number(t.value):t.value};let e=this.valueOf(t);if(e!==void 0)return nt(e)?{lit:Number(e)}:{e:this.expr(e,t.loc)};return"name"in t&&this.report("LIPS-C004","error",`<for ${t.name}=…> takes a number or an expression`,t.loc.offset,t.loc.length),{lit:void 0}}valueOf(t){if(t.k==="expr")return t.source;if(t.k==="interp"&&t.parts.length===1&&typeof t.parts[0]!=="string")return t.parts[0].expr}macroCall(t,e,r){let s=this.macros.get(t.tag);if(this.macroStack.includes(s.name))return this.report("LIPS-C009","error",`Recursive macro <${s.name}> (${[...this.macroStack,s.name].join(" → ")})`,t.loc.offset,t.loc.length),null;let i=[];for(let a of t.attrs)if(a.k==="literal"||a.k==="expr"||a.k==="interp"||a.k==="bool")i.push({name:a.name,ci:this.compInput(a)});else if(a.k==="spread")i.push({spread:this.expr(a.source,a.loc)});else if(a.k==="event")this.report("LIPS-C023","error",`on-${a.name}( … ) on the macro <${t.tag}> wires no listener`,a.loc.offset,a.loc.length,"Pass the handler as an argument (fn=self.pick) and wire it in the body");t.children.length&&this.report("LIPS-C024","error",`<${t.tag}> is a macro: what it encloses is not rendered`,t.loc.offset,t.loc.length,"A component takes content: <{input.renderer}/>"),this.macroStack.push(s.name);let n=this.block(s.children,[...r,...s.argv]);return this.macroStack.pop(),{t:"macro",p:e,name:s.name,sets:i,args:s.argv,block:n}}quotedEvent(t,e){if(!("name"in e)||!e.name.startsWith("on-"))return!1;return this.report("LIPS-C020","error",`${e.name}="…" on <${t}> wires no listener`,e.loc.offset,e.loc.length,`Handlers use the instruction form: ${e.name}( … ). `+"Quoted, it is an ordinary attribute — the handler never runs and the source is emitted into the DOM."),!0}modifiers(t,e){let r=t.name.split(".").slice(1),s=r.find((i)=>!$t.has(i));(s||e&&r[0])&&this.report("LIPS-C022",s?"error":"warning",s?`Unknown event modifier .${s}: use .stop, .capture or .outside`:`.${r[0]} does nothing on a component's event`,t.loc.offset,t.loc.length)}compLike(t,e,r,s){let i={},n=[],a=[],o=[];for(let p of t.attrs){if(p.k!=="event"&&this.quotedEvent(t.tag,p))continue;switch(p.k){case"literal":case"bool":case"expr":case"interp":if(p.name==="@format"&&p.k!=="bool"){let{ref:b,e:k}=this.formatBind(e,p);i[p.name]={lit:{ref:b,e:k}};break}i[p.name]=this.compInput(p);break;case"event":this.modifiers(p,s==="comp"),a.push({name:p.name,e:this.synth(p.source)});break;case"spread":n.push(this.expr(p.source,p.loc));break;case"args":o=[...o,...p.names];break;case"fn":i[p.name]={e:this.expr(p.source,p.loc)};break}}let l=t.children.length?{args:o,block:this.block(t.children,[...r,...o])}:void 0;return s==="comp"?{t:"comp",p:e,name:t.tag,inputs:i,spreads:n,events:a,contents:l}:{t:"dynamic",p:e,tag:this.expr(t.dynamicTag.expr,t.dynamicTag.loc),inputs:i,spreads:n,events:a,contents:l}}}function Nt(t,e,r){let s=new Map;if(!t?.trim())return s;let i=W(t);e.push(...i.diagnostics),r?.(i.root.children,e,t);for(let n of i.root.children){if(n.t!=="element")continue;if(n.tag!=="macro"){e.push({code:"LIPS-C010",severity:"warning",message:`Only <macro> definitions are allowed in the macros source — ignoring <${n.tag}>`,loc:{line:1,col:1,offset:n.loc.offset,length:n.loc.length}});continue}let a="",o=[];for(let l of n.attrs)if(l.k==="args")o.push(...l.names);else if(l.k==="literal"&&l.name==="name")a=l.value;if(!a){e.push({code:"LIPS-C011",severity:"error",message:"<macro> requires a name attribute",loc:{line:1,col:1,offset:n.loc.offset,length:n.loc.length}});continue}s.set(a.toLowerCase(),{name:a,argv:o,children:n.children})}return s}function F(t,e){let r=[],s=Nt(e?.macros||"",r,e?.check),i=W(t);e?.check?.(i.root.children,r,t),e?.transform?.(i.root.children,r);let n=new at(t,s,e?.target==="tree");return{ir:n.compile(i.root.children),diagnostics:[...r,...i.diagnostics,...n.diagnostics]}}var Tt=null;var At=/^[-\w]+$/,ut=/^(%|[a-zA-Z]+)/,lt=["<number>","0"];function M(t,e){let r=t[e];e++;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===r)return e+1;e++}return e}function ft(t,e){let r=t.indexOf("*/",e+2);return r<0?t.length:r+2}function Ot(t,e){let r=t.indexOf(`
|
|
9
|
+
`,e+2);return r<0?t.length:r}var _t=(t)=>t.replace(/["\\]/g,"\\$&");function D(t,e,r){let s=1,i=-1;for(let n=0;n<e;n++)if(t[n]===`
|
|
10
|
+
`)s++,i=n;return{line:s,col:e-i,offset:e,length:r}}function G(t,e){let r=e+1,s=0,i=!1,n=!1;while(r<t.length){let o=t[r];if(o==='"'||o==="'"){r=M(t,r);continue}if(o==="{"||o===";")return null;if(o==="}")break;if(o==="("||o==="[")s++;else if(o===")"||o==="]")s--;else if(s===0){if(o==="?")i=!0;else if(o===":"&&!i)n=!0}r++}if(r>=t.length||n)return null;let a=t.slice(e+1,r).trim();return a?{end:r,expr:a}:null}var jt=new Set(["state","input","static","context","self"]);function Bt(t,e,r,s){let i=[],n=e,a=e,o=0;while(n<t.length){let l=t[n];if(l==='"'||l==="'"){n=M(t,n);continue}if(l==="/"&&t[n+1]==="*"){let p=ft(t,n);if(!r)i.push(t.slice(a,n)," "),a=p;n=p;continue}if(l==="("){o++,n++;continue}if(l===")"){o--,n++;continue}if(o===0&&(l===";"||l==="}"))return i.push(t.slice(a,n)),{end:n,parts:i};if(l==="{"){let p=G(t,n);if(!p)return t.indexOf("}",n+1)<0&&s?.(n),null;i.push(t.slice(a,n));let b=ut.exec(t.slice(p.end+1)),k=b?b[1]:"";i.push({expr:p.expr,unit:k,at:n}),n=p.end+1+k.length,a=n;continue}n++}return i.some((l)=>typeof l!=="string")&&s?.(e),null}var Dt=/^@(-\w+-)?(keyframes|font-face|property|counter-style|font-feature-values|font-palette-values|page|view-transition|position-try|color-profile|function)\b/i,ct=/^@(import|charset|namespace)\b/i,Mt=/^@(media|supports|container|layer|scope|starting-style|document)\b/i,qt=/^([a-zA-Z_*\\]|[^\x00-\x7f])/,Ut=/^(?:[-\w*|]|[^\x00-\x7f]|\\[\s\S])+/,Wt=/&[-_]/,gt=/\s/,pt=/[{};]/,ht=/[-\w]/,mt=/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/g,Ht=new RegExp(`(${mt.source})|\\s+`,"g"),Ft=/\/\*[\s\S]*?\*\//g,Gt=/^@layer\b/i,Vt=(t)=>t.replace(Ht,(e,r)=>r||" ");function zt(t){let e=[],r=0,s=0;for(let i=0;i<t.length;i++){let n=t[i];if(n==="\\"){i++;continue}if(n==='"'||n==="'"){i=M(t,i)-1;continue}if(n==="("||n==="[")s++;else if(n===")"||n==="]")s--;else if(n===","&&!s)e.push(t.slice(r,i)),r=i+1}return e.push(t.slice(r)),e.map((i)=>{let n=i.trimStart(),a=n.length;while(a&>.test(n[a-1])&&n[a-2]!=="\\")a--;if(n=n.slice(0,a),!qt.test(n))return n;return n.includes("&")?n.replace(Ut,":is($&)"):`& ${n}`}).join(",")}function Zt(t,e,r,s){let i=[],n=[],a=[],o=`--${e.nsp.replace(/[^a-zA-Z0-9_-]/g,"-")}`,l=(h,v,g,S,P)=>s.push({code:h,severity:"error",message:v,hint:P,loc:D(t,g,S)}),p=(h,v,g,S,P)=>s.push({code:h,severity:"warning",message:v,hint:P,loc:D(t,g,S)}),b=(h,v,g,S)=>e.lint?.(h,S)?.forEach((P)=>s.push({...P,loc:D(t,v,g-v)})),k=(h)=>{let v=i.indexOf(h);if(v<0)v=i.push(h)-1;return v},E=(h)=>{let{ast:v,diagnostics:g}=_(h.expr),S=h.expr.length+2;if(g.length){l("LIPS-S004",`Invalid expression: ${g[0].message}`,h.at,S);return}for(let P of et(v))if(!jt.has(P)&&!(P in globalThis))l("LIPS-S003",`'${P}' is not readable from a stylesheet`,h.at,S,"Stylesheets see state, input, static, context and self — not <for> iterators or <let> names, "+"which are local to a template position.");h.unit&&v.t==="lit"&&typeof v.v==="string"&&p("LIPS-S005",`Unit '${h.unit}' after a string value`,h.at,S,`A unit suffix multiplies a number: drop the unit, or return ${h.unit==="%"?"50":"8"} instead of a string.`)},d="",y="",I="",m=!1,u=(h)=>{if(!h)return;if(m&&I&&!pt.test(I)&&!pt.test(h[0]))y+=" ";m=!1,y+=h,I=h[h.length-1]},R=(h)=>{d+=y+h,y="",I=h,m=!1},w=()=>{let h=y;return y=I="",m=!1,h},j=(h)=>":"+(Vt(h).trim()||" "),f=0,c=0,x=0,L="",O="",z="",Z=!1,N=[{ctx:e.meta?"top":"style"}],dt=()=>{let h=N[N.length-1],v=y,g;if(h.ctx==="opaque"||b(v,x,f),v[0]==="@")if(h.ctx!=="opaque"&&Dt.test(v))g={ctx:"opaque",hoist:d.length};else if(Mt.test(v))g={ctx:h.ctx,group:v,at:d.length};else g={ctx:"opaque"};else{if(h.ctx==="style"){if(r)Wt.test(v.replace(mt,""))&&p("LIPS-S008",`'${v}' joins '&' to a name`,x,f-x,"Native nesting cannot: write the full selector, or use stylisPreprocessor."),y=zt(v)}g={ctx:h.ctx==="opaque"?"opaque":"style"}}N.push(g),R("{"),g.group&&(g.body=d.length)},J=()=>{let h=N.pop();if(h.group&&!y&&d.length===h.body&&!Gt.test(h.group)){d=d.slice(0,h.at),I="",m=!1;return}if(R("}"),h.hoist===void 0)return;let v=d.slice(h.hoist),g=N.filter((T)=>T.group),S=g.map((T)=>T.group).join("{"),P="}".repeat(g.length);d=d.slice(0,h.hoist),I="",O=S&&S===z?O.slice(0,O.length-P.length)+v+P:O+g.map((T)=>T.group+"{").join("")+v+P,z=S};while(f<t.length){let h=t[f];if(h==="\\"){u(t.slice(f,f+2)),f+=2;continue}let v=h==="/"&&!t.slice(x,f).trim();if(h==="/"&&(t[f+1]==="*"||t[f+1]==="/"&&v)){let g=t[f+1]==="/",S=g?Ot(t,f):ft(t,f);if(!g&&!r)y?u(t.slice(f,S)):d+=t.slice(f,S);else ht.test(I)&&ht.test(t[S]||"")&&(m=!0);v&&(x=S),f=S;continue}if(h==='"'||h==="'"){let g=M(t,f);u(t.slice(f,g)),f=g;continue}if(gt.test(h)){x===f&&x++,m=!0,f++;continue}if(h==="(")c++;else if(h===")")c--;if(h===":"&&c===0){let g=t.slice(x,f).replace(Ft,"").trim();if(At.test(g)){let S=Bt(t,f+1,!r,(P)=>{Z=!0,l("LIPS-S004","Unterminated interpolation",P,t.length-P,"Close the expression with `}`.")});if(S){let P=S.parts.filter((C)=>typeof C!=="string");for(let C of P)E(C);if(m=!1,g.startsWith("--")&&P.length===1&&!P[0].unit&&S.parts.every((C)=>typeof C!=="string"||!C.trim())){n.push({prop:g,e:k(P[0].expr)}),w(),f=S.end+(t[S.end]===";"?1:0),x=f;continue}let B="";for(let C of S.parts){if(typeof C==="string"){B+=C;continue}let K=k(C.expr),A=`${o}-${K}`;if(!n.some((q)=>q.prop===A)){if(n.push({prop:A,e:K}),C.unit&&!a.some((q)=>q.name===A))a.push({name:A,syntax:lt[0],inherits:!0,initial:lt[1]})}B+=C.unit?`calc(var(${A}) * 1${C.unit})`:`var(${A})`}b(g,x,S.end,B),u(j(B)),f=S.end;continue}}}if(h==="{"){if(c>0){let g=G(t,f);if(g){l("LIPS-S002","Interpolation in an at-rule condition",f,g.end-f+1,"Media and container conditions cannot read custom properties. Keep the condition static.");let S=ut.exec(t.slice(g.end+1));f=g.end+1+(S?S[1].length:0);continue}}if(!t.slice(x,f).trim()){let g=G(t,f);if(g){l("LIPS-S001","Interpolation in a selector",f,g.end-f+1,"Selectors are static in Layer 1. Bind a value inside the rule instead."),f=g.end+1,x=f;continue}}dt(),x=++f;continue}if(h==="}"){if(N.length>1)J();else p("LIPS-S007","Unmatched `}` dropped",f,1),y&&R(";");x=++f;continue}if(h===";"){if(y[0]==="@"&&b(y,x,f),N.length===1&&ct.test(y))L+=w()+";";else R(";");x=++f;continue}u(h),f++}if(N.length>1){Z||p("LIPS-S007","Unclosed `{` closed at the end",t.length,0);while(N.length>1)J()}return ct.test(y)&&(L+=w()+";"),R(""),{css:d,statements:L,hoisted:O,exprs:i,binds:n,props:a}}function V(t,e){let r=[],s=e.preprocess||Tt,{css:i,statements:n,hoisted:a,exprs:o,binds:l,props:p}=Zt(t,e,!s,r),b={v:1,nsp:e.nsp,css:"",exprs:[],binds:[]},k=e.meta||!i?i:`${e.scope||`[rel="${_t(e.nsp)}"]`}{${i}}`,E=a+k,d=e.layer?`@layer ${e.layer}{${E}}`:E,y;try{y=s?s(d):d}catch(u){return r.push({code:"LIPS-S006",severity:"error",message:`Style compilation failed: ${u.message}`,loc:D(t,0,t.length)}),{ir:b,diagnostics:r}}let I=p.map((u)=>`@property ${u.name}{syntax:"${u.syntax}";inherits:${u.inherits};initial-value:${u.initial}}`).join(""),m={v:1,nsp:e.nsp,css:n+I+y,exprs:o,binds:l};if(p.length)m.props=p;return{ir:m,diagnostics:r}}function pe(t,e={}){let r={macros:t.macros,target:e.target},{ir:s,diagnostics:i}=F(t.default||"",r),{default:n,macros:a,stylesheet:o,...l}=t;if(!o)return{template:{...l,ir:s},diagnostics:i};let p=V(o,{nsp:e.name||"lips",preprocess:e.preprocess});return{template:{...l,ir:s,style:p.ir},diagnostics:[...i,...p.diagnostics]}}var Jt=(t)=>JSON.stringify(t),Kt=(t)=>JSON.stringify(t);function he(t={}){let e=t.include||/\.lips$/,r=t.reportDiagnostics!==!1;return{name:"lips:precompile",enforce:"pre",async transform(s,i){if(!e.test(i))return null;await Promise.resolve().then(() => H());let{script:a}=X(s),o=s.slice(a.length),l=/\bconst\s+macros\s*=\s*`([^`]*)`/.exec(a)?.[1];if(/\bconst\s+macros\b/.test(a)&&(l===void 0||l.includes("${")))throw Error(`[lips] ${i}: const macros must be a plain template literal — it is inlined at build time`);let{ir:p,diagnostics:b}=F(o,{target:t.target,macros:l});if(r)for(let u of b)this?.warn?.(`[lips] ${u.code} ${u.message} (${i}:${u.loc.line}:${u.loc.col})`);let k=b.filter((u)=>u.severity==="error");if(k.length)throw Error(`[lips] ${i}: ${k[0].message} at line ${k[0].loc.line}:${k[0].loc.col}`);let E=(i.split(/[\\/]/).pop()||"lips").replace(/\.lips$/,""),d=/\bconst\s+stylesheet\s*=\s*`([^`]*)`/.exec(a),y=/\bconst\s+stylesheet\b/.test(a),I=d&&!d[1].includes("${"),m="";if(I){let u=V(d[1],{nsp:E,preprocess:t.preprocess});if(r)for(let w of u.diagnostics)this?.warn?.(`[lips] ${w.code} ${w.message} (${i}:${w.loc.line}:${w.loc.col})`);let R=u.diagnostics.filter((w)=>w.severity==="error");if(R.length)throw Error(`[lips] ${i}: ${R[0].message} at line ${R[0].loc.line}:${R[0].loc.col}`);m=` style: ${Kt(u.ir)},
|
|
11
|
+
`}else if(y&&r)this?.warn?.(`[lips] ${i}: stylesheet could not be precompiled (interpolated template literal) — `+'it ships as source and needs "@lipsjs/lips", not "@lipsjs/lips/runtime".');return{code:`${a}
|
|
12
|
+
const __lips_ir__ = ${Jt(p)};
|
|
13
13
|
export default {
|
|
14
14
|
ir: __lips_ir__,
|
|
15
|
-
${
|
|
15
|
+
${m} ${/\bconst\s+state\b/.test(a)?"state,":""}
|
|
16
16
|
${/\bconst\s+handler\b/.test(a)?"handler,":""}
|
|
17
17
|
${/\bconst\s+_static\b/.test(a)?"_static,":""}
|
|
18
|
-
${/\bconst\s+
|
|
19
|
-
${
|
|
18
|
+
${/\bconst\s+watchContext\b/.test(a)?"watchContext,":""}
|
|
19
|
+
${y&&!I?"stylesheet,":""}
|
|
20
20
|
};
|
|
21
|
-
`,map:null}}}}export{
|
|
21
|
+
`,map:null}}}}export{he as lipsPlugin,pe as precompile,Jt as serializeIR,Kt as serializeStyleIR};
|
|
22
22
|
|
|
23
|
-
//# debugId=
|
|
23
|
+
//# debugId=14B7246B84A3AC2564756E2164756E21
|