@hyperfixi/core 2.7.2 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/hyperscript-api.d.ts +1 -0
- package/dist/ast-utils/index.js +1910 -233
- package/dist/ast-utils/index.mjs +1910 -233
- package/dist/bundle-generator/index.d.ts +1 -1
- package/dist/bundle-generator/index.js +77 -68
- package/dist/bundle-generator/index.mjs +76 -69
- package/dist/bundle-generator/template-capabilities.d.ts +2 -0
- package/dist/chunks/bridge-DHj-SYm2.js +2 -0
- package/dist/chunks/browser-modular-D1m0Eikh.js +2 -0
- package/dist/chunks/{index-D2WUNSCR.js → index-CuPeasRm.js} +2 -2
- package/dist/commands/index.js +117 -5
- package/dist/commands/index.mjs +117 -5
- package/dist/compatibility/browser-modular.d.ts +2 -2
- package/dist/expressions/index.d.ts +1 -1
- package/dist/htmx/hcon.d.ts +9 -0
- package/dist/htmx/htmx-translator.d.ts +1 -0
- package/dist/hyperfixi-browser-classic-i18n.js +1 -1
- package/dist/hyperfixi-browser-minimal.js +1 -1
- package/dist/hyperfixi-browser-standard.js +1 -1
- package/dist/hyperfixi-browser.js +1 -1
- package/dist/hyperfixi-classic-i18n.js +1 -1
- package/dist/hyperfixi-hx-v4.js +1 -1
- package/dist/hyperfixi-hx.js +1 -1
- package/dist/hyperfixi-hybrid-complete.js +1 -1
- package/dist/hyperfixi-hybrid-hx.js +1 -1
- package/dist/hyperfixi-minimal.js +1 -1
- package/dist/hyperfixi-multilingual.js +1 -1
- package/dist/hyperfixi-standard.js +1 -1
- package/dist/hyperfixi.js +1 -1
- package/dist/hyperfixi.mjs +1 -1
- package/dist/index.js +4517 -535
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +4517 -535
- package/dist/lokascript-browser-classic-i18n.js +1 -1
- package/dist/lokascript-browser-minimal.js +1 -1
- package/dist/lokascript-browser-standard.js +1 -1
- package/dist/lokascript-browser.js +1 -1
- package/dist/lokascript-hybrid-complete.js +1 -1
- package/dist/lokascript-hybrid-hx.js +1 -1
- package/dist/lokascript-multilingual.js +1 -1
- package/dist/lse/index.d.ts +7 -7
- package/dist/metadata.d.ts +1 -1
- package/dist/metadata.js +31 -14
- package/dist/metadata.mjs +31 -14
- package/dist/multilingual/index.js +8 -1
- package/dist/multilingual/index.mjs +8 -1
- package/dist/parser/command-parsers/animation-commands.d.ts +2 -2
- package/dist/parser/command-parsers/async-commands.d.ts +2 -2
- package/dist/parser/command-parsers/dom-commands.d.ts +5 -5
- package/dist/parser/command-parsers/navigation-commands.d.ts +4 -0
- package/dist/parser/command-parsers/utility-commands.d.ts +2 -1
- package/dist/parser/command-parsers/variable-commands.d.ts +2 -2
- package/dist/parser/full-parser.js +117 -5
- package/dist/parser/full-parser.mjs +117 -5
- package/dist/parser/semantic-integration.d.ts +1 -0
- package/dist/performance/integration.d.ts +1 -1
- package/dist/registry/index.js +117 -5
- package/dist/registry/index.mjs +117 -5
- package/package.json +12 -19
- package/dist/chunks/bridge-DuveK8T4.js +0 -2
- package/dist/chunks/browser-modular-DW4nC6lH.js +0 -2
- package/dist/compatibility/browser-bundle-animation-generated.d.ts +0 -16
- package/dist/compatibility/browser-bundle-forms-generated.d.ts +0 -16
- package/dist/compatibility/browser-bundle-minimal-generated.d.ts +0 -16
package/dist/hyperfixi-hx.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t){"use strict";const e=new Set(["on","from","to","into","before","after","in","of","at","with","if","else","unless","end","then","and","or","not","repeat","times","for","each","while","until","toggle","add","remove","put","set","get","call","return","append","log","send","trigger","wait","settle","fetch","as","show","hide","take","increment","decrement","focus","blur","go","transition","over","the","a","an","my","its","me","it","you","first","last","next","previous","closest","parent","true","false","null","undefined","is","matches","contains","includes","exists","has","init","every","by","halt","via","values","default","event"]);function s(t){const s=[];let n=0;for(;t.length>n;){if(/\s/.test(t[n])){n++;continue}if("--"===t.slice(n,n+2)){for(;t.length>n&&"\n"!==t[n];)n++;continue}const i=n;if("<"===t[n]&&/[a-zA-Z]/.test(t[n+1]||"")){for(n++;t.length>n&&">"!==t[n];)n++;">"===t[n]&&n++;const e=t.slice(i,n);if(e.endsWith("/>")||e.endsWith(">")){const t=e.slice(1).replace(/\/?>$/,"");s.push({type:"selector",value:t,pos:i});continue}}if("'s"===t.slice(n,n+2)&&!/[a-zA-Z]/.test(t[n+2]||"")){s.push({type:"operator",value:"'s",pos:i}),n+=2;continue}if('"'===t[n]||"'"===t[n]){const e=t[n++];for(;t.length>n&&t[n]!==e;)"\\"===t[n]&&n++,n++;n++,s.push({type:"string",value:t.slice(i,n),pos:i});continue}if(/\d/.test(t[n])||"-"===t[n]&&/\d/.test(t[n+1]||"")){for("-"===t[n]&&n++;t.length>n&&/[\d.]/.test(t[n]);)n++;"ms"===t.slice(n,n+2)?n+=2:"s"!==t[n]||/[a-zA-Z]/.test(t[n+1]||"")?"px"===t.slice(n,n+2)&&(n+=2):n++,s.push({type:"number",value:t.slice(i,n),pos:i});continue}if(":"===t[n]){for(n++;t.length>n&&/[\w]/.test(t[n]);)n++;s.push({type:"localVar",value:t.slice(i,n),pos:i});continue}if("$"===t[n]){for(n++;t.length>n&&/[\w]/.test(t[n]);)n++;s.push({type:"globalVar",value:t.slice(i,n),pos:i});continue}if("@"===t[n]){for(n++;t.length>n&&/[\w-]/.test(t[n]);)n++;s.push({type:"selector",value:t.slice(i,n),pos:i});continue}if("#"===t[n]||"."===t[n]){if("."===t[n]&&t.slice(n+1).match(/^(once|prevent|stop|debounce|throttle)\b/i)){s.push({type:"symbol",value:".",pos:i}),n++;continue}for(n++;t.length>n&&/[\w-]/.test(t[n]);)n++;s.push({type:"selector",value:t.slice(i,n),pos:i});continue}if("["===t[n]){let e=n+1;for(;t.length>e&&/\s/.test(t[e]);)e++;const r=t[e]||"";if(/['"\d\[\]:\$\-]/.test(r)||""===r){s.push({type:"symbol",value:"[",pos:i}),n++;continue}{n++;let e=1;for(;t.length>n&&e>0;)"["===t[n]&&e++,"]"===t[n]&&e--,n++;s.push({type:"selector",value:t.slice(i,n),pos:i});continue}}if("]"===t[n]){s.push({type:"symbol",value:"]",pos:i}),n++;continue}if("'s"===t.slice(n,n+2)){s.push({type:"operator",value:"'s",pos:i}),n+=2;continue}const r=t.slice(n,n+2);if(["==","!=","<=",">=","&&","||"].includes(r))s.push({type:"operator",value:r,pos:i}),n+=2;else if("*"===t[n]&&/[a-zA-Z]/.test(t[n+1]||"")){for(n++;t.length>n&&/[\w-]/.test(t[n]);)n++;s.push({type:"styleProperty",value:t.slice(i,n),pos:i})}else if("+-*/%<>!".includes(t[n]))s.push({type:"operator",value:t[n],pos:i}),n++;else if("()[]{},.".includes(t[n]))s.push({type:"symbol",value:t[n],pos:i}),n++;else{if(/[a-zA-Z_]/.test(t[n])){for(;t.length>n&&/[\w-]/.test(t[n]);)n++;const r=t.slice(i,n),o=e.has(r.toLowerCase())?"keyword":"identifier";s.push({type:o,value:r,pos:i});continue}n++}}return s.push({type:"eof",value:"",pos:t.length}),s}const n={flip:"toggle",switch:"toggle",display:"show",reveal:"show",conceal:"hide",increase:"increment",decrease:"decrement",fire:"trigger",dispatch:"send",navigate:"go",goto:"go"},i={clicked:"click",pressed:"keydown",changed:"change",submitted:"submit",loaded:"load"};function r(t){const e=t.toLowerCase();return n[e]||e}function o(t){const e=t.toLowerCase();return i[e]||e}class a{constructor(t){this.pos=0,this.tokens=s(t)}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}advance(){return this.tokens[this.pos++]}match(...t){const e=this.peek();return t.some(t=>e.value.toLowerCase()===t.toLowerCase())}matchType(...t){return t.includes(this.peek().type)}expect(t){if(!this.match(t)&&r(this.peek().value)!==t)throw Error(`Expected '${t}', got '${this.peek().value}'`);return this.advance()}isAtEnd(){return"eof"===this.peek().type}parse(){return this.match("on")?this.parseEventHandler():this.match("init")?(this.advance(),{type:"event",event:"init",modifiers:{},body:this.parseCommandSequence()}):this.match("every")?this.parseEveryHandler():{type:"sequence",commands:this.parseCommandSequence()}}parseEventHandler(){this.expect("on");const t=this.advance().value,e={};let s;for(;"."===this.peek().value;){this.advance();const t=this.advance().value.toLowerCase();if("once"===t)e.once=1;else if("prevent"===t)e.prevent=1;else if("stop"===t)e.stop=1;else if(("debounce"===t||"throttle"===t)&&"("===this.peek().value){this.advance();const s=this.advance().value;this.expect(")"),"debounce"===t?e.debounce=parseInt(s)||100:e.throttle=parseInt(s)||100}}return this.match("from")&&(this.advance(),s=this.parseExpression()),{type:"event",event:o(t),filter:s,modifiers:e,body:this.parseCommandSequence()}}parseEveryHandler(){return this.expect("every"),{type:"event",event:"interval:"+this.advance().value,modifiers:{},body:this.parseCommandSequence()}}parseCommandSequence(){const t=[];for(;!this.isAtEnd()&&!this.match("end","else");){const e=this.parseCommand();e&&t.push(e),this.match("then","and")&&this.advance()}return t}parseCommand(){if(this.match("if","unless"))return this.parseIf();if(this.match("repeat"))return this.parseRepeat();if(this.match("for"))return this.parseFor();if(this.match("while"))return this.parseWhile();if(this.match("fetch"))return this.parseFetchBlock();const t={toggle:()=>this.parseToggle(),add:()=>this.parseAdd(),remove:()=>this.parseRemove(),put:()=>this.parsePut(),append:()=>this.parseAppend(),set:()=>this.parseSet(),get:()=>this.parseGet(),call:()=>this.parseCall(),log:()=>this.parseLog(),send:()=>this.parseSend(),trigger:()=>this.parseSend(),wait:()=>this.parseWait(),show:()=>this.parseShow(),hide:()=>this.parseHide(),take:()=>this.parseTake(),increment:()=>this.parseIncDec("increment"),decrement:()=>this.parseIncDec("decrement"),focus:()=>this.parseFocusBlur("focus"),blur:()=>this.parseFocusBlur("blur"),go:()=>this.parseGo(),return:()=>this.parseReturn(),transition:()=>this.parseTransition(),halt:()=>this.parseHalt()},e=r(this.peek().value);return t[e]?t[e]():(this.isAtEnd()||this.match("then","and","end","else")||this.advance(),null)}parseIf(){const t=this.match("unless");this.advance();const e=this.parseExpression(),s=this.parseCommandSequence();let n;return this.match("else")&&(this.advance(),n=this.parseCommandSequence()),this.match("end")&&this.advance(),{type:"if",condition:t?{type:"unary",operator:"not",operand:e}:e,body:s,elseBody:n}}parseRepeat(){let t;this.expect("repeat"),this.match("until","while","forever")||(t=this.parseExpression(),this.match("times")&&this.advance());const e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"repeat",condition:t,body:e}}parseFor(){this.expect("for"),this.match("each")&&this.advance();const t=this.advance().value;this.expect("in");const e=this.parseExpression(),s=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"for",condition:{type:"forCondition",variable:t,iterable:e},body:s}}parseWhile(){this.expect("while");const t=this.parseExpression(),e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"while",condition:t,body:e}}parseFetchBlock(){this.expect("fetch");const t=this.parseExpression();let e,s,n={type:"literal",value:"text"};this.match("{")&&(this.pos--,e=this.parseExpression());for(let t=0;3>t;t++)if(!this.match("via")||s)if(this.match("as"))this.advance(),(this.match("a")||this.match("an"))&&this.advance(),n=this.parseExpression();else{if(!this.match("with")||e)break;this.advance(),e=this.parseExpression()}else this.advance(),s=this.parseExpression();return this.match("then")&&this.advance(),{type:"fetch",condition:{type:"fetchConfig",url:t,responseType:n,options:e,method:s},body:this.parseCommandSequence()}}parseToggle(){this.expect("toggle");const t=this.parseExpression();let e;return this.match("on")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"toggle",args:[t],target:e}}parseAdd(){this.expect("add");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"add",args:[t],target:e}}parseRemove(){if(this.expect("remove"),this.matchType("selector")){const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"removeClass",args:[t],target:e}}return{type:"command",name:"remove",args:[],target:this.parseExpression()}}parsePut(){this.expect("put");const t=this.parseExpression();let e="into";if(this.match("into","before","after","at")&&(e=this.advance().value,"at"===e)){const t=this.advance().value;this.expect("of"),e=`at ${t} of`}return{type:"command",name:"put",args:[t],target:this.parseExpression(),modifier:e}}parseAppend(){this.expect("append");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"append",args:[t],target:e}}parseSet(){this.expect("set");const t=this.parseExpression();return this.match("to")?(this.advance(),{type:"command",name:"set",args:[t,this.parseExpression()]}):{type:"command",name:"set",args:[t]}}parseGet(){return this.expect("get"),{type:"command",name:"get",args:[this.parseExpression()]}}parseCall(){return this.expect("call"),{type:"command",name:"call",args:[this.parseExpression()]}}parseLog(){this.expect("log");const t=[];for(;!this.isAtEnd()&&!this.match("then","and","end","else")&&(t.push(this.parseExpression()),this.match(","));)this.advance();return{type:"command",name:"log",args:t}}parseSend(){this.advance();const t=this.advance().value;let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"send",args:[{type:"literal",value:t}],target:e}}parseWait(){if(this.expect("wait"),this.match("for")){this.advance();const t=this.advance().value;let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"waitFor",args:[{type:"literal",value:t}],target:e}}return{type:"command",name:"wait",args:[this.parseExpression()]}}parseShow(){let t;this.expect("show");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"show",args:[],target:t,modifiers:e}}parseHide(){let t;this.expect("hide");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"hide",args:[],target:t,modifiers:e}}parseTake(){this.expect("take");const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"take",args:[t],target:e}}parseIncDec(t){this.advance();const e=this.parseExpression();let s={type:"literal",value:1};return this.match("by")&&(this.advance(),s=this.parseExpression()),{type:"command",name:t,args:[e,s]}}parseFocusBlur(t){let e;return this.advance(),this.isAtEnd()||this.match("then","and","end","else")||(e=this.parseExpression()),{type:"command",name:t,args:[],target:e}}parseGo(){return this.expect("go"),this.match("to")&&this.advance(),this.match("url")&&this.advance(),{type:"command",name:"go",args:[this.parseExpression()]}}parseReturn(){let t;return this.expect("return"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"return",args:t?[t]:[]}}parseHalt(){return this.expect("halt"),this.match("the")&&this.advance(),this.match("event","default")&&this.advance(),{type:"command",name:"halt",args:[]}}parseTransition(){let t;if(this.expect("transition"),this.match("my","its"))t={type:"identifier",value:"my"===this.advance().value?"me":"it"};else if(this.matchType("selector")){const e=this.parseExpression();if("possessive"===e.type)return this.parseTransitionRest(e.object,e.property);t=e}const e=this.peek();let s;return s="styleProperty"===e.type||"identifier"===e.type||"keyword"===e.type?this.advance().value:"opacity",this.parseTransitionRest(t,s)}parseTransitionRest(t,e){let s={type:"literal",value:1};this.match("to")&&(this.advance(),s=this.parseExpression());let n={type:"literal",value:300};return this.match("over")&&(this.advance(),n=this.parseExpression()),{type:"command",name:"transition",args:[{type:"literal",value:e},s,n],target:t}}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.match("or","||");)this.advance(),t={type:"binary",operator:"or",left:t,right:this.parseAnd()};return t}parseAnd(){let t=this.parseEquality();for(;this.match("and","&&")&&!this.isCommandKeyword(this.peek(1));)this.advance(),t={type:"binary",operator:"and",left:t,right:this.parseEquality()};return t}isCommandKeyword(t){return["toggle","add","remove","set","put","log","send","wait","show","hide","increment","decrement","focus","blur","go"].includes(r(t.value))}parseEquality(){let t=this.parseComparison();for(;this.match("==","!=","is","matches","contains","includes","has");){const e=this.advance().value;"is"===e.toLowerCase()&&this.match("not")?(this.advance(),t={type:"binary",operator:"is not",left:t,right:this.parseComparison()}):t={type:"binary",operator:e,left:t,right:this.parseComparison()}}return t}parseComparison(){let t=this.parseAdditive();for(;this.match("<",">","<=",">=");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseAdditive()};return t}parseAdditive(){let t=this.parseMultiplicative();for(;this.match("+","-");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseMultiplicative()};return t}parseMultiplicative(){let t=this.parseUnary();for(;this.match("*","/","%");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseUnary()};return t}parseUnary(){if(this.match("not","!"))return this.advance(),{type:"unary",operator:"not",operand:this.parseUnary()};if(this.match("-")&&"number"===this.peek(1).type){this.advance();const t=this.advance();return{type:"literal",value:-parseFloat(t.value)}}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("'s"))this.advance(),this.peek(),t={type:"possessive",object:t,property:this.advance().value};else if("styleProperty"===this.peek().type)t={type:"possessive",object:t,property:this.advance().value};else if("."===this.peek().value)this.advance(),t={type:"member",object:t,property:this.advance().value};else if("selector"===this.peek().type&&this.peek().value.startsWith("."))t={type:"member",object:t,property:this.advance().value.slice(1)};else if("("===this.peek().value){this.advance();const e=[];for(;!this.match(")");)e.push(this.parseExpression()),this.match(",")&&this.advance();this.expect(")"),t={type:"call",callee:t,args:e}}else{if("["!==this.peek().value||"selector"===t.type)break;{this.advance();const e=this.parseExpression();this.expect("]"),t={type:"member",object:t,property:e,computed:1}}}return t}parsePrimary(){const t=this.peek();if("("===t.value){this.advance();const t=this.parseExpression();return this.expect(")"),t}if("{"===t.value)return this.parseObjectLiteral();if("["===t.value)return this.parseArrayLiteral();if("number"===t.type){this.advance();const e=t.value;return e.endsWith("ms")?{type:"literal",value:parseInt(e),unit:"ms"}:e.endsWith("s")?{type:"literal",value:1e3*parseFloat(e),unit:"ms"}:{type:"literal",value:parseFloat(e)}}if("string"===t.type)return this.advance(),{type:"literal",value:t.value.slice(1,-1)};if(this.match("true"))return this.advance(),{type:"literal",value:1};if(this.match("false"))return this.advance(),{type:"literal",value:0};if(this.match("null"))return this.advance(),{type:"literal",value:null};if(this.match("undefined"))return this.advance(),{type:"literal",value:void 0};if("localVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"local"};if("globalVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"global"};if("selector"===t.type)return this.advance(),{type:"selector",value:t.value};if(this.match("my")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"me"}:{type:"possessive",object:{type:"identifier",value:"me"},property:this.advance().value}}if(this.match("its")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"it"}:{type:"possessive",object:{type:"identifier",value:"it"},property:this.advance().value}}return this.match("me")?(this.advance(),{type:"identifier",value:"me"}):this.match("it")?(this.advance(),{type:"identifier",value:"it"}):this.match("you")?(this.advance(),{type:"identifier",value:"you"}):this.match("the","a","an")?(this.advance(),this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:this.parsePrimary()):this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:this.match("values")?(this.advance(),this.match("of")?(this.advance(),{type:"valuesOf",target:this.parseExpression()}):{type:"identifier",value:t.value}):(this.advance(),{type:"identifier",value:t.value})}parseObjectLiteral(){this.expect("{");const t=[];for(;!this.match("}");){const e=this.advance().value;this.expect(":");const s=this.parseExpression();t.push({key:e,value:s}),this.match(",")&&this.advance()}return this.expect("}"),{type:"object",properties:t}}parseArrayLiteral(){this.expect("[");const t=[];for(;!this.match("]");)t.push(this.parseExpression()),this.match(",")&&this.advance();return this.expect("]"),{type:"array",elements:t}}parsePositionalTarget(){const t=this.peek();return"selector"===t.type?{type:"selector",value:this.advance().value}:"identifier"===t.type||"keyword"===t.type?{type:"identifier",value:this.advance().value}:this.parseExpression()}}const c=new Map,h=new WeakMap;function l(t){let e=h.get(t);return e||(e=new Map,h.set(t,e)),e}const u=1e3;async function f(t,e){switch(t.type){case"literal":return t.value;case"identifier":return"me"===t.value||"my"===t.value?e.me:"it"===t.value?e.it:"you"===t.value?e.you:"event"===t.value?e.event:"body"===t.value?document.body:"document"===t.value?document:"window"===t.value?window:e.locals.has(t.value)?e.locals.get(t.value):t.value in e.me?e.me[t.value]:t.value in window?window[t.value]:t.value;case"variable":if("local"===t.scope)return l(e.me).get(t.name.slice(1));const s=t.name.slice(1);return c.has(s)?c.get(s):window[t.name];case"selector":const n=document.querySelectorAll(t.value);return 1===n.length?n[0]:Array.from(n);case"binary":return async function(t,e){if("has"===t.operator){const s=await f(t.left,e);return s instanceof Element&&"selector"===t.right.type&&t.right.value.startsWith(".")?s.classList.contains(t.right.value.slice(1)):0}const s=await f(t.left,e),n=await f(t.right,e);switch(t.operator){case"+":return s+n;case"-":return s-n;case"*":return s*n;case"/":return s/n;case"%":return s%n;case"==":case"is":return s==n;case"!=":case"is not":return s!=n;case"<":return n>s;case">":return s>n;case"<=":return n>=s;case">=":return s>=n;case"and":case"&&":return s&&n;case"or":case"||":return s||n;case"has":if(s instanceof Element){const t="string"==typeof n?n:n?.value;if("string"==typeof t&&t.startsWith("."))return s.classList.contains(t.slice(1))}return 0;case"contains":case"includes":return"string"==typeof s||Array.isArray(s)?s.includes(n):s instanceof Element?s.contains(n):0;case"matches":return s instanceof Element?s.matches(n):"string"==typeof s?RegExp(n).test(s):0;default:return}}(t,e);case"unary":const i=await f(t.operand,e);return"not"===t.operator?!i:i;case"possessive":case"member":const r=await f(t.object,e);if(null==r)return;const o=t.computed?await f(t.property,e):t.property;return"values"===o&&r instanceof Element?p(r):r[o];case"call":{let s,n=null;if("member"===t.callee.type||"possessive"===t.callee.type){n=await f(t.callee.object,e);const i=t.callee.computed?await f(t.callee.property,e):t.callee.property;s=n?.[i]}else s=await f(t.callee,e);const i=await Promise.all(t.args.map(t=>f(t,e)));return"function"==typeof s?s.apply(n,i):void 0}case"positional":return function(t,e){const s=t.target;let n=[],i=null;switch(("selector"===s.type||"identifier"===s.type||"htmlSelector"===s.type)&&(i=s.value),i&&(n=Array.from(document.querySelectorAll(i))),t.position){case"first":default:return n[0]||null;case"last":return n[n.length-1]||null;case"next":if(i){let t=e.me.nextElementSibling;for(;t;){if(t.matches(i))return t;t=t.nextElementSibling}return null}return e.me.nextElementSibling;case"previous":if(i){let t=e.me.previousElementSibling;for(;t;){if(t.matches(i))return t;t=t.previousElementSibling}return null}return e.me.previousElementSibling;case"closest":return i?e.me.closest(i):null;case"parent":if(i){let t=e.me.parentElement;for(;t;){if(t.matches(i))return t;t=t.parentElement}return null}return e.me.parentElement}}(t,e);case"object":const a={};for(const s of t.properties)a[s.key]=await f(s.value,e);return a;case"array":return Promise.all(t.elements.map(t=>f(t,e)));case"valuesOf":{const s=await f(t.target,e);return s instanceof Element?p(s):new FormData}default:return}}function p(t){if(t instanceof HTMLFormElement)return new FormData(t);const e=new FormData;return t.querySelectorAll("input, select, textarea").forEach(t=>{const s=t.getAttribute("name");s&&"value"in t&&e.append(s,t.value)}),e}async function d(t,e){const s=async()=>{if(!t.target)return[e.me];const s=await f(t.target,e);return Array.isArray(s)?s:s instanceof Element?[s]:"string"==typeof s?Array.from(document.querySelectorAll(s)):[e.me]},n=t=>{if(!t)return"";if("selector"===t.type)return t.value.startsWith("@")?t.value:t.value.slice(1);if("string"===t.type||"literal"===t.type){const e=t.value;return"string"==typeof e&&e.startsWith(".")?e.slice(1):e+""}return"identifier"===t.type?t.value:""},i=t=>Array.isArray(t)?t.filter(t=>t instanceof Element):t instanceof Element?[t]:"string"==typeof t?Array.from(document.querySelectorAll(t)):[],r=t=>t.startsWith("*"),o=t=>t.substring(1),a=(t,e,s)=>r(e)?(t.style.setProperty(o(e),s+""),1):0,h=(t,e)=>{if(r(e))return getComputedStyle(t).getPropertyValue(o(e))};switch(t.name){case"toggle":{const i=n(t.args[0])||await f(t.args[0],e)+"",r=await s();if(i.startsWith("@")){const t=i.slice(1);for(const e of r)e.hasAttribute(t)?e.removeAttribute(t):e.setAttribute(t,"")}else for(const t of r)t.classList.toggle(i);return e.it=1===r.length?r[0]:r,e.it}case"add":{const i=n(t.args[0])||await f(t.args[0],e)+"",r=await s();if(i.startsWith("@")){const t=i.slice(1);for(const e of r)e.setAttribute(t,"")}else for(const t of r)t.classList.add(i);return e.it=1===r.length?r[0]:r,e.it}case"removeClass":{const i=n(t.args[0])||await f(t.args[0],e)+"",r=await s();if(i.startsWith("@")){const t=i.slice(1);for(const e of r)e.removeAttribute(t)}else for(const t of r)t.classList.remove(i);return e.it=1===r.length?r[0]:r,e.it}case"remove":{const t=await s();for(const e of t)e.remove();return null}case"put":{const n=await f(t.args[0],e),o=t.modifier||"into";if("possessive"===t.target?.type&&r(t.target.property)){const s=i(await f(t.target.object,e));for(const e of s)a(e,t.target.property,n);return e.it=n,n}const c=await s();for(const t of c){const e=n+"";"into"===o?t.innerHTML=e:"before"===o?t.insertAdjacentHTML("beforebegin",e):"after"===o?t.insertAdjacentHTML("afterend",e):"at start of"===o?t.insertAdjacentHTML("afterbegin",e):"at end of"===o&&t.insertAdjacentHTML("beforeend",e)}return e.it=n,n}case"append":{const n=await f(t.args[0],e),i=await s();for(const t of i)t.insertAdjacentHTML("beforeend",n+"");return e.it=n,n}case"set":{const s=t.args[0],n=await f(t.args[1],e);if("variable"===s.type){const t=s.name.slice(1);return("local"===s.scope?l(e.me):c).set(t,n),e.it=n,n}if("possessive"===s.type||"member"===s.type){const t=await f(s.object,e);if(t)return t instanceof Element&&a(t,s.property,n)?(e.it=n,n):(t[s.property]=n,e.it=n,n)}return e.it=n,n}case"get":{const s=await f(t.args[0],e);return e.it=s,s}case"call":{const s=await f(t.args[0],e);return e.it=s,s}case"log":{const s=await Promise.all(t.args.map(t=>f(t,e)));return console.log(...s),s[0]}case"send":{const n=await f(t.args[0],e),i=await s(),r=new CustomEvent(n+"",{bubbles:1,detail:e.it});for(const t of i)t.dispatchEvent(r);return e.it=r,r}case"wait":{const s=await f(t.args[0],e),n="number"==typeof s?s:parseInt(s+"");return await new Promise(t=>setTimeout(t,n)),n}case"waitFor":{const n=await f(t.args[0],e),i=(await s())[0]||e.me;return new Promise(t=>{i.addEventListener(n+"",s=>{e.it=s,t(s)},{once:1})})}case"show":{const t=await s();for(const e of t)e.style.display="",e.classList.remove("hidden");return t}case"hide":{const t=await s();for(const e of t)e.style.display="none";return t}case"transition":{const n=(await f(t.args[0],e)+"").replace(/^\*/,""),i=await f(t.args[1],e),r=await f(t.args[2],e),o="number"==typeof r?r:(r+"").endsWith("ms")?parseInt(r+""):(r+"").endsWith("s")?1e3*parseFloat(r+""):parseInt(r+"")||300,a=await s(),c=[];for(const t of a){const e=t,s=n.replace(/([A-Z])/g,"-$1").toLowerCase(),r=e.style.transition;e.style.transition=`${s} ${o}ms ease`,e.style.setProperty(s,i+""),c.push(new Promise(t=>{const n=()=>{e.style.transition=r,t()},i=t=>{t.propertyName===s&&(e.removeEventListener("transitionend",i),n())};e.addEventListener("transitionend",i),setTimeout(n,o+50)}))}return await Promise.all(c),e.it=1===a.length?a[0]:a,e.it}case"take":{const i=n(await f(t.args[0],e)),r=t.target?await s():[e.me.parentElement];for(const t of r)t.querySelectorAll("."+i).forEach(t=>t.classList.remove(i));return e.me.classList.add(i),e.me}case"increment":case"decrement":{const s=t.args[0],n=await f(t.args[1],e),o="increment"===t.name?n:-n;if("variable"===s.type){const t=s.name.slice(1),n="local"===s.scope?l(e.me):c,i=(n.get(t)||0)+o;return n.set(t,i),e.it=i,i}if("possessive"===s.type&&r(s.property)){const t=i(await f(s.object,e));for(const n of t){const t=(parseFloat(h(n,s.property)||"0")||0)+o;a(n,s.property,t),e.it=t}return e.it}const u=i(await f(s,e));for(const t of u){const s=(parseFloat(t.textContent||"0")||0)+o;t.textContent=s+"",e.it=s}return e.it}case"focus":{const t=await s();for(const e of t)e.focus();return t}case"blur":{const t=await s();for(const e of t)e.blur();return t}case"go":{const s=await f(t.args[0],e),n=(s+"").toLowerCase();return"back"===n?history.back():"forward"===n?history.forward():window.location.href=s+"",null}case"return":throw{type:"return",value:t.args[0]?await f(t.args[0],e):e.it};case"halt":return e.event&&(e.event.preventDefault(),e.event.stopPropagation()),null;default:return console.warn("Unknown command: "+t.name),null}}async function m(t,e){try{return await w(t,e)}catch(t){if("return"===t?.type)throw t;throw t}}async function y(t,e){switch(t.type){case"if":return await f(t.condition,e)?m(t.body,e):t.elseBody?m(t.elseBody,e):null;case"repeat":{const s=await f(t.condition,e),n="number"==typeof s?s:parseInt(s+"");for(let s=0;n>s&&u>s;s++)e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await m(t.body,e);return null}case"for":{const{variable:s,iterable:n}=t.condition,i=await f(n,e),r=Array.isArray(i)?i:i instanceof NodeList?Array.from(i):[i],o=s.startsWith(":")?s.slice(1):s;for(let s=0;r.length>s&&u>s;s++)e.locals.set(o,r[s]),e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await m(t.body,e);return null}case"while":{let s=0;for(;await f(t.condition,e)&&u>s;)e.locals.set("__loop_index__",s),await m(t.body,e),s++;return null}case"fetch":{const{url:s,responseType:n,options:i,method:r}=t.condition;try{const o=await f(s,e),a={};if(r){const t=await f(r,e);a.method=(t+"").toUpperCase()}if(i){const t=await f(i,e);t instanceof FormData?a.body=t:!t||"object"!=typeof t||t instanceof Element||Object.assign(a,t)}const c=await fetch(o+"",a);if(!c.ok)throw Error("HTTP "+c.status);const h=await f(n,e);let l;if("json"===h)l=await c.json();else if("html"===h){const t=await c.text();l=(new DOMParser).parseFromString(t,"text/html").body.innerHTML}else l=await c.text();e.it=l,e.locals.set("it",l),e.locals.set("result",l),e.locals.set("response",c),await m(t.body,e)}catch(t){if("return"===t?.type)throw t;e.locals.set("error",t),console.error("Fetch error:",t)}return null}default:return null}}async function w(t,e){let s;for(const n of t)"command"===n.type?s=await d(n,e):["if","repeat","for","while","fetch"].includes(n.type)&&(s=await y(n,e));return s}async function g(t,e,s){const n={me:e,event:s,locals:new Map,globals:c};if("sequence"===t.type)return w(t.commands,n);if("event"===t.type){const s=t,i=s.event;if(i.startsWith("interval:")){const t=i.split(":")[1],n=t.endsWith("ms")?parseInt(t):t.endsWith("s")?1e3*parseFloat(t):parseInt(t);return void setInterval(async()=>{const t={me:e,locals:new Map,globals:c};try{await w(s.body,t)}catch(t){if("return"!==t?.type)throw t}},n)}if("init"===i){try{await w(s.body,n)}catch(t){if("return"!==t?.type)throw t}return}const r=s.filter?await f(s.filter,n):e,o=r instanceof Element?r:e,a=s.modifiers;let h=async t=>{a.prevent&&t.preventDefault(),a.stop&&t.stopPropagation();const n={me:e,event:t,you:t.target instanceof Element?t.target:void 0,locals:new Map,globals:c};try{await w(s.body,n)}catch(t){if("return"===t?.type)return t.value;throw t}};if(a.debounce){let t;const e=h;h=async s=>{clearTimeout(t),t=setTimeout(()=>e(s),a.debounce)}}if(a.throttle){let t=0;const e=h;h=async s=>{const n=Date.now();a.throttle>n-t||(t=n,await e(s))}}return void o.addEventListener(i,h,{once:!!a.once})}return null}function b(t){const e=t.getAttribute("_");if(e)try{g(new a(e).parse(),t)}catch(t){console.error("HyperFixi Hybrid Complete error:",t,"Code:",e)}}function v(t=document){t.querySelectorAll("[_]").forEach(b)}const x={version:"1.0.0-hybrid-complete",parse:t=>new a(t).parse(),async execute(t,e){const s=e||document.body;return g(new a(t).parse(),s)},init:v,process:v,addAliases:function(t){Object.assign(n,t)},addEventAliases:function(t){Object.assign(i,t)},tokenize:s,evaluate:f,commands:["toggle","add","remove","put","append","set","get","call","log","send","trigger","wait","show","hide","transition","take","increment","decrement","focus","blur","go","return","halt"],blocks:["if","else","unless","repeat","for","while","fetch"]};"undefined"!=typeof window&&(window.hyperfixi=x,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>v()):v());let E={nameOf:(t,e,s)=>`${e}-${s}`,selectorFor:(t,e)=>`[${t}-${e}]`,eventNameOf:(t,e)=>e};function $(){return E}const M={innerHTML:"innerHTML",outerHTML:"outerHTML",beforebegin:"before",afterbegin:"start",beforeend:"end",afterend:"after",delete:"delete",none:"none",morph:"morph","morph:innerHTML":"innerHTML morph","morph:outerHTML":"morph"},k={click:"click",load:"init",revealed:"intersection",intersect:"intersection",submit:"submit",change:"change",input:"input",keyup:"keyup",keydown:"keydown",focus:"focus",blur:"blur",mouseenter:"mouseenter",mouseleave:"mouseleave"};function S(t){if("this"===t)return"me";const e=t.match(/^closest\s+(.+)$/);if(e)return`closest <${e[1]}/>`;const s=t.match(/^find\s+(.+)$/);if(s)return`first <${s[1]}/> in me`;const n=t.match(/^next\s+(.+)$/);if(n)return`next <${n[1]}/>`;const i=t.match(/^previous\s+(.+)$/);return i?`previous <${i[1]}/>`:t}function T(t,e){const s=[];if(t.hxLive&&s.push(`live\n ${t.hxLive}\nend`),!t.url)return s.join("\n");const n=[],i=t.trigger||function(t){const e=t.tagName.toLowerCase();if("form"===e)return"submit";if("input"===e||"textarea"===e||"select"===e){const e=t.getAttribute("type");return"submit"===e||"button"===e?"click":"change"}return"click"}(e),{event:r,modifiers:o}=function(t,e){const s=t.trim().split(/\s+/),n=s[0],i=s.slice(1),r=n.match(/^(\w+)\[(.+)\]$/);if(r){const t=e(r[1]);return{event:k[t]||t,modifiers:["filter: "+r[2],...i]}}const o=e(n);return{event:k[o]||o,modifiers:i}}(i,t=>$().eventNameOf(e,t)),a=function(t){const e=[];for(const s of t){const t=s.match(/^delay:(\d+)(ms|s)?$/);if(t){e.push(`.debounce(${t[1]}${"s"===(t[2]||"ms")?"000":""})`);continue}const n=s.match(/^throttle:(\d+)(ms|s)?$/);n?e.push(`.throttle(${n[1]}${"s"===(n[2]||"ms")?"000":""})`):"once"!==s||e.push(".once")}return e.join("")}(o);t.confirm&&n.push(`if not js window.confirm('${t.confirm.replace(/'/g,"\\'")}') return end`);const c=e.tagName.toLowerCase();"form"!==c&&"a"!==c||n.push("halt the event");let h=`fetch '${t.url}'`;t.method&&"GET"!==t.method&&(h+=" via "+t.method),"form"===c?h+=" with values of me":t.vals&&(h+=" with "+t.vals),h+=" as html",n.push(h);const l=function(t,e){const s=M[e]||e;return"none"===s?"":"delete"===s?"remove "+t:"before"===s?"put it before "+t:"after"===s?"put it after "+t:"start"===s?"put it at start of "+t:"end"===s?"put it at end of "+t:"morph"===s?`morph ${t} with it`:"innerHTML morph"===s?`morph innerHTML of ${t} with it`:"outerHTML"===s?`set ${t}'s outerHTML to it`:"put it into "+t}(t.target?S(t.target):"me",t.swap||"innerHTML");l&&n.push("then "+l),t.pushUrl?n.push(`then push url '${1==t.pushUrl?t.url:t.pushUrl}'`):t.replaceUrl&&n.push(`then replace url '${1==t.replaceUrl?t.url:t.replaceUrl}'`);const u=`on ${r}${a}\n ${n.join("\n ")}`;return s.push(u),s.join("\n")}function H(t){const e=t.attributes;for(let t=0;e.length>t;t++)if(e[t].name.startsWith("hx-"))return 1;return 0}function A(t){return t.hasAttribute("fx-action")}function _(t){return H(t)||A(t)}const q=new Set(["add","append","async","beep","blur","break","breakpoint","call","clear","close","continue","copy","decrement","default","empty","exit","fetch","focus","for","get","go","halt","hide","open","if","increment","install","js","log","make","measure","morph","pick","process","push","put","remove","render","repeat","replace","reset","return","scroll","select","send","set","settle","show","start","swap","take","tell","throw","toggle","transition","trigger","unless","wait"]),C=new Set(["==","!=","===","!==","<",">","<=",">=","is","is not","am","is a","is an","is not a","is not an","precedes","does not precede","follows","does not follow","contains","starts with","ends with","does not start with","does not end with","has","have","does not contain","include","includes","does not include","match","matches","exists","does not exist","is empty","is not empty","is in","is not in","is between","is not between","equals","in","is equal to","is really equal to","is not equal to","is not really equal to","is greater than","is less than","is greater than or equal to","is less than or equal to","really equals","am in","am not in","am between","am not between","is really","is not really","is equal","is not equal","contain","do not contain","does not contains","do not match","does not match","ignoring case","sorted by","mapped to","split by","joined by"]);function L(t,e){return{infix:{bp:[t,t+1],handler:e??((e,s,n)=>{const i=n.parseExpr(t+1);return{type:"binaryExpression",operator:s.value,left:e,right:i,start:e.start,end:i.end??s.end,line:e.line??s.line,column:e.column??s.column}})}}}function O(t,e){return{infix:{bp:[t+1,t],handler:(e,s,n)=>{const i=n.parseExpr(t);return{type:"binaryExpression",operator:s.value,left:e,right:i,start:e.start,end:i.end??s.end,line:e.line??s.line,column:e.column??s.column}}}}}function F(t,e){return{prefix:{bp:t,handler:e??((e,s)=>{const n=s.parseExpr(t);return{type:"unaryExpression",operator:e.value,operand:n,argument:n,prefix:1,start:e.start,end:n.end??e.end,line:e.line,column:e.column}})}}}function P(t){return(e,s,n)=>{const i=n.advance();if(!i||!i.value)throw Error(`Type check requires a type name after 'is ${t?"not ":""}a/an', got: <end>`);let r=1;const o=n.peek();return o&&"!"===o.value&&(n.advance(),r=0),{type:"typeCheckExpression",value:e,typeName:i.value,nullOk:r,negated:t,start:e.start,end:i.end}}}const j=function(...t){const e=new Map;for(const s of t)for(const[t,n]of s){const s=e.get(t);e.set(t,s?{prefix:n.prefix??s.prefix,infix:n.infix??s.infix}:{...n})}return e}(new Map([["or",L(10)],["||",L(10)],["and",L(20)],["&&",L(20)],["==",L(30)],["!=",L(30)],["<",L(30)],[">",L(30)],["<=",L(30)],[">=",L(30)],["is",L(30)],["matches",L(30)],["contains",L(30)],["starts with",L(30)],["ends with",L(30)],["does not start with",L(30)],["does not end with",L(30)],["is between",L(30,(t,e,s)=>{const n=s.parseExpr(31),i=s.peek();if(!i||"and"!==i.value.toLowerCase())throw Error("between requires 'and' between min and max operands, got: "+(i?.value??"<end>"));s.advance();const r=s.parseExpr(31);return{type:"betweenExpression",value:t,min:n,max:r,negated:0,start:t.start,end:r.end}})],["is not between",L(30,(t,e,s)=>{const n=s.parseExpr(31),i=s.peek();if(!i||"and"!==i.value.toLowerCase())throw Error("between requires 'and' between min and max operands, got: "+(i?.value??"<end>"));s.advance();const r=s.parseExpr(31);return{type:"betweenExpression",value:t,min:n,max:r,negated:1,start:t.start,end:r.end}})],["am between",L(30,(t,e,s)=>{const n=s.parseExpr(31),i=s.peek();if(!i||"and"!==i.value.toLowerCase())throw Error("between requires 'and' between min and max operands, got: "+(i?.value??"<end>"));s.advance();const r=s.parseExpr(31);return{type:"betweenExpression",value:t,min:n,max:r,negated:0,start:t.start,end:r.end}})],["am not between",L(30,(t,e,s)=>{const n=s.parseExpr(31),i=s.peek();if(!i||"and"!==i.value.toLowerCase())throw Error("between requires 'and' between min and max operands, got: "+(i?.value??"<end>"));s.advance();const r=s.parseExpr(31);return{type:"betweenExpression",value:t,min:n,max:r,negated:1,start:t.start,end:r.end}})],["ignoring case",{infix:{bp:[25,26],handler:(t,e,s)=>(t.ignoringCase=1,t)}}],["where",L(28,(t,e,s)=>{const n=s.parseExpr(29);return{type:"collectionExpression",operator:"where",collection:t,right:n,start:t.start,end:n.end}})],["sorted by",L(28,(t,e,s)=>{const n=s.parseExpr(29);let i="asc";const r=s.peek();if(r&&"string"==typeof r.value){const t=r.value.toLowerCase();"asc"===t||"ascending"===t?(s.advance(),i="asc"):"desc"!==t&&"descending"!==t||(s.advance(),i="desc")}return{type:"collectionExpression",operator:"sorted by",collection:t,right:n,order:i,start:t.start,end:n.end}})],["mapped to",L(28,(t,e,s)=>{const n=s.parseExpr(29);return{type:"collectionExpression",operator:"mapped to",collection:t,right:n,start:t.start,end:n.end}})],["split by",L(28,(t,e,s)=>{const n=s.parseExpr(29);return{type:"collectionExpression",operator:"split by",collection:t,right:n,start:t.start,end:n.end}})],["joined by",L(28,(t,e,s)=>{const n=s.parseExpr(29);return{type:"collectionExpression",operator:"joined by",collection:t,right:n,start:t.start,end:n.end}})],["+",{...L(40),...F(80)}],["-",{...L(40),...F(80)}],["*",L(50)],["/",L(50)],["%",L(50)],["mod",L(50)],["^",O(60)],["**",O(60)],["as",L(70,(t,e,s)=>{const n=()=>{const t=s.peek();!t||"a"!==t.value&&"an"!==t.value||s.advance();const e=s.parseExpr(71),n=s.peek();if(n&&":"===n.value&&e&&"identifier"===e.type){s.advance();const t=s.advance();t&&void 0!==t.value&&(e.name=`${e.name}:${t.value}`,e.end=t.end)}return e};let i=n(),r={type:"asExpression",expression:t,targetType:i,start:t.start,end:i.end??e.end,line:t.line??e.line,column:t.column??e.column};for(;s.peek()&&"|"===s.peek().value;){s.advance();const t=n();r={type:"asExpression",expression:r,targetType:t,start:r.start,end:t.end??r.end,line:r.line,column:r.column}}return r})],["not",F(80)],["!",F(80)],["no",F(27)]]),new Map([["===",L(30)],["!==",L(30)],["is not",L(30)],["am",L(30)],["is in",L(30)],["is not in",L(30)],["precedes",L(30)],["does not precede",L(30)],["follows",L(30)],["does not follow",L(30)],["is a",L(30,P(0))],["is an",L(30,P(0))],["is not a",L(30,P(1))],["is not an",L(30,P(1))],["has",L(30)],["have",L(30)],["match",L(30)],["include",L(30)],["includes",L(30)],["equals",L(30)],["does not contain",L(30)],["does not include",L(30)],["am in",L(30)],["am not in",L(30)],["is really",L(30)],["is not really",L(30)],["is equal",L(30)],["is not equal",L(30)],["contain",L(30)],["do not contain",L(30)],["does not contains",L(30)],["do not match",L(30)],["does not match",L(30)],["is equal to",L(30)],["is not equal to",L(30)],["is really equal to",L(30)],["is not really equal to",L(30)],["really equals",L(30)],["is greater than",L(30)],["is less than",L(30)],["is greater than or equal to",L(30)],["is less than or equal to",L(30)],["in",L(30)],["of",O(30)],["really",L(30)],["exists",{prefix:{bp:80,handler:(t,e)=>({type:"unaryExpression",operator:t.value,operand:e.parseExpr(80),start:t.start})},infix:{bp:[30,31],handler:(t,e)=>({type:"unaryExpression",operator:e.value,operand:t,prefix:0,start:t.start})}}],["does not exist",{infix:{bp:[30,31],handler:(t,e)=>({type:"unaryExpression",operator:e.value,operand:t,prefix:0,start:t.start})}}],["is empty",{infix:{bp:[30,31],handler:(t,e)=>({type:"unaryExpression",operator:e.value,operand:t,prefix:0,start:t.start})}}],["is not empty",{infix:{bp:[30,31],handler:(t,e)=>({type:"unaryExpression",operator:e.value,operand:t,prefix:0,start:t.start})}}],["some",F(80)]]),new Map([["=",O(5)]])),W=new Map,R=new Map,D=new Map,I=new Set,G=new Set,N=new Set,z=new Set,Z=new class{registerCommand(t){q.add(t.toLowerCase())}registerCompoundOperator(t){C.add(t.toLowerCase())}registerInfixOperator(t,e,s,n){const i=t.toLowerCase(),r=j.get(i);j.set(i,{...r??{},infix:{bp:[e,s],handler:n}})}registerPrefixOperator(t,e,s){const n=t.toLowerCase(),i=j.get(n);j.set(n,{...i??{},prefix:{bp:e,handler:s}})}hasCommand(t){return q.has(t.toLowerCase())}registerFeature(t,e){W.set(t.toLowerCase(),e)}hasFeature(t){return W.has(t.toLowerCase())}registerNodeEvaluator(t,e){R.set(t,e)}registerNodeWriter(t,e){D.set(t,e)}registerGlobalWriteHook(t){return I.add(t),()=>I.delete(t)}registerGlobalReadHook(t){return G.add(t),()=>G.delete(t)}registerLocalWriteHook(t){return N.add(t),()=>N.delete(t)}registerLocalReadHook(t){return z.add(t),()=>z.delete(t)}snapshot(){return{commands:Array.from(q),operators:Array.from(C),prattEntries:Array.from(j.entries()).map(([t,e])=>[t,{...e}]),features:Array.from(W.entries()),nodeEvaluators:Array.from(R.entries()),nodeWriters:Array.from(D.entries()),globalWriteHooks:Array.from(I),globalReadHooks:Array.from(G),localWriteHooks:Array.from(N),localReadHooks:Array.from(z)}}restore(t){q.clear();for(const e of t.commands)q.add(e);C.clear();for(const e of t.operators)C.add(e);j.clear();for(const[e,s]of t.prattEntries)j.set(e,s);W.clear();for(const[e,s]of t.features)W.set(e,s);R.clear();for(const[e,s]of t.nodeEvaluators)R.set(e,s);D.clear();for(const[e,s]of t.nodeWriters??[])D.set(e,s);I.clear();for(const e of t.globalWriteHooks)I.add(e);G.clear();for(const e of t.globalReadHooks??[])G.add(e);N.clear();for(const e of t.localWriteHooks??[])N.add(e);z.clear();for(const e of t.localReadHooks??[])z.add(e)}},B="__hyperfixi_parser_extension_registry__";class J{constructor(t,e,s,n={}){this.element=t,this.url=e,this.swapHandler=s,this.source=null,this.listeners=new Map,this.destroyed=0,this.reconnectAttempts=0,this.reconnectTimer=null,this.maxAttempts=n.maxAttempts??5,this.baseBackoffMs=n.baseBackoffMs??1e3,this.maxBackoffMs=n.maxBackoffMs??3e4,this.debug=n.debug??0,this.EventSourceCtor=n.EventSourceCtor??("undefined"!=typeof EventSource?EventSource:null),this.EventSourceCtor?this.open():this.debug&&void 0!==console&&console.warn("[sse] EventSource is not available in this environment")}listenFor(t){if(this.destroyed)return;if(this.listeners.has(t))return;const e=t=>{this.swapHandler(t.type,t.data)};this.listeners.set(t,e),this.source&&this.source.addEventListener(t,e)}detach(){this.destroyed||(this.destroyed=1,null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.closeSource(),this.dispatch("htmx:sseClose",{url:this.url}))}get readyState(){return this.source?.readyState??-1}open(){if(!this.destroyed){try{this.source=new this.EventSourceCtor(this.url)}catch(t){return this.dispatch("htmx:sseError",{url:this.url,error:t}),void this.scheduleReconnect()}this.source.onopen=()=>{this.reconnectAttempts=0,this.dispatch("htmx:sseOpen",{url:this.url})},this.source.onmessage=t=>{this.dispatch("htmx:sseMessage",{url:this.url,data:t.data})},this.source.onerror=t=>{this.dispatch("htmx:sseError",{url:this.url,event:t}),this.source&&2===this.source.readyState&&(this.closeSource(),this.scheduleReconnect())};for(const[t,e]of this.listeners)this.source.addEventListener(t,e)}}closeSource(){if(this.source){for(const[t,e]of this.listeners)try{this.source.removeEventListener(t,e)}catch{}this.source.onopen=null,this.source.onmessage=null,this.source.onerror=null;try{this.source.close()}catch{}this.source=null}}scheduleReconnect(){if(this.destroyed)return;if(this.reconnectAttempts>=this.maxAttempts)return this.debug&&void 0!==console&&console.warn(`[sse] giving up after ${this.maxAttempts} reconnect attempts to ${this.url}`),void this.detach();const t=Math.min(this.baseBackoffMs*Math.pow(2,this.reconnectAttempts),this.maxBackoffMs);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.open()},t)}dispatch(t,e){if("undefined"!=typeof CustomEvent)try{const s=new CustomEvent(t,{detail:e,bubbles:1,cancelable:0});this.element.dispatchEvent(s)}catch{}}}class V{constructor(t,e,s,n={}){this.element=t,this.url=e,this.swapHandler=s,this.socket=null,this.destroyed=0,this.reconnectAttempts=0,this.reconnectTimer=null,this.outboundQueue=[],this.maxAttempts=n.maxAttempts??5,this.baseBackoffMs=n.baseBackoffMs??1e3,this.maxBackoffMs=n.maxBackoffMs??3e4,this.debug=n.debug??0,this.protocols=n.protocols,this.WSCtor=n.WSEventSourceCtor??("undefined"!=typeof WebSocket?WebSocket:null),this.WSCtor?this.open():this.debug&&void 0!==console&&console.warn("[ws] WebSocket is not available in this environment")}get readyState(){return this.socket?.readyState??-1}get isDestroyed(){return this.destroyed}send(t){if(this.destroyed)return;const e="string"==typeof t?t:JSON.stringify(t);this.socket&&1===this.socket.readyState?this.socket.send(e):this.outboundQueue.push(e)}detach(){this.destroyed||(this.destroyed=1,null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.closeSocket(),this.dispatch("htmx:wsClose",{url:this.url,code:1e3,reason:"detached"}))}open(){if(!this.destroyed){try{this.socket=new this.WSCtor(this.url,this.protocols)}catch(t){return this.dispatch("htmx:wsError",{url:this.url,error:t}),void this.scheduleReconnect()}this.socket.onopen=()=>{if(this.reconnectAttempts=0,this.dispatch("htmx:wsOpen",{url:this.url}),this.outboundQueue.length&&this.socket){for(const t of this.outboundQueue)try{this.socket.send(t)}catch(t){this.dispatch("htmx:wsError",{url:this.url,error:t})}this.outboundQueue=[]}},this.socket.onmessage=t=>{const e="string"==typeof t.data?t.data:t.data+"",s=function(t){if(!t||"{"!==t[0])return null;let e;try{e=JSON.parse(t)}catch{return null}return"object"!=typeof e||null===e||"string"!=typeof e.target||"string"!=typeof e.data?null:{target:e.target,swap:"string"==typeof e.swap?e.swap:void 0,data:e.data}}(e);s?this.swapHandler(s,s.data):this.dispatch("htmx:wsMessage",{url:this.url,data:e})},this.socket.onerror=t=>{this.dispatch("htmx:wsError",{url:this.url,event:t})},this.socket.onclose=t=>{this.dispatch("htmx:wsClose",{url:this.url,code:t.code,reason:t.reason}),this.socket=null,this.destroyed||t.wasClean||this.scheduleReconnect()}}}closeSocket(){if(this.socket){this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null;try{this.socket.close(1e3,"detached")}catch{}this.socket=null}}scheduleReconnect(){if(this.destroyed)return;if(this.reconnectAttempts>=this.maxAttempts)return this.debug&&void 0!==console&&console.warn(`[ws] giving up after ${this.maxAttempts} reconnect attempts to ${this.url}`),void this.detach();const t=Math.min(this.baseBackoffMs*Math.pow(2,this.reconnectAttempts),this.maxBackoffMs);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.open()},t)}dispatch(t,e){if("undefined"!=typeof CustomEvent)try{const s=new CustomEvent(t,{detail:e,bubbles:1,cancelable:0});this.element.dispatchEvent(s)}catch{}}}function U(t){if("undefined"!=typeof HTMLFormElement&&t instanceof HTMLFormElement){const e=new FormData(t),s={};for(const[t,n]of e.entries())s[t]="string"==typeof n?n:n.name;return s}const e=t.getAttribute("name"),s=t.value;return e&&void 0!==s?{[e]:s+""}:{}}function K(t){return t?t.split(/[-_]/)[0].toLowerCase():"en"}function Q(t){const e=t.getAttribute?.("data-hyperfixi-lang");if(e)return K(e);const s=t.closest?.("[data-hyperfixi-lang]");if(s)return K(s.getAttribute("data-hyperfixi-lang"));const n=t.closest?.("[lang]");return n?K(n.getAttribute("lang")):"en"}const X=new Map,Y=new Map,tt=new Set;let et=0;const st=new Set;function nt(){const t=new Set;for(const e of Y.values())for(const s of e.values())t.add(s);return[...t]}function it(t,e){const s=K(t),n=e?.hyperfixi??{};var i;X.set(s,n),Y.set(s,function(t){const e=new Map;if(!t)return e;for(const[s,n]of Object.entries(t))e.set(n,s);return e}(n.attrs)),tt.delete(s),et||(i={nameOf:(t,e,s)=>{const n=`${e}-${s}`,i=Q(t);if("en"===i)return n;const r=Y.get(i)?.get(n);return r||(X.has(i)||tt.has(i)||(tt.add(i),void 0!==console&&console.warn(`[hyperfixi-i18n] No vocab registered for lang="${i}". Elements in this language scope fall back to English attribute names. Load packages/core/dist/i18n/htmx/${i}.js to opt in.`)),n)},selectorFor:(t,e)=>{const s=`${t}-${e}`,n=new Set([s]);for(const t of Y.values()){const e=t.get(s);e&&n.add(e)}return[...n].map(t=>`[${t}]`).join(", ")},eventNameOf:(t,e)=>{const s=Q(t);return"en"===s?e:X.get(s)?.events?.[e]??e}},E=i,et=1);for(const t of st)t()}const rt="__hyperfixi_i18n";function ot(){if("undefined"==typeof window)return;const t=window;t[rt]||(t[rt]={register:it})}function at(t){for(const e of function(){const t=new Set(["hx-on:"]);for(const e of Y.values()){const s=e.get("hx-on");s&&t.add(s+":")}return[...t]}())if(t.startsWith(e))return t.slice(e.length);return null}ot();const ct=["get","post","put","patch","delete","target","swap","trigger","confirm","boost","vals","headers","push-url","replace-url","on","live"].filter(t=>"on"!==t).map(t=>"hx-"+t).concat(["sse-swap","ws-send"]),ht=["live"],lt=["fx-action","fx-method","fx-trigger","fx-target","fx-swap","fx-ignore"],ut=[...ct,...lt];function ft(t,e,s){return t.getAttribute($().nameOf(t,e,s))}function pt(t,e,s){return t.hasAttribute($().nameOf(t,e,s))}class dt{getSwapTemplate(t,e){const s=`${e.target??"me"}|${e.swap??"innerHTML"}`,n=this.swapTemplateCache.get(t);if(n&&n.sig===s)return n.build;const i=function(t){const e=t.swap??"innerHTML",s=S(t.target??"me");switch(e){case"outerHTML":return t=>`set ${s}'s outerHTML to ${t}`;case"beforebegin":return t=>`put ${t} before ${s}`;case"afterend":return t=>`put ${t} after ${s}`;case"afterbegin":return t=>`put ${t} at start of ${s}`;case"beforeend":return t=>`put ${t} at end of ${s}`;case"none":return()=>"";case"delete":return()=>"remove "+s;default:return t=>`put ${t} into ${s}`}}(e);return this.swapTemplateCache.set(t,{sig:s,build:i}),i}dispatchLifecycleEvent(t,e,s,n={}){const i=new CustomEvent(e,{detail:s,bubbles:n.bubbles??1,cancelable:n.cancelable??1}),r=t.dispatchEvent(i);return!r&&this.options.debug&&console.log(`[${n.debugPrefix??"htmx"}-compat] ${e} cancelled`),r}constructor(t={}){this.observer=null,this.processedElements=new WeakSet,this.executeCallback=null,this.pendingRequests=new WeakMap,this.sseConnections=new WeakMap,this.sseConnectionsSet=new Set,this.wsConnections=new WeakMap,this.wsConnectionsSet=new Set,this.wsSendListeners=new WeakMap,this.onHandlerListeners=new WeakMap,this.onHandlerElements=new Set,this.localizedAttrSet=new Set,this.unsubscribeVocab=null,this.swapTemplateCache=new WeakMap,this.options={processExisting:t.processExisting??1,watchMutations:t.watchMutations??1,debug:t.debug??0,root:t.root??("undefined"!=typeof document?document.body:null),requestDropping:t.requestDropping??1,fixiEvents:t.fixiEvents??1,eventSourceCtor:t.eventSourceCtor,wsEventSourceCtor:t.wsEventSourceCtor},this.eventSourceCtor=t.eventSourceCtor,this.wsEventSourceCtor=t.wsEventSourceCtor}init(t){this.executeCallback=t,this.options.processExisting&&this.options.root&&this.processSubtree(this.options.root),this.options.watchMutations&&"undefined"!=typeof MutationObserver&&this.options.root&&this.startObserver()}destroy(){this.unsubscribeVocab&&(this.unsubscribeVocab(),this.unsubscribeVocab=null),this.observer&&(this.observer.disconnect(),this.observer=null);for(const t of this.sseConnectionsSet)t.detach();this.sseConnectionsSet.clear();for(const t of this.wsConnectionsSet)t.detach();this.wsConnectionsSet.clear();for(const t of[...this.onHandlerElements])this.detachOnHandlers(t);this.executeCallback=null}attachSSE(t){const e=this.sseConnections.get(t);if(e)return e;const s=ft(t,"sse","connect");if(!s)return null;const n=new J(t,s,(e,n)=>{const i={url:void 0,method:"GET",target:ft(t,"hx","target")??void 0,swap:ft(t,"hx","swap")??"innerHTML"},r=this.getSwapTemplate(t,i)(JSON.stringify(n));r&&(this.dispatchLifecycleEvent(t,"htmx:sseMessage",{url:s,event:e,data:n},{cancelable:0}),this.executeCallback&&this.executeCallback(r,t).catch(t=>{void 0!==console&&console.error("[sse-compat] swap execution failed:",t)}))},{EventSourceCtor:this.eventSourceCtor,debug:this.options.debug});this.sseConnections.set(t,n),this.sseConnectionsSet.add(n);const i=ft(t,"sse","swap");if(i)for(const t of i.split(",").map(t=>t.trim()).filter(Boolean))n.listenFor(t);return n}getSSEConnection(t){return this.sseConnections.get(t)??null}detachSSE(t){const e=this.sseConnections.get(t);e&&(e.detach(),this.sseConnections.delete(t),this.sseConnectionsSet.delete(e))}detachSSESubtree(t){if(this.detachSSE(t),"function"!=typeof t.querySelectorAll)return;const e=t.querySelectorAll($().selectorFor("sse","connect"));for(const t of e)this.detachSSE(t)}attachWS(t){const e=this.wsConnections.get(t);if(e)return e;const s=ft(t,"ws","connect");if(!s)return null;const n=new V(t,s,(e,n)=>{const i={url:void 0,method:"GET",target:e.target,swap:e.swap??ft(t,"hx","swap")??"innerHTML"},r=this.getSwapTemplate(t,i)(JSON.stringify(e.data));r&&(this.dispatchLifecycleEvent(t,"htmx:wsMessage",{url:s,envelope:e,data:e.data},{cancelable:0}),this.executeCallback&&this.executeCallback(r,t).catch(t=>{void 0!==console&&console.error("[ws-compat] swap execution failed:",t)}))},{WSEventSourceCtor:this.wsEventSourceCtor,debug:this.options.debug});return this.wsConnections.set(t,n),this.wsConnectionsSet.add(n),this.wireWSSendDescendants(t,n),n}wireWSSendDescendants(t,e){if("function"!=typeof t.querySelectorAll)return;const s=$().selectorFor("ws","send"),n=[];t.matches?.(s)&&n.push(t);for(const e of t.querySelectorAll(s))n.push(e);for(const t of n){if(this.wsSendListeners.has(t))continue;const s="FORM"===t.tagName?"submit":"click",n=n=>{"submit"===s&&n.preventDefault();const i=U(t);e.send(i)};t.addEventListener(s,n),this.wsSendListeners.set(t,()=>t.removeEventListener(s,n))}}getWSConnection(t){return this.wsConnections.get(t)??null}detachWS(t){const e=this.wsConnections.get(t);if(e&&(e.detach(),this.wsConnections.delete(t),this.wsConnectionsSet.delete(e),"function"==typeof t.querySelectorAll)){const e=$().selectorFor("ws","send"),s=[];t.matches?.(e)&&s.push(t);for(const n of t.querySelectorAll(e))s.push(n);for(const t of s){const e=this.wsSendListeners.get(t);e&&(e(),this.wsSendListeners.delete(t))}}}detachWSSubtree(t){if(this.detachWS(t),"function"!=typeof t.querySelectorAll)return;const e=t.querySelectorAll($().selectorFor("ws","connect"));for(const t of e)this.detachWS(t)}installOnHandlers(t,e){if(this.detachOnHandlers(t),!this.executeCallback)return;const s=this.executeCallback,n=new Map;for(const[i,r]of Object.entries(e)){const e=$().eventNameOf(t,i),o=e=>{s(r,t).catch(t=>{void 0!==console&&console.error(`[htmx-compat] hx-on:${i} execution failed:`,t)})};t.addEventListener(e,o),n.set(e,()=>t.removeEventListener(e,o))}this.onHandlerListeners.set(t,n),this.onHandlerElements.add(t)}detachOnHandlers(t){const e=this.onHandlerListeners.get(t);if(e){for(const t of e.values())t();this.onHandlerListeners.delete(t),this.onHandlerElements.delete(t)}}detachOnHandlersSubtree(t){for(const e of this.findHxOnElements(t))this.detachOnHandlers(e)}scanForHtmxElements(t){const e=t??this.options.root;if(!e)return[];if(e.closest?.("[fx-ignore]"))return[];const s=function(){const t=$(),e=[];for(const s of["get","post","put","patch","delete",...ht])e.push(t.selectorFor("hx",s));return e.push(t.selectorFor("sse","connect")),e.push(t.selectorFor("ws","connect")),e.push("[fx-action]"),e.join(", ")}(),n=new Set(e.querySelectorAll(s));e.matches?.(s)&&n.add(e);for(const t of this.findHxOnElements(e))n.add(t);return Array.from(n).filter(t=>!t.closest("[fx-ignore]"))}findHxOnElements(t){const e=[],s=t=>{const s=t.attributes;for(let n=0;s.length>n;n++)if(null!==at(s[n].name))return void e.push(t)};if(s(t),"function"==typeof t.querySelectorAll)for(const e of t.querySelectorAll("*"))s(e);return e}collectAttributes(t){const e={};for(const s of["get","post","put","patch","delete"]){const n=ft(t,"hx",s);if(n){e.method=s.toUpperCase(),e.url=n;break}}const s=ft(t,"hx","target");s&&(e.target=s);const n=ft(t,"hx","swap");n&&(e.swap=n);const i=ft(t,"hx","trigger");i&&(e.trigger=i);const r=ft(t,"hx","confirm");r&&(e.confirm=r),"true"===ft(t,"hx","boost")&&(e.boost=1);const o=ft(t,"hx","vals");o&&(e.vals=o);const a=ft(t,"hx","headers");a&&(e.headers=a);const c=ft(t,"hx","push-url");c&&(e.pushUrl="true"===c?1:c);const h=ft(t,"hx","replace-url");h&&(e.replaceUrl="true"===h?1:h);const l={};for(const e of t.attributes){const t=at(e.name);null!==t&&(l[t]=e.value)}Object.keys(l).length>0&&(e.onHandlers=l);const u=ft(t,"hx","live");return u&&(e.hxLive=u),e}collectFxAttributes(t){const e={},s=t.getAttribute("fx-action");s&&(e.url=s);const n=t.getAttribute("fx-method");e.method=n?.toUpperCase()||"GET";const i=t.getAttribute("fx-target");i&&(e.target=i);const r=t.getAttribute("fx-swap");e.swap=r||"outerHTML";const o=t.getAttribute("fx-trigger");return o&&(e.trigger=o),e}isFxElement(t){return t.hasAttribute("fx-action")}processElement(t){if(this.processedElements.has(t))return;pt(t,"sse","connect")&&this.attachSSE(t),pt(t,"ws","connect")&&this.attachWS(t);const e=this.isFxElement(t),s=e?this.collectFxAttributes(t):this.collectAttributes(t),n=e?"fx":"htmx";if(s.onHandlers&&this.installOnHandlers(t,s.onHandlers),!s.url&&!s.boost&&!s.hxLive)return;if(s.hxLive&&!function(){if("undefined"!=typeof globalThis){const t=globalThis,e=t[B];if(e&&"object"==typeof e&&"function"==typeof e.registerFeature)return e;t[B]=Z}return Z}().hasFeature("live")&&(void 0!==console&&console.error(`[${n}-compat] hx-live requires @hyperfixi/reactivity to be installed. Install it via \`installPlugin(runtime, reactivityPlugin)\`, or use the hyperfixi-hx-v4 bundle which auto-installs it. Element:`,t),delete s.hxLive,!s.url&&!s.boost))return;if(e&&this.options.fixiEvents&&!this.dispatchLifecycleEvent(t,"fx:init",{element:t,options:{}},{debugPrefix:"fx"}))return;if(!this.dispatchLifecycleEvent(t,"htmx:configuring",{config:s,element:t},{debugPrefix:n}))return;if(e&&this.options.fixiEvents){const e={cfg:{trigger:s.trigger||"click",method:s.method||"GET",action:s.url,headers:{},target:s.target,swap:s.swap||"outerHTML",body:null,drop:this.pendingRequests.has(t)?1:0,transition:1,preventTrigger:1,signal:(new AbortController).signal},element:t};if(!this.dispatchLifecycleEvent(t,"fx:config",e,{debugPrefix:"fx"}))return}const i=T(s,t);if(this.options.debug&&console.log(`[${n}-compat] Translated:`,{element:t.tagName,config:s,hyperscript:i}),this.processedElements.add(t),this.executeCallback&&i){if(e&&this.options.requestDropping&&this.pendingRequests.has(t))return void(this.options.debug&&console.log("[fx-compat] Request dropped - pending request exists"));const r=new AbortController;if(e&&this.options.requestDropping&&this.pendingRequests.set(t,r),t.setAttribute(e?"data-fx-generated":"data-hx-generated",i),!this.dispatchLifecycleEvent(t,"htmx:beforeRequest",{element:t,url:s.url,method:s.method||"GET"},{debugPrefix:n}))return void this.pendingRequests.delete(t);if(e&&this.options.fixiEvents&&!this.dispatchLifecycleEvent(t,"fx:before",{element:t,url:s.url,method:s.method||"GET"},{debugPrefix:"fx"}))return void this.pendingRequests.delete(t);let o=1;this.executeCallback(i,t).then(()=>{e&&this.options.fixiEvents&&!this.dispatchLifecycleEvent(t,"fx:after",{cfg:{trigger:s.trigger||"click",method:s.method||"GET",action:s.url,headers:{},target:s.target,swap:s.swap||"outerHTML",body:null,drop:0,transition:1,preventTrigger:1,signal:r.signal,response:null,text:""},element:t},{debugPrefix:"fx"})||(this.dispatchLifecycleEvent(t,"htmx:afterSettle",{element:t,target:s.target},{cancelable:0}),e&&this.options.fixiEvents&&this.dispatchLifecycleEvent(t,"fx:swapped",{element:t,target:s.target},{cancelable:0,debugPrefix:"fx"}))}).catch(s=>{o=0,console.error(`[${n}-compat] Execution error:`,s);const i=s instanceof Error?s:Error(s+"");this.dispatchLifecycleEvent(t,"htmx:error",{element:t,error:i},{cancelable:0}),e&&this.options.fixiEvents&&this.dispatchLifecycleEvent(t,"fx:error",{element:t,error:i},{cancelable:0,debugPrefix:"fx"})}).finally(()=>{this.pendingRequests.delete(t),e&&this.options.fixiEvents&&this.dispatchLifecycleEvent(t,"fx:finally",{element:t,success:o},{cancelable:0,debugPrefix:"fx"}),e&&this.options.fixiEvents&&this.dispatchLifecycleEvent(t,"fx:inited",{element:t},{cancelable:0,bubbles:0,debugPrefix:"fx"})})}}processSubtree(t){const e=this.scanForHtmxElements(t);for(const t of e)this.processElement(t)}startObserver(){var t;this.observer=new MutationObserver(t=>{for(const e of t){for(const t of e.addedNodes)t instanceof Element&&this.processSubtree(t);for(const t of e.removedNodes)t instanceof Element&&(this.detachSSESubtree(t),this.detachWSSubtree(t),this.detachOnHandlersSubtree(t));if("attributes"===e.type&&e.target instanceof Element){const t=e.attributeName;null!=t&&(ut.includes(t)||null!==at(t)||this.localizedAttrSet.has(t))&&(this.processedElements.delete(e.target),this.processElement(e.target))}}}),this.localizedAttrSet=new Set(nt()),this.unsubscribeVocab=(st.add(t=()=>this.refreshLocalizedAttrs()),()=>{st.delete(t)}),this.options.root&&this.observer.observe(this.options.root,{childList:1,subtree:1,attributes:1,attributeFilter:this.computeAttributeFilter()})}computeAttributeFilter(){const t=nt();return 0===t.length?ut:[...new Set([...ut,...t])]}refreshLocalizedAttrs(){this.localizedAttrSet=new Set(nt()),this.observer&&this.options.root&&(this.observer.disconnect(),this.observer.observe(this.options.root,{childList:1,subtree:1,attributes:1,attributeFilter:this.computeAttributeFilter()}))}manualProcess(t){return T(this.isFxElement(t)?this.collectFxAttributes(t):this.collectAttributes(t),t)}hasPendingRequest(t){return this.pendingRequests.has(t)}abortPendingRequest(t){const e=this.pendingRequests.get(t);return e?(e.abort(),this.pendingRequests.delete(t),1):0}}ot();let mt=null;function yt(t={}){const{processHyperscript:e=1,...s}=t;mt=new dt({processExisting:s.processExisting??1,watchMutations:s.watchMutations??1,debug:s.debug??0,root:s.root??document.body,requestDropping:s.requestDropping??1,fixiEvents:s.fixiEvents??1}),mt.init(async(t,e)=>{await x.execute(t,e)}),wt||"undefined"==typeof document||(wt=t=>{const e=t.detail,s=e?.elt??t.target;s&&"function"==typeof s.querySelector&&x.process(s)},document.addEventListener("htmx:load",wt),document.addEventListener("htmx:after:process",wt)),t.debug&&console.log("[hyperfixi-hx] htmx/fixi compatibility enabled")}let wt=null;function gt(){mt&&(mt.destroy(),mt=null),wt&&"undefined"!=typeof document&&(document.removeEventListener("htmx:load",wt),document.removeEventListener("htmx:after:process",wt),wt=null)}function bt(t){return new dt({processExisting:0,watchMutations:0}).manualProcess(t)}const vt={...x,version:"1.0.0-hybrid-hx",enableHtmxCompatibility:yt,disableHtmxCompatibility:gt,getHtmxProcessor:function(){return mt},translateHtmx:bt,hasHtmxAttributes:H,hasFxAttributes:A,hasAnyAttributes:_,HtmxAttributeProcessor:dt,translateToHyperscript:T,features:{htmx:1,fixi:1,hyperscript:1},htmxAttributes:ct,fixiAttributes:lt,fixiEvents:["fx:init","fx:inited","fx:config","fx:before","fx:after","fx:error","fx:finally","fx:swapped"]};if("undefined"!=typeof window){window.hyperfixi=vt,window.lokascript=vt;const t=()=>{yt({processExisting:1,watchMutations:1,processHyperscript:1,requestDropping:1,fixiEvents:1})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}t.FIXI_ATTRS=lt,t.HTMX_ATTRS=ct,t.HtmxAttributeProcessor=dt,t.default=vt,t.disableHtmxCompatibility=gt,t.enableHtmxCompatibility=yt,t.hasAnyAttributes=_,t.hasFxAttributes=A,t.translateHtmx=bt,Object.defineProperty(t,"t",{value:1})}({});
|
|
1
|
+
!function(t){"use strict";const e=new Set(["on","from","to","into","before","after","in","of","at","with","if","else","unless","end","then","and","or","not","repeat","times","for","each","while","until","toggle","add","remove","put","set","get","call","return","append","log","send","trigger","wait","settle","fetch","as","show","hide","take","increment","decrement","focus","blur","go","transition","over","the","a","an","my","its","me","it","you","first","last","next","previous","closest","parent","true","false","null","undefined","is","matches","contains","includes","exists","has","init","every","by","halt","via","values","default","event"]);function s(t){const s=[];let n=0;for(;t.length>n;){if(/\s/.test(t[n])){n++;continue}if("--"===t.slice(n,n+2)){for(;t.length>n&&"\n"!==t[n];)n++;continue}const i=n;if("<"===t[n]&&/[a-zA-Z]/.test(t[n+1]||"")){for(n++;t.length>n&&">"!==t[n];)n++;">"===t[n]&&n++;const e=t.slice(i,n);if(e.endsWith("/>")||e.endsWith(">")){const t=e.slice(1).replace(/\/?>$/,"");s.push({type:"selector",value:t,pos:i});continue}}if("'s"===t.slice(n,n+2)&&!/[a-zA-Z]/.test(t[n+2]||"")){s.push({type:"operator",value:"'s",pos:i}),n+=2;continue}if('"'===t[n]||"'"===t[n]){const e=t[n++];for(;t.length>n&&t[n]!==e;)"\\"===t[n]&&n++,n++;n++,s.push({type:"string",value:t.slice(i,n),pos:i});continue}if(/\d/.test(t[n])||"-"===t[n]&&/\d/.test(t[n+1]||"")){for("-"===t[n]&&n++;t.length>n&&/[\d.]/.test(t[n]);)n++;"ms"===t.slice(n,n+2)?n+=2:"s"!==t[n]||/[a-zA-Z]/.test(t[n+1]||"")?"px"===t.slice(n,n+2)&&(n+=2):n++,s.push({type:"number",value:t.slice(i,n),pos:i});continue}if(":"===t[n]){for(n++;t.length>n&&/[\w]/.test(t[n]);)n++;s.push({type:"localVar",value:t.slice(i,n),pos:i});continue}if("$"===t[n]){for(n++;t.length>n&&/[\w]/.test(t[n]);)n++;s.push({type:"globalVar",value:t.slice(i,n),pos:i});continue}if("@"===t[n]){for(n++;t.length>n&&/[\w-]/.test(t[n]);)n++;s.push({type:"selector",value:t.slice(i,n),pos:i});continue}if("#"===t[n]||"."===t[n]){if("."===t[n]&&t.slice(n+1).match(/^(once|prevent|stop|debounce|throttle)\b/i)){s.push({type:"symbol",value:".",pos:i}),n++;continue}for(n++;t.length>n&&/[\w-]/.test(t[n]);)n++;s.push({type:"selector",value:t.slice(i,n),pos:i});continue}if("["===t[n]){let e=n+1;for(;t.length>e&&/\s/.test(t[e]);)e++;const r=t[e]||"";if(/['"\d\[\]:\$\-]/.test(r)||""===r){s.push({type:"symbol",value:"[",pos:i}),n++;continue}{n++;let e=1;for(;t.length>n&&e>0;)"["===t[n]&&e++,"]"===t[n]&&e--,n++;s.push({type:"selector",value:t.slice(i,n),pos:i});continue}}if("]"===t[n]){s.push({type:"symbol",value:"]",pos:i}),n++;continue}if("'s"===t.slice(n,n+2)){s.push({type:"operator",value:"'s",pos:i}),n+=2;continue}const r=t.slice(n,n+2);if(["==","!=","<=",">=","&&","||"].includes(r))s.push({type:"operator",value:r,pos:i}),n+=2;else if("*"===t[n]&&/[a-zA-Z]/.test(t[n+1]||"")){for(n++;t.length>n&&/[\w-]/.test(t[n]);)n++;s.push({type:"styleProperty",value:t.slice(i,n),pos:i})}else if("+-*/%<>!".includes(t[n]))s.push({type:"operator",value:t[n],pos:i}),n++;else if("()[]{},.".includes(t[n]))s.push({type:"symbol",value:t[n],pos:i}),n++;else{if(/[a-zA-Z_]/.test(t[n])){for(;t.length>n&&/[\w-]/.test(t[n]);)n++;const r=t.slice(i,n),o=e.has(r.toLowerCase())?"keyword":"identifier";s.push({type:o,value:r,pos:i});continue}n++}}return s.push({type:"eof",value:"",pos:t.length}),s}const n={flip:"toggle",switch:"toggle",display:"show",reveal:"show",conceal:"hide",increase:"increment",decrease:"decrement",fire:"trigger",dispatch:"send",navigate:"go",goto:"go"},i={clicked:"click",pressed:"keydown",changed:"change",submitted:"submit",loaded:"load"};function r(t){const e=t.toLowerCase();return n[e]||e}function o(t){const e=t.toLowerCase();return i[e]||e}class a{constructor(t){this.pos=0,this.tokens=s(t)}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}advance(){return this.tokens[this.pos++]}match(...t){const e=this.peek();return t.some(t=>e.value.toLowerCase()===t.toLowerCase())}matchType(...t){return t.includes(this.peek().type)}expect(t){if(!this.match(t)&&r(this.peek().value)!==t)throw Error(`Expected '${t}', got '${this.peek().value}'`);return this.advance()}isAtEnd(){return"eof"===this.peek().type}parse(){return this.match("on")?this.parseEventHandler():this.match("init")?(this.advance(),{type:"event",event:"init",modifiers:{},body:this.parseCommandSequence()}):this.match("every")?this.parseEveryHandler():{type:"sequence",commands:this.parseCommandSequence()}}parseEventHandler(){this.expect("on");const t=this.advance().value,e={};let s;for(;"."===this.peek().value;){this.advance();const t=this.advance().value.toLowerCase();if("once"===t)e.once=1;else if("prevent"===t)e.prevent=1;else if("stop"===t)e.stop=1;else if(("debounce"===t||"throttle"===t)&&"("===this.peek().value){this.advance();const s=this.advance().value;this.expect(")"),"debounce"===t?e.debounce=parseInt(s)||100:e.throttle=parseInt(s)||100}}return this.match("from")&&(this.advance(),s=this.parseExpression()),{type:"event",event:o(t),filter:s,modifiers:e,body:this.parseCommandSequence()}}parseEveryHandler(){return this.expect("every"),{type:"event",event:"interval:"+this.advance().value,modifiers:{},body:this.parseCommandSequence()}}parseCommandSequence(){const t=[];for(;!this.isAtEnd()&&!this.match("end","else");){const e=this.parseCommand();e&&t.push(e),this.match("then","and")&&this.advance()}return t}parseCommand(){if(this.match("if","unless"))return this.parseIf();if(this.match("repeat"))return this.parseRepeat();if(this.match("for"))return this.parseFor();if(this.match("while"))return this.parseWhile();if(this.match("fetch"))return this.parseFetchBlock();const t={toggle:()=>this.parseToggle(),add:()=>this.parseAdd(),remove:()=>this.parseRemove(),put:()=>this.parsePut(),append:()=>this.parseAppend(),set:()=>this.parseSet(),get:()=>this.parseGet(),call:()=>this.parseCall(),log:()=>this.parseLog(),send:()=>this.parseSend(),trigger:()=>this.parseSend(),wait:()=>this.parseWait(),show:()=>this.parseShow(),hide:()=>this.parseHide(),take:()=>this.parseTake(),increment:()=>this.parseIncDec("increment"),decrement:()=>this.parseIncDec("decrement"),focus:()=>this.parseFocusBlur("focus"),blur:()=>this.parseFocusBlur("blur"),go:()=>this.parseGo(),return:()=>this.parseReturn(),transition:()=>this.parseTransition(),halt:()=>this.parseHalt()},e=r(this.peek().value);return t[e]?t[e]():(this.isAtEnd()||this.match("then","and","end","else")||this.advance(),null)}parseIf(){const t=this.match("unless");this.advance();const e=this.parseExpression(),s=this.parseCommandSequence();let n;return this.match("else")&&(this.advance(),n=this.parseCommandSequence()),this.match("end")&&this.advance(),{type:"if",condition:t?{type:"unary",operator:"not",operand:e}:e,body:s,elseBody:n}}parseRepeat(){let t;this.expect("repeat"),this.match("until","while","forever")||(t=this.parseExpression(),this.match("times")&&this.advance());const e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"repeat",condition:t,body:e}}parseFor(){this.expect("for"),this.match("each")&&this.advance();const t=this.advance().value;this.expect("in");const e=this.parseExpression(),s=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"for",condition:{type:"forCondition",variable:t,iterable:e},body:s}}parseWhile(){this.expect("while");const t=this.parseExpression(),e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"while",condition:t,body:e}}parseFetchBlock(){this.expect("fetch");const t=this.parseExpression();let e,s,n={type:"literal",value:"text"};this.match("{")&&(this.pos--,e=this.parseExpression());for(let t=0;3>t;t++)if(!this.match("via")||s)if(this.match("as"))this.advance(),(this.match("a")||this.match("an"))&&this.advance(),n=this.parseExpression();else{if(!this.match("with")||e)break;this.advance(),e=this.parseExpression()}else this.advance(),s=this.parseExpression();return this.match("then")&&this.advance(),{type:"fetch",condition:{type:"fetchConfig",url:t,responseType:n,options:e,method:s},body:this.parseCommandSequence()}}parseToggle(){this.expect("toggle");const t=this.parseExpression();let e;return this.match("on")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"toggle",args:[t],target:e}}parseAdd(){this.expect("add");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"add",args:[t],target:e}}parseRemove(){if(this.expect("remove"),this.matchType("selector")){const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"removeClass",args:[t],target:e}}return{type:"command",name:"remove",args:[],target:this.parseExpression()}}parsePut(){this.expect("put");const t=this.parseExpression();let e="into";if(this.match("into","before","after","at")&&(e=this.advance().value,"at"===e)){const t=this.advance().value;this.expect("of"),e=`at ${t} of`}return{type:"command",name:"put",args:[t],target:this.parseExpression(),modifier:e}}parseAppend(){this.expect("append");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"append",args:[t],target:e}}parseSet(){this.expect("set");const t=this.parseExpression();return this.match("to")?(this.advance(),{type:"command",name:"set",args:[t,this.parseExpression()]}):{type:"command",name:"set",args:[t]}}parseGet(){return this.expect("get"),{type:"command",name:"get",args:[this.parseExpression()]}}parseCall(){return this.expect("call"),{type:"command",name:"call",args:[this.parseExpression()]}}parseLog(){this.expect("log");const t=[];for(;!this.isAtEnd()&&!this.match("then","and","end","else")&&(t.push(this.parseExpression()),this.match(","));)this.advance();return{type:"command",name:"log",args:t}}parseSend(){this.advance();const t=this.advance().value;let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"send",args:[{type:"literal",value:t}],target:e}}parseWait(){if(this.expect("wait"),this.match("for")){this.advance();const t=this.advance().value;let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"waitFor",args:[{type:"literal",value:t}],target:e}}return{type:"command",name:"wait",args:[this.parseExpression()]}}parseShow(){let t;this.expect("show");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"show",args:[],target:t,modifiers:e}}parseHide(){let t;this.expect("hide");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"hide",args:[],target:t,modifiers:e}}parseTake(){this.expect("take");const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"take",args:[t],target:e}}parseIncDec(t){this.advance();const e=this.parseExpression();let s={type:"literal",value:1};return this.match("by")&&(this.advance(),s=this.parseExpression()),{type:"command",name:t,args:[e,s]}}parseFocusBlur(t){let e;return this.advance(),this.isAtEnd()||this.match("then","and","end","else")||(e=this.parseExpression()),{type:"command",name:t,args:[],target:e}}parseGo(){return this.expect("go"),this.match("to")&&this.advance(),this.match("url")&&this.advance(),{type:"command",name:"go",args:[this.parseExpression()]}}parseReturn(){let t;return this.expect("return"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"return",args:t?[t]:[]}}parseHalt(){return this.expect("halt"),this.match("the")&&this.advance(),this.match("event","default")&&this.advance(),{type:"command",name:"halt",args:[]}}parseTransition(){let t;if(this.expect("transition"),this.match("my","its"))t={type:"identifier",value:"my"===this.advance().value?"me":"it"};else if(this.matchType("selector")){const e=this.parseExpression();if("possessive"===e.type)return this.parseTransitionRest(e.object,e.property);t=e}const e=this.peek();let s;return s="styleProperty"===e.type||"identifier"===e.type||"keyword"===e.type?this.advance().value:"opacity",this.parseTransitionRest(t,s)}parseTransitionRest(t,e){let s={type:"literal",value:1};this.match("to")&&(this.advance(),s=this.parseExpression());let n={type:"literal",value:300};return this.match("over")&&(this.advance(),n=this.parseExpression()),{type:"command",name:"transition",args:[{type:"literal",value:e},s,n],target:t}}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.match("or","||");)this.advance(),t={type:"binary",operator:"or",left:t,right:this.parseAnd()};return t}parseAnd(){let t=this.parseEquality();for(;this.match("and","&&")&&!this.isCommandKeyword(this.peek(1));)this.advance(),t={type:"binary",operator:"and",left:t,right:this.parseEquality()};return t}isCommandKeyword(t){return["toggle","add","remove","set","put","log","send","wait","show","hide","increment","decrement","focus","blur","go"].includes(r(t.value))}parseEquality(){let t=this.parseComparison();for(;this.match("==","!=","is","matches","contains","includes","has");){const e=this.advance().value;"is"===e.toLowerCase()&&this.match("not")?(this.advance(),t={type:"binary",operator:"is not",left:t,right:this.parseComparison()}):t={type:"binary",operator:e,left:t,right:this.parseComparison()}}return t}parseComparison(){let t=this.parseAdditive();for(;this.match("<",">","<=",">=");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseAdditive()};return t}parseAdditive(){let t=this.parseMultiplicative();for(;this.match("+","-");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseMultiplicative()};return t}parseMultiplicative(){let t=this.parseUnary();for(;this.match("*","/","%");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseUnary()};return t}parseUnary(){if(this.match("not","!"))return this.advance(),{type:"unary",operator:"not",operand:this.parseUnary()};if(this.match("-")&&"number"===this.peek(1).type){this.advance();const t=this.advance();return{type:"literal",value:-parseFloat(t.value)}}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("'s"))this.advance(),this.peek(),t={type:"possessive",object:t,property:this.advance().value};else if("styleProperty"===this.peek().type)t={type:"possessive",object:t,property:this.advance().value};else if("."===this.peek().value)this.advance(),t={type:"member",object:t,property:this.advance().value};else if("selector"===this.peek().type&&this.peek().value.startsWith("."))t={type:"member",object:t,property:this.advance().value.slice(1)};else if("("===this.peek().value){this.advance();const e=[];for(;!this.match(")");)e.push(this.parseExpression()),this.match(",")&&this.advance();this.expect(")"),t={type:"call",callee:t,args:e}}else{if("["!==this.peek().value||"selector"===t.type)break;{this.advance();const e=this.parseExpression();this.expect("]"),t={type:"member",object:t,property:e,computed:1}}}return t}parsePrimary(){const t=this.peek();if("("===t.value){this.advance();const t=this.parseExpression();return this.expect(")"),t}if("{"===t.value)return this.parseObjectLiteral();if("["===t.value)return this.parseArrayLiteral();if("number"===t.type){this.advance();const e=t.value;return e.endsWith("ms")?{type:"literal",value:parseInt(e),unit:"ms"}:e.endsWith("s")?{type:"literal",value:1e3*parseFloat(e),unit:"ms"}:{type:"literal",value:parseFloat(e)}}if("string"===t.type)return this.advance(),{type:"literal",value:t.value.slice(1,-1)};if(this.match("true"))return this.advance(),{type:"literal",value:1};if(this.match("false"))return this.advance(),{type:"literal",value:0};if(this.match("null"))return this.advance(),{type:"literal",value:null};if(this.match("undefined"))return this.advance(),{type:"literal",value:void 0};if("localVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"local"};if("globalVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"global"};if("selector"===t.type)return this.advance(),{type:"selector",value:t.value};if(this.match("my")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"me"}:{type:"possessive",object:{type:"identifier",value:"me"},property:this.advance().value}}if(this.match("its")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"it"}:{type:"possessive",object:{type:"identifier",value:"it"},property:this.advance().value}}return this.match("me")?(this.advance(),{type:"identifier",value:"me"}):this.match("it")?(this.advance(),{type:"identifier",value:"it"}):this.match("you")?(this.advance(),{type:"identifier",value:"you"}):this.match("the","a","an")?(this.advance(),this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:this.parsePrimary()):this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:this.match("values")?(this.advance(),this.match("of")?(this.advance(),{type:"valuesOf",target:this.parseExpression()}):{type:"identifier",value:t.value}):(this.advance(),{type:"identifier",value:t.value})}parseObjectLiteral(){this.expect("{");const t=[];for(;!this.match("}");){const e=this.advance().value;this.expect(":");const s=this.parseExpression();t.push({key:e,value:s}),this.match(",")&&this.advance()}return this.expect("}"),{type:"object",properties:t}}parseArrayLiteral(){this.expect("[");const t=[];for(;!this.match("]");)t.push(this.parseExpression()),this.match(",")&&this.advance();return this.expect("]"),{type:"array",elements:t}}parsePositionalTarget(){const t=this.peek();return"selector"===t.type?{type:"selector",value:this.advance().value}:"identifier"===t.type||"keyword"===t.type?{type:"identifier",value:this.advance().value}:this.parseExpression()}}const c=new Map,h=new WeakMap;function l(t){let e=h.get(t);return e||(e=new Map,h.set(t,e)),e}const u=1e3;async function f(t,e){switch(t.type){case"literal":return t.value;case"identifier":return"me"===t.value||"my"===t.value?e.me:"it"===t.value?e.it:"you"===t.value?e.you:"event"===t.value?e.event:"body"===t.value?document.body:"document"===t.value?document:"window"===t.value?window:e.locals.has(t.value)?e.locals.get(t.value):t.value in e.me?e.me[t.value]:t.value in window?window[t.value]:t.value;case"variable":if("local"===t.scope)return l(e.me).get(t.name.slice(1));const s=t.name.slice(1);return c.has(s)?c.get(s):window[t.name];case"selector":const n=document.querySelectorAll(t.value);return 1===n.length?n[0]:Array.from(n);case"binary":return async function(t,e){if("has"===t.operator){const s=await f(t.left,e);return s instanceof Element&&"selector"===t.right.type&&t.right.value.startsWith(".")?s.classList.contains(t.right.value.slice(1)):0}const s=await f(t.left,e),n=await f(t.right,e);switch(t.operator){case"+":return s+n;case"-":return s-n;case"*":return s*n;case"/":return s/n;case"%":return s%n;case"==":case"is":return s==n;case"!=":case"is not":return s!=n;case"<":return n>s;case">":return s>n;case"<=":return n>=s;case">=":return s>=n;case"and":case"&&":return s&&n;case"or":case"||":return s||n;case"has":if(s instanceof Element){const t="string"==typeof n?n:n?.value;if("string"==typeof t&&t.startsWith("."))return s.classList.contains(t.slice(1))}return 0;case"contains":case"includes":return"string"==typeof s||Array.isArray(s)?s.includes(n):s instanceof Element?s.contains(n):0;case"matches":return s instanceof Element?s.matches(n):"string"==typeof s?RegExp(n).test(s):0;default:return}}(t,e);case"unary":const i=await f(t.operand,e);return"not"===t.operator?!i:i;case"possessive":case"member":const r=await f(t.object,e);if(null==r)return;const o=t.computed?await f(t.property,e):t.property;return"values"===o&&r instanceof Element?p(r):r[o];case"call":{let s,n=null;if("member"===t.callee.type||"possessive"===t.callee.type){n=await f(t.callee.object,e);const i=t.callee.computed?await f(t.callee.property,e):t.callee.property;s=n?.[i]}else s=await f(t.callee,e);const i=await Promise.all(t.args.map(t=>f(t,e)));return"function"==typeof s?s.apply(n,i):void 0}case"positional":return function(t,e){const s=t.target;let n=[],i=null;switch(("selector"===s.type||"identifier"===s.type||"htmlSelector"===s.type)&&(i=s.value),i&&(n=Array.from(document.querySelectorAll(i))),t.position){case"first":default:return n[0]||null;case"last":return n[n.length-1]||null;case"next":if(i){let t=e.me.nextElementSibling;for(;t;){if(t.matches(i))return t;t=t.nextElementSibling}return null}return e.me.nextElementSibling;case"previous":if(i){let t=e.me.previousElementSibling;for(;t;){if(t.matches(i))return t;t=t.previousElementSibling}return null}return e.me.previousElementSibling;case"closest":return i?e.me.closest(i):null;case"parent":if(i){let t=e.me.parentElement;for(;t;){if(t.matches(i))return t;t=t.parentElement}return null}return e.me.parentElement}}(t,e);case"object":const a={};for(const s of t.properties)a[s.key]=await f(s.value,e);return a;case"array":return Promise.all(t.elements.map(t=>f(t,e)));case"valuesOf":{const s=await f(t.target,e);return s instanceof Element?p(s):new FormData}default:return}}function p(t){if(t instanceof HTMLFormElement)return new FormData(t);const e=new FormData;return t.querySelectorAll("input, select, textarea").forEach(t=>{const s=t.getAttribute("name");s&&"value"in t&&e.append(s,t.value)}),e}async function d(t,e){const s=async()=>{if(!t.target)return[e.me];const s=await f(t.target,e);return Array.isArray(s)?s:s instanceof Element?[s]:"string"==typeof s?Array.from(document.querySelectorAll(s)):[e.me]},n=t=>{if(!t)return"";if("selector"===t.type)return t.value.startsWith("@")?t.value:t.value.slice(1);if("string"===t.type||"literal"===t.type){const e=t.value;return"string"==typeof e&&e.startsWith(".")?e.slice(1):e+""}return"identifier"===t.type?t.value:""},i=t=>Array.isArray(t)?t.filter(t=>t instanceof Element):t instanceof Element?[t]:"string"==typeof t?Array.from(document.querySelectorAll(t)):[],r=t=>t.startsWith("*"),o=t=>t.substring(1),a=(t,e,s)=>r(e)?(t.style.setProperty(o(e),s+""),1):0,h=(t,e)=>{if(r(e))return getComputedStyle(t).getPropertyValue(o(e))};switch(t.name){case"toggle":{const i=n(t.args[0])||await f(t.args[0],e)+"",r=await s();if(i.startsWith("@")){const t=i.slice(1);for(const e of r)e.hasAttribute(t)?e.removeAttribute(t):e.setAttribute(t,"")}else for(const t of r)t.classList.toggle(i);return e.it=1===r.length?r[0]:r,e.it}case"add":{const i=n(t.args[0])||await f(t.args[0],e)+"",r=await s();if(i.startsWith("@")){const t=i.slice(1);for(const e of r)e.setAttribute(t,"")}else for(const t of r)t.classList.add(i);return e.it=1===r.length?r[0]:r,e.it}case"removeClass":{const i=n(t.args[0])||await f(t.args[0],e)+"",r=await s();if(i.startsWith("@")){const t=i.slice(1);for(const e of r)e.removeAttribute(t)}else for(const t of r)t.classList.remove(i);return e.it=1===r.length?r[0]:r,e.it}case"remove":{const t=await s();for(const e of t)e.remove();return null}case"put":{const n=await f(t.args[0],e),o=t.modifier||"into";if("possessive"===t.target?.type&&r(t.target.property)){const s=i(await f(t.target.object,e));for(const e of s)a(e,t.target.property,n);return e.it=n,n}const c=await s();for(const t of c){const e=n+"";"into"===o?t.innerHTML=e:"before"===o?t.insertAdjacentHTML("beforebegin",e):"after"===o?t.insertAdjacentHTML("afterend",e):"at start of"===o?t.insertAdjacentHTML("afterbegin",e):"at end of"===o&&t.insertAdjacentHTML("beforeend",e)}return e.it=n,n}case"append":{const n=await f(t.args[0],e),i=await s();for(const t of i)t.insertAdjacentHTML("beforeend",n+"");return e.it=n,n}case"set":{const s=t.args[0],n=await f(t.args[1],e);if("variable"===s.type){const t=s.name.slice(1);return("local"===s.scope?l(e.me):c).set(t,n),e.it=n,n}if("possessive"===s.type||"member"===s.type){const t=await f(s.object,e);if(t)return t instanceof Element&&a(t,s.property,n)?(e.it=n,n):(t[s.property]=n,e.it=n,n)}return e.it=n,n}case"get":{const s=await f(t.args[0],e);return e.it=s,s}case"call":{const s=await f(t.args[0],e);return e.it=s,s}case"log":{const s=await Promise.all(t.args.map(t=>f(t,e)));return console.log(...s),s[0]}case"trigger":case"send":{const n=await f(t.args[0],e),i=await s(),r=new CustomEvent(n+"",{bubbles:1,detail:e.it});for(const t of i)t.dispatchEvent(r);return e.it=r,r}case"wait":{const s=await f(t.args[0],e),n="number"==typeof s?s:parseInt(s+"");return await new Promise(t=>setTimeout(t,n)),n}case"waitFor":{const n=await f(t.args[0],e),i=(await s())[0]||e.me;return new Promise(t=>{i.addEventListener(n+"",s=>{e.it=s,t(s)},{once:1})})}case"show":{const t=await s();for(const e of t)e.style.display="",e.classList.remove("hidden");return t}case"hide":{const t=await s();for(const e of t)e.style.display="none";return t}case"transition":{const n=(await f(t.args[0],e)+"").replace(/^\*/,""),i=await f(t.args[1],e),r=await f(t.args[2],e),o="number"==typeof r?r:(r+"").endsWith("ms")?parseInt(r+""):(r+"").endsWith("s")?1e3*parseFloat(r+""):parseInt(r+"")||300,a=await s(),c=[];for(const t of a){const e=t,s=n.replace(/([A-Z])/g,"-$1").toLowerCase(),r=e.style.transition;e.style.transition=`${s} ${o}ms ease`,e.style.setProperty(s,i+""),c.push(new Promise(t=>{const n=()=>{e.style.transition=r,t()},i=t=>{t.propertyName===s&&(e.removeEventListener("transitionend",i),n())};e.addEventListener("transitionend",i),setTimeout(n,o+50)}))}return await Promise.all(c),e.it=1===a.length?a[0]:a,e.it}case"take":{const i=n(await f(t.args[0],e)),r=t.target?await s():[e.me.parentElement];for(const t of r)t.querySelectorAll("."+i).forEach(t=>t.classList.remove(i));return e.me.classList.add(i),e.me}case"increment":case"decrement":{const s=t.args[0],n=await f(t.args[1],e),o="increment"===t.name?n:-n;if("variable"===s.type){const t=s.name.slice(1),n="local"===s.scope?l(e.me):c,i=(n.get(t)||0)+o;return n.set(t,i),e.it=i,i}if("possessive"===s.type&&r(s.property)){const t=i(await f(s.object,e));for(const n of t){const t=(parseFloat(h(n,s.property)||"0")||0)+o;a(n,s.property,t),e.it=t}return e.it}const u=i(await f(s,e));for(const t of u){const s=(parseFloat(t.textContent||"0")||0)+o;t.textContent=s+"",e.it=s}return e.it}case"focus":{const t=await s();for(const e of t)e.focus();return t}case"blur":{const t=await s();for(const e of t)e.blur();return t}case"go":{const s=await f(t.args[0],e),n=(s+"").toLowerCase();return"back"===n?history.back():"forward"===n?history.forward():window.location.href=s+"",null}case"return":throw{type:"return",value:t.args[0]?await f(t.args[0],e):e.it};case"halt":return e.event&&(e.event.preventDefault(),e.event.stopPropagation()),null;default:return console.warn("Unknown command: "+t.name),null}}async function m(t,e){try{return await w(t,e)}catch(t){if("return"===t?.type)throw t;throw t}}async function y(t,e){switch(t.type){case"if":return await f(t.condition,e)?m(t.body,e):t.elseBody?m(t.elseBody,e):null;case"repeat":{const s=await f(t.condition,e),n="number"==typeof s?s:parseInt(s+"");for(let s=0;n>s&&u>s;s++)e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await m(t.body,e);return null}case"for":{const{variable:s,iterable:n}=t.condition,i=await f(n,e),r=Array.isArray(i)?i:i instanceof NodeList?Array.from(i):[i],o=s.startsWith(":")?s.slice(1):s;for(let s=0;r.length>s&&u>s;s++)e.locals.set(o,r[s]),e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await m(t.body,e);return null}case"while":{let s=0;for(;await f(t.condition,e)&&u>s;)e.locals.set("__loop_index__",s),await m(t.body,e),s++;return null}case"fetch":{const{url:s,responseType:n,options:i,method:r}=t.condition;try{const o=await f(s,e),a={};if(r){const t=await f(r,e);a.method=(t+"").toUpperCase()}if(i){const t=await f(i,e);t instanceof FormData?a.body=t:!t||"object"!=typeof t||t instanceof Element||Object.assign(a,t)}const c=await fetch(o+"",a);if(!c.ok)throw Error("HTTP "+c.status);const h=await f(n,e);let l;if("json"===h)l=await c.json();else if("html"===h){const t=await c.text();l=(new DOMParser).parseFromString(t,"text/html").body.innerHTML}else l=await c.text();e.it=l,e.locals.set("it",l),e.locals.set("result",l),e.locals.set("response",c),await m(t.body,e)}catch(t){if("return"===t?.type)throw t;e.locals.set("error",t),console.error("Fetch error:",t)}return null}default:return null}}async function w(t,e){let s;for(const n of t)"command"===n.type?s=await d(n,e):["if","repeat","for","while","fetch"].includes(n.type)&&(s=await y(n,e));return s}async function g(t,e,s){const n={me:e,event:s,locals:new Map,globals:c};if("sequence"===t.type)return w(t.commands,n);if("event"===t.type){const s=t,i=s.event;if(i.startsWith("interval:")){const t=i.split(":")[1],n=t.endsWith("ms")?parseInt(t):t.endsWith("s")?1e3*parseFloat(t):parseInt(t);return void setInterval(async()=>{const t={me:e,locals:new Map,globals:c};try{await w(s.body,t)}catch(t){if("return"!==t?.type)throw t}},n)}if("init"===i){try{await w(s.body,n)}catch(t){if("return"!==t?.type)throw t}return}const r=s.filter?await f(s.filter,n):e,o=r instanceof Element?r:e,a=s.modifiers;let h=async t=>{a.prevent&&t.preventDefault(),a.stop&&t.stopPropagation();const n={me:e,event:t,you:t.target instanceof Element?t.target:void 0,locals:new Map,globals:c};try{await w(s.body,n)}catch(t){if("return"===t?.type)return t.value;throw t}};if(a.debounce){let t;const e=h;h=async s=>{clearTimeout(t),t=setTimeout(()=>e(s),a.debounce)}}if(a.throttle){let t=0;const e=h;h=async s=>{const n=Date.now();a.throttle>n-t||(t=n,await e(s))}}return void o.addEventListener(i,h,{once:!!a.once})}return null}function b(t){const e=t.getAttribute("_");if(e)try{g(new a(e).parse(),t)}catch(t){console.error("HyperFixi Hybrid Complete error:",t,"Code:",e)}}function v(t=document){t.querySelectorAll("[_]").forEach(b)}const x={version:"1.0.0-hybrid-complete",parse:t=>new a(t).parse(),async execute(t,e){const s=e||document.body;return g(new a(t).parse(),s)},init:v,process:v,addAliases:function(t){Object.assign(n,t)},addEventAliases:function(t){Object.assign(i,t)},tokenize:s,evaluate:f,commands:["toggle","add","remove","put","append","set","get","call","log","send","trigger","wait","show","hide","transition","take","increment","decrement","focus","blur","go","return","halt"],blocks:["if","else","unless","repeat","for","while","fetch"]};"undefined"!=typeof window&&(window.hyperfixi=x,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>v()):v());const E=["__proto__","constructor","prototype"],$=/(?:"([^"]+)"|'([^']+)'|([^\s,:]+))(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|<((?:[^/]|\/(?!>))+)\/>|([^\s,]+)))?(?=\s|,|$)/g,S=/,(?![^[]*\])(?![^(]*\))(?![^<]*\/>)(?=(?:[^"']|"[^"]*"|'[^']*')*$)/;function k(t){if(!t)return{};if(t.startsWith("{"))return JSON.parse(t);const e={};for(const s of t.matchAll($)){const[,t,n,i,r,o,a,c]=s,h=t??n??i;let l=(r??o??a??c??"true").trim();try{l=JSON.parse(l)}catch{}const u=i?.includes(".");M(u?h.split(".").reduceRight((t,e)=>({[e]:t}),l):{[h]:l},e)}return e}function M(t,e){const s="string"==typeof t?k(t):t;for(const[t,n]of Object.entries(s))E.includes(t)||(n&&"object"==typeof n&&!Array.isArray(n)&&e[t]&&"object"==typeof e[t]&&!Array.isArray(e[t])?M(n,e[t]):e[t]=n);return e}let T={nameOf:(t,e,s)=>`${e}-${s}`,selectorFor:(t,e)=>`[${t}-${e}]`,eventNameOf:(t,e)=>e};function H(){return T}const A={innerHTML:"innerHTML",outerHTML:"outerHTML",beforebegin:"before",afterbegin:"start",beforeend:"end",afterend:"after",delete:"delete",none:"none",morph:"morph","morph:innerHTML":"innerHTML morph","morph:outerHTML":"morph"},O={click:"click",load:"init",revealed:"intersection",intersect:"intersection",submit:"submit",change:"change",input:"input",keyup:"keyup",keydown:"keydown",focus:"focus",blur:"blur",mouseenter:"mouseenter",mouseleave:"mouseleave"},_=new Set(["__proto__","constructor","prototype"]),j=new Set;function q(t,e){const s=`${e}:${t}`;j.has(s)||(j.add(s),console.warn(`[hyperfixi] htmx ${e} modifier "${t}" is recognized but not supported; ignoring it.`))}function F(t){j.has(t)||(j.add(t),console.warn("[hyperfixi] "+t))}function L(t){F(t+' uses a "js:" prefix, which is not evaluated; ignoring it.')}function C(t){return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}'`}function P(t){return null===t?"null":"number"==typeof t||"boolean"==typeof t?t+"":"string"==typeof t?C(t):Array.isArray(t)?`[${t.map(P).join(", ")}]`:W(t)}function W(t){const e=Object.entries(t).filter(([t])=>!_.has(t)).map(([t,e])=>`${C(t)}: ${P(e)}`);return e.length?`{ ${e.join(", ")} }`:"{}"}const R=/^([\d.]+)\s*(ms|s|m)?$/;function N(t){if("number"==typeof t)return Number.isFinite(t)?Math.round(t):null;if("string"!=typeof t)return null;const e=t.trim().match(R);if(!e)return null;const s=parseFloat(e[1]);if(!Number.isFinite(s))return null;const n=e[2]??"ms";return Math.round(s*("s"===n?1e3:"m"===n?6e4:1))}const D=new Set(["window","document","body","me"]);function G(t){const e=t.trim();return e?"this"===e?"me":D.has(e)?e:/^(closest|find|next|previous)\s+/.test(e)?(q("from:"+e.split(/\s+/)[0],"trigger"),null):`<${e}/>`:null}const I=/^[.#:[]|^[a-zA-Z][\w-]*$/;function z(t){const e=t.trim();return I.test(e)?"target matches "+C(e):(q("target","trigger"),null)}function J(t){return t.startsWith("js:")||t.startsWith("javascript:")}function Z(t){if("this"===t)return"me";const e=t.match(/^closest\s+(.+)$/);if(e)return`closest <${e[1]}/>`;const s=t.match(/^find\s+(.+)$/);if(s)return`first <${s[1]}/> in me`;const n=t.match(/^next\s+(.+)$/);if(n)return`next <${n[1]}/>`;const i=t.match(/^previous\s+(.+)$/);return i?`previous <${i[1]}/>`:t}const B=/^(\S+\[[^\]]*\]|\S+)\s*(.*)$/,V=/^(\w+)\[(.+)\]$/;function U(t,e){const s=[];if(t.hxLive&&s.push(`live\n ${t.hxLive}\nend`),!t.url)return s.join("\n");const n=[],i=t.trigger||function(t){const e=t.tagName.toLowerCase();if("form"===e)return"submit";if("input"===e||"textarea"===e||"select"===e){const e=t.getAttribute("type");return"submit"===e||"button"===e?"click":"change"}return"click"}(e),r=function(t){let e=null,s=null,n=0,i=null,r=null;for(const[o,a]of Object.entries(t.modifiers))switch(o){case"delay":e=N(a),null===e&&q("delay","trigger");break;case"throttle":s=N(a),null===s&&q("throttle","trigger");break;case"once":n=0!=a;break;case"changed":break;case"from":i=G(a+"");break;case"target":r=z(a+"");break;default:q(o,"trigger")}let o="";null!==e&&(o+=`.debounce(${e})`),null!==s&&(o+=`.throttle(${s})`),n&&(o+=".once");const a=[t.filter,r].filter(Boolean);return`on ${t.event}${o}${0===a.length?"":1===a.length?`[${a[0]}]`:`[(${a[0]}) and (${a[1]})]`}${i?" from "+i:""}`}(function(t,e){const s=t.trim().match(B);if(!s)return{event:"click",modifiers:{}};let n=s[1];const i=s[2]??"",r=i?k(i):{};/\[[^\]]*$/.test(n)&&(q("unterminated event filter","trigger"),n=n.slice(0,n.indexOf("[")));const o=n.match(V);if(o){const t=e(o[1]);return{event:O[t]||t,filter:o[2],modifiers:r}}const a=e(n);return{event:O[a]||a,modifiers:r}}(i,t=>H().eventNameOf(e,t)));t.confirm&&n.push(`if not js window.confirm('${t.confirm.replace(/'/g,"\\'")}') return end`);const o=e.tagName.toLowerCase();"form"!==o&&"a"!==o||n.push("halt the event"),n.push(function(t,e){const s=!t.method||"GET"===t.method,n={};t.headers&&(J(t.headers.trim())?L("hx-headers"):Object.assign(n,k(t.headers)));let i=null;t.vals&&(J(t.vals.trim())?L("hx-vals"):i=k(t.vals));let r=t.url,o=null;"form"===e?(i&&Object.keys(i).length&&F("hx-vals is not merged with form values; the form fields win."),s?F("GET form values are not appended to the query string yet."):o="me as FormEncoded"):i&&Object.keys(i).length&&(s?r=function(t,e){const s=new URLSearchParams;for(const[t,n]of Object.entries(e))if(!_.has(t)&&null!=n)if(Array.isArray(n))for(const e of n)s.append(t,e+"");else s.append(t,"object"==typeof n?JSON.stringify(n):n+"");const n=""+s;return n?`${t}${t.includes("?")?"&":"?"}${n}`:t}(r,i):o=W(i)+" as FormEncoded"),o&&!function(t){return Object.keys(t).some(t=>"content-type"===t.toLowerCase())}(n)&&(n["Content-Type"]="application/x-www-form-urlencoded");const a=[];t.method&&"GET"!==t.method&&a.push("method: "+C(t.method)),Object.keys(n).length&&a.push("headers: "+W(n)),o&&a.push("body: "+o);let c="fetch "+C(r);return a.length&&(c+=` with { ${a.join(", ")} }`),c+" as html"}(t,o));const a=t.target?Z(t.target):"me",{style:c,modifiers:h}=function(t,e){const s=(t??"").trim();if(!s)return{style:e,modifiers:{}};const n=s.split(/\s+/)[0];return Object.prototype.hasOwnProperty.call(A,n)||!/^\S*:/.test(s)?{style:n,modifiers:k(s.slice(n.length))}:{style:e,modifiers:k(s)}}(t.swap,"innerHTML"),{swapWaitMs:l,settleWaitMs:u}=function(t){let e=null,s=null;for(const[n,i]of Object.entries(t))switch(n){case"swap":e=N(i),null===e&&q("swap","swap");break;case"settle":s=N(i),null===s&&q("settle","swap");break;default:q(n,"swap")}return{swapWaitMs:e,settleWaitMs:s}}(h),f=function(t,e){const s=A[e]||e;return"none"===s?"":"delete"===s?"remove "+t:"before"===s?"put it before "+t:"after"===s?"put it after "+t:"start"===s?"put it at start of "+t:"end"===s?"put it at end of "+t:"morph"===s?`morph ${t} with it`:"innerHTML morph"===s?`morph innerHTML of ${t} with it`:"outerHTML"===s?`set ${t}'s outerHTML to it`:"put it into "+t}(a,c);null!==l&&n.push(`then wait ${l}ms`),f&&n.push("then "+f),null!==u&&n.push(`then wait ${u}ms`),t.pushUrl?n.push("then push url "+C(1==t.pushUrl?t.url:t.pushUrl)):t.replaceUrl&&n.push("then replace url "+C(1==t.replaceUrl?t.url:t.replaceUrl));const p=`${r}\n ${n.join("\n ")}`;return s.push(p),s.join("\n")}function K(t){const e=t.attributes;for(let t=0;e.length>t;t++)if(e[t].name.startsWith("hx-"))return 1;return 0}function Q(t){return t.hasAttribute("fx-action")}function X(t){return K(t)||Q(t)}const Y=new Set(["add","append","async","beep","blur","break","breakpoint","call","clear","close","continue","copy","decrement","default","empty","exit","fetch","focus","for","get","go","halt","hide","open","if","increment","install","js","log","make","measure","morph","pick","process","push","put","remove","render","repeat","replace","reset","return","scroll","select","send","set","settle","show","start","swap","take","tell","throw","toggle","transition","trigger","unless","wait"]),tt=new Set(["==","!=","===","!==","<",">","<=",">=","is","is not","am","is a","is an","is not a","is not an","precedes","does not precede","follows","does not follow","contains","starts with","ends with","does not start with","does not end with","has","have","does not contain","include","includes","does not include","match","matches","exists","does not exist","is empty","is not empty","is in","is not in","is between","is not between","equals","in","is equal to","is really equal to","is not equal to","is not really equal to","is greater than","is less than","is greater than or equal to","is less than or equal to","really equals","am in","am not in","am between","am not between","is really","is not really","is equal","is not equal","contain","do not contain","does not contains","do not match","does not match","ignoring case","sorted by","mapped to","split by","joined by"]);function et(t,e){return{infix:{bp:[t,t+1],handler:e??((e,s,n)=>{const i=n.parseExpr(t+1);return{type:"binaryExpression",operator:s.value,left:e,right:i,start:e.start,end:i.end??s.end,line:e.line??s.line,column:e.column??s.column}})}}}function st(t,e){return{infix:{bp:[t+1,t],handler:(e,s,n)=>{const i=n.parseExpr(t);return{type:"binaryExpression",operator:s.value,left:e,right:i,start:e.start,end:i.end??s.end,line:e.line??s.line,column:e.column??s.column}}}}}function nt(t,e){return{prefix:{bp:t,handler:e??((e,s)=>{const n=s.parseExpr(t);return{type:"unaryExpression",operator:e.value,operand:n,argument:n,prefix:1,start:e.start,end:n.end??e.end,line:e.line,column:e.column}})}}}function it(t){return(e,s,n)=>{const i=n.advance();if(!i||!i.value)throw Error(`Type check requires a type name after 'is ${t?"not ":""}a/an', got: <end>`);let r=1;const o=n.peek();return o&&"!"===o.value&&(n.advance(),r=0),{type:"typeCheckExpression",value:e,typeName:i.value,nullOk:r,negated:t,start:e.start,end:i.end}}}const rt=function(...t){const e=new Map;for(const s of t)for(const[t,n]of s){const s=e.get(t);e.set(t,s?{prefix:n.prefix??s.prefix,infix:n.infix??s.infix}:{...n})}return e}(new Map([["or",et(10)],["||",et(10)],["and",et(20)],["&&",et(20)],["==",et(30)],["!=",et(30)],["<",et(30)],[">",et(30)],["<=",et(30)],[">=",et(30)],["is",et(30)],["matches",et(30)],["contains",et(30)],["starts with",et(30)],["ends with",et(30)],["does not start with",et(30)],["does not end with",et(30)],["is between",et(30,(t,e,s)=>{const n=s.parseExpr(31),i=s.peek();if(!i||"and"!==i.value.toLowerCase())throw Error("between requires 'and' between min and max operands, got: "+(i?.value??"<end>"));s.advance();const r=s.parseExpr(31);return{type:"betweenExpression",value:t,min:n,max:r,negated:0,start:t.start,end:r.end}})],["is not between",et(30,(t,e,s)=>{const n=s.parseExpr(31),i=s.peek();if(!i||"and"!==i.value.toLowerCase())throw Error("between requires 'and' between min and max operands, got: "+(i?.value??"<end>"));s.advance();const r=s.parseExpr(31);return{type:"betweenExpression",value:t,min:n,max:r,negated:1,start:t.start,end:r.end}})],["am between",et(30,(t,e,s)=>{const n=s.parseExpr(31),i=s.peek();if(!i||"and"!==i.value.toLowerCase())throw Error("between requires 'and' between min and max operands, got: "+(i?.value??"<end>"));s.advance();const r=s.parseExpr(31);return{type:"betweenExpression",value:t,min:n,max:r,negated:0,start:t.start,end:r.end}})],["am not between",et(30,(t,e,s)=>{const n=s.parseExpr(31),i=s.peek();if(!i||"and"!==i.value.toLowerCase())throw Error("between requires 'and' between min and max operands, got: "+(i?.value??"<end>"));s.advance();const r=s.parseExpr(31);return{type:"betweenExpression",value:t,min:n,max:r,negated:1,start:t.start,end:r.end}})],["ignoring case",{infix:{bp:[25,26],handler:(t,e,s)=>(t.ignoringCase=1,t)}}],["where",et(28,(t,e,s)=>{const n=s.parseExpr(29);return{type:"collectionExpression",operator:"where",collection:t,right:n,start:t.start,end:n.end}})],["sorted by",et(28,(t,e,s)=>{const n=s.parseExpr(29);let i="asc";const r=s.peek();if(r&&"string"==typeof r.value){const t=r.value.toLowerCase();"asc"===t||"ascending"===t?(s.advance(),i="asc"):"desc"!==t&&"descending"!==t||(s.advance(),i="desc")}return{type:"collectionExpression",operator:"sorted by",collection:t,right:n,order:i,start:t.start,end:n.end}})],["mapped to",et(28,(t,e,s)=>{const n=s.parseExpr(29);return{type:"collectionExpression",operator:"mapped to",collection:t,right:n,start:t.start,end:n.end}})],["split by",et(28,(t,e,s)=>{const n=s.parseExpr(29);return{type:"collectionExpression",operator:"split by",collection:t,right:n,start:t.start,end:n.end}})],["joined by",et(28,(t,e,s)=>{const n=s.parseExpr(29);return{type:"collectionExpression",operator:"joined by",collection:t,right:n,start:t.start,end:n.end}})],["+",{...et(40),...nt(80)}],["-",{...et(40),...nt(80)}],["*",et(50)],["/",et(50)],["%",et(50)],["mod",et(50)],["^",st(60)],["**",st(60)],["as",et(70,(t,e,s)=>{const n=()=>{const t=s.peek();!t||"a"!==t.value&&"an"!==t.value||s.advance();const e=s.parseExpr(71),n=s.peek();if(n&&":"===n.value&&e&&"identifier"===e.type){s.advance();const t=s.advance();t&&void 0!==t.value&&(e.name=`${e.name}:${t.value}`,e.end=t.end)}return e};let i=n(),r={type:"asExpression",expression:t,targetType:i,start:t.start,end:i.end??e.end,line:t.line??e.line,column:t.column??e.column};for(;s.peek()&&"|"===s.peek().value;){s.advance();const t=n();r={type:"asExpression",expression:r,targetType:t,start:r.start,end:t.end??r.end,line:r.line,column:r.column}}return r})],["not",nt(80)],["!",nt(80)],["no",nt(27)]]),new Map([["===",et(30)],["!==",et(30)],["is not",et(30)],["am",et(30)],["is in",et(30)],["is not in",et(30)],["precedes",et(30)],["does not precede",et(30)],["follows",et(30)],["does not follow",et(30)],["is a",et(30,it(0))],["is an",et(30,it(0))],["is not a",et(30,it(1))],["is not an",et(30,it(1))],["has",et(30)],["have",et(30)],["match",et(30)],["include",et(30)],["includes",et(30)],["equals",et(30)],["does not contain",et(30)],["does not include",et(30)],["am in",et(30)],["am not in",et(30)],["is really",et(30)],["is not really",et(30)],["is equal",et(30)],["is not equal",et(30)],["contain",et(30)],["do not contain",et(30)],["does not contains",et(30)],["do not match",et(30)],["does not match",et(30)],["is equal to",et(30)],["is not equal to",et(30)],["is really equal to",et(30)],["is not really equal to",et(30)],["really equals",et(30)],["is greater than",et(30)],["is less than",et(30)],["is greater than or equal to",et(30)],["is less than or equal to",et(30)],["in",et(30)],["of",st(30)],["really",et(30)],["exists",{prefix:{bp:80,handler:(t,e)=>({type:"unaryExpression",operator:t.value,operand:e.parseExpr(80),start:t.start})},infix:{bp:[30,31],handler:(t,e)=>({type:"unaryExpression",operator:e.value,operand:t,prefix:0,start:t.start})}}],["does not exist",{infix:{bp:[30,31],handler:(t,e)=>({type:"unaryExpression",operator:e.value,operand:t,prefix:0,start:t.start})}}],["is empty",{infix:{bp:[30,31],handler:(t,e)=>({type:"unaryExpression",operator:e.value,operand:t,prefix:0,start:t.start})}}],["is not empty",{infix:{bp:[30,31],handler:(t,e)=>({type:"unaryExpression",operator:e.value,operand:t,prefix:0,start:t.start})}}],["some",nt(80)]]),new Map([["=",st(5)]])),ot=new Map,at=new Map,ct=new Map,ht=new Set,lt=new Set,ut=new Set,ft=new Set,pt=new class{registerCommand(t){Y.add(t.toLowerCase())}registerCompoundOperator(t){tt.add(t.toLowerCase())}registerInfixOperator(t,e,s,n){const i=t.toLowerCase(),r=rt.get(i);rt.set(i,{...r??{},infix:{bp:[e,s],handler:n}})}registerPrefixOperator(t,e,s){const n=t.toLowerCase(),i=rt.get(n);rt.set(n,{...i??{},prefix:{bp:e,handler:s}})}hasCommand(t){return Y.has(t.toLowerCase())}registerFeature(t,e){ot.set(t.toLowerCase(),e)}hasFeature(t){return ot.has(t.toLowerCase())}registerNodeEvaluator(t,e){at.set(t,e)}registerNodeWriter(t,e){ct.set(t,e)}registerGlobalWriteHook(t){return ht.add(t),()=>ht.delete(t)}registerGlobalReadHook(t){return lt.add(t),()=>lt.delete(t)}registerLocalWriteHook(t){return ut.add(t),()=>ut.delete(t)}registerLocalReadHook(t){return ft.add(t),()=>ft.delete(t)}snapshot(){return{commands:Array.from(Y),operators:Array.from(tt),prattEntries:Array.from(rt.entries()).map(([t,e])=>[t,{...e}]),features:Array.from(ot.entries()),nodeEvaluators:Array.from(at.entries()),nodeWriters:Array.from(ct.entries()),globalWriteHooks:Array.from(ht),globalReadHooks:Array.from(lt),localWriteHooks:Array.from(ut),localReadHooks:Array.from(ft)}}restore(t){Y.clear();for(const e of t.commands)Y.add(e);tt.clear();for(const e of t.operators)tt.add(e);rt.clear();for(const[e,s]of t.prattEntries)rt.set(e,s);ot.clear();for(const[e,s]of t.features)ot.set(e,s);at.clear();for(const[e,s]of t.nodeEvaluators)at.set(e,s);ct.clear();for(const[e,s]of t.nodeWriters??[])ct.set(e,s);ht.clear();for(const e of t.globalWriteHooks)ht.add(e);lt.clear();for(const e of t.globalReadHooks??[])lt.add(e);ut.clear();for(const e of t.localWriteHooks??[])ut.add(e);ft.clear();for(const e of t.localReadHooks??[])ft.add(e)}},dt="__hyperfixi_parser_extension_registry__";class mt{constructor(t,e,s,n={}){this.element=t,this.url=e,this.swapHandler=s,this.source=null,this.listeners=new Map,this.destroyed=0,this.reconnectAttempts=0,this.reconnectTimer=null,this.maxAttempts=n.maxAttempts??5,this.baseBackoffMs=n.baseBackoffMs??1e3,this.maxBackoffMs=n.maxBackoffMs??3e4,this.debug=n.debug??0,this.EventSourceCtor=n.EventSourceCtor??("undefined"!=typeof EventSource?EventSource:null),this.EventSourceCtor?this.open():this.debug&&void 0!==console&&console.warn("[sse] EventSource is not available in this environment")}listenFor(t){if(this.destroyed)return;if(this.listeners.has(t))return;const e=t=>{this.swapHandler(t.type,t.data)};this.listeners.set(t,e),this.source&&this.source.addEventListener(t,e)}detach(){this.destroyed||(this.destroyed=1,null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.closeSource(),this.dispatch("htmx:sseClose",{url:this.url}))}get readyState(){return this.source?.readyState??-1}open(){if(!this.destroyed){try{this.source=new this.EventSourceCtor(this.url)}catch(t){return this.dispatch("htmx:sseError",{url:this.url,error:t}),void this.scheduleReconnect()}this.source.onopen=()=>{this.reconnectAttempts=0,this.dispatch("htmx:sseOpen",{url:this.url})},this.source.onmessage=t=>{this.dispatch("htmx:sseMessage",{url:this.url,data:t.data})},this.source.onerror=t=>{this.dispatch("htmx:sseError",{url:this.url,event:t}),this.source&&2===this.source.readyState&&(this.closeSource(),this.scheduleReconnect())};for(const[t,e]of this.listeners)this.source.addEventListener(t,e)}}closeSource(){if(this.source){for(const[t,e]of this.listeners)try{this.source.removeEventListener(t,e)}catch{}this.source.onopen=null,this.source.onmessage=null,this.source.onerror=null;try{this.source.close()}catch{}this.source=null}}scheduleReconnect(){if(this.destroyed)return;if(this.reconnectAttempts>=this.maxAttempts)return this.debug&&void 0!==console&&console.warn(`[sse] giving up after ${this.maxAttempts} reconnect attempts to ${this.url}`),void this.detach();const t=Math.min(this.baseBackoffMs*Math.pow(2,this.reconnectAttempts),this.maxBackoffMs);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.open()},t)}dispatch(t,e){if("undefined"!=typeof CustomEvent)try{const s=new CustomEvent(t,{detail:e,bubbles:1,cancelable:0});this.element.dispatchEvent(s)}catch{}}}class yt{constructor(t,e,s,n={}){this.element=t,this.url=e,this.swapHandler=s,this.socket=null,this.destroyed=0,this.reconnectAttempts=0,this.reconnectTimer=null,this.outboundQueue=[],this.maxAttempts=n.maxAttempts??5,this.baseBackoffMs=n.baseBackoffMs??1e3,this.maxBackoffMs=n.maxBackoffMs??3e4,this.debug=n.debug??0,this.protocols=n.protocols,this.WSCtor=n.WSEventSourceCtor??("undefined"!=typeof WebSocket?WebSocket:null),this.WSCtor?this.open():this.debug&&void 0!==console&&console.warn("[ws] WebSocket is not available in this environment")}get readyState(){return this.socket?.readyState??-1}get isDestroyed(){return this.destroyed}send(t){if(this.destroyed)return;const e="string"==typeof t?t:JSON.stringify(t);this.socket&&1===this.socket.readyState?this.socket.send(e):this.outboundQueue.push(e)}detach(){this.destroyed||(this.destroyed=1,null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.closeSocket(),this.dispatch("htmx:wsClose",{url:this.url,code:1e3,reason:"detached"}))}open(){if(!this.destroyed){try{this.socket=new this.WSCtor(this.url,this.protocols)}catch(t){return this.dispatch("htmx:wsError",{url:this.url,error:t}),void this.scheduleReconnect()}this.socket.onopen=()=>{if(this.reconnectAttempts=0,this.dispatch("htmx:wsOpen",{url:this.url}),this.outboundQueue.length&&this.socket){for(const t of this.outboundQueue)try{this.socket.send(t)}catch(t){this.dispatch("htmx:wsError",{url:this.url,error:t})}this.outboundQueue=[]}},this.socket.onmessage=t=>{const e="string"==typeof t.data?t.data:t.data+"",s=function(t){if(!t||"{"!==t[0])return null;let e;try{e=JSON.parse(t)}catch{return null}return"object"!=typeof e||null===e||"string"!=typeof e.target||"string"!=typeof e.data?null:{target:e.target,swap:"string"==typeof e.swap?e.swap:void 0,data:e.data}}(e);s?this.swapHandler(s,s.data):this.dispatch("htmx:wsMessage",{url:this.url,data:e})},this.socket.onerror=t=>{this.dispatch("htmx:wsError",{url:this.url,event:t})},this.socket.onclose=t=>{this.dispatch("htmx:wsClose",{url:this.url,code:t.code,reason:t.reason}),this.socket=null,this.destroyed||t.wasClean||this.scheduleReconnect()}}}closeSocket(){if(this.socket){this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null;try{this.socket.close(1e3,"detached")}catch{}this.socket=null}}scheduleReconnect(){if(this.destroyed)return;if(this.reconnectAttempts>=this.maxAttempts)return this.debug&&void 0!==console&&console.warn(`[ws] giving up after ${this.maxAttempts} reconnect attempts to ${this.url}`),void this.detach();const t=Math.min(this.baseBackoffMs*Math.pow(2,this.reconnectAttempts),this.maxBackoffMs);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.open()},t)}dispatch(t,e){if("undefined"!=typeof CustomEvent)try{const s=new CustomEvent(t,{detail:e,bubbles:1,cancelable:0});this.element.dispatchEvent(s)}catch{}}}function wt(t){if("undefined"!=typeof HTMLFormElement&&t instanceof HTMLFormElement){const e=new FormData(t),s={};for(const[t,n]of e.entries())s[t]="string"==typeof n?n:n.name;return s}const e=t.getAttribute("name"),s=t.value;return e&&void 0!==s?{[e]:s+""}:{}}function gt(t){return t?t.split(/[-_]/)[0].toLowerCase():"en"}function bt(t){const e=t.getAttribute?.("data-hyperfixi-lang");if(e)return gt(e);const s=t.closest?.("[data-hyperfixi-lang]");if(s)return gt(s.getAttribute("data-hyperfixi-lang"));const n=t.closest?.("[lang]");return n?gt(n.getAttribute("lang")):"en"}const vt=new Map,xt=new Map,Et=new Set;let $t=0;const St=new Set;function kt(){const t=new Set;for(const e of xt.values())for(const s of e.values())t.add(s);return[...t]}function Mt(t,e){const s=gt(t),n=e?.hyperfixi??{};var i;vt.set(s,n),xt.set(s,function(t){const e=new Map;if(!t)return e;for(const[s,n]of Object.entries(t))e.set(n,s);return e}(n.attrs)),Et.delete(s),$t||(i={nameOf:(t,e,s)=>{const n=`${e}-${s}`,i=bt(t);if("en"===i)return n;const r=xt.get(i)?.get(n);return r||(vt.has(i)||Et.has(i)||(Et.add(i),void 0!==console&&console.warn(`[hyperfixi-i18n] No vocab registered for lang="${i}". Elements in this language scope fall back to English attribute names. Load packages/core/dist/i18n/htmx/${i}.js to opt in.`)),n)},selectorFor:(t,e)=>{const s=`${t}-${e}`,n=new Set([s]);for(const t of xt.values()){const e=t.get(s);e&&n.add(e)}return[...n].map(t=>`[${t}]`).join(", ")},eventNameOf:(t,e)=>{const s=bt(t);return"en"===s?e:vt.get(s)?.events?.[e]??e}},T=i,$t=1);for(const t of St)t()}const Tt="__hyperfixi_i18n";function Ht(){if("undefined"==typeof window)return;const t=window;t[Tt]||(t[Tt]={register:Mt})}function At(t){for(const e of function(){const t=new Set(["hx-on:"]);for(const e of xt.values()){const s=e.get("hx-on");s&&t.add(s+":")}return[...t]}())if(t.startsWith(e))return t.slice(e.length);return null}Ht();const Ot=["get","post","put","patch","delete","target","swap","trigger","confirm","boost","vals","headers","push-url","replace-url","on","live"].filter(t=>"on"!==t).map(t=>"hx-"+t).concat(["sse-swap","ws-send"]),_t=["live"],jt=["fx-action","fx-method","fx-trigger","fx-target","fx-swap","fx-ignore"],qt=[...Ot,...jt];function Ft(t,e,s){return t.getAttribute(H().nameOf(t,e,s))}function Lt(t,e,s){return t.hasAttribute(H().nameOf(t,e,s))}class Ct{getSwapTemplate(t,e){const s=`${e.target??"me"}|${e.swap??"innerHTML"}`,n=this.swapTemplateCache.get(t);if(n&&n.sig===s)return n.build;const i=function(t){const e=t.swap??"innerHTML",s=Z(t.target??"me");switch(e){case"outerHTML":return t=>`set ${s}'s outerHTML to ${t}`;case"beforebegin":return t=>`put ${t} before ${s}`;case"afterend":return t=>`put ${t} after ${s}`;case"afterbegin":return t=>`put ${t} at start of ${s}`;case"beforeend":return t=>`put ${t} at end of ${s}`;case"none":return()=>"";case"delete":return()=>"remove "+s;default:return t=>`put ${t} into ${s}`}}(e);return this.swapTemplateCache.set(t,{sig:s,build:i}),i}dispatchLifecycleEvent(t,e,s,n={}){const i=new CustomEvent(e,{detail:s,bubbles:n.bubbles??1,cancelable:n.cancelable??1}),r=t.dispatchEvent(i);return!r&&this.options.debug&&console.log(`[${n.debugPrefix??"htmx"}-compat] ${e} cancelled`),r}constructor(t={}){this.observer=null,this.processedElements=new WeakSet,this.executeCallback=null,this.pendingRequests=new WeakMap,this.sseConnections=new WeakMap,this.sseConnectionsSet=new Set,this.wsConnections=new WeakMap,this.wsConnectionsSet=new Set,this.wsSendListeners=new WeakMap,this.onHandlerListeners=new WeakMap,this.onHandlerElements=new Set,this.localizedAttrSet=new Set,this.unsubscribeVocab=null,this.swapTemplateCache=new WeakMap,this.options={processExisting:t.processExisting??1,watchMutations:t.watchMutations??1,debug:t.debug??0,root:t.root??("undefined"!=typeof document?document.body:null),requestDropping:t.requestDropping??1,fixiEvents:t.fixiEvents??1,eventSourceCtor:t.eventSourceCtor,wsEventSourceCtor:t.wsEventSourceCtor},this.eventSourceCtor=t.eventSourceCtor,this.wsEventSourceCtor=t.wsEventSourceCtor}init(t){this.executeCallback=t,this.options.processExisting&&this.options.root&&this.processSubtree(this.options.root),this.options.watchMutations&&"undefined"!=typeof MutationObserver&&this.options.root&&this.startObserver()}destroy(){this.unsubscribeVocab&&(this.unsubscribeVocab(),this.unsubscribeVocab=null),this.observer&&(this.observer.disconnect(),this.observer=null);for(const t of this.sseConnectionsSet)t.detach();this.sseConnectionsSet.clear();for(const t of this.wsConnectionsSet)t.detach();this.wsConnectionsSet.clear();for(const t of[...this.onHandlerElements])this.detachOnHandlers(t);this.executeCallback=null}attachSSE(t){const e=this.sseConnections.get(t);if(e)return e;const s=Ft(t,"sse","connect");if(!s)return null;const n=new mt(t,s,(e,n)=>{const i={url:void 0,method:"GET",target:Ft(t,"hx","target")??void 0,swap:Ft(t,"hx","swap")??"innerHTML"},r=this.getSwapTemplate(t,i)(JSON.stringify(n));r&&(this.dispatchLifecycleEvent(t,"htmx:sseMessage",{url:s,event:e,data:n},{cancelable:0}),this.executeCallback&&this.executeCallback(r,t).catch(t=>{void 0!==console&&console.error("[sse-compat] swap execution failed:",t)}))},{EventSourceCtor:this.eventSourceCtor,debug:this.options.debug});this.sseConnections.set(t,n),this.sseConnectionsSet.add(n);const i=Ft(t,"sse","swap");if(i)for(const t of(r=i,r.split(S)).map(t=>t.trim()).filter(Boolean))n.listenFor(t);var r;return n}getSSEConnection(t){return this.sseConnections.get(t)??null}detachSSE(t){const e=this.sseConnections.get(t);e&&(e.detach(),this.sseConnections.delete(t),this.sseConnectionsSet.delete(e))}detachSSESubtree(t){if(this.detachSSE(t),"function"!=typeof t.querySelectorAll)return;const e=t.querySelectorAll(H().selectorFor("sse","connect"));for(const t of e)this.detachSSE(t)}attachWS(t){const e=this.wsConnections.get(t);if(e)return e;const s=Ft(t,"ws","connect");if(!s)return null;const n=new yt(t,s,(e,n)=>{const i={url:void 0,method:"GET",target:e.target,swap:e.swap??Ft(t,"hx","swap")??"innerHTML"},r=this.getSwapTemplate(t,i)(JSON.stringify(e.data));r&&(this.dispatchLifecycleEvent(t,"htmx:wsMessage",{url:s,envelope:e,data:e.data},{cancelable:0}),this.executeCallback&&this.executeCallback(r,t).catch(t=>{void 0!==console&&console.error("[ws-compat] swap execution failed:",t)}))},{WSEventSourceCtor:this.wsEventSourceCtor,debug:this.options.debug});return this.wsConnections.set(t,n),this.wsConnectionsSet.add(n),this.wireWSSendDescendants(t,n),n}wireWSSendDescendants(t,e){if("function"!=typeof t.querySelectorAll)return;const s=H().selectorFor("ws","send"),n=[];t.matches?.(s)&&n.push(t);for(const e of t.querySelectorAll(s))n.push(e);for(const t of n){if(this.wsSendListeners.has(t))continue;const s="FORM"===t.tagName?"submit":"click",n=n=>{"submit"===s&&n.preventDefault();const i=wt(t);e.send(i)};t.addEventListener(s,n),this.wsSendListeners.set(t,()=>t.removeEventListener(s,n))}}getWSConnection(t){return this.wsConnections.get(t)??null}detachWS(t){const e=this.wsConnections.get(t);if(e&&(e.detach(),this.wsConnections.delete(t),this.wsConnectionsSet.delete(e),"function"==typeof t.querySelectorAll)){const e=H().selectorFor("ws","send"),s=[];t.matches?.(e)&&s.push(t);for(const n of t.querySelectorAll(e))s.push(n);for(const t of s){const e=this.wsSendListeners.get(t);e&&(e(),this.wsSendListeners.delete(t))}}}detachWSSubtree(t){if(this.detachWS(t),"function"!=typeof t.querySelectorAll)return;const e=t.querySelectorAll(H().selectorFor("ws","connect"));for(const t of e)this.detachWS(t)}installOnHandlers(t,e){if(this.detachOnHandlers(t),!this.executeCallback)return;const s=this.executeCallback,n=new Map;for(const[i,r]of Object.entries(e)){const e=H().eventNameOf(t,i),o=e=>{s(r,t).catch(t=>{void 0!==console&&console.error(`[htmx-compat] hx-on:${i} execution failed:`,t)})};t.addEventListener(e,o),n.set(e,()=>t.removeEventListener(e,o))}this.onHandlerListeners.set(t,n),this.onHandlerElements.add(t)}detachOnHandlers(t){const e=this.onHandlerListeners.get(t);if(e){for(const t of e.values())t();this.onHandlerListeners.delete(t),this.onHandlerElements.delete(t)}}detachOnHandlersSubtree(t){for(const e of this.findHxOnElements(t))this.detachOnHandlers(e)}scanForHtmxElements(t){const e=t??this.options.root;if(!e)return[];if(e.closest?.("[fx-ignore]"))return[];const s=function(){const t=H(),e=[];for(const s of["get","post","put","patch","delete",..._t])e.push(t.selectorFor("hx",s));return e.push(t.selectorFor("sse","connect")),e.push(t.selectorFor("ws","connect")),e.push("[fx-action]"),e.join(", ")}(),n=new Set(e.querySelectorAll(s));e.matches?.(s)&&n.add(e);for(const t of this.findHxOnElements(e))n.add(t);return Array.from(n).filter(t=>!t.closest("[fx-ignore]"))}findHxOnElements(t){const e=[],s=t=>{const s=t.attributes;for(let n=0;s.length>n;n++)if(null!==At(s[n].name))return void e.push(t)};if(s(t),"function"==typeof t.querySelectorAll)for(const e of t.querySelectorAll("*"))s(e);return e}collectAttributes(t){const e={};for(const s of["get","post","put","patch","delete"]){const n=Ft(t,"hx",s);if(n){e.method=s.toUpperCase(),e.url=n;break}}const s=Ft(t,"hx","target");s&&(e.target=s);const n=Ft(t,"hx","swap");n&&(e.swap=n);const i=Ft(t,"hx","trigger");i&&(e.trigger=i);const r=Ft(t,"hx","confirm");r&&(e.confirm=r),"true"===Ft(t,"hx","boost")&&(e.boost=1);const o=Ft(t,"hx","vals");o&&(e.vals=o);const a=Ft(t,"hx","headers");a&&(e.headers=a);const c=Ft(t,"hx","push-url");c&&(e.pushUrl="true"===c?1:c);const h=Ft(t,"hx","replace-url");h&&(e.replaceUrl="true"===h?1:h);const l={};for(const e of t.attributes){const t=At(e.name);null!==t&&(l[t]=e.value)}Object.keys(l).length>0&&(e.onHandlers=l);const u=Ft(t,"hx","live");return u&&(e.hxLive=u),e}collectFxAttributes(t){const e={},s=t.getAttribute("fx-action");s&&(e.url=s);const n=t.getAttribute("fx-method");e.method=n?.toUpperCase()||"GET";const i=t.getAttribute("fx-target");i&&(e.target=i);const r=t.getAttribute("fx-swap");e.swap=r||"outerHTML";const o=t.getAttribute("fx-trigger");return o&&(e.trigger=o),e}isFxElement(t){return t.hasAttribute("fx-action")}processElement(t){if(this.processedElements.has(t))return;Lt(t,"sse","connect")&&this.attachSSE(t),Lt(t,"ws","connect")&&this.attachWS(t);const e=this.isFxElement(t),s=e?this.collectFxAttributes(t):this.collectAttributes(t),n=e?"fx":"htmx";if(s.onHandlers&&this.installOnHandlers(t,s.onHandlers),!s.url&&!s.boost&&!s.hxLive)return;if(s.hxLive&&!function(){if("undefined"!=typeof globalThis){const t=globalThis,e=t[dt];if(e&&"object"==typeof e&&"function"==typeof e.registerFeature)return e;t[dt]=pt}return pt}().hasFeature("live")&&(void 0!==console&&console.error(`[${n}-compat] hx-live requires @hyperfixi/reactivity to be installed. Install it via \`installPlugin(runtime, reactivityPlugin)\`, or use the hyperfixi-hx-v4 bundle which auto-installs it. Element:`,t),delete s.hxLive,!s.url&&!s.boost))return;if(e&&this.options.fixiEvents&&!this.dispatchLifecycleEvent(t,"fx:init",{element:t,options:{}},{debugPrefix:"fx"}))return;if(!this.dispatchLifecycleEvent(t,"htmx:configuring",{config:s,element:t},{debugPrefix:n}))return;if(e&&this.options.fixiEvents){const e={cfg:{trigger:s.trigger||"click",method:s.method||"GET",action:s.url,headers:{},target:s.target,swap:s.swap||"outerHTML",body:null,drop:this.pendingRequests.has(t)?1:0,transition:1,preventTrigger:1,signal:(new AbortController).signal},element:t};if(!this.dispatchLifecycleEvent(t,"fx:config",e,{debugPrefix:"fx"}))return}const i=U(s,t);if(this.options.debug&&console.log(`[${n}-compat] Translated:`,{element:t.tagName,config:s,hyperscript:i}),this.processedElements.add(t),this.executeCallback&&i){if(e&&this.options.requestDropping&&this.pendingRequests.has(t))return void(this.options.debug&&console.log("[fx-compat] Request dropped - pending request exists"));const r=new AbortController;if(e&&this.options.requestDropping&&this.pendingRequests.set(t,r),t.setAttribute(e?"data-fx-generated":"data-hx-generated",i),!this.dispatchLifecycleEvent(t,"htmx:beforeRequest",{element:t,url:s.url,method:s.method||"GET"},{debugPrefix:n}))return void this.pendingRequests.delete(t);if(e&&this.options.fixiEvents&&!this.dispatchLifecycleEvent(t,"fx:before",{element:t,url:s.url,method:s.method||"GET"},{debugPrefix:"fx"}))return void this.pendingRequests.delete(t);let o=1;this.executeCallback(i,t).then(()=>{e&&this.options.fixiEvents&&!this.dispatchLifecycleEvent(t,"fx:after",{cfg:{trigger:s.trigger||"click",method:s.method||"GET",action:s.url,headers:{},target:s.target,swap:s.swap||"outerHTML",body:null,drop:0,transition:1,preventTrigger:1,signal:r.signal,response:null,text:""},element:t},{debugPrefix:"fx"})||(this.dispatchLifecycleEvent(t,"htmx:afterSettle",{element:t,target:s.target},{cancelable:0}),e&&this.options.fixiEvents&&this.dispatchLifecycleEvent(t,"fx:swapped",{element:t,target:s.target},{cancelable:0,debugPrefix:"fx"}))}).catch(s=>{o=0,console.error(`[${n}-compat] Execution error:`,s);const i=s instanceof Error?s:Error(s+"");this.dispatchLifecycleEvent(t,"htmx:error",{element:t,error:i},{cancelable:0}),e&&this.options.fixiEvents&&this.dispatchLifecycleEvent(t,"fx:error",{element:t,error:i},{cancelable:0,debugPrefix:"fx"})}).finally(()=>{this.pendingRequests.delete(t),e&&this.options.fixiEvents&&this.dispatchLifecycleEvent(t,"fx:finally",{element:t,success:o},{cancelable:0,debugPrefix:"fx"}),e&&this.options.fixiEvents&&this.dispatchLifecycleEvent(t,"fx:inited",{element:t},{cancelable:0,bubbles:0,debugPrefix:"fx"})})}}processSubtree(t){const e=this.scanForHtmxElements(t);for(const t of e)this.processElement(t)}startObserver(){var t;this.observer=new MutationObserver(t=>{for(const e of t){for(const t of e.addedNodes)t instanceof Element&&this.processSubtree(t);for(const t of e.removedNodes)t instanceof Element&&(this.detachSSESubtree(t),this.detachWSSubtree(t),this.detachOnHandlersSubtree(t));if("attributes"===e.type&&e.target instanceof Element){const t=e.attributeName;null!=t&&(qt.includes(t)||null!==At(t)||this.localizedAttrSet.has(t))&&(this.processedElements.delete(e.target),this.processElement(e.target))}}}),this.localizedAttrSet=new Set(kt()),this.unsubscribeVocab=(St.add(t=()=>this.refreshLocalizedAttrs()),()=>{St.delete(t)}),this.options.root&&this.observer.observe(this.options.root,{childList:1,subtree:1,attributes:1,attributeFilter:this.computeAttributeFilter()})}computeAttributeFilter(){const t=kt();return 0===t.length?qt:[...new Set([...qt,...t])]}refreshLocalizedAttrs(){this.localizedAttrSet=new Set(kt()),this.observer&&this.options.root&&(this.observer.disconnect(),this.observer.observe(this.options.root,{childList:1,subtree:1,attributes:1,attributeFilter:this.computeAttributeFilter()}))}manualProcess(t){return U(this.isFxElement(t)?this.collectFxAttributes(t):this.collectAttributes(t),t)}hasPendingRequest(t){return this.pendingRequests.has(t)}abortPendingRequest(t){const e=this.pendingRequests.get(t);return e?(e.abort(),this.pendingRequests.delete(t),1):0}}Ht();let Pt=null;function Wt(t={}){const{processHyperscript:e=1,...s}=t;Pt=new Ct({processExisting:s.processExisting??1,watchMutations:s.watchMutations??1,debug:s.debug??0,root:s.root??document.body,requestDropping:s.requestDropping??1,fixiEvents:s.fixiEvents??1}),Pt.init(async(t,e)=>{await x.execute(t,e)}),Rt||"undefined"==typeof document||(Rt=t=>{const e=t.detail,s=e?.elt??t.target;s&&"function"==typeof s.querySelector&&x.process(s)},document.addEventListener("htmx:load",Rt),document.addEventListener("htmx:after:process",Rt)),t.debug&&console.log("[hyperfixi-hx] htmx/fixi compatibility enabled")}let Rt=null;function Nt(){Pt&&(Pt.destroy(),Pt=null),Rt&&"undefined"!=typeof document&&(document.removeEventListener("htmx:load",Rt),document.removeEventListener("htmx:after:process",Rt),Rt=null)}function Dt(t){return new Ct({processExisting:0,watchMutations:0}).manualProcess(t)}const Gt={...x,version:"1.0.0-hybrid-hx",enableHtmxCompatibility:Wt,disableHtmxCompatibility:Nt,getHtmxProcessor:function(){return Pt},translateHtmx:Dt,hasHtmxAttributes:K,hasFxAttributes:Q,hasAnyAttributes:X,HtmxAttributeProcessor:Ct,translateToHyperscript:U,features:{htmx:1,fixi:1,hyperscript:1},htmxAttributes:Ot,fixiAttributes:jt,fixiEvents:["fx:init","fx:inited","fx:config","fx:before","fx:after","fx:error","fx:finally","fx:swapped"]};if("undefined"!=typeof window){window.hyperfixi=Gt,window.lokascript=Gt;const t=()=>{Wt({processExisting:1,watchMutations:1,processHyperscript:1,requestDropping:1,fixiEvents:1})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}t.FIXI_ATTRS=jt,t.HTMX_ATTRS=Ot,t.HtmxAttributeProcessor=Ct,t.default=Gt,t.disableHtmxCompatibility=Nt,t.enableHtmxCompatibility=Wt,t.hasAnyAttributes=X,t.hasFxAttributes=Q,t.translateHtmx=Dt,Object.defineProperty(t,"t",{value:1})}({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";const t=new Set(["on","from","to","into","before","after","in","of","at","with","if","else","unless","end","then","and","or","not","repeat","times","for","each","while","until","toggle","add","remove","put","set","get","call","return","append","log","send","trigger","wait","settle","fetch","as","show","hide","take","increment","decrement","focus","blur","go","transition","over","the","a","an","my","its","me","it","you","first","last","next","previous","closest","parent","true","false","null","undefined","is","matches","contains","includes","exists","has","init","every","by","halt","via","values","default","event"]);function e(e){const s=[];let i=0;for(;e.length>i;){if(/\s/.test(e[i])){i++;continue}if("--"===e.slice(i,i+2)){for(;e.length>i&&"\n"!==e[i];)i++;continue}const r=i;if("<"===e[i]&&/[a-zA-Z]/.test(e[i+1]||"")){for(i++;e.length>i&&">"!==e[i];)i++;">"===e[i]&&i++;const t=e.slice(r,i);if(t.endsWith("/>")||t.endsWith(">")){const e=t.slice(1).replace(/\/?>$/,"");s.push({type:"selector",value:e,pos:r});continue}}if("'s"===e.slice(i,i+2)&&!/[a-zA-Z]/.test(e[i+2]||"")){s.push({type:"operator",value:"'s",pos:r}),i+=2;continue}if('"'===e[i]||"'"===e[i]){const t=e[i++];for(;e.length>i&&e[i]!==t;)"\\"===e[i]&&i++,i++;i++,s.push({type:"string",value:e.slice(r,i),pos:r});continue}if(/\d/.test(e[i])||"-"===e[i]&&/\d/.test(e[i+1]||"")){for("-"===e[i]&&i++;e.length>i&&/[\d.]/.test(e[i]);)i++;"ms"===e.slice(i,i+2)?i+=2:"s"!==e[i]||/[a-zA-Z]/.test(e[i+1]||"")?"px"===e.slice(i,i+2)&&(i+=2):i++,s.push({type:"number",value:e.slice(r,i),pos:r});continue}if(":"===e[i]){for(i++;e.length>i&&/[\w]/.test(e[i]);)i++;s.push({type:"localVar",value:e.slice(r,i),pos:r});continue}if("$"===e[i]){for(i++;e.length>i&&/[\w]/.test(e[i]);)i++;s.push({type:"globalVar",value:e.slice(r,i),pos:r});continue}if("@"===e[i]){for(i++;e.length>i&&/[\w-]/.test(e[i]);)i++;s.push({type:"selector",value:e.slice(r,i),pos:r});continue}if("#"===e[i]||"."===e[i]){if("."===e[i]&&e.slice(i+1).match(/^(once|prevent|stop|debounce|throttle)\b/i)){s.push({type:"symbol",value:".",pos:r}),i++;continue}for(i++;e.length>i&&/[\w-]/.test(e[i]);)i++;s.push({type:"selector",value:e.slice(r,i),pos:r});continue}if("["===e[i]){let t=i+1;for(;e.length>t&&/\s/.test(e[t]);)t++;const n=e[t]||"";if(/['"\d\[\]:\$\-]/.test(n)||""===n){s.push({type:"symbol",value:"[",pos:r}),i++;continue}{i++;let t=1;for(;e.length>i&&t>0;)"["===e[i]&&t++,"]"===e[i]&&t--,i++;s.push({type:"selector",value:e.slice(r,i),pos:r});continue}}if("]"===e[i]){s.push({type:"symbol",value:"]",pos:r}),i++;continue}if("'s"===e.slice(i,i+2)){s.push({type:"operator",value:"'s",pos:r}),i+=2;continue}const n=e.slice(i,i+2);if(["==","!=","<=",">=","&&","||"].includes(n))s.push({type:"operator",value:n,pos:r}),i+=2;else if("*"===e[i]&&/[a-zA-Z]/.test(e[i+1]||"")){for(i++;e.length>i&&/[\w-]/.test(e[i]);)i++;s.push({type:"styleProperty",value:e.slice(r,i),pos:r})}else if("+-*/%<>!".includes(e[i]))s.push({type:"operator",value:e[i],pos:r}),i++;else if("()[]{},.".includes(e[i]))s.push({type:"symbol",value:e[i],pos:r}),i++;else{if(/[a-zA-Z_]/.test(e[i])){for(;e.length>i&&/[\w-]/.test(e[i]);)i++;const n=e.slice(r,i),a=t.has(n.toLowerCase())?"keyword":"identifier";s.push({type:a,value:n,pos:r});continue}i++}}return s.push({type:"eof",value:"",pos:e.length}),s}const s={flip:"toggle",switch:"toggle",display:"show",reveal:"show",conceal:"hide",increase:"increment",decrease:"decrement",fire:"trigger",dispatch:"send",navigate:"go",goto:"go"},i={clicked:"click",pressed:"keydown",changed:"change",submitted:"submit",loaded:"load"};function r(t){const e=t.toLowerCase();return s[e]||e}function n(t){const e=t.toLowerCase();return i[e]||e}class a{constructor(t){this.pos=0,this.tokens=e(t)}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}advance(){return this.tokens[this.pos++]}match(...t){const e=this.peek();return t.some(t=>e.value.toLowerCase()===t.toLowerCase())}matchType(...t){return t.includes(this.peek().type)}expect(t){if(!this.match(t)&&r(this.peek().value)!==t)throw Error(`Expected '${t}', got '${this.peek().value}'`);return this.advance()}isAtEnd(){return"eof"===this.peek().type}parse(){return this.match("on")?this.parseEventHandler():this.match("init")?(this.advance(),{type:"event",event:"init",modifiers:{},body:this.parseCommandSequence()}):this.match("every")?this.parseEveryHandler():{type:"sequence",commands:this.parseCommandSequence()}}parseEventHandler(){this.expect("on");const t=this.advance().value,e={};let s;for(;"."===this.peek().value;){this.advance();const t=this.advance().value.toLowerCase();if("once"===t)e.once=1;else if("prevent"===t)e.prevent=1;else if("stop"===t)e.stop=1;else if(("debounce"===t||"throttle"===t)&&"("===this.peek().value){this.advance();const s=this.advance().value;this.expect(")"),"debounce"===t?e.debounce=parseInt(s)||100:e.throttle=parseInt(s)||100}}return this.match("from")&&(this.advance(),s=this.parseExpression()),{type:"event",event:n(t),filter:s,modifiers:e,body:this.parseCommandSequence()}}parseEveryHandler(){return this.expect("every"),{type:"event",event:"interval:"+this.advance().value,modifiers:{},body:this.parseCommandSequence()}}parseCommandSequence(){const t=[];for(;!this.isAtEnd()&&!this.match("end","else");){const e=this.parseCommand();e&&t.push(e),this.match("then","and")&&this.advance()}return t}parseCommand(){if(this.match("if","unless"))return this.parseIf();if(this.match("repeat"))return this.parseRepeat();if(this.match("for"))return this.parseFor();if(this.match("while"))return this.parseWhile();if(this.match("fetch"))return this.parseFetchBlock();const t={toggle:()=>this.parseToggle(),add:()=>this.parseAdd(),remove:()=>this.parseRemove(),put:()=>this.parsePut(),append:()=>this.parseAppend(),set:()=>this.parseSet(),get:()=>this.parseGet(),call:()=>this.parseCall(),log:()=>this.parseLog(),send:()=>this.parseSend(),trigger:()=>this.parseSend(),wait:()=>this.parseWait(),show:()=>this.parseShow(),hide:()=>this.parseHide(),take:()=>this.parseTake(),increment:()=>this.parseIncDec("increment"),decrement:()=>this.parseIncDec("decrement"),focus:()=>this.parseFocusBlur("focus"),blur:()=>this.parseFocusBlur("blur"),go:()=>this.parseGo(),return:()=>this.parseReturn(),transition:()=>this.parseTransition(),halt:()=>this.parseHalt()},e=r(this.peek().value);return t[e]?t[e]():(this.isAtEnd()||this.match("then","and","end","else")||this.advance(),null)}parseIf(){const t=this.match("unless");this.advance();const e=this.parseExpression(),s=this.parseCommandSequence();let i;return this.match("else")&&(this.advance(),i=this.parseCommandSequence()),this.match("end")&&this.advance(),{type:"if",condition:t?{type:"unary",operator:"not",operand:e}:e,body:s,elseBody:i}}parseRepeat(){let t;this.expect("repeat"),this.match("until","while","forever")||(t=this.parseExpression(),this.match("times")&&this.advance());const e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"repeat",condition:t,body:e}}parseFor(){this.expect("for"),this.match("each")&&this.advance();const t=this.advance().value;this.expect("in");const e=this.parseExpression(),s=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"for",condition:{type:"forCondition",variable:t,iterable:e},body:s}}parseWhile(){this.expect("while");const t=this.parseExpression(),e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"while",condition:t,body:e}}parseFetchBlock(){this.expect("fetch");const t=this.parseExpression();let e,s,i={type:"literal",value:"text"};this.match("{")&&(this.pos--,e=this.parseExpression());for(let t=0;3>t;t++)if(!this.match("via")||s)if(this.match("as"))this.advance(),(this.match("a")||this.match("an"))&&this.advance(),i=this.parseExpression();else{if(!this.match("with")||e)break;this.advance(),e=this.parseExpression()}else this.advance(),s=this.parseExpression();return this.match("then")&&this.advance(),{type:"fetch",condition:{type:"fetchConfig",url:t,responseType:i,options:e,method:s},body:this.parseCommandSequence()}}parseToggle(){this.expect("toggle");const t=this.parseExpression();let e;return this.match("on")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"toggle",args:[t],target:e}}parseAdd(){this.expect("add");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"add",args:[t],target:e}}parseRemove(){if(this.expect("remove"),this.matchType("selector")){const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"removeClass",args:[t],target:e}}return{type:"command",name:"remove",args:[],target:this.parseExpression()}}parsePut(){this.expect("put");const t=this.parseExpression();let e="into";if(this.match("into","before","after","at")&&(e=this.advance().value,"at"===e)){const t=this.advance().value;this.expect("of"),e=`at ${t} of`}return{type:"command",name:"put",args:[t],target:this.parseExpression(),modifier:e}}parseAppend(){this.expect("append");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"append",args:[t],target:e}}parseSet(){this.expect("set");const t=this.parseExpression();return this.match("to")?(this.advance(),{type:"command",name:"set",args:[t,this.parseExpression()]}):{type:"command",name:"set",args:[t]}}parseGet(){return this.expect("get"),{type:"command",name:"get",args:[this.parseExpression()]}}parseCall(){return this.expect("call"),{type:"command",name:"call",args:[this.parseExpression()]}}parseLog(){this.expect("log");const t=[];for(;!this.isAtEnd()&&!this.match("then","and","end","else")&&(t.push(this.parseExpression()),this.match(","));)this.advance();return{type:"command",name:"log",args:t}}parseSend(){this.advance();const t=this.advance().value;let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"send",args:[{type:"literal",value:t}],target:e}}parseWait(){if(this.expect("wait"),this.match("for")){this.advance();const t=this.advance().value;let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"waitFor",args:[{type:"literal",value:t}],target:e}}return{type:"command",name:"wait",args:[this.parseExpression()]}}parseShow(){let t;this.expect("show");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"show",args:[],target:t,modifiers:e}}parseHide(){let t;this.expect("hide");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"hide",args:[],target:t,modifiers:e}}parseTake(){this.expect("take");const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"take",args:[t],target:e}}parseIncDec(t){this.advance();const e=this.parseExpression();let s={type:"literal",value:1};return this.match("by")&&(this.advance(),s=this.parseExpression()),{type:"command",name:t,args:[e,s]}}parseFocusBlur(t){let e;return this.advance(),this.isAtEnd()||this.match("then","and","end","else")||(e=this.parseExpression()),{type:"command",name:t,args:[],target:e}}parseGo(){return this.expect("go"),this.match("to")&&this.advance(),this.match("url")&&this.advance(),{type:"command",name:"go",args:[this.parseExpression()]}}parseReturn(){let t;return this.expect("return"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"return",args:t?[t]:[]}}parseHalt(){return this.expect("halt"),this.match("the")&&this.advance(),this.match("event","default")&&this.advance(),{type:"command",name:"halt",args:[]}}parseTransition(){let t;if(this.expect("transition"),this.match("my","its"))t={type:"identifier",value:"my"===this.advance().value?"me":"it"};else if(this.matchType("selector")){const e=this.parseExpression();if("possessive"===e.type)return this.parseTransitionRest(e.object,e.property);t=e}const e=this.peek();let s;return s="styleProperty"===e.type||"identifier"===e.type||"keyword"===e.type?this.advance().value:"opacity",this.parseTransitionRest(t,s)}parseTransitionRest(t,e){let s={type:"literal",value:1};this.match("to")&&(this.advance(),s=this.parseExpression());let i={type:"literal",value:300};return this.match("over")&&(this.advance(),i=this.parseExpression()),{type:"command",name:"transition",args:[{type:"literal",value:e},s,i],target:t}}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.match("or","||");)this.advance(),t={type:"binary",operator:"or",left:t,right:this.parseAnd()};return t}parseAnd(){let t=this.parseEquality();for(;this.match("and","&&")&&!this.isCommandKeyword(this.peek(1));)this.advance(),t={type:"binary",operator:"and",left:t,right:this.parseEquality()};return t}isCommandKeyword(t){return["toggle","add","remove","set","put","log","send","wait","show","hide","increment","decrement","focus","blur","go"].includes(r(t.value))}parseEquality(){let t=this.parseComparison();for(;this.match("==","!=","is","matches","contains","includes","has");){const e=this.advance().value;"is"===e.toLowerCase()&&this.match("not")?(this.advance(),t={type:"binary",operator:"is not",left:t,right:this.parseComparison()}):t={type:"binary",operator:e,left:t,right:this.parseComparison()}}return t}parseComparison(){let t=this.parseAdditive();for(;this.match("<",">","<=",">=");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseAdditive()};return t}parseAdditive(){let t=this.parseMultiplicative();for(;this.match("+","-");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseMultiplicative()};return t}parseMultiplicative(){let t=this.parseUnary();for(;this.match("*","/","%");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseUnary()};return t}parseUnary(){if(this.match("not","!"))return this.advance(),{type:"unary",operator:"not",operand:this.parseUnary()};if(this.match("-")&&"number"===this.peek(1).type){this.advance();const t=this.advance();return{type:"literal",value:-parseFloat(t.value)}}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("'s"))this.advance(),this.peek(),t={type:"possessive",object:t,property:this.advance().value};else if("styleProperty"===this.peek().type)t={type:"possessive",object:t,property:this.advance().value};else if("."===this.peek().value)this.advance(),t={type:"member",object:t,property:this.advance().value};else if("selector"===this.peek().type&&this.peek().value.startsWith("."))t={type:"member",object:t,property:this.advance().value.slice(1)};else if("("===this.peek().value){this.advance();const e=[];for(;!this.match(")");)e.push(this.parseExpression()),this.match(",")&&this.advance();this.expect(")"),t={type:"call",callee:t,args:e}}else{if("["!==this.peek().value||"selector"===t.type)break;{this.advance();const e=this.parseExpression();this.expect("]"),t={type:"member",object:t,property:e,computed:1}}}return t}parsePrimary(){const t=this.peek();if("("===t.value){this.advance();const t=this.parseExpression();return this.expect(")"),t}if("{"===t.value)return this.parseObjectLiteral();if("["===t.value)return this.parseArrayLiteral();if("number"===t.type){this.advance();const e=t.value;return e.endsWith("ms")?{type:"literal",value:parseInt(e),unit:"ms"}:e.endsWith("s")?{type:"literal",value:1e3*parseFloat(e),unit:"ms"}:{type:"literal",value:parseFloat(e)}}if("string"===t.type)return this.advance(),{type:"literal",value:t.value.slice(1,-1)};if(this.match("true"))return this.advance(),{type:"literal",value:1};if(this.match("false"))return this.advance(),{type:"literal",value:0};if(this.match("null"))return this.advance(),{type:"literal",value:null};if(this.match("undefined"))return this.advance(),{type:"literal",value:void 0};if("localVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"local"};if("globalVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"global"};if("selector"===t.type)return this.advance(),{type:"selector",value:t.value};if(this.match("my")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"me"}:{type:"possessive",object:{type:"identifier",value:"me"},property:this.advance().value}}if(this.match("its")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"it"}:{type:"possessive",object:{type:"identifier",value:"it"},property:this.advance().value}}return this.match("me")?(this.advance(),{type:"identifier",value:"me"}):this.match("it")?(this.advance(),{type:"identifier",value:"it"}):this.match("you")?(this.advance(),{type:"identifier",value:"you"}):this.match("the","a","an")?(this.advance(),this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:this.parsePrimary()):this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:this.match("values")?(this.advance(),this.match("of")?(this.advance(),{type:"valuesOf",target:this.parseExpression()}):{type:"identifier",value:t.value}):(this.advance(),{type:"identifier",value:t.value})}parseObjectLiteral(){this.expect("{");const t=[];for(;!this.match("}");){const e=this.advance().value;this.expect(":");const s=this.parseExpression();t.push({key:e,value:s}),this.match(",")&&this.advance()}return this.expect("}"),{type:"object",properties:t}}parseArrayLiteral(){this.expect("[");const t=[];for(;!this.match("]");)t.push(this.parseExpression()),this.match(",")&&this.advance();return this.expect("]"),{type:"array",elements:t}}parsePositionalTarget(){const t=this.peek();return"selector"===t.type?{type:"selector",value:this.advance().value}:"identifier"===t.type||"keyword"===t.type?{type:"identifier",value:this.advance().value}:this.parseExpression()}}const o=new Map,h=new WeakMap;function c(t){let e=h.get(t);return e||(e=new Map,h.set(t,e)),e}const l=1e3;async function u(t,e){switch(t.type){case"literal":return t.value;case"identifier":return"me"===t.value||"my"===t.value?e.me:"it"===t.value?e.it:"you"===t.value?e.you:"event"===t.value?e.event:"body"===t.value?document.body:"document"===t.value?document:"window"===t.value?window:e.locals.has(t.value)?e.locals.get(t.value):t.value in e.me?e.me[t.value]:t.value in window?window[t.value]:t.value;case"variable":if("local"===t.scope)return c(e.me).get(t.name.slice(1));const s=t.name.slice(1);return o.has(s)?o.get(s):window[t.name];case"selector":const i=document.querySelectorAll(t.value);return 1===i.length?i[0]:Array.from(i);case"binary":return async function(t,e){if("has"===t.operator){const s=await u(t.left,e);return s instanceof Element&&"selector"===t.right.type&&t.right.value.startsWith(".")?s.classList.contains(t.right.value.slice(1)):0}const s=await u(t.left,e),i=await u(t.right,e);switch(t.operator){case"+":return s+i;case"-":return s-i;case"*":return s*i;case"/":return s/i;case"%":return s%i;case"==":case"is":return s==i;case"!=":case"is not":return s!=i;case"<":return i>s;case">":return s>i;case"<=":return i>=s;case">=":return s>=i;case"and":case"&&":return s&&i;case"or":case"||":return s||i;case"has":if(s instanceof Element){const t="string"==typeof i?i:i?.value;if("string"==typeof t&&t.startsWith("."))return s.classList.contains(t.slice(1))}return 0;case"contains":case"includes":return"string"==typeof s||Array.isArray(s)?s.includes(i):s instanceof Element?s.contains(i):0;case"matches":return s instanceof Element?s.matches(i):"string"==typeof s?RegExp(i).test(s):0;default:return}}(t,e);case"unary":const r=await u(t.operand,e);return"not"===t.operator?!r:r;case"possessive":case"member":const n=await u(t.object,e);if(null==n)return;const a=t.computed?await u(t.property,e):t.property;return"values"===a&&n instanceof Element?f(n):n[a];case"call":{let s,i=null;if("member"===t.callee.type||"possessive"===t.callee.type){i=await u(t.callee.object,e);const r=t.callee.computed?await u(t.callee.property,e):t.callee.property;s=i?.[r]}else s=await u(t.callee,e);const r=await Promise.all(t.args.map(t=>u(t,e)));return"function"==typeof s?s.apply(i,r):void 0}case"positional":return function(t,e){const s=t.target;let i=[],r=null;switch(("selector"===s.type||"identifier"===s.type||"htmlSelector"===s.type)&&(r=s.value),r&&(i=Array.from(document.querySelectorAll(r))),t.position){case"first":default:return i[0]||null;case"last":return i[i.length-1]||null;case"next":if(r){let t=e.me.nextElementSibling;for(;t;){if(t.matches(r))return t;t=t.nextElementSibling}return null}return e.me.nextElementSibling;case"previous":if(r){let t=e.me.previousElementSibling;for(;t;){if(t.matches(r))return t;t=t.previousElementSibling}return null}return e.me.previousElementSibling;case"closest":return r?e.me.closest(r):null;case"parent":if(r){let t=e.me.parentElement;for(;t;){if(t.matches(r))return t;t=t.parentElement}return null}return e.me.parentElement}}(t,e);case"object":const h={};for(const s of t.properties)h[s.key]=await u(s.value,e);return h;case"array":return Promise.all(t.elements.map(t=>u(t,e)));case"valuesOf":{const s=await u(t.target,e);return s instanceof Element?f(s):new FormData}default:return}}function f(t){if(t instanceof HTMLFormElement)return new FormData(t);const e=new FormData;return t.querySelectorAll("input, select, textarea").forEach(t=>{const s=t.getAttribute("name");s&&"value"in t&&e.append(s,t.value)}),e}async function p(t,e){const s=async()=>{if(!t.target)return[e.me];const s=await u(t.target,e);return Array.isArray(s)?s:s instanceof Element?[s]:"string"==typeof s?Array.from(document.querySelectorAll(s)):[e.me]},i=t=>{if(!t)return"";if("selector"===t.type)return t.value.startsWith("@")?t.value:t.value.slice(1);if("string"===t.type||"literal"===t.type){const e=t.value;return"string"==typeof e&&e.startsWith(".")?e.slice(1):e+""}return"identifier"===t.type?t.value:""},r=t=>Array.isArray(t)?t.filter(t=>t instanceof Element):t instanceof Element?[t]:"string"==typeof t?Array.from(document.querySelectorAll(t)):[],n=t=>t.startsWith("*"),a=t=>t.substring(1),h=(t,e,s)=>n(e)?(t.style.setProperty(a(e),s+""),1):0,l=(t,e)=>{if(n(e))return getComputedStyle(t).getPropertyValue(a(e))};switch(t.name){case"toggle":{const r=i(t.args[0])||await u(t.args[0],e)+"",n=await s();if(r.startsWith("@")){const t=r.slice(1);for(const e of n)e.hasAttribute(t)?e.removeAttribute(t):e.setAttribute(t,"")}else for(const t of n)t.classList.toggle(r);return e.it=1===n.length?n[0]:n,e.it}case"add":{const r=i(t.args[0])||await u(t.args[0],e)+"",n=await s();if(r.startsWith("@")){const t=r.slice(1);for(const e of n)e.setAttribute(t,"")}else for(const t of n)t.classList.add(r);return e.it=1===n.length?n[0]:n,e.it}case"removeClass":{const r=i(t.args[0])||await u(t.args[0],e)+"",n=await s();if(r.startsWith("@")){const t=r.slice(1);for(const e of n)e.removeAttribute(t)}else for(const t of n)t.classList.remove(r);return e.it=1===n.length?n[0]:n,e.it}case"remove":{const t=await s();for(const e of t)e.remove();return null}case"put":{const i=await u(t.args[0],e),a=t.modifier||"into";if("possessive"===t.target?.type&&n(t.target.property)){const s=r(await u(t.target.object,e));for(const e of s)h(e,t.target.property,i);return e.it=i,i}const o=await s();for(const t of o){const e=i+"";"into"===a?t.innerHTML=e:"before"===a?t.insertAdjacentHTML("beforebegin",e):"after"===a?t.insertAdjacentHTML("afterend",e):"at start of"===a?t.insertAdjacentHTML("afterbegin",e):"at end of"===a&&t.insertAdjacentHTML("beforeend",e)}return e.it=i,i}case"append":{const i=await u(t.args[0],e),r=await s();for(const t of r)t.insertAdjacentHTML("beforeend",i+"");return e.it=i,i}case"set":{const s=t.args[0],i=await u(t.args[1],e);if("variable"===s.type){const t=s.name.slice(1);return("local"===s.scope?c(e.me):o).set(t,i),e.it=i,i}if("possessive"===s.type||"member"===s.type){const t=await u(s.object,e);if(t)return t instanceof Element&&h(t,s.property,i)?(e.it=i,i):(t[s.property]=i,e.it=i,i)}return e.it=i,i}case"get":{const s=await u(t.args[0],e);return e.it=s,s}case"call":{const s=await u(t.args[0],e);return e.it=s,s}case"log":{const s=await Promise.all(t.args.map(t=>u(t,e)));return console.log(...s),s[0]}case"send":{const i=await u(t.args[0],e),r=await s(),n=new CustomEvent(i+"",{bubbles:1,detail:e.it});for(const t of r)t.dispatchEvent(n);return e.it=n,n}case"wait":{const s=await u(t.args[0],e),i="number"==typeof s?s:parseInt(s+"");return await new Promise(t=>setTimeout(t,i)),i}case"waitFor":{const i=await u(t.args[0],e),r=(await s())[0]||e.me;return new Promise(t=>{r.addEventListener(i+"",s=>{e.it=s,t(s)},{once:1})})}case"show":{const t=await s();for(const e of t)e.style.display="",e.classList.remove("hidden");return t}case"hide":{const t=await s();for(const e of t)e.style.display="none";return t}case"transition":{const i=(await u(t.args[0],e)+"").replace(/^\*/,""),r=await u(t.args[1],e),n=await u(t.args[2],e),a="number"==typeof n?n:(n+"").endsWith("ms")?parseInt(n+""):(n+"").endsWith("s")?1e3*parseFloat(n+""):parseInt(n+"")||300,o=await s(),h=[];for(const t of o){const e=t,s=i.replace(/([A-Z])/g,"-$1").toLowerCase(),n=e.style.transition;e.style.transition=`${s} ${a}ms ease`,e.style.setProperty(s,r+""),h.push(new Promise(t=>{const i=()=>{e.style.transition=n,t()},r=t=>{t.propertyName===s&&(e.removeEventListener("transitionend",r),i())};e.addEventListener("transitionend",r),setTimeout(i,a+50)}))}return await Promise.all(h),e.it=1===o.length?o[0]:o,e.it}case"take":{const r=i(await u(t.args[0],e)),n=t.target?await s():[e.me.parentElement];for(const t of n)t.querySelectorAll("."+r).forEach(t=>t.classList.remove(r));return e.me.classList.add(r),e.me}case"increment":case"decrement":{const s=t.args[0],i=await u(t.args[1],e),a="increment"===t.name?i:-i;if("variable"===s.type){const t=s.name.slice(1),i="local"===s.scope?c(e.me):o,r=(i.get(t)||0)+a;return i.set(t,r),e.it=r,r}if("possessive"===s.type&&n(s.property)){const t=r(await u(s.object,e));for(const i of t){const t=(parseFloat(l(i,s.property)||"0")||0)+a;h(i,s.property,t),e.it=t}return e.it}const f=r(await u(s,e));for(const t of f){const s=(parseFloat(t.textContent||"0")||0)+a;t.textContent=s+"",e.it=s}return e.it}case"focus":{const t=await s();for(const e of t)e.focus();return t}case"blur":{const t=await s();for(const e of t)e.blur();return t}case"go":{const s=await u(t.args[0],e),i=(s+"").toLowerCase();return"back"===i?history.back():"forward"===i?history.forward():window.location.href=s+"",null}case"return":throw{type:"return",value:t.args[0]?await u(t.args[0],e):e.it};case"halt":return e.event&&(e.event.preventDefault(),e.event.stopPropagation()),null;default:return console.warn("Unknown command: "+t.name),null}}async function d(t,e){try{return await y(t,e)}catch(t){if("return"===t?.type)throw t;throw t}}async function m(t,e){switch(t.type){case"if":return await u(t.condition,e)?d(t.body,e):t.elseBody?d(t.elseBody,e):null;case"repeat":{const s=await u(t.condition,e),i="number"==typeof s?s:parseInt(s+"");for(let s=0;i>s&&l>s;s++)e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await d(t.body,e);return null}case"for":{const{variable:s,iterable:i}=t.condition,r=await u(i,e),n=Array.isArray(r)?r:r instanceof NodeList?Array.from(r):[r],a=s.startsWith(":")?s.slice(1):s;for(let s=0;n.length>s&&l>s;s++)e.locals.set(a,n[s]),e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await d(t.body,e);return null}case"while":{let s=0;for(;await u(t.condition,e)&&l>s;)e.locals.set("__loop_index__",s),await d(t.body,e),s++;return null}case"fetch":{const{url:s,responseType:i,options:r,method:n}=t.condition;try{const a=await u(s,e),o={};if(n){const t=await u(n,e);o.method=(t+"").toUpperCase()}if(r){const t=await u(r,e);t instanceof FormData?o.body=t:!t||"object"!=typeof t||t instanceof Element||Object.assign(o,t)}const h=await fetch(a+"",o);if(!h.ok)throw Error("HTTP "+h.status);const c=await u(i,e);let l;if("json"===c)l=await h.json();else if("html"===c){const t=await h.text();l=(new DOMParser).parseFromString(t,"text/html").body.innerHTML}else l=await h.text();e.it=l,e.locals.set("it",l),e.locals.set("result",l),e.locals.set("response",h),await d(t.body,e)}catch(t){if("return"===t?.type)throw t;e.locals.set("error",t),console.error("Fetch error:",t)}return null}default:return null}}async function y(t,e){let s;for(const i of t)"command"===i.type?s=await p(i,e):["if","repeat","for","while","fetch"].includes(i.type)&&(s=await m(i,e));return s}async function w(t,e,s){const i={me:e,event:s,locals:new Map,globals:o};if("sequence"===t.type)return y(t.commands,i);if("event"===t.type){const s=t,r=s.event;if(r.startsWith("interval:")){const t=r.split(":")[1],i=t.endsWith("ms")?parseInt(t):t.endsWith("s")?1e3*parseFloat(t):parseInt(t);return void setInterval(async()=>{const t={me:e,locals:new Map,globals:o};try{await y(s.body,t)}catch(t){if("return"!==t?.type)throw t}},i)}if("init"===r){try{await y(s.body,i)}catch(t){if("return"!==t?.type)throw t}return}const n=s.filter?await u(s.filter,i):e,a=n instanceof Element?n:e,h=s.modifiers;let c=async t=>{h.prevent&&t.preventDefault(),h.stop&&t.stopPropagation();const i={me:e,event:t,you:t.target instanceof Element?t.target:void 0,locals:new Map,globals:o};try{await y(s.body,i)}catch(t){if("return"===t?.type)return t.value;throw t}};if(h.debounce){let t;const e=c;c=async s=>{clearTimeout(t),t=setTimeout(()=>e(s),h.debounce)}}if(h.throttle){let t=0;const e=c;c=async s=>{const i=Date.now();h.throttle>i-t||(t=i,await e(s))}}return void a.addEventListener(r,c,{once:!!h.once})}return null}function v(t){const e=t.getAttribute("_");if(e)try{w(new a(e).parse(),t)}catch(t){console.error("HyperFixi Hybrid Complete error:",t,"Code:",e)}}function g(t=document){t.querySelectorAll("[_]").forEach(v)}"undefined"!=typeof window&&(window.hyperfixi={version:"1.0.0-hybrid-complete",parse:t=>new a(t).parse(),async execute(t,e){const s=e||document.body;return w(new a(t).parse(),s)},init:g,process:g,addAliases:function(t){Object.assign(s,t)},addEventAliases:function(t){Object.assign(i,t)},tokenize:e,evaluate:u,commands:["toggle","add","remove","put","append","set","get","call","log","send","trigger","wait","show","hide","transition","take","increment","decrement","focus","blur","go","return","halt"],blocks:["if","else","unless","repeat","for","while","fetch"]},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>g()):g())}();
|
|
1
|
+
!function(){"use strict";const t=new Set(["on","from","to","into","before","after","in","of","at","with","if","else","unless","end","then","and","or","not","repeat","times","for","each","while","until","toggle","add","remove","put","set","get","call","return","append","log","send","trigger","wait","settle","fetch","as","show","hide","take","increment","decrement","focus","blur","go","transition","over","the","a","an","my","its","me","it","you","first","last","next","previous","closest","parent","true","false","null","undefined","is","matches","contains","includes","exists","has","init","every","by","halt","via","values","default","event"]);function e(e){const s=[];let i=0;for(;e.length>i;){if(/\s/.test(e[i])){i++;continue}if("--"===e.slice(i,i+2)){for(;e.length>i&&"\n"!==e[i];)i++;continue}const r=i;if("<"===e[i]&&/[a-zA-Z]/.test(e[i+1]||"")){for(i++;e.length>i&&">"!==e[i];)i++;">"===e[i]&&i++;const t=e.slice(r,i);if(t.endsWith("/>")||t.endsWith(">")){const e=t.slice(1).replace(/\/?>$/,"");s.push({type:"selector",value:e,pos:r});continue}}if("'s"===e.slice(i,i+2)&&!/[a-zA-Z]/.test(e[i+2]||"")){s.push({type:"operator",value:"'s",pos:r}),i+=2;continue}if('"'===e[i]||"'"===e[i]){const t=e[i++];for(;e.length>i&&e[i]!==t;)"\\"===e[i]&&i++,i++;i++,s.push({type:"string",value:e.slice(r,i),pos:r});continue}if(/\d/.test(e[i])||"-"===e[i]&&/\d/.test(e[i+1]||"")){for("-"===e[i]&&i++;e.length>i&&/[\d.]/.test(e[i]);)i++;"ms"===e.slice(i,i+2)?i+=2:"s"!==e[i]||/[a-zA-Z]/.test(e[i+1]||"")?"px"===e.slice(i,i+2)&&(i+=2):i++,s.push({type:"number",value:e.slice(r,i),pos:r});continue}if(":"===e[i]){for(i++;e.length>i&&/[\w]/.test(e[i]);)i++;s.push({type:"localVar",value:e.slice(r,i),pos:r});continue}if("$"===e[i]){for(i++;e.length>i&&/[\w]/.test(e[i]);)i++;s.push({type:"globalVar",value:e.slice(r,i),pos:r});continue}if("@"===e[i]){for(i++;e.length>i&&/[\w-]/.test(e[i]);)i++;s.push({type:"selector",value:e.slice(r,i),pos:r});continue}if("#"===e[i]||"."===e[i]){if("."===e[i]&&e.slice(i+1).match(/^(once|prevent|stop|debounce|throttle)\b/i)){s.push({type:"symbol",value:".",pos:r}),i++;continue}for(i++;e.length>i&&/[\w-]/.test(e[i]);)i++;s.push({type:"selector",value:e.slice(r,i),pos:r});continue}if("["===e[i]){let t=i+1;for(;e.length>t&&/\s/.test(e[t]);)t++;const n=e[t]||"";if(/['"\d\[\]:\$\-]/.test(n)||""===n){s.push({type:"symbol",value:"[",pos:r}),i++;continue}{i++;let t=1;for(;e.length>i&&t>0;)"["===e[i]&&t++,"]"===e[i]&&t--,i++;s.push({type:"selector",value:e.slice(r,i),pos:r});continue}}if("]"===e[i]){s.push({type:"symbol",value:"]",pos:r}),i++;continue}if("'s"===e.slice(i,i+2)){s.push({type:"operator",value:"'s",pos:r}),i+=2;continue}const n=e.slice(i,i+2);if(["==","!=","<=",">=","&&","||"].includes(n))s.push({type:"operator",value:n,pos:r}),i+=2;else if("*"===e[i]&&/[a-zA-Z]/.test(e[i+1]||"")){for(i++;e.length>i&&/[\w-]/.test(e[i]);)i++;s.push({type:"styleProperty",value:e.slice(r,i),pos:r})}else if("+-*/%<>!".includes(e[i]))s.push({type:"operator",value:e[i],pos:r}),i++;else if("()[]{},.".includes(e[i]))s.push({type:"symbol",value:e[i],pos:r}),i++;else{if(/[a-zA-Z_]/.test(e[i])){for(;e.length>i&&/[\w-]/.test(e[i]);)i++;const n=e.slice(r,i),a=t.has(n.toLowerCase())?"keyword":"identifier";s.push({type:a,value:n,pos:r});continue}i++}}return s.push({type:"eof",value:"",pos:e.length}),s}const s={flip:"toggle",switch:"toggle",display:"show",reveal:"show",conceal:"hide",increase:"increment",decrease:"decrement",fire:"trigger",dispatch:"send",navigate:"go",goto:"go"},i={clicked:"click",pressed:"keydown",changed:"change",submitted:"submit",loaded:"load"};function r(t){const e=t.toLowerCase();return s[e]||e}function n(t){const e=t.toLowerCase();return i[e]||e}class a{constructor(t){this.pos=0,this.tokens=e(t)}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}advance(){return this.tokens[this.pos++]}match(...t){const e=this.peek();return t.some(t=>e.value.toLowerCase()===t.toLowerCase())}matchType(...t){return t.includes(this.peek().type)}expect(t){if(!this.match(t)&&r(this.peek().value)!==t)throw Error(`Expected '${t}', got '${this.peek().value}'`);return this.advance()}isAtEnd(){return"eof"===this.peek().type}parse(){return this.match("on")?this.parseEventHandler():this.match("init")?(this.advance(),{type:"event",event:"init",modifiers:{},body:this.parseCommandSequence()}):this.match("every")?this.parseEveryHandler():{type:"sequence",commands:this.parseCommandSequence()}}parseEventHandler(){this.expect("on");const t=this.advance().value,e={};let s;for(;"."===this.peek().value;){this.advance();const t=this.advance().value.toLowerCase();if("once"===t)e.once=1;else if("prevent"===t)e.prevent=1;else if("stop"===t)e.stop=1;else if(("debounce"===t||"throttle"===t)&&"("===this.peek().value){this.advance();const s=this.advance().value;this.expect(")"),"debounce"===t?e.debounce=parseInt(s)||100:e.throttle=parseInt(s)||100}}return this.match("from")&&(this.advance(),s=this.parseExpression()),{type:"event",event:n(t),filter:s,modifiers:e,body:this.parseCommandSequence()}}parseEveryHandler(){return this.expect("every"),{type:"event",event:"interval:"+this.advance().value,modifiers:{},body:this.parseCommandSequence()}}parseCommandSequence(){const t=[];for(;!this.isAtEnd()&&!this.match("end","else");){const e=this.parseCommand();e&&t.push(e),this.match("then","and")&&this.advance()}return t}parseCommand(){if(this.match("if","unless"))return this.parseIf();if(this.match("repeat"))return this.parseRepeat();if(this.match("for"))return this.parseFor();if(this.match("while"))return this.parseWhile();if(this.match("fetch"))return this.parseFetchBlock();const t={toggle:()=>this.parseToggle(),add:()=>this.parseAdd(),remove:()=>this.parseRemove(),put:()=>this.parsePut(),append:()=>this.parseAppend(),set:()=>this.parseSet(),get:()=>this.parseGet(),call:()=>this.parseCall(),log:()=>this.parseLog(),send:()=>this.parseSend(),trigger:()=>this.parseSend(),wait:()=>this.parseWait(),show:()=>this.parseShow(),hide:()=>this.parseHide(),take:()=>this.parseTake(),increment:()=>this.parseIncDec("increment"),decrement:()=>this.parseIncDec("decrement"),focus:()=>this.parseFocusBlur("focus"),blur:()=>this.parseFocusBlur("blur"),go:()=>this.parseGo(),return:()=>this.parseReturn(),transition:()=>this.parseTransition(),halt:()=>this.parseHalt()},e=r(this.peek().value);return t[e]?t[e]():(this.isAtEnd()||this.match("then","and","end","else")||this.advance(),null)}parseIf(){const t=this.match("unless");this.advance();const e=this.parseExpression(),s=this.parseCommandSequence();let i;return this.match("else")&&(this.advance(),i=this.parseCommandSequence()),this.match("end")&&this.advance(),{type:"if",condition:t?{type:"unary",operator:"not",operand:e}:e,body:s,elseBody:i}}parseRepeat(){let t;this.expect("repeat"),this.match("until","while","forever")||(t=this.parseExpression(),this.match("times")&&this.advance());const e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"repeat",condition:t,body:e}}parseFor(){this.expect("for"),this.match("each")&&this.advance();const t=this.advance().value;this.expect("in");const e=this.parseExpression(),s=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"for",condition:{type:"forCondition",variable:t,iterable:e},body:s}}parseWhile(){this.expect("while");const t=this.parseExpression(),e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"while",condition:t,body:e}}parseFetchBlock(){this.expect("fetch");const t=this.parseExpression();let e,s,i={type:"literal",value:"text"};this.match("{")&&(this.pos--,e=this.parseExpression());for(let t=0;3>t;t++)if(!this.match("via")||s)if(this.match("as"))this.advance(),(this.match("a")||this.match("an"))&&this.advance(),i=this.parseExpression();else{if(!this.match("with")||e)break;this.advance(),e=this.parseExpression()}else this.advance(),s=this.parseExpression();return this.match("then")&&this.advance(),{type:"fetch",condition:{type:"fetchConfig",url:t,responseType:i,options:e,method:s},body:this.parseCommandSequence()}}parseToggle(){this.expect("toggle");const t=this.parseExpression();let e;return this.match("on")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"toggle",args:[t],target:e}}parseAdd(){this.expect("add");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"add",args:[t],target:e}}parseRemove(){if(this.expect("remove"),this.matchType("selector")){const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"removeClass",args:[t],target:e}}return{type:"command",name:"remove",args:[],target:this.parseExpression()}}parsePut(){this.expect("put");const t=this.parseExpression();let e="into";if(this.match("into","before","after","at")&&(e=this.advance().value,"at"===e)){const t=this.advance().value;this.expect("of"),e=`at ${t} of`}return{type:"command",name:"put",args:[t],target:this.parseExpression(),modifier:e}}parseAppend(){this.expect("append");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"append",args:[t],target:e}}parseSet(){this.expect("set");const t=this.parseExpression();return this.match("to")?(this.advance(),{type:"command",name:"set",args:[t,this.parseExpression()]}):{type:"command",name:"set",args:[t]}}parseGet(){return this.expect("get"),{type:"command",name:"get",args:[this.parseExpression()]}}parseCall(){return this.expect("call"),{type:"command",name:"call",args:[this.parseExpression()]}}parseLog(){this.expect("log");const t=[];for(;!this.isAtEnd()&&!this.match("then","and","end","else")&&(t.push(this.parseExpression()),this.match(","));)this.advance();return{type:"command",name:"log",args:t}}parseSend(){this.advance();const t=this.advance().value;let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"send",args:[{type:"literal",value:t}],target:e}}parseWait(){if(this.expect("wait"),this.match("for")){this.advance();const t=this.advance().value;let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"waitFor",args:[{type:"literal",value:t}],target:e}}return{type:"command",name:"wait",args:[this.parseExpression()]}}parseShow(){let t;this.expect("show");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"show",args:[],target:t,modifiers:e}}parseHide(){let t;this.expect("hide");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"hide",args:[],target:t,modifiers:e}}parseTake(){this.expect("take");const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"take",args:[t],target:e}}parseIncDec(t){this.advance();const e=this.parseExpression();let s={type:"literal",value:1};return this.match("by")&&(this.advance(),s=this.parseExpression()),{type:"command",name:t,args:[e,s]}}parseFocusBlur(t){let e;return this.advance(),this.isAtEnd()||this.match("then","and","end","else")||(e=this.parseExpression()),{type:"command",name:t,args:[],target:e}}parseGo(){return this.expect("go"),this.match("to")&&this.advance(),this.match("url")&&this.advance(),{type:"command",name:"go",args:[this.parseExpression()]}}parseReturn(){let t;return this.expect("return"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"return",args:t?[t]:[]}}parseHalt(){return this.expect("halt"),this.match("the")&&this.advance(),this.match("event","default")&&this.advance(),{type:"command",name:"halt",args:[]}}parseTransition(){let t;if(this.expect("transition"),this.match("my","its"))t={type:"identifier",value:"my"===this.advance().value?"me":"it"};else if(this.matchType("selector")){const e=this.parseExpression();if("possessive"===e.type)return this.parseTransitionRest(e.object,e.property);t=e}const e=this.peek();let s;return s="styleProperty"===e.type||"identifier"===e.type||"keyword"===e.type?this.advance().value:"opacity",this.parseTransitionRest(t,s)}parseTransitionRest(t,e){let s={type:"literal",value:1};this.match("to")&&(this.advance(),s=this.parseExpression());let i={type:"literal",value:300};return this.match("over")&&(this.advance(),i=this.parseExpression()),{type:"command",name:"transition",args:[{type:"literal",value:e},s,i],target:t}}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.match("or","||");)this.advance(),t={type:"binary",operator:"or",left:t,right:this.parseAnd()};return t}parseAnd(){let t=this.parseEquality();for(;this.match("and","&&")&&!this.isCommandKeyword(this.peek(1));)this.advance(),t={type:"binary",operator:"and",left:t,right:this.parseEquality()};return t}isCommandKeyword(t){return["toggle","add","remove","set","put","log","send","wait","show","hide","increment","decrement","focus","blur","go"].includes(r(t.value))}parseEquality(){let t=this.parseComparison();for(;this.match("==","!=","is","matches","contains","includes","has");){const e=this.advance().value;"is"===e.toLowerCase()&&this.match("not")?(this.advance(),t={type:"binary",operator:"is not",left:t,right:this.parseComparison()}):t={type:"binary",operator:e,left:t,right:this.parseComparison()}}return t}parseComparison(){let t=this.parseAdditive();for(;this.match("<",">","<=",">=");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseAdditive()};return t}parseAdditive(){let t=this.parseMultiplicative();for(;this.match("+","-");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseMultiplicative()};return t}parseMultiplicative(){let t=this.parseUnary();for(;this.match("*","/","%");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseUnary()};return t}parseUnary(){if(this.match("not","!"))return this.advance(),{type:"unary",operator:"not",operand:this.parseUnary()};if(this.match("-")&&"number"===this.peek(1).type){this.advance();const t=this.advance();return{type:"literal",value:-parseFloat(t.value)}}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("'s"))this.advance(),this.peek(),t={type:"possessive",object:t,property:this.advance().value};else if("styleProperty"===this.peek().type)t={type:"possessive",object:t,property:this.advance().value};else if("."===this.peek().value)this.advance(),t={type:"member",object:t,property:this.advance().value};else if("selector"===this.peek().type&&this.peek().value.startsWith("."))t={type:"member",object:t,property:this.advance().value.slice(1)};else if("("===this.peek().value){this.advance();const e=[];for(;!this.match(")");)e.push(this.parseExpression()),this.match(",")&&this.advance();this.expect(")"),t={type:"call",callee:t,args:e}}else{if("["!==this.peek().value||"selector"===t.type)break;{this.advance();const e=this.parseExpression();this.expect("]"),t={type:"member",object:t,property:e,computed:1}}}return t}parsePrimary(){const t=this.peek();if("("===t.value){this.advance();const t=this.parseExpression();return this.expect(")"),t}if("{"===t.value)return this.parseObjectLiteral();if("["===t.value)return this.parseArrayLiteral();if("number"===t.type){this.advance();const e=t.value;return e.endsWith("ms")?{type:"literal",value:parseInt(e),unit:"ms"}:e.endsWith("s")?{type:"literal",value:1e3*parseFloat(e),unit:"ms"}:{type:"literal",value:parseFloat(e)}}if("string"===t.type)return this.advance(),{type:"literal",value:t.value.slice(1,-1)};if(this.match("true"))return this.advance(),{type:"literal",value:1};if(this.match("false"))return this.advance(),{type:"literal",value:0};if(this.match("null"))return this.advance(),{type:"literal",value:null};if(this.match("undefined"))return this.advance(),{type:"literal",value:void 0};if("localVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"local"};if("globalVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"global"};if("selector"===t.type)return this.advance(),{type:"selector",value:t.value};if(this.match("my")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"me"}:{type:"possessive",object:{type:"identifier",value:"me"},property:this.advance().value}}if(this.match("its")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"it"}:{type:"possessive",object:{type:"identifier",value:"it"},property:this.advance().value}}return this.match("me")?(this.advance(),{type:"identifier",value:"me"}):this.match("it")?(this.advance(),{type:"identifier",value:"it"}):this.match("you")?(this.advance(),{type:"identifier",value:"you"}):this.match("the","a","an")?(this.advance(),this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:this.parsePrimary()):this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:this.match("values")?(this.advance(),this.match("of")?(this.advance(),{type:"valuesOf",target:this.parseExpression()}):{type:"identifier",value:t.value}):(this.advance(),{type:"identifier",value:t.value})}parseObjectLiteral(){this.expect("{");const t=[];for(;!this.match("}");){const e=this.advance().value;this.expect(":");const s=this.parseExpression();t.push({key:e,value:s}),this.match(",")&&this.advance()}return this.expect("}"),{type:"object",properties:t}}parseArrayLiteral(){this.expect("[");const t=[];for(;!this.match("]");)t.push(this.parseExpression()),this.match(",")&&this.advance();return this.expect("]"),{type:"array",elements:t}}parsePositionalTarget(){const t=this.peek();return"selector"===t.type?{type:"selector",value:this.advance().value}:"identifier"===t.type||"keyword"===t.type?{type:"identifier",value:this.advance().value}:this.parseExpression()}}const o=new Map,h=new WeakMap;function c(t){let e=h.get(t);return e||(e=new Map,h.set(t,e)),e}const l=1e3;async function u(t,e){switch(t.type){case"literal":return t.value;case"identifier":return"me"===t.value||"my"===t.value?e.me:"it"===t.value?e.it:"you"===t.value?e.you:"event"===t.value?e.event:"body"===t.value?document.body:"document"===t.value?document:"window"===t.value?window:e.locals.has(t.value)?e.locals.get(t.value):t.value in e.me?e.me[t.value]:t.value in window?window[t.value]:t.value;case"variable":if("local"===t.scope)return c(e.me).get(t.name.slice(1));const s=t.name.slice(1);return o.has(s)?o.get(s):window[t.name];case"selector":const i=document.querySelectorAll(t.value);return 1===i.length?i[0]:Array.from(i);case"binary":return async function(t,e){if("has"===t.operator){const s=await u(t.left,e);return s instanceof Element&&"selector"===t.right.type&&t.right.value.startsWith(".")?s.classList.contains(t.right.value.slice(1)):0}const s=await u(t.left,e),i=await u(t.right,e);switch(t.operator){case"+":return s+i;case"-":return s-i;case"*":return s*i;case"/":return s/i;case"%":return s%i;case"==":case"is":return s==i;case"!=":case"is not":return s!=i;case"<":return i>s;case">":return s>i;case"<=":return i>=s;case">=":return s>=i;case"and":case"&&":return s&&i;case"or":case"||":return s||i;case"has":if(s instanceof Element){const t="string"==typeof i?i:i?.value;if("string"==typeof t&&t.startsWith("."))return s.classList.contains(t.slice(1))}return 0;case"contains":case"includes":return"string"==typeof s||Array.isArray(s)?s.includes(i):s instanceof Element?s.contains(i):0;case"matches":return s instanceof Element?s.matches(i):"string"==typeof s?RegExp(i).test(s):0;default:return}}(t,e);case"unary":const r=await u(t.operand,e);return"not"===t.operator?!r:r;case"possessive":case"member":const n=await u(t.object,e);if(null==n)return;const a=t.computed?await u(t.property,e):t.property;return"values"===a&&n instanceof Element?f(n):n[a];case"call":{let s,i=null;if("member"===t.callee.type||"possessive"===t.callee.type){i=await u(t.callee.object,e);const r=t.callee.computed?await u(t.callee.property,e):t.callee.property;s=i?.[r]}else s=await u(t.callee,e);const r=await Promise.all(t.args.map(t=>u(t,e)));return"function"==typeof s?s.apply(i,r):void 0}case"positional":return function(t,e){const s=t.target;let i=[],r=null;switch(("selector"===s.type||"identifier"===s.type||"htmlSelector"===s.type)&&(r=s.value),r&&(i=Array.from(document.querySelectorAll(r))),t.position){case"first":default:return i[0]||null;case"last":return i[i.length-1]||null;case"next":if(r){let t=e.me.nextElementSibling;for(;t;){if(t.matches(r))return t;t=t.nextElementSibling}return null}return e.me.nextElementSibling;case"previous":if(r){let t=e.me.previousElementSibling;for(;t;){if(t.matches(r))return t;t=t.previousElementSibling}return null}return e.me.previousElementSibling;case"closest":return r?e.me.closest(r):null;case"parent":if(r){let t=e.me.parentElement;for(;t;){if(t.matches(r))return t;t=t.parentElement}return null}return e.me.parentElement}}(t,e);case"object":const h={};for(const s of t.properties)h[s.key]=await u(s.value,e);return h;case"array":return Promise.all(t.elements.map(t=>u(t,e)));case"valuesOf":{const s=await u(t.target,e);return s instanceof Element?f(s):new FormData}default:return}}function f(t){if(t instanceof HTMLFormElement)return new FormData(t);const e=new FormData;return t.querySelectorAll("input, select, textarea").forEach(t=>{const s=t.getAttribute("name");s&&"value"in t&&e.append(s,t.value)}),e}async function p(t,e){const s=async()=>{if(!t.target)return[e.me];const s=await u(t.target,e);return Array.isArray(s)?s:s instanceof Element?[s]:"string"==typeof s?Array.from(document.querySelectorAll(s)):[e.me]},i=t=>{if(!t)return"";if("selector"===t.type)return t.value.startsWith("@")?t.value:t.value.slice(1);if("string"===t.type||"literal"===t.type){const e=t.value;return"string"==typeof e&&e.startsWith(".")?e.slice(1):e+""}return"identifier"===t.type?t.value:""},r=t=>Array.isArray(t)?t.filter(t=>t instanceof Element):t instanceof Element?[t]:"string"==typeof t?Array.from(document.querySelectorAll(t)):[],n=t=>t.startsWith("*"),a=t=>t.substring(1),h=(t,e,s)=>n(e)?(t.style.setProperty(a(e),s+""),1):0,l=(t,e)=>{if(n(e))return getComputedStyle(t).getPropertyValue(a(e))};switch(t.name){case"toggle":{const r=i(t.args[0])||await u(t.args[0],e)+"",n=await s();if(r.startsWith("@")){const t=r.slice(1);for(const e of n)e.hasAttribute(t)?e.removeAttribute(t):e.setAttribute(t,"")}else for(const t of n)t.classList.toggle(r);return e.it=1===n.length?n[0]:n,e.it}case"add":{const r=i(t.args[0])||await u(t.args[0],e)+"",n=await s();if(r.startsWith("@")){const t=r.slice(1);for(const e of n)e.setAttribute(t,"")}else for(const t of n)t.classList.add(r);return e.it=1===n.length?n[0]:n,e.it}case"removeClass":{const r=i(t.args[0])||await u(t.args[0],e)+"",n=await s();if(r.startsWith("@")){const t=r.slice(1);for(const e of n)e.removeAttribute(t)}else for(const t of n)t.classList.remove(r);return e.it=1===n.length?n[0]:n,e.it}case"remove":{const t=await s();for(const e of t)e.remove();return null}case"put":{const i=await u(t.args[0],e),a=t.modifier||"into";if("possessive"===t.target?.type&&n(t.target.property)){const s=r(await u(t.target.object,e));for(const e of s)h(e,t.target.property,i);return e.it=i,i}const o=await s();for(const t of o){const e=i+"";"into"===a?t.innerHTML=e:"before"===a?t.insertAdjacentHTML("beforebegin",e):"after"===a?t.insertAdjacentHTML("afterend",e):"at start of"===a?t.insertAdjacentHTML("afterbegin",e):"at end of"===a&&t.insertAdjacentHTML("beforeend",e)}return e.it=i,i}case"append":{const i=await u(t.args[0],e),r=await s();for(const t of r)t.insertAdjacentHTML("beforeend",i+"");return e.it=i,i}case"set":{const s=t.args[0],i=await u(t.args[1],e);if("variable"===s.type){const t=s.name.slice(1);return("local"===s.scope?c(e.me):o).set(t,i),e.it=i,i}if("possessive"===s.type||"member"===s.type){const t=await u(s.object,e);if(t)return t instanceof Element&&h(t,s.property,i)?(e.it=i,i):(t[s.property]=i,e.it=i,i)}return e.it=i,i}case"get":{const s=await u(t.args[0],e);return e.it=s,s}case"call":{const s=await u(t.args[0],e);return e.it=s,s}case"log":{const s=await Promise.all(t.args.map(t=>u(t,e)));return console.log(...s),s[0]}case"trigger":case"send":{const i=await u(t.args[0],e),r=await s(),n=new CustomEvent(i+"",{bubbles:1,detail:e.it});for(const t of r)t.dispatchEvent(n);return e.it=n,n}case"wait":{const s=await u(t.args[0],e),i="number"==typeof s?s:parseInt(s+"");return await new Promise(t=>setTimeout(t,i)),i}case"waitFor":{const i=await u(t.args[0],e),r=(await s())[0]||e.me;return new Promise(t=>{r.addEventListener(i+"",s=>{e.it=s,t(s)},{once:1})})}case"show":{const t=await s();for(const e of t)e.style.display="",e.classList.remove("hidden");return t}case"hide":{const t=await s();for(const e of t)e.style.display="none";return t}case"transition":{const i=(await u(t.args[0],e)+"").replace(/^\*/,""),r=await u(t.args[1],e),n=await u(t.args[2],e),a="number"==typeof n?n:(n+"").endsWith("ms")?parseInt(n+""):(n+"").endsWith("s")?1e3*parseFloat(n+""):parseInt(n+"")||300,o=await s(),h=[];for(const t of o){const e=t,s=i.replace(/([A-Z])/g,"-$1").toLowerCase(),n=e.style.transition;e.style.transition=`${s} ${a}ms ease`,e.style.setProperty(s,r+""),h.push(new Promise(t=>{const i=()=>{e.style.transition=n,t()},r=t=>{t.propertyName===s&&(e.removeEventListener("transitionend",r),i())};e.addEventListener("transitionend",r),setTimeout(i,a+50)}))}return await Promise.all(h),e.it=1===o.length?o[0]:o,e.it}case"take":{const r=i(await u(t.args[0],e)),n=t.target?await s():[e.me.parentElement];for(const t of n)t.querySelectorAll("."+r).forEach(t=>t.classList.remove(r));return e.me.classList.add(r),e.me}case"increment":case"decrement":{const s=t.args[0],i=await u(t.args[1],e),a="increment"===t.name?i:-i;if("variable"===s.type){const t=s.name.slice(1),i="local"===s.scope?c(e.me):o,r=(i.get(t)||0)+a;return i.set(t,r),e.it=r,r}if("possessive"===s.type&&n(s.property)){const t=r(await u(s.object,e));for(const i of t){const t=(parseFloat(l(i,s.property)||"0")||0)+a;h(i,s.property,t),e.it=t}return e.it}const f=r(await u(s,e));for(const t of f){const s=(parseFloat(t.textContent||"0")||0)+a;t.textContent=s+"",e.it=s}return e.it}case"focus":{const t=await s();for(const e of t)e.focus();return t}case"blur":{const t=await s();for(const e of t)e.blur();return t}case"go":{const s=await u(t.args[0],e),i=(s+"").toLowerCase();return"back"===i?history.back():"forward"===i?history.forward():window.location.href=s+"",null}case"return":throw{type:"return",value:t.args[0]?await u(t.args[0],e):e.it};case"halt":return e.event&&(e.event.preventDefault(),e.event.stopPropagation()),null;default:return console.warn("Unknown command: "+t.name),null}}async function d(t,e){try{return await y(t,e)}catch(t){if("return"===t?.type)throw t;throw t}}async function m(t,e){switch(t.type){case"if":return await u(t.condition,e)?d(t.body,e):t.elseBody?d(t.elseBody,e):null;case"repeat":{const s=await u(t.condition,e),i="number"==typeof s?s:parseInt(s+"");for(let s=0;i>s&&l>s;s++)e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await d(t.body,e);return null}case"for":{const{variable:s,iterable:i}=t.condition,r=await u(i,e),n=Array.isArray(r)?r:r instanceof NodeList?Array.from(r):[r],a=s.startsWith(":")?s.slice(1):s;for(let s=0;n.length>s&&l>s;s++)e.locals.set(a,n[s]),e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await d(t.body,e);return null}case"while":{let s=0;for(;await u(t.condition,e)&&l>s;)e.locals.set("__loop_index__",s),await d(t.body,e),s++;return null}case"fetch":{const{url:s,responseType:i,options:r,method:n}=t.condition;try{const a=await u(s,e),o={};if(n){const t=await u(n,e);o.method=(t+"").toUpperCase()}if(r){const t=await u(r,e);t instanceof FormData?o.body=t:!t||"object"!=typeof t||t instanceof Element||Object.assign(o,t)}const h=await fetch(a+"",o);if(!h.ok)throw Error("HTTP "+h.status);const c=await u(i,e);let l;if("json"===c)l=await h.json();else if("html"===c){const t=await h.text();l=(new DOMParser).parseFromString(t,"text/html").body.innerHTML}else l=await h.text();e.it=l,e.locals.set("it",l),e.locals.set("result",l),e.locals.set("response",h),await d(t.body,e)}catch(t){if("return"===t?.type)throw t;e.locals.set("error",t),console.error("Fetch error:",t)}return null}default:return null}}async function y(t,e){let s;for(const i of t)"command"===i.type?s=await p(i,e):["if","repeat","for","while","fetch"].includes(i.type)&&(s=await m(i,e));return s}async function w(t,e,s){const i={me:e,event:s,locals:new Map,globals:o};if("sequence"===t.type)return y(t.commands,i);if("event"===t.type){const s=t,r=s.event;if(r.startsWith("interval:")){const t=r.split(":")[1],i=t.endsWith("ms")?parseInt(t):t.endsWith("s")?1e3*parseFloat(t):parseInt(t);return void setInterval(async()=>{const t={me:e,locals:new Map,globals:o};try{await y(s.body,t)}catch(t){if("return"!==t?.type)throw t}},i)}if("init"===r){try{await y(s.body,i)}catch(t){if("return"!==t?.type)throw t}return}const n=s.filter?await u(s.filter,i):e,a=n instanceof Element?n:e,h=s.modifiers;let c=async t=>{h.prevent&&t.preventDefault(),h.stop&&t.stopPropagation();const i={me:e,event:t,you:t.target instanceof Element?t.target:void 0,locals:new Map,globals:o};try{await y(s.body,i)}catch(t){if("return"===t?.type)return t.value;throw t}};if(h.debounce){let t;const e=c;c=async s=>{clearTimeout(t),t=setTimeout(()=>e(s),h.debounce)}}if(h.throttle){let t=0;const e=c;c=async s=>{const i=Date.now();h.throttle>i-t||(t=i,await e(s))}}return void a.addEventListener(r,c,{once:!!h.once})}return null}function g(t){const e=t.getAttribute("_");if(e)try{w(new a(e).parse(),t)}catch(t){console.error("HyperFixi Hybrid Complete error:",t,"Code:",e)}}function v(t=document){t.querySelectorAll("[_]").forEach(g)}"undefined"!=typeof window&&(window.hyperfixi={version:"1.0.0-hybrid-complete",parse:t=>new a(t).parse(),async execute(t,e){const s=e||document.body;return w(new a(t).parse(),s)},init:v,process:v,addAliases:function(t){Object.assign(s,t)},addEventAliases:function(t){Object.assign(i,t)},tokenize:e,evaluate:u,commands:["toggle","add","remove","put","append","set","get","call","log","send","trigger","wait","show","hide","transition","take","increment","decrement","focus","blur","go","return","halt"],blocks:["if","else","unless","repeat","for","while","fetch"]},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>v()):v())}();
|