@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.
- package/dist/browser-ar.ar.global.js +2 -2
- package/dist/browser-core.core.global.js +2 -2
- package/dist/browser-de.de.global.js +2 -2
- package/dist/browser-east-asian.east-asian.global.js +2 -2
- package/dist/browser-en-tr.en-tr.global.js +2 -2
- package/dist/browser-en.en.global.js +2 -2
- package/dist/browser-es-en.es-en.global.js +2 -2
- package/dist/browser-es.es.global.js +2 -2
- package/dist/browser-fr.fr.global.js +2 -2
- package/dist/browser-id.id.global.js +2 -2
- package/dist/browser-ja.ja.global.js +2 -2
- package/dist/browser-ko.ko.global.js +2 -2
- package/dist/browser-lazy.lazy.global.js +2 -2
- package/dist/browser-priority.priority.global.js +2 -2
- package/dist/browser-pt.pt.global.js +2 -2
- package/dist/browser-qu.qu.global.js +2 -2
- package/dist/browser-sw.sw.global.js +2 -2
- package/dist/browser-tr.tr.global.js +2 -2
- package/dist/browser-western.western.global.js +2 -2
- package/dist/browser-zh.zh.global.js +2 -2
- package/dist/browser.global.js +2 -2
- package/dist/browser.global.js.map +1 -1
- package/dist/index.cjs +13042 -17462
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -5
- package/dist/index.d.ts +49 -5
- package/dist/index.js +14044 -18464
- package/dist/index.js.map +1 -1
- package/dist/languages/ar.d.ts +1 -1
- package/dist/languages/ar.js +31 -44
- package/dist/languages/ar.js.map +1 -1
- package/dist/languages/de.d.ts +1 -1
- package/dist/languages/de.js +14 -2
- package/dist/languages/de.js.map +1 -1
- package/dist/languages/en.d.ts +1 -1
- package/dist/languages/en.js +558 -12
- package/dist/languages/en.js.map +1 -1
- package/dist/languages/es.d.ts +1 -1
- package/dist/languages/es.js +16 -0
- package/dist/languages/es.js.map +1 -1
- package/dist/languages/fr.d.ts +1 -1
- package/dist/languages/fr.js +14 -2
- package/dist/languages/fr.js.map +1 -1
- package/dist/languages/id.d.ts +1 -1
- package/dist/languages/id.js +14 -2
- package/dist/languages/id.js.map +1 -1
- package/dist/languages/ja.d.ts +1 -1
- package/dist/languages/ja.js +18 -3
- package/dist/languages/ja.js.map +1 -1
- package/dist/languages/ko.d.ts +8 -1
- package/dist/languages/ko.js +75 -43
- package/dist/languages/ko.js.map +1 -1
- package/dist/languages/pt.d.ts +1 -1
- package/dist/languages/pt.js +17 -0
- package/dist/languages/pt.js.map +1 -1
- package/dist/languages/qu.d.ts +12 -1
- package/dist/languages/qu.js +77 -2
- package/dist/languages/qu.js.map +1 -1
- package/dist/languages/sw.d.ts +1 -1
- package/dist/languages/sw.js.map +1 -1
- package/dist/languages/tr.d.ts +9 -1
- package/dist/languages/tr.js +96 -72
- package/dist/languages/tr.js.map +1 -1
- package/dist/languages/zh.d.ts +1 -1
- package/dist/languages/zh.js +16 -0
- package/dist/languages/zh.js.map +1 -1
- package/dist/{types-C4dcj53L.d.ts → types-BY3Id07j.d.ts} +20 -5
- package/package.json +20 -29
- package/src/generators/command-schemas.ts +21 -10
- package/src/generators/event-handler-generator.ts +50 -44
- package/src/generators/language-profiles.ts +6 -0
- package/src/generators/pattern-generator.ts +883 -1
- package/src/generators/profiles/arabic.ts +19 -3
- package/src/generators/profiles/bengali.ts +12 -1
- package/src/generators/profiles/chinese.ts +15 -0
- package/src/generators/profiles/french.ts +12 -1
- package/src/generators/profiles/german.ts +12 -1
- package/src/generators/profiles/hebrew.ts +148 -0
- package/src/generators/profiles/hindi.ts +12 -1
- package/src/generators/profiles/index.ts +2 -0
- package/src/generators/profiles/indonesian.ts +12 -1
- package/src/generators/profiles/italian.ts +16 -0
- package/src/generators/profiles/japanese.ts +11 -2
- package/src/generators/profiles/korean.ts +15 -1
- package/src/generators/profiles/polish.ts +12 -0
- package/src/generators/profiles/portuguese.ts +16 -0
- package/src/generators/profiles/russian.ts +11 -0
- package/src/generators/profiles/spanish.ts +15 -0
- package/src/generators/profiles/spanishMexico.ts +176 -0
- package/src/generators/profiles/thai.ts +11 -0
- package/src/generators/profiles/turkish.ts +49 -7
- package/src/generators/profiles/types.ts +21 -5
- package/src/generators/profiles/ukrainian.ts +11 -0
- package/src/generators/profiles/vietnamese.ts +11 -0
- package/src/language-building-schema.ts +111 -0
- package/src/languages/_all.ts +5 -1
- package/src/languages/es-MX.ts +32 -0
- package/src/languages/he.ts +15 -0
- package/src/parser/pattern-matcher.ts +10 -1
- package/src/parser/semantic-parser.ts +3 -0
- package/src/patterns/add/ar.ts +3 -59
- package/src/patterns/add/index.ts +5 -1
- package/src/patterns/add/ja.ts +3 -81
- package/src/patterns/add/ko.ts +3 -62
- package/src/patterns/add/qu.ts +69 -0
- package/src/patterns/add/tr.ts +3 -59
- package/src/patterns/builders.ts +1 -0
- package/src/patterns/decrement/tr.ts +3 -36
- package/src/patterns/event-handler/ar.ts +3 -139
- package/src/patterns/event-handler/he.ts +15 -0
- package/src/patterns/event-handler/index.ts +5 -1
- package/src/patterns/event-handler/ja.ts +3 -106
- package/src/patterns/event-handler/ko.ts +3 -121
- package/src/patterns/event-handler/ms.ts +45 -20
- package/src/patterns/event-handler/tr.ts +3 -158
- package/src/patterns/get/ar.ts +3 -37
- package/src/patterns/get/ja.ts +3 -41
- package/src/patterns/get/ko.ts +3 -41
- package/src/patterns/grammar-transformed/ja.ts +3 -1701
- package/src/patterns/grammar-transformed/ko.ts +3 -1299
- package/src/patterns/grammar-transformed/tr.ts +3 -1055
- package/src/patterns/hide/ar.ts +3 -55
- package/src/patterns/hide/ja.ts +3 -57
- package/src/patterns/hide/ko.ts +3 -57
- package/src/patterns/hide/tr.ts +3 -53
- package/src/patterns/increment/tr.ts +3 -40
- package/src/patterns/put/ar.ts +3 -62
- package/src/patterns/put/ja.ts +3 -63
- package/src/patterns/put/ko.ts +3 -55
- package/src/patterns/put/tr.ts +3 -55
- package/src/patterns/remove/ar.ts +3 -59
- package/src/patterns/remove/index.ts +5 -1
- package/src/patterns/remove/ja.ts +3 -62
- package/src/patterns/remove/ko.ts +3 -66
- package/src/patterns/remove/qu.ts +69 -0
- package/src/patterns/remove/tr.ts +3 -66
- package/src/patterns/set/ar.ts +3 -72
- package/src/patterns/set/ja.ts +3 -74
- package/src/patterns/set/ko.ts +3 -73
- package/src/patterns/set/tr.ts +3 -95
- package/src/patterns/show/ar.ts +3 -55
- package/src/patterns/show/ja.ts +3 -57
- package/src/patterns/show/ko.ts +3 -61
- package/src/patterns/show/tr.ts +3 -53
- package/src/patterns/take/ar.ts +3 -39
- package/src/patterns/toggle/ar.ts +3 -49
- package/src/patterns/toggle/index.ts +5 -1
- package/src/patterns/toggle/ja.ts +3 -144
- package/src/patterns/toggle/ko.ts +3 -101
- package/src/patterns/toggle/qu.ts +90 -0
- package/src/patterns/toggle/tr.ts +3 -76
- package/src/registry.ts +179 -15
- package/src/tokenizers/arabic.ts +13 -46
- package/src/tokenizers/bengali.ts +2 -16
- package/src/tokenizers/he.ts +542 -0
- package/src/tokenizers/index.ts +1 -0
- package/src/tokenizers/japanese.ts +3 -1
- package/src/tokenizers/korean.ts +104 -48
- package/src/tokenizers/ms.ts +3 -0
- package/src/tokenizers/quechua.ts +101 -2
- package/src/tokenizers/turkish.ts +64 -69
- package/src/types.ts +13 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var LokaScriptSemanticWestern=(()=>{var ke=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var Vt=(i,t)=>{for(var e in t)ke(i,e,{get:t[e],enumerable:!0})},Ot=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of At(t))!It.call(i,n)&&n!==e&&ke(i,n,{get:()=>t[n],enumerable:!(r=Mt(t,n))||r.enumerable});return i};var _t=i=>Ot(ke({},"__esModule",{value:!0}),i);var Pi={};Vt(Pi,{ASTBuilder:()=>oe,DEFAULT_CONFIDENCE_THRESHOLD:()=>De,HIGH_CONFIDENCE_THRESHOLD:()=>Ct,SemanticAnalyzerImpl:()=>ae,VERSION:()=>zi,buildAST:()=>Et,canParse:()=>qe,createCommandNode:()=>B,createEventHandler:()=>Q,createLiteral:()=>z,createPropertyPath:()=>X,createReference:()=>V,createSelector:()=>W,createSemanticAnalyzer:()=>Pt,englishProfile:()=>q,englishTokenizer:()=>pe,frenchProfile:()=>F,frenchTokenizer:()=>ye,fromExplicit:()=>Be,germanProfile:()=>H,germanTokenizer:()=>he,getCommandMapper:()=>ie,getPatternsForLanguage:()=>Lt,getPatternsForLanguageAndCommand:()=>Ei,getProfile:()=>Ee,getSupportedLanguages:()=>ki,getTokenizer:()=>we,isExplicitSyntax:()=>Z,isLanguageSupported:()=>Ze,parse:()=>Y,parseAny:()=>je,parseExplicit:()=>K,portugueseProfile:()=>$,portugueseTokenizer:()=>ge,registerCommandMapper:()=>Ue,render:()=>re,renderExplicit:()=>ne,shouldUseSemanticResult:()=>Nt,spanishProfile:()=>D,spanishTokenizer:()=>fe,toExplicit:()=>We,tokenize:()=>wi,tryGetProfile:()=>_});var G=new Map,le=new Map,J=new Map;var Fe=null;function M(i,t,e){G.set(i,t),le.set(i,e),J.delete(i)}var He=new Map;function Xe(i,t){He.set(i,t),J.delete(i)}function we(i){let t=G.get(i);if(!t){let e=Array.from(G.keys()).join(", ");throw new Error(`Language '${i}' is not registered. Registered languages: ${e||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return t}function Ee(i){let t=le.get(i);if(!t){let e=Array.from(le.keys()).join(", ");throw new Error(`Language profile '${i}' is not registered. Registered languages: ${e||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return t}function Qe(i){return G.get(i)}function _(i){return le.get(i)}function ce(){return Array.from(G.keys())}function Ze(i){return G.has(i)}function Ye(i,t){return we(t).tokenize(i)}function A(i){let t=J.get(i);if(t)return t;let e=He.get(i);if(e)return J.set(i,e),e;if(!Fe)throw new Error(`No patterns registered for language '${i}'. Either import the language module or set a pattern generator.`);let r=Ee(i),n=Fe(r);return J.set(i,n),n}function Je(i,t){return A(i).filter(e=>e.command===t).sort((e,r)=>r.priority-e.priority)}var E=class{constructor(t,e){this.pos=0;this.tokens=t,this.language=e}peek(t=0){let e=this.pos+t;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return{position:this.pos}}reset(t){this.pos=t.position}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(t){let e=[];for(;!this.isAtEnd()&&t(this.peek());)e.push(this.advance());return e}skipWhile(t){for(;!this.isAtEnd()&&t(this.peek());)this.advance()}};function h(i,t){return{start:i,end:t}}function v(i,t,e,r){if(typeof r=="string")return{value:i,kind:t,position:e,normalized:r};if(r){let{normalized:n,stem:o,stemConfidence:s}=r,a={value:i,kind:t,position:e};return n!==void 0&&(a.normalized=n),o!==void 0&&(a.stem=o,s!==void 0&&(a.stemConfidence=s)),a}return{value:i,kind:t,position:e}}function w(i){return/\s/.test(i)}function C(i){return i==="#"||i==="."||i==="["||i==="@"||i==="*"||i==="<"}function N(i){return i==='"'||i==="'"||i==="`"||i==="\u300C"||i==="\u300D"}function T(i){return/\d/.test(i)}function et(i){return/[a-zA-Z]/.test(i)}function b(i){return/[a-zA-Z0-9_-]/.test(i)}function I(i){let t=r=>i.test(r);return{isLetter:t,isIdentifierChar:r=>t(r)||/[0-9_-]/.test(r)}}function tt(i,t){if(t>=i.length)return null;let e=i[t];if(!C(e))return null;let r=t,n="";if(e==="#"||e==="."){for(n+=i[r++];r<i.length&&b(i[r]);)n+=i[r++];if(n.length<=1)return null;if(r<i.length&&i[r]==="."&&e==="#"){let s=r+1;for(;s<i.length&&b(i[s]);)s++;if(s<i.length&&i[s]==="(")return n}}else if(e==="["){let o=1,s=!1,a=null,l=!1;for(n+=i[r++];r<i.length&&o>0;){let c=i[r];n+=c,l?l=!1:c==="\\"?l=!0:s?c===a&&(s=!1,a=null):c==='"'||c==="'"||c==="`"?(s=!0,a=c):c==="["?o++:c==="]"&&o--,r++}if(o!==0)return null}else if(e==="@"){for(n+=i[r++];r<i.length&&b(i[r]);)n+=i[r++];if(n.length<=1)return null}else if(e==="*"){for(n+=i[r++];r<i.length&&b(i[r]);)n+=i[r++];if(n.length<=1)return null}else if(e==="<"){if(n+=i[r++],r>=i.length||!et(i[r]))return null;for(;r<i.length&&b(i[r]);)n+=i[r++];for(;r<i.length;){let o=i[r];if(o==="."){if(n+=i[r++],r>=i.length||!b(i[r]))return null;for(;r<i.length&&b(i[r]);)n+=i[r++]}else if(o==="#"){if(n+=i[r++],r>=i.length||!b(i[r]))return null;for(;r<i.length&&b(i[r]);)n+=i[r++]}else if(o==="["){let s=1,a=!1,l=null,c=!1;for(n+=i[r++];r<i.length&&s>0;){let p=i[r];n+=p,c?c=!1:p==="\\"?c=!0:a?p===l&&(a=!1,l=null):p==='"'||p==="'"||p==="`"?(a=!0,l=p):p==="["?s++:p==="]"&&s--,r++}if(s!==0)return null}else break}for(;r<i.length&&w(i[r]);)n+=i[r++];if(r<i.length&&i[r]==="/")for(n+=i[r++];r<i.length&&w(i[r]);)n+=i[r++];if(r>=i.length||i[r]!==">")return null;n+=i[r++]}return n||null}function Pe(i,t){if(t>=i.length||i[t]!=="'"||t+1>=i.length||i[t+1].toLowerCase()!=="s")return!1;if(t+2>=i.length)return!0;let r=i[t+2];return w(r)||r==="*"||!b(r)}function rt(i,t){if(t>=i.length)return null;let e=i[t];if(!N(e)||e==="'"&&Pe(i,t))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[e];if(!n)return null;let o=t+1,s=e,a=!1;for(;o<i.length;){let l=i[o];if(s+=l,a)a=!1;else if(l==="\\")a=!0;else if(l===n)return s;o++}return s}function R(i,t){if(t>=i.length)return!1;let e=i[t],r=i[t+1]||"",n=i[t+2]||"";if(e==="/"&&r!=="/"&&/[a-zA-Z0-9._-]/.test(r)||e==="/"&&r==="/"&&/[a-zA-Z]/.test(n)||e==="."&&(r==="/"||r==="."&&n==="/"))return!0;let o=i.slice(t,t+8).toLowerCase();return!!(o.startsWith("http://")||o.startsWith("https://"))}function nt(i,t){if(!R(i,t))return null;let e=t,r="",n=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;e<i.length;){let o=i[e];if(o==="#"){if(r.length>0&&/[a-zA-Z0-9/.]$/.test(r))for(r+=o,e++;e<i.length&&/[a-zA-Z0-9_-]/.test(i[e]);)r+=i[e++];break}if(n.test(o))r+=o,e++;else break}return r.length<2?null:r}function it(i,t){if(t>=i.length)return null;let e=i[t];if(!T(e)&&e!=="-"&&e!=="+")return null;let r=t,n="";if((i[r]==="-"||i[r]==="+")&&(n+=i[r++]),r>=i.length||!T(i[r]))return null;for(;r<i.length&&T(i[r]);)n+=i[r++];if(r<i.length&&i[r]===".")for(n+=i[r++];r<i.length&&T(i[r]);)n+=i[r++];return r<i.length&&(i.slice(r,r+2)==="ms"?n+="ms":(i[r]==="s"||i[r]==="m"||i[r]==="h")&&(n+=i[r])),n}var de=class de{constructor(){this.profileKeywords=[];this.profileKeywordMap=new Map}initializeKeywordsFromProfile(t,e=[]){let r=new Map;if(t.keywords){for(let[n,o]of Object.entries(t.keywords))if(r.set(o.primary,{native:o.primary,normalized:o.normalized||n}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:o.normalized||n})}if(t.references)for(let[n,o]of Object.entries(t.references))r.set(o,{native:o,normalized:n});if(t.roleMarkers){for(let[n,o]of Object.entries(t.roleMarkers))if(o.primary&&r.set(o.primary,{native:o.primary,normalized:n}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:n})}for(let n of e)r.set(n.native,n);this.profileKeywords=Array.from(r.values()).sort((n,o)=>o.native.length-n.native.length),this.profileKeywordMap=new Map;for(let n of this.profileKeywords){this.profileKeywordMap.set(n.native.toLowerCase(),n);let o=this.removeDiacritics(n.native);o!==n.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),n)}}removeDiacritics(t){return t.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(t,e){for(let r of this.profileKeywords)if(t.slice(e).startsWith(r.native))return v(r.native,"keyword",h(e,e+r.native.length),r.normalized);return null}isKeywordStart(t,e){let r=t.slice(e);return this.profileKeywords.some(n=>r.startsWith(n.native))}lookupKeyword(t){return this.profileKeywordMap.get(t.toLowerCase())}isKeyword(t){return this.profileKeywordMap.has(t.toLowerCase())}setNormalizer(t){this.normalizer=t}tryNormalize(t){if(!this.normalizer)return null;let e=this.normalizer.normalize(t);return e.stem!==t&&e.confidence>=.7?e:null}tryMorphKeywordMatch(t,e,r){let n=this.tryNormalize(t);if(!n)return null;let o=this.lookupKeyword(n.stem);if(!o)return null;let s={normalized:o.normalized,stem:n.stem,stemConfidence:n.confidence};return v(t,"keyword",h(e,r),s)}trySelector(t,e){let r=tt(t,e);return r?v(r,"selector",h(e,e+r.length)):null}tryEventModifier(t,e){if(t[e]!==".")return null;let r=t.slice(e).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!r)return null;let n=r[0].replace(/(\s|\.)$/,""),o=n.slice(1).split("(")[0],s=r[1];return{...v(n,"event-modifier",h(e,e+n.length)),metadata:{modifierName:o,value:s?o==="queue"?s:parseInt(s,10):void 0}}}tryString(t,e){let r=rt(t,e);return r?v(r,"literal",h(e,e+r.length)):null}tryNumber(t,e){let r=it(t,e);return r?v(r,"literal",h(e,e+r.length)):null}tryMatchTimeUnit(t,e,r,n=!1){let o=e;if(n)for(;o<t.length&&w(t[o]);)o++;let s=t.slice(o);for(let a of r){let l=s.slice(0,a.length);if(a.caseInsensitive?l.toLowerCase()===a.pattern.toLowerCase():l===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let p=s[a.length]||"";if(b(p))continue}return{suffix:a.suffix,endPos:o+a.length}}}return null}parseBaseNumber(t,e,r=!0){let n=e,o="";if(r&&(t[n]==="-"||t[n]==="+")&&(o+=t[n++]),n>=t.length||!T(t[n]))return null;for(;n<t.length&&T(t[n]);)o+=t[n++];if(n<t.length&&t[n]===".")for(o+=t[n++];n<t.length&&T(t[n]);)o+=t[n++];return!o||o==="-"||o==="+"?null:{number:o,endPos:n}}tryNumberWithTimeUnits(t,e,r,n={}){let{allowSign:o=!0,skipWhitespace:s=!1}=n,a=this.parseBaseNumber(t,e,o);if(!a)return null;let{number:l,endPos:c}=a,p=[...r,...de.STANDARD_TIME_UNITS],S=this.tryMatchTimeUnit(t,c,p,s);return S&&(l+=S.suffix,c=S.endPos),v(l,"literal",h(e,c))}tryUrl(t,e){let r=nt(t,e);return r?v(r,"url",h(e,e+r.length)):null}tryVariableRef(t,e){if(t[e]!==":"||e+1>=t.length||!b(t[e+1]))return null;let r=e+1;for(;r<t.length&&b(t[r]);)r++;let n=t.slice(e,r);return v(n,"identifier",h(e,r))}tryOperator(t,e){let r=t.slice(e,e+2);if(["==","!=","<=",">=","&&","||","->"].includes(r))return v(r,"operator",h(e,e+2));let n=t[e];return["<",">","!","+","-","*","/","="].includes(n)?v(n,"operator",h(e,e+1)):["(",")","{","}",",",";",":"].includes(n)?v(n,"punctuation",h(e,e+1)):null}tryMultiCharParticle(t,e,r){for(let n of r)if(t.slice(e,e+n.length)===n)return v(n,"particle",h(e,e+n.length));return null}};de.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 P=de;var q={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 qt=[{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"}],Ce=class extends P{constructor(){super();this.language="en";this.direction="ltr";this.initializeKeywordsFromProfile(q,qt)}tokenize(e){let r=[],n=0;for(;n<e.length;){if(w(e[n])){n++;continue}if(C(e[n])){let a=this.tryEventModifier(e,n);if(a){r.push(a),n=a.position.end;continue}if(e[n]==="."){let c=r[r.length-1],p=c&&c.position.end<n;if(c&&!p&&(c.kind==="identifier"||c.kind==="keyword"||c.kind==="selector")){r.push(v(".","operator",h(n,n+1))),n++;continue}let g=n+1;for(;g<e.length&&b(e[g]);)g++;if(g<e.length&&e[g]==="("){r.push(v(".","operator",h(n,n+1))),n++;continue}}let l=this.trySelector(e,n);if(l){r.push(l),n=l.position.end;continue}}if(N(e[n])){if(e[n]==="'"&&Pe(e,n)){r.push(v("'s","punctuation",h(n,n+2))),n+=2;continue}let a=this.tryString(e,n);if(a){r.push(a),n=a.position.end;continue}}if(R(e,n)){let a=this.tryUrl(e,n);if(a){r.push(a),n=a.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let a=this.tryNumber(e,n);if(a){r.push(a),n=a.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}if(b(e[n])){let a=this.extractWord(e,n);if(a){r.push(a),n=a.position.end;continue}}let s=this.tryOperator(e,n);if(s){r.push(s),n=s.position.end;continue}n++}return new E(r,"en")}classifyToken(e){return this.isKeyword(e)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(e)?"operator":e.startsWith("/")||e.startsWith("./")||e.startsWith("http")?"url":"identifier"}extractWord(e,r){let n=r,o="";for(;n<e.length&&b(e[n]);)o+=e[n++];if(!o)return null;if(n<e.length&&e[n]===":"){let c=n;n++;let p="";for(;n<e.length&&b(e[n]);)p+=e[n++];p?o=o+":"+p:n=c}let s=this.classifyToken(o),a=this.lookupKeyword(o),l=a&&a.normalized!==a.native?a.normalized:void 0;if(s==="identifier"){let c=this.tryConvertToClassSelector(e,n,o);if(c)return c.token}return v(o,s,h(r,n),l)}tryConvertToClassSelector(e,r,n){let o=r;for(;o<e.length&&/\s/.test(e[o]);)o++;if(e.slice(o,o+5).toLowerCase()==="class"){let s=o+5;if(s>=e.length||!b(e[s])){let a="."+n;return{token:v(a,"selector",h(r-n.length,r)),endPos:r}}}return null}},pe=new Ce;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)"}},Bt={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"}},jt={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"}},Kt={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"}},Ut={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>"}},Gt={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}]},Dt={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}]},$t={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}]},Ft={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}]},Ht={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}]},Xt={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}]},Zt={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}]},Yt={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}]},er={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}]},tr={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}]},rr={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}]},nr={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}]},ir={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}]},or={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}]},ar={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}]},sr={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"}}]},lr={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}]},cr={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}]},dr={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},pr={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"'},mr={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}]},ur={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}]},fr={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},gr={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}]},yr={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}]},hr={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}]},vr={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}]},xr={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}]},Sr={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}]},Tr={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}]},br={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}]},zr={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:!0,roles:[]},kr={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}]},wr={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}]},Er={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}]},Cr={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}]},Nr={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}]},Rr={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}]},Lr={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}]},Mr={toggle:Wt,add:Bt,remove:jt,put:Kt,set:Ut,show:Gt,hide:Dt,on:$t,trigger:Ft,wait:Ht,fetch:Xt,increment:Qt,decrement:Zt,append:Yt,prepend:Jt,log:er,get:tr,take:rr,make:nr,halt:ir,settle:or,throw:ar,send:sr,if:lr,unless:cr,else:dr,repeat:pr,for:mr,while:ur,continue:fr,go:gr,transition:yr,clone:hr,focus:vr,blur:xr,call:Sr,return:Tr,js:br,async:zr,tell:kr,default:wr,init:Er,behavior:Pr,install:Cr,measure:Nr,swap:Rr,morph:Lr,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:!0,roles:[]}};function ot(){return Object.values(Mr).filter(i=>i.roles.length>0)}function Ne(i,t){let e=t==="SOV"?"sovPosition":"svoPosition";return[...i].sort((r,n)=>{let o=r[e]??99,s=n[e]??99;return o-s})}function at(i,t){let e=i.markerOverride?.[t.code],r=t.roleMarkers[i.role];if(e!==void 0)return{primary:e,position:r?.position??"before",isOverride:!0};if(r&&r.primary){let n={primary:r.primary,position:r.position,isOverride:!1};return r.alternatives&&(n.alternatives=r.alternatives),n}return null}var me={basePriority:100,generateSimpleVariants:!0,generateAlternatives:!0};function st(i,t,e=me){let r=`${i.action}-${t.code}-generated`,n=e.basePriority??100,o=t.keywords[i.action];if(!o)throw new Error(`No keyword translation for '${i.action}' in ${t.code}`);let s=Vr(i,t,o),a=ct(i,t),l=Wr(i,t,o);return{id:r,language:t.code,command:i.action,priority:n,template:{format:l,tokens:s},extraction:a}}function Ar(i,t,e=me){if(i.roles.filter(a=>!a.required).length===0)return null;let n=i.roles.filter(a=>a.required),o={...i,roles:n};return{...st(o,t,e),id:`${i.action}-${t.code}-simple`,priority:(e.basePriority??100)-5,extraction:ct(i,t)}}function Ir(i,t,e=me){let r=[];if(r.push(st(i,t,e)),e.generateSimpleVariants){let n=Ar(i,t,e);n&&r.push(n)}return r}function lt(i,t=me){let e=[],r=ot();for(let n of r){if(!i.keywords[n.action])continue;let o=Ir(n,i,t);e.push(...o)}return e}function Vr(i,t,e){let r=[],n=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary},o=Or(i,t);switch(t.wordOrder){case"SVO":r.push(n),r.push(...o);break;case"SOV":r.push(...o),r.push(n);break;case"VSO":r.push(n),r.push(...o);break;default:r.push(n),r.push(...o)}return r}function Or(i,t){let e=[],r=Ne(i.roles,t.wordOrder);for(let n of r){let o=_r(n,t);n.required?e.push(...o):e.push({type:"group",optional:!0,tokens:o})}return e}function _r(i,t){let e=[],r=i.markerOverride?.[t.code],n=t.roleMarkers[i.role],o={type:"role",role:i.role,optional:!i.required,expectedTypes:i.expectedTypes};if(r!==void 0)(n?.position??"before")==="before"?(r&&e.push({type:"literal",value:r}),e.push(o)):(e.push(o),r&&e.push({type:"literal",value:r}));else if(n)if(n.position==="before"){if(n.primary){let s=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};e.push(s)}e.push(o)}else{e.push(o);let s=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};e.push(s)}else e.push(o);return e}function qr(i,t){let e={};for(let r of i.roles){let n=r.markerOverride?.[t.code],o=t.roleMarkers[r.role];n!==void 0?e[r.role]=n?{marker:n}:{}:o&&o.primary?e[r.role]=o.alternatives?{marker:o.primary,markerAlternatives:o.alternatives}:{marker:o.primary}:e[r.role]={}}return e}function ct(i,t){let e=qr(i,t),r={};for(let n of i.roles){let o=e[n.role]||{};!n.required&&n.default?r[n.role]={...o,default:n.default}:r[n.role]=o}return r}function Wr(i,t,e){let r=[],o=Ne(i.roles,t.wordOrder).map(s=>{let a=at(s,t),l="";return a&&a.primary?a.position==="before"?l=`${a.primary} {${s.role}}`:l=`{${s.role}} ${a.primary}`:l=`{${s.role}}`,s.required?l:`[${l}]`});switch(t.wordOrder){case"SVO":case"VSO":r.push(e.primary,...o);break;case"SOV":r.push(...o,e.primary);break;default:r.push(e.primary,...o)}return r.join(" ")}function dt(){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 pt(){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 mt(){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 Br={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"}}},jr={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}}},Kr={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}}},Ur={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"}}}},Gr={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"}}}},Dr={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"}}},$r={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"}}}},Fr={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}}},Hr={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}}},Xr={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 ut(){let i=[];i.push(...dt()),i.push(...pt()),i.push(...mt()),i.push(Br,jr,Kr,Ur,Gr,Dr,$r,Fr,Hr,Xr,Qr);let t=lt(q);return i.push(...t),i}M("en",pe,q);Xe("en",ut());function Re(i){return{stem:i,confidence:1}}function ue(i,t,e){return e?{stem:i,confidence:t,metadata:e}:{stem:i,confidence:t}}function Zr(i){return/[áéíóúüñÁÉÍÓÚÜÑ]/.test(i)}function Yr(i){let t=i.toLowerCase();if(t.endsWith("ar")||t.endsWith("er")||t.endsWith("ir")||t.endsWith("ando")||t.endsWith("iendo")||t.endsWith("ado")||t.endsWith("ido")||t.endsWith("arse")||t.endsWith("erse")||t.endsWith("irse"))return!0;for(let e of i)if(Zr(e))return!0;return!1}var ft=["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"}],en=[{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"}],tn=[{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"}],rn=[...Jr,...en,...tn].sort((i,t)=>t.ending.length-i.ending.length),ee=class{constructor(){this.language="es"}isNormalizable(t){return t.length<3?!1:Yr(t)}normalize(t){let e=t.toLowerCase();if((e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir"))&&!ft.some(o=>e.endsWith(o+"ar")||e.endsWith(o+"er")||e.endsWith(o+"ir")))return Re(t);let r=this.tryReflexiveNormalization(e);if(r)return r;let n=this.tryConjugationNormalization(e);return n||Re(t)}tryReflexiveNormalization(t){for(let e of ft)if(t.endsWith(e)){let r=t.slice(0,-e.length);if(r.endsWith("ar")||r.endsWith("er")||r.endsWith("ir"))return ue(r,.88,{removedSuffixes:[e],conjugationType:"reflexive"});let n=this.tryConjugationNormalization(r);if(n&&n.stem!==r)return ue(n.stem,n.confidence*.95,{removedSuffixes:[e,...n.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationNormalization(t){for(let e of rn)if(t.endsWith(e.ending)){let r=t.slice(0,-e.ending.length);if(r.length<2)continue;let n=r+e.stem;return ue(n,e.confidence,{removedSuffixes:[e.ending],conjugationType:e.type})}return null}},io=new ee;var D={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:gt,isIdentifierChar:nn}=I(/[a-zA-ZáéíóúüñÁÉÍÓÚÜÑ]/),on=[{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}],yt=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),an=[{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"}],Le=class extends P{constructor(){super();this.language="es";this.direction="ltr";this.initializeKeywordsFromProfile(D,an),this.normalizer=new ee}tokenize(e){let r=[],n=0;for(;n<e.length;){if(w(e[n])){n++;continue}if(C(e[n])){let l=this.tryEventModifier(e,n);if(l){r.push(l),n=l.position.end;continue}let c=this.trySelector(e,n);if(c){r.push(c),n=c.position.end;continue}}if(N(e[n])){let l=this.tryString(e,n);if(l){r.push(l),n=l.position.end;continue}}if(R(e,n)){let l=this.tryUrl(e,n);if(l){r.push(l),n=l.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let l=this.extractSpanishNumber(e,n);if(l){r.push(l),n=l.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}let s=this.tryMultiWordPhrase(e,n);if(s){r.push(s),n=s.position.end;continue}if(gt(e[n])){let l=this.extractSpanishWord(e,n);if(l){r.push(l),n=l.position.end;continue}}let a=this.tryOperator(e,n);if(a){r.push(a),n=a.position.end;continue}n++}return new E(r,"es")}classifyToken(e){let r=e.toLowerCase();return yt.has(r)?"particle":this.isKeyword(r)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(e)?"operator":"identifier"}tryMultiWordPhrase(e,r){for(let n of this.profileKeywords){if(!n.native.includes(" "))continue;let o=n.native;if(e.slice(r,r+o.length).toLowerCase()===o.toLowerCase()){let a=r+o.length;if(a>=e.length||w(e[a])||!gt(e[a]))return v(e.slice(r,r+o.length),"keyword",h(r,a),n.normalized)}}return null}extractSpanishWord(e,r){let n=r,o="";for(;n<e.length&&nn(e[n]);)o+=e[n++];if(!o)return null;let s=o.toLowerCase();if(yt.has(s))return v(o,"particle",h(r,n));let a=this.lookupKeyword(s);if(a)return v(o,"keyword",h(r,n),a.normalized);let l=this.tryMorphKeywordMatch(s,r,n);return l||v(o,"identifier",h(r,n))}extractSpanishNumber(e,r){return this.tryNumberWithTimeUnits(e,r,on,{allowSign:!0,skipWhitespace:!0})}},fe=new Le;M("es",fe,D);var $={code:"pt",name:"Portuguese",nativeName:"Portugu\xEAs",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,verb:{position:"start",subjectDrop:!0},references:{me:"eu",it:"ele",you:"voc\xEA",result:"resultado",event:"evento",target:"alvo",body:"corpo"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:!0,specialForms:{me:"meu",it:"seu",you:"teu"},keywords:{meu:"me",minha:"me",teu:"you",tua:"you",seu:"it",sua:"it"}},roleMarkers:{destination:{primary:"em",alternatives:["para","a"],position:"before"},source:{primary:"de",alternatives:["desde"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"com",position:"before"}},keywords:{toggle:{primary:"alternar",alternatives:["trocar"],normalized:"toggle"},add:{primary:"adicionar",alternatives:["acrescentar"],normalized:"add"},remove:{primary:"remover",alternatives:["eliminar","apagar"],normalized:"remove"},put:{primary:"colocar",alternatives:["p\xF4r","por"],normalized:"put"},append:{primary:"anexar",normalized:"append"},prepend:{primary:"preceder",normalized:"prepend"},take:{primary:"pegar",normalized:"take"},make:{primary:"fazer",alternatives:["criar"],normalized:"make"},clone:{primary:"clonar",alternatives:["copiar"],normalized:"clone"},swap:{primary:"trocar",alternatives:["substituir"],normalized:"swap"},morph:{primary:"transformar",alternatives:["converter"],normalized:"morph"},set:{primary:"definir",alternatives:["configurar"],normalized:"set"},get:{primary:"obter",normalized:"get"},increment:{primary:"incrementar",alternatives:["aumentar"],normalized:"increment"},decrement:{primary:"decrementar",alternatives:["diminuir"],normalized:"decrement"},log:{primary:"registrar",alternatives:["imprimir"],normalized:"log"},show:{primary:"mostrar",alternatives:["exibir"],normalized:"show"},hide:{primary:"ocultar",alternatives:["esconder"],normalized:"hide"},transition:{primary:"transi\xE7\xE3o",alternatives:["animar"],normalized:"transition"},on:{primary:"em",alternatives:["quando","ao"],normalized:"on"},trigger:{primary:"disparar",alternatives:["ativar"],normalized:"trigger"},send:{primary:"enviar",normalized:"send"},focus:{primary:"focar",normalized:"focus"},blur:{primary:"desfocar",normalized:"blur"},go:{primary:"ir",alternatives:["navegar"],normalized:"go"},wait:{primary:"esperar",alternatives:["aguardar"],normalized:"wait"},fetch:{primary:"buscar",normalized:"fetch"},settle:{primary:"estabilizar",normalized:"settle"},if:{primary:"se",normalized:"if"},when:{primary:"quando",normalized:"when"},where:{primary:"onde",normalized:"where"},else:{primary:"sen\xE3o",normalized:"else"},repeat:{primary:"repetir",normalized:"repeat"},for:{primary:"para",normalized:"for"},while:{primary:"enquanto",normalized:"while"},continue:{primary:"continuar",normalized:"continue"},halt:{primary:"parar",normalized:"halt"},throw:{primary:"lan\xE7ar",normalized:"throw"},call:{primary:"chamar",normalized:"call"},return:{primary:"retornar",alternatives:["devolver"],normalized:"return"},then:{primary:"ent\xE3o",alternatives:["depois","logo"],normalized:"then"},and:{primary:"e",alternatives:["tamb\xE9m","al\xE9m disso"],normalized:"and"},end:{primary:"fim",alternatives:["final","t\xE9rmino"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"ass\xEDncrono",normalized:"async"},tell:{primary:"dizer",normalized:"tell"},default:{primary:"padr\xE3o",normalized:"default"},init:{primary:"iniciar",alternatives:["inicializar"],normalized:"init"},behavior:{primary:"comportamento",normalized:"behavior"},install:{primary:"instalar",normalized:"install"},measure:{primary:"medir",normalized:"measure"},into:{primary:"em",alternatives:["dentro de"],normalized:"into"},before:{primary:"antes",normalized:"before"},after:{primary:"depois",normalized:"after"},until:{primary:"at\xE9",normalized:"until"},event:{primary:"evento",normalized:"event"},from:{primary:"de",alternatives:["desde"],normalized:"from"}}};var{isLetter:sn,isIdentifierChar:ln}=I(/[a-zA-ZáàâãéêíóôõúüçÁÀÂÃÉÊÍÓÔÕÚÜÇ]/),ht=new Set(["em","a","de","desde","at\xE9","ate","com","sem","por","para","sobre","entre","antes","depois","dentro","fora","ao","do","no","na"]),cn=[{native:"verdadeiro",normalized:"true"},{native:"falso",normalized:"false"},{native:"nulo",normalized:"null"},{native:"indefinido",normalized:"undefined"},{native:"primeiro",normalized:"first"},{native:"primeira",normalized:"first"},{native:"\xFAltimo",normalized:"last"},{native:"ultima",normalized:"last"},{native:"pr\xF3ximo",normalized:"next"},{native:"proximo",normalized:"next"},{native:"anterior",normalized:"previous"},{native:"mais pr\xF3ximo",normalized:"closest"},{native:"mais proximo",normalized:"closest"},{native:"pai",normalized:"parent"},{native:"clique",normalized:"click"},{native:"click",normalized:"click"},{native:"entrada",normalized:"input"},{native:"mudan\xE7a",normalized:"change"},{native:"mudanca",normalized:"change"},{native:"envio",normalized:"submit"},{native:"tecla baixo",normalized:"keydown"},{native:"tecla cima",normalized:"keyup"},{native:"mouse sobre",normalized:"mouseover"},{native:"mouse fora",normalized:"mouseout"},{native:"foco",normalized:"focus"},{native:"desfoque",normalized:"blur"},{native:"carregar",normalized:"load"},{native:"rolagem",normalized:"scroll"},{native:"meu",normalized:"my"},{native:"minha",normalized:"my"},{native:"isso",normalized:"it"},{native:"segundo",normalized:"s"},{native:"segundos",normalized:"s"},{native:"milissegundo",normalized:"ms"},{native:"milissegundos",normalized:"ms"},{native:"minuto",normalized:"m"},{native:"minutos",normalized:"m"},{native:"hora",normalized:"h"},{native:"horas",normalized:"h"},{native:"senao",normalized:"else"},{native:"transicao",normalized:"transition"},{native:"ate",normalized:"until"},{native:"entao",normalized:"then"},{native:"lancar",normalized:"throw"},{native:"assincrono",normalized:"async"},{native:"padrao",normalized:"default"},{native:"at\xE9 que",normalized:"until"},{native:"dentro de",normalized:"into"}],dn=[{pattern:"milissegundos",suffix:"ms",length:13,caseInsensitive:!0},{pattern:"milissegundo",suffix:"ms",length:12,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}],Me=class extends P{constructor(){super();this.language="pt";this.direction="ltr";this.initializeKeywordsFromProfile($,cn)}tokenize(e){let r=[],n=0;for(;n<e.length;){if(w(e[n])){n++;continue}if(C(e[n])){let a=this.tryEventModifier(e,n);if(a){r.push(a),n=a.position.end;continue}let l=this.trySelector(e,n);if(l){r.push(l),n=l.position.end;continue}}if(N(e[n])){let a=this.tryString(e,n);if(a){r.push(a),n=a.position.end;continue}}if(R(e,n)){let a=this.tryUrl(e,n);if(a){r.push(a),n=a.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let a=this.extractNumber(e,n);if(a){r.push(a),n=a.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}if(sn(e[n])){let a=this.extractWord(e,n);if(a){r.push(a),n=a.position.end;continue}}let s=this.tryOperator(e,n);if(s){r.push(s),n=s.position.end;continue}n++}return new E(r,"pt")}classifyToken(e){let r=e.toLowerCase();return ht.has(r)?"particle":this.isKeyword(r)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":"identifier"}extractWord(e,r){let n=r,o="";for(;n<e.length&&ln(e[n]);)o+=e[n++];if(!o)return null;let s=o.toLowerCase(),a=this.lookupKeyword(s);return a?v(o,"keyword",h(r,n),a.normalized):ht.has(s)?v(o,"particle",h(r,n)):v(o,"identifier",h(r,n))}extractNumber(e,r){return this.tryNumberWithTimeUnits(e,r,dn,{allowSign:!0,skipWhitespace:!0})}},ge=new Me;M("pt",ge,$);var F={code:"fr",name:"French",nativeName:"Fran\xE7ais",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:!1},references:{me:"moi",it:"il",you:"toi",result:"r\xE9sultat",event:"\xE9v\xE9nement",target:"cible",body:"corps"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:!0,specialForms:{me:"ma",it:"sa",you:"ta"},keywords:{mon:"me",ma:"me",mes:"me",ton:"you",ta:"you",tes:"you",son:"it",sa:"it",ses:"it"}},roleMarkers:{destination:{primary:"sur",alternatives:["\xE0","dans"],position:"before"},source:{primary:"de",alternatives:["depuis"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"avec",position:"before"}},keywords:{toggle:{primary:"basculer",alternatives:["permuter","alterner"],normalized:"toggle"},add:{primary:"ajouter",normalized:"add"},remove:{primary:"supprimer",alternatives:["enlever","retirer"],normalized:"remove"},put:{primary:"mettre",alternatives:["placer"],normalized:"put"},append:{primary:"annexer",normalized:"append"},prepend:{primary:"pr\xE9fixer",normalized:"prepend"},take:{primary:"prendre",normalized:"take"},make:{primary:"faire",alternatives:["cr\xE9er"],normalized:"make"},clone:{primary:"cloner",alternatives:["copier"],normalized:"clone"},swap:{primary:"\xE9changer",alternatives:["permuter"],normalized:"swap"},morph:{primary:"transformer",alternatives:["m\xE9tamorphoser"],normalized:"morph"},set:{primary:"d\xE9finir",alternatives:["\xE9tablir"],normalized:"set"},get:{primary:"obtenir",normalized:"get"},increment:{primary:"incr\xE9menter",alternatives:["augmenter"],normalized:"increment"},decrement:{primary:"d\xE9cr\xE9menter",alternatives:["diminuer"],normalized:"decrement"},log:{primary:"enregistrer",alternatives:["afficher"],normalized:"log"},show:{primary:"montrer",alternatives:["afficher"],normalized:"show"},hide:{primary:"cacher",alternatives:["masquer"],normalized:"hide"},transition:{primary:"transition",alternatives:["animer"],normalized:"transition"},on:{primary:"sur",alternatives:["quand","lors"],normalized:"on"},trigger:{primary:"d\xE9clencher",normalized:"trigger"},send:{primary:"envoyer",normalized:"send"},focus:{primary:"focaliser",alternatives:["concentrer"],normalized:"focus"},blur:{primary:"d\xE9focaliser",normalized:"blur"},go:{primary:"aller",alternatives:["naviguer"],normalized:"go"},wait:{primary:"attendre",normalized:"wait"},fetch:{primary:"chercher",alternatives:["r\xE9cup\xE9rer"],normalized:"fetch"},settle:{primary:"stabiliser",normalized:"settle"},if:{primary:"si",normalized:"if"},when:{primary:"quand",normalized:"when"},where:{primary:"o\xF9",normalized:"where"},else:{primary:"sinon",normalized:"else"},repeat:{primary:"r\xE9p\xE9ter",normalized:"repeat"},for:{primary:"pour",normalized:"for"},while:{primary:"pendant",normalized:"while"},continue:{primary:"continuer",normalized:"continue"},halt:{primary:"arr\xEAter",alternatives:["stopper"],normalized:"halt"},throw:{primary:"lancer",normalized:"throw"},call:{primary:"appeler",normalized:"call"},return:{primary:"retourner",alternatives:["renvoyer"],normalized:"return"},then:{primary:"puis",alternatives:["ensuite","alors"],normalized:"then"},and:{primary:"et",alternatives:["aussi","\xE9galement"],normalized:"and"},end:{primary:"fin",alternatives:["terminer","finir"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"asynchrone",normalized:"async"},tell:{primary:"dire",normalized:"tell"},default:{primary:"d\xE9faut",normalized:"default"},init:{primary:"initialiser",normalized:"init"},behavior:{primary:"comportement",normalized:"behavior"},install:{primary:"installer",normalized:"install"},measure:{primary:"mesurer",normalized:"measure"},into:{primary:"dans",normalized:"into"},before:{primary:"avant",normalized:"before"},after:{primary:"apr\xE8s",normalized:"after"},until:{primary:"jusqu'\xE0",alternatives:["jusque"],normalized:"until"},event:{primary:"\xE9v\xE9nement",normalized:"event"},from:{primary:"de",alternatives:["depuis"],normalized:"from"}},eventHandler:{keyword:{primary:"sur",alternatives:["lors"]},sourceMarker:{primary:"de",alternatives:["depuis"],position:"before"},conditionalKeyword:{primary:"quand",alternatives:["lorsque"]}}};var{isLetter:pn,isIdentifierChar:mn}=I(/[a-zA-ZàâäéèêëîïôùûüçœæÀÂÄÉÈÊËÎÏÔÙÛÜÇŒÆ]/),vt=new Set(["\xE0","a","de","du","des","dans","sur","sous","avec","sans","par","pour","entre","avant","apr\xE8s","apres","depuis","vers","chez","contre","au","aux"]),un=[{native:"vrai",normalized:"true"},{native:"faux",normalized:"false"},{native:"nul",normalized:"null"},{native:"ind\xE9fini",normalized:"undefined"},{native:"indefini",normalized:"undefined"},{native:"premier",normalized:"first"},{native:"premi\xE8re",normalized:"first"},{native:"premiere",normalized:"first"},{native:"dernier",normalized:"last"},{native:"derni\xE8re",normalized:"last"},{native:"derniere",normalized:"last"},{native:"suivant",normalized:"next"},{native:"pr\xE9c\xE9dent",normalized:"previous"},{native:"precedent",normalized:"previous"},{native:"plus proche",normalized:"closest"},{native:"parent",normalized:"parent"},{native:"clic",normalized:"click"},{native:"click",normalized:"click"},{native:"entr\xE9e",normalized:"input"},{native:"entree",normalized:"input"},{native:"changement",normalized:"change"},{native:"soumission",normalized:"submit"},{native:"touche bas",normalized:"keydown"},{native:"touche haut",normalized:"keyup"},{native:"souris dessus",normalized:"mouseover"},{native:"souris dehors",normalized:"mouseout"},{native:"focus",normalized:"focus"},{native:"flou",normalized:"blur"},{native:"chargement",normalized:"load"},{native:"d\xE9filement",normalized:"scroll"},{native:"defilement",normalized:"scroll"},{native:"je",normalized:"me"},{native:"mon",normalized:"my"},{native:"ma",normalized:"my"},{native:"mes",normalized:"my"},{native:"\xE7a",normalized:"it"},{native:"ca",normalized:"it"},{native:"resultat",normalized:"result"},{native:"evenement",normalized:"event"},{native:"seconde",normalized:"s"},{native:"secondes",normalized:"s"},{native:"milliseconde",normalized:"ms"},{native:"millisecondes",normalized:"ms"},{native:"minute",normalized:"m"},{native:"minutes",normalized:"m"},{native:"heure",normalized:"h"},{native:"heures",normalized:"h"},{native:"prefixer",normalized:"prepend"},{native:"creer",normalized:"make"},{native:"definir",normalized:"set"},{native:"etablir",normalized:"set"},{native:"incrementer",normalized:"increment"},{native:"decrementer",normalized:"decrement"},{native:"declencher",normalized:"trigger"},{native:"defocaliser",normalized:"blur"},{native:"recuperer",normalized:"fetch"},{native:"repeter",normalized:"repeat"},{native:"arreter",normalized:"halt"},{native:"defaut",normalized:"default"},{native:"jusqua",normalized:"until"},{native:"apres",normalized:"after"},{native:"journaliser",normalized:"log"},{native:"transmuter",normalized:"morph"},{native:"tant que",normalized:"while"}],fn=[{pattern:"millisecondes",suffix:"ms",length:13,caseInsensitive:!0},{pattern:"milliseconde",suffix:"ms",length:12,caseInsensitive:!0},{pattern:"secondes",suffix:"s",length:8,caseInsensitive:!0},{pattern:"seconde",suffix:"s",length:7,caseInsensitive:!0},{pattern:"minutes",suffix:"m",length:7,caseInsensitive:!0},{pattern:"minute",suffix:"m",length:6,caseInsensitive:!0},{pattern:"heures",suffix:"h",length:6,caseInsensitive:!0},{pattern:"heure",suffix:"h",length:5,caseInsensitive:!0}],Ae=class extends P{constructor(){super();this.language="fr";this.direction="ltr";this.initializeKeywordsFromProfile(F,un)}tokenize(e){let r=[],n=0;for(;n<e.length;){if(w(e[n])){n++;continue}if(C(e[n])){let a=this.tryEventModifier(e,n);if(a){r.push(a),n=a.position.end;continue}let l=this.trySelector(e,n);if(l){r.push(l),n=l.position.end;continue}}if(N(e[n])){let a=this.tryString(e,n);if(a){r.push(a),n=a.position.end;continue}}if(R(e,n)){let a=this.tryUrl(e,n);if(a){r.push(a),n=a.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let a=this.extractNumber(e,n);if(a){r.push(a),n=a.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}if(pn(e[n])){let a=this.extractWord(e,n);if(a){r.push(a),n=a.position.end;continue}}let s=this.tryOperator(e,n);if(s){r.push(s),n=s.position.end;continue}n++}return new E(r,"fr")}classifyToken(e){let r=e.toLowerCase();return vt.has(r)?"particle":this.isKeyword(r)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":"identifier"}extractWord(e,r){let n=r,o="";for(;n<e.length&&mn(e[n]);)o+=e[n++];if(!o)return null;let s=o.toLowerCase(),a=this.lookupKeyword(s);return a?v(o,"keyword",h(r,n),a.normalized):vt.has(s)?v(o,"particle",h(r,n)):v(o,"identifier",h(r,n))}extractNumber(e,r){return this.tryNumberWithTimeUnits(e,r,fn,{allowSign:!0,skipWhitespace:!0})}},ye=new Ae;M("fr",ye,F);var H={code:"de",name:"German",nativeName:"Deutsch",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:!1},references:{me:"ich",it:"es",you:"du",result:"Ergebnis",event:"Ereignis",target:"Ziel",body:"K\xF6rper"},possessive:{marker:"",markerPosition:"before-property",usePossessiveAdjectives:!0,specialForms:{me:"mein",it:"sein",you:"dein"},keywords:{mein:"me",meine:"me",meinen:"me",dein:"you",deine:"you",deinen:"you",sein:"it",seine:"it",seinen:"it"}},roleMarkers:{destination:{primary:"auf",alternatives:["zu","in"],position:"before"},source:{primary:"von",alternatives:["aus"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"mit",position:"before"}},keywords:{toggle:{primary:"umschalten",alternatives:["wechseln"],normalized:"toggle"},add:{primary:"hinzuf\xFCgen",normalized:"add"},remove:{primary:"entfernen",alternatives:["l\xF6schen"],normalized:"remove"},put:{primary:"setzen",alternatives:["stellen","platzieren"],normalized:"put"},append:{primary:"anh\xE4ngen",normalized:"append"},prepend:{primary:"voranstellen",normalized:"prepend"},take:{primary:"nehmen",normalized:"take"},make:{primary:"machen",alternatives:["erstellen","erzeugen"],normalized:"make"},clone:{primary:"klonen",alternatives:["kopieren"],normalized:"clone"},swap:{primary:"austauschen",alternatives:["tauschen","wechseln"],normalized:"swap"},morph:{primary:"verwandeln",alternatives:["transformieren"],normalized:"morph"},set:{primary:"festlegen",alternatives:["definieren"],normalized:"set"},get:{primary:"holen",alternatives:["bekommen"],normalized:"get"},increment:{primary:"erh\xF6hen",normalized:"increment"},decrement:{primary:"verringern",alternatives:["vermindern"],normalized:"decrement"},log:{primary:"protokollieren",alternatives:["ausgeben"],normalized:"log"},show:{primary:"zeigen",alternatives:["anzeigen"],normalized:"show"},hide:{primary:"verbergen",alternatives:["verstecken"],normalized:"hide"},transition:{primary:"\xFCbergang",alternatives:["animieren"],normalized:"transition"},on:{primary:"bei",alternatives:["wenn","auf"],normalized:"on"},trigger:{primary:"ausl\xF6sen",normalized:"trigger"},send:{primary:"senden",alternatives:["schicken"],normalized:"send"},focus:{primary:"fokussieren",normalized:"focus"},blur:{primary:"defokussieren",alternatives:["entfokussieren"],normalized:"blur"},go:{primary:"gehen",alternatives:["navigieren"],normalized:"go"},wait:{primary:"warten",normalized:"wait"},fetch:{primary:"abrufen",alternatives:["laden"],normalized:"fetch"},settle:{primary:"stabilisieren",normalized:"settle"},if:{primary:"wenn",alternatives:["falls"],normalized:"if"},when:{primary:"wenn",normalized:"when"},where:{primary:"wo",normalized:"where"},else:{primary:"sonst",alternatives:["ansonsten"],normalized:"else"},repeat:{primary:"wiederholen",normalized:"repeat"},for:{primary:"f\xFCr",normalized:"for"},while:{primary:"solange",alternatives:["w\xE4hrend"],normalized:"while"},continue:{primary:"fortfahren",alternatives:["weiter"],normalized:"continue"},halt:{primary:"anhalten",alternatives:["stoppen"],normalized:"halt"},throw:{primary:"werfen",normalized:"throw"},call:{primary:"aufrufen",normalized:"call"},return:{primary:"zur\xFCckgeben",normalized:"return"},then:{primary:"dann",alternatives:["danach","anschlie\xDFend"],normalized:"then"},and:{primary:"und",alternatives:["sowie","auch"],normalized:"and"},end:{primary:"ende",alternatives:["beenden","fertig"],normalized:"end"},js:{primary:"js",alternatives:["javascript"],normalized:"js"},async:{primary:"asynchron",normalized:"async"},tell:{primary:"sagen",normalized:"tell"},default:{primary:"standard",normalized:"default"},init:{primary:"initialisieren",normalized:"init"},behavior:{primary:"verhalten",normalized:"behavior"},install:{primary:"installieren",normalized:"install"},measure:{primary:"messen",normalized:"measure"},into:{primary:"hinein",normalized:"into"},before:{primary:"vor",normalized:"before"},after:{primary:"nach",normalized:"after"},until:{primary:"bis",normalized:"until"},event:{primary:"Ereignis",alternatives:["Event"],normalized:"event"},from:{primary:"von",alternatives:["aus"],normalized:"from"}},eventHandler:{keyword:{primary:"bei",alternatives:["auf"]},sourceMarker:{primary:"von",alternatives:["aus"],position:"before"},conditionalKeyword:{primary:"wenn",alternatives:["falls"]}}};var{isLetter:gn,isIdentifierChar:yn}=I(/[a-zA-ZäöüÄÖÜß]/),xt=new Set(["an","auf","aus","bei","durch","f\xFCr","fur","gegen","in","mit","nach","ohne","seit","\xFCber","uber","um","unter","von","vor","zu","zwischen","bis","gegen\xFCber","gegenuber","w\xE4hrend","wahrend","wegen","trotz","statt","innerhalb","au\xDFerhalb","ausserhalb"]),hn=[{native:"wahr",normalized:"true"},{native:"falsch",normalized:"false"},{native:"null",normalized:"null"},{native:"undefiniert",normalized:"undefined"},{native:"erste",normalized:"first"},{native:"erster",normalized:"first"},{native:"erstes",normalized:"first"},{native:"letzte",normalized:"last"},{native:"letzter",normalized:"last"},{native:"letztes",normalized:"last"},{native:"n\xE4chste",normalized:"next"},{native:"nachste",normalized:"next"},{native:"vorherige",normalized:"previous"},{native:"n\xE4chste",normalized:"closest"},{native:"eltern",normalized:"parent"},{native:"klick",normalized:"click"},{native:"click",normalized:"click"},{native:"eingabe",normalized:"input"},{native:"\xE4nderung",normalized:"change"},{native:"anderung",normalized:"change"},{native:"absenden",normalized:"submit"},{native:"taste unten",normalized:"keydown"},{native:"taste oben",normalized:"keyup"},{native:"maus dr\xFCber",normalized:"mouseover"},{native:"maus druber",normalized:"mouseover"},{native:"maus weg",normalized:"mouseout"},{native:"fokus",normalized:"focus"},{native:"unsch\xE4rfe",normalized:"blur"},{native:"unscharfe",normalized:"blur"},{native:"scrollen",normalized:"scroll"},{native:"meine",normalized:"my"},{native:"meinen",normalized:"my"},{native:"ergebnis",normalized:"result"},{native:"ziel",normalized:"target"},{native:"sekunde",normalized:"s"},{native:"sekunden",normalized:"s"},{native:"millisekunde",normalized:"ms"},{native:"millisekunden",normalized:"ms"},{native:"minute",normalized:"m"},{native:"minuten",normalized:"m"},{native:"stunde",normalized:"h"},{native:"stunden",normalized:"h"},{native:"hinzufugen",normalized:"add"},{native:"hinzufgen",normalized:"add"},{native:"loschen",normalized:"remove"},{native:"anhangen",normalized:"append"},{native:"erhohen",normalized:"increment"},{native:"ubergang",normalized:"transition"},{native:"auslosen",normalized:"trigger"},{native:"zuruckgeben",normalized:"return"},{native:"anschliessend",normalized:"then"},{native:"erh\xF6he",normalized:"increment"},{native:"erhohe",normalized:"increment"},{native:"verringere",normalized:"decrement"}],vn=[{pattern:"millisekunden",suffix:"ms",length:13,caseInsensitive:!0},{pattern:"millisekunde",suffix:"ms",length:12,caseInsensitive:!0},{pattern:"sekunden",suffix:"s",length:8,caseInsensitive:!0},{pattern:"sekunde",suffix:"s",length:7,caseInsensitive:!0},{pattern:"minuten",suffix:"m",length:7,caseInsensitive:!0},{pattern:"minute",suffix:"m",length:6,caseInsensitive:!0},{pattern:"stunden",suffix:"h",length:7,caseInsensitive:!0},{pattern:"stunde",suffix:"h",length:6,caseInsensitive:!0}],Ie=class extends P{constructor(){super();this.language="de";this.direction="ltr";this.initializeKeywordsFromProfile(H,hn)}tokenize(e){let r=[],n=0;for(;n<e.length;){if(w(e[n])){n++;continue}if(C(e[n])){let a=this.tryEventModifier(e,n);if(a){r.push(a),n=a.position.end;continue}let l=this.trySelector(e,n);if(l){r.push(l),n=l.position.end;continue}}if(N(e[n])){let a=this.tryString(e,n);if(a){r.push(a),n=a.position.end;continue}}if(R(e,n)){let a=this.tryUrl(e,n);if(a){r.push(a),n=a.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let a=this.extractNumber(e,n);if(a){r.push(a),n=a.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}if(gn(e[n])){let a=this.extractWord(e,n);if(a){r.push(a),n=a.position.end;continue}}let s=this.tryOperator(e,n);if(s){r.push(s),n=s.position.end;continue}n++}return new E(r,"de")}classifyToken(e){let r=e.toLowerCase();return xt.has(r)?"particle":this.isKeyword(r)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":"identifier"}extractWord(e,r){let n=r,o="";for(;n<e.length&&yn(e[n]);)o+=e[n++];if(!o)return null;let s=o.toLowerCase(),a=this.lookupKeyword(s);return a?v(o,"keyword",h(r,n),a.normalized):xt.has(s)?v(o,"particle",h(r,n)):v(o,"identifier",h(r,n))}extractNumber(e,r){return this.tryNumberWithTimeUnits(e,r,vn,{allowSign:!0,skipWhitespace:!0})}},he=new Ie;M("de",he,H);function St(i){return Qe(i)}function ve(i,t){return Ye(i,t)}function xe(){return ce()}function W(i){let t="complex";return i.startsWith("#")&&!i.includes(" ")?t="id":i.startsWith(".")&&!i.includes(" ")?t="class":i.startsWith("[")&&i.endsWith("]")?t="attribute":/^[a-z][a-z0-9]*$/i.test(i)&&(t="element"),{type:"selector",value:i,selectorKind:t}}function z(i,t){let e={type:"literal",value:i};return t!==void 0?{type:"literal",value:i,dataType:t}:e}function V(i){return{type:"reference",value:i}}function X(i,t){return{type:"property-path",object:i,property:t}}function B(i,t,e){let r={kind:"command",action:i,roles:new Map(Object.entries(t))};return e!==void 0?{...r,metadata:e}:r}function Q(i,t,e,r,n){let o=new Map;o.set("event",i);let s={kind:"event-handler",action:"on",roles:o,body:t};return e!==void 0&&(s.eventModifiers=e),r!==void 0&&(s.metadata=r),n!==void 0&&n.length>0&&(s.parameterNames=n),s}function Tt(i,t="then",e){let r={kind:"compound",action:"compound",roles:new Map,statements:i,chainType:t};return e!==void 0&&(r.metadata=e),r}function Ve(i,t){return!t||t.length===0||t.includes(i)||t.includes("expression")?!0:i==="property-path"?t.some(e=>["selector","reference","expression"].includes(e)):!1}function bt(i,t){return i.possessive?.keywords?.[t]}var O=class O{constructor(){this.stemMatchCount=0;this.totalKeywordMatches=0}matchPattern(t,e){let r=t.mark(),n=new Map;if(this.currentProfile=_(e.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(t,e.template.tokens,n))return t.reset(r),null;let s=this.calculateConfidence(e,n);return this.applyExtractionRules(e,n),{pattern:e,captured:n,consumedTokens:t.position()-r.position,confidence:s}}matchBest(t,e){let r=[];for(let o of e){let s=t.mark(),a=this.matchPattern(t,o);a&&r.push(a),t.reset(s)}if(r.length===0)return null;r.sort((o,s)=>{let a=s.pattern.priority-o.pattern.priority;return a!==0?a:s.confidence-o.confidence});let n=r[0];return this.matchPattern(t,n.pattern),n}matchTokenSequence(t,e,r){if(this.currentProfile?.code==="ar")for(;t.peek()?.kind==="conjunction";)t.advance();for(let n of e)if(!this.matchPatternToken(t,n,r)){if(this.isOptional(n))continue;return!1}return!0}matchPatternToken(t,e,r){switch(e.type){case"literal":return this.matchLiteralToken(t,e);case"role":return this.matchRoleToken(t,e,r);case"group":return this.matchGroupToken(t,e,r);default:return!1}}matchLiteralToken(t,e){let r=t.peek();if(!r)return!1;let n=this.getMatchType(r,e.value);if(n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,t.advance(),!0;if(e.alternatives)for(let o of e.alternatives){let s=this.getMatchType(r,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,t.advance(),!0}return!1}matchRoleToken(t,e,r){this.skipNoiseWords(t);let n=t.peek();if(!n)return e.optional||!1;let o=this.tryMatchPossessiveExpression(t);if(o)return e.expectedTypes&&e.expectedTypes.length>0&&!e.expectedTypes.includes(o.type)&&!e.expectedTypes.includes("expression")?e.optional||!1:(r.set(e.role,o),!0);let s=this.tryMatchMethodCallExpression(t);if(s)return e.expectedTypes&&e.expectedTypes.length>0&&!e.expectedTypes.includes(s.type)&&!e.expectedTypes.includes("expression")?e.optional||!1:(r.set(e.role,s),!0);let a=this.tryMatchPossessiveSelectorExpression(t);if(a)return e.expectedTypes&&e.expectedTypes.length>0&&!Ve(a.type,e.expectedTypes)?e.optional||!1:(r.set(e.role,a),!0);let l=this.tryMatchPropertyAccessExpression(t);if(l)return e.expectedTypes&&e.expectedTypes.length>0&&!e.expectedTypes.includes(l.type)&&!e.expectedTypes.includes("expression")?e.optional||!1:(r.set(e.role,l),!0);let c=this.tryMatchSelectorPropertyExpression(t);if(c)return e.expectedTypes&&e.expectedTypes.length>0&&!Ve(c.type,e.expectedTypes)?e.optional||!1:(r.set(e.role,c),!0);let p=this.tokenToSemanticValue(n);return!p||e.expectedTypes&&e.expectedTypes.length>0&&!e.expectedTypes.includes(p.type)?e.optional||!1:(r.set(e.role,p),t.advance(),!0)}tryMatchPossessiveExpression(t){let e=t.peek();if(!e||!this.currentProfile)return null;let r=(e.normalized||e.value).toLowerCase(),n=bt(this.currentProfile,r);if(!n)return null;let o=t.mark();t.advance();let s=t.peek();return s&&(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*"))?(t.advance(),X(V(n),s.value)):(t.reset(o),null)}isStructuralKeyword(t){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(t.toLowerCase())}tryMatchMethodCallExpression(t){let e=t.peek();if(!e||e.kind!=="selector")return null;let r=t.mark();t.advance();let n=t.peek();if(!n||n.kind!=="operator"||n.value!==".")return t.reset(r),null;t.advance();let o=t.peek();if(!o||o.kind!=="identifier")return t.reset(r),null;t.advance();let s=t.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return t.reset(r),null;t.advance();let a=[];for(;!t.isAtEnd()&&a.length<O.MAX_METHOD_ARGS;){let c=t.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){t.advance();break}if(c.kind==="punctuation"&&c.value===","){t.advance();continue}a.push(c.value),t.advance()}return{type:"expression",raw:`${e.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(t){let e=t.peek();if(!e||e.kind!=="identifier"&&e.kind!=="keyword")return null;let r=t.mark();t.advance();let n=t.peek();if(!n||n.kind!=="operator"||n.value!==".")return t.reset(r),null;t.advance();let o=t.peek();if(!o||o.kind!=="identifier")return t.reset(r),null;t.advance();let s=`${e.value}.${o.value}`,a=1;for(;!t.isAtEnd()&&a<O.MAX_PROPERTY_DEPTH;){let c=t.peek();if(!c||c.kind!=="operator"||c.value!==".")break;t.advance();let p=t.peek();if(!p||p.kind!=="identifier")break;t.advance(),s+=`.${p.value}`,a++}let l=t.peek();if(l&&l.kind==="punctuation"&&l.value==="("){t.advance();let c=[],p=0;for(;!t.isAtEnd()&&c.length<O.MAX_METHOD_ARGS;){let x=t.peek();if(!x)break;if(x.kind==="punctuation"&&x.value===")"){if(p===0){t.advance();break}p--}if(x.kind==="punctuation"&&x.value==="("&&p++,x.kind==="punctuation"&&x.value===","){t.advance();continue}c.push(x.value),t.advance()}return{type:"expression",raw:`${s}(${c.join(", ")})`}}return{type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(t){let e=t.peek();if(!e||e.kind!=="selector")return null;let r=t.mark();t.advance();let n=t.peek();if(!n||n.kind!=="punctuation"||n.value!=="'s")return t.reset(r),null;t.advance();let o=t.peek();return!o||o.kind!=="selector"&&o.kind!=="identifier"?(t.reset(r),null):(t.advance(),X(W(e.value),o.value))}tryMatchSelectorPropertyExpression(t){let e=t.peek();if(!e||e.kind!=="selector"||!e.value.startsWith("#"))return null;let r=t.mark();t.advance();let n=t.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return t.reset(r),null;let o=t.peek(1);o&&o.kind,t.advance();let s=n.value.slice(1);return X(W(e.value),s)}matchGroupToken(t,e,r){let n=t.mark(),o=new Set(r.keys());if(!this.matchTokenSequence(t,e.tokens,r)){t.reset(n);for(let a of r.keys())o.has(a)||r.delete(a);return e.optional||!1}return!0}getMatchType(t,e){return t.value===e?"exact":t.normalized===e?"normalized":t.stem===e&&t.stemConfidence!==void 0&&t.stemConfidence>=.7?"stem":t.kind==="keyword"&&t.value.toLowerCase()===e.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(t){switch(t.kind){case"selector":return W(t.value);case"literal":return this.parseLiteralValue(t.value);case"keyword":let e=(t.normalized||t.value).toLowerCase();return["me","you","it","result","event","target","body"].includes(e)?V(e):z(t.normalized||t.value);case"identifier":if(t.value.startsWith(":"))return V(t.value);let r=t.value.toLowerCase();return["me","you","it","result","event","target","body"].includes(r)?V(r):{type:"expression",raw:t.value};case"url":return z(t.value,"string");default:return null}}parseLiteralValue(t){if(t.startsWith('"')||t.startsWith("'")||t.startsWith("`")||t.startsWith("\u300C")){let n=t.slice(1,-1);return z(n,"string")}if(t==="true")return z(!0,"boolean");if(t==="false")return z(!1,"boolean");let e=t.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let n=parseFloat(e[1]);return e[2]?z(t,"duration"):z(n,"number")}let r=parseFloat(t);return isNaN(r)?z(t,"string"):z(r,"number")}applyExtractionRules(t,e){for(let[r,n]of Object.entries(t.extraction))!e.has(r)&&n.default&&e.set(r,n.default)}isOptional(t){return t.optional===!0}calculateConfidence(t,e){let r=0,n=0,o=c=>t.extraction?.[c]?.default!==void 0;for(let c of t.template.tokens)if(c.type==="role")n+=1,e.has(c.role)&&(r+=1);else if(c.type==="group"){for(let p of c.tokens)if(p.type==="role"){let S=o(p.role),x=.8;n+=x,e.has(p.role)?r+=x:S&&(r+=x*.6)}}let s=n>0?r/n:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-c)}let a=this.calculateVSOConfidenceBoost(t);s=Math.min(1,s+a);let l=this.arabicPrepositionDisambiguation(t,e);return s=Math.max(0,Math.min(1,s+l)),s}calculateVSOConfidenceBoost(t){if(t.language!=="ar")return 0;let e=t.template.tokens[0];if(!e||e.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(e.value))return .15;if(e.alternatives){for(let n of e.alternatives)if(r.has(n))return .15}return 0}arabicPrepositionDisambiguation(t,e){if(t.language!=="ar")return 0;let r=0,n={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[o,s]of e.entries()){let a=n[o];if(!a||a.length===0)continue;let l=s.metadata;if(l&&typeof l.prepositionValue=="string"){let c=l.prepositionValue;a.includes(c)?r+=.1:r-=.1}}return Math.max(-.1,Math.min(.1,r))}skipNoiseWords(t){let e=t.peek();if(!e)return;let r=e.value.toLowerCase();if(O.ENGLISH_NOISE_WORDS.has(r)){let n=t.mark();t.advance();let o=t.peek();if(o&&o.kind==="selector")return;t.reset(n)}r==="class"&&t.advance()}extractEventModifiers(t){let e={},r=!1;for(;!t.isAtEnd();){let n=t.peek();if(!n||n.kind!=="event-modifier")break;let o=n.metadata;if(!o)break;switch(r=!0,o.modifierName){case"once":e.once=!0;break;case"debounce":typeof o.value=="number"&&(e.debounce=o.value);break;case"throttle":typeof o.value=="number"&&(e.throttle=o.value);break;case"queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(e.queue=o.value);break}t.advance()}return r?e:void 0}};O.MAX_PROPERTY_DEPTH=10,O.MAX_METHOD_ARGS=20,O.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var te=O,j=new te;var Se=class{render(t,e){if(t.kind==="compound")return this.renderCompound(t,e);let r=Je(e,t.action);if(r.length===0)return this.renderExplicit(t);let n=this.findBestPattern(t,r);return n?this.renderWithPattern(t,n):this.renderExplicit(t)}renderCompound(t,e){let r=t.statements.map(o=>this.render(o,e)),n=this.getChainWord(t.chainType,e);return r.join(` ${n} `)}getChainWord(t,e){let r=_(e);return r?.keywords?r.keywords[t]?.primary??t:t}renderExplicit(t){if(t.kind==="compound"){let r=t;return r.statements.map(o=>this.renderExplicit(o)).join(` ${r.chainType} `)}let e=[t.action];for(let[r,n]of t.roles)e.push(`${r}:${this.valueToString(n)}`);if(t.kind==="event-handler"){let r=t;if(r.body&&r.body.length>0){let n=r.body.map(o=>this.renderExplicit(o));e.push(`body:${n.join(" ")}`)}}return`[${e.join(" ")}]`}supportedLanguages(){return xe()}findBestPattern(t,e){let r=e.map(n=>{let o=n.priority;for(let s of n.template.tokens)s.type==="role"&&(t.roles.has(s.role)?o+=10:s.optional||(o-=50));return n.language==="en"&&((n.id.includes("standard")||n.id.includes("en-source"))&&(o+=20),(n.id.includes("-when")||n.id.includes("-if")||n.id.includes("-upon"))&&(o-=15)),{pattern:n,score:o}});return r.sort((n,o)=>o.score-n.score),r.length>0?r[0].pattern:null}renderWithPattern(t,e){let r=[],n=e.language;for(let o of e.template.tokens){let s=this.renderPatternToken(o,t,n);s!==null&&r.push(s)}if(t.kind==="event-handler"){let o=t;if(o.body&&o.body.length>0){let s=o.body.map(a=>this.render(a,n));r.push(s.join(" "))}}return r.join(" ")}renderPatternToken(t,e,r){switch(t.type){case"literal":return t.value;case"role":{let n=e.roles.get(t.role);return n?this.valueToNaturalString(n,r):(t.optional,null)}case"group":{if(!t.tokens.filter(s=>s.type==="role"&&!s.optional).every(s=>e.roles.has(s.role))&&t.optional)return null;if(t.optional&&t.tokens.find(a=>a.type==="role"&&a.role==="destination")){let a=e.roles.get("destination");if(a?.type==="reference"&&a.value==="me")return null}let o=[];for(let s of t.tokens){let a=this.renderPatternToken(s,e,r);a!==null&&o.push(a)}return o.length>0?o.join(" "):null}default:return null}}valueToString(t){switch(t.type){case"literal":return typeof t.value=="string"?t.dataType==="string"||/\s/.test(t.value)?`"${t.value}"`:t.value:String(t.value);case"selector":return t.value;case"reference":return t.value;case"property-path":return`${this.valueToString(t.object)}'s ${t.property}`;case"expression":return t.raw}}valueToNaturalString(t,e="en"){switch(t.type){case"literal":return typeof t.value=="string"&&t.dataType==="string"?`"${t.value}"`:String(t.value);case"selector":return t.value;case"reference":return this.renderReference(t,e);case"property-path":return this.renderPropertyPath(t,e);case"expression":return t.raw}}renderReference(t,e){let r=_(e);return r?.references?r.references[t.value]??t.value:t.value}renderPropertyPath(t,e){let r=_(e),n=t.property,o=t.object.type==="reference"?t.object.value:null;if(r?.possessive?.specialForms&&o){let a=r.possessive.specialForms[o];if(a){let{markerPosition:l,usePossessiveAdjectives:c}=r.possessive;return c&&l==="after-object"?`${n} ${a}`:`${a} ${n}`}}let s=this.valueToNaturalString(t.object,e);if(r?.possessive){let{marker:a,markerPosition:l,usePossessiveAdjectives:c}=r.possessive;if(c&&o&&l==="after-object")return`${n} ${s}`;if(a)switch(l){case"between":return r.usesSpaces?`${s}${a} ${n}`:`${s}${a}${n}`;case"after-object":return`${s}${a} ${n}`;case"before-property":return`${s} ${a} ${n}`}}return e==="en"||!r?.possessive?s==="me"?`my ${n}`:s==="it"?`its ${n}`:`${s}'s ${n}`:`${s} ${n}`}},Oe=new Se;function re(i,t){return Oe.render(i,t)}function ne(i){return Oe.renderExplicit(i)}function K(i){let t=i.trim();if(!t.startsWith("[")||!t.endsWith("]"))throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");let e=t.slice(1,-1).trim();if(!e)throw new Error("Empty explicit statement");let r=xn(e);if(r.length===0)throw new Error("No command specified in explicit statement");let n=r[0].toLowerCase(),o=new Map;for(let a=1;a<r.length;a++){let l=r[a],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=Tn(l,c+1),m=l.slice(c+1,g+1);o.set(p,{type:"expression",raw:m});continue}let x=Sn(S);o.set(p,x)}if(n==="on"){let a=o.get("event");if(!a)throw new Error("Event handler requires event role: [on event:click ...]");let l=o.get("body"),c=[];return l&&l.type==="expression"&&c.push(K(l.raw)),o.delete("body"),Q(a,c,void 0,{sourceLanguage:"explicit"})}let s={};for(let[a,l]of o)s[a]=l;return B(n,s,{sourceLanguage:"explicit"})}function xn(i){let t=[],e="",r=!1,n="",o=0;for(let s=0;s<i.length;s++){let a=i[s];if(r){e+=a,a===n&&i[s-1]!=="\\"&&(r=!1);continue}if(a==='"'||a==="'"){r=!0,n=a,e+=a;continue}if(a==="["){o++,e+=a;continue}if(a==="]"){o--,e+=a;continue}if(a===" "&&o===0){e&&(t.push(e),e="");continue}e+=a}return e&&t.push(e),t}function Sn(i){if(i.startsWith("#")||i.startsWith(".")||i.startsWith("[")||i.startsWith("@")||i.startsWith("*"))return W(i);if(i.startsWith('"')||i.startsWith("'")){let e=i.slice(1,-1);return z(e,"string")}if(i==="true")return z(!0,"boolean");if(i==="false")return z(!1,"boolean");if(["me","you","it","result","event","target","body"].includes(i.toLowerCase()))return V(i.toLowerCase());let t=i.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let e=parseFloat(t[1]);return t[2]?z(i,"duration"):z(e,"number")}return z(i,"string")}function Tn(i,t){let e=0;for(let r=t;r<i.length;r++)if(i[r]==="[")e++;else if(i[r]==="]"&&(e--,e===0))return r;return i.length-1}function Z(i){let t=i.trim();return t.startsWith("[")&&t.endsWith("]")}var Te=class{parse(t,e){let r=ve(t,e),n=A(e);if(n.length===0)throw new Error(`No patterns available for language: ${e}`);let o=[...n].sort((p,S)=>S.priority-p.priority),s=o.filter(p=>p.command==="on"),a=j.matchBest(r,s);if(a)return this.buildEventHandler(a,r,e);let l=o.filter(p=>p.command!=="on"),c=j.matchBest(r,l);if(c)return this.buildCommand(c,e);throw new Error(`Could not parse input in ${e}: ${t}`)}canParse(t,e){try{return this.parse(t,e),!0}catch{return!1}}supportedLanguages(){return xe()}buildCommand(t,e){if(!t)throw new Error("No match to build command from");let r={};for(let[n,o]of t.captured)r[n]=o;return B(t.pattern.command,r,{sourceLanguage:e,patternId:t.pattern.id})}buildEventHandler(t,e,r){if(!t)throw new Error("No match to build event handler from");let n=t.captured.get("event");if(!n)throw new Error("Event handler pattern matched but no event captured");let o=j.extractEventModifiers(e),s,a=t.captured.get("action");if(a&&a.type==="literal"){let l=a.value,c={};for(let[x,g]of t.captured)x!=="event"&&x!=="action"&&x!=="continues"&&(c[x]=g);let p=B(l,c,{sourceLanguage:r,patternId:t.pattern.id}),S=t.captured.get("continues");if(S&&S.type==="literal"&&S.value==="then"){let x=A(r).filter(u=>u.command!=="on").sort((u,y)=>y.priority-u.priority),g=A(r).filter(u=>u.id.startsWith("grammar-")&&u.id.includes("-continuation")).sort((u,y)=>y.priority-u.priority),m=this.parseBodyWithGrammarPatterns(e,x,g,r);m.length>0?s=[p,...m]:s=[p]}else s=[p]}else{let l=A(r).filter(c=>c.command!=="on").sort((c,p)=>p.priority-c.priority);s=this.parseBodyWithClauses(e,l,r)}return Q(n,s,o,{sourceLanguage:r,patternId:t.pattern.id})}parseBodyWithClauses(t,e,r){let n=[],o=[];for(;!t.isAtEnd();){let s=t.peek();if(!s)break;let a=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,r),l=s.kind==="keyword"&&this.isEndKeyword(s.value,r);if(a){if(o.length>0){let c=this.parseClause(o,e,r);n.push(...c),o.length=0}t.advance();continue}if(l){if(o.length>0){let c=this.parseClause(o,e,r);n.push(...c)}t.advance();break}o.push(s),t.advance()}if(o.length>0){let s=this.parseClause(o,e,r);n.push(...s)}return n.length>1?[Tt(n,"then",{sourceLanguage:r})]:n}parseClause(t,e,r){if(t.length===0)return[];let n=new E(t,r),o=[];for(;!n.isAtEnd();){let s=j.matchBest(n,e);s?o.push(this.buildCommand(s,r)):n.advance()}return o}parseBodyWithGrammarPatterns(t,e,r,n){let o=[];for(;!t.isAtEnd();){let s=t.peek();if(s&&this.isThenKeyword(s.value,n)){t.advance();continue}if(s&&this.isEndKeyword(s.value,n)){t.advance();break}let a=!1;if(r.length>0){let l=j.matchBest(t,r);if(l){let c=l.pattern.command,p={};for(let[g,m]of l.captured)g!=="event"&&g!=="action"&&g!=="continues"&&(p[g]=m);let S=B(c,p,{sourceLanguage:n,patternId:l.pattern.id});o.push(S),a=!0;let x=l.captured.get("continues");if(x&&x.type==="literal"&&x.value==="then")continue}}if(!a){let l=j.matchBest(t,e);l&&(o.push(this.buildCommand(l,n)),a=!0)}a||t.advance()}return o}isThenKeyword(t,e){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[e]||r.en).has(t.toLowerCase())}isEndKeyword(t,e){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[e]||r.en).has(t.toLowerCase())}},_e=new Te;function Y(i,t){return _e.parse(i,t)}function qe(i,t){return _e.canParse(i,t)}function We(i,t){if(Z(i))return i;let e=Y(i,t);return ne(e)}function Be(i,t){let e=K(i);return re(e,t)}function je(i,t){return Z(i)?K(i):Y(i,t)}var bn=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),zn=new Set(["and","or","not","no"]),kn=new Set(["true","false","null","undefined"]),wn=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function zt(i){let t=[],e=0,r=1,n=1;function o(){if(t.length===0)return!0;let m=t[t.length-1];return["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(m.type)}function s(m=0){return i[e+m]??""}function a(){let m=i[e];return e++,m===`
|
|
2
|
-
`?(r++,n=1):n++,m}function l(){for(;e<i.length&&/\s/.test(i[e]);)a()}function c(m){let u="";for(;e<i.length&&m(i[e]);)u+=a();return u}function p(m){let u=m;for(a();e<i.length&&i[e]!==m;)i[e]==="\\"&&e+1<i.length&&(u+=a()),u+=a();return e<i.length&&(u+=a()),u}function S(){let m="`";for(a();e<i.length&&i[e]!=="`";)i[e]==="\\"&&e+1<i.length&&(m+=a()),m+=a();return e<i.length&&(m+=a()),m}function x(){let m="<";for(a();e<i.length&&(m+=a(),!m.endsWith("/>")););return m}function g(m,u,y){return{type:m,value:u,start:y,end:e,line:r,column:n-u.length}}for(;e<i.length&&(l(),!(e>=i.length));){let m=e,u=s();if(u==="'"&&s(1)==="s"&&!/\w/.test(s(2))){a(),a(),t.push(g("POSSESSIVE","'s",m));continue}if(u==='"'||u==="'"){let y=p(u);t.push(g("STRING",y,m));continue}if(u==="`"){let y=S();t.push(g("TEMPLATE_LITERAL",y,m));continue}if(u==="<"&&/[a-zA-Z.#\[]/.test(s(1))){let y=x();t.push(g("QUERY_SELECTOR",y,m));continue}if(u==="#"&&o()){a();let y=c(k=>/[\w-]/.test(k));t.push(g("ID_SELECTOR","#"+y,m));continue}if(u==="."&&/[a-zA-Z_-]/.test(s(1))&&o()){a();let y=c(k=>/[\w-]/.test(k));t.push(g("CLASS_SELECTOR","."+y,m));continue}if(u==="["&&o()){let y=s(1);if(y==="@"||/[a-zA-Z]/.test(y)){let k="";for(k+=a();e<i.length&&i[e]!=="]";)i[e]==='"'||i[e]==="'"?k+=p(i[e]):k+=a();e<i.length&&(k+=a()),t.push(g("ATTRIBUTE_SELECTOR",k,m));continue}}if(u==="["){a(),t.push(g("LBRACKET","[",m));continue}if(u==="]"){a(),t.push(g("RBRACKET","]",m));continue}if(/\d/.test(u)){let y=c(ze=>/[\d.]/.test(ze)),k=e,se=c(ze=>/[a-zA-Z]/.test(ze));wn.has(se)?t.push(g("TIME_EXPRESSION",y+se,m)):(e=k,t.push(g("NUMBER",y,m)));continue}if(u==="("){a(),t.push(g("LPAREN","(",m));continue}if(u===")"){a(),t.push(g("RPAREN",")",m));continue}if(u==="{"){a(),t.push(g("LBRACE","{",m));continue}if(u==="}"){a(),t.push(g("RBRACE","}",m));continue}if(u===","){a(),t.push(g("COMMA",",",m));continue}if(u===":"){a(),t.push(g("COLON",":",m));continue}if(u==="."){a(),t.push(g("DOT",".",m));continue}if(u==="+"||u==="-"||u==="*"||u==="/"||u==="%"){a(),t.push(g("OPERATOR",u,m));continue}if(u==="="||u==="!"||u==="<"||u===">"){let y=a();s()==="="&&(y+=a()),t.push(g("COMPARISON",y,m));continue}if(/[a-zA-Z_$]/.test(u)){let y=c(se=>/[\w$]/.test(se)),k=y.toLowerCase();bn.has(k)?t.push(g("CONTEXT_VAR",y,m)):zn.has(k)?t.push(g("LOGICAL",y,m)):kn.has(k)?t.push(g("BOOLEAN",y,m)):t.push(g("IDENTIFIER",y,m));continue}a()}return t.push(g("EOF","",e)),t}var be=class{constructor(){this.tokens=[];this.current=0}parse(t){try{return this.tokens=zt(t),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(e){return{success:!1,error:e instanceof Error?e.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(t){return this.peek().type===t}checkValue(t){return this.peek().value.toLowerCase()===t.toLowerCase()}match(...t){for(let e of t)if(this.check(e))return this.advance(),!0;return!1}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.checkValue("or");){let e=this.advance().value,r=this.parseAnd();t=this.createBinaryExpression(e,t,r)}return t}parseAnd(){let t=this.parseEquality();for(;this.checkValue("and");){let e=this.advance().value,r=this.parseEquality();t=this.createBinaryExpression(e,t,r)}return t}parseEquality(){let t=this.parseComparison();for(;this.match("COMPARISON")||this.checkValue("is")||this.checkValue("matches")||this.checkValue("contains")||this.checkValue("in");){let e=this.previous().value,r=this.parseComparison();t=this.createBinaryExpression(e,t,r)}return t}parseComparison(){let t=this.parseAddition();for(;this.check("COMPARISON");){let e=this.advance().value,r=this.parseAddition();t=this.createBinaryExpression(e,t,r)}return t}parseAddition(){let t=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let e=this.advance().value,r=this.parseMultiplication();t=this.createBinaryExpression(e,t,r)}return t}parseMultiplication(){let t=this.parseUnary();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%";){let e=this.advance().value,r=this.parseUnary();t=this.createBinaryExpression(e,t,r)}return t}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let t=this.advance().value,e=this.parseUnary();return this.createUnaryExpression(t,e)}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance().value;t=this.createPropertyAccess(t,e)}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance().value;t=this.createPossessiveExpression(t,e)}else break;else if(this.match("LPAREN")){let e=this.parseArguments();t=this.createCallExpression(t,e)}else if(this.match("LBRACKET")){let e=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");t=this.createPropertyAccess(t,e)}else break;return t}parsePrimary(){let t=this.peek();if(this.match("NUMBER"))return this.createLiteral(parseFloat(t.value),"number",t);if(this.match("STRING")){let e=t.value.slice(1,-1);return this.createLiteral(e,"string",t)}if(this.match("BOOLEAN")){let e=t.value==="true"?!0:t.value==="false"?!1:t.value==="null"?null:void 0;return this.createLiteral(e,t.value,t)}if(this.match("TEMPLATE_LITERAL"))return{type:"templateLiteral",value:t.value,start:t.start,end:t.end,line:t.line,column:t.column};if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(t);if(this.match("ID_SELECTOR"))return this.createSelector(t.value,"id",t);if(this.match("CLASS_SELECTOR"))return this.createSelector(t.value,"class",t);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(t.value,"attribute",t);if(this.match("QUERY_SELECTOR")){let e=t.value.slice(1,-2);return this.createSelector(e,"query",t)}if(this.match("CONTEXT_VAR"))return this.createContextReference(t.value,t);if(this.match("IDENTIFIER"))return this.createIdentifier(t.value,t);if(this.match("LPAREN")){let e=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return e}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${t.value}`)}parseArguments(){let t=[];if(!this.check("RPAREN"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return t}parseArrayLiteral(){let t=[],e=this.previous().start;if(!this.check("RBRACKET"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return{type:"arrayLiteral",elements:t,start:e,end:this.previous().end}}parseObjectLiteral(){let t=[],e=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 n=this.parseExpression();t.push({key:r,value:n})}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return{type:"objectLiteral",properties:t.map(r=>({type:"objectProperty",key:r.key,value:r.value})),start:e,end:this.previous().end}}parseTimeExpression(t){let e=t.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!e)throw new Error(`Invalid time expression: ${t.value}`);let r=parseFloat(e[1]),n=e[2].toLowerCase();return{type:"timeExpression",value:r,unit:n,raw:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createLiteral(t,e,r){return{type:"literal",value:t,dataType:e,raw:r.value,start:r.start,end:r.end,line:r.line,column:r.column}}createSelector(t,e,r){return{type:"selector",value:t,selector:t,selectorType:e,start:r.start,end:r.end,line:r.line,column:r.column}}createContextReference(t,e){return{type:"contextReference",contextType:t,name:e.value,start:e.start,end:e.end,line:e.line,column:e.column}}createIdentifier(t,e){return{type:"identifier",name:t,start:e.start,end:e.end,line:e.line,column:e.column}}createPropertyAccess(t,e){return{type:"propertyAccess",object:t,property:typeof e=="string"?e:e.name??"",start:t.start,end:this.previous().end}}createPossessiveExpression(t,e){return{type:"possessiveExpression",object:t,property:e,start:t.start,end:this.previous().end}}createBinaryExpression(t,e,r){return{type:"binaryExpression",operator:t,left:e,right:r,start:e.start,end:r.end}}createUnaryExpression(t,e){return{type:"unaryExpression",operator:t,operand:e,prefix:!0,start:this.previous().start,end:e.end}}createCallExpression(t,e){return{type:"callExpression",callee:t,arguments:e,start:t.start,end:this.previous().end}}};function Ke(i){return new be().parse(i)}function L(i,t){switch(i.type){case"literal":return En(i);case"selector":return Pn(i,t);case"reference":return Cn(i);case"property-path":return Nn(i,t);case"expression":return Rn(i);default:let e=i;throw new Error(`Unknown semantic value type: ${e.type}`)}}function En(i){let t={type:"literal",value:i.value};return i.dataType?{...t,dataType:i.dataType}:t}function Pn(i,t){return t&&i.value.startsWith("*")&&/^[a-zA-Z-]/.test(i.value.slice(1))&&t.push(`Converted '${i.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:i.value,selector:i.value,selectorType:i.selectorKind}}function Cn(i){return{type:"contextReference",contextType:i.value,name:i.value}}function Nn(i,t){return{type:"propertyAccess",object:L(i.object,t),property:i.property}}function Rn(i){let t=Ke(i.raw);return!t.success||!t.node?{type:"identifier",name:i.raw}:t.node}function kt(i,t){return i.roles.get(t)}function d(i,t,e){let r=kt(i,t);return r?L(r,e):void 0}function f(i,t=[],e,r={}){let n={type:"command",name:i,args:t};return e&&Object.keys(e).length>0&&(n.modifiers=e),r.isBlocking&&(n.isBlocking=r.isBlocking),r.implicitTarget&&(n.implicitTarget=r.implicitTarget),n}var Ln={action:"toggle",toAST(i,t){let e=d(i,"patient"),r=d(i,"destination"),n=d(i,"duration"),o=e?[e]:[],s={};return r&&(s.on=r),n&&(s.for=n),f("toggle",o,s)}},Mn={action:"add",toAST(i,t){let e=d(i,"patient"),r=d(i,"destination"),n=e?[e]:[],o={};return r&&(o.to=r),f("add",n,o)}},An={action:"remove",toAST(i,t){let e=d(i,"patient"),r=d(i,"source"),n=e?[e]:[],o={};return r&&(o.from=r),f("remove",n,o)}},In={action:"set",toAST(i,t){let e=d(i,"destination"),r=d(i,"patient"),n=[],o={};return e&&n.push(e),r&&(o.to=r),f("set",n,o)}},Vn={action:"show",toAST(i,t){let e=d(i,"destination"),r=d(i,"patient"),n=d(i,"duration"),o=[],s={},a=e??r;return a&&o.push(a),n&&(s.with=n),f("show",o,s)}},On={action:"hide",toAST(i,t){let e=d(i,"destination"),r=d(i,"patient"),n=d(i,"duration"),o=[],s={},a=e??r;return a&&o.push(a),n&&(s.with=n),f("hide",o,s)}},_n={action:"increment",toAST(i,t){let e=d(i,"destination"),r=d(i,"patient"),n=d(i,"quantity"),o=[],s={},a=e??r;return a&&o.push(a),n&&(s.by=n),f("increment",o,s)}},qn={action:"decrement",toAST(i,t){let e=d(i,"destination"),r=d(i,"patient"),n=d(i,"quantity"),o=[],s={},a=e??r;return a&&o.push(a),n&&(s.by=n),f("decrement",o,s)}},Wn={action:"wait",toAST(i,t){let e=d(i,"duration");return f("wait",e?[e]:[],void 0,{isBlocking:!0})}},Bn={action:"log",toAST(i,t){let e=d(i,"patient"),r=[];return e&&r.push(e),f("log",r)}},jn={action:"put",toAST(i,t){let e=d(i,"patient"),r=d(i,"destination"),n=kt(i,"method"),o=e?[e]:[],s={};if(r){let a=n?.type==="literal"?String(n.value):"into";s[a]=r}return f("put",o,s)}},Kn={action:"fetch",toAST(i,t){let e=d(i,"source"),r=d(i,"method"),n=d(i,"responseType"),o=d(i,"patient"),s=e?[e]:[],a={};return r&&(a.with=r),n&&(a.as=n),o&&(a.body=o),f("fetch",s,a,{isBlocking:!0})}},Un={action:"append",toAST(i,t){let e=d(i,"patient"),r=d(i,"destination"),n=e?[e]:[],o={};return r&&(o.to=r),f("append",n,o)}},Gn={action:"prepend",toAST(i,t){let e=d(i,"patient"),r=d(i,"destination"),n=e?[e]:[],o={};return r&&(o.to=r),f("prepend",n,o)}},Dn={action:"trigger",toAST(i,t){let e=d(i,"event"),r=d(i,"destination"),n=e?[e]:[],o={};return r&&(o.on=r),f("trigger",n,o)}},$n={action:"send",toAST(i,t){let e=d(i,"event"),r=d(i,"destination"),n=d(i,"patient"),o=e?[e]:[],s={};return r&&(s.to=r),n&&(s.detail=n),f("send",o,s)}},Fn={action:"go",toAST(i,t){let e=d(i,"source"),r=d(i,"destination"),n=[],o={};return e&&n.push(e),r&&(o.to=r),f("go",n,o)}},Hn={action:"transition",toAST(i,t){let e=d(i,"patient"),r=d(i,"goal"),n=d(i,"duration"),o=d(i,"destination"),s=e?[e]:[],a={};return r&&(a.to=r),n&&(a.over=n),o&&(a.on=o),f("transition",s,a)}},Xn={action:"focus",toAST(i,t){let e=d(i,"destination"),r=d(i,"patient"),n=[],o={},s=e??r;return s&&n.push(s),f("focus",n,o)}},Qn={action:"blur",toAST(i,t){let e=d(i,"destination"),r=d(i,"patient"),n=[],o=e??r;return o&&n.push(o),f("blur",n)}},Zn={action:"get",toAST(i,t){let e=d(i,"source"),r=d(i,"patient"),n=[],o=e??r;return o&&n.push(o),f("get",n)}},Yn={action:"take",toAST(i,t){let e=d(i,"patient"),r=d(i,"source"),n=e?[e]:[],o={};return r&&(o.from=r),f("take",n,o)}},Jn={action:"call",toAST(i,t){let e=d(i,"patient");return f("call",e?[e]:[])}},ei={action:"return",toAST(i,t){let e=d(i,"patient");return f("return",e?[e]:[])}},ti={action:"halt",toAST(i,t){return f("halt",[])}},ri={action:"throw",toAST(i,t){let e=d(i,"patient");return f("throw",e?[e]:[])}},ni={action:"settle",toAST(i,t){let e=d(i,"destination"),r=d(i,"patient"),n=[],o=e??r;return o&&n.push(o),f("settle",n,void 0,{isBlocking:!0})}},ii={action:"swap",toAST(i,t){let e=d(i,"patient"),r=d(i,"source"),n=d(i,"destination"),o=d(i,"style"),s=[],a={};return e&&s.push(e),r&&s.push(r),n&&(a.on=n),o&&(a.with=o),f("swap",s,a)}},oi={action:"morph",toAST(i,t){let e=d(i,"source"),r=d(i,"destination"),n=d(i,"patient"),o=[],s={},a=e??n;return a&&o.push(a),r&&(s.on=r),f("morph",o,s)}},ai={action:"clone",toAST(i,t){let e=d(i,"source"),r=d(i,"destination"),n=d(i,"patient"),o=[],s={},a=e??n;return a&&o.push(a),r&&(s.into=r),f("clone",o,s)}},si={action:"make",toAST(i,t){let e=d(i,"patient");return f("make",e?[e]:[])}},li={action:"measure",toAST(i,t){let e=d(i,"patient"),r=d(i,"destination"),n=d(i,"source"),o=[],s={};e&&o.push(e);let a=r??n;return a&&(s.of=a),f("measure",o,s)}},ci={action:"tell",toAST(i,t){let e=d(i,"destination"),r=d(i,"patient"),n=[],o=e??r;return o&&n.push(o),f("tell",n)}},di={action:"js",toAST(i,t){let e=d(i,"patient");return f("js",e?[e]:[])}},pi={action:"async",toAST(i,t){return f("async",[])}},mi={action:"if",toAST(i,t){let e=d(i,"condition");return f("if",e?[e]:[])}},ui={action:"unless",toAST(i,t){let e=d(i,"condition");return f("unless",e?[e]:[])}},fi={action:"repeat",toAST(i,t){let e=d(i,"quantity"),r=d(i,"patient"),n=[],o=e??r;return o&&n.push(o),f("repeat",n)}},gi={action:"for",toAST(i,t){let e=d(i,"patient"),r=d(i,"source"),n=e?[e]:[],o={};return r&&(o.in=r),f("for",n,o)}},yi={action:"while",toAST(i,t){let e=d(i,"condition");return f("while",e?[e]:[])}},hi={action:"continue",toAST(i,t){return f("continue",[])}},vi={action:"default",toAST(i,t){let e=d(i,"patient"),r=d(i,"source"),n=e?[e]:[],o={};return r&&(o.to=r),f("default",n,o)}},xi={action:"init",toAST(i,t){return f("init",[])}},Si={action:"behavior",toAST(i,t){let e=d(i,"patient");return f("behavior",e?[e]:[])}},Ti={action:"install",toAST(i,t){let e=d(i,"patient"),r=d(i,"destination"),n=e?[e]:[],o={};return r&&(o.on=r),f("install",n,o)}},bi={action:"on",toAST(i,t){let e=d(i,"event"),r=d(i,"source"),n=e?[e]:[],o={};return r&&(o.from=r),f("on",n,o)}},wt=new Map([["toggle",Ln],["add",Mn],["remove",An],["set",In],["show",Vn],["hide",On],["increment",_n],["decrement",qn],["wait",Wn],["log",Bn],["put",jn],["fetch",Kn],["append",Un],["prepend",Gn],["get",Zn],["take",Yn],["trigger",Dn],["send",$n],["on",bi],["go",Fn],["transition",Hn],["focus",Xn],["blur",Qn],["call",Jn],["return",ei],["halt",ti],["throw",ri],["settle",ni],["swap",ii],["morph",oi],["clone",ai],["measure",li],["make",si],["tell",ci],["default",vi],["js",di],["async",pi],["if",mi],["unless",ui],["repeat",fi],["for",gi],["while",yi],["continue",hi],["init",xi],["behavior",Si],["install",Ti]]);function ie(i){return wt.get(i)}function Ue(i){wt.set(i.action,i)}var oe=class{constructor(t={}){this.warnings=[]}build(t){switch(t.kind){case"command":return this.buildCommand(t);case"event-handler":return this.buildEventHandler(t);case"conditional":return this.buildConditional(t);case"compound":return this.buildCompound(t);case"loop":return this.buildLoop(t);default:throw new Error(`Unknown semantic node kind: ${t.kind}`)}}buildCommand(t){let e=ie(t.action);if(e){let r=e.toAST(t,this);if("ast"in r&&"warnings"in r){let n=r;return this.warnings.push(...n.warnings),n.ast}else return r}return this.buildGenericCommand(t)}buildGenericCommand(t){let e=[],r={},n=["patient","source","quantity"],o=["destination","duration","method","style"];for(let a of n){let l=t.roles.get(a);l&&e.push(L(l))}for(let a of o){let l=t.roles.get(a);if(l){let c=this.roleToModifierKey(a);r[c]=L(l)}}let s={type:"command",name:t.action,args:e};return Object.keys(r).length>0?{...s,modifiers:r}:s}roleToModifierKey(t){return{destination:"on",duration:"for",source:"from",condition:"if",method:"via",style:"with"}[t]??t}buildEventHandler(t){let e=t.roles.get("event"),r,n;if(e?.type==="literal"){let y=String(e.value);y.includes("|")||y.includes(" or ")?(n=y.split(/\s+or\s+|\|/).map(k=>k.trim()),r=n[0]):r=y}else e?.type==="reference"?r=e.value:r="click";let o=t.body.map(y=>this.build(y)),s=t.roles.get("source"),a,l;s?.type==="selector"?(a=s.value,l=s.value):s?.type==="reference"?l=s.value:s?.type==="literal"&&(l=String(s.value));let c=t.roles.get("condition"),p=c?L(c):void 0,S=t.roles.get("destination"),x=S?L(S):void 0,g=t.eventModifiers,m=a;if(g?.from){let y=g.from;y.type==="selector"&&!a&&(m=y.value)}let u=t.parameterNames?[...t.parameterNames]:void 0;return{type:"eventHandler",event:r,commands:o,...n&&n.length>1?{events:n}:{},...m?{selector:m}:{},...l?{target:l}:{},...p?{condition:p}:{},...x?{watchTarget:x}:{},...u&&u.length>0?{args:u,params:u}:{}}}buildConditional(t){let e=t.roles.get("condition");if(!e)throw new Error("Conditional node missing condition");let r=L(e),n=t.thenBranch.map(a=>this.build(a)),o=t.elseBranch?.map(a=>this.build(a)),s=[r,{type:"block",commands:n}];return o&&o.length>0&&s.push({type:"block",commands:o}),{type:"command",name:"if",args:s}}buildCompound(t){let e=t.statements.map(n=>this.build(n));return e.length===1?e[0]:e.length===0?{type:"block",commands:[]}:{type:"CommandSequence",commands:e}}buildLoop(t){let e=t.body.map(n=>this.build(n)),r=[{type:"identifier",name:t.loopVariant}];switch(t.loopVariant){case"times":{let n=t.roles.get("quantity");n&&r.push(L(n));break}case"for":{t.loopVariable&&r.push({type:"string",value:t.loopVariable});let n=t.roles.get("source");n&&r.push(L(n));break}case"while":case"until":{let n=t.roles.get("condition");n&&r.push(L(n));break}case"forever":break}return r.push({type:"block",commands:e}),{type:"command",name:"repeat",args:r}}buildBlock(t){return{type:"block",commands:t.map(r=>this.build(r))}}};function Et(i){let t=new oe;return{ast:t.build(i),warnings:t.warnings}}var U=class{constructor(t={}){this.cache=new Map,this.config={maxSize:t.maxSize??1e3,ttlMs:t.ttlMs??0,enabled:t.enabled??!0},this.stats={hits:0,misses:0,evictions:0,expirations:0}}makeKey(t,e){return`${e}:${t}`}isExpired(t){return this.config.ttlMs===0?!1:Date.now()-t.createdAt>this.config.ttlMs}evictLRU(){let t=this.cache.keys().next().value;t!==void 0&&(this.cache.delete(t),this.stats.evictions++)}get(t,e){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(t,e),n=this.cache.get(r);if(!n){this.stats.misses++;return}if(this.isExpired(n)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),n.lastAccessed=Date.now(),this.cache.set(r,n),this.stats.hits++,n.result}set(t,e,r){if(!this.config.enabled||r.confidence===0)return;let n=this.makeKey(t,e),o=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(n,{result:r,createdAt:o,lastAccessed:o})}has(t,e){if(!this.config.enabled)return!1;let r=this.makeKey(t,e),n=this.cache.get(r);return n?this.isExpired(n)?(this.cache.delete(r),this.stats.expirations++,!1):!0:!1}delete(t,e){let r=this.makeKey(t,e);return this.cache.delete(r)}clear(){this.cache.clear()}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0}}getStats(){let t=this.stats.hits+this.stats.misses;return{hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:t>0?this.stats.hits/t:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(t){if(t.maxSize!==void 0)for(this.config.maxSize=t.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();t.ttlMs!==void 0&&(this.config.ttlMs=t.ttlMs),t.enabled!==void 0&&(this.config.enabled=t.enabled)}enable(){this.config.enabled=!0}disable(){this.config.enabled=!1}getConfig(){return{...this.config}}},Ge=new U;var ae=class{constructor(t={}){this.patternMatcher=new te,this.languages=new Set(ce()),t.cache===!1?this.cache=new U({enabled:!1}):this.cache=t.cache?new U(t.cache):Ge}analyze(t,e){if(!this.supportsLanguage(e))return{confidence:0,errors:[`Language '${e}' is not supported for semantic parsing`]};let r=this.cache.get(t,e);if(r)return r;let n=this.analyzeUncached(t,e);return this.cache.set(t,e,n),n}analyzeUncached(t,e){try{let r=St(e);if(!r)return{confidence:0,errors:[`No tokenizer available for language '${e}'`]};let n=r.tokenize(t),o=A(e);if(o.length===0)return{confidence:0,errors:[`No patterns available for language '${e}'`]};let s=this.patternMatcher.matchBest(n,o);if(!s)return{confidence:0,errors:["No pattern matched the input"]};let a=this.buildSemanticNode(s);return{confidence:s.confidence,command:{name:s.pattern.command,roles:s.captured},node:a,tokensConsumed:s.consumedTokens}}catch(r){return{confidence:0,errors:[r instanceof Error?r.message:String(r)]}}}supportsLanguage(t){return this.languages.has(t)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear()}configureCache(t){this.cache.configure(t)}buildSemanticNode(t){return{kind:"command",action:t.pattern.command,roles:t.captured,metadata:{patternId:t.pattern.id}}}};function Pt(i){return new ae(i)}var De=.5,Ct=.8;function Nt(i,t=De){return i.confidence>=t&&i.command!==void 0}var zi="1.0.0-western",$e=["en","es","pt","fr","de"];function ki(){return[...$e]}function Rt(i){if(!$e.includes(i))throw new Error(`Language not supported in this bundle: ${i}. Supported: ${$e.join(", ")}`)}function wi(i,t){return Rt(t),[...ve(i,t).tokens]}function Lt(i){return Rt(i),A(i)}function Ei(i,t){return Lt(i).filter(e=>e.command===t).sort((e,r)=>r.priority-e.priority)}return _t(Pi);})();
|
|
1
|
+
"use strict";var LokaScriptSemanticWestern=(()=>{var Ee=Object.defineProperty;var qt=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var jt=Object.prototype.hasOwnProperty;var Kt=(i,t)=>{for(var e in t)Ee(i,e,{get:t[e],enumerable:!0})},$t=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Wt(t))!jt.call(i,n)&&n!==e&&Ee(i,n,{get:()=>t[n],enumerable:!(r=qt(t,n))||r.enumerable});return i};var Bt=i=>$t(Ee({},"__esModule",{value:!0}),i);var $i={};Kt($i,{ASTBuilder:()=>ce,DEFAULT_CONFIDENCE_THRESHOLD:()=>Xe,HIGH_CONFIDENCE_THRESHOLD:()=>It,SemanticAnalyzerImpl:()=>de,VERSION:()=>qi,buildAST:()=>Mt,canParse:()=>$e,createCommandNode:()=>K,createEventHandler:()=>ee,createLiteral:()=>k,createPropertyPath:()=>J,createReference:()=>O,createSelector:()=>j,createSemanticAnalyzer:()=>At,englishProfile:()=>W,englishTokenizer:()=>fe,frenchProfile:()=>Z,frenchTokenizer:()=>ve,fromExplicit:()=>Ue,germanProfile:()=>Y,germanTokenizer:()=>xe,getCommandMapper:()=>le,getPatternsForLanguage:()=>_t,getPatternsForLanguageAndCommand:()=>Ki,getProfile:()=>Ne,getSupportedLanguages:()=>Wi,getTokenizer:()=>Ce,isExplicitSyntax:()=>te,isLanguageSupported:()=>tt,parse:()=>re,parseAny:()=>Ge,parseExplicit:()=>D,portugueseProfile:()=>Q,portugueseTokenizer:()=>he,registerCommandMapper:()=>He,render:()=>ae,renderExplicit:()=>se,shouldUseSemanticResult:()=>Vt,spanishProfile:()=>X,spanishTokenizer:()=>ye,toExplicit:()=>Be,tokenize:()=>ji,tryGetProfile:()=>q});var I=new Map,$=new Map,F=new Map;var Ze=null;function Ye(i,t){let e={...i};for(let r of Object.keys(t)){let n=t[r],o=i[r];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?e[r]=Ye(o,n):e[r]=n)}return e}function Ut(i,t){return Ye(i,t)}function Re(i){if(!i.extends)return i;let t=$.get(i.extends);if(!t)return console.warn(`[Registry] Profile '${i.code}' extends '${i.extends}' but base is not registered. Make sure to import the base language before the variant.`),i;let e=Re(t);return Ut(e,i)}function M(i,t,e){I.set(i,t),$.set(i,e),F.delete(i)}var we=new Map;function Je(i,t){we.set(i,t),F.delete(i)}function B(i){return i.split("-")[0]}function U(i){return i.includes("-")}function Ce(i){let t=I.get(i);if(!t&&U(i)){let e=B(i);t=I.get(e)}if(!t){let e=Array.from(I.keys()).join(", ");throw new Error(`Language '${i}' is not registered. Registered languages: ${e||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return t}function Ne(i){let t=$.get(i);if(!t&&U(i)){let e=B(i);t=$.get(e)}if(!t){let e=Array.from($.keys()).join(", ");throw new Error(`Language profile '${i}' is not registered. Registered languages: ${e||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return Re(t)}function et(i){let t=I.get(i);return!t&&U(i)&&(t=I.get(B(i))),t}function q(i){let t=$.get(i);return!t&&U(i)&&(t=$.get(B(i))),t?Re(t):void 0}function me(){return Array.from(I.keys())}function tt(i){return I.has(i)?!0:U(i)?I.has(B(i)):!1}function rt(i,t){return Ce(t).tokenize(i)}function A(i){let t=F.get(i);if(!t&&U(i)&&(t=F.get(B(i))),t)return t;let e=we.get(i);if(!e&&U(i)&&(e=we.get(B(i))),e)return F.set(i,e),e;if(!Ze)throw new Error(`No patterns registered for language '${i}'. Either import the language module or set a pattern generator.`);let r=Ne(i),n=Ze(r);return F.set(i,n),n}function nt(i,t){return A(i).filter(e=>e.command===t).sort((e,r)=>r.priority-e.priority)}var E=class{constructor(t,e){this.pos=0;this.tokens=t,this.language=e}peek(t=0){let e=this.pos+t;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return{position:this.pos}}reset(t){this.pos=t.position}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(t){let e=[];for(;!this.isAtEnd()&&t(this.peek());)e.push(this.advance());return e}skipWhile(t){for(;!this.isAtEnd()&&t(this.peek());)this.advance()}};function x(i,t){return{start:i,end:t}}function S(i,t,e,r){if(typeof r=="string")return{value:i,kind:t,position:e,normalized:r};if(r){let{normalized:n,stem:o,stemConfidence:s}=r,a={value:i,kind:t,position:e};return n!==void 0&&(a.normalized=n),o!==void 0&&(a.stem=o,s!==void 0&&(a.stemConfidence=s)),a}return{value:i,kind:t,position:e}}function P(i){return/\s/.test(i)}function R(i){return i==="#"||i==="."||i==="["||i==="@"||i==="*"||i==="<"}function C(i){return i==='"'||i==="'"||i==="`"||i==="\u300C"||i==="\u300D"}function T(i){return/\d/.test(i)}function it(i){return/[a-zA-Z]/.test(i)}function b(i){return/[a-zA-Z0-9_-]/.test(i)}function V(i){let t=r=>i.test(r);return{isLetter:t,isIdentifierChar:r=>t(r)||/[0-9_-]/.test(r)}}function ot(i,t){if(t>=i.length)return null;let e=i[t];if(!R(e))return null;let r=t,n="";if(e==="#"||e==="."){for(n+=i[r++];r<i.length&&b(i[r]);)n+=i[r++];if(n.length<=1)return null;if(r<i.length&&i[r]==="."&&e==="#"){let s=r+1;for(;s<i.length&&b(i[s]);)s++;if(s<i.length&&i[s]==="(")return n}}else if(e==="["){let o=1,s=!1,a=null,l=!1;for(n+=i[r++];r<i.length&&o>0;){let c=i[r];n+=c,l?l=!1:c==="\\"?l=!0:s?c===a&&(s=!1,a=null):c==='"'||c==="'"||c==="`"?(s=!0,a=c):c==="["?o++:c==="]"&&o--,r++}if(o!==0)return null}else if(e==="@"){for(n+=i[r++];r<i.length&&b(i[r]);)n+=i[r++];if(n.length<=1)return null}else if(e==="*"){for(n+=i[r++];r<i.length&&b(i[r]);)n+=i[r++];if(n.length<=1)return null}else if(e==="<"){if(n+=i[r++],r>=i.length||!it(i[r]))return null;for(;r<i.length&&b(i[r]);)n+=i[r++];for(;r<i.length;){let o=i[r];if(o==="."){if(n+=i[r++],r>=i.length||!b(i[r]))return null;for(;r<i.length&&b(i[r]);)n+=i[r++]}else if(o==="#"){if(n+=i[r++],r>=i.length||!b(i[r]))return null;for(;r<i.length&&b(i[r]);)n+=i[r++]}else if(o==="["){let s=1,a=!1,l=null,c=!1;for(n+=i[r++];r<i.length&&s>0;){let d=i[r];n+=d,c?c=!1:d==="\\"?c=!0:a?d===l&&(a=!1,l=null):d==='"'||d==="'"||d==="`"?(a=!0,l=d):d==="["?s++:d==="]"&&s--,r++}if(s!==0)return null}else break}for(;r<i.length&&P(i[r]);)n+=i[r++];if(r<i.length&&i[r]==="/")for(n+=i[r++];r<i.length&&P(i[r]);)n+=i[r++];if(r>=i.length||i[r]!==">")return null;n+=i[r++]}return n||null}function Le(i,t){if(t>=i.length||i[t]!=="'"||t+1>=i.length||i[t+1].toLowerCase()!=="s")return!1;if(t+2>=i.length)return!0;let r=i[t+2];return P(r)||r==="*"||!b(r)}function at(i,t){if(t>=i.length)return null;let e=i[t];if(!C(e)||e==="'"&&Le(i,t))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[e];if(!n)return null;let o=t+1,s=e,a=!1;for(;o<i.length;){let l=i[o];if(s+=l,a)a=!1;else if(l==="\\")a=!0;else if(l===n)return s;o++}return s}function N(i,t){if(t>=i.length)return!1;let e=i[t],r=i[t+1]||"",n=i[t+2]||"";if(e==="/"&&r!=="/"&&/[a-zA-Z0-9._-]/.test(r)||e==="/"&&r==="/"&&/[a-zA-Z]/.test(n)||e==="."&&(r==="/"||r==="."&&n==="/"))return!0;let o=i.slice(t,t+8).toLowerCase();return!!(o.startsWith("http://")||o.startsWith("https://"))}function st(i,t){if(!N(i,t))return null;let e=t,r="",n=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;e<i.length;){let o=i[e];if(o==="#"){if(r.length>0&&/[a-zA-Z0-9/.]$/.test(r))for(r+=o,e++;e<i.length&&/[a-zA-Z0-9_-]/.test(i[e]);)r+=i[e++];break}if(n.test(o))r+=o,e++;else break}return r.length<2?null:r}function lt(i,t){if(t>=i.length)return null;let e=i[t];if(!T(e)&&e!=="-"&&e!=="+")return null;let r=t,n="";if((i[r]==="-"||i[r]==="+")&&(n+=i[r++]),r>=i.length||!T(i[r]))return null;for(;r<i.length&&T(i[r]);)n+=i[r++];if(r<i.length&&i[r]===".")for(n+=i[r++];r<i.length&&T(i[r]);)n+=i[r++];return r<i.length&&(i.slice(r,r+2)==="ms"?n+="ms":(i[r]==="s"||i[r]==="m"||i[r]==="h")&&(n+=i[r])),n}var ue=class ue{constructor(){this.profileKeywords=[];this.profileKeywordMap=new Map}initializeKeywordsFromProfile(t,e=[]){let r=new Map;if(t.keywords){for(let[n,o]of Object.entries(t.keywords))if(r.set(o.primary,{native:o.primary,normalized:o.normalized||n}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:o.normalized||n})}if(t.references)for(let[n,o]of Object.entries(t.references))r.set(o,{native:o,normalized:n});if(t.roleMarkers){for(let[n,o]of Object.entries(t.roleMarkers))if(o.primary&&r.set(o.primary,{native:o.primary,normalized:n}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:n})}for(let n of e)r.set(n.native,n);this.profileKeywords=Array.from(r.values()).sort((n,o)=>o.native.length-n.native.length),this.profileKeywordMap=new Map;for(let n of this.profileKeywords){this.profileKeywordMap.set(n.native.toLowerCase(),n);let o=this.removeDiacritics(n.native);o!==n.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),n)}}removeDiacritics(t){return t.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(t,e){for(let r of this.profileKeywords)if(t.slice(e).startsWith(r.native))return S(r.native,"keyword",x(e,e+r.native.length),r.normalized);return null}isKeywordStart(t,e){let r=t.slice(e);return this.profileKeywords.some(n=>r.startsWith(n.native))}lookupKeyword(t){return this.profileKeywordMap.get(t.toLowerCase())}isKeyword(t){return this.profileKeywordMap.has(t.toLowerCase())}setNormalizer(t){this.normalizer=t}tryNormalize(t){if(!this.normalizer)return null;let e=this.normalizer.normalize(t);return e.stem!==t&&e.confidence>=.7?e:null}tryMorphKeywordMatch(t,e,r){let n=this.tryNormalize(t);if(!n)return null;let o=this.lookupKeyword(n.stem);if(!o)return null;let s={normalized:o.normalized,stem:n.stem,stemConfidence:n.confidence};return S(t,"keyword",x(e,r),s)}trySelector(t,e){let r=ot(t,e);return r?S(r,"selector",x(e,e+r.length)):null}tryEventModifier(t,e){if(t[e]!==".")return null;let r=t.slice(e).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!r)return null;let n=r[0].replace(/(\s|\.)$/,""),o=n.slice(1).split("(")[0],s=r[1];return{...S(n,"event-modifier",x(e,e+n.length)),metadata:{modifierName:o,value:s?o==="queue"?s:parseInt(s,10):void 0}}}tryString(t,e){let r=at(t,e);return r?S(r,"literal",x(e,e+r.length)):null}tryNumber(t,e){let r=lt(t,e);return r?S(r,"literal",x(e,e+r.length)):null}tryMatchTimeUnit(t,e,r,n=!1){let o=e;if(n)for(;o<t.length&&P(t[o]);)o++;let s=t.slice(o);for(let a of r){let l=s.slice(0,a.length);if(a.caseInsensitive?l.toLowerCase()===a.pattern.toLowerCase():l===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let d=s[a.length]||"";if(b(d))continue}return{suffix:a.suffix,endPos:o+a.length}}}return null}parseBaseNumber(t,e,r=!0){let n=e,o="";if(r&&(t[n]==="-"||t[n]==="+")&&(o+=t[n++]),n>=t.length||!T(t[n]))return null;for(;n<t.length&&T(t[n]);)o+=t[n++];if(n<t.length&&t[n]===".")for(o+=t[n++];n<t.length&&T(t[n]);)o+=t[n++];return!o||o==="-"||o==="+"?null:{number:o,endPos:n}}tryNumberWithTimeUnits(t,e,r,n={}){let{allowSign:o=!0,skipWhitespace:s=!1}=n,a=this.parseBaseNumber(t,e,o);if(!a)return null;let{number:l,endPos:c}=a,d=[...r,...ue.STANDARD_TIME_UNITS],g=this.tryMatchTimeUnit(t,c,d,s);return g&&(l+=g.suffix,c=g.endPos),S(l,"literal",x(e,c))}tryUrl(t,e){let r=st(t,e);return r?S(r,"url",x(e,e+r.length)):null}tryVariableRef(t,e){if(t[e]!==":"||e+1>=t.length||!b(t[e+1]))return null;let r=e+1;for(;r<t.length&&b(t[r]);)r++;let n=t.slice(e,r);return S(n,"identifier",x(e,r))}tryOperator(t,e){let r=t.slice(e,e+2);if(["==","!=","<=",">=","&&","||","->"].includes(r))return S(r,"operator",x(e,e+2));let n=t[e];return["<",">","!","+","-","*","/","="].includes(n)?S(n,"operator",x(e,e+1)):["(",")","{","}",",",";",":"].includes(n)?S(n,"punctuation",x(e,e+1)):null}tryMultiCharParticle(t,e,r){for(let n of r)if(t.slice(e,e+n.length)===n)return S(n,"particle",x(e,e+n.length));return null}};ue.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 w=ue;var W={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 Gt=[{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"}],Me=class extends w{constructor(){super();this.language="en";this.direction="ltr";this.initializeKeywordsFromProfile(W,Gt)}tokenize(e){let r=[],n=0;for(;n<e.length;){if(P(e[n])){n++;continue}if(R(e[n])){let a=this.tryEventModifier(e,n);if(a){r.push(a),n=a.position.end;continue}if(e[n]==="."){let c=r[r.length-1],d=c&&c.position.end<n;if(c&&!d&&(c.kind==="identifier"||c.kind==="keyword"||c.kind==="selector")){r.push(S(".","operator",x(n,n+1))),n++;continue}let m=n+1;for(;m<e.length&&b(e[m]);)m++;if(m<e.length&&e[m]==="("){r.push(S(".","operator",x(n,n+1))),n++;continue}}let l=this.trySelector(e,n);if(l){r.push(l),n=l.position.end;continue}}if(C(e[n])){if(e[n]==="'"&&Le(e,n)){r.push(S("'s","punctuation",x(n,n+2))),n+=2;continue}let a=this.tryString(e,n);if(a){r.push(a),n=a.position.end;continue}}if(N(e,n)){let a=this.tryUrl(e,n);if(a){r.push(a),n=a.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let a=this.tryNumber(e,n);if(a){r.push(a),n=a.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}if(b(e[n])){let a=this.extractWord(e,n);if(a){r.push(a),n=a.position.end;continue}}let s=this.tryOperator(e,n);if(s){r.push(s),n=s.position.end;continue}n++}return new E(r,"en")}classifyToken(e){return this.isKeyword(e)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(e)?"operator":e.startsWith("/")||e.startsWith("./")||e.startsWith("http")?"url":"identifier"}extractWord(e,r){let n=r,o="";for(;n<e.length&&b(e[n]);)o+=e[n++];if(!o)return null;if(n<e.length&&e[n]===":"){let c=n;n++;let d="";for(;n<e.length&&b(e[n]);)d+=e[n++];d?o=o+":"+d:n=c}let s=this.classifyToken(o),a=this.lookupKeyword(o),l=a&&a.normalized!==a.native?a.normalized:void 0;if(s==="identifier"){let c=this.tryConvertToClassSelector(e,n,o);if(c)return c.token}return S(o,s,x(r,n),l)}tryConvertToClassSelector(e,r,n){let o=r;for(;o<e.length&&/\s/.test(e[o]);)o++;if(e.slice(o,o+5).toLowerCase()==="class"){let s=o+5;if(s>=e.length||!b(e[s])){let a="."+n;return{token:S(a,"selector",x(r-n.length,r)),endPos:r}}}return null}},fe=new Me;var Dt={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)"}},Ht={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"}},Ft={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"}},Xt={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>"}},Zt={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}]},Yt={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}]},Jt={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}]},er={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}]},tr={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}]},rr={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}]},nr={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}]},ir={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}]},or={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}]},ar={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}]},sr={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}]},lr={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}]},cr={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:!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}]},dr={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}]},pr={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}]},mr={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}]},ur={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}]},fr={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"}}]},gr={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}]},yr={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}]},hr={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},vr={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"'},xr={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}]},Sr={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}]},Tr={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},br={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},kr={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}]},zr={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}]},Pr={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}]},Er={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}]},wr={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}]},Rr={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}]},Cr={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}]},Nr={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:!0,roles:[]},Lr={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}]},Ar={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},Ir={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}]},Vr={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}]},Or={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}]},_r={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}]},qr={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}]},Wr={toggle:Dt,add:Ht,remove:Ft,put:Xt,set:Qt,show:Zt,hide:Yt,on:Jt,trigger:er,wait:tr,fetch:rr,increment:nr,decrement:ir,append:or,prepend:ar,log:sr,get:lr,take:cr,make:dr,halt:pr,settle:mr,throw:ur,send:fr,if:gr,unless:yr,else:hr,repeat:vr,for:xr,while:Sr,continue:Tr,go:br,transition:kr,clone:zr,focus:Pr,blur:Er,call:wr,return:Rr,js:Cr,async:Nr,tell:Lr,default:Mr,init:Ar,behavior:Ir,install:Vr,measure:Or,swap:_r,morph:qr,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:!0,roles:[]}};function ct(){return Object.values(Wr).filter(i=>i.roles.length>0)}function Ae(i,t){let e=t==="SOV"?"sovPosition":"svoPosition";return[...i].sort((r,n)=>{let o=r[e]??99,s=n[e]??99;return o-s})}function dt(i,t){let e=i.markerOverride?.[t.code],r=t.roleMarkers[i.role];if(e!==void 0)return{primary:e,position:r?.position??"before",isOverride:!0};if(r&&r.primary){let n={primary:r.primary,position:r.position,isOverride:!1};return r.alternatives&&(n.alternatives=r.alternatives),n}return null}var ne={basePriority:100,generateSimpleVariants:!0,generateAlternatives:!0};function ut(i,t,e=ne){let r=`${i.action}-${t.code}-generated`,n=e.basePriority??100,o=t.keywords[i.action];if(!o)throw new Error(`No keyword translation for '${i.action}' in ${t.code}`);let s=Qr(i,t,o),a=gt(i,t),l=en(i,t,o);return{id:r,language:t.code,command:i.action,priority:n,template:{format:l,tokens:s},extraction:a}}function jr(i,t,e=ne){if(i.roles.filter(a=>!a.required).length===0)return null;let n=i.roles.filter(a=>a.required),o={...i,roles:n};return{...ut(o,t,e),id:`${i.action}-${t.code}-simple`,priority:(e.basePriority??100)-5,extraction:gt(i,t)}}function Kr(i,t,e=ne){let r=[];if(r.push(ut(i,t,e)),e.generateSimpleVariants){let n=jr(i,t,e);n&&r.push(n)}return r}function ft(i,t=ne){let e=[],r=ct();for(let n of r){if(!i.keywords[n.action])continue;let o=Kr(n,i,t);if(e.push(...o),i.eventHandler?.eventMarker){let s=$r(n,i,t);e.push(...s)}}return e}function $r(i,t,e=ne){if(!t.eventHandler||!t.eventHandler.eventMarker)return[];let r=[],n=t.eventHandler.eventMarker,o=t.keywords[i.action];if(!o)return[];let a=i.roles.filter(l=>l.required).length===2;if(t.wordOrder==="SOV")if(a)r.push(Hr(i,t,o,n,e));else{r.push(Br(i,t,o,n,e));let l=n.primary.split(/\s+/),c=n.alternatives?.some(g=>!g.includes(" ")&&g.length>1);l.length>1&&c&&r.push(Ur(i,t,o,n,e)),r.push(Gr(i,t,o,n,e));let d=Dr(i,t,o,e);d&&r.push(d)}else t.wordOrder==="VSO"?a?r.push(mt(i,t,o,n,e)):(r.push(pt(i,t,o,n,e)),t.eventHandler?.negationMarker&&r.push(Fr(i,t,o,n,e)),t.tokenization?.prefixes&&r.push(Xr(i,t,o,e))):a?r.push(mt(i,t,o,n,e)):r.push(pt(i,t,o,n,e));return r}function Br(i,t,e,r,n){let o=[];if(o.push({type:"role",role:"event",optional:!1}),r.position==="after"){let c=r.primary.split(/\s+/);if(c.length>1)for(let d of c)o.push({type:"literal",value:d});else{let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(d)}}let s=t.roleMarkers.destination;s&&o.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}]}),o.push({type:"role",role:"patient",optional:!1});let a=t.roleMarkers.patient;if(a){let c=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};o.push(c)}let l=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary};return o.push(l),{id:`${i.action}-event-${t.code}-sov`,language:t.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`{event} ${r.primary} {destination?} {patient} ${a?.primary||""} ${e.primary}`,tokens:o},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Ur(i,t,e,r,n){let o=[];o.push({type:"role",role:"event",optional:!1});let s=r.alternatives?.filter(d=>!d.includes(" ")&&d.length>1)||[];s.length>0&&o.push({type:"literal",value:s[0],alternatives:s.slice(1)});let a=t.roleMarkers.destination;a&&o.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}]}),o.push({type:"role",role:"patient",optional:!1});let l=t.roleMarkers.patient;if(l){let d=l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary};o.push(d)}let c=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary};return o.push(c),{id:`${i.action}-event-${t.code}-sov-compact`,language:t.code,command:"on",priority:(n.basePriority??100)+52,template:{format:`{event}${s[0]||""} {patient} ${e.primary}`,tokens:o},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Gr(i,t,e,r,n){let o=[];if(o.push({type:"role",role:"event",optional:!1}),r.position==="after"){let a=r.primary.split(/\s+/);if(a.length>1)for(let l of a)o.push({type:"literal",value:l});else{let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l)}}let s=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary};return o.push(s),{id:`${i.action}-event-${t.code}-sov-simple`,language:t.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{event} ${r.primary} ${e.primary}`,tokens:o},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function Dr(i,t,e,r){let n=t.eventHandler?.temporalMarkers;if(!n||n.length===0)return null;let o=[];o.push({type:"role",role:"event",optional:!1}),t.possessive?.marker&&o.push({type:"group",optional:!0,tokens:[{type:"literal",value:t.possessive.marker}]}),o.push({type:"literal",value:n[0],alternatives:n.slice(1)}),o.push({type:"role",role:"patient",optional:!1});let s=t.roleMarkers.patient;if(s?.primary){let l=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(l)}let a=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary};return o.push(a),{id:`${i.action}-event-${t.code}-sov-temporal`,language:t.code,command:"on",priority:(r.basePriority??100)+49,template:{format:`{event} ${n[0]} {patient} ${e.primary}`,tokens:o},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function pt(i,t,e,r,n){let o=[];if(r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l)}o.push({type:"role",role:"event",optional:!1});let s=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary};o.push(s),o.push({type:"role",role:"patient",optional:!1});let a=t.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:`${i.action}-event-${t.code}-vso`,language:t.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`${r.primary} {event} ${e.primary} {patient} ${a?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Hr(i,t,e,r,n){let o=[];if(o.push({type:"role",role:"event",optional:!1}),r.position==="after"){let d=r.primary.split(/\s+/);if(d.length>1)for(let g of d)o.push({type:"literal",value:g});else{let g=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(g)}}let a=[...i.roles.filter(d=>d.required)].sort((d,g)=>{let h=d.sovPosition??999,m=g.sovPosition??999;return h-m});for(let d of a){o.push({type:"role",role:d.role,optional:!1});let g,h;if(d.markerOverride&&d.markerOverride[t.code])g=d.markerOverride[t.code];else{let m=t.roleMarkers[d.role];m&&(g=m.primary,h=m.alternatives)}if(g){let m=h?{type:"literal",value:g,alternatives:h}:{type:"literal",value:g};o.push(m)}}let l=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary};o.push(l);let c=a.map(d=>`{${d.role}}`).join(" ");return{id:`${i.action}-event-${t.code}-sov-2role`,language:t.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`{event} ${r.primary} ${c} ${e.primary}`,tokens:o},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function mt(i,t,e,r,n){let o=[];if(r.position==="before"){let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(d)}o.push({type:"role",role:"event",optional:!1});let s=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary};o.push(s);let l=[...i.roles.filter(d=>d.required)].sort((d,g)=>{let h=d.svoPosition??999,m=g.svoPosition??999;return h-m});for(let d of l){let g,h;if(d.markerOverride&&d.markerOverride[t.code])g=d.markerOverride[t.code];else{let m=t.roleMarkers[d.role];m&&(g=m.primary,h=m.alternatives)}if(g){let m=h?{type:"literal",value:g,alternatives:h}:{type:"literal",value:g};o.push(m)}o.push({type:"role",role:d.role,optional:!1})}let c=l.map(d=>`{${d.role}}`).join(" ");return{id:`${i.action}-event-${t.code}-vso-2role`,language:t.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`${r.primary} {event} ${e.primary} ${c}`,tokens:o},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function Fr(i,t,e,r,n){let o=[],s=t.eventHandler?.negationMarker;if(r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c)}if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(c)}o.push({type:"role",role:"event",optional:!1});let a=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary};o.push(a),o.push({type:"role",role:"patient",optional:!1});let l=t.roleMarkers.destination;return l&&o.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:`${i.action}-event-${t.code}-vso-negated`,language:t.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${r.primary} ${s?.primary||""} {event} ${e.primary} {patient} ${l?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Xr(i,t,e,r){let n=[];n.push({type:"literal",value:"and",alternatives:["then"]}),n.push({type:"role",role:"event",optional:!1});let o=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary};n.push(o),n.push({type:"role",role:"patient",optional:!1});let s=t.roleMarkers.destination;return s&&n.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:`${i.action}-event-${t.code}-vso-proclitic`,language:t.code,command:"on",priority:(r.basePriority??100)+45,template:{format:`[proclitic?] {event} ${e.primary} {patient} ${s?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Qr(i,t,e){let r=[],n=e.alternatives?{type:"literal",value:e.primary,alternatives:e.alternatives}:{type:"literal",value:e.primary},o=Zr(i,t);switch(t.wordOrder){case"SVO":r.push(n),r.push(...o);break;case"SOV":r.push(...o),r.push(n);break;case"VSO":r.push(n),r.push(...o);break;default:r.push(n),r.push(...o)}return r}function Zr(i,t){let e=[],r=Ae(i.roles,t.wordOrder);for(let n of r){let o=Yr(n,t);n.required?e.push(...o):e.push({type:"group",optional:!0,tokens:o})}return e}function Yr(i,t){let e=[],r=i.markerOverride?.[t.code],n=t.roleMarkers[i.role],o={type:"role",role:i.role,optional:!i.required,expectedTypes:i.expectedTypes};if(r!==void 0)(n?.position??"before")==="before"?(r&&e.push({type:"literal",value:r}),e.push(o)):(e.push(o),r&&e.push({type:"literal",value:r}));else if(n)if(n.position==="before"){if(n.primary){let s=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};e.push(s)}e.push(o)}else{e.push(o);let s=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};e.push(s)}else e.push(o);return e}function Jr(i,t){let e={};for(let r of i.roles){let n=r.markerOverride?.[t.code],o=t.roleMarkers[r.role];n!==void 0?e[r.role]=n?{marker:n}:{}:o&&o.primary?e[r.role]=o.alternatives?{marker:o.primary,markerAlternatives:o.alternatives}:{marker:o.primary}:e[r.role]={}}return e}function gt(i,t){let e=Jr(i,t),r={};for(let n of i.roles){let o=e[n.role]||{};!n.required&&n.default?r[n.role]={...o,default:n.default}:r[n.role]=o}return r}function en(i,t,e){let r=[],o=Ae(i.roles,t.wordOrder).map(s=>{let a=dt(s,t),l="";return a&&a.primary?a.position==="before"?l=`${a.primary} {${s.role}}`:l=`{${s.role}} ${a.primary}`:l=`{${s.role}}`,s.required?l:`[${l}]`});switch(t.wordOrder){case"SVO":case"VSO":r.push(e.primary,...o);break;case"SOV":r.push(...o,e.primary);break;default:r.push(e.primary,...o)}return r.join(" ")}function yt(){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 ht(){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 vt(){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 tn={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"}}},rn={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}}},nn={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}}},on={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"}}}},an={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"}}}},sn={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"}}},ln={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"}}}},cn={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}}},dn={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}}},pn={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}}},mn={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 xt(){let i=[];i.push(...yt()),i.push(...ht()),i.push(...vt()),i.push(tn,rn,nn,on,an,sn,ln,cn,dn,pn,mn);let t=ft(W);return i.push(...t),i}M("en",fe,W);Je("en",xt());function Ie(i){return{stem:i,confidence:1}}function ge(i,t,e){return e?{stem:i,confidence:t,metadata:e}:{stem:i,confidence:t}}function un(i){return/[áéíóúüñÁÉÍÓÚÜÑ]/.test(i)}function fn(i){let t=i.toLowerCase();if(t.endsWith("ar")||t.endsWith("er")||t.endsWith("ir")||t.endsWith("ando")||t.endsWith("iendo")||t.endsWith("ado")||t.endsWith("ido")||t.endsWith("arse")||t.endsWith("erse")||t.endsWith("irse"))return!0;for(let e of i)if(un(e))return!0;return!1}var St=["se","me","te","nos","os"],gn=[{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"}],yn=[{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"}],hn=[{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"}],vn=[...gn,...yn,...hn].sort((i,t)=>t.ending.length-i.ending.length),ie=class{constructor(){this.language="es"}isNormalizable(t){return t.length<3?!1:fn(t)}normalize(t){let e=t.toLowerCase();if((e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir"))&&!St.some(o=>e.endsWith(o+"ar")||e.endsWith(o+"er")||e.endsWith(o+"ir")))return Ie(t);let r=this.tryReflexiveNormalization(e);if(r)return r;let n=this.tryConjugationNormalization(e);return n||Ie(t)}tryReflexiveNormalization(t){for(let e of St)if(t.endsWith(e)){let r=t.slice(0,-e.length);if(r.endsWith("ar")||r.endsWith("er")||r.endsWith("ir"))return ge(r,.88,{removedSuffixes:[e],conjugationType:"reflexive"});let n=this.tryConjugationNormalization(r);if(n&&n.stem!==r)return ge(n.stem,n.confidence*.95,{removedSuffixes:[e,...n.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationNormalization(t){for(let e of vn)if(t.endsWith(e.ending)){let r=t.slice(0,-e.ending.length);if(r.length<2)continue;let n=r+e.stem;return ge(n,e.confidence,{removedSuffixes:[e.ending],conjugationType:e.type})}return null}},So=new ie;var X={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:Tt,isIdentifierChar:xn}=V(/[a-zA-ZáéíóúüñÁÉÍÓÚÜÑ]/),Sn=[{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}],bt=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),Tn=[{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"}],Ve=class extends w{constructor(){super();this.language="es";this.direction="ltr";this.initializeKeywordsFromProfile(X,Tn),this.normalizer=new ie}tokenize(e){let r=[],n=0;for(;n<e.length;){if(P(e[n])){n++;continue}if(R(e[n])){let l=this.tryEventModifier(e,n);if(l){r.push(l),n=l.position.end;continue}let c=this.trySelector(e,n);if(c){r.push(c),n=c.position.end;continue}}if(C(e[n])){let l=this.tryString(e,n);if(l){r.push(l),n=l.position.end;continue}}if(N(e,n)){let l=this.tryUrl(e,n);if(l){r.push(l),n=l.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let l=this.extractSpanishNumber(e,n);if(l){r.push(l),n=l.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}let s=this.tryMultiWordPhrase(e,n);if(s){r.push(s),n=s.position.end;continue}if(Tt(e[n])){let l=this.extractSpanishWord(e,n);if(l){r.push(l),n=l.position.end;continue}}let a=this.tryOperator(e,n);if(a){r.push(a),n=a.position.end;continue}n++}return new E(r,"es")}classifyToken(e){let r=e.toLowerCase();return bt.has(r)?"particle":this.isKeyword(r)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(e)?"operator":"identifier"}tryMultiWordPhrase(e,r){for(let n of this.profileKeywords){if(!n.native.includes(" "))continue;let o=n.native;if(e.slice(r,r+o.length).toLowerCase()===o.toLowerCase()){let a=r+o.length;if(a>=e.length||P(e[a])||!Tt(e[a]))return S(e.slice(r,r+o.length),"keyword",x(r,a),n.normalized)}}return null}extractSpanishWord(e,r){let n=r,o="";for(;n<e.length&&xn(e[n]);)o+=e[n++];if(!o)return null;let s=o.toLowerCase();if(bt.has(s))return S(o,"particle",x(r,n));let a=this.lookupKeyword(s);if(a)return S(o,"keyword",x(r,n),a.normalized);let l=this.tryMorphKeywordMatch(s,r,n);return l||S(o,"identifier",x(r,n))}extractSpanishNumber(e,r){return this.tryNumberWithTimeUnits(e,r,Sn,{allowSign:!0,skipWhitespace:!0})}},ye=new Ve;M("es",ye,X);var Q={code:"pt",name:"Portuguese",nativeName:"Portugu\xEAs",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,verb:{position:"start",subjectDrop:!0},references:{me:"eu",it:"ele",you:"voc\xEA",result:"resultado",event:"evento",target:"alvo",body:"corpo"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:!0,specialForms:{me:"meu",it:"seu",you:"teu"},keywords:{meu:"me",minha:"me",teu:"you",tua:"you",seu:"it",sua:"it"}},roleMarkers:{destination:{primary:"em",alternatives:["para","a"],position:"before"},source:{primary:"de",alternatives:["desde"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"com",position:"before"}},keywords:{toggle:{primary:"alternar",alternatives:["trocar"],normalized:"toggle"},add:{primary:"adicionar",alternatives:["acrescentar"],normalized:"add"},remove:{primary:"remover",alternatives:["eliminar","apagar"],normalized:"remove"},put:{primary:"colocar",alternatives:["p\xF4r","por"],normalized:"put"},append:{primary:"anexar",normalized:"append"},prepend:{primary:"preceder",normalized:"prepend"},take:{primary:"pegar",normalized:"take"},make:{primary:"fazer",alternatives:["criar"],normalized:"make"},clone:{primary:"clonar",alternatives:["copiar"],normalized:"clone"},swap:{primary:"trocar",alternatives:["substituir"],normalized:"swap"},morph:{primary:"transformar",alternatives:["converter"],normalized:"morph"},set:{primary:"definir",alternatives:["configurar"],normalized:"set"},get:{primary:"obter",normalized:"get"},increment:{primary:"incrementar",alternatives:["aumentar"],normalized:"increment"},decrement:{primary:"decrementar",alternatives:["diminuir"],normalized:"decrement"},log:{primary:"registrar",alternatives:["imprimir"],normalized:"log"},show:{primary:"mostrar",alternatives:["exibir"],normalized:"show"},hide:{primary:"ocultar",alternatives:["esconder"],normalized:"hide"},transition:{primary:"transi\xE7\xE3o",alternatives:["animar"],normalized:"transition"},on:{primary:"em",alternatives:["quando","ao"],normalized:"on"},trigger:{primary:"disparar",alternatives:["ativar"],normalized:"trigger"},send:{primary:"enviar",normalized:"send"},focus:{primary:"focar",normalized:"focus"},blur:{primary:"desfocar",normalized:"blur"},go:{primary:"ir",alternatives:["navegar"],normalized:"go"},wait:{primary:"esperar",alternatives:["aguardar"],normalized:"wait"},fetch:{primary:"buscar",normalized:"fetch"},settle:{primary:"estabilizar",normalized:"settle"},if:{primary:"se",normalized:"if"},when:{primary:"quando",normalized:"when"},where:{primary:"onde",normalized:"where"},else:{primary:"sen\xE3o",normalized:"else"},repeat:{primary:"repetir",normalized:"repeat"},for:{primary:"para",normalized:"for"},while:{primary:"enquanto",normalized:"while"},continue:{primary:"continuar",normalized:"continue"},halt:{primary:"parar",normalized:"halt"},throw:{primary:"lan\xE7ar",normalized:"throw"},call:{primary:"chamar",normalized:"call"},return:{primary:"retornar",alternatives:["devolver"],normalized:"return"},then:{primary:"ent\xE3o",alternatives:["depois","logo"],normalized:"then"},and:{primary:"e",alternatives:["tamb\xE9m","al\xE9m disso"],normalized:"and"},end:{primary:"fim",alternatives:["final","t\xE9rmino"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"ass\xEDncrono",normalized:"async"},tell:{primary:"dizer",normalized:"tell"},default:{primary:"padr\xE3o",normalized:"default"},init:{primary:"iniciar",alternatives:["inicializar"],normalized:"init"},behavior:{primary:"comportamento",normalized:"behavior"},install:{primary:"instalar",normalized:"install"},measure:{primary:"medir",normalized:"measure"},into:{primary:"em",alternatives:["dentro de"],normalized:"into"},before:{primary:"antes",normalized:"before"},after:{primary:"depois",normalized:"after"},click:{primary:"clique",alternatives:["clicar"],normalized:"click"},hover:{primary:"sobrevoar",alternatives:["passar"],normalized:"hover"},submit:{primary:"envio",alternatives:["submeter"],normalized:"submit"},input:{primary:"entrada",alternatives:["inser\xE7\xE3o"],normalized:"input"},change:{primary:"altera\xE7\xE3o",alternatives:["mudan\xE7a"],normalized:"change"},until:{primary:"at\xE9",normalized:"until"},event:{primary:"evento",normalized:"event"},from:{primary:"de",alternatives:["desde"],normalized:"from"}},eventHandler:{keyword:{primary:"em",alternatives:["ao","quando"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["desde"],position:"before"},conditionalKeyword:{primary:"quando",alternatives:["se"]},eventMarker:{primary:"ao",alternatives:["no"],position:"before"},temporalMarkers:["quando","ao"]}};var{isLetter:bn,isIdentifierChar:kn}=V(/[a-zA-ZáàâãéêíóôõúüçÁÀÂÃÉÊÍÓÔÕÚÜÇ]/),kt=new Set(["em","a","de","desde","at\xE9","ate","com","sem","por","para","sobre","entre","antes","depois","dentro","fora","ao","do","no","na"]),zn=[{native:"verdadeiro",normalized:"true"},{native:"falso",normalized:"false"},{native:"nulo",normalized:"null"},{native:"indefinido",normalized:"undefined"},{native:"primeiro",normalized:"first"},{native:"primeira",normalized:"first"},{native:"\xFAltimo",normalized:"last"},{native:"ultima",normalized:"last"},{native:"pr\xF3ximo",normalized:"next"},{native:"proximo",normalized:"next"},{native:"anterior",normalized:"previous"},{native:"mais pr\xF3ximo",normalized:"closest"},{native:"mais proximo",normalized:"closest"},{native:"pai",normalized:"parent"},{native:"clique",normalized:"click"},{native:"click",normalized:"click"},{native:"entrada",normalized:"input"},{native:"mudan\xE7a",normalized:"change"},{native:"mudanca",normalized:"change"},{native:"envio",normalized:"submit"},{native:"tecla baixo",normalized:"keydown"},{native:"tecla cima",normalized:"keyup"},{native:"mouse sobre",normalized:"mouseover"},{native:"mouse fora",normalized:"mouseout"},{native:"foco",normalized:"focus"},{native:"desfoque",normalized:"blur"},{native:"carregar",normalized:"load"},{native:"rolagem",normalized:"scroll"},{native:"meu",normalized:"my"},{native:"minha",normalized:"my"},{native:"isso",normalized:"it"},{native:"segundo",normalized:"s"},{native:"segundos",normalized:"s"},{native:"milissegundo",normalized:"ms"},{native:"milissegundos",normalized:"ms"},{native:"minuto",normalized:"m"},{native:"minutos",normalized:"m"},{native:"hora",normalized:"h"},{native:"horas",normalized:"h"},{native:"senao",normalized:"else"},{native:"transicao",normalized:"transition"},{native:"ate",normalized:"until"},{native:"entao",normalized:"then"},{native:"lancar",normalized:"throw"},{native:"assincrono",normalized:"async"},{native:"padrao",normalized:"default"},{native:"at\xE9 que",normalized:"until"},{native:"dentro de",normalized:"into"}],Pn=[{pattern:"milissegundos",suffix:"ms",length:13,caseInsensitive:!0},{pattern:"milissegundo",suffix:"ms",length:12,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}],Oe=class extends w{constructor(){super();this.language="pt";this.direction="ltr";this.initializeKeywordsFromProfile(Q,zn)}tokenize(e){let r=[],n=0;for(;n<e.length;){if(P(e[n])){n++;continue}if(R(e[n])){let a=this.tryEventModifier(e,n);if(a){r.push(a),n=a.position.end;continue}let l=this.trySelector(e,n);if(l){r.push(l),n=l.position.end;continue}}if(C(e[n])){let a=this.tryString(e,n);if(a){r.push(a),n=a.position.end;continue}}if(N(e,n)){let a=this.tryUrl(e,n);if(a){r.push(a),n=a.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let a=this.extractNumber(e,n);if(a){r.push(a),n=a.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}if(bn(e[n])){let a=this.extractWord(e,n);if(a){r.push(a),n=a.position.end;continue}}let s=this.tryOperator(e,n);if(s){r.push(s),n=s.position.end;continue}n++}return new E(r,"pt")}classifyToken(e){let r=e.toLowerCase();return kt.has(r)?"particle":this.isKeyword(r)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":"identifier"}extractWord(e,r){let n=r,o="";for(;n<e.length&&kn(e[n]);)o+=e[n++];if(!o)return null;let s=o.toLowerCase(),a=this.lookupKeyword(s);return a?S(o,"keyword",x(r,n),a.normalized):kt.has(s)?S(o,"particle",x(r,n)):S(o,"identifier",x(r,n))}extractNumber(e,r){return this.tryNumberWithTimeUnits(e,r,Pn,{allowSign:!0,skipWhitespace:!0})}},he=new Oe;M("pt",he,Q);var Z={code:"fr",name:"French",nativeName:"Fran\xE7ais",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:!1},references:{me:"moi",it:"il",you:"toi",result:"r\xE9sultat",event:"\xE9v\xE9nement",target:"cible",body:"corps"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:!0,specialForms:{me:"ma",it:"sa",you:"ta"},keywords:{mon:"me",ma:"me",mes:"me",ton:"you",ta:"you",tes:"you",son:"it",sa:"it",ses:"it"}},roleMarkers:{destination:{primary:"sur",alternatives:["\xE0","dans"],position:"before"},source:{primary:"de",alternatives:["depuis"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"avec",position:"before"}},keywords:{toggle:{primary:"basculer",alternatives:["permuter","alterner"],normalized:"toggle"},add:{primary:"ajouter",normalized:"add"},remove:{primary:"supprimer",alternatives:["enlever","retirer"],normalized:"remove"},put:{primary:"mettre",alternatives:["placer"],normalized:"put"},append:{primary:"annexer",normalized:"append"},prepend:{primary:"pr\xE9fixer",normalized:"prepend"},take:{primary:"prendre",normalized:"take"},make:{primary:"faire",alternatives:["cr\xE9er"],normalized:"make"},clone:{primary:"cloner",alternatives:["copier"],normalized:"clone"},swap:{primary:"\xE9changer",alternatives:["permuter"],normalized:"swap"},morph:{primary:"transformer",alternatives:["m\xE9tamorphoser"],normalized:"morph"},set:{primary:"d\xE9finir",alternatives:["\xE9tablir"],normalized:"set"},get:{primary:"obtenir",normalized:"get"},increment:{primary:"incr\xE9menter",alternatives:["augmenter"],normalized:"increment"},decrement:{primary:"d\xE9cr\xE9menter",alternatives:["diminuer"],normalized:"decrement"},log:{primary:"enregistrer",alternatives:["afficher"],normalized:"log"},show:{primary:"montrer",alternatives:["afficher"],normalized:"show"},hide:{primary:"cacher",alternatives:["masquer"],normalized:"hide"},transition:{primary:"transition",alternatives:["animer"],normalized:"transition"},on:{primary:"sur",alternatives:["quand","lors"],normalized:"on"},trigger:{primary:"d\xE9clencher",normalized:"trigger"},send:{primary:"envoyer",normalized:"send"},focus:{primary:"focaliser",alternatives:["concentrer"],normalized:"focus"},blur:{primary:"d\xE9focaliser",normalized:"blur"},go:{primary:"aller",alternatives:["naviguer"],normalized:"go"},wait:{primary:"attendre",normalized:"wait"},fetch:{primary:"chercher",alternatives:["r\xE9cup\xE9rer"],normalized:"fetch"},settle:{primary:"stabiliser",normalized:"settle"},if:{primary:"si",normalized:"if"},when:{primary:"quand",normalized:"when"},where:{primary:"o\xF9",normalized:"where"},else:{primary:"sinon",normalized:"else"},repeat:{primary:"r\xE9p\xE9ter",normalized:"repeat"},for:{primary:"pour",normalized:"for"},while:{primary:"pendant",normalized:"while"},continue:{primary:"continuer",normalized:"continue"},halt:{primary:"arr\xEAter",alternatives:["stopper"],normalized:"halt"},throw:{primary:"lancer",normalized:"throw"},call:{primary:"appeler",normalized:"call"},return:{primary:"retourner",alternatives:["renvoyer"],normalized:"return"},then:{primary:"puis",alternatives:["ensuite","alors"],normalized:"then"},and:{primary:"et",alternatives:["aussi","\xE9galement"],normalized:"and"},end:{primary:"fin",alternatives:["terminer","finir"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"asynchrone",normalized:"async"},tell:{primary:"dire",normalized:"tell"},default:{primary:"d\xE9faut",normalized:"default"},init:{primary:"initialiser",normalized:"init"},behavior:{primary:"comportement",normalized:"behavior"},install:{primary:"installer",normalized:"install"},measure:{primary:"mesurer",normalized:"measure"},into:{primary:"dans",normalized:"into"},before:{primary:"avant",normalized:"before"},after:{primary:"apr\xE8s",normalized:"after"},click:{primary:"clic",alternatives:["clique"],normalized:"click"},hover:{primary:"survol",alternatives:["survoler"],normalized:"hover"},submit:{primary:"soumission",alternatives:["soumettre"],normalized:"submit"},input:{primary:"saisie",alternatives:["entr\xE9e"],normalized:"input"},change:{primary:"changement",alternatives:["modifier"],normalized:"change"},until:{primary:"jusqu'\xE0",alternatives:["jusque"],normalized:"until"},event:{primary:"\xE9v\xE9nement",normalized:"event"},from:{primary:"de",alternatives:["depuis"],normalized:"from"}},eventHandler:{keyword:{primary:"sur",alternatives:["lors"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["depuis"],position:"before"},conditionalKeyword:{primary:"quand",alternatives:["lorsque"]},eventMarker:{primary:"au",alternatives:["lors du","lors de"],position:"before"},temporalMarkers:["quand","lorsque"]}};var{isLetter:En,isIdentifierChar:wn}=V(/[a-zA-ZàâäéèêëîïôùûüçœæÀÂÄÉÈÊËÎÏÔÙÛÜÇŒÆ]/),zt=new Set(["\xE0","a","de","du","des","dans","sur","sous","avec","sans","par","pour","entre","avant","apr\xE8s","apres","depuis","vers","chez","contre","au","aux"]),Rn=[{native:"vrai",normalized:"true"},{native:"faux",normalized:"false"},{native:"nul",normalized:"null"},{native:"ind\xE9fini",normalized:"undefined"},{native:"indefini",normalized:"undefined"},{native:"premier",normalized:"first"},{native:"premi\xE8re",normalized:"first"},{native:"premiere",normalized:"first"},{native:"dernier",normalized:"last"},{native:"derni\xE8re",normalized:"last"},{native:"derniere",normalized:"last"},{native:"suivant",normalized:"next"},{native:"pr\xE9c\xE9dent",normalized:"previous"},{native:"precedent",normalized:"previous"},{native:"plus proche",normalized:"closest"},{native:"parent",normalized:"parent"},{native:"clic",normalized:"click"},{native:"click",normalized:"click"},{native:"entr\xE9e",normalized:"input"},{native:"entree",normalized:"input"},{native:"changement",normalized:"change"},{native:"soumission",normalized:"submit"},{native:"touche bas",normalized:"keydown"},{native:"touche haut",normalized:"keyup"},{native:"souris dessus",normalized:"mouseover"},{native:"souris dehors",normalized:"mouseout"},{native:"focus",normalized:"focus"},{native:"flou",normalized:"blur"},{native:"chargement",normalized:"load"},{native:"d\xE9filement",normalized:"scroll"},{native:"defilement",normalized:"scroll"},{native:"je",normalized:"me"},{native:"mon",normalized:"my"},{native:"ma",normalized:"my"},{native:"mes",normalized:"my"},{native:"\xE7a",normalized:"it"},{native:"ca",normalized:"it"},{native:"resultat",normalized:"result"},{native:"evenement",normalized:"event"},{native:"seconde",normalized:"s"},{native:"secondes",normalized:"s"},{native:"milliseconde",normalized:"ms"},{native:"millisecondes",normalized:"ms"},{native:"minute",normalized:"m"},{native:"minutes",normalized:"m"},{native:"heure",normalized:"h"},{native:"heures",normalized:"h"},{native:"prefixer",normalized:"prepend"},{native:"creer",normalized:"make"},{native:"definir",normalized:"set"},{native:"etablir",normalized:"set"},{native:"incrementer",normalized:"increment"},{native:"decrementer",normalized:"decrement"},{native:"declencher",normalized:"trigger"},{native:"defocaliser",normalized:"blur"},{native:"recuperer",normalized:"fetch"},{native:"repeter",normalized:"repeat"},{native:"arreter",normalized:"halt"},{native:"defaut",normalized:"default"},{native:"jusqua",normalized:"until"},{native:"apres",normalized:"after"},{native:"journaliser",normalized:"log"},{native:"transmuter",normalized:"morph"},{native:"tant que",normalized:"while"}],Cn=[{pattern:"millisecondes",suffix:"ms",length:13,caseInsensitive:!0},{pattern:"milliseconde",suffix:"ms",length:12,caseInsensitive:!0},{pattern:"secondes",suffix:"s",length:8,caseInsensitive:!0},{pattern:"seconde",suffix:"s",length:7,caseInsensitive:!0},{pattern:"minutes",suffix:"m",length:7,caseInsensitive:!0},{pattern:"minute",suffix:"m",length:6,caseInsensitive:!0},{pattern:"heures",suffix:"h",length:6,caseInsensitive:!0},{pattern:"heure",suffix:"h",length:5,caseInsensitive:!0}],_e=class extends w{constructor(){super();this.language="fr";this.direction="ltr";this.initializeKeywordsFromProfile(Z,Rn)}tokenize(e){let r=[],n=0;for(;n<e.length;){if(P(e[n])){n++;continue}if(R(e[n])){let a=this.tryEventModifier(e,n);if(a){r.push(a),n=a.position.end;continue}let l=this.trySelector(e,n);if(l){r.push(l),n=l.position.end;continue}}if(C(e[n])){let a=this.tryString(e,n);if(a){r.push(a),n=a.position.end;continue}}if(N(e,n)){let a=this.tryUrl(e,n);if(a){r.push(a),n=a.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let a=this.extractNumber(e,n);if(a){r.push(a),n=a.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}if(En(e[n])){let a=this.extractWord(e,n);if(a){r.push(a),n=a.position.end;continue}}let s=this.tryOperator(e,n);if(s){r.push(s),n=s.position.end;continue}n++}return new E(r,"fr")}classifyToken(e){let r=e.toLowerCase();return zt.has(r)?"particle":this.isKeyword(r)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":"identifier"}extractWord(e,r){let n=r,o="";for(;n<e.length&&wn(e[n]);)o+=e[n++];if(!o)return null;let s=o.toLowerCase(),a=this.lookupKeyword(s);return a?S(o,"keyword",x(r,n),a.normalized):zt.has(s)?S(o,"particle",x(r,n)):S(o,"identifier",x(r,n))}extractNumber(e,r){return this.tryNumberWithTimeUnits(e,r,Cn,{allowSign:!0,skipWhitespace:!0})}},ve=new _e;M("fr",ve,Z);var Y={code:"de",name:"German",nativeName:"Deutsch",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:!0,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:!1},references:{me:"ich",it:"es",you:"du",result:"Ergebnis",event:"Ereignis",target:"Ziel",body:"K\xF6rper"},possessive:{marker:"",markerPosition:"before-property",usePossessiveAdjectives:!0,specialForms:{me:"mein",it:"sein",you:"dein"},keywords:{mein:"me",meine:"me",meinen:"me",dein:"you",deine:"you",deinen:"you",sein:"it",seine:"it",seinen:"it"}},roleMarkers:{destination:{primary:"auf",alternatives:["zu","in"],position:"before"},source:{primary:"von",alternatives:["aus"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"mit",position:"before"}},keywords:{toggle:{primary:"umschalten",alternatives:["wechseln"],normalized:"toggle"},add:{primary:"hinzuf\xFCgen",normalized:"add"},remove:{primary:"entfernen",alternatives:["l\xF6schen"],normalized:"remove"},put:{primary:"setzen",alternatives:["stellen","platzieren"],normalized:"put"},append:{primary:"anh\xE4ngen",normalized:"append"},prepend:{primary:"voranstellen",normalized:"prepend"},take:{primary:"nehmen",normalized:"take"},make:{primary:"machen",alternatives:["erstellen","erzeugen"],normalized:"make"},clone:{primary:"klonen",alternatives:["kopieren"],normalized:"clone"},swap:{primary:"austauschen",alternatives:["tauschen","wechseln"],normalized:"swap"},morph:{primary:"verwandeln",alternatives:["transformieren"],normalized:"morph"},set:{primary:"festlegen",alternatives:["definieren"],normalized:"set"},get:{primary:"holen",alternatives:["bekommen"],normalized:"get"},increment:{primary:"erh\xF6hen",normalized:"increment"},decrement:{primary:"verringern",alternatives:["vermindern"],normalized:"decrement"},log:{primary:"protokollieren",alternatives:["ausgeben"],normalized:"log"},show:{primary:"zeigen",alternatives:["anzeigen"],normalized:"show"},hide:{primary:"verbergen",alternatives:["verstecken"],normalized:"hide"},transition:{primary:"\xFCbergang",alternatives:["animieren"],normalized:"transition"},on:{primary:"bei",alternatives:["wenn","auf"],normalized:"on"},trigger:{primary:"ausl\xF6sen",normalized:"trigger"},send:{primary:"senden",alternatives:["schicken"],normalized:"send"},focus:{primary:"fokussieren",normalized:"focus"},blur:{primary:"defokussieren",alternatives:["entfokussieren"],normalized:"blur"},go:{primary:"gehen",alternatives:["navigieren"],normalized:"go"},wait:{primary:"warten",normalized:"wait"},fetch:{primary:"abrufen",alternatives:["laden"],normalized:"fetch"},settle:{primary:"stabilisieren",normalized:"settle"},if:{primary:"wenn",alternatives:["falls"],normalized:"if"},when:{primary:"wenn",normalized:"when"},where:{primary:"wo",normalized:"where"},else:{primary:"sonst",alternatives:["ansonsten"],normalized:"else"},repeat:{primary:"wiederholen",normalized:"repeat"},for:{primary:"f\xFCr",normalized:"for"},while:{primary:"solange",alternatives:["w\xE4hrend"],normalized:"while"},continue:{primary:"fortfahren",alternatives:["weiter"],normalized:"continue"},halt:{primary:"anhalten",alternatives:["stoppen"],normalized:"halt"},throw:{primary:"werfen",normalized:"throw"},call:{primary:"aufrufen",normalized:"call"},return:{primary:"zur\xFCckgeben",normalized:"return"},then:{primary:"dann",alternatives:["danach","anschlie\xDFend"],normalized:"then"},and:{primary:"und",alternatives:["sowie","auch"],normalized:"and"},end:{primary:"ende",alternatives:["beenden","fertig"],normalized:"end"},js:{primary:"js",alternatives:["javascript"],normalized:"js"},async:{primary:"asynchron",normalized:"async"},tell:{primary:"sagen",normalized:"tell"},default:{primary:"standard",normalized:"default"},init:{primary:"initialisieren",normalized:"init"},behavior:{primary:"verhalten",normalized:"behavior"},install:{primary:"installieren",normalized:"install"},measure:{primary:"messen",normalized:"measure"},into:{primary:"hinein",normalized:"into"},before:{primary:"vor",normalized:"before"},after:{primary:"nach",normalized:"after"},click:{primary:"Klick",alternatives:["Klicken"],normalized:"click"},hover:{primary:"Hover",alternatives:["Schweben"],normalized:"hover"},submit:{primary:"Absenden",alternatives:["Senden"],normalized:"submit"},input:{primary:"Eingabe",normalized:"input"},change:{primary:"\xC4nderung",alternatives:["\xC4ndern"],normalized:"change"},until:{primary:"bis",normalized:"until"},event:{primary:"Ereignis",alternatives:["Event"],normalized:"event"},from:{primary:"von",alternatives:["aus"],normalized:"from"}},eventHandler:{keyword:{primary:"bei",alternatives:["auf"],normalized:"on"},sourceMarker:{primary:"von",alternatives:["aus"],position:"before"},conditionalKeyword:{primary:"wenn",alternatives:["falls"]},eventMarker:{primary:"bei",alternatives:["beim"],position:"before"},temporalMarkers:["wenn","bei"]}};var{isLetter:Nn,isIdentifierChar:Ln}=V(/[a-zA-ZäöüÄÖÜß]/),Pt=new Set(["an","auf","aus","bei","durch","f\xFCr","fur","gegen","in","mit","nach","ohne","seit","\xFCber","uber","um","unter","von","vor","zu","zwischen","bis","gegen\xFCber","gegenuber","w\xE4hrend","wahrend","wegen","trotz","statt","innerhalb","au\xDFerhalb","ausserhalb"]),Mn=[{native:"wahr",normalized:"true"},{native:"falsch",normalized:"false"},{native:"null",normalized:"null"},{native:"undefiniert",normalized:"undefined"},{native:"erste",normalized:"first"},{native:"erster",normalized:"first"},{native:"erstes",normalized:"first"},{native:"letzte",normalized:"last"},{native:"letzter",normalized:"last"},{native:"letztes",normalized:"last"},{native:"n\xE4chste",normalized:"next"},{native:"nachste",normalized:"next"},{native:"vorherige",normalized:"previous"},{native:"n\xE4chste",normalized:"closest"},{native:"eltern",normalized:"parent"},{native:"klick",normalized:"click"},{native:"click",normalized:"click"},{native:"eingabe",normalized:"input"},{native:"\xE4nderung",normalized:"change"},{native:"anderung",normalized:"change"},{native:"absenden",normalized:"submit"},{native:"taste unten",normalized:"keydown"},{native:"taste oben",normalized:"keyup"},{native:"maus dr\xFCber",normalized:"mouseover"},{native:"maus druber",normalized:"mouseover"},{native:"maus weg",normalized:"mouseout"},{native:"fokus",normalized:"focus"},{native:"unsch\xE4rfe",normalized:"blur"},{native:"unscharfe",normalized:"blur"},{native:"scrollen",normalized:"scroll"},{native:"meine",normalized:"my"},{native:"meinen",normalized:"my"},{native:"ergebnis",normalized:"result"},{native:"ziel",normalized:"target"},{native:"sekunde",normalized:"s"},{native:"sekunden",normalized:"s"},{native:"millisekunde",normalized:"ms"},{native:"millisekunden",normalized:"ms"},{native:"minute",normalized:"m"},{native:"minuten",normalized:"m"},{native:"stunde",normalized:"h"},{native:"stunden",normalized:"h"},{native:"hinzufugen",normalized:"add"},{native:"hinzufgen",normalized:"add"},{native:"loschen",normalized:"remove"},{native:"anhangen",normalized:"append"},{native:"erhohen",normalized:"increment"},{native:"ubergang",normalized:"transition"},{native:"auslosen",normalized:"trigger"},{native:"zuruckgeben",normalized:"return"},{native:"anschliessend",normalized:"then"},{native:"erh\xF6he",normalized:"increment"},{native:"erhohe",normalized:"increment"},{native:"verringere",normalized:"decrement"}],An=[{pattern:"millisekunden",suffix:"ms",length:13,caseInsensitive:!0},{pattern:"millisekunde",suffix:"ms",length:12,caseInsensitive:!0},{pattern:"sekunden",suffix:"s",length:8,caseInsensitive:!0},{pattern:"sekunde",suffix:"s",length:7,caseInsensitive:!0},{pattern:"minuten",suffix:"m",length:7,caseInsensitive:!0},{pattern:"minute",suffix:"m",length:6,caseInsensitive:!0},{pattern:"stunden",suffix:"h",length:7,caseInsensitive:!0},{pattern:"stunde",suffix:"h",length:6,caseInsensitive:!0}],qe=class extends w{constructor(){super();this.language="de";this.direction="ltr";this.initializeKeywordsFromProfile(Y,Mn)}tokenize(e){let r=[],n=0;for(;n<e.length;){if(P(e[n])){n++;continue}if(R(e[n])){let a=this.tryEventModifier(e,n);if(a){r.push(a),n=a.position.end;continue}let l=this.trySelector(e,n);if(l){r.push(l),n=l.position.end;continue}}if(C(e[n])){let a=this.tryString(e,n);if(a){r.push(a),n=a.position.end;continue}}if(N(e,n)){let a=this.tryUrl(e,n);if(a){r.push(a),n=a.position.end;continue}}if(T(e[n])||e[n]==="-"&&n+1<e.length&&T(e[n+1])){let a=this.extractNumber(e,n);if(a){r.push(a),n=a.position.end;continue}}let o=this.tryVariableRef(e,n);if(o){r.push(o),n=o.position.end;continue}if(Nn(e[n])){let a=this.extractWord(e,n);if(a){r.push(a),n=a.position.end;continue}}let s=this.tryOperator(e,n);if(s){r.push(s),n=s.position.end;continue}n++}return new E(r,"de")}classifyToken(e){let r=e.toLowerCase();return Pt.has(r)?"particle":this.isKeyword(r)?"keyword":e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?"selector":e.startsWith('"')||e.startsWith("'")||/^\d/.test(e)?"literal":"identifier"}extractWord(e,r){let n=r,o="";for(;n<e.length&&Ln(e[n]);)o+=e[n++];if(!o)return null;let s=o.toLowerCase(),a=this.lookupKeyword(s);return a?S(o,"keyword",x(r,n),a.normalized):Pt.has(s)?S(o,"particle",x(r,n)):S(o,"identifier",x(r,n))}extractNumber(e,r){return this.tryNumberWithTimeUnits(e,r,An,{allowSign:!0,skipWhitespace:!0})}},xe=new qe;M("de",xe,Y);function Et(i){return et(i)}function Se(i,t){return rt(i,t)}function Te(){return me()}function j(i){let t="complex";return i.startsWith("#")&&!i.includes(" ")?t="id":i.startsWith(".")&&!i.includes(" ")?t="class":i.startsWith("[")&&i.endsWith("]")?t="attribute":/^[a-z][a-z0-9]*$/i.test(i)&&(t="element"),{type:"selector",value:i,selectorKind:t}}function k(i,t){let e={type:"literal",value:i};return t!==void 0?{type:"literal",value:i,dataType:t}:e}function O(i){return{type:"reference",value:i}}function J(i,t){return{type:"property-path",object:i,property:t}}function K(i,t,e){let r={kind:"command",action:i,roles:new Map(Object.entries(t))};return e!==void 0?{...r,metadata:e}:r}function ee(i,t,e,r,n){let o=new Map;o.set("event",i);let s={kind:"event-handler",action:"on",roles:o,body:t};return e!==void 0&&(s.eventModifiers=e),r!==void 0&&(s.metadata=r),n!==void 0&&n.length>0&&(s.parameterNames=n),s}function wt(i,t="then",e){let r={kind:"compound",action:"compound",roles:new Map,statements:i,chainType:t};return e!==void 0&&(r.metadata=e),r}function We(i,t){return!t||t.length===0||t.includes(i)||t.includes("expression")?!0:i==="property-path"?t.some(e=>["selector","reference","expression"].includes(e)):!1}function Rt(i,t){return i.possessive?.keywords?.[t]}var _=class _{constructor(){this.stemMatchCount=0;this.totalKeywordMatches=0}matchPattern(t,e){let r=t.mark(),n=new Map;if(this.currentProfile=q(e.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(t,e.template.tokens,n))return t.reset(r),null;let s=this.calculateConfidence(e,n);return this.applyExtractionRules(e,n),{pattern:e,captured:n,consumedTokens:t.position()-r.position,confidence:s}}matchBest(t,e){let r=[];for(let o of e){let s=t.mark(),a=this.matchPattern(t,o);a&&r.push(a),t.reset(s)}if(r.length===0)return null;r.sort((o,s)=>{let a=s.pattern.priority-o.pattern.priority;return a!==0?a:s.confidence-o.confidence});let n=r[0];return this.matchPattern(t,n.pattern),n}matchTokenSequence(t,e,r){let n=e[0],o=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;t.peek()?.kind==="conjunction";)t.advance();for(let s of e)if(!this.matchPatternToken(t,s,r)){if(this.isOptional(s))continue;return!1}return!0}matchPatternToken(t,e,r){switch(e.type){case"literal":return this.matchLiteralToken(t,e);case"role":return this.matchRoleToken(t,e,r);case"group":return this.matchGroupToken(t,e,r);default:return!1}}matchLiteralToken(t,e){let r=t.peek();if(!r)return!1;let n=this.getMatchType(r,e.value);if(n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,t.advance(),!0;if(e.alternatives)for(let o of e.alternatives){let s=this.getMatchType(r,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,t.advance(),!0}return!1}matchRoleToken(t,e,r){this.skipNoiseWords(t);let n=t.peek();if(!n)return e.optional||!1;let o=this.tryMatchPossessiveExpression(t);if(o)return e.expectedTypes&&e.expectedTypes.length>0&&!e.expectedTypes.includes(o.type)&&!e.expectedTypes.includes("expression")?e.optional||!1:(r.set(e.role,o),!0);let s=this.tryMatchMethodCallExpression(t);if(s)return e.expectedTypes&&e.expectedTypes.length>0&&!e.expectedTypes.includes(s.type)&&!e.expectedTypes.includes("expression")?e.optional||!1:(r.set(e.role,s),!0);let a=this.tryMatchPossessiveSelectorExpression(t);if(a)return e.expectedTypes&&e.expectedTypes.length>0&&!We(a.type,e.expectedTypes)?e.optional||!1:(r.set(e.role,a),!0);let l=this.tryMatchPropertyAccessExpression(t);if(l)return e.expectedTypes&&e.expectedTypes.length>0&&!e.expectedTypes.includes(l.type)&&!e.expectedTypes.includes("expression")?e.optional||!1:(r.set(e.role,l),!0);let c=this.tryMatchSelectorPropertyExpression(t);if(c)return e.expectedTypes&&e.expectedTypes.length>0&&!We(c.type,e.expectedTypes)?e.optional||!1:(r.set(e.role,c),!0);let d=this.tokenToSemanticValue(n);return!d||e.expectedTypes&&e.expectedTypes.length>0&&!e.expectedTypes.includes(d.type)?e.optional||!1:(r.set(e.role,d),t.advance(),!0)}tryMatchPossessiveExpression(t){let e=t.peek();if(!e||!this.currentProfile)return null;let r=(e.normalized||e.value).toLowerCase(),n=Rt(this.currentProfile,r);if(!n)return null;let o=t.mark();t.advance();let s=t.peek();return s&&(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*"))?(t.advance(),J(O(n),s.value)):(t.reset(o),null)}isStructuralKeyword(t){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(t.toLowerCase())}tryMatchMethodCallExpression(t){let e=t.peek();if(!e||e.kind!=="selector")return null;let r=t.mark();t.advance();let n=t.peek();if(!n||n.kind!=="operator"||n.value!==".")return t.reset(r),null;t.advance();let o=t.peek();if(!o||o.kind!=="identifier")return t.reset(r),null;t.advance();let s=t.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return t.reset(r),null;t.advance();let a=[];for(;!t.isAtEnd()&&a.length<_.MAX_METHOD_ARGS;){let c=t.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){t.advance();break}if(c.kind==="punctuation"&&c.value===","){t.advance();continue}a.push(c.value),t.advance()}return{type:"expression",raw:`${e.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(t){let e=t.peek();if(!e||e.kind!=="identifier"&&e.kind!=="keyword")return null;let r=t.mark();t.advance();let n=t.peek();if(!n||n.kind!=="operator"||n.value!==".")return t.reset(r),null;t.advance();let o=t.peek();if(!o||o.kind!=="identifier")return t.reset(r),null;t.advance();let s=`${e.value}.${o.value}`,a=1;for(;!t.isAtEnd()&&a<_.MAX_PROPERTY_DEPTH;){let c=t.peek();if(!c||c.kind!=="operator"||c.value!==".")break;t.advance();let d=t.peek();if(!d||d.kind!=="identifier")break;t.advance(),s+=`.${d.value}`,a++}let l=t.peek();if(l&&l.kind==="punctuation"&&l.value==="("){t.advance();let c=[],d=0;for(;!t.isAtEnd()&&c.length<_.MAX_METHOD_ARGS;){let h=t.peek();if(!h)break;if(h.kind==="punctuation"&&h.value===")"){if(d===0){t.advance();break}d--}if(h.kind==="punctuation"&&h.value==="("&&d++,h.kind==="punctuation"&&h.value===","){t.advance();continue}c.push(h.value),t.advance()}return{type:"expression",raw:`${s}(${c.join(", ")})`}}return{type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(t){let e=t.peek();if(!e||e.kind!=="selector")return null;let r=t.mark();t.advance();let n=t.peek();if(!n||n.kind!=="punctuation"||n.value!=="'s")return t.reset(r),null;t.advance();let o=t.peek();return!o||o.kind!=="selector"&&o.kind!=="identifier"?(t.reset(r),null):(t.advance(),J(j(e.value),o.value))}tryMatchSelectorPropertyExpression(t){let e=t.peek();if(!e||e.kind!=="selector"||!e.value.startsWith("#"))return null;let r=t.mark();t.advance();let n=t.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return t.reset(r),null;let o=t.peek(1);o&&o.kind,t.advance();let s=n.value.slice(1);return J(j(e.value),s)}matchGroupToken(t,e,r){let n=t.mark(),o=new Set(r.keys());if(!this.matchTokenSequence(t,e.tokens,r)){t.reset(n);for(let a of r.keys())o.has(a)||r.delete(a);return e.optional||!1}return!0}getMatchType(t,e){return t.value===e?"exact":t.normalized===e?"normalized":t.stem===e&&t.stemConfidence!==void 0&&t.stemConfidence>=.7?"stem":t.kind==="keyword"&&t.value.toLowerCase()===e.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(t){switch(t.kind){case"selector":return j(t.value);case"literal":return this.parseLiteralValue(t.value);case"keyword":let e=(t.normalized||t.value).toLowerCase();return["me","you","it","result","event","target","body"].includes(e)?O(e):k(t.normalized||t.value);case"identifier":if(t.value.startsWith(":"))return O(t.value);let r=t.value.toLowerCase();return["me","you","it","result","event","target","body"].includes(r)?O(r):{type:"expression",raw:t.value};case"url":return k(t.value,"string");default:return null}}parseLiteralValue(t){if(t.startsWith('"')||t.startsWith("'")||t.startsWith("`")||t.startsWith("\u300C")){let n=t.slice(1,-1);return k(n,"string")}if(t==="true")return k(!0,"boolean");if(t==="false")return k(!1,"boolean");let e=t.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let n=parseFloat(e[1]);return e[2]?k(t,"duration"):k(n,"number")}let r=parseFloat(t);return isNaN(r)?k(t,"string"):k(r,"number")}applyExtractionRules(t,e){for(let[r,n]of Object.entries(t.extraction))!e.has(r)&&n.default&&e.set(r,n.default)}isOptional(t){return t.optional===!0}calculateConfidence(t,e){let r=0,n=0,o=c=>t.extraction?.[c]?.default!==void 0;for(let c of t.template.tokens)if(c.type==="role")n+=1,e.has(c.role)&&(r+=1);else if(c.type==="group"){for(let d of c.tokens)if(d.type==="role"){let g=o(d.role),h=.8;n+=h,e.has(d.role)?r+=h:g&&(r+=h*.6)}}let s=n>0?r/n:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-c)}let a=this.calculateVSOConfidenceBoost(t);s=Math.min(1,s+a);let l=this.arabicPrepositionDisambiguation(t,e);return s=Math.max(0,Math.min(1,s+l)),s}calculateVSOConfidenceBoost(t){if(t.language!=="ar")return 0;let e=t.template.tokens[0];if(!e||e.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(e.value))return .15;if(e.alternatives){for(let n of e.alternatives)if(r.has(n))return .15}return 0}arabicPrepositionDisambiguation(t,e){if(t.language!=="ar")return 0;let r=0,n={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[o,s]of e.entries()){let a=n[o];if(!a||a.length===0)continue;let l=s.metadata;if(l&&typeof l.prepositionValue=="string"){let c=l.prepositionValue;a.includes(c)?r+=.1:r-=.1}}return Math.max(-.1,Math.min(.1,r))}skipNoiseWords(t){let e=t.peek();if(!e)return;let r=e.value.toLowerCase();if(_.ENGLISH_NOISE_WORDS.has(r)){let n=t.mark();t.advance();let o=t.peek();if(o&&o.kind==="selector")return;t.reset(n)}r==="class"&&t.advance()}extractEventModifiers(t){let e={},r=!1;for(;!t.isAtEnd();){let n=t.peek();if(!n||n.kind!=="event-modifier")break;let o=n.metadata;if(!o)break;switch(r=!0,o.modifierName){case"once":e.once=!0;break;case"debounce":typeof o.value=="number"&&(e.debounce=o.value);break;case"throttle":typeof o.value=="number"&&(e.throttle=o.value);break;case"queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(e.queue=o.value);break}t.advance()}return r?e:void 0}};_.MAX_PROPERTY_DEPTH=10,_.MAX_METHOD_ARGS=20,_.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var oe=_,G=new oe;var be=class{render(t,e){if(t.kind==="compound")return this.renderCompound(t,e);let r=nt(e,t.action);if(r.length===0)return this.renderExplicit(t);let n=this.findBestPattern(t,r);return n?this.renderWithPattern(t,n):this.renderExplicit(t)}renderCompound(t,e){let r=t.statements.map(o=>this.render(o,e)),n=this.getChainWord(t.chainType,e);return r.join(` ${n} `)}getChainWord(t,e){let r=q(e);return r?.keywords?r.keywords[t]?.primary??t:t}renderExplicit(t){if(t.kind==="compound"){let r=t;return r.statements.map(o=>this.renderExplicit(o)).join(` ${r.chainType} `)}let e=[t.action];for(let[r,n]of t.roles)e.push(`${r}:${this.valueToString(n)}`);if(t.kind==="event-handler"){let r=t;if(r.body&&r.body.length>0){let n=r.body.map(o=>this.renderExplicit(o));e.push(`body:${n.join(" ")}`)}}return`[${e.join(" ")}]`}supportedLanguages(){return Te()}findBestPattern(t,e){let r=e.map(n=>{let o=n.priority;for(let s of n.template.tokens)s.type==="role"&&(t.roles.has(s.role)?o+=10:s.optional||(o-=50));return n.language==="en"&&((n.id.includes("standard")||n.id.includes("en-source"))&&(o+=20),(n.id.includes("-when")||n.id.includes("-if")||n.id.includes("-upon"))&&(o-=15)),{pattern:n,score:o}});return r.sort((n,o)=>o.score-n.score),r.length>0?r[0].pattern:null}renderWithPattern(t,e){let r=[],n=e.language;for(let o of e.template.tokens){let s=this.renderPatternToken(o,t,n);s!==null&&r.push(s)}if(t.kind==="event-handler"){let o=t;if(o.body&&o.body.length>0){let s=o.body.map(a=>this.render(a,n));r.push(s.join(" "))}}return r.join(" ")}renderPatternToken(t,e,r){switch(t.type){case"literal":return t.value;case"role":{let n=e.roles.get(t.role);return n?this.valueToNaturalString(n,r):(t.optional,null)}case"group":{if(!t.tokens.filter(s=>s.type==="role"&&!s.optional).every(s=>e.roles.has(s.role))&&t.optional)return null;if(t.optional&&t.tokens.find(a=>a.type==="role"&&a.role==="destination")){let a=e.roles.get("destination");if(a?.type==="reference"&&a.value==="me")return null}let o=[];for(let s of t.tokens){let a=this.renderPatternToken(s,e,r);a!==null&&o.push(a)}return o.length>0?o.join(" "):null}default:return null}}valueToString(t){switch(t.type){case"literal":return typeof t.value=="string"?t.dataType==="string"||/\s/.test(t.value)?`"${t.value}"`:t.value:String(t.value);case"selector":return t.value;case"reference":return t.value;case"property-path":return`${this.valueToString(t.object)}'s ${t.property}`;case"expression":return t.raw}}valueToNaturalString(t,e="en"){switch(t.type){case"literal":return typeof t.value=="string"&&t.dataType==="string"?`"${t.value}"`:String(t.value);case"selector":return t.value;case"reference":return this.renderReference(t,e);case"property-path":return this.renderPropertyPath(t,e);case"expression":return t.raw}}renderReference(t,e){let r=q(e);return r?.references?r.references[t.value]??t.value:t.value}renderPropertyPath(t,e){let r=q(e),n=t.property,o=t.object.type==="reference"?t.object.value:null;if(r?.possessive?.specialForms&&o){let a=r.possessive.specialForms[o];if(a){let{markerPosition:l,usePossessiveAdjectives:c}=r.possessive;return c&&l==="after-object"?`${n} ${a}`:`${a} ${n}`}}let s=this.valueToNaturalString(t.object,e);if(r?.possessive){let{marker:a,markerPosition:l,usePossessiveAdjectives:c}=r.possessive;if(c&&o&&l==="after-object")return`${n} ${s}`;if(a)switch(l){case"between":return r.usesSpaces?`${s}${a} ${n}`:`${s}${a}${n}`;case"after-object":return`${s}${a} ${n}`;case"before-property":return`${s} ${a} ${n}`}}return e==="en"||!r?.possessive?s==="me"?`my ${n}`:s==="it"?`its ${n}`:`${s}'s ${n}`:`${s} ${n}`}},je=new be;function ae(i,t){return je.render(i,t)}function se(i){return je.renderExplicit(i)}function D(i){let t=i.trim();if(!t.startsWith("[")||!t.endsWith("]"))throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");let e=t.slice(1,-1).trim();if(!e)throw new Error("Empty explicit statement");let r=In(e);if(r.length===0)throw new Error("No command specified in explicit statement");let n=r[0].toLowerCase(),o=new Map;for(let a=1;a<r.length;a++){let l=r[a],c=l.indexOf(":");if(c===-1)throw new Error(`Invalid role format: "${l}". Expected role:value`);let d=l.slice(0,c),g=l.slice(c+1);if(d==="body"&&g.startsWith("[")){let m=On(l,c+1),u=l.slice(c+1,m+1);o.set(d,{type:"expression",raw:u});continue}let h=Vn(g);o.set(d,h)}if(n==="on"){let a=o.get("event");if(!a)throw new Error("Event handler requires event role: [on event:click ...]");let l=o.get("body"),c=[];return l&&l.type==="expression"&&c.push(D(l.raw)),o.delete("body"),ee(a,c,void 0,{sourceLanguage:"explicit"})}let s={};for(let[a,l]of o)s[a]=l;return K(n,s,{sourceLanguage:"explicit"})}function In(i){let t=[],e="",r=!1,n="",o=0;for(let s=0;s<i.length;s++){let a=i[s];if(r){e+=a,a===n&&i[s-1]!=="\\"&&(r=!1);continue}if(a==='"'||a==="'"){r=!0,n=a,e+=a;continue}if(a==="["){o++,e+=a;continue}if(a==="]"){o--,e+=a;continue}if(a===" "&&o===0){e&&(t.push(e),e="");continue}e+=a}return e&&t.push(e),t}function Vn(i){if(i.startsWith("#")||i.startsWith(".")||i.startsWith("[")||i.startsWith("@")||i.startsWith("*"))return j(i);if(i.startsWith('"')||i.startsWith("'")){let e=i.slice(1,-1);return k(e,"string")}if(i==="true")return k(!0,"boolean");if(i==="false")return k(!1,"boolean");if(["me","you","it","result","event","target","body"].includes(i.toLowerCase()))return O(i.toLowerCase());let t=i.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let e=parseFloat(t[1]);return t[2]?k(i,"duration"):k(e,"number")}return k(i,"string")}function On(i,t){let e=0;for(let r=t;r<i.length;r++)if(i[r]==="[")e++;else if(i[r]==="]"&&(e--,e===0))return r;return i.length-1}function te(i){let t=i.trim();return t.startsWith("[")&&t.endsWith("]")}var ke=class{parse(t,e){let r=Se(t,e),n=A(e);if(n.length===0)throw new Error(`No patterns available for language: ${e}`);let o=[...n].sort((d,g)=>g.priority-d.priority),s=o.filter(d=>d.command==="on"),a=G.matchBest(r,s);if(a)return this.buildEventHandler(a,r,e);let l=o.filter(d=>d.command!=="on"),c=G.matchBest(r,l);if(c)return this.buildCommand(c,e);throw new Error(`Could not parse input in ${e}: ${t}`)}canParse(t,e){try{return this.parse(t,e),!0}catch{return!1}}supportedLanguages(){return Te()}buildCommand(t,e){if(!t)throw new Error("No match to build command from");let r={};for(let[n,o]of t.captured)r[n]=o;return K(t.pattern.command,r,{sourceLanguage:e,patternId:t.pattern.id,confidence:t.confidence})}buildEventHandler(t,e,r){if(!t)throw new Error("No match to build event handler from");let n=t.captured.get("event");if(!n)throw new Error("Event handler pattern matched but no event captured");let o=G.extractEventModifiers(e),s,a=t.captured.get("action");if(a&&a.type==="literal"){let l=a.value,c={};for(let[h,m]of t.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(c[h]=m);let d=K(l,c,{sourceLanguage:r,patternId:t.pattern.id,confidence:t.confidence}),g=t.captured.get("continues");if(g&&g.type==="literal"&&g.value==="then"){let h=A(r).filter(f=>f.command!=="on").sort((f,v)=>v.priority-f.priority),m=A(r).filter(f=>f.id.startsWith("grammar-")&&f.id.includes("-continuation")).sort((f,v)=>v.priority-f.priority),u=this.parseBodyWithGrammarPatterns(e,h,m,r);u.length>0?s=[d,...u]:s=[d]}else s=[d]}else{let l=A(r).filter(c=>c.command!=="on").sort((c,d)=>d.priority-c.priority);s=this.parseBodyWithClauses(e,l,r)}return ee(n,s,o,{sourceLanguage:r,patternId:t.pattern.id,confidence:t.confidence})}parseBodyWithClauses(t,e,r){let n=[],o=[];for(;!t.isAtEnd();){let s=t.peek();if(!s)break;let a=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,r),l=s.kind==="keyword"&&this.isEndKeyword(s.value,r);if(a){if(o.length>0){let c=this.parseClause(o,e,r);n.push(...c),o.length=0}t.advance();continue}if(l){if(o.length>0){let c=this.parseClause(o,e,r);n.push(...c)}t.advance();break}o.push(s),t.advance()}if(o.length>0){let s=this.parseClause(o,e,r);n.push(...s)}return n.length>1?[wt(n,"then",{sourceLanguage:r})]:n}parseClause(t,e,r){if(t.length===0)return[];let n=new E(t,r),o=[];for(;!n.isAtEnd();){let s=G.matchBest(n,e);s?o.push(this.buildCommand(s,r)):n.advance()}return o}parseBodyWithGrammarPatterns(t,e,r,n){let o=[];for(;!t.isAtEnd();){let s=t.peek();if(s&&this.isThenKeyword(s.value,n)){t.advance();continue}if(s&&this.isEndKeyword(s.value,n)){t.advance();break}let a=!1;if(r.length>0){let l=G.matchBest(t,r);if(l){let c=l.pattern.command,d={};for(let[m,u]of l.captured)m!=="event"&&m!=="action"&&m!=="continues"&&(d[m]=u);let g=K(c,d,{sourceLanguage:n,patternId:l.pattern.id});o.push(g),a=!0;let h=l.captured.get("continues");if(h&&h.type==="literal"&&h.value==="then")continue}}if(!a){let l=G.matchBest(t,e);l&&(o.push(this.buildCommand(l,n)),a=!0)}a||t.advance()}return o}isThenKeyword(t,e){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[e]||r.en).has(t.toLowerCase())}isEndKeyword(t,e){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[e]||r.en).has(t.toLowerCase())}},Ke=new ke;function re(i,t){return Ke.parse(i,t)}function $e(i,t){return Ke.canParse(i,t)}function Be(i,t){if(te(i))return i;let e=re(i,t);return se(e)}function Ue(i,t){let e=D(i);return ae(e,t)}function Ge(i,t){return te(i)?D(i):re(i,t)}var _n=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),qn=new Set(["and","or","not","no"]),Wn=new Set(["true","false","null","undefined"]),jn=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function Ct(i){let t=[],e=0,r=1,n=1;function o(){if(t.length===0)return!0;let u=t[t.length-1];return["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(u.type)}function s(u=0){return i[e+u]??""}function a(){let u=i[e];return e++,u===`
|
|
2
|
+
`?(r++,n=1):n++,u}function l(){for(;e<i.length&&/\s/.test(i[e]);)a()}function c(u){let f="";for(;e<i.length&&u(i[e]);)f+=a();return f}function d(u){let f=u;for(a();e<i.length&&i[e]!==u;)i[e]==="\\"&&e+1<i.length&&(f+=a()),f+=a();return e<i.length&&(f+=a()),f}function g(){let u="`";for(a();e<i.length&&i[e]!=="`";)i[e]==="\\"&&e+1<i.length&&(u+=a()),u+=a();return e<i.length&&(u+=a()),u}function h(){let u="<";for(a();e<i.length&&(u+=a(),!u.endsWith("/>")););return u}function m(u,f,v){return{type:u,value:f,start:v,end:e,line:r,column:n-f.length}}for(;e<i.length&&(l(),!(e>=i.length));){let u=e,f=s();if(f==="'"&&s(1)==="s"&&!/\w/.test(s(2))){a(),a(),t.push(m("POSSESSIVE","'s",u));continue}if(f==='"'||f==="'"){let v=d(f);t.push(m("STRING",v,u));continue}if(f==="`"){let v=g();t.push(m("TEMPLATE_LITERAL",v,u));continue}if(f==="<"&&/[a-zA-Z.#\[]/.test(s(1))){let v=h();t.push(m("QUERY_SELECTOR",v,u));continue}if(f==="#"&&o()){a();let v=c(z=>/[\w-]/.test(z));t.push(m("ID_SELECTOR","#"+v,u));continue}if(f==="."&&/[a-zA-Z_-]/.test(s(1))&&o()){a();let v=c(z=>/[\w-]/.test(z));t.push(m("CLASS_SELECTOR","."+v,u));continue}if(f==="["&&o()){let v=s(1);if(v==="@"||/[a-zA-Z]/.test(v)){let z="";for(z+=a();e<i.length&&i[e]!=="]";)i[e]==='"'||i[e]==="'"?z+=d(i[e]):z+=a();e<i.length&&(z+=a()),t.push(m("ATTRIBUTE_SELECTOR",z,u));continue}}if(f==="["){a(),t.push(m("LBRACKET","[",u));continue}if(f==="]"){a(),t.push(m("RBRACKET","]",u));continue}if(/\d/.test(f)){let v=c(Pe=>/[\d.]/.test(Pe)),z=e,pe=c(Pe=>/[a-zA-Z]/.test(Pe));jn.has(pe)?t.push(m("TIME_EXPRESSION",v+pe,u)):(e=z,t.push(m("NUMBER",v,u)));continue}if(f==="("){a(),t.push(m("LPAREN","(",u));continue}if(f===")"){a(),t.push(m("RPAREN",")",u));continue}if(f==="{"){a(),t.push(m("LBRACE","{",u));continue}if(f==="}"){a(),t.push(m("RBRACE","}",u));continue}if(f===","){a(),t.push(m("COMMA",",",u));continue}if(f===":"){a(),t.push(m("COLON",":",u));continue}if(f==="."){a(),t.push(m("DOT",".",u));continue}if(f==="+"||f==="-"||f==="*"||f==="/"||f==="%"){a(),t.push(m("OPERATOR",f,u));continue}if(f==="="||f==="!"||f==="<"||f===">"){let v=a();s()==="="&&(v+=a()),t.push(m("COMPARISON",v,u));continue}if(/[a-zA-Z_$]/.test(f)){let v=c(pe=>/[\w$]/.test(pe)),z=v.toLowerCase();_n.has(z)?t.push(m("CONTEXT_VAR",v,u)):qn.has(z)?t.push(m("LOGICAL",v,u)):Wn.has(z)?t.push(m("BOOLEAN",v,u)):t.push(m("IDENTIFIER",v,u));continue}a()}return t.push(m("EOF","",e)),t}var ze=class{constructor(){this.tokens=[];this.current=0}parse(t){try{return this.tokens=Ct(t),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(e){return{success:!1,error:e instanceof Error?e.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(t){return this.peek().type===t}checkValue(t){return this.peek().value.toLowerCase()===t.toLowerCase()}match(...t){for(let e of t)if(this.check(e))return this.advance(),!0;return!1}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.checkValue("or");){let e=this.advance().value,r=this.parseAnd();t=this.createBinaryExpression(e,t,r)}return t}parseAnd(){let t=this.parseEquality();for(;this.checkValue("and");){let e=this.advance().value,r=this.parseEquality();t=this.createBinaryExpression(e,t,r)}return t}parseEquality(){let t=this.parseComparison();for(;this.match("COMPARISON")||this.checkValue("is")||this.checkValue("matches")||this.checkValue("contains")||this.checkValue("in");){let e=this.previous().value,r=this.parseComparison();t=this.createBinaryExpression(e,t,r)}return t}parseComparison(){let t=this.parseAddition();for(;this.check("COMPARISON");){let e=this.advance().value,r=this.parseAddition();t=this.createBinaryExpression(e,t,r)}return t}parseAddition(){let t=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let e=this.advance().value,r=this.parseMultiplication();t=this.createBinaryExpression(e,t,r)}return t}parseMultiplication(){let t=this.parseUnary();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%";){let e=this.advance().value,r=this.parseUnary();t=this.createBinaryExpression(e,t,r)}return t}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let t=this.advance().value,e=this.parseUnary();return this.createUnaryExpression(t,e)}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance().value;t=this.createPropertyAccess(t,e)}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance().value;t=this.createPossessiveExpression(t,e)}else break;else if(this.match("LPAREN")){let e=this.parseArguments();t=this.createCallExpression(t,e)}else if(this.match("LBRACKET")){let e=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");t=this.createPropertyAccess(t,e)}else break;return t}parsePrimary(){let t=this.peek();if(this.match("NUMBER"))return this.createLiteral(parseFloat(t.value),"number",t);if(this.match("STRING")){let e=t.value.slice(1,-1);return this.createLiteral(e,"string",t)}if(this.match("BOOLEAN")){let e=t.value==="true"?!0:t.value==="false"?!1:t.value==="null"?null:void 0;return this.createLiteral(e,t.value,t)}if(this.match("TEMPLATE_LITERAL"))return{type:"templateLiteral",value:t.value,start:t.start,end:t.end,line:t.line,column:t.column};if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(t);if(this.match("ID_SELECTOR"))return this.createSelector(t.value,"id",t);if(this.match("CLASS_SELECTOR"))return this.createSelector(t.value,"class",t);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(t.value,"attribute",t);if(this.match("QUERY_SELECTOR")){let e=t.value.slice(1,-2);return this.createSelector(e,"query",t)}if(this.match("CONTEXT_VAR"))return this.createContextReference(t.value,t);if(this.match("IDENTIFIER"))return this.createIdentifier(t.value,t);if(this.match("LPAREN")){let e=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return e}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${t.value}`)}parseArguments(){let t=[];if(!this.check("RPAREN"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return t}parseArrayLiteral(){let t=[],e=this.previous().start;if(!this.check("RBRACKET"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return{type:"arrayLiteral",elements:t,start:e,end:this.previous().end}}parseObjectLiteral(){let t=[],e=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 n=this.parseExpression();t.push({key:r,value:n})}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return{type:"objectLiteral",properties:t.map(r=>({type:"objectProperty",key:r.key,value:r.value})),start:e,end:this.previous().end}}parseTimeExpression(t){let e=t.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!e)throw new Error(`Invalid time expression: ${t.value}`);let r=parseFloat(e[1]),n=e[2].toLowerCase();return{type:"timeExpression",value:r,unit:n,raw:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createLiteral(t,e,r){return{type:"literal",value:t,dataType:e,raw:r.value,start:r.start,end:r.end,line:r.line,column:r.column}}createSelector(t,e,r){return{type:"selector",value:t,selector:t,selectorType:e,start:r.start,end:r.end,line:r.line,column:r.column}}createContextReference(t,e){return{type:"contextReference",contextType:t,name:e.value,start:e.start,end:e.end,line:e.line,column:e.column}}createIdentifier(t,e){return{type:"identifier",name:t,start:e.start,end:e.end,line:e.line,column:e.column}}createPropertyAccess(t,e){return{type:"propertyAccess",object:t,property:typeof e=="string"?e:e.name??"",start:t.start,end:this.previous().end}}createPossessiveExpression(t,e){return{type:"possessiveExpression",object:t,property:e,start:t.start,end:this.previous().end}}createBinaryExpression(t,e,r){return{type:"binaryExpression",operator:t,left:e,right:r,start:e.start,end:r.end}}createUnaryExpression(t,e){return{type:"unaryExpression",operator:t,operand:e,prefix:!0,start:this.previous().start,end:e.end}}createCallExpression(t,e){return{type:"callExpression",callee:t,arguments:e,start:t.start,end:this.previous().end}}};function De(i){return new ze().parse(i)}function L(i,t){switch(i.type){case"literal":return Kn(i);case"selector":return $n(i,t);case"reference":return Bn(i);case"property-path":return Un(i,t);case"expression":return Gn(i);default:let e=i;throw new Error(`Unknown semantic value type: ${e.type}`)}}function Kn(i){let t={type:"literal",value:i.value};return i.dataType?{...t,dataType:i.dataType}:t}function $n(i,t){return t&&i.value.startsWith("*")&&/^[a-zA-Z-]/.test(i.value.slice(1))&&t.push(`Converted '${i.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:i.value,selector:i.value,selectorType:i.selectorKind}}function Bn(i){return{type:"contextReference",contextType:i.value,name:i.value}}function Un(i,t){return{type:"propertyAccess",object:L(i.object,t),property:i.property}}function Gn(i){let t=De(i.raw);return!t.success||!t.node?{type:"identifier",name:i.raw}:t.node}function Nt(i,t){return i.roles.get(t)}function p(i,t,e){let r=Nt(i,t);return r?L(r,e):void 0}function y(i,t=[],e,r={}){let n={type:"command",name:i,args:t};return e&&Object.keys(e).length>0&&(n.modifiers=e),r.isBlocking&&(n.isBlocking=r.isBlocking),r.implicitTarget&&(n.implicitTarget=r.implicitTarget),n}var Dn={action:"toggle",toAST(i,t){let e=p(i,"patient"),r=p(i,"destination"),n=p(i,"duration"),o=e?[e]:[],s={};return r&&(s.on=r),n&&(s.for=n),y("toggle",o,s)}},Hn={action:"add",toAST(i,t){let e=p(i,"patient"),r=p(i,"destination"),n=e?[e]:[],o={};return r&&(o.to=r),y("add",n,o)}},Fn={action:"remove",toAST(i,t){let e=p(i,"patient"),r=p(i,"source"),n=e?[e]:[],o={};return r&&(o.from=r),y("remove",n,o)}},Xn={action:"set",toAST(i,t){let e=p(i,"destination"),r=p(i,"patient"),n=[],o={};return e&&n.push(e),r&&(o.to=r),y("set",n,o)}},Qn={action:"show",toAST(i,t){let e=p(i,"destination"),r=p(i,"patient"),n=p(i,"duration"),o=[],s={},a=e??r;return a&&o.push(a),n&&(s.with=n),y("show",o,s)}},Zn={action:"hide",toAST(i,t){let e=p(i,"destination"),r=p(i,"patient"),n=p(i,"duration"),o=[],s={},a=e??r;return a&&o.push(a),n&&(s.with=n),y("hide",o,s)}},Yn={action:"increment",toAST(i,t){let e=p(i,"destination"),r=p(i,"patient"),n=p(i,"quantity"),o=[],s={},a=e??r;return a&&o.push(a),n&&(s.by=n),y("increment",o,s)}},Jn={action:"decrement",toAST(i,t){let e=p(i,"destination"),r=p(i,"patient"),n=p(i,"quantity"),o=[],s={},a=e??r;return a&&o.push(a),n&&(s.by=n),y("decrement",o,s)}},ei={action:"wait",toAST(i,t){let e=p(i,"duration");return y("wait",e?[e]:[],void 0,{isBlocking:!0})}},ti={action:"log",toAST(i,t){let e=p(i,"patient"),r=[];return e&&r.push(e),y("log",r)}},ri={action:"put",toAST(i,t){let e=p(i,"patient"),r=p(i,"destination"),n=Nt(i,"method"),o=e?[e]:[],s={};if(r){let a=n?.type==="literal"?String(n.value):"into";s[a]=r}return y("put",o,s)}},ni={action:"fetch",toAST(i,t){let e=p(i,"source"),r=p(i,"method"),n=p(i,"responseType"),o=p(i,"patient"),s=e?[e]:[],a={};return r&&(a.with=r),n&&(a.as=n),o&&(a.body=o),y("fetch",s,a,{isBlocking:!0})}},ii={action:"append",toAST(i,t){let e=p(i,"patient"),r=p(i,"destination"),n=e?[e]:[],o={};return r&&(o.to=r),y("append",n,o)}},oi={action:"prepend",toAST(i,t){let e=p(i,"patient"),r=p(i,"destination"),n=e?[e]:[],o={};return r&&(o.to=r),y("prepend",n,o)}},ai={action:"trigger",toAST(i,t){let e=p(i,"event"),r=p(i,"destination"),n=e?[e]:[],o={};return r&&(o.on=r),y("trigger",n,o)}},si={action:"send",toAST(i,t){let e=p(i,"event"),r=p(i,"destination"),n=p(i,"patient"),o=e?[e]:[],s={};return r&&(s.to=r),n&&(s.detail=n),y("send",o,s)}},li={action:"go",toAST(i,t){let e=p(i,"source"),r=p(i,"destination"),n=[],o={};return e&&n.push(e),r&&(o.to=r),y("go",n,o)}},ci={action:"transition",toAST(i,t){let e=p(i,"patient"),r=p(i,"goal"),n=p(i,"duration"),o=p(i,"destination"),s=e?[e]:[],a={};return r&&(a.to=r),n&&(a.over=n),o&&(a.on=o),y("transition",s,a)}},di={action:"focus",toAST(i,t){let e=p(i,"destination"),r=p(i,"patient"),n=[],o={},s=e??r;return s&&n.push(s),y("focus",n,o)}},pi={action:"blur",toAST(i,t){let e=p(i,"destination"),r=p(i,"patient"),n=[],o=e??r;return o&&n.push(o),y("blur",n)}},mi={action:"get",toAST(i,t){let e=p(i,"source"),r=p(i,"patient"),n=[],o=e??r;return o&&n.push(o),y("get",n)}},ui={action:"take",toAST(i,t){let e=p(i,"patient"),r=p(i,"source"),n=e?[e]:[],o={};return r&&(o.from=r),y("take",n,o)}},fi={action:"call",toAST(i,t){let e=p(i,"patient");return y("call",e?[e]:[])}},gi={action:"return",toAST(i,t){let e=p(i,"patient");return y("return",e?[e]:[])}},yi={action:"halt",toAST(i,t){return y("halt",[])}},hi={action:"throw",toAST(i,t){let e=p(i,"patient");return y("throw",e?[e]:[])}},vi={action:"settle",toAST(i,t){let e=p(i,"destination"),r=p(i,"patient"),n=[],o=e??r;return o&&n.push(o),y("settle",n,void 0,{isBlocking:!0})}},xi={action:"swap",toAST(i,t){let e=p(i,"patient"),r=p(i,"source"),n=p(i,"destination"),o=p(i,"style"),s=[],a={};return e&&s.push(e),r&&s.push(r),n&&(a.on=n),o&&(a.with=o),y("swap",s,a)}},Si={action:"morph",toAST(i,t){let e=p(i,"source"),r=p(i,"destination"),n=p(i,"patient"),o=[],s={},a=e??n;return a&&o.push(a),r&&(s.on=r),y("morph",o,s)}},Ti={action:"clone",toAST(i,t){let e=p(i,"source"),r=p(i,"destination"),n=p(i,"patient"),o=[],s={},a=e??n;return a&&o.push(a),r&&(s.into=r),y("clone",o,s)}},bi={action:"make",toAST(i,t){let e=p(i,"patient");return y("make",e?[e]:[])}},ki={action:"measure",toAST(i,t){let e=p(i,"patient"),r=p(i,"destination"),n=p(i,"source"),o=[],s={};e&&o.push(e);let a=r??n;return a&&(s.of=a),y("measure",o,s)}},zi={action:"tell",toAST(i,t){let e=p(i,"destination"),r=p(i,"patient"),n=[],o=e??r;return o&&n.push(o),y("tell",n)}},Pi={action:"js",toAST(i,t){let e=p(i,"patient");return y("js",e?[e]:[])}},Ei={action:"async",toAST(i,t){return y("async",[])}},wi={action:"if",toAST(i,t){let e=p(i,"condition");return y("if",e?[e]:[])}},Ri={action:"unless",toAST(i,t){let e=p(i,"condition");return y("unless",e?[e]:[])}},Ci={action:"repeat",toAST(i,t){let e=p(i,"quantity"),r=p(i,"patient"),n=[],o=e??r;return o&&n.push(o),y("repeat",n)}},Ni={action:"for",toAST(i,t){let e=p(i,"patient"),r=p(i,"source"),n=e?[e]:[],o={};return r&&(o.in=r),y("for",n,o)}},Li={action:"while",toAST(i,t){let e=p(i,"condition");return y("while",e?[e]:[])}},Mi={action:"continue",toAST(i,t){return y("continue",[])}},Ai={action:"default",toAST(i,t){let e=p(i,"patient"),r=p(i,"source"),n=e?[e]:[],o={};return r&&(o.to=r),y("default",n,o)}},Ii={action:"init",toAST(i,t){return y("init",[])}},Vi={action:"behavior",toAST(i,t){let e=p(i,"patient");return y("behavior",e?[e]:[])}},Oi={action:"install",toAST(i,t){let e=p(i,"patient"),r=p(i,"destination"),n=e?[e]:[],o={};return r&&(o.on=r),y("install",n,o)}},_i={action:"on",toAST(i,t){let e=p(i,"event"),r=p(i,"source"),n=e?[e]:[],o={};return r&&(o.from=r),y("on",n,o)}},Lt=new Map([["toggle",Dn],["add",Hn],["remove",Fn],["set",Xn],["show",Qn],["hide",Zn],["increment",Yn],["decrement",Jn],["wait",ei],["log",ti],["put",ri],["fetch",ni],["append",ii],["prepend",oi],["get",mi],["take",ui],["trigger",ai],["send",si],["on",_i],["go",li],["transition",ci],["focus",di],["blur",pi],["call",fi],["return",gi],["halt",yi],["throw",hi],["settle",vi],["swap",xi],["morph",Si],["clone",Ti],["measure",ki],["make",bi],["tell",zi],["default",Ai],["js",Pi],["async",Ei],["if",wi],["unless",Ri],["repeat",Ci],["for",Ni],["while",Li],["continue",Mi],["init",Ii],["behavior",Vi],["install",Oi]]);function le(i){return Lt.get(i)}function He(i){Lt.set(i.action,i)}var ce=class{constructor(t={}){this.warnings=[]}build(t){switch(t.kind){case"command":return this.buildCommand(t);case"event-handler":return this.buildEventHandler(t);case"conditional":return this.buildConditional(t);case"compound":return this.buildCompound(t);case"loop":return this.buildLoop(t);default:throw new Error(`Unknown semantic node kind: ${t.kind}`)}}buildCommand(t){let e=le(t.action);if(e){let r=e.toAST(t,this);if("ast"in r&&"warnings"in r){let n=r;return this.warnings.push(...n.warnings),n.ast}else return r}return this.buildGenericCommand(t)}buildGenericCommand(t){let e=[],r={},n=["patient","source","quantity"],o=["destination","duration","method","style"];for(let a of n){let l=t.roles.get(a);l&&e.push(L(l))}for(let a of o){let l=t.roles.get(a);if(l){let c=this.roleToModifierKey(a);r[c]=L(l)}}let s={type:"command",name:t.action,args:e};return Object.keys(r).length>0?{...s,modifiers:r}:s}roleToModifierKey(t){return{destination:"on",duration:"for",source:"from",condition:"if",method:"via",style:"with"}[t]??t}buildEventHandler(t){let e=t.roles.get("event"),r,n;if(e?.type==="literal"){let v=String(e.value);v.includes("|")||v.includes(" or ")?(n=v.split(/\s+or\s+|\|/).map(z=>z.trim()),r=n[0]):r=v}else e?.type==="reference"?r=e.value:r="click";let o=t.body.map(v=>this.build(v)),s=t.roles.get("source"),a,l;s?.type==="selector"?(a=s.value,l=s.value):s?.type==="reference"?l=s.value:s?.type==="literal"&&(l=String(s.value));let c=t.roles.get("condition"),d=c?L(c):void 0,g=t.roles.get("destination"),h=g?L(g):void 0,m=t.eventModifiers,u=a;if(m?.from){let v=m.from;v.type==="selector"&&!a&&(u=v.value)}let f=t.parameterNames?[...t.parameterNames]:void 0;return{type:"eventHandler",event:r,commands:o,...n&&n.length>1?{events:n}:{},...u?{selector:u}:{},...l?{target:l}:{},...d?{condition:d}:{},...h?{watchTarget:h}:{},...f&&f.length>0?{args:f,params:f}:{}}}buildConditional(t){let e=t.roles.get("condition");if(!e)throw new Error("Conditional node missing condition");let r=L(e),n=t.thenBranch.map(a=>this.build(a)),o=t.elseBranch?.map(a=>this.build(a)),s=[r,{type:"block",commands:n}];return o&&o.length>0&&s.push({type:"block",commands:o}),{type:"command",name:"if",args:s}}buildCompound(t){let e=t.statements.map(n=>this.build(n));return e.length===1?e[0]:e.length===0?{type:"block",commands:[]}:{type:"CommandSequence",commands:e}}buildLoop(t){let e=t.body.map(n=>this.build(n)),r=[{type:"identifier",name:t.loopVariant}];switch(t.loopVariant){case"times":{let n=t.roles.get("quantity");n&&r.push(L(n));break}case"for":{t.loopVariable&&r.push({type:"string",value:t.loopVariable});let n=t.roles.get("source");n&&r.push(L(n));break}case"while":case"until":{let n=t.roles.get("condition");n&&r.push(L(n));break}case"forever":break}return r.push({type:"block",commands:e}),{type:"command",name:"repeat",args:r}}buildBlock(t){return{type:"block",commands:t.map(r=>this.build(r))}}};function Mt(i){let t=new ce;return{ast:t.build(i),warnings:t.warnings}}var H=class{constructor(t={}){this.cache=new Map,this.config={maxSize:t.maxSize??1e3,ttlMs:t.ttlMs??0,enabled:t.enabled??!0},this.stats={hits:0,misses:0,evictions:0,expirations:0}}makeKey(t,e){return`${e}:${t}`}isExpired(t){return this.config.ttlMs===0?!1:Date.now()-t.createdAt>this.config.ttlMs}evictLRU(){let t=this.cache.keys().next().value;t!==void 0&&(this.cache.delete(t),this.stats.evictions++)}get(t,e){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(t,e),n=this.cache.get(r);if(!n){this.stats.misses++;return}if(this.isExpired(n)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),n.lastAccessed=Date.now(),this.cache.set(r,n),this.stats.hits++,n.result}set(t,e,r){if(!this.config.enabled||r.confidence===0)return;let n=this.makeKey(t,e),o=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(n,{result:r,createdAt:o,lastAccessed:o})}has(t,e){if(!this.config.enabled)return!1;let r=this.makeKey(t,e),n=this.cache.get(r);return n?this.isExpired(n)?(this.cache.delete(r),this.stats.expirations++,!1):!0:!1}delete(t,e){let r=this.makeKey(t,e);return this.cache.delete(r)}clear(){this.cache.clear()}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0}}getStats(){let t=this.stats.hits+this.stats.misses;return{hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:t>0?this.stats.hits/t:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(t){if(t.maxSize!==void 0)for(this.config.maxSize=t.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();t.ttlMs!==void 0&&(this.config.ttlMs=t.ttlMs),t.enabled!==void 0&&(this.config.enabled=t.enabled)}enable(){this.config.enabled=!0}disable(){this.config.enabled=!1}getConfig(){return{...this.config}}},Fe=new H;var de=class{constructor(t={}){this.patternMatcher=new oe,this.languages=new Set(me()),t.cache===!1?this.cache=new H({enabled:!1}):this.cache=t.cache?new H(t.cache):Fe}analyze(t,e){if(!this.supportsLanguage(e))return{confidence:0,errors:[`Language '${e}' is not supported for semantic parsing`]};let r=this.cache.get(t,e);if(r)return r;let n=this.analyzeUncached(t,e);return this.cache.set(t,e,n),n}analyzeUncached(t,e){try{let r=Et(e);if(!r)return{confidence:0,errors:[`No tokenizer available for language '${e}'`]};let n=r.tokenize(t),o=A(e);if(o.length===0)return{confidence:0,errors:[`No patterns available for language '${e}'`]};let s=this.patternMatcher.matchBest(n,o);if(!s)return{confidence:0,errors:["No pattern matched the input"]};let a=this.buildSemanticNode(s);return{confidence:s.confidence,command:{name:s.pattern.command,roles:s.captured},node:a,tokensConsumed:s.consumedTokens}}catch(r){return{confidence:0,errors:[r instanceof Error?r.message:String(r)]}}}supportsLanguage(t){return this.languages.has(t)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear()}configureCache(t){this.cache.configure(t)}buildSemanticNode(t){return{kind:"command",action:t.pattern.command,roles:t.captured,metadata:{patternId:t.pattern.id}}}};function At(i){return new de(i)}var Xe=.5,It=.8;function Vt(i,t=Xe){return i.confidence>=t&&i.command!==void 0}var qi="1.0.0-western",Qe=["en","es","pt","fr","de"];function Wi(){return[...Qe]}function Ot(i){if(!Qe.includes(i))throw new Error(`Language not supported in this bundle: ${i}. Supported: ${Qe.join(", ")}`)}function ji(i,t){return Ot(t),[...Se(i,t).tokens]}function _t(i){return Ot(i),A(i)}function Ki(i,t){return _t(i).filter(e=>e.command===t).sort((e,r)=>r.priority-e.priority)}return Bt($i);})();
|