@lokascript/core 1.1.2 → 1.1.3

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.
Files changed (38) hide show
  1. package/dist/chunks/bridge-qXDe7P1g.js +2 -0
  2. package/dist/chunks/bridge-qXDe7P1g.js.map +1 -0
  3. package/dist/chunks/browser-modular-DfWTWK1K.js +2 -0
  4. package/dist/chunks/browser-modular-DfWTWK1K.js.map +1 -0
  5. package/dist/chunks/feature-eventsource-VXpBMoKs.js +2 -0
  6. package/dist/chunks/feature-eventsource-VXpBMoKs.js.map +1 -0
  7. package/dist/chunks/feature-sockets-CFuglALU.js +2 -0
  8. package/dist/chunks/feature-sockets-CFuglALU.js.map +1 -0
  9. package/dist/chunks/feature-webworker-JSaX8ZKW.js +2 -0
  10. package/dist/chunks/feature-webworker-JSaX8ZKW.js.map +1 -0
  11. package/dist/hyperfixi-browser-classic-i18n.js +2 -0
  12. package/dist/hyperfixi-browser-classic-i18n.js.map +1 -0
  13. package/dist/hyperfixi-browser-minimal.js +1 -0
  14. package/dist/hyperfixi-browser-standard.js +2 -0
  15. package/dist/hyperfixi-browser-standard.js.map +1 -0
  16. package/dist/hyperfixi-browser.js +2 -0
  17. package/dist/hyperfixi-browser.js.map +1 -0
  18. package/dist/hyperfixi-hybrid-complete.js +1 -0
  19. package/dist/hyperfixi-hybrid-hx.js +1 -0
  20. package/dist/hyperfixi-lite-plus.js +1 -0
  21. package/dist/hyperfixi-lite.js +1 -0
  22. package/dist/hyperfixi.mjs +2 -0
  23. package/dist/hyperfixi.mjs.map +1 -0
  24. package/dist/lokascript-browser-classic-i18n.js +2 -0
  25. package/dist/lokascript-browser-classic-i18n.js.map +1 -0
  26. package/dist/lokascript-browser-minimal.js +1 -0
  27. package/dist/lokascript-browser-standard.js +2 -0
  28. package/dist/lokascript-browser-standard.js.map +1 -0
  29. package/dist/lokascript-browser.js +2 -0
  30. package/dist/lokascript-browser.js.map +1 -0
  31. package/dist/lokascript-hybrid-complete.js +1 -0
  32. package/dist/lokascript-hybrid-hx.js +1 -0
  33. package/dist/lokascript-lite-plus.js +1 -0
  34. package/dist/lokascript-lite.js +1 -0
  35. package/dist/lokascript-multilingual.js +2 -0
  36. package/dist/lokascript-multilingual.js.map +1 -0
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ !function(){"use strict";const t=new Set(["on","from","to","into","before","after","in","of","at","with","if","else","unless","end","then","and","or","not","repeat","times","for","each","while","until","toggle","add","remove","put","set","get","call","return","append","log","send","trigger","wait","settle","fetch","as","show","hide","take","increment","decrement","focus","blur","go","transition","over","the","a","an","my","its","me","it","you","first","last","next","previous","closest","parent","true","false","null","undefined","is","matches","contains","includes","exists","has","init","every","by"]);function e(e){const s=[];let i=0;for(;e.length>i;){if(/\s/.test(e[i])){i++;continue}if("--"===e.slice(i,i+2)){for(;e.length>i&&"\n"!==e[i];)i++;continue}const r=i;if("<"===e[i]&&/[a-zA-Z]/.test(e[i+1]||"")){for(i++;e.length>i&&">"!==e[i];)i++;">"===e[i]&&i++;const t=e.slice(r,i);if(t.endsWith("/>")||t.endsWith(">")){const e=t.slice(1).replace(/\/?>$/,"");s.push({type:"selector",value:e,pos:r});continue}}if("'s"===e.slice(i,i+2)&&!/[a-zA-Z]/.test(e[i+2]||"")){s.push({type:"operator",value:"'s",pos:r}),i+=2;continue}if('"'===e[i]||"'"===e[i]){const t=e[i++];for(;e.length>i&&e[i]!==t;)"\\"===e[i]&&i++,i++;i++,s.push({type:"string",value:e.slice(r,i),pos:r});continue}if(/\d/.test(e[i])||"-"===e[i]&&/\d/.test(e[i+1]||"")){for("-"===e[i]&&i++;e.length>i&&/[\d.]/.test(e[i]);)i++;"ms"===e.slice(i,i+2)?i+=2:"s"!==e[i]||/[a-zA-Z]/.test(e[i+1]||"")?"px"===e.slice(i,i+2)&&(i+=2):i++,s.push({type:"number",value:e.slice(r,i),pos:r});continue}if(":"===e[i]){for(i++;e.length>i&&/[\w]/.test(e[i]);)i++;s.push({type:"localVar",value:e.slice(r,i),pos:r});continue}if("$"===e[i]){for(i++;e.length>i&&/[\w]/.test(e[i]);)i++;s.push({type:"globalVar",value:e.slice(r,i),pos:r});continue}if("#"===e[i]||"."===e[i]){if("."===e[i]&&e.slice(i+1).match(/^(once|prevent|stop|debounce|throttle)\b/i)){s.push({type:"symbol",value:".",pos:r}),i++;continue}for(i++;e.length>i&&/[\w-]/.test(e[i]);)i++;s.push({type:"selector",value:e.slice(r,i),pos:r});continue}if("["===e[i]){let t=i+1;for(;e.length>t&&/\s/.test(e[t]);)t++;const n=e[t]||"";if(/['"\d\[\]:\$\-]/.test(n)||""===n){s.push({type:"symbol",value:"[",pos:r}),i++;continue}{i++;let t=1;for(;e.length>i&&t>0;)"["===e[i]&&t++,"]"===e[i]&&t--,i++;s.push({type:"selector",value:e.slice(r,i),pos:r});continue}}if("]"===e[i]){s.push({type:"symbol",value:"]",pos:r}),i++;continue}if("'s"===e.slice(i,i+2)){s.push({type:"operator",value:"'s",pos:r}),i+=2;continue}const n=e.slice(i,i+2);if(["==","!=","<=",">=","&&","||"].includes(n))s.push({type:"operator",value:n,pos:r}),i+=2;else if("*"===e[i]&&/[a-zA-Z]/.test(e[i+1]||"")){for(i++;e.length>i&&/[\w-]/.test(e[i]);)i++;s.push({type:"styleProperty",value:e.slice(r,i),pos:r})}else if("+-*/%<>!".includes(e[i]))s.push({type:"operator",value:e[i],pos:r}),i++;else if("()[]{},.".includes(e[i]))s.push({type:"symbol",value:e[i],pos:r}),i++;else{if(/[a-zA-Z_]/.test(e[i])){for(;e.length>i&&/[\w-]/.test(e[i]);)i++;const n=e.slice(r,i),a=t.has(n.toLowerCase())?"keyword":"identifier";s.push({type:a,value:n,pos:r});continue}i++}}return s.push({type:"eof",value:"",pos:e.length}),s}const s={flip:"toggle",switch:"toggle",display:"show",reveal:"show",conceal:"hide",increase:"increment",decrease:"decrement",fire:"trigger",dispatch:"send",navigate:"go",goto:"go"},i={clicked:"click",pressed:"keydown",changed:"change",submitted:"submit",loaded:"load"};function r(t){const e=t.toLowerCase();return s[e]||e}function n(t){const e=t.toLowerCase();return i[e]||e}class a{constructor(t){this.pos=0,this.tokens=e(t)}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}advance(){return this.tokens[this.pos++]}match(...t){const e=this.peek();return t.some(t=>e.value.toLowerCase()===t.toLowerCase())}matchType(...t){return t.includes(this.peek().type)}expect(t){if(!this.match(t)&&r(this.peek().value)!==t)throw Error(`Expected '${t}', got '${this.peek().value}'`);return this.advance()}isAtEnd(){return"eof"===this.peek().type}parse(){return this.match("on")?this.parseEventHandler():this.match("init")?(this.advance(),{type:"event",event:"init",modifiers:{},body:this.parseCommandSequence()}):this.match("every")?this.parseEveryHandler():{type:"sequence",commands:this.parseCommandSequence()}}parseEventHandler(){this.expect("on");const t=this.advance().value,e={};let s;for(;"."===this.peek().value;){this.advance();const t=this.advance().value.toLowerCase();if("once"===t)e.once=1;else if("prevent"===t)e.prevent=1;else if("stop"===t)e.stop=1;else if(("debounce"===t||"throttle"===t)&&"("===this.peek().value){this.advance();const s=this.advance().value;this.expect(")"),"debounce"===t?e.debounce=parseInt(s)||100:e.throttle=parseInt(s)||100}}return this.match("from")&&(this.advance(),s=this.parseExpression()),{type:"event",event:n(t),filter:s,modifiers:e,body:this.parseCommandSequence()}}parseEveryHandler(){return this.expect("every"),{type:"event",event:"interval:"+this.advance().value,modifiers:{},body:this.parseCommandSequence()}}parseCommandSequence(){const t=[];for(;!this.isAtEnd()&&!this.match("end","else");){const e=this.parseCommand();e&&t.push(e),this.match("then","and")&&this.advance()}return t}parseCommand(){if(this.match("if","unless"))return this.parseIf();if(this.match("repeat"))return this.parseRepeat();if(this.match("for"))return this.parseFor();if(this.match("while"))return this.parseWhile();if(this.match("fetch"))return this.parseFetchBlock();const t={toggle:()=>this.parseToggle(),add:()=>this.parseAdd(),remove:()=>this.parseRemove(),put:()=>this.parsePut(),append:()=>this.parseAppend(),set:()=>this.parseSet(),get:()=>this.parseGet(),call:()=>this.parseCall(),log:()=>this.parseLog(),send:()=>this.parseSend(),trigger:()=>this.parseSend(),wait:()=>this.parseWait(),show:()=>this.parseShow(),hide:()=>this.parseHide(),take:()=>this.parseTake(),increment:()=>this.parseIncDec("increment"),decrement:()=>this.parseIncDec("decrement"),focus:()=>this.parseFocusBlur("focus"),blur:()=>this.parseFocusBlur("blur"),go:()=>this.parseGo(),return:()=>this.parseReturn(),transition:()=>this.parseTransition()},e=r(this.peek().value);return t[e]?t[e]():(this.isAtEnd()||this.match("then","and","end","else")||this.advance(),null)}parseIf(){const t=this.match("unless");this.advance();const e=this.parseExpression(),s=this.parseCommandSequence();let i;return this.match("else")&&(this.advance(),i=this.parseCommandSequence()),this.match("end")&&this.advance(),{type:"if",condition:t?{type:"unary",operator:"not",operand:e}:e,body:s,elseBody:i}}parseRepeat(){let t;this.expect("repeat"),this.match("until","while","forever")||(t=this.parseExpression(),this.match("times")&&this.advance());const e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"repeat",condition:t,body:e}}parseFor(){this.expect("for"),this.match("each")&&this.advance();const t=this.advance().value;this.expect("in");const e=this.parseExpression(),s=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"for",condition:{type:"forCondition",variable:t,iterable:e},body:s}}parseWhile(){this.expect("while");const t=this.parseExpression(),e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"while",condition:t,body:e}}parseFetchBlock(){this.expect("fetch");const t=this.parseExpression();let e={type:"literal",value:"text"};return this.match("as")&&(this.advance(),e=this.parseExpression()),this.match("then")&&this.advance(),{type:"fetch",condition:{type:"fetchConfig",url:t,responseType:e},body:this.parseCommandSequence()}}parseToggle(){this.expect("toggle");const t=this.parseExpression();let e;return this.match("on")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"toggle",args:[t],target:e}}parseAdd(){this.expect("add");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"add",args:[t],target:e}}parseRemove(){if(this.expect("remove"),this.matchType("selector")){const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"removeClass",args:[t],target:e}}return{type:"command",name:"remove",args:[],target:this.parseExpression()}}parsePut(){this.expect("put");const t=this.parseExpression();let e="into";if(this.match("into","before","after","at")&&(e=this.advance().value,"at"===e)){const t=this.advance().value;this.expect("of"),e=`at ${t} of`}return{type:"command",name:"put",args:[t],target:this.parseExpression(),modifier:e}}parseAppend(){this.expect("append");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"append",args:[t],target:e}}parseSet(){this.expect("set");const t=this.parseExpression();return this.match("to")?(this.advance(),{type:"command",name:"set",args:[t,this.parseExpression()]}):{type:"command",name:"set",args:[t]}}parseGet(){return this.expect("get"),{type:"command",name:"get",args:[this.parseExpression()]}}parseCall(){return this.expect("call"),{type:"command",name:"call",args:[this.parseExpression()]}}parseLog(){this.expect("log");const t=[];for(;!this.isAtEnd()&&!this.match("then","and","end","else")&&(t.push(this.parseExpression()),this.match(","));)this.advance();return{type:"command",name:"log",args:t}}parseSend(){this.advance();const t=this.advance().value;let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"send",args:[{type:"literal",value:t}],target:e}}parseWait(){if(this.expect("wait"),this.match("for")){this.advance();const t=this.advance().value;let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"waitFor",args:[{type:"literal",value:t}],target:e}}return{type:"command",name:"wait",args:[this.parseExpression()]}}parseShow(){let t;this.expect("show");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"show",args:[],target:t,modifiers:e}}parseHide(){let t;this.expect("hide");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"hide",args:[],target:t,modifiers:e}}parseTake(){this.expect("take");const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"take",args:[t],target:e}}parseIncDec(t){this.advance();const e=this.parseExpression();let s={type:"literal",value:1};return this.match("by")&&(this.advance(),s=this.parseExpression()),{type:"command",name:t,args:[e,s]}}parseFocusBlur(t){let e;return this.advance(),this.isAtEnd()||this.match("then","and","end","else")||(e=this.parseExpression()),{type:"command",name:t,args:[],target:e}}parseGo(){return this.expect("go"),this.match("to")&&this.advance(),this.match("url")&&this.advance(),{type:"command",name:"go",args:[this.parseExpression()]}}parseReturn(){let t;return this.expect("return"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"return",args:t?[t]:[]}}parseTransition(){let t;if(this.expect("transition"),this.match("my","its"))t={type:"identifier",value:"my"===this.advance().value?"me":"it"};else if(this.matchType("selector")){const e=this.parseExpression();if("possessive"===e.type)return this.parseTransitionRest(e.object,e.property);t=e}const e=this.peek();let s;return s="styleProperty"===e.type||"identifier"===e.type||"keyword"===e.type?this.advance().value:"opacity",this.parseTransitionRest(t,s)}parseTransitionRest(t,e){let s={type:"literal",value:1};this.match("to")&&(this.advance(),s=this.parseExpression());let i={type:"literal",value:300};return this.match("over")&&(this.advance(),i=this.parseExpression()),{type:"command",name:"transition",args:[{type:"literal",value:e},s,i],target:t}}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.match("or","||");)this.advance(),t={type:"binary",operator:"or",left:t,right:this.parseAnd()};return t}parseAnd(){let t=this.parseEquality();for(;this.match("and","&&")&&!this.isCommandKeyword(this.peek(1));)this.advance(),t={type:"binary",operator:"and",left:t,right:this.parseEquality()};return t}isCommandKeyword(t){return["toggle","add","remove","set","put","log","send","wait","show","hide","increment","decrement","focus","blur","go"].includes(r(t.value))}parseEquality(){let t=this.parseComparison();for(;this.match("==","!=","is","matches","contains","includes","has");){const e=this.advance().value;"is"===e.toLowerCase()&&this.match("not")?(this.advance(),t={type:"binary",operator:"is not",left:t,right:this.parseComparison()}):t={type:"binary",operator:e,left:t,right:this.parseComparison()}}return t}parseComparison(){let t=this.parseAdditive();for(;this.match("<",">","<=",">=");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseAdditive()};return t}parseAdditive(){let t=this.parseMultiplicative();for(;this.match("+","-");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseMultiplicative()};return t}parseMultiplicative(){let t=this.parseUnary();for(;this.match("*","/","%");)t={type:"binary",operator:this.advance().value,left:t,right:this.parseUnary()};return t}parseUnary(){if(this.match("not","!"))return this.advance(),{type:"unary",operator:"not",operand:this.parseUnary()};if(this.match("-")&&"number"===this.peek(1).type){this.advance();const t=this.advance();return{type:"literal",value:-parseFloat(t.value)}}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("'s"))this.advance(),this.peek(),t={type:"possessive",object:t,property:this.advance().value};else if("styleProperty"===this.peek().type)t={type:"possessive",object:t,property:this.advance().value};else if("."===this.peek().value)this.advance(),t={type:"member",object:t,property:this.advance().value};else if("selector"===this.peek().type&&this.peek().value.startsWith("."))t={type:"member",object:t,property:this.advance().value.slice(1)};else if("("===this.peek().value){this.advance();const e=[];for(;!this.match(")");)e.push(this.parseExpression()),this.match(",")&&this.advance();this.expect(")"),t={type:"call",callee:t,args:e}}else{if("["!==this.peek().value||"selector"===t.type)break;{this.advance();const e=this.parseExpression();this.expect("]"),t={type:"member",object:t,property:e,computed:1}}}return t}parsePrimary(){const t=this.peek();if("("===t.value){this.advance();const t=this.parseExpression();return this.expect(")"),t}if("{"===t.value)return this.parseObjectLiteral();if("["===t.value)return this.parseArrayLiteral();if("number"===t.type){this.advance();const e=t.value;return e.endsWith("ms")?{type:"literal",value:parseInt(e),unit:"ms"}:e.endsWith("s")?{type:"literal",value:1e3*parseFloat(e),unit:"ms"}:{type:"literal",value:parseFloat(e)}}if("string"===t.type)return this.advance(),{type:"literal",value:t.value.slice(1,-1)};if(this.match("true"))return this.advance(),{type:"literal",value:1};if(this.match("false"))return this.advance(),{type:"literal",value:0};if(this.match("null"))return this.advance(),{type:"literal",value:null};if(this.match("undefined"))return this.advance(),{type:"literal",value:void 0};if("localVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"local"};if("globalVar"===t.type)return this.advance(),{type:"variable",name:t.value,scope:"global"};if("selector"===t.type)return this.advance(),{type:"selector",value:t.value};if(this.match("my")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"me"}:{type:"possessive",object:{type:"identifier",value:"me"},property:this.advance().value}}if(this.match("its")){this.advance();const t=this.peek();return"identifier"!==t.type&&"keyword"!==t.type||this.isCommandKeyword(t)?{type:"identifier",value:"it"}:{type:"possessive",object:{type:"identifier",value:"it"},property:this.advance().value}}return this.match("me")?(this.advance(),{type:"identifier",value:"me"}):this.match("it")?(this.advance(),{type:"identifier",value:"it"}):this.match("you")?(this.advance(),{type:"identifier",value:"you"}):this.match("the","a","an")?(this.advance(),this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:this.parsePrimary()):this.match("first","last","next","previous","closest","parent")?{type:"positional",position:this.advance().value,target:this.parsePositionalTarget()}:(this.advance(),{type:"identifier",value:t.value})}parseObjectLiteral(){this.expect("{");const t=[];for(;!this.match("}");){const e=this.advance().value;this.expect(":");const s=this.parseExpression();t.push({key:e,value:s}),this.match(",")&&this.advance()}return this.expect("}"),{type:"object",properties:t}}parseArrayLiteral(){this.expect("[");const t=[];for(;!this.match("]");)t.push(this.parseExpression()),this.match(",")&&this.advance();return this.expect("]"),{type:"array",elements:t}}parsePositionalTarget(){const t=this.peek();return"selector"===t.type?{type:"selector",value:this.advance().value}:"identifier"===t.type||"keyword"===t.type?{type:"identifier",value:this.advance().value}:this.parseExpression()}}const o=new Map,c=1e3;async function h(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 e.locals.get(t.name.slice(1));const s=t.name.slice(1);return o.has(s)?o.get(s):window[t.name];case"selector":const i=document.querySelectorAll(t.value);return 1===i.length?i[0]:Array.from(i);case"binary":return async function(t,e){if("has"===t.operator){const s=await h(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 h(t.left,e),i=await h(t.right,e);switch(t.operator){case"+":return s+i;case"-":return s-i;case"*":return s*i;case"/":return s/i;case"%":return s%i;case"==":case"is":return s==i;case"!=":case"is not":return s!=i;case"<":return i>s;case">":return s>i;case"<=":return i>=s;case">=":return s>=i;case"and":case"&&":return s&&i;case"or":case"||":return s||i;case"has":if(s instanceof Element){const t="string"==typeof i?i:i?.value;if("string"==typeof t&&t.startsWith("."))return s.classList.contains(t.slice(1))}return 0;case"contains":case"includes":return"string"==typeof s||Array.isArray(s)?s.includes(i):s instanceof Element?s.contains(i):0;case"matches":return s instanceof Element?s.matches(i):"string"==typeof s?RegExp(i).test(s):0;default:return}}(t,e);case"unary":const r=await h(t.operand,e);return"not"===t.operator?!r:r;case"possessive":case"member":const n=await h(t.object,e);if(null==n)return;return n[t.computed?await h(t.property,e):t.property];case"call":{let s,i=null;if("member"===t.callee.type||"possessive"===t.callee.type){i=await h(t.callee.object,e);const r=t.callee.computed?await h(t.callee.property,e):t.callee.property;s=i?.[r]}else s=await h(t.callee,e);const r=await Promise.all(t.args.map(t=>h(t,e)));return"function"==typeof s?s.apply(i,r):void 0}case"positional":return function(t,e){const s=t.target;let i=[],r=null;switch(("selector"===s.type||"identifier"===s.type||"htmlSelector"===s.type)&&(r=s.value),r&&(i=Array.from(document.querySelectorAll(r))),t.position){case"first":default:return i[0]||null;case"last":return i[i.length-1]||null;case"next":return e.me.nextElementSibling;case"previous":return e.me.previousElementSibling;case"closest":return s.value?e.me.closest(s.value):null;case"parent":return e.me.parentElement}}(t,e);case"object":const a={};for(const s of t.properties)a[s.key]=await h(s.value,e);return a;case"array":return Promise.all(t.elements.map(t=>h(t,e)));default:return}}async function l(t,e){const s=async()=>{if(!t.target)return[e.me];const s=await h(t.target,e);return Array.isArray(s)?s:s instanceof Element?[s]:"string"==typeof s?Array.from(document.querySelectorAll(s)):[e.me]},i=t=>{if(!t)return"";if("selector"===t.type)return t.value.slice(1);if("string"===t.type||"literal"===t.type){const e=t.value;return"string"==typeof e&&e.startsWith(".")?e.slice(1):e+""}return"identifier"===t.type?t.value:""},r=t=>Array.isArray(t)?t.filter(t=>t instanceof Element):t instanceof Element?[t]:"string"==typeof t?Array.from(document.querySelectorAll(t)):[],n=t=>t.startsWith("*"),a=t=>t.substring(1),c=(t,e,s)=>n(e)?(t.style.setProperty(a(e),s+""),1):0,l=(t,e)=>{if(n(e))return getComputedStyle(t).getPropertyValue(a(e))};switch(t.name){case"toggle":{const r=i(t.args[0])||await h(t.args[0],e)+"",n=await s();for(const t of n)t.classList.toggle(r);return e.it=1===n.length?n[0]:n,e.it}case"add":{const r=i(t.args[0])||await h(t.args[0],e)+"",n=await s();for(const t of n)t.classList.add(r);return e.it=1===n.length?n[0]:n,e.it}case"removeClass":{const r=i(t.args[0])||await h(t.args[0],e)+"",n=await s();for(const t of n)t.classList.remove(r);return e.it=1===n.length?n[0]:n,e.it}case"remove":{const t=await s();for(const e of t)e.remove();return null}case"put":{const i=await h(t.args[0],e),a=t.modifier||"into";if("possessive"===t.target?.type&&n(t.target.property)){const s=r(await h(t.target.object,e));for(const e of s)c(e,t.target.property,i);return e.it=i,i}const o=await s();for(const t of o){const e=i+"";"into"===a?t.innerHTML=e:"before"===a?t.insertAdjacentHTML("beforebegin",e):"after"===a?t.insertAdjacentHTML("afterend",e):"at start of"===a?t.insertAdjacentHTML("afterbegin",e):"at end of"===a&&t.insertAdjacentHTML("beforeend",e)}return e.it=i,i}case"append":{const i=await h(t.args[0],e),r=await s();for(const t of r)t.insertAdjacentHTML("beforeend",i+"");return e.it=i,i}case"set":{const s=t.args[0],i=await h(t.args[1],e);if("variable"===s.type){const t=s.name.slice(1);return("local"===s.scope?e.locals:o).set(t,i),e.it=i,i}if("possessive"===s.type||"member"===s.type){const t=await h(s.object,e);if(t)return t instanceof Element&&c(t,s.property,i)?(e.it=i,i):(t[s.property]=i,e.it=i,i)}return e.it=i,i}case"get":{const s=await h(t.args[0],e);return e.it=s,s}case"call":{const s=await h(t.args[0],e);return e.it=s,s}case"log":{const s=await Promise.all(t.args.map(t=>h(t,e)));return console.log(...s),s[0]}case"send":{const i=await h(t.args[0],e),r=await s(),n=new CustomEvent(i+"",{bubbles:1,detail:e.it});for(const t of r)t.dispatchEvent(n);return e.it=n,n}case"wait":{const s=await h(t.args[0],e),i="number"==typeof s?s:parseInt(s+"");return await new Promise(t=>setTimeout(t,i)),i}case"waitFor":{const i=await h(t.args[0],e),r=(await s())[0]||e.me;return new Promise(t=>{r.addEventListener(i+"",s=>{e.it=s,t(s)},{once:1})})}case"show":{const t=await s();for(const e of t)e.style.display="",e.classList.remove("hidden");return t}case"hide":{const t=await s();for(const e of t)e.style.display="none";return t}case"transition":{const i=(await h(t.args[0],e)+"").replace(/^\*/,""),r=await h(t.args[1],e),n=await h(t.args[2],e),a="number"==typeof n?n:(n+"").endsWith("ms")?parseInt(n+""):(n+"").endsWith("s")?1e3*parseFloat(n+""):parseInt(n+"")||300,o=await s(),c=[];for(const t of o){const e=t,s=i.replace(/([A-Z])/g,"-$1").toLowerCase(),n=e.style.transition;e.style.transition=`${s} ${a}ms ease`,e.style.setProperty(s,r+""),c.push(new Promise(t=>{const i=()=>{e.style.transition=n,t()},r=t=>{t.propertyName===s&&(e.removeEventListener("transitionend",r),i())};e.addEventListener("transitionend",r),setTimeout(i,a+50)}))}return await Promise.all(c),e.it=1===o.length?o[0]:o,e.it}case"take":{const r=i(await h(t.args[0],e)),n=t.target?await s():[e.me.parentElement];for(const t of n)t.querySelectorAll("."+r).forEach(t=>t.classList.remove(r));return e.me.classList.add(r),e.me}case"increment":case"decrement":{const s=t.args[0],i=await h(t.args[1],e),a="increment"===t.name?i:-i;if("variable"===s.type){const t=s.name.slice(1),i="local"===s.scope?e.locals:o,r=(i.get(t)||0)+a;return i.set(t,r),e.it=r,r}if("possessive"===s.type&&n(s.property)){const t=r(await h(s.object,e));for(const i of t){const t=(parseFloat(l(i,s.property)||"0")||0)+a;c(i,s.property,t),e.it=t}return e.it}const u=r(await h(s,e));for(const t of u){const s=(parseFloat(t.textContent||"0")||0)+a;t.textContent=s+"",e.it=s}return e.it}case"focus":{const t=await s();for(const e of t)e.focus();return t}case"blur":{const t=await s();for(const e of t)e.blur();return t}case"go":{const s=await h(t.args[0],e),i=(s+"").toLowerCase();return"back"===i?history.back():"forward"===i?history.forward():window.location.href=s+"",null}case"return":throw{type:"return",value:t.args[0]?await h(t.args[0],e):e.it};default:return console.warn("Unknown command: "+t.name),null}}async function u(t,e){try{return await f(t,e)}catch(t){if("return"===t?.type)throw t;throw t}}async function p(t,e){switch(t.type){case"if":return await h(t.condition,e)?u(t.body,e):t.elseBody?u(t.elseBody,e):null;case"repeat":{const s=await h(t.condition,e),i="number"==typeof s?s:parseInt(s+"");for(let s=0;i>s&&c>s;s++)e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await u(t.body,e);return null}case"for":{const{variable:s,iterable:i}=t.condition,r=await h(i,e),n=Array.isArray(r)?r:r instanceof NodeList?Array.from(r):[r],a=s.startsWith(":")?s.slice(1):s;for(let s=0;n.length>s&&c>s;s++)e.locals.set(a,n[s]),e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await u(t.body,e);return null}case"while":{let s=0;for(;await h(t.condition,e)&&c>s;)e.locals.set("__loop_index__",s),await u(t.body,e),s++;return null}case"fetch":{const{url:s,responseType:i}=t.condition;try{const r=await h(s,e),n=await fetch(r+"");if(!n.ok)throw Error("HTTP "+n.status);const a=await h(i,e);let o;if("json"===a)o=await n.json();else if("html"===a){const t=await n.text();o=(new DOMParser).parseFromString(t,"text/html").body.innerHTML}else o=await n.text();e.it=o,e.locals.set("it",o),e.locals.set("result",o),e.locals.set("response",n),await u(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 i of t)"command"===i.type?s=await l(i,e):["if","repeat","for","while","fetch"].includes(i.type)&&(s=await p(i,e));return s}async function d(t,e,s){const i={me:e,event:s,locals:new Map,globals:o};if("sequence"===t.type)return f(t.commands,i);if("event"===t.type){const s=t,r=s.event;if(r.startsWith("interval:")){const t=r.split(":")[1],i=t.endsWith("ms")?parseInt(t):t.endsWith("s")?1e3*parseFloat(t):parseInt(t);return void setInterval(async()=>{const t={me:e,locals:new Map,globals:o};try{await f(s.body,t)}catch(t){if("return"!==t?.type)throw t}},i)}if("init"===r){try{await f(s.body,i)}catch(t){if("return"!==t?.type)throw t}return}const n=s.filter?await h(s.filter,i):e,a=n instanceof Element?n:e,c=s.modifiers;let l=async t=>{c.prevent&&t.preventDefault(),c.stop&&t.stopPropagation();const i={me:e,event:t,you:t.target instanceof Element?t.target:void 0,locals:new Map,globals:o};try{await f(s.body,i)}catch(t){if("return"===t?.type)return t.value;throw t}};if(c.debounce){let t;const e=l;l=async s=>{clearTimeout(t),t=setTimeout(()=>e(s),c.debounce)}}if(c.throttle){let t=0;const e=l;l=async s=>{const i=Date.now();c.throttle>i-t||(t=i,await e(s))}}return void a.addEventListener(r,l,{once:!!c.once})}return null}function y(t){const e=t.getAttribute("_");if(e)try{const s=new a(e).parse();console.log("HyperFixi AST:",JSON.stringify(s,null,2).slice(0,500)),d(s,t)}catch(t){console.error("HyperFixi Hybrid Complete error:",t,"Code:",e)}}function m(t=document){t.querySelectorAll("[_]").forEach(y)}"undefined"!=typeof window&&(window.hyperfixi={version:"1.0.0-hybrid-complete",parse:t=>new a(t).parse(),async execute(t,e){const s=e||document.body;return d(new a(t).parse(),s)},init:m,process:m,addAliases:function(t){Object.assign(s,t)},addEventAliases:function(t){Object.assign(i,t)},tokenize:e,evaluate:h,commands:["toggle","add","remove","put","append","set","get","call","log","send","trigger","wait","show","hide","transition","take","increment","decrement","focus","blur","go","return"],blocks:["if","else","unless","repeat","for","while","fetch"]},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>m()):m())}();
@@ -0,0 +1 @@
1
+ !function(t){"use strict";const e=new Set(["on","from","to","into","before","after","in","of","at","with","if","else","unless","end","then","and","or","not","repeat","times","for","each","while","until","toggle","add","remove","put","set","get","call","return","append","log","send","trigger","wait","settle","fetch","as","show","hide","take","increment","decrement","focus","blur","go","transition","over","the","a","an","my","its","me","it","you","first","last","next","previous","closest","parent","true","false","null","undefined","is","matches","contains","includes","exists","has","init","every","by"]);function s(t){const s=[];let i=0;for(;t.length>i;){if(/\s/.test(t[i])){i++;continue}if("--"===t.slice(i,i+2)){for(;t.length>i&&"\n"!==t[i];)i++;continue}const r=i;if("<"===t[i]&&/[a-zA-Z]/.test(t[i+1]||"")){for(i++;t.length>i&&">"!==t[i];)i++;">"===t[i]&&i++;const e=t.slice(r,i);if(e.endsWith("/>")||e.endsWith(">")){const t=e.slice(1).replace(/\/?>$/,"");s.push({type:"selector",value:t,pos:r});continue}}if("'s"===t.slice(i,i+2)&&!/[a-zA-Z]/.test(t[i+2]||"")){s.push({type:"operator",value:"'s",pos:r}),i+=2;continue}if('"'===t[i]||"'"===t[i]){const e=t[i++];for(;t.length>i&&t[i]!==e;)"\\"===t[i]&&i++,i++;i++,s.push({type:"string",value:t.slice(r,i),pos:r});continue}if(/\d/.test(t[i])||"-"===t[i]&&/\d/.test(t[i+1]||"")){for("-"===t[i]&&i++;t.length>i&&/[\d.]/.test(t[i]);)i++;"ms"===t.slice(i,i+2)?i+=2:"s"!==t[i]||/[a-zA-Z]/.test(t[i+1]||"")?"px"===t.slice(i,i+2)&&(i+=2):i++,s.push({type:"number",value:t.slice(r,i),pos:r});continue}if(":"===t[i]){for(i++;t.length>i&&/[\w]/.test(t[i]);)i++;s.push({type:"localVar",value:t.slice(r,i),pos:r});continue}if("$"===t[i]){for(i++;t.length>i&&/[\w]/.test(t[i]);)i++;s.push({type:"globalVar",value:t.slice(r,i),pos:r});continue}if("#"===t[i]||"."===t[i]){if("."===t[i]&&t.slice(i+1).match(/^(once|prevent|stop|debounce|throttle)\b/i)){s.push({type:"symbol",value:".",pos:r}),i++;continue}for(i++;t.length>i&&/[\w-]/.test(t[i]);)i++;s.push({type:"selector",value:t.slice(r,i),pos:r});continue}if("["===t[i]){let e=i+1;for(;t.length>e&&/\s/.test(t[e]);)e++;const n=t[e]||"";if(/['"\d\[\]:\$\-]/.test(n)||""===n){s.push({type:"symbol",value:"[",pos:r}),i++;continue}{i++;let e=1;for(;t.length>i&&e>0;)"["===t[i]&&e++,"]"===t[i]&&e--,i++;s.push({type:"selector",value:t.slice(r,i),pos:r});continue}}if("]"===t[i]){s.push({type:"symbol",value:"]",pos:r}),i++;continue}if("'s"===t.slice(i,i+2)){s.push({type:"operator",value:"'s",pos:r}),i+=2;continue}const n=t.slice(i,i+2);if(["==","!=","<=",">=","&&","||"].includes(n))s.push({type:"operator",value:n,pos:r}),i+=2;else if("*"===t[i]&&/[a-zA-Z]/.test(t[i+1]||"")){for(i++;t.length>i&&/[\w-]/.test(t[i]);)i++;s.push({type:"styleProperty",value:t.slice(r,i),pos:r})}else if("+-*/%<>!".includes(t[i]))s.push({type:"operator",value:t[i],pos:r}),i++;else if("()[]{},.".includes(t[i]))s.push({type:"symbol",value:t[i],pos:r}),i++;else{if(/[a-zA-Z_]/.test(t[i])){for(;t.length>i&&/[\w-]/.test(t[i]);)i++;const n=t.slice(r,i),o=e.has(n.toLowerCase())?"keyword":"identifier";s.push({type:o,value:n,pos:r});continue}i++}}return s.push({type:"eof",value:"",pos:t.length}),s}const i={flip:"toggle",switch:"toggle",display:"show",reveal:"show",conceal:"hide",increase:"increment",decrease:"decrement",fire:"trigger",dispatch:"send",navigate:"go",goto:"go"},r={clicked:"click",pressed:"keydown",changed:"change",submitted:"submit",loaded:"load"};function n(t){const e=t.toLowerCase();return i[e]||e}function o(t){const e=t.toLowerCase();return r[e]||e}class a{constructor(t){this.pos=0,this.tokens=s(t)}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}advance(){return this.tokens[this.pos++]}match(...t){const e=this.peek();return t.some(t=>e.value.toLowerCase()===t.toLowerCase())}matchType(...t){return t.includes(this.peek().type)}expect(t){if(!this.match(t)&&n(this.peek().value)!==t)throw Error(`Expected '${t}', got '${this.peek().value}'`);return this.advance()}isAtEnd(){return"eof"===this.peek().type}parse(){return this.match("on")?this.parseEventHandler():this.match("init")?(this.advance(),{type:"event",event:"init",modifiers:{},body:this.parseCommandSequence()}):this.match("every")?this.parseEveryHandler():{type:"sequence",commands:this.parseCommandSequence()}}parseEventHandler(){this.expect("on");const t=this.advance().value,e={};let s;for(;"."===this.peek().value;){this.advance();const t=this.advance().value.toLowerCase();if("once"===t)e.once=1;else if("prevent"===t)e.prevent=1;else if("stop"===t)e.stop=1;else if(("debounce"===t||"throttle"===t)&&"("===this.peek().value){this.advance();const s=this.advance().value;this.expect(")"),"debounce"===t?e.debounce=parseInt(s)||100:e.throttle=parseInt(s)||100}}return this.match("from")&&(this.advance(),s=this.parseExpression()),{type:"event",event:o(t),filter:s,modifiers:e,body:this.parseCommandSequence()}}parseEveryHandler(){return this.expect("every"),{type:"event",event:"interval:"+this.advance().value,modifiers:{},body:this.parseCommandSequence()}}parseCommandSequence(){const t=[];for(;!this.isAtEnd()&&!this.match("end","else");){const e=this.parseCommand();e&&t.push(e),this.match("then","and")&&this.advance()}return t}parseCommand(){if(this.match("if","unless"))return this.parseIf();if(this.match("repeat"))return this.parseRepeat();if(this.match("for"))return this.parseFor();if(this.match("while"))return this.parseWhile();if(this.match("fetch"))return this.parseFetchBlock();const t={toggle:()=>this.parseToggle(),add:()=>this.parseAdd(),remove:()=>this.parseRemove(),put:()=>this.parsePut(),append:()=>this.parseAppend(),set:()=>this.parseSet(),get:()=>this.parseGet(),call:()=>this.parseCall(),log:()=>this.parseLog(),send:()=>this.parseSend(),trigger:()=>this.parseSend(),wait:()=>this.parseWait(),show:()=>this.parseShow(),hide:()=>this.parseHide(),take:()=>this.parseTake(),increment:()=>this.parseIncDec("increment"),decrement:()=>this.parseIncDec("decrement"),focus:()=>this.parseFocusBlur("focus"),blur:()=>this.parseFocusBlur("blur"),go:()=>this.parseGo(),return:()=>this.parseReturn(),transition:()=>this.parseTransition()},e=n(this.peek().value);return t[e]?t[e]():(this.isAtEnd()||this.match("then","and","end","else")||this.advance(),null)}parseIf(){const t=this.match("unless");this.advance();const e=this.parseExpression(),s=this.parseCommandSequence();let i;return this.match("else")&&(this.advance(),i=this.parseCommandSequence()),this.match("end")&&this.advance(),{type:"if",condition:t?{type:"unary",operator:"not",operand:e}:e,body:s,elseBody:i}}parseRepeat(){let t;this.expect("repeat"),this.match("until","while","forever")||(t=this.parseExpression(),this.match("times")&&this.advance());const e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"repeat",condition:t,body:e}}parseFor(){this.expect("for"),this.match("each")&&this.advance();const t=this.advance().value;this.expect("in");const e=this.parseExpression(),s=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"for",condition:{type:"forCondition",variable:t,iterable:e},body:s}}parseWhile(){this.expect("while");const t=this.parseExpression(),e=this.parseCommandSequence();return this.match("end")&&this.advance(),{type:"while",condition:t,body:e}}parseFetchBlock(){this.expect("fetch");const t=this.parseExpression();let e={type:"literal",value:"text"};return this.match("as")&&(this.advance(),e=this.parseExpression()),this.match("then")&&this.advance(),{type:"fetch",condition:{type:"fetchConfig",url:t,responseType:e},body:this.parseCommandSequence()}}parseToggle(){this.expect("toggle");const t=this.parseExpression();let e;return this.match("on")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"toggle",args:[t],target:e}}parseAdd(){this.expect("add");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"add",args:[t],target:e}}parseRemove(){if(this.expect("remove"),this.matchType("selector")){const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"removeClass",args:[t],target:e}}return{type:"command",name:"remove",args:[],target:this.parseExpression()}}parsePut(){this.expect("put");const t=this.parseExpression();let e="into";if(this.match("into","before","after","at")&&(e=this.advance().value,"at"===e)){const t=this.advance().value;this.expect("of"),e=`at ${t} of`}return{type:"command",name:"put",args:[t],target:this.parseExpression(),modifier:e}}parseAppend(){this.expect("append");const t=this.parseExpression();let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"append",args:[t],target:e}}parseSet(){this.expect("set");const t=this.parseExpression();return this.match("to")?(this.advance(),{type:"command",name:"set",args:[t,this.parseExpression()]}):{type:"command",name:"set",args:[t]}}parseGet(){return this.expect("get"),{type:"command",name:"get",args:[this.parseExpression()]}}parseCall(){return this.expect("call"),{type:"command",name:"call",args:[this.parseExpression()]}}parseLog(){this.expect("log");const t=[];for(;!this.isAtEnd()&&!this.match("then","and","end","else")&&(t.push(this.parseExpression()),this.match(","));)this.advance();return{type:"command",name:"log",args:t}}parseSend(){this.advance();const t=this.advance().value;let e;return this.match("to")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"send",args:[{type:"literal",value:t}],target:e}}parseWait(){if(this.expect("wait"),this.match("for")){this.advance();const t=this.advance().value;let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"waitFor",args:[{type:"literal",value:t}],target:e}}return{type:"command",name:"wait",args:[this.parseExpression()]}}parseShow(){let t;this.expect("show");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"show",args:[],target:t,modifiers:e}}parseHide(){let t;this.expect("hide");const e={};return this.isAtEnd()||this.match("then","and","end","else","when","where")||(t=this.parseExpression()),!this.isAtEnd()&&this.match("when","where")&&(e[this.advance().value]=this.parseExpression()),{type:"command",name:"hide",args:[],target:t,modifiers:e}}parseTake(){this.expect("take");const t=this.parseExpression();let e;return this.match("from")&&(this.advance(),e=this.parseExpression()),{type:"command",name:"take",args:[t],target:e}}parseIncDec(t){this.advance();const e=this.parseExpression();let s={type:"literal",value:1};return this.match("by")&&(this.advance(),s=this.parseExpression()),{type:"command",name:t,args:[e,s]}}parseFocusBlur(t){let e;return this.advance(),this.isAtEnd()||this.match("then","and","end","else")||(e=this.parseExpression()),{type:"command",name:t,args:[],target:e}}parseGo(){return this.expect("go"),this.match("to")&&this.advance(),this.match("url")&&this.advance(),{type:"command",name:"go",args:[this.parseExpression()]}}parseReturn(){let t;return this.expect("return"),this.isAtEnd()||this.match("then","and","end","else")||(t=this.parseExpression()),{type:"command",name:"return",args:t?[t]:[]}}parseTransition(){let t;if(this.expect("transition"),this.match("my","its"))t={type:"identifier",value:"my"===this.advance().value?"me":"it"};else if(this.matchType("selector")){const e=this.parseExpression();if("possessive"===e.type)return this.parseTransitionRest(e.object,e.property);t=e}const e=this.peek();let s;return s="styleProperty"===e.type||"identifier"===e.type||"keyword"===e.type?this.advance().value:"opacity",this.parseTransitionRest(t,s)}parseTransitionRest(t,e){let s={type:"literal",value:1};this.match("to")&&(this.advance(),s=this.parseExpression());let i={type:"literal",value:300};return this.match("over")&&(this.advance(),i=this.parseExpression()),{type:"command",name:"transition",args:[{type:"literal",value:e},s,i],target:t}}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.match("or","||");)this.advance(),t={type:"binary",operator:"or",left:t,right:this.parseAnd()};return t}parseAnd(){let t=this.parseEquality();for(;this.match("and","&&")&&!this.isCommandKeyword(this.peek(1));)this.advance(),t={type:"binary",operator:"and",left:t,right:this.parseEquality()};return t}isCommandKeyword(t){return["toggle","add","remove","set","put","log","send","wait","show","hide","increment","decrement","focus","blur","go"].includes(n(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.advance(),{type:"identifier",value:t.value})}parseObjectLiteral(){this.expect("{");const t=[];for(;!this.match("}");){const e=this.advance().value;this.expect(":");const s=this.parseExpression();t.push({key:e,value:s}),this.match(",")&&this.advance()}return this.expect("}"),{type:"object",properties:t}}parseArrayLiteral(){this.expect("[");const t=[];for(;!this.match("]");)t.push(this.parseExpression()),this.match(",")&&this.advance();return this.expect("]"),{type:"array",elements:t}}parsePositionalTarget(){const t=this.peek();return"selector"===t.type?{type:"selector",value:this.advance().value}:"identifier"===t.type||"keyword"===t.type?{type:"identifier",value:this.advance().value}:this.parseExpression()}}const c=new Map,h=1e3;async function l(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 e.locals.get(t.name.slice(1));const s=t.name.slice(1);return c.has(s)?c.get(s):window[t.name];case"selector":const i=document.querySelectorAll(t.value);return 1===i.length?i[0]:Array.from(i);case"binary":return async function(t,e){if("has"===t.operator){const s=await l(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 l(t.left,e),i=await l(t.right,e);switch(t.operator){case"+":return s+i;case"-":return s-i;case"*":return s*i;case"/":return s/i;case"%":return s%i;case"==":case"is":return s==i;case"!=":case"is not":return s!=i;case"<":return i>s;case">":return s>i;case"<=":return i>=s;case">=":return s>=i;case"and":case"&&":return s&&i;case"or":case"||":return s||i;case"has":if(s instanceof Element){const t="string"==typeof i?i:i?.value;if("string"==typeof t&&t.startsWith("."))return s.classList.contains(t.slice(1))}return 0;case"contains":case"includes":return"string"==typeof s||Array.isArray(s)?s.includes(i):s instanceof Element?s.contains(i):0;case"matches":return s instanceof Element?s.matches(i):"string"==typeof s?RegExp(i).test(s):0;default:return}}(t,e);case"unary":const r=await l(t.operand,e);return"not"===t.operator?!r:r;case"possessive":case"member":const n=await l(t.object,e);if(null==n)return;return n[t.computed?await l(t.property,e):t.property];case"call":{let s,i=null;if("member"===t.callee.type||"possessive"===t.callee.type){i=await l(t.callee.object,e);const r=t.callee.computed?await l(t.callee.property,e):t.callee.property;s=i?.[r]}else s=await l(t.callee,e);const r=await Promise.all(t.args.map(t=>l(t,e)));return"function"==typeof s?s.apply(i,r):void 0}case"positional":return function(t,e){const s=t.target;let i=[],r=null;switch(("selector"===s.type||"identifier"===s.type||"htmlSelector"===s.type)&&(r=s.value),r&&(i=Array.from(document.querySelectorAll(r))),t.position){case"first":default:return i[0]||null;case"last":return i[i.length-1]||null;case"next":return e.me.nextElementSibling;case"previous":return e.me.previousElementSibling;case"closest":return s.value?e.me.closest(s.value):null;case"parent":return e.me.parentElement}}(t,e);case"object":const o={};for(const s of t.properties)o[s.key]=await l(s.value,e);return o;case"array":return Promise.all(t.elements.map(t=>l(t,e)));default:return}}async function u(t,e){const s=async()=>{if(!t.target)return[e.me];const s=await l(t.target,e);return Array.isArray(s)?s:s instanceof Element?[s]:"string"==typeof s?Array.from(document.querySelectorAll(s)):[e.me]},i=t=>{if(!t)return"";if("selector"===t.type)return t.value.slice(1);if("string"===t.type||"literal"===t.type){const e=t.value;return"string"==typeof e&&e.startsWith(".")?e.slice(1):e+""}return"identifier"===t.type?t.value:""},r=t=>Array.isArray(t)?t.filter(t=>t instanceof Element):t instanceof Element?[t]:"string"==typeof t?Array.from(document.querySelectorAll(t)):[],n=t=>t.startsWith("*"),o=t=>t.substring(1),a=(t,e,s)=>n(e)?(t.style.setProperty(o(e),s+""),1):0,h=(t,e)=>{if(n(e))return getComputedStyle(t).getPropertyValue(o(e))};switch(t.name){case"toggle":{const r=i(t.args[0])||await l(t.args[0],e)+"",n=await s();for(const t of n)t.classList.toggle(r);return e.it=1===n.length?n[0]:n,e.it}case"add":{const r=i(t.args[0])||await l(t.args[0],e)+"",n=await s();for(const t of n)t.classList.add(r);return e.it=1===n.length?n[0]:n,e.it}case"removeClass":{const r=i(t.args[0])||await l(t.args[0],e)+"",n=await s();for(const t of n)t.classList.remove(r);return e.it=1===n.length?n[0]:n,e.it}case"remove":{const t=await s();for(const e of t)e.remove();return null}case"put":{const i=await l(t.args[0],e),o=t.modifier||"into";if("possessive"===t.target?.type&&n(t.target.property)){const s=r(await l(t.target.object,e));for(const e of s)a(e,t.target.property,i);return e.it=i,i}const c=await s();for(const t of c){const e=i+"";"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=i,i}case"append":{const i=await l(t.args[0],e),r=await s();for(const t of r)t.insertAdjacentHTML("beforeend",i+"");return e.it=i,i}case"set":{const s=t.args[0],i=await l(t.args[1],e);if("variable"===s.type){const t=s.name.slice(1);return("local"===s.scope?e.locals:c).set(t,i),e.it=i,i}if("possessive"===s.type||"member"===s.type){const t=await l(s.object,e);if(t)return t instanceof Element&&a(t,s.property,i)?(e.it=i,i):(t[s.property]=i,e.it=i,i)}return e.it=i,i}case"get":{const s=await l(t.args[0],e);return e.it=s,s}case"call":{const s=await l(t.args[0],e);return e.it=s,s}case"log":{const s=await Promise.all(t.args.map(t=>l(t,e)));return console.log(...s),s[0]}case"send":{const i=await l(t.args[0],e),r=await s(),n=new CustomEvent(i+"",{bubbles:1,detail:e.it});for(const t of r)t.dispatchEvent(n);return e.it=n,n}case"wait":{const s=await l(t.args[0],e),i="number"==typeof s?s:parseInt(s+"");return await new Promise(t=>setTimeout(t,i)),i}case"waitFor":{const i=await l(t.args[0],e),r=(await s())[0]||e.me;return new Promise(t=>{r.addEventListener(i+"",s=>{e.it=s,t(s)},{once:1})})}case"show":{const t=await s();for(const e of t)e.style.display="",e.classList.remove("hidden");return t}case"hide":{const t=await s();for(const e of t)e.style.display="none";return t}case"transition":{const i=(await l(t.args[0],e)+"").replace(/^\*/,""),r=await l(t.args[1],e),n=await l(t.args[2],e),o="number"==typeof n?n:(n+"").endsWith("ms")?parseInt(n+""):(n+"").endsWith("s")?1e3*parseFloat(n+""):parseInt(n+"")||300,a=await s(),c=[];for(const t of a){const e=t,s=i.replace(/([A-Z])/g,"-$1").toLowerCase(),n=e.style.transition;e.style.transition=`${s} ${o}ms ease`,e.style.setProperty(s,r+""),c.push(new Promise(t=>{const i=()=>{e.style.transition=n,t()},r=t=>{t.propertyName===s&&(e.removeEventListener("transitionend",r),i())};e.addEventListener("transitionend",r),setTimeout(i,o+50)}))}return await Promise.all(c),e.it=1===a.length?a[0]:a,e.it}case"take":{const r=i(await l(t.args[0],e)),n=t.target?await s():[e.me.parentElement];for(const t of n)t.querySelectorAll("."+r).forEach(t=>t.classList.remove(r));return e.me.classList.add(r),e.me}case"increment":case"decrement":{const s=t.args[0],i=await l(t.args[1],e),o="increment"===t.name?i:-i;if("variable"===s.type){const t=s.name.slice(1),i="local"===s.scope?e.locals:c,r=(i.get(t)||0)+o;return i.set(t,r),e.it=r,r}if("possessive"===s.type&&n(s.property)){const t=r(await l(s.object,e));for(const i of t){const t=(parseFloat(h(i,s.property)||"0")||0)+o;a(i,s.property,t),e.it=t}return e.it}const u=r(await l(s,e));for(const t of u){const s=(parseFloat(t.textContent||"0")||0)+o;t.textContent=s+"",e.it=s}return e.it}case"focus":{const t=await s();for(const e of t)e.focus();return t}case"blur":{const t=await s();for(const e of t)e.blur();return t}case"go":{const s=await l(t.args[0],e),i=(s+"").toLowerCase();return"back"===i?history.back():"forward"===i?history.forward():window.location.href=s+"",null}case"return":throw{type:"return",value:t.args[0]?await l(t.args[0],e):e.it};default:return console.warn("Unknown command: "+t.name),null}}async function f(t,e){try{return await d(t,e)}catch(t){if("return"===t?.type)throw t;throw t}}async function p(t,e){switch(t.type){case"if":return await l(t.condition,e)?f(t.body,e):t.elseBody?f(t.elseBody,e):null;case"repeat":{const s=await l(t.condition,e),i="number"==typeof s?s:parseInt(s+"");for(let s=0;i>s&&h>s;s++)e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await f(t.body,e);return null}case"for":{const{variable:s,iterable:i}=t.condition,r=await l(i,e),n=Array.isArray(r)?r:r instanceof NodeList?Array.from(r):[r],o=s.startsWith(":")?s.slice(1):s;for(let s=0;n.length>s&&h>s;s++)e.locals.set(o,n[s]),e.locals.set("__loop_index__",s),e.locals.set("__loop_count__",s+1),await f(t.body,e);return null}case"while":{let s=0;for(;await l(t.condition,e)&&h>s;)e.locals.set("__loop_index__",s),await f(t.body,e),s++;return null}case"fetch":{const{url:s,responseType:i}=t.condition;try{const r=await l(s,e),n=await fetch(r+"");if(!n.ok)throw Error("HTTP "+n.status);const o=await l(i,e);let a;if("json"===o)a=await n.json();else if("html"===o){const t=await n.text();a=(new DOMParser).parseFromString(t,"text/html").body.innerHTML}else a=await n.text();e.it=a,e.locals.set("it",a),e.locals.set("result",a),e.locals.set("response",n),await f(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 d(t,e){let s;for(const i of t)"command"===i.type?s=await u(i,e):["if","repeat","for","while","fetch"].includes(i.type)&&(s=await p(i,e));return s}async function m(t,e,s){const i={me:e,event:s,locals:new Map,globals:c};if("sequence"===t.type)return d(t.commands,i);if("event"===t.type){const s=t,r=s.event;if(r.startsWith("interval:")){const t=r.split(":")[1],i=t.endsWith("ms")?parseInt(t):t.endsWith("s")?1e3*parseFloat(t):parseInt(t);return void setInterval(async()=>{const t={me:e,locals:new Map,globals:c};try{await d(s.body,t)}catch(t){if("return"!==t?.type)throw t}},i)}if("init"===r){try{await d(s.body,i)}catch(t){if("return"!==t?.type)throw t}return}const n=s.filter?await l(s.filter,i):e,o=n instanceof Element?n:e,a=s.modifiers;let h=async t=>{a.prevent&&t.preventDefault(),a.stop&&t.stopPropagation();const i={me:e,event:t,you:t.target instanceof Element?t.target:void 0,locals:new Map,globals:c};try{await d(s.body,i)}catch(t){if("return"===t?.type)return t.value;throw t}};if(a.debounce){let t;const e=h;h=async s=>{clearTimeout(t),t=setTimeout(()=>e(s),a.debounce)}}if(a.throttle){let t=0;const e=h;h=async s=>{const i=Date.now();a.throttle>i-t||(t=i,await e(s))}}return void o.addEventListener(r,h,{once:!!a.once})}return null}function y(t){const e=t.getAttribute("_");if(e)try{const s=new a(e).parse();console.log("HyperFixi AST:",JSON.stringify(s,null,2).slice(0,500)),m(s,t)}catch(t){console.error("HyperFixi Hybrid Complete error:",t,"Code:",e)}}function w(t=document){t.querySelectorAll("[_]").forEach(y)}const g={version:"1.0.0-hybrid-complete",parse:t=>new a(t).parse(),async execute(t,e){const s=e||document.body;return m(new a(t).parse(),s)},init:w,process:w,addAliases:function(t){Object.assign(i,t)},addEventAliases:function(t){Object.assign(r,t)},tokenize:s,evaluate:l,commands:["toggle","add","remove","put","append","set","get","call","log","send","trigger","wait","show","hide","transition","take","increment","decrement","focus","blur","go","return"],blocks:["if","else","unless","repeat","for","while","fetch"]};"undefined"!=typeof window&&(window.hyperfixi=g,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>w()):w());const b={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"},v={click:"click",load:"load",revealed:"intersection",intersect:"intersection",submit:"submit",change:"change",input:"input",keyup:"keyup",keydown:"keydown",focus:"focus",blur:"blur",mouseenter:"mouseenter",mouseleave:"mouseleave"};function x(t,e){const s=[];if(t.onHandlers)for(const[e,i]of Object.entries(t.onHandlers))s.push(`on ${e} ${i}`);if(!t.url)return s.join("\n");const i=[],r=t.trigger||function(t){const e=t.tagName.toLowerCase();if("form"===e)return"submit";if("input"===e||"textarea"===e||"select"===e){const e=t.getAttribute("type");return"submit"===e||"button"===e?"click":"change"}return"click"}(e),{event:n,modifiers:o}=function(t){const e=t.trim().split(/\s+/),s=e[0],i=e.slice(1),r=s.match(/^(\w+)\[(.+)\]$/);return r?{event:v[r[1]]||r[1],modifiers:["filter: "+r[2],...i]}:{event:v[s]||s,modifiers:i}}(r),a=function(t){const e=[];for(const s of t){const t=s.match(/^delay:(\d+)(ms|s)?$/);if(t){e.push(`.debounce(${t[1]}${"s"===(t[2]||"ms")?"000":""})`);continue}const i=s.match(/^throttle:(\d+)(ms|s)?$/);i?e.push(`.throttle(${i[1]}${"s"===(i[2]||"ms")?"000":""})`):"once"!==s||e.push(".once")}return e.join("")}(o);t.confirm&&i.push(`if not js window.confirm('${t.confirm.replace(/'/g,"\\'")}') return end`);const c=e.tagName.toLowerCase();"form"!==c&&"a"!==c||i.push("halt the event");let h=`fetch '${t.url}'`;t.method&&"GET"!==t.method&&(h+=" via "+t.method),"form"===c?h+=" with values of me":t.vals&&(h+=" with "+t.vals),h+=" as html",i.push(h);const l=function(t,e){const s=b[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?`swap ${t} with it`:`swap innerHTML of ${t} with it`}(t.target?function(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 i=t.match(/^next\s+(.+)$/);if(i)return`next <${i[1]}/>`;const r=t.match(/^previous\s+(.+)$/);return r?`previous <${r[1]}/>`:t}(t.target):"me",t.swap||"innerHTML");l&&i.push("then "+l),t.pushUrl?i.push(`then push url '${1==t.pushUrl?t.url:t.pushUrl}'`):t.replaceUrl&&i.push(`then replace url '${1==t.replaceUrl?t.url:t.replaceUrl}'`);const u=`on ${n}${a}\n ${i.join("\n ")}`;return s.push(u),s.join("\n")}function E(t){const e=t.attributes;for(let t=0;e.length>t;t++)if(e[t].name.startsWith("hx-"))return 1;return 0}function $(t){return t.hasAttribute("fx-action")}function T(t){return E(t)||$(t)}const k=["hx-get","hx-post","hx-put","hx-patch","hx-delete"],A=[...k,"hx-target","hx-swap","hx-trigger","hx-confirm","hx-boost","hx-vals","hx-headers","hx-push-url","hx-replace-url"],H=["fx-action","fx-method","fx-trigger","fx-target","fx-swap","fx-ignore"],M=[...A,...H],P=k.map(t=>`[${t}]`).join(", ")+", [hx-on\\:], [fx-action]";class _{dispatchLifecycleEvent(t,e,s,i={}){const r=new CustomEvent(e,{detail:s,bubbles:i.bubbles??1,cancelable:i.cancelable??1}),n=t.dispatchEvent(r);return!n&&this.options.debug&&console.log(`[${i.debugPrefix??"htmx"}-compat] ${e} cancelled`),n}constructor(t={}){this.observer=null,this.processedElements=new WeakSet,this.executeCallback=null,this.pendingRequests=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}}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.observer&&(this.observer.disconnect(),this.observer=null),this.executeCallback=null}scanForHtmxElements(t){const e=t??this.options.root;if(!e)return[];if(e.closest?.("[fx-ignore]"))return[];const s=Array.from(e.querySelectorAll(P));return e.matches?.(P)&&s.unshift(e),s.filter(t=>!t.closest("[fx-ignore]"))}collectAttributes(t){const e={};for(const s of["get","post","put","patch","delete"]){const i=t.getAttribute("hx-"+s);if(i){e.method=s.toUpperCase(),e.url=i;break}}const s=t.getAttribute("hx-target");s&&(e.target=s);const i=t.getAttribute("hx-swap");i&&(e.swap=i);const r=t.getAttribute("hx-trigger");r&&(e.trigger=r);const n=t.getAttribute("hx-confirm");n&&(e.confirm=n),"true"===t.getAttribute("hx-boost")&&(e.boost=1);const o=t.getAttribute("hx-vals");o&&(e.vals=o);const a=t.getAttribute("hx-headers");a&&(e.headers=a);const c=t.getAttribute("hx-push-url");c&&(e.pushUrl="true"===c?1:c);const h=t.getAttribute("hx-replace-url");h&&(e.replaceUrl="true"===h?1:h);const l={};for(const e of t.attributes)e.name.startsWith("hx-on:")&&(l[e.name.slice(6)]=e.value);return Object.keys(l).length>0&&(e.onHandlers=l),e}collectFxAttributes(t){const e={},s=t.getAttribute("fx-action");s&&(e.url=s);const i=t.getAttribute("fx-method");e.method=i?.toUpperCase()||"GET";const r=t.getAttribute("fx-target");r&&(e.target=r);const n=t.getAttribute("fx-swap");e.swap=n||"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;const e=this.isFxElement(t),s=e?this.collectFxAttributes(t):this.collectAttributes(t),i=e?"fx":"htmx";if(!s.url&&!s.onHandlers&&!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:i}))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 r=x(s,t);if(this.options.debug&&console.log(`[${i}-compat] Translated:`,{element:t.tagName,config:s,hyperscript:r}),this.processedElements.add(t),this.executeCallback&&r){if(e&&this.options.requestDropping&&this.pendingRequests.has(t))return void(this.options.debug&&console.log("[fx-compat] Request dropped - pending request exists"));const n=new AbortController;if(e&&this.options.requestDropping&&this.pendingRequests.set(t,n),t.setAttribute(e?"data-fx-generated":"data-hx-generated",r),!this.dispatchLifecycleEvent(t,"htmx:beforeRequest",{element:t,url:s.url,method:s.method||"GET"},{debugPrefix:i}))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(r,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:n.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(`[${i}-compat] Execution error:`,s);const r=s instanceof Error?s:Error(s+"");this.dispatchLifecycleEvent(t,"htmx:error",{element:t,error:r},{cancelable:0}),e&&this.options.fixiEvents&&this.dispatchLifecycleEvent(t,"fx:error",{element:t,error:r},{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(){this.observer=new MutationObserver(t=>{for(const e of t){for(const t of e.addedNodes)t instanceof Element&&this.processSubtree(t);if("attributes"===e.type&&e.target instanceof Element){const t=e.attributeName;t&&(M.includes(t)||t.startsWith("hx-on:"))&&(this.processedElements.delete(e.target),this.processElement(e.target))}}}),this.options.root&&this.observer.observe(this.options.root,{childList:1,subtree:1,attributes:1,attributeFilter:M})}manualProcess(t){return x(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}}let L=null;function C(t={}){const{processHyperscript:e=1,...s}=t;L=new _({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}),L.init(async(t,e)=>{await g.execute(t,e)}),t.debug&&console.log("[lokascript-hx] htmx/fixi compatibility enabled")}function F(){L&&(L.destroy(),L=null)}function j(t){return new _({processExisting:0,watchMutations:0}).manualProcess(t)}const O={...g,version:"1.0.0-hybrid-hx",enableHtmxCompatibility:C,disableHtmxCompatibility:F,getHtmxProcessor:function(){return L},translateHtmx:j,hasHtmxAttributes:E,hasFxAttributes:$,hasAnyAttributes:T,HtmxAttributeProcessor:_,translateToHyperscript:x,features:{htmx:1,fixi:1,hyperscript:1},htmxAttributes:A,fixiAttributes:H,fixiEvents:["fx:init","fx:inited","fx:config","fx:before","fx:after","fx:error","fx:finally","fx:swapped"]};if("undefined"!=typeof window){window.hyperfixi=O,window.lokascript=O;const t=()=>{C({processExisting:1,watchMutations:1,processHyperscript:1,requestDropping:1,fixiEvents:1})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}t.FIXI_ATTRS=H,t.HTMX_ATTRS=A,t.HtmxAttributeProcessor=_,t.default=O,t.disableHtmxCompatibility=F,t.enableHtmxCompatibility=C,t.hasAnyAttributes=T,t.hasFxAttributes=$,t.translateHtmx=j,Object.defineProperty(t,"t",{value:1})}({});
@@ -0,0 +1 @@
1
+ !function(){"use strict";const e={flip:"toggle",switch:"toggle",display:"show",reveal:"show",conceal:"hide",increase:"increment",decrease:"decrement",fire:"trigger",dispatch:"send",navigate:"go",goto:"go"},n={clicked:"click",pressed:"keydown",changed:"change",submitted:"submit",loaded:"load"};function t(n){const t=n.toLowerCase();return e[t]||t}function r(e){const t=e.toLowerCase();return n[t]||t}function s(e){const n=e.trim(),t=n.match(/^on\s+(\w+)(?:\s+from\s+([^\s]+))?\s+(.+)$/i);if(t)return{event:r(t[1]),filter:t[2],commands:o(t[3])};const s=n.match(/^every\s+(\d+)(ms|s)?\s+(.+)$/i);if(s)return{event:"interval:"+("s"===s[2]?1e3*parseInt(s[1]):parseInt(s[1])),commands:o(s[3])};const i=n.match(/^init\s+(.+)$/i);return i?{event:"init",commands:o(i[1])}:o(n)}function o(e){return e.split(/\s+(?:then|and)\s+/i).map(i).filter(Boolean)}function i(e){const n=e.trim();if(!n)return null;let r;if(r=n.match(/^(\w+)\s+(\.\w+|\w+)(?:\s+on\s+(.+))?$/i),r&&"toggle"===t(r[1]))return{name:"toggle",args:[r[2]],target:r[3]};if(r=n.match(/^(\w+)\s+(\.\w+|\w+)(?:\s+to\s+(.+))?$/i),r&&"add"===t(r[1]))return{name:"add",args:[r[2]],target:r[3]};if(r=n.match(/^(\w+)\s+(\.\w+)(?:\s+from\s+(.+))?$/i),r&&"remove"===t(r[1]))return{name:"remove",args:[r[2]],target:r[3]};if(r=n.match(/^(\w+)\s+(.+)$/i),r&&"remove"===t(r[1]))return{name:"remove",args:[],target:r[2]};if(r=n.match(/^(\w+)\s+(\.\w+)\s+from\s+(.+)$/i),r&&"take"===t(r[1]))return{name:"take",args:[r[2]],target:r[3]};if(r=n.match(/^(\w+)\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s+(into|before|after)\s+(.+)$/i),r&&"put"===t(r[1]))return{name:"put",args:[r[2]||r[3]||r[4]],modifier:r[5],target:r[6]};if(r=n.match(/^(\w+)\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s+to\s+(.+)$/i),r&&"append"===t(r[1]))return{name:"append",args:[r[2]||r[3]||r[4]],target:r[5]};if(r=n.match(/^(\w+)\s+(.+?)\s+to\s+(.+)$/i),r&&"set"===t(r[1]))return{name:"set",args:[r[2],r[3]]};if(r=n.match(/^(\w+)\s+(.+?)(?:\s+by\s+(\d+))?$/i),r&&("increment"===t(r[1])||"decrement"===t(r[1])))return{name:t(r[1]),args:[r[2],r[3]||"1"]};if(r=n.match(/^(\w+)\s+(.+)$/i),r&&"log"===t(r[1]))return{name:"log",args:[r[2]]};if(r=n.match(/^(\w+)\s+(\w+)(?:\s+to\s+(.+))?$/i),r&&("send"===t(r[1])||"trigger"===t(r[1])))return{name:"send",args:[r[2]],target:r[3]};if(r=n.match(/^(\w+)\s+(\d+)(ms|s)?$/i),r&&"wait"===t(r[1]))return{name:"wait",args:[""+("s"===r[3]?1e3*parseInt(r[2]):parseInt(r[2]))]};if(r=n.match(/^(\w+)(?:\s+(.+))?$/i),r&&("focus"===t(r[1])||"blur"===t(r[1])))return{name:t(r[1]),args:[],target:r[2]};if(r=n.match(/^(\w+)\s+(?:to\s+(?:url\s+)?)?(.+)$/i),r&&"go"===t(r[1]))return{name:"go",args:[r[2]]};if(r=n.match(/^(\w+)(?:\s+(.+))?$/i),r&&("show"===t(r[1])||"hide"===t(r[1]))){const e=r[2];return"show"===t(r[1])?{name:"remove",args:[".hidden"],target:e}:{name:"add",args:[".hidden"],target:e}}if(r=n.match(/^(if|unless)\s+(.+?)\s+(toggle|add|remove|put|set|log|send|wait|show|hide|increment|decrement|focus|blur|go|take|append)\s+(.+)$/i),r){const e=i(`${r[3]} ${r[4]}`);if(e)return e.modifier=r[1].toLowerCase(),e.args.unshift(r[2]),e}const s=n.split(/\s+/);return s.length>0?{name:t(s[0]),args:s.slice(1)}:null}function a(e,n){if(!e)return n;const t=e.trim();if("me"===t)return n;if("body"===t)return document.body;if(t.startsWith("#")||t.startsWith(".")||t.startsWith("[")){const e=document.querySelectorAll(t);return 1===e.length?e[0]:Array.from(e)}return/^\w+$/.test(t)&&document.getElementById(t)?document.getElementById(t):n}function c(e){return e.startsWith(".")?e.slice(1):e}function u(e,n,t){if(!e)return;const r=e.trim();if(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))return r.slice(1,-1);if(/^-?\d+(\.\d+)?$/.test(r))return parseFloat(r);if("true"===r)return 1;if("false"===r)return 0;if("null"===r)return null;if(r.startsWith(":"))return t.get(r.slice(1));if("me"===r)return n;if("my"===r)return n;if("body"===r)return document.body;const s=r.match(/^(me|my)\.(\w+)$/);if(s)return n[s[2]];const o=r.match(/^([#.\w]+)(?:'s|\.)\s*(\w+)$/);if(o){const e=a(o[1],n);if(e&&!Array.isArray(e))return e[o[2]]}return r}function f(e,n,t){const r=e.trim(),s=r.match(/^(me|my)\s+has\s+\.(\w+)$/i);if(s)return n.classList.contains(s[2]);const o=r.match(/^(me|my)\.(\w+)$/i);return o?!!n[o[2]]:r.startsWith(":")?!!t.get(r.slice(1)):!!u(r,n,t)}async function d(e,n,t){const r=a(e.target,n),s=Array.isArray(r)?r:r?[r]:[n];switch(e.name){case"toggle":{const n=c(e.args[0]);for(const e of s)e.classList.toggle(n);return 1===s.length?s[0]:s}case"add":{const n=c(e.args[0]);for(const e of s)e.classList.add(n);return 1===s.length?s[0]:s}case"remove":if(e.args[0]){const n=c(e.args[0]);for(const e of s)e.classList.remove(n)}else for(const e of s)e.remove();return null;case"take":{const t=c(e.args[0]),r=a(e.target,n),s=Array.isArray(r)?r:r?[r]:[];for(const e of s)e.classList.remove(t);return n.classList.add(t),n}case"put":{const r=u(e.args[0],n,t);for(const n of s)switch(e.modifier?.toLowerCase()){case"into":default:n.innerHTML=r+"";break;case"before":n.insertAdjacentHTML("beforebegin",r+"");break;case"after":n.insertAdjacentHTML("afterend",r+"")}return 1===s.length?s[0]:s}case"append":{const r=u(e.args[0],n,t);for(const e of s)e.insertAdjacentHTML("beforeend",r+"");return 1===s.length?s[0]:s}case"set":{const[r,s]=e.args,o=u(s,n,t);if(r.startsWith(":"))return t.set(r.slice(1),o),o;const i=r.match(/^(.+?)(?:'s|\.)\s*(\w+)$/);if(i){const e=a(i[1],n);if(e)return e[i[2]]=o,e}return o}case"increment":{const[r,s]=e.args,o=parseInt(s)||1;if(r.startsWith(":")){const e=t.get(r.slice(1))||0;return t.set(r.slice(1),e+o),e+o}const i=r.match(/^(.+?)(?:'s|\.)\s*(\w+)$/);if(i){const e=a(i[1],n);if(e)return e[i[2]]=(parseInt(e[i[2]])||0)+o,e[i[2]]}const c=a(r,n);if(c&&!Array.isArray(c)){const e=parseInt(c.textContent||"0")||0;return c.textContent=e+o+"",e+o}return null}case"decrement":{const[r,s]=e.args,o=parseInt(s)||1;if(r.startsWith(":")){const e=t.get(r.slice(1))||0;return t.set(r.slice(1),e-o),e-o}const i=r.match(/^(.+?)(?:'s|\.)\s*(\w+)$/);if(i){const e=a(i[1],n);if(e)return e[i[2]]=(parseInt(e[i[2]])||0)-o,e[i[2]]}const c=a(r,n);if(c&&!Array.isArray(c)){const e=parseInt(c.textContent||"0")||0;return c.textContent=e-o+"",e-o}return null}case"focus":for(const e of s)e.focus();return 1===s.length?s[0]:s;case"blur":for(const e of s)e.blur();return 1===s.length?s[0]:s;case"go":{const n=e.args[0]?.trim();if("back"===n)history.back();else if("forward"===n)history.forward();else if(n){const e=n.replace(/^["']|["']$/g,"");window.location.href=e}return null}case"log":{const r=u(e.args.join(" "),n,t);return console.log(r),r}case"send":{const n=new CustomEvent(e.args[0],{bubbles:1});for(const e of s)e.dispatchEvent(n);return n}case"wait":{const n=parseInt(e.args[0])||0;return await new Promise(e=>setTimeout(e,n)),n}default:return console.warn("Unknown command: "+e.name),null}}async function m(e,n,t=new Map){if(Array.isArray(e)){let r;for(const s of e){if("if"===s.modifier||"unless"===s.modifier){const e=f(s.args[0],n,t);if(!("if"===s.modifier?e:!e))continue;s.args.shift()}r=await d(s,n,t)}return r}const r=e,s=r.filter?document.querySelector(r.filter):n,o=r.event;if(o.startsWith("interval:")){const e=parseInt(o.split(":")[1]);return setInterval(async()=>{const e=new Map(t);for(const t of r.commands)await d(t,n,e)},e),n}if("init"===o){const e=new Map(t);for(const t of r.commands)await d(t,n,e);return n}return s&&s.addEventListener(o,async e=>{const s=new Map(t);s.set("event",e);for(const e of r.commands)await d(e,n,s)}),n}function l(e=document){const n=e.querySelectorAll("[_]");for(const e of n){const n=e.getAttribute("_");if(n)try{m(s(n),e)}catch(e){console.error("HyperFixi Lite+ error:",e,"Code:",n)}}}"undefined"!=typeof window&&(window.hyperfixi={version:"1.0.0-lite-plus",parse:s,execute:async(e,n)=>{const t=n||document.body;return m(s(e),t)},init:l,process:l,addAliases:n=>{Object.assign(e,n)},addEventAliases:e=>{Object.assign(n,e)},commands:["add","remove","toggle","take","put","append","set","increment","decrement","show","hide","focus","blur","log","send","trigger","wait","go"]},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>l()):l())}();
@@ -0,0 +1 @@
1
+ !function(){"use strict";function e(e){const t=e.trim(),r=t.match(/^on\s+(\w+)(?:\s+from\s+([^\s]+))?\s+(.+)$/i);if(r)return{event:r[1],filter:r[2],commands:n(r[3])};const s=t.match(/^every\s+(\d+)(ms|s)?\s+(.+)$/i);if(s)return{event:"interval:"+("s"===s[2]?1e3*parseInt(s[1]):parseInt(s[1])),commands:n(s[3])};const o=t.match(/^init\s+(.+)$/i);return o?{event:"init",commands:n(o[1])}:n(t)}function n(e){return e.split(/\s+(?:then|and)\s+/i).map(t).filter(Boolean)}function t(e){const n=e.trim();if(!n)return null;let r=n.match(/^toggle\s+(\.\w+|\w+)(?:\s+on\s+(.+))?$/i);if(r)return{name:"toggle",args:[r[1]],target:r[2]};if(r=n.match(/^add\s+(\.\w+|\w+)(?:\s+to\s+(.+))?$/i),r)return{name:"add",args:[r[1]],target:r[2]};if(r=n.match(/^remove\s+(\.\w+)(?:\s+from\s+(.+))?$/i),r)return{name:"remove",args:[r[1]],target:r[2]};if(r=n.match(/^remove\s+(.+)$/i),r)return{name:"remove",args:[],target:r[1]};if(r=n.match(/^put\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s+(into|before|after)\s+(.+)$/i),r)return{name:"put",args:[r[1]||r[2]||r[3]],modifier:r[4],target:r[5]};if(r=n.match(/^set\s+(.+?)\s+to\s+(.+)$/i),r)return{name:"set",args:[r[1],r[2]]};if(r=n.match(/^log\s+(.+)$/i),r)return{name:"log",args:[r[1]]};if(r=n.match(/^send\s+(\w+)(?:\s+to\s+(.+))?$/i),r)return{name:"send",args:[r[1]],target:r[2]};if(r=n.match(/^wait\s+(\d+)(ms|s)?$/i),r)return{name:"wait",args:[""+("s"===r[2]?1e3*parseInt(r[1]):parseInt(r[1]))]};if(r=n.match(/^(if|unless)\s+(.+?)\s+(toggle|add|remove|put|set|log|send|wait)\s+(.+)$/i),r){const e=t(`${r[3]} ${r[4]}`);if(e)return e.modifier=r[1].toLowerCase(),e.args.unshift(r[2]),e}if(r=n.match(/^(show|hide)(?:\s+(.+))?$/i),r){const e=r[2];return"show"===r[1].toLowerCase()?{name:"remove",args:[".hidden"],target:e}:{name:"add",args:[".hidden"],target:e}}const s=n.split(/\s+/);return s.length>0?{name:s[0],args:s.slice(1)}:null}function r(e,n){if(!e)return n;const t=e.trim();if("me"===t)return n;if("body"===t)return document.body;if(t.startsWith("#")||t.startsWith(".")||t.startsWith("[")){const e=document.querySelectorAll(t);return 1===e.length?e[0]:Array.from(e)}return/^\w+$/.test(t)&&document.getElementById(t)?document.getElementById(t):n}function s(e){return e.startsWith(".")?e.slice(1):e}async function o(e,n,t){const o=r(e.target,n),a=Array.isArray(o)?o:o?[o]:[n];switch(e.name){case"toggle":{const n=s(e.args[0]);for(const e of a)e.classList.toggle(n);return 1===a.length?a[0]:a}case"add":{const n=s(e.args[0]);for(const e of a)e.classList.add(n);return 1===a.length?a[0]:a}case"remove":if(e.args[0]){const n=s(e.args[0]);for(const e of a)e.classList.remove(n)}else for(const e of a)e.remove();return null;case"put":{const r=i(e.args[0],n,t);for(const n of a)switch(e.modifier?.toLowerCase()){case"into":default:n.innerHTML=r+"";break;case"before":n.insertAdjacentHTML("beforebegin",r+"");break;case"after":n.insertAdjacentHTML("afterend",r+"")}return 1===a.length?a[0]:a}case"set":{const[s,o]=e.args,a=i(o,n,t);if(s.startsWith(":"))return t.set(s.slice(1),a),a;const c=s.match(/^(.+?)(?:'s|\.)\s*(\w+)$/);if(c){const e=r(c[1],n);if(e)return e[c[2]]=a,e}return a}case"log":{const r=i(e.args.join(" "),n,t);return console.log(r),r}case"send":{const n=new CustomEvent(e.args[0],{bubbles:1});for(const e of a)e.dispatchEvent(n);return n}case"wait":{const n=parseInt(e.args[0])||0;return await new Promise(e=>setTimeout(e,n)),n}default:return console.warn("Unknown command: "+e.name),null}}function i(e,n,t){if(!e)return;const r=e.trim();if(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))return r.slice(1,-1);if(/^-?\d+(\.\d+)?$/.test(r))return parseFloat(r);if("true"===r)return 1;if("false"===r)return 0;if("null"===r)return null;if(r.startsWith(":"))return t.get(r.slice(1));if("me"===r)return n;if("my"===r)return n;if("body"===r)return document.body;const s=r.match(/^(me|my)\.(\w+)$/);return s?n[s[2]]:r}async function a(e,n,t=new Map){if(Array.isArray(e)){let r;for(const s of e){if("if"===s.modifier||"unless"===s.modifier){const e=c(s.args[0],n,t);if(!("if"===s.modifier?e:!e))continue;s.args.shift()}r=await o(s,n,t)}return r}const r=e,s=r.filter?document.querySelector(r.filter):n,i=r.event;if(i.startsWith("interval:")){const e=parseInt(i.split(":")[1]);return setInterval(async()=>{const e=new Map(t);for(const t of r.commands)await o(t,n,e)},e),n}if("init"===i){const e=new Map(t);for(const t of r.commands)await o(t,n,e);return n}return s&&s.addEventListener(i,async e=>{const s=new Map(t);s.set("event",e);for(const e of r.commands)await o(e,n,s)}),n}function c(e,n,t){const r=e.trim(),s=r.match(/^(me|my)\s+has\s+\.(\w+)$/i);if(s)return n.classList.contains(s[2]);const o=r.match(/^(me|my)\.(\w+)$/i);return o?!!n[o[2]]:r.startsWith(":")?!!t.get(r.slice(1)):!!i(r,n,t)}function u(n=document){const t=n.querySelectorAll("[_]");for(const n of t){const t=n.getAttribute("_");if(t)try{a(e(t),n)}catch(e){console.error("HyperFixi Lite error:",e,"Code:",t)}}}"undefined"!=typeof window&&(window.hyperfixi={version:"1.0.0-lite",parse:e,execute:async(n,t)=>{const r=t||document.body;return a(e(n),r)},init:u,process:u,commands:["add","remove","toggle","put","set","log","send","wait"]},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>u()):u())}();