@hyperfixi/core 3.1.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -36
- package/dist/ast/command-slots.d.ts +1 -1
- package/dist/ast/nodes.d.ts +2 -0
- package/dist/ast-utils/index.cjs +193 -48
- package/dist/ast-utils/index.mjs +193 -48
- package/dist/ast-utils/interchange/types.d.ts +19 -1
- package/dist/behaviors/index.cjs +19 -0
- package/dist/behaviors/index.mjs +19 -0
- package/dist/bundle-generator/index.cjs +36 -17
- package/dist/bundle-generator/index.mjs +36 -17
- package/dist/bundle-generator/parser-templates.d.ts +1 -1
- package/dist/chunks/bridge-CI9SOl8u.js +2 -0
- package/dist/chunks/browser-modular-7CpI5VF2.js +2 -0
- package/dist/chunks/index-BwXDEK0m.js +2 -0
- package/dist/chunks/index-DQi2o8Lk.js +2 -0
- package/dist/chunks/index-uCOQ8Qn0.js +2 -0
- package/dist/commands/animation/transition.d.ts +12 -6
- package/dist/commands/helpers/loop-executor.d.ts +2 -2
- package/dist/commands/helpers/numeric-target-parser.d.ts +1 -1
- package/dist/commands/helpers/variable-access.d.ts +5 -2
- package/dist/commands/helpers/write-target.d.ts +5 -0
- package/dist/commands/index.cjs +938 -425
- package/dist/commands/index.mjs +938 -425
- package/dist/commands/templates/render.d.ts +4 -4
- package/dist/commands/utility/beep.d.ts +0 -3
- package/dist/expressions/index.cjs +7 -13
- package/dist/expressions/index.mjs +7 -13
- package/dist/htmx/i18n-hooks.d.ts +4 -1
- package/dist/hyperfixi-browser-classic-i18n.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-multilingual.js +1 -1
- package/dist/hyperfixi.js +1 -1
- package/dist/hyperfixi.mjs +1 -1
- package/dist/index.cjs +1149 -485
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +1149 -485
- package/dist/lib/swap-executor.d.ts +1 -1
- package/dist/lokascript-browser-classic-i18n.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/metadata.cjs +9 -9
- package/dist/metadata.d.ts +1 -1
- package/dist/metadata.mjs +9 -9
- package/dist/parser/command-grammar.d.ts +1 -0
- package/dist/parser/full-parser.cjs +396 -153
- package/dist/parser/full-parser.mjs +396 -153
- package/dist/parser/helpers/parsing-helpers.d.ts +3 -0
- package/dist/parser/hybrid/index.cjs +3 -0
- package/dist/parser/hybrid/index.mjs +3 -0
- package/dist/parser/hybrid/parser-core.cjs +3 -0
- package/dist/parser/hybrid/parser-core.mjs +3 -0
- package/dist/parser/hybrid-parser.cjs +3 -0
- package/dist/parser/hybrid-parser.mjs +3 -0
- package/dist/parser/parser-types.d.ts +2 -0
- package/dist/parser/parser.d.ts +9 -0
- package/dist/parser/pratt-parser.d.ts +2 -0
- package/dist/registry/index.cjs +535 -210
- package/dist/registry/index.mjs +535 -210
- package/dist/utils/beep.d.ts +8 -0
- package/dist/version.d.ts +1 -1
- package/package.json +21 -18
- package/vocab/htmx/ar.js +22 -20
- package/vocab/htmx/bn.js +21 -5
- package/vocab/htmx/de.js +33 -10
- package/vocab/htmx/en.js +4 -1
- package/vocab/htmx/es.js +28 -9
- package/vocab/htmx/fr.js +28 -8
- package/vocab/htmx/he.js +22 -1
- package/vocab/htmx/hi.js +28 -7
- package/vocab/htmx/id.js +29 -10
- package/vocab/htmx/it.js +26 -5
- package/vocab/htmx/ja.js +36 -11
- package/vocab/htmx/ko.js +27 -6
- package/vocab/htmx/ms.js +24 -1
- package/vocab/htmx/pl.js +27 -7
- package/vocab/htmx/pt.js +30 -9
- package/vocab/htmx/qu.js +32 -9
- package/vocab/htmx/ru.js +28 -6
- package/vocab/htmx/sw.js +28 -8
- package/vocab/htmx/th.js +19 -1
- package/vocab/htmx/tl.js +24 -1
- package/vocab/htmx/tr.js +34 -8
- package/vocab/htmx/uk.js +28 -6
- package/vocab/htmx/vi.js +27 -19
- package/vocab/htmx/zh.js +28 -9
- package/dist/chunks/bridge-D7qrHhV0.js +0 -2
- package/dist/chunks/browser-modular-C4LFxfoS.js +0 -2
- package/dist/chunks/index-C7lqD4mo.js +0 -2
- package/dist/chunks/index-CAPhqA6k.js +0 -2
- package/dist/chunks/index-CLdRyZaP.js +0 -2
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","prepend","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.cmdMap={toggle:()=>this.parseToggle(),add:()=>this.parseAdd(),remove:()=>this.parseRemove(),put:()=>this.parsePut(),append:()=>this.parseInsertion("append"),prepend:()=>this.parseInsertion("prepend"),set:()=>this.parseSet(),get:()=>this.parseGet(),call:()=>this.parseCall(),log:()=>this.parseLog(),send:()=>this.parseSend("to"),trigger:()=>this.parseSend("on"),wait:()=>this.parseWait(),show:()=>this.parseShow(),hide:()=>this.parseHide(),take:()=>this.parseTake(),empty:()=>this.parseEmpty(),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(),copy:()=>this.parseCopy(),beep:()=>this.parseBeep(),push:()=>this.parseUrlCommand("push"),replace:()=>this.parseUrlCommand("replace"),morph:()=>this.parseMorph(),js:()=>this.parseJs(),throw:()=>this.parseThrow(),break:()=>this.parseBare("break"),continue:()=>this.parseBare("continue"),exit:()=>this.parseBare("exit")},this.source=t,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=r(this.peek().value);if(this.cmdMap[t])return this.cmdMap[t]();if(this.match("catch","finally"))throw Error(`'${this.peek().value}' needs the full parser (use hyperfixi.js)`);const e=this.peek();if(!(this.isAtEnd()||"identifier"!==e.type&&"keyword"!==e.type||this.match("then","and","end","else")))throw Error(`'${e.value}' needs the full parser (use hyperfixi.js)`);return 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}}parseNakedUrl(){const t=this.peek(),e="operator"===t.type&&"/"===t.value,s=("http"===t.value||"https"===t.value)&&"://"===this.source.slice(t.pos+t.value.length,t.pos+t.value.length+3);if(!e&&!s)return null;let n=t.pos;for(;this.source.length>n&&!/\s/.test(this.source[n]);)n++;for(;!this.isAtEnd()&&this.peek().pos<n;)this.advance();return{type:"literal",value:this.source.slice(t.pos,n)}}parseFetchBlock(){this.expect("fetch");const t=this.parseNakedUrl()??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")&&/^[.@]/.test(this.peek().value)){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}}parseInsertion(t){this.expect(t);const e=this.parseExpression();let s;return this.match("to")&&(this.advance(),s=this.parseExpression()),{type:"command",name:t,args:[e],target:s}}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(t){this.advance();const e=this.advance();let s,n=e.value,i=e.pos+e.value.length;for(;!this.isAtEnd()&&"localVar"===this.peek().type&&this.peek().pos===i;){const t=this.advance();n+=t.value,i=t.pos+t.value.length}return this.match(t)&&(this.advance(),s=this.parseExpression()),{type:"command",name:"send",args:[{type:"literal",value:n}],target:s}}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]:[]}}parseEmpty(){let t;return this.expect("empty"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"empty",args:[],target:t}}parseCopy(){return this.expect("copy"),{type:"command",name:"copy",args:[this.parseExpression()]}}parseBeep(){this.advance(),this.match("!")&&this.advance();const t=[];for(;!this.isAtEnd()&&!this.match("then","and","end","else")&&(t.push(this.parseExpression()),this.match(","));)this.advance();return{type:"command",name:"beep",args:t}}parseUrlCommand(t){this.advance(),this.match("url")&&this.advance();const e=this.parseExpression(),s={};return this.match("with")&&(this.advance(),this.match("title")&&(this.advance(),s.title=this.parseExpression())),{type:"command",name:t,args:[e],modifiers:s}}parseMorph(){let t;this.expect("morph"),this.match("over")&&(this.advance(),t="over");const e=this.parseExpression();return this.match("with","to","into")&&this.advance(),{type:"command",name:"morph",args:[this.parseExpression()],target:e,modifier:t}}parseJs(){if(this.advance(),this.match("(")){for(;!this.isAtEnd()&&!this.match(")");)this.advance();this.match(")")&&this.advance()}const t=this.peek().pos;for(;!this.isAtEnd()&&!this.match("end");)this.advance();const e=this.peek().pos;return this.match("end")&&this.advance(),{type:"command",name:"js",args:[{type:"literal",value:this.source.slice(t,e).trim()}]}}parseThrow(){let t;return this.expect("throw"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"throw",args:t?[t]:[]}}parseBare(t){return this.advance(),{type:"command",name:t,args:[]}}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()}}var c="moveBefore"in Element.prototype,h=[0,1,0,0,0,0,0,0,0,1,0,1,0],l=new Set,u=new Set,f=new Set,p=new Set,d=new Set,m=new Set;function y(t,e,s={}){"string"==typeof e&&(e=b(e).childNodes),!s.preserveChanges&&$(t)&&g(t),new x(s).morph(t,e)}function w(t,e,s={}){if("string"==typeof e){const t=b(e);if(!t.firstChild||1!==t.childNodes.length||1!==t.firstChild.nodeType)throw Error("[Morphlex] The string was not a valid HTML element.");e=t.firstChild}if(1!==t.nodeType||1!==e.nodeType||t.localName!==e.localName)throw Error("[Morphlex] You can only do an inner morph with matching elements.");$(t)&&g(t),new x(s).visitChildNodes(t,e)}function g(t){for(const e of t.querySelectorAll("input"))(e.name&&e.value!==e.defaultValue||e.checked!==e.defaultChecked)&&e.setAttribute("morphlex-dirty","");for(const e of t.querySelectorAll("option"))e.value&&e.selected!==e.defaultSelected&&e.setAttribute("morphlex-dirty","");for(const e of t.querySelectorAll("textarea"))e.value!==e.defaultValue&&e.setAttribute("morphlex-dirty","")}function b(t){const e=document.createElement("template");return e.innerHTML=t.trim(),e.content}function v(t,e,s){if(e!==s){if(e.parentNode===t){if(e.nextSibling===s)return;if(c)return void t.moveBefore(e,s)}t.insertBefore(e,s)}}class x{#t=new WeakMap;#e=new WeakMap;#s;constructor(t={}){this.#s=t}morph(t,e){$(t)&&this.#n(t),e instanceof NodeList?(this.#i(e),this.#r(t,e)):$(e)&&(this.#o(e),this.#a(t,e))}#r(t,e){const s=e.length;if(0===s)this.#c(t);else if(1===s)this.#a(t,e[0]);else if(s>1){const s=[...e];this.#a(t,s.shift());const n=t.nextSibling,i=t.parentNode||document;for(let t=0;s.length>t;t++){const e=s[t];(this.#s.beforeNodeAdded?.(i,e,n)??1)&&(i.insertBefore(e,n),this.#s.afterNodeAdded?.(e))}}}#a(t,e){t!==e&&(t.isEqualNode(e)||(1===t.nodeType&&1===e.nodeType?t.localName===e.localName?this.#h(t,e):this.#l(t,e):this.#u(t,e)))}#h(t,e){(this.#s.beforeNodeVisited?.(t,e)??1)&&((t.hasAttributes()||e.hasAttributes())&&this.#f(t,e),"textarea"===t.localName&&"textarea"===e.localName?this.#p(t,e):(t.hasChildNodes()||e.hasChildNodes())&&this.visitChildNodes(t,e),this.#s.afterNodeVisited?.(t,e))}#l(t,e){(this.#s.beforeNodeVisited?.(t,e)??1)&&(this.#d(t,e),this.#s.afterNodeVisited?.(t,e))}#u(t,e){(this.#s.beforeNodeVisited?.(t,e)??1)&&(t.nodeType===e.nodeType&&null!==t.nodeValue&&null!==e.nodeValue?t.nodeValue=e.nodeValue:this.#d(t,e),this.#s.afterNodeVisited?.(t,e))}#f(t,e){t.hasAttribute("morphlex-dirty")&&t.removeAttribute("morphlex-dirty");for(const{name:s,value:n}of e.attributes){"value"===s&&E(t)&&t.value!==n&&(this.#s.preserveChanges&&t.value!==t.defaultValue||(t.value=n)),"selected"===s&&k(t)&&!t.selected&&(this.#s.preserveChanges&&t.selected!==t.defaultSelected||(t.selected=1)),"checked"===s&&E(t)&&!t.checked&&(this.#s.preserveChanges&&t.checked!==t.defaultChecked||(t.checked=1));const e=t.getAttribute(s);e!==n&&(this.#s.beforeAttributeUpdated?.(t,s,n)??1)&&(t.setAttribute(s,n),this.#s.afterAttributeUpdated?.(t,s,e))}for(const{name:s,value:n}of t.attributes)e.hasAttribute(s)||("selected"===s&&k(t)&&t.selected&&(this.#s.preserveChanges&&t.selected!==t.defaultSelected||(t.selected=0)),"checked"===s&&E(t)&&t.checked&&(this.#s.preserveChanges&&t.checked!==t.defaultChecked||(t.checked=0)),(this.#s.beforeAttributeUpdated?.(t,s,null)??1)&&(t.removeAttribute(s),this.#s.afterAttributeUpdated?.(t,s,n)))}#p(t,e){const s=e.textContent||"",n=t.value!==t.defaultValue;t.textContent!==s&&(t.textContent=s),this.#s.preserveChanges&&n||(t.value=t.defaultValue)}visitChildNodes(t,e){if(!(this.#s.beforeChildrenVisited?.(t)??1))return;const s=t,n=[...t.childNodes],i=[...e.childNodes];l.clear(),u.clear(),f.clear(),p.clear(),d.clear(),m.clear();const r=[],o=[],a=[],c=[],h=[],y=[];for(let t=0;n.length>t;t++){const e=n[t],s=e.nodeType;c[t]=s,1===s?(y[t]=e.localName,""!==e.id?f.add(t):u.add(t)):3===s&&""===e.textContent?.trim()?m.add(t):l.add(t)}for(let t=0;i.length>t;t++){const e=i[t],s=e.nodeType;if(a[t]=s,1===s)h[t]=e.localName,d.add(t);else{if(3===s&&""===e.textContent?.trim())continue;p.add(t)}}for(const t of d){const e=h[t],s=i[t];for(const i of u)if(e===y[i]&&n[i].isEqualNode(s)){r[t]=i,o[t]=0,u.delete(i),d.delete(t);break}}for(const t of d){const e=i[t],s=e.id,a=this.#t.get(e);if(""!==s||a)t:for(const e of f){const i=n[e];if(h[t]===y[e]){if(""!==s&&s===i.id){r[t]=e,o[t]=1,f.delete(e),d.delete(t);break t}if(a){const s=this.#e.get(i);if(s)for(let n=0;a.length>n;n++)if(s.has(a[n])){r[t]=e,o[t]=1,f.delete(e),d.delete(t);break t}}}}}for(const t of d){const e=i[t],s=e.getAttribute("name"),a=e.getAttribute("href"),c=e.getAttribute("src");for(const e of u){const i=n[e];if(h[t]===y[e]&&(s&&s===i.getAttribute("name")||a&&a===i.getAttribute("href")||c&&c===i.getAttribute("src"))){r[t]=e,o[t]=1,u.delete(e),d.delete(t);break}}}for(const t of d){const e=i[t],s=h[t];for(const i of u)if(s===y[i]){if("input"===s&&n[i].type!==e.type)continue;r[t]=i,o[t]=1,u.delete(i),d.delete(t);break}}for(const t of p){const e=i[t];for(const s of l)if(n[s].isEqualNode(e)){r[t]=s,o[t]=0,l.delete(s),p.delete(t);break}}for(const t of p){const e=a[t];for(const s of l)if(e===c[s]){r[t]=s,o[t]=2,l.delete(s),p.delete(t);break}}for(const t of l)this.#c(n[t]);for(const t of m)this.#c(n[t]);for(const t of u)this.#c(n[t]);for(const t of f)this.#c(n[t]);const w=function(t){const e=t.length;if(0===e)return[];const s=[],n=[],i=Array(e);for(let r=0;e>r;r++){const e=t[r];if(void 0===e)continue;let o=0,a=s.length;for(;a>o;){const t=Math.floor((o+a)/2);e>s[t]?o=t+1:a=t}i[r]=o>0?n[o-1]:-1,o===s.length?(s.push(e),n.push(r)):(s[o]=e,n[o]=r)}const r=[];if(0===n.length)return r;let o=n[n.length-1];for(;void 0!==o&&-1!==o;)r.unshift(o),o=i[o];return r}(r),g=Array(n.length);for(let t=0;w.length>t;t++)g[r[w[t]]]=1;let b=s.firstChild;for(let t=0;i.length>t;t++){const e=i[t],a=r[t];if(void 0!==a){const i=n[a],r=o[t];g[a]||v(s,i,b),0===r||(1===r?this.#h(i,e):this.#a(i,e)),b=i.nextSibling}else(this.#s.beforeNodeAdded?.(s,e,b)??1)&&(s.insertBefore(e,b),this.#s.afterNodeAdded?.(e),b=e.nextSibling)}this.#s.afterChildrenVisited?.(t)}#d(t,e){const s=t.parentNode||document,n=t;(this.#s.beforeNodeRemoved?.(t)??1)&&(this.#s.beforeNodeAdded?.(s,e,n)??1)&&(s.insertBefore(e,n),this.#s.afterNodeAdded?.(e),t.remove(),this.#s.afterNodeRemoved?.(t))}#c(t){(this.#s.beforeNodeRemoved?.(t)??1)&&(t.remove(),this.#s.afterNodeRemoved?.(t))}#i(t){for(const e of t)$(e)&&this.#o(e)}#o(t){const e=this.#t;for(const s of t.querySelectorAll("[id]")){const n=s.id;if(""===n)continue;let i=s;for(;i;){const s=e.get(i);if(s?s.push(n):e.set(i,[n]),i===t)break;i=i.parentElement}}}#n(t){const e=this.#e;for(const s of t.querySelectorAll("[id]")){const n=s.id;if(""===n)continue;let i=s;for(;i;){const s=e.get(i);if(s?s.add(n):e.set(i,new Set([n])),i===t)break;i=i.parentElement}}}}function E(t){return"input"===t.localName}function k(t){return"option"===t.localName}function $(t){return!!h[t.nodeType]}const M=new Map,S=new WeakMap;function T(t){let e=S.get(t);return e||(e=new Map,S.set(t,e)),e}const A=1e3;async function O(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 T(e.me).get(t.name.slice(1));const s=t.name.slice(1);return M.has(s)?M.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 O(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 O(t.left,e),n=await O(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 O(t.operand,e);return"not"===t.operator?!i:i;case"possessive":case"member":const r=await O(t.object,e);if(null==r)return;const o=t.computed?await O(t.property,e):t.property;return"values"===o&&r instanceof Element?H(r):r[o];case"call":{let s,n=null;if("member"===t.callee.type||"possessive"===t.callee.type){n=await O(t.callee.object,e);const i=t.callee.computed?await O(t.callee.property,e):t.callee.property;s=n?.[i]}else s=await O(t.callee,e);const i=await Promise.all(t.args.map(t=>O(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 O(s.value,e);return a;case"array":return Promise.all(t.elements.map(t=>O(t,e)));case"valuesOf":{const s=await O(t.target,e);return s instanceof Element?H(s):new FormData}default:return}}function H(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 j(t,e){const s=async()=>{if(!t.target)return[e.me];const s=await O(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,c=(t,e)=>{if(r(e))return getComputedStyle(t).getPropertyValue(o(e))};switch(t.name){case"toggle":{const i=n(t.args[0])||await O(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 O(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"remove":{const t=await s();for(const e of t)e.remove();return null}case"removeClass":{const i=n(t.args[0])||await O(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 r}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"put":{const n=await O(t.args[0],e),o=t.modifier||"into";if("possessive"===t.target?.type&&r(t.target.property)){const s=i(await O(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 O(t.args[0],e),i=await s();for(const t of i)t.insertAdjacentHTML("beforeend",n+"");return e.it=n,n}case"prepend":{const n=await O(t.args[0],e),i=await s();for(const t of i)t.insertAdjacentHTML("afterbegin",n+"");return e.it=n,n}case"take":{const i=n(t.args[0]),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"empty":{const t=await s();for(const e of t)e.innerHTML="";return t}case"set":{const s=t.args[0],n=await O(t.args[1],e);if("variable"===s.type){const t=s.name.slice(1);return("local"===s.scope?T(e.me):M).set(t,n),e.it=n,n}if("possessive"===s.type||"member"===s.type){const t=await O(s.object,e);if(t)return t instanceof Element&&r(s.property)?a(t,s.property,n):t[s.property]=n,e.it=n,n}return e.it=n,n}case"get":{const s=await O(t.args[0],e);return e.it=s,s}case"increment":{const s=t.args[0],n=t.args[1]?await O(t.args[1],e):1;if("variable"===s.type){const t=s.name.slice(1),i="local"===s.scope?T(e.me):M,r=(i.get(t)||0)+n;return i.set(t,r),e.it=r,r}if("possessive"===s.type&&r(s.property)){const t=i(await O(s.object,e));for(const i of t){const t=(parseFloat(c(i,s.property)||"0")||0)+n;a(i,s.property,t),e.it=t}return e.it}const o=i(await O(s,e));for(const t of o){const s=(parseFloat(t.textContent||"0")||0)+n;t.textContent=s+"",e.it=s}return e.it}case"decrement":{const s=t.args[0],n=t.args[1]?await O(t.args[1],e):1;if("variable"===s.type){const t=s.name.slice(1),i="local"===s.scope?T(e.me):M,r=(i.get(t)||0)-n;return i.set(t,r),e.it=r,r}if("possessive"===s.type&&r(s.property)){const t=i(await O(s.object,e));for(const i of t){const t=(parseFloat(c(i,s.property)||"0")||0)-n;a(i,s.property,t),e.it=t}return e.it}const o=i(await O(s,e));for(const t of o){const s=(parseFloat(t.textContent||"0")||0)-n;t.textContent=s+"",e.it=s}return e.it}case"wait":{const s=await O(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 O(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"transition":{const n=(await O(t.args[0],e)+"").replace(/^\*/,""),i=await O(t.args[1],e),r=await O(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"send":{const n=await O(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"log":{const s=await Promise.all(t.args.map(t=>O(t,e)));return console.log(...s),s[0]}case"call":{const s=await O(t.args[0],e);return e.it=s,s}case"copy":{const s=await O(t.args[0],e);let n="";n="string"==typeof s?s:s instanceof Element?s.textContent||"":s+"";try{if(navigator.clipboard)await navigator.clipboard.writeText(n);else{const t=document.createElement("textarea");t.value=n,t.style.cssText="position:fixed;top:0;left:-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}return e.me instanceof Element&&e.me.dispatchEvent(new CustomEvent("copy:success",{bubbles:1,detail:{text:n}})),e.it=n,n}catch(t){throw e.me instanceof Element&&e.me.dispatchEvent(new CustomEvent("copy:error",{bubbles:1,detail:{error:t}})),t}}case"beep":{const s=await Promise.all(t.args.map(t=>O(t,e))),n=s.length>0?s:[e.it];for(const t of n){const e=null===t?"null":void 0===t?"undefined":Array.isArray(t)?`Array[${t.length}]`:t instanceof Element?`Element<${t.tagName.toLowerCase()}>`:typeof t;console.log("[beep]",e+":",t)}return n[0]}case"go":{const s=await O(t.args[0],e),n=(s+"").toLowerCase();return"back"===n?history.back():"forward"===n?history.forward():"bottom"===n?e.me.scrollIntoView({block:"end",behavior:"smooth"}):"top"===n?e.me.scrollIntoView({block:"start",behavior:"smooth"}):window.location.href=s+"",null}case"push":{const s=await O(t.args[0],e)+"";let n="";return t.modifiers?.title&&(n=await O(t.modifiers.title,e)+""),window.history.pushState(null,"",s),n&&(document.title=n),window.dispatchEvent(new CustomEvent("lokascript:pushurl",{detail:{url:s,title:n}})),{url:s,title:n,mode:"push"}}case"replace":{const s=await O(t.args[0],e)+"";let n="";return t.modifiers?.title&&(n=await O(t.modifiers.title,e)+""),window.history.replaceState(null,"",s),n&&(document.title=n),window.dispatchEvent(new CustomEvent("lokascript:replaceurl",{detail:{url:s,title:n}})),{url:s,title:n,mode:"replace"}}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"return":throw{type:"return",value:t.args[0]?await O(t.args[0],e):e.it};case"break":throw{type:"break"};case"continue":throw{type:"continue"};case"halt":{const s=t.args[0];let n=e.event;if("identifier"===s?.type&&"the"===s.name&&"event"===t.args[1]?.name)n=e.event;else if(s){const t=await O(s,e);t?.preventDefault&&(n=t)}if(n&&"function"==typeof n.preventDefault)return n.preventDefault(),n.stopPropagation(),{halted:1,eventHalted:1};const i=Error("HALT_EXECUTION");throw i.isHalt=1,i}case"exit":{const t=Error("EXIT_COMMAND");throw t.isExit=1,t}case"throw":{const s=t.args[0]?await O(t.args[0],e):"Error";throw s instanceof Error?s:Error(s+"")}case"js":{const s=t.args[0];let n="";n="string"===s.type?s.value:"template"===s.type?await O(s,e):await O(s,e)+"";const i={me:e.me,it:e.it,event:e.event,target:e.me,locals:Object.fromEntries(e.locals),globals:Object.fromEntries(M),document:"undefined"!=typeof document?document:void 0,window:"undefined"!=typeof window?window:void 0};try{const t=Function("ctx",`with(ctx) { return (async () => { ${n} })(); }`),s=await t(i);return e.it=s,s}catch(t){throw console.error("[js] Execution error:",t),t}}case"morph":{const n=await s(),i=await O(t.args[0],e)+"",r="over"===t.modifier;for(const t of n)try{if(r)y(t,i);else{const e=document.createElement(t.tagName);e.innerHTML=i,w(t,e)}}catch(e){console.warn("[LokaScript] Morph failed, falling back:",e),r?t.outerHTML=i:t.innerHTML=i}return e.it=1===n.length?n[0]:n,e.it}default:return console.error(`[hyperfixi] Unknown command "${t.name}" \u2014 not in this bundle. Use hyperfixi.js (full bundle).`),null}}async function _(t,e){try{return await F(t,e)}catch(t){if("return"===t?.type)throw t;throw t}}async function C(t,e){switch(t.type){case"if":return await O(t.condition,e)?_(t.body,e):t.elseBody?_(t.elseBody,e):null;case"repeat":{const s=await O(t.condition,e),n="number"==typeof s?s:parseInt(s+"");for(let s=0;n>s&&A>s;s++){e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1);try{await _(t.body,e)}catch(t){if("break"===t?.type)break;if("continue"===t?.type)continue;throw t}}return null}case"for":{const{variable:s,iterable:n}=t.condition,i=await O(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&&A>s;s++){e.locals.set(o,r[s]),e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1);try{await _(t.body,e)}catch(t){if("break"===t?.type)break;if("continue"===t?.type)continue;throw t}}return null}case"while":{let s=0;for(;await O(t.condition,e)&&A>s;){e.locals.set("__loop_index__",s);try{await _(t.body,e)}catch(t){if("break"===t?.type)break;if("continue"===t?.type){s++;continue}throw t}s++}return null}case"fetch":{const{url:s,responseType:n,options:i,method:r}=t.condition;try{const o=await O(s,e),a={};if(r){const t=await O(r,e);a.method=(t+"").toUpperCase()}if(i){const t=await O(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 O(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 _(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 F(t,e){let s;for(const n of t)"command"===n.type?s=await j(n,e):["if","repeat","for","while","fetch"].includes(n.type)&&(s=await C(n,e));return s}async function L(t,e,s){const n={me:e,event:s,locals:new Map,globals:M};if("sequence"===t.type)try{return await F(t.commands,n)}catch(t){if("return"===t?.type)return t.value;throw t}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:M};try{await F(s.body,t)}catch(t){if("return"!==t?.type)throw t}},n)}if("init"===i){try{await F(s.body,n)}catch(t){if("return"!==t?.type)throw t}return}const r=s.filter?await O(s.filter,n):e,o=r instanceof Element?r:e,a=s.modifiers;let c=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:M};try{await F(s.body,n)}catch(t){if("return"===t?.type)return t.value;throw t}};if(a.debounce){let t;const e=c;c=async s=>{clearTimeout(t),t=setTimeout(()=>e(s),a.debounce)}}if(a.throttle){let t=0;const e=c;c=async s=>{const n=Date.now();a.throttle>n-t||(t=n,await e(s))}}return void o.addEventListener(i,c,{once:!!a.once})}return null}const q=t=>new a(t).parse(),P=function(t,e){return(s=document)=>{s.querySelectorAll("[_]").forEach(s=>{const n=s.getAttribute("_");if(n)try{e(t(n),s)}catch(t){console.error("HyperFixi Hybrid Complete error:",t,"Code:",n)}})}}(q,L),W={version:"1.0.0-hybrid-complete",parse:q,execute:async(t,e)=>L(q(t),e||document.body),init:P,process:P,addAliases:function(t){Object.assign(n,t)},addEventAliases:function(t){Object.assign(i,t)},tokenize:s,evaluate:O,commands:["toggle","add","remove","removeClass","show","hide","put","append","prepend","take","empty","set","get","increment","decrement","wait","transition","send","trigger","log","call","copy","beep","go","push","push-url","replace","replace-url","focus","blur","return","break","continue","halt","exit","throw","js","morph"],blocks:["if","else","unless","repeat","for","while","fetch"]};!function(t,e,s="hyperfixi"){"undefined"!=typeof window&&(window[s]=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>e()):e())}(W,P);const N=["__proto__","constructor","prototype"],I=/(?:"([^"]+)"|'([^']+)'|([^\s,:]+))(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|<((?:[^/]|\/(?!>))+)\/>|([^\s,]+)))?(?=\s|,|$)/g,R=/,(?![^[]*\])(?![^(]*\))(?![^<]*\/>)(?=(?:[^"']|"[^"]*"|'[^']*')*$)/;function D(t){if(!t)return{};if(t.startsWith("{"))return JSON.parse(t);const e={};for(const s of t.matchAll(I)){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(".");G(u?h.split(".").reduceRight((t,e)=>({[e]:t}),l):{[h]:l},e)}return e}function G(t,e){const s="string"==typeof t?D(t):t;for(const[t,n]of Object.entries(s))N.includes(t)||(n&&"object"==typeof n&&!Array.isArray(n)&&e[t]&&"object"==typeof e[t]&&!Array.isArray(e[t])?G(n,e[t]):e[t]=n);return e}let z={nameOf:(t,e,s)=>`${e}-${s}`,selectorFor:(t,e)=>`[${t}-${e}]`,eventNameOf:(t,e)=>e};function B(){return z}const J={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"},U={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"},Z=new Set(["__proto__","constructor","prototype"]),V=new Set;function X(t,e){const s=`${e}:${t}`;V.has(s)||(V.add(s),console.warn(`[hyperfixi] htmx ${e} modifier "${t}" is recognized but not supported; ignoring it.`))}function K(t){V.has(t)||(V.add(t),console.warn("[hyperfixi] "+t))}function Y(t){K(t+' uses a "js:" prefix, which is not evaluated; ignoring it.')}function Q(t){return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}'`}function tt(t){return null===t?"null":"number"==typeof t||"boolean"==typeof t?t+"":"string"==typeof t?Q(t):Array.isArray(t)?`[${t.map(tt).join(", ")}]`:et(t)}function et(t){const e=Object.entries(t).filter(([t])=>!Z.has(t)).map(([t,e])=>`${Q(t)}: ${tt(e)}`);return e.length?`{ ${e.join(", ")} }`:"{}"}const st=/^([\d.]+)\s*(ms|s|m)?$/;function nt(t){if("number"==typeof t)return Number.isFinite(t)?Math.round(t):null;if("string"!=typeof t)return null;const e=t.trim().match(st);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 it=new Set(["window","document","body","me"]);function rt(t){const e=t.trim();return e?"this"===e?"me":it.has(e)?e:/^(closest|find|next|previous)\s+/.test(e)?(X("from:"+e.split(/\s+/)[0],"trigger"),null):`<${e}/>`:null}const ot=/^[.#:[]|^[a-zA-Z][\w-]*$/;function at(t){const e=t.trim();return ot.test(e)?"target matches "+Q(e):(X("target","trigger"),null)}function ct(t){return t.startsWith("js:")||t.startsWith("javascript:")}function ht(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 lt=/^(\S+\[[^\]]*\]|\S+)\s*(.*)$/,ut=/^(\w+)\[(.+)\]$/;function ft(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=nt(a),null===e&&X("delay","trigger");break;case"throttle":s=nt(a),null===s&&X("throttle","trigger");break;case"once":n=0!=a;break;case"changed":break;case"from":i=rt(a+"");break;case"target":r=at(a+"");break;default:X(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(lt);if(!s)return{event:"click",modifiers:{}};let n=s[1];const i=s[2]??"",r=i?D(i):{};/\[[^\]]*$/.test(n)&&(X("unterminated event filter","trigger"),n=n.slice(0,n.indexOf("[")));const o=n.match(ut);if(o){const t=e(o[1]);return{event:U[t]||t,filter:o[2],modifiers:r}}const a=e(n);return{event:U[a]||a,modifiers:r}}(i,t=>B().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&&(ct(t.headers.trim())?Y("hx-headers"):Object.assign(n,D(t.headers)));let i=null;t.vals&&(ct(t.vals.trim())?Y("hx-vals"):i=D(t.vals));let r=t.url,o=null;"form"===e?(i&&Object.keys(i).length&&K("hx-vals is not merged with form values; the form fields win."),s?K("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(!Z.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=et(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: "+Q(t.method)),Object.keys(n).length&&a.push("headers: "+et(n)),o&&a.push("body: "+o);let c="fetch "+Q(r);return a.length&&(c+=` with { ${a.join(", ")} }`),c+" as html"}(t,o));const a=t.target?ht(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(J,n)||!/^\S*:/.test(s)?{style:n,modifiers:D(s.slice(n.length))}:{style:e,modifiers:D(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=nt(i),null===e&&X("swap","swap");break;case"settle":s=nt(i),null===s&&X("settle","swap");break;default:X(n,"swap")}return{swapWaitMs:e,settleWaitMs:s}}(h),f=function(t,e){const s=J[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 "+Q(1==t.pushUrl?t.url:t.pushUrl)):t.replaceUrl&&n.push("then replace url "+Q(1==t.replaceUrl?t.url:t.replaceUrl));const p=`${r}\n ${n.join("\n ")}`;return s.push(p),s.join("\n")}function pt(t){const e=t.attributes;for(let t=0;e.length>t;t++)if(e[t].name.startsWith("hx-"))return 1;return 0}function dt(t){return t.hasAttribute("fx-action")}function mt(t){return pt(t)||dt(t)}const yt=new Set(["add","append","beep","blur","break","breakpoint","call","clear","close","continue","copy","decrement","default","empty","exit","fetch","focus","get","go","halt","hide","if","increment","install","js","log","make","measure","morph","open","pick","prepend","process","pseudo-command","push","put","remove","render","repeat","replace","reset","return","scroll","select","send","set","settle","show","start","swap","take","tell","throw","toggle","transition","trigger","unless","wait","for"]),wt=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 gt(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 bt(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 vt(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 xt(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 Et=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",gt(10)],["||",gt(10)],["and",gt(20)],["&&",gt(20)],["==",gt(30)],["!=",gt(30)],["<",gt(30)],[">",gt(30)],["<=",gt(30)],[">=",gt(30)],["is",gt(30)],["matches",gt(30)],["contains",gt(30)],["starts with",gt(30)],["ends with",gt(30)],["does not start with",gt(30)],["does not end with",gt(30)],["is between",gt(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",gt(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",gt(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",gt(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",gt(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",gt(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",gt(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",gt(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",gt(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}})],["+",{...gt(40),...vt(80)}],["-",{...gt(40),...vt(80)}],["*",gt(50)],["/",gt(50)],["%",gt(50)],["mod",gt(50)],["^",bt(60)],["**",bt(60)],["as",gt(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();if(t&&void 0!==t.value)return{...e,name:`${e.name+""}:${t.value}`,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",vt(80)],["!",vt(80)],["no",vt(27)]]),new Map([["===",gt(30)],["!==",gt(30)],["is not",gt(30)],["am",gt(30)],["is in",gt(30)],["is not in",gt(30)],["precedes",gt(30)],["does not precede",gt(30)],["follows",gt(30)],["does not follow",gt(30)],["is a",gt(30,xt(0))],["is an",gt(30,xt(0))],["is not a",gt(30,xt(1))],["is not an",gt(30,xt(1))],["has",gt(30)],["have",gt(30)],["match",gt(30)],["include",gt(30)],["includes",gt(30)],["equals",gt(30)],["does not contain",gt(30)],["does not include",gt(30)],["am in",gt(30)],["am not in",gt(30)],["is really",gt(30)],["is not really",gt(30)],["is equal",gt(30)],["is not equal",gt(30)],["contain",gt(30)],["do not contain",gt(30)],["does not contains",gt(30)],["do not match",gt(30)],["does not match",gt(30)],["is equal to",gt(30)],["is not equal to",gt(30)],["is really equal to",gt(30)],["is not really equal to",gt(30)],["really equals",gt(30)],["is greater than",gt(30)],["is less than",gt(30)],["is greater than or equal to",gt(30)],["is less than or equal to",gt(30)],["in",gt(30)],["of",bt(30)],["really",gt(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",vt(80)]]),new Map([["=",bt(5)]])),kt=new Set,$t=new Set,Mt=new Set,St=new Set,Tt=new Map,At=new Map,Ot=new Map,Ht=new class{registerCommand(t){yt.add(t.toLowerCase())}registerCompoundOperator(t){wt.add(t.toLowerCase())}registerInfixOperator(t,e,s,n){const i=t.toLowerCase(),r=Et.get(i);Et.set(i,{...r??{},infix:{bp:[e,s],handler:n}})}registerPrefixOperator(t,e,s){const n=t.toLowerCase(),i=Et.get(n);Et.set(n,{...i??{},prefix:{bp:e,handler:s}})}hasCommand(t){return yt.has(t.toLowerCase())}registerFeature(t,e){Tt.set(t.toLowerCase(),e)}hasFeature(t){return Tt.has(t.toLowerCase())}registerNodeEvaluator(t,e){At.set(t,e)}registerNodeWriter(t,e){Ot.set(t,e)}registerGlobalWriteHook(t){return function(t){return kt.add(t),()=>kt.delete(t)}(t)}registerGlobalReadHook(t){return function(t){return $t.add(t),()=>$t.delete(t)}(t)}registerLocalWriteHook(t){return function(t){return Mt.add(t),()=>Mt.delete(t)}(t)}registerLocalReadHook(t){return function(t){return St.add(t),()=>St.delete(t)}(t)}snapshot(){return{commands:Array.from(yt),operators:Array.from(wt),prattEntries:Array.from(Et.entries()).map(([t,e])=>[t,{...e}]),features:Array.from(Tt.entries()),nodeEvaluators:Array.from(At.entries()),nodeWriters:Array.from(Ot.entries()),globalWriteHooks:Array.from(kt),globalReadHooks:Array.from($t),localWriteHooks:Array.from(Mt),localReadHooks:Array.from(St)}}restore(t){yt.clear();for(const e of t.commands)yt.add(e);wt.clear();for(const e of t.operators)wt.add(e);Et.clear();for(const[e,s]of t.prattEntries)Et.set(e,s);Tt.clear();for(const[e,s]of t.features)Tt.set(e,s);At.clear();for(const[e,s]of t.nodeEvaluators)At.set(e,s);Ot.clear();for(const[e,s]of t.nodeWriters??[])Ot.set(e,s);!function(t){kt.clear();for(const e of t.globalWriteHooks??[])kt.add(e);$t.clear();for(const e of t.globalReadHooks??[])$t.add(e);Mt.clear();for(const e of t.localWriteHooks??[])Mt.add(e);St.clear();for(const e of t.localReadHooks??[])St.add(e)}(t)}},jt="__hyperfixi_parser_extension_registry__";class _t{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 Ct{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 Ft(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 Lt(t){return t?t.split(/[-_]/)[0].toLowerCase():"en"}function qt(t){const e=t.getAttribute?.("data-hyperfixi-lang");if(e)return Lt(e);const s=t.closest?.("[data-hyperfixi-lang]");if(s)return Lt(s.getAttribute("data-hyperfixi-lang"));const n=t.closest?.("[lang]");return n?Lt(n.getAttribute("lang")):"en"}const Pt=new Map,Wt=new Map,Nt=new Set;let It=0;const Rt=new Set;function Dt(){const t=new Set;for(const e of Wt.values())for(const s of e.values())t.add(s);return[...t]}function Gt(t,e){const s=Lt(t),n=e?.hyperfixi??{};var i;Pt.set(s,n),Wt.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)),Nt.delete(s),It||(i={nameOf:(t,e,s)=>{const n=`${e}-${s}`,i=qt(t);if("en"===i)return n;const r=Wt.get(i)?.get(n);return r||(Pt.has(i)||Nt.has(i)||(Nt.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 Wt.values()){const e=t.get(s);e&&n.add(e)}return[...n].map(t=>`[${t}]`).join(", ")},eventNameOf:(t,e)=>{const s=qt(t);return"en"===s?e:Pt.get(s)?.events?.[e]??e}},z=i,It=1);for(const t of Rt)t()}const zt="__hyperfixi_i18n";function Bt(){if("undefined"==typeof window)return;const t=window;t[zt]||(t[zt]={register:Gt})}function Jt(t){for(const e of function(){const t=new Set(["hx-on:"]);for(const e of Wt.values()){const s=e.get("hx-on");s&&t.add(s+":")}return[...t]}())if(t.startsWith(e))return t.slice(e.length);return null}Bt();const Ut=["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"]),Zt=["live"],Vt=["fx-action","fx-method","fx-trigger","fx-target","fx-swap","fx-ignore"],Xt=[...Ut,...Vt];function Kt(t,e,s){return t.getAttribute(B().nameOf(t,e,s))}function Yt(t,e,s){return t.hasAttribute(B().nameOf(t,e,s))}class Qt{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=ht(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=Kt(t,"sse","connect");if(!s)return null;const n=new _t(t,s,(e,n)=>{const i={url:void 0,method:"GET",target:Kt(t,"hx","target")??void 0,swap:Kt(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=Kt(t,"sse","swap");if(i)for(const t of(r=i,r.split(R)).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(B().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=Kt(t,"ws","connect");if(!s)return null;const n=new Ct(t,s,(e,n)=>{const i={url:void 0,method:"GET",target:e.target,swap:e.swap??Kt(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=B().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=Ft(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=B().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(B().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=B().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=B(),e=[];for(const s of["get","post","put","patch","delete",...Zt])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!==Jt(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=Kt(t,"hx",s);if(n){e.method=s.toUpperCase(),e.url=n;break}}const s=Kt(t,"hx","target");s&&(e.target=s);const n=Kt(t,"hx","swap");n&&(e.swap=n);const i=Kt(t,"hx","trigger");i&&(e.trigger=i);const r=Kt(t,"hx","confirm");r&&(e.confirm=r),"true"===Kt(t,"hx","boost")&&(e.boost=1);const o=Kt(t,"hx","vals");o&&(e.vals=o);const a=Kt(t,"hx","headers");a&&(e.headers=a);const c=Kt(t,"hx","push-url");c&&(e.pushUrl="true"===c?1:c);const h=Kt(t,"hx","replace-url");h&&(e.replaceUrl="true"===h?1:h);const l={};for(const e of t.attributes){const t=Jt(e.name);null!==t&&(l[t]=e.value)}Object.keys(l).length>0&&(e.onHandlers=l);const u=Kt(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;Yt(t,"sse","connect")&&this.attachSSE(t),Yt(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[jt];if(e&&"object"==typeof e&&"function"==typeof e.registerFeature)return e;t[jt]=Ht}return Ht}().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=ft(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&&(Xt.includes(t)||null!==Jt(t)||this.localizedAttrSet.has(t))&&(this.processedElements.delete(e.target),this.processElement(e.target))}}}),this.localizedAttrSet=new Set(Dt()),this.unsubscribeVocab=(Rt.add(t=()=>this.refreshLocalizedAttrs()),()=>{Rt.delete(t)}),this.options.root&&this.observer.observe(this.options.root,{childList:1,subtree:1,attributes:1,attributeFilter:this.computeAttributeFilter()})}computeAttributeFilter(){const t=Dt();return 0===t.length?Xt:[...new Set([...Xt,...t])]}refreshLocalizedAttrs(){this.localizedAttrSet=new Set(Dt()),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 ft(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}}Bt();let te=null;function ee(t={}){const{processHyperscript:e=1,...s}=t;te=new Qt({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}),te.init(async(t,e)=>{await W.execute(t,e)}),se||"undefined"==typeof document||(se=t=>{const e=t.detail,s=e?.elt??t.target;s&&"function"==typeof s.querySelector&&W.process(s)},document.addEventListener("htmx:load",se),document.addEventListener("htmx:after:process",se)),t.debug&&console.log("[hyperfixi-hx] htmx/fixi compatibility enabled")}let se=null;function ne(){te&&(te.destroy(),te=null),se&&"undefined"!=typeof document&&(document.removeEventListener("htmx:load",se),document.removeEventListener("htmx:after:process",se),se=null)}function ie(t){return new Qt({processExisting:0,watchMutations:0}).manualProcess(t)}const re={...W,version:"1.0.0-hybrid-hx",enableHtmxCompatibility:ee,disableHtmxCompatibility:ne,getHtmxProcessor:function(){return te},translateHtmx:ie,hasHtmxAttributes:pt,hasFxAttributes:dt,hasAnyAttributes:mt,HtmxAttributeProcessor:Qt,translateToHyperscript:ft,features:{htmx:1,fixi:1,hyperscript:1},htmxAttributes:Ut,fixiAttributes:Vt,fixiEvents:["fx:init","fx:inited","fx:config","fx:before","fx:after","fx:error","fx:finally","fx:swapped"]};if("undefined"!=typeof window){window.hyperfixi=re,window.lokascript=re;const t=()=>{ee({processExisting:1,watchMutations:1,processHyperscript:1,requestDropping:1,fixiEvents:1})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}t.FIXI_ATTRS=Vt,t.HTMX_ATTRS=Ut,t.HtmxAttributeProcessor=Qt,t.default=re,t.disableHtmxCompatibility=ne,t.enableHtmxCompatibility=ee,t.hasAnyAttributes=mt,t.hasFxAttributes=dt,t.translateHtmx=ie,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","prepend","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.cmdMap={toggle:()=>this.parseToggle(),add:()=>this.parseAdd(),remove:()=>this.parseRemove(),put:()=>this.parsePut(),append:()=>this.parseInsertion("append"),prepend:()=>this.parseInsertion("prepend"),set:()=>this.parseSet(),get:()=>this.parseGet(),call:()=>this.parseCall(),log:()=>this.parseLog(),send:()=>this.parseSend("to"),trigger:()=>this.parseSend("on"),wait:()=>this.parseWait(),show:()=>this.parseShow(),hide:()=>this.parseHide(),take:()=>this.parseTake(),empty:()=>this.parseEmpty(),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(),copy:()=>this.parseCopy(),beep:()=>this.parseBeep(),push:()=>this.parseUrlCommand("push"),replace:()=>this.parseUrlCommand("replace"),morph:()=>this.parseMorph(),js:()=>this.parseJs(),throw:()=>this.parseThrow(),break:()=>this.parseBare("break"),continue:()=>this.parseBare("continue"),exit:()=>this.parseBare("exit")},this.source=t,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=r(this.peek().value);if(this.cmdMap[t])return this.cmdMap[t]();if(this.match("catch","finally"))throw Error(`'${this.peek().value}' needs the full parser (use hyperfixi.js)`);const e=this.peek();if(!(this.isAtEnd()||"identifier"!==e.type&&"keyword"!==e.type||this.match("then","and","end","else")))throw Error(`'${e.value}' needs the full parser (use hyperfixi.js)`);return 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}}parseNakedUrl(){const t=this.peek(),e="operator"===t.type&&"/"===t.value,s=("http"===t.value||"https"===t.value)&&"://"===this.source.slice(t.pos+t.value.length,t.pos+t.value.length+3);if(!e&&!s)return null;let n=t.pos;for(;this.source.length>n&&!/\s/.test(this.source[n]);)n++;for(;!this.isAtEnd()&&this.peek().pos<n;)this.advance();return{type:"literal",value:this.source.slice(t.pos,n)}}parseFetchBlock(){this.expect("fetch");const t=this.parseNakedUrl()??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")&&/^[.@]/.test(this.peek().value)){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}}parseInsertion(t){this.expect(t);const e=this.parseExpression();let s;return this.match("to")&&(this.advance(),s=this.parseExpression()),{type:"command",name:t,args:[e],target:s}}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(t){this.advance();const e=this.advance();let s,n=e.value,i=e.pos+e.value.length;for(;!this.isAtEnd()&&"localVar"===this.peek().type&&this.peek().pos===i;){const t=this.advance();n+=t.value,i=t.pos+t.value.length}return this.match(t)&&(this.advance(),s=this.parseExpression()),{type:"command",name:"send",args:[{type:"literal",value:n}],target:s}}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]:[]}}parseEmpty(){let t;return this.expect("empty"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"empty",args:[],target:t}}parseCopy(){return this.expect("copy"),{type:"command",name:"copy",args:[this.parseExpression()]}}parseBeep(){this.advance(),this.match("!")&&this.advance();const t=[];for(;!this.isAtEnd()&&!this.match("then","and","end","else")&&(t.push(this.parseExpression()),this.match(","));)this.advance();return{type:"command",name:"beep",args:t}}parseUrlCommand(t){this.advance(),this.match("url")&&this.advance();const e=this.parseExpression(),s={};return this.match("with")&&(this.advance(),this.match("title")&&(this.advance(),s.title=this.parseExpression())),{type:"command",name:t,args:[e],modifiers:s}}parseMorph(){let t;this.expect("morph"),this.match("over")&&(this.advance(),t="over");const e=this.parseExpression();return this.match("with","to","into")&&this.advance(),{type:"command",name:"morph",args:[this.parseExpression()],target:e,modifier:t}}parseJs(){if(this.advance(),this.match("(")){for(;!this.isAtEnd()&&!this.match(")");)this.advance();this.match(")")&&this.advance()}const t=this.peek().pos;for(;!this.isAtEnd()&&!this.match("end");)this.advance();const e=this.peek().pos;return this.match("end")&&this.advance(),{type:"command",name:"js",args:[{type:"literal",value:this.source.slice(t,e).trim()}]}}parseThrow(){let t;return this.expect("throw"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"throw",args:t?[t]:[]}}parseBare(t){return this.advance(),{type:"command",name:t,args:[]}}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("beep")&&"!"===this.peek(1).value)throw Error("'beep!' needs the full parser (use hyperfixi.js)");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()}}var c="moveBefore"in Element.prototype,h=[0,1,0,0,0,0,0,0,0,1,0,1,0],l=new Set,u=new Set,f=new Set,p=new Set,d=new Set,m=new Set;function y(t,e,s={}){"string"==typeof e&&(e=b(e).childNodes),!s.preserveChanges&&$(t)&&g(t),new x(s).morph(t,e)}function w(t,e,s={}){if("string"==typeof e){const t=b(e);if(!t.firstChild||1!==t.childNodes.length||1!==t.firstChild.nodeType)throw Error("[Morphlex] The string was not a valid HTML element.");e=t.firstChild}if(1!==t.nodeType||1!==e.nodeType||t.localName!==e.localName)throw Error("[Morphlex] You can only do an inner morph with matching elements.");$(t)&&g(t),new x(s).visitChildNodes(t,e)}function g(t){for(const e of t.querySelectorAll("input"))(e.name&&e.value!==e.defaultValue||e.checked!==e.defaultChecked)&&e.setAttribute("morphlex-dirty","");for(const e of t.querySelectorAll("option"))e.value&&e.selected!==e.defaultSelected&&e.setAttribute("morphlex-dirty","");for(const e of t.querySelectorAll("textarea"))e.value!==e.defaultValue&&e.setAttribute("morphlex-dirty","")}function b(t){const e=document.createElement("template");return e.innerHTML=t.trim(),e.content}function v(t,e,s){if(e!==s){if(e.parentNode===t){if(e.nextSibling===s)return;if(c)return void t.moveBefore(e,s)}t.insertBefore(e,s)}}class x{#t=new WeakMap;#e=new WeakMap;#s;constructor(t={}){this.#s=t}morph(t,e){$(t)&&this.#n(t),e instanceof NodeList?(this.#i(e),this.#r(t,e)):$(e)&&(this.#o(e),this.#a(t,e))}#r(t,e){const s=e.length;if(0===s)this.#c(t);else if(1===s)this.#a(t,e[0]);else if(s>1){const s=[...e];this.#a(t,s.shift());const n=t.nextSibling,i=t.parentNode||document;for(let t=0;s.length>t;t++){const e=s[t];(this.#s.beforeNodeAdded?.(i,e,n)??1)&&(i.insertBefore(e,n),this.#s.afterNodeAdded?.(e))}}}#a(t,e){t!==e&&(t.isEqualNode(e)||(1===t.nodeType&&1===e.nodeType?t.localName===e.localName?this.#h(t,e):this.#l(t,e):this.#u(t,e)))}#h(t,e){(this.#s.beforeNodeVisited?.(t,e)??1)&&((t.hasAttributes()||e.hasAttributes())&&this.#f(t,e),"textarea"===t.localName&&"textarea"===e.localName?this.#p(t,e):(t.hasChildNodes()||e.hasChildNodes())&&this.visitChildNodes(t,e),this.#s.afterNodeVisited?.(t,e))}#l(t,e){(this.#s.beforeNodeVisited?.(t,e)??1)&&(this.#d(t,e),this.#s.afterNodeVisited?.(t,e))}#u(t,e){(this.#s.beforeNodeVisited?.(t,e)??1)&&(t.nodeType===e.nodeType&&null!==t.nodeValue&&null!==e.nodeValue?t.nodeValue=e.nodeValue:this.#d(t,e),this.#s.afterNodeVisited?.(t,e))}#f(t,e){t.hasAttribute("morphlex-dirty")&&t.removeAttribute("morphlex-dirty");for(const{name:s,value:n}of e.attributes){"value"===s&&E(t)&&t.value!==n&&(this.#s.preserveChanges&&t.value!==t.defaultValue||(t.value=n)),"selected"===s&&k(t)&&!t.selected&&(this.#s.preserveChanges&&t.selected!==t.defaultSelected||(t.selected=1)),"checked"===s&&E(t)&&!t.checked&&(this.#s.preserveChanges&&t.checked!==t.defaultChecked||(t.checked=1));const e=t.getAttribute(s);e!==n&&(this.#s.beforeAttributeUpdated?.(t,s,n)??1)&&(t.setAttribute(s,n),this.#s.afterAttributeUpdated?.(t,s,e))}for(const{name:s,value:n}of t.attributes)e.hasAttribute(s)||("selected"===s&&k(t)&&t.selected&&(this.#s.preserveChanges&&t.selected!==t.defaultSelected||(t.selected=0)),"checked"===s&&E(t)&&t.checked&&(this.#s.preserveChanges&&t.checked!==t.defaultChecked||(t.checked=0)),(this.#s.beforeAttributeUpdated?.(t,s,null)??1)&&(t.removeAttribute(s),this.#s.afterAttributeUpdated?.(t,s,n)))}#p(t,e){const s=e.textContent||"",n=t.value!==t.defaultValue;t.textContent!==s&&(t.textContent=s),this.#s.preserveChanges&&n||(t.value=t.defaultValue)}visitChildNodes(t,e){if(!(this.#s.beforeChildrenVisited?.(t)??1))return;const s=t,n=[...t.childNodes],i=[...e.childNodes];l.clear(),u.clear(),f.clear(),p.clear(),d.clear(),m.clear();const r=[],o=[],a=[],c=[],h=[],y=[];for(let t=0;n.length>t;t++){const e=n[t],s=e.nodeType;c[t]=s,1===s?(y[t]=e.localName,""!==e.id?f.add(t):u.add(t)):3===s&&""===e.textContent?.trim()?m.add(t):l.add(t)}for(let t=0;i.length>t;t++){const e=i[t],s=e.nodeType;if(a[t]=s,1===s)h[t]=e.localName,d.add(t);else{if(3===s&&""===e.textContent?.trim())continue;p.add(t)}}for(const t of d){const e=h[t],s=i[t];for(const i of u)if(e===y[i]&&n[i].isEqualNode(s)){r[t]=i,o[t]=0,u.delete(i),d.delete(t);break}}for(const t of d){const e=i[t],s=e.id,a=this.#t.get(e);if(""!==s||a)t:for(const e of f){const i=n[e];if(h[t]===y[e]){if(""!==s&&s===i.id){r[t]=e,o[t]=1,f.delete(e),d.delete(t);break t}if(a){const s=this.#e.get(i);if(s)for(let n=0;a.length>n;n++)if(s.has(a[n])){r[t]=e,o[t]=1,f.delete(e),d.delete(t);break t}}}}}for(const t of d){const e=i[t],s=e.getAttribute("name"),a=e.getAttribute("href"),c=e.getAttribute("src");for(const e of u){const i=n[e];if(h[t]===y[e]&&(s&&s===i.getAttribute("name")||a&&a===i.getAttribute("href")||c&&c===i.getAttribute("src"))){r[t]=e,o[t]=1,u.delete(e),d.delete(t);break}}}for(const t of d){const e=i[t],s=h[t];for(const i of u)if(s===y[i]){if("input"===s&&n[i].type!==e.type)continue;r[t]=i,o[t]=1,u.delete(i),d.delete(t);break}}for(const t of p){const e=i[t];for(const s of l)if(n[s].isEqualNode(e)){r[t]=s,o[t]=0,l.delete(s),p.delete(t);break}}for(const t of p){const e=a[t];for(const s of l)if(e===c[s]){r[t]=s,o[t]=2,l.delete(s),p.delete(t);break}}for(const t of l)this.#c(n[t]);for(const t of m)this.#c(n[t]);for(const t of u)this.#c(n[t]);for(const t of f)this.#c(n[t]);const w=function(t){const e=t.length;if(0===e)return[];const s=[],n=[],i=Array(e);for(let r=0;e>r;r++){const e=t[r];if(void 0===e)continue;let o=0,a=s.length;for(;a>o;){const t=Math.floor((o+a)/2);e>s[t]?o=t+1:a=t}i[r]=o>0?n[o-1]:-1,o===s.length?(s.push(e),n.push(r)):(s[o]=e,n[o]=r)}const r=[];if(0===n.length)return r;let o=n[n.length-1];for(;void 0!==o&&-1!==o;)r.unshift(o),o=i[o];return r}(r),g=Array(n.length);for(let t=0;w.length>t;t++)g[r[w[t]]]=1;let b=s.firstChild;for(let t=0;i.length>t;t++){const e=i[t],a=r[t];if(void 0!==a){const i=n[a],r=o[t];g[a]||v(s,i,b),0===r||(1===r?this.#h(i,e):this.#a(i,e)),b=i.nextSibling}else(this.#s.beforeNodeAdded?.(s,e,b)??1)&&(s.insertBefore(e,b),this.#s.afterNodeAdded?.(e),b=e.nextSibling)}this.#s.afterChildrenVisited?.(t)}#d(t,e){const s=t.parentNode||document,n=t;(this.#s.beforeNodeRemoved?.(t)??1)&&(this.#s.beforeNodeAdded?.(s,e,n)??1)&&(s.insertBefore(e,n),this.#s.afterNodeAdded?.(e),t.remove(),this.#s.afterNodeRemoved?.(t))}#c(t){(this.#s.beforeNodeRemoved?.(t)??1)&&(t.remove(),this.#s.afterNodeRemoved?.(t))}#i(t){for(const e of t)$(e)&&this.#o(e)}#o(t){const e=this.#t;for(const s of t.querySelectorAll("[id]")){const n=s.id;if(""===n)continue;let i=s;for(;i;){const s=e.get(i);if(s?s.push(n):e.set(i,[n]),i===t)break;i=i.parentElement}}}#n(t){const e=this.#e;for(const s of t.querySelectorAll("[id]")){const n=s.id;if(""===n)continue;let i=s;for(;i;){const s=e.get(i);if(s?s.add(n):e.set(i,new Set([n])),i===t)break;i=i.parentElement}}}}function E(t){return"input"===t.localName}function k(t){return"option"===t.localName}function $(t){return!!h[t.nodeType]}const M=new Map,S=new WeakMap;function T(t){let e=S.get(t);return e||(e=new Map,S.set(t,e)),e}const A=1e3;async function O(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 T(e.me).get(t.name.slice(1));const s=t.name.slice(1);return M.has(s)?M.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 O(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 O(t.left,e),n=await O(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 O(t.operand,e);return"not"===t.operator?!i:i;case"possessive":case"member":const r=await O(t.object,e);if(null==r)return;const o=t.computed?await O(t.property,e):t.property;return"values"===o&&r instanceof Element?j(r):r[o];case"call":{let s,n=null;if("member"===t.callee.type||"possessive"===t.callee.type){n=await O(t.callee.object,e);const i=t.callee.computed?await O(t.callee.property,e):t.callee.property;s=n?.[i]}else s=await O(t.callee,e);const i=await Promise.all(t.args.map(t=>O(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 O(s.value,e);return a;case"array":return Promise.all(t.elements.map(t=>O(t,e)));case"valuesOf":{const s=await O(t.target,e);return s instanceof Element?j(s):new FormData}default:return}}function j(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 H(t,e){const s=async()=>{if(!t.target)return[e.me];const s=await O(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,c=(t,e)=>{if(r(e))return getComputedStyle(t).getPropertyValue(o(e))};switch(t.name){case"toggle":{const i=n(t.args[0])||await O(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 O(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"remove":{const t=await s();for(const e of t)e.remove();return null}case"removeClass":{const i=n(t.args[0])||await O(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 r}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"put":{const n=await O(t.args[0],e),o=t.modifier||"into";if("possessive"===t.target?.type&&r(t.target.property)){const s=i(await O(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 O(t.args[0],e),i=await s();for(const t of i)t.insertAdjacentHTML("beforeend",n+"");return e.it=n,n}case"prepend":{const n=await O(t.args[0],e),i=await s();for(const t of i)t.insertAdjacentHTML("afterbegin",n+"");return e.it=n,n}case"take":{const i=n(t.args[0]),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"empty":{const t=await s();for(const e of t)e.innerHTML="";return t}case"set":{const s=t.args[0],n=await O(t.args[1],e);if("variable"===s.type){const t=s.name.slice(1);return("local"===s.scope?T(e.me):M).set(t,n),e.it=n,n}if("possessive"===s.type||"member"===s.type){const t=await O(s.object,e);if(t)return t instanceof Element&&r(s.property)?a(t,s.property,n):t[s.property]=n,e.it=n,n}return e.it=n,n}case"get":{const s=await O(t.args[0],e);return e.it=s,s}case"increment":{const s=t.args[0],n=t.args[1]?await O(t.args[1],e):1;if("variable"===s.type){const t=s.name.slice(1),i="local"===s.scope?T(e.me):M,r=(i.get(t)||0)+n;return i.set(t,r),e.it=r,r}if("possessive"===s.type){const t=r(s.property),o=i(await O(s.object,e));for(const i of o){const r=t?c(i,s.property):Reflect.get(i,s.property),o=(parseFloat(r||"0")||0)+n;t?a(i,s.property,o):Reflect.set(i,s.property,o),e.it=o}return e.it}const o=i(await O(s,e));for(const t of o){const s=(parseFloat(t.textContent||"0")||0)+n;t.textContent=s+"",e.it=s}return e.it}case"decrement":{const s=t.args[0],n=t.args[1]?await O(t.args[1],e):1;if("variable"===s.type){const t=s.name.slice(1),i="local"===s.scope?T(e.me):M,r=(i.get(t)||0)-n;return i.set(t,r),e.it=r,r}if("possessive"===s.type){const t=r(s.property),o=i(await O(s.object,e));for(const i of o){const r=t?c(i,s.property):Reflect.get(i,s.property),o=(parseFloat(r||"0")||0)-n;t?a(i,s.property,o):Reflect.set(i,s.property,o),e.it=o}return e.it}const o=i(await O(s,e));for(const t of o){const s=(parseFloat(t.textContent||"0")||0)-n;t.textContent=s+"",e.it=s}return e.it}case"wait":{const s=await O(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 O(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"transition":{const n=(await O(t.args[0],e)+"").replace(/^\*/,""),i=await O(t.args[1],e),r=await O(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"send":{const n=await O(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"log":{const s=await Promise.all(t.args.map(t=>O(t,e)));return console.log(...s),s[0]}case"call":{const s=await O(t.args[0],e);return e.it=s,s}case"copy":{const s=await O(t.args[0],e);let n="";n="string"==typeof s?s:s instanceof Element?s.textContent||"":s+"";try{if(navigator.clipboard)await navigator.clipboard.writeText(n);else{const t=document.createElement("textarea");t.value=n,t.style.cssText="position:fixed;top:0;left:-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}return e.me instanceof Element&&e.me.dispatchEvent(new CustomEvent("copy:success",{bubbles:1,detail:{text:n}})),e.it=n,n}catch(t){throw e.me instanceof Element&&e.me.dispatchEvent(new CustomEvent("copy:error",{bubbles:1,detail:{error:t}})),t}}case"beep":{const s=await Promise.all(t.args.map(t=>O(t,e))),n=s.length>0?s:[e.it];for(const t of n){const e=null===t?"null":void 0===t?"undefined":Array.isArray(t)?`Array[${t.length}]`:t instanceof Element?`Element<${t.tagName.toLowerCase()}>`:typeof t;console.log("[beep]",e+":",t)}return n[0]}case"go":{const s=await O(t.args[0],e),n=(s+"").toLowerCase();return"back"===n?history.back():"forward"===n?history.forward():"bottom"===n?e.me.scrollIntoView({block:"end",behavior:"smooth"}):"top"===n?e.me.scrollIntoView({block:"start",behavior:"smooth"}):window.location.href=s+"",null}case"push":{const s=await O(t.args[0],e)+"";let n="";return t.modifiers?.title&&(n=await O(t.modifiers.title,e)+""),window.history.pushState(null,"",s),n&&(document.title=n),window.dispatchEvent(new CustomEvent("lokascript:pushurl",{detail:{url:s,title:n}})),{url:s,title:n,mode:"push"}}case"replace":{const s=await O(t.args[0],e)+"";let n="";return t.modifiers?.title&&(n=await O(t.modifiers.title,e)+""),window.history.replaceState(null,"",s),n&&(document.title=n),window.dispatchEvent(new CustomEvent("lokascript:replaceurl",{detail:{url:s,title:n}})),{url:s,title:n,mode:"replace"}}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"return":throw{type:"return",value:t.args[0]?await O(t.args[0],e):e.it};case"break":throw{type:"break"};case"continue":throw{type:"continue"};case"halt":{const s=t.args[0];let n=e.event;if("identifier"===s?.type&&"the"===s.name&&"event"===t.args[1]?.name)n=e.event;else if(s){const t=await O(s,e);t?.preventDefault&&(n=t)}if(n&&"function"==typeof n.preventDefault)return n.preventDefault(),n.stopPropagation(),{halted:1,eventHalted:1};const i=Error("HALT_EXECUTION");throw i.isHalt=1,i}case"exit":{const t=Error("EXIT_COMMAND");throw t.isExit=1,t}case"throw":{const s=t.args[0]?await O(t.args[0],e):"Error";throw s instanceof Error?s:Error(s+"")}case"js":{const s=t.args[0];let n="";n="string"===s.type?s.value:"template"===s.type?await O(s,e):await O(s,e)+"";const i={me:e.me,it:e.it,event:e.event,target:e.me,locals:Object.fromEntries(e.locals),globals:Object.fromEntries(M),document:"undefined"!=typeof document?document:void 0,window:"undefined"!=typeof window?window:void 0};try{const t=Function("ctx",`with(ctx) { return (async () => { ${n} })(); }`),s=await t(i);return e.it=s,s}catch(t){throw console.error("[js] Execution error:",t),t}}case"morph":{const n=await s(),i=await O(t.args[0],e)+"",r="over"===t.modifier;for(const t of n)try{if(r)y(t,i);else{const e=document.createElement("template");e.innerHTML=i;const s=e.content.firstElementChild;if(s&&!s.nextElementSibling&&s.tagName===t.tagName)y(t,s);else{const e=document.createElement(t.tagName);e.innerHTML=i,w(t,e)}}}catch(e){console.warn("[LokaScript] Morph failed, falling back:",e),r?t.outerHTML=i:t.innerHTML=i}return e.it=1===n.length?n[0]:n,e.it}default:return console.error(`[hyperfixi] Unknown command "${t.name}" \u2014 not in this bundle. Use hyperfixi.js (full bundle).`),null}}async function _(t,e){try{return await F(t,e)}catch(t){if("return"===t?.type)throw t;throw t}}async function C(t,e){switch(t.type){case"if":return await O(t.condition,e)?_(t.body,e):t.elseBody?_(t.elseBody,e):null;case"repeat":{const s=await O(t.condition,e),n=Number(s)||0;for(let s=0;n>s&&A>s;s++){e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1);try{await _(t.body,e)}catch(t){if("break"===t?.type)break;if("continue"===t?.type)continue;throw t}}return null}case"for":{const{variable:s,iterable:n}=t.condition,i=await O(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&&A>s;s++){e.locals.set(o,r[s]),e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1);try{await _(t.body,e)}catch(t){if("break"===t?.type)break;if("continue"===t?.type)continue;throw t}}return null}case"while":{let s=0;for(;await O(t.condition,e)&&A>s;){e.locals.set("__loop_index__",s);try{await _(t.body,e)}catch(t){if("break"===t?.type)break;if("continue"===t?.type){s++;continue}throw t}s++}return null}case"fetch":{const{url:s,responseType:n,options:i,method:r}=t.condition;try{const o=await O(s,e),a={};if(r){const t=await O(r,e);a.method=(t+"").toUpperCase()}if(i){const t=await O(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 O(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 _(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 F(t,e){let s;for(const n of t)"command"===n.type?s=await H(n,e):["if","repeat","for","while","fetch"].includes(n.type)&&(s=await C(n,e));return s}async function L(t,e,s){const n={me:e,event:s,locals:new Map,globals:M};if("sequence"===t.type)try{return await F(t.commands,n)}catch(t){if("return"===t?.type)return t.value;throw t}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:M};try{await F(s.body,t)}catch(t){if("return"!==t?.type)throw t}},n)}if("init"===i){try{await F(s.body,n)}catch(t){if("return"!==t?.type)throw t}return}const r=s.filter?await O(s.filter,n):e,o=r instanceof Element?r:e,a=s.modifiers;let c=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:M};try{await F(s.body,n)}catch(t){if("return"===t?.type)return t.value;throw t}};if(a.debounce){let t;const e=c;c=async s=>{clearTimeout(t),t=setTimeout(()=>e(s),a.debounce)}}if(a.throttle){let t=0;const e=c;c=async s=>{const n=Date.now();a.throttle>n-t||(t=n,await e(s))}}return void o.addEventListener(i,c,{once:!!a.once})}return null}const q=t=>new a(t).parse(),P=function(t,e){return(s=document)=>{s.querySelectorAll("[_]").forEach(s=>{const n=s.getAttribute("_");if(n)try{e(t(n),s)}catch(t){console.error("HyperFixi Hybrid Complete error:",t,"Code:",n)}})}}(q,L),W={version:"1.0.0-hybrid-complete",parse:q,execute:async(t,e)=>L(q(t),e||document.body),init:P,process:P,addAliases:function(t){Object.assign(n,t)},addEventAliases:function(t){Object.assign(i,t)},tokenize:s,evaluate:O,commands:["toggle","add","remove","removeClass","show","hide","put","append","prepend","take","empty","set","get","increment","decrement","wait","transition","send","trigger","log","call","copy","beep","go","push","push-url","replace","replace-url","focus","blur","return","break","continue","halt","exit","throw","js","morph"],blocks:["if","else","unless","repeat","for","while","fetch"]};!function(t,e,s="hyperfixi"){"undefined"!=typeof window&&(window[s]=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>e()):e())}(W,P);const N=["__proto__","constructor","prototype"],R=/(?:"([^"]+)"|'([^']+)'|([^\s,:]+))(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|<((?:[^/]|\/(?!>))+)\/>|([^\s,]+)))?(?=\s|,|$)/g,I=/,(?![^[]*\])(?![^(]*\))(?![^<]*\/>)(?=(?:[^"']|"[^"]*"|'[^']*')*$)/;function D(t){if(!t)return{};if(t.startsWith("{"))return JSON.parse(t);const e={};for(const s of t.matchAll(R)){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(".");G(u?h.split(".").reduceRight((t,e)=>({[e]:t}),l):{[h]:l},e)}return e}function G(t,e){const s="string"==typeof t?D(t):t;for(const[t,n]of Object.entries(s))N.includes(t)||(n&&"object"==typeof n&&!Array.isArray(n)&&e[t]&&"object"==typeof e[t]&&!Array.isArray(e[t])?G(n,e[t]):e[t]=n);return e}let z={nameOf:(t,e,s)=>`${e}-${s}`,selectorFor:(t,e)=>`[${t}-${e}]`,eventNameOf:(t,e)=>e};function B(){return z}const J={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"},Z={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"},U=new Set(["__proto__","constructor","prototype"]),V=new Set;function X(t,e){const s=`${e}:${t}`;V.has(s)||(V.add(s),console.warn(`[hyperfixi] htmx ${e} modifier "${t}" is recognized but not supported; ignoring it.`))}function K(t){V.has(t)||(V.add(t),console.warn("[hyperfixi] "+t))}function Y(t){K(t+' uses a "js:" prefix, which is not evaluated; ignoring it.')}function Q(t){return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}'`}function tt(t){return null===t?"null":"number"==typeof t||"boolean"==typeof t?t+"":"string"==typeof t?Q(t):Array.isArray(t)?`[${t.map(tt).join(", ")}]`:et(t)}function et(t){const e=Object.entries(t).filter(([t])=>!U.has(t)).map(([t,e])=>`${Q(t)}: ${tt(e)}`);return e.length?`{ ${e.join(", ")} }`:"{}"}const st=/^([\d.]+)\s*(ms|s|m)?$/;function nt(t){if("number"==typeof t)return Number.isFinite(t)?Math.round(t):null;if("string"!=typeof t)return null;const e=t.trim().match(st);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 it=new Set(["window","document","body","me"]);function rt(t){const e=t.trim();return e?"this"===e?"me":it.has(e)?e:/^(closest|find|next|previous)\s+/.test(e)?(X("from:"+e.split(/\s+/)[0],"trigger"),null):`<${e}/>`:null}const ot=/^[.#:[]|^[a-zA-Z][\w-]*$/;function at(t){const e=t.trim();return ot.test(e)?"target matches "+Q(e):(X("target","trigger"),null)}function ct(t){return t.startsWith("js:")||t.startsWith("javascript:")}function ht(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 lt=/^(\S+\[[^\]]*\]|\S+)\s*(.*)$/,ut=/^(\w+)\[(.+)\]$/;function ft(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=nt(a),null===e&&X("delay","trigger");break;case"throttle":s=nt(a),null===s&&X("throttle","trigger");break;case"once":n=0!=a;break;case"changed":break;case"from":i=rt(a+"");break;case"target":r=at(a+"");break;default:X(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(lt);if(!s)return{event:"click",modifiers:{}};let n=s[1];const i=s[2]??"",r=i?D(i):{};/\[[^\]]*$/.test(n)&&(X("unterminated event filter","trigger"),n=n.slice(0,n.indexOf("[")));const o=n.match(ut);if(o){const t=e(o[1]);return{event:Z[t]||t,filter:o[2],modifiers:r}}const a=e(n);return{event:Z[a]||a,modifiers:r}}(i,t=>B().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&&(ct(t.headers.trim())?Y("hx-headers"):Object.assign(n,D(t.headers)));let i=null;t.vals&&(ct(t.vals.trim())?Y("hx-vals"):i=D(t.vals));let r=t.url,o=null;"form"===e?(i&&Object.keys(i).length&&K("hx-vals is not merged with form values; the form fields win."),s?K("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(!U.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=et(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: "+Q(t.method)),Object.keys(n).length&&a.push("headers: "+et(n)),o&&a.push("body: "+o);let c="fetch "+Q(r);return a.length&&(c+=` with { ${a.join(", ")} }`),c+" as html"}(t,o));const a=t.target?ht(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(J,n)||!/^\S*:/.test(s)?{style:n,modifiers:D(s.slice(n.length))}:{style:e,modifiers:D(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=nt(i),null===e&&X("swap","swap");break;case"settle":s=nt(i),null===s&&X("settle","swap");break;default:X(n,"swap")}return{swapWaitMs:e,settleWaitMs:s}}(h),f=function(t,e){const s=J[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 "+Q(1==t.pushUrl?t.url:t.pushUrl)):t.replaceUrl&&n.push("then replace url "+Q(1==t.replaceUrl?t.url:t.replaceUrl));const p=`${r}\n ${n.join("\n ")}`;return s.push(p),s.join("\n")}function pt(t){const e=t.attributes;for(let t=0;e.length>t;t++)if(e[t].name.startsWith("hx-"))return 1;return 0}function dt(t){return t.hasAttribute("fx-action")}function mt(t){return pt(t)||dt(t)}const yt=new Set(["add","append","beep","blur","break","breakpoint","call","clear","close","continue","copy","decrement","default","empty","exit","fetch","focus","get","go","halt","hide","if","increment","install","js","log","make","measure","morph","open","pick","prepend","process","pseudo-command","push","put","remove","render","repeat","replace","reset","return","scroll","select","send","set","settle","show","start","swap","take","tell","throw","toggle","transition","trigger","unless","wait","for"]),wt=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 gt(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 bt(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 vt(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 xt(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 Et=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",gt(10)],["||",gt(10)],["and",gt(20)],["&&",gt(20)],["==",gt(30)],["!=",gt(30)],["<",gt(30)],[">",gt(30)],["<=",gt(30)],[">=",gt(30)],["is",gt(30)],["matches",gt(30)],["contains",gt(30)],["starts with",gt(30)],["ends with",gt(30)],["does not start with",gt(30)],["does not end with",gt(30)],["is between",gt(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",gt(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",gt(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",gt(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",gt(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",gt(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",gt(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",gt(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",gt(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}})],["+",{...gt(40),...vt(80)}],["-",{...gt(40),...vt(80)}],["*",gt(50)],["/",gt(50)],["%",gt(50)],["mod",gt(50)],["^",bt(60)],["**",bt(60)],["as",gt(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();if(t&&void 0!==t.value)return{...e,name:`${e.name+""}:${t.value}`,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",vt(80)],["!",vt(80)],["no",vt(27)]]),new Map([["===",gt(30)],["!==",gt(30)],["is not",gt(30)],["am",gt(30)],["is in",gt(30)],["is not in",gt(30)],["precedes",gt(30)],["does not precede",gt(30)],["follows",gt(30)],["does not follow",gt(30)],["is a",gt(30,xt(0))],["is an",gt(30,xt(0))],["is not a",gt(30,xt(1))],["is not an",gt(30,xt(1))],["has",gt(30)],["have",gt(30)],["match",gt(30)],["include",gt(30)],["includes",gt(30)],["equals",gt(30)],["does not contain",gt(30)],["does not include",gt(30)],["am in",gt(30)],["am not in",gt(30)],["is really",gt(30)],["is not really",gt(30)],["is equal",gt(30)],["is not equal",gt(30)],["contain",gt(30)],["do not contain",gt(30)],["does not contains",gt(30)],["do not match",gt(30)],["does not match",gt(30)],["is equal to",gt(30)],["is not equal to",gt(30)],["is really equal to",gt(30)],["is not really equal to",gt(30)],["really equals",gt(30)],["is greater than",gt(30)],["is less than",gt(30)],["is greater than or equal to",gt(30)],["is less than or equal to",gt(30)],["in",gt(30)],["of",{infix:{bp:[90,70],handler:function(t,e,s){const n=function(t,e=70){let s=t.parseExpr(e);if("in"===t.peek()?.value){const n=t.advance(),i=t.parseExpr(e);s={type:"binaryExpression",operator:"in",left:s,right:i,start:s.start,end:i.end??n.end,line:s.line??n.line,column:s.column??n.column}}return s}(s);return{type:"binaryExpression",operator:e.value,left:t,right:n,start:t.start,end:n.end??e.end,line:t.line??e.line,column:t.column??e.column}}}}],["really",gt(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",vt(80)]]),new Map([["=",bt(5)]])),kt=new Set,$t=new Set,Mt=new Set,St=new Set,Tt=new Map,At=new Map,Ot=new Map,jt=new class{registerCommand(t){yt.add(t.toLowerCase())}registerCompoundOperator(t){wt.add(t.toLowerCase())}registerInfixOperator(t,e,s,n){const i=t.toLowerCase(),r=Et.get(i);Et.set(i,{...r??{},infix:{bp:[e,s],handler:n}})}registerPrefixOperator(t,e,s){const n=t.toLowerCase(),i=Et.get(n);Et.set(n,{...i??{},prefix:{bp:e,handler:s}})}hasCommand(t){return yt.has(t.toLowerCase())}registerFeature(t,e){Tt.set(t.toLowerCase(),e)}hasFeature(t){return Tt.has(t.toLowerCase())}registerNodeEvaluator(t,e){At.set(t,e)}registerNodeWriter(t,e){Ot.set(t,e)}registerGlobalWriteHook(t){return function(t){return kt.add(t),()=>kt.delete(t)}(t)}registerGlobalReadHook(t){return function(t){return $t.add(t),()=>$t.delete(t)}(t)}registerLocalWriteHook(t){return function(t){return Mt.add(t),()=>Mt.delete(t)}(t)}registerLocalReadHook(t){return function(t){return St.add(t),()=>St.delete(t)}(t)}snapshot(){return{commands:Array.from(yt),operators:Array.from(wt),prattEntries:Array.from(Et.entries()).map(([t,e])=>[t,{...e}]),features:Array.from(Tt.entries()),nodeEvaluators:Array.from(At.entries()),nodeWriters:Array.from(Ot.entries()),globalWriteHooks:Array.from(kt),globalReadHooks:Array.from($t),localWriteHooks:Array.from(Mt),localReadHooks:Array.from(St)}}restore(t){yt.clear();for(const e of t.commands)yt.add(e);wt.clear();for(const e of t.operators)wt.add(e);Et.clear();for(const[e,s]of t.prattEntries)Et.set(e,s);Tt.clear();for(const[e,s]of t.features)Tt.set(e,s);At.clear();for(const[e,s]of t.nodeEvaluators)At.set(e,s);Ot.clear();for(const[e,s]of t.nodeWriters??[])Ot.set(e,s);!function(t){kt.clear();for(const e of t.globalWriteHooks??[])kt.add(e);$t.clear();for(const e of t.globalReadHooks??[])$t.add(e);Mt.clear();for(const e of t.localWriteHooks??[])Mt.add(e);St.clear();for(const e of t.localReadHooks??[])St.add(e)}(t)}},Ht="__hyperfixi_parser_extension_registry__";class _t{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 Ct{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 Ft(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 Lt(t){return t?t.split(/[-_]/)[0].toLowerCase():"en"}function qt(t){const e=t.getAttribute?.("data-hyperfixi-lang");if(e)return Lt(e);const s=t.closest?.("[data-hyperfixi-lang]");if(s)return Lt(s.getAttribute("data-hyperfixi-lang"));const n=t.closest?.("[lang]");return n?Lt(n.getAttribute("lang")):"en"}const Pt=new Map,Wt=new Map,Nt=new Map,Rt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),It=t=>t.replace(/[A-Z]+/g,t=>t.toLowerCase()),Dt=new Set;let Gt=0;const zt=new Set;function Bt(){const t=new Set;for(const e of Wt.values())for(const s of e.values())for(const e of s)t.add(e);return[...t]}function Jt(t,e){const s=Lt(t),n=e?.hyperfixi??{};var i;Pt.set(s,n),Wt.set(s,function(t){const e=new Map;if(!t)return e;for(const[s,n]of Object.entries(t)){const t=e.get(n);t?t.push(s):e.set(n,[s])}return e}(n.attrs)),Nt.set(s,function(t){const e=new Map;if(!t)return e;for(const[s,n]of Object.entries(t)){const i=It(s);i===s||Rt(t,i)||e.has(i)||e.set(i,n)}return e}(n.events)),Dt.delete(s),Gt||(i={nameOf:(t,e,s)=>{const n=`${e}-${s}`,i=qt(t);if("en"===i)return n;const r=Wt.get(i)?.get(n);return r?r.find(e=>t.hasAttribute(e))??r[0]:(Pt.has(i)||Dt.has(i)||(Dt.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 Wt.values())for(const e of t.get(s)??[])n.add(e);return[...n].map(t=>`[${t}]`).join(", ")},eventNameOf:(t,e,s)=>{const n=qt(t);if("en"===n)return e;const i=Pt.get(n)?.events;return i?Rt(i,e)?i[e]:s?.fromAttrName&&Nt.get(n)?.get(e)||e:e}},z=i,Gt=1);for(const t of zt)t()}const Zt="__hyperfixi_i18n";function Ut(){if("undefined"==typeof window)return;const t=window;t[Zt]||(t[Zt]={register:Jt})}function Vt(t){for(const e of function(){const t=new Set(["hx-on:"]);for(const e of Wt.values())for(const s of e.get("hx-on")??[])t.add(s+":");return[...t]}())if(t.startsWith(e))return t.slice(e.length);return null}Ut();const Xt=["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"]),Kt=["live"],Yt=["fx-action","fx-method","fx-trigger","fx-target","fx-swap","fx-ignore"],Qt=[...Xt,...Yt];function te(t,e,s){return t.getAttribute(B().nameOf(t,e,s))}function ee(t,e,s){return t.hasAttribute(B().nameOf(t,e,s))}class se{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=ht(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=te(t,"sse","connect");if(!s)return null;const n=new _t(t,s,(e,n)=>{const i={url:void 0,method:"GET",target:te(t,"hx","target")??void 0,swap:te(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=te(t,"sse","swap");if(i)for(const t of(r=i,r.split(I)).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(B().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=te(t,"ws","connect");if(!s)return null;const n=new Ct(t,s,(e,n)=>{const i={url:void 0,method:"GET",target:e.target,swap:e.swap??te(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=B().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=Ft(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=B().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(B().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=B().eventNameOf(t,i,{fromAttrName:1}),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=B(),e=[];for(const s of["get","post","put","patch","delete",...Kt])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!==Vt(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=te(t,"hx",s);if(n){e.method=s.toUpperCase(),e.url=n;break}}const s=te(t,"hx","target");s&&(e.target=s);const n=te(t,"hx","swap");n&&(e.swap=n);const i=te(t,"hx","trigger");i&&(e.trigger=i);const r=te(t,"hx","confirm");r&&(e.confirm=r),"true"===te(t,"hx","boost")&&(e.boost=1);const o=te(t,"hx","vals");o&&(e.vals=o);const a=te(t,"hx","headers");a&&(e.headers=a);const c=te(t,"hx","push-url");c&&(e.pushUrl="true"===c?1:c);const h=te(t,"hx","replace-url");h&&(e.replaceUrl="true"===h?1:h);const l={};for(const e of t.attributes){const t=Vt(e.name);null!==t&&(l[t]=e.value)}Object.keys(l).length>0&&(e.onHandlers=l);const u=te(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;ee(t,"sse","connect")&&this.attachSSE(t),ee(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[Ht];if(e&&"object"==typeof e&&"function"==typeof e.registerFeature)return e;t[Ht]=jt}return jt}().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=ft(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!==Vt(t)||this.localizedAttrSet.has(t))&&(this.processedElements.delete(e.target),this.processElement(e.target))}}}),this.localizedAttrSet=new Set(Bt()),this.unsubscribeVocab=(zt.add(t=()=>this.refreshLocalizedAttrs()),()=>{zt.delete(t)}),this.options.root&&this.observer.observe(this.options.root,{childList:1,subtree:1,attributes:1,attributeFilter:this.computeAttributeFilter()})}computeAttributeFilter(){const t=Bt();return 0===t.length?Qt:[...new Set([...Qt,...t])]}refreshLocalizedAttrs(){this.localizedAttrSet=new Set(Bt()),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 ft(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}}Ut();let ne=null;function ie(t={}){const{processHyperscript:e=1,...s}=t;ne=new se({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}),ne.init(async(t,e)=>{await W.execute(t,e)}),re||"undefined"==typeof document||(re=t=>{const e=t.detail,s=e?.elt??t.target;s&&"function"==typeof s.querySelector&&W.process(s)},document.addEventListener("htmx:load",re),document.addEventListener("htmx:after:process",re)),t.debug&&console.log("[hyperfixi-hx] htmx/fixi compatibility enabled")}let re=null;function oe(){ne&&(ne.destroy(),ne=null),re&&"undefined"!=typeof document&&(document.removeEventListener("htmx:load",re),document.removeEventListener("htmx:after:process",re),re=null)}function ae(t){return new se({processExisting:0,watchMutations:0}).manualProcess(t)}const ce={...W,version:"1.0.0-hybrid-hx",enableHtmxCompatibility:ie,disableHtmxCompatibility:oe,getHtmxProcessor:function(){return ne},translateHtmx:ae,hasHtmxAttributes:pt,hasFxAttributes:dt,hasAnyAttributes:mt,HtmxAttributeProcessor:se,translateToHyperscript:ft,features:{htmx:1,fixi:1,hyperscript:1},htmxAttributes:Xt,fixiAttributes:Yt,fixiEvents:["fx:init","fx:inited","fx:config","fx:before","fx:after","fx:error","fx:finally","fx:swapped"]};if("undefined"!=typeof window){window.hyperfixi=ce,window.lokascript=ce;const t=()=>{ie({processExisting:1,watchMutations:1,processHyperscript:1,requestDropping:1,fixiEvents:1})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}t.FIXI_ATTRS=Yt,t.HTMX_ATTRS=Xt,t.HtmxAttributeProcessor=se,t.default=ce,t.disableHtmxCompatibility=oe,t.enableHtmxCompatibility=ie,t.hasAnyAttributes=mt,t.hasFxAttributes=dt,t.translateHtmx=ae,Object.defineProperty(t,"t",{value:1})}({});
|