@lokascript/semantic 1.0.0 → 1.1.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 (162) hide show
  1. package/dist/browser-ar.ar.global.js +2 -2
  2. package/dist/browser-core.core.global.js +2 -2
  3. package/dist/browser-de.de.global.js +2 -2
  4. package/dist/browser-east-asian.east-asian.global.js +2 -2
  5. package/dist/browser-en-tr.en-tr.global.js +2 -2
  6. package/dist/browser-en.en.global.js +2 -2
  7. package/dist/browser-es-en.es-en.global.js +2 -2
  8. package/dist/browser-es.es.global.js +2 -2
  9. package/dist/browser-fr.fr.global.js +2 -2
  10. package/dist/browser-id.id.global.js +2 -2
  11. package/dist/browser-ja.ja.global.js +2 -2
  12. package/dist/browser-ko.ko.global.js +2 -2
  13. package/dist/browser-lazy.lazy.global.js +2 -2
  14. package/dist/browser-priority.priority.global.js +2 -2
  15. package/dist/browser-pt.pt.global.js +2 -2
  16. package/dist/browser-qu.qu.global.js +2 -2
  17. package/dist/browser-sw.sw.global.js +2 -2
  18. package/dist/browser-tr.tr.global.js +2 -2
  19. package/dist/browser-western.western.global.js +2 -2
  20. package/dist/browser-zh.zh.global.js +2 -2
  21. package/dist/browser.global.js +2 -2
  22. package/dist/browser.global.js.map +1 -1
  23. package/dist/index.cjs +13042 -17462
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +49 -5
  26. package/dist/index.d.ts +49 -5
  27. package/dist/index.js +14044 -18464
  28. package/dist/index.js.map +1 -1
  29. package/dist/languages/ar.d.ts +1 -1
  30. package/dist/languages/ar.js +31 -44
  31. package/dist/languages/ar.js.map +1 -1
  32. package/dist/languages/de.d.ts +1 -1
  33. package/dist/languages/de.js +14 -2
  34. package/dist/languages/de.js.map +1 -1
  35. package/dist/languages/en.d.ts +1 -1
  36. package/dist/languages/en.js +558 -12
  37. package/dist/languages/en.js.map +1 -1
  38. package/dist/languages/es.d.ts +1 -1
  39. package/dist/languages/es.js +16 -0
  40. package/dist/languages/es.js.map +1 -1
  41. package/dist/languages/fr.d.ts +1 -1
  42. package/dist/languages/fr.js +14 -2
  43. package/dist/languages/fr.js.map +1 -1
  44. package/dist/languages/id.d.ts +1 -1
  45. package/dist/languages/id.js +14 -2
  46. package/dist/languages/id.js.map +1 -1
  47. package/dist/languages/ja.d.ts +1 -1
  48. package/dist/languages/ja.js +18 -3
  49. package/dist/languages/ja.js.map +1 -1
  50. package/dist/languages/ko.d.ts +8 -1
  51. package/dist/languages/ko.js +75 -43
  52. package/dist/languages/ko.js.map +1 -1
  53. package/dist/languages/pt.d.ts +1 -1
  54. package/dist/languages/pt.js +17 -0
  55. package/dist/languages/pt.js.map +1 -1
  56. package/dist/languages/qu.d.ts +12 -1
  57. package/dist/languages/qu.js +77 -2
  58. package/dist/languages/qu.js.map +1 -1
  59. package/dist/languages/sw.d.ts +1 -1
  60. package/dist/languages/sw.js.map +1 -1
  61. package/dist/languages/tr.d.ts +9 -1
  62. package/dist/languages/tr.js +96 -72
  63. package/dist/languages/tr.js.map +1 -1
  64. package/dist/languages/zh.d.ts +1 -1
  65. package/dist/languages/zh.js +16 -0
  66. package/dist/languages/zh.js.map +1 -1
  67. package/dist/{types-C4dcj53L.d.ts → types-BY3Id07j.d.ts} +20 -5
  68. package/package.json +20 -29
  69. package/src/generators/command-schemas.ts +21 -10
  70. package/src/generators/event-handler-generator.ts +50 -44
  71. package/src/generators/language-profiles.ts +6 -0
  72. package/src/generators/pattern-generator.ts +883 -1
  73. package/src/generators/profiles/arabic.ts +19 -3
  74. package/src/generators/profiles/bengali.ts +12 -1
  75. package/src/generators/profiles/chinese.ts +15 -0
  76. package/src/generators/profiles/french.ts +12 -1
  77. package/src/generators/profiles/german.ts +12 -1
  78. package/src/generators/profiles/hebrew.ts +148 -0
  79. package/src/generators/profiles/hindi.ts +12 -1
  80. package/src/generators/profiles/index.ts +2 -0
  81. package/src/generators/profiles/indonesian.ts +12 -1
  82. package/src/generators/profiles/italian.ts +16 -0
  83. package/src/generators/profiles/japanese.ts +11 -2
  84. package/src/generators/profiles/korean.ts +15 -1
  85. package/src/generators/profiles/polish.ts +12 -0
  86. package/src/generators/profiles/portuguese.ts +16 -0
  87. package/src/generators/profiles/russian.ts +11 -0
  88. package/src/generators/profiles/spanish.ts +15 -0
  89. package/src/generators/profiles/spanishMexico.ts +176 -0
  90. package/src/generators/profiles/thai.ts +11 -0
  91. package/src/generators/profiles/turkish.ts +49 -7
  92. package/src/generators/profiles/types.ts +21 -5
  93. package/src/generators/profiles/ukrainian.ts +11 -0
  94. package/src/generators/profiles/vietnamese.ts +11 -0
  95. package/src/language-building-schema.ts +111 -0
  96. package/src/languages/_all.ts +5 -1
  97. package/src/languages/es-MX.ts +32 -0
  98. package/src/languages/he.ts +15 -0
  99. package/src/parser/pattern-matcher.ts +10 -1
  100. package/src/parser/semantic-parser.ts +3 -0
  101. package/src/patterns/add/ar.ts +3 -59
  102. package/src/patterns/add/index.ts +5 -1
  103. package/src/patterns/add/ja.ts +3 -81
  104. package/src/patterns/add/ko.ts +3 -62
  105. package/src/patterns/add/qu.ts +69 -0
  106. package/src/patterns/add/tr.ts +3 -59
  107. package/src/patterns/builders.ts +1 -0
  108. package/src/patterns/decrement/tr.ts +3 -36
  109. package/src/patterns/event-handler/ar.ts +3 -139
  110. package/src/patterns/event-handler/he.ts +15 -0
  111. package/src/patterns/event-handler/index.ts +5 -1
  112. package/src/patterns/event-handler/ja.ts +3 -106
  113. package/src/patterns/event-handler/ko.ts +3 -121
  114. package/src/patterns/event-handler/ms.ts +45 -20
  115. package/src/patterns/event-handler/tr.ts +3 -158
  116. package/src/patterns/get/ar.ts +3 -37
  117. package/src/patterns/get/ja.ts +3 -41
  118. package/src/patterns/get/ko.ts +3 -41
  119. package/src/patterns/grammar-transformed/ja.ts +3 -1701
  120. package/src/patterns/grammar-transformed/ko.ts +3 -1299
  121. package/src/patterns/grammar-transformed/tr.ts +3 -1055
  122. package/src/patterns/hide/ar.ts +3 -55
  123. package/src/patterns/hide/ja.ts +3 -57
  124. package/src/patterns/hide/ko.ts +3 -57
  125. package/src/patterns/hide/tr.ts +3 -53
  126. package/src/patterns/increment/tr.ts +3 -40
  127. package/src/patterns/put/ar.ts +3 -62
  128. package/src/patterns/put/ja.ts +3 -63
  129. package/src/patterns/put/ko.ts +3 -55
  130. package/src/patterns/put/tr.ts +3 -55
  131. package/src/patterns/remove/ar.ts +3 -59
  132. package/src/patterns/remove/index.ts +5 -1
  133. package/src/patterns/remove/ja.ts +3 -62
  134. package/src/patterns/remove/ko.ts +3 -66
  135. package/src/patterns/remove/qu.ts +69 -0
  136. package/src/patterns/remove/tr.ts +3 -66
  137. package/src/patterns/set/ar.ts +3 -72
  138. package/src/patterns/set/ja.ts +3 -74
  139. package/src/patterns/set/ko.ts +3 -73
  140. package/src/patterns/set/tr.ts +3 -95
  141. package/src/patterns/show/ar.ts +3 -55
  142. package/src/patterns/show/ja.ts +3 -57
  143. package/src/patterns/show/ko.ts +3 -61
  144. package/src/patterns/show/tr.ts +3 -53
  145. package/src/patterns/take/ar.ts +3 -39
  146. package/src/patterns/toggle/ar.ts +3 -49
  147. package/src/patterns/toggle/index.ts +5 -1
  148. package/src/patterns/toggle/ja.ts +3 -144
  149. package/src/patterns/toggle/ko.ts +3 -101
  150. package/src/patterns/toggle/qu.ts +90 -0
  151. package/src/patterns/toggle/tr.ts +3 -76
  152. package/src/registry.ts +179 -15
  153. package/src/tokenizers/arabic.ts +13 -46
  154. package/src/tokenizers/bengali.ts +2 -16
  155. package/src/tokenizers/he.ts +542 -0
  156. package/src/tokenizers/index.ts +1 -0
  157. package/src/tokenizers/japanese.ts +3 -1
  158. package/src/tokenizers/korean.ts +104 -48
  159. package/src/tokenizers/ms.ts +3 -0
  160. package/src/tokenizers/quechua.ts +101 -2
  161. package/src/tokenizers/turkish.ts +64 -69
  162. package/src/types.ts +13 -0
@@ -1,2 +1,2 @@
1
- "use strict";var LokaScriptSemanticEsEn=(()=>{var xe=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var bt=Object.prototype.hasOwnProperty;var Pt=(n,e)=>{for(var t in e)xe(n,t,{get:e[t],enumerable:!0})},kt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Tt(e))!bt.call(n,o)&&o!==t&&xe(n,o,{get:()=>e[o],enumerable:!(r=St(e,o))||r.enumerable});return n};var Et=n=>kt(xe({},"__esModule",{value:!0}),n);var io={};Pt(io,{ASTBuilder:()=>ee,DEFAULT_CONFIDENCE_THRESHOLD:()=>qe,HIGH_CONFIDENCE_THRESHOLD:()=>yt,SemanticAnalyzerImpl:()=>te,VERSION:()=>Jn,buildAST:()=>gt,canParse:()=>ze,createCommandNode:()=>A,createEventHandler:()=>H,createLiteral:()=>b,createPropertyPath:()=>F,createReference:()=>L,createSelector:()=>M,createSemanticAnalyzer:()=>ht,englishProfile:()=>N,englishTokenizer:()=>se,fromExplicit:()=>ge,getAllTranslations:()=>oo,getCommandMapper:()=>J,getPatternsForLanguage:()=>xt,getPatternsForLanguageAndCommand:()=>ro,getProfile:()=>Te,getSupportedLanguages:()=>eo,getTokenizer:()=>Se,isExplicitSyntax:()=>B,isLanguageSupported:()=>Ge,parse:()=>W,parseAny:()=>he,parseExplicit:()=>q,registerCommandMapper:()=>Oe,render:()=>_,renderExplicit:()=>X,shouldUseSemanticResult:()=>vt,spanishProfile:()=>I,spanishTokenizer:()=>de,toExplicit:()=>Me,tokenize:()=>to,translate:()=>no});var K=new Map,ne=new Map,Q=new Map;var Be=null;function oe(n,e,t){K.set(n,e),ne.set(n,t),Q.delete(n)}var We=new Map;function je(n,e){We.set(n,e),Q.delete(n)}function Se(n){let e=K.get(n);if(!e){let t=Array.from(K.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 Te(n){let e=ne.get(n);if(!e){let t=Array.from(ne.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 e}function Ke(n){return K.get(n)}function G(n){return ne.get(n)}function ie(){return Array.from(K.keys())}function Ge(n){return K.has(n)}function Ue(n,e){return Se(e).tokenize(n)}function C(n){let e=Q.get(n);if(e)return e;let t=We.get(n);if(t)return Q.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=Te(n),o=Be(r);return Q.set(n,o),o}function $e(n,e){return C(n).filter(t=>t.command===e).sort((t,r)=>r.priority-t.priority)}var R=class{constructor(e,t){this.pos=0;this.tokens=e,this.language=t}peek(e=0){let t=this.pos+e;return t<0||t>=this.tokens.length?null:this.tokens[t]}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(e){this.pos=e.position}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(e){let t=[];for(;!this.isAtEnd()&&e(this.peek());)t.push(this.advance());return t}skipWhile(e){for(;!this.isAtEnd()&&e(this.peek());)this.advance()}};function v(n,e){return{start:n,end:e}}function x(n,e,t,r){if(typeof r=="string")return{value:n,kind:e,position:t,normalized:r};if(r){let{normalized:o,stem:i,stemConfidence:a}=r,s={value:n,kind:e,position:t};return o!==void 0&&(s.normalized=o),i!==void 0&&(s.stem=i,a!==void 0&&(s.stemConfidence=a)),s}return{value:n,kind:e,position:t}}function w(n){return/\s/.test(n)}function U(n){return n==="#"||n==="."||n==="["||n==="@"||n==="*"||n==="<"}function $(n){return n==='"'||n==="'"||n==="`"||n==="\u300C"||n==="\u300D"}function k(n){return/\d/.test(n)}function De(n){return/[a-zA-Z]/.test(n)}function T(n){return/[a-zA-Z0-9_-]/.test(n)}function be(n){let e=r=>n.test(r);return{isLetter:e,isIdentifierChar:r=>e(r)||/[0-9_-]/.test(r)}}function Fe(n,e){if(e>=n.length)return null;let t=n[e];if(!U(t))return null;let r=e,o="";if(t==="#"||t==="."){for(o+=n[r++];r<n.length&&T(n[r]);)o+=n[r++];if(o.length<=1)return null;if(r<n.length&&n[r]==="."&&t==="#"){let a=r+1;for(;a<n.length&&T(n[a]);)a++;if(a<n.length&&n[a]==="(")return o}}else if(t==="["){let i=1,a=!1,s=null,l=!1;for(o+=n[r++];r<n.length&&i>0;){let c=n[r];o+=c,l?l=!1:c==="\\"?l=!0:a?c===s&&(a=!1,s=null):c==='"'||c==="'"||c==="`"?(a=!0,s=c):c==="["?i++:c==="]"&&i--,r++}if(i!==0)return null}else if(t==="@"){for(o+=n[r++];r<n.length&&T(n[r]);)o+=n[r++];if(o.length<=1)return null}else if(t==="*"){for(o+=n[r++];r<n.length&&T(n[r]);)o+=n[r++];if(o.length<=1)return null}else if(t==="<"){if(o+=n[r++],r>=n.length||!De(n[r]))return null;for(;r<n.length&&T(n[r]);)o+=n[r++];for(;r<n.length;){let i=n[r];if(i==="."){if(o+=n[r++],r>=n.length||!T(n[r]))return null;for(;r<n.length&&T(n[r]);)o+=n[r++]}else if(i==="#"){if(o+=n[r++],r>=n.length||!T(n[r]))return null;for(;r<n.length&&T(n[r]);)o+=n[r++]}else if(i==="["){let a=1,s=!1,l=null,c=!1;for(o+=n[r++];r<n.length&&a>0;){let p=n[r];o+=p,c?c=!1:p==="\\"?c=!0:s?p===l&&(s=!1,l=null):p==='"'||p==="'"||p==="`"?(s=!0,l=p):p==="["?a++:p==="]"&&a--,r++}if(a!==0)return null}else break}for(;r<n.length&&w(n[r]);)o+=n[r++];if(r<n.length&&n[r]==="/")for(o+=n[r++];r<n.length&&w(n[r]);)o+=n[r++];if(r>=n.length||n[r]!==">")return null;o+=n[r++]}return o||null}function Pe(n,e){if(e>=n.length||n[e]!=="'"||e+1>=n.length||n[e+1].toLowerCase()!=="s")return!1;if(e+2>=n.length)return!0;let r=n[e+2];return w(r)||r==="*"||!T(r)}function He(n,e){if(e>=n.length)return null;let t=n[e];if(!$(t)||t==="'"&&Pe(n,e))return null;let o={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!o)return null;let i=e+1,a=t,s=!1;for(;i<n.length;){let l=n[i];if(a+=l,s)s=!1;else if(l==="\\")s=!0;else if(l===o)return a;i++}return a}function D(n,e){if(e>=n.length)return!1;let t=n[e],r=n[e+1]||"",o=n[e+2]||"";if(t==="/"&&r!=="/"&&/[a-zA-Z0-9._-]/.test(r)||t==="/"&&r==="/"&&/[a-zA-Z]/.test(o)||t==="."&&(r==="/"||r==="."&&o==="/"))return!0;let i=n.slice(e,e+8).toLowerCase();return!!(i.startsWith("http://")||i.startsWith("https://"))}function Xe(n,e){if(!D(n,e))return null;let t=e,r="",o=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<n.length;){let i=n[t];if(i==="#"){if(r.length>0&&/[a-zA-Z0-9/.]$/.test(r))for(r+=i,t++;t<n.length&&/[a-zA-Z0-9_-]/.test(n[t]);)r+=n[t++];break}if(o.test(i))r+=i,t++;else break}return r.length<2?null:r}function Qe(n,e){if(e>=n.length)return null;let t=n[e];if(!k(t)&&t!=="-"&&t!=="+")return null;let r=e,o="";if((n[r]==="-"||n[r]==="+")&&(o+=n[r++]),r>=n.length||!k(n[r]))return null;for(;r<n.length&&k(n[r]);)o+=n[r++];if(r<n.length&&n[r]===".")for(o+=n[r++];r<n.length&&k(n[r]);)o+=n[r++];return r<n.length&&(n.slice(r,r+2)==="ms"?o+="ms":(n[r]==="s"||n[r]==="m"||n[r]==="h")&&(o+=n[r])),o}var ae=class ae{constructor(){this.profileKeywords=[];this.profileKeywordMap=new Map}initializeKeywordsFromProfile(e,t=[]){let r=new Map;if(e.keywords){for(let[o,i]of Object.entries(e.keywords))if(r.set(i.primary,{native:i.primary,normalized:i.normalized||o}),i.alternatives)for(let a of i.alternatives)r.set(a,{native:a,normalized:i.normalized||o})}if(e.references)for(let[o,i]of Object.entries(e.references))r.set(i,{native:i,normalized:o});if(e.roleMarkers){for(let[o,i]of Object.entries(e.roleMarkers))if(i.primary&&r.set(i.primary,{native:i.primary,normalized:o}),i.alternatives)for(let a of i.alternatives)r.set(a,{native:a,normalized:o})}for(let o of t)r.set(o.native,o);this.profileKeywords=Array.from(r.values()).sort((o,i)=>i.native.length-o.native.length),this.profileKeywordMap=new Map;for(let o of this.profileKeywords){this.profileKeywordMap.set(o.native.toLowerCase(),o);let i=this.removeDiacritics(o.native);i!==o.native&&!this.profileKeywordMap.has(i.toLowerCase())&&this.profileKeywordMap.set(i.toLowerCase(),o)}}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 x(r.native,"keyword",v(t,t+r.native.length),r.normalized);return null}isKeywordStart(e,t){let r=e.slice(t);return this.profileKeywords.some(o=>r.startsWith(o.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 o=this.tryNormalize(e);if(!o)return null;let i=this.lookupKeyword(o.stem);if(!i)return null;let a={normalized:i.normalized,stem:o.stem,stemConfidence:o.confidence};return x(e,"keyword",v(t,r),a)}trySelector(e,t){let r=Fe(e,t);return r?x(r,"selector",v(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 o=r[0].replace(/(\s|\.)$/,""),i=o.slice(1).split("(")[0],a=r[1];return{...x(o,"event-modifier",v(t,t+o.length)),metadata:{modifierName:i,value:a?i==="queue"?a:parseInt(a,10):void 0}}}tryString(e,t){let r=He(e,t);return r?x(r,"literal",v(t,t+r.length)):null}tryNumber(e,t){let r=Qe(e,t);return r?x(r,"literal",v(t,t+r.length)):null}tryMatchTimeUnit(e,t,r,o=!1){let i=t;if(o)for(;i<e.length&&w(e[i]);)i++;let a=e.slice(i);for(let s of r){let l=a.slice(0,s.length);if(s.caseInsensitive?l.toLowerCase()===s.pattern.toLowerCase():l===s.pattern){if(s.notFollowedBy&&(a[s.length]||"")===s.notFollowedBy)continue;if(s.checkBoundary){let p=a[s.length]||"";if(T(p))continue}return{suffix:s.suffix,endPos:i+s.length}}}return null}parseBaseNumber(e,t,r=!0){let o=t,i="";if(r&&(e[o]==="-"||e[o]==="+")&&(i+=e[o++]),o>=e.length||!k(e[o]))return null;for(;o<e.length&&k(e[o]);)i+=e[o++];if(o<e.length&&e[o]===".")for(i+=e[o++];o<e.length&&k(e[o]);)i+=e[o++];return!i||i==="-"||i==="+"?null:{number:i,endPos:o}}tryNumberWithTimeUnits(e,t,r,o={}){let{allowSign:i=!0,skipWhitespace:a=!1}=o,s=this.parseBaseNumber(e,t,i);if(!s)return null;let{number:l,endPos:c}=s,p=[...r,...ae.STANDARD_TIME_UNITS],S=this.tryMatchTimeUnit(e,c,p,a);return S&&(l+=S.suffix,c=S.endPos),x(l,"literal",v(t,c))}tryUrl(e,t){let r=Xe(e,t);return r?x(r,"url",v(t,t+r.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!T(e[t+1]))return null;let r=t+1;for(;r<e.length&&T(e[r]);)r++;let o=e.slice(t,r);return x(o,"identifier",v(t,r))}tryOperator(e,t){let r=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(r))return x(r,"operator",v(t,t+2));let o=e[t];return["<",">","!","+","-","*","/","="].includes(o)?x(o,"operator",v(t,t+1)):["(",")","{","}",",",";",":"].includes(o)?x(o,"punctuation",v(t,t+1)):null}tryMultiCharParticle(e,t,r){for(let o of r)if(e.slice(t,t+o.length)===o)return x(o,"particle",v(t,t+o.length));return null}};ae.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:!0},{pattern:"m",suffix:"m",length:1,checkBoundary:!0,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:!0}];var V=ae;var N={code:"en",name:"English",nativeName:"English",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,defaultVerbForm:"base",verb:{position:"start",subjectDrop:!1},references:{me:"me",it:"it",you:"you",result:"result",event:"event",target:"target",body:"body"},possessive:{marker:"'s",markerPosition:"after-object",specialForms:{me:"my",it:"its",you:"your"},keywords:{my:"me",your:"you",its:"it"}},roleMarkers:{destination:{primary:"on",alternatives:["to","from"],position:"before"},source:{primary:"from",position:"before"},patient:{primary:"",position:"before"},style:{primary:"with",alternatives:["by","using"],position:"before"},responseType:{primary:"as",position:"before"},method:{primary:"via",alternatives:["using"],position:"before"}},keywords:{toggle:{primary:"toggle"},add:{primary:"add"},remove:{primary:"remove"},put:{primary:"put"},append:{primary:"append"},prepend:{primary:"prepend"},take:{primary:"take"},make:{primary:"make"},clone:{primary:"clone"},swap:{primary:"swap"},morph:{primary:"morph"},set:{primary:"set"},get:{primary:"get"},increment:{primary:"increment"},decrement:{primary:"decrement"},log:{primary:"log"},show:{primary:"show"},hide:{primary:"hide"},transition:{primary:"transition"},on:{primary:"on"},trigger:{primary:"trigger"},send:{primary:"send"},focus:{primary:"focus"},blur:{primary:"blur"},go:{primary:"go"},wait:{primary:"wait"},fetch:{primary:"fetch"},settle:{primary:"settle"},if:{primary:"if"},when:{primary:"when",normalized:"when"},where:{primary:"where",normalized:"where"},else:{primary:"else"},repeat:{primary:"repeat"},for:{primary:"for"},while:{primary:"while"},continue:{primary:"continue"},halt:{primary:"halt"},throw:{primary:"throw"},call:{primary:"call"},return:{primary:"return"},then:{primary:"then"},and:{primary:"and"},end:{primary:"end"},js:{primary:"js"},async:{primary:"async"},tell:{primary:"tell"},default:{primary:"default"},init:{primary:"init"},behavior:{primary:"behavior"},install:{primary:"install"},measure:{primary:"measure"},into:{primary:"into"},before:{primary:"before"},after:{primary:"after"},until:{primary:"until"},event:{primary:"event"},from:{primary:"from"}}};var Ct=[{native:"true",normalized:"true"},{native:"false",normalized:"false"},{native:"null",normalized:"null"},{native:"undefined",normalized:"undefined"},{native:"first",normalized:"first"},{native:"last",normalized:"last"},{native:"next",normalized:"next"},{native:"previous",normalized:"previous"},{native:"closest",normalized:"closest"},{native:"click",normalized:"click"},{native:"dblclick",normalized:"dblclick"},{native:"mousedown",normalized:"mousedown"},{native:"mouseup",normalized:"mouseup"},{native:"mouseover",normalized:"mouseover"},{native:"mouseout",normalized:"mouseout"},{native:"mouseenter",normalized:"mouseenter"},{native:"mouseleave",normalized:"mouseleave"},{native:"mousemove",normalized:"mousemove"},{native:"keydown",normalized:"keydown"},{native:"keyup",normalized:"keyup"},{native:"keypress",normalized:"keypress"},{native:"input",normalized:"input"},{native:"change",normalized:"change"},{native:"submit",normalized:"submit"},{native:"reset",normalized:"reset"},{native:"load",normalized:"load"},{native:"unload",normalized:"unload"},{native:"scroll",normalized:"scroll"},{native:"resize",normalized:"resize"},{native:"dragstart",normalized:"dragstart"},{native:"drag",normalized:"drag"},{native:"dragend",normalized:"dragend"},{native:"dragenter",normalized:"dragenter"},{native:"dragleave",normalized:"dragleave"},{native:"dragover",normalized:"dragover"},{native:"drop",normalized:"drop"},{native:"touchstart",normalized:"touchstart"},{native:"touchmove",normalized:"touchmove"},{native:"touchend",normalized:"touchend"},{native:"touchcancel",normalized:"touchcancel"},{native:"in",normalized:"in"},{native:"to",normalized:"to"},{native:"at",normalized:"at"},{native:"by",normalized:"by"},{native:"with",normalized:"with"},{native:"without",normalized:"without"},{native:"of",normalized:"of"},{native:"as",normalized:"as"},{native:"every",normalized:"every"},{native:"upon",normalized:"upon"},{native:"unless",normalized:"unless"},{native:"forever",normalized:"forever"},{native:"times",normalized:"times"},{native:"and",normalized:"and"},{native:"or",normalized:"or"},{native:"not",normalized:"not"},{native:"is",normalized:"is"},{native:"exists",normalized:"exists"},{native:"empty",normalized:"empty"},{native:"my",normalized:"my"},{native:"your",normalized:"your"},{native:"its",normalized:"its"},{native:"the",normalized:"the"},{native:"a",normalized:"a"},{native:"an",normalized:"an"},{native:"delete",normalized:"delete"},{native:"innerHTML",normalized:"innerHTML"},{native:"outerHTML",normalized:"outerHTML"},{native:"beforebegin",normalized:"beforebegin"},{native:"afterend",normalized:"afterend"},{native:"beforeend",normalized:"beforeend"},{native:"afterbegin",normalized:"afterbegin"},{native:"flip",normalized:"toggle"},{native:"switch",normalized:"toggle"},{native:"increase",normalized:"increment"},{native:"decrease",normalized:"decrement"},{native:"display",normalized:"show"},{native:"reveal",normalized:"show"},{native:"conceal",normalized:"hide"},{native:"colour",normalized:"color"},{native:"grey",normalized:"gray"},{native:"centre",normalized:"center"},{native:"behaviour",normalized:"behavior"},{native:"initialise",normalized:"initialize"},{native:"favourite",normalized:"favorite"}],ke=class extends V{constructor(){super();this.language="en";this.direction="ltr";this.initializeKeywordsFromProfile(N,Ct)}tokenize(t){let r=[],o=0;for(;o<t.length;){if(w(t[o])){o++;continue}if(U(t[o])){let s=this.tryEventModifier(t,o);if(s){r.push(s),o=s.position.end;continue}if(t[o]==="."){let c=r[r.length-1],p=c&&c.position.end<o;if(c&&!p&&(c.kind==="identifier"||c.kind==="keyword"||c.kind==="selector")){r.push(x(".","operator",v(o,o+1))),o++;continue}let g=o+1;for(;g<t.length&&T(t[g]);)g++;if(g<t.length&&t[g]==="("){r.push(x(".","operator",v(o,o+1))),o++;continue}}let l=this.trySelector(t,o);if(l){r.push(l),o=l.position.end;continue}}if($(t[o])){if(t[o]==="'"&&Pe(t,o)){r.push(x("'s","punctuation",v(o,o+2))),o+=2;continue}let s=this.tryString(t,o);if(s){r.push(s),o=s.position.end;continue}}if(D(t,o)){let s=this.tryUrl(t,o);if(s){r.push(s),o=s.position.end;continue}}if(k(t[o])||t[o]==="-"&&o+1<t.length&&k(t[o+1])){let s=this.tryNumber(t,o);if(s){r.push(s),o=s.position.end;continue}}let i=this.tryVariableRef(t,o);if(i){r.push(i),o=i.position.end;continue}if(T(t[o])){let s=this.extractWord(t,o);if(s){r.push(s),o=s.position.end;continue}}let a=this.tryOperator(t,o);if(a){r.push(a),o=a.position.end;continue}o++}return new R(r,"en")}classifyToken(t){return this.isKeyword(t)?"keyword":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}extractWord(t,r){let o=r,i="";for(;o<t.length&&T(t[o]);)i+=t[o++];if(!i)return null;if(o<t.length&&t[o]===":"){let c=o;o++;let p="";for(;o<t.length&&T(t[o]);)p+=t[o++];p?i=i+":"+p:o=c}let a=this.classifyToken(i),s=this.lookupKeyword(i),l=s&&s.normalized!==s.native?s.normalized:void 0;if(a==="identifier"){let c=this.tryConvertToClassSelector(t,o,i);if(c)return c.token}return x(i,a,v(r,o),l)}tryConvertToClassSelector(t,r,o){let i=r;for(;i<t.length&&/\s/.test(t[i]);)i++;if(t.slice(i,i+5).toLowerCase()==="class"){let a=i+5;if(a>=t.length||!T(t[a])){let s="."+o;return{token:x(s,"selector",v(r-o.length,r)),endPos:r}}}return null}},se=new ke;var wt={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:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,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)"}},Rt={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:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],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"}},Nt={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:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:!1,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"}},Lt={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:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the content",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1}],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"}},zt={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:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"patient",description:"The value to set",required:!0,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke"}}],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>"}},Mt={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:!0,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:!1,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},At={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:!0,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:!1,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Vt={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:!0,roles:[{role:"event",description:"The event to handle",required:!0,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},It={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:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Ot={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},_t={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:!1,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:!1,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:!1,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},qt={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:!1,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2}]},Bt={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:!1,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2}]},Wt={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:!0,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1}]},jt={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:!0,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1}]},Kt={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Gt={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"",zh:"",ko:"",ar:"",tr:"",id:""}},{role:"destination",description:"Where to store the result (optional)",required:!1,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},Ut={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:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},$t={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:!0,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},Dt={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:!1,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Ft={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:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ht={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Xt={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,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"}}]},Qt={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to evaluate",required:!0,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Zt={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:!0,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Yt={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},Jt={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:!0,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:!0,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:!1,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:!1,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},er={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The iteration variable",required:!0,expectedTypes:["reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1}]},tr={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to check",required:!0,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},rr={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},nr={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},or={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:!0,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"goal",description:"The target value to transition to",required:!0,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:!1,expectedTypes:["literal"],svoPosition:4,sovPosition:4},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:!1,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},ir={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:!1,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1}]},ar={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},sr={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:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},lr={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:!0,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},cr={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:!1,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},dr={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The JavaScript code to execute",required:!1,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},pr={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:!0,roles:[]},ur={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:!0,roles:[{role:"destination",description:"The element to tell",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1}]},mr={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:!0,expectedTypes:["reference"],svoPosition:1,sovPosition:1},{role:"patient",description:"The default value",required:!0,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2}]},fr={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},gr={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},hr={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},yr={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:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2}]},vr={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:!1,expectedTypes:["literal"],svoPosition:1,sovPosition:3},{role:"destination",description:"The element to swap content in/for",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1},{role:"patient",description:"The content to swap in (optional for delete)",required:!1,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2}]},xr={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:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1},{role:"patient",description:"The target content/element to morph into",required:!0,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2}]},Sr={toggle:wt,add:Rt,remove:Nt,put:Lt,set:zt,show:Mt,hide:At,on:Vt,trigger:It,wait:Ot,fetch:_t,increment:qt,decrement:Bt,append:Wt,prepend:jt,log:Kt,get:Gt,take:Ut,make:$t,halt:Dt,settle:Ft,throw:Ht,send:Xt,if:Qt,unless:Zt,else:Yt,repeat:Jt,for:er,while:tr,continue:rr,go:nr,transition:or,clone:ir,focus:ar,blur:sr,call:lr,return:cr,js:dr,async:pr,tell:ur,default:mr,init:fr,behavior:gr,install:hr,measure:yr,swap:vr,morph:xr,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:!0,roles:[]}};function Ze(){return Object.values(Sr).filter(n=>n.roles.length>0)}function Ee(n,e){let t=e==="SOV"?"sovPosition":"svoPosition";return[...n].sort((r,o)=>{let i=r[t]??99,a=o[t]??99;return i-a})}function Ye(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:!0};if(r&&r.primary){let o={primary:r.primary,position:r.position,isOverride:!1};return r.alternatives&&(o.alternatives=r.alternatives),o}return null}var le={basePriority:100,generateSimpleVariants:!0,generateAlternatives:!0};function Je(n,e,t=le){let r=`${n.action}-${e.code}-generated`,o=t.basePriority??100,i=e.keywords[n.action];if(!i)throw new Error(`No keyword translation for '${n.action}' in ${e.code}`);let a=Pr(n,e,i),s=tt(n,e),l=wr(n,e,i);return{id:r,language:e.code,command:n.action,priority:o,template:{format:l,tokens:a},extraction:s}}function Tr(n,e,t=le){if(n.roles.filter(s=>!s.required).length===0)return null;let o=n.roles.filter(s=>s.required),i={...n,roles:o};return{...Je(i,e,t),id:`${n.action}-${e.code}-simple`,priority:(t.basePriority??100)-5,extraction:tt(n,e)}}function br(n,e,t=le){let r=[];if(r.push(Je(n,e,t)),t.generateSimpleVariants){let o=Tr(n,e,t);o&&r.push(o)}return r}function et(n,e=le){let t=[],r=Ze();for(let o of r){if(!n.keywords[o.action])continue;let i=br(o,n,e);t.push(...i)}return t}function Pr(n,e,t){let r=[],o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},i=kr(n,e);switch(e.wordOrder){case"SVO":r.push(o),r.push(...i);break;case"SOV":r.push(...i),r.push(o);break;case"VSO":r.push(o),r.push(...i);break;default:r.push(o),r.push(...i)}return r}function kr(n,e){let t=[],r=Ee(n.roles,e.wordOrder);for(let o of r){let i=Er(o,e);o.required?t.push(...i):t.push({type:"group",optional:!0,tokens:i})}return t}function Er(n,e){let t=[],r=n.markerOverride?.[e.code],o=e.roleMarkers[n.role],i={type:"role",role:n.role,optional:!n.required,expectedTypes:n.expectedTypes};if(r!==void 0)(o?.position??"before")==="before"?(r&&t.push({type:"literal",value:r}),t.push(i)):(t.push(i),r&&t.push({type:"literal",value:r}));else if(o)if(o.position==="before"){if(o.primary){let a=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};t.push(a)}t.push(i)}else{t.push(i);let a=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};t.push(a)}else t.push(i);return t}function Cr(n,e){let t={};for(let r of n.roles){let o=r.markerOverride?.[e.code],i=e.roleMarkers[r.role];o!==void 0?t[r.role]=o?{marker:o}:{}:i&&i.primary?t[r.role]=i.alternatives?{marker:i.primary,markerAlternatives:i.alternatives}:{marker:i.primary}:t[r.role]={}}return t}function tt(n,e){let t=Cr(n,e),r={};for(let o of n.roles){let i=t[o.role]||{};!o.required&&o.default?r[o.role]={...i,default:o.default}:r[o.role]=i}return r}function wr(n,e,t){let r=[],i=Ee(n.roles,e.wordOrder).map(a=>{let s=Ye(a,e),l="";return s&&s.primary?s.position==="before"?l=`${s.primary} {${a.role}}`:l=`{${a.role}} ${s.primary}`:l=`{${a.role}}`,a.required?l:`[${l}]`});switch(e.wordOrder){case"SVO":case"VSO":r.push(t.primary,...i);break;case"SOV":r.push(...i,t.primary);break;default:r.push(t.primary,...i)}return r.join(" ")}function rt(){return[{id:"toggle-en-full",language:"en",command:"toggle",priority:100,template:{format:"toggle {patient} on {target}",tokens:[{type:"literal",value:"toggle"},{type:"role",role:"patient"},{type:"group",optional:!0,tokens:[{type:"literal",value:"on",alternatives:["from"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"on",markerAlternatives:["from"],default:{type:"reference",value:"me"}}}},{id:"toggle-en-simple",language:"en",command:"toggle",priority:90,template:{format:"toggle {patient}",tokens:[{type:"literal",value:"toggle"},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function nt(){return[{id:"put-en-into",language:"en",command:"put",priority:100,template:{format:"put {patient} into {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"into",alternatives:["in","to"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"into",markerAlternatives:["in","to"]}}},{id:"put-en-before",language:"en",command:"put",priority:95,template:{format:"put {patient} before {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"before"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"before"},manner:{default:{type:"literal",value:"before"}}}},{id:"put-en-after",language:"en",command:"put",priority:95,template:{format:"put {patient} after {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"after"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"after"},manner:{default:{type:"literal",value:"after"}}}}]}function ot(){return[{id:"event-en-when-source",language:"en",command:"on",priority:115,template:{format:"when {event} from {source} {body}",tokens:[{type:"literal",value:"when"},{type:"role",role:"event"},{type:"literal",value:"from"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"from"}}},{id:"event-en-when",language:"en",command:"on",priority:105,template:{format:"when {event} {body}",tokens:[{type:"literal",value:"when"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-en-source",language:"en",command:"on",priority:110,template:{format:"on {event} from {source} {body}",tokens:[{type:"literal",value:"on"},{type:"role",role:"event"},{type:"literal",value:"from"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"from"}}},{id:"event-en-standard",language:"en",command:"on",priority:100,template:{format:"on {event} {body}",tokens:[{type:"literal",value:"on"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-en-upon",language:"en",command:"on",priority:98,template:{format:"upon {event} {body}",tokens:[{type:"literal",value:"upon"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-en-if",language:"en",command:"on",priority:95,template:{format:"if {event} {body}",tokens:[{type:"literal",value:"if"},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}var Rr={id:"fetch-en-with-response-type",language:"en",command:"fetch",priority:90,template:{format:"fetch {source} as {responseType}",tokens:[{type:"literal",value:"fetch"},{type:"role",role:"source",expectedTypes:["literal","expression"]},{type:"literal",value:"as"},{type:"role",role:"responseType",expectedTypes:["literal","expression"]}]},extraction:{source:{position:1},responseType:{marker:"as"}}},Nr={id:"fetch-en-simple",language:"en",command:"fetch",priority:80,template:{format:"fetch {source}",tokens:[{type:"literal",value:"fetch"},{type:"role",role:"source"}]},extraction:{source:{position:1}}},Lr={id:"swap-en-handcrafted",language:"en",command:"swap",priority:110,template:{format:"swap {method} {destination}",tokens:[{type:"literal",value:"swap"},{type:"role",role:"method"},{type:"role",role:"destination"}]},extraction:{method:{position:1},destination:{position:2}}},zr={id:"repeat-en-until-event-from",language:"en",command:"repeat",priority:120,template:{format:"repeat until event {event} from {source}",tokens:[{type:"literal",value:"repeat"},{type:"literal",value:"until"},{type:"literal",value:"event"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:"from"},{type:"role",role:"source",expectedTypes:["selector","reference","expression"]}]},extraction:{event:{marker:"event"},source:{marker:"from"},loopType:{default:{type:"literal",value:"until-event"}}}},Mr={id:"repeat-en-until-event",language:"en",command:"repeat",priority:110,template:{format:"repeat until event {event}",tokens:[{type:"literal",value:"repeat"},{type:"literal",value:"until"},{type:"literal",value:"event"},{type:"role",role:"event",expectedTypes:["literal","expression"]}]},extraction:{event:{marker:"event"},loopType:{default:{type:"literal",value:"until-event"}}}},Ar={id:"set-en-possessive",language:"en",command:"set",priority:100,template:{format:"set {destination} to {patient}",tokens:[{type:"literal",value:"set"},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"to"},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]}]},extraction:{destination:{position:1},patient:{marker:"to"}}},Vr={id:"for-en-basic",language:"en",command:"for",priority:100,template:{format:"for {patient} in {source}",tokens:[{type:"literal",value:"for"},{type:"role",role:"patient",expectedTypes:["expression","reference"]},{type:"literal",value:"in"},{type:"role",role:"source",expectedTypes:["selector","expression","reference"]}]},extraction:{patient:{position:1},source:{marker:"in"},loopType:{default:{type:"literal",value:"for"}}}},Ir={id:"if-en-basic",language:"en",command:"if",priority:100,template:{format:"if {condition}",tokens:[{type:"literal",value:"if"},{type:"role",role:"condition",expectedTypes:["expression","reference","selector"]}]},extraction:{condition:{position:1}}},Or={id:"unless-en-basic",language:"en",command:"unless",priority:100,template:{format:"unless {condition}",tokens:[{type:"literal",value:"unless"},{type:"role",role:"condition",expectedTypes:["expression","reference","selector"]}]},extraction:{condition:{position:1}}},_r={id:"temporal-en-in",language:"en",command:"wait",priority:95,template:{format:"in {duration}",tokens:[{type:"literal",value:"in"},{type:"role",role:"duration",expectedTypes:["literal","expression"]}]},extraction:{duration:{position:1}}},qr={id:"temporal-en-after",language:"en",command:"wait",priority:95,template:{format:"after {duration}",tokens:[{type:"literal",value:"after"},{type:"role",role:"duration",expectedTypes:["literal","expression"]}]},extraction:{duration:{position:1}}};function it(){let n=[];n.push(...rt()),n.push(...nt()),n.push(...ot()),n.push(Rr,Nr,Lr,zr,Mr,Ar,Vr,Ir,Or,_r,qr);let e=et(N);return n.push(...e),n}oe("en",se,N);je("en",it());function Ce(n){return{stem:n,confidence:1}}function ce(n,e,t){return t?{stem:n,confidence:e,metadata:t}:{stem:n,confidence:e}}function Br(n){return/[áéíóúüñÁÉÍÓÚÜÑ]/.test(n)}function Wr(n){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!0;for(let t of n)if(Br(t))return!0;return!1}var at=["se","me","te","nos","os"],jr=[{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"}],Kr=[{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"}],Gr=[{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"}],Ur=[...jr,...Kr,...Gr].sort((n,e)=>e.ending.length-n.ending.length),Z=class{constructor(){this.language="es"}isNormalizable(e){return e.length<3?!1:Wr(e)}normalize(e){let t=e.toLowerCase();if((t.endsWith("ar")||t.endsWith("er")||t.endsWith("ir"))&&!at.some(i=>t.endsWith(i+"ar")||t.endsWith(i+"er")||t.endsWith(i+"ir")))return Ce(e);let r=this.tryReflexiveNormalization(t);if(r)return r;let o=this.tryConjugationNormalization(t);return o||Ce(e)}tryReflexiveNormalization(e){for(let t of at)if(e.endsWith(t)){let r=e.slice(0,-t.length);if(r.endsWith("ar")||r.endsWith("er")||r.endsWith("ir"))return ce(r,.88,{removedSuffixes:[t],conjugationType:"reflexive"});let o=this.tryConjugationNormalization(r);if(o&&o.stem!==r)return ce(o.stem,o.confidence*.95,{removedSuffixes:[t,...o.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationNormalization(e){for(let t of Ur)if(e.endsWith(t.ending)){let r=e.slice(0,-t.ending.length);if(r.length<2)continue;let o=r+t.stem;return ce(o,t.confidence,{removedSuffixes:[t.ending],conjugationType:t.type})}return null}},_o=new Z;var I={code:"es",name:"Spanish",nativeName:"Espa\xF1ol",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:!0},references:{me:"yo",it:"ello",you:"t\xFA",result:"resultado",event:"evento",target:"objetivo",body:"cuerpo"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:!0,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"},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"},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"}}};var{isLetter:st,isIdentifierChar:$r}=be(/[a-zA-ZáéíóúüñÁÉÍÓÚÜÑ]/),Dr=[{pattern:"milisegundos",suffix:"ms",length:12,caseInsensitive:!0},{pattern:"milisegundo",suffix:"ms",length:11,caseInsensitive:!0},{pattern:"segundos",suffix:"s",length:8,caseInsensitive:!0},{pattern:"segundo",suffix:"s",length:7,caseInsensitive:!0},{pattern:"minutos",suffix:"m",length:7,caseInsensitive:!0},{pattern:"minuto",suffix:"m",length:6,caseInsensitive:!0},{pattern:"horas",suffix:"h",length:5,caseInsensitive:!0},{pattern:"hora",suffix:"h",length:4,caseInsensitive:!0}],lt=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),Fr=[{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"}],we=class extends V{constructor(){super();this.language="es";this.direction="ltr";this.initializeKeywordsFromProfile(I,Fr),this.normalizer=new Z}tokenize(t){let r=[],o=0;for(;o<t.length;){if(w(t[o])){o++;continue}if(U(t[o])){let l=this.tryEventModifier(t,o);if(l){r.push(l),o=l.position.end;continue}let c=this.trySelector(t,o);if(c){r.push(c),o=c.position.end;continue}}if($(t[o])){let l=this.tryString(t,o);if(l){r.push(l),o=l.position.end;continue}}if(D(t,o)){let l=this.tryUrl(t,o);if(l){r.push(l),o=l.position.end;continue}}if(k(t[o])||t[o]==="-"&&o+1<t.length&&k(t[o+1])){let l=this.extractSpanishNumber(t,o);if(l){r.push(l),o=l.position.end;continue}}let i=this.tryVariableRef(t,o);if(i){r.push(i),o=i.position.end;continue}let a=this.tryMultiWordPhrase(t,o);if(a){r.push(a),o=a.position.end;continue}if(st(t[o])){let l=this.extractSpanishWord(t,o);if(l){r.push(l),o=l.position.end;continue}}let s=this.tryOperator(t,o);if(s){r.push(s),o=s.position.end;continue}o++}return new R(r,"es")}classifyToken(t){let r=t.toLowerCase();return lt.has(r)?"particle":this.isKeyword(r)?"keyword":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":"identifier"}tryMultiWordPhrase(t,r){for(let o of this.profileKeywords){if(!o.native.includes(" "))continue;let i=o.native;if(t.slice(r,r+i.length).toLowerCase()===i.toLowerCase()){let s=r+i.length;if(s>=t.length||w(t[s])||!st(t[s]))return x(t.slice(r,r+i.length),"keyword",v(r,s),o.normalized)}}return null}extractSpanishWord(t,r){let o=r,i="";for(;o<t.length&&$r(t[o]);)i+=t[o++];if(!i)return null;let a=i.toLowerCase();if(lt.has(a))return x(i,"particle",v(r,o));let s=this.lookupKeyword(a);if(s)return x(i,"keyword",v(r,o),s.normalized);let l=this.tryMorphKeywordMatch(a,r,o);return l||x(i,"identifier",v(r,o))}extractSpanishNumber(t,r){return this.tryNumberWithTimeUnits(t,r,Dr,{allowSign:!0,skipWhitespace:!0})}},de=new we;oe("es",de,I);function ct(n){return Ke(n)}function pe(n,e){return Ue(n,e)}function ue(){return ie()}function M(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 b(n,e){let t={type:"literal",value:n};return e!==void 0?{type:"literal",value:n,dataType:e}:t}function L(n){return{type:"reference",value:n}}function F(n,e){return{type:"property-path",object:n,property:e}}function A(n,e,t){let r={kind:"command",action:n,roles:new Map(Object.entries(e))};return t!==void 0?{...r,metadata:t}:r}function H(n,e,t,r,o){let i=new Map;i.set("event",n);let a={kind:"event-handler",action:"on",roles:i,body:e};return t!==void 0&&(a.eventModifiers=t),r!==void 0&&(a.metadata=r),o!==void 0&&o.length>0&&(a.parameterNames=o),a}function dt(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 Re(n,e){return!e||e.length===0||e.includes(n)||e.includes("expression")?!0:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):!1}function pt(n,e){return n.possessive?.keywords?.[e]}var z=class z{constructor(){this.stemMatchCount=0;this.totalKeywordMatches=0}matchPattern(e,t){let r=e.mark(),o=new Map;if(this.currentProfile=G(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,o))return e.reset(r),null;let a=this.calculateConfidence(t,o);return this.applyExtractionRules(t,o),{pattern:t,captured:o,consumedTokens:e.position()-r.position,confidence:a}}matchBest(e,t){let r=[];for(let i of t){let a=e.mark(),s=this.matchPattern(e,i);s&&r.push(s),e.reset(a)}if(r.length===0)return null;r.sort((i,a)=>{let s=a.pattern.priority-i.pattern.priority;return s!==0?s:a.confidence-i.confidence});let o=r[0];return this.matchPattern(e,o.pattern),o}matchTokenSequence(e,t,r){if(this.currentProfile?.code==="ar")for(;e.peek()?.kind==="conjunction";)e.advance();for(let o of t)if(!this.matchPatternToken(e,o,r)){if(this.isOptional(o))continue;return!1}return!0}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!1}}matchLiteralToken(e,t){let r=e.peek();if(!r)return!1;let o=this.getMatchType(r,t.value);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),!0;if(t.alternatives)for(let i of t.alternatives){let a=this.getMatchType(r,i);if(a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),!0}return!1}matchRoleToken(e,t,r){this.skipNoiseWords(e);let o=e.peek();if(!o)return t.optional||!1;let i=this.tryMatchPossessiveExpression(e);if(i)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(i.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(r.set(t.role,i),!0);let a=this.tryMatchMethodCallExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(a.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(r.set(t.role,a),!0);let s=this.tryMatchPossessiveSelectorExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!Re(s.type,t.expectedTypes)?t.optional||!1:(r.set(t.role,s),!0);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||!1:(r.set(t.role,l),!0);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!Re(c.type,t.expectedTypes)?t.optional||!1:(r.set(t.role,c),!0);let p=this.tokenToSemanticValue(o);return!p||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(p.type)?t.optional||!1:(r.set(t.role,p),e.advance(),!0)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=(t.normalized||t.value).toLowerCase(),o=pt(this.currentProfile,r);if(!o)return null;let i=e.mark();e.advance();let a=e.peek();return a&&(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*"))?(e.advance(),F(L(o),a.value)):(e.reset(i),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 o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="(")return e.reset(r),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<z.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}s.push(c.value),e.advance()}return{type:"expression",raw:`${t.value}.${i.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let a=`${t.value}.${i.value}`,s=1;for(;!e.isAtEnd()&&s<z.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let p=e.peek();if(!p||p.kind!=="identifier")break;e.advance(),a+=`.${p.value}`,s++}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let c=[],p=0;for(;!e.isAtEnd()&&c.length<z.MAX_METHOD_ARGS;){let y=e.peek();if(!y)break;if(y.kind==="punctuation"&&y.value===")"){if(p===0){e.advance();break}p--}if(y.kind==="punctuation"&&y.value==="("&&p++,y.kind==="punctuation"&&y.value===","){e.advance();continue}c.push(y.value),e.advance()}return{type:"expression",raw:`${a}(${c.join(", ")})`}}return{type:"expression",raw:a}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="'s")return e.reset(r),null;e.advance();let i=e.peek();return!i||i.kind!=="selector"&&i.kind!=="identifier"?(e.reset(r),null):(e.advance(),F(M(t.value),i.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="selector"||!o.value.startsWith("."))return e.reset(r),null;let i=e.peek(1);i&&i.kind,e.advance();let a=o.value.slice(1);return F(M(t.value),a)}matchGroupToken(e,t,r){let o=e.mark(),i=new Set(r.keys());if(!this.matchTokenSequence(e,t.tokens,r)){e.reset(o);for(let s of r.keys())i.has(s)||r.delete(s);return t.optional||!1}return!0}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 M(e.value);case"literal":return this.parseLiteralValue(e.value);case"keyword":let t=(e.normalized||e.value).toLowerCase();return["me","you","it","result","event","target","body"].includes(t)?L(t):b(e.normalized||e.value);case"identifier":if(e.value.startsWith(":"))return L(e.value);let r=e.value.toLowerCase();return["me","you","it","result","event","target","body"].includes(r)?L(r):{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 o=e.slice(1,-1);return b(o,"string")}if(e==="true")return b(!0,"boolean");if(e==="false")return b(!1,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let o=parseFloat(t[1]);return t[2]?b(e,"duration"):b(o,"number")}let r=parseFloat(e);return isNaN(r)?b(e,"string"):b(r,"number")}applyExtractionRules(e,t){for(let[r,o]of Object.entries(e.extraction))!t.has(r)&&o.default&&t.set(r,o.default)}isOptional(e){return e.optional===!0}calculateConfidence(e,t){let r=0,o=0,i=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")o+=1,t.has(c.role)&&(r+=1);else if(c.type==="group"){for(let p of c.tokens)if(p.type==="role"){let S=i(p.role),y=.8;o+=y,t.has(p.role)?r+=y:S&&(r+=y*.6)}}let a=o>0?r/o:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;a=Math.max(.5,a-c)}let s=this.calculateVSOConfidenceBoost(e);a=Math.min(1,a+s);let l=this.arabicPrepositionDisambiguation(e,t);return a=Math.max(0,Math.min(1,a+l)),a}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 o of t.alternatives)if(r.has(o))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let r=0,o={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[i,a]of t.entries()){let s=o[i];if(!s||s.length===0)continue;let l=a.metadata;if(l&&typeof l.prepositionValue=="string"){let c=l.prepositionValue;s.includes(c)?r+=.1:r-=.1}}return Math.max(-.1,Math.min(.1,r))}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=t.value.toLowerCase();if(z.ENGLISH_NOISE_WORDS.has(r)){let o=e.mark();e.advance();let i=e.peek();if(i&&i.kind==="selector")return;e.reset(o)}r==="class"&&e.advance()}extractEventModifiers(e){let t={},r=!1;for(;!e.isAtEnd();){let o=e.peek();if(!o||o.kind!=="event-modifier")break;let i=o.metadata;if(!i)break;switch(r=!0,i.modifierName){case"once":t.once=!0;break;case"debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case"throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case"queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance()}return r?t:void 0}};z.MAX_PROPERTY_DEPTH=10,z.MAX_METHOD_ARGS=20,z.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Y=z,O=new Y;var me=class{render(e,t){if(e.kind==="compound")return this.renderCompound(e,t);let r=$e(t,e.action);if(r.length===0)return this.renderExplicit(e);let o=this.findBestPattern(e,r);return o?this.renderWithPattern(e,o):this.renderExplicit(e)}renderCompound(e,t){let r=e.statements.map(i=>this.render(i,t)),o=this.getChainWord(e.chainType,t);return r.join(` ${o} `)}getChainWord(e,t){let r=G(t);return r?.keywords?r.keywords[e]?.primary??e:e}renderExplicit(e){if(e.kind==="compound"){let r=e;return r.statements.map(i=>this.renderExplicit(i)).join(` ${r.chainType} `)}let t=[e.action];for(let[r,o]of e.roles)t.push(`${r}:${this.valueToString(o)}`);if(e.kind==="event-handler"){let r=e;if(r.body&&r.body.length>0){let o=r.body.map(i=>this.renderExplicit(i));t.push(`body:${o.join(" ")}`)}}return`[${t.join(" ")}]`}supportedLanguages(){return ue()}findBestPattern(e,t){let r=t.map(o=>{let i=o.priority;for(let a of o.template.tokens)a.type==="role"&&(e.roles.has(a.role)?i+=10:a.optional||(i-=50));return o.language==="en"&&((o.id.includes("standard")||o.id.includes("en-source"))&&(i+=20),(o.id.includes("-when")||o.id.includes("-if")||o.id.includes("-upon"))&&(i-=15)),{pattern:o,score:i}});return r.sort((o,i)=>i.score-o.score),r.length>0?r[0].pattern:null}renderWithPattern(e,t){let r=[],o=t.language;for(let i of t.template.tokens){let a=this.renderPatternToken(i,e,o);a!==null&&r.push(a)}if(e.kind==="event-handler"){let i=e;if(i.body&&i.body.length>0){let a=i.body.map(s=>this.render(s,o));r.push(a.join(" "))}}return r.join(" ")}renderPatternToken(e,t,r){switch(e.type){case"literal":return e.value;case"role":{let o=t.roles.get(e.role);return o?this.valueToNaturalString(o,r):(e.optional,null)}case"group":{if(!e.tokens.filter(a=>a.type==="role"&&!a.optional).every(a=>t.roles.has(a.role))&&e.optional)return null;if(e.optional&&e.tokens.find(s=>s.type==="role"&&s.role==="destination")){let s=t.roles.get("destination");if(s?.type==="reference"&&s.value==="me")return null}let i=[];for(let a of e.tokens){let s=this.renderPatternToken(a,t,r);s!==null&&i.push(s)}return i.length>0?i.join(" "):null}default:return null}}valueToString(e){switch(e.type){case"literal":return typeof e.value=="string"?e.dataType==="string"||/\s/.test(e.value)?`"${e.value}"`:e.value:String(e.value);case"selector":return e.value;case"reference":return e.value;case"property-path":return`${this.valueToString(e.object)}'s ${e.property}`;case"expression":return e.raw}}valueToNaturalString(e,t="en"){switch(e.type){case"literal":return typeof e.value=="string"&&e.dataType==="string"?`"${e.value}"`:String(e.value);case"selector":return e.value;case"reference":return this.renderReference(e,t);case"property-path":return this.renderPropertyPath(e,t);case"expression":return e.raw}}renderReference(e,t){let r=G(t);return r?.references?r.references[e.value]??e.value:e.value}renderPropertyPath(e,t){let r=G(t),o=e.property,i=e.object.type==="reference"?e.object.value:null;if(r?.possessive?.specialForms&&i){let s=r.possessive.specialForms[i];if(s){let{markerPosition:l,usePossessiveAdjectives:c}=r.possessive;return c&&l==="after-object"?`${o} ${s}`:`${s} ${o}`}}let a=this.valueToNaturalString(e.object,t);if(r?.possessive){let{marker:s,markerPosition:l,usePossessiveAdjectives:c}=r.possessive;if(c&&i&&l==="after-object")return`${o} ${a}`;if(s)switch(l){case"between":return r.usesSpaces?`${a}${s} ${o}`:`${a}${s}${o}`;case"after-object":return`${a}${s} ${o}`;case"before-property":return`${a} ${s} ${o}`}}return t==="en"||!r?.possessive?a==="me"?`my ${o}`:a==="it"?`its ${o}`:`${a}'s ${o}`:`${a} ${o}`}},Ne=new me;function _(n,e){return Ne.render(n,e)}function X(n){return Ne.renderExplicit(n)}function q(n){let e=n.trim();if(!e.startsWith("[")||!e.endsWith("]"))throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");let t=e.slice(1,-1).trim();if(!t)throw new Error("Empty explicit statement");let r=Hr(t);if(r.length===0)throw new Error("No command specified in explicit statement");let o=r[0].toLowerCase(),i=new Map;for(let s=1;s<r.length;s++){let l=r[s],c=l.indexOf(":");if(c===-1)throw new Error(`Invalid role format: "${l}". Expected role:value`);let p=l.slice(0,c),S=l.slice(c+1);if(p==="body"&&S.startsWith("[")){let g=Qr(l,c+1),u=l.slice(c+1,g+1);i.set(p,{type:"expression",raw:u});continue}let y=Xr(S);i.set(p,y)}if(o==="on"){let s=i.get("event");if(!s)throw new Error("Event handler requires event role: [on event:click ...]");let l=i.get("body"),c=[];return l&&l.type==="expression"&&c.push(q(l.raw)),i.delete("body"),H(s,c,void 0,{sourceLanguage:"explicit"})}let a={};for(let[s,l]of i)a[s]=l;return A(o,a,{sourceLanguage:"explicit"})}function Hr(n){let e=[],t="",r=!1,o="",i=0;for(let a=0;a<n.length;a++){let s=n[a];if(r){t+=s,s===o&&n[a-1]!=="\\"&&(r=!1);continue}if(s==='"'||s==="'"){r=!0,o=s,t+=s;continue}if(s==="["){i++,t+=s;continue}if(s==="]"){i--,t+=s;continue}if(s===" "&&i===0){t&&(e.push(t),t="");continue}t+=s}return t&&e.push(t),e}function Xr(n){if(n.startsWith("#")||n.startsWith(".")||n.startsWith("[")||n.startsWith("@")||n.startsWith("*"))return M(n);if(n.startsWith('"')||n.startsWith("'")){let t=n.slice(1,-1);return b(t,"string")}if(n==="true")return b(!0,"boolean");if(n==="false")return b(!1,"boolean");if(["me","you","it","result","event","target","body"].includes(n.toLowerCase()))return L(n.toLowerCase());let e=n.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let t=parseFloat(e[1]);return e[2]?b(n,"duration"):b(t,"number")}return b(n,"string")}function Qr(n,e){let t=0;for(let r=e;r<n.length;r++)if(n[r]==="[")t++;else if(n[r]==="]"&&(t--,t===0))return r;return n.length-1}function B(n){let e=n.trim();return e.startsWith("[")&&e.endsWith("]")}var fe=class{parse(e,t){let r=pe(e,t),o=C(t);if(o.length===0)throw new Error(`No patterns available for language: ${t}`);let i=[...o].sort((p,S)=>S.priority-p.priority),a=i.filter(p=>p.command==="on"),s=O.matchBest(r,a);if(s)return this.buildEventHandler(s,r,t);let l=i.filter(p=>p.command!=="on"),c=O.matchBest(r,l);if(c)return this.buildCommand(c,t);throw new Error(`Could not parse input in ${t}: ${e}`)}canParse(e,t){try{return this.parse(e,t),!0}catch{return!1}}supportedLanguages(){return ue()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let r={};for(let[o,i]of e.captured)r[o]=i;return A(e.pattern.command,r,{sourceLanguage:t,patternId:e.pattern.id})}buildEventHandler(e,t,r){if(!e)throw new Error("No match to build event handler from");let o=e.captured.get("event");if(!o)throw new Error("Event handler pattern matched but no event captured");let i=O.extractEventModifiers(t),a,s=e.captured.get("action");if(s&&s.type==="literal"){let l=s.value,c={};for(let[y,g]of e.captured)y!=="event"&&y!=="action"&&y!=="continues"&&(c[y]=g);let p=A(l,c,{sourceLanguage:r,patternId:e.pattern.id}),S=e.captured.get("continues");if(S&&S.type==="literal"&&S.value==="then"){let y=C(r).filter(m=>m.command!=="on").sort((m,h)=>h.priority-m.priority),g=C(r).filter(m=>m.id.startsWith("grammar-")&&m.id.includes("-continuation")).sort((m,h)=>h.priority-m.priority),u=this.parseBodyWithGrammarPatterns(t,y,g,r);u.length>0?a=[p,...u]:a=[p]}else a=[p]}else{let l=C(r).filter(c=>c.command!=="on").sort((c,p)=>p.priority-c.priority);a=this.parseBodyWithClauses(t,l,r)}return H(o,a,i,{sourceLanguage:r,patternId:e.pattern.id})}parseBodyWithClauses(e,t,r){let o=[],i=[];for(;!e.isAtEnd();){let a=e.peek();if(!a)break;let s=a.kind==="conjunction"||a.kind==="keyword"&&this.isThenKeyword(a.value,r),l=a.kind==="keyword"&&this.isEndKeyword(a.value,r);if(s){if(i.length>0){let c=this.parseClause(i,t,r);o.push(...c),i.length=0}e.advance();continue}if(l){if(i.length>0){let c=this.parseClause(i,t,r);o.push(...c)}e.advance();break}i.push(a),e.advance()}if(i.length>0){let a=this.parseClause(i,t,r);o.push(...a)}return o.length>1?[dt(o,"then",{sourceLanguage:r})]:o}parseClause(e,t,r){if(e.length===0)return[];let o=new R(e,r),i=[];for(;!o.isAtEnd();){let a=O.matchBest(o,t);a?i.push(this.buildCommand(a,r)):o.advance()}return i}parseBodyWithGrammarPatterns(e,t,r,o){let i=[];for(;!e.isAtEnd();){let a=e.peek();if(a&&this.isThenKeyword(a.value,o)){e.advance();continue}if(a&&this.isEndKeyword(a.value,o)){e.advance();break}let s=!1;if(r.length>0){let l=O.matchBest(e,r);if(l){let c=l.pattern.command,p={};for(let[g,u]of l.captured)g!=="event"&&g!=="action"&&g!=="continues"&&(p[g]=u);let S=A(c,p,{sourceLanguage:o,patternId:l.pattern.id});i.push(S),s=!0;let y=l.captured.get("continues");if(y&&y.type==="literal"&&y.value==="then")continue}}if(!s){let l=O.matchBest(e,t);l&&(i.push(this.buildCommand(l,o)),s=!0)}s||e.advance()}return i}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"]),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"]),qu:new Set(["chaymantataq","hinaspa","chaymanta"]),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"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return(r[t]||r.en).has(e.toLowerCase())}},Le=new fe;function W(n,e){return Le.parse(n,e)}function ze(n,e){return Le.canParse(n,e)}function Me(n,e){if(B(n))return n;let t=W(n,e);return X(t)}function ge(n,e){let t=q(n);return _(t,e)}function Ae(n,e,t){if(B(n))return ge(n,t);let r=W(n,e);return _(r,t)}function he(n,e){return B(n)?q(n):W(n,e)}function Ve(n,e,t=["en","ja","ar","es","ko","zh","tr","pt","fr","de","id","qu","sw"]){let r={},o=he(n,e);for(let i of t)r[i]=_(o,i);return r.explicit=X(o),r}var Zr=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),Yr=new Set(["and","or","not","no"]),Jr=new Set(["true","false","null","undefined"]),en=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function ut(n){let e=[],t=0,r=1,o=1;function i(){if(e.length===0)return!0;let u=e[e.length-1];return["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(u.type)}function a(u=0){return n[t+u]??""}function s(){let u=n[t];return t++,u===`
2
- `?(r++,o=1):o++,u}function l(){for(;t<n.length&&/\s/.test(n[t]);)s()}function c(u){let m="";for(;t<n.length&&u(n[t]);)m+=s();return m}function p(u){let m=u;for(s();t<n.length&&n[t]!==u;)n[t]==="\\"&&t+1<n.length&&(m+=s()),m+=s();return t<n.length&&(m+=s()),m}function S(){let u="`";for(s();t<n.length&&n[t]!=="`";)n[t]==="\\"&&t+1<n.length&&(u+=s()),u+=s();return t<n.length&&(u+=s()),u}function y(){let u="<";for(s();t<n.length&&(u+=s(),!u.endsWith("/>")););return u}function g(u,m,h){return{type:u,value:m,start:h,end:t,line:r,column:o-m.length}}for(;t<n.length&&(l(),!(t>=n.length));){let u=t,m=a();if(m==="'"&&a(1)==="s"&&!/\w/.test(a(2))){s(),s(),e.push(g("POSSESSIVE","'s",u));continue}if(m==='"'||m==="'"){let h=p(m);e.push(g("STRING",h,u));continue}if(m==="`"){let h=S();e.push(g("TEMPLATE_LITERAL",h,u));continue}if(m==="<"&&/[a-zA-Z.#\[]/.test(a(1))){let h=y();e.push(g("QUERY_SELECTOR",h,u));continue}if(m==="#"&&i()){s();let h=c(P=>/[\w-]/.test(P));e.push(g("ID_SELECTOR","#"+h,u));continue}if(m==="."&&/[a-zA-Z_-]/.test(a(1))&&i()){s();let h=c(P=>/[\w-]/.test(P));e.push(g("CLASS_SELECTOR","."+h,u));continue}if(m==="["&&i()){let h=a(1);if(h==="@"||/[a-zA-Z]/.test(h)){let P="";for(P+=s();t<n.length&&n[t]!=="]";)n[t]==='"'||n[t]==="'"?P+=p(n[t]):P+=s();t<n.length&&(P+=s()),e.push(g("ATTRIBUTE_SELECTOR",P,u));continue}}if(m==="["){s(),e.push(g("LBRACKET","[",u));continue}if(m==="]"){s(),e.push(g("RBRACKET","]",u));continue}if(/\d/.test(m)){let h=c(ve=>/[\d.]/.test(ve)),P=t,re=c(ve=>/[a-zA-Z]/.test(ve));en.has(re)?e.push(g("TIME_EXPRESSION",h+re,u)):(t=P,e.push(g("NUMBER",h,u)));continue}if(m==="("){s(),e.push(g("LPAREN","(",u));continue}if(m===")"){s(),e.push(g("RPAREN",")",u));continue}if(m==="{"){s(),e.push(g("LBRACE","{",u));continue}if(m==="}"){s(),e.push(g("RBRACE","}",u));continue}if(m===","){s(),e.push(g("COMMA",",",u));continue}if(m===":"){s(),e.push(g("COLON",":",u));continue}if(m==="."){s(),e.push(g("DOT",".",u));continue}if(m==="+"||m==="-"||m==="*"||m==="/"||m==="%"){s(),e.push(g("OPERATOR",m,u));continue}if(m==="="||m==="!"||m==="<"||m===">"){let h=s();a()==="="&&(h+=s()),e.push(g("COMPARISON",h,u));continue}if(/[a-zA-Z_$]/.test(m)){let h=c(re=>/[\w$]/.test(re)),P=h.toLowerCase();Zr.has(P)?e.push(g("CONTEXT_VAR",h,u)):Yr.has(P)?e.push(g("LOGICAL",h,u)):Jr.has(P)?e.push(g("BOOLEAN",h,u)):e.push(g("IDENTIFIER",h,u));continue}s()}return e.push(g("EOF","",t)),e}var ye=class{constructor(){this.tokens=[];this.current=0}parse(e){try{return this.tokens=ut(e),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Parse error"}}}peek(){return this.tokens[this.current]??{type:"EOF",value:"",start:0,end:0}}previous(){return this.tokens[this.current-1]??{type:"EOF",value:"",start:0,end:0}}isAtEnd(){return this.peek().type==="EOF"}advance(){return this.isAtEnd()||this.current++,this.previous()}check(e){return this.peek().type===e}checkValue(e){return this.peek().value.toLowerCase()===e.toLowerCase()}match(...e){for(let t of e)if(this.check(t))return this.advance(),!0;return!1}parseExpression(){return this.parseOr()}parseOr(){let e=this.parseAnd();for(;this.checkValue("or");){let t=this.advance().value,r=this.parseAnd();e=this.createBinaryExpression(t,e,r)}return e}parseAnd(){let e=this.parseEquality();for(;this.checkValue("and");){let t=this.advance().value,r=this.parseEquality();e=this.createBinaryExpression(t,e,r)}return e}parseEquality(){let e=this.parseComparison();for(;this.match("COMPARISON")||this.checkValue("is")||this.checkValue("matches")||this.checkValue("contains")||this.checkValue("in");){let t=this.previous().value,r=this.parseComparison();e=this.createBinaryExpression(t,e,r)}return e}parseComparison(){let e=this.parseAddition();for(;this.check("COMPARISON");){let t=this.advance().value,r=this.parseAddition();e=this.createBinaryExpression(t,e,r)}return e}parseAddition(){let e=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let t=this.advance().value,r=this.parseMultiplication();e=this.createBinaryExpression(t,e,r)}return e}parseMultiplication(){let e=this.parseUnary();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%";){let t=this.advance().value,r=this.parseUnary();e=this.createBinaryExpression(t,e,r)}return e}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let e=this.advance().value,t=this.parseUnary();return this.createUnaryExpression(e,t)}return this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let t=this.advance().value;e=this.createPropertyAccess(e,t)}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let t=this.advance().value;e=this.createPossessiveExpression(e,t)}else break;else if(this.match("LPAREN")){let t=this.parseArguments();e=this.createCallExpression(e,t)}else if(this.match("LBRACKET")){let t=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");e=this.createPropertyAccess(e,t)}else break;return e}parsePrimary(){let e=this.peek();if(this.match("NUMBER"))return this.createLiteral(parseFloat(e.value),"number",e);if(this.match("STRING")){let t=e.value.slice(1,-1);return this.createLiteral(t,"string",e)}if(this.match("BOOLEAN")){let t=e.value==="true"?!0:e.value==="false"?!1:e.value==="null"?null:void 0;return this.createLiteral(t,e.value,e)}if(this.match("TEMPLATE_LITERAL"))return{type:"templateLiteral",value:e.value,start:e.start,end:e.end,line:e.line,column:e.column};if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(e);if(this.match("ID_SELECTOR"))return this.createSelector(e.value,"id",e);if(this.match("CLASS_SELECTOR"))return this.createSelector(e.value,"class",e);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(e.value,"attribute",e);if(this.match("QUERY_SELECTOR")){let t=e.value.slice(1,-2);return this.createSelector(t,"query",e)}if(this.match("CONTEXT_VAR"))return this.createContextReference(e.value,e);if(this.match("IDENTIFIER"))return this.createIdentifier(e.value,e);if(this.match("LPAREN")){let t=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return t}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${e.value}`)}parseArguments(){let e=[];if(!this.check("RPAREN"))do e.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return e}parseArrayLiteral(){let e=[],t=this.previous().start;if(!this.check("RBRACKET"))do e.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return{type:"arrayLiteral",elements:e,start:t,end:this.previous().end}}parseObjectLiteral(){let e=[],t=this.previous().start;if(!this.check("RBRACE"))do{let r;if(this.check("STRING"))r=this.advance().value.slice(1,-1);else if(this.check("IDENTIFIER"))r=this.advance().value;else throw new Error("Expected property name");if(!this.match("COLON"))throw new Error("Expected : after property name");let o=this.parseExpression();e.push({key:r,value:o})}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return{type:"objectLiteral",properties:e.map(r=>({type:"objectProperty",key:r.key,value:r.value})),start:t,end:this.previous().end}}parseTimeExpression(e){let t=e.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!t)throw new Error(`Invalid time expression: ${e.value}`);let r=parseFloat(t[1]),o=t[2].toLowerCase();return{type:"timeExpression",value:r,unit:o,raw:e.value,start:e.start,end:e.end,line:e.line,column:e.column}}createLiteral(e,t,r){return{type:"literal",value:e,dataType:t,raw:r.value,start:r.start,end:r.end,line:r.line,column:r.column}}createSelector(e,t,r){return{type:"selector",value:e,selector:e,selectorType:t,start:r.start,end:r.end,line:r.line,column:r.column}}createContextReference(e,t){return{type:"contextReference",contextType:e,name:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createIdentifier(e,t){return{type:"identifier",name:e,start:t.start,end:t.end,line:t.line,column:t.column}}createPropertyAccess(e,t){return{type:"propertyAccess",object:e,property:typeof t=="string"?t:t.name??"",start:e.start,end:this.previous().end}}createPossessiveExpression(e,t){return{type:"possessiveExpression",object:e,property:t,start:e.start,end:this.previous().end}}createBinaryExpression(e,t,r){return{type:"binaryExpression",operator:e,left:t,right:r,start:t.start,end:r.end}}createUnaryExpression(e,t){return{type:"unaryExpression",operator:e,operand:t,prefix:!0,start:this.previous().start,end:t.end}}createCallExpression(e,t){return{type:"callExpression",callee:e,arguments:t,start:e.start,end:this.previous().end}}};function Ie(n){return new ye().parse(n)}function E(n,e){switch(n.type){case"literal":return tn(n);case"selector":return rn(n,e);case"reference":return nn(n);case"property-path":return on(n,e);case"expression":return an(n);default:let t=n;throw new Error(`Unknown semantic value type: ${t.type}`)}}function tn(n){let e={type:"literal",value:n.value};return n.dataType?{...e,dataType:n.dataType}:e}function rn(n,e){return e&&n.value.startsWith("*")&&/^[a-zA-Z-]/.test(n.value.slice(1))&&e.push(`Converted '${n.value}' to a CSS selector, but it looks like a CSS property name. CSS properties in commands like 'transition' should be literal strings, not selectors. Consider using expectedTypes: ['literal'] instead of ['literal', 'selector'] in the command schema.`),{type:"selector",value:n.value,selector:n.value,selectorType:n.selectorKind}}function nn(n){return{type:"contextReference",contextType:n.value,name:n.value}}function on(n,e){return{type:"propertyAccess",object:E(n.object,e),property:n.property}}function an(n){let e=Ie(n.raw);return!e.success||!e.node?{type:"identifier",name:n.raw}:e.node}function mt(n,e){return n.roles.get(e)}function d(n,e,t){let r=mt(n,e);return r?E(r,t):void 0}function f(n,e=[],t,r={}){let o={type:"command",name:n,args:e};return t&&Object.keys(t).length>0&&(o.modifiers=t),r.isBlocking&&(o.isBlocking=r.isBlocking),r.implicitTarget&&(o.implicitTarget=r.implicitTarget),o}var sn={action:"toggle",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=d(n,"duration"),i=t?[t]:[],a={};return r&&(a.on=r),o&&(a.for=o),f("toggle",i,a)}},ln={action:"add",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.to=r),f("add",o,i)}},cn={action:"remove",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.from=r),f("remove",o,i)}},dn={action:"set",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i={};return t&&o.push(t),r&&(i.to=r),f("set",o,i)}},pn={action:"show",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=d(n,"duration"),i=[],a={},s=t??r;return s&&i.push(s),o&&(a.with=o),f("show",i,a)}},un={action:"hide",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=d(n,"duration"),i=[],a={},s=t??r;return s&&i.push(s),o&&(a.with=o),f("hide",i,a)}},mn={action:"increment",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=d(n,"quantity"),i=[],a={},s=t??r;return s&&i.push(s),o&&(a.by=o),f("increment",i,a)}},fn={action:"decrement",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=d(n,"quantity"),i=[],a={},s=t??r;return s&&i.push(s),o&&(a.by=o),f("decrement",i,a)}},gn={action:"wait",toAST(n,e){let t=d(n,"duration");return f("wait",t?[t]:[],void 0,{isBlocking:!0})}},hn={action:"log",toAST(n,e){let t=d(n,"patient"),r=[];return t&&r.push(t),f("log",r)}},yn={action:"put",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=mt(n,"method"),i=t?[t]:[],a={};if(r){let s=o?.type==="literal"?String(o.value):"into";a[s]=r}return f("put",i,a)}},vn={action:"fetch",toAST(n,e){let t=d(n,"source"),r=d(n,"method"),o=d(n,"responseType"),i=d(n,"patient"),a=t?[t]:[],s={};return r&&(s.with=r),o&&(s.as=o),i&&(s.body=i),f("fetch",a,s,{isBlocking:!0})}},xn={action:"append",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.to=r),f("append",o,i)}},Sn={action:"prepend",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.to=r),f("prepend",o,i)}},Tn={action:"trigger",toAST(n,e){let t=d(n,"event"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.on=r),f("trigger",o,i)}},bn={action:"send",toAST(n,e){let t=d(n,"event"),r=d(n,"destination"),o=d(n,"patient"),i=t?[t]:[],a={};return r&&(a.to=r),o&&(a.detail=o),f("send",i,a)}},Pn={action:"go",toAST(n,e){let t=d(n,"source"),r=d(n,"destination"),o=[],i={};return t&&o.push(t),r&&(i.to=r),f("go",o,i)}},kn={action:"transition",toAST(n,e){let t=d(n,"patient"),r=d(n,"goal"),o=d(n,"duration"),i=d(n,"destination"),a=t?[t]:[],s={};return r&&(s.to=r),o&&(s.over=o),i&&(s.on=i),f("transition",a,s)}},En={action:"focus",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i={},a=t??r;return a&&o.push(a),f("focus",o,i)}},Cn={action:"blur",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),f("blur",o)}},wn={action:"get",toAST(n,e){let t=d(n,"source"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),f("get",o)}},Rn={action:"take",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.from=r),f("take",o,i)}},Nn={action:"call",toAST(n,e){let t=d(n,"patient");return f("call",t?[t]:[])}},Ln={action:"return",toAST(n,e){let t=d(n,"patient");return f("return",t?[t]:[])}},zn={action:"halt",toAST(n,e){return f("halt",[])}},Mn={action:"throw",toAST(n,e){let t=d(n,"patient");return f("throw",t?[t]:[])}},An={action:"settle",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),f("settle",o,void 0,{isBlocking:!0})}},Vn={action:"swap",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=d(n,"destination"),i=d(n,"style"),a=[],s={};return t&&a.push(t),r&&a.push(r),o&&(s.on=o),i&&(s.with=i),f("swap",a,s)}},In={action:"morph",toAST(n,e){let t=d(n,"source"),r=d(n,"destination"),o=d(n,"patient"),i=[],a={},s=t??o;return s&&i.push(s),r&&(a.on=r),f("morph",i,a)}},On={action:"clone",toAST(n,e){let t=d(n,"source"),r=d(n,"destination"),o=d(n,"patient"),i=[],a={},s=t??o;return s&&i.push(s),r&&(a.into=r),f("clone",i,a)}},_n={action:"make",toAST(n,e){let t=d(n,"patient");return f("make",t?[t]:[])}},qn={action:"measure",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=d(n,"source"),i=[],a={};t&&i.push(t);let s=r??o;return s&&(a.of=s),f("measure",i,a)}},Bn={action:"tell",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),f("tell",o)}},Wn={action:"js",toAST(n,e){let t=d(n,"patient");return f("js",t?[t]:[])}},jn={action:"async",toAST(n,e){return f("async",[])}},Kn={action:"if",toAST(n,e){let t=d(n,"condition");return f("if",t?[t]:[])}},Gn={action:"unless",toAST(n,e){let t=d(n,"condition");return f("unless",t?[t]:[])}},Un={action:"repeat",toAST(n,e){let t=d(n,"quantity"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),f("repeat",o)}},$n={action:"for",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.in=r),f("for",o,i)}},Dn={action:"while",toAST(n,e){let t=d(n,"condition");return f("while",t?[t]:[])}},Fn={action:"continue",toAST(n,e){return f("continue",[])}},Hn={action:"default",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.to=r),f("default",o,i)}},Xn={action:"init",toAST(n,e){return f("init",[])}},Qn={action:"behavior",toAST(n,e){let t=d(n,"patient");return f("behavior",t?[t]:[])}},Zn={action:"install",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.on=r),f("install",o,i)}},Yn={action:"on",toAST(n,e){let t=d(n,"event"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.from=r),f("on",o,i)}},ft=new Map([["toggle",sn],["add",ln],["remove",cn],["set",dn],["show",pn],["hide",un],["increment",mn],["decrement",fn],["wait",gn],["log",hn],["put",yn],["fetch",vn],["append",xn],["prepend",Sn],["get",wn],["take",Rn],["trigger",Tn],["send",bn],["on",Yn],["go",Pn],["transition",kn],["focus",En],["blur",Cn],["call",Nn],["return",Ln],["halt",zn],["throw",Mn],["settle",An],["swap",Vn],["morph",In],["clone",On],["measure",qn],["make",_n],["tell",Bn],["default",Hn],["js",Wn],["async",jn],["if",Kn],["unless",Gn],["repeat",Un],["for",$n],["while",Dn],["continue",Fn],["init",Xn],["behavior",Qn],["install",Zn]]);function J(n){return ft.get(n)}function Oe(n){ft.set(n.action,n)}var ee=class{constructor(e={}){this.warnings=[]}build(e){switch(e.kind){case"command":return this.buildCommand(e);case"event-handler":return this.buildEventHandler(e);case"conditional":return this.buildConditional(e);case"compound":return this.buildCompound(e);case"loop":return this.buildLoop(e);default:throw new Error(`Unknown semantic node kind: ${e.kind}`)}}buildCommand(e){let t=J(e.action);if(t){let r=t.toAST(e,this);if("ast"in r&&"warnings"in r){let o=r;return this.warnings.push(...o.warnings),o.ast}else return r}return this.buildGenericCommand(e)}buildGenericCommand(e){let t=[],r={},o=["patient","source","quantity"],i=["destination","duration","method","style"];for(let s of o){let l=e.roles.get(s);l&&t.push(E(l))}for(let s of i){let l=e.roles.get(s);if(l){let c=this.roleToModifierKey(s);r[c]=E(l)}}let a={type:"command",name:e.action,args:t};return Object.keys(r).length>0?{...a,modifiers:r}:a}roleToModifierKey(e){return{destination:"on",duration:"for",source:"from",condition:"if",method:"via",style:"with"}[e]??e}buildEventHandler(e){let t=e.roles.get("event"),r,o;if(t?.type==="literal"){let h=String(t.value);h.includes("|")||h.includes(" or ")?(o=h.split(/\s+or\s+|\|/).map(P=>P.trim()),r=o[0]):r=h}else t?.type==="reference"?r=t.value:r="click";let i=e.body.map(h=>this.build(h)),a=e.roles.get("source"),s,l;a?.type==="selector"?(s=a.value,l=a.value):a?.type==="reference"?l=a.value:a?.type==="literal"&&(l=String(a.value));let c=e.roles.get("condition"),p=c?E(c):void 0,S=e.roles.get("destination"),y=S?E(S):void 0,g=e.eventModifiers,u=s;if(g?.from){let h=g.from;h.type==="selector"&&!s&&(u=h.value)}let m=e.parameterNames?[...e.parameterNames]:void 0;return{type:"eventHandler",event:r,commands:i,...o&&o.length>1?{events:o}:{},...u?{selector:u}:{},...l?{target:l}:{},...p?{condition:p}:{},...y?{watchTarget:y}:{},...m&&m.length>0?{args:m,params:m}:{}}}buildConditional(e){let t=e.roles.get("condition");if(!t)throw new Error("Conditional node missing condition");let r=E(t),o=e.thenBranch.map(s=>this.build(s)),i=e.elseBranch?.map(s=>this.build(s)),a=[r,{type:"block",commands:o}];return i&&i.length>0&&a.push({type:"block",commands:i}),{type:"command",name:"if",args:a}}buildCompound(e){let t=e.statements.map(o=>this.build(o));return t.length===1?t[0]:t.length===0?{type:"block",commands:[]}:{type:"CommandSequence",commands:t}}buildLoop(e){let t=e.body.map(o=>this.build(o)),r=[{type:"identifier",name:e.loopVariant}];switch(e.loopVariant){case"times":{let o=e.roles.get("quantity");o&&r.push(E(o));break}case"for":{e.loopVariable&&r.push({type:"string",value:e.loopVariable});let o=e.roles.get("source");o&&r.push(E(o));break}case"while":case"until":{let o=e.roles.get("condition");o&&r.push(E(o));break}case"forever":break}return r.push({type:"block",commands:t}),{type:"command",name:"repeat",args:r}}buildBlock(e){return{type:"block",commands:e.map(r=>this.build(r))}}};function gt(n){let e=new ee;return{ast:e.build(n),warnings:e.warnings}}var j=class{constructor(e={}){this.cache=new Map,this.config={maxSize:e.maxSize??1e3,ttlMs:e.ttlMs??0,enabled:e.enabled??!0},this.stats={hits:0,misses:0,evictions:0,expirations:0}}makeKey(e,t){return`${t}:${e}`}isExpired(e){return this.config.ttlMs===0?!1:Date.now()-e.createdAt>this.config.ttlMs}evictLRU(){let e=this.cache.keys().next().value;e!==void 0&&(this.cache.delete(e),this.stats.evictions++)}get(e,t){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(e,t),o=this.cache.get(r);if(!o){this.stats.misses++;return}if(this.isExpired(o)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),o.lastAccessed=Date.now(),this.cache.set(r,o),this.stats.hits++,o.result}set(e,t,r){if(!this.config.enabled||r.confidence===0)return;let o=this.makeKey(e,t),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(o,{result:r,createdAt:i,lastAccessed:i})}has(e,t){if(!this.config.enabled)return!1;let r=this.makeKey(e,t),o=this.cache.get(r);return o?this.isExpired(o)?(this.cache.delete(r),this.stats.expirations++,!1):!0:!1}delete(e,t){let r=this.makeKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear()}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0}}getStats(){let e=this.stats.hits+this.stats.misses;return{hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:e>0?this.stats.hits/e:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(e){if(e.maxSize!==void 0)for(this.config.maxSize=e.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();e.ttlMs!==void 0&&(this.config.ttlMs=e.ttlMs),e.enabled!==void 0&&(this.config.enabled=e.enabled)}enable(){this.config.enabled=!0}disable(){this.config.enabled=!1}getConfig(){return{...this.config}}},_e=new j;var te=class{constructor(e={}){this.patternMatcher=new Y,this.languages=new Set(ie()),e.cache===!1?this.cache=new j({enabled:!1}):this.cache=e.cache?new j(e.cache):_e}analyze(e,t){if(!this.supportsLanguage(t))return{confidence:0,errors:[`Language '${t}' is not supported for semantic parsing`]};let r=this.cache.get(e,t);if(r)return r;let o=this.analyzeUncached(e,t);return this.cache.set(e,t,o),o}analyzeUncached(e,t){try{let r=ct(t);if(!r)return{confidence:0,errors:[`No tokenizer available for language '${t}'`]};let o=r.tokenize(e),i=C(t);if(i.length===0)return{confidence:0,errors:[`No patterns available for language '${t}'`]};let a=this.patternMatcher.matchBest(o,i);if(!a)return{confidence:0,errors:["No pattern matched the input"]};let s=this.buildSemanticNode(a);return{confidence:a.confidence,command:{name:a.pattern.command,roles:a.captured},node:s,tokensConsumed:a.consumedTokens}}catch(r){return{confidence:0,errors:[r instanceof Error?r.message:String(r)]}}}supportsLanguage(e){return this.languages.has(e)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear()}configureCache(e){this.cache.configure(e)}buildSemanticNode(e){return{kind:"command",action:e.pattern.command,roles:e.captured,metadata:{patternId:e.pattern.id}}}};function ht(n){return new te(n)}var qe=.5,yt=.8;function vt(n,e=qe){return n.confidence>=e&&n.command!==void 0}var Jn="1.0.0-es-en";function eo(){return["en","es"]}function to(n,e){if(e!=="en"&&e!=="es")throw new Error(`Language not supported in this bundle: ${e}. Supported: en, es`);return[...pe(n,e).tokens]}function xt(n){if(n!=="en"&&n!=="es")throw new Error(`Language not supported in this bundle: ${n}. Supported: en, es`);return C(n)}function ro(n,e){return xt(n).filter(t=>t.command===e).sort((t,r)=>r.priority-t.priority)}function no(n,e,t){if(e!=="en"&&e!=="es"||t!=="en"&&t!=="es")throw new Error("This bundle only supports translation between en and es");return Ae(n,e,t)}function oo(n,e){if(e!=="en"&&e!=="es")throw new Error(`Language not supported in this bundle: ${e}. Supported: en, es`);let t=Ve(n,e);return{en:t.en,es:t.es}}return Et(io);})();
1
+ "use strict";var LokaScriptSemanticEsEn=(()=>{var Te=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var Nt=Object.prototype.hasOwnProperty;var wt=(n,e)=>{for(var t in e)Te(n,t,{get:e[t],enumerable:!0})},Lt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ct(e))!Nt.call(n,o)&&o!==t&&Te(n,o,{get:()=>e[o],enumerable:!(r=Rt(e,o))||r.enumerable});return n};var zt=n=>Lt(Te({},"__esModule",{value:!0}),n);var To={};wt(To,{ASTBuilder:()=>oe,DEFAULT_CONFIDENCE_THRESHOLD:()=>je,HIGH_CONFIDENCE_THRESHOLD:()=>bt,SemanticAnalyzerImpl:()=>ie,VERSION:()=>go,buildAST:()=>Tt,canParse:()=>Ie,createCommandNode:()=>V,createEventHandler:()=>Y,createLiteral:()=>P,createPropertyPath:()=>Z,createReference:()=>z,createSelector:()=>A,createSemanticAnalyzer:()=>Pt,englishProfile:()=>L,englishTokenizer:()=>pe,fromExplicit:()=>he,getAllTranslations:()=>So,getCommandMapper:()=>ne,getPatternsForLanguage:()=>Et,getPatternsForLanguageAndCommand:()=>vo,getProfile:()=>Ee,getSupportedLanguages:()=>yo,getTokenizer:()=>ke,isExplicitSyntax:()=>K,isLanguageSupported:()=>He,parse:()=>G,parseAny:()=>ve,parseExplicit:()=>j,registerCommandMapper:()=>We,render:()=>B,renderExplicit:()=>J,shouldUseSemanticResult:()=>kt,spanishProfile:()=>$,spanishTokenizer:()=>ue,toExplicit:()=>Oe,tokenize:()=>ho,translate:()=>xo});var N=new Map,I=new Map,D=new Map;var Ke=null;function Ge(n,e){let t={...n};for(let r of Object.keys(e)){let o=e[r],i=n[r];o!==void 0&&(typeof o=="object"&&o!==null&&!Array.isArray(o)&&typeof i=="object"&&i!==null&&!Array.isArray(i)?t[r]=Ge(i,o):t[r]=o)}return t}function Mt(n,e){return Ge(n,e)}function be(n){if(!n.extends)return n;let e=I.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=be(e);return Mt(t,n)}function se(n,e,t){N.set(n,e),I.set(n,t),D.delete(n)}var Pe=new Map;function Ue(n,e){Pe.set(n,e),D.delete(n)}function O(n){return n.split("-")[0]}function _(n){return n.includes("-")}function ke(n){let e=N.get(n);if(!e&&_(n)){let t=O(n);e=N.get(t)}if(!e){let t=Array.from(N.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 Ee(n){let e=I.get(n);if(!e&&_(n)){let t=O(n);e=I.get(t)}if(!e){let t=Array.from(I.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 be(e)}function De(n){let e=N.get(n);return!e&&_(n)&&(e=N.get(O(n))),e}function H(n){let e=I.get(n);return!e&&_(n)&&(e=I.get(O(n))),e?be(e):void 0}function le(){return Array.from(N.keys())}function He(n){return N.has(n)?!0:_(n)?N.has(O(n)):!1}function Fe(n,e){return ke(e).tokenize(n)}function R(n){let e=D.get(n);if(!e&&_(n)&&(e=D.get(O(n))),e)return e;let t=Pe.get(n);if(!t&&_(n)&&(t=Pe.get(O(n))),t)return D.set(n,t),t;if(!Ke)throw new Error(`No patterns registered for language '${n}'. Either import the language module or set a pattern generator.`);let r=Ee(n),o=Ke(r);return D.set(n,o),o}function Xe(n,e){return R(n).filter(t=>t.command===e).sort((t,r)=>r.priority-t.priority)}var w=class{constructor(e,t){this.pos=0;this.tokens=e,this.language=t}peek(e=0){let t=this.pos+e;return t<0||t>=this.tokens.length?null:this.tokens[t]}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(e){this.pos=e.position}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(e){let t=[];for(;!this.isAtEnd()&&e(this.peek());)t.push(this.advance());return t}skipWhile(e){for(;!this.isAtEnd()&&e(this.peek());)this.advance()}};function x(n,e){return{start:n,end:e}}function S(n,e,t,r){if(typeof r=="string")return{value:n,kind:e,position:t,normalized:r};if(r){let{normalized:o,stem:i,stemConfidence:a}=r,s={value:n,kind:e,position:t};return o!==void 0&&(s.normalized=o),i!==void 0&&(s.stem=i,a!==void 0&&(s.stemConfidence=a)),s}return{value:n,kind:e,position:t}}function C(n){return/\s/.test(n)}function F(n){return n==="#"||n==="."||n==="["||n==="@"||n==="*"||n==="<"}function X(n){return n==='"'||n==="'"||n==="`"||n==="\u300C"||n==="\u300D"}function k(n){return/\d/.test(n)}function Qe(n){return/[a-zA-Z]/.test(n)}function T(n){return/[a-zA-Z0-9_-]/.test(n)}function Re(n){let e=r=>n.test(r);return{isLetter:e,isIdentifierChar:r=>e(r)||/[0-9_-]/.test(r)}}function Ze(n,e){if(e>=n.length)return null;let t=n[e];if(!F(t))return null;let r=e,o="";if(t==="#"||t==="."){for(o+=n[r++];r<n.length&&T(n[r]);)o+=n[r++];if(o.length<=1)return null;if(r<n.length&&n[r]==="."&&t==="#"){let a=r+1;for(;a<n.length&&T(n[a]);)a++;if(a<n.length&&n[a]==="(")return o}}else if(t==="["){let i=1,a=!1,s=null,l=!1;for(o+=n[r++];r<n.length&&i>0;){let c=n[r];o+=c,l?l=!1:c==="\\"?l=!0:a?c===s&&(a=!1,s=null):c==='"'||c==="'"||c==="`"?(a=!0,s=c):c==="["?i++:c==="]"&&i--,r++}if(i!==0)return null}else if(t==="@"){for(o+=n[r++];r<n.length&&T(n[r]);)o+=n[r++];if(o.length<=1)return null}else if(t==="*"){for(o+=n[r++];r<n.length&&T(n[r]);)o+=n[r++];if(o.length<=1)return null}else if(t==="<"){if(o+=n[r++],r>=n.length||!Qe(n[r]))return null;for(;r<n.length&&T(n[r]);)o+=n[r++];for(;r<n.length;){let i=n[r];if(i==="."){if(o+=n[r++],r>=n.length||!T(n[r]))return null;for(;r<n.length&&T(n[r]);)o+=n[r++]}else if(i==="#"){if(o+=n[r++],r>=n.length||!T(n[r]))return null;for(;r<n.length&&T(n[r]);)o+=n[r++]}else if(i==="["){let a=1,s=!1,l=null,c=!1;for(o+=n[r++];r<n.length&&a>0;){let p=n[r];o+=p,c?c=!1:p==="\\"?c=!0:s?p===l&&(s=!1,l=null):p==='"'||p==="'"||p==="`"?(s=!0,l=p):p==="["?a++:p==="]"&&a--,r++}if(a!==0)return null}else break}for(;r<n.length&&C(n[r]);)o+=n[r++];if(r<n.length&&n[r]==="/")for(o+=n[r++];r<n.length&&C(n[r]);)o+=n[r++];if(r>=n.length||n[r]!==">")return null;o+=n[r++]}return o||null}function Ce(n,e){if(e>=n.length||n[e]!=="'"||e+1>=n.length||n[e+1].toLowerCase()!=="s")return!1;if(e+2>=n.length)return!0;let r=n[e+2];return C(r)||r==="*"||!T(r)}function Ye(n,e){if(e>=n.length)return null;let t=n[e];if(!X(t)||t==="'"&&Ce(n,e))return null;let o={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!o)return null;let i=e+1,a=t,s=!1;for(;i<n.length;){let l=n[i];if(a+=l,s)s=!1;else if(l==="\\")s=!0;else if(l===o)return a;i++}return a}function Q(n,e){if(e>=n.length)return!1;let t=n[e],r=n[e+1]||"",o=n[e+2]||"";if(t==="/"&&r!=="/"&&/[a-zA-Z0-9._-]/.test(r)||t==="/"&&r==="/"&&/[a-zA-Z]/.test(o)||t==="."&&(r==="/"||r==="."&&o==="/"))return!0;let i=n.slice(e,e+8).toLowerCase();return!!(i.startsWith("http://")||i.startsWith("https://"))}function Je(n,e){if(!Q(n,e))return null;let t=e,r="",o=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<n.length;){let i=n[t];if(i==="#"){if(r.length>0&&/[a-zA-Z0-9/.]$/.test(r))for(r+=i,t++;t<n.length&&/[a-zA-Z0-9_-]/.test(n[t]);)r+=n[t++];break}if(o.test(i))r+=i,t++;else break}return r.length<2?null:r}function et(n,e){if(e>=n.length)return null;let t=n[e];if(!k(t)&&t!=="-"&&t!=="+")return null;let r=e,o="";if((n[r]==="-"||n[r]==="+")&&(o+=n[r++]),r>=n.length||!k(n[r]))return null;for(;r<n.length&&k(n[r]);)o+=n[r++];if(r<n.length&&n[r]===".")for(o+=n[r++];r<n.length&&k(n[r]);)o+=n[r++];return r<n.length&&(n.slice(r,r+2)==="ms"?o+="ms":(n[r]==="s"||n[r]==="m"||n[r]==="h")&&(o+=n[r])),o}var ce=class ce{constructor(){this.profileKeywords=[];this.profileKeywordMap=new Map}initializeKeywordsFromProfile(e,t=[]){let r=new Map;if(e.keywords){for(let[o,i]of Object.entries(e.keywords))if(r.set(i.primary,{native:i.primary,normalized:i.normalized||o}),i.alternatives)for(let a of i.alternatives)r.set(a,{native:a,normalized:i.normalized||o})}if(e.references)for(let[o,i]of Object.entries(e.references))r.set(i,{native:i,normalized:o});if(e.roleMarkers){for(let[o,i]of Object.entries(e.roleMarkers))if(i.primary&&r.set(i.primary,{native:i.primary,normalized:o}),i.alternatives)for(let a of i.alternatives)r.set(a,{native:a,normalized:o})}for(let o of t)r.set(o.native,o);this.profileKeywords=Array.from(r.values()).sort((o,i)=>i.native.length-o.native.length),this.profileKeywordMap=new Map;for(let o of this.profileKeywords){this.profileKeywordMap.set(o.native.toLowerCase(),o);let i=this.removeDiacritics(o.native);i!==o.native&&!this.profileKeywordMap.has(i.toLowerCase())&&this.profileKeywordMap.set(i.toLowerCase(),o)}}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 S(r.native,"keyword",x(t,t+r.native.length),r.normalized);return null}isKeywordStart(e,t){let r=e.slice(t);return this.profileKeywords.some(o=>r.startsWith(o.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 o=this.tryNormalize(e);if(!o)return null;let i=this.lookupKeyword(o.stem);if(!i)return null;let a={normalized:i.normalized,stem:o.stem,stemConfidence:o.confidence};return S(e,"keyword",x(t,r),a)}trySelector(e,t){let r=Ze(e,t);return r?S(r,"selector",x(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 o=r[0].replace(/(\s|\.)$/,""),i=o.slice(1).split("(")[0],a=r[1];return{...S(o,"event-modifier",x(t,t+o.length)),metadata:{modifierName:i,value:a?i==="queue"?a:parseInt(a,10):void 0}}}tryString(e,t){let r=Ye(e,t);return r?S(r,"literal",x(t,t+r.length)):null}tryNumber(e,t){let r=et(e,t);return r?S(r,"literal",x(t,t+r.length)):null}tryMatchTimeUnit(e,t,r,o=!1){let i=t;if(o)for(;i<e.length&&C(e[i]);)i++;let a=e.slice(i);for(let s of r){let l=a.slice(0,s.length);if(s.caseInsensitive?l.toLowerCase()===s.pattern.toLowerCase():l===s.pattern){if(s.notFollowedBy&&(a[s.length]||"")===s.notFollowedBy)continue;if(s.checkBoundary){let p=a[s.length]||"";if(T(p))continue}return{suffix:s.suffix,endPos:i+s.length}}}return null}parseBaseNumber(e,t,r=!0){let o=t,i="";if(r&&(e[o]==="-"||e[o]==="+")&&(i+=e[o++]),o>=e.length||!k(e[o]))return null;for(;o<e.length&&k(e[o]);)i+=e[o++];if(o<e.length&&e[o]===".")for(i+=e[o++];o<e.length&&k(e[o]);)i+=e[o++];return!i||i==="-"||i==="+"?null:{number:i,endPos:o}}tryNumberWithTimeUnits(e,t,r,o={}){let{allowSign:i=!0,skipWhitespace:a=!1}=o,s=this.parseBaseNumber(e,t,i);if(!s)return null;let{number:l,endPos:c}=s,p=[...r,...ce.STANDARD_TIME_UNITS],g=this.tryMatchTimeUnit(e,c,p,a);return g&&(l+=g.suffix,c=g.endPos),S(l,"literal",x(t,c))}tryUrl(e,t){let r=Je(e,t);return r?S(r,"url",x(t,t+r.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!T(e[t+1]))return null;let r=t+1;for(;r<e.length&&T(e[r]);)r++;let o=e.slice(t,r);return S(o,"identifier",x(t,r))}tryOperator(e,t){let r=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(r))return S(r,"operator",x(t,t+2));let o=e[t];return["<",">","!","+","-","*","/","="].includes(o)?S(o,"operator",x(t,t+1)):["(",")","{","}",",",";",":"].includes(o)?S(o,"punctuation",x(t,t+1)):null}tryMultiCharParticle(e,t,r){for(let o of r)if(e.slice(t,t+o.length)===o)return S(o,"particle",x(t,t+o.length));return null}};ce.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:!0},{pattern:"m",suffix:"m",length:1,checkBoundary:!0,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:!0}];var q=ce;var L={code:"en",name:"English",nativeName:"English",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,defaultVerbForm:"base",verb:{position:"start",subjectDrop:!1},references:{me:"me",it:"it",you:"you",result:"result",event:"event",target:"target",body:"body"},possessive:{marker:"'s",markerPosition:"after-object",specialForms:{me:"my",it:"its",you:"your"},keywords:{my:"me",your:"you",its:"it"}},roleMarkers:{destination:{primary:"on",alternatives:["to","from"],position:"before"},source:{primary:"from",position:"before"},patient:{primary:"",position:"before"},style:{primary:"with",alternatives:["by","using"],position:"before"},responseType:{primary:"as",position:"before"},method:{primary:"via",alternatives:["using"],position:"before"}},keywords:{toggle:{primary:"toggle"},add:{primary:"add"},remove:{primary:"remove"},put:{primary:"put"},append:{primary:"append"},prepend:{primary:"prepend"},take:{primary:"take"},make:{primary:"make"},clone:{primary:"clone"},swap:{primary:"swap"},morph:{primary:"morph"},set:{primary:"set"},get:{primary:"get"},increment:{primary:"increment"},decrement:{primary:"decrement"},log:{primary:"log"},show:{primary:"show"},hide:{primary:"hide"},transition:{primary:"transition"},on:{primary:"on"},trigger:{primary:"trigger"},send:{primary:"send"},focus:{primary:"focus"},blur:{primary:"blur"},go:{primary:"go"},wait:{primary:"wait"},fetch:{primary:"fetch"},settle:{primary:"settle"},if:{primary:"if"},when:{primary:"when",normalized:"when"},where:{primary:"where",normalized:"where"},else:{primary:"else"},repeat:{primary:"repeat"},for:{primary:"for"},while:{primary:"while"},continue:{primary:"continue"},halt:{primary:"halt"},throw:{primary:"throw"},call:{primary:"call"},return:{primary:"return"},then:{primary:"then"},and:{primary:"and"},end:{primary:"end"},js:{primary:"js"},async:{primary:"async"},tell:{primary:"tell"},default:{primary:"default"},init:{primary:"init"},behavior:{primary:"behavior"},install:{primary:"install"},measure:{primary:"measure"},into:{primary:"into"},before:{primary:"before"},after:{primary:"after"},until:{primary:"until"},event:{primary:"event"},from:{primary:"from"}}};var At=[{native:"true",normalized:"true"},{native:"false",normalized:"false"},{native:"null",normalized:"null"},{native:"undefined",normalized:"undefined"},{native:"first",normalized:"first"},{native:"last",normalized:"last"},{native:"next",normalized:"next"},{native:"previous",normalized:"previous"},{native:"closest",normalized:"closest"},{native:"click",normalized:"click"},{native:"dblclick",normalized:"dblclick"},{native:"mousedown",normalized:"mousedown"},{native:"mouseup",normalized:"mouseup"},{native:"mouseover",normalized:"mouseover"},{native:"mouseout",normalized:"mouseout"},{native:"mouseenter",normalized:"mouseenter"},{native:"mouseleave",normalized:"mouseleave"},{native:"mousemove",normalized:"mousemove"},{native:"keydown",normalized:"keydown"},{native:"keyup",normalized:"keyup"},{native:"keypress",normalized:"keypress"},{native:"input",normalized:"input"},{native:"change",normalized:"change"},{native:"submit",normalized:"submit"},{native:"reset",normalized:"reset"},{native:"load",normalized:"load"},{native:"unload",normalized:"unload"},{native:"scroll",normalized:"scroll"},{native:"resize",normalized:"resize"},{native:"dragstart",normalized:"dragstart"},{native:"drag",normalized:"drag"},{native:"dragend",normalized:"dragend"},{native:"dragenter",normalized:"dragenter"},{native:"dragleave",normalized:"dragleave"},{native:"dragover",normalized:"dragover"},{native:"drop",normalized:"drop"},{native:"touchstart",normalized:"touchstart"},{native:"touchmove",normalized:"touchmove"},{native:"touchend",normalized:"touchend"},{native:"touchcancel",normalized:"touchcancel"},{native:"in",normalized:"in"},{native:"to",normalized:"to"},{native:"at",normalized:"at"},{native:"by",normalized:"by"},{native:"with",normalized:"with"},{native:"without",normalized:"without"},{native:"of",normalized:"of"},{native:"as",normalized:"as"},{native:"every",normalized:"every"},{native:"upon",normalized:"upon"},{native:"unless",normalized:"unless"},{native:"forever",normalized:"forever"},{native:"times",normalized:"times"},{native:"and",normalized:"and"},{native:"or",normalized:"or"},{native:"not",normalized:"not"},{native:"is",normalized:"is"},{native:"exists",normalized:"exists"},{native:"empty",normalized:"empty"},{native:"my",normalized:"my"},{native:"your",normalized:"your"},{native:"its",normalized:"its"},{native:"the",normalized:"the"},{native:"a",normalized:"a"},{native:"an",normalized:"an"},{native:"delete",normalized:"delete"},{native:"innerHTML",normalized:"innerHTML"},{native:"outerHTML",normalized:"outerHTML"},{native:"beforebegin",normalized:"beforebegin"},{native:"afterend",normalized:"afterend"},{native:"beforeend",normalized:"beforeend"},{native:"afterbegin",normalized:"afterbegin"},{native:"flip",normalized:"toggle"},{native:"switch",normalized:"toggle"},{native:"increase",normalized:"increment"},{native:"decrease",normalized:"decrement"},{native:"display",normalized:"show"},{native:"reveal",normalized:"show"},{native:"conceal",normalized:"hide"},{native:"colour",normalized:"color"},{native:"grey",normalized:"gray"},{native:"centre",normalized:"center"},{native:"behaviour",normalized:"behavior"},{native:"initialise",normalized:"initialize"},{native:"favourite",normalized:"favorite"}],Ne=class extends q{constructor(){super();this.language="en";this.direction="ltr";this.initializeKeywordsFromProfile(L,At)}tokenize(t){let r=[],o=0;for(;o<t.length;){if(C(t[o])){o++;continue}if(F(t[o])){let s=this.tryEventModifier(t,o);if(s){r.push(s),o=s.position.end;continue}if(t[o]==="."){let c=r[r.length-1],p=c&&c.position.end<o;if(c&&!p&&(c.kind==="identifier"||c.kind==="keyword"||c.kind==="selector")){r.push(S(".","operator",x(o,o+1))),o++;continue}let u=o+1;for(;u<t.length&&T(t[u]);)u++;if(u<t.length&&t[u]==="("){r.push(S(".","operator",x(o,o+1))),o++;continue}}let l=this.trySelector(t,o);if(l){r.push(l),o=l.position.end;continue}}if(X(t[o])){if(t[o]==="'"&&Ce(t,o)){r.push(S("'s","punctuation",x(o,o+2))),o+=2;continue}let s=this.tryString(t,o);if(s){r.push(s),o=s.position.end;continue}}if(Q(t,o)){let s=this.tryUrl(t,o);if(s){r.push(s),o=s.position.end;continue}}if(k(t[o])||t[o]==="-"&&o+1<t.length&&k(t[o+1])){let s=this.tryNumber(t,o);if(s){r.push(s),o=s.position.end;continue}}let i=this.tryVariableRef(t,o);if(i){r.push(i),o=i.position.end;continue}if(T(t[o])){let s=this.extractWord(t,o);if(s){r.push(s),o=s.position.end;continue}}let a=this.tryOperator(t,o);if(a){r.push(a),o=a.position.end;continue}o++}return new w(r,"en")}classifyToken(t){return this.isKeyword(t)?"keyword":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}extractWord(t,r){let o=r,i="";for(;o<t.length&&T(t[o]);)i+=t[o++];if(!i)return null;if(o<t.length&&t[o]===":"){let c=o;o++;let p="";for(;o<t.length&&T(t[o]);)p+=t[o++];p?i=i+":"+p:o=c}let a=this.classifyToken(i),s=this.lookupKeyword(i),l=s&&s.normalized!==s.native?s.normalized:void 0;if(a==="identifier"){let c=this.tryConvertToClassSelector(t,o,i);if(c)return c.token}return S(i,a,x(r,o),l)}tryConvertToClassSelector(t,r,o){let i=r;for(;i<t.length&&/\s/.test(t[i]);)i++;if(t.slice(i,i+5).toLowerCase()==="class"){let a=i+5;if(a>=t.length||!T(t[a])){let s="."+o;return{token:S(s,"selector",x(r-o.length,r)),endPos:r}}}return null}},pe=new Ne;var Vt={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:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,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)"}},It={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:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],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"}},Ot={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:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:!1,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"}},_t={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:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2}],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"}},qt={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:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:""}},{role:"patient",description:"The value to set",required:!0,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"}}],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>"}},$t={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:!0,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:!1,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Wt={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:!0,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:!1,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Bt={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:!0,roles:[{role:"event",description:"The event to handle",required:!0,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},jt={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:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Kt={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Gt={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:!1,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:!1,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:!1,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},Ut={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:!1,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2}]},Dt={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:!1,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2}]},Ht={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:!0,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1}]},Ft={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:!0,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1}]},Xt={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Qt={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:!0,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:""}},{role:"destination",description:"Where to store the result (optional)",required:!1,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},Zt={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:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Yt={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:!0,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},Jt={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:!1,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},er={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:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},tr={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},rr={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,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:!0,roles:[{role:"condition",description:"The condition to evaluate",required:!0,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},or={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:!0,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},ir={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},ar={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:!0,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:!0,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:!1,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:!1,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},sr={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The iteration variable",required:!0,expectedTypes:["reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1}]},lr={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to check",required:!0,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},cr={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},pr={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},dr={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:!0,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"goal",description:"The target value to transition to",required:!0,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:!1,expectedTypes:["literal"],svoPosition:4,sovPosition:4},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:!1,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},ur={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:!1,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1}]},mr={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:!1,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:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},gr={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:!0,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},yr={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:!1,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},hr={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The JavaScript code to execute",required:!1,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},vr={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:!0,roles:[]},xr={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:!0,roles:[{role:"destination",description:"The element to tell",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1}]},Sr={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:!0,expectedTypes:["reference"],svoPosition:1,sovPosition:1},{role:"patient",description:"The default value",required:!0,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2}]},Tr={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},Pr={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},br={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},kr={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:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2}]},Er={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:!1,expectedTypes:["literal"],svoPosition:1,sovPosition:3},{role:"destination",description:"The element to swap content in/for",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1},{role:"patient",description:"The content to swap in (optional for delete)",required:!1,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2}]},Rr={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:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1},{role:"patient",description:"The target content/element to morph into",required:!0,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2}]},Cr={toggle:Vt,add:It,remove:Ot,put:_t,set:qt,show:$t,hide:Wt,on:Bt,trigger:jt,wait:Kt,fetch:Gt,increment:Ut,decrement:Dt,append:Ht,prepend:Ft,log:Xt,get:Qt,take:Zt,make:Yt,halt:Jt,settle:er,throw:tr,send:rr,if:nr,unless:or,else:ir,repeat:ar,for:sr,while:lr,continue:cr,go:pr,transition:dr,clone:ur,focus:mr,blur:fr,call:gr,return:yr,js:hr,async:vr,tell:xr,default:Sr,init:Tr,behavior:Pr,install:br,measure:kr,swap:Er,morph:Rr,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:!0,roles:[]}};function tt(){return Object.values(Cr).filter(n=>n.roles.length>0)}function we(n,e){let t=e==="SOV"?"sovPosition":"svoPosition";return[...n].sort((r,o)=>{let i=r[t]??99,a=o[t]??99;return i-a})}function rt(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:!0};if(r&&r.primary){let o={primary:r.primary,position:r.position,isOverride:!1};return r.alternatives&&(o.alternatives=r.alternatives),o}return null}var ee={basePriority:100,generateSimpleVariants:!0,generateAlternatives:!0};function it(n,e,t=ee){let r=`${n.action}-${e.code}-generated`,o=t.basePriority??100,i=e.keywords[n.action];if(!i)throw new Error(`No keyword translation for '${n.action}' in ${e.code}`);let a=qr(n,e,i),s=st(n,e),l=jr(n,e,i);return{id:r,language:e.code,command:n.action,priority:o,template:{format:l,tokens:a},extraction:s}}function Nr(n,e,t=ee){if(n.roles.filter(s=>!s.required).length===0)return null;let o=n.roles.filter(s=>s.required),i={...n,roles:o};return{...it(i,e,t),id:`${n.action}-${e.code}-simple`,priority:(t.basePriority??100)-5,extraction:st(n,e)}}function wr(n,e,t=ee){let r=[];if(r.push(it(n,e,t)),t.generateSimpleVariants){let o=Nr(n,e,t);o&&r.push(o)}return r}function at(n,e=ee){let t=[],r=tt();for(let o of r){if(!n.keywords[o.action])continue;let i=wr(o,n,e);if(t.push(...i),n.eventHandler?.eventMarker){let a=Lr(o,n,e);t.push(...a)}}return t}function Lr(n,e,t=ee){if(!e.eventHandler||!e.eventHandler.eventMarker)return[];let r=[],o=e.eventHandler.eventMarker,i=e.keywords[n.action];if(!i)return[];let s=n.roles.filter(l=>l.required).length===2;if(e.wordOrder==="SOV")if(s)r.push(Ir(n,e,i,o,t));else{r.push(zr(n,e,i,o,t));let l=o.primary.split(/\s+/),c=o.alternatives?.some(g=>!g.includes(" ")&&g.length>1);l.length>1&&c&&r.push(Mr(n,e,i,o,t)),r.push(Ar(n,e,i,o,t));let p=Vr(n,e,i,t);p&&r.push(p)}else e.wordOrder==="VSO"?s?r.push(ot(n,e,i,o,t)):(r.push(nt(n,e,i,o,t)),e.eventHandler?.negationMarker&&r.push(Or(n,e,i,o,t)),e.tokenization?.prefixes&&r.push(_r(n,e,i,t))):s?r.push(ot(n,e,i,o,t)):r.push(nt(n,e,i,o,t));return r}function zr(n,e,t,r,o){let i=[];if(i.push({type:"role",role:"event",optional:!1}),r.position==="after"){let c=r.primary.split(/\s+/);if(c.length>1)for(let p of c)i.push({type:"literal",value:p});else{let p=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(p)}}let a=e.roleMarkers.destination;a&&i.push({type:"group",optional:!0,tokens:[{type:"role",role:"destination",optional:!0},a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary}]}),i.push({type:"role",role:"patient",optional:!1});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};i.push(c)}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(l),{id:`${n.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(o.basePriority??100)+50,template:{format:`{event} ${r.primary} {destination?} {patient} ${s?.primary||""} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Mr(n,e,t,r,o){let i=[];i.push({type:"role",role:"event",optional:!1});let a=r.alternatives?.filter(p=>!p.includes(" ")&&p.length>1)||[];a.length>0&&i.push({type:"literal",value:a[0],alternatives:a.slice(1)});let s=e.roleMarkers.destination;s&&i.push({type:"group",optional:!0,tokens:[{type:"role",role:"destination",optional:!0},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),i.push({type:"role",role:"patient",optional:!1});let l=e.roleMarkers.patient;if(l){let p=l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary};i.push(p)}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(c),{id:`${n.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(o.basePriority??100)+52,template:{format:`{event}${a[0]||""} {patient} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Ar(n,e,t,r,o){let i=[];if(i.push({type:"role",role:"event",optional:!1}),r.position==="after"){let s=r.primary.split(/\s+/);if(s.length>1)for(let l of s)i.push({type:"literal",value:l});else{let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(l)}}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(a),{id:`${n.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`{event} ${r.primary} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function Vr(n,e,t,r){let o=e.eventHandler?.temporalMarkers;if(!o||o.length===0)return null;let i=[];i.push({type:"role",role:"event",optional:!1}),e.possessive?.marker&&i.push({type:"group",optional:!0,tokens:[{type:"literal",value:e.possessive.marker}]}),i.push({type:"literal",value:o[0],alternatives:o.slice(1)}),i.push({type:"role",role:"patient",optional:!1});let a=e.roleMarkers.patient;if(a?.primary){let l=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};i.push(l)}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(s),{id:`${n.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(r.basePriority??100)+49,template:{format:`{event} ${o[0]} {patient} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function nt(n,e,t,r,o){let i=[];if(r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(l)}i.push({type:"role",role:"event",optional:!1});let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(a),i.push({type:"role",role:"patient",optional:!1});let s=e.roleMarkers.destination;return s&&i.push({type:"group",optional:!0,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:!0}]}),{id:`${n.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(o.basePriority??100)+50,template:{format:`${r.primary} {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"}}}}}function Ir(n,e,t,r,o){let i=[];if(i.push({type:"role",role:"event",optional:!1}),r.position==="after"){let p=r.primary.split(/\s+/);if(p.length>1)for(let g of p)i.push({type:"literal",value:g});else{let g=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(g)}}let s=[...n.roles.filter(p=>p.required)].sort((p,g)=>{let h=p.sovPosition??999,u=g.sovPosition??999;return h-u});for(let p of s){i.push({type:"role",role:p.role,optional:!1});let g,h;if(p.markerOverride&&p.markerOverride[e.code])g=p.markerOverride[e.code];else{let u=e.roleMarkers[p.role];u&&(g=u.primary,h=u.alternatives)}if(g){let u=h?{type:"literal",value:g,alternatives:h}:{type:"literal",value:g};i.push(u)}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(l);let c=s.map(p=>`{${p.role}}`).join(" ");return{id:`${n.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(o.basePriority??100)+55,template:{format:`{event} ${r.primary} ${c} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function ot(n,e,t,r,o){let i=[];if(r.position==="before"){let p=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(p)}i.push({type:"role",role:"event",optional:!1});let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(a);let l=[...n.roles.filter(p=>p.required)].sort((p,g)=>{let h=p.svoPosition??999,u=g.svoPosition??999;return h-u});for(let p of l){let g,h;if(p.markerOverride&&p.markerOverride[e.code])g=p.markerOverride[e.code];else{let u=e.roleMarkers[p.role];u&&(g=u.primary,h=u.alternatives)}if(g){let u=h?{type:"literal",value:g,alternatives:h}:{type:"literal",value:g};i.push(u)}i.push({type:"role",role:p.role,optional:!1})}let c=l.map(p=>`{${p.role}}`).join(" ");return{id:`${n.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(o.basePriority??100)+55,template:{format:`${r.primary} {event} ${t.primary} ${c}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function Or(n,e,t,r,o){let i=[],a=e.eventHandler?.negationMarker;if(r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(c)}if(a){let c=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};i.push(c)}i.push({type:"role",role:"event",optional:!1});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(s),i.push({type:"role",role:"patient",optional:!1});let l=e.roleMarkers.destination;return l&&i.push({type:"group",optional:!0,tokens:[l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary},{type:"role",role:"destination",optional:!0}]}),{id:`${n.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`${r.primary} ${a?.primary||""} {event} ${t.primary} {patient} ${l?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function _r(n,e,t,r){let o=[];o.push({type:"literal",value:"and",alternatives:["then"]}),o.push({type:"role",role:"event",optional:!1});let i=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(i),o.push({type:"role",role:"patient",optional:!1});let a=e.roleMarkers.destination;return a&&o.push({type:"group",optional:!0,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:!0}]}),{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} ${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 qr(n,e,t){let r=[],o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},i=$r(n,e);switch(e.wordOrder){case"SVO":r.push(o),r.push(...i);break;case"SOV":r.push(...i),r.push(o);break;case"VSO":r.push(o),r.push(...i);break;default:r.push(o),r.push(...i)}return r}function $r(n,e){let t=[],r=we(n.roles,e.wordOrder);for(let o of r){let i=Wr(o,e);o.required?t.push(...i):t.push({type:"group",optional:!0,tokens:i})}return t}function Wr(n,e){let t=[],r=n.markerOverride?.[e.code],o=e.roleMarkers[n.role],i={type:"role",role:n.role,optional:!n.required,expectedTypes:n.expectedTypes};if(r!==void 0)(o?.position??"before")==="before"?(r&&t.push({type:"literal",value:r}),t.push(i)):(t.push(i),r&&t.push({type:"literal",value:r}));else if(o)if(o.position==="before"){if(o.primary){let a=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};t.push(a)}t.push(i)}else{t.push(i);let a=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};t.push(a)}else t.push(i);return t}function Br(n,e){let t={};for(let r of n.roles){let o=r.markerOverride?.[e.code],i=e.roleMarkers[r.role];o!==void 0?t[r.role]=o?{marker:o}:{}:i&&i.primary?t[r.role]=i.alternatives?{marker:i.primary,markerAlternatives:i.alternatives}:{marker:i.primary}:t[r.role]={}}return t}function st(n,e){let t=Br(n,e),r={};for(let o of n.roles){let i=t[o.role]||{};!o.required&&o.default?r[o.role]={...i,default:o.default}:r[o.role]=i}return r}function jr(n,e,t){let r=[],i=we(n.roles,e.wordOrder).map(a=>{let s=rt(a,e),l="";return s&&s.primary?s.position==="before"?l=`${s.primary} {${a.role}}`:l=`{${a.role}} ${s.primary}`:l=`{${a.role}}`,a.required?l:`[${l}]`});switch(e.wordOrder){case"SVO":case"VSO":r.push(t.primary,...i);break;case"SOV":r.push(...i,t.primary);break;default:r.push(t.primary,...i)}return r.join(" ")}function lt(){return[{id:"toggle-en-full",language:"en",command:"toggle",priority:100,template:{format:"toggle {patient} on {target}",tokens:[{type:"literal",value:"toggle"},{type:"role",role:"patient"},{type:"group",optional:!0,tokens:[{type:"literal",value:"on",alternatives:["from"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"on",markerAlternatives:["from"],default:{type:"reference",value:"me"}}}},{id:"toggle-en-simple",language:"en",command:"toggle",priority:90,template:{format:"toggle {patient}",tokens:[{type:"literal",value:"toggle"},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function ct(){return[{id:"put-en-into",language:"en",command:"put",priority:100,template:{format:"put {patient} into {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"into",alternatives:["in","to"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"into",markerAlternatives:["in","to"]}}},{id:"put-en-before",language:"en",command:"put",priority:95,template:{format:"put {patient} before {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"before"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"before"},manner:{default:{type:"literal",value:"before"}}}},{id:"put-en-after",language:"en",command:"put",priority:95,template:{format:"put {patient} after {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"after"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"after"},manner:{default:{type:"literal",value:"after"}}}}]}function pt(){return[{id:"event-en-when-source",language:"en",command:"on",priority:115,template:{format:"when {event} from {source} {body}",tokens:[{type:"literal",value:"when"},{type:"role",role:"event"},{type:"literal",value:"from"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"from"}}},{id:"event-en-when",language:"en",command:"on",priority:105,template:{format:"when {event} {body}",tokens:[{type:"literal",value:"when"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-en-source",language:"en",command:"on",priority:110,template:{format:"on {event} from {source} {body}",tokens:[{type:"literal",value:"on"},{type:"role",role:"event"},{type:"literal",value:"from"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"from"}}},{id:"event-en-standard",language:"en",command:"on",priority:100,template:{format:"on {event} {body}",tokens:[{type:"literal",value:"on"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-en-upon",language:"en",command:"on",priority:98,template:{format:"upon {event} {body}",tokens:[{type:"literal",value:"upon"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-en-if",language:"en",command:"on",priority:95,template:{format:"if {event} {body}",tokens:[{type:"literal",value:"if"},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}var Kr={id:"fetch-en-with-response-type",language:"en",command:"fetch",priority:90,template:{format:"fetch {source} as {responseType}",tokens:[{type:"literal",value:"fetch"},{type:"role",role:"source",expectedTypes:["literal","expression"]},{type:"literal",value:"as"},{type:"role",role:"responseType",expectedTypes:["literal","expression"]}]},extraction:{source:{position:1},responseType:{marker:"as"}}},Gr={id:"fetch-en-simple",language:"en",command:"fetch",priority:80,template:{format:"fetch {source}",tokens:[{type:"literal",value:"fetch"},{type:"role",role:"source"}]},extraction:{source:{position:1}}},Ur={id:"swap-en-handcrafted",language:"en",command:"swap",priority:110,template:{format:"swap {method} {destination}",tokens:[{type:"literal",value:"swap"},{type:"role",role:"method"},{type:"role",role:"destination"}]},extraction:{method:{position:1},destination:{position:2}}},Dr={id:"repeat-en-until-event-from",language:"en",command:"repeat",priority:120,template:{format:"repeat until event {event} from {source}",tokens:[{type:"literal",value:"repeat"},{type:"literal",value:"until"},{type:"literal",value:"event"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:"from"},{type:"role",role:"source",expectedTypes:["selector","reference","expression"]}]},extraction:{event:{marker:"event"},source:{marker:"from"},loopType:{default:{type:"literal",value:"until-event"}}}},Hr={id:"repeat-en-until-event",language:"en",command:"repeat",priority:110,template:{format:"repeat until event {event}",tokens:[{type:"literal",value:"repeat"},{type:"literal",value:"until"},{type:"literal",value:"event"},{type:"role",role:"event",expectedTypes:["literal","expression"]}]},extraction:{event:{marker:"event"},loopType:{default:{type:"literal",value:"until-event"}}}},Fr={id:"set-en-possessive",language:"en",command:"set",priority:100,template:{format:"set {destination} to {patient}",tokens:[{type:"literal",value:"set"},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"to"},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]}]},extraction:{destination:{position:1},patient:{marker:"to"}}},Xr={id:"for-en-basic",language:"en",command:"for",priority:100,template:{format:"for {patient} in {source}",tokens:[{type:"literal",value:"for"},{type:"role",role:"patient",expectedTypes:["expression","reference"]},{type:"literal",value:"in"},{type:"role",role:"source",expectedTypes:["selector","expression","reference"]}]},extraction:{patient:{position:1},source:{marker:"in"},loopType:{default:{type:"literal",value:"for"}}}},Qr={id:"if-en-basic",language:"en",command:"if",priority:100,template:{format:"if {condition}",tokens:[{type:"literal",value:"if"},{type:"role",role:"condition",expectedTypes:["expression","reference","selector"]}]},extraction:{condition:{position:1}}},Zr={id:"unless-en-basic",language:"en",command:"unless",priority:100,template:{format:"unless {condition}",tokens:[{type:"literal",value:"unless"},{type:"role",role:"condition",expectedTypes:["expression","reference","selector"]}]},extraction:{condition:{position:1}}},Yr={id:"temporal-en-in",language:"en",command:"wait",priority:95,template:{format:"in {duration}",tokens:[{type:"literal",value:"in"},{type:"role",role:"duration",expectedTypes:["literal","expression"]}]},extraction:{duration:{position:1}}},Jr={id:"temporal-en-after",language:"en",command:"wait",priority:95,template:{format:"after {duration}",tokens:[{type:"literal",value:"after"},{type:"role",role:"duration",expectedTypes:["literal","expression"]}]},extraction:{duration:{position:1}}};function dt(){let n=[];n.push(...lt()),n.push(...ct()),n.push(...pt()),n.push(Kr,Gr,Ur,Dr,Hr,Fr,Xr,Qr,Zr,Yr,Jr);let e=at(L);return n.push(...e),n}se("en",pe,L);Ue("en",dt());function Le(n){return{stem:n,confidence:1}}function de(n,e,t){return t?{stem:n,confidence:e,metadata:t}:{stem:n,confidence:e}}function en(n){return/[áéíóúüñÁÉÍÓÚÜÑ]/.test(n)}function tn(n){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!0;for(let t of n)if(en(t))return!0;return!1}var ut=["se","me","te","nos","os"],rn=[{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"}],nn=[{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"}],on=[{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"}],an=[...rn,...nn,...on].sort((n,e)=>e.ending.length-n.ending.length),te=class{constructor(){this.language="es"}isNormalizable(e){return e.length<3?!1:tn(e)}normalize(e){let t=e.toLowerCase();if((t.endsWith("ar")||t.endsWith("er")||t.endsWith("ir"))&&!ut.some(i=>t.endsWith(i+"ar")||t.endsWith(i+"er")||t.endsWith(i+"ir")))return Le(e);let r=this.tryReflexiveNormalization(t);if(r)return r;let o=this.tryConjugationNormalization(t);return o||Le(e)}tryReflexiveNormalization(e){for(let t of ut)if(e.endsWith(t)){let r=e.slice(0,-t.length);if(r.endsWith("ar")||r.endsWith("er")||r.endsWith("ir"))return de(r,.88,{removedSuffixes:[t],conjugationType:"reflexive"});let o=this.tryConjugationNormalization(r);if(o&&o.stem!==r)return de(o.stem,o.confidence*.95,{removedSuffixes:[t,...o.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationNormalization(e){for(let t of an)if(e.endsWith(t.ending)){let r=e.slice(0,-t.ending.length);if(r.length<2)continue;let o=r+t.stem;return de(o,t.confidence,{removedSuffixes:[t.ending],conjugationType:t.type})}return null}},Yo=new te;var $={code:"es",name:"Spanish",nativeName:"Espa\xF1ol",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:!0},references:{me:"yo",it:"ello",you:"t\xFA",result:"resultado",event:"evento",target:"objetivo",body:"cuerpo"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:!0,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"},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"]}};var{isLetter:mt,isIdentifierChar:sn}=Re(/[a-zA-ZáéíóúüñÁÉÍÓÚÜÑ]/),ln=[{pattern:"milisegundos",suffix:"ms",length:12,caseInsensitive:!0},{pattern:"milisegundo",suffix:"ms",length:11,caseInsensitive:!0},{pattern:"segundos",suffix:"s",length:8,caseInsensitive:!0},{pattern:"segundo",suffix:"s",length:7,caseInsensitive:!0},{pattern:"minutos",suffix:"m",length:7,caseInsensitive:!0},{pattern:"minuto",suffix:"m",length:6,caseInsensitive:!0},{pattern:"horas",suffix:"h",length:5,caseInsensitive:!0},{pattern:"hora",suffix:"h",length:4,caseInsensitive:!0}],ft=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),cn=[{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"}],ze=class extends q{constructor(){super();this.language="es";this.direction="ltr";this.initializeKeywordsFromProfile($,cn),this.normalizer=new te}tokenize(t){let r=[],o=0;for(;o<t.length;){if(C(t[o])){o++;continue}if(F(t[o])){let l=this.tryEventModifier(t,o);if(l){r.push(l),o=l.position.end;continue}let c=this.trySelector(t,o);if(c){r.push(c),o=c.position.end;continue}}if(X(t[o])){let l=this.tryString(t,o);if(l){r.push(l),o=l.position.end;continue}}if(Q(t,o)){let l=this.tryUrl(t,o);if(l){r.push(l),o=l.position.end;continue}}if(k(t[o])||t[o]==="-"&&o+1<t.length&&k(t[o+1])){let l=this.extractSpanishNumber(t,o);if(l){r.push(l),o=l.position.end;continue}}let i=this.tryVariableRef(t,o);if(i){r.push(i),o=i.position.end;continue}let a=this.tryMultiWordPhrase(t,o);if(a){r.push(a),o=a.position.end;continue}if(mt(t[o])){let l=this.extractSpanishWord(t,o);if(l){r.push(l),o=l.position.end;continue}}let s=this.tryOperator(t,o);if(s){r.push(s),o=s.position.end;continue}o++}return new w(r,"es")}classifyToken(t){let r=t.toLowerCase();return ft.has(r)?"particle":this.isKeyword(r)?"keyword":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":"identifier"}tryMultiWordPhrase(t,r){for(let o of this.profileKeywords){if(!o.native.includes(" "))continue;let i=o.native;if(t.slice(r,r+i.length).toLowerCase()===i.toLowerCase()){let s=r+i.length;if(s>=t.length||C(t[s])||!mt(t[s]))return S(t.slice(r,r+i.length),"keyword",x(r,s),o.normalized)}}return null}extractSpanishWord(t,r){let o=r,i="";for(;o<t.length&&sn(t[o]);)i+=t[o++];if(!i)return null;let a=i.toLowerCase();if(ft.has(a))return S(i,"particle",x(r,o));let s=this.lookupKeyword(a);if(s)return S(i,"keyword",x(r,o),s.normalized);let l=this.tryMorphKeywordMatch(a,r,o);return l||S(i,"identifier",x(r,o))}extractSpanishNumber(t,r){return this.tryNumberWithTimeUnits(t,r,ln,{allowSign:!0,skipWhitespace:!0})}},ue=new ze;se("es",ue,$);function gt(n){return De(n)}function me(n,e){return Fe(n,e)}function fe(){return le()}function A(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 P(n,e){let t={type:"literal",value:n};return e!==void 0?{type:"literal",value:n,dataType:e}:t}function z(n){return{type:"reference",value:n}}function Z(n,e){return{type:"property-path",object:n,property:e}}function V(n,e,t){let r={kind:"command",action:n,roles:new Map(Object.entries(e))};return t!==void 0?{...r,metadata:t}:r}function Y(n,e,t,r,o){let i=new Map;i.set("event",n);let a={kind:"event-handler",action:"on",roles:i,body:e};return t!==void 0&&(a.eventModifiers=t),r!==void 0&&(a.metadata=r),o!==void 0&&o.length>0&&(a.parameterNames=o),a}function yt(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 Me(n,e){return!e||e.length===0||e.includes(n)||e.includes("expression")?!0:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):!1}function ht(n,e){return n.possessive?.keywords?.[e]}var M=class M{constructor(){this.stemMatchCount=0;this.totalKeywordMatches=0}matchPattern(e,t){let r=e.mark(),o=new Map;if(this.currentProfile=H(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,o))return e.reset(r),null;let a=this.calculateConfidence(t,o);return this.applyExtractionRules(t,o),{pattern:t,captured:o,consumedTokens:e.position()-r.position,confidence:a}}matchBest(e,t){let r=[];for(let i of t){let a=e.mark(),s=this.matchPattern(e,i);s&&r.push(s),e.reset(a)}if(r.length===0)return null;r.sort((i,a)=>{let s=a.pattern.priority-i.pattern.priority;return s!==0?s:a.confidence-i.confidence});let o=r[0];return this.matchPattern(e,o.pattern),o}matchTokenSequence(e,t,r){let o=t[0],i=o?.type==="literal"&&(o.value==="and"||o.value==="then"||o.alternatives?.includes("and")||o.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!i)for(;e.peek()?.kind==="conjunction";)e.advance();for(let a of t)if(!this.matchPatternToken(e,a,r)){if(this.isOptional(a))continue;return!1}return!0}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!1}}matchLiteralToken(e,t){let r=e.peek();if(!r)return!1;let o=this.getMatchType(r,t.value);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),!0;if(t.alternatives)for(let i of t.alternatives){let a=this.getMatchType(r,i);if(a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),!0}return!1}matchRoleToken(e,t,r){this.skipNoiseWords(e);let o=e.peek();if(!o)return t.optional||!1;let i=this.tryMatchPossessiveExpression(e);if(i)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(i.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(r.set(t.role,i),!0);let a=this.tryMatchMethodCallExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(a.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(r.set(t.role,a),!0);let s=this.tryMatchPossessiveSelectorExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!Me(s.type,t.expectedTypes)?t.optional||!1:(r.set(t.role,s),!0);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||!1:(r.set(t.role,l),!0);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!Me(c.type,t.expectedTypes)?t.optional||!1:(r.set(t.role,c),!0);let p=this.tokenToSemanticValue(o);return!p||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(p.type)?t.optional||!1:(r.set(t.role,p),e.advance(),!0)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=(t.normalized||t.value).toLowerCase(),o=ht(this.currentProfile,r);if(!o)return null;let i=e.mark();e.advance();let a=e.peek();return a&&(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*"))?(e.advance(),Z(z(o),a.value)):(e.reset(i),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 o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="(")return e.reset(r),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<M.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}s.push(c.value),e.advance()}return{type:"expression",raw:`${t.value}.${i.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let a=`${t.value}.${i.value}`,s=1;for(;!e.isAtEnd()&&s<M.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let p=e.peek();if(!p||p.kind!=="identifier")break;e.advance(),a+=`.${p.value}`,s++}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let c=[],p=0;for(;!e.isAtEnd()&&c.length<M.MAX_METHOD_ARGS;){let h=e.peek();if(!h)break;if(h.kind==="punctuation"&&h.value===")"){if(p===0){e.advance();break}p--}if(h.kind==="punctuation"&&h.value==="("&&p++,h.kind==="punctuation"&&h.value===","){e.advance();continue}c.push(h.value),e.advance()}return{type:"expression",raw:`${a}(${c.join(", ")})`}}return{type:"expression",raw:a}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="'s")return e.reset(r),null;e.advance();let i=e.peek();return!i||i.kind!=="selector"&&i.kind!=="identifier"?(e.reset(r),null):(e.advance(),Z(A(t.value),i.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="selector"||!o.value.startsWith("."))return e.reset(r),null;let i=e.peek(1);i&&i.kind,e.advance();let a=o.value.slice(1);return Z(A(t.value),a)}matchGroupToken(e,t,r){let o=e.mark(),i=new Set(r.keys());if(!this.matchTokenSequence(e,t.tokens,r)){e.reset(o);for(let s of r.keys())i.has(s)||r.delete(s);return t.optional||!1}return!0}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 A(e.value);case"literal":return this.parseLiteralValue(e.value);case"keyword":let t=(e.normalized||e.value).toLowerCase();return["me","you","it","result","event","target","body"].includes(t)?z(t):P(e.normalized||e.value);case"identifier":if(e.value.startsWith(":"))return z(e.value);let r=e.value.toLowerCase();return["me","you","it","result","event","target","body"].includes(r)?z(r):{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 o=e.slice(1,-1);return P(o,"string")}if(e==="true")return P(!0,"boolean");if(e==="false")return P(!1,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let o=parseFloat(t[1]);return t[2]?P(e,"duration"):P(o,"number")}let r=parseFloat(e);return isNaN(r)?P(e,"string"):P(r,"number")}applyExtractionRules(e,t){for(let[r,o]of Object.entries(e.extraction))!t.has(r)&&o.default&&t.set(r,o.default)}isOptional(e){return e.optional===!0}calculateConfidence(e,t){let r=0,o=0,i=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")o+=1,t.has(c.role)&&(r+=1);else if(c.type==="group"){for(let p of c.tokens)if(p.type==="role"){let g=i(p.role),h=.8;o+=h,t.has(p.role)?r+=h:g&&(r+=h*.6)}}let a=o>0?r/o:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;a=Math.max(.5,a-c)}let s=this.calculateVSOConfidenceBoost(e);a=Math.min(1,a+s);let l=this.arabicPrepositionDisambiguation(e,t);return a=Math.max(0,Math.min(1,a+l)),a}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 o of t.alternatives)if(r.has(o))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let r=0,o={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[i,a]of t.entries()){let s=o[i];if(!s||s.length===0)continue;let l=a.metadata;if(l&&typeof l.prepositionValue=="string"){let c=l.prepositionValue;s.includes(c)?r+=.1:r-=.1}}return Math.max(-.1,Math.min(.1,r))}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=t.value.toLowerCase();if(M.ENGLISH_NOISE_WORDS.has(r)){let o=e.mark();e.advance();let i=e.peek();if(i&&i.kind==="selector")return;e.reset(o)}r==="class"&&e.advance()}extractEventModifiers(e){let t={},r=!1;for(;!e.isAtEnd();){let o=e.peek();if(!o||o.kind!=="event-modifier")break;let i=o.metadata;if(!i)break;switch(r=!0,i.modifierName){case"once":t.once=!0;break;case"debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case"throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case"queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance()}return r?t:void 0}};M.MAX_PROPERTY_DEPTH=10,M.MAX_METHOD_ARGS=20,M.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var re=M,W=new re;var ge=class{render(e,t){if(e.kind==="compound")return this.renderCompound(e,t);let r=Xe(t,e.action);if(r.length===0)return this.renderExplicit(e);let o=this.findBestPattern(e,r);return o?this.renderWithPattern(e,o):this.renderExplicit(e)}renderCompound(e,t){let r=e.statements.map(i=>this.render(i,t)),o=this.getChainWord(e.chainType,t);return r.join(` ${o} `)}getChainWord(e,t){let r=H(t);return r?.keywords?r.keywords[e]?.primary??e:e}renderExplicit(e){if(e.kind==="compound"){let r=e;return r.statements.map(i=>this.renderExplicit(i)).join(` ${r.chainType} `)}let t=[e.action];for(let[r,o]of e.roles)t.push(`${r}:${this.valueToString(o)}`);if(e.kind==="event-handler"){let r=e;if(r.body&&r.body.length>0){let o=r.body.map(i=>this.renderExplicit(i));t.push(`body:${o.join(" ")}`)}}return`[${t.join(" ")}]`}supportedLanguages(){return fe()}findBestPattern(e,t){let r=t.map(o=>{let i=o.priority;for(let a of o.template.tokens)a.type==="role"&&(e.roles.has(a.role)?i+=10:a.optional||(i-=50));return o.language==="en"&&((o.id.includes("standard")||o.id.includes("en-source"))&&(i+=20),(o.id.includes("-when")||o.id.includes("-if")||o.id.includes("-upon"))&&(i-=15)),{pattern:o,score:i}});return r.sort((o,i)=>i.score-o.score),r.length>0?r[0].pattern:null}renderWithPattern(e,t){let r=[],o=t.language;for(let i of t.template.tokens){let a=this.renderPatternToken(i,e,o);a!==null&&r.push(a)}if(e.kind==="event-handler"){let i=e;if(i.body&&i.body.length>0){let a=i.body.map(s=>this.render(s,o));r.push(a.join(" "))}}return r.join(" ")}renderPatternToken(e,t,r){switch(e.type){case"literal":return e.value;case"role":{let o=t.roles.get(e.role);return o?this.valueToNaturalString(o,r):(e.optional,null)}case"group":{if(!e.tokens.filter(a=>a.type==="role"&&!a.optional).every(a=>t.roles.has(a.role))&&e.optional)return null;if(e.optional&&e.tokens.find(s=>s.type==="role"&&s.role==="destination")){let s=t.roles.get("destination");if(s?.type==="reference"&&s.value==="me")return null}let i=[];for(let a of e.tokens){let s=this.renderPatternToken(a,t,r);s!==null&&i.push(s)}return i.length>0?i.join(" "):null}default:return null}}valueToString(e){switch(e.type){case"literal":return typeof e.value=="string"?e.dataType==="string"||/\s/.test(e.value)?`"${e.value}"`:e.value:String(e.value);case"selector":return e.value;case"reference":return e.value;case"property-path":return`${this.valueToString(e.object)}'s ${e.property}`;case"expression":return e.raw}}valueToNaturalString(e,t="en"){switch(e.type){case"literal":return typeof e.value=="string"&&e.dataType==="string"?`"${e.value}"`:String(e.value);case"selector":return e.value;case"reference":return this.renderReference(e,t);case"property-path":return this.renderPropertyPath(e,t);case"expression":return e.raw}}renderReference(e,t){let r=H(t);return r?.references?r.references[e.value]??e.value:e.value}renderPropertyPath(e,t){let r=H(t),o=e.property,i=e.object.type==="reference"?e.object.value:null;if(r?.possessive?.specialForms&&i){let s=r.possessive.specialForms[i];if(s){let{markerPosition:l,usePossessiveAdjectives:c}=r.possessive;return c&&l==="after-object"?`${o} ${s}`:`${s} ${o}`}}let a=this.valueToNaturalString(e.object,t);if(r?.possessive){let{marker:s,markerPosition:l,usePossessiveAdjectives:c}=r.possessive;if(c&&i&&l==="after-object")return`${o} ${a}`;if(s)switch(l){case"between":return r.usesSpaces?`${a}${s} ${o}`:`${a}${s}${o}`;case"after-object":return`${a}${s} ${o}`;case"before-property":return`${a} ${s} ${o}`}}return t==="en"||!r?.possessive?a==="me"?`my ${o}`:a==="it"?`its ${o}`:`${a}'s ${o}`:`${a} ${o}`}},Ae=new ge;function B(n,e){return Ae.render(n,e)}function J(n){return Ae.renderExplicit(n)}function j(n){let e=n.trim();if(!e.startsWith("[")||!e.endsWith("]"))throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");let t=e.slice(1,-1).trim();if(!t)throw new Error("Empty explicit statement");let r=pn(t);if(r.length===0)throw new Error("No command specified in explicit statement");let o=r[0].toLowerCase(),i=new Map;for(let s=1;s<r.length;s++){let l=r[s],c=l.indexOf(":");if(c===-1)throw new Error(`Invalid role format: "${l}". Expected role:value`);let p=l.slice(0,c),g=l.slice(c+1);if(p==="body"&&g.startsWith("[")){let u=un(l,c+1),m=l.slice(c+1,u+1);i.set(p,{type:"expression",raw:m});continue}let h=dn(g);i.set(p,h)}if(o==="on"){let s=i.get("event");if(!s)throw new Error("Event handler requires event role: [on event:click ...]");let l=i.get("body"),c=[];return l&&l.type==="expression"&&c.push(j(l.raw)),i.delete("body"),Y(s,c,void 0,{sourceLanguage:"explicit"})}let a={};for(let[s,l]of i)a[s]=l;return V(o,a,{sourceLanguage:"explicit"})}function pn(n){let e=[],t="",r=!1,o="",i=0;for(let a=0;a<n.length;a++){let s=n[a];if(r){t+=s,s===o&&n[a-1]!=="\\"&&(r=!1);continue}if(s==='"'||s==="'"){r=!0,o=s,t+=s;continue}if(s==="["){i++,t+=s;continue}if(s==="]"){i--,t+=s;continue}if(s===" "&&i===0){t&&(e.push(t),t="");continue}t+=s}return t&&e.push(t),e}function dn(n){if(n.startsWith("#")||n.startsWith(".")||n.startsWith("[")||n.startsWith("@")||n.startsWith("*"))return A(n);if(n.startsWith('"')||n.startsWith("'")){let t=n.slice(1,-1);return P(t,"string")}if(n==="true")return P(!0,"boolean");if(n==="false")return P(!1,"boolean");if(["me","you","it","result","event","target","body"].includes(n.toLowerCase()))return z(n.toLowerCase());let e=n.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let t=parseFloat(e[1]);return e[2]?P(n,"duration"):P(t,"number")}return P(n,"string")}function un(n,e){let t=0;for(let r=e;r<n.length;r++)if(n[r]==="[")t++;else if(n[r]==="]"&&(t--,t===0))return r;return n.length-1}function K(n){let e=n.trim();return e.startsWith("[")&&e.endsWith("]")}var ye=class{parse(e,t){let r=me(e,t),o=R(t);if(o.length===0)throw new Error(`No patterns available for language: ${t}`);let i=[...o].sort((p,g)=>g.priority-p.priority),a=i.filter(p=>p.command==="on"),s=W.matchBest(r,a);if(s)return this.buildEventHandler(s,r,t);let l=i.filter(p=>p.command!=="on"),c=W.matchBest(r,l);if(c)return this.buildCommand(c,t);throw new Error(`Could not parse input in ${t}: ${e}`)}canParse(e,t){try{return this.parse(e,t),!0}catch{return!1}}supportedLanguages(){return fe()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let r={};for(let[o,i]of e.captured)r[o]=i;return V(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 o=e.captured.get("event");if(!o)throw new Error("Event handler pattern matched but no event captured");let i=W.extractEventModifiers(t),a,s=e.captured.get("action");if(s&&s.type==="literal"){let l=s.value,c={};for(let[h,u]of e.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(c[h]=u);let p=V(l,c,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence}),g=e.captured.get("continues");if(g&&g.type==="literal"&&g.value==="then"){let h=R(r).filter(f=>f.command!=="on").sort((f,v)=>v.priority-f.priority),u=R(r).filter(f=>f.id.startsWith("grammar-")&&f.id.includes("-continuation")).sort((f,v)=>v.priority-f.priority),m=this.parseBodyWithGrammarPatterns(t,h,u,r);m.length>0?a=[p,...m]:a=[p]}else a=[p]}else{let l=R(r).filter(c=>c.command!=="on").sort((c,p)=>p.priority-c.priority);a=this.parseBodyWithClauses(t,l,r)}return Y(o,a,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,r){let o=[],i=[];for(;!e.isAtEnd();){let a=e.peek();if(!a)break;let s=a.kind==="conjunction"||a.kind==="keyword"&&this.isThenKeyword(a.value,r),l=a.kind==="keyword"&&this.isEndKeyword(a.value,r);if(s){if(i.length>0){let c=this.parseClause(i,t,r);o.push(...c),i.length=0}e.advance();continue}if(l){if(i.length>0){let c=this.parseClause(i,t,r);o.push(...c)}e.advance();break}i.push(a),e.advance()}if(i.length>0){let a=this.parseClause(i,t,r);o.push(...a)}return o.length>1?[yt(o,"then",{sourceLanguage:r})]:o}parseClause(e,t,r){if(e.length===0)return[];let o=new w(e,r),i=[];for(;!o.isAtEnd();){let a=W.matchBest(o,t);a?i.push(this.buildCommand(a,r)):o.advance()}return i}parseBodyWithGrammarPatterns(e,t,r,o){let i=[];for(;!e.isAtEnd();){let a=e.peek();if(a&&this.isThenKeyword(a.value,o)){e.advance();continue}if(a&&this.isEndKeyword(a.value,o)){e.advance();break}let s=!1;if(r.length>0){let l=W.matchBest(e,r);if(l){let c=l.pattern.command,p={};for(let[u,m]of l.captured)u!=="event"&&u!=="action"&&u!=="continues"&&(p[u]=m);let g=V(c,p,{sourceLanguage:o,patternId:l.pattern.id});i.push(g),s=!0;let h=l.captured.get("continues");if(h&&h.type==="literal"&&h.value==="then")continue}}if(!s){let l=W.matchBest(e,t);l&&(i.push(this.buildCommand(l,o)),s=!0)}s||e.advance()}return i}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"]),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"]),qu:new Set(["chaymantataq","hinaspa","chaymanta"]),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"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return(r[t]||r.en).has(e.toLowerCase())}},Ve=new ye;function G(n,e){return Ve.parse(n,e)}function Ie(n,e){return Ve.canParse(n,e)}function Oe(n,e){if(K(n))return n;let t=G(n,e);return J(t)}function he(n,e){let t=j(n);return B(t,e)}function _e(n,e,t){if(K(n))return he(n,t);let r=G(n,e);return B(r,t)}function ve(n,e){return K(n)?j(n):G(n,e)}function qe(n,e,t=["en","ja","ar","es","ko","zh","tr","pt","fr","de","id","qu","sw"]){let r={},o=ve(n,e);for(let i of t)r[i]=B(o,i);return r.explicit=J(o),r}var mn=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),fn=new Set(["and","or","not","no"]),gn=new Set(["true","false","null","undefined"]),yn=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function vt(n){let e=[],t=0,r=1,o=1;function i(){if(e.length===0)return!0;let m=e[e.length-1];return["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(m.type)}function a(m=0){return n[t+m]??""}function s(){let m=n[t];return t++,m===`
2
+ `?(r++,o=1):o++,m}function l(){for(;t<n.length&&/\s/.test(n[t]);)s()}function c(m){let f="";for(;t<n.length&&m(n[t]);)f+=s();return f}function p(m){let f=m;for(s();t<n.length&&n[t]!==m;)n[t]==="\\"&&t+1<n.length&&(f+=s()),f+=s();return t<n.length&&(f+=s()),f}function g(){let m="`";for(s();t<n.length&&n[t]!=="`";)n[t]==="\\"&&t+1<n.length&&(m+=s()),m+=s();return t<n.length&&(m+=s()),m}function h(){let m="<";for(s();t<n.length&&(m+=s(),!m.endsWith("/>")););return m}function u(m,f,v){return{type:m,value:f,start:v,end:t,line:r,column:o-f.length}}for(;t<n.length&&(l(),!(t>=n.length));){let m=t,f=a();if(f==="'"&&a(1)==="s"&&!/\w/.test(a(2))){s(),s(),e.push(u("POSSESSIVE","'s",m));continue}if(f==='"'||f==="'"){let v=p(f);e.push(u("STRING",v,m));continue}if(f==="`"){let v=g();e.push(u("TEMPLATE_LITERAL",v,m));continue}if(f==="<"&&/[a-zA-Z.#\[]/.test(a(1))){let v=h();e.push(u("QUERY_SELECTOR",v,m));continue}if(f==="#"&&i()){s();let v=c(b=>/[\w-]/.test(b));e.push(u("ID_SELECTOR","#"+v,m));continue}if(f==="."&&/[a-zA-Z_-]/.test(a(1))&&i()){s();let v=c(b=>/[\w-]/.test(b));e.push(u("CLASS_SELECTOR","."+v,m));continue}if(f==="["&&i()){let v=a(1);if(v==="@"||/[a-zA-Z]/.test(v)){let b="";for(b+=s();t<n.length&&n[t]!=="]";)n[t]==='"'||n[t]==="'"?b+=p(n[t]):b+=s();t<n.length&&(b+=s()),e.push(u("ATTRIBUTE_SELECTOR",b,m));continue}}if(f==="["){s(),e.push(u("LBRACKET","[",m));continue}if(f==="]"){s(),e.push(u("RBRACKET","]",m));continue}if(/\d/.test(f)){let v=c(Se=>/[\d.]/.test(Se)),b=t,ae=c(Se=>/[a-zA-Z]/.test(Se));yn.has(ae)?e.push(u("TIME_EXPRESSION",v+ae,m)):(t=b,e.push(u("NUMBER",v,m)));continue}if(f==="("){s(),e.push(u("LPAREN","(",m));continue}if(f===")"){s(),e.push(u("RPAREN",")",m));continue}if(f==="{"){s(),e.push(u("LBRACE","{",m));continue}if(f==="}"){s(),e.push(u("RBRACE","}",m));continue}if(f===","){s(),e.push(u("COMMA",",",m));continue}if(f===":"){s(),e.push(u("COLON",":",m));continue}if(f==="."){s(),e.push(u("DOT",".",m));continue}if(f==="+"||f==="-"||f==="*"||f==="/"||f==="%"){s(),e.push(u("OPERATOR",f,m));continue}if(f==="="||f==="!"||f==="<"||f===">"){let v=s();a()==="="&&(v+=s()),e.push(u("COMPARISON",v,m));continue}if(/[a-zA-Z_$]/.test(f)){let v=c(ae=>/[\w$]/.test(ae)),b=v.toLowerCase();mn.has(b)?e.push(u("CONTEXT_VAR",v,m)):fn.has(b)?e.push(u("LOGICAL",v,m)):gn.has(b)?e.push(u("BOOLEAN",v,m)):e.push(u("IDENTIFIER",v,m));continue}s()}return e.push(u("EOF","",t)),e}var xe=class{constructor(){this.tokens=[];this.current=0}parse(e){try{return this.tokens=vt(e),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Parse error"}}}peek(){return this.tokens[this.current]??{type:"EOF",value:"",start:0,end:0}}previous(){return this.tokens[this.current-1]??{type:"EOF",value:"",start:0,end:0}}isAtEnd(){return this.peek().type==="EOF"}advance(){return this.isAtEnd()||this.current++,this.previous()}check(e){return this.peek().type===e}checkValue(e){return this.peek().value.toLowerCase()===e.toLowerCase()}match(...e){for(let t of e)if(this.check(t))return this.advance(),!0;return!1}parseExpression(){return this.parseOr()}parseOr(){let e=this.parseAnd();for(;this.checkValue("or");){let t=this.advance().value,r=this.parseAnd();e=this.createBinaryExpression(t,e,r)}return e}parseAnd(){let e=this.parseEquality();for(;this.checkValue("and");){let t=this.advance().value,r=this.parseEquality();e=this.createBinaryExpression(t,e,r)}return e}parseEquality(){let e=this.parseComparison();for(;this.match("COMPARISON")||this.checkValue("is")||this.checkValue("matches")||this.checkValue("contains")||this.checkValue("in");){let t=this.previous().value,r=this.parseComparison();e=this.createBinaryExpression(t,e,r)}return e}parseComparison(){let e=this.parseAddition();for(;this.check("COMPARISON");){let t=this.advance().value,r=this.parseAddition();e=this.createBinaryExpression(t,e,r)}return e}parseAddition(){let e=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let t=this.advance().value,r=this.parseMultiplication();e=this.createBinaryExpression(t,e,r)}return e}parseMultiplication(){let e=this.parseUnary();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%";){let t=this.advance().value,r=this.parseUnary();e=this.createBinaryExpression(t,e,r)}return e}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let e=this.advance().value,t=this.parseUnary();return this.createUnaryExpression(e,t)}return this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let t=this.advance().value;e=this.createPropertyAccess(e,t)}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let t=this.advance().value;e=this.createPossessiveExpression(e,t)}else break;else if(this.match("LPAREN")){let t=this.parseArguments();e=this.createCallExpression(e,t)}else if(this.match("LBRACKET")){let t=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");e=this.createPropertyAccess(e,t)}else break;return e}parsePrimary(){let e=this.peek();if(this.match("NUMBER"))return this.createLiteral(parseFloat(e.value),"number",e);if(this.match("STRING")){let t=e.value.slice(1,-1);return this.createLiteral(t,"string",e)}if(this.match("BOOLEAN")){let t=e.value==="true"?!0:e.value==="false"?!1:e.value==="null"?null:void 0;return this.createLiteral(t,e.value,e)}if(this.match("TEMPLATE_LITERAL"))return{type:"templateLiteral",value:e.value,start:e.start,end:e.end,line:e.line,column:e.column};if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(e);if(this.match("ID_SELECTOR"))return this.createSelector(e.value,"id",e);if(this.match("CLASS_SELECTOR"))return this.createSelector(e.value,"class",e);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(e.value,"attribute",e);if(this.match("QUERY_SELECTOR")){let t=e.value.slice(1,-2);return this.createSelector(t,"query",e)}if(this.match("CONTEXT_VAR"))return this.createContextReference(e.value,e);if(this.match("IDENTIFIER"))return this.createIdentifier(e.value,e);if(this.match("LPAREN")){let t=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return t}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${e.value}`)}parseArguments(){let e=[];if(!this.check("RPAREN"))do e.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return e}parseArrayLiteral(){let e=[],t=this.previous().start;if(!this.check("RBRACKET"))do e.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return{type:"arrayLiteral",elements:e,start:t,end:this.previous().end}}parseObjectLiteral(){let e=[],t=this.previous().start;if(!this.check("RBRACE"))do{let r;if(this.check("STRING"))r=this.advance().value.slice(1,-1);else if(this.check("IDENTIFIER"))r=this.advance().value;else throw new Error("Expected property name");if(!this.match("COLON"))throw new Error("Expected : after property name");let o=this.parseExpression();e.push({key:r,value:o})}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return{type:"objectLiteral",properties:e.map(r=>({type:"objectProperty",key:r.key,value:r.value})),start:t,end:this.previous().end}}parseTimeExpression(e){let t=e.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!t)throw new Error(`Invalid time expression: ${e.value}`);let r=parseFloat(t[1]),o=t[2].toLowerCase();return{type:"timeExpression",value:r,unit:o,raw:e.value,start:e.start,end:e.end,line:e.line,column:e.column}}createLiteral(e,t,r){return{type:"literal",value:e,dataType:t,raw:r.value,start:r.start,end:r.end,line:r.line,column:r.column}}createSelector(e,t,r){return{type:"selector",value:e,selector:e,selectorType:t,start:r.start,end:r.end,line:r.line,column:r.column}}createContextReference(e,t){return{type:"contextReference",contextType:e,name:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createIdentifier(e,t){return{type:"identifier",name:e,start:t.start,end:t.end,line:t.line,column:t.column}}createPropertyAccess(e,t){return{type:"propertyAccess",object:e,property:typeof t=="string"?t:t.name??"",start:e.start,end:this.previous().end}}createPossessiveExpression(e,t){return{type:"possessiveExpression",object:e,property:t,start:e.start,end:this.previous().end}}createBinaryExpression(e,t,r){return{type:"binaryExpression",operator:e,left:t,right:r,start:t.start,end:r.end}}createUnaryExpression(e,t){return{type:"unaryExpression",operator:e,operand:t,prefix:!0,start:this.previous().start,end:t.end}}createCallExpression(e,t){return{type:"callExpression",callee:e,arguments:t,start:e.start,end:this.previous().end}}};function $e(n){return new xe().parse(n)}function E(n,e){switch(n.type){case"literal":return hn(n);case"selector":return vn(n,e);case"reference":return xn(n);case"property-path":return Sn(n,e);case"expression":return Tn(n);default:let t=n;throw new Error(`Unknown semantic value type: ${t.type}`)}}function hn(n){let e={type:"literal",value:n.value};return n.dataType?{...e,dataType:n.dataType}:e}function vn(n,e){return e&&n.value.startsWith("*")&&/^[a-zA-Z-]/.test(n.value.slice(1))&&e.push(`Converted '${n.value}' to a CSS selector, but it looks like a CSS property name. CSS properties in commands like 'transition' should be literal strings, not selectors. Consider using expectedTypes: ['literal'] instead of ['literal', 'selector'] in the command schema.`),{type:"selector",value:n.value,selector:n.value,selectorType:n.selectorKind}}function xn(n){return{type:"contextReference",contextType:n.value,name:n.value}}function Sn(n,e){return{type:"propertyAccess",object:E(n.object,e),property:n.property}}function Tn(n){let e=$e(n.raw);return!e.success||!e.node?{type:"identifier",name:n.raw}:e.node}function xt(n,e){return n.roles.get(e)}function d(n,e,t){let r=xt(n,e);return r?E(r,t):void 0}function y(n,e=[],t,r={}){let o={type:"command",name:n,args:e};return t&&Object.keys(t).length>0&&(o.modifiers=t),r.isBlocking&&(o.isBlocking=r.isBlocking),r.implicitTarget&&(o.implicitTarget=r.implicitTarget),o}var Pn={action:"toggle",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=d(n,"duration"),i=t?[t]:[],a={};return r&&(a.on=r),o&&(a.for=o),y("toggle",i,a)}},bn={action:"add",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.to=r),y("add",o,i)}},kn={action:"remove",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.from=r),y("remove",o,i)}},En={action:"set",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i={};return t&&o.push(t),r&&(i.to=r),y("set",o,i)}},Rn={action:"show",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=d(n,"duration"),i=[],a={},s=t??r;return s&&i.push(s),o&&(a.with=o),y("show",i,a)}},Cn={action:"hide",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=d(n,"duration"),i=[],a={},s=t??r;return s&&i.push(s),o&&(a.with=o),y("hide",i,a)}},Nn={action:"increment",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=d(n,"quantity"),i=[],a={},s=t??r;return s&&i.push(s),o&&(a.by=o),y("increment",i,a)}},wn={action:"decrement",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=d(n,"quantity"),i=[],a={},s=t??r;return s&&i.push(s),o&&(a.by=o),y("decrement",i,a)}},Ln={action:"wait",toAST(n,e){let t=d(n,"duration");return y("wait",t?[t]:[],void 0,{isBlocking:!0})}},zn={action:"log",toAST(n,e){let t=d(n,"patient"),r=[];return t&&r.push(t),y("log",r)}},Mn={action:"put",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=xt(n,"method"),i=t?[t]:[],a={};if(r){let s=o?.type==="literal"?String(o.value):"into";a[s]=r}return y("put",i,a)}},An={action:"fetch",toAST(n,e){let t=d(n,"source"),r=d(n,"method"),o=d(n,"responseType"),i=d(n,"patient"),a=t?[t]:[],s={};return r&&(s.with=r),o&&(s.as=o),i&&(s.body=i),y("fetch",a,s,{isBlocking:!0})}},Vn={action:"append",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.to=r),y("append",o,i)}},In={action:"prepend",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.to=r),y("prepend",o,i)}},On={action:"trigger",toAST(n,e){let t=d(n,"event"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.on=r),y("trigger",o,i)}},_n={action:"send",toAST(n,e){let t=d(n,"event"),r=d(n,"destination"),o=d(n,"patient"),i=t?[t]:[],a={};return r&&(a.to=r),o&&(a.detail=o),y("send",i,a)}},qn={action:"go",toAST(n,e){let t=d(n,"source"),r=d(n,"destination"),o=[],i={};return t&&o.push(t),r&&(i.to=r),y("go",o,i)}},$n={action:"transition",toAST(n,e){let t=d(n,"patient"),r=d(n,"goal"),o=d(n,"duration"),i=d(n,"destination"),a=t?[t]:[],s={};return r&&(s.to=r),o&&(s.over=o),i&&(s.on=i),y("transition",a,s)}},Wn={action:"focus",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i={},a=t??r;return a&&o.push(a),y("focus",o,i)}},Bn={action:"blur",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),y("blur",o)}},jn={action:"get",toAST(n,e){let t=d(n,"source"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),y("get",o)}},Kn={action:"take",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.from=r),y("take",o,i)}},Gn={action:"call",toAST(n,e){let t=d(n,"patient");return y("call",t?[t]:[])}},Un={action:"return",toAST(n,e){let t=d(n,"patient");return y("return",t?[t]:[])}},Dn={action:"halt",toAST(n,e){return y("halt",[])}},Hn={action:"throw",toAST(n,e){let t=d(n,"patient");return y("throw",t?[t]:[])}},Fn={action:"settle",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),y("settle",o,void 0,{isBlocking:!0})}},Xn={action:"swap",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=d(n,"destination"),i=d(n,"style"),a=[],s={};return t&&a.push(t),r&&a.push(r),o&&(s.on=o),i&&(s.with=i),y("swap",a,s)}},Qn={action:"morph",toAST(n,e){let t=d(n,"source"),r=d(n,"destination"),o=d(n,"patient"),i=[],a={},s=t??o;return s&&i.push(s),r&&(a.on=r),y("morph",i,a)}},Zn={action:"clone",toAST(n,e){let t=d(n,"source"),r=d(n,"destination"),o=d(n,"patient"),i=[],a={},s=t??o;return s&&i.push(s),r&&(a.into=r),y("clone",i,a)}},Yn={action:"make",toAST(n,e){let t=d(n,"patient");return y("make",t?[t]:[])}},Jn={action:"measure",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=d(n,"source"),i=[],a={};t&&i.push(t);let s=r??o;return s&&(a.of=s),y("measure",i,a)}},eo={action:"tell",toAST(n,e){let t=d(n,"destination"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),y("tell",o)}},to={action:"js",toAST(n,e){let t=d(n,"patient");return y("js",t?[t]:[])}},ro={action:"async",toAST(n,e){return y("async",[])}},no={action:"if",toAST(n,e){let t=d(n,"condition");return y("if",t?[t]:[])}},oo={action:"unless",toAST(n,e){let t=d(n,"condition");return y("unless",t?[t]:[])}},io={action:"repeat",toAST(n,e){let t=d(n,"quantity"),r=d(n,"patient"),o=[],i=t??r;return i&&o.push(i),y("repeat",o)}},ao={action:"for",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.in=r),y("for",o,i)}},so={action:"while",toAST(n,e){let t=d(n,"condition");return y("while",t?[t]:[])}},lo={action:"continue",toAST(n,e){return y("continue",[])}},co={action:"default",toAST(n,e){let t=d(n,"patient"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.to=r),y("default",o,i)}},po={action:"init",toAST(n,e){return y("init",[])}},uo={action:"behavior",toAST(n,e){let t=d(n,"patient");return y("behavior",t?[t]:[])}},mo={action:"install",toAST(n,e){let t=d(n,"patient"),r=d(n,"destination"),o=t?[t]:[],i={};return r&&(i.on=r),y("install",o,i)}},fo={action:"on",toAST(n,e){let t=d(n,"event"),r=d(n,"source"),o=t?[t]:[],i={};return r&&(i.from=r),y("on",o,i)}},St=new Map([["toggle",Pn],["add",bn],["remove",kn],["set",En],["show",Rn],["hide",Cn],["increment",Nn],["decrement",wn],["wait",Ln],["log",zn],["put",Mn],["fetch",An],["append",Vn],["prepend",In],["get",jn],["take",Kn],["trigger",On],["send",_n],["on",fo],["go",qn],["transition",$n],["focus",Wn],["blur",Bn],["call",Gn],["return",Un],["halt",Dn],["throw",Hn],["settle",Fn],["swap",Xn],["morph",Qn],["clone",Zn],["measure",Jn],["make",Yn],["tell",eo],["default",co],["js",to],["async",ro],["if",no],["unless",oo],["repeat",io],["for",ao],["while",so],["continue",lo],["init",po],["behavior",uo],["install",mo]]);function ne(n){return St.get(n)}function We(n){St.set(n.action,n)}var oe=class{constructor(e={}){this.warnings=[]}build(e){switch(e.kind){case"command":return this.buildCommand(e);case"event-handler":return this.buildEventHandler(e);case"conditional":return this.buildConditional(e);case"compound":return this.buildCompound(e);case"loop":return this.buildLoop(e);default:throw new Error(`Unknown semantic node kind: ${e.kind}`)}}buildCommand(e){let t=ne(e.action);if(t){let r=t.toAST(e,this);if("ast"in r&&"warnings"in r){let o=r;return this.warnings.push(...o.warnings),o.ast}else return r}return this.buildGenericCommand(e)}buildGenericCommand(e){let t=[],r={},o=["patient","source","quantity"],i=["destination","duration","method","style"];for(let s of o){let l=e.roles.get(s);l&&t.push(E(l))}for(let s of i){let l=e.roles.get(s);if(l){let c=this.roleToModifierKey(s);r[c]=E(l)}}let a={type:"command",name:e.action,args:t};return Object.keys(r).length>0?{...a,modifiers:r}:a}roleToModifierKey(e){return{destination:"on",duration:"for",source:"from",condition:"if",method:"via",style:"with"}[e]??e}buildEventHandler(e){let t=e.roles.get("event"),r,o;if(t?.type==="literal"){let v=String(t.value);v.includes("|")||v.includes(" or ")?(o=v.split(/\s+or\s+|\|/).map(b=>b.trim()),r=o[0]):r=v}else t?.type==="reference"?r=t.value:r="click";let i=e.body.map(v=>this.build(v)),a=e.roles.get("source"),s,l;a?.type==="selector"?(s=a.value,l=a.value):a?.type==="reference"?l=a.value:a?.type==="literal"&&(l=String(a.value));let c=e.roles.get("condition"),p=c?E(c):void 0,g=e.roles.get("destination"),h=g?E(g):void 0,u=e.eventModifiers,m=s;if(u?.from){let v=u.from;v.type==="selector"&&!s&&(m=v.value)}let f=e.parameterNames?[...e.parameterNames]:void 0;return{type:"eventHandler",event:r,commands:i,...o&&o.length>1?{events:o}:{},...m?{selector:m}:{},...l?{target:l}:{},...p?{condition:p}:{},...h?{watchTarget:h}:{},...f&&f.length>0?{args:f,params:f}:{}}}buildConditional(e){let t=e.roles.get("condition");if(!t)throw new Error("Conditional node missing condition");let r=E(t),o=e.thenBranch.map(s=>this.build(s)),i=e.elseBranch?.map(s=>this.build(s)),a=[r,{type:"block",commands:o}];return i&&i.length>0&&a.push({type:"block",commands:i}),{type:"command",name:"if",args:a}}buildCompound(e){let t=e.statements.map(o=>this.build(o));return t.length===1?t[0]:t.length===0?{type:"block",commands:[]}:{type:"CommandSequence",commands:t}}buildLoop(e){let t=e.body.map(o=>this.build(o)),r=[{type:"identifier",name:e.loopVariant}];switch(e.loopVariant){case"times":{let o=e.roles.get("quantity");o&&r.push(E(o));break}case"for":{e.loopVariable&&r.push({type:"string",value:e.loopVariable});let o=e.roles.get("source");o&&r.push(E(o));break}case"while":case"until":{let o=e.roles.get("condition");o&&r.push(E(o));break}case"forever":break}return r.push({type:"block",commands:t}),{type:"command",name:"repeat",args:r}}buildBlock(e){return{type:"block",commands:e.map(r=>this.build(r))}}};function Tt(n){let e=new oe;return{ast:e.build(n),warnings:e.warnings}}var U=class{constructor(e={}){this.cache=new Map,this.config={maxSize:e.maxSize??1e3,ttlMs:e.ttlMs??0,enabled:e.enabled??!0},this.stats={hits:0,misses:0,evictions:0,expirations:0}}makeKey(e,t){return`${t}:${e}`}isExpired(e){return this.config.ttlMs===0?!1:Date.now()-e.createdAt>this.config.ttlMs}evictLRU(){let e=this.cache.keys().next().value;e!==void 0&&(this.cache.delete(e),this.stats.evictions++)}get(e,t){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(e,t),o=this.cache.get(r);if(!o){this.stats.misses++;return}if(this.isExpired(o)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),o.lastAccessed=Date.now(),this.cache.set(r,o),this.stats.hits++,o.result}set(e,t,r){if(!this.config.enabled||r.confidence===0)return;let o=this.makeKey(e,t),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(o,{result:r,createdAt:i,lastAccessed:i})}has(e,t){if(!this.config.enabled)return!1;let r=this.makeKey(e,t),o=this.cache.get(r);return o?this.isExpired(o)?(this.cache.delete(r),this.stats.expirations++,!1):!0:!1}delete(e,t){let r=this.makeKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear()}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0}}getStats(){let e=this.stats.hits+this.stats.misses;return{hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:e>0?this.stats.hits/e:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(e){if(e.maxSize!==void 0)for(this.config.maxSize=e.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();e.ttlMs!==void 0&&(this.config.ttlMs=e.ttlMs),e.enabled!==void 0&&(this.config.enabled=e.enabled)}enable(){this.config.enabled=!0}disable(){this.config.enabled=!1}getConfig(){return{...this.config}}},Be=new U;var ie=class{constructor(e={}){this.patternMatcher=new re,this.languages=new Set(le()),e.cache===!1?this.cache=new U({enabled:!1}):this.cache=e.cache?new U(e.cache):Be}analyze(e,t){if(!this.supportsLanguage(t))return{confidence:0,errors:[`Language '${t}' is not supported for semantic parsing`]};let r=this.cache.get(e,t);if(r)return r;let o=this.analyzeUncached(e,t);return this.cache.set(e,t,o),o}analyzeUncached(e,t){try{let r=gt(t);if(!r)return{confidence:0,errors:[`No tokenizer available for language '${t}'`]};let o=r.tokenize(e),i=R(t);if(i.length===0)return{confidence:0,errors:[`No patterns available for language '${t}'`]};let a=this.patternMatcher.matchBest(o,i);if(!a)return{confidence:0,errors:["No pattern matched the input"]};let s=this.buildSemanticNode(a);return{confidence:a.confidence,command:{name:a.pattern.command,roles:a.captured},node:s,tokensConsumed:a.consumedTokens}}catch(r){return{confidence:0,errors:[r instanceof Error?r.message:String(r)]}}}supportsLanguage(e){return this.languages.has(e)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear()}configureCache(e){this.cache.configure(e)}buildSemanticNode(e){return{kind:"command",action:e.pattern.command,roles:e.captured,metadata:{patternId:e.pattern.id}}}};function Pt(n){return new ie(n)}var je=.5,bt=.8;function kt(n,e=je){return n.confidence>=e&&n.command!==void 0}var go="1.0.0-es-en";function yo(){return["en","es"]}function ho(n,e){if(e!=="en"&&e!=="es")throw new Error(`Language not supported in this bundle: ${e}. Supported: en, es`);return[...me(n,e).tokens]}function Et(n){if(n!=="en"&&n!=="es")throw new Error(`Language not supported in this bundle: ${n}. Supported: en, es`);return R(n)}function vo(n,e){return Et(n).filter(t=>t.command===e).sort((t,r)=>r.priority-t.priority)}function xo(n,e,t){if(e!=="en"&&e!=="es"||t!=="en"&&t!=="es")throw new Error("This bundle only supports translation between en and es");return _e(n,e,t)}function So(n,e){if(e!=="en"&&e!=="es")throw new Error(`Language not supported in this bundle: ${e}. Supported: en, es`);let t=qe(n,e);return{en:t.en,es:t.es}}return zt(To);})();