@lokascript/hyperscript-adapter 2.0.0 → 2.2.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.
Files changed (34) hide show
  1. package/README.md +46 -3
  2. package/dist/hyperscript-i18n-ar.global.js +4 -4
  3. package/dist/hyperscript-i18n-bn.global.js +4 -4
  4. package/dist/hyperscript-i18n-de.global.js +4 -4
  5. package/dist/hyperscript-i18n-east-asian.global.js +4 -4
  6. package/dist/hyperscript-i18n-en.global.js +6 -6
  7. package/dist/hyperscript-i18n-es.global.js +4 -4
  8. package/dist/hyperscript-i18n-fr.global.js +4 -4
  9. package/dist/hyperscript-i18n-he.global.js +4 -4
  10. package/dist/hyperscript-i18n-hi.global.js +4 -4
  11. package/dist/hyperscript-i18n-id.global.js +4 -4
  12. package/dist/hyperscript-i18n-it.global.js +4 -4
  13. package/dist/hyperscript-i18n-ja.global.js +4 -4
  14. package/dist/hyperscript-i18n-ko.global.js +4 -4
  15. package/dist/hyperscript-i18n-ms.global.js +4 -4
  16. package/dist/hyperscript-i18n-pl.global.js +4 -4
  17. package/dist/hyperscript-i18n-pt.global.js +4 -4
  18. package/dist/hyperscript-i18n-qu.global.js +4 -4
  19. package/dist/hyperscript-i18n-ru.global.js +4 -4
  20. package/dist/hyperscript-i18n-slavic.global.js +4 -4
  21. package/dist/hyperscript-i18n-south-asian.global.js +4 -4
  22. package/dist/hyperscript-i18n-southeast-asian.global.js +4 -4
  23. package/dist/hyperscript-i18n-sw.global.js +4 -4
  24. package/dist/hyperscript-i18n-th.global.js +4 -4
  25. package/dist/hyperscript-i18n-tl.global.js +4 -4
  26. package/dist/hyperscript-i18n-tr.global.js +4 -4
  27. package/dist/hyperscript-i18n-uk.global.js +4 -4
  28. package/dist/hyperscript-i18n-vi.global.js +4 -4
  29. package/dist/hyperscript-i18n-western.global.js +4 -4
  30. package/dist/hyperscript-i18n-zh.global.js +4 -4
  31. package/dist/hyperscript-i18n.global.js +73 -7
  32. package/dist/hyperscript-i18n.global.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/hyperscript-renderer.ts +3 -0
@@ -1,4 +1,4 @@
1
- var HyperscriptI18n=(function(exports){'use strict';var ct=new Map,ut=new Map,pt=new Map;function dt(r,e,t){ct.set(r,e),ut.set(r,t),pt.delete(r);}var ft=class{constructor(r,e){this.pos=0,this.tokens=r,this.language=e;}peek(r=0){let e=this.pos+r;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(r){this.pos=r.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(r){let e=[];for(;!this.isAtEnd()&&r(this.peek());)e.push(this.advance());return e}skipWhile(r){for(;!this.isAtEnd()&&r(this.peek());)this.advance();}};function g(r,e){return {start:r,end:e}}function E(r,e,t,n){if(typeof n=="string")return {value:r,kind:e,position:t,normalized:n};if(n){let{normalized:i,stem:o,stemConfidence:s}=n;return {value:r,kind:e,position:t,...i!==void 0&&{normalized:i},...o!==void 0&&{stem:o},...s!==void 0&&{stemConfidence:s}}}return {value:r,kind:e,position:t}}function M(r){return /\s/.test(r)}function ke(r){return r==="#"||r==="."||r==="["||r==="@"||r==="*"||r==="<"}function we(r){return r==='"'||r==="'"||r==="`"||r==="\u300C"||r==="\u300D"}function x(r){return /\d/.test(r)}function mt(r){return /[a-zA-Z]/.test(r)}function w(r){return /[a-zA-Z0-9_-]/.test(r)}function ht(r){let e=n=>r.test(n);return {isLetter:e,isIdentifierChar:n=>e(n)||/[0-9_-]/.test(n)}}function vt(r,e){if(e>=r.length)return null;let t=r[e];if(!ke(t))return null;let n=e,i="";if(t==="#"||t==="."){for(i+=r[n++];n<r.length&&w(r[n]);)i+=r[n++];if(i.length<=1)return null;if(n<r.length&&r[n]==="."&&t==="#"){let s=n+1;for(;s<r.length&&w(r[s]);)s++;if(s<r.length&&r[s]==="(")return i}}else if(t==="["){let o=1,s=false,a=null,l=false;for(i+=r[n++];n<r.length&&o>0;){let u=r[n];i+=u,l?l=false:u==="\\"?l=true:s?u===a&&(s=false,a=null):u==='"'||u==="'"||u==="`"?(s=true,a=u):u==="["?o++:u==="]"&&o--,n++;}if(o!==0)return null}else if(t==="@"){for(i+=r[n++];n<r.length&&w(r[n]);)i+=r[n++];if(i.length<=1)return null}else if(t==="*"){for(i+=r[n++];n<r.length&&w(r[n]);)i+=r[n++];if(i.length<=1)return null}else if(t==="<"){if(i+=r[n++],n>=r.length||!mt(r[n]))return null;for(;n<r.length&&w(r[n]);)i+=r[n++];for(;n<r.length;){let o=r[n];if(o==="."){if(i+=r[n++],n>=r.length||!w(r[n]))return null;for(;n<r.length&&w(r[n]);)i+=r[n++];}else if(o==="#"){if(i+=r[n++],n>=r.length||!w(r[n]))return null;for(;n<r.length&&w(r[n]);)i+=r[n++];}else if(o==="["){let s=1,a=false,l=null,u=false;for(i+=r[n++];n<r.length&&s>0;){let c=r[n];i+=c,u?u=false:c==="\\"?u=true:a?c===l&&(a=false,l=null):c==='"'||c==="'"||c==="`"?(a=true,l=c):c==="["?s++:c==="]"&&s--,n++;}if(s!==0)return null}else break}for(;n<r.length&&M(r[n]);)i+=r[n++];if(n<r.length&&r[n]==="/")for(i+=r[n++];n<r.length&&M(r[n]);)i+=r[n++];if(n>=r.length||r[n]!==">")return null;i+=r[n++];}return i||null}function yt(r,e){if(e>=r.length||r[e]!=="'"||e+1>=r.length||r[e+1].toLowerCase()!=="s")return false;if(e+2>=r.length)return true;let n=r[e+2];return M(n)||n==="*"||!w(n)}function gt(r,e){if(e>=r.length)return null;let t=r[e];if(!we(t)||t==="'"&&yt(r,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!i)return null;let o=e+1,s=t,a=false;for(;o<r.length;){let l=r[o];if(s+=l,a)a=false;else if(l==="\\")a=true;else if(l===i)return s;o++;}return s}function Ce(r,e){if(e>=r.length)return false;let t=r[e],n=r[e+1]||"",i=r[e+2]||"";if(t==="/"&&n!=="/"&&/[a-zA-Z0-9._-]/.test(n)||t==="/"&&n==="/"&&/[a-zA-Z]/.test(i)||t==="."&&(n==="/"||n==="."&&i==="/"))return true;let o=r.slice(e,e+8).toLowerCase();return !!(o.startsWith("http://")||o.startsWith("https://"))}function Et(r,e){if(!Ce(r,e))return null;let t=e,n="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<r.length;){let o=r[t];if(o==="#"){if(n.length>0&&/[a-zA-Z0-9/.]$/.test(n))for(n+=o,t++;t<r.length&&/[a-zA-Z0-9_-]/.test(r[t]);)n+=r[t++];break}if(i.test(o))n+=o,t++;else break}return n.length<2?null:n}function Tt(r,e){if(e>=r.length)return null;let t=r[e];if(!x(t)&&t!=="-"&&t!=="+")return null;let n=e,i="";if((r[n]==="-"||r[n]==="+")&&(i+=r[n++]),n>=r.length||!x(r[n]))return null;for(;n<r.length&&x(r[n]);)i+=r[n++];if(n<r.length&&r[n]===".")for(i+=r[n++];n<r.length&&x(r[n]);)i+=r[n++];return n<r.length&&(r.slice(n,n+2)==="ms"?i+="ms":(r[n]==="s"||r[n]==="m"||r[n]==="h")&&(i+=r[n])),i}var Ae=class xe{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map;}tryPropertyAccess(e,t,n){if(e[t]!==".")return false;let i=n[n.length-1],o=i&&i.position.end<t;if(i&&!o&&(i.kind==="identifier"||i.kind==="keyword"||i.kind==="selector"))return n.push(E(".","operator",g(t,t+1))),true;let l=t+1;for(;l<e.length&&w(e[l]);)l++;return l<e.length&&e[l]==="("?(n.push(E(".","operator",g(t,t+1))),true):false}initializeKeywordsFromProfile(e,t=[]){let n=new Map;if(e.keywords){for(let[i,o]of Object.entries(e.keywords))if(n.set(o.primary,{native:o.primary,normalized:o.normalized||i}),o.alternatives)for(let s of o.alternatives)n.set(s,{native:s,normalized:o.normalized||i});}if(e.references){for(let[i,o]of Object.entries(e.references))n.set(o,{native:o,normalized:i});for(let i of Object.keys(e.references))n.has(i)||n.set(i,{native:i,normalized:i});}if(e.roleMarkers){for(let[i,o]of Object.entries(e.roleMarkers))if(o.primary&&n.set(o.primary,{native:o.primary,normalized:i}),o.alternatives)for(let s of o.alternatives)n.set(s,{native:s,normalized:i});}for(let i of t)n.set(i.native,i);this.profileKeywords=Array.from(n.values()).sort((i,o)=>o.native.length-i.native.length),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let o=this.removeDiacritics(i.native);o!==i.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),i);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,t){for(let n of this.profileKeywords)if(e.slice(t).startsWith(n.native))return E(n.native,"keyword",g(t,t+n.native.length),n.normalized);return null}isKeywordStart(e,t){let n=e.slice(t);return this.profileKeywords.some(i=>n.startsWith(i.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let t=this.normalizer.normalize(e);return t.stem!==e&&t.confidence>=.7?t:null}tryMorphKeywordMatch(e,t,n){let i=this.tryNormalize(e);if(!i)return null;let o=this.lookupKeyword(i.stem);if(!o)return null;let s={normalized:o.normalized,stem:i.stem,stemConfidence:i.confidence};return E(e,"keyword",g(t,n),s)}trySelector(e,t){let n=vt(e,t);return n?E(n,"selector",g(t,t+n.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let n=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!n)return null;let i=n[0].replace(/(\s|\.)$/,""),o=i.slice(1).split("(")[0],s=n[1];return {...E(i,"event-modifier",g(t,t+i.length)),metadata:{modifierName:o,value:s?o==="queue"?s:parseInt(s,10):void 0}}}tryString(e,t){let n=gt(e,t);return n?E(n,"literal",g(t,t+n.length)):null}tryNumber(e,t){let n=Tt(e,t);return n?E(n,"literal",g(t,t+n.length)):null}tryMatchTimeUnit(e,t,n,i=false){let o=t;if(i)for(;o<e.length&&M(e[o]);)o++;let s=e.slice(o);for(let a of n){let l=s.slice(0,a.length);if(a.caseInsensitive?l.toLowerCase()===a.pattern.toLowerCase():l===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let c=s[a.length]||"";if(w(c))continue}return {suffix:a.suffix,endPos:o+a.length}}}return null}parseBaseNumber(e,t,n=true){let i=t,o="";if(n&&(e[i]==="-"||e[i]==="+")&&(o+=e[i++]),i>=e.length||!x(e[i]))return null;for(;i<e.length&&x(e[i]);)o+=e[i++];if(i<e.length&&e[i]===".")for(o+=e[i++];i<e.length&&x(e[i]);)o+=e[i++];return !o||o==="-"||o==="+"?null:{number:o,endPos:i}}tryNumberWithTimeUnits(e,t,n,i={}){let{allowSign:o=true,skipWhitespace:s=false}=i,a=this.parseBaseNumber(e,t,o);if(!a)return null;let{number:l,endPos:u}=a,c=[...n,...xe.STANDARD_TIME_UNITS],p=this.tryMatchTimeUnit(e,u,c,s);return p&&(l+=p.suffix,u=p.endPos),E(l,"literal",g(t,u))}tryUrl(e,t){let n=Et(e,t);return n?E(n,"url",g(t,t+n.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!w(e[t+1]))return null;let n=t+1;for(;n<e.length&&w(e[n]);)n++;let i=e.slice(t,n);return E(i,"identifier",g(t,n))}tryOperator(e,t){let n=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(n))return E(n,"operator",g(t,t+2));let i=e[t];return ["<",">","!","+","-","*","/","="].includes(i)?E(i,"operator",g(t,t+1)):["(",")","{","}",",",";",":"].includes(i)?E(i,"punctuation",g(t,t+1)):null}tryMultiCharParticle(e,t,n){for(let i of n)if(e.slice(t,t+i.length)===i)return E(i,"particle",g(t,t+i.length));return null}};Ae.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var bt=Ae;function Ee(r){return {stem:r,confidence:1}}function ne(r,e,t){return t?{stem:r,confidence:e,metadata:t}:{stem:r,confidence:e}}function St(r){return /[áéíóúüñÁÉÍÓÚÜÑ]/.test(r)}function kt(r){let e=r.toLowerCase();if(e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir")||e.endsWith("ando")||e.endsWith("iendo")||e.endsWith("ado")||e.endsWith("ido")||e.endsWith("arse")||e.endsWith("erse")||e.endsWith("irse"))return true;for(let t of r)if(St(t))return true;return false}var Te=["se","me","te","nos","os"],wt=[{ending:"ando",stem:"ar",confidence:.88,type:"gerund"},{ending:"ado",stem:"ar",confidence:.88,type:"participle"},{ending:"ada",stem:"ar",confidence:.88,type:"participle"},{ending:"ados",stem:"ar",confidence:.88,type:"participle"},{ending:"adas",stem:"ar",confidence:.88,type:"participle"},{ending:"o",stem:"ar",confidence:.75,type:"present"},{ending:"as",stem:"ar",confidence:.82,type:"present"},{ending:"a",stem:"ar",confidence:.75,type:"present"},{ending:"amos",stem:"ar",confidence:.85,type:"present"},{ending:"\xE1is",stem:"ar",confidence:.85,type:"present"},{ending:"ais",stem:"ar",confidence:.82,type:"present"},{ending:"an",stem:"ar",confidence:.8,type:"present"},{ending:"\xE9",stem:"ar",confidence:.85,type:"past"},{ending:"aste",stem:"ar",confidence:.88,type:"past"},{ending:"\xF3",stem:"ar",confidence:.82,type:"past"},{ending:"amos",stem:"ar",confidence:.85,type:"past"},{ending:"asteis",stem:"ar",confidence:.88,type:"past"},{ending:"aron",stem:"ar",confidence:.88,type:"past"},{ending:"aba",stem:"ar",confidence:.88,type:"past"},{ending:"abas",stem:"ar",confidence:.88,type:"past"},{ending:"\xE1bamos",stem:"ar",confidence:.88,type:"past"},{ending:"abamos",stem:"ar",confidence:.85,type:"past"},{ending:"abais",stem:"ar",confidence:.88,type:"past"},{ending:"aban",stem:"ar",confidence:.88,type:"past"},{ending:"e",stem:"ar",confidence:.72,type:"subjunctive"},{ending:"es",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"emos",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"\xE9is",stem:"ar",confidence:.85,type:"subjunctive"},{ending:"eis",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"en",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"a",stem:"ar",confidence:.75,type:"imperative"},{ending:"ad",stem:"ar",confidence:.85,type:"imperative"},{ending:"ar",stem:"ar",confidence:.92,type:"dictionary"}],Ct=[{ending:"iendo",stem:"er",confidence:.88,type:"gerund"},{ending:"ido",stem:"er",confidence:.85,type:"participle"},{ending:"ida",stem:"er",confidence:.85,type:"participle"},{ending:"idos",stem:"er",confidence:.85,type:"participle"},{ending:"idas",stem:"er",confidence:.85,type:"participle"},{ending:"o",stem:"er",confidence:.72,type:"present"},{ending:"es",stem:"er",confidence:.78,type:"present"},{ending:"e",stem:"er",confidence:.72,type:"present"},{ending:"emos",stem:"er",confidence:.85,type:"present"},{ending:"\xE9is",stem:"er",confidence:.85,type:"present"},{ending:"eis",stem:"er",confidence:.82,type:"present"},{ending:"en",stem:"er",confidence:.78,type:"present"},{ending:"\xED",stem:"er",confidence:.85,type:"past"},{ending:"iste",stem:"er",confidence:.88,type:"past"},{ending:"i\xF3",stem:"er",confidence:.85,type:"past"},{ending:"io",stem:"er",confidence:.82,type:"past"},{ending:"imos",stem:"er",confidence:.85,type:"past"},{ending:"isteis",stem:"er",confidence:.88,type:"past"},{ending:"ieron",stem:"er",confidence:.88,type:"past"},{ending:"\xEDa",stem:"er",confidence:.88,type:"past"},{ending:"ia",stem:"er",confidence:.85,type:"past"},{ending:"\xEDas",stem:"er",confidence:.88,type:"past"},{ending:"ias",stem:"er",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"er",confidence:.88,type:"past"},{ending:"iamos",stem:"er",confidence:.85,type:"past"},{ending:"\xEDais",stem:"er",confidence:.88,type:"past"},{ending:"iais",stem:"er",confidence:.85,type:"past"},{ending:"\xEDan",stem:"er",confidence:.88,type:"past"},{ending:"ian",stem:"er",confidence:.85,type:"past"},{ending:"er",stem:"er",confidence:.92,type:"dictionary"}],At=[{ending:"iendo",stem:"ir",confidence:.88,type:"gerund"},{ending:"ido",stem:"ir",confidence:.85,type:"participle"},{ending:"ida",stem:"ir",confidence:.85,type:"participle"},{ending:"idos",stem:"ir",confidence:.85,type:"participle"},{ending:"idas",stem:"ir",confidence:.85,type:"participle"},{ending:"o",stem:"ir",confidence:.72,type:"present"},{ending:"es",stem:"ir",confidence:.78,type:"present"},{ending:"e",stem:"ir",confidence:.72,type:"present"},{ending:"imos",stem:"ir",confidence:.85,type:"present"},{ending:"\xEDs",stem:"ir",confidence:.85,type:"present"},{ending:"is",stem:"ir",confidence:.82,type:"present"},{ending:"en",stem:"ir",confidence:.78,type:"present"},{ending:"\xED",stem:"ir",confidence:.85,type:"past"},{ending:"iste",stem:"ir",confidence:.88,type:"past"},{ending:"i\xF3",stem:"ir",confidence:.85,type:"past"},{ending:"io",stem:"ir",confidence:.82,type:"past"},{ending:"imos",stem:"ir",confidence:.85,type:"past"},{ending:"isteis",stem:"ir",confidence:.88,type:"past"},{ending:"ieron",stem:"ir",confidence:.88,type:"past"},{ending:"\xEDa",stem:"ir",confidence:.88,type:"past"},{ending:"ia",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDas",stem:"ir",confidence:.88,type:"past"},{ending:"ias",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"ir",confidence:.88,type:"past"},{ending:"iamos",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDais",stem:"ir",confidence:.88,type:"past"},{ending:"iais",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDan",stem:"ir",confidence:.88,type:"past"},{ending:"ian",stem:"ir",confidence:.85,type:"past"},{ending:"ir",stem:"ir",confidence:.92,type:"dictionary"}],xt=[...wt,...Ct,...At].sort((r,e)=>e.ending.length-r.ending.length),Re=class{constructor(){this.language="es";}isNormalizable(r){return r.length<3?false:kt(r)}normalize(r){let e=r.toLowerCase();if((e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir"))&&!Te.some(i=>e.endsWith(i+"ar")||e.endsWith(i+"er")||e.endsWith(i+"ir")))return Ee(r);let t=this.tryReflexiveNormalization(e);if(t)return t;let n=this.tryConjugationNormalization(e);return n||Ee(r)}tryReflexiveNormalization(r){for(let e of Te)if(r.endsWith(e)){let t=r.slice(0,-e.length);if(t.endsWith("ar")||t.endsWith("er")||t.endsWith("ir"))return ne(t,.88,{removedSuffixes:[e],conjugationType:"reflexive"});let n=this.tryConjugationNormalization(t);if(n&&n.stem!==t)return ne(n.stem,n.confidence*.95,{removedSuffixes:[e,...n.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationNormalization(r){for(let e of xt)if(r.endsWith(e.ending)){let t=r.slice(0,-e.ending.length);if(t.length<2)continue;let n=t+e.stem;return ne(n,e.confidence,{removedSuffixes:[e.ending],conjugationType:e.type})}return null}},Pe={code:"es",name:"Spanish",nativeName:"Espa\xF1ol",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:true},references:{me:"yo",it:"ello",you:"t\xFA",result:"resultado",event:"evento",target:"objetivo",body:"cuerpo"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"mi",it:"su",you:"tu"},keywords:{mi:"me",tu:"you",su:"it"}},roleMarkers:{destination:{primary:"en",alternatives:["sobre","a"],position:"before"},source:{primary:"de",alternatives:["desde"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"con",position:"before"}},keywords:{toggle:{primary:"alternar",alternatives:["cambiar","conmutar"],normalized:"toggle"},add:{primary:"agregar",alternatives:["a\xF1adir"],normalized:"add"},remove:{primary:"quitar",alternatives:["eliminar","remover","sacar"],normalized:"remove"},put:{primary:"poner",alternatives:["colocar"],normalized:"put"},append:{primary:"a\xF1adir",normalized:"append"},prepend:{primary:"anteponer",normalized:"prepend"},take:{primary:"tomar",normalized:"take"},make:{primary:"hacer",alternatives:["crear"],normalized:"make"},clone:{primary:"clonar",alternatives:["copiar"],normalized:"clone"},swap:{primary:"intercambiar",alternatives:["cambiar"],normalized:"swap"},morph:{primary:"transformar",alternatives:["convertir"],normalized:"morph"},set:{primary:"establecer",alternatives:["fijar","definir"],normalized:"set"},get:{primary:"obtener",alternatives:["conseguir"],normalized:"get"},increment:{primary:"incrementar",alternatives:["aumentar"],normalized:"increment"},decrement:{primary:"decrementar",alternatives:["disminuir"],normalized:"decrement"},log:{primary:"registrar",alternatives:["imprimir"],normalized:"log"},show:{primary:"mostrar",alternatives:["ense\xF1ar"],normalized:"show"},hide:{primary:"ocultar",alternatives:["esconder"],normalized:"hide"},transition:{primary:"transici\xF3n",alternatives:["animar"],normalized:"transition"},on:{primary:"en",alternatives:["cuando","al"],normalized:"on"},trigger:{primary:"disparar",alternatives:["activar"],normalized:"trigger"},send:{primary:"enviar",normalized:"send"},focus:{primary:"enfocar",normalized:"focus"},blur:{primary:"desenfocar",normalized:"blur"},click:{primary:"clic",alternatives:["hacer clic"],normalized:"click"},hover:{primary:"sobrevolar",alternatives:["pasar por encima"],normalized:"hover"},submit:{primary:"env\xEDo",alternatives:["enviar"],normalized:"submit"},input:{primary:"entrada",alternatives:["introducir"],normalized:"input"},change:{primary:"cambio",alternatives:["cambiar"],normalized:"change"},go:{primary:"ir",alternatives:["navegar"],normalized:"go"},wait:{primary:"esperar",normalized:"wait"},fetch:{primary:"buscar",alternatives:["obtener"],normalized:"fetch"},settle:{primary:"estabilizar",normalized:"settle"},if:{primary:"si",normalized:"if"},when:{primary:"cuando",normalized:"when"},where:{primary:"donde",normalized:"where"},else:{primary:"sino",alternatives:["de lo contrario"],normalized:"else"},repeat:{primary:"repetir",normalized:"repeat"},for:{primary:"para",normalized:"for"},while:{primary:"mientras",normalized:"while"},continue:{primary:"continuar",normalized:"continue"},halt:{primary:"detener",alternatives:["parar"],normalized:"halt"},throw:{primary:"lanzar",alternatives:["arrojar"],normalized:"throw"},call:{primary:"llamar",normalized:"call"},return:{primary:"retornar",alternatives:["devolver"],normalized:"return"},then:{primary:"entonces",alternatives:["luego","despu\xE9s"],normalized:"then"},and:{primary:"y",alternatives:["adem\xE1s","tambi\xE9n"],normalized:"and"},end:{primary:"fin",alternatives:["final","terminar"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"as\xEDncrono",normalized:"async"},tell:{primary:"decir",normalized:"tell"},default:{primary:"predeterminar",alternatives:["por defecto"],normalized:"default"},init:{primary:"iniciar",alternatives:["inicializar"],normalized:"init"},behavior:{primary:"comportamiento",normalized:"behavior"},install:{primary:"instalar",normalized:"install"},measure:{primary:"medir",normalized:"measure"},beep:{primary:"pitido",normalized:"beep"},break:{primary:"romper",normalized:"break"},copy:{primary:"copiar",normalized:"copy"},exit:{primary:"salir",normalized:"exit"},pick:{primary:"escoger",normalized:"pick"},render:{primary:"renderizar",normalized:"render"},into:{primary:"en",alternatives:["dentro de"],normalized:"into"},before:{primary:"antes",normalized:"before"},after:{primary:"despu\xE9s",normalized:"after"},until:{primary:"hasta",normalized:"until"},event:{primary:"evento",normalized:"event"},from:{primary:"de",alternatives:["desde"],normalized:"from"}},eventHandler:{keyword:{primary:"al",alternatives:["cuando","en"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["desde"],position:"before"},eventMarker:{primary:"al",alternatives:["cuando"],position:"before"},temporalMarkers:["cuando","al"]}},{isLetter:be,isIdentifierChar:Rt}=ht(/[a-zA-ZáéíóúüñÁÉÍÓÚÜÑ]/),Pt=[{pattern:"milisegundos",suffix:"ms",length:12,caseInsensitive:true},{pattern:"milisegundo",suffix:"ms",length:11,caseInsensitive:true},{pattern:"segundos",suffix:"s",length:8,caseInsensitive:true},{pattern:"segundo",suffix:"s",length:7,caseInsensitive:true},{pattern:"minutos",suffix:"m",length:7,caseInsensitive:true},{pattern:"minuto",suffix:"m",length:6,caseInsensitive:true},{pattern:"horas",suffix:"h",length:5,caseInsensitive:true},{pattern:"hora",suffix:"h",length:4,caseInsensitive:true}],Se=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),_t=[{native:"verdadero",normalized:"true"},{native:"falso",normalized:"false"},{native:"nulo",normalized:"null"},{native:"indefinido",normalized:"undefined"},{native:"primero",normalized:"first"},{native:"primera",normalized:"first"},{native:"\xFAltimo",normalized:"last"},{native:"ultima",normalized:"last"},{native:"siguiente",normalized:"next"},{native:"anterior",normalized:"previous"},{native:"cercano",normalized:"closest"},{native:"padre",normalized:"parent"},{native:"clic",normalized:"click"},{native:"click",normalized:"click"},{native:"hacer clic",normalized:"click"},{native:"entrada",normalized:"input"},{native:"cambio",normalized:"change"},{native:"env\xEDo",normalized:"submit"},{native:"envio",normalized:"submit"},{native:"tecla abajo",normalized:"keydown"},{native:"tecla arriba",normalized:"keyup"},{native:"rat\xF3n encima",normalized:"mouseover"},{native:"raton encima",normalized:"mouseover"},{native:"rat\xF3n fuera",normalized:"mouseout"},{native:"raton fuera",normalized:"mouseout"},{native:"enfoque",normalized:"focus"},{native:"desenfoque",normalized:"blur"},{native:"carga",normalized:"load"},{native:"desplazamiento",normalized:"scroll"},{native:"yo",normalized:"me"},{native:"m\xED",normalized:"me"},{native:"mi",normalized:"me"},{native:"ello",normalized:"it"},{native:"resultado",normalized:"result"},{native:"objetivo",normalized:"target"},{native:"destino",normalized:"target"},{native:"segundo",normalized:"s"},{native:"segundos",normalized:"s"},{native:"milisegundo",normalized:"ms"},{native:"milisegundos",normalized:"ms"},{native:"minuto",normalized:"m"},{native:"minutos",normalized:"m"},{native:"hora",normalized:"h"},{native:"horas",normalized:"h"},{native:"de lo contrario",normalized:"else"},{native:"hasta que",normalized:"until"},{native:"antes de",normalized:"before"},{native:"despu\xE9s de",normalized:"after"},{native:"despues de",normalized:"after"},{native:"dentro de",normalized:"into"},{native:"fuera de",normalized:"out"},{native:"asincrono",normalized:"async"},{native:"despues",normalized:"after"},{native:"a\xF1adir",normalized:"add"},{native:"toggle",normalized:"toggle"},{native:"borrar",normalized:"remove"},{native:"pon",normalized:"put"},{native:"crear",normalized:"make"},{native:"y",normalized:"and"},{native:"o",normalized:"or"},{native:"no",normalized:"not"},{native:"es",normalized:"is"},{native:"existe",normalized:"exists"},{native:"vac\xEDo",normalized:"empty"},{native:"vacio",normalized:"empty"}],Nt=class extends bt{constructor(){super(),this.language="es",this.direction="ltr",this.initializeKeywordsFromProfile(Pe,_t),this.normalizer=new Re;}tokenize(r){let e=[],t=0;for(;t<r.length;){if(M(r[t])){t++;continue}if(ke(r[t])){let s=this.tryEventModifier(r,t);if(s){e.push(s),t=s.position.end;continue}if(this.tryPropertyAccess(r,t,e)){t++;continue}let a=this.trySelector(r,t);if(a){e.push(a),t=a.position.end;continue}}if(we(r[t])){let s=this.tryString(r,t);if(s){e.push(s),t=s.position.end;continue}}if(Ce(r,t)){let s=this.tryUrl(r,t);if(s){e.push(s),t=s.position.end;continue}}if(x(r[t])||r[t]==="-"&&t+1<r.length&&x(r[t+1])){let s=this.extractSpanishNumber(r,t);if(s){e.push(s),t=s.position.end;continue}}let n=this.tryVariableRef(r,t);if(n){e.push(n),t=n.position.end;continue}let i=this.tryMultiWordPhrase(r,t);if(i){e.push(i),t=i.position.end;continue}if(be(r[t])){let s=this.extractSpanishWord(r,t);if(s){e.push(s),t=s.position.end;continue}}let o=this.tryOperator(r,t);if(o){e.push(o),t=o.position.end;continue}t++;}return new ft(e,"es")}classifyToken(r){let e=r.toLowerCase();return Se.has(e)?"particle":this.isKeyword(e)?"keyword":r.startsWith("#")||r.startsWith(".")||r.startsWith("[")||r.startsWith("*")||r.startsWith("<")?"selector":r.startsWith('"')||r.startsWith("'")||/^\d/.test(r)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(r)?"operator":"identifier"}tryMultiWordPhrase(r,e){for(let t of this.profileKeywords){if(!t.native.includes(" "))continue;let n=t.native;if(r.slice(e,e+n.length).toLowerCase()===n.toLowerCase()){let o=e+n.length;if(o>=r.length||M(r[o])||!be(r[o]))return E(r.slice(e,e+n.length),"keyword",g(e,o),t.normalized)}}return null}extractSpanishWord(r,e){let t=e,n="";for(;t<r.length&&Rt(r[t]);)n+=r[t++];if(!n)return null;let i=n.toLowerCase();if(Se.has(i))return E(n,"particle",g(e,t));let o=this.lookupKeyword(i);if(o)return E(n,"keyword",g(e,t),o.normalized);let s=this.tryMorphKeywordMatch(i,e,t);return s||E(n,"identifier",g(e,t))}extractSpanishNumber(r,e){return this.tryNumberWithTimeUnits(r,e,Pt,{allowSign:true,skipWhitespace:true})}},Ot=new Nt;dt("es",Ot,Pe);var It=Object.defineProperty,Mt=Object.getOwnPropertyNames,Be=(r,e)=>function(){return r&&(e=(0, r[Mt(r)[0]])(r=0)),e},Lt=(r,e)=>{for(var t in e)It(r,t,{get:e[t],enumerable:true});};function _e(r,e){return r.replace(/\{(\w+)\}/g,(t,n)=>String(e[n]??`{${n}}`))}function C(r,e,t={},n){let i=$e[r],o=_e(i,t),s=qe[r],a=s?_e(s,t):void 0;return {code:r,message:o,severity:e,...n&&{role:n},...a&&{suggestion:a}}}var h,$e,qe,zt=Be({"src/generators/schema-error-codes.ts"(){h={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION"},$e={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[h.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[h.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[h.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[h.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[h.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[h.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[h.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[h.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition."},qe={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[h.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[h.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[h.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[h.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[h.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition."};}}),Ve={};Lt(Ve,{SchemaErrorCodes:()=>h,formatValidationResults:()=>Wt,getValidationStats:()=>jt,validateAllSchemas:()=>Ft,validateCommandSchema:()=>Fe});function Dt(r,e){return {action:r,items:e,get notes(){return e.filter(t=>t.severity==="note").map(t=>t.message)},get warnings(){return e.filter(t=>t.severity==="warning").map(t=>t.message)},get errors(){return e.filter(t=>t.severity==="error").map(t=>t.message)}}}function Fe(r){let e=[];for(let n of r.roles)n.expectedTypes.includes("literal")&&n.expectedTypes.includes("selector")&&(n.role==="patient"&&ae.has(r.action)?e.push(C(h.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:n.role,command:r.action},n.role)):e.push(C(h.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:n.role},n.role))),n.expectedTypes.length>3&&!ae.has(r.action)&&e.push(C(h.TOO_MANY_EXPECTED_TYPES,"warning",{role:n.role,count:n.expectedTypes.length},n.role));switch(r.action){case "transition":Bt(r,e);break;case "on":$t(r,e);break;case "if":case "unless":qt(r,e);break;case "repeat":case "for":case "while":Vt(r,e);break}return r.roles.filter(n=>n.required).length===0&&(We.has(r.action)?e.push(C(h.NO_REQUIRED_ROLES_EXPECTED,"note",{command:r.action})):e.push(C(h.NO_REQUIRED_ROLES,"warning",{}))),Dt(r.action,e)}function Bt(r,e){let t=r.roles.find(i=>i.role==="patient"),n=r.roles.find(i=>i.role==="goal");t&&t.expectedTypes.includes("selector")&&e.push(C(h.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),t&&!n&&e.push(C(h.TRANSITION_MISSING_GOAL,"error",{}));}function $t(r,e){let t=r.roles.find(n=>n.role==="event");t||e.push(C(h.EVENT_HANDLER_MISSING_EVENT,"warning",{})),t&&!t.required&&e.push(C(h.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function qt(r,e){let t=r.roles.find(n=>n.role==="condition");t||e.push(C(h.CONDITIONAL_MISSING_CONDITION,"warning",{})),t&&!t.required&&e.push(C(h.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Vt(r,e){r.action==="for"?r.roles.find(n=>n.role==="source")||e.push(C(h.FOR_LOOP_MISSING_SOURCE,"warning",{})):r.action==="while"&&(r.roles.find(n=>n.role==="condition")||e.push(C(h.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Ft(r,e={}){let t=new Map,{includeNotes:n=false}=e;for(let[i,o]of Object.entries(r)){let s=Fe(o),a=s.items.some(u=>u.severity==="warning"||u.severity==="error"),l=n&&s.items.some(u=>u.severity==="note");(a||l)&&t.set(i,s);}return t}function Wt(r,e={}){let t=[],{showNotes:n=false,showCodes:i=true}=e;for(let[o,s]of r){let a=s.items.filter(c=>c.severity==="error"),l=s.items.filter(c=>c.severity==="warning"),u=s.items.filter(c=>c.severity==="note");if(a.length>0){t.push(` \u274C ${o}:`);for(let c of a){let p=i?` [${c.code}]`:"";t.push(` ERROR${p}: ${c.message}`),c.suggestion&&t.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(l.length>0){t.push(` \u26A0\uFE0F ${o}:`);for(let c of l){let p=i?` [${c.code}]`:"";t.push(` ${p?`${c.code}: `:""}${c.message}`),c.suggestion&&t.push(` \u{1F4A1} ${c.suggestion}`);}}if(n&&u.length>0){t.push(` \u2139\uFE0F ${o}:`);for(let c of u){let p=i?` [${c.code}]`:"";t.push(` ${p?`${c.code}: `:""}${c.message}`);}}}return t.join(`
2
- `)}function jt(r){let e=0,t=0,n=0,i={};for(let o of r.values())for(let s of o.items)s.severity==="error"?e++:s.severity==="warning"?t++:s.severity==="note"&&n++,i[s.code]=(i[s.code]||0)+1;return {totalCommands:r.size,errors:e,warnings:t,notes:n,byCode:i}}var ae,We,Gt=Be({"src/generators/schema-validator.ts"(){zt(),ae=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),We=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep"]);}});function j(r){let e="complex";return r.startsWith("#")&&!r.includes(" ")?e="id":r.startsWith(".")&&!r.includes(" ")?e="class":r.startsWith("[")&&r.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(r)&&(e="element"),{type:"selector",value:r,selectorKind:e}}function b(r,e){let t={type:"literal",value:r};return e!==void 0?{type:"literal",value:r,dataType:e}:t}var Ut=new Set(["me","you","it","result","event","target","body"]);function Ne(r){return Ut.has(r)}function N(r){return {type:"reference",value:r}}function ie(r,e){return {type:"property-path",object:r,property:e}}function X(r,e,t){let n={kind:"command",action:r,roles:new Map(Object.entries(e))};return t!==void 0?{...n,metadata:t}:n}function Oe(r,e,t,n,i,o){let s=new Map;s.set("event",r);let a={kind:"event-handler",action:"on",roles:s,body:e};return t!==void 0&&(a.eventModifiers=t),n!==void 0&&(a.metadata=n),a}function Ie(r,e="then",t){let n={kind:"compound",action:"compound",roles:new Map,statements:r,chainType:e};return t!==void 0&&(n.metadata=t),n}function Me(r,e){return !e||e.length===0||e.includes(r)||e.includes("expression")?true:r==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function Ht(r,e){return r.possessive?.keywords?.[e]}var D=new Map,B=new Map,Q=new Map,le=null;function je(r,e){let t={...r};for(let n of Object.keys(e)){let i=e[n],o=r[n];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?t[n]=je(o,i):t[n]=i);}return t}function Kt(r,e){return je(r,e)}function ue(r){if(!r.extends)return r;let e=B.get(r.extends);if(!e)return console.warn(`[Registry] Profile '${r.code}' extends '${r.extends}' but base is not registered. Make sure to import the base language before the variant.`),r;let t=ue(e);return Kt(t,r)}function Ge(r){le=r;}var Le=new Map;function $(r){return r.split("-")[0]}function q(r){return r.includes("-")}function Yt(r){let e=D.get(r);if(!e&&q(r)){let t=$(r);e=D.get(t);}if(!e){let t=Array.from(D.keys()).join(", ");throw new Error(`Language '${r}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${r}';`)}return e}function Xt(r){let e=B.get(r);if(!e&&q(r)){let t=$(r);e=B.get(t);}if(!e){let t=Array.from(B.keys()).join(", ");throw new Error(`Language profile '${r}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${r}';`)}return ue(e)}function Qt(r){let e=D.get(r);return !e&&q(r)&&(e=D.get($(r))),e}function O(r){let e=B.get(r);return !e&&q(r)&&(e=B.get($(r))),e?ue(e):void 0}function Ue(){return Array.from(D.keys())}function Zt(r,e){return Yt(e).tokenize(r)}function z(r){let e=Q.get(r);if(!e&&q(r)&&(e=Q.get($(r))),e)return e;let t=Le.get(r);if(!t&&q(r)&&(t=Le.get($(r))),t)return Q.set(r,t),t;if(!le)throw new Error(`No patterns registered for language '${r}'. Either import the language module or set a pattern generator.`);let n=Xt(r),i=le(n);return Q.set(r,i),i}var Z=class W{constructor(){this.stemMatchCount=0,this.totalKeywordMatches=0;}matchPattern(e,t){let n=e.mark(),i=new Map;if(this.currentProfile=O(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,i))return e.reset(n),null;let s=this.calculateConfidence(t,i);return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-n.position,confidence:s}}matchBest(e,t){let n=[];for(let o of t){let s=e.mark(),a=this.matchPattern(e,o);a&&n.push(a),e.reset(s);}if(n.length===0)return null;n.sort((o,s)=>{let a=s.pattern.priority-o.pattern.priority;return a!==0?a:s.confidence-o.confidence});let i=n[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,n){let i=t[0],o=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();for(let s of t)if(!this.matchPatternToken(e,s,n)){if(this.isOptional(s))continue;return false}return true}matchPatternToken(e,t,n){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,n);case "group":return this.matchGroupToken(e,t,n);default:return false}}matchLiteralToken(e,t){let n=e.peek();if(!n)return false;let i=this.getMatchType(n,t.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let o of t.alternatives){let s=this.getMatchType(n,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,n){this.skipNoiseWords(e);let i=e.peek();if(!i)return t.optional||false;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(o.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(n.set(t.role,o),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(s.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(n.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Me(a.type,t.expectedTypes)?t.optional||false:(n.set(t.role,a),true);let l=this.tryMatchPropertyAccessExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(l.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(n.set(t.role,l),true);let u=this.tryMatchSelectorPropertyExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!Me(u.type,t.expectedTypes)?t.optional||false:(n.set(t.role,u),true);let c=this.tokenToSemanticValue(i);return !c||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(c.type)?t.optional||false:(n.set(t.role,c),e.advance(),true)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let n=(t.normalized||t.value).toLowerCase(),i=Ht(this.currentProfile,n);if(!i)return null;let o=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(o),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let a=s.value;s.kind==="selector"&&a.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a)&&(a=a.substring(1));let l=a;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let u=e.peek();return u?.kind==="literal"&&u.value.startsWith("(")&&(l+=u.value,e.advance()),ie(N(i),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(n),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<W.MAX_METHOD_ARGS;){let u=e.peek();if(!u)break;if(u.kind==="punctuation"&&u.value===")"){e.advance();break}if(u.kind==="punctuation"&&u.value===","){e.advance();continue}a.push(u.value),e.advance();}return {type:"expression",raw:`${t.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let s=`${t.value}.${o.value}`,a=1;for(;!e.isAtEnd()&&a<W.MAX_PROPERTY_DEPTH;){let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),s+=`.${c.value}`,a++;}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let u=[],c=0;for(;!e.isAtEnd()&&u.length<W.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(c===0){e.advance();break}c--;}if(d.kind==="punctuation"&&d.value==="("&&c++,d.kind==="punctuation"&&d.value===","){e.advance();continue}u.push(d.value),e.advance();}return {type:"expression",raw:`${s}(${u.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(n),null;e.advance();let o=e.peek();return !o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(n),null):(e.advance(),ie(j(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(n),null;let o=e.peek(1);o&&o.kind,e.advance();let s=i.value.slice(1);return ie(j(t.value),s)}matchGroupToken(e,t,n){let i=e.mark(),o=new Set(n.keys());if(!this.matchTokenSequence(e,t.tokens,n)){e.reset(i);for(let a of n.keys())o.has(a)||n.delete(a);return t.optional||false}return true}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return j(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=(e.normalized||e.value).toLowerCase();return Ne(t)?N(t):b(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return N(e.value);let n=e.value.toLowerCase();return Ne(n)?N(n):{type:"expression",raw:e.value};case "url":return b(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return b(i,"string")}if(e==="true")return b(true,"boolean");if(e==="false")return b(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?b(e,"duration"):b(i,"number")}let n=parseFloat(e);return isNaN(n)?b(e,"string"):b(n,"number")}applyExtractionRules(e,t){for(let[n,i]of Object.entries(e.extraction))t.has(n)||(i.value!==void 0?t.set(n,{type:"literal",value:i.value}):i.default&&t.set(n,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,t){let n=0,i=0,o=u=>e.extraction?.[u]?.default!==void 0;for(let u of e.template.tokens)if(u.type==="role")i+=1,t.has(u.role)&&(n+=1);else if(u.type==="group"){for(let c of u.tokens)if(c.type==="role"){let p=o(c.role),d=.8;i+=d,t.has(c.role)?n+=d:p&&(n+=d*.6);}}let s=i>0?n/i:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let u=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-u);}let a=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+a);let l=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+l)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let n=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(n.has(t.value))return .15;if(t.alternatives){for(let i of t.alternatives)if(n.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let n=0,i={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[o,s]of t.entries()){let a=i[o];if(!a||a.length===0)continue;let l="metadata"in s?s.metadata:void 0;if(l&&typeof l.prepositionValue=="string"){let u=l.prepositionValue;a.includes(u)?n+=.1:n-=.1;}}return Math.max(-0.1,Math.min(.1,n))}skipNoiseWords(e){let t=e.peek();if(!t)return;let n=t.value.toLowerCase();if(W.ENGLISH_NOISE_WORDS.has(n)){let i=e.mark();e.advance();let o=e.peek();if(o&&o.kind==="selector")return;e.reset(i);}n==="class"&&e.advance();}extractEventModifiers(e){let t={},n=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(n=true,o.modifierName){case "once":t.once=true;break;case "debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case "throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case "queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance();}return n?t:void 0}};Z.MAX_PROPERTY_DEPTH=10;Z.MAX_METHOD_ARGS=20;Z.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var He=Z,L=new He,oe=class{constructor(r,e){this.pos=0,this.tokens=r,this.language=e;}peek(r=0){let e=this.pos+r;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(r){this.pos=r.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(r){let e=[];for(;!this.isAtEnd()&&r(this.peek());)e.push(this.advance());return e}skipWhile(r){for(;!this.isAtEnd()&&r(this.peek());)this.advance();}};function er(r){return Qt(r)}function se(r,e){return Zt(r,e)}function Ke(){return Ue()}var tr={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyut_de\u011Fi\u015Ftir:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};var V=class R{parse(e,t){let{modifiers:n,remainingInput:i}=this.extractStandaloneModifiers(e,t),o=i||e,s=se(o,t),a=z(t);if(a.length===0)throw new Error(`No patterns available for language: ${t}`);let l=[...a].sort((v,S)=>S.priority-v.priority),u=l.filter(v=>v.command==="on"),c=L.matchBest(s,u);if(c){let v=this.buildEventHandler(c,s,t);return n?this.applyModifiers(v,n):v}let p=l.filter(v=>v.command!=="on"),d=L.matchBest(s,p);if(d)return this.buildCommand(d,t);let f=this.trySOVEventExtraction(o,t,l);if(f)return n?this.applyModifiers(f,n):f;let m=this.tryCompoundCommandParsing(s,p,t);if(m)return m;throw new Error(`Could not parse input in ${t}: ${o}`)}canParse(e,t){try{return this.parse(e,t),!0}catch{return false}}supportedLanguages(){return Ke()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let n={};for(let[i,o]of e.captured)n[i]=o;return X(e.pattern.command,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,t,n){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");let o=L.extractEventModifiers(t),s=this.extractOrConjunctionEvents(t,n),a=i;s.length>0&&i.type==="literal"&&(a={type:"literal",value:[String(i.value),...s.map(p=>String("value"in p?p.value:""))].join(" or ")});let l,u=e.captured.get("action");if(u&&u.type==="literal"){let c=u.value,p={};for(let[m,v]of e.captured)m!=="event"&&m!=="action"&&m!=="continues"&&(p[m]=v);let d=X(c,p,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence}),f=e.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then"){let m=z(n).filter(T=>T.command!=="on").sort((T,A)=>A.priority-T.priority),v=z(n).filter(T=>T.id.startsWith("grammar-")&&T.id.includes("-continuation")).sort((T,A)=>A.priority-T.priority),S=this.parseBodyWithGrammarPatterns(t,m,v,n);S.length>0?l=[d,...S]:l=[d];}else l=[d];}else {let c=z(n).filter(p=>p.command!=="on").sort((p,d)=>d.priority-p.priority);l=this.parseBodyWithClauses(t,c,n);}return Oe(a,l,o,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,n){let i=[],o=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;let a=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,n),l=s.kind==="keyword"&&this.isEndKeyword(s.value,n);if(a){if(o.length>0){let u=this.parseClause(o,t,n);i.push(...u),o.length=0;}e.advance();continue}if(l){if(o.length>0){let u=this.parseClause(o,t,n);i.push(...u);}e.advance();break}o.push(s),e.advance();}if(o.length>0){let s=this.parseClause(o,t,n);i.push(...s);}return i.length>1?[Ie(i,"then",{sourceLanguage:n})]:i}parseClause(e,t,n){if(e.length===0)return [];let i=new oe(e,n),o=[];for(;!i.isAtEnd();){let s=L.matchBest(i,t);s?o.push(this.buildCommand(s,n)):i.advance();}if(o.length===0){let s=this.parseSOVClauseByVerbAnchoring(e,n);if(s.length>0)return s}return o}static buildVerbLookup(e){let t=new Map;for(let[n,i]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(n)&&(t.set(i.primary.toLowerCase(),n),i.alternatives))for(let o of i.alternatives)t.set(o.toLowerCase(),n);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[n,i]of Object.entries(e.roleMarkers))if(i&&(t.set(i.primary,n),i.alternatives))for(let o of i.alternatives)t.has(o)||t.set(o,n);return t}parseSOVClauseByVerbAnchoring(e,t){let n=O(t);if(!n||n.wordOrder!=="SOV")return [];let i=R.buildVerbLookup(n),o=R.buildMarkerToRoleLookup(n),s=[],a=0;for(;a<e.length;){let l=-1,u="";for(let m=a;m<e.length;m++){let v=e[m],S=i.get(v.value.toLowerCase()),T=v.normalized?i.get(v.normalized.toLowerCase()):void 0,A=S||T;if(A){l=m,u=A;break}}if(l===-1)break;let c=e.slice(a,l),p=e.length;for(let m=l+1;m<e.length;m++){let v=e[m];if(v.kind==="conjunction"||this.isThenKeyword(v.value,t)){p=m;break}if(m>l+1&&(i.get(v.value.toLowerCase())||(v.normalized?i.get(v.normalized.toLowerCase()):void 0))){p=m;break}}let d=e.slice(l+1,p),f=this.extractRolesFromMarkedTokens(c,d,o,u,t);if(s.push(X(u,f,{sourceLanguage:t,confidence:.7})),a=p,a<e.length){let m=e[a];(m.kind==="conjunction"||this.isThenKeyword(m.value,t))&&a++;}}return s}extractRolesFromMarkedTokens(e,t,n,i,o){let s={},a=l=>{let u=[];for(let c of l){let p=n.get(c.value);if(p&&c.kind==="particle"&&u.length>0){let d=this.tokensToSemanticValue(u);if(d){let f=this.mapRoleForCommand(p,i,s);f&&(s[f]=d);}u=[];}else u.push(c);}if(u.length>0){let c=this.tokensToSemanticValue(u);c&&(s.patient?s.destination||(s.destination=c):s.patient=c);}};return a(e),a(t),s}mapRoleForCommand(e,t,n){return n[e]?e==="patient"&&!n.destination?"destination":e==="destination"&&!n.patient?"patient":e==="source"&&!n.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let t=e.filter(o=>o.kind!=="whitespace");if(t.length===0)return null;if(t.length===1)return this.tokenToSemanticValue(t[0]);let n=t.map(o=>o.value).join(""),i=t[0];return i.kind==="selector"||i.value.startsWith("#")||i.value.startsWith(".")||i.value.startsWith("@")||i.value.startsWith("*")?j(n):i.kind==="literal"||i.value.startsWith('"')||i.value.startsWith("'")?b(n):i.kind==="reference"?N(n):b(n)}tokenToSemanticValue(e){let t=e.value;if(e.kind==="selector"||t.startsWith("#")||t.startsWith(".")||t.startsWith("@")||t.startsWith("*"))return j(t);if(t.startsWith('"')||t.startsWith("'"))return b(t);if(/^-?\d+(\.\d+)?$/.test(t))return b(parseFloat(t));if(t==="true"||t==="\u771F"||t==="\uCC38"||t==="do\u011Fru")return b(true);if(t==="false"||t==="\u507D"||t==="\uAC70\uC9D3"||t==="yanl\u0131\u015F")return b(false);let n=e.normalized?.toLowerCase();return n==="me"||n==="it"||n==="you"||n==="result"||n==="body"?N(n):e.kind==="reference"?N(e.normalized||"me"):b(t)}parseBodyWithGrammarPatterns(e,t,n,i){let o=[];for(;!e.isAtEnd();){let s=e.peek();if(s&&this.isThenKeyword(s.value,i)){e.advance();continue}if(s&&this.isEndKeyword(s.value,i)){e.advance();break}let a=false;if(n.length>0){let l=L.matchBest(e,n);if(l){let u=l.pattern.command,c={};for(let[f,m]of l.captured)f!=="event"&&f!=="action"&&f!=="continues"&&(c[f]=m);let p=X(u,c,{sourceLanguage:i,patternId:l.pattern.id});o.push(p),a=true;let d=l.captured.get("continues");if(d&&d.type==="literal"&&d.value==="then")continue}}if(!a){let l=L.matchBest(e,t);l&&(o.push(this.buildCommand(l,i)),a=true);}a||e.advance();}return o}tryCompoundCommandParsing(e,t,n){let i=e.tokens;if(!i.some(l=>l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,n)))return null;let s=new oe(i,n),a=this.parseBodyWithClauses(s,t,n);return a.length===0?null:a.length===1?a[0]:Ie(a,"then",{sourceLanguage:n,confidence:.65})}trySOVEventExtraction(e,t,n){let i=R.SOV_EVENT_MARKERS[t];if(!i)return null;let s=se(e,t).tokens,a=tr[t],l=new Set;if(a)for(let y of Object.keys(a))l.add(y.toLowerCase());let u=R.SOV_SOURCE_MARKERS[t],c=-1,p="",d="",f=1;for(let y=0;y<s.length;y++){let k=s[y],P=k.value.toLowerCase(),_=P,I="",ee=P.indexOf("[");ee>0&&(_=P.slice(0,ee),I=k.value.slice(ee));let te=k.normalized?.toLowerCase(),ye=te&&R.KNOWN_EVENTS.has(te),ge=l.has(P)||l.has(_),lt=R.KNOWN_EVENTS.has(_);if(ye||ge||lt){let F;if(ye?F=te:ge?F=a?.[P]??a?.[_]??_:F=_,i.size>0){let K=1,re=s[y+1];re&&re.kind==="selector"&&re.value.startsWith("[")&&(K=2);let Y=s[y+K];if(Y&&(Y.kind==="particle"||Y.kind==="keyword")&&i.has(Y.value)){c=y,p=F,d=I||(K===2?s[y+1].value:""),f=K+1;break}}else {c=y,p=F,d=I,f=1;break}}}if(c===-1)return null;let m=new Set;for(let y=c;y<c+f;y++)m.add(y);if(u){let y=c+f;if(y<s.length){let k=s[y];(k.kind==="particle"||k.kind==="keyword")&&u.markers.has(k.value)&&m.add(y);}for(let k=0;k<c;k++){let P=s[k],_=P.value.toLowerCase(),I=P.normalized?.toLowerCase();if(u.windowTokens.has(_)||I&&u.windowTokens.has(I)){m.add(k);break}}}let v=s.filter((y,k)=>!m.has(k));if(v.length===0)return null;let S=n.filter(y=>y.command!=="on"),T=new oe(v,t),A=this.parseBodyWithClauses(T,S,t);if(A.length===0)return null;let ve={sourceLanguage:t,confidence:.75};return d&&(ve.keyFilter=d),Oe({type:"literal",value:p},A,void 0,ve)}isThenKeyword(e,t){let n={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (n[t]||n.en).has(e.toLowerCase())}isEndKeyword(e,t){let n={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return (n[t]||n.en).has(e.toLowerCase())}extractStandaloneModifiers(e,t){let i=se(e,t).tokens;if(i.length===0)return {modifiers:null,remainingInput:null};let s=i[0].value.toLowerCase(),a=R.STANDALONE_MODIFIERS[s];if(!a)return {modifiers:null,remainingInput:null};let l={},u=1;if(a==="once")l.once=true;else {let f=1;if(f<i.length){let m=i[f];(m.kind==="keyword"||m.kind==="particle")&&(f++,u++);}if(f<i.length){let m=i[f];if(m.kind==="literal"){let v=m.value.match(/^(\d+)(ms|s|m)?$/);if(v){let S=parseInt(v[1],10),T=v[2]||"ms";T==="s"?S*=1e3:T==="m"&&(S*=6e4),l[a]=S,u=f+1;}}}l[a]||(l[a]=a==="debounce"?300:100);}let c=i.slice(u);if(c.length===0)return {modifiers:null,remainingInput:null};let p=c[0].position.start,d=e.slice(p);return {modifiers:l,remainingInput:d}}applyModifiers(e,t){return {...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let n=[];for(;;){let i=e.mark(),o=e.peek();if(!o)break;let s=(o.normalized||o.value).toLowerCase();if(!R.OR_KEYWORDS.has(s)){e.reset(i);break}e.advance();let a=e.peek();if(!a){e.reset(i);break}let l=(a.normalized||a.value).toLowerCase();e.advance(),n.push({type:"literal",value:l});}return n}};V.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);V.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"])};V.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])}};V.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};V.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o"]);var nr=V,ir=new nr;function pe(r,e){return ir.parse(r,e)}var ce=class{constructor(r={}){this.cache=new Map,this.config={maxSize:r.maxSize??1e3,ttlMs:r.ttlMs??0,enabled:r.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(r,e){return `${e}:${r}`}isExpired(r){return this.config.ttlMs===0?false:Date.now()-r.createdAt>this.config.ttlMs}evictLRU(){let r=this.cache.keys().next().value;r!==void 0&&(this.cache.delete(r),this.stats.evictions++);}get(r,e){if(!this.config.enabled){this.stats.misses++;return}let t=this.makeKey(r,e),n=this.cache.get(t);if(!n){this.stats.misses++;return}if(this.isExpired(n)){this.cache.delete(t),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(t),n.lastAccessed=Date.now(),this.cache.set(t,n),this.stats.hits++,n.result}set(r,e,t){if(!this.config.enabled||t.confidence===0)return;let n=this.makeKey(r,e),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(n,{result:t,createdAt:i,lastAccessed:i});}has(r,e){if(!this.config.enabled)return false;let t=this.makeKey(r,e),n=this.cache.get(t);return n?this.isExpired(n)?(this.cache.delete(t),this.stats.expirations++,false):true:false}delete(r,e){let t=this.makeKey(r,e);return this.cache.delete(t)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let r=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:r>0?this.stats.hits/r:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(r){if(r.maxSize!==void 0)for(this.config.maxSize=r.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();r.ttlMs!==void 0&&(this.config.ttlMs=r.ttlMs),r.enabled!==void 0&&(this.config.enabled=r.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}},or=new ce;var sr=class{constructor(r={}){this.patternMatcher=new He,this.languages=new Set(Ue()),r.cache===false?this.cache=new ce({enabled:false}):this.cache=r.cache?new ce(r.cache):or;}analyze(r,e){if(!this.supportsLanguage(e))return {confidence:0,errors:[`Language '${e}' is not supported for semantic parsing`]};let t=this.cache.get(r,e);if(t)return t;let n=this.analyzeUncached(r,e);return this.cache.set(r,e,n),n}analyzeUncached(r,e){try{try{let s=pe(r,e),a={confidence:s.metadata?.confidence??.8,node:s};return s.kind==="command"?{...a,command:{name:s.action,roles:s.roles}}:a}catch{}let t=er(e);if(!t)return {confidence:0,errors:[`No tokenizer available for language '${e}'`]};let n=t.tokenize(r),i=z(e);if(i.length===0)return {confidence:0,errors:[`No patterns available for language '${e}'`]};let o=this.patternMatcher.matchBest(n,i);if(o){let s=this.buildSemanticNode(o);return {confidence:o.confidence,command:{name:o.pattern.command,roles:o.captured},node:s,tokensConsumed:o.consumedTokens}}return {confidence:0,errors:["No pattern matched the input"]}}catch(t){return {confidence:0,errors:[t instanceof Error?t.message:String(t)]}}}supportsLanguage(r){return this.languages.has(r)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear();}configureCache(r){this.cache.configure(r);}buildSemanticNode(r){return {kind:"command",action:r.pattern.command,roles:r.captured,metadata:{patternId:r.pattern.id}}}};function Ye(r){return new sr(r)}var ar=.5;function Xe(r,e=ar){return r.confidence>=e&&r.command!==void 0}var lr={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},cr={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},ur={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},pr={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"}}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},dr={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},fr={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},mr={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},hr={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},vr={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},yr={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},gr={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},Er={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},Tr={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},br={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Sr={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},kr={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},wr={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},Cr={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Ar={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},xr={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Rr={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Pr={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},_r={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"-e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"-man",sw:"kwa"}}]},Nr={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Or={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Ir={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Mr={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},Lr={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in"}}]},zr={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Dr={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Br={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""}}]},$r={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"auf",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},qr={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},Vr={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Fr={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Wr={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},jr={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},Gr={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Ur={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Hr={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}}]},Kr={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man"}}]},Yr={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Xr={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Qr={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Zr={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Jr={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with"}}]},en={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"destination",roles:[{role:"destination",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"patient",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},tn={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:false,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},rn={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},nn={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},on={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},sn={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},an={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},Qe={toggle:lr,add:cr,remove:ur,put:pr,set:dr,show:fr,hide:mr,on:hr,trigger:vr,wait:yr,fetch:gr,increment:Er,decrement:Tr,append:br,prepend:Sr,log:kr,get:wr,take:Cr,make:Ar,halt:xr,settle:Rr,throw:Pr,send:_r,if:Nr,unless:Or,else:Ir,repeat:Mr,for:Lr,while:zr,continue:Dr,go:Br,transition:$r,clone:qr,focus:Vr,blur:Fr,call:Wr,return:jr,js:Gr,async:Ur,tell:Hr,default:Kr,init:Yr,behavior:Xr,install:Qr,measure:Zr,swap:Jr,morph:en,beep:tn,break:rn,copy:nn,exit:on,pick:sn,render:an,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function ln(){return Object.values(Qe).filter(r=>r.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Gt(),Ve)).then(({validateAllSchemas:r,formatValidationResults:e})=>{let t=r(Qe);t.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(t)),console.warn(`
3
- These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(r=>{console.debug("Schema validation skipped:",r);});function Ze(r,e){let t=e==="SOV"?"sovPosition":"svoPosition";return [...r].sort((n,i)=>{let o=n[t]??99,s=i[t]??99;return o-s})}function cn(r,e){let t=r.markerOverride?.[e.code],n=e.roleMarkers[r.role];if(t!==void 0)return {primary:t,position:n?.position??"before",isOverride:true};if(n&&n.primary){let i={primary:n.primary,position:n.position,isOverride:false};return n.alternatives&&(i.alternatives=n.alternatives),i}return null}function un(r,e,t,n,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let u=n.primary.split(/\s+/);if(u.length>1)for(let c of u)o.push({type:"literal",value:c});else {let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(c);}}let s=e.roleMarkers.destination;s&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.patient;if(a){let u=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};o.push(u);}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(l),{id:`${r.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`{event} ${n.primary} {destination?} {patient} ${a?.primary||""} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function pn(r,e,t,n,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let l=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(l);}if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let l=n.primary.split(/\s+/);if(l.length>1)for(let u of l)o.push({type:"literal",value:u});else {let u=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(u);}}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${r.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${n.primary} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function dn(r,e,t,n,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(u);}let a=e.roleMarkers.destination;if(a&&(o.push({type:"role",role:"destination",optional:false}),o.push(a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary})),o.push({type:"role",role:"event",optional:false}),n.position==="after"){let u=n.primary.split(/\s+/);if(u.length>1)for(let c of u)o.push({type:"literal",value:c});else {let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(c);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(l),{id:`${r.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`{patient} ${s?.primary||""} {destination} ${a?.primary||""} {event} ${n.primary} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function fn(r,e,t,n,i){let o=[];o.push({type:"role",role:"event",optional:false});let s=n.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];s.length>0&&o.push({type:"literal",value:s[0],alternatives:s.slice(1)});let a=e.roleMarkers.destination;a&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary}]}),o.push({type:"role",role:"patient",optional:false});let l=e.roleMarkers.patient;if(l){let c=l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary};o.push(c);}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(u),{id:`${r.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(i.basePriority??100)+52,template:{format:`{event}${s[0]||""} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function mn(r,e,t,n,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let a=n.primary.split(/\s+/);if(a.length>1)for(let l of a)o.push({type:"literal",value:l});else {let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(s),{id:`${r.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{event} ${n.primary} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function hn(r,e,t,n){let i=e.eventHandler?.temporalMarkers;if(!i||i.length===0)return null;let o=[];o.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&o.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),o.push({type:"literal",value:i[0],alternatives:i.slice(1)}),o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s?.primary){let l=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(l);}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${r.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(n.basePriority??100)+49,template:{format:`{event} ${i[0]} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function vn(r,e,t,n,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let c=n.primary.split(/\s+/);if(c.length>1)for(let p of c)o.push({type:"literal",value:p});else {let p=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(p);}}let a=[...r.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.sovPosition??999,f=p.sovPosition??999;return d-f});for(let c of a){o.push({type:"role",role:c.role,optional:false});let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(l);let u=a.map(c=>`{${c.role}}`).join(" ");return {id:`${r.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`{event} ${n.primary} ${u} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(a.map(c=>[c.role,{fromRole:c.role}]))}}}function yn(r,e,t,n,i){let o=[],a=[...r.roles.filter(m=>m.required)].sort((m,v)=>{let S=m.sovPosition??999,T=v.sovPosition??999;return S-T}),l=a[0];o.push({type:"role",role:l.role,optional:false});let u;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)u=l.markerOverride[e.code];else {let m=e.roleMarkers[l.role];m&&(u=m.primary);}if(u&&o.push({type:"literal",value:u}),o.push({type:"role",role:"event",optional:false}),n.position==="after"){let m=n.primary.split(/\s+/);if(m.length>1)for(let v of m)o.push({type:"literal",value:v});else {let v=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(v);}}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(c);let p=a[1];o.push({type:"role",role:p.role,optional:false});let d,f;if(p.markerOverride&&p.markerOverride[e.code]!==void 0)d=p.markerOverride[e.code];else {let m=e.roleMarkers[p.role];m&&(d=m.primary,f=m.alternatives);}if(d){let m=f?{type:"literal",value:d,alternatives:f}:{type:"literal",value:d};o.push(m);}return {id:`${r.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{${l.role}} {event} ${n.primary} ${t.primary} {${p.role}}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},[l.role]:{fromRole:l.role},[p.role]:{fromRole:p.role}}}}function ze(r,e,t,n,i){let o=[];if(n.position==="before"){let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;return a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),{id:`${r.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`${n.primary} {event} ${t.primary} {patient} ${a?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function gn(r,e,t,n,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;if(a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),n.position==="before"){let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}return o.push({type:"role",role:"event",optional:false}),{id:`${r.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`${t.primary} {patient} ${a?.primary||""} {destination?} ${n.primary} {event}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function En(r,e,t,n,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let l=[...r.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.svoPosition??999,f=p.svoPosition??999;return d-f});for(let c of l){let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:c.role,optional:false});}if(n.position==="before"){let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(c);}o.push({type:"role",role:"event",optional:false});let u=l.map(c=>`{${c.role}}`).join(" ");return {id:`${r.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${t.primary} ${u} ${n.primary} {event}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(l.map(c=>[c.role,{fromRole:c.role}]))}}}function De(r,e,t,n,i){let o=[];if(n.position==="before"){let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(c);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let l=[...r.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.svoPosition??999,f=p.svoPosition??999;return d-f});for(let c of l){let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:c.role,optional:false});}let u=l.map(c=>`{${c.role}}`).join(" ");return {id:`${r.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`${n.primary} {event} ${t.primary} ${u}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(l.map(c=>[c.role,{fromRole:c.role}]))}}}function Tn(r,e,t,n,i){let o=[],s=e.eventHandler?.negationMarker;if(n.position==="before"){let u=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(u);}if(s){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(u);}o.push({type:"role",role:"event",optional:false});let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(a),o.push({type:"role",role:"patient",optional:false});let l=e.roleMarkers.destination;return l&&o.push({type:"group",optional:true,tokens:[l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary},{type:"role",role:"destination",optional:true}]}),{id:`${r.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${n.primary} ${s?.primary||""} {event} ${t.primary} {patient} ${l?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function bn(r,e,t,n){let i=[];i.push({type:"literal",value:"and",alternatives:["then"]}),i.push({type:"role",role:"event",optional:false});let o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(o),i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&i.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${r.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`[proclitic?] {event} ${t.primary} {patient} ${s?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var G={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Je(r,e,t=G){let n=`${r.action}-${e.code}-generated`,i=t.basePriority??100,o=e.keywords[r.action];if(!o)throw new Error(`No keyword translation for '${r.action}' in ${e.code}`);let s=Cn(r,e,o),a=tt(r,e),l=Pn(r,e,o);return {id:n,language:e.code,command:r.action,priority:i,template:{format:l,tokens:s},extraction:a}}function Sn(r,e,t=G){if(r.roles.filter(a=>!a.required).length===0)return null;let i=r.roles.filter(a=>a.required),o={...r,roles:i};return {...Je(o,e,t),id:`${r.action}-${e.code}-simple`,priority:(t.basePriority??100)-5,extraction:tt(r,e)}}function kn(r,e,t=G){let n=[];if(n.push(Je(r,e,t)),t.generateSimpleVariants){let i=Sn(r,e,t);i&&n.push(i);}return n}function et(r,e=G){let t=[],n=ln();for(let i of n){if(!r.keywords[i.action])continue;let o=kn(i,r,e);if(t.push(...o),r.eventHandler?.eventMarker){let s=wn(i,r,e);t.push(...s);}}return t}function wn(r,e,t=G){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let n=[],i=e.eventHandler.eventMarker,o=e.keywords[r.action];if(!o)return [];let a=r.roles.filter(l=>l.required).length===2;if(e.wordOrder==="SOV")if(a)n.push(vn(r,e,o,i,t)),n.push(yn(r,e,o,i,t));else {n.push(un(r,e,o,i,t)),n.push(pn(r,e,o,i,t));let l=e.roleMarkers.destination;l&&l.primary!==i.primary&&n.push(dn(r,e,o,i,t));let u=i.primary.split(/\s+/),c=i.alternatives?.some(d=>!d.includes(" ")&&d.length>1);u.length>1&&c&&n.push(fn(r,e,o,i,t)),n.push(mn(r,e,o,i,t));let p=hn(r,e,o,t);p&&n.push(p);}else e.wordOrder==="VSO"?a?(n.push(De(r,e,o,i,t)),n.push(En(r,e,o,i,t))):(n.push(ze(r,e,o,i,t)),n.push(gn(r,e,o,i,t)),e.eventHandler?.negationMarker&&n.push(Tn(r,e,o,i,t)),e.tokenization?.prefixes&&n.push(bn(r,e,o,t))):a?n.push(De(r,e,o,i,t)):n.push(ze(r,e,o,i,t));return n}function Cn(r,e,t){let n=[],i=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},o=An(r,e);switch(e.wordOrder){case "SVO":n.push(i),n.push(...o);break;case "SOV":n.push(...o),n.push(i);break;case "VSO":n.push(i),n.push(...o);break;default:n.push(i),n.push(...o);}return n}function An(r,e){let t=[],n=Ze(r.roles,e.wordOrder);for(let i of n){let o=xn(i,e);i.required?t.push(...o):t.push({type:"group",optional:true,tokens:o});}return t}function xn(r,e){let t=[],n=r.markerOverride?.[e.code],i=e.roleMarkers[r.role],o={type:"role",role:r.role,optional:!r.required,expectedTypes:r.expectedTypes};if(n!==void 0)(i?.position??"before")==="before"?(n&&t.push({type:"literal",value:n}),t.push(o)):(t.push(o),n&&t.push({type:"literal",value:n}));else if(i)if(i.position==="before"){if(i.primary){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}t.push(o);}else {t.push(o);let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}else t.push(o);return t}function Rn(r,e){let t={};for(let n of r.roles){let i=n.markerOverride?.[e.code],o=e.roleMarkers[n.role];i!==void 0?t[n.role]=i?{marker:i}:{}:o&&o.primary?t[n.role]=o.alternatives?{marker:o.primary,markerAlternatives:o.alternatives}:{marker:o.primary}:t[n.role]={};}return t}function tt(r,e){let t=Rn(r,e),n={};for(let i of r.roles){let o=t[i.role]||{};!i.required&&i.default?n[i.role]={...o,default:i.default}:n[i.role]=o;}return n}function Pn(r,e,t){let n=[],o=Ze(r.roles,e.wordOrder).map(s=>{let a=cn(s,e),l="";return a&&a.primary?a.position==="before"?l=`${a.primary} {${s.role}}`:l=`{${s.role}} ${a.primary}`:l=`{${s.role}}`,s.required?l:`[${l}]`});switch(e.wordOrder){case "SVO":case "VSO":n.push(t.primary,...o);break;case "SOV":n.push(...o,t.primary);break;default:n.push(t.primary,...o);}return n.join(" ")}function J(r){let e=r.getAttribute("data-lang");if(e)return de(e);let t=r.getAttribute("data-hyperscript-lang")??r.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return de(t);let n=typeof document<"u"?document.documentElement?.lang:null;return n&&n!=="en"?de(n):null}function de(r){return r.split("-")[0].toLowerCase()}var rt={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],blur:[["patient",""]],break:[],call:[["patient",""]],clone:[["patient",""],["destination","into"]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","to"]],on:[["event",""],["source","from"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],return:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["patient",""]],while:[["condition",""]]};function H(r){switch(r.kind){case "event-handler":return _n(r);case "compound":return Nn(r);default:return On(r)}}function _n(r){let e=["on"],t=r.roles.get("event");t&&e.push(U(t));let n=r.roles.get("source");if(n&&e.push("from",U(n)),r.body&&r.body.length>0){let i=r.body.map(H);e.push(i.join(" then "));}return e.join(" ")}function Nn(r){let e=r.chainType==="async"?"async":r.chainType;return r.statements.map(H).join(` ${e} `)}function On(r){let e=rt[r.action];if(e){let n=[r.action];for(let[i,o]of e){let s=r.roles.get(i);s&&(i==="destination"&&s.type==="reference"&&s.value==="me"||(o&&n.push(o),n.push(U(s))));}return n.join(" ")}let t=[r.action];for(let[,n]of r.roles)t.push(U(n));return t.join(" ")}function U(r){switch(r.type){case "literal":return typeof r.value=="string"&&r.dataType==="string"?`"${r.value}"`:String(r.value);case "selector":return r.value;case "reference":return r.value;case "property-path":return In(r);case "expression":return r.raw}}function In(r){let e=U(r.object),t=r.property;if(r.object.type==="reference")switch(r.object.value){case "me":return `my ${t}`;case "it":return `its ${t}`;case "you":return `your ${t}`}return `${e}'s ${t}`}var it=.5,Mn={confidenceThreshold:it,strategy:"semantic",fallbackToOriginal:true};function Ln(r,e){return typeof r=="number"?r:r[e]??r["*"]??it}var fe=null;function zn(){return fe||(fe=Ye()),fe}function me(r,e,t={}){let n={...Mn,...t},i=nt(r,e,n);if(i!==null)return i;let o=Bn(r);if(o){let s=nt(o.commands,e,n);if(s!==null)return o.prefix+s}return r}function nt(r,e,t){if(t.strategy==="semantic"||t.strategy==="auto"){let n=Ln(t.confidenceThreshold,e),i=ot(r,e,n);if(i!==null)return i}if((t.strategy==="auto"||t.strategy==="i18n")&&t.i18nToEnglish){let n=$n(r,e,t.i18nToEnglish);if(n!==null)return n}return null}var Dn=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Bn(r){let e=r.match(Dn);if(!e)return null;let t=e[1],n=r.slice(t.length);return n?{prefix:t,commands:n}:null}function ot(r,e,t){try{let n=Vn(r,e);if(n.length>1)return Fn(n,e,t);let i=zn();if(!i.supportsLanguage(e))return null;let o=i.analyze(r,e);if(!Xe(o,t))return null;if(o.node)return H(o.node);let s=pe(r,e);return H(s)}catch{return null}}function $n(r,e,t){try{let n=t(r,e);return n!==r?n:null}catch{return null}}function qn(r){let e=["then"],t=O(r);if(t?.keywords?.then){let n=t.keywords.then;if(n.primary&&n.primary!=="then"&&e.push(n.primary),n.alternatives)for(let i of n.alternatives)e.includes(i)||e.push(i);}return e}function Vn(r,e){let n=qn(e).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\s+(?:${n.join("|")})\\s+`,"i"),o=r.split(`
4
- `).map(a=>a.trim()).filter(a=>a.length>0),s=[];for(let a of o){let l=a.split(i);s.push(...l);}return s}function Fn(r,e,t){let n=[];for(let i of r){let o=ot(i.trim(),e,t);if(o===null)return null;n.push(o);}return n.join(" then ")}function he(r={}){return function(t){let{internals:n}=t,i=n.runtime,o=i.getScript.bind(i);i.getScript=function(s){let a=o(s);if(!a)return null;let l=Wn(s,r);if(!l||l==="en")return a;let u=me(a,l,r);return r.debug&&u!==a&&console.log(`[hyperscript-i18n] ${l}: "${a}" \u2192 "${u}"`),u};}}function Wn(r,e){if(e.languageAttribute){let n=r.getAttribute(e.languageAttribute);if(n)return n.split("-")[0].toLowerCase()}let t=J(r);return t||(e.defaultLanguage??null)}function st(r,e,t={}){return e==="en"?r:me(r,e,t)}Ge(r=>et(r));function at(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(he()),jn());}function jn(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let t=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(t).forEach(n=>{let i=e.getInternalData(n);i.initialized&&(i.initialized=false);}),e.processNode(document.body);}var yi=["es"];at();exports.plugin=he;exports.preprocess=st;exports.resolveLanguage=J;exports.supportedLanguages=yi;return exports;})({});
1
+ var HyperscriptI18n=(function(exports){'use strict';function P(n,e){return e?{type:"literal",value:n,dataType:e}:{type:"literal",value:n}}function fe(n,e){return e?{type:"selector",value:n,selectorKind:e}:{type:"selector",value:n}}function ie(n){return {type:"reference",value:n}}function me(n,e){return {type:"property-path",object:n,property:e}}var At=class{constructor(n){this.namespace=n,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let n=process.env.DEBUG||"";return n==="*"||n.includes("framework:*")||n.includes(`framework:${this.namespace}`)}return false}log(n,e,...t){if(!this.enabled)return;let r=`[framework:${this.namespace}]`,i=new Date().toISOString();switch(n){case "debug":console.debug(`${i} ${r} DEBUG:`,e,...t);break;case "info":console.info(`${i} ${r} INFO:`,e,...t);break;case "warn":console.warn(`${i} ${r} WARN:`,e,...t);break;case "error":console.error(`${i} ${r} ERROR:`,e,...t);break}}debug(n,...e){this.log("debug",n,...e);}info(n,...e){this.log("info",n,...e);}warn(n,...e){this.log("warn",n,...e);}error(n,...e){this.log("error",n,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function Rt(n){return new At(n)}function V(n,e){return !e||e.length===0||e.includes(n)||e.includes("expression")?true:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function Pt(n,e){return n?.possessive?.keywords?.[e]}var Y=class B{constructor(){this.logger=Rt("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,t,r){let i=e.mark(),o=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",t.id),this.logger.debug("Pattern command:",t.command),this.logger.debug("Pattern language:",t.language),this.logger.debug("Pattern template:",JSON.stringify(t.template,null,2)),this.logger.isEnabled()){let c=[];for(let u=0;u<10;u++){let l=e.peek(u);if(l)c.push({type:l.type,value:l.value,kind:l.kind});else break}this.logger.debug("Input tokens (first 10):",c),this.logger.debug("Profile code:",r?.code);}this.currentProfile=r,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(t.template.tokens,null,2));let s=this.matchTokenSequence(e,t.template.tokens,o);if(this.logger.debug("matchTokenSequence returned:",s),this.logger.debug("Captured roles:",Array.from(o.entries()).map(([c,u])=>[c,JSON.stringify(u)])),!s)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(i),null;let a=this.calculateConfidence(t,o);return this.applyExtractionRules(t,o),{pattern:t,captured:o,consumedTokens:e.position()-i.position,confidence:a}}matchBest(e,t,r){let i=[];for(let s of t){let a=e.mark(),c=this.matchPattern(e,s,r);c&&i.push(c),e.reset(a);}if(i.length===0)return null;i.sort((s,a)=>{let c=a.pattern.priority-s.pattern.priority;if(c!==0)return c;let u=a.confidence-s.confidence;return Math.abs(u)>.001?u:a.consumedTokens-s.consumedTokens});let o=i[0];return this.matchPattern(e,o.pattern),o}matchTokenSequence(e,t,r,i){let o=t[0],s=o?.type==="literal"&&(o.value==="and"||o.value==="then"||o.alternatives?.includes("and")||o.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!s)for(;e.peek()?.kind==="conjunction";)e.advance();let a=null,c=null;for(let u=0;u<t.length;u++){let l=t[u];this.logger.debug(" >> Matching pattern token:",JSON.stringify(l,null,2));let d=e.peek();if(this.logger.debug(" >> Current input token:",d?JSON.stringify({type:d.type,value:d.value,kind:d.kind}):"EOF"),l.type==="role"&&l.greedy){let y=this.collectStopMarkers(t,u+1);if(i)for(let E of i)y.add(E);let v=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||this.isStopMarker(E,y))break;v.push(E.value),e.advance();}if(v.length>0){r.set(l.role,{type:"expression",raw:v.join(" ")}),a=null,c=null;continue}else {if(l.optional)continue;return false}}if(l.type==="group"){let y=this.collectStopMarkers(t,u+1);if(i)for(let E of i)y.add(E);if(this.matchGroupToken(e,l,r,y)){a=null,c=null;continue}if(this.isOptional(l))continue;return false}let p=l.type==="role"&&l.optional===true,f=p?e.mark():null;if(l.type==="role"&&!p){let y=u+1<t.length?t[u+1]:null;if(y?.type==="literal"){let v=e.peek();if(v&&this.getMatchType(v,y.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(l))continue;if(a&&c){this.logger.debug(" >> BACKTRACKING: undoing optional role",c),e.reset(a),r.delete(c),a=null,c=null;let E=this.matchPatternToken(e,l,r);if(this.logger.debug(" >> Backtrack retry result:",E),E)continue}return false}}}let g=this.matchPatternToken(e,l,r);if(this.logger.debug(" >> Match result:",g),g){p?(a=f,c=l.role):(a=null,c=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(l)){if(a&&c){this.logger.debug(" >> BACKTRACKING: undoing optional role",c),e.reset(a),r.delete(c),a=null,c=null;let y=this.matchPatternToken(e,l,r);if(this.logger.debug(" >> Backtrack retry result:",y),y)continue}return false}}return true}matchPatternToken(e,t,r){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,r);case "group":return this.matchGroupToken(e,t,r);default:return false}}matchLiteralToken(e,t){let r=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",t.value),this.logger.debug(" >>> matchLiteralToken: got token",r?JSON.stringify({type:r.type,value:r.value,kind:r.kind}):"null"),!r)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let i=this.getMatchType(r,t.value);if(this.logger.debug(" >>> matchType for",r.value,"vs",t.value,":",i),i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let o of t.alternatives){let s=this.getMatchType(r,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,r){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",t.role),this.logger.debug(" >>> matchRoleToken: expected types",t.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",t.optional),this.skipNoiseWords(e);let i=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null"),!i)return t.optional||false;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!V(o.type,t.expectedTypes)?t.optional||false:(r.set(t.role,o),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!V(s.type,t.expectedTypes)?t.optional||false:(r.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!V(a.type,t.expectedTypes)?t.optional||false:(r.set(t.role,a),true);let c=this.tryMatchPropertyAccessExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!V(c.type,t.expectedTypes)?t.optional||false:(r.set(t.role,c),true);let u=this.tryMatchSelectorPropertyExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!V(u.type,t.expectedTypes)?t.optional||false:(r.set(t.role,u),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null");let l=this.tokenToSemanticValue(i);return this.logger.debug(" >>> tokenToSemanticValue returned:",l?JSON.stringify(l):"null"),l?(this.logger.debug(" >>> Validating type:",l.type,"against expected:",t.expectedTypes),t.expectedTypes&&t.expectedTypes.length>0&&!V(l.type,t.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",t.optional||false),t.optional||false):(this.logger.debug(" >>> Type validation PASSED"),r.set(t.role,l),e.advance(),true)):t.optional||false}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=t.normalized||t.value,i=this.safeToLowerCase(r),o=Pt(this.currentProfile,i);if(!o)return null;let s=e.mark();e.advance();let a=e.peek();if(!a)return e.reset(s),null;if(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*")||a.kind==="selector"&&a.value.startsWith("@")||a.kind==="selector"&&a.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a.value)){e.advance();let c=a.value;a.kind==="selector"&&c.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(c)&&(c=c.substring(1));let u=c;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)u+=e.peek().value,e.advance();let l=e.peek();return l?.kind==="literal"&&l.value.startsWith("(")&&(u+=l.value,e.advance()),me(ie(o),u)}return e.reset(s),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(r),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<B.MAX_METHOD_ARGS;){let u=e.peek();if(!u)break;if(u.kind==="punctuation"&&u.value===")"){e.advance();break}if(u.kind==="punctuation"&&u.value===","){e.advance();continue}a.push(u.value),e.advance();}return {type:"expression",raw:`${t.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=`${t.value}.${o.value}`,a=1;for(;!e.isAtEnd()&&a<B.MAX_PROPERTY_DEPTH;){let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")break;e.advance();let l=e.peek();if(!l||l.kind!=="identifier")break;e.advance(),s+=`.${l.value}`,a++;}let c=e.peek();if(c&&c.kind==="punctuation"&&c.value==="("){e.advance();let u=[],l=0;for(;!e.isAtEnd()&&u.length<B.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(l===0){e.advance();break}l--;}if(p.kind==="punctuation"&&p.value==="("&&l++,p.kind==="punctuation"&&p.value===","){e.advance();continue}u.push(p.value),e.advance();}return {type:"expression",raw:`${s}(${u.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(r),null;e.advance();let o=e.peek();return !o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(r),null):(e.advance(),me(fe(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||typeof t.value!="string"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(r),null;let o=e.peek(1);o&&o.kind,e.advance();let s=i.value.slice(1);return me(fe(t.value),s)}matchGroupToken(e,t,r,i){let o=e.mark(),s=new Set(r.keys());if(this.matchTokenSequence(e,t.tokens,r,i))return true;e.reset(o);for(let u of r.keys())s.has(u)||r.delete(u);if(!t.optional)return false;let c=this.getGroupLeadingMarker(t);if(c)for(let u=1;u<=B.MAX_MARKER_SCAN;u++){let l=e.peek(u);if(!l)break;if((l.normalized||l.value).toLowerCase()===c){this.logger.debug(" >> MARKER SCAN: found",c,"at offset",u,"- skipping intervening tokens");for(let f=0;f<u;f++)e.advance();if(this.matchTokenSequence(e,t.tokens,r,i))return true;e.reset(o);for(let f of r.keys())s.has(f)||r.delete(f);break}}return true}getGroupLeadingMarker(e){let t=e.tokens[0];return t?.type==="literal"?t.value.toLowerCase():null}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===t.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,t){let r=new Set;for(let i=t;i<e.length;i++){let o=e[i];if(o.type==="literal"){if(r.add(o.value.toLowerCase()),o.alternatives)for(let s of o.alternatives)r.add(s.toLowerCase());break}if(o.type==="group"){for(let s of o.tokens)if(s.type==="literal"){if(r.add(s.value.toLowerCase()),s.alternatives)for(let a of s.alternatives)r.add(a.toLowerCase());break}if(!o.optional)break}}return r}isStopMarker(e,t){return t.size===0?false:!!(t.has(e.value.toLowerCase())||e.normalized&&t.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return fe(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=e.normalized||e.value;this.safeToLowerCase(t);return P(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return ie(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return P(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return P(i,"string")}if(e==="true")return P(true,"boolean");if(e==="false")return P(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?P(e,"duration"):P(i,"number")}let r=parseFloat(e);return isNaN(r)?P(e,"string"):P(r,"number")}applyExtractionRules(e,t){for(let[r,i]of Object.entries(e.extraction))t.has(r)||(i.value!==void 0?t.set(r,{type:"literal",value:i.value}):i.default&&t.set(r,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,t){let r=0,i=0,o=u=>e.extraction?.[u]?.default!==void 0;for(let u of e.template.tokens)if(u.type==="role")i+=1,t.has(u.role)&&(r+=1);else if(u.type==="group"){for(let l of u.tokens)if(l.type==="role"){let d=o(l.role),p=.8;i+=p,t.has(l.role)?r+=p:d&&(r+=p*.6);}}let s=i>0?r/i:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let u=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-u);}let a=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+a);let c=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+c)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let r=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(r.has(t.value))return .15;if(t.alternatives){for(let i of t.alternatives)if(r.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let r=0,i={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[o,s]of t.entries()){let a=i[o];if(!a||a.length===0)continue;let c="metadata"in s?s.metadata:void 0;if(c&&typeof c.prepositionValue=="string"){let u=c.prepositionValue;a.includes(u)?r+=.1:r-=.1;}}return Math.max(-0.1,Math.min(.1,r))}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=this.safeToLowerCase(t.value);if(B.ENGLISH_NOISE_WORDS.has(r)){let i=e.mark();e.advance();let o=e.peek();if(o&&o.kind==="selector")return;e.reset(i);}r==="class"&&e.advance();}extractEventModifiers(e){let t={},r=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(r=true,o.modifierName){case "once":t.once=true;break;case "debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case "throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case "queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance();}return r?t:void 0}};Y.MAX_MARKER_SCAN=3;Y.MAX_PROPERTY_DEPTH=10;Y.MAX_METHOD_ARGS=20;Y.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Nt=Y;new Nt;var _e=class{constructor(){this.name="string-literal";}canExtract(n,e){let t=n[e];return t==='"'||t==="'"||t==="`"||t==="\u201C"||t==="\u2018"}extract(n,e){let t=n[e];if(t==="\u201C"){let o=1;for(;e+o<n.length;){if(n[e+o]==="\u201D")return o++,{value:n.substring(e,e+o),length:o};o++;}return null}if(t==="\u2018"){let o=1;for(;e+o<n.length;){if(n[e+o]==="\u2019")return o++,{value:n.substring(e,e+o),length:o};o++;}return null}let r=1,i=false;for(;e+r<n.length;){let o=n[e+r];if(i){i=false,r++;continue}if(o==="\\"){i=true,r++;continue}if(o===t)return r++,{value:n.substring(e,e+r),length:r};r++;}return null}},Ie=class{constructor(){this.name="number";}canExtract(n,e){return /\d/.test(n[e])}extract(n,e){let t=0,r=false;for(;e+t<n.length;){let s=n[e+t];if(/\d/.test(s))t++;else if(s==="."&&!r)r=true,t++;else break}if(t===0)return null;let i=n.substring(e,e+t),o=e+t;if(o<n.length){let s=n.slice(o),a=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let u of a)if(s.startsWith(u.pattern))return {value:i+u.suffix,length:t+u.pattern.length,metadata:{hasTimeUnit:true}};if(s.startsWith("ms"))return {value:i+"ms",length:t+2,metadata:{hasTimeUnit:true}};let c=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let u of c)if(s.startsWith(u.pattern))return {value:i+u.suffix,length:t+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(s))return {value:i+s[0],length:t+1,metadata:{hasTimeUnit:true}}}return {value:i,length:t}}};function Ot(n){return "setContext"in n&&typeof n.setContext=="function"}function _t(n){let e={language:n.language,direction:n.direction,lookupKeyword:n.lookupKeyword.bind(n),isKeyword:n.isKeyword.bind(n),isKeywordStart:n.isKeywordStart.bind(n)};return n.normalizer?{...e,normalizer:n.normalizer}:e}var It=new Set(["me","you","it","result","event","target","body"]);function Me(n,e=It){return e.has(n)}var X=class{constructor(n,e){this.pos=0,this.tokens=n,this.language=e;}peek(n=0){let e=this.pos+n;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(n){this.pos=n.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(n){let e=[];for(;!this.isAtEnd()&&n(this.peek());)e.push(this.advance());return e}skipWhile(n){for(;!this.isAtEnd()&&n(this.peek());)this.advance();}};function S(n,e){return {start:n,end:e}}function w(n,e,t,r){if(typeof n=="object"){let{value:o,kind:s,position:a,normalized:c,stem:u,stemConfidence:l,metadata:d}=n;return {value:o,kind:s,position:a,...c!==void 0&&{normalized:c},...u!==void 0&&{stem:u},...l!==void 0&&{stemConfidence:l},...d!==void 0&&{metadata:d}}}let i=n;if(!e||!t)throw new Error("createToken requires kind and position parameters");if(typeof r=="string")return {value:i,kind:e,position:t,normalized:r};if(r){let{normalized:o,stem:s,stemConfidence:a,metadata:c}=r;return {value:i,kind:e,position:t,...o!==void 0&&{normalized:o},...s!==void 0&&{stem:s},...a!==void 0&&{stemConfidence:a},...c!==void 0&&{metadata:c}}}return {value:i,kind:e,position:t}}function M(n){return /\s/.test(n)}function Lt(n){return n==="#"||n==="."||n==="["||n==="@"||n==="*"||n==="<"}function $t(n){return n==='"'||n==="'"||n==="`"||n==="\u300C"||n==="\u300D"}function I(n){return /\d/.test(n)}function Dt(n){return /[a-zA-Z]/.test(n)}function x(n){return /[a-zA-Z0-9_-]/.test(n)}function Vt(n,e){if(e>=n.length)return null;let t=n[e];if(!Lt(t))return null;let r=e,i="";if(t==="#"||t==="."){for(i+=n[r++];r<n.length&&x(n[r]);)i+=n[r++];if(i.length<=1)return null;if(r<n.length&&n[r]==="."&&t==="#"){let s=r+1;for(;s<n.length&&x(n[s]);)s++;if(s<n.length&&n[s]==="(")return i}}else if(t==="["){let o=1,s=false,a=null,c=false;for(i+=n[r++];r<n.length&&o>0;){let u=n[r];i+=u,c?c=false:u==="\\"?c=true:s?u===a&&(s=false,a=null):u==='"'||u==="'"||u==="`"?(s=true,a=u):u==="["?o++:u==="]"&&o--,r++;}if(o!==0)return null}else if(t==="@"){for(i+=n[r++];r<n.length&&x(n[r]);)i+=n[r++];if(i.length<=1)return null}else if(t==="*"){for(i+=n[r++];r<n.length&&x(n[r]);)i+=n[r++];if(i.length<=1)return null}else if(t==="<"){if(i+=n[r++],r>=n.length||!Dt(n[r]))return null;for(;r<n.length&&x(n[r]);)i+=n[r++];for(;r<n.length;){let o=n[r];if(o==="."){if(i+=n[r++],r>=n.length||!x(n[r]))return null;for(;r<n.length&&x(n[r]);)i+=n[r++];}else if(o==="#"){if(i+=n[r++],r>=n.length||!x(n[r]))return null;for(;r<n.length&&x(n[r]);)i+=n[r++];}else if(o==="["){let s=1,a=false,c=null,u=false;for(i+=n[r++];r<n.length&&s>0;){let l=n[r];i+=l,u?u=false:l==="\\"?u=true:a?l===c&&(a=false,c=null):l==='"'||l==="'"||l==="`"?(a=true,c=l):l==="["?s++:l==="]"&&s--,r++;}if(s!==0)return null}else break}for(;r<n.length&&M(n[r]);)i+=n[r++];if(r<n.length&&n[r]==="/")for(i+=n[r++];r<n.length&&M(n[r]);)i+=n[r++];if(r>=n.length||n[r]!==">")return null;i+=n[r++];}return i||null}function Bt(n,e){if(e>=n.length||n[e]!=="'"||e+1>=n.length||n[e+1].toLowerCase()!=="s")return false;if(e+2>=n.length)return true;let r=n[e+2];return M(r)||r==="*"||!x(r)}function zt(n,e){if(e>=n.length)return null;let t=n[e];if(!$t(t)||t==="'"&&Bt(n,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!i)return null;let o=e+1,s=t,a=false;for(;o<n.length;){let c=n[o];if(s+=c,a)a=false;else if(c==="\\")a=true;else if(c===i)return s;o++;}return s}function qt(n,e){if(e>=n.length)return false;let t=n[e],r=n[e+1]||"",i=n[e+2]||"";if(t==="/"&&r!=="/"&&/[a-zA-Z0-9._-]/.test(r)||t==="/"&&r==="/"&&/[a-zA-Z]/.test(i)||t==="."&&(r==="/"||r==="."&&i==="/"))return true;let o=n.slice(e,e+8).toLowerCase();return !!(o.startsWith("http://")||o.startsWith("https://"))}function Wt(n,e){if(!qt(n,e))return null;let t=e,r="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<n.length;){let o=n[t];if(o==="#"){if(r.length>0&&/[a-zA-Z0-9/.]$/.test(r))for(r+=o,t++;t<n.length&&/[a-zA-Z0-9_-]/.test(n[t]);)r+=n[t++];break}if(i.test(o))r+=o,t++;else break}return r.length<2?null:r}function jt(n,e){if(e>=n.length)return null;let t=n[e];if(!I(t)&&t!=="-"&&t!=="+")return null;let r=e,i="";if((n[r]==="-"||n[r]==="+")&&(i+=n[r++]),r>=n.length||!I(n[r]))return null;for(;r<n.length&&I(n[r]);)i+=n[r++];if(r<n.length&&n[r]===".")for(i+=n[r++];r<n.length&&I(n[r]);)i+=n[r++];return r<n.length&&(n.slice(r,r+2)==="ms"?i+="ms":(n[r]==="s"||n[r]==="m"||n[r]==="h")&&(i+=n[r])),i}var Ft=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Ft);var $e=class De{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map,this.extractors=[];}tokenize(e){if(this.isUsingExtractors())return this.tokenizeWithExtractors(e);throw new Error(`${this.constructor.name}: tokenize() not implemented and no extractors registered. Either register extractors or override tokenize() method.`)}registerExtractor(e){Ot(e)&&e.setContext(_t(this)),this.extractors.push(e);}registerExtractors(e){for(let t of e)this.registerExtractor(t);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let t=[],r=0;for(;r<e.length;){for(;r<e.length&&M(e[r]);)r++;if(r>=e.length)break;let i=false;for(let o of this.extractors)if(o.canExtract(e,r)){let s=o.extract(e,r);if(s){let a=s.metadata?.normalized,c=s.metadata?.stem,u=s.metadata?.stemConfidence,l={};if(s.metadata)for(let[p,f]of Object.entries(s.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(l[p]=f);let d={};a&&(d.normalized=a),c&&(d.stem=c),u!==void 0&&(d.stemConfidence=u),Object.keys(l).length>0&&(d.metadata=l),t.push(w(s.value,this.classifyToken(s.value),S(r,r+s.length),Object.keys(d).length>0?d:void 0)),r+=s.length,i=true;break}}if(!i){let o=e[r],s=this.classifyUnknownChar(o);t.push(w(o,s,S(r,r+1))),r++;}}return new X(t,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,t,r){if(e[t]!==".")return false;let i=r[r.length-1],o=i&&i.position.end<t;if(i&&!o&&(i.kind==="identifier"||i.kind==="keyword"||i.kind==="selector"))return r.push(w(".","operator",S(t,t+1))),true;let c=t+1;for(;c<e.length&&x(e[c]);)c++;return c<e.length&&e[c]==="("?(r.push(w(".","operator",S(t,t+1))),true):false}initializeKeywordsFromProfile(e,t=[]){let r=new Map;if(e.keywords){for(let[i,o]of Object.entries(e.keywords))if(r.set(o.primary,{native:o.primary,normalized:o.normalized||i}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:o.normalized||i});}if(e.references){for(let[i,o]of Object.entries(e.references))r.set(o,{native:o,normalized:i});for(let i of Object.keys(e.references))r.has(i)||r.set(i,{native:i,normalized:i});}if(e.roleMarkers){for(let[i,o]of Object.entries(e.roleMarkers))if(o.primary&&r.set(o.primary,{native:o.primary,normalized:i}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:i});}if(e.possessive?.keywords)for(let[i,o]of Object.entries(e.possessive.keywords))r.set(i,{native:i,normalized:o});for(let i of t)r.set(i.native,i);this.profileKeywords=Array.from(r.values()).sort((i,o)=>o.native.length-i.native.length),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let o=this.removeDiacritics(i.native);o!==i.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),i);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,t){for(let r of this.profileKeywords)if(e.slice(t).startsWith(r.native))return w(r.native,"keyword",S(t,t+r.native.length),r.normalized);return null}isKeywordStart(e,t){let r=e.slice(t);return this.profileKeywords.some(i=>r.startsWith(i.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let t=this.normalizer.normalize(e);return t.stem!==e&&t.confidence>=.7?t:null}tryMorphKeywordMatch(e,t,r){let i=this.tryNormalize(e);if(!i)return null;let o=this.lookupKeyword(i.stem);if(!o)return null;let s={normalized:o.normalized,stem:i.stem,stemConfidence:i.confidence};return w(e,"keyword",S(t,r),s)}trySelector(e,t){let r=Vt(e,t);return r?w(r,"selector",S(t,t+r.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let r=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!r)return null;let i=r[0].replace(/(\s|\.)$/,""),o=i.slice(1).split("(")[0],s=r[1];return {...w(i,"event-modifier",S(t,t+i.length)),metadata:{modifierName:o,value:s?o==="queue"?s:parseInt(s,10):void 0}}}tryString(e,t){let r=zt(e,t);return r?w(r,"literal",S(t,t+r.length)):null}tryNumber(e,t){let r=jt(e,t);return r?w(r,"literal",S(t,t+r.length)):null}tryMatchTimeUnit(e,t,r,i=false){let o=t;if(i)for(;o<e.length&&M(e[o]);)o++;let s=e.slice(o);for(let a of r){let c=s.slice(0,a.length);if(a.caseInsensitive?c.toLowerCase()===a.pattern.toLowerCase():c===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let l=s[a.length]||"";if(x(l))continue}return {suffix:a.suffix,endPos:o+a.length}}}return null}parseBaseNumber(e,t,r=true){let i=t,o="";if(r&&(e[i]==="-"||e[i]==="+")&&(o+=e[i++]),i>=e.length||!I(e[i]))return null;for(;i<e.length&&I(e[i]);)o+=e[i++];if(i<e.length&&e[i]===".")for(o+=e[i++];i<e.length&&I(e[i]);)o+=e[i++];return !o||o==="-"||o==="+"?null:{number:o,endPos:i}}tryNumberWithTimeUnits(e,t,r,i={}){let{allowSign:o=true,skipWhitespace:s=false}=i,a=this.parseBaseNumber(e,t,o);if(!a)return null;let{number:c,endPos:u}=a,l=[...r,...De.STANDARD_TIME_UNITS],d=this.tryMatchTimeUnit(e,u,l,s);return d&&(c+=d.suffix,u=d.endPos),w(c,"literal",S(t,u))}tryUrl(e,t){let r=Wt(e,t);return r?w(r,"url",S(t,t+r.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!x(e[t+1]))return null;let r=t+1;for(;r<e.length&&x(e[r]);)r++;let i=e.slice(t,r);return w(i,"identifier",S(t,r))}tryOperator(e,t){let r=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(r))return w(r,"operator",S(t,t+2));let i=e[t];return ["<",">","!","+","-","*","/","="].includes(i)?w(i,"operator",S(t,t+1)):["(",")","{","}",",",";",":"].includes(i)?w(i,"punctuation",S(t,t+1)):null}tryMultiCharParticle(e,t,r){for(let i of r)if(e.slice(t,t+i.length)===i)return w(i,"particle",S(t,t+i.length));return null}};$e.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var Ve=$e;function Oe(n){return {stem:n,confidence:1}}function H(n,e,t){return t?{stem:n,confidence:e,metadata:t}:{stem:n,confidence:e}}var Be=class{constructor(n){this.language=n.language,this.config={minWordLength:3,minStemLength:2,...n};}normalize(n){let e=n.toLowerCase();if(this.isAlreadyNormalized(e))return Oe(n);if(this.config.reflexiveSuffixes){let t=this.tryReflexiveNormalization(e);if(t)return t}if(this.config.endings){let t=this.tryConjugationEndings(e);if(t)return t}if(this.config.suffixRules){let t=this.trySuffixRules(e);if(t)return t}if(this.config.prefixRules){let t=this.tryPrefixRules(e);if(t)return t}return Oe(n)}isAlreadyNormalized(n){return this.config.infinitiveEndings?this.config.infinitiveEndings.some(e=>n.endsWith(e)):false}tryReflexiveNormalization(n){let e=this.config.reflexiveSuffixes;if(!e)return null;for(let t of e){if(!n.endsWith(t))continue;let r=n.slice(0,-t.length);if(this.isAlreadyNormalized(r))return H(r,.88,{removedSuffixes:[t],conjugationType:"reflexive"});let i=this.tryConjugationEndings(r)||this.trySuffixRules(r);if(i&&i.stem!==r)return H(i.stem,i.confidence*.95,{removedSuffixes:[t,...i.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationEndings(n){let e=this.config.endings;if(!e)return null;let t=this.config.minStemLength??2;for(let r of e){if(!n.endsWith(r.ending))continue;let i=n.slice(0,-r.ending.length);if(i.length<t)continue;let o=i+r.stem;return H(o,r.confidence,{removedSuffixes:[r.ending],conjugationType:r.type})}return null}trySuffixRules(n){let e=this.config.suffixRules;if(!e)return null;let t=this.config.minStemLength??2;for(let r of e){if(!n.endsWith(r.pattern))continue;let i=n.slice(0,-r.pattern.length),o=r.minStemLength??t;if(i.length<o)continue;let s=i+(r.replacement||"");return H(s,r.confidence,{removedSuffixes:[r.pattern],...r.conjugationType&&{conjugationType:r.conjugationType}})}return null}tryPrefixRules(n){let e=this.config.prefixRules;if(!e)return null;for(let t of e){if(!n.startsWith(t.pattern))continue;let r=n.slice(t.pattern.length),i=t.minRemaining??this.config.minStemLength??2;if(!(r.length<i))return H(r,1-t.confidencePenalty,{removedPrefixes:[t.pattern]})}return null}};var Ut=new Map,Gt=new Map,Kt=new Map;function Ht(n,e,t){Ut.set(n,e),Gt.set(n,t),Kt.delete(n);}function Yt(n){return /[áéíóúüñÁÉÍÓÚÜÑ]/.test(n)}var Xt=[{ending:"ando",stem:"ar",confidence:.88,type:"gerund"},{ending:"ado",stem:"ar",confidence:.88,type:"participle"},{ending:"ada",stem:"ar",confidence:.88,type:"participle"},{ending:"ados",stem:"ar",confidence:.88,type:"participle"},{ending:"adas",stem:"ar",confidence:.88,type:"participle"},{ending:"o",stem:"ar",confidence:.75,type:"present"},{ending:"as",stem:"ar",confidence:.82,type:"present"},{ending:"a",stem:"ar",confidence:.75,type:"present"},{ending:"amos",stem:"ar",confidence:.85,type:"present"},{ending:"\xE1is",stem:"ar",confidence:.85,type:"present"},{ending:"ais",stem:"ar",confidence:.82,type:"present"},{ending:"an",stem:"ar",confidence:.8,type:"present"},{ending:"\xE9",stem:"ar",confidence:.85,type:"past"},{ending:"aste",stem:"ar",confidence:.88,type:"past"},{ending:"\xF3",stem:"ar",confidence:.82,type:"past"},{ending:"amos",stem:"ar",confidence:.85,type:"past"},{ending:"asteis",stem:"ar",confidence:.88,type:"past"},{ending:"aron",stem:"ar",confidence:.88,type:"past"},{ending:"aba",stem:"ar",confidence:.88,type:"past"},{ending:"abas",stem:"ar",confidence:.88,type:"past"},{ending:"\xE1bamos",stem:"ar",confidence:.88,type:"past"},{ending:"abamos",stem:"ar",confidence:.85,type:"past"},{ending:"abais",stem:"ar",confidence:.88,type:"past"},{ending:"aban",stem:"ar",confidence:.88,type:"past"},{ending:"e",stem:"ar",confidence:.72,type:"subjunctive"},{ending:"es",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"emos",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"\xE9is",stem:"ar",confidence:.85,type:"subjunctive"},{ending:"eis",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"en",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"a",stem:"ar",confidence:.75,type:"imperative"},{ending:"ad",stem:"ar",confidence:.85,type:"imperative"},{ending:"ar",stem:"ar",confidence:.92,type:"dictionary"}],Qt=[{ending:"iendo",stem:"er",confidence:.88,type:"gerund"},{ending:"ido",stem:"er",confidence:.85,type:"participle"},{ending:"ida",stem:"er",confidence:.85,type:"participle"},{ending:"idos",stem:"er",confidence:.85,type:"participle"},{ending:"idas",stem:"er",confidence:.85,type:"participle"},{ending:"o",stem:"er",confidence:.72,type:"present"},{ending:"es",stem:"er",confidence:.78,type:"present"},{ending:"e",stem:"er",confidence:.72,type:"present"},{ending:"emos",stem:"er",confidence:.85,type:"present"},{ending:"\xE9is",stem:"er",confidence:.85,type:"present"},{ending:"eis",stem:"er",confidence:.82,type:"present"},{ending:"en",stem:"er",confidence:.78,type:"present"},{ending:"\xED",stem:"er",confidence:.85,type:"past"},{ending:"iste",stem:"er",confidence:.88,type:"past"},{ending:"i\xF3",stem:"er",confidence:.85,type:"past"},{ending:"io",stem:"er",confidence:.82,type:"past"},{ending:"imos",stem:"er",confidence:.85,type:"past"},{ending:"isteis",stem:"er",confidence:.88,type:"past"},{ending:"ieron",stem:"er",confidence:.88,type:"past"},{ending:"\xEDa",stem:"er",confidence:.88,type:"past"},{ending:"ia",stem:"er",confidence:.85,type:"past"},{ending:"\xEDas",stem:"er",confidence:.88,type:"past"},{ending:"ias",stem:"er",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"er",confidence:.88,type:"past"},{ending:"iamos",stem:"er",confidence:.85,type:"past"},{ending:"\xEDais",stem:"er",confidence:.88,type:"past"},{ending:"iais",stem:"er",confidence:.85,type:"past"},{ending:"\xEDan",stem:"er",confidence:.88,type:"past"},{ending:"ian",stem:"er",confidence:.85,type:"past"},{ending:"er",stem:"er",confidence:.92,type:"dictionary"}],Jt=[{ending:"iendo",stem:"ir",confidence:.88,type:"gerund"},{ending:"ido",stem:"ir",confidence:.85,type:"participle"},{ending:"ida",stem:"ir",confidence:.85,type:"participle"},{ending:"idos",stem:"ir",confidence:.85,type:"participle"},{ending:"idas",stem:"ir",confidence:.85,type:"participle"},{ending:"o",stem:"ir",confidence:.72,type:"present"},{ending:"es",stem:"ir",confidence:.78,type:"present"},{ending:"e",stem:"ir",confidence:.72,type:"present"},{ending:"imos",stem:"ir",confidence:.85,type:"present"},{ending:"\xEDs",stem:"ir",confidence:.85,type:"present"},{ending:"is",stem:"ir",confidence:.82,type:"present"},{ending:"en",stem:"ir",confidence:.78,type:"present"},{ending:"\xED",stem:"ir",confidence:.85,type:"past"},{ending:"iste",stem:"ir",confidence:.88,type:"past"},{ending:"i\xF3",stem:"ir",confidence:.85,type:"past"},{ending:"io",stem:"ir",confidence:.82,type:"past"},{ending:"imos",stem:"ir",confidence:.85,type:"past"},{ending:"isteis",stem:"ir",confidence:.88,type:"past"},{ending:"ieron",stem:"ir",confidence:.88,type:"past"},{ending:"\xEDa",stem:"ir",confidence:.88,type:"past"},{ending:"ia",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDas",stem:"ir",confidence:.88,type:"past"},{ending:"ias",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"ir",confidence:.88,type:"past"},{ending:"iamos",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDais",stem:"ir",confidence:.88,type:"past"},{ending:"iais",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDan",stem:"ir",confidence:.88,type:"past"},{ending:"ian",stem:"ir",confidence:.85,type:"past"},{ending:"ir",stem:"ir",confidence:.92,type:"dictionary"}],Zt=[...Xt,...Qt,...Jt].sort((n,e)=>e.ending.length-n.ending.length),qe=class extends Be{constructor(){super({language:"es",minWordLength:3,minStemLength:2,endings:Zt,reflexiveSuffixes:["se","me","te","nos","os"],infinitiveEndings:["ar","er","ir"]});}isNormalizable(n){if(n.length<3)return false;let e=n.toLowerCase();if(e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir")||e.endsWith("ando")||e.endsWith("iendo")||e.endsWith("ado")||e.endsWith("ido")||e.endsWith("arse")||e.endsWith("erse")||e.endsWith("irse"))return true;for(let t of n)if(Yt(t))return true;return false}};new qe;var We={code:"es",name:"Spanish",nativeName:"Espa\xF1ol",regions:["western","priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:true},references:{me:"yo",it:"ello",you:"t\xFA",result:"resultado",event:"evento",target:"objetivo",body:"cuerpo"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"mi",it:"su",you:"tu"},keywords:{mi:"me",tu:"you",su:"it"}},roleMarkers:{destination:{primary:"en",alternatives:["sobre","a"],position:"before"},source:{primary:"de",alternatives:["desde"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"con",position:"before"}},keywords:{toggle:{primary:"alternar",alternatives:["conmutar","toggle"],normalized:"toggle"},add:{primary:"agregar",alternatives:["a\xF1adir"],normalized:"add"},remove:{primary:"quitar",alternatives:["eliminar","remover","sacar","borrar"],normalized:"remove"},put:{primary:"poner",alternatives:["colocar","pon"],normalized:"put"},append:{primary:"anexar",normalized:"append"},prepend:{primary:"anteponer",normalized:"prepend"},take:{primary:"tomar",normalized:"take"},make:{primary:"hacer",alternatives:["crear"],normalized:"make"},clone:{primary:"clonar",alternatives:["duplicar"],normalized:"clone"},swap:{primary:"intercambiar",alternatives:["permutar"],normalized:"swap"},morph:{primary:"transformar",alternatives:["convertir"],normalized:"morph"},set:{primary:"establecer",alternatives:["fijar","definir"],normalized:"set"},get:{primary:"obtener",alternatives:["conseguir"],normalized:"get"},increment:{primary:"incrementar",alternatives:["aumentar"],normalized:"increment"},decrement:{primary:"decrementar",alternatives:["disminuir"],normalized:"decrement"},log:{primary:"registrar",alternatives:["imprimir"],normalized:"log"},show:{primary:"mostrar",alternatives:["ense\xF1ar"],normalized:"show"},hide:{primary:"ocultar",alternatives:["esconder"],normalized:"hide"},transition:{primary:"transici\xF3n",alternatives:["animar"],normalized:"transition"},on:{primary:"en",alternatives:["al"],normalized:"on"},trigger:{primary:"disparar",alternatives:["activar"],normalized:"trigger"},send:{primary:"enviar",normalized:"send"},focus:{primary:"enfocar",alternatives:["enfoque"],normalized:"focus"},blur:{primary:"desenfocar",alternatives:["desenfoque"],normalized:"blur"},click:{primary:"clic",alternatives:["hacer clic","click"],normalized:"click"},hover:{primary:"sobrevolar",alternatives:["pasar por encima"],normalized:"hover"},submit:{primary:"env\xEDo",alternatives:["envio","someter"],normalized:"submit"},input:{primary:"entrada",alternatives:["introducir"],normalized:"input"},change:{primary:"cambio",alternatives:["cambiar"],normalized:"change"},load:{primary:"carga",normalized:"load"},scroll:{primary:"desplazamiento",normalized:"scroll"},keydown:{primary:"tecla abajo",normalized:"keydown"},keyup:{primary:"tecla arriba",normalized:"keyup"},mouseover:{primary:"rat\xF3n encima",alternatives:["raton encima"],normalized:"mouseover"},mouseout:{primary:"rat\xF3n fuera",alternatives:["raton fuera"],normalized:"mouseout"},go:{primary:"ir",alternatives:["navegar"],normalized:"go"},wait:{primary:"esperar",normalized:"wait"},fetch:{primary:"buscar",alternatives:["recuperar"],normalized:"fetch"},settle:{primary:"estabilizar",normalized:"settle"},if:{primary:"si",normalized:"if"},when:{primary:"cuando",normalized:"when"},where:{primary:"donde",normalized:"where"},else:{primary:"sino",alternatives:["de lo contrario"],normalized:"else"},repeat:{primary:"repetir",normalized:"repeat"},for:{primary:"para",normalized:"for"},while:{primary:"mientras",normalized:"while"},continue:{primary:"continuar",normalized:"continue"},halt:{primary:"detener",alternatives:["parar"],normalized:"halt"},throw:{primary:"lanzar",alternatives:["arrojar"],normalized:"throw"},call:{primary:"llamar",normalized:"call"},return:{primary:"retornar",alternatives:["devolver"],normalized:"return"},then:{primary:"entonces",alternatives:["luego"],normalized:"then"},and:{primary:"y",alternatives:["adem\xE1s","tambi\xE9n"],normalized:"and"},or:{primary:"o",normalized:"or"},not:{primary:"no",normalized:"not"},is:{primary:"es",normalized:"is"},exists:{primary:"existe",normalized:"exists"},empty:{primary:"vac\xEDo",alternatives:["vacio"],normalized:"empty"},end:{primary:"fin",alternatives:["final","terminar"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"as\xEDncrono",alternatives:["asincrono"],normalized:"async"},tell:{primary:"decir",normalized:"tell"},default:{primary:"predeterminar",alternatives:["por defecto"],normalized:"default"},init:{primary:"iniciar",alternatives:["inicializar"],normalized:"init"},behavior:{primary:"comportamiento",normalized:"behavior"},install:{primary:"instalar",normalized:"install"},measure:{primary:"medir",normalized:"measure"},beep:{primary:"pitido",normalized:"beep"},break:{primary:"romper",normalized:"break"},copy:{primary:"copiar",normalized:"copy"},exit:{primary:"salir",normalized:"exit"},pick:{primary:"escoger",normalized:"pick"},render:{primary:"renderizar",normalized:"render"},first:{primary:"primero",alternatives:["primera"],normalized:"first"},last:{primary:"\xFAltimo",alternatives:["ultima"],normalized:"last"},next:{primary:"siguiente",normalized:"next"},previous:{primary:"anterior",normalized:"previous"},closest:{primary:"cercano",normalized:"closest"},parent:{primary:"padre",normalized:"parent"},into:{primary:"dentro",alternatives:["adentro","dentro de"],normalized:"into"},before:{primary:"antes",alternatives:["antes de"],normalized:"before"},after:{primary:"despu\xE9s",alternatives:["despues","despu\xE9s de","despues de"],normalized:"after"},out:{primary:"fuera",alternatives:["fuera de"],normalized:"out"},until:{primary:"hasta",alternatives:["hasta que"],normalized:"until"},event:{primary:"evento",normalized:"event"},from:{primary:"de",alternatives:["desde"],normalized:"from"}},eventHandler:{keyword:{primary:"al",alternatives:["cuando","en"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["desde"],position:"before"},eventMarker:{primary:"al",alternatives:["cuando"],position:"before"},temporalMarkers:["cuando","al"]}},er=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],tr=class{constructor(n=er){this.name="operator",this.operators=[...n].sort((e,t)=>t.length-e.length);}canExtract(n,e){return this.operators.some(t=>n.startsWith(t,e))}extract(n,e){for(let t of this.operators)if(n.startsWith(t,e))return {value:t,length:t.length};return null}},rr="()[]{},:;",nr=class{constructor(n=rr){this.punctuation=n,this.name="punctuation";}canExtract(n,e){return this.punctuation.includes(n[e])}extract(n,e){let t=n[e];return this.punctuation.includes(t)?{value:t,length:1}:null}};function ir(n,e){let t=n[e];if(t==="#"){let r=n.slice(e).match(/^#[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="."){let r=n.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="["){let r=0,i=e;for(;i<n.length;){if(n[i]==="["&&r++,n[i]==="]"&&(r--,r===0))return n.slice(e,i+1);i++;}return null}if(t==="<"){let r=n.slice(e).match(/^<[\w-]+(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return r?r[0]:null}return null}var or=class{constructor(){this.name="css-selector";}canExtract(n,e){let t=n[e];return t==="#"||t==="."||t==="["||t==="<"}extract(n,e){let t=ir(n,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},sr=class{constructor(){this.name="event-modifier";}canExtract(n,e){if(n[e]!==".")return false;let t=n.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(t)}extract(n,e){let t=n.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!t)return null;let r=t[0],i=r.slice(1).split("(")[0],o=t[1];return {value:r,length:r.length,metadata:{modifierName:i,value:o?i==="queue"?o:parseInt(o,10):void 0}}}};function ar(n,e){let t=n.slice(e);if(t.startsWith("http://")||t.startsWith("https://")){let r=t.match(/^https?:\/\/[^\s]*/);return r?r[0]:null}if(t.startsWith("//")){let r=t.match(/^\/\/[^\s]*/);return r?r[0]:null}if(t.startsWith("./")||t.startsWith("../")){let r=t.match(/^\.\.?\/[^\s]*/);return r?r[0]:null}if(t.startsWith("/")){let r=t.match(/^\/[^\s]*/);return r?r[0]:null}return null}var cr=class{constructor(){this.name="url";}canExtract(n,e){let t=n.slice(e);return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")}extract(n,e){let t=ar(n,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},lr=class{constructor(){this.name="variable-ref";}canExtract(n,e){return n[e]===":"&&e+1<n.length&&/[a-zA-Z_]/.test(n[e+1])}extract(n,e){if(!this.canExtract(n,e))return null;let t=1;for(;e+t<n.length&&/[a-zA-Z0-9_]/.test(n[e+t]);)t++;return {value:n.substring(e,e+t),length:t,metadata:{type:"variable-reference"}}}};function ur(){return [new cr,new sr,new lr,new or]}function dr(n){return {isLetter:r=>n.test(r),isIdentifierChar:r=>/[0-9]/.test(r)||n.test(r)}}var{isLetter:ze,isIdentifierChar:pr}=dr(/[a-zA-ZáéíóúüñÁÉÍÓÚÜÑ]/),fr=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),mr=class{constructor(){this.name="spanish-keyword";}setContext(n){this.context=n;}canExtract(n,e){return ze(n[e])}extract(n,e){if(!this.context)throw new Error("SpanishKeywordExtractor: context not set");let t=this.tryMultiWordPhrase(n,e);return t||this.extractSpanishWord(n,e)}tryMultiWordPhrase(n,e){if(!this.context)return null;let t=["de lo contrario","de lo normal","por defecto","de nuevo","de otra manera"];for(let r of t)if(n.slice(e,e+r.length).toLowerCase()===r.toLowerCase()){let o=e+r.length;if(o>=n.length||M(n[o])||!ze(n[o])){let s=this.context.lookupKeyword(r);return {value:n.slice(e,o),length:r.length,metadata:{normalized:s?.normalized,multiWord:true}}}}return null}extractSpanishWord(n,e){if(!this.context)return null;let t=e,r="";for(;t<n.length&&pr(n[t]);)r+=n[t++];if(!r)return null;let i=r.toLowerCase(),o=fr.has(i),s=this.context.lookupKeyword(r),a=s&&s.normalized!==s.native?s.normalized:void 0,c;if(!s&&this.context.normalizer){let u=this.context.normalizer.normalize(r);if(u.stem!==r&&u.confidence>=.7){let l=this.context.lookupKeyword(u.stem);l&&(c=l.normalized);}}return {value:r,length:t-e,metadata:{normalized:a||c,isPreposition:o}}}};function hr(){return [new mr]}var yr=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),gr=[{native:"verdadero",normalized:"true"},{native:"falso",normalized:"false"},{native:"nulo",normalized:"null"},{native:"indefinido",normalized:"undefined"},{native:"segundo",normalized:"s"},{native:"segundos",normalized:"s"},{native:"milisegundo",normalized:"ms"},{native:"milisegundos",normalized:"ms"},{native:"minuto",normalized:"m"},{native:"minutos",normalized:"m"},{native:"hora",normalized:"h"},{native:"horas",normalized:"h"},{native:"m\xED",normalized:"me"},{native:"destino",normalized:"target"}],vr=class extends Ve{constructor(){super(),this.language="es",this.direction="ltr",this.initializeKeywordsFromProfile(We,gr),this.setNormalizer(new qe),this.registerExtractors(ur()),this.registerExtractor(new _e),this.registerExtractor(new Ie),this.registerExtractors(hr()),this.registerExtractor(new tr),this.registerExtractor(new nr);}classifyToken(n){let e=n.toLowerCase();return yr.has(e)?"particle":this.isKeyword(e)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(n)?"event-modifier":n.startsWith("#")||n.startsWith(".")||n.startsWith("[")||n.startsWith("*")||n.startsWith("<")?"selector":n.startsWith('"')||n.startsWith("'")||/^\d/.test(n)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(n)?"operator":"identifier"}},br=new vr;Ht("es",br,We);var Er=Object.defineProperty,Sr=Object.getOwnPropertyNames,tt=(n,e)=>function(){return n&&(e=(0, n[Sr(n)[0]])(n=0)),e},wr=(n,e)=>{for(var t in e)Er(n,t,{get:e[t],enumerable:true});};function je(n,e){return n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`))}function C(n,e,t={},r){let i=rt[n],o=je(i,t),s=nt[n],a=s?je(s,t):void 0;return {code:n,message:o,severity:e,...r&&{role:r},...a&&{suggestion:a}}}var h,rt,nt,Tr=tt({"src/generators/schema-error-codes.ts"(){h={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},rt={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[h.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[h.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[h.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[h.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[h.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[h.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[h.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[h.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[h.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[h.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[h.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},nt={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[h.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[h.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[h.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[h.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[h.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[h.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[h.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[h.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),it={};wr(it,{SchemaErrorCodes:()=>h,formatValidationResults:()=>Nr,getValidationStats:()=>Or,validateAllKeywordCollisions:()=>Ir,validateAllSchemas:()=>Pr,validateCommandSchema:()=>ot,validateKeywordCollisions:()=>st,validateRoleValues:()=>_r});function kr(n,e){return {action:n,items:e,get notes(){return e.filter(t=>t.severity==="note").map(t=>t.message)},get warnings(){return e.filter(t=>t.severity==="warning").map(t=>t.message)},get errors(){return e.filter(t=>t.severity==="error").map(t=>t.message)}}}function ot(n){let e=[];for(let r of n.roles)r.expectedTypes.includes("literal")&&r.expectedTypes.includes("selector")&&(r.role==="patient"&&ve.has(n.action)?e.push(C(h.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:r.role,command:n.action},r.role)):e.push(C(h.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:r.role},r.role))),r.expectedTypes.length>3&&!ve.has(n.action)&&e.push(C(h.TOO_MANY_EXPECTED_TYPES,"warning",{role:r.role,count:r.expectedTypes.length},r.role));for(let r of n.roles)r.selectorKinds&&r.selectorKinds.length>0&&(r.expectedTypes.includes("selector")||e.push(C(h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:r.role},r.role)));switch(n.action){case "transition":xr(n,e);break;case "on":Cr(n,e);break;case "if":case "unless":Ar(n,e);break;case "repeat":case "for":case "while":Rr(n,e);break}return n.roles.filter(r=>r.required).length===0&&(at.has(n.action)?e.push(C(h.NO_REQUIRED_ROLES_EXPECTED,"note",{command:n.action})):e.push(C(h.NO_REQUIRED_ROLES,"warning",{}))),kr(n.action,e)}function xr(n,e){let t=n.roles.find(i=>i.role==="patient"),r=n.roles.find(i=>i.role==="goal");t&&t.expectedTypes.includes("selector")&&e.push(C(h.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),t&&!r&&e.push(C(h.TRANSITION_MISSING_GOAL,"error",{}));}function Cr(n,e){let t=n.roles.find(r=>r.role==="event");t||e.push(C(h.EVENT_HANDLER_MISSING_EVENT,"warning",{})),t&&!t.required&&e.push(C(h.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Ar(n,e){let t=n.roles.find(r=>r.role==="condition");t||e.push(C(h.CONDITIONAL_MISSING_CONDITION,"warning",{})),t&&!t.required&&e.push(C(h.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Rr(n,e){n.action==="for"?n.roles.find(r=>r.role==="source")||e.push(C(h.FOR_LOOP_MISSING_SOURCE,"warning",{})):n.action==="while"&&(n.roles.find(r=>r.role==="condition")||e.push(C(h.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Pr(n,e={}){let t=new Map,{includeNotes:r=false}=e;for(let[i,o]of Object.entries(n)){let s=ot(o),a=s.items.some(u=>u.severity==="warning"||u.severity==="error"),c=r&&s.items.some(u=>u.severity==="note");(a||c)&&t.set(i,s);}return t}function Nr(n,e={}){let t=[],{showNotes:r=false,showCodes:i=true}=e;for(let[o,s]of n){let a=s.items.filter(l=>l.severity==="error"),c=s.items.filter(l=>l.severity==="warning"),u=s.items.filter(l=>l.severity==="note");if(a.length>0){t.push(` \u274C ${o}:`);for(let l of a){let d=i?` [${l.code}]`:"";t.push(` ERROR${d}: ${l.message}`),l.suggestion&&t.push(` \u{1F4A1} Suggestion: ${l.suggestion}`);}}if(c.length>0){t.push(` \u26A0\uFE0F ${o}:`);for(let l of c){let d=i?` [${l.code}]`:"";t.push(` ${d?`${l.code}: `:""}${l.message}`),l.suggestion&&t.push(` \u{1F4A1} ${l.suggestion}`);}}if(r&&u.length>0){t.push(` \u2139\uFE0F ${o}:`);for(let l of u){let d=i?` [${l.code}]`:"";t.push(` ${d?`${l.code}: `:""}${l.message}`);}}}return t.join(`
2
+ `)}function Or(n){let e=0,t=0,r=0,i={};for(let o of n.values())for(let s of o.items)s.severity==="error"?e++:s.severity==="warning"?t++:s.severity==="note"&&r++,i[s.code]=(i[s.code]||0)+1;return {totalCommands:n.size,errors:e,warnings:t,notes:r,byCode:i}}function _r(n,e){let t=[];for(let r of e){let i=n.roles.find(o=>o.role===r.role);i&&(i.expectedTypes.length>0&&!i.expectedTypes.includes(r.type)&&(i.expectedTypes.includes("expression")||t.push({level:"error",role:r.role,message:`${n.action}.${r.role} expects type [${i.expectedTypes.join(", ")}], got '${r.type}'`,code:h.VALUE_TYPE_MISMATCH})),r.type==="selector"&&r.selectorKind&&i.selectorKinds&&i.selectorKinds.length>0&&(i.selectorKinds.includes(r.selectorKind)||t.push({level:"error",role:r.role,message:`${n.action}.${r.role} expects selector kind [${i.selectorKinds.join(", ")}], got '${r.selectorKind}'`,code:h.SELECTOR_KIND_MISMATCH})));}return t}function st(n){let e=[];if(!n.keywords)return {language:n.code,collisions:e};let t=new Map;for(let[i,o]of Object.entries(n.keywords)){if(!o||!o.primary)continue;let s=t.get(o.primary)||[];if(s.push({command:i,isPrimary:true}),t.set(o.primary,s),o.alternatives)for(let a of o.alternatives){let c=t.get(a)||[];c.push({command:i,isPrimary:false}),t.set(a,c);}}for(let[i,o]of t){let s=[...new Set(o.map(u=>u.command))];if(s.length<=1)continue;let a=o.filter(u=>u.isPrimary).length,c;a>=2?c="primary-primary":a===1?c="primary-alternative":c="alternative-alternative",e.push({keyword:i,commands:s.sort(),type:c});}let r={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((i,o)=>r[i.type]-r[o.type]),{language:n.code,collisions:e}}function Ir(n){let e=[];for(let[,t]of Object.entries(n)){let r=st(t);r.collisions.length>0&&e.push(r);}return e.sort((t,r)=>t.language.localeCompare(r.language))}var ve,at,Mr=tt({"src/generators/schema-validator.ts"(){Tr(),ve=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),at=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep"]);}});function J(n){let e="complex";return n.startsWith("#")&&!n.includes(" ")?e="id":n.startsWith(".")&&!n.includes(" ")?e="class":n.startsWith("[")&&n.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(n)&&(e="element"),{type:"selector",value:n,selectorKind:e}}function T(n,e){let t={type:"literal",value:n};return e!==void 0?{type:"literal",value:n,dataType:e}:t}function Fe(n){return Me(n)}function L(n){return {type:"reference",value:n}}function he(n,e){return {type:"property-path",object:n,property:e}}function oe(n,e,t){let r={kind:"command",action:n,roles:new Map(Object.entries(e))};return t!==void 0?{...r,metadata:t}:r}function Ue(n,e,t,r,i,o){let s=new Map;s.set("event",n);let a={kind:"event-handler",action:"on",roles:s,body:e};return t!==void 0&&(a.eventModifiers=t),r!==void 0&&(a.metadata=r),a}function Ge(n,e="then",t){let r={kind:"compound",action:"compound",roles:new Map,statements:n,chainType:e};return t!==void 0&&(r.metadata=t),r}function Ke(n,e){return !e||e.length===0||e.includes(n)||e.includes("expression")?true:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function Lr(n,e){return n.possessive?.keywords?.[e]}var W=new Map,j=new Map,se=new Map,be=null;function ct(n,e){let t={...n};for(let r of Object.keys(e)){let i=e[r],o=n[r];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?t[r]=ct(o,i):t[r]=i);}return t}function $r(n,e){return ct(n,e)}function Se(n){if(!n.extends)return n;let e=j.get(n.extends);if(!e)return console.warn(`[Registry] Profile '${n.code}' extends '${n.extends}' but base is not registered. Make sure to import the base language before the variant.`),n;let t=Se(e);return $r(t,n)}function lt(n){be=n;}var He=new Map;function F(n){return n.split("-")[0]}function U(n){return n.includes("-")}function Dr(n){let e=W.get(n);if(!e&&U(n)){let t=F(n);e=W.get(t);}if(!e){let t=Array.from(W.keys()).join(", ");throw new Error(`Language '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return e}function Vr(n){let e=j.get(n);if(!e&&U(n)){let t=F(n);e=j.get(t);}if(!e){let t=Array.from(j.keys()).join(", ");throw new Error(`Language profile '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return Se(e)}function Br(n){let e=W.get(n);return !e&&U(n)&&(e=W.get(F(n))),e}function $(n){let e=j.get(n);return !e&&U(n)&&(e=j.get(F(n))),e?Se(e):void 0}function ut(){return Array.from(W.keys())}function zr(n,e){return Dr(e).tokenize(n)}function q(n){let e=se.get(n);if(!e&&U(n)&&(e=se.get(F(n))),e)return e;let t=He.get(n);if(!t&&U(n)&&(t=He.get(F(n))),t)return se.set(n,t),t;if(!be)throw new Error(`No patterns registered for language '${n}'. Either import the language module or set a pattern generator.`);let r=Vr(n),i=be(r);return se.set(n,i),i}var ye=.8,Wr=.6,jr=.15,Fr=.5,Ye=.15,Xe=.1,Qe=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]),Ur={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]},Gr=class{calculate(n){return this.calculateWithBreakdown(n).final}calculateWithBreakdown(n){let e=this.scoreRoleCoverage(n),t=this.scoreStemPenalty(n),r=this.scoreLanguageBoost(n),i=this.scoreLanguageAdjustment(n),o=e;return o=Math.max(Fr,o+t),o=Math.min(1,o+r),o=Math.max(0,Math.min(1,o+i)),{roleCoverage:e,stemPenalty:t,languageBoost:r,languageAdjustment:i,final:o}}scoreRoleCoverage(n){let{pattern:e,captured:t}=n,r=0,i=0,o=s=>e.extraction?.[s]?.default!==void 0;for(let s of e.template.tokens)if(s.type==="role")i+=1,t.has(s.role)&&(r+=1);else if(s.type==="group")for(let a of s.tokens)a.type==="role"&&(i+=ye,t.has(a.role)?r+=ye:o(a.role)&&(r+=ye*Wr));return i>0?r/i:1}scoreStemPenalty(n){let{stemMatchCount:e,totalKeywordMatches:t}=n;return e<=0||t<=0?0:-(e/t)*jr}scoreLanguageBoost(n){let{pattern:e}=n;if(e.language!=="ar")return 0;let t=e.template.tokens[0];return !t||t.type!=="literal"?0:Qe.has(t.value)||t.alternatives?.some(r=>Qe.has(r))?Ye:0}scoreLanguageAdjustment(n){let{pattern:e,captured:t}=n;if(e.language!=="ar")return 0;let r=0;for(let[i,o]of t.entries()){let s=Ur[i];if(!s||s.length===0)continue;let a="metadata"in o?o.metadata:void 0;a&&typeof a.prepositionValue=="string"&&(s.includes(a.prepositionValue)?r+=.1:r-=.1);}return Math.max(-Xe,Math.min(Xe,r))}},Kr=new Gr,ce=class Q{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Kr;}matchPattern(e,t){let r=e.mark(),i=new Map;if(this.currentProfile=$(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,i))return e.reset(r),null;let s=this.confidenceModel.calculate({pattern:t,captured:i,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-r.position,confidence:s}}matchBest(e,t){this.matchCache.clear();let r=[],i=e.position();for(let s of t){let a=e.mark(),c=`${i}:${s.id}`,u;this.matchCache.has(c)?u=this.matchCache.get(c):(u=this.matchPattern(e,s),this.matchCache.set(c,u)),u&&r.push(u),e.reset(a);}if(r.length===0)return null;r.sort((s,a)=>{let c=a.pattern.priority-s.pattern.priority;return c!==0?c:a.confidence-s.confidence});let o=r[0];return this.matchPattern(e,o.pattern),o}matchTokenSequence(e,t,r){let i=t[0],o=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();for(let s of t)if(!this.matchPatternToken(e,s,r)){if(this.isOptional(s))continue;return false}return true}matchPatternToken(e,t,r){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,r);case "group":return this.matchGroupToken(e,t,r);default:return false}}matchLiteralToken(e,t){let r=e.peek();if(!r)return false;let i=this.getMatchType(r,t.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let o of t.alternatives){let s=this.getMatchType(r,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,r){this.skipNoiseWords(e);let i=e.peek();if(!i)return t.optional||false;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(o.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,o),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(s.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Ke(a.type,t.expectedTypes)?t.optional||false:(r.set(t.role,a),true);let c=this.tryMatchPropertyAccessExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(c.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,c),true);let u=this.tryMatchSelectorPropertyExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!Ke(u.type,t.expectedTypes)?t.optional||false:(r.set(t.role,u),true);let l=this.tokenToSemanticValue(i);return !l||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(l.type)?t.optional||false:(r.set(t.role,l),e.advance(),true)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=(t.normalized||t.value).toLowerCase(),i=Lr(this.currentProfile,r);if(!i)return null;let o=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(o),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let a=s.value;s.kind==="selector"&&a.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a)&&(a=a.substring(1));let c=a;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)c+=e.peek().value,e.advance();let u=e.peek();return u?.kind==="literal"&&u.value.startsWith("(")&&(c+=u.value,e.advance()),he(L(i),c)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(r),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<Q.MAX_METHOD_ARGS;){let u=e.peek();if(!u)break;if(u.kind==="punctuation"&&u.value===")"){e.advance();break}if(u.kind==="punctuation"&&u.value===","){e.advance();continue}a.push(u.value),e.advance();}return {type:"expression",raw:`${t.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=`${t.value}.${o.value}`,a=1;for(;!e.isAtEnd()&&a<Q.MAX_PROPERTY_DEPTH;){let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")break;e.advance();let l=e.peek();if(!l||l.kind!=="identifier")break;e.advance(),s+=`.${l.value}`,a++;}let c=e.peek();if(c&&c.kind==="punctuation"&&c.value==="("){e.advance();let u=[],l=0;for(;!e.isAtEnd()&&u.length<Q.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(l===0){e.advance();break}l--;}if(p.kind==="punctuation"&&p.value==="("&&l++,p.kind==="punctuation"&&p.value===","){e.advance();continue}u.push(p.value),e.advance();}return {type:"expression",raw:`${s}(${u.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(r),null;e.advance();let o=e.peek();return !o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(r),null):(e.advance(),he(J(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(r),null;let o=e.peek(1);o&&o.kind,e.advance();let s=i.value.slice(1);return he(J(t.value),s)}matchGroupToken(e,t,r){let i=e.mark(),o=new Set(r.keys());if(!this.matchTokenSequence(e,t.tokens,r)){e.reset(i);for(let a of r.keys())o.has(a)||r.delete(a);return t.optional||false}return true}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return J(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=(e.normalized||e.value).toLowerCase();return Fe(t)?L(t):T(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return L(e.value);let r=e.value.toLowerCase();return Fe(r)?L(r):{type:"expression",raw:e.value};case "url":return T(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return T(i,"string")}if(e==="true")return T(true,"boolean");if(e==="false")return T(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?T(e,"duration"):T(i,"number")}let r=parseFloat(e);return isNaN(r)?T(e,"string"):T(r,"number")}applyExtractionRules(e,t){for(let[r,i]of Object.entries(e.extraction))t.has(r)||(i.value!==void 0?t.set(r,{type:"literal",value:i.value}):i.default&&t.set(r,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=t.value.toLowerCase();if(Q.ENGLISH_NOISE_WORDS.has(r)){let i=e.mark();e.advance();let o=e.peek();if(o&&(o.kind==="selector"||o.kind==="identifier"))return;e.reset(i);}r==="class"&&e.advance();}extractEventModifiers(e){let t={},r=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(r=true,o.modifierName){case "once":t.once=true;break;case "debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case "throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case "queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance();}return r?t:void 0}};ce.MAX_PROPERTY_DEPTH=10;ce.MAX_METHOD_ARGS=20;ce.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var dt=ce,z=new dt;function Hr(n){return Br(n)}function ge(n,e){return zr(n,e)}function pt(){return ut()}var Yr={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyut_de\u011Fi\u015Ftir:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};var Qr={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},Jr={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},Zr={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},en={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"}}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},tn={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},rn={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},nn={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},on={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},sn={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},an={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},cn={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},ln={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},un={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},dn={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},pn={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},fn={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},mn={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},hn={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},yn={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},gn={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},vn={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},bn={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},En={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"-e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"-man",sw:"kwa"}}]},Sn={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},wn={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Tn={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},kn={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},xn={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in"}}]},Cn={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},An={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Rn={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""}}]},Pn={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"auf",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},Nn={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},On={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},_n={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},In={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},Mn={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},Ln={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},$n={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Dn={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}}]},Vn={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man"}}]},Bn={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},zn={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},qn={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Wn={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},jn={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with"}}]},Fn={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"destination",roles:[{role:"destination",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"patient",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},Un={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:false,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Gn={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Kn={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Hn={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},Yn={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Xn={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},ft={toggle:Qr,add:Jr,remove:Zr,put:en,set:tn,show:rn,hide:nn,on,trigger:sn,wait:an,fetch:cn,increment:ln,decrement:un,append:dn,prepend:pn,log:fn,get:mn,take:hn,make:yn,halt:gn,settle:vn,throw:bn,send:En,if:Sn,unless:wn,else:Tn,repeat:kn,for:xn,while:Cn,continue:An,go:Rn,transition:Pn,clone:Nn,focus:On,blur:_n,call:In,return:Mn,js:Ln,async:$n,tell:Dn,default:Vn,init:Bn,behavior:zn,install:qn,measure:Wn,swap:jn,morph:Fn,beep:Un,break:Gn,copy:Kn,exit:Hn,pick:Yn,render:Xn,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function Qn(){return Object.values(ft).filter(n=>n.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Mr(),it)).then(({validateAllSchemas:n,formatValidationResults:e})=>{let t=n(ft);t.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(t)),console.warn(`
3
+ These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(n=>{console.debug("Schema validation skipped:",n);});var Je=class extends Error{constructor(n,e,t,r){super(n),this.name="SemanticParseError",this.language=e,this.input=t,this.diagnostics=r;}};function R(n,e,t){return {message:n,severity:e,source:"semantic-parser",...t&&{code:t}}}function ae(n,e){return e.length===0?n:{...n,diagnostics:e}}var G=class N{parse(e,t){let{modifiers:r,remainingInput:i}=this.extractStandaloneModifiers(e,t),o=i||e,s=[],a=ge(o,t),c=q(t);if(c.length===0)throw new Je(`No patterns available for language: ${t}`,t,o,[R(`No patterns registered for language '${t}'`,"error","no-patterns")]);let u=[...c].sort((y,v)=>v.priority-y.priority),l=u.filter(y=>y.command==="on"),d=z.matchBest(a,l);if(d){s.push(R(`event pattern matched: ${d.pattern.id} (confidence: ${d.confidence.toFixed(2)})`,"info","pattern-match"));let y=this.buildEventHandler(d,a,t),v=r?this.applyModifiers(y,r):y;return ae(v,s)}s.push(R(`event patterns: ${l.length} tried, no match`,"info","stage-event"));let p=u.filter(y=>y.command!=="on"),f=z.matchBest(a,p);if(f)return s.push(R(`command pattern matched: ${f.pattern.id} (confidence: ${f.confidence.toFixed(2)})`,"info","pattern-match")),ae(this.buildCommand(f,t),s);s.push(R(`command patterns: ${p.length} tried, no match`,"info","stage-command"));let m=this.trySOVEventExtraction(o,t,u);if(m){s.push(R("SOV event extraction succeeded","info","stage-sov"));let y=r?this.applyModifiers(m,r):m;return ae(y,s)}s.push(R("SOV event extraction: no event keyword found","info","stage-sov"));let g=this.tryCompoundCommandParsing(a,p,t);if(g)return s.push(R("compound command parsing succeeded","info","stage-compound")),ae(g,s);throw s.push(R("compound parsing: no then-keywords or no command matches","info","stage-compound")),s.push(R(`all parse stages exhausted for "${o}"`,"error","parse-failed")),new Je(`Could not parse input in ${t}: ${o}`,t,o,s)}canParse(e,t){try{return this.parse(e,t),!0}catch{return false}}supportedLanguages(){return pt()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let r={};for(let[i,o]of e.captured)r[i]=o;return oe(e.pattern.command,r,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,t,r){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");let o=z.extractEventModifiers(t),s=this.extractOrConjunctionEvents(t,r),a=i;s.length>0&&i.type==="literal"&&(a={type:"literal",value:[String(i.value),...s.map(d=>String("value"in d?d.value:""))].join(" or ")});let c,u=e.captured.get("action");if(u&&u.type==="literal"){let l=u.value,d={};for(let[m,g]of e.captured)m!=="event"&&m!=="action"&&m!=="continues"&&(d[m]=g);let p=oe(l,d,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence}),f=e.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then"){let m=q(r).filter(v=>v.command!=="on").sort((v,E)=>E.priority-v.priority),g=q(r).filter(v=>v.id.startsWith("grammar-")&&v.id.includes("-continuation")).sort((v,E)=>E.priority-v.priority),y=this.parseBodyWithGrammarPatterns(t,m,g,r);y.length>0?c=[p,...y]:c=[p];}else c=[p];}else {let l=q(r).filter(d=>d.command!=="on").sort((d,p)=>p.priority-d.priority);c=this.parseBodyWithClauses(t,l,r);}return Ue(a,c,o,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,r){let i=[],o=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;let a=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,r),c=s.kind==="keyword"&&this.isEndKeyword(s.value,r);if(a){if(o.length>0){let u=this.parseClause(o,t,r);i.push(...u),o.length=0;}e.advance();continue}if(c){if(o.length>0){let u=this.parseClause(o,t,r);i.push(...u);}e.advance();break}o.push(s),e.advance();}if(o.length>0){let s=this.parseClause(o,t,r);i.push(...s);}return i.length>1?[Ge(i,"then",{sourceLanguage:r})]:i}parseClause(e,t,r){if(e.length===0)return [];let i=new X(e,r),o=[];for(;!i.isAtEnd();){let s=z.matchBest(i,t);s?o.push(this.buildCommand(s,r)):i.advance();}if(o.length===0){let s=this.parseSOVClauseByVerbAnchoring(e,r);if(s.length>0)return s}return o}static buildVerbLookup(e){let t=new Map;for(let[r,i]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(r)&&(t.set(i.primary.toLowerCase(),r),i.alternatives))for(let o of i.alternatives)t.set(o.toLowerCase(),r);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[r,i]of Object.entries(e.roleMarkers))if(i&&(t.set(i.primary,r),i.alternatives))for(let o of i.alternatives)t.has(o)||t.set(o,r);return t}parseSOVClauseByVerbAnchoring(e,t){let r=$(t);if(!r||r.wordOrder!=="SOV")return [];let i=N.buildVerbLookup(r),o=N.buildMarkerToRoleLookup(r),s=[],a=0;for(;a<e.length;){let c=-1,u="";for(let m=a;m<e.length;m++){let g=e[m],y=i.get(g.value.toLowerCase()),v=g.normalized?i.get(g.normalized.toLowerCase()):void 0,E=y||v;if(E){c=m,u=E;break}}if(c===-1)break;let l=e.slice(a,c),d=e.length;for(let m=c+1;m<e.length;m++){let g=e[m];if(g.kind==="conjunction"||this.isThenKeyword(g.value,t)){d=m;break}if(m>c+1&&(i.get(g.value.toLowerCase())||(g.normalized?i.get(g.normalized.toLowerCase()):void 0))){d=m;break}}let p=e.slice(c+1,d),f=this.extractRolesFromMarkedTokens(l,p,o,u,t);if(s.push(oe(u,f,{sourceLanguage:t,confidence:.7})),a=d,a<e.length){let m=e[a];(m.kind==="conjunction"||this.isThenKeyword(m.value,t))&&a++;}}return s}extractRolesFromMarkedTokens(e,t,r,i,o){let s={},a=c=>{let u=[];for(let l of c){let d=r.get(l.value);if(d&&l.kind==="particle"&&u.length>0){let p=this.tokensToSemanticValue(u);if(p){let f=this.mapRoleForCommand(d,i,s);f&&(s[f]=p);}u=[];}else u.push(l);}if(u.length>0){let l=this.tokensToSemanticValue(u);l&&(s.patient?s.destination||(s.destination=l):s.patient=l);}};return a(e),a(t),s}mapRoleForCommand(e,t,r){return r[e]?e==="patient"&&!r.destination?"destination":e==="destination"&&!r.patient?"patient":e==="source"&&!r.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let t=e.filter(o=>o.kind!=="whitespace");if(t.length===0)return null;if(t.length===1)return this.tokenToSemanticValue(t[0]);let r=t.map(o=>o.value).join(""),i=t[0];return i.kind==="selector"||i.value.startsWith("#")||i.value.startsWith(".")||i.value.startsWith("@")||i.value.startsWith("*")?J(r):i.kind==="literal"||i.value.startsWith('"')||i.value.startsWith("'")?T(r):i.kind==="reference"?L(r):T(r)}tokenToSemanticValue(e){let t=e.value;if(e.kind==="selector"||t.startsWith("#")||t.startsWith(".")||t.startsWith("@")||t.startsWith("*"))return J(t);if(t.startsWith('"')||t.startsWith("'"))return T(t);if(/^-?\d+(\.\d+)?$/.test(t))return T(parseFloat(t));if(t==="true"||t==="\u771F"||t==="\uCC38"||t==="do\u011Fru")return T(true);if(t==="false"||t==="\u507D"||t==="\uAC70\uC9D3"||t==="yanl\u0131\u015F")return T(false);let r=e.normalized?.toLowerCase();return r==="me"||r==="it"||r==="you"||r==="result"||r==="body"?L(r):e.kind==="reference"?L(e.normalized||"me"):T(t)}parseBodyWithGrammarPatterns(e,t,r,i){let o=[];for(;!e.isAtEnd();){let s=e.peek();if(s&&this.isThenKeyword(s.value,i)){e.advance();continue}if(s&&this.isEndKeyword(s.value,i)){e.advance();break}let a=false;if(r.length>0){let c=z.matchBest(e,r);if(c){let u=c.pattern.command,l={};for(let[f,m]of c.captured)f!=="event"&&f!=="action"&&f!=="continues"&&(l[f]=m);let d=oe(u,l,{sourceLanguage:i,patternId:c.pattern.id});o.push(d),a=true;let p=c.captured.get("continues");if(p&&p.type==="literal"&&p.value==="then")continue}}if(!a){let c=z.matchBest(e,t);c&&(o.push(this.buildCommand(c,i)),a=true);}a||e.advance();}return o}tryCompoundCommandParsing(e,t,r){let i=e.tokens;if(!i.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,r)))return null;let s=new X(i,r),a=this.parseBodyWithClauses(s,t,r);return a.length===0?null:a.length===1?a[0]:Ge(a,"then",{sourceLanguage:r,confidence:.65})}trySOVEventExtraction(e,t,r){let i=N.SOV_EVENT_MARKERS[t];if(!i)return null;let s=ge(e,t).tokens,a=Yr[t],c=new Set;if(a)for(let b of Object.keys(a))c.add(b.toLowerCase());let u=N.SOV_SOURCE_MARKERS[t],l=-1,d="",p="",f=1;for(let b=0;b<s.length;b++){let k=s[b],O=k.value.toLowerCase(),_=O,D="",ue=O.indexOf("[");ue>0&&(_=O.slice(0,ue),D=k.value.slice(ue));let de=k.normalized?.toLowerCase(),Re=de&&N.KNOWN_EVENTS.has(de),Pe=c.has(O)||c.has(_),Ct=N.KNOWN_EVENTS.has(_);if(Re||Pe||Ct){let K;if(Re?K=de:Pe?K=a?.[O]??a?.[_]??_:K=_,i.size>0){let re=1,pe=s[b+1];pe&&pe.kind==="selector"&&pe.value.startsWith("[")&&(re=2);let ne=s[b+re];if(ne&&(ne.kind==="particle"||ne.kind==="keyword")&&i.has(ne.value)){l=b,d=K,p=D||(re===2?s[b+1].value:""),f=re+1;break}}else {l=b,d=K,p=D,f=1;break}}}if(l===-1)return null;let m=new Set;for(let b=l;b<l+f;b++)m.add(b);if(u){let b=l+f;if(b<s.length){let k=s[b];(k.kind==="particle"||k.kind==="keyword")&&u.markers.has(k.value)&&m.add(b);}for(let k=0;k<l;k++){let O=s[k],_=O.value.toLowerCase(),D=O.normalized?.toLowerCase();if(u.windowTokens.has(_)||D&&u.windowTokens.has(D)){m.add(k);break}}}let g=s.filter((b,k)=>!m.has(k));if(g.length===0)return null;let y=r.filter(b=>b.command!=="on"),v=new X(g,t),E=this.parseBodyWithClauses(v,y,t);if(E.length===0)return null;let Ae={sourceLanguage:t,confidence:.75};return p&&(Ae.keyFilter=p),Ue({type:"literal",value:d},E,void 0,Ae)}isThenKeyword(e,t){let r={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (r[t]||r.en).has(e.toLowerCase())}isEndKeyword(e,t){let r={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return (r[t]||r.en).has(e.toLowerCase())}extractStandaloneModifiers(e,t){let i=ge(e,t).tokens;if(i.length===0)return {modifiers:null,remainingInput:null};let s=i[0].value.toLowerCase(),a=N.STANDALONE_MODIFIERS[s];if(!a)return {modifiers:null,remainingInput:null};let c={},u=1;if(a==="once")c.once=true;else {let f=1;if(f<i.length){let m=i[f];(m.kind==="keyword"||m.kind==="particle")&&(f++,u++);}if(f<i.length){let m=i[f];if(m.kind==="literal"){let g=m.value.match(/^(\d+)(ms|s|m)?$/);if(g){let y=parseInt(g[1],10),v=g[2]||"ms";v==="s"?y*=1e3:v==="m"&&(y*=6e4),c[a]=y,u=f+1;}}}c[a]||(c[a]=a==="debounce"?300:100);}let l=i.slice(u);if(l.length===0)return {modifiers:null,remainingInput:null};let d=l[0].position.start,p=e.slice(d);return {modifiers:c,remainingInput:p}}applyModifiers(e,t){return {...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let r=[];for(;;){let i=e.mark(),o=e.peek();if(!o)break;let s=(o.normalized||o.value).toLowerCase();if(!N.OR_KEYWORDS.has(s)){e.reset(i);break}e.advance();let a=e.peek();if(!a){e.reset(i);break}let c=(a.normalized||a.value).toLowerCase();e.advance(),r.push({type:"literal",value:c});}return r}};G.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);G.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"])};G.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])}};G.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};G.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o"]);var Jn=G,Zn=new Jn;function we(n,e){return Zn.parse(n,e)}var Ee=class{constructor(n={}){this.cache=new Map,this.config={maxSize:n.maxSize??1e3,ttlMs:n.ttlMs??0,enabled:n.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(n,e){return `${e}:${n}`}isExpired(n){return this.config.ttlMs===0?false:Date.now()-n.createdAt>this.config.ttlMs}evictLRU(){let n=this.cache.keys().next().value;n!==void 0&&(this.cache.delete(n),this.stats.evictions++);}get(n,e){if(!this.config.enabled){this.stats.misses++;return}let t=this.makeKey(n,e),r=this.cache.get(t);if(!r){this.stats.misses++;return}if(this.isExpired(r)){this.cache.delete(t),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(t),r.lastAccessed=Date.now(),this.cache.set(t,r),this.stats.hits++,r.result}set(n,e,t){if(!this.config.enabled||t.confidence===0)return;let r=this.makeKey(n,e),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(r,{result:t,createdAt:i,lastAccessed:i});}has(n,e){if(!this.config.enabled)return false;let t=this.makeKey(n,e),r=this.cache.get(t);return r?this.isExpired(r)?(this.cache.delete(t),this.stats.expirations++,false):true:false}delete(n,e){let t=this.makeKey(n,e);return this.cache.delete(t)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let n=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:n>0?this.stats.hits/n:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(n){if(n.maxSize!==void 0)for(this.config.maxSize=n.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();n.ttlMs!==void 0&&(this.config.ttlMs=n.ttlMs),n.enabled!==void 0&&(this.config.enabled=n.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}},ei=new Ee;var ti=class{constructor(n={}){this.patternMatcher=new dt,this.languages=new Set(ut()),n.cache===false?this.cache=new Ee({enabled:false}):this.cache=n.cache?new Ee(n.cache):ei;}analyze(n,e){if(!this.supportsLanguage(e))return {confidence:0,errors:[`Language '${e}' is not supported for semantic parsing`]};let t=this.cache.get(n,e);if(t)return t;let r=this.analyzeUncached(n,e);return this.cache.set(n,e,r),r}analyzeUncached(n,e){try{try{let s=we(n,e),a={confidence:s.metadata?.confidence??.8,node:s};return s.kind==="command"?{...a,command:{name:s.action,roles:s.roles}}:a}catch{}let t=Hr(e);if(!t)return {confidence:0,errors:[`No tokenizer available for language '${e}'`]};let r=t.tokenize(n),i=q(e);if(i.length===0)return {confidence:0,errors:[`No patterns available for language '${e}'`]};let o=this.patternMatcher.matchBest(r,i);if(o){let s=this.buildSemanticNode(o);return {confidence:o.confidence,command:{name:o.pattern.command,roles:o.captured},node:s,tokensConsumed:o.consumedTokens}}return {confidence:0,errors:["No pattern matched the input"]}}catch(t){return {confidence:0,errors:[t instanceof Error?t.message:String(t)]}}}supportsLanguage(n){return this.languages.has(n)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear();}configureCache(n){this.cache.configure(n);}buildSemanticNode(n){return {kind:"command",action:n.pattern.command,roles:n.captured,metadata:{patternId:n.pattern.id}}}};function mt(n){return new ti(n)}var ri=.5;function ht(n,e=ri){return n.confidence>=e&&n.command!==void 0}function yt(n,e){let t=e==="SOV"?"sovPosition":"svoPosition";return [...n].sort((r,i)=>{let o=r[t]??99,s=i[t]??99;return o-s})}function ni(n,e){let t=n.markerOverride?.[e.code],r=e.roleMarkers[n.role];if(t!==void 0)return {primary:t,position:r?.position??"before",isOverride:true};if(r&&r.primary){let i={primary:r.primary,position:r.position,isOverride:false};return r.alternatives&&(i.alternatives=r.alternatives),i}return null}function ii(n,e,t,r,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let u=r.primary.split(/\s+/);if(u.length>1)for(let l of u)o.push({type:"literal",value:l});else {let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}}let s=e.roleMarkers.destination;s&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.patient;if(a){let u=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};o.push(u);}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(c),{id:`${n.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`{event} ${r.primary} {destination?} {patient} ${a?.primary||""} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function oi(n,e,t,r,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(c);}if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let c=r.primary.split(/\s+/);if(c.length>1)for(let u of c)o.push({type:"literal",value:u});else {let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(u);}}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${n.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function si(n,e,t,r,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(u);}let a=e.roleMarkers.destination;if(a&&(o.push({type:"role",role:"destination",optional:false}),o.push(a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary})),o.push({type:"role",role:"event",optional:false}),r.position==="after"){let u=r.primary.split(/\s+/);if(u.length>1)for(let l of u)o.push({type:"literal",value:l});else {let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(c),{id:`${n.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`{patient} ${s?.primary||""} {destination} ${a?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function ai(n,e,t,r,i){let o=[];o.push({type:"role",role:"event",optional:false});let s=r.alternatives?.filter(l=>!l.includes(" ")&&l.length>1)||[];s.length>0&&o.push({type:"literal",value:s[0],alternatives:s.slice(1)});let a=e.roleMarkers.destination;a&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary}]}),o.push({type:"role",role:"patient",optional:false});let c=e.roleMarkers.patient;if(c){let l=c.alternatives?{type:"literal",value:c.primary,alternatives:c.alternatives}:{type:"literal",value:c.primary};o.push(l);}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(u),{id:`${n.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(i.basePriority??100)+52,template:{format:`{event}${s[0]||""} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ci(n,e,t,r,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let a=r.primary.split(/\s+/);if(a.length>1)for(let c of a)o.push({type:"literal",value:c});else {let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c);}}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(s),{id:`${n.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{event} ${r.primary} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function li(n,e,t,r){let i=e.eventHandler?.temporalMarkers;if(!i||i.length===0)return null;let o=[];o.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&o.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),o.push({type:"literal",value:i[0],alternatives:i.slice(1)}),o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s?.primary){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(c);}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${n.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(r.basePriority??100)+49,template:{format:`{event} ${i[0]} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function ui(n,e,t,r,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let l=r.primary.split(/\s+/);if(l.length>1)for(let d of l)o.push({type:"literal",value:d});else {let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(d);}}let a=[...n.roles.filter(l=>l.required)].sort((l,d)=>{let p=l.sovPosition??999,f=d.sovPosition??999;return p-f});for(let l of a){o.push({type:"role",role:l.role,optional:false});let d,p;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)d=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(d=f.primary,p=f.alternatives);}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};o.push(f);}}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(c);let u=a.map(l=>`{${l.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`{event} ${r.primary} ${u} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(a.map(l=>[l.role,{fromRole:l.role}]))}}}function di(n,e,t,r,i){let o=[],a=[...n.roles.filter(m=>m.required)].sort((m,g)=>{let y=m.sovPosition??999,v=g.sovPosition??999;return y-v}),c=a[0];o.push({type:"role",role:c.role,optional:false});let u;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)u=c.markerOverride[e.code];else {let m=e.roleMarkers[c.role];m&&(u=m.primary);}if(u&&o.push({type:"literal",value:u}),o.push({type:"role",role:"event",optional:false}),r.position==="after"){let m=r.primary.split(/\s+/);if(m.length>1)for(let g of m)o.push({type:"literal",value:g});else {let g=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(g);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(l);let d=a[1];o.push({type:"role",role:d.role,optional:false});let p,f;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)p=d.markerOverride[e.code];else {let m=e.roleMarkers[d.role];m&&(p=m.primary,f=m.alternatives);}if(p){let m=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};o.push(m);}return {id:`${n.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{${c.role}} {event} ${r.primary} ${t.primary} {${d.role}}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},[c.role]:{fromRole:c.role},[d.role]:{fromRole:d.role}}}}function Ze(n,e,t,r,i){let o=[];if(r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;return a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`${r.primary} {event} ${t.primary} {patient} ${a?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function pi(n,e,t,r,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;if(a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c);}return o.push({type:"role",role:"event",optional:false}),{id:`${n.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`${t.primary} {patient} ${a?.primary||""} {destination?} ${r.primary} {event}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function fi(n,e,t,r,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let c=[...n.roles.filter(l=>l.required)].sort((l,d)=>{let p=l.svoPosition??999,f=d.svoPosition??999;return p-f});for(let l of c){let d,p;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)d=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(d=f.primary,p=f.alternatives);}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};o.push(f);}o.push({type:"role",role:l.role,optional:false});}if(r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}o.push({type:"role",role:"event",optional:false});let u=c.map(l=>`{${l.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${t.primary} ${u} ${r.primary} {event}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(c.map(l=>[l.role,{fromRole:l.role}]))}}}function et(n,e,t,r,i){let o=[];if(r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let c=[...n.roles.filter(l=>l.required)].sort((l,d)=>{let p=l.svoPosition??999,f=d.svoPosition??999;return p-f});for(let l of c){let d,p;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)d=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(d=f.primary,p=f.alternatives);}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};o.push(f);}o.push({type:"role",role:l.role,optional:false});}let u=c.map(l=>`{${l.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`${r.primary} {event} ${t.primary} ${u}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(c.map(l=>[l.role,{fromRole:l.role}]))}}}function mi(n,e,t,r,i){let o=[],s=e.eventHandler?.negationMarker;if(r.position==="before"){let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(u);}if(s){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(u);}o.push({type:"role",role:"event",optional:false});let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(a),o.push({type:"role",role:"patient",optional:false});let c=e.roleMarkers.destination;return c&&o.push({type:"group",optional:true,tokens:[c.alternatives?{type:"literal",value:c.primary,alternatives:c.alternatives}:{type:"literal",value:c.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${r.primary} ${s?.primary||""} {event} ${t.primary} {patient} ${c?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function hi(n,e,t,r){let i=[];i.push({type:"literal",value:"and",alternatives:["then"]}),i.push({type:"role",role:"event",optional:false});let o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(o),i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&i.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(r.basePriority??100)+45,template:{format:`[proclitic?] {event} ${t.primary} {patient} ${s?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var Z={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function gt(n,e,t=Z){let r=`${n.action}-${e.code}-generated`,i=t.basePriority??100,o=e.keywords[n.action];if(!o)throw new Error(`No keyword translation for '${n.action}' in ${e.code}`);let s=bi(n,e,o),a=bt(n,e),c=Ti(n,e,o);return {id:r,language:e.code,command:n.action,priority:i,template:{format:c,tokens:s},extraction:a}}function yi(n,e,t=Z){if(n.roles.filter(a=>!a.required).length===0)return null;let i=n.roles.filter(a=>a.required),o={...n,roles:i};return {...gt(o,e,t),id:`${n.action}-${e.code}-generated-simple`,priority:(t.basePriority??100)-5,extraction:bt(n,e)}}function gi(n,e,t=Z){let r=[];if(r.push(gt(n,e,t)),t.generateSimpleVariants){let i=yi(n,e,t);i&&r.push(i);}return r}function vt(n,e=Z){let t=[],r=Qn();for(let i of r){if(!n.keywords[i.action])continue;let o=gi(i,n,e);if(t.push(...o),n.eventHandler?.eventMarker){let s=vi(i,n,e);t.push(...s);}}return t}function vi(n,e,t=Z){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let r=[],i=e.eventHandler.eventMarker,o=e.keywords[n.action];if(!o)return [];let a=n.roles.filter(c=>c.required).length===2;if(e.wordOrder==="SOV")if(a)r.push(ui(n,e,o,i,t)),r.push(di(n,e,o,i,t));else {r.push(ii(n,e,o,i,t)),r.push(oi(n,e,o,i,t));let c=e.roleMarkers.destination;c&&c.primary!==i.primary&&r.push(si(n,e,o,i,t));let u=i.primary.split(/\s+/),l=i.alternatives?.some(p=>!p.includes(" ")&&p.length>1);u.length>1&&l&&r.push(ai(n,e,o,i,t)),r.push(ci(n,e,o,i,t));let d=li(n,e,o,t);d&&r.push(d);}else e.wordOrder==="VSO"?a?(r.push(et(n,e,o,i,t)),r.push(fi(n,e,o,i,t))):(r.push(Ze(n,e,o,i,t)),r.push(pi(n,e,o,i,t)),e.eventHandler?.negationMarker&&r.push(mi(n,e,o,i,t)),e.tokenization?.prefixes&&r.push(hi(n,e,o,t))):a?r.push(et(n,e,o,i,t)):r.push(Ze(n,e,o,i,t));return r}function bi(n,e,t){let r=[],i=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},o=Ei(n,e);switch(e.wordOrder){case "SVO":r.push(i),r.push(...o);break;case "SOV":r.push(...o),r.push(i);break;case "VSO":r.push(i),r.push(...o);break;default:r.push(i),r.push(...o);}return r}function Ei(n,e){let t=[],r=yt(n.roles,e.wordOrder);for(let i of r){let o=Si(i,e);i.required?t.push(...o):t.push({type:"group",optional:true,tokens:o});}return t}function Si(n,e){let t=[],r=n.markerOverride?.[e.code],i=e.roleMarkers[n.role],o={type:"role",role:n.role,optional:!n.required,expectedTypes:n.expectedTypes};if(r!==void 0)(i?.position??"before")==="before"?(r&&t.push({type:"literal",value:r}),t.push(o)):(t.push(o),r&&t.push({type:"literal",value:r}));else if(i)if(i.position==="before"){if(i.primary){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}t.push(o);}else {t.push(o);let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}else t.push(o);return t}function wi(n,e){let t={};for(let r of n.roles){let i=r.markerOverride?.[e.code],o=e.roleMarkers[r.role];i!==void 0?t[r.role]=i?{marker:i}:{}:o&&o.primary?t[r.role]=o.alternatives?{marker:o.primary,markerAlternatives:o.alternatives}:{marker:o.primary}:t[r.role]={};}return t}function bt(n,e){let t=wi(n,e),r={};for(let i of n.roles){let o=t[i.role]||{};!i.required&&i.default?r[i.role]={...o,default:i.default}:r[i.role]=o;}return r}function Ti(n,e,t){let r=[],o=yt(n.roles,e.wordOrder).map(s=>{let a=ni(s,e),c="";return a&&a.primary?a.position==="before"?c=`${a.primary} {${s.role}}`:c=`{${s.role}} ${a.primary}`:c=`{${s.role}}`,s.required?c:`[${c}]`});switch(e.wordOrder){case "SVO":case "VSO":r.push(t.primary,...o);break;case "SOV":r.push(...o,t.primary);break;default:r.push(t.primary,...o);}return r.join(" ")}function le(n){let e=n.getAttribute("data-lang");if(e)return Te(e);let t=n.getAttribute("data-hyperscript-lang")??n.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return Te(t);let r=typeof document<"u"?document.documentElement?.lang:null;return r&&r!=="en"?Te(r):null}function Te(n){return n.split("-")[0].toLowerCase()}var Et={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],blur:[["patient",""]],break:[],call:[["patient",""]],clone:[["patient",""],["destination","into"]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","to"]],on:[["event",""],["source","from"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],return:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["patient",""]],while:[["condition",""]]};function te(n){switch(n.kind){case "event-handler":return ki(n);case "compound":return xi(n);default:return Ci(n)}}function ki(n){let e=["on"],t=n.roles.get("event");t&&e.push(ee(t));let r=n.roles.get("source");if(r&&e.push("from",ee(r)),n.body&&n.body.length>0){let i=n.body.map(te);e.push(i.join(" then "));}return e.join(" ")}function xi(n){let e=n.chainType==="async"?"async":n.chainType;return n.statements.map(te).join(` ${e} `)}function Ci(n){let e=Et[n.action];if(e){let r=[n.action];for(let[i,o]of e){let s=n.roles.get(i);s&&(i==="destination"&&s.type==="reference"&&s.value==="me"||(o&&r.push(o),r.push(ee(s))));}return r.join(" ")}let t=[n.action];for(let[,r]of n.roles)t.push(ee(r));return t.join(" ")}function ee(n){switch(n.type){case "literal":return typeof n.value=="string"&&n.dataType==="string"?`"${n.value}"`:String(n.value);case "selector":return n.value;case "reference":return n.value;case "property-path":return Ai(n);case "expression":return n.raw;case "flag":return n.enabled?`+${n.name}`:`~${n.name}`}}function Ai(n){let e=ee(n.object),t=n.property;if(n.object.type==="reference")switch(n.object.value){case "me":return `my ${t}`;case "it":return `its ${t}`;case "you":return `your ${t}`}return `${e}'s ${t}`}var wt=.5,Ri={confidenceThreshold:wt,strategy:"semantic",fallbackToOriginal:true};function Pi(n,e){return typeof n=="number"?n:n[e]??n["*"]??wt}var ke=null;function Ni(){return ke||(ke=mt()),ke}function xe(n,e,t={}){let r={...Ri,...t},i=St(n,e,r);if(i!==null)return i;let o=_i(n);if(o){let s=St(o.commands,e,r);if(s!==null)return o.prefix+s}return n}function St(n,e,t){if(t.strategy==="semantic"||t.strategy==="auto"){let r=Pi(t.confidenceThreshold,e),i=Tt(n,e,r);if(i!==null)return i}if((t.strategy==="auto"||t.strategy==="i18n")&&t.i18nToEnglish){let r=Ii(n,e,t.i18nToEnglish);if(r!==null)return r}return null}var Oi=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function _i(n){let e=n.match(Oi);if(!e)return null;let t=e[1],r=n.slice(t.length);return r?{prefix:t,commands:r}:null}function Tt(n,e,t){try{let r=Li(n,e);if(r.length>1)return $i(r,e,t);let i=Ni();if(!i.supportsLanguage(e))return null;let o=i.analyze(n,e);if(!ht(o,t))return null;if(o.node)return te(o.node);let s=we(n,e);return te(s)}catch{return null}}function Ii(n,e,t){try{let r=t(n,e);return r!==n?r:null}catch{return null}}function Mi(n){let e=["then"],t=$(n);if(t?.keywords?.then){let r=t.keywords.then;if(r.primary&&r.primary!=="then"&&e.push(r.primary),r.alternatives)for(let i of r.alternatives)e.includes(i)||e.push(i);}return e}function Li(n,e){let r=Mi(e).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\s+(?:${r.join("|")})\\s+`,"i"),o=n.split(`
4
+ `).map(a=>a.trim()).filter(a=>a.length>0),s=[];for(let a of o){let c=a.split(i);s.push(...c);}return s}function $i(n,e,t){let r=[];for(let i of n){let o=Tt(i.trim(),e,t);if(o===null)return null;r.push(o);}return r.join(" then ")}function Ce(n={}){return function(t){let{internals:r}=t,i=r.runtime,o=i.getScript.bind(i);i.getScript=function(s){let a=o(s);if(!a)return null;let c=Di(s,n);if(!c||c==="en")return a;let u=xe(a,c,n);return n.debug&&u!==a&&console.log(`[hyperscript-i18n] ${c}: "${a}" \u2192 "${u}"`),u};}}function Di(n,e){if(e.languageAttribute){let r=n.getAttribute(e.languageAttribute);if(r)return r.split("-")[0].toLowerCase()}let t=le(n);return t||(e.defaultLanguage??null)}function kt(n,e,t={}){return e==="en"?n:xe(n,e,t)}lt(n=>vt(n));function xt(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Ce()),Vi());}function Vi(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let t=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(t).forEach(r=>{let i=e.getInternalData(r);i.initialized&&(i.initialized=false);}),e.processNode(document.body);}var Zo=["es"];xt();exports.plugin=Ce;exports.preprocess=kt;exports.resolveLanguage=le;exports.supportedLanguages=Zo;return exports;})({});