@hyperfixi/engine 7.5.0 → 7.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/CHANGELOG.md +124 -0
- package/README.md +109 -30
- package/dist/additions.d.ts +11 -4
- package/dist/common.js +247 -201
- package/dist/common.min.js +9 -9
- package/dist/core.js +55 -3
- package/dist/core.min.js +9 -9
- package/dist/engine.d.ts +9 -1
- package/dist/ext/socket.d.ts +32 -0
- package/dist/ext/socket.dev.js +139 -0
- package/dist/ext/socket.esm.js +127 -0
- package/dist/ext/socket.js +1 -0
- package/dist/ext/tailwind.d.ts +16 -0
- package/dist/ext/tailwind.dev.js +30 -0
- package/dist/ext/tailwind.esm.js +16 -0
- package/dist/ext/tailwind.js +1 -0
- package/dist/full.js +82 -12
- package/dist/full.min.js +15 -15
- package/dist/hyperfixi-hs.dev.js +82 -12
- package/dist/hyperfixi-hs.js +15 -15
- package/dist/index.d.ts +1 -2
- package/dist/index.js +68 -12
- package/dist/kit.d.ts +13 -0
- package/dist/minimal.js +56 -10
- package/dist/minimal.min.js +8 -8
- package/dist/parser.d.ts +15 -2
- package/dist/statements.d.ts +1 -1
- package/package.json +8 -1
package/dist/core.min.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";(()=>{var G=e=>typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function",E=(e,t)=>G(e)?e.then(t):t(e),S=(e,t)=>e.some(G)?Promise.all(e).then(t):t(e),C=e=>e!=null,
|
|
2
|
-
`,r:"\r",t:" ",v:"\v"},
|
|
3
|
-
`,
|
|
4
|
-
`?(i++,o=0):o++,s),p=f=>({type:f,value:"",start:r,end:r+1,line:i,column:o}),m=(f,h)=>(f.value=h,f.end=r,f),d=f=>{let h="";for(;
|
|
5
|
-
`),c();else if(Te(f))n.push(m(p("WHITESPACE"),d(Te)));else if(!I()&&f==="."&&(q(h)||h==="{"||h==="-"))n.push(j("CLASS_REF",!0));else if(!I()&&f==="#"&&(q(h)||h==="{"))n.push(j("ID_REF",!1));else if(f==="@"||f==="["&&h==="@")n.push(Lt());else if(f==="*"&&q(h)){let x=p("STYLE_REF");n.push(m(x,c()+d(T=>q(T)||T==="-")))}else if(y()&&(q(f)||f==="\\"))n.push(qt());else if(!y()&&(q(f)||f==="_"||f==="$"))n.push(Me());else if(_(f))n.push(_t());else if(!y()&&(f==='"'||f==="`"))n.push(F());else if(!y()&&f==="'")n.push(Dt()?F():He());else if(Ke.has(f))s==="$"&&f==="{"&&a++,f==="}"&&a--,n.push(He());else if(y()||f==="`"){let x=p("RESERVED");n.push(m(x,c()))}else throw new Error("Unknown token: "+f+" ")}return n}function b(e){return e.match("the"),Wt(e)}function Wt(e){let t=nt(e),n,r=()=>e.match("and")??e.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&e.err("You must parenthesize logical operations with different operators"),t=Gt(o.value,t,nt(e));return t}function Gt(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>E(t.ev(o),i=>!!i===r?i:n.ev(o))}}var zt={"+":(e,t)=>Array.isArray(e)?e.concat(t):v(e)+v(t),"-":(e,t)=>v(e)-v(t),"*":(e,t)=>v(e)*v(t),"/":(e,t)=>v(e)/v(t),mod:(e,t)=>v(e)%v(t)};function Se(e){let t=Oe(e),n,r=()=>e.matchAnyOp("+","-","*","/")??e.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&e.err("You must parenthesize math operations with different operators");let i=t,s=Oe(e),a=zt[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>S([i.ev(l),s.ev(l)],([c,p])=>a(c,p))}}return t}function Oe(e){let t=M(e);for(let n=!0;n;){n=!1;for(let r of e.g.collections){let o=r(e,t);if(o){t=o,n=!0;break}}}return t}function M(e){e.match("the");let t=e.pos();if(e.match("not"))return Ie(e,"logicalNot",t,M(e),n=>!n);if(e.match("no"))return Ie(e,"noExpression",t,Oe(e),ke);for(let n of e.g.unaries){let r=n(e);if(r)return O(e,r)}return Qt(e)}function Ie(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:a=>E(r.ev(a),u=>o(u,a))};return i?O(e,s):s}var Bt="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function Qt(e){let t=it(e),n=e.matchAny(...Bt)??e.matchOp("%");if(n)return tt(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return tt(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function tt(e,t,n,r){let o=s=>typeof r=="number"?v(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>E(n.ev(s),o)};return n.stat&&(i.stat=()=>o(ne(n))),i}function it(e){let t=e.pos();return e.matchOp("-")?Ie(e,"negativeNumber",t,it(e),n=>-v(n)):Vt(e)}function Vt(e){let t=Zt(e);return t?O(e,t):e.err("Unexpected value: "+e.cur().value)}function ne(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function Yt(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(u,l=!0,c=!1)=>({operator:u,right:l,isType:c}),r=()=>e.match("equal")&&e.match("to"),o=(u,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(u));if(e.match("is")||e.match("am")){let u=!!e.match("not"),l=u?"not ":"";return e.match("in")?n(l+"in"):e.match("a")||e.match("an")?n(l+"a",!1,!0):e.match("empty")?n(l+"empty",!1):e.match("between")?n(l+"between"):!u&&e.match("less")?o("<","<="):!u&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(u?"!==":"===")):e.match("equal")?(e.match("to"),n(u?"!=":"==")):n(u?"is not":"is")}if(e.match("equals"))return n("==");if(e.match("really"))return e.req("equals"),n("===");if(e.matchAny("exist","exists"))return n("exist",!1);let i=!!e.matchAny("do","does");i&&e.req("not");let s=i?"not ":"",a=(u,l)=>e.match(u)??(i&&u!=="match"&&u!=="contain"?void 0:e.match(l));if(a("match","matches"))return n(s+"match");if(a("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(a("include","includes"))return n(s+"include");if(e.match(i?"start":"starts"))return e.req("with"),n(s+"start with");if(e.match(i?"end":"ends"))return e.req("with"),n(s+"end with");if(a("precede","precedes"))return n(s+"precede");if(a("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function nt(e){let t=Se(e),n=Yt(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,a;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=Se(e),r.endsWith("match")&&(a=s.css));let u;r.endsWith("between")&&(e.req("and"),u=Se(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let c=d=>l&&typeof d=="string"?d.toLowerCase():d,p=s?.type==="symbol"&&"scope"in s&&s.scope==="local"&&s.name!=="undefined"&&s.name!=="null"?s.name:void 0;return{type:"comparisonOperator",operator:r,left:t,right:s,right2:u,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:d=>S([t.ev(d),a??s?.ev(d),u?.ev(d)],([y,I,j])=>{if(o){let F=ze(y,o,i);return r==="a"?F:!F}if(p&&I===void 0&&(r==="is"||r==="is not")){let F=!!J(y,p);return r==="is"?F:!F}return ut(r,c(y),c(I),j)})}}function rt(e,t){let n=g(e,"contains")??g(e,"includes");if(!L(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function Jt(e,t){let n=g(e,"match")??g(e,"matches");if(!L(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var ot=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function ut(e,t,n,r){if(e==="not between")return v(t)<v(n)||v(t)>v(r);if(e.startsWith("not "))return!ut(e.slice(4),t,n,r);switch(e){case"is":case"==":return t==n;case"is not":case"!=":return t!=n;case"===":return t===n;case"!==":return t!==n;case"<":return v(t)<v(n);case">":return v(t)>v(n);case"<=":return v(t)<=v(n);case">=":return v(t)>=v(n);case"match":return t!=null&&Jt(t,n);case"in":return n!=null&&rt(n,t);case"contain":case"include":return t!=null&&rt(t,n);case"start with":return t!=null&&String(t).startsWith(String(n));case"end with":return t!=null&&String(t).endsWith(String(n));case"between":return v(t)>=v(n)&&v(t)<=v(r);case"precede":return ot(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return ot(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return ke(t);case"exist":return Ge(t)}throw new Error("Unknown comparison : "+e)}function Zt(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Re("number",parseFloat(t.value),t);case"STRING":return en(e);case"ID_REF":return on(e);case"CLASS_REF":return sn(e);case"ATTRIBUTE_REF":return Ae(e);case"STYLE_REF":return ft(e)}if(t.op){if(t.value==="(")return Xt(e);if(t.value==="[")return tn(e);if(t.value==="{")return nn(e);if(t.value==="<")return un(e)}let n=e.match("true")??e.match("false");if(n)return Re("boolean",n.value==="true",n);let r=e.match("null");if(r)return Re("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return rn(e)}function Re(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function Xt(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>b(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var Kt=(e,t)=>S(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function at(e,t){let n=e.child(te(t,!0),t),r=[],o="";do{o+=n.lastWs();let i=n.cur();if(i.value==="$"){n.consume();let s=n.matchOp("{");r.push(o,b(n)),o="",s&&n.reqOp("}")}else i.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function en(e){let t=e.consume(),n=t.value,r={type:"string",value:n,start:t.start,end:t.end,ev:()=>n};if(t.template){let o=r.parts=at(e,n);r.ev=i=>Kt(o,i)}else r.stat=()=>n;return r}function tn(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(b(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>S(n.map(o=>o.ev(r)),o=>o)}}function nn(e){let t=e.pos();e.consume();let n=[],r=[],o=()=>e.cur().op&&e.cur().value==="}";if(!e.matchOp("}")){do{let i=e.matchType("STRING");if(i)n.push(i.value);else if(e.matchOp("["))n.push(b(e)),e.reqOp("]");else{let s="";for(let a=e.matchType("IDENTIFIER")??e.matchOp("-");a;a=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=a.value;n.push(s)}e.reqOp(":"),r.push(b(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>S([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((a,u)=>[String(s[u]),s[n.length+u]])))}}function ct(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function rn(e){let t=e.pos(),n;e.match("global")?n="global":e.match("element")?(n="element",e.matchOp("'")&&e.req("s")):e.match("dom")?n="inherited":e.match("local")&&(n="local");let r=e.matchOp(":"),o=!r&&e.matchOp("^"),i=e.matchType("IDENTIFIER");if(!i?.value)return;let s=(r?":":o?"^":"")+i.value,u=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return u==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>b(e))),{type:"symbol",name:s,scope:u,...l?{on:l}:{},start:t,end:e.endPos(),ev:c=>Je(s,c,u,l?.ev(c)),lhs:()=>{},put:(c,p,m)=>Ze(s,c,u,m,l?.ev(c))}}var lt=(e,t)=>{let n=t.value.substring(2);return b(e.child(te(n),n))};function on(e){let t=e.consume(),n=(o,i)=>Ee(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>E(r.ev(o),a=>a&&K(a,s))};if(t.template){let o=r.expr=lt(e,t);r.ev=i=>E(o.ev(i),s=>n(i,s))}else{let o=r.value=t.value.substring(1);r.css=t.value,r.ev=i=>n(i,o)}return r}function sn(e){let t=e.matchType("CLASS_REF");if(!t)return;let n={type:"classRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(r,o,i)=>E(n.ev(r),s=>K(Array.from(s instanceof A?s:[]),i))};if(t.template){let r=n.expr=lt(e,t);n.ev=o=>E(r.ev(o),i=>new A("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new A(r,o.me,!0)}return n}var Ce=class extends A{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>k(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(k);n.forEach((o,i)=>o.setAttribute("data-hs-query-id",String(i)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function un(e){let t=e.pos();e.consume();let n=e.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");e.reqOp("/"),e.reqOp(">");let r={type:"queryRef",css:n,start:t,end:e.endPos(),ev:o=>new A(n,o.me),lhs:()=>{},put:(o,i,s)=>E(r.ev(o),a=>K(Array.from(a instanceof A?a:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=at(e,n);r.ev=i=>S(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new Ce(i.me,s))}return r}function Ae(e){let t=e.matchType("ATTRIBUTE_REF");if(!t)return;let n=t.value.startsWith("[")?t.value.slice(2,-1):t.value.slice(1),[r,o]=n.split("="),i=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:i,css:`[${n}]`,start:t.start,end:t.end,ev:s=>Z(s.you||s.me,r),lhs:()=>{},put:(s,a,u)=>X(s.you||s.me,r,u)}}function ft(e){let t=e.matchType("STYLE_REF");if(!t)return;let n=t.value.startsWith("*computed-"),r=t.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:t.start,end:t.end,ev:o=>(n?ce:ae)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>le(o.you||o.me,r,s)}}function dt(e){let t=e.matchType("IDENTIFIER");if(!t)return;let n=[t.value],r=e.matchOp(".")??e.matchOp(":");if(r)do n.push(e.reqType("IDENTIFIER","NUMBER").value);while(e.matchOp(r.value));return n.join(r?.value??"")}function mt(e,t="Expected event name"){return e.matchType("STRING")?.value??dt(e)??e.err(t)}function O(e,t){return cn(e,t)??ln(e,t)??hn(e,t)??fn(e,t)??dn(e,t)??mn(e,t)??pn(e,t)??yn(e,t)??an(e,t)??t}function an(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function cn(e,t){if(!e.matchOp("."))return;let n=e.reqType("IDENTIFIER").value,r=e.text(t),o={type:"propertyAccess",root:t,prop:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>J(s,n)),lhs:i=>o.root.ev(i),put:(i,s,a)=>{R(s,r),fe(s,n,a)},del:(i,s)=>{R(s,r),P(s,a=>{C(a)&&delete a[n],w.wroteProperty(a)})}};return O(e,o)}function ln(e,t){if(!e.match("of"))return;let n=M(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],a=o.name;if(!s||a===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let u=e.text(n),l={property:J,attribute:Z,style:ae,computed:ce}[s],c={type:"ofExpression",root:n,name:a,kind:s,start:t.start,end:e.endPos(),ev:p=>E(c.root.ev(p),m=>l(m,a)),lhs:p=>c.root.ev(p),put:(p,m,d)=>{R(m,u),s==="attribute"?X(m,a,d):s==="property"?fe(m,a,d):le(m,a,d)},del:(p,m)=>{R(m,u),P(m,d=>{s==="attribute"?k(d)&&d.removeAttribute(a):s==="property"?(C(d)&&delete d[a],w.wroteProperty(d)):d instanceof HTMLElement&&d.style.removeProperty(a)})}};return r?(r.root=c,O(e,t)):O(e,c)}function fn(e,t){let n=e.matchOp("'"),r=t.type==="symbol"&&["my","its","your"].includes(t.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(e.cur().type);if(!n&&!r)return;n&&e.req("s");let o=Ae(e)??ft(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),a=l=>i!==void 0?J(l,i):o?.type==="attributeRef"?Z(l,o.name):o?.type==="computedStyleRef"?ce(l,o.name):o&&ae(l,o.name),u={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>E(u.root.ev(l),a),lhs:l=>u.root.ev(l),put:(l,c,p)=>{R(c,s),i!==void 0?fe(c,i,p):o?.type==="attributeRef"?X(c,o.name,p):o&&le(c,o.name,p)}};return O(e,u)}function dn(e,t){if(!e.match("in"))return;let n=M(e),r=(s,a)=>{if(s==null)return[];let u=[],l=g(s,"css");if(typeof l=="string")P(a,c=>k(c)&&u.push(...xe(c,l)));else if(k(s)){let c=!1;if(P(a,p=>{p instanceof Node&&p.contains(s)&&(c=!0)}),c)return s}else P(s,c=>P(a,p=>c===p&&u.push(c)));return u},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>S([o.root.ev(s),n.ev(s)],([a,u])=>r(a,u)),lhs:s=>o.ev(s),put:(s,a,u)=>K(a,u)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return O(e,i??o)}function mn(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=dt(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:a=>E(s.root.ev(a),u=>Be(u,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return O(e,r)}function pn(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(b(e));while(e.matchOp(","));e.reqOp(")")}let r=e.text(t),o=t.root?e.text(t.root):"",i={type:"functionCall",root:t,args:n,start:t.start,end:e.endPos(),ev:s=>{let a=i.root,u=a.prop,l=u===void 0?void 0:a.root;return S([(l??a).ev(s),...n.map(c=>c.ev(s))],([c,...p])=>{if(!l||u===void 0)return st(c,void 0,p,s,r);R(c,o);let m=st(g(c,u),c,p,s,r);return We(c,u),m})}};return O(e,i)}function st(e,t,n,r,o){if(!L(e))throw R(e,o),new Error(`'${o}' is not a function`);return g(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function hn(e,t){let n=Ae(e);return n&&gn(e,t,n)}function gn(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>Z(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,a)=>{R(s,r),X(s,n.name,a)}};return o}function yn(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=b(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=b(e))),e.reqOp("]");let s=e.text(t),a=(c,p)=>v(p)<0?v(g(c,"length"))+v(p):v(p),u=(c,p,m)=>{let d=g(c,"slice");return L(d)?Reflect.apply(d,c,[p,m]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:c=>S([l.root.ev(c),r.ev(c),i?.ev(c)],([p,m,d])=>p==null?null:n?u(p,0,a(p,m)+1):o?d==null?u(p,v(m)):u(p,v(m),a(p,d)+1):g(p,String(m))),lhs:c=>S([l.root.ev(c),r.ev(c)],p=>p),put:(c,p,m)=>{let[d,y]=Array.isArray(p)?p:[];R(d,s),C(d)&&(d[String(y)]=m)},del:(c,p)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[m,d]=Array.isArray(p)?p:[];R(m,s),Array.isArray(m)?m.splice(a(m,d),1):C(m)&&delete m[String(d)],w.wroteProperty(m)}};return O(e,l)}var pt=new WeakSet;function ht(e){if(pt.has(e))return;pt.add(e);let t=!1,n=o=>{let i=t;t=!0;try{o()}finally{t=i}};document.addEventListener("htmx:load",o=>n(()=>e.process(o.detail?.elt))),document.addEventListener("htmx:after:process",o=>n(()=>e.process(o.target))),document.addEventListener("fx:swapped",o=>{let i=o.detail?.cfg?.target;e.process(i instanceof Element&&i.isConnected?i.parentElement??i:document.body)});let r=Reflect.get(globalThis,"htmx");typeof r?.process=="function"&&(e.addAfterProcessHook(o=>{t||n(()=>r.process(o))}),r.version?.startsWith("4")&&r.registerExtension?.("hs-include",{htmx_config_request(o,i){let s=i?.ctx;if(!s)return;let a=vn(s.sourceElement||o);if(!a)return;let u=En(a.value,a.scopeElt),l=s.request?.body;if(l instanceof FormData)for(let c in u)l.set(c,u[c])}}))}function vn(e){let t=e.getAttribute("hs-include");if(t!==null)return{value:t,scopeElt:e};for(let n=e.parentElement;n;n=n.parentElement){let r=n.getAttribute("hs-include:inherited");if(r!==null)return{value:r,scopeElt:n}}return null}var me=e=>e&&D(e)?.scopes?.elementScope||{};function de(e){if(e==null)return"";if(typeof e=="object")try{return JSON.stringify(e)}catch{return""}return String(e)}function wn(e,t){for(let n=t;n;n=n.parentElement){let r=me(n);if(e in r)return r[e]}}function En(e,t){let n={},r=e.trim();if(r==="*"){let o=me(t);for(let i of Object.keys(o))n[i[0]===":"?i.slice(1):i]=de(o[i]);return n}for(let o of r.split(","))if(o=o.trim(),!!o){if(o[0]===":"){let i=me(t);o in i&&(n[o.slice(1)]=de(i[o]))}else if(o[0]==="^"){let i=wn(":"+o.slice(1),t);i!==void 0&&(n[o.slice(1)]=de(i))}else if(o[0]==="#"){let i=o.lastIndexOf(":");if(i>0){let s=me(document.querySelector(o.slice(0,i))),a=o.slice(i+1);":"+a in s&&(n[a]=de(s[":"+a]))}}}return n}var H=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},gt=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),pe=class e{constructor(t,n,r){this.g=t;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(t,n){return new e(this.g,t,n)}tok(t=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(t--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(t){return this.src.substring(t.start,t.end)}match(t,n="IDENTIFIER"){if(this.follows.includes(t))return;let r=this.cur();if(r.value===t&&r.type===n)return this.consume()}matchOp(t){let n=this.cur();if(n.op&&n.value===t)return this.consume()}matchType(...t){if(t.includes(this.cur().type))return this.consume()}matchAny(...t){for(let n of t){let r=this.match(n);if(r)return r}}matchAnyOp(...t){for(let n of t){let r=this.matchOp(n);if(r)return r}}req(t){return this.match(t)??this.expected(t)}reqOp(t){return this.matchOp(t)??this.expected(t)}reqType(...t){return this.matchType(...t)??this.expected(...t)}peek(t,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===t&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(t,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(t==null||o.value!==t)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let t=this.tokens[this.i-1];return t?.type==="WHITESPACE"?t.value:""}pushFollow(...t){return this.follows.push(...t),t.length}popFollow(t=1){this.follows.length-=t}withFollow(t,n){let r=this.pushFollow(...t);try{return n()}finally{this.popFollow(r)}}withoutFollows(t){let n=this.follows;this.follows=[];try{return t()}finally{this.follows=n}}err(t,n){let r=this.cur();throw new H(t??"Unexpected Token : "+r.value,r,this.src,n)}expected(...t){this.err(t.length===1?`Expected '${t[0]}' but found '${this.cur().value}'`:"Expected one of: "+t.map(n=>`'${n}'`).join(", "),t)}commandStart(t){return t.value in this.g.commands}featureStart(t){return t.value in this.g.features}commandBoundary(t){return["end","then","else","otherwise",")"].includes(t.value)||this.commandStart(t)||this.featureStart(t)||t.type==="EOF"}};function Fe(e){let t=e.source.split(`
|
|
1
|
+
"use strict";(()=>{var G=e=>typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function",E=(e,t)=>G(e)?e.then(t):t(e),S=(e,t)=>e.some(G)?Promise.all(e).then(t):t(e),C=e=>e!=null,D=e=>typeof e=="function",g=(e,t)=>C(e)?e[t]:void 0,z=(e,t,n)=>{C(e)&&(e[t]=n)},k=e=>e instanceof Element,B=e=>D(g(e,"addEventListener"));var w=e=>e;var ie={attributes:"_, script, data-script",defaultTransition:"all 500ms ease-in",disableSelector:"[disable-scripting], [data-disable-scripting]",hideShowStrategies:{},fetchThrowsOn:[/^4/,/^5/]},ye=Object.assign(Object.create(null),{String:e=>String(e),Int:e=>parseInt(String(e)),Float:e=>parseFloat(String(e)),Number:e=>Number(e),Fragment:e=>Je(e)}),we=[],Y={process(e){},enter(e){}},Ge=new WeakMap;function ve(e){if(e.window!==e)return e;let t=Ge.get(e);return t||Ge.set(e,t={}),t}var M=e=>ve(e)._hyperscript;function Ee(e){let t=ve(e),n=t._hyperscript!==void 0;return delete t._hyperscript,n}function U(e){return ve(e)._hyperscript??={}}var v={tracking:!1,readGlobal(e){},readElement(e,t){},readProperty(e,t){},readAttribute(e,t){},readQuery(e){},wroteGlobal(e){},wroteElement(e,t){},wroteProperty(e){},stop(e){}},se=e=>(v.tracking&&typeof e=="object"&&e!==null&&v.readProperty(e,"__mutation__"),e),Ut={Array:["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"],Set:["add","delete","clear"],Map:["set","delete","clear"]};function Be(e,t){let n=g(g(e,"constructor"),"name");typeof n=="string"&&Ut[n]?.includes(t)&&v.wroteProperty(e)}var be=e=>{if(e instanceof Node){let t=e.getRootNode();if(t instanceof Document||t instanceof ShadowRoot)return t}return document},Wt=e=>e.replace(/[:&()[\]/]/g,t=>"\\"+t);function xe(e,t){return v.tracking&&v.readQuery(e),e.querySelectorAll(t)}var A=class{constructor(t,n,r=!1){this.raw=t;this.relativeTo=n;this.escape=r}get css(){return this.escape?Wt(this.raw):this.raw}get className(){return this.raw.slice(1)}get length(){return this.select().length}contains(t){for(let n of this)if(n.contains(t))return!0;return!1}select(){return xe(be(this.relativeTo),this.css)}[Symbol.iterator](){return this.select()[Symbol.iterator]()}},ke=e=>e instanceof A||Array.isArray(e)||e instanceof NodeList||e instanceof HTMLCollection||e instanceof FileList;function P(e,t){if(ke(e))for(let n of e)t(n);else t(e)}var ae=(e,t)=>{if(e==null)return;let n=t(e);if(n!==void 0)return n;if(ke(e))return Array.from(e,t)},J=(e,t)=>(v.tracking&&v.readProperty(e,t),ae(e,n=>g(n,t))),Z=(e,t)=>(v.tracking&&v.readAttribute(e,t),ae(e,n=>k(n)?n.getAttribute(t):void 0)),ue=(e,t)=>ae(e,n=>g(g(n,"style"),t)),ce=(e,t)=>ae(e,n=>k(n)?getComputedStyle(n).getPropertyValue(t):void 0),X=(e,t,n)=>P(e,r=>{k(r)&&(n==null?r.removeAttribute(t):r.setAttribute(t,String(n)))}),le=(e,t,n)=>P(e,r=>z(g(r,"style"),t,n)),fe=(e,t,n)=>P(e,r=>{z(r,t,n),v.wroteProperty(r)});function R(e,t){if(e==null)throw new Error(`'${t}' is null`)}var Te=e=>e==null||g(e,"length")===0;function Qe(e){if(e==null)return!1;if(ke(e)){for(let t of e)return!0;return!1}return!0}function Ve(e,t,n){if(e==null&&n||Object.prototype.toString.call(e).slice(8,-1)===t)return!0;let r=g(globalThis,t);return D(r)&&e instanceof r}function Ye(e,t){for(let r of we){let o=r(t,e);if(o!==void 0)return o}if(e==null)return null;let n=ye[t];if(n)return n(e);throw new Error("Unknown conversion : "+t)}function Je(e){let t=document.createDocumentFragment();return e==null?t.append("null"):P(e,n=>{if(n instanceof Node)t.append(n);else{let r=document.createElement("template");r.innerHTML=n===null?"":String(n),t.append(r.content)}}),t}function K(e,t){P(e,n=>{if(!k(n))return;let r=n.parentElement;n.replaceWith(t instanceof Node?t.cloneNode(!0):Je(t)),r&&Y.process(r)})}function N(e,t,n={},r){if(!B(e))return!0;n.sender=r;let o=Object.assign(new Event(t,{bubbles:!0,cancelable:!0,composed:!0}),{detail:n});return e.dispatchEvent(o)}var Ze=(e,t="elementScope")=>(U(e).scopes??={})[t]??={},Gt=Object.create(null,{selection:{get:()=>getSelection()?.toString(),enumerable:!0},clipboard:{get:()=>navigator.clipboard.readText(),set:e=>void navigator.clipboard.writeText(String(e))}});function ee(e,t,n,r){let o=g(r,"detail"),i=Object.create(Gt);for(let s=k(e)?e:null;s;s=s.parentElement)Object.assign(i,M(s)?.features);return{meta:{owner:e,feature:t},locals:i,me:n,you:void 0,result:void 0,beingTested:null,event:r,target:g(r,"target")??null,detail:o??null,sender:g(o,"sender")??null,body:typeof document>"u"?null:document.body}}var ge=["meta","it","result","locals","event","target","detail","sender","body"],Q=e=>{let t=e.meta.owner,n=e.meta.feature?.behavior;return C(t)?Ze(t,n?n+"Scope":void 0):{}};function Xe(e,t,n){let r=k(n)?n:k(t.meta.owner)?t.meta.owner:null;for(;r;){let o=M(r)?.scopes?.elementScope;if(o&&e in o)return{value:o[e],element:r};let i=r.getAttribute("dom-scope");if(i==="isolated")break;let s=i?.match(/^closest\s+(.+)/),u=i?.match(/^parent\s+of\s+(.+)/);s?r=r.parentElement?.closest(s[1])??null:u?r=r.closest(u[1])?.parentElement??null:r=r.parentElement}return{value:void 0,element:null}}function Ke(e,t,n,r){if(e==="me"||e==="my"||e==="I")return t.me;if(e==="it"||e==="its")return t.beingTested??t.result;if(e==="result")return t.result;if(e==="you"||e==="your"||e==="yourself")return t.you;let o=t.meta.owner,i=()=>(v.tracking&&v.readGlobal(e),se(g(globalThis,e)));if(n==="global")return i();if(n==="element")return v.tracking&&v.readElement(e,o),se(Q(t)[e]);if(n==="inherited"){let l=Xe(e,t,r);return v.tracking&&v.readElement(e,l.element??(k(r)?r:o)),se(l.value)}let s=t.meta.context;if(s!=null){let l=g(s,e);if(l!==void 0)return l;let c=g(g(s,"detail"),e);if(c!==void 0)return c}let u=ge.includes(e)?g(t,e):t.locals[e];if(u!==void 0)return u;let a=Q(t)[e];return a!==void 0?(v.tracking&&v.readElement(e,o),se(a)):i()}function et(e,t,n,r,o){if(n==="global")z(globalThis,e,r),v.wroteGlobal(e);else if(n==="element")Q(t)[e]=r,v.wroteElement(e,t.meta.owner);else if(n==="inherited"){let s=Xe(e,t,o).element??(k(o)?o:t.meta.owner);C(s)&&(Ze(s)[e]=r),v.wroteElement(e,s)}else!ge.includes(e)&&t.locals[e]!==void 0?t.locals[e]=r:Q(t)[e]!==void 0?(Q(t)[e]=r,v.wroteElement(e,t.meta.owner)):ge.includes(e)?z(t,e,r):t.locals[e]=r}function $(e,t,n=0){for(let r=n;r<e.length;r++){let o=e[r].run(t);if(G(o))return o.then(i=>i||$(e,t,r+1));if(o)return o}}function V(e,t){try{let n=e();return G(n)?n.then(void 0,t):n}catch(n){return t(n)}}function tt(e,t,n){let{errorSymbol:r,errorHandler:o,finallyHandler:i}=n,s=()=>V(()=>E($(t,e),a=>{let l=g(a,"k");if(l==="break"||l==="continue")throw new Error(`Command \`${l}\` cannot be used outside of a \`repeat\` loop.`);return ze(a)}),a=>{if(!o||!r)throw a;return e.locals[r]=a,$(o,e)});if(!i)return s();let u=()=>V(()=>E($(i,e),()=>{}),a=>console.error(" Exception in finally block: ",a));return V(()=>E(s(),a=>E(u(),()=>ze(a))),a=>E(u(),()=>{throw a}))}var ze=e=>{let t=g(e,"k");if(t==="return")return{k:"return",value:g(e,"value")};if(t==="break"||t==="continue")return{k:t}};var nt=new Set("+ - * / . .. \\ : % | ! ? # & $ ; , ( ) < > <= >= == === != !== { } [ ] = ~ ^".split(" ")),rt={b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" ",v:"\v"},_=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",L=e=>e>="0"&&e<="9",Pe=e=>e===" "||e===" "||e==="\r"||e===`
|
|
3
|
+
`,Ne=e=>_(e)||L(e)||e==="-"||e==="_"||e===":",Se=e=>_(e)||L(e)||e==="_"||e==="$";function te(e,t=!1){let n=[],r=0,o=0,i=1,s="<START>",u=0,a=()=>e.charAt(r),l=f=>e.charAt(r+f),c=()=>(s=e.charAt(r++),s===`
|
|
4
|
+
`?(i++,o=0):o++,s),p=f=>({type:f,value:"",start:r,end:r+1,line:i,column:o}),m=(f,h)=>(f.value=h,f.end=r,f),d=f=>{let h="";for(;a()&&f(a());)h+=c();return h},y=()=>t&&u===0,I=()=>_(s)||L(s)||")\"'`}]".includes(s),j=(f,h)=>{let b=p(f),T=c();if(a()==="{"){if(b.template=!0,T+=c(),T+=d($t=>$t!=="}"),a()!=="}")throw new Error("Unterminated "+(h?"class":"id")+" reference");let oe=c();h&&(T+=oe)}else if(h)for(;Ne(a())||a()==="\\";)a()==="\\"&&c(),T+=c();else T+=d(Ne);return m(b,T)},q=()=>{let f=p("STRING"),h=c();f.template=h==="`";let b="";for(;a()&&a()!==h;)if(a()==="\\"){c();let T=c();if(T in rt)b+=rt[T];else if(f.template&&T==="$")b+="\\$";else if(T==="x"){let oe=a()&&l(1)?parseInt(c()+c(),16):NaN;if(Number.isNaN(oe))throw new Error(`Invalid hexadecimal escape at [Line: ${f.line}, Column: ${f.column}]`);b+=String.fromCharCode(oe)}else b+=T}else b+=c();if(a()!==h)throw new Error(`Unterminated string at [Line: ${f.line}, Column: ${f.column}]`);return c(),m(f,b)},Ue=()=>{let f=p("IDENTIFIER"),h=c()+d(Se);return a()==="!"&&h==="beep"&&(h+=c()),m(f,h)},Lt=()=>{let f=p("IDENTIFIER"),h=c(),b=h==="\\";for(b&&(h="");(Se(a())||"\\{}".includes(a()||" "))&&!(a()==="$"&&!b);)a()==="\\"?(b=!0,c()):(b=!1,h+=c());return m(f,h)},Dt=()=>{let f=p("NUMBER"),h=c()+d(L);return a()==="."&&L(l(1))&&(h+=c()),h+=d(L),(a()==="e"||a()==="E")&&(L(l(1))?h+=c():l(1)==="-"&&(h+=c()+c())),m(f,h+d(L))},We=()=>{let f=p("OP");f.op=!0;let h=c();for(;a()&&nt.has(h+a());)h+=c();return m(f,h)},Mt=()=>{let f=p("ATTRIBUTE_REF"),h=c();return h==="["?(h+=d(b=>b!=="]"),a()==="]"&&(h+=c())):(h+=d(Ne),a()==="="&&(h+=c(),a()==='"'||a()==="'"?h+=q().value:Se(a())&&(h+=Ue().value))),m(f,h)},Ht=()=>{let f=n.at(-1);return f?f.type==="IDENTIFIER"||f.type==="CLASS_REF"||f.type==="ID_REF"?!1:!(f.op&&(f.value===">"||f.value===")")):!0},jt=()=>{let f=a(),h=l(2);return(f==="-"||f==="/")&&l(1)===f&&(Pe(h)||h===""||h===f)};for(;r<e.length;){let f=a(),h=l(1);if(jt())d(b=>b!=="\r"&&b!==`
|
|
5
|
+
`),c();else if(Pe(f))n.push(m(p("WHITESPACE"),d(Pe)));else if(!I()&&f==="."&&(_(h)||h==="{"||h==="-"))n.push(j("CLASS_REF",!0));else if(!I()&&f==="#"&&(_(h)||h==="{"))n.push(j("ID_REF",!1));else if(f==="@"||f==="["&&h==="@")n.push(Mt());else if(f==="*"&&_(h)){let b=p("STYLE_REF");n.push(m(b,c()+d(T=>_(T)||T==="-")))}else if(y()&&(_(f)||f==="\\"))n.push(Lt());else if(!y()&&(_(f)||f==="_"||f==="$"))n.push(Ue());else if(L(f))n.push(Dt());else if(!y()&&(f==='"'||f==="`"))n.push(q());else if(!y()&&f==="'")n.push(Ht()?q():We());else if(nt.has(f))s==="$"&&f==="{"&&u++,f==="}"&&u--,n.push(We());else if(y()||f==="`"){let b=p("RESERVED");n.push(m(b,c()))}else throw new Error("Unknown token: "+f+" ")}return n}function x(e){return e.match("the"),zt(e)}function zt(e){let t=st(e),n,r=()=>e.match("and")??e.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&e.err("You must parenthesize logical operations with different operators"),t=Bt(o.value,t,st(e));return t}function Bt(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>E(t.ev(o),i=>!!i===r?i:n.ev(o))}}var Qt={"+":(e,t)=>Array.isArray(e)?e.concat(t):w(e)+w(t),"-":(e,t)=>w(e)-w(t),"*":(e,t)=>w(e)*w(t),"/":(e,t)=>w(e)/w(t),mod:(e,t)=>w(e)%w(t)};function Re(e){let t=Ie(e),n,r=()=>e.matchAnyOp("+","-","*","/")??e.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&e.err("You must parenthesize math operations with different operators");let i=t,s=Ie(e),u=Qt[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>S([i.ev(l),s.ev(l)],([c,p])=>u(c,p))}}return t}function Ie(e){let t=H(e);for(let n=!0;n;){n=!1;for(let r of e.g.collections){let o=r(e,t);if(o){t=o,n=!0;break}}}return t}function H(e){e.match("the");let t=e.pos();if(e.match("not"))return Ce(e,"logicalNot",t,H(e),n=>!n);if(e.match("no"))return Ce(e,"noExpression",t,Ie(e),Te);for(let n of e.g.unaries){let r=n(e);if(r)return O(e,r)}return Yt(e)}function Ce(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:u=>E(r.ev(u),a=>o(a,u))};return i?O(e,s):s}var Vt="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function Yt(e){let t=ct(e),n=e.matchAny(...Vt)??e.matchOp("%");if(n)return ot(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return ot(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function ot(e,t,n,r){let o=s=>typeof r=="number"?w(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>E(n.ev(s),o)};return n.stat&&(i.stat=()=>o(ne(n))),i}function ct(e){let t=e.pos();return e.matchOp("-")?Ce(e,"negativeNumber",t,ct(e),n=>-w(n)):Jt(e)}function Jt(e){let t=Kt(e);return t?O(e,t):e.err("Unexpected value: "+e.cur().value)}function ne(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function Zt(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(a,l=!0,c=!1)=>({operator:a,right:l,isType:c}),r=()=>e.match("equal")&&e.match("to"),o=(a,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(a));if(e.match("is")||e.match("am")){let a=!!e.match("not"),l=a?"not ":"";return e.match("in")?n(l+"in"):e.match("a")||e.match("an")?n(l+"a",!1,!0):e.match("empty")?n(l+"empty",!1):e.match("between")?n(l+"between"):!a&&e.match("less")?o("<","<="):!a&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(a?"!==":"===")):e.match("equal")?(e.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(e.match("equals"))return n("==");if(e.match("really"))return e.req("equals"),n("===");if(e.matchAny("exist","exists"))return n("exist",!1);let i=!!e.matchAny("do","does");i&&e.req("not");let s=i?"not ":"",u=(a,l)=>e.match(a)??(i&&a!=="match"&&a!=="contain"?void 0:e.match(l));if(u("match","matches"))return n(s+"match");if(u("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(u("include","includes"))return n(s+"include");if(e.match(i?"start":"starts"))return e.req("with"),n(s+"start with");if(e.match(i?"end":"ends"))return e.req("with"),n(s+"end with");if(u("precede","precedes"))return n(s+"precede");if(u("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function st(e){let t=Re(e),n=Zt(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,u;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=Re(e),r.endsWith("match")&&(u=s.css));let a;r.endsWith("between")&&(e.req("and"),a=Re(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let c=d=>l&&typeof d=="string"?d.toLowerCase():d,p=s?.type==="symbol"&&"scope"in s&&s.scope==="local"&&s.name!=="undefined"&&s.name!=="null"?s.name:void 0;return{type:"comparisonOperator",operator:r,left:t,right:s,right2:a,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:d=>S([t.ev(d),u??s?.ev(d),a?.ev(d)],([y,I,j])=>{if(o){let q=Ve(y,o,i);return r==="a"?q:!q}if(p&&I===void 0&&(r==="is"||r==="is not")){let q=!!J(y,p);return r==="is"?q:!q}return lt(r,c(y),c(I),j)})}}function it(e,t){let n=g(e,"contains")??g(e,"includes");if(!D(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function Xt(e,t){let n=g(e,"match")??g(e,"matches");if(!D(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var at=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function lt(e,t,n,r){if(e==="not between")return w(t)<w(n)||w(t)>w(r);if(e.startsWith("not "))return!lt(e.slice(4),t,n,r);switch(e){case"is":case"==":return t==n;case"is not":case"!=":return t!=n;case"===":return t===n;case"!==":return t!==n;case"<":return w(t)<w(n);case">":return w(t)>w(n);case"<=":return w(t)<=w(n);case">=":return w(t)>=w(n);case"match":return t!=null&&Xt(t,n);case"in":return n!=null&&it(n,t);case"contain":case"include":return t!=null&&it(t,n);case"start with":return t!=null&&String(t).startsWith(String(n));case"end with":return t!=null&&String(t).endsWith(String(n));case"between":return w(t)>=w(n)&&w(t)<=w(r);case"precede":return at(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return at(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return Te(t);case"exist":return Qe(t)}throw new Error("Unknown comparison : "+e)}function Kt(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Oe("number",parseFloat(t.value),t);case"STRING":return nn(e);case"ID_REF":return an(e);case"CLASS_REF":return un(e);case"ATTRIBUTE_REF":return Fe(e);case"STYLE_REF":return pt(e)}if(t.op){if(t.value==="(")return en(e);if(t.value==="[")return rn(e);if(t.value==="{")return on(e);if(t.value==="<")return cn(e)}let n=e.match("true")??e.match("false");if(n)return Oe("boolean",n.value==="true",n);let r=e.match("null");if(r)return Oe("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return sn(e)}function Oe(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function en(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>x(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var tn=(e,t)=>S(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function ft(e,t){let n=e.child(te(t,!0),t),r=[],o="";do{o+=n.lastWs();let i=n.cur();if(i.value==="$"){n.consume();let s=n.matchOp("{");r.push(o,x(n)),o="",s&&n.reqOp("}")}else i.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function nn(e){let t=e.consume(),n=t.value,r={type:"string",value:n,start:t.start,end:t.end,ev:()=>n};if(t.template){let o=r.parts=ft(e,n);r.ev=i=>tn(o,i)}else r.stat=()=>n;return r}function rn(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(x(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>S(n.map(o=>o.ev(r)),o=>o)}}function on(e){let t=e.pos();e.consume();let n=[],r=[],o=()=>e.cur().op&&e.cur().value==="}";if(!e.matchOp("}")){do{let i=e.matchType("STRING");if(i)n.push(i.value);else if(e.matchOp("["))n.push(x(e)),e.reqOp("]");else{let s="";for(let u=e.matchType("IDENTIFIER")??e.matchOp("-");u;u=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=u.value;n.push(s)}e.reqOp(":"),r.push(x(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>S([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((u,a)=>[String(s[a]),s[n.length+a]])))}}function dt(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function sn(e){let t=e.pos(),n;e.match("global")?n="global":e.match("element")?(n="element",e.matchOp("'")&&e.req("s")):e.match("dom")?n="inherited":e.match("local")&&(n="local");let r=e.matchOp(":"),o=!r&&e.matchOp("^"),i=e.matchType("IDENTIFIER");if(!i?.value)return;let s=(r?":":o?"^":"")+i.value,a=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return a==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>x(e))),{type:"symbol",name:s,scope:a,...l?{on:l}:{},start:t,end:e.endPos(),ev:c=>Ke(s,c,a,l?.ev(c)),lhs:()=>{},put:(c,p,m)=>et(s,c,a,m,l?.ev(c))}}var mt=(e,t)=>{let n=t.value.substring(2);return x(e.child(te(n),n))};function an(e){let t=e.consume(),n=(o,i)=>be(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>E(r.ev(o),u=>u&&K(u,s))};if(t.template){let o=r.expr=mt(e,t);r.ev=i=>E(o.ev(i),s=>n(i,s))}else{let o=r.value=t.value.substring(1);r.css=t.value,r.ev=i=>n(i,o)}return r}function un(e){let t=e.matchType("CLASS_REF");if(!t)return;let n={type:"classRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(r,o,i)=>E(n.ev(r),s=>K(Array.from(s instanceof A?s:[]),i))};if(t.template){let r=n.expr=mt(e,t);n.ev=o=>E(r.ev(o),i=>new A("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new A(r,o.me,!0)}return n}var Ae=class extends A{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>k(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(k);n.forEach((o,i)=>o.setAttribute("data-hs-query-id",String(i)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function cn(e){let t=e.pos();e.consume();let n=e.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");e.reqOp("/"),e.reqOp(">");let r={type:"queryRef",css:n,start:t,end:e.endPos(),ev:o=>new A(n,o.me),lhs:()=>{},put:(o,i,s)=>E(r.ev(o),u=>K(Array.from(u instanceof A?u:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=ft(e,n);r.ev=i=>S(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new Ae(i.me,s))}return r}function Fe(e){let t=e.matchType("ATTRIBUTE_REF");if(!t)return;let n=t.value.startsWith("[")?t.value.slice(2,-1):t.value.slice(1),[r,o]=n.split("="),i=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:i,css:`[${n}]`,start:t.start,end:t.end,ev:s=>Z(s.you||s.me,r),lhs:()=>{},put:(s,u,a)=>X(s.you||s.me,r,a)}}function pt(e){let t=e.matchType("STYLE_REF");if(!t)return;let n=t.value.startsWith("*computed-"),r=t.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:t.start,end:t.end,ev:o=>(n?ce:ue)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>le(o.you||o.me,r,s)}}function ht(e){let t=e.matchType("IDENTIFIER");if(!t)return;let n=[t.value],r=e.matchOp(".")??e.matchOp(":");if(r)do n.push(e.reqType("IDENTIFIER","NUMBER").value);while(e.matchOp(r.value));return n.join(r?.value??"")}function gt(e,t="Expected event name"){return e.matchType("STRING")?.value??ht(e)??e.err(t)}function O(e,t){return fn(e,t)??dn(e,t)??yn(e,t)??mn(e,t)??pn(e,t)??hn(e,t)??gn(e,t)??vn(e,t)??ln(e,t)??t}function ln(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function fn(e,t){if(!e.matchOp("."))return;let n=e.reqType("IDENTIFIER").value,r=e.text(t),o={type:"propertyAccess",root:t,prop:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>J(s,n)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{R(s,r),fe(s,n,u)},del:(i,s)=>{R(s,r),P(s,u=>{C(u)&&delete u[n],v.wroteProperty(u)})}};return O(e,o)}function dn(e,t){if(!e.match("of"))return;let n=H(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],u=o.name;if(!s||u===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let a=e.text(n),l={property:J,attribute:Z,style:ue,computed:ce}[s],c={type:"ofExpression",root:n,name:u,kind:s,start:t.start,end:e.endPos(),ev:p=>E(c.root.ev(p),m=>l(m,u)),lhs:p=>c.root.ev(p),put:(p,m,d)=>{R(m,a),s==="attribute"?X(m,u,d):s==="property"?fe(m,u,d):le(m,u,d)},del:(p,m)=>{R(m,a),P(m,d=>{s==="attribute"?k(d)&&d.removeAttribute(u):s==="property"?(C(d)&&delete d[u],v.wroteProperty(d)):d instanceof HTMLElement&&d.style.removeProperty(u)})}};return r?(r.root=c,O(e,t)):O(e,c)}function mn(e,t){let n=e.matchOp("'"),r=t.type==="symbol"&&["my","its","your"].includes(t.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(e.cur().type);if(!n&&!r)return;n&&e.req("s");let o=Fe(e)??pt(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),u=l=>i!==void 0?J(l,i):o?.type==="attributeRef"?Z(l,o.name):o?.type==="computedStyleRef"?ce(l,o.name):o&&ue(l,o.name),a={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>E(a.root.ev(l),u),lhs:l=>a.root.ev(l),put:(l,c,p)=>{R(c,s),i!==void 0?fe(c,i,p):o?.type==="attributeRef"?X(c,o.name,p):o&&le(c,o.name,p)}};return O(e,a)}function pn(e,t){if(!e.match("in"))return;let n=H(e),r=(s,u)=>{if(s==null)return[];let a=[],l=g(s,"css");if(typeof l=="string")P(u,c=>k(c)&&a.push(...xe(c,l)));else if(k(s)){let c=!1;if(P(u,p=>{p instanceof Node&&p.contains(s)&&(c=!0)}),c)return s}else P(s,c=>P(u,p=>c===p&&a.push(c)));return a},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>S([o.root.ev(s),n.ev(s)],([u,a])=>r(u,a)),lhs:s=>o.ev(s),put:(s,u,a)=>K(u,a)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return O(e,i??o)}function hn(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=ht(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:u=>E(s.root.ev(u),a=>Ye(a,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return O(e,r)}function gn(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(x(e));while(e.matchOp(","));e.reqOp(")")}let r=e.text(t),o=t.root?e.text(t.root):"",i={type:"functionCall",root:t,args:n,start:t.start,end:e.endPos(),ev:s=>{let u=i.root,a=u.prop,l=a===void 0?void 0:u.root;return S([(l??u).ev(s),...n.map(c=>c.ev(s))],([c,...p])=>{if(!l||a===void 0)return ut(c,void 0,p,s,r);R(c,o);let m=ut(g(c,a),c,p,s,r);return Be(c,a),m})}};return O(e,i)}function ut(e,t,n,r,o){if(!D(e))throw R(e,o),new Error(`'${o}' is not a function`);return g(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function yn(e,t){let n=Fe(e);return n&&wn(e,t,n)}function wn(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>Z(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{R(s,r),X(s,n.name,u)}};return o}function vn(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=x(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=x(e))),e.reqOp("]");let s=e.text(t),u=(c,p)=>w(p)<0?w(g(c,"length"))+w(p):w(p),a=(c,p,m)=>{let d=g(c,"slice");return D(d)?Reflect.apply(d,c,[p,m]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:c=>S([l.root.ev(c),r.ev(c),i?.ev(c)],([p,m,d])=>p==null?null:n?a(p,0,u(p,m)+1):o?d==null?a(p,w(m)):a(p,w(m),u(p,d)+1):g(p,String(m))),lhs:c=>S([l.root.ev(c),r.ev(c)],p=>p),put:(c,p,m)=>{let[d,y]=Array.isArray(p)?p:[];R(d,s),C(d)&&(d[String(y)]=m)},del:(c,p)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[m,d]=Array.isArray(p)?p:[];R(m,s),Array.isArray(m)?m.splice(u(m,d),1):C(m)&&delete m[String(d)],v.wroteProperty(m)}};return O(e,l)}var yt=new WeakSet;function wt(e){if(yt.has(e))return;yt.add(e);let t=!1,n=o=>{let i=t;t=!0;try{o()}finally{t=i}};document.addEventListener("htmx:load",o=>n(()=>e.process(o.detail?.elt))),document.addEventListener("htmx:after:process",o=>n(()=>e.process(o.target))),document.addEventListener("fx:swapped",o=>{let i=o.detail?.cfg?.target;e.process(i instanceof Element&&i.isConnected?i.parentElement??i:document.body)});let r=Reflect.get(globalThis,"htmx");typeof r?.process=="function"&&(e.addAfterProcessHook(o=>{t||n(()=>r.process(o))}),r.version?.startsWith("4")&&r.registerExtension?.("hs-include",{htmx_config_request(o,i){let s=i?.ctx;if(!s)return;let u=En(s.sourceElement||o);if(!u)return;let a=xn(u.value,u.scopeElt),l=s.request?.body;if(l instanceof FormData)for(let c in a)l.set(c,a[c])}}))}function En(e){let t=e.getAttribute("hs-include");if(t!==null)return{value:t,scopeElt:e};for(let n=e.parentElement;n;n=n.parentElement){let r=n.getAttribute("hs-include:inherited");if(r!==null)return{value:r,scopeElt:n}}return null}var me=e=>e&&M(e)?.scopes?.elementScope||{};function de(e){if(e==null)return"";if(typeof e=="object")try{return JSON.stringify(e)}catch{return""}return String(e)}function bn(e,t){for(let n=t;n;n=n.parentElement){let r=me(n);if(e in r)return r[e]}}function xn(e,t){let n={},r=e.trim();if(r==="*"){let o=me(t);for(let i of Object.keys(o))n[i[0]===":"?i.slice(1):i]=de(o[i]);return n}for(let o of r.split(","))if(o=o.trim(),!!o){if(o[0]===":"){let i=me(t);o in i&&(n[o.slice(1)]=de(i[o]))}else if(o[0]==="^"){let i=bn(":"+o.slice(1),t);i!==void 0&&(n[o.slice(1)]=de(i))}else if(o[0]==="#"){let i=o.lastIndexOf(":");if(i>0){let s=me(document.querySelector(o.slice(0,i))),u=o.slice(i+1);":"+u in s&&(n[u]=de(s[":"+u]))}}}return n}var F=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},vt=()=>({commands:Object.create(null),fallbacks:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),pe=class e{constructor(t,n,r){this.g=t;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(t,n){return new e(this.g,t,n)}tok(t=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(t--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}mark(){return{i:this.i,last:this.last,follows:this.follows.length}}reset(t){this.i=t.i,this.last=t.last,this.follows.length=t.follows}endPos(){return this.last.end}text(t){return this.src.substring(t.start,t.end)}match(t,n="IDENTIFIER"){if(this.follows.includes(t))return;let r=this.cur();if(r.value===t&&r.type===n)return this.consume()}matchOp(t){let n=this.cur();if(n.op&&n.value===t)return this.consume()}matchType(...t){if(t.includes(this.cur().type))return this.consume()}matchAny(...t){for(let n of t){let r=this.match(n);if(r)return r}}matchAnyOp(...t){for(let n of t){let r=this.matchOp(n);if(r)return r}}req(t){return this.match(t)??this.expected(t)}reqOp(t){return this.matchOp(t)??this.expected(t)}reqType(...t){return this.matchType(...t)??this.expected(...t)}peek(t,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===t&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(t,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(t==null||o.value!==t)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let t=this.tokens[this.i-1];return t?.type==="WHITESPACE"?t.value:""}pushFollow(...t){return this.follows.push(...t),t.length}popFollow(t=1){this.follows.length-=t}withFollow(t,n){let r=this.pushFollow(...t);try{return n()}finally{this.popFollow(r)}}withoutFollows(t){let n=this.follows;this.follows=[];try{return t()}finally{this.follows=n}}err(t,n){let r=this.cur();throw new F(t??"Unexpected Token : "+r.value,r,this.src,n)}expected(...t){this.err(t.length===1?`Expected '${t[0]}' but found '${this.cur().value}'`:"Expected one of: "+t.map(n=>`'${n}'`).join(", "),t)}commandStart(t){return t.value in this.g.commands}featureStart(t){return t.value in this.g.features}commandBoundary(t){return["end","then","else","otherwise",")"].includes(t.value)||this.commandStart(t)||this.featureStart(t)||t.type==="EOF"}};function qe(e){let t=e.source.split(`
|
|
6
6
|
`),n=e.token.line?e.token.line-1:t.length-1,r=t[n]??"",o=e.token.line?e.token.column:Math.max(0,r.length-1),i=String(n+1).length,s=" ".repeat(i+5+o);return` ${n+1} | ${r}
|
|
7
7
|
`+s+"^".repeat(Math.max(1,e.token.value.length))+`
|
|
8
8
|
`+s+e.message+`
|
|
9
|
-
`}function
|
|
9
|
+
`}function kn(e,t,n,r){let o=e.g.fallbacks[n];if(!o)return t(e,n,r);let i=e.mark();try{return t(e,n,r)}catch(s){if(!(s instanceof F))throw s;let u=s;for(let a of o){e.reset(i);try{let l=a(e,n,r);if(l&&e.pos()>=s.token.start)return l}catch(l){if(!(l instanceof F))throw l;l.token.start>u.token.start&&(u=l)}}throw u}}function Et(e){let t=e.pos();if(e.matchOp("(")){let a=Et(e)??e.err("Expected command");return e.reqOp(")"),a}let n=e.cur(),r=e.g.commands[n.value],o;if(r?o=e.match(n.value)&&kn(e,r,n.value,t):n.type==="IDENTIFIER"&&(o=e.g.pseudo?.(e,t)),!o||!e.match("unless"))return o;let i=o,s=x(e);return{type:"unlessStatementModifier",command:i,condition:s,start:t,end:e.endPos(),run:a=>E(s.ev(a),l=>l?void 0:i.run(a))}}function W(e){let t=[];for(;e.hasMore();){let n=Et(e);if(!n)break;t.push(n),e.match("then")}return t}function bt(e){let t=e.pos();if(e.matchOp("(")){let o=bt(e);return e.reqOp(")"),o}let n=e.cur(),r=e.g.features[n.value];return!r||!e.match(n.value)?e.err("Expected feature"):r(e,t)}function _e(e){let t=e.pos(),n=[];for(;e.hasMore();){let r=e.cur();if(e.featureStart(r)||r.value==="(")n.push(bt(e)),e.match("end");else{if(r.value==="end")break;e.err()}}return{type:"hyperscript",features:n,start:t,end:e.endPos()}}function xt(e){let t={};return e.match("catch")&&(t.errorSymbol=e.reqType("IDENTIFIER").value,t.errorHandler=W(e)),e.match("finally")&&(t.finallyHandler=W(e)),t}function kt(e){let t=[],n=e.tok(1).value,r=e.tok(2).value;if(e.cur().value==="("&&(n===")"||r===","||r===")")){e.matchOp("(");do t.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}return t}var Nt=vt(),Tt=new Set,De=new Set;function je(...e){let t=e.filter(n=>!Tt.has(n));for(let n of t)Tt.add(n),n(Nt);if(t.length)for(let n of[...De])De.delete(n),n.isConnected&&(Ee(n),Me(n))}var St=e=>new pe(Nt,te(e),e);function Tn(e){let t=St(e),n=_e(t);return t.hasMore()&&t.err(),n}function Rt(e){let t=St(e),n=t.cur(),r=t.commandStart(n)?{kind:"commands",commands:W(t)}:t.featureStart(n)?{kind:"features",program:_e(t)}:{kind:"expression",expression:x(t)};return t.hasMore()&&t.err(),r}function Pt(e,t){let n;try{n=Rt(e)}catch(i){throw i instanceof F?new Error(i.message+`
|
|
10
10
|
|
|
11
|
-
`+
|
|
11
|
+
`+qe(i)):i}let r=document.body;if(n.kind==="features"){for(let i of n.program.features)i.install(r,r);return}let o=Object.assign(ee(r,void 0,r,null),t);return n.kind==="expression"?n.expression.ev(o):E($(n.commands,o),i=>{let s=g(i,"k")==="return"?g(i,"value"):void 0;return s!==void 0?s:o.result})}var Ot=()=>ie.attributes.replaceAll(" ","").split(","),It=e=>e instanceof HTMLScriptElement&&e.type==="text/hyperscript";function Pn(e){for(let t of Ot())if(e.hasAttribute(t))return e.getAttribute(t);return It(e)?e.innerText:null}var Nn=e=>{let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return t},Ct=[];function Me(e){if(e.closest(ie.disableSelector))return;let t=Pn(e);if(!t)return;let n=Nn(t);if(M(e)?.initialized){if(M(e)?.scriptHash===n)return Y.enter(e);he(e)}if(!N(e,"hyperscript:before:init"))return;Object.assign(U(e),{initialized:!0,scriptHash:n});let r=It(e)?document.body:e,o=t;try{for(let s of Ct)o=s(o,e)??o;let{features:i}=Tn(o);Y.enter(e);for(let s of i)s.install(r,e);e.setAttribute("data-hyperscript-powered","true"),N(e,"hyperscript:after:init"),setTimeout(()=>N(r,"load",{hyperscript:!0}),1)}catch(i){if(i instanceof F){De.add(e),o!==t&&(i.written=t),N(e,"hyperscript:parse-error",{errors:[i]});let s=i.written?`
|
|
12
12
|
rewritten from: ${i.written}
|
|
13
13
|
`:"";console.error("hyperscript: 1 parse error(s) on:",e,`
|
|
14
14
|
|
|
15
|
-
`+
|
|
15
|
+
`+qe(i)+s)}else N(e,"exception",{error:i}),console.error("hyperscript errors were found on the following element:",e,`
|
|
16
16
|
|
|
17
|
-
`,i)}}var
|
|
17
|
+
`,i)}}var At=[],Ft=[],Le=new Set;function re(e){if((e instanceof Element||e instanceof Document||e instanceof DocumentFragment)&&!Le.has(e)){Le.add(e);try{for(let n of At)n(e);let t=Ot().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&Me(e),e.querySelectorAll(t).forEach(Me);for(let n of Ft)n(e)}finally{Le.delete(e)}}}function he(e){let t=M(e);if(t){N(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);v.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(he),N(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),Ee(e)}}Y.process=re;function Sn(e){try{let t=Rt(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof F)return{errors:[t]};throw t}}var He=Object.assign(Pt,{config:Object.assign(ie,{conversions:Object.assign(ye,{dynamicResolvers:we})}),use(e){e(He)},addBeforeProcessHook:e=>void At.push(e),addAfterProcessHook:e=>void Ft.push(e),addSourceTransform:e=>void Ct.push(e),register:je,extensions:new Set,evaluate:Pt,parse:Sn,process:re,processNode:re,cleanup:he,internals:{runtime:{cleanup:he,processNode:re}},version:"7.6.0"});function qt(){if(Object.assign(globalThis,{_hyperscript:He}),typeof document>"u")return;let e=()=>{re(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready")),wt(He)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}function Rn(e,t){if(typeof e!="object"||e===null)return{queue:[],executing:!1};let n=U(e).eventQueues??=new Map,r=n.get(t);return r||n.set(t,r={queue:[],executing:!1}),r}function $e(e,t){let n=Rn(e.me,t);if(n.executing&&!t.every){if(t.queue==="none"||t.queue==="first"&&n.queue.length>0)return;t.queue!=="all"&&(n.queue.length=0),n.queue.push(e);return}n.executing=!0;let r=o=>{n.executing=!1;let i=n.queue.shift();if(i&&setTimeout(()=>$e(i,t),1),o){let{error:s}=o;console.error(g(s,"message")??s),console.error(g(s,"stack")),N(e.me,"exception",{error:s})}};V(()=>E(tt(e,t.body,t),()=>r()),o=>r({error:o}))}function On(e,t){if(!B(t))return;let n=U(t),r=n.listeners??=[],o=n.observers??=[],i=n.timers??=new Set;for(let s of e.events){let u={execCount:0},a=s.elsewhere?[document]:s.from?s.from.ev(ee(t,e,t,null)):[t];P(a,l=>{if(!B(l)){console.warn("'%s' feature ignored because target does not exists:",e.displayName,t);return}let c=s.on;if(s.mutationSpec&&l instanceof Node){c="hyperscript:mutation";let m=new MutationObserver(d=>N(l,c,{mutationList:d,observer:m}));m.observe(l,s.mutationSpec),o.push(m)}if(s.intersectionSpec&&l instanceof Element){c="hyperscript:intersection";let m=new IntersectionObserver(d=>{for(let y of d)N(l,c,{observer:m,entry:y,intersecting:y.isIntersecting,isIntersecting:y.isIntersecting,intersectionRatio:y.intersectionRatio})},s.intersectionSpec);m.observe(l),o.push(m)}if(s.resizeSpec&&l instanceof Element){c="hyperscript:resize";let m=new ResizeObserver(d=>{for(let y of d){let{width:I,height:j}=y.contentRect;N(l,c,{width:I,height:j,contentRect:y.contentRect,entry:y})}});m.observe(l),o.push(m)}let p=m=>{if(t instanceof Node&&l!==t&&!t.isConnected){l.removeEventListener(c,p);return}let d=ee(t,e,t,m);if(!(s.elsewhere&&t instanceof Node&&m.target instanceof Node&&t.contains(m.target))){s.from&&(d.result=l);for(let y of s.args){let I=g(m,y);I!==void 0?d.locals[y]=I:d.detail!=null&&(d.locals[y]=g(d.detail,y))}if(s.filter){d.meta.context=m;try{if(!s.filter.ev(d))return}finally{d.meta.context=void 0}}if(s.inExpr?.css){let y=m.target instanceof Element?m.target:null;for(;y&&!y.matches(s.inExpr.css);)y=y.parentElement;if(!y)return;d.result=y}if(u.execCount++,s.startCount){let y=u.execCount;if(s.endCount?y<s.startCount||y>s.endCount:s.unbounded?y<s.startCount:y!==s.startCount)return}if(s.debounceTime){u.debounced&&(clearTimeout(u.debounced),i.delete(u.debounced)),i.add(u.debounced=setTimeout(()=>$e(d,e),s.debounceTime));return}if(s.throttleTime){if(u.lastExec&&Date.now()<u.lastExec+s.throttleTime)return;u.lastExec=Date.now()}$e(d,e)}};l.addEventListener(c,p),r.push({target:l,event:c,handler:p})})}}function In(e){if(!e.match("of"))return{attributes:!0,characterData:!0,childList:!0,attributeOldValue:!0,characterDataOldValue:!0};let t={};do if(e.match("anything"))Object.assign(t,{attributes:!0,subtree:!0,characterData:!0,childList:!0});else if(e.match("childList"))t.childList=!0;else if(e.match("attributes"))t.attributes=!0;else if(e.match("subtree"))t.subtree=!0;else if(e.match("characterData"))t.characterData=!0;else if(e.cur().type==="ATTRIBUTE_REF"){let n=e.consume().value;n.startsWith("@")||e.err("Only shorthand attribute references are allowed here"),(t.attributeFilter??=[]).push(n.substring(1))}else e.err("Unknown mutation config specification");while(e.match("or"));return(t.attributes||t.attributeFilter)&&(t.attributeOldValue=!0),t.characterData&&(t.characterDataOldValue=!0),t}function Cn(e){let t={};if(e.match("with")){let n=ne(x(e));n instanceof Element&&(t.root=n)}if(e.match("having"))do e.match("margin")?t.rootMargin=dt(e):e.match("threshold")?t.threshold=Number(ne(x(e))):e.err("Unknown intersection config specification");while(e.match("and"));return t}function An(e,t){let n=gt(e),r=kt(e),o;e.matchOp("[")&&(o=x(e),e.reqOp("]"));let i,s,u=!1;t?i=1:e.cur().type==="NUMBER"&&(i=parseInt(e.consume().value),e.match("to")?s=parseInt(e.consume().value):e.match("and")&&(u=!0,e.req("on")));let a={on:n,args:r,filter:o,startCount:i,endCount:s,unbounded:u,elsewhere:!1,resizeSpec:n==="resize"};n==="intersection"?a.intersectionSpec=Cn(e):n==="mutation"&&(a.mutationSpec=In(e)),e.match("from")&&(e.match("elsewhere")?a.elsewhere=!0:a.from=e.withFollow(["or"],()=>x(e))),!a.from&&!a.elsewhere&&e.match("elsewhere")&&(a.elsewhere=!0),e.match("in")&&(a.inExpr=H(e));let l=()=>(e.req("at"),Number(ne(H(e))));return e.match("debounced")?a.debounceTime=l():e.match("throttled")&&(a.throttleTime=l()),a}function _t(e){e.features.on=(t,n)=>{let r=!!t.match("every"),o=!r&&!!t.match("first"),i=[];do i.push(An(t,o));while(t.match("or"));let s="last";!r&&t.match("queue")&&(t.match("all")?s="all":t.match("first")?s="first":t.match("none")?s="none":t.req("last"));let u=W(t),a={type:"onFeature",displayName:"on "+i.map(l=>l.on).join(" or "),events:i,body:u,every:r,queue:s,...xt(t),start:n,end:t.endPos(),install:l=>On(a,l)};return a}}je(_t);qt();})();
|
package/dist/engine.d.ts
CHANGED
|
@@ -8,7 +8,11 @@ import type { Cmd, Ctx, Expr, Program } from './ast';
|
|
|
8
8
|
import { ParseError, type Grammar } from './parser';
|
|
9
9
|
export type Module = (g: Grammar) => void;
|
|
10
10
|
export declare const grammar: Grammar;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Add grammar modules to this bundle's engine; a module already added is skipped. Elements
|
|
13
|
+
* already read whose scripts failed to parse are read again, and only those: an extension that
|
|
14
|
+
* claims only what upstream rejects cannot change a script that parsed.
|
|
15
|
+
*/
|
|
12
16
|
export declare function register(...modules: Module[]): void;
|
|
13
17
|
/** Parse the script of an element. Throws `ParseError`; a leftover token is an error. */
|
|
14
18
|
export declare function parseProgram(src: string): Program;
|
|
@@ -59,6 +63,10 @@ export declare const api: typeof evaluate & {
|
|
|
59
63
|
addAfterProcessHook: (hook: ProcessHook) => undefined;
|
|
60
64
|
/** Not in upstream: rewrite a script as it is read, leaving the attribute as written. */
|
|
61
65
|
addSourceTransform: (transform: SourceTransform) => undefined;
|
|
66
|
+
/** Not in upstream: add grammar modules, from a script tag (`dist/ext/<name>.js`) or a page. */
|
|
67
|
+
register: typeof register;
|
|
68
|
+
/** Not in upstream: the extension files (`dist/ext/<name>.js`) this page has loaded. */
|
|
69
|
+
extensions: Set<string>;
|
|
62
70
|
evaluate: typeof evaluate;
|
|
63
71
|
parse: typeof hostParse;
|
|
64
72
|
process: typeof processNode;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upstream's `socket` extension (`src/ext/socket.js`, 0.9.93): a WebSocket as a named feature.
|
|
3
|
+
*
|
|
4
|
+
* socket Chat ws://example.com/chat [with timeout 5000]
|
|
5
|
+
* [on message [as JSON] <commands>]
|
|
6
|
+
* end
|
|
7
|
+
*
|
|
8
|
+
* `Chat` is defined on the element, or globally for a script tag; `MyApp.chat` defines it in a
|
|
9
|
+
* namespace. It has `Chat.raw` (the WebSocket), `dispatchEvent` (so `send ping(n: 1) to Chat`
|
|
10
|
+
* sends `{"type":"ping","n":1}`), and `Chat.rpc.f(…)`: it sends `{iid, function, args}` and
|
|
11
|
+
* returns a promise for the reply's `return` (or its `throw`), which times out after the
|
|
12
|
+
* socket's timeout (10 s unless `with timeout`); `.noTimeout` and `.timeout(ms)` change that
|
|
13
|
+
* for one call. In `on message`, `message` (and `it`) is the data, parsed with `as JSON`. A
|
|
14
|
+
* relative URL (`/chat`) takes the page's host, as `wss:` on an https page. Upstream's tests for
|
|
15
|
+
* it (`test/features/socket.js`) are in the gate.
|
|
16
|
+
*
|
|
17
|
+
* Two differences from upstream, which its tests do not see: the WebSocket opens when the
|
|
18
|
+
* feature is installed, not when it is parsed, so a parse alone (`_hyperscript.parse`, an
|
|
19
|
+
* editor, a gate) opens nothing; and with `as JSON` a message that is JSON `0`, `false` or
|
|
20
|
+
* `null` is that value, where upstream reports it as not JSON.
|
|
21
|
+
*/
|
|
22
|
+
import type { Cmd, Feature } from '../ast';
|
|
23
|
+
import type { Module } from '../engine';
|
|
24
|
+
export interface SocketFeature extends Feature {
|
|
25
|
+
type: 'socketFeature';
|
|
26
|
+
name: string;
|
|
27
|
+
url: string;
|
|
28
|
+
timeout: number;
|
|
29
|
+
json: boolean;
|
|
30
|
+
messageHandler?: Cmd[];
|
|
31
|
+
}
|
|
32
|
+
export declare const socket: Module;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
// kit:kit
|
|
3
|
+
var kit = globalThis._hyperscript && globalThis._hyperscript.kit || {};
|
|
4
|
+
var read = (name) => kit[name];
|
|
5
|
+
var assignToNamespace = /* @__PURE__ */ read("assignToNamespace");
|
|
6
|
+
var commandList = /* @__PURE__ */ read("commandList");
|
|
7
|
+
var dotOrColonPath = /* @__PURE__ */ read("dotOrColonPath");
|
|
8
|
+
var evalStatic = /* @__PURE__ */ read("evalStatic");
|
|
9
|
+
var expr = /* @__PURE__ */ read("expr");
|
|
10
|
+
var makeContext = /* @__PURE__ */ read("makeContext");
|
|
11
|
+
var runList = /* @__PURE__ */ read("runList");
|
|
12
|
+
var urlOrExpression = /* @__PURE__ */ read("urlOrExpression");
|
|
13
|
+
|
|
14
|
+
// src/ext/socket.ts
|
|
15
|
+
var PROXY_BLACKLIST = ["then", "catch", "length", "toJSON"];
|
|
16
|
+
var genUUID = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
17
|
+
const r = Math.random() * 16 | 0;
|
|
18
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
19
|
+
});
|
|
20
|
+
function parseUrl(url) {
|
|
21
|
+
if (!url.startsWith("/")) return url;
|
|
22
|
+
const host = location.hostname + (location.port ? ":" + location.port : "");
|
|
23
|
+
if (location.protocol === "https:") return "wss://" + host + url;
|
|
24
|
+
if (location.protocol === "http:") return "ws://" + host + url;
|
|
25
|
+
return url;
|
|
26
|
+
}
|
|
27
|
+
var socket = (g) => {
|
|
28
|
+
g.features.socket = (p, start) => {
|
|
29
|
+
const name = dotOrColonPath(p) ?? p.err("Expected dotOrColonPath");
|
|
30
|
+
const url = String(evalStatic(urlOrExpression(p)));
|
|
31
|
+
let timeout = 1e4;
|
|
32
|
+
if (p.match("with")) {
|
|
33
|
+
p.req("timeout");
|
|
34
|
+
timeout = Number(evalStatic(expr(p)));
|
|
35
|
+
}
|
|
36
|
+
let json = false;
|
|
37
|
+
let messageHandler;
|
|
38
|
+
if (p.match("on")) {
|
|
39
|
+
p.req("message");
|
|
40
|
+
if (p.match("as")) {
|
|
41
|
+
if (!p.match("JSON")) p.req("json");
|
|
42
|
+
json = true;
|
|
43
|
+
}
|
|
44
|
+
messageHandler = commandList(p);
|
|
45
|
+
}
|
|
46
|
+
const namespace = name.split(".");
|
|
47
|
+
const socketName = namespace.pop() ?? name;
|
|
48
|
+
const feature = {
|
|
49
|
+
type: "socketFeature",
|
|
50
|
+
name,
|
|
51
|
+
url,
|
|
52
|
+
timeout,
|
|
53
|
+
json,
|
|
54
|
+
messageHandler,
|
|
55
|
+
start,
|
|
56
|
+
end: p.endPos(),
|
|
57
|
+
install: (target) => {
|
|
58
|
+
const pending = {};
|
|
59
|
+
let ws = open();
|
|
60
|
+
function open() {
|
|
61
|
+
const created = new WebSocket(parseUrl(url));
|
|
62
|
+
created.onmessage = receive;
|
|
63
|
+
created.addEventListener("close", () => ws = null);
|
|
64
|
+
return created;
|
|
65
|
+
}
|
|
66
|
+
const proxy = (wait) => new Proxy(
|
|
67
|
+
{},
|
|
68
|
+
{
|
|
69
|
+
get: (_, property) => {
|
|
70
|
+
if (PROXY_BLACKLIST.includes(String(property))) return null;
|
|
71
|
+
if (property === "noTimeout") return proxy(-1);
|
|
72
|
+
if (property === "timeout") return (ms) => proxy(parseInt(String(ms)));
|
|
73
|
+
return (...args) => {
|
|
74
|
+
const iid = genUUID();
|
|
75
|
+
ws ??= open();
|
|
76
|
+
ws.send(JSON.stringify({ iid, function: property, args }));
|
|
77
|
+
const reply = new Promise(
|
|
78
|
+
(resolve, reject) => pending[iid] = { resolve, reject }
|
|
79
|
+
);
|
|
80
|
+
if (wait >= 0)
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
pending[iid]?.reject("Timed out");
|
|
83
|
+
delete pending[iid];
|
|
84
|
+
}, wait);
|
|
85
|
+
return reply;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
const socketObject = {
|
|
91
|
+
raw: ws,
|
|
92
|
+
dispatchEvent(evt) {
|
|
93
|
+
const detail = evt.detail ?? {};
|
|
94
|
+
delete detail.sender;
|
|
95
|
+
delete detail._namedArgList_;
|
|
96
|
+
ws?.send(JSON.stringify({ type: evt.type, ...detail }));
|
|
97
|
+
},
|
|
98
|
+
rpc: proxy(timeout)
|
|
99
|
+
};
|
|
100
|
+
function receive(evt) {
|
|
101
|
+
const data = evt.data;
|
|
102
|
+
let parsed;
|
|
103
|
+
try {
|
|
104
|
+
parsed = JSON.parse(String(data));
|
|
105
|
+
} catch {
|
|
106
|
+
}
|
|
107
|
+
const reply = parsed;
|
|
108
|
+
if (reply?.iid && pending[reply.iid]) {
|
|
109
|
+
if (reply.throw) pending[reply.iid].reject(reply.throw);
|
|
110
|
+
else pending[reply.iid].resolve(reply.return);
|
|
111
|
+
delete pending[reply.iid];
|
|
112
|
+
}
|
|
113
|
+
if (!messageHandler) return;
|
|
114
|
+
if (json && parsed === void 0)
|
|
115
|
+
throw new Error("Received non-JSON message from socket: " + String(data));
|
|
116
|
+
const message = json ? parsed : data;
|
|
117
|
+
const ctx = makeContext(socketObject, feature, socketObject, null);
|
|
118
|
+
ctx.locals.message = message;
|
|
119
|
+
ctx.result = message;
|
|
120
|
+
Promise.resolve(runList(messageHandler, ctx)).catch((error) => console.error(error));
|
|
121
|
+
}
|
|
122
|
+
assignToNamespace(target, namespace, socketName, socketObject);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return feature;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// ext/socket.js
|
|
130
|
+
var hs = globalThis._hyperscript;
|
|
131
|
+
if (!hs || !hs.register)
|
|
132
|
+
console.warn("[hyperfixi] ext/socket.js needs @hyperfixi/engine (hyperfixi-hs.js), loaded before it");
|
|
133
|
+
else if (!hs.kit)
|
|
134
|
+
console.warn("[hyperfixi] ext/socket.js needs hyperfixi-hs.js; with the Vite plugin, list it: extensions: ['socket']");
|
|
135
|
+
else if (!hs.extensions.has("socket")) {
|
|
136
|
+
hs.extensions.add("socket");
|
|
137
|
+
hs.register(socket);
|
|
138
|
+
}
|
|
139
|
+
})();
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// src/ext/socket.ts
|
|
2
|
+
import {
|
|
3
|
+
assignToNamespace,
|
|
4
|
+
commandList,
|
|
5
|
+
dotOrColonPath,
|
|
6
|
+
evalStatic,
|
|
7
|
+
expr,
|
|
8
|
+
makeContext,
|
|
9
|
+
runList,
|
|
10
|
+
urlOrExpression
|
|
11
|
+
} from "@hyperfixi/engine";
|
|
12
|
+
var PROXY_BLACKLIST = ["then", "catch", "length", "toJSON"];
|
|
13
|
+
var genUUID = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
14
|
+
const r = Math.random() * 16 | 0;
|
|
15
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
16
|
+
});
|
|
17
|
+
function parseUrl(url) {
|
|
18
|
+
if (!url.startsWith("/")) return url;
|
|
19
|
+
const host = location.hostname + (location.port ? ":" + location.port : "");
|
|
20
|
+
if (location.protocol === "https:") return "wss://" + host + url;
|
|
21
|
+
if (location.protocol === "http:") return "ws://" + host + url;
|
|
22
|
+
return url;
|
|
23
|
+
}
|
|
24
|
+
var socket = (g) => {
|
|
25
|
+
g.features.socket = (p, start) => {
|
|
26
|
+
const name = dotOrColonPath(p) ?? p.err("Expected dotOrColonPath");
|
|
27
|
+
const url = String(evalStatic(urlOrExpression(p)));
|
|
28
|
+
let timeout = 1e4;
|
|
29
|
+
if (p.match("with")) {
|
|
30
|
+
p.req("timeout");
|
|
31
|
+
timeout = Number(evalStatic(expr(p)));
|
|
32
|
+
}
|
|
33
|
+
let json = false;
|
|
34
|
+
let messageHandler;
|
|
35
|
+
if (p.match("on")) {
|
|
36
|
+
p.req("message");
|
|
37
|
+
if (p.match("as")) {
|
|
38
|
+
if (!p.match("JSON")) p.req("json");
|
|
39
|
+
json = true;
|
|
40
|
+
}
|
|
41
|
+
messageHandler = commandList(p);
|
|
42
|
+
}
|
|
43
|
+
const namespace = name.split(".");
|
|
44
|
+
const socketName = namespace.pop() ?? name;
|
|
45
|
+
const feature = {
|
|
46
|
+
type: "socketFeature",
|
|
47
|
+
name,
|
|
48
|
+
url,
|
|
49
|
+
timeout,
|
|
50
|
+
json,
|
|
51
|
+
messageHandler,
|
|
52
|
+
start,
|
|
53
|
+
end: p.endPos(),
|
|
54
|
+
install: (target) => {
|
|
55
|
+
const pending = {};
|
|
56
|
+
let ws = open();
|
|
57
|
+
function open() {
|
|
58
|
+
const created = new WebSocket(parseUrl(url));
|
|
59
|
+
created.onmessage = receive;
|
|
60
|
+
created.addEventListener("close", () => ws = null);
|
|
61
|
+
return created;
|
|
62
|
+
}
|
|
63
|
+
const proxy = (wait) => new Proxy(
|
|
64
|
+
{},
|
|
65
|
+
{
|
|
66
|
+
get: (_, property) => {
|
|
67
|
+
if (PROXY_BLACKLIST.includes(String(property))) return null;
|
|
68
|
+
if (property === "noTimeout") return proxy(-1);
|
|
69
|
+
if (property === "timeout") return (ms) => proxy(parseInt(String(ms)));
|
|
70
|
+
return (...args) => {
|
|
71
|
+
const iid = genUUID();
|
|
72
|
+
ws ??= open();
|
|
73
|
+
ws.send(JSON.stringify({ iid, function: property, args }));
|
|
74
|
+
const reply = new Promise(
|
|
75
|
+
(resolve, reject) => pending[iid] = { resolve, reject }
|
|
76
|
+
);
|
|
77
|
+
if (wait >= 0)
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
pending[iid]?.reject("Timed out");
|
|
80
|
+
delete pending[iid];
|
|
81
|
+
}, wait);
|
|
82
|
+
return reply;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
const socketObject = {
|
|
88
|
+
raw: ws,
|
|
89
|
+
dispatchEvent(evt) {
|
|
90
|
+
const detail = evt.detail ?? {};
|
|
91
|
+
delete detail.sender;
|
|
92
|
+
delete detail._namedArgList_;
|
|
93
|
+
ws?.send(JSON.stringify({ type: evt.type, ...detail }));
|
|
94
|
+
},
|
|
95
|
+
rpc: proxy(timeout)
|
|
96
|
+
};
|
|
97
|
+
function receive(evt) {
|
|
98
|
+
const data = evt.data;
|
|
99
|
+
let parsed;
|
|
100
|
+
try {
|
|
101
|
+
parsed = JSON.parse(String(data));
|
|
102
|
+
} catch {
|
|
103
|
+
}
|
|
104
|
+
const reply = parsed;
|
|
105
|
+
if (reply?.iid && pending[reply.iid]) {
|
|
106
|
+
if (reply.throw) pending[reply.iid].reject(reply.throw);
|
|
107
|
+
else pending[reply.iid].resolve(reply.return);
|
|
108
|
+
delete pending[reply.iid];
|
|
109
|
+
}
|
|
110
|
+
if (!messageHandler) return;
|
|
111
|
+
if (json && parsed === void 0)
|
|
112
|
+
throw new Error("Received non-JSON message from socket: " + String(data));
|
|
113
|
+
const message = json ? parsed : data;
|
|
114
|
+
const ctx = makeContext(socketObject, feature, socketObject, null);
|
|
115
|
+
ctx.locals.message = message;
|
|
116
|
+
ctx.result = message;
|
|
117
|
+
Promise.resolve(runList(messageHandler, ctx)).catch((error) => console.error(error));
|
|
118
|
+
}
|
|
119
|
+
assignToNamespace(target, namespace, socketName, socketObject);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return feature;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
export {
|
|
126
|
+
socket
|
|
127
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var q=globalThis._hyperscript&&globalThis._hyperscript.kit||{},i=n=>q[n],b=i("assignToNamespace"),j=i("commandList");var C=i("dotOrColonPath"),w=i("evalStatic"),N=i("expr"),P=i("makeContext"),E=i("runList"),L=i("urlOrExpression");var I=["then","catch","length","toJSON"],R=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)});function U(n){if(!n.startsWith("/"))return n;let e=location.hostname+(location.port?":"+location.port:"");return location.protocol==="https:"?"wss://"+e+n:location.protocol==="http:"?"ws://"+e+n:n}var T=n=>{n.features.socket=(e,_)=>{let p=C(e)??e.err("Expected dotOrColonPath"),y=String(w(L(e))),f=1e4;e.match("with")&&(e.req("timeout"),f=Number(w(N(e))));let u=!1,m;e.match("on")&&(e.req("message"),e.match("as")&&(e.match("JSON")||e.req("json"),u=!0),m=j(e));let S=p.split("."),F=S.pop()??p,v={type:"socketFeature",name:p,url:y,timeout:f,json:u,messageHandler:m,start:_,end:e.endPos(),install:J=>{let c={},x=O();function O(){let o=new WebSocket(U(y));return o.onmessage=M,o.addEventListener("close",()=>x=null),o}let g=o=>new Proxy({},{get:(r,s)=>I.includes(String(s))?null:s==="noTimeout"?g(-1):s==="timeout"?t=>g(parseInt(String(t))):(...t)=>{let a=R();x??=O(),x.send(JSON.stringify({iid:a,function:s,args:t}));let d=new Promise((k,W)=>c[a]={resolve:k,reject:W});return o>=0&&setTimeout(()=>{c[a]?.reject("Timed out"),delete c[a]},o),d}}),h={raw:x,dispatchEvent(o){let r=o.detail??{};delete r.sender,delete r._namedArgList_,x?.send(JSON.stringify({type:o.type,...r}))},rpc:g(f)};function M(o){let r=o.data,s;try{s=JSON.parse(String(r))}catch{}let t=s;if(t?.iid&&c[t.iid]&&(t.throw?c[t.iid].reject(t.throw):c[t.iid].resolve(t.return),delete c[t.iid]),!m)return;if(u&&s===void 0)throw new Error("Received non-JSON message from socket: "+String(r));let a=u?s:r,d=P(h,v,h,null);d.locals.message=a,d.result=a,Promise.resolve(E(m,d)).catch(k=>console.error(k))}b(J,S,F,h)}};return v}};var l=globalThis._hyperscript;!l||!l.register?console.warn("[hyperfixi] ext/socket.js needs @hyperfixi/engine (hyperfixi-hs.js), loaded before it"):l.kit?l.extensions.has("socket")||(l.extensions.add("socket"),l.register(T)):console.warn("[hyperfixi] ext/socket.js needs hyperfixi-hs.js; with the Vite plugin, list it: extensions: ['socket']");})();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upstream's `tailwind` extension (`src/ext/tailwind.js`, 0.9.93): three hide/show strategies
|
|
3
|
+
* that work through Tailwind's classes. `hide with twDisplay` adds `hidden`, `twVisibility`
|
|
4
|
+
* adds `invisible`, `twOpacity` adds `opacity-0`; `show` removes the class, `toggle` flips it.
|
|
5
|
+
* Upstream's tests for it (`test/ext/tailwind.js`) are in the gate.
|
|
6
|
+
*
|
|
7
|
+
* <script src="hyperfixi-hs.js"></script>
|
|
8
|
+
* <script src="ext/tailwind.js"></script>
|
|
9
|
+
*
|
|
10
|
+
* or, from `@hyperfixi/engine/ext/tailwind`, `register(...everything, tailwind)`.
|
|
11
|
+
*
|
|
12
|
+
* One difference from upstream, which its tests do not see: upstream replaces
|
|
13
|
+
* `config.hideShowStrategies`, dropping any strategy a page added before it; this adds to it.
|
|
14
|
+
*/
|
|
15
|
+
import type { Module } from '../engine';
|
|
16
|
+
export declare const tailwind: Module;
|