@lokascript/hyperscript-adapter 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +46 -3
  2. package/dist/hyperscript-i18n-ar.global.js +4 -4
  3. package/dist/hyperscript-i18n-bn.global.js +4 -4
  4. package/dist/hyperscript-i18n-de.global.js +4 -4
  5. package/dist/hyperscript-i18n-east-asian.global.js +4 -4
  6. package/dist/hyperscript-i18n-en.global.js +6 -6
  7. package/dist/hyperscript-i18n-es.global.js +4 -4
  8. package/dist/hyperscript-i18n-fr.global.js +4 -4
  9. package/dist/hyperscript-i18n-he.global.js +4 -4
  10. package/dist/hyperscript-i18n-hi.global.js +4 -4
  11. package/dist/hyperscript-i18n-id.global.js +4 -4
  12. package/dist/hyperscript-i18n-it.global.js +4 -4
  13. package/dist/hyperscript-i18n-ja.global.js +4 -4
  14. package/dist/hyperscript-i18n-ko.global.js +4 -4
  15. package/dist/hyperscript-i18n-ms.global.js +4 -4
  16. package/dist/hyperscript-i18n-pl.global.js +4 -4
  17. package/dist/hyperscript-i18n-pt.global.js +4 -4
  18. package/dist/hyperscript-i18n-qu.global.js +4 -4
  19. package/dist/hyperscript-i18n-ru.global.js +4 -4
  20. package/dist/hyperscript-i18n-slavic.global.js +4 -4
  21. package/dist/hyperscript-i18n-south-asian.global.js +4 -4
  22. package/dist/hyperscript-i18n-southeast-asian.global.js +4 -4
  23. package/dist/hyperscript-i18n-sw.global.js +4 -4
  24. package/dist/hyperscript-i18n-th.global.js +4 -4
  25. package/dist/hyperscript-i18n-tl.global.js +4 -4
  26. package/dist/hyperscript-i18n-tr.global.js +4 -4
  27. package/dist/hyperscript-i18n-uk.global.js +4 -4
  28. package/dist/hyperscript-i18n-vi.global.js +4 -4
  29. package/dist/hyperscript-i18n-western.global.js +4 -4
  30. package/dist/hyperscript-i18n-zh.global.js +4 -4
  31. package/dist/hyperscript-i18n.global.js +73 -7
  32. package/dist/hyperscript-i18n.global.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/hyperscript-renderer.ts +3 -0
@@ -1,4 +1,4 @@
1
- var HyperscriptI18n=(function(exports){'use strict';var at=new Map,lt=new Map,ct=new Map;function pt(t,e,r){at.set(t,e),lt.set(t,r),ct.delete(t);}var dt=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 E(t,e){return {start:t,end:e}}function C(t,e,r,n){if(typeof n=="string")return {value:t,kind:e,position:r,normalized:n};if(n){let{normalized:i,stem:o,stemConfidence:s}=n;return {value:t,kind:e,position:r,...i!==void 0&&{normalized:i},...o!==void 0&&{stem:o},...s!==void 0&&{stemConfidence:s}}}return {value:t,kind:e,position:r}}function B(t){return /\s/.test(t)}function Se(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function ke(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function R(t){return /\d/.test(t)}function ft(t){return /[a-zA-Z]/.test(t)}function A(t){return /[a-zA-Z0-9_-]/.test(t)}function mt(t){let e=n=>t.test(n);return {isLetter:e,isIdentifierChar:n=>e(n)||/[0-9_-]/.test(n)}}function ht(t,e){if(e>=t.length)return null;let r=t[e];if(!Se(r))return null;let n=e,i="";if(r==="#"||r==="."){for(i+=t[n++];n<t.length&&A(t[n]);)i+=t[n++];if(i.length<=1)return null;if(n<t.length&&t[n]==="."&&r==="#"){let s=n+1;for(;s<t.length&&A(t[s]);)s++;if(s<t.length&&t[s]==="(")return i}}else if(r==="["){let o=1,s=false,u=null,a=false;for(i+=t[n++];n<t.length&&o>0;){let c=t[n];i+=c,a?a=false:c==="\\"?a=true:s?c===u&&(s=false,u=null):c==='"'||c==="'"||c==="`"?(s=true,u=c):c==="["?o++:c==="]"&&o--,n++;}if(o!==0)return null}else if(r==="@"){for(i+=t[n++];n<t.length&&A(t[n]);)i+=t[n++];if(i.length<=1)return null}else if(r==="*"){for(i+=t[n++];n<t.length&&A(t[n]);)i+=t[n++];if(i.length<=1)return null}else if(r==="<"){if(i+=t[n++],n>=t.length||!ft(t[n]))return null;for(;n<t.length&&A(t[n]);)i+=t[n++];for(;n<t.length;){let o=t[n];if(o==="."){if(i+=t[n++],n>=t.length||!A(t[n]))return null;for(;n<t.length&&A(t[n]);)i+=t[n++];}else if(o==="#"){if(i+=t[n++],n>=t.length||!A(t[n]))return null;for(;n<t.length&&A(t[n]);)i+=t[n++];}else if(o==="["){let s=1,u=false,a=null,c=false;for(i+=t[n++];n<t.length&&s>0;){let l=t[n];i+=l,c?c=false:l==="\\"?c=true:u?l===a&&(u=false,a=null):l==='"'||l==="'"||l==="`"?(u=true,a=l):l==="["?s++:l==="]"&&s--,n++;}if(s!==0)return null}else break}for(;n<t.length&&B(t[n]);)i+=t[n++];if(n<t.length&&t[n]==="/")for(i+=t[n++];n<t.length&&B(t[n]);)i+=t[n++];if(n>=t.length||t[n]!==">")return null;i+=t[n++];}return i||null}function vt(t,e){if(e>=t.length||t[e]!=="'"||e+1>=t.length||t[e+1].toLowerCase()!=="s")return false;if(e+2>=t.length)return true;let n=t[e+2];return B(n)||n==="*"||!A(n)}function yt(t,e){if(e>=t.length)return null;let r=t[e];if(!ke(r)||r==="'"&&vt(t,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!i)return null;let o=e+1,s=r,u=false;for(;o<t.length;){let a=t[o];if(s+=a,u)u=false;else if(a==="\\")u=true;else if(a===i)return s;o++;}return s}function be(t,e){if(e>=t.length)return false;let r=t[e],n=t[e+1]||"",i=t[e+2]||"";if(r==="/"&&n!=="/"&&/[a-zA-Z0-9._-]/.test(n)||r==="/"&&n==="/"&&/[a-zA-Z]/.test(i)||r==="."&&(n==="/"||n==="."&&i==="/"))return true;let o=t.slice(e,e+8).toLowerCase();return !!(o.startsWith("http://")||o.startsWith("https://"))}function gt(t,e){if(!be(t,e))return null;let r=e,n="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<t.length;){let o=t[r];if(o==="#"){if(n.length>0&&/[a-zA-Z0-9/.]$/.test(n))for(n+=o,r++;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)n+=t[r++];break}if(i.test(o))n+=o,r++;else break}return n.length<2?null:n}function Et(t,e){if(e>=t.length)return null;let r=t[e];if(!R(r)&&r!=="-"&&r!=="+")return null;let n=e,i="";if((t[n]==="-"||t[n]==="+")&&(i+=t[n++]),n>=t.length||!R(t[n]))return null;for(;n<t.length&&R(t[n]);)i+=t[n++];if(n<t.length&&t[n]===".")for(i+=t[n++];n<t.length&&R(t[n]);)i+=t[n++];return n<t.length&&(t.slice(n,n+2)==="ms"?i+="ms":(t[n]==="s"||t[n]==="m"||t[n]==="h")&&(i+=t[n])),i}var Ae=class we{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map;}tryPropertyAccess(e,r,n){if(e[r]!==".")return false;let i=n[n.length-1],o=i&&i.position.end<r;if(i&&!o&&(i.kind==="identifier"||i.kind==="keyword"||i.kind==="selector"))return n.push(C(".","operator",E(r,r+1))),true;let a=r+1;for(;a<e.length&&A(e[a]);)a++;return a<e.length&&e[a]==="("?(n.push(C(".","operator",E(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let n=new Map;if(e.keywords){for(let[i,o]of Object.entries(e.keywords))if(n.set(o.primary,{native:o.primary,normalized:o.normalized||i}),o.alternatives)for(let s of o.alternatives)n.set(s,{native:s,normalized:o.normalized||i});}if(e.references){for(let[i,o]of Object.entries(e.references))n.set(o,{native:o,normalized:i});for(let i of Object.keys(e.references))n.has(i)||n.set(i,{native:i,normalized:i});}if(e.roleMarkers){for(let[i,o]of Object.entries(e.roleMarkers))if(o.primary&&n.set(o.primary,{native:o.primary,normalized:i}),o.alternatives)for(let s of o.alternatives)n.set(s,{native:s,normalized:i});}for(let i of r)n.set(i.native,i);this.profileKeywords=Array.from(n.values()).sort((i,o)=>o.native.length-i.native.length),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let o=this.removeDiacritics(i.native);o!==i.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),i);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,r){for(let n of this.profileKeywords)if(e.slice(r).startsWith(n.native))return C(n.native,"keyword",E(r,r+n.native.length),n.normalized);return null}isKeywordStart(e,r){let n=e.slice(r);return this.profileKeywords.some(i=>n.startsWith(i.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let r=this.normalizer.normalize(e);return r.stem!==e&&r.confidence>=.7?r:null}tryMorphKeywordMatch(e,r,n){let i=this.tryNormalize(e);if(!i)return null;let o=this.lookupKeyword(i.stem);if(!o)return null;let s={normalized:o.normalized,stem:i.stem,stemConfidence:i.confidence};return C(e,"keyword",E(r,n),s)}trySelector(e,r){let n=ht(e,r);return n?C(n,"selector",E(r,r+n.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let n=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!n)return null;let i=n[0].replace(/(\s|\.)$/,""),o=i.slice(1).split("(")[0],s=n[1];return {...C(i,"event-modifier",E(r,r+i.length)),metadata:{modifierName:o,value:s?o==="queue"?s:parseInt(s,10):void 0}}}tryString(e,r){let n=yt(e,r);return n?C(n,"literal",E(r,r+n.length)):null}tryNumber(e,r){let n=Et(e,r);return n?C(n,"literal",E(r,r+n.length)):null}tryMatchTimeUnit(e,r,n,i=false){let o=r;if(i)for(;o<e.length&&B(e[o]);)o++;let s=e.slice(o);for(let u of n){let a=s.slice(0,u.length);if(u.caseInsensitive?a.toLowerCase()===u.pattern.toLowerCase():a===u.pattern){if(u.notFollowedBy&&(s[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let l=s[u.length]||"";if(A(l))continue}return {suffix:u.suffix,endPos:o+u.length}}}return null}parseBaseNumber(e,r,n=true){let i=r,o="";if(n&&(e[i]==="-"||e[i]==="+")&&(o+=e[i++]),i>=e.length||!R(e[i]))return null;for(;i<e.length&&R(e[i]);)o+=e[i++];if(i<e.length&&e[i]===".")for(o+=e[i++];i<e.length&&R(e[i]);)o+=e[i++];return !o||o==="-"||o==="+"?null:{number:o,endPos:i}}tryNumberWithTimeUnits(e,r,n,i={}){let{allowSign:o=true,skipWhitespace:s=false}=i,u=this.parseBaseNumber(e,r,o);if(!u)return null;let{number:a,endPos:c}=u,l=[...n,...we.STANDARD_TIME_UNITS],p=this.tryMatchTimeUnit(e,c,l,s);return p&&(a+=p.suffix,c=p.endPos),C(a,"literal",E(r,c))}tryUrl(e,r){let n=gt(e,r);return n?C(n,"url",E(r,r+n.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!A(e[r+1]))return null;let n=r+1;for(;n<e.length&&A(e[n]);)n++;let i=e.slice(r,n);return C(i,"identifier",E(r,n))}tryOperator(e,r){let n=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(n))return C(n,"operator",E(r,r+2));let i=e[r];return ["<",">","!","+","-","*","/","="].includes(i)?C(i,"operator",E(r,r+1)):["(",")","{","}",",",";",":"].includes(i)?C(i,"punctuation",E(r,r+1)):null}tryMultiCharParticle(e,r,n){for(let i of n)if(e.slice(r,r+i.length)===i)return C(i,"particle",E(r,r+i.length));return null}};Ae.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var Ct=Ae,Re={code:"ru",name:"Russian",nativeName:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",direction:"ltr",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:true,suffixes:["\u0442\u044C","\u0442\u044C\u0441\u044F","\u0438\u0442\u044C","\u0438\u0442\u044C\u0441\u044F","\u0430\u0442\u044C","\u0430\u0442\u044C\u0441\u044F","\u0435\u0442\u044C","\u0435\u0442\u044C\u0441\u044F"]},references:{me:"\u044F",it:"\u044D\u0442\u043E",you:"\u0442\u044B",result:"\u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442",event:"\u0441\u043E\u0431\u044B\u0442\u0438\u0435",target:"\u0446\u0435\u043B\u044C",body:"body"},possessive:{marker:"",markerPosition:"after-object",usePossessiveAdjectives:true,specialForms:{me:"\u043C\u043E\u0439",it:"\u0435\u0433\u043E",you:"\u0442\u0432\u043E\u0439"},keywords:{\u043C\u043E\u0439:"me",\u043C\u043E\u044F:"me",\u043C\u043E\u0451:"me",\u043C\u043E\u0438:"me",\u0442\u0432\u043E\u0439:"you",\u0442\u0432\u043E\u044F:"you",\u0442\u0432\u043E\u0451:"you",\u0442\u0432\u043E\u0438:"you",\u0435\u0433\u043E:"it",\u0435\u0451:"it"}},roleMarkers:{destination:{primary:"\u0432",alternatives:["\u043D\u0430","\u043A"],position:"before"},source:{primary:"\u0438\u0437",alternatives:["\u043E\u0442","\u0441"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"\u0441",alternatives:["\u0441\u043E"],position:"before"}},keywords:{toggle:{primary:"\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C",alternatives:["\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438"],normalized:"toggle",form:"infinitive"},add:{primary:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C",alternatives:["\u0434\u043E\u0431\u0430\u0432\u044C"],normalized:"add",form:"infinitive"},remove:{primary:"\u0443\u0434\u0430\u043B\u0438\u0442\u044C",alternatives:["\u0443\u0434\u0430\u043B\u0438","\u0443\u0431\u0440\u0430\u0442\u044C","\u0443\u0431\u0435\u0440\u0438"],normalized:"remove",form:"infinitive"},put:{primary:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",alternatives:["\u043F\u043E\u043B\u043E\u0436\u0438","\u043F\u043E\u043C\u0435\u0441\u0442\u0438\u0442\u044C","\u043F\u043E\u043C\u0435\u0441\u0442\u0438","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C","\u0432\u0441\u0442\u0430\u0432\u044C"],normalized:"put",form:"infinitive"},append:{primary:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C_\u0432_\u043A\u043E\u043D\u0435\u0446",alternatives:["\u0434\u043E\u043F\u0438\u0441\u0430\u0442\u044C"],normalized:"append",form:"infinitive"},prepend:{primary:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C_\u0432_\u043D\u0430\u0447\u0430\u043B\u043E",normalized:"prepend",form:"infinitive"},take:{primary:"\u0432\u0437\u044F\u0442\u044C",alternatives:["\u0432\u043E\u0437\u044C\u043C\u0438"],normalized:"take",form:"infinitive"},make:{primary:"\u0441\u043E\u0437\u0434\u0430\u0442\u044C",alternatives:["\u0441\u043E\u0437\u0434\u0430\u0439"],normalized:"make",form:"infinitive"},clone:{primary:"\u043A\u043B\u043E\u043D\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u043A\u043B\u043E\u043D\u0438\u0440\u0443\u0439"],normalized:"clone",form:"infinitive"},swap:{primary:"\u043F\u043E\u043C\u0435\u043D\u044F\u0442\u044C",alternatives:["\u043F\u043E\u043C\u0435\u043D\u044F\u0439"],normalized:"swap",form:"infinitive"},morph:{primary:"\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u0443\u0439"],normalized:"morph",form:"infinitive"},set:{primary:"\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C",alternatives:["\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0437\u0430\u0434\u0430\u0442\u044C","\u0437\u0430\u0434\u0430\u0439"],normalized:"set",form:"infinitive"},get:{primary:"\u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C",alternatives:["\u043F\u043E\u043B\u0443\u0447\u0438"],normalized:"get",form:"infinitive"},increment:{primary:"\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C",alternatives:["\u0443\u0432\u0435\u043B\u0438\u0447\u044C"],normalized:"increment",form:"infinitive"},decrement:{primary:"\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C",alternatives:["\u0443\u043C\u0435\u043D\u044C\u0448\u0438"],normalized:"decrement",form:"infinitive"},log:{primary:"\u0437\u0430\u043F\u0438\u0441\u0430\u0442\u044C",alternatives:["\u0437\u0430\u043F\u0438\u0448\u0438"],normalized:"log",form:"infinitive"},show:{primary:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C",alternatives:["\u043F\u043E\u043A\u0430\u0436\u0438"],normalized:"show",form:"infinitive"},hide:{primary:"\u0441\u043A\u0440\u044B\u0442\u044C",alternatives:["\u0441\u043A\u0440\u043E\u0439","\u0441\u043F\u0440\u044F\u0442\u0430\u0442\u044C","\u0441\u043F\u0440\u044F\u0447\u044C"],normalized:"hide",form:"infinitive"},transition:{primary:"\u0430\u043D\u0438\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u0430\u043D\u0438\u043C\u0438\u0440\u0443\u0439"],normalized:"transition",form:"infinitive"},on:{primary:"\u043F\u0440\u0438",alternatives:["\u043A\u043E\u0433\u0434\u0430"],normalized:"on"},trigger:{primary:"\u0432\u044B\u0437\u0432\u0430\u0442\u044C",alternatives:["\u0432\u044B\u0437\u043E\u0432\u0438"],normalized:"trigger",form:"infinitive"},send:{primary:"\u043E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C",alternatives:["\u043E\u0442\u043F\u0440\u0430\u0432\u044C"],normalized:"send",form:"infinitive"},focus:{primary:"\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u0443\u0439","\u0444\u043E\u043A\u0443\u0441"],normalized:"focus",form:"infinitive"},blur:{primary:"\u0440\u0430\u0437\u043C\u044B\u0442\u044C",alternatives:["\u0440\u0430\u0437\u043C\u043E\u0439"],normalized:"blur",form:"infinitive"},click:{primary:"\u043A\u043B\u0438\u043A",alternatives:["\u043A\u043B\u0438\u043A\u0435","\u043D\u0430\u0436\u0430\u0442\u0438\u0438"],normalized:"click"},hover:{primary:"\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u0438\u0438",alternatives:["\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u0438\u0435"],normalized:"hover"},submit:{primary:"\u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0435",alternatives:["\u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0430"],normalized:"submit"},input:{primary:"\u0432\u0432\u043E\u0434\u0435",alternatives:["\u0432\u0432\u043E\u0434"],normalized:"input"},change:{primary:"\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0438",alternatives:["\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0435"],normalized:"change"},go:{primary:"\u043F\u0435\u0440\u0435\u0439\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u0439\u0434\u0438","\u0438\u0434\u0442\u0438","\u0438\u0434\u0438"],normalized:"go",form:"infinitive"},wait:{primary:"\u0436\u0434\u0430\u0442\u044C",alternatives:["\u0436\u0434\u0438","\u043F\u043E\u0434\u043E\u0436\u0434\u0438"],normalized:"wait",form:"infinitive"},fetch:{primary:"\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",alternatives:["\u0437\u0430\u0433\u0440\u0443\u0437\u0438"],normalized:"fetch",form:"infinitive"},settle:{primary:"\u0441\u0442\u0430\u0431\u0438\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C",normalized:"settle",form:"infinitive"},if:{primary:"\u0435\u0441\u043B\u0438",normalized:"if"},when:{primary:"\u043A\u043E\u0433\u0434\u0430",normalized:"when"},where:{primary:"\u0433\u0434\u0435",normalized:"where"},else:{primary:"\u0438\u043D\u0430\u0447\u0435",normalized:"else"},repeat:{primary:"\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C",alternatives:["\u043F\u043E\u0432\u0442\u043E\u0440\u0438"],normalized:"repeat",form:"infinitive"},for:{primary:"\u0434\u043B\u044F",alternatives:["\u043A\u0430\u0436\u0434\u044B\u0439"],normalized:"for"},while:{primary:"\u043F\u043E\u043A\u0430",normalized:"while"},continue:{primary:"\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C",alternatives:["\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438"],normalized:"continue",form:"infinitive"},halt:{primary:"\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C",alternatives:["\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0441\u044C","\u0441\u0442\u043E\u043F"],normalized:"halt",form:"infinitive"},throw:{primary:"\u0431\u0440\u043E\u0441\u0438\u0442\u044C",alternatives:["\u0431\u0440\u043E\u0441\u044C"],normalized:"throw",form:"infinitive"},call:{primary:"\u0432\u044B\u0437\u0432\u0430\u0442\u044C",alternatives:["\u0432\u044B\u0437\u043E\u0432\u0438"],normalized:"call",form:"infinitive"},return:{primary:"\u0432\u0435\u0440\u043D\u0443\u0442\u044C",alternatives:["\u0432\u0435\u0440\u043D\u0438"],normalized:"return",form:"infinitive"},then:{primary:"\u0437\u0430\u0442\u0435\u043C",alternatives:["\u043F\u043E\u0442\u043E\u043C","\u0442\u043E\u0433\u0434\u0430"],normalized:"then"},and:{primary:"\u0438",normalized:"and"},end:{primary:"\u043A\u043E\u043D\u0435\u0446",normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"\u0430\u0441\u0438\u043D\u0445\u0440\u043E\u043D\u043D\u043E",alternatives:["async"],normalized:"async"},tell:{primary:"\u0441\u043A\u0430\u0437\u0430\u0442\u044C",alternatives:["\u0441\u043A\u0430\u0436\u0438"],normalized:"tell",form:"infinitive"},default:{primary:"\u043F\u043E_\u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",normalized:"default"},init:{primary:"\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u0443\u0439"],normalized:"init",form:"infinitive"},behavior:{primary:"\u043F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u0435",normalized:"behavior"},install:{primary:"\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C_\u043F\u0430\u043A\u0435\u0442",normalized:"install",form:"infinitive"},measure:{primary:"\u0438\u0437\u043C\u0435\u0440\u0438\u0442\u044C",alternatives:["\u0438\u0437\u043C\u0435\u0440\u044C"],normalized:"measure",form:"infinitive"},beep:{primary:"\u0437\u0432\u0443\u043A",normalized:"beep"},break:{primary:"\u043F\u0440\u0435\u0440\u0432\u0430\u0442\u044C",normalized:"break"},copy:{primary:"\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C",normalized:"copy"},exit:{primary:"\u0432\u044B\u0439\u0442\u0438",normalized:"exit"},pick:{primary:"\u0432\u044B\u0431\u0440\u0430\u0442\u044C",normalized:"pick"},render:{primary:"\u043E\u0442\u043E\u0431\u0440\u0430\u0437\u0438\u0442\u044C",normalized:"render"},into:{primary:"\u0432",alternatives:["\u0432\u043E"],normalized:"into"},before:{primary:"\u0434\u043E",alternatives:["\u043F\u0435\u0440\u0435\u0434"],normalized:"before"},after:{primary:"\u043F\u043E\u0441\u043B\u0435",normalized:"after"},until:{primary:"\u0434\u043E",alternatives:["\u043F\u043E\u043A\u0430_\u043D\u0435"],normalized:"until"},event:{primary:"\u0441\u043E\u0431\u044B\u0442\u0438\u0435",normalized:"event"},from:{primary:"\u0438\u0437",alternatives:["\u043E\u0442","\u0441"],normalized:"from"}},eventHandler:{keyword:{primary:"\u043F\u0440\u0438",alternatives:["\u043A\u043E\u0433\u0434\u0430"],normalized:"on"},sourceMarker:{primary:"\u043D\u0430",alternatives:["\u0432","\u043F\u0440\u0438"],position:"before"},eventMarker:{primary:"\u043F\u0440\u0438",alternatives:["\u043A\u043E\u0433\u0434\u0430"],position:"before"},temporalMarkers:["\u043A\u043E\u0433\u0434\u0430","\u0435\u0441\u043B\u0438"]}};function j(t){return {stem:t,confidence:1}}function y(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}function Tt(t){return /[а-яА-ЯёЁ]/.test(t)}function St(t){for(let e of t)if(Tt(e))return true;return false}var Ce=new Map([["\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438","\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C"],["\u0434\u043E\u0431\u0430\u0432\u044C","\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C"],["\u0443\u0434\u0430\u043B\u0438","\u0443\u0434\u0430\u043B\u0438\u0442\u044C"],["\u0443\u0431\u0435\u0440\u0438","\u0443\u0431\u0440\u0430\u0442\u044C"],["\u043F\u043E\u043B\u043E\u0436\u0438","\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C"],["\u043F\u043E\u043C\u0435\u0441\u0442\u0438","\u043F\u043E\u043C\u0435\u0441\u0442\u0438\u0442\u044C"],["\u0432\u0441\u0442\u0430\u0432\u044C","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C"],["\u0432\u043E\u0437\u044C\u043C\u0438","\u0432\u0437\u044F\u0442\u044C"],["\u0441\u043E\u0437\u0434\u0430\u0439","\u0441\u043E\u0437\u0434\u0430\u0442\u044C"],["\u043A\u043B\u043E\u043D\u0438\u0440\u0443\u0439","\u043A\u043B\u043E\u043D\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u043F\u043E\u043C\u0435\u043D\u044F\u0439","\u043F\u043E\u043C\u0435\u043D\u044F\u0442\u044C"],["\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u0443\u0439","\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C"],["\u0437\u0430\u0434\u0430\u0439","\u0437\u0430\u0434\u0430\u0442\u044C"],["\u043F\u043E\u043B\u0443\u0447\u0438","\u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C"],["\u0443\u0432\u0435\u043B\u0438\u0447\u044C","\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C"],["\u0443\u043C\u0435\u043D\u044C\u0448\u0438","\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C"],["\u0437\u0430\u043F\u0438\u0448\u0438","\u0437\u0430\u043F\u0438\u0441\u0430\u0442\u044C"],["\u043F\u043E\u043A\u0430\u0436\u0438","\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C"],["\u0441\u043A\u0440\u043E\u0439","\u0441\u043A\u0440\u044B\u0442\u044C"],["\u0441\u043F\u0440\u044F\u0447\u044C","\u0441\u043F\u0440\u044F\u0442\u0430\u0442\u044C"],["\u0430\u043D\u0438\u043C\u0438\u0440\u0443\u0439","\u0430\u043D\u0438\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u0432\u044B\u0437\u043E\u0432\u0438","\u0432\u044B\u0437\u0432\u0430\u0442\u044C"],["\u043E\u0442\u043F\u0440\u0430\u0432\u044C","\u043E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C"],["\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u0443\u0439","\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u0440\u0430\u0437\u043C\u043E\u0439","\u0440\u0430\u0437\u043C\u044B\u0442\u044C"],["\u043F\u0435\u0440\u0435\u0439\u0434\u0438","\u043F\u0435\u0440\u0435\u0439\u0442\u0438"],["\u0438\u0434\u0438","\u0438\u0434\u0442\u0438"],["\u0436\u0434\u0438","\u0436\u0434\u0430\u0442\u044C"],["\u043F\u043E\u0434\u043E\u0436\u0434\u0438","\u043F\u043E\u0434\u043E\u0436\u0434\u0430\u0442\u044C"],["\u0437\u0430\u0433\u0440\u0443\u0437\u0438","\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C"],["\u043F\u043E\u0432\u0442\u043E\u0440\u0438","\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C"],["\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438","\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C"],["\u0431\u0440\u043E\u0441\u044C","\u0431\u0440\u043E\u0441\u0438\u0442\u044C"],["\u0432\u0435\u0440\u043D\u0438","\u0432\u0435\u0440\u043D\u0443\u0442\u044C"],["\u0441\u043A\u0430\u0436\u0438","\u0441\u043A\u0430\u0437\u0430\u0442\u044C"],["\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u0443\u0439","\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u0438\u0437\u043C\u0435\u0440\u044C","\u0438\u0437\u043C\u0435\u0440\u0438\u0442\u044C"]]),xe=class{constructor(){this.language="ru";}isNormalizable(t){return t.length<3?false:St(t)}normalize(t){let e=t.toLowerCase();if(e.endsWith("\u0441\u044F")||e.endsWith("\u0441\u044C")){let s=this.tryReflexiveNormalization(e);if(s)return s}if(e.endsWith("\u0442\u044C")||e.endsWith("\u0442\u0438")||e.endsWith("\u0447\u044C"))return j(t);let r=this.tryImperativeLookup(e);if(r)return r;let n=this.tryPastTenseNormalization(e);if(n)return n;let i=this.tryPresentTenseNormalization(e);if(i)return i;let o=this.tryGenericImperativeNormalization(e);return o||j(t)}tryReflexiveNormalization(t){(t.endsWith("\u0441\u044F"),2);let r=t.slice(0,-2);if(t.endsWith("\u0442\u044C\u0441\u044F")||t.endsWith("\u0442\u0438\u0441\u044C")||t.endsWith("\u0447\u044C\u0441\u044F"))return j(t);let n=this.normalizeNonReflexive(r);if(n.confidence<1){let i=n.stem.endsWith("\u0442\u044C")?n.stem.slice(0,-2)+"\u0442\u044C\u0441\u044F":n.stem+"\u0441\u044F";return y(i,n.confidence*.95,{removedSuffixes:["\u0441\u044F",...n.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}normalizeNonReflexive(t){if(t.endsWith("\u0442\u044C")||t.endsWith("\u0442\u0438")||t.endsWith("\u0447\u044C"))return j(t);let e=this.tryImperativeLookup(t);if(e)return e;let r=this.tryPastTenseNormalization(t);if(r)return r;let n=this.tryPresentTenseNormalization(t);if(n)return n;let i=this.tryGenericImperativeNormalization(t);return i||j(t)}tryImperativeLookup(t){return Ce.has(t)?y(Ce.get(t),.95,{removedSuffixes:["imperative"],conjugationType:"imperative"}):null}tryGenericImperativeNormalization(t){return t.endsWith("\u0439\u0442\u0435")&&t.length>5?y(t.slice(0,-3)+"\u0442\u044C",.8,{removedSuffixes:["\u0439\u0442\u0435"],conjugationType:"imperative"}):t.endsWith("\u0438\u0442\u0435")&&t.length>5?y(t.slice(0,-3)+"\u0438\u0442\u044C",.8,{removedSuffixes:["\u0438\u0442\u0435"],conjugationType:"imperative"}):t.endsWith("\u0439")&&t.length>3?y(t.slice(0,-1)+"\u0442\u044C",.75,{removedSuffixes:["\u0439"],conjugationType:"imperative"}):t.endsWith("\u0438")&&t.length>3?y(t+"\u0442\u044C",.7,{removedSuffixes:["\u0438\u2192\u0438\u0442\u044C"],conjugationType:"imperative"}):null}tryPastTenseNormalization(t){return t.endsWith("\u0430\u043B\u0430")&&t.length>4?y(t.slice(0,-3)+"\u0430\u0442\u044C",.85,{removedSuffixes:["\u0430\u043B\u0430"],conjugationType:"past"}):t.endsWith("\u0438\u043B\u0430")&&t.length>4?y(t.slice(0,-3)+"\u0438\u0442\u044C",.85,{removedSuffixes:["\u0438\u043B\u0430"],conjugationType:"past"}):t.endsWith("\u0435\u043B\u043E")&&t.length>4?y(t.slice(0,-3)+"\u0435\u0442\u044C",.82,{removedSuffixes:["\u0435\u043B\u043E"],conjugationType:"past"}):t.endsWith("\u0430\u0431\u043E")&&t.length>4?y(t.slice(0,-3)+"\u0430\u0442\u044C",.82,{removedSuffixes:["\u0430\u0431\u043E"],conjugationType:"past"}):t.endsWith("\u0430\u043B\u0438")&&t.length>4?y(t.slice(0,-3)+"\u0430\u0442\u044C",.85,{removedSuffixes:["\u0430\u043B\u0438"],conjugationType:"past"}):t.endsWith("\u0438\u043B\u0438")&&t.length>4?y(t.slice(0,-3)+"\u0438\u0442\u044C",.85,{removedSuffixes:["\u0438\u043B\u0438"],conjugationType:"past"}):t.endsWith("\u0430\u043B")&&t.length>3?y(t.slice(0,-2)+"\u0430\u0442\u044C",.82,{removedSuffixes:["\u0430\u043B"],conjugationType:"past"}):t.endsWith("\u0438\u043B")&&t.length>3?y(t.slice(0,-2)+"\u0438\u0442\u044C",.82,{removedSuffixes:["\u0438\u043B"],conjugationType:"past"}):null}tryPresentTenseNormalization(t){return t.endsWith("\u0438\u0448\u044C")&&t.length>4?y(t.slice(0,-3)+"\u0438\u0442\u044C",.8,{removedSuffixes:["\u0438\u0448\u044C"],conjugationType:"present"}):t.endsWith("\u0438\u0442")&&t.length>3?y(t.slice(0,-2)+"\u0438\u0442\u044C",.78,{removedSuffixes:["\u0438\u0442"],conjugationType:"present"}):t.endsWith("\u0438\u043C")&&t.length>3?y(t.slice(0,-2)+"\u0438\u0442\u044C",.78,{removedSuffixes:["\u0438\u043C"],conjugationType:"present"}):t.endsWith("\u044F\u0442")&&t.length>3?y(t.slice(0,-2)+"\u0438\u0442\u044C",.78,{removedSuffixes:["\u044F\u0442"],conjugationType:"present"}):t.endsWith("\u0435\u0448\u044C")&&t.length>4?y(t.slice(0,-3)+"\u0430\u0442\u044C",.75,{removedSuffixes:["\u0435\u0448\u044C"],conjugationType:"present"}):t.endsWith("\u0435\u0442")&&t.length>3?y(t.slice(0,-2)+"\u0430\u0442\u044C",.72,{removedSuffixes:["\u0435\u0442"],conjugationType:"present"}):t.endsWith("\u0435\u043C")&&t.length>3?y(t.slice(0,-2)+"\u0430\u0442\u044C",.72,{removedSuffixes:["\u0435\u043C"],conjugationType:"present"}):t.endsWith("\u044E\u0442")&&t.length>3?y(t.slice(0,-2)+"\u0430\u0442\u044C",.75,{removedSuffixes:["\u044E\u0442"],conjugationType:"present"}):t.endsWith("\u0443\u0442")&&t.length>3?y(t.slice(0,-2)+"\u0430\u0442\u044C",.72,{removedSuffixes:["\u0443\u0442"],conjugationType:"present"}):null}},{isLetter:kt,isIdentifierChar:bt}=mt(/[a-zA-Zа-яА-ЯёЁ]/),Te=new Set(["\u0432","\u0432\u043E","\u043D\u0430","\u0441","\u0441\u043E","\u043A","\u043A\u043E","\u043E","\u043E\u0431","\u043E\u0431\u043E","\u0443","\u043E\u0442","\u0434\u043E","\u0438\u0437","\u0437\u0430","\u043F\u043E","\u043F\u043E\u0434","\u043D\u0430\u0434","\u043F\u0435\u0440\u0435\u0434","\u043F\u0435\u0440\u0435\u0434\u043E","\u043C\u0435\u0436\u0434\u0443","\u0447\u0435\u0440\u0435\u0437","\u0431\u0435\u0437","\u0434\u043B\u044F","\u043F\u0440\u0438","\u043F\u0440\u043E","\u043F\u043E\u0441\u043B\u0435","\u0432\u043E\u043A\u0440\u0443\u0433","\u043F\u0440\u043E\u0442\u0438\u0432","\u0432\u043C\u0435\u0441\u0442\u043E","\u043A\u0440\u043E\u043C\u0435","\u0441\u0440\u0435\u0434\u0438"]),At=[{native:"\u0438\u0441\u0442\u0438\u043D\u0430",normalized:"true"},{native:"\u043F\u0440\u0430\u0432\u0434\u0430",normalized:"true"},{native:"\u043B\u043E\u0436\u044C",normalized:"false"},{native:"null",normalized:"null"},{native:"\u043D\u0435\u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D\u043E",normalized:"undefined"},{native:"\u043F\u0435\u0440\u0432\u044B\u0439",normalized:"first"},{native:"\u043F\u0435\u0440\u0432\u0430\u044F",normalized:"first"},{native:"\u043F\u0435\u0440\u0432\u043E\u0435",normalized:"first"},{native:"\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0439",normalized:"last"},{native:"\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u044F\u044F",normalized:"last"},{native:"\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0435\u0435",normalized:"last"},{native:"\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439",normalized:"next"},{native:"\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F",normalized:"next"},{native:"\u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0438\u0439",normalized:"previous"},{native:"\u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F",normalized:"previous"},{native:"\u0431\u043B\u0438\u0436\u0430\u0439\u0448\u0438\u0439",normalized:"closest"},{native:"\u0440\u043E\u0434\u0438\u0442\u0435\u043B\u044C",normalized:"parent"},{native:"\u043A\u043B\u0438\u043A",normalized:"click"},{native:"\u043D\u0430\u0436\u0430\u0442\u0438\u0435",normalized:"click"},{native:"click",normalized:"click"},{native:"\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0435",normalized:"change"},{native:"\u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0430",normalized:"submit"},{native:"\u043A\u043B\u0430\u0432\u0438\u0448\u0430",normalized:"keydown"},{native:"\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u0438\u0435",normalized:"mouseover"},{native:"\u0443\u0445\u043E\u0434",normalized:"mouseout"},{native:"\u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0430",normalized:"load"},{native:"\u043F\u0440\u043E\u043A\u0440\u0443\u0442\u043A\u0430",normalized:"scroll"},{native:"\u0432\u0432\u043E\u0434",normalized:"input"},{native:"\u043C\u043E\u0439",normalized:"my"},{native:"\u043C\u043E\u044F",normalized:"my"},{native:"\u043C\u043E\u0451",normalized:"my"},{native:"\u043C\u043E\u0438",normalized:"my"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434\u0430",normalized:"s"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434\u044B",normalized:"s"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434",normalized:"s"},{native:"\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0430",normalized:"ms"},{native:"\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u044B",normalized:"ms"},{native:"\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434",normalized:"ms"},{native:"\u043C\u0438\u043D\u0443\u0442\u0430",normalized:"m"},{native:"\u043C\u0438\u043D\u0443\u0442\u044B",normalized:"m"},{native:"\u043C\u0438\u043D\u0443\u0442",normalized:"m"},{native:"\u0447\u0430\u0441",normalized:"h"},{native:"\u0447\u0430\u0441\u0430",normalized:"h"},{native:"\u0447\u0430\u0441\u043E\u0432",normalized:"h"},{native:"\u0438\u043B\u0438",normalized:"or"},{native:"\u043D\u0435",normalized:"not"},{native:"\u0435\u0441\u0442\u044C",normalized:"is"},{native:"\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442",normalized:"exists"},{native:"\u043F\u0443\u0441\u0442\u043E\u0439",normalized:"empty"},{native:"\u043F\u0443\u0441\u0442\u0430\u044F",normalized:"empty"},{native:"\u043F\u0443\u0441\u0442\u043E\u0435",normalized:"empty"}],wt=class extends Ct{constructor(){super(),this.language="ru",this.direction="ltr",this.initializeKeywordsFromProfile(Re,At),this.normalizer=new xe;}tokenize(t){let e=[],r=0;for(;r<t.length;){if(B(t[r])){r++;continue}if(Se(t[r])){let o=this.tryEventModifier(t,r);if(o){e.push(o),r=o.position.end;continue}if(this.tryPropertyAccess(t,r,e)){r++;continue}let s=this.trySelector(t,r);if(s){e.push(s),r=s.position.end;continue}}if(ke(t[r])){let o=this.tryString(t,r);if(o){e.push(o),r=o.position.end;continue}}if(be(t,r)){let o=this.tryUrl(t,r);if(o){e.push(o),r=o.position.end;continue}}if(R(t[r])||t[r]==="-"&&r+1<t.length&&R(t[r+1])){let o=this.extractNumber(t,r);if(o){e.push(o),r=o.position.end;continue}}let n=this.tryVariableRef(t,r);if(n){e.push(n),r=n.position.end;continue}if(kt(t[r])){let o=this.extractWord(t,r);if(o){e.push(o),r=o.position.end;continue}}let i=this.tryOperator(t,r);if(i){e.push(i),r=i.position.end;continue}r++;}return new dt(e,"ru")}classifyToken(t){let e=t.toLowerCase();return Te.has(e)?"particle":this.isKeyword(e)?"keyword":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":"identifier"}extractWord(t,e){let r=e,n="";for(;r<t.length&&bt(t[r]);)n+=t[r++];if(!n)return null;let i=n.toLowerCase();if(Te.has(i))return C(n,"particle",E(e,r));let o=this.lookupKeyword(i);return o?C(n,"keyword",E(e,r),o.normalized):C(n,"identifier",E(e,r))}extractNumber(t,e){let r=e,n="";for((t[r]==="-"||t[r]==="+")&&(n+=t[r++]);r<t.length&&R(t[r]);)n+=t[r++];if(r<t.length&&t[r]===".")for(n+=t[r++];r<t.length&&R(t[r]);)n+=t[r++];let i=r;for(;i<t.length&&B(t[i]);)i++;let o=t.slice(i).toLowerCase();return o.startsWith("\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434")||o.startsWith("\u043C\u0441")?o.startsWith("\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434")?(n+="ms",r=i+11,o.length>11&&/[аы]/.test(o[11])&&r++):(n+="ms",r=i+2):o.startsWith("\u0441\u0435\u043A\u0443\u043D\u0434")||o.startsWith("\u0441\u0435\u043A")?o.startsWith("\u0441\u0435\u043A\u0443\u043D\u0434")?(n+="s",r=i+6,o.length>6&&/[аы]/.test(o[6])&&r++):(n+="s",r=i+3):o.startsWith("\u043C\u0438\u043D\u0443\u0442")||o.startsWith("\u043C\u0438\u043D")?o.startsWith("\u043C\u0438\u043D\u0443\u0442")?(n+="m",r=i+5,o.length>5&&/[аы]/.test(o[5])&&r++):(n+="m",r=i+3):o.startsWith("\u0447\u0430\u0441")?(n+="h",r=i+3,o.length>3&&o[3]==="\u0430"?r++:o.length>3&&o.slice(3,5)==="\u043E\u0432"&&(r+=2)):o.startsWith("ms")?(n+="ms",r=i+2):o.startsWith("s")&&!o.startsWith("se")&&(n+="s",r=i+1),!n||n==="-"||n==="+"?null:C(n,"literal",E(e,r))}},Rt=new wt;pt("ru",Rt,Re);var xt=Object.defineProperty,Pt=Object.getOwnPropertyNames,Le=(t,e)=>function(){return t&&(e=(0, t[Pt(t)[0]])(t=0)),e},_t=(t,e)=>{for(var r in e)xt(t,r,{get:e[r],enumerable:true});};function Pe(t,e){return t.replace(/\{(\w+)\}/g,(r,n)=>String(e[n]??`{${n}}`))}function w(t,e,r={},n){let i=Fe[t],o=Pe(i,r),s=ze[t],u=s?Pe(s,r):void 0;return {code:t,message:o,severity:e,...n&&{role:n},...u&&{suggestion:u}}}var h,Fe,ze,Nt=Le({"src/generators/schema-error-codes.ts"(){h={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION"},Fe={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[h.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[h.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[h.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[h.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[h.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[h.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[h.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[h.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition."},ze={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[h.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[h.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[h.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[h.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[h.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition."};}}),$e={};_t($e,{SchemaErrorCodes:()=>h,formatValidationResults:()=>Ft,getValidationStats:()=>zt,validateAllSchemas:()=>Lt,validateCommandSchema:()=>qe});function Ot(t,e){return {action:t,items:e,get notes(){return e.filter(r=>r.severity==="note").map(r=>r.message)},get warnings(){return e.filter(r=>r.severity==="warning").map(r=>r.message)},get errors(){return e.filter(r=>r.severity==="error").map(r=>r.message)}}}function qe(t){let e=[];for(let n of t.roles)n.expectedTypes.includes("literal")&&n.expectedTypes.includes("selector")&&(n.role==="patient"&&ae.has(t.action)?e.push(w(h.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:n.role,command:t.action},n.role)):e.push(w(h.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:n.role},n.role))),n.expectedTypes.length>3&&!ae.has(t.action)&&e.push(w(h.TOO_MANY_EXPECTED_TYPES,"warning",{role:n.role,count:n.expectedTypes.length},n.role));switch(t.action){case "transition":It(t,e);break;case "on":Mt(t,e);break;case "if":case "unless":Bt(t,e);break;case "repeat":case "for":case "while":Dt(t,e);break}return t.roles.filter(n=>n.required).length===0&&(Ve.has(t.action)?e.push(w(h.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(w(h.NO_REQUIRED_ROLES,"warning",{}))),Ot(t.action,e)}function It(t,e){let r=t.roles.find(i=>i.role==="patient"),n=t.roles.find(i=>i.role==="goal");r&&r.expectedTypes.includes("selector")&&e.push(w(h.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),r&&!n&&e.push(w(h.TRANSITION_MISSING_GOAL,"error",{}));}function Mt(t,e){let r=t.roles.find(n=>n.role==="event");r||e.push(w(h.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(w(h.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Bt(t,e){let r=t.roles.find(n=>n.role==="condition");r||e.push(w(h.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(w(h.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Dt(t,e){t.action==="for"?t.roles.find(n=>n.role==="source")||e.push(w(h.FOR_LOOP_MISSING_SOURCE,"warning",{})):t.action==="while"&&(t.roles.find(n=>n.role==="condition")||e.push(w(h.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Lt(t,e={}){let r=new Map,{includeNotes:n=false}=e;for(let[i,o]of Object.entries(t)){let s=qe(o),u=s.items.some(c=>c.severity==="warning"||c.severity==="error"),a=n&&s.items.some(c=>c.severity==="note");(u||a)&&r.set(i,s);}return r}function Ft(t,e={}){let r=[],{showNotes:n=false,showCodes:i=true}=e;for(let[o,s]of t){let u=s.items.filter(l=>l.severity==="error"),a=s.items.filter(l=>l.severity==="warning"),c=s.items.filter(l=>l.severity==="note");if(u.length>0){r.push(` \u274C ${o}:`);for(let l of u){let p=i?` [${l.code}]`:"";r.push(` ERROR${p}: ${l.message}`),l.suggestion&&r.push(` \u{1F4A1} Suggestion: ${l.suggestion}`);}}if(a.length>0){r.push(` \u26A0\uFE0F ${o}:`);for(let l of a){let p=i?` [${l.code}]`:"";r.push(` ${p?`${l.code}: `:""}${l.message}`),l.suggestion&&r.push(` \u{1F4A1} ${l.suggestion}`);}}if(n&&c.length>0){r.push(` \u2139\uFE0F ${o}:`);for(let l of c){let p=i?` [${l.code}]`:"";r.push(` ${p?`${l.code}: `:""}${l.message}`);}}}return r.join(`
2
- `)}function zt(t){let e=0,r=0,n=0,i={};for(let o of t.values())for(let s of o.items)s.severity==="error"?e++:s.severity==="warning"?r++:s.severity==="note"&&n++,i[s.code]=(i[s.code]||0)+1;return {totalCommands:t.size,errors:e,warnings:r,notes:n,byCode:i}}var ae,Ve,$t=Le({"src/generators/schema-validator.ts"(){Nt(),ae=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Ve=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep"]);}});function U(t){let e="complex";return t.startsWith("#")&&!t.includes(" ")?e="id":t.startsWith(".")&&!t.includes(" ")?e="class":t.startsWith("[")&&t.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(t)&&(e="element"),{type:"selector",value:t,selectorKind:e}}function S(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}var qt=new Set(["me","you","it","result","event","target","body"]);function _e(t){return qt.has(t)}function O(t){return {type:"reference",value:t}}function oe(t,e){return {type:"property-path",object:t,property:e}}function Z(t,e,r){let n={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...n,metadata:r}:n}function Ne(t,e,r,n,i,o){let s=new Map;s.set("event",t);let u={kind:"event-handler",action:"on",roles:s,body:e};return r!==void 0&&(u.eventModifiers=r),n!==void 0&&(u.metadata=n),u}function Oe(t,e="then",r){let n={kind:"compound",action:"compound",roles:new Map,statements:t,chainType:e};return r!==void 0&&(n.metadata=r),n}function Ie(t,e){return !e||e.length===0||e.includes(t)||e.includes("expression")?true:t==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function Vt(t,e){return t.possessive?.keywords?.[e]}var F=new Map,z=new Map,J=new Map,le=null;function We(t,e){let r={...t};for(let n of Object.keys(e)){let i=e[n],o=t[n];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?r[n]=We(o,i):r[n]=i);}return r}function Wt(t,e){return We(t,e)}function pe(t){if(!t.extends)return t;let e=z.get(t.extends);if(!e)return console.warn(`[Registry] Profile '${t.code}' extends '${t.extends}' but base is not registered. Make sure to import the base language before the variant.`),t;let r=pe(e);return Wt(r,t)}function je(t){le=t;}var Me=new Map;function $(t){return t.split("-")[0]}function q(t){return t.includes("-")}function jt(t){let e=F.get(t);if(!e&&q(t)){let r=$(t);e=F.get(r);}if(!e){let r=Array.from(F.keys()).join(", ");throw new Error(`Language '${t}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${t}';`)}return e}function Gt(t){let e=z.get(t);if(!e&&q(t)){let r=$(t);e=z.get(r);}if(!e){let r=Array.from(z.keys()).join(", ");throw new Error(`Language profile '${t}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${t}';`)}return pe(e)}function Ut(t){let e=F.get(t);return !e&&q(t)&&(e=F.get($(t))),e}function I(t){let e=z.get(t);return !e&&q(t)&&(e=z.get($(t))),e?pe(e):void 0}function Ge(){return Array.from(F.keys())}function Ht(t,e){return jt(e).tokenize(t)}function L(t){let e=J.get(t);if(!e&&q(t)&&(e=J.get($(t))),e)return e;let r=Me.get(t);if(!r&&q(t)&&(r=Me.get($(t))),r)return J.set(t,r),r;if(!le)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let n=Gt(t),i=le(n);return J.set(t,i),i}var ee=class G{constructor(){this.stemMatchCount=0,this.totalKeywordMatches=0;}matchPattern(e,r){let n=e.mark(),i=new Map;if(this.currentProfile=I(r.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,r.template.tokens,i))return e.reset(n),null;let s=this.calculateConfidence(r,i);return this.applyExtractionRules(r,i),{pattern:r,captured:i,consumedTokens:e.position()-n.position,confidence:s}}matchBest(e,r){let n=[];for(let o of r){let s=e.mark(),u=this.matchPattern(e,o);u&&n.push(u),e.reset(s);}if(n.length===0)return null;n.sort((o,s)=>{let u=s.pattern.priority-o.pattern.priority;return u!==0?u:s.confidence-o.confidence});let i=n[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,r,n){let i=r[0],o=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();for(let s of r)if(!this.matchPatternToken(e,s,n)){if(this.isOptional(s))continue;return false}return true}matchPatternToken(e,r,n){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,n);case "group":return this.matchGroupToken(e,r,n);default:return false}}matchLiteralToken(e,r){let n=e.peek();if(!n)return false;let i=this.getMatchType(n,r.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let o of r.alternatives){let s=this.getMatchType(n,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,n){this.skipNoiseWords(e);let i=e.peek();if(!i)return r.optional||false;let o=this.tryMatchPossessiveExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(o.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(n.set(r.role,o),true);let s=this.tryMatchMethodCallExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(s.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(n.set(r.role,s),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Ie(u.type,r.expectedTypes)?r.optional||false:(n.set(r.role,u),true);let a=this.tryMatchPropertyAccessExpression(e);if(a)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(a.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(n.set(r.role,a),true);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return r.expectedTypes&&r.expectedTypes.length>0&&!Ie(c.type,r.expectedTypes)?r.optional||false:(n.set(r.role,c),true);let l=this.tokenToSemanticValue(i);return !l||r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(l.type)?r.optional||false:(n.set(r.role,l),e.advance(),true)}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let n=(r.normalized||r.value).toLowerCase(),i=Vt(this.currentProfile,n);if(!i)return null;let o=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(o),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let u=s.value;s.kind==="selector"&&u.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u)&&(u=u.substring(1));let a=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)a+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(a+=c.value,e.advance()),oe(O(i),a)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(n),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<G.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}u.push(c.value),e.advance();}return {type:"expression",raw:`${r.value}.${o.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let s=`${r.value}.${o.value}`,u=1;for(;!e.isAtEnd()&&u<G.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let l=e.peek();if(!l||l.kind!=="identifier")break;e.advance(),s+=`.${l.value}`,u++;}let a=e.peek();if(a&&a.kind==="punctuation"&&a.value==="("){e.advance();let c=[],l=0;for(;!e.isAtEnd()&&c.length<G.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(l===0){e.advance();break}l--;}if(d.kind==="punctuation"&&d.value==="("&&l++,d.kind==="punctuation"&&d.value===","){e.advance();continue}c.push(d.value),e.advance();}return {type:"expression",raw:`${s}(${c.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(n),null;e.advance();let o=e.peek();return !o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(n),null):(e.advance(),oe(U(r.value),o.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(n),null;let o=e.peek(1);o&&o.kind,e.advance();let s=i.value.slice(1);return oe(U(r.value),s)}matchGroupToken(e,r,n){let i=e.mark(),o=new Set(n.keys());if(!this.matchTokenSequence(e,r.tokens,n)){e.reset(i);for(let u of n.keys())o.has(u)||n.delete(u);return r.optional||false}return true}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return U(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return _e(r)?O(r):S(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return O(e.value);let n=e.value.toLowerCase();return _e(n)?O(n):{type:"expression",raw:e.value};case "url":return S(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return S(i,"string")}if(e==="true")return S(true,"boolean");if(e==="false")return S(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let i=parseFloat(r[1]);return r[2]?S(e,"duration"):S(i,"number")}let n=parseFloat(e);return isNaN(n)?S(e,"string"):S(n,"number")}applyExtractionRules(e,r){for(let[n,i]of Object.entries(e.extraction))r.has(n)||(i.value!==void 0?r.set(n,{type:"literal",value:i.value}):i.default&&r.set(n,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let n=0,i=0,o=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")i+=1,r.has(c.role)&&(n+=1);else if(c.type==="group"){for(let l of c.tokens)if(l.type==="role"){let p=o(l.role),d=.8;i+=d,r.has(l.role)?n+=d:p&&(n+=d*.6);}}let s=i>0?n/i:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-c);}let u=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+u);let a=this.arabicPrepositionDisambiguation(e,r);return s=Math.max(0,Math.min(1,s+a)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let r=e.template.tokens[0];if(!r||r.type!=="literal")return 0;let n=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(n.has(r.value))return .15;if(r.alternatives){for(let i of r.alternatives)if(n.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let n=0,i={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[o,s]of r.entries()){let u=i[o];if(!u||u.length===0)continue;let a="metadata"in s?s.metadata:void 0;if(a&&typeof a.prepositionValue=="string"){let c=a.prepositionValue;u.includes(c)?n+=.1:n-=.1;}}return Math.max(-0.1,Math.min(.1,n))}skipNoiseWords(e){let r=e.peek();if(!r)return;let n=r.value.toLowerCase();if(G.ENGLISH_NOISE_WORDS.has(n)){let i=e.mark();e.advance();let o=e.peek();if(o&&o.kind==="selector")return;e.reset(i);}n==="class"&&e.advance();}extractEventModifiers(e){let r={},n=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(n=true,o.modifierName){case "once":r.once=true;break;case "debounce":typeof o.value=="number"&&(r.debounce=o.value);break;case "throttle":typeof o.value=="number"&&(r.throttle=o.value);break;case "queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(r.queue=o.value);break}e.advance();}return n?r:void 0}};ee.MAX_PROPERTY_DEPTH=10;ee.MAX_METHOD_ARGS=20;ee.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ue=ee,D=new Ue,se=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 Yt(t){return Ut(t)}function ue(t,e){return Ht(t,e)}function He(){return Ge()}var Xt={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyut_de\u011Fi\u015Ftir:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};var V=class P{parse(e,r){let{modifiers:n,remainingInput:i}=this.extractStandaloneModifiers(e,r),o=i||e,s=ue(o,r),u=L(r);if(u.length===0)throw new Error(`No patterns available for language: ${r}`);let a=[...u].sort((v,k)=>k.priority-v.priority),c=a.filter(v=>v.command==="on"),l=D.matchBest(s,c);if(l){let v=this.buildEventHandler(l,s,r);return n?this.applyModifiers(v,n):v}let p=a.filter(v=>v.command!=="on"),d=D.matchBest(s,p);if(d)return this.buildCommand(d,r);let f=this.trySOVEventExtraction(o,r,a);if(f)return n?this.applyModifiers(f,n):f;let m=this.tryCompoundCommandParsing(s,p,r);if(m)return m;throw new Error(`Could not parse input in ${r}: ${o}`)}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return He()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let n={};for(let[i,o]of e.captured)n[i]=o;return Z(e.pattern.command,n,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,r,n){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");let o=D.extractEventModifiers(r),s=this.extractOrConjunctionEvents(r,n),u=i;s.length>0&&i.type==="literal"&&(u={type:"literal",value:[String(i.value),...s.map(p=>String("value"in p?p.value:""))].join(" or ")});let a,c=e.captured.get("action");if(c&&c.type==="literal"){let l=c.value,p={};for(let[m,v]of e.captured)m!=="event"&&m!=="action"&&m!=="continues"&&(p[m]=v);let d=Z(l,p,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence}),f=e.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then"){let m=L(n).filter(T=>T.command!=="on").sort((T,x)=>x.priority-T.priority),v=L(n).filter(T=>T.id.startsWith("grammar-")&&T.id.includes("-continuation")).sort((T,x)=>x.priority-T.priority),k=this.parseBodyWithGrammarPatterns(r,m,v,n);k.length>0?a=[d,...k]:a=[d];}else a=[d];}else {let l=L(n).filter(p=>p.command!=="on").sort((p,d)=>d.priority-p.priority);a=this.parseBodyWithClauses(r,l,n);}return Ne(u,a,o,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,n){let i=[],o=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;let u=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,n),a=s.kind==="keyword"&&this.isEndKeyword(s.value,n);if(u){if(o.length>0){let c=this.parseClause(o,r,n);i.push(...c),o.length=0;}e.advance();continue}if(a){if(o.length>0){let c=this.parseClause(o,r,n);i.push(...c);}e.advance();break}o.push(s),e.advance();}if(o.length>0){let s=this.parseClause(o,r,n);i.push(...s);}return i.length>1?[Oe(i,"then",{sourceLanguage:n})]:i}parseClause(e,r,n){if(e.length===0)return [];let i=new se(e,n),o=[];for(;!i.isAtEnd();){let s=D.matchBest(i,r);s?o.push(this.buildCommand(s,n)):i.advance();}if(o.length===0){let s=this.parseSOVClauseByVerbAnchoring(e,n);if(s.length>0)return s}return o}static buildVerbLookup(e){let r=new Map;for(let[n,i]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(n)&&(r.set(i.primary.toLowerCase(),n),i.alternatives))for(let o of i.alternatives)r.set(o.toLowerCase(),n);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[n,i]of Object.entries(e.roleMarkers))if(i&&(r.set(i.primary,n),i.alternatives))for(let o of i.alternatives)r.has(o)||r.set(o,n);return r}parseSOVClauseByVerbAnchoring(e,r){let n=I(r);if(!n||n.wordOrder!=="SOV")return [];let i=P.buildVerbLookup(n),o=P.buildMarkerToRoleLookup(n),s=[],u=0;for(;u<e.length;){let a=-1,c="";for(let m=u;m<e.length;m++){let v=e[m],k=i.get(v.value.toLowerCase()),T=v.normalized?i.get(v.normalized.toLowerCase()):void 0,x=k||T;if(x){a=m,c=x;break}}if(a===-1)break;let l=e.slice(u,a),p=e.length;for(let m=a+1;m<e.length;m++){let v=e[m];if(v.kind==="conjunction"||this.isThenKeyword(v.value,r)){p=m;break}if(m>a+1&&(i.get(v.value.toLowerCase())||(v.normalized?i.get(v.normalized.toLowerCase()):void 0))){p=m;break}}let d=e.slice(a+1,p),f=this.extractRolesFromMarkedTokens(l,d,o,c,r);if(s.push(Z(c,f,{sourceLanguage:r,confidence:.7})),u=p,u<e.length){let m=e[u];(m.kind==="conjunction"||this.isThenKeyword(m.value,r))&&u++;}}return s}extractRolesFromMarkedTokens(e,r,n,i,o){let s={},u=a=>{let c=[];for(let l of a){let p=n.get(l.value);if(p&&l.kind==="particle"&&c.length>0){let d=this.tokensToSemanticValue(c);if(d){let f=this.mapRoleForCommand(p,i,s);f&&(s[f]=d);}c=[];}else c.push(l);}if(c.length>0){let l=this.tokensToSemanticValue(c);l&&(s.patient?s.destination||(s.destination=l):s.patient=l);}};return u(e),u(r),s}mapRoleForCommand(e,r,n){return n[e]?e==="patient"&&!n.destination?"destination":e==="destination"&&!n.patient?"patient":e==="source"&&!n.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let r=e.filter(o=>o.kind!=="whitespace");if(r.length===0)return null;if(r.length===1)return this.tokenToSemanticValue(r[0]);let n=r.map(o=>o.value).join(""),i=r[0];return i.kind==="selector"||i.value.startsWith("#")||i.value.startsWith(".")||i.value.startsWith("@")||i.value.startsWith("*")?U(n):i.kind==="literal"||i.value.startsWith('"')||i.value.startsWith("'")?S(n):i.kind==="reference"?O(n):S(n)}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return U(r);if(r.startsWith('"')||r.startsWith("'"))return S(r);if(/^-?\d+(\.\d+)?$/.test(r))return S(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return S(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return S(false);let n=e.normalized?.toLowerCase();return n==="me"||n==="it"||n==="you"||n==="result"||n==="body"?O(n):e.kind==="reference"?O(e.normalized||"me"):S(r)}parseBodyWithGrammarPatterns(e,r,n,i){let o=[];for(;!e.isAtEnd();){let s=e.peek();if(s&&this.isThenKeyword(s.value,i)){e.advance();continue}if(s&&this.isEndKeyword(s.value,i)){e.advance();break}let u=false;if(n.length>0){let a=D.matchBest(e,n);if(a){let c=a.pattern.command,l={};for(let[f,m]of a.captured)f!=="event"&&f!=="action"&&f!=="continues"&&(l[f]=m);let p=Z(c,l,{sourceLanguage:i,patternId:a.pattern.id});o.push(p),u=true;let d=a.captured.get("continues");if(d&&d.type==="literal"&&d.value==="then")continue}}if(!u){let a=D.matchBest(e,r);a&&(o.push(this.buildCommand(a,i)),u=true);}u||e.advance();}return o}tryCompoundCommandParsing(e,r,n){let i=e.tokens;if(!i.some(a=>a.kind==="conjunction"||a.kind==="keyword"&&this.isThenKeyword(a.value,n)))return null;let s=new se(i,n),u=this.parseBodyWithClauses(s,r,n);return u.length===0?null:u.length===1?u[0]:Oe(u,"then",{sourceLanguage:n,confidence:.65})}trySOVEventExtraction(e,r,n){let i=P.SOV_EVENT_MARKERS[r];if(!i)return null;let s=ue(e,r).tokens,u=Xt[r],a=new Set;if(u)for(let g of Object.keys(u))a.add(g.toLowerCase());let c=P.SOV_SOURCE_MARKERS[r],l=-1,p="",d="",f=1;for(let g=0;g<s.length;g++){let b=s[g],_=b.value.toLowerCase(),N=_,M="",re=_.indexOf("[");re>0&&(N=_.slice(0,re),M=b.value.slice(re));let ne=b.normalized?.toLowerCase(),ge=ne&&P.KNOWN_EVENTS.has(ne),Ee=a.has(_)||a.has(N),ut=P.KNOWN_EVENTS.has(N);if(ge||Ee||ut){let W;if(ge?W=ne:Ee?W=u?.[_]??u?.[N]??N:W=N,i.size>0){let X=1,ie=s[g+1];ie&&ie.kind==="selector"&&ie.value.startsWith("[")&&(X=2);let Q=s[g+X];if(Q&&(Q.kind==="particle"||Q.kind==="keyword")&&i.has(Q.value)){l=g,p=W,d=M||(X===2?s[g+1].value:""),f=X+1;break}}else {l=g,p=W,d=M,f=1;break}}}if(l===-1)return null;let m=new Set;for(let g=l;g<l+f;g++)m.add(g);if(c){let g=l+f;if(g<s.length){let b=s[g];(b.kind==="particle"||b.kind==="keyword")&&c.markers.has(b.value)&&m.add(g);}for(let b=0;b<l;b++){let _=s[b],N=_.value.toLowerCase(),M=_.normalized?.toLowerCase();if(c.windowTokens.has(N)||M&&c.windowTokens.has(M)){m.add(b);break}}}let v=s.filter((g,b)=>!m.has(b));if(v.length===0)return null;let k=n.filter(g=>g.command!=="on"),T=new se(v,r),x=this.parseBodyWithClauses(T,k,r);if(x.length===0)return null;let ye={sourceLanguage:r,confidence:.75};return d&&(ye.keyFilter=d),Ne({type:"literal",value:p},x,void 0,ye)}isThenKeyword(e,r){let n={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (n[r]||n.en).has(e.toLowerCase())}isEndKeyword(e,r){let n={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return (n[r]||n.en).has(e.toLowerCase())}extractStandaloneModifiers(e,r){let i=ue(e,r).tokens;if(i.length===0)return {modifiers:null,remainingInput:null};let s=i[0].value.toLowerCase(),u=P.STANDALONE_MODIFIERS[s];if(!u)return {modifiers:null,remainingInput:null};let a={},c=1;if(u==="once")a.once=true;else {let f=1;if(f<i.length){let m=i[f];(m.kind==="keyword"||m.kind==="particle")&&(f++,c++);}if(f<i.length){let m=i[f];if(m.kind==="literal"){let v=m.value.match(/^(\d+)(ms|s|m)?$/);if(v){let k=parseInt(v[1],10),T=v[2]||"ms";T==="s"?k*=1e3:T==="m"&&(k*=6e4),a[u]=k,c=f+1;}}}a[u]||(a[u]=u==="debounce"?300:100);}let l=i.slice(c);if(l.length===0)return {modifiers:null,remainingInput:null};let p=l[0].position.start,d=e.slice(p);return {modifiers:a,remainingInput:d}}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let n=[];for(;;){let i=e.mark(),o=e.peek();if(!o)break;let s=(o.normalized||o.value).toLowerCase();if(!P.OR_KEYWORDS.has(s)){e.reset(i);break}e.advance();let u=e.peek();if(!u){e.reset(i);break}let a=(u.normalized||u.value).toLowerCase();e.advance(),n.push({type:"literal",value:a});}return n}};V.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);V.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"])};V.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])}};V.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};V.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o"]);var Zt=V,Jt=new Zt;function de(t,e){return Jt.parse(t,e)}var ce=class{constructor(t={}){this.cache=new Map,this.config={maxSize:t.maxSize??1e3,ttlMs:t.ttlMs??0,enabled:t.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(t,e){return `${e}:${t}`}isExpired(t){return this.config.ttlMs===0?false: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),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(n,{result:r,createdAt:i,lastAccessed:i});}has(t,e){if(!this.config.enabled)return false;let r=this.makeKey(t,e),n=this.cache.get(r);return n?this.isExpired(n)?(this.cache.delete(r),this.stats.expirations++,false):true:false}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=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}},er=new ce;var tr=class{constructor(t={}){this.patternMatcher=new Ue,this.languages=new Set(Ge()),t.cache===false?this.cache=new ce({enabled:false}):this.cache=t.cache?new ce(t.cache):er;}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{try{let s=de(t,e),u={confidence:s.metadata?.confidence??.8,node:s};return s.kind==="command"?{...u,command:{name:s.action,roles:s.roles}}:u}catch{}let r=Yt(e);if(!r)return {confidence:0,errors:[`No tokenizer available for language '${e}'`]};let n=r.tokenize(t),i=L(e);if(i.length===0)return {confidence:0,errors:[`No patterns available for language '${e}'`]};let o=this.patternMatcher.matchBest(n,i);if(o){let s=this.buildSemanticNode(o);return {confidence:o.confidence,command:{name:o.pattern.command,roles:o.captured},node:s,tokensConsumed:o.consumedTokens}}return {confidence:0,errors:["No pattern matched the input"]}}catch(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 Ke(t){return new tr(t)}var rr=.5;function Ye(t,e=rr){return t.confidence>=e&&t.command!==void 0}var nr={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},ir={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},or={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},sr={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"}}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},ur={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},ar={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},lr={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},cr={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},pr={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},dr={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},fr={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},mr={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},hr={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},vr={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},yr={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},gr={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Er={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},Cr={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Tr={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},Sr={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},kr={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},br={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Ar={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"-e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"-man",sw:"kwa"}}]},wr={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Rr={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},xr={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Pr={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},_r={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in"}}]},Nr={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Or={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Ir={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""}}]},Mr={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"auf",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},Br={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},Dr={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Lr={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Fr={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},zr={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},$r={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},qr={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Vr={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}}]},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:true,expectedTypes:["reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man"}}]},jr={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Gr={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Ur={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Hr={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Kr={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with"}}]},Yr={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"destination",roles:[{role:"destination",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"patient",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},Xr={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:false,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Qr={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Zr={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Jr={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},en={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},tn={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},Xe={toggle:nr,add:ir,remove:or,put:sr,set:ur,show:ar,hide:lr,on:cr,trigger:pr,wait:dr,fetch:fr,increment:mr,decrement:hr,append:vr,prepend:yr,log:gr,get:Er,take:Cr,make:Tr,halt:Sr,settle:kr,throw:br,send:Ar,if:wr,unless:Rr,else:xr,repeat:Pr,for:_r,while:Nr,continue:Or,go:Ir,transition:Mr,clone:Br,focus:Dr,blur:Lr,call:Fr,return:zr,js:$r,async:qr,tell:Vr,default:Wr,init:jr,behavior:Gr,install:Ur,measure:Hr,swap:Kr,morph:Yr,beep:Xr,break:Qr,copy:Zr,exit:Jr,pick:en,render:tn,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function rn(){return Object.values(Xe).filter(t=>t.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>($t(),$e)).then(({validateAllSchemas:t,formatValidationResults:e})=>{let r=t(Xe);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
3
- These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(t=>{console.debug("Schema validation skipped:",t);});function Qe(t,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...t].sort((n,i)=>{let o=n[r]??99,s=i[r]??99;return o-s})}function nn(t,e){let r=t.markerOverride?.[e.code],n=e.roleMarkers[t.role];if(r!==void 0)return {primary:r,position:n?.position??"before",isOverride:true};if(n&&n.primary){let i={primary:n.primary,position:n.position,isOverride:false};return n.alternatives&&(i.alternatives=n.alternatives),i}return null}function on(t,e,r,n,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let c=n.primary.split(/\s+/);if(c.length>1)for(let l of c)o.push({type:"literal",value:l});else {let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}}let s=e.roleMarkers.destination;s&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),o.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let c=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};o.push(c);}let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return o.push(a),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`{event} ${n.primary} {destination?} {patient} ${u?.primary||""} ${r.primary}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function sn(t,e,r,n,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let a=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(a);}if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let a=n.primary.split(/\s+/);if(a.length>1)for(let c of a)o.push({type:"literal",value:c});else {let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(c);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return o.push(u),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${n.primary} ${r.primary}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function un(t,e,r,n,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(c);}let u=e.roleMarkers.destination;if(u&&(o.push({type:"role",role:"destination",optional:false}),o.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),o.push({type:"role",role:"event",optional:false}),n.position==="after"){let c=n.primary.split(/\s+/);if(c.length>1)for(let l of c)o.push({type:"literal",value:l});else {let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}}let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return o.push(a),{id:`${t.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`{patient} ${s?.primary||""} {destination} ${u?.primary||""} {event} ${n.primary} ${r.primary}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function an(t,e,r,n,i){let o=[];o.push({type:"role",role:"event",optional:false});let s=n.alternatives?.filter(l=>!l.includes(" ")&&l.length>1)||[];s.length>0&&o.push({type:"literal",value:s[0],alternatives:s.slice(1)});let u=e.roleMarkers.destination;u&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.patient;if(a){let l=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};o.push(l);}let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return o.push(c),{id:`${t.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(i.basePriority??100)+52,template:{format:`{event}${s[0]||""} {patient} ${r.primary}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ln(t,e,r,n,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let u=n.primary.split(/\s+/);if(u.length>1)for(let a of u)o.push({type:"literal",value:a});else {let a=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(a);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return o.push(s),{id:`${t.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{event} ${n.primary} ${r.primary}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function cn(t,e,r,n){let i=e.eventHandler?.temporalMarkers;if(!i||i.length===0)return null;let o=[];o.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&o.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),o.push({type:"literal",value:i[0],alternatives:i.slice(1)}),o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s?.primary){let a=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(a);}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return o.push(u),{id:`${t.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(n.basePriority??100)+49,template:{format:`{event} ${i[0]} {patient} ${r.primary}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function pn(t,e,r,n,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let l=n.primary.split(/\s+/);if(l.length>1)for(let p of l)o.push({type:"literal",value:p});else {let p=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(p);}}let u=[...t.roles.filter(l=>l.required)].sort((l,p)=>{let d=l.sovPosition??999,f=p.sovPosition??999;return d-f});for(let l of u){o.push({type:"role",role:l.role,optional:false});let p,d;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)p=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}}let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(a);let c=u.map(l=>`{${l.role}}`).join(" ");return {id:`${t.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`{event} ${n.primary} ${c} ${r.primary}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(l=>[l.role,{fromRole:l.role}]))}}}function dn(t,e,r,n,i){let o=[],u=[...t.roles.filter(m=>m.required)].sort((m,v)=>{let k=m.sovPosition??999,T=v.sovPosition??999;return k-T}),a=u[0];o.push({type:"role",role:a.role,optional:false});let c;if(a.markerOverride&&a.markerOverride[e.code]!==void 0)c=a.markerOverride[e.code];else {let m=e.roleMarkers[a.role];m&&(c=m.primary);}if(c&&o.push({type:"literal",value:c}),o.push({type:"role",role:"event",optional:false}),n.position==="after"){let m=n.primary.split(/\s+/);if(m.length>1)for(let v of m)o.push({type:"literal",value:v});else {let v=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(v);}}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);let p=u[1];o.push({type:"role",role:p.role,optional:false});let d,f;if(p.markerOverride&&p.markerOverride[e.code]!==void 0)d=p.markerOverride[e.code];else {let m=e.roleMarkers[p.role];m&&(d=m.primary,f=m.alternatives);}if(d){let m=f?{type:"literal",value:d,alternatives:f}:{type:"literal",value:d};o.push(m);}return {id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{${a.role}} {event} ${n.primary} ${r.primary} {${p.role}}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},[a.role]:{fromRole:a.role},[p.role]:{fromRole:p.role}}}}function Be(t,e,r,n,i){let o=[];if(n.position==="before"){let a=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(a);}o.push({type:"role",role:"event",optional:false});let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&o.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`${n.primary} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function fn(t,e,r,n,i){let o=[],s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;if(u&&o.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),n.position==="before"){let a=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(a);}return o.push({type:"role",role:"event",optional:false}),{id:`${t.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${n.primary} {event}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function mn(t,e,r,n,i){let o=[],s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(s);let a=[...t.roles.filter(l=>l.required)].sort((l,p)=>{let d=l.svoPosition??999,f=p.svoPosition??999;return d-f});for(let l of a){let p,d;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)p=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:l.role,optional:false});}if(n.position==="before"){let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}o.push({type:"role",role:"event",optional:false});let c=a.map(l=>`{${l.role}}`).join(" ");return {id:`${t.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${r.primary} ${c} ${n.primary} {event}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(a.map(l=>[l.role,{fromRole:l.role}]))}}}function De(t,e,r,n,i){let o=[];if(n.position==="before"){let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}o.push({type:"role",role:"event",optional:false});let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(s);let a=[...t.roles.filter(l=>l.required)].sort((l,p)=>{let d=l.svoPosition??999,f=p.svoPosition??999;return d-f});for(let l of a){let p,d;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)p=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:l.role,optional:false});}let c=a.map(l=>`{${l.role}}`).join(" ");return {id:`${t.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`${n.primary} {event} ${r.primary} ${c}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(a.map(l=>[l.role,{fromRole:l.role}]))}}}function hn(t,e,r,n,i){let o=[],s=e.eventHandler?.negationMarker;if(n.position==="before"){let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.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:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(u),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;return a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${n.primary} ${s?.primary||""} {event} ${r.primary} {patient} ${a?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function vn(t,e,r,n){let i=[];i.push({type:"literal",value:"and",alternatives:["then"]}),i.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(o),i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&i.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${t.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var H={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Ze(t,e,r=H){let n=`${t.action}-${e.code}-generated`,i=r.basePriority??100,o=e.keywords[t.action];if(!o)throw new Error(`No keyword translation for '${t.action}' in ${e.code}`);let s=Cn(t,e,o),u=et(t,e),a=bn(t,e,o);return {id:n,language:e.code,command:t.action,priority:i,template:{format:a,tokens:s},extraction:u}}function yn(t,e,r=H){if(t.roles.filter(u=>!u.required).length===0)return null;let i=t.roles.filter(u=>u.required),o={...t,roles:i};return {...Ze(o,e,r),id:`${t.action}-${e.code}-simple`,priority:(r.basePriority??100)-5,extraction:et(t,e)}}function gn(t,e,r=H){let n=[];if(n.push(Ze(t,e,r)),r.generateSimpleVariants){let i=yn(t,e,r);i&&n.push(i);}return n}function Je(t,e=H){let r=[],n=rn();for(let i of n){if(!t.keywords[i.action])continue;let o=gn(i,t,e);if(r.push(...o),t.eventHandler?.eventMarker){let s=En(i,t,e);r.push(...s);}}return r}function En(t,e,r=H){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let n=[],i=e.eventHandler.eventMarker,o=e.keywords[t.action];if(!o)return [];let u=t.roles.filter(a=>a.required).length===2;if(e.wordOrder==="SOV")if(u)n.push(pn(t,e,o,i,r)),n.push(dn(t,e,o,i,r));else {n.push(on(t,e,o,i,r)),n.push(sn(t,e,o,i,r));let a=e.roleMarkers.destination;a&&a.primary!==i.primary&&n.push(un(t,e,o,i,r));let c=i.primary.split(/\s+/),l=i.alternatives?.some(d=>!d.includes(" ")&&d.length>1);c.length>1&&l&&n.push(an(t,e,o,i,r)),n.push(ln(t,e,o,i,r));let p=cn(t,e,o,r);p&&n.push(p);}else e.wordOrder==="VSO"?u?(n.push(De(t,e,o,i,r)),n.push(mn(t,e,o,i,r))):(n.push(Be(t,e,o,i,r)),n.push(fn(t,e,o,i,r)),e.eventHandler?.negationMarker&&n.push(hn(t,e,o,i,r)),e.tokenization?.prefixes&&n.push(vn(t,e,o,r))):u?n.push(De(t,e,o,i,r)):n.push(Be(t,e,o,i,r));return n}function Cn(t,e,r){let n=[],i=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},o=Tn(t,e);switch(e.wordOrder){case "SVO":n.push(i),n.push(...o);break;case "SOV":n.push(...o),n.push(i);break;case "VSO":n.push(i),n.push(...o);break;default:n.push(i),n.push(...o);}return n}function Tn(t,e){let r=[],n=Qe(t.roles,e.wordOrder);for(let i of n){let o=Sn(i,e);i.required?r.push(...o):r.push({type:"group",optional:true,tokens:o});}return r}function Sn(t,e){let r=[],n=t.markerOverride?.[e.code],i=e.roleMarkers[t.role],o={type:"role",role:t.role,optional:!t.required,expectedTypes:t.expectedTypes};if(n!==void 0)(i?.position??"before")==="before"?(n&&r.push({type:"literal",value:n}),r.push(o)):(r.push(o),n&&r.push({type:"literal",value:n}));else if(i)if(i.position==="before"){if(i.primary){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};r.push(s);}r.push(o);}else {r.push(o);let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};r.push(s);}else r.push(o);return r}function kn(t,e){let r={};for(let n of t.roles){let i=n.markerOverride?.[e.code],o=e.roleMarkers[n.role];i!==void 0?r[n.role]=i?{marker:i}:{}:o&&o.primary?r[n.role]=o.alternatives?{marker:o.primary,markerAlternatives:o.alternatives}:{marker:o.primary}:r[n.role]={};}return r}function et(t,e){let r=kn(t,e),n={};for(let i of t.roles){let o=r[i.role]||{};!i.required&&i.default?n[i.role]={...o,default:i.default}:n[i.role]=o;}return n}function bn(t,e,r){let n=[],o=Qe(t.roles,e.wordOrder).map(s=>{let u=nn(s,e),a="";return u&&u.primary?u.position==="before"?a=`${u.primary} {${s.role}}`:a=`{${s.role}} ${u.primary}`:a=`{${s.role}}`,s.required?a:`[${a}]`});switch(e.wordOrder){case "SVO":case "VSO":n.push(r.primary,...o);break;case "SOV":n.push(...o,r.primary);break;default:n.push(r.primary,...o);}return n.join(" ")}function te(t){let e=t.getAttribute("data-lang");if(e)return fe(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return fe(r);let n=typeof document<"u"?document.documentElement?.lang:null;return n&&n!=="en"?fe(n):null}function fe(t){return t.split("-")[0].toLowerCase()}var tt={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],blur:[["patient",""]],break:[],call:[["patient",""]],clone:[["patient",""],["destination","into"]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","to"]],on:[["event",""],["source","from"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],return:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["patient",""]],while:[["condition",""]]};function Y(t){switch(t.kind){case "event-handler":return An(t);case "compound":return wn(t);default:return Rn(t)}}function An(t){let e=["on"],r=t.roles.get("event");r&&e.push(K(r));let n=t.roles.get("source");if(n&&e.push("from",K(n)),t.body&&t.body.length>0){let i=t.body.map(Y);e.push(i.join(" then "));}return e.join(" ")}function wn(t){let e=t.chainType==="async"?"async":t.chainType;return t.statements.map(Y).join(` ${e} `)}function Rn(t){let e=tt[t.action];if(e){let n=[t.action];for(let[i,o]of e){let s=t.roles.get(i);s&&(i==="destination"&&s.type==="reference"&&s.value==="me"||(o&&n.push(o),n.push(K(s))));}return n.join(" ")}let r=[t.action];for(let[,n]of t.roles)r.push(K(n));return r.join(" ")}function K(t){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 t.value;case "property-path":return xn(t);case "expression":return t.raw}}function xn(t){let e=K(t.object),r=t.property;if(t.object.type==="reference")switch(t.object.value){case "me":return `my ${r}`;case "it":return `its ${r}`;case "you":return `your ${r}`}return `${e}'s ${r}`}var nt=.5,Pn={confidenceThreshold:nt,strategy:"semantic",fallbackToOriginal:true};function _n(t,e){return typeof t=="number"?t:t[e]??t["*"]??nt}var me=null;function Nn(){return me||(me=Ke()),me}function he(t,e,r={}){let n={...Pn,...r},i=rt(t,e,n);if(i!==null)return i;let o=In(t);if(o){let s=rt(o.commands,e,n);if(s!==null)return o.prefix+s}return t}function rt(t,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let n=_n(r.confidenceThreshold,e),i=it(t,e,n);if(i!==null)return i}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let n=Mn(t,e,r.i18nToEnglish);if(n!==null)return n}return null}var On=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function In(t){let e=t.match(On);if(!e)return null;let r=e[1],n=t.slice(r.length);return n?{prefix:r,commands:n}:null}function it(t,e,r){try{let n=Dn(t,e);if(n.length>1)return Ln(n,e,r);let i=Nn();if(!i.supportsLanguage(e))return null;let o=i.analyze(t,e);if(!Ye(o,r))return null;if(o.node)return Y(o.node);let s=de(t,e);return Y(s)}catch{return null}}function Mn(t,e,r){try{let n=r(t,e);return n!==t?n:null}catch{return null}}function Bn(t){let e=["then"],r=I(t);if(r?.keywords?.then){let n=r.keywords.then;if(n.primary&&n.primary!=="then"&&e.push(n.primary),n.alternatives)for(let i of n.alternatives)e.includes(i)||e.push(i);}return e}function Dn(t,e){let n=Bn(e).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\s+(?:${n.join("|")})\\s+`,"i"),o=t.split(`
4
- `).map(u=>u.trim()).filter(u=>u.length>0),s=[];for(let u of o){let a=u.split(i);s.push(...a);}return s}function Ln(t,e,r){let n=[];for(let i of t){let o=it(i.trim(),e,r);if(o===null)return null;n.push(o);}return n.join(" then ")}function ve(t={}){return function(r){let{internals:n}=r,i=n.runtime,o=i.getScript.bind(i);i.getScript=function(s){let u=o(s);if(!u)return null;let a=Fn(s,t);if(!a||a==="en")return u;let c=he(u,a,t);return t.debug&&c!==u&&console.log(`[hyperscript-i18n] ${a}: "${u}" \u2192 "${c}"`),c};}}function Fn(t,e){if(e.languageAttribute){let n=t.getAttribute(e.languageAttribute);if(n)return n.split("-")[0].toLowerCase()}let r=te(t);return r||(e.defaultLanguage??null)}function ot(t,e,r={}){return e==="en"?t:he(t,e,r)}je(t=>Je(t));function st(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(ve()),zn());}function zn(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let r=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(r).forEach(n=>{let i=e.getInternalData(n);i.initialized&&(i.initialized=false);}),e.processNode(document.body);}var di=["ru"];st();exports.plugin=ve;exports.preprocess=ot;exports.resolveLanguage=te;exports.supportedLanguages=di;return exports;})({});
1
+ var HyperscriptI18n=(function(exports){'use strict';function N(r,e){return e?{type:"literal",value:r,dataType:e}:{type:"literal",value:r}}function me(r,e){return e?{type:"selector",value:r,selectorKind:e}:{type:"selector",value:r}}function oe(r){return {type:"reference",value:r}}function he(r,e){return {type:"property-path",object:r,property:e}}var xt=class{constructor(r){this.namespace=r,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let r=process.env.DEBUG||"";return r==="*"||r.includes("framework:*")||r.includes(`framework:${this.namespace}`)}return false}log(r,e,...t){if(!this.enabled)return;let n=`[framework:${this.namespace}]`,i=new Date().toISOString();switch(r){case "debug":console.debug(`${i} ${n} DEBUG:`,e,...t);break;case "info":console.info(`${i} ${n} INFO:`,e,...t);break;case "warn":console.warn(`${i} ${n} WARN:`,e,...t);break;case "error":console.error(`${i} ${n} ERROR:`,e,...t);break}}debug(r,...e){this.log("debug",r,...e);}info(r,...e){this.log("info",r,...e);}warn(r,...e){this.log("warn",r,...e);}error(r,...e){this.log("error",r,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function At(r){return new xt(r)}function $(r,e){return !e||e.length===0||e.includes(r)||e.includes("expression")?true:r==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function Rt(r,e){return r?.possessive?.keywords?.[e]}var X=class V{constructor(){this.logger=At("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,t,n){let i=e.mark(),o=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",t.id),this.logger.debug("Pattern command:",t.command),this.logger.debug("Pattern language:",t.language),this.logger.debug("Pattern template:",JSON.stringify(t.template,null,2)),this.logger.isEnabled()){let u=[];for(let c=0;c<10;c++){let l=e.peek(c);if(l)u.push({type:l.type,value:l.value,kind:l.kind});else break}this.logger.debug("Input tokens (first 10):",u),this.logger.debug("Profile code:",n?.code);}this.currentProfile=n,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(t.template.tokens,null,2));let s=this.matchTokenSequence(e,t.template.tokens,o);if(this.logger.debug("matchTokenSequence returned:",s),this.logger.debug("Captured roles:",Array.from(o.entries()).map(([u,c])=>[u,JSON.stringify(c)])),!s)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(i),null;let a=this.calculateConfidence(t,o);return this.applyExtractionRules(t,o),{pattern:t,captured:o,consumedTokens:e.position()-i.position,confidence:a}}matchBest(e,t,n){let i=[];for(let s of t){let a=e.mark(),u=this.matchPattern(e,s,n);u&&i.push(u),e.reset(a);}if(i.length===0)return null;i.sort((s,a)=>{let u=a.pattern.priority-s.pattern.priority;if(u!==0)return u;let c=a.confidence-s.confidence;return Math.abs(c)>.001?c:a.consumedTokens-s.consumedTokens});let o=i[0];return this.matchPattern(e,o.pattern),o}matchTokenSequence(e,t,n,i){let o=t[0],s=o?.type==="literal"&&(o.value==="and"||o.value==="then"||o.alternatives?.includes("and")||o.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!s)for(;e.peek()?.kind==="conjunction";)e.advance();let a=null,u=null;for(let c=0;c<t.length;c++){let l=t[c];this.logger.debug(" >> Matching pattern token:",JSON.stringify(l,null,2));let p=e.peek();if(this.logger.debug(" >> Current input token:",p?JSON.stringify({type:p.type,value:p.value,kind:p.kind}):"EOF"),l.type==="role"&&l.greedy){let y=this.collectStopMarkers(t,c+1);if(i)for(let S of i)y.add(S);let g=[];for(;!e.isAtEnd();){let S=e.peek();if(!S||this.isStopMarker(S,y))break;g.push(S.value),e.advance();}if(g.length>0){n.set(l.role,{type:"expression",raw:g.join(" ")}),a=null,u=null;continue}else {if(l.optional)continue;return false}}if(l.type==="group"){let y=this.collectStopMarkers(t,c+1);if(i)for(let S of i)y.add(S);if(this.matchGroupToken(e,l,n,y)){a=null,u=null;continue}if(this.isOptional(l))continue;return false}let d=l.type==="role"&&l.optional===true,f=d?e.mark():null;if(l.type==="role"&&!d){let y=c+1<t.length?t[c+1]:null;if(y?.type==="literal"){let g=e.peek();if(g&&this.getMatchType(g,y.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(l))continue;if(a&&u){this.logger.debug(" >> BACKTRACKING: undoing optional role",u),e.reset(a),n.delete(u),a=null,u=null;let S=this.matchPatternToken(e,l,n);if(this.logger.debug(" >> Backtrack retry result:",S),S)continue}return false}}}let v=this.matchPatternToken(e,l,n);if(this.logger.debug(" >> Match result:",v),v){d?(a=f,u=l.role):(a=null,u=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(l)){if(a&&u){this.logger.debug(" >> BACKTRACKING: undoing optional role",u),e.reset(a),n.delete(u),a=null,u=null;let y=this.matchPatternToken(e,l,n);if(this.logger.debug(" >> Backtrack retry result:",y),y)continue}return false}}return true}matchPatternToken(e,t,n){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,n);case "group":return this.matchGroupToken(e,t,n);default:return false}}matchLiteralToken(e,t){let n=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",t.value),this.logger.debug(" >>> matchLiteralToken: got token",n?JSON.stringify({type:n.type,value:n.value,kind:n.kind}):"null"),!n)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let i=this.getMatchType(n,t.value);if(this.logger.debug(" >>> matchType for",n.value,"vs",t.value,":",i),i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let o of t.alternatives){let s=this.getMatchType(n,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,n){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",t.role),this.logger.debug(" >>> matchRoleToken: expected types",t.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",t.optional),this.skipNoiseWords(e);let i=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null"),!i)return t.optional||false;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!$(o.type,t.expectedTypes)?t.optional||false:(n.set(t.role,o),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!$(s.type,t.expectedTypes)?t.optional||false:(n.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!$(a.type,t.expectedTypes)?t.optional||false:(n.set(t.role,a),true);let u=this.tryMatchPropertyAccessExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!$(u.type,t.expectedTypes)?t.optional||false:(n.set(t.role,u),true);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!$(c.type,t.expectedTypes)?t.optional||false:(n.set(t.role,c),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null");let l=this.tokenToSemanticValue(i);return this.logger.debug(" >>> tokenToSemanticValue returned:",l?JSON.stringify(l):"null"),l?(this.logger.debug(" >>> Validating type:",l.type,"against expected:",t.expectedTypes),t.expectedTypes&&t.expectedTypes.length>0&&!$(l.type,t.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",t.optional||false),t.optional||false):(this.logger.debug(" >>> Type validation PASSED"),n.set(t.role,l),e.advance(),true)):t.optional||false}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let n=t.normalized||t.value,i=this.safeToLowerCase(n),o=Rt(this.currentProfile,i);if(!o)return null;let s=e.mark();e.advance();let a=e.peek();if(!a)return e.reset(s),null;if(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*")||a.kind==="selector"&&a.value.startsWith("@")||a.kind==="selector"&&a.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a.value)){e.advance();let u=a.value;a.kind==="selector"&&u.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u)&&(u=u.substring(1));let c=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)c+=e.peek().value,e.advance();let l=e.peek();return l?.kind==="literal"&&l.value.startsWith("(")&&(c+=l.value,e.advance()),he(oe(o),c)}return e.reset(s),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(n),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<V.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance();}return {type:"expression",raw:`${t.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let s=`${t.value}.${o.value}`,a=1;for(;!e.isAtEnd()&&a<V.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let l=e.peek();if(!l||l.kind!=="identifier")break;e.advance(),s+=`.${l.value}`,a++;}let u=e.peek();if(u&&u.kind==="punctuation"&&u.value==="("){e.advance();let c=[],l=0;for(;!e.isAtEnd()&&c.length<V.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(l===0){e.advance();break}l--;}if(d.kind==="punctuation"&&d.value==="("&&l++,d.kind==="punctuation"&&d.value===","){e.advance();continue}c.push(d.value),e.advance();}return {type:"expression",raw:`${s}(${c.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(n),null;e.advance();let o=e.peek();return !o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(n),null):(e.advance(),he(me(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||typeof t.value!="string"||!t.value.startsWith("#"))return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(n),null;let o=e.peek(1);o&&o.kind,e.advance();let s=i.value.slice(1);return he(me(t.value),s)}matchGroupToken(e,t,n,i){let o=e.mark(),s=new Set(n.keys());if(this.matchTokenSequence(e,t.tokens,n,i))return true;e.reset(o);for(let c of n.keys())s.has(c)||n.delete(c);if(!t.optional)return false;let u=this.getGroupLeadingMarker(t);if(u)for(let c=1;c<=V.MAX_MARKER_SCAN;c++){let l=e.peek(c);if(!l)break;if((l.normalized||l.value).toLowerCase()===u){this.logger.debug(" >> MARKER SCAN: found",u,"at offset",c,"- skipping intervening tokens");for(let f=0;f<c;f++)e.advance();if(this.matchTokenSequence(e,t.tokens,n,i))return true;e.reset(o);for(let f of n.keys())s.has(f)||n.delete(f);break}}return true}getGroupLeadingMarker(e){let t=e.tokens[0];return t?.type==="literal"?t.value.toLowerCase():null}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===t.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,t){let n=new Set;for(let i=t;i<e.length;i++){let o=e[i];if(o.type==="literal"){if(n.add(o.value.toLowerCase()),o.alternatives)for(let s of o.alternatives)n.add(s.toLowerCase());break}if(o.type==="group"){for(let s of o.tokens)if(s.type==="literal"){if(n.add(s.value.toLowerCase()),s.alternatives)for(let a of s.alternatives)n.add(a.toLowerCase());break}if(!o.optional)break}}return n}isStopMarker(e,t){return t.size===0?false:!!(t.has(e.value.toLowerCase())||e.normalized&&t.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return me(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=e.normalized||e.value;this.safeToLowerCase(t);return N(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return oe(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return N(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return N(i,"string")}if(e==="true")return N(true,"boolean");if(e==="false")return N(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?N(e,"duration"):N(i,"number")}let n=parseFloat(e);return isNaN(n)?N(e,"string"):N(n,"number")}applyExtractionRules(e,t){for(let[n,i]of Object.entries(e.extraction))t.has(n)||(i.value!==void 0?t.set(n,{type:"literal",value:i.value}):i.default&&t.set(n,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,t){let n=0,i=0,o=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")i+=1,t.has(c.role)&&(n+=1);else if(c.type==="group"){for(let l of c.tokens)if(l.type==="role"){let p=o(l.role),d=.8;i+=d,t.has(l.role)?n+=d:p&&(n+=d*.6);}}let s=i>0?n/i: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(e);s=Math.min(1,s+a);let u=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+u)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let n=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(n.has(t.value))return .15;if(t.alternatives){for(let i of t.alternatives)if(n.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let n=0,i={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[o,s]of t.entries()){let a=i[o];if(!a||a.length===0)continue;let u="metadata"in s?s.metadata:void 0;if(u&&typeof u.prepositionValue=="string"){let c=u.prepositionValue;a.includes(c)?n+=.1:n-=.1;}}return Math.max(-0.1,Math.min(.1,n))}skipNoiseWords(e){let t=e.peek();if(!t)return;let n=this.safeToLowerCase(t.value);if(V.ENGLISH_NOISE_WORDS.has(n)){let i=e.mark();e.advance();let o=e.peek();if(o&&o.kind==="selector")return;e.reset(i);}n==="class"&&e.advance();}extractEventModifiers(e){let t={},n=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(n=true,o.modifierName){case "once":t.once=true;break;case "debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case "throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case "queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance();}return n?t:void 0}};X.MAX_MARKER_SCAN=3;X.MAX_PROPERTY_DEPTH=10;X.MAX_METHOD_ARGS=20;X.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Pt=X;new Pt;var _e=class{constructor(){this.name="string-literal";}canExtract(r,e){let t=r[e];return t==='"'||t==="'"||t==="`"||t==="\u201C"||t==="\u2018"}extract(r,e){let t=r[e];if(t==="\u201C"){let o=1;for(;e+o<r.length;){if(r[e+o]==="\u201D")return o++,{value:r.substring(e,e+o),length:o};o++;}return null}if(t==="\u2018"){let o=1;for(;e+o<r.length;){if(r[e+o]==="\u2019")return o++,{value:r.substring(e,e+o),length:o};o++;}return null}let n=1,i=false;for(;e+n<r.length;){let o=r[e+n];if(i){i=false,n++;continue}if(o==="\\"){i=true,n++;continue}if(o===t)return n++,{value:r.substring(e,e+n),length:n};n++;}return null}},Ie=class{constructor(){this.name="number";}canExtract(r,e){return /\d/.test(r[e])}extract(r,e){let t=0,n=false;for(;e+t<r.length;){let s=r[e+t];if(/\d/.test(s))t++;else if(s==="."&&!n)n=true,t++;else break}if(t===0)return null;let i=r.substring(e,e+t),o=e+t;if(o<r.length){let s=r.slice(o),a=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let c of a)if(s.startsWith(c.pattern))return {value:i+c.suffix,length:t+c.pattern.length,metadata:{hasTimeUnit:true}};if(s.startsWith("ms"))return {value:i+"ms",length:t+2,metadata:{hasTimeUnit:true}};let u=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let c of u)if(s.startsWith(c.pattern))return {value:i+c.suffix,length:t+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(s))return {value:i+s[0],length:t+1,metadata:{hasTimeUnit:true}}}return {value:i,length:t}}};function Nt(r){return "setContext"in r&&typeof r.setContext=="function"}function Ot(r){let e={language:r.language,direction:r.direction,lookupKeyword:r.lookupKeyword.bind(r),isKeyword:r.isKeyword.bind(r),isKeywordStart:r.isKeywordStart.bind(r)};return r.normalizer?{...e,normalizer:r.normalizer}:e}var _t=new Set(["me","you","it","result","event","target","body"]);function Me(r,e=_t){return e.has(r)}var J=class{constructor(r,e){this.pos=0,this.tokens=r,this.language=e;}peek(r=0){let e=this.pos+r;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(r){this.pos=r.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(r){let e=[];for(;!this.isAtEnd()&&r(this.peek());)e.push(this.advance());return e}skipWhile(r){for(;!this.isAtEnd()&&r(this.peek());)this.advance();}};function T(r,e){return {start:r,end:e}}function C(r,e,t,n){if(typeof r=="object"){let{value:o,kind:s,position:a,normalized:u,stem:c,stemConfidence:l,metadata:p}=r;return {value:o,kind:s,position:a,...u!==void 0&&{normalized:u},...c!==void 0&&{stem:c},...l!==void 0&&{stemConfidence:l},...p!==void 0&&{metadata:p}}}let i=r;if(!e||!t)throw new Error("createToken requires kind and position parameters");if(typeof n=="string")return {value:i,kind:e,position:t,normalized:n};if(n){let{normalized:o,stem:s,stemConfidence:a,metadata:u}=n;return {value:i,kind:e,position:t,...o!==void 0&&{normalized:o},...s!==void 0&&{stem:s},...a!==void 0&&{stemConfidence:a},...u!==void 0&&{metadata:u}}}return {value:i,kind:e,position:t}}function Y(r){return /\s/.test(r)}function Mt(r){return r==="#"||r==="."||r==="["||r==="@"||r==="*"||r==="<"}function Lt(r){return r==='"'||r==="'"||r==="`"||r==="\u300C"||r==="\u300D"}function M(r){return /\d/.test(r)}function Dt(r){return /[a-zA-Z]/.test(r)}function x(r){return /[a-zA-Z0-9_-]/.test(r)}function Bt(r,e){if(e>=r.length)return null;let t=r[e];if(!Mt(t))return null;let n=e,i="";if(t==="#"||t==="."){for(i+=r[n++];n<r.length&&x(r[n]);)i+=r[n++];if(i.length<=1)return null;if(n<r.length&&r[n]==="."&&t==="#"){let s=n+1;for(;s<r.length&&x(r[s]);)s++;if(s<r.length&&r[s]==="(")return i}}else if(t==="["){let o=1,s=false,a=null,u=false;for(i+=r[n++];n<r.length&&o>0;){let c=r[n];i+=c,u?u=false:c==="\\"?u=true:s?c===a&&(s=false,a=null):c==='"'||c==="'"||c==="`"?(s=true,a=c):c==="["?o++:c==="]"&&o--,n++;}if(o!==0)return null}else if(t==="@"){for(i+=r[n++];n<r.length&&x(r[n]);)i+=r[n++];if(i.length<=1)return null}else if(t==="*"){for(i+=r[n++];n<r.length&&x(r[n]);)i+=r[n++];if(i.length<=1)return null}else if(t==="<"){if(i+=r[n++],n>=r.length||!Dt(r[n]))return null;for(;n<r.length&&x(r[n]);)i+=r[n++];for(;n<r.length;){let o=r[n];if(o==="."){if(i+=r[n++],n>=r.length||!x(r[n]))return null;for(;n<r.length&&x(r[n]);)i+=r[n++];}else if(o==="#"){if(i+=r[n++],n>=r.length||!x(r[n]))return null;for(;n<r.length&&x(r[n]);)i+=r[n++];}else if(o==="["){let s=1,a=false,u=null,c=false;for(i+=r[n++];n<r.length&&s>0;){let l=r[n];i+=l,c?c=false:l==="\\"?c=true:a?l===u&&(a=false,u=null):l==='"'||l==="'"||l==="`"?(a=true,u=l):l==="["?s++:l==="]"&&s--,n++;}if(s!==0)return null}else break}for(;n<r.length&&Y(r[n]);)i+=r[n++];if(n<r.length&&r[n]==="/")for(i+=r[n++];n<r.length&&Y(r[n]);)i+=r[n++];if(n>=r.length||r[n]!==">")return null;i+=r[n++];}return i||null}function $t(r,e){if(e>=r.length||r[e]!=="'"||e+1>=r.length||r[e+1].toLowerCase()!=="s")return false;if(e+2>=r.length)return true;let n=r[e+2];return Y(n)||n==="*"||!x(n)}function Vt(r,e){if(e>=r.length)return null;let t=r[e];if(!Lt(t)||t==="'"&&$t(r,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!i)return null;let o=e+1,s=t,a=false;for(;o<r.length;){let u=r[o];if(s+=u,a)a=false;else if(u==="\\")a=true;else if(u===i)return s;o++;}return s}function Ft(r,e){if(e>=r.length)return false;let t=r[e],n=r[e+1]||"",i=r[e+2]||"";if(t==="/"&&n!=="/"&&/[a-zA-Z0-9._-]/.test(n)||t==="/"&&n==="/"&&/[a-zA-Z]/.test(i)||t==="."&&(n==="/"||n==="."&&i==="/"))return true;let o=r.slice(e,e+8).toLowerCase();return !!(o.startsWith("http://")||o.startsWith("https://"))}function zt(r,e){if(!Ft(r,e))return null;let t=e,n="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<r.length;){let o=r[t];if(o==="#"){if(n.length>0&&/[a-zA-Z0-9/.]$/.test(n))for(n+=o,t++;t<r.length&&/[a-zA-Z0-9_-]/.test(r[t]);)n+=r[t++];break}if(i.test(o))n+=o,t++;else break}return n.length<2?null:n}function qt(r,e){if(e>=r.length)return null;let t=r[e];if(!M(t)&&t!=="-"&&t!=="+")return null;let n=e,i="";if((r[n]==="-"||r[n]==="+")&&(i+=r[n++]),n>=r.length||!M(r[n]))return null;for(;n<r.length&&M(r[n]);)i+=r[n++];if(n<r.length&&r[n]===".")for(i+=r[n++];n<r.length&&M(r[n]);)i+=r[n++];return n<r.length&&(r.slice(n,n+2)==="ms"?i+="ms":(r[n]==="s"||r[n]==="m"||r[n]==="h")&&(i+=r[n])),i}var Wt=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Wt);var De=class Be{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map,this.extractors=[];}tokenize(e){if(this.isUsingExtractors())return this.tokenizeWithExtractors(e);throw new Error(`${this.constructor.name}: tokenize() not implemented and no extractors registered. Either register extractors or override tokenize() method.`)}registerExtractor(e){Nt(e)&&e.setContext(Ot(this)),this.extractors.push(e);}registerExtractors(e){for(let t of e)this.registerExtractor(t);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&Y(e[n]);)n++;if(n>=e.length)break;let i=false;for(let o of this.extractors)if(o.canExtract(e,n)){let s=o.extract(e,n);if(s){let a=s.metadata?.normalized,u=s.metadata?.stem,c=s.metadata?.stemConfidence,l={};if(s.metadata)for(let[d,f]of Object.entries(s.metadata))d!=="normalized"&&d!=="stem"&&d!=="stemConfidence"&&(l[d]=f);let p={};a&&(p.normalized=a),u&&(p.stem=u),c!==void 0&&(p.stemConfidence=c),Object.keys(l).length>0&&(p.metadata=l),t.push(C(s.value,this.classifyToken(s.value),T(n,n+s.length),Object.keys(p).length>0?p:void 0)),n+=s.length,i=true;break}}if(!i){let o=e[n],s=this.classifyUnknownChar(o);t.push(C(o,s,T(n,n+1))),n++;}}return new J(t,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,t,n){if(e[t]!==".")return false;let i=n[n.length-1],o=i&&i.position.end<t;if(i&&!o&&(i.kind==="identifier"||i.kind==="keyword"||i.kind==="selector"))return n.push(C(".","operator",T(t,t+1))),true;let u=t+1;for(;u<e.length&&x(e[u]);)u++;return u<e.length&&e[u]==="("?(n.push(C(".","operator",T(t,t+1))),true):false}initializeKeywordsFromProfile(e,t=[]){let n=new Map;if(e.keywords){for(let[i,o]of Object.entries(e.keywords))if(n.set(o.primary,{native:o.primary,normalized:o.normalized||i}),o.alternatives)for(let s of o.alternatives)n.set(s,{native:s,normalized:o.normalized||i});}if(e.references){for(let[i,o]of Object.entries(e.references))n.set(o,{native:o,normalized:i});for(let i of Object.keys(e.references))n.has(i)||n.set(i,{native:i,normalized:i});}if(e.roleMarkers){for(let[i,o]of Object.entries(e.roleMarkers))if(o.primary&&n.set(o.primary,{native:o.primary,normalized:i}),o.alternatives)for(let s of o.alternatives)n.set(s,{native:s,normalized:i});}if(e.possessive?.keywords)for(let[i,o]of Object.entries(e.possessive.keywords))n.set(i,{native:i,normalized:o});for(let i of t)n.set(i.native,i);this.profileKeywords=Array.from(n.values()).sort((i,o)=>o.native.length-i.native.length),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let o=this.removeDiacritics(i.native);o!==i.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),i);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,t){for(let n of this.profileKeywords)if(e.slice(t).startsWith(n.native))return C(n.native,"keyword",T(t,t+n.native.length),n.normalized);return null}isKeywordStart(e,t){let n=e.slice(t);return this.profileKeywords.some(i=>n.startsWith(i.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let t=this.normalizer.normalize(e);return t.stem!==e&&t.confidence>=.7?t:null}tryMorphKeywordMatch(e,t,n){let i=this.tryNormalize(e);if(!i)return null;let o=this.lookupKeyword(i.stem);if(!o)return null;let s={normalized:o.normalized,stem:i.stem,stemConfidence:i.confidence};return C(e,"keyword",T(t,n),s)}trySelector(e,t){let n=Bt(e,t);return n?C(n,"selector",T(t,t+n.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let n=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!n)return null;let i=n[0].replace(/(\s|\.)$/,""),o=i.slice(1).split("(")[0],s=n[1];return {...C(i,"event-modifier",T(t,t+i.length)),metadata:{modifierName:o,value:s?o==="queue"?s:parseInt(s,10):void 0}}}tryString(e,t){let n=Vt(e,t);return n?C(n,"literal",T(t,t+n.length)):null}tryNumber(e,t){let n=qt(e,t);return n?C(n,"literal",T(t,t+n.length)):null}tryMatchTimeUnit(e,t,n,i=false){let o=t;if(i)for(;o<e.length&&Y(e[o]);)o++;let s=e.slice(o);for(let a of n){let u=s.slice(0,a.length);if(a.caseInsensitive?u.toLowerCase()===a.pattern.toLowerCase():u===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let l=s[a.length]||"";if(x(l))continue}return {suffix:a.suffix,endPos:o+a.length}}}return null}parseBaseNumber(e,t,n=true){let i=t,o="";if(n&&(e[i]==="-"||e[i]==="+")&&(o+=e[i++]),i>=e.length||!M(e[i]))return null;for(;i<e.length&&M(e[i]);)o+=e[i++];if(i<e.length&&e[i]===".")for(o+=e[i++];i<e.length&&M(e[i]);)o+=e[i++];return !o||o==="-"||o==="+"?null:{number:o,endPos:i}}tryNumberWithTimeUnits(e,t,n,i={}){let{allowSign:o=true,skipWhitespace:s=false}=i,a=this.parseBaseNumber(e,t,o);if(!a)return null;let{number:u,endPos:c}=a,l=[...n,...Be.STANDARD_TIME_UNITS],p=this.tryMatchTimeUnit(e,c,l,s);return p&&(u+=p.suffix,c=p.endPos),C(u,"literal",T(t,c))}tryUrl(e,t){let n=zt(e,t);return n?C(n,"url",T(t,t+n.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!x(e[t+1]))return null;let n=t+1;for(;n<e.length&&x(e[n]);)n++;let i=e.slice(t,n);return C(i,"identifier",T(t,n))}tryOperator(e,t){let n=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(n))return C(n,"operator",T(t,t+2));let i=e[t];return ["<",">","!","+","-","*","/","="].includes(i)?C(i,"operator",T(t,t+1)):["(",")","{","}",",",";",":"].includes(i)?C(i,"punctuation",T(t,t+1)):null}tryMultiCharParticle(e,t,n){for(let i of n)if(e.slice(t,t+i.length)===i)return C(i,"particle",T(t,t+i.length));return null}};De.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var $e=De;function F(r){return {stem:r,confidence:1}}function E(r,e,t){return t?{stem:r,confidence:e,metadata:t}:{stem:r,confidence:e}}var jt=new Map,Ut=new Map,Gt=new Map;function Kt(r,e,t){jt.set(r,e),Ut.set(r,t),Gt.delete(r);}function Ht(r){return /[а-яА-ЯёЁ]/.test(r)}function Yt(r){for(let e of r)if(Ht(e))return true;return false}var Ve=new Map([["\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438","\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C"],["\u0434\u043E\u0431\u0430\u0432\u044C","\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C"],["\u0443\u0434\u0430\u043B\u0438","\u0443\u0434\u0430\u043B\u0438\u0442\u044C"],["\u0443\u0431\u0435\u0440\u0438","\u0443\u0431\u0440\u0430\u0442\u044C"],["\u043F\u043E\u043B\u043E\u0436\u0438","\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C"],["\u043F\u043E\u043C\u0435\u0441\u0442\u0438","\u043F\u043E\u043C\u0435\u0441\u0442\u0438\u0442\u044C"],["\u0432\u0441\u0442\u0430\u0432\u044C","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C"],["\u0432\u043E\u0437\u044C\u043C\u0438","\u0432\u0437\u044F\u0442\u044C"],["\u0441\u043E\u0437\u0434\u0430\u0439","\u0441\u043E\u0437\u0434\u0430\u0442\u044C"],["\u043A\u043B\u043E\u043D\u0438\u0440\u0443\u0439","\u043A\u043B\u043E\u043D\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u043F\u043E\u043C\u0435\u043D\u044F\u0439","\u043F\u043E\u043C\u0435\u043D\u044F\u0442\u044C"],["\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u0443\u0439","\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C"],["\u0437\u0430\u0434\u0430\u0439","\u0437\u0430\u0434\u0430\u0442\u044C"],["\u043F\u043E\u043B\u0443\u0447\u0438","\u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C"],["\u0443\u0432\u0435\u043B\u0438\u0447\u044C","\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C"],["\u0443\u043C\u0435\u043D\u044C\u0448\u0438","\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C"],["\u0437\u0430\u043F\u0438\u0448\u0438","\u0437\u0430\u043F\u0438\u0441\u0430\u0442\u044C"],["\u043F\u043E\u043A\u0430\u0436\u0438","\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C"],["\u0441\u043A\u0440\u043E\u0439","\u0441\u043A\u0440\u044B\u0442\u044C"],["\u0441\u043F\u0440\u044F\u0447\u044C","\u0441\u043F\u0440\u044F\u0442\u0430\u0442\u044C"],["\u0430\u043D\u0438\u043C\u0438\u0440\u0443\u0439","\u0430\u043D\u0438\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u0432\u044B\u0437\u043E\u0432\u0438","\u0432\u044B\u0437\u0432\u0430\u0442\u044C"],["\u043E\u0442\u043F\u0440\u0430\u0432\u044C","\u043E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C"],["\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u0443\u0439","\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u0440\u0430\u0437\u043C\u043E\u0439","\u0440\u0430\u0437\u043C\u044B\u0442\u044C"],["\u043F\u0435\u0440\u0435\u0439\u0434\u0438","\u043F\u0435\u0440\u0435\u0439\u0442\u0438"],["\u0438\u0434\u0438","\u0438\u0434\u0442\u0438"],["\u0436\u0434\u0438","\u0436\u0434\u0430\u0442\u044C"],["\u043F\u043E\u0434\u043E\u0436\u0434\u0438","\u043F\u043E\u0434\u043E\u0436\u0434\u0430\u0442\u044C"],["\u0437\u0430\u0433\u0440\u0443\u0437\u0438","\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C"],["\u043F\u043E\u0432\u0442\u043E\u0440\u0438","\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C"],["\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438","\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C"],["\u0431\u0440\u043E\u0441\u044C","\u0431\u0440\u043E\u0441\u0438\u0442\u044C"],["\u0432\u0435\u0440\u043D\u0438","\u0432\u0435\u0440\u043D\u0443\u0442\u044C"],["\u0441\u043A\u0430\u0436\u0438","\u0441\u043A\u0430\u0437\u0430\u0442\u044C"],["\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u0443\u0439","\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C"],["\u0438\u0437\u043C\u0435\u0440\u044C","\u0438\u0437\u043C\u0435\u0440\u0438\u0442\u044C"]]),Fe=class{constructor(){this.language="ru";}isNormalizable(r){return r.length<3?false:Yt(r)}normalize(r){let e=r.toLowerCase();if(e.endsWith("\u0441\u044F")||e.endsWith("\u0441\u044C")){let s=this.tryReflexiveNormalization(e);if(s)return s}if(e.endsWith("\u0442\u044C")||e.endsWith("\u0442\u0438")||e.endsWith("\u0447\u044C"))return F(r);let t=this.tryImperativeLookup(e);if(t)return t;let n=this.tryPastTenseNormalization(e);if(n)return n;let i=this.tryPresentTenseNormalization(e);if(i)return i;let o=this.tryGenericImperativeNormalization(e);return o||F(r)}tryReflexiveNormalization(r){(r.endsWith("\u0441\u044F"),2);let t=r.slice(0,-2);if(r.endsWith("\u0442\u044C\u0441\u044F")||r.endsWith("\u0442\u0438\u0441\u044C")||r.endsWith("\u0447\u044C\u0441\u044F"))return F(r);let n=this.normalizeNonReflexive(t);if(n.confidence<1){let i=n.stem.endsWith("\u0442\u044C")?n.stem.slice(0,-2)+"\u0442\u044C\u0441\u044F":n.stem+"\u0441\u044F";return E(i,n.confidence*.95,{removedSuffixes:["\u0441\u044F",...n.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}normalizeNonReflexive(r){if(r.endsWith("\u0442\u044C")||r.endsWith("\u0442\u0438")||r.endsWith("\u0447\u044C"))return F(r);let e=this.tryImperativeLookup(r);if(e)return e;let t=this.tryPastTenseNormalization(r);if(t)return t;let n=this.tryPresentTenseNormalization(r);if(n)return n;let i=this.tryGenericImperativeNormalization(r);return i||F(r)}tryImperativeLookup(r){return Ve.has(r)?E(Ve.get(r),.95,{removedSuffixes:["imperative"],conjugationType:"imperative"}):null}tryGenericImperativeNormalization(r){return r.endsWith("\u0439\u0442\u0435")&&r.length>5?E(r.slice(0,-3)+"\u0442\u044C",.8,{removedSuffixes:["\u0439\u0442\u0435"],conjugationType:"imperative"}):r.endsWith("\u0438\u0442\u0435")&&r.length>5?E(r.slice(0,-3)+"\u0438\u0442\u044C",.8,{removedSuffixes:["\u0438\u0442\u0435"],conjugationType:"imperative"}):r.endsWith("\u0439")&&r.length>3?E(r.slice(0,-1)+"\u0442\u044C",.75,{removedSuffixes:["\u0439"],conjugationType:"imperative"}):r.endsWith("\u0438")&&r.length>3?E(r+"\u0442\u044C",.7,{removedSuffixes:["\u0438\u2192\u0438\u0442\u044C"],conjugationType:"imperative"}):null}tryPastTenseNormalization(r){return r.endsWith("\u0430\u043B\u0430")&&r.length>4?E(r.slice(0,-3)+"\u0430\u0442\u044C",.85,{removedSuffixes:["\u0430\u043B\u0430"],conjugationType:"past"}):r.endsWith("\u0438\u043B\u0430")&&r.length>4?E(r.slice(0,-3)+"\u0438\u0442\u044C",.85,{removedSuffixes:["\u0438\u043B\u0430"],conjugationType:"past"}):r.endsWith("\u0435\u043B\u043E")&&r.length>4?E(r.slice(0,-3)+"\u0435\u0442\u044C",.82,{removedSuffixes:["\u0435\u043B\u043E"],conjugationType:"past"}):r.endsWith("\u0430\u0431\u043E")&&r.length>4?E(r.slice(0,-3)+"\u0430\u0442\u044C",.82,{removedSuffixes:["\u0430\u0431\u043E"],conjugationType:"past"}):r.endsWith("\u0430\u043B\u0438")&&r.length>4?E(r.slice(0,-3)+"\u0430\u0442\u044C",.85,{removedSuffixes:["\u0430\u043B\u0438"],conjugationType:"past"}):r.endsWith("\u0438\u043B\u0438")&&r.length>4?E(r.slice(0,-3)+"\u0438\u0442\u044C",.85,{removedSuffixes:["\u0438\u043B\u0438"],conjugationType:"past"}):r.endsWith("\u0430\u043B")&&r.length>3?E(r.slice(0,-2)+"\u0430\u0442\u044C",.82,{removedSuffixes:["\u0430\u043B"],conjugationType:"past"}):r.endsWith("\u0438\u043B")&&r.length>3?E(r.slice(0,-2)+"\u0438\u0442\u044C",.82,{removedSuffixes:["\u0438\u043B"],conjugationType:"past"}):null}tryPresentTenseNormalization(r){return r.endsWith("\u0438\u0448\u044C")&&r.length>4?E(r.slice(0,-3)+"\u0438\u0442\u044C",.8,{removedSuffixes:["\u0438\u0448\u044C"],conjugationType:"present"}):r.endsWith("\u0438\u0442")&&r.length>3?E(r.slice(0,-2)+"\u0438\u0442\u044C",.78,{removedSuffixes:["\u0438\u0442"],conjugationType:"present"}):r.endsWith("\u0438\u043C")&&r.length>3?E(r.slice(0,-2)+"\u0438\u0442\u044C",.78,{removedSuffixes:["\u0438\u043C"],conjugationType:"present"}):r.endsWith("\u044F\u0442")&&r.length>3?E(r.slice(0,-2)+"\u0438\u0442\u044C",.78,{removedSuffixes:["\u044F\u0442"],conjugationType:"present"}):r.endsWith("\u0435\u0448\u044C")&&r.length>4?E(r.slice(0,-3)+"\u0430\u0442\u044C",.75,{removedSuffixes:["\u0435\u0448\u044C"],conjugationType:"present"}):r.endsWith("\u0435\u0442")&&r.length>3?E(r.slice(0,-2)+"\u0430\u0442\u044C",.72,{removedSuffixes:["\u0435\u0442"],conjugationType:"present"}):r.endsWith("\u0435\u043C")&&r.length>3?E(r.slice(0,-2)+"\u0430\u0442\u044C",.72,{removedSuffixes:["\u0435\u043C"],conjugationType:"present"}):r.endsWith("\u044E\u0442")&&r.length>3?E(r.slice(0,-2)+"\u0430\u0442\u044C",.75,{removedSuffixes:["\u044E\u0442"],conjugationType:"present"}):r.endsWith("\u0443\u0442")&&r.length>3?E(r.slice(0,-2)+"\u0430\u0442\u044C",.72,{removedSuffixes:["\u0443\u0442"],conjugationType:"present"}):null}},ze={code:"ru",name:"Russian",nativeName:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",direction:"ltr",script:"cyrillic",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:true,suffixes:["\u0442\u044C","\u0442\u044C\u0441\u044F","\u0438\u0442\u044C","\u0438\u0442\u044C\u0441\u044F","\u0430\u0442\u044C","\u0430\u0442\u044C\u0441\u044F","\u0435\u0442\u044C","\u0435\u0442\u044C\u0441\u044F"]},references:{me:"\u044F",it:"\u044D\u0442\u043E",you:"\u0442\u044B",result:"\u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442",event:"\u0441\u043E\u0431\u044B\u0442\u0438\u0435",target:"\u0446\u0435\u043B\u044C",body:"body"},possessive:{marker:"",markerPosition:"after-object",usePossessiveAdjectives:true,specialForms:{me:"\u043C\u043E\u0439",it:"\u0435\u0433\u043E",you:"\u0442\u0432\u043E\u0439"},keywords:{\u043C\u043E\u0439:"me",\u043C\u043E\u044F:"me",\u043C\u043E\u0451:"me",\u043C\u043E\u0438:"me",\u0442\u0432\u043E\u0439:"you",\u0442\u0432\u043E\u044F:"you",\u0442\u0432\u043E\u0451:"you",\u0442\u0432\u043E\u0438:"you",\u0435\u0433\u043E:"it",\u0435\u0451:"it"}},roleMarkers:{destination:{primary:"\u0432",alternatives:["\u043D\u0430","\u043A"],position:"before"},source:{primary:"\u0438\u0437",alternatives:["\u043E\u0442","\u0441"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"\u0441",alternatives:["\u0441\u043E"],position:"before"}},keywords:{toggle:{primary:"\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C",alternatives:["\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438"],normalized:"toggle",form:"infinitive"},add:{primary:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C",alternatives:["\u0434\u043E\u0431\u0430\u0432\u044C"],normalized:"add",form:"infinitive"},remove:{primary:"\u0443\u0434\u0430\u043B\u0438\u0442\u044C",alternatives:["\u0443\u0434\u0430\u043B\u0438","\u0443\u0431\u0440\u0430\u0442\u044C","\u0443\u0431\u0435\u0440\u0438"],normalized:"remove",form:"infinitive"},put:{primary:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",alternatives:["\u043F\u043E\u043B\u043E\u0436\u0438","\u043F\u043E\u043C\u0435\u0441\u0442\u0438\u0442\u044C","\u043F\u043E\u043C\u0435\u0441\u0442\u0438","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C","\u0432\u0441\u0442\u0430\u0432\u044C"],normalized:"put",form:"infinitive"},append:{primary:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C_\u0432_\u043A\u043E\u043D\u0435\u0446",alternatives:["\u0434\u043E\u043F\u0438\u0441\u0430\u0442\u044C"],normalized:"append",form:"infinitive"},prepend:{primary:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C_\u0432_\u043D\u0430\u0447\u0430\u043B\u043E",normalized:"prepend",form:"infinitive"},take:{primary:"\u0432\u0437\u044F\u0442\u044C",alternatives:["\u0432\u043E\u0437\u044C\u043C\u0438"],normalized:"take",form:"infinitive"},make:{primary:"\u0441\u043E\u0437\u0434\u0430\u0442\u044C",alternatives:["\u0441\u043E\u0437\u0434\u0430\u0439"],normalized:"make",form:"infinitive"},clone:{primary:"\u043A\u043B\u043E\u043D\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u043A\u043B\u043E\u043D\u0438\u0440\u0443\u0439"],normalized:"clone",form:"infinitive"},swap:{primary:"\u043F\u043E\u043C\u0435\u043D\u044F\u0442\u044C",alternatives:["\u043F\u043E\u043C\u0435\u043D\u044F\u0439"],normalized:"swap",form:"infinitive"},morph:{primary:"\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u0443\u0439"],normalized:"morph",form:"infinitive"},set:{primary:"\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C",alternatives:["\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0437\u0430\u0434\u0430\u0442\u044C","\u0437\u0430\u0434\u0430\u0439"],normalized:"set",form:"infinitive"},get:{primary:"\u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C",alternatives:["\u043F\u043E\u043B\u0443\u0447\u0438"],normalized:"get",form:"infinitive"},increment:{primary:"\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C",alternatives:["\u0443\u0432\u0435\u043B\u0438\u0447\u044C"],normalized:"increment",form:"infinitive"},decrement:{primary:"\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C",alternatives:["\u0443\u043C\u0435\u043D\u044C\u0448\u0438"],normalized:"decrement",form:"infinitive"},log:{primary:"\u0437\u0430\u043F\u0438\u0441\u0430\u0442\u044C",alternatives:["\u0437\u0430\u043F\u0438\u0448\u0438"],normalized:"log",form:"infinitive"},show:{primary:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C",alternatives:["\u043F\u043E\u043A\u0430\u0436\u0438"],normalized:"show",form:"infinitive"},hide:{primary:"\u0441\u043A\u0440\u044B\u0442\u044C",alternatives:["\u0441\u043A\u0440\u043E\u0439","\u0441\u043F\u0440\u044F\u0442\u0430\u0442\u044C","\u0441\u043F\u0440\u044F\u0447\u044C"],normalized:"hide",form:"infinitive"},transition:{primary:"\u0430\u043D\u0438\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u0430\u043D\u0438\u043C\u0438\u0440\u0443\u0439"],normalized:"transition",form:"infinitive"},on:{primary:"\u043F\u0440\u0438",normalized:"on"},trigger:{primary:"\u0438\u043D\u0438\u0446\u0438\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C","\u0437\u0430\u043F\u0443\u0441\u0442\u0438"],normalized:"trigger",form:"infinitive"},send:{primary:"\u043E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C",alternatives:["\u043E\u0442\u043F\u0440\u0430\u0432\u044C"],normalized:"send",form:"infinitive"},focus:{primary:"\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u0443\u0439","\u0444\u043E\u043A\u0443\u0441"],normalized:"focus",form:"infinitive"},blur:{primary:"\u0440\u0430\u0437\u043C\u044B\u0442\u044C",alternatives:["\u0440\u0430\u0437\u043C\u043E\u0439"],normalized:"blur",form:"infinitive"},click:{primary:"\u043A\u043B\u0438\u043A",alternatives:["\u043A\u043B\u0438\u043A\u0435","\u043D\u0430\u0436\u0430\u0442\u0438\u0438"],normalized:"click"},hover:{primary:"\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u0438\u0438",alternatives:["\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u0438\u0435"],normalized:"hover"},submit:{primary:"\u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0435",alternatives:["\u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0430"],normalized:"submit"},input:{primary:"\u0432\u0432\u043E\u0434\u0435",alternatives:["\u0432\u0432\u043E\u0434"],normalized:"input"},change:{primary:"\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0438",alternatives:["\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0435"],normalized:"change"},go:{primary:"\u043F\u0435\u0440\u0435\u0439\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u0439\u0434\u0438","\u0438\u0434\u0442\u0438","\u0438\u0434\u0438"],normalized:"go",form:"infinitive"},wait:{primary:"\u0436\u0434\u0430\u0442\u044C",alternatives:["\u0436\u0434\u0438","\u043F\u043E\u0434\u043E\u0436\u0434\u0438"],normalized:"wait",form:"infinitive"},fetch:{primary:"\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",alternatives:["\u0437\u0430\u0433\u0440\u0443\u0437\u0438"],normalized:"fetch",form:"infinitive"},settle:{primary:"\u0441\u0442\u0430\u0431\u0438\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C",normalized:"settle",form:"infinitive"},if:{primary:"\u0435\u0441\u043B\u0438",normalized:"if"},when:{primary:"\u043A\u043E\u0433\u0434\u0430",normalized:"when"},where:{primary:"\u0433\u0434\u0435",normalized:"where"},else:{primary:"\u0438\u043D\u0430\u0447\u0435",normalized:"else"},repeat:{primary:"\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C",alternatives:["\u043F\u043E\u0432\u0442\u043E\u0440\u0438"],normalized:"repeat",form:"infinitive"},for:{primary:"\u0434\u043B\u044F",alternatives:["\u043A\u0430\u0436\u0434\u044B\u0439"],normalized:"for"},while:{primary:"\u043F\u043E\u043A\u0430",normalized:"while"},continue:{primary:"\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C",alternatives:["\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438"],normalized:"continue",form:"infinitive"},halt:{primary:"\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C",alternatives:["\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0441\u044C","\u0441\u0442\u043E\u043F"],normalized:"halt",form:"infinitive"},throw:{primary:"\u0431\u0440\u043E\u0441\u0438\u0442\u044C",alternatives:["\u0431\u0440\u043E\u0441\u044C"],normalized:"throw",form:"infinitive"},call:{primary:"\u0432\u044B\u0437\u0432\u0430\u0442\u044C",alternatives:["\u0432\u044B\u0437\u043E\u0432\u0438"],normalized:"call",form:"infinitive"},return:{primary:"\u0432\u0435\u0440\u043D\u0443\u0442\u044C",alternatives:["\u0432\u0435\u0440\u043D\u0438"],normalized:"return",form:"infinitive"},then:{primary:"\u0437\u0430\u0442\u0435\u043C",alternatives:["\u043F\u043E\u0442\u043E\u043C","\u0442\u043E\u0433\u0434\u0430"],normalized:"then"},and:{primary:"\u0438",normalized:"and"},end:{primary:"\u043A\u043E\u043D\u0435\u0446",normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"\u0430\u0441\u0438\u043D\u0445\u0440\u043E\u043D\u043D\u043E",alternatives:["async"],normalized:"async"},tell:{primary:"\u0441\u043A\u0430\u0437\u0430\u0442\u044C",alternatives:["\u0441\u043A\u0430\u0436\u0438"],normalized:"tell",form:"infinitive"},default:{primary:"\u043F\u043E_\u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",normalized:"default"},init:{primary:"\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C",alternatives:["\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u0443\u0439"],normalized:"init",form:"infinitive"},behavior:{primary:"\u043F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u0435",normalized:"behavior"},install:{primary:"\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C_\u043F\u0430\u043A\u0435\u0442",normalized:"install",form:"infinitive"},measure:{primary:"\u0438\u0437\u043C\u0435\u0440\u0438\u0442\u044C",alternatives:["\u0438\u0437\u043C\u0435\u0440\u044C"],normalized:"measure",form:"infinitive"},beep:{primary:"\u0437\u0432\u0443\u043A",normalized:"beep"},break:{primary:"\u043F\u0440\u0435\u0440\u0432\u0430\u0442\u044C",normalized:"break"},copy:{primary:"\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C",normalized:"copy"},exit:{primary:"\u0432\u044B\u0439\u0442\u0438",normalized:"exit"},pick:{primary:"\u0432\u044B\u0431\u0440\u0430\u0442\u044C",normalized:"pick"},render:{primary:"\u043E\u0442\u043E\u0431\u0440\u0430\u0437\u0438\u0442\u044C",normalized:"render"},into:{primary:"\u0432",alternatives:["\u0432\u043E"],normalized:"into"},before:{primary:"\u0434\u043E",alternatives:["\u043F\u0435\u0440\u0435\u0434"],normalized:"before"},after:{primary:"\u043F\u043E\u0441\u043B\u0435",normalized:"after"},until:{primary:"\u043F\u043E\u043A\u0430_\u043D\u0435",normalized:"until"},event:{primary:"\u0441\u043E\u0431\u044B\u0442\u0438\u0435",normalized:"event"},from:{primary:"\u0438\u0437",alternatives:["\u043E\u0442","\u0441"],normalized:"from"}},eventHandler:{keyword:{primary:"\u043F\u0440\u0438",normalized:"on"},sourceMarker:{primary:"\u043D\u0430",alternatives:["\u0432","\u043F\u0440\u0438"],position:"before"},eventMarker:{primary:"\u043F\u0440\u0438",position:"before"},temporalMarkers:["\u043A\u043E\u0433\u0434\u0430","\u0435\u0441\u043B\u0438"]}},Xt=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Jt=class{constructor(r=Xt){this.name="operator",this.operators=[...r].sort((e,t)=>t.length-e.length);}canExtract(r,e){return this.operators.some(t=>r.startsWith(t,e))}extract(r,e){for(let t of this.operators)if(r.startsWith(t,e))return {value:t,length:t.length};return null}},Qt="()[]{},:;",Zt=class{constructor(r=Qt){this.punctuation=r,this.name="punctuation";}canExtract(r,e){return this.punctuation.includes(r[e])}extract(r,e){let t=r[e];return this.punctuation.includes(t)?{value:t,length:1}:null}};function er(r,e){let t=r[e];if(t==="#"){let n=r.slice(e).match(/^#[a-zA-Z_][\w-]*/);return n?n[0]:null}if(t==="."){let n=r.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return n?n[0]:null}if(t==="["){let n=0,i=e;for(;i<r.length;){if(r[i]==="["&&n++,r[i]==="]"&&(n--,n===0))return r.slice(e,i+1);i++;}return null}if(t==="<"){let n=r.slice(e).match(/^<[\w-]+(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return n?n[0]:null}return null}var tr=class{constructor(){this.name="css-selector";}canExtract(r,e){let t=r[e];return t==="#"||t==="."||t==="["||t==="<"}extract(r,e){let t=er(r,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},rr=class{constructor(){this.name="event-modifier";}canExtract(r,e){if(r[e]!==".")return false;let t=r.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(t)}extract(r,e){let t=r.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!t)return null;let n=t[0],i=n.slice(1).split("(")[0],o=t[1];return {value:n,length:n.length,metadata:{modifierName:i,value:o?i==="queue"?o:parseInt(o,10):void 0}}}};function nr(r,e){let t=r.slice(e);if(t.startsWith("http://")||t.startsWith("https://")){let n=t.match(/^https?:\/\/[^\s]*/);return n?n[0]:null}if(t.startsWith("//")){let n=t.match(/^\/\/[^\s]*/);return n?n[0]:null}if(t.startsWith("./")||t.startsWith("../")){let n=t.match(/^\.\.?\/[^\s]*/);return n?n[0]:null}if(t.startsWith("/")){let n=t.match(/^\/[^\s]*/);return n?n[0]:null}return null}var ir=class{constructor(){this.name="url";}canExtract(r,e){let t=r.slice(e);return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")}extract(r,e){let t=nr(r,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},or=class{constructor(){this.name="variable-ref";}canExtract(r,e){return r[e]===":"&&e+1<r.length&&/[a-zA-Z_]/.test(r[e+1])}extract(r,e){if(!this.canExtract(r,e))return null;let t=1;for(;e+t<r.length&&/[a-zA-Z0-9_]/.test(r[e+t]);)t++;return {value:r.substring(e,e+t),length:t,metadata:{type:"variable-reference"}}}};function sr(r){return {isLetter:n=>r.test(n),isIdentifierChar:n=>/[0-9]/.test(n)||r.test(n)}}var ar=class{constructor(r,e,t){this.name=r;let n=sr(e);this.isLetter=n.isLetter,this.isIdentifierChar=n.isIdentifierChar,this.prepositions=t;}setContext(r){this.context=r;}canExtract(r,e){return this.isLetter(r[e])}extract(r,e){if(!this.context)throw new Error(`${this.name}: context not set`);let t=e,n="";for(;t<r.length&&this.isIdentifierChar(r[t]);)n+=r[t++];if(!n)return null;let i=n.toLowerCase(),o=this.prepositions.has(i),s=this.context.lookupKeyword(i),a=s&&s.normalized!==s.native?s.normalized:void 0,u;if(!s&&this.context.normalizer){let c=this.context.normalizer.normalize(n);if(c.stem!==n&&c.confidence>=.7){let l=this.context.lookupKeyword(c.stem);l&&(u=l.normalized);}}return {value:n,length:t-e,metadata:{normalized:a||u,isPreposition:o}}}},ur=new Set(["\u0432","\u0432\u043E","\u043D\u0430","\u0441","\u0441\u043E","\u043A","\u043A\u043E","\u043E","\u043E\u0431","\u043E\u0431\u043E","\u0443","\u043E\u0442","\u0434\u043E","\u0438\u0437","\u0437\u0430","\u043F\u043E","\u043F\u043E\u0434","\u043D\u0430\u0434","\u043F\u0435\u0440\u0435\u0434","\u043F\u0435\u0440\u0435\u0434\u043E","\u043C\u0435\u0436\u0434\u0443","\u0447\u0435\u0440\u0435\u0437","\u0431\u0435\u0437","\u0434\u043B\u044F","\u043F\u0440\u0438","\u043F\u0440\u043E","\u043F\u043E\u0441\u043B\u0435","\u0432\u043E\u043A\u0440\u0443\u0433","\u043F\u0440\u043E\u0442\u0438\u0432","\u0432\u043C\u0435\u0441\u0442\u043E","\u043A\u0440\u043E\u043C\u0435","\u0441\u0440\u0435\u0434\u0438"]);function lr(){return [new ar("russian-keyword",/[a-zA-Zа-яА-ЯёЁ]/,ur)]}function cr(r){let e=r.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function pr(r){let e=r.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var dr=class{constructor(){this.name="ascii-identifier";}setContext(r){this.context=r;}canExtract(r,e){return cr(r[e])}extract(r,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let t=e,n="",i=e;for(;i<r.length&&pr(r[i]);)n+=r[i],i++;if(!n)return null;let o=this.context.lookupKeyword(n),s=o&&o.normalized!==o.native?o.normalized:void 0;return {value:n,length:i-t,metadata:{normalized:s}}}};function fr(){return [new ir,new rr,new or,new tr]}var mr=new Set(["\u0432","\u0432\u043E","\u043D\u0430","\u0441","\u0441\u043E","\u043A","\u043A\u043E","\u043E","\u043E\u0431","\u043E\u0431\u043E","\u0443","\u043E\u0442","\u0434\u043E","\u0438\u0437","\u0437\u0430","\u043F\u043E","\u043F\u043E\u0434","\u043D\u0430\u0434","\u043F\u0435\u0440\u0435\u0434","\u043F\u0435\u0440\u0435\u0434\u043E","\u043C\u0435\u0436\u0434\u0443","\u0447\u0435\u0440\u0435\u0437","\u0431\u0435\u0437","\u0434\u043B\u044F","\u043F\u0440\u0438","\u043F\u0440\u043E","\u043F\u043E\u0441\u043B\u0435","\u0432\u043E\u043A\u0440\u0443\u0433","\u043F\u0440\u043E\u0442\u0438\u0432","\u0432\u043C\u0435\u0441\u0442\u043E","\u043A\u0440\u043E\u043C\u0435","\u0441\u0440\u0435\u0434\u0438"]),hr=[{native:"\u0438\u0441\u0442\u0438\u043D\u0430",normalized:"true"},{native:"\u043F\u0440\u0430\u0432\u0434\u0430",normalized:"true"},{native:"\u043B\u043E\u0436\u044C",normalized:"false"},{native:"null",normalized:"null"},{native:"\u043D\u0435\u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D\u043E",normalized:"undefined"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434\u0430",normalized:"s"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434\u044B",normalized:"s"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434",normalized:"s"},{native:"\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0430",normalized:"ms"},{native:"\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u044B",normalized:"ms"},{native:"\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434",normalized:"ms"},{native:"\u043C\u0438\u043D\u0443\u0442\u0430",normalized:"m"},{native:"\u043C\u0438\u043D\u0443\u0442\u044B",normalized:"m"},{native:"\u043C\u0438\u043D\u0443\u0442",normalized:"m"},{native:"\u0447\u0430\u0441",normalized:"h"},{native:"\u0447\u0430\u0441\u0430",normalized:"h"},{native:"\u0447\u0430\u0441\u043E\u0432",normalized:"h"},{native:"\u043F\u0435\u0440\u0432\u0430\u044F",normalized:"first"},{native:"\u043F\u0435\u0440\u0432\u043E\u0435",normalized:"first"},{native:"\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u044F\u044F",normalized:"last"},{native:"\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0435\u0435",normalized:"last"},{native:"\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F",normalized:"next"},{native:"\u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F",normalized:"previous"},{native:"\u043F\u0443\u0441\u0442\u0430\u044F",normalized:"empty"},{native:"\u043F\u0443\u0441\u0442\u043E\u0435",normalized:"empty"},{native:"\u043C\u043E\u044F",normalized:"my"},{native:"\u043C\u043E\u0451",normalized:"my"},{native:"\u043C\u043E\u0438",normalized:"my"}],yr=class extends $e{constructor(){super(),this.language="ru",this.direction="ltr",this.initializeKeywordsFromProfile(ze,hr),this.setNormalizer(new Fe),this.registerExtractors([...fr(),...lr(),new _e,new Ie,new dr,new Jt,new Zt]);}classifyToken(r){let e=r.toLowerCase();return mr.has(e)?"particle":this.isKeyword(e)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(r)?"event-modifier":r.startsWith("#")||r.startsWith(".")||r.startsWith("[")||r.startsWith("*")||r.startsWith("<")?"selector":r.startsWith('"')||r.startsWith("'")||/^\d/.test(r)?"literal":"identifier"}},vr=new yr;Kt("ru",vr,ze);var gr=Object.defineProperty,Er=Object.getOwnPropertyNames,et=(r,e)=>function(){return r&&(e=(0, r[Er(r)[0]])(r=0)),e},br=(r,e)=>{for(var t in e)gr(r,t,{get:e[t],enumerable:true});};function qe(r,e){return r.replace(/\{(\w+)\}/g,(t,n)=>String(e[n]??`{${n}}`))}function A(r,e,t={},n){let i=tt[r],o=qe(i,t),s=rt[r],a=s?qe(s,t):void 0;return {code:r,message:o,severity:e,...n&&{role:n},...a&&{suggestion:a}}}var h,tt,rt,Sr=et({"src/generators/schema-error-codes.ts"(){h={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},tt={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[h.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[h.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[h.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[h.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[h.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[h.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[h.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[h.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[h.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[h.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[h.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},rt={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[h.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[h.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[h.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[h.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[h.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[h.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[h.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[h.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),nt={};br(nt,{SchemaErrorCodes:()=>h,formatValidationResults:()=>Rr,getValidationStats:()=>Pr,validateAllKeywordCollisions:()=>Or,validateAllSchemas:()=>Ar,validateCommandSchema:()=>it,validateKeywordCollisions:()=>ot,validateRoleValues:()=>Nr});function Tr(r,e){return {action:r,items:e,get notes(){return e.filter(t=>t.severity==="note").map(t=>t.message)},get warnings(){return e.filter(t=>t.severity==="warning").map(t=>t.message)},get errors(){return e.filter(t=>t.severity==="error").map(t=>t.message)}}}function it(r){let e=[];for(let n of r.roles)n.expectedTypes.includes("literal")&&n.expectedTypes.includes("selector")&&(n.role==="patient"&&Ee.has(r.action)?e.push(A(h.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:n.role,command:r.action},n.role)):e.push(A(h.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:n.role},n.role))),n.expectedTypes.length>3&&!Ee.has(r.action)&&e.push(A(h.TOO_MANY_EXPECTED_TYPES,"warning",{role:n.role,count:n.expectedTypes.length},n.role));for(let n of r.roles)n.selectorKinds&&n.selectorKinds.length>0&&(n.expectedTypes.includes("selector")||e.push(A(h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:n.role},n.role)));switch(r.action){case "transition":Cr(r,e);break;case "on":wr(r,e);break;case "if":case "unless":kr(r,e);break;case "repeat":case "for":case "while":xr(r,e);break}return r.roles.filter(n=>n.required).length===0&&(st.has(r.action)?e.push(A(h.NO_REQUIRED_ROLES_EXPECTED,"note",{command:r.action})):e.push(A(h.NO_REQUIRED_ROLES,"warning",{}))),Tr(r.action,e)}function Cr(r,e){let t=r.roles.find(i=>i.role==="patient"),n=r.roles.find(i=>i.role==="goal");t&&t.expectedTypes.includes("selector")&&e.push(A(h.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),t&&!n&&e.push(A(h.TRANSITION_MISSING_GOAL,"error",{}));}function wr(r,e){let t=r.roles.find(n=>n.role==="event");t||e.push(A(h.EVENT_HANDLER_MISSING_EVENT,"warning",{})),t&&!t.required&&e.push(A(h.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function kr(r,e){let t=r.roles.find(n=>n.role==="condition");t||e.push(A(h.CONDITIONAL_MISSING_CONDITION,"warning",{})),t&&!t.required&&e.push(A(h.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function xr(r,e){r.action==="for"?r.roles.find(n=>n.role==="source")||e.push(A(h.FOR_LOOP_MISSING_SOURCE,"warning",{})):r.action==="while"&&(r.roles.find(n=>n.role==="condition")||e.push(A(h.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Ar(r,e={}){let t=new Map,{includeNotes:n=false}=e;for(let[i,o]of Object.entries(r)){let s=it(o),a=s.items.some(c=>c.severity==="warning"||c.severity==="error"),u=n&&s.items.some(c=>c.severity==="note");(a||u)&&t.set(i,s);}return t}function Rr(r,e={}){let t=[],{showNotes:n=false,showCodes:i=true}=e;for(let[o,s]of r){let a=s.items.filter(l=>l.severity==="error"),u=s.items.filter(l=>l.severity==="warning"),c=s.items.filter(l=>l.severity==="note");if(a.length>0){t.push(` \u274C ${o}:`);for(let l of a){let p=i?` [${l.code}]`:"";t.push(` ERROR${p}: ${l.message}`),l.suggestion&&t.push(` \u{1F4A1} Suggestion: ${l.suggestion}`);}}if(u.length>0){t.push(` \u26A0\uFE0F ${o}:`);for(let l of u){let p=i?` [${l.code}]`:"";t.push(` ${p?`${l.code}: `:""}${l.message}`),l.suggestion&&t.push(` \u{1F4A1} ${l.suggestion}`);}}if(n&&c.length>0){t.push(` \u2139\uFE0F ${o}:`);for(let l of c){let p=i?` [${l.code}]`:"";t.push(` ${p?`${l.code}: `:""}${l.message}`);}}}return t.join(`
2
+ `)}function Pr(r){let e=0,t=0,n=0,i={};for(let o of r.values())for(let s of o.items)s.severity==="error"?e++:s.severity==="warning"?t++:s.severity==="note"&&n++,i[s.code]=(i[s.code]||0)+1;return {totalCommands:r.size,errors:e,warnings:t,notes:n,byCode:i}}function Nr(r,e){let t=[];for(let n of e){let i=r.roles.find(o=>o.role===n.role);i&&(i.expectedTypes.length>0&&!i.expectedTypes.includes(n.type)&&(i.expectedTypes.includes("expression")||t.push({level:"error",role:n.role,message:`${r.action}.${n.role} expects type [${i.expectedTypes.join(", ")}], got '${n.type}'`,code:h.VALUE_TYPE_MISMATCH})),n.type==="selector"&&n.selectorKind&&i.selectorKinds&&i.selectorKinds.length>0&&(i.selectorKinds.includes(n.selectorKind)||t.push({level:"error",role:n.role,message:`${r.action}.${n.role} expects selector kind [${i.selectorKinds.join(", ")}], got '${n.selectorKind}'`,code:h.SELECTOR_KIND_MISMATCH})));}return t}function ot(r){let e=[];if(!r.keywords)return {language:r.code,collisions:e};let t=new Map;for(let[i,o]of Object.entries(r.keywords)){if(!o||!o.primary)continue;let s=t.get(o.primary)||[];if(s.push({command:i,isPrimary:true}),t.set(o.primary,s),o.alternatives)for(let a of o.alternatives){let u=t.get(a)||[];u.push({command:i,isPrimary:false}),t.set(a,u);}}for(let[i,o]of t){let s=[...new Set(o.map(c=>c.command))];if(s.length<=1)continue;let a=o.filter(c=>c.isPrimary).length,u;a>=2?u="primary-primary":a===1?u="primary-alternative":u="alternative-alternative",e.push({keyword:i,commands:s.sort(),type:u});}let n={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((i,o)=>n[i.type]-n[o.type]),{language:r.code,collisions:e}}function Or(r){let e=[];for(let[,t]of Object.entries(r)){let n=ot(t);n.collisions.length>0&&e.push(n);}return e.sort((t,n)=>t.language.localeCompare(n.language))}var Ee,st,_r=et({"src/generators/schema-validator.ts"(){Sr(),Ee=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),st=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep"]);}});function Z(r){let e="complex";return r.startsWith("#")&&!r.includes(" ")?e="id":r.startsWith(".")&&!r.includes(" ")?e="class":r.startsWith("[")&&r.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(r)&&(e="element"),{type:"selector",value:r,selectorKind:e}}function w(r,e){let t={type:"literal",value:r};return e!==void 0?{type:"literal",value:r,dataType:e}:t}function We(r){return Me(r)}function L(r){return {type:"reference",value:r}}function ye(r,e){return {type:"property-path",object:r,property:e}}function se(r,e,t){let n={kind:"command",action:r,roles:new Map(Object.entries(e))};return t!==void 0?{...n,metadata:t}:n}function je(r,e,t,n,i,o){let s=new Map;s.set("event",r);let a={kind:"event-handler",action:"on",roles:s,body:e};return t!==void 0&&(a.eventModifiers=t),n!==void 0&&(a.metadata=n),a}function Ue(r,e="then",t){let n={kind:"compound",action:"compound",roles:new Map,statements:r,chainType:e};return t!==void 0&&(n.metadata=t),n}function Ge(r,e){return !e||e.length===0||e.includes(r)||e.includes("expression")?true:r==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function Ir(r,e){return r.possessive?.keywords?.[e]}var W=new Map,j=new Map,ae=new Map,be=null;function at(r,e){let t={...r};for(let n of Object.keys(e)){let i=e[n],o=r[n];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?t[n]=at(o,i):t[n]=i);}return t}function Mr(r,e){return at(r,e)}function Te(r){if(!r.extends)return r;let e=j.get(r.extends);if(!e)return console.warn(`[Registry] Profile '${r.code}' extends '${r.extends}' but base is not registered. Make sure to import the base language before the variant.`),r;let t=Te(e);return Mr(t,r)}function ut(r){be=r;}var Ke=new Map;function U(r){return r.split("-")[0]}function G(r){return r.includes("-")}function Lr(r){let e=W.get(r);if(!e&&G(r)){let t=U(r);e=W.get(t);}if(!e){let t=Array.from(W.keys()).join(", ");throw new Error(`Language '${r}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${r}';`)}return e}function Dr(r){let e=j.get(r);if(!e&&G(r)){let t=U(r);e=j.get(t);}if(!e){let t=Array.from(j.keys()).join(", ");throw new Error(`Language profile '${r}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${r}';`)}return Te(e)}function Br(r){let e=W.get(r);return !e&&G(r)&&(e=W.get(U(r))),e}function D(r){let e=j.get(r);return !e&&G(r)&&(e=j.get(U(r))),e?Te(e):void 0}function lt(){return Array.from(W.keys())}function $r(r,e){return Lr(e).tokenize(r)}function q(r){let e=ae.get(r);if(!e&&G(r)&&(e=ae.get(U(r))),e)return e;let t=Ke.get(r);if(!t&&G(r)&&(t=Ke.get(U(r))),t)return ae.set(r,t),t;if(!be)throw new Error(`No patterns registered for language '${r}'. Either import the language module or set a pattern generator.`);let n=Dr(r),i=be(n);return ae.set(r,i),i}var ve=.8,Fr=.6,zr=.15,qr=.5,He=.15,Ye=.1,Xe=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"]),Wr={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"]},jr=class{calculate(r){return this.calculateWithBreakdown(r).final}calculateWithBreakdown(r){let e=this.scoreRoleCoverage(r),t=this.scoreStemPenalty(r),n=this.scoreLanguageBoost(r),i=this.scoreLanguageAdjustment(r),o=e;return o=Math.max(qr,o+t),o=Math.min(1,o+n),o=Math.max(0,Math.min(1,o+i)),{roleCoverage:e,stemPenalty:t,languageBoost:n,languageAdjustment:i,final:o}}scoreRoleCoverage(r){let{pattern:e,captured:t}=r,n=0,i=0,o=s=>e.extraction?.[s]?.default!==void 0;for(let s of e.template.tokens)if(s.type==="role")i+=1,t.has(s.role)&&(n+=1);else if(s.type==="group")for(let a of s.tokens)a.type==="role"&&(i+=ve,t.has(a.role)?n+=ve:o(a.role)&&(n+=ve*Fr));return i>0?n/i:1}scoreStemPenalty(r){let{stemMatchCount:e,totalKeywordMatches:t}=r;return e<=0||t<=0?0:-(e/t)*zr}scoreLanguageBoost(r){let{pattern:e}=r;if(e.language!=="ar")return 0;let t=e.template.tokens[0];return !t||t.type!=="literal"?0:Xe.has(t.value)||t.alternatives?.some(n=>Xe.has(n))?He:0}scoreLanguageAdjustment(r){let{pattern:e,captured:t}=r;if(e.language!=="ar")return 0;let n=0;for(let[i,o]of t.entries()){let s=Wr[i];if(!s||s.length===0)continue;let a="metadata"in o?o.metadata:void 0;a&&typeof a.prepositionValue=="string"&&(s.includes(a.prepositionValue)?n+=.1:n-=.1);}return Math.max(-Ye,Math.min(Ye,n))}},Ur=new jr,le=class Q{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Ur;}matchPattern(e,t){let n=e.mark(),i=new Map;if(this.currentProfile=D(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,i))return e.reset(n),null;let s=this.confidenceModel.calculate({pattern:t,captured:i,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-n.position,confidence:s}}matchBest(e,t){this.matchCache.clear();let n=[],i=e.position();for(let s of t){let a=e.mark(),u=`${i}:${s.id}`,c;this.matchCache.has(u)?c=this.matchCache.get(u):(c=this.matchPattern(e,s),this.matchCache.set(u,c)),c&&n.push(c),e.reset(a);}if(n.length===0)return null;n.sort((s,a)=>{let u=a.pattern.priority-s.pattern.priority;return u!==0?u:a.confidence-s.confidence});let o=n[0];return this.matchPattern(e,o.pattern),o}matchTokenSequence(e,t,n){let i=t[0],o=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();for(let s of t)if(!this.matchPatternToken(e,s,n)){if(this.isOptional(s))continue;return false}return true}matchPatternToken(e,t,n){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,n);case "group":return this.matchGroupToken(e,t,n);default:return false}}matchLiteralToken(e,t){let n=e.peek();if(!n)return false;let i=this.getMatchType(n,t.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let o of t.alternatives){let s=this.getMatchType(n,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,n){this.skipNoiseWords(e);let i=e.peek();if(!i)return t.optional||false;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(o.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(n.set(t.role,o),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(s.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(n.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Ge(a.type,t.expectedTypes)?t.optional||false:(n.set(t.role,a),true);let u=this.tryMatchPropertyAccessExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(u.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(n.set(t.role,u),true);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!Ge(c.type,t.expectedTypes)?t.optional||false:(n.set(t.role,c),true);let l=this.tokenToSemanticValue(i);return !l||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(l.type)?t.optional||false:(n.set(t.role,l),e.advance(),true)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let n=(t.normalized||t.value).toLowerCase(),i=Ir(this.currentProfile,n);if(!i)return null;let o=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(o),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let a=s.value;s.kind==="selector"&&a.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a)&&(a=a.substring(1));let u=a;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)u+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(u+=c.value,e.advance()),ye(L(i),u)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(n),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<Q.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance();}return {type:"expression",raw:`${t.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let s=`${t.value}.${o.value}`,a=1;for(;!e.isAtEnd()&&a<Q.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let l=e.peek();if(!l||l.kind!=="identifier")break;e.advance(),s+=`.${l.value}`,a++;}let u=e.peek();if(u&&u.kind==="punctuation"&&u.value==="("){e.advance();let c=[],l=0;for(;!e.isAtEnd()&&c.length<Q.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(l===0){e.advance();break}l--;}if(d.kind==="punctuation"&&d.value==="("&&l++,d.kind==="punctuation"&&d.value===","){e.advance();continue}c.push(d.value),e.advance();}return {type:"expression",raw:`${s}(${c.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(n),null;e.advance();let o=e.peek();return !o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(n),null):(e.advance(),ye(Z(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(n),null;let o=e.peek(1);o&&o.kind,e.advance();let s=i.value.slice(1);return ye(Z(t.value),s)}matchGroupToken(e,t,n){let i=e.mark(),o=new Set(n.keys());if(!this.matchTokenSequence(e,t.tokens,n)){e.reset(i);for(let a of n.keys())o.has(a)||n.delete(a);return t.optional||false}return true}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return Z(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=(e.normalized||e.value).toLowerCase();return We(t)?L(t):w(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return L(e.value);let n=e.value.toLowerCase();return We(n)?L(n):{type:"expression",raw:e.value};case "url":return w(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return w(i,"string")}if(e==="true")return w(true,"boolean");if(e==="false")return w(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?w(e,"duration"):w(i,"number")}let n=parseFloat(e);return isNaN(n)?w(e,"string"):w(n,"number")}applyExtractionRules(e,t){for(let[n,i]of Object.entries(e.extraction))t.has(n)||(i.value!==void 0?t.set(n,{type:"literal",value:i.value}):i.default&&t.set(n,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let t=e.peek();if(!t)return;let n=t.value.toLowerCase();if(Q.ENGLISH_NOISE_WORDS.has(n)){let i=e.mark();e.advance();let o=e.peek();if(o&&(o.kind==="selector"||o.kind==="identifier"))return;e.reset(i);}n==="class"&&e.advance();}extractEventModifiers(e){let t={},n=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(n=true,o.modifierName){case "once":t.once=true;break;case "debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case "throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case "queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance();}return n?t:void 0}};le.MAX_PROPERTY_DEPTH=10;le.MAX_METHOD_ARGS=20;le.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var ct=le,z=new ct;function Gr(r){return Br(r)}function ge(r,e){return $r(r,e)}function pt(){return lt()}var Kr={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyut_de\u011Fi\u015Ftir:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};var Yr={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},Xr={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},Jr={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},Qr={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"}}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},Zr={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},en={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},tn={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},rn={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},nn={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},on={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},sn={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},an={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},un={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},ln={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},cn={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},pn={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},dn={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},fn={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},mn={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},hn={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},yn={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},vn={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},gn={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"-e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"-man",sw:"kwa"}}]},En={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},bn={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Sn={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Tn={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},Cn={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in"}}]},wn={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},kn={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},xn={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""}}]},An={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"auf",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},Rn={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},Pn={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Nn={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},On={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},_n={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},In={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Mn={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Ln={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}}]},Dn={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man"}}]},Bn={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},$n={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Vn={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Fn={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},zn={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with"}}]},qn={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"destination",roles:[{role:"destination",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"patient",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},Wn={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:false,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},jn={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Un={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Gn={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},Kn={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Hn={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},dt={toggle:Yr,add:Xr,remove:Jr,put:Qr,set:Zr,show:en,hide:tn,on:rn,trigger:nn,wait:on,fetch:sn,increment:an,decrement:un,append:ln,prepend:cn,log:pn,get:dn,take:fn,make:mn,halt:hn,settle:yn,throw:vn,send:gn,if:En,unless:bn,else:Sn,repeat:Tn,for:Cn,while:wn,continue:kn,go:xn,transition:An,clone:Rn,focus:Pn,blur:Nn,call:On,return:_n,js:In,async:Mn,tell:Ln,default:Dn,init:Bn,behavior:$n,install:Vn,measure:Fn,swap:zn,morph:qn,beep:Wn,break:jn,copy:Un,exit:Gn,pick:Kn,render:Hn,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function Yn(){return Object.values(dt).filter(r=>r.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(_r(),nt)).then(({validateAllSchemas:r,formatValidationResults:e})=>{let t=r(dt);t.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(t)),console.warn(`
3
+ These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(r=>{console.debug("Schema validation skipped:",r);});var Je=class extends Error{constructor(r,e,t,n){super(r),this.name="SemanticParseError",this.language=e,this.input=t,this.diagnostics=n;}};function P(r,e,t){return {message:r,severity:e,source:"semantic-parser",...t&&{code:t}}}function ue(r,e){return e.length===0?r:{...r,diagnostics:e}}var K=class O{parse(e,t){let{modifiers:n,remainingInput:i}=this.extractStandaloneModifiers(e,t),o=i||e,s=[],a=ge(o,t),u=q(t);if(u.length===0)throw new Je(`No patterns available for language: ${t}`,t,o,[P(`No patterns registered for language '${t}'`,"error","no-patterns")]);let c=[...u].sort((y,g)=>g.priority-y.priority),l=c.filter(y=>y.command==="on"),p=z.matchBest(a,l);if(p){s.push(P(`event pattern matched: ${p.pattern.id} (confidence: ${p.confidence.toFixed(2)})`,"info","pattern-match"));let y=this.buildEventHandler(p,a,t),g=n?this.applyModifiers(y,n):y;return ue(g,s)}s.push(P(`event patterns: ${l.length} tried, no match`,"info","stage-event"));let d=c.filter(y=>y.command!=="on"),f=z.matchBest(a,d);if(f)return s.push(P(`command pattern matched: ${f.pattern.id} (confidence: ${f.confidence.toFixed(2)})`,"info","pattern-match")),ue(this.buildCommand(f,t),s);s.push(P(`command patterns: ${d.length} tried, no match`,"info","stage-command"));let m=this.trySOVEventExtraction(o,t,c);if(m){s.push(P("SOV event extraction succeeded","info","stage-sov"));let y=n?this.applyModifiers(m,n):m;return ue(y,s)}s.push(P("SOV event extraction: no event keyword found","info","stage-sov"));let v=this.tryCompoundCommandParsing(a,d,t);if(v)return s.push(P("compound command parsing succeeded","info","stage-compound")),ue(v,s);throw s.push(P("compound parsing: no then-keywords or no command matches","info","stage-compound")),s.push(P(`all parse stages exhausted for "${o}"`,"error","parse-failed")),new Je(`Could not parse input in ${t}: ${o}`,t,o,s)}canParse(e,t){try{return this.parse(e,t),!0}catch{return false}}supportedLanguages(){return pt()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let n={};for(let[i,o]of e.captured)n[i]=o;return se(e.pattern.command,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,t,n){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");let o=z.extractEventModifiers(t),s=this.extractOrConjunctionEvents(t,n),a=i;s.length>0&&i.type==="literal"&&(a={type:"literal",value:[String(i.value),...s.map(p=>String("value"in p?p.value:""))].join(" or ")});let u,c=e.captured.get("action");if(c&&c.type==="literal"){let l=c.value,p={};for(let[m,v]of e.captured)m!=="event"&&m!=="action"&&m!=="continues"&&(p[m]=v);let d=se(l,p,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence}),f=e.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then"){let m=q(n).filter(g=>g.command!=="on").sort((g,S)=>S.priority-g.priority),v=q(n).filter(g=>g.id.startsWith("grammar-")&&g.id.includes("-continuation")).sort((g,S)=>S.priority-g.priority),y=this.parseBodyWithGrammarPatterns(t,m,v,n);y.length>0?u=[d,...y]:u=[d];}else u=[d];}else {let l=q(n).filter(p=>p.command!=="on").sort((p,d)=>d.priority-p.priority);u=this.parseBodyWithClauses(t,l,n);}return je(a,u,o,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,n){let i=[],o=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;let a=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,n),u=s.kind==="keyword"&&this.isEndKeyword(s.value,n);if(a){if(o.length>0){let c=this.parseClause(o,t,n);i.push(...c),o.length=0;}e.advance();continue}if(u){if(o.length>0){let c=this.parseClause(o,t,n);i.push(...c);}e.advance();break}o.push(s),e.advance();}if(o.length>0){let s=this.parseClause(o,t,n);i.push(...s);}return i.length>1?[Ue(i,"then",{sourceLanguage:n})]:i}parseClause(e,t,n){if(e.length===0)return [];let i=new J(e,n),o=[];for(;!i.isAtEnd();){let s=z.matchBest(i,t);s?o.push(this.buildCommand(s,n)):i.advance();}if(o.length===0){let s=this.parseSOVClauseByVerbAnchoring(e,n);if(s.length>0)return s}return o}static buildVerbLookup(e){let t=new Map;for(let[n,i]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(n)&&(t.set(i.primary.toLowerCase(),n),i.alternatives))for(let o of i.alternatives)t.set(o.toLowerCase(),n);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[n,i]of Object.entries(e.roleMarkers))if(i&&(t.set(i.primary,n),i.alternatives))for(let o of i.alternatives)t.has(o)||t.set(o,n);return t}parseSOVClauseByVerbAnchoring(e,t){let n=D(t);if(!n||n.wordOrder!=="SOV")return [];let i=O.buildVerbLookup(n),o=O.buildMarkerToRoleLookup(n),s=[],a=0;for(;a<e.length;){let u=-1,c="";for(let m=a;m<e.length;m++){let v=e[m],y=i.get(v.value.toLowerCase()),g=v.normalized?i.get(v.normalized.toLowerCase()):void 0,S=y||g;if(S){u=m,c=S;break}}if(u===-1)break;let l=e.slice(a,u),p=e.length;for(let m=u+1;m<e.length;m++){let v=e[m];if(v.kind==="conjunction"||this.isThenKeyword(v.value,t)){p=m;break}if(m>u+1&&(i.get(v.value.toLowerCase())||(v.normalized?i.get(v.normalized.toLowerCase()):void 0))){p=m;break}}let d=e.slice(u+1,p),f=this.extractRolesFromMarkedTokens(l,d,o,c,t);if(s.push(se(c,f,{sourceLanguage:t,confidence:.7})),a=p,a<e.length){let m=e[a];(m.kind==="conjunction"||this.isThenKeyword(m.value,t))&&a++;}}return s}extractRolesFromMarkedTokens(e,t,n,i,o){let s={},a=u=>{let c=[];for(let l of u){let p=n.get(l.value);if(p&&l.kind==="particle"&&c.length>0){let d=this.tokensToSemanticValue(c);if(d){let f=this.mapRoleForCommand(p,i,s);f&&(s[f]=d);}c=[];}else c.push(l);}if(c.length>0){let l=this.tokensToSemanticValue(c);l&&(s.patient?s.destination||(s.destination=l):s.patient=l);}};return a(e),a(t),s}mapRoleForCommand(e,t,n){return n[e]?e==="patient"&&!n.destination?"destination":e==="destination"&&!n.patient?"patient":e==="source"&&!n.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let t=e.filter(o=>o.kind!=="whitespace");if(t.length===0)return null;if(t.length===1)return this.tokenToSemanticValue(t[0]);let n=t.map(o=>o.value).join(""),i=t[0];return i.kind==="selector"||i.value.startsWith("#")||i.value.startsWith(".")||i.value.startsWith("@")||i.value.startsWith("*")?Z(n):i.kind==="literal"||i.value.startsWith('"')||i.value.startsWith("'")?w(n):i.kind==="reference"?L(n):w(n)}tokenToSemanticValue(e){let t=e.value;if(e.kind==="selector"||t.startsWith("#")||t.startsWith(".")||t.startsWith("@")||t.startsWith("*"))return Z(t);if(t.startsWith('"')||t.startsWith("'"))return w(t);if(/^-?\d+(\.\d+)?$/.test(t))return w(parseFloat(t));if(t==="true"||t==="\u771F"||t==="\uCC38"||t==="do\u011Fru")return w(true);if(t==="false"||t==="\u507D"||t==="\uAC70\uC9D3"||t==="yanl\u0131\u015F")return w(false);let n=e.normalized?.toLowerCase();return n==="me"||n==="it"||n==="you"||n==="result"||n==="body"?L(n):e.kind==="reference"?L(e.normalized||"me"):w(t)}parseBodyWithGrammarPatterns(e,t,n,i){let o=[];for(;!e.isAtEnd();){let s=e.peek();if(s&&this.isThenKeyword(s.value,i)){e.advance();continue}if(s&&this.isEndKeyword(s.value,i)){e.advance();break}let a=false;if(n.length>0){let u=z.matchBest(e,n);if(u){let c=u.pattern.command,l={};for(let[f,m]of u.captured)f!=="event"&&f!=="action"&&f!=="continues"&&(l[f]=m);let p=se(c,l,{sourceLanguage:i,patternId:u.pattern.id});o.push(p),a=true;let d=u.captured.get("continues");if(d&&d.type==="literal"&&d.value==="then")continue}}if(!a){let u=z.matchBest(e,t);u&&(o.push(this.buildCommand(u,i)),a=true);}a||e.advance();}return o}tryCompoundCommandParsing(e,t,n){let i=e.tokens;if(!i.some(u=>u.kind==="conjunction"||u.kind==="keyword"&&this.isThenKeyword(u.value,n)))return null;let s=new J(i,n),a=this.parseBodyWithClauses(s,t,n);return a.length===0?null:a.length===1?a[0]:Ue(a,"then",{sourceLanguage:n,confidence:.65})}trySOVEventExtraction(e,t,n){let i=O.SOV_EVENT_MARKERS[t];if(!i)return null;let s=ge(e,t).tokens,a=Kr[t],u=new Set;if(a)for(let b of Object.keys(a))u.add(b.toLowerCase());let c=O.SOV_SOURCE_MARKERS[t],l=-1,p="",d="",f=1;for(let b=0;b<s.length;b++){let k=s[b],_=k.value.toLowerCase(),I=_,B="",pe=_.indexOf("[");pe>0&&(I=_.slice(0,pe),B=k.value.slice(pe));let de=k.normalized?.toLowerCase(),Pe=de&&O.KNOWN_EVENTS.has(de),Ne=u.has(_)||u.has(I),kt=O.KNOWN_EVENTS.has(I);if(Pe||Ne||kt){let H;if(Pe?H=de:Ne?H=a?.[_]??a?.[I]??I:H=I,i.size>0){let ne=1,fe=s[b+1];fe&&fe.kind==="selector"&&fe.value.startsWith("[")&&(ne=2);let ie=s[b+ne];if(ie&&(ie.kind==="particle"||ie.kind==="keyword")&&i.has(ie.value)){l=b,p=H,d=B||(ne===2?s[b+1].value:""),f=ne+1;break}}else {l=b,p=H,d=B,f=1;break}}}if(l===-1)return null;let m=new Set;for(let b=l;b<l+f;b++)m.add(b);if(c){let b=l+f;if(b<s.length){let k=s[b];(k.kind==="particle"||k.kind==="keyword")&&c.markers.has(k.value)&&m.add(b);}for(let k=0;k<l;k++){let _=s[k],I=_.value.toLowerCase(),B=_.normalized?.toLowerCase();if(c.windowTokens.has(I)||B&&c.windowTokens.has(B)){m.add(k);break}}}let v=s.filter((b,k)=>!m.has(k));if(v.length===0)return null;let y=n.filter(b=>b.command!=="on"),g=new J(v,t),S=this.parseBodyWithClauses(g,y,t);if(S.length===0)return null;let Re={sourceLanguage:t,confidence:.75};return d&&(Re.keyFilter=d),je({type:"literal",value:p},S,void 0,Re)}isThenKeyword(e,t){let n={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (n[t]||n.en).has(e.toLowerCase())}isEndKeyword(e,t){let n={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return (n[t]||n.en).has(e.toLowerCase())}extractStandaloneModifiers(e,t){let i=ge(e,t).tokens;if(i.length===0)return {modifiers:null,remainingInput:null};let s=i[0].value.toLowerCase(),a=O.STANDALONE_MODIFIERS[s];if(!a)return {modifiers:null,remainingInput:null};let u={},c=1;if(a==="once")u.once=true;else {let f=1;if(f<i.length){let m=i[f];(m.kind==="keyword"||m.kind==="particle")&&(f++,c++);}if(f<i.length){let m=i[f];if(m.kind==="literal"){let v=m.value.match(/^(\d+)(ms|s|m)?$/);if(v){let y=parseInt(v[1],10),g=v[2]||"ms";g==="s"?y*=1e3:g==="m"&&(y*=6e4),u[a]=y,c=f+1;}}}u[a]||(u[a]=a==="debounce"?300:100);}let l=i.slice(c);if(l.length===0)return {modifiers:null,remainingInput:null};let p=l[0].position.start,d=e.slice(p);return {modifiers:u,remainingInput:d}}applyModifiers(e,t){return {...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let n=[];for(;;){let i=e.mark(),o=e.peek();if(!o)break;let s=(o.normalized||o.value).toLowerCase();if(!O.OR_KEYWORDS.has(s)){e.reset(i);break}e.advance();let a=e.peek();if(!a){e.reset(i);break}let u=(a.normalized||a.value).toLowerCase();e.advance(),n.push({type:"literal",value:u});}return n}};K.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);K.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"])};K.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])}};K.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};K.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o"]);var Xn=K,Jn=new Xn;function Ce(r,e){return Jn.parse(r,e)}var Se=class{constructor(r={}){this.cache=new Map,this.config={maxSize:r.maxSize??1e3,ttlMs:r.ttlMs??0,enabled:r.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(r,e){return `${e}:${r}`}isExpired(r){return this.config.ttlMs===0?false:Date.now()-r.createdAt>this.config.ttlMs}evictLRU(){let r=this.cache.keys().next().value;r!==void 0&&(this.cache.delete(r),this.stats.evictions++);}get(r,e){if(!this.config.enabled){this.stats.misses++;return}let t=this.makeKey(r,e),n=this.cache.get(t);if(!n){this.stats.misses++;return}if(this.isExpired(n)){this.cache.delete(t),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(t),n.lastAccessed=Date.now(),this.cache.set(t,n),this.stats.hits++,n.result}set(r,e,t){if(!this.config.enabled||t.confidence===0)return;let n=this.makeKey(r,e),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(n,{result:t,createdAt:i,lastAccessed:i});}has(r,e){if(!this.config.enabled)return false;let t=this.makeKey(r,e),n=this.cache.get(t);return n?this.isExpired(n)?(this.cache.delete(t),this.stats.expirations++,false):true:false}delete(r,e){let t=this.makeKey(r,e);return this.cache.delete(t)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let r=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:r>0?this.stats.hits/r:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(r){if(r.maxSize!==void 0)for(this.config.maxSize=r.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();r.ttlMs!==void 0&&(this.config.ttlMs=r.ttlMs),r.enabled!==void 0&&(this.config.enabled=r.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}},Qn=new Se;var Zn=class{constructor(r={}){this.patternMatcher=new ct,this.languages=new Set(lt()),r.cache===false?this.cache=new Se({enabled:false}):this.cache=r.cache?new Se(r.cache):Qn;}analyze(r,e){if(!this.supportsLanguage(e))return {confidence:0,errors:[`Language '${e}' is not supported for semantic parsing`]};let t=this.cache.get(r,e);if(t)return t;let n=this.analyzeUncached(r,e);return this.cache.set(r,e,n),n}analyzeUncached(r,e){try{try{let s=Ce(r,e),a={confidence:s.metadata?.confidence??.8,node:s};return s.kind==="command"?{...a,command:{name:s.action,roles:s.roles}}:a}catch{}let t=Gr(e);if(!t)return {confidence:0,errors:[`No tokenizer available for language '${e}'`]};let n=t.tokenize(r),i=q(e);if(i.length===0)return {confidence:0,errors:[`No patterns available for language '${e}'`]};let o=this.patternMatcher.matchBest(n,i);if(o){let s=this.buildSemanticNode(o);return {confidence:o.confidence,command:{name:o.pattern.command,roles:o.captured},node:s,tokensConsumed:o.consumedTokens}}return {confidence:0,errors:["No pattern matched the input"]}}catch(t){return {confidence:0,errors:[t instanceof Error?t.message:String(t)]}}}supportsLanguage(r){return this.languages.has(r)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear();}configureCache(r){this.cache.configure(r);}buildSemanticNode(r){return {kind:"command",action:r.pattern.command,roles:r.captured,metadata:{patternId:r.pattern.id}}}};function ft(r){return new Zn(r)}var ei=.5;function mt(r,e=ei){return r.confidence>=e&&r.command!==void 0}function ht(r,e){let t=e==="SOV"?"sovPosition":"svoPosition";return [...r].sort((n,i)=>{let o=n[t]??99,s=i[t]??99;return o-s})}function ti(r,e){let t=r.markerOverride?.[e.code],n=e.roleMarkers[r.role];if(t!==void 0)return {primary:t,position:n?.position??"before",isOverride:true};if(n&&n.primary){let i={primary:n.primary,position:n.position,isOverride:false};return n.alternatives&&(i.alternatives=n.alternatives),i}return null}function ri(r,e,t,n,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let c=n.primary.split(/\s+/);if(c.length>1)for(let l of c)o.push({type:"literal",value:l});else {let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}}let s=e.roleMarkers.destination;s&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.patient;if(a){let c=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};o.push(c);}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(u),{id:`${r.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`{event} ${n.primary} {destination?} {patient} ${a?.primary||""} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ni(r,e,t,n,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(u);}if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let u=n.primary.split(/\s+/);if(u.length>1)for(let c of u)o.push({type:"literal",value:c});else {let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(c);}}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${r.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${n.primary} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ii(r,e,t,n,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(c);}let a=e.roleMarkers.destination;if(a&&(o.push({type:"role",role:"destination",optional:false}),o.push(a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary})),o.push({type:"role",role:"event",optional:false}),n.position==="after"){let c=n.primary.split(/\s+/);if(c.length>1)for(let l of c)o.push({type:"literal",value:l});else {let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(u),{id:`${r.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`{patient} ${s?.primary||""} {destination} ${a?.primary||""} {event} ${n.primary} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function oi(r,e,t,n,i){let o=[];o.push({type:"role",role:"event",optional:false});let s=n.alternatives?.filter(l=>!l.includes(" ")&&l.length>1)||[];s.length>0&&o.push({type:"literal",value:s[0],alternatives:s.slice(1)});let a=e.roleMarkers.destination;a&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary}]}),o.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let l=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};o.push(l);}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(c),{id:`${r.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(i.basePriority??100)+52,template:{format:`{event}${s[0]||""} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function si(r,e,t,n,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let a=n.primary.split(/\s+/);if(a.length>1)for(let u of a)o.push({type:"literal",value:u});else {let u=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(u);}}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(s),{id:`${r.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{event} ${n.primary} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function ai(r,e,t,n){let i=e.eventHandler?.temporalMarkers;if(!i||i.length===0)return null;let o=[];o.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&o.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),o.push({type:"literal",value:i[0],alternatives:i.slice(1)}),o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s?.primary){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(u);}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${r.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(n.basePriority??100)+49,template:{format:`{event} ${i[0]} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function ui(r,e,t,n,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),n.position==="after"){let l=n.primary.split(/\s+/);if(l.length>1)for(let p of l)o.push({type:"literal",value:p});else {let p=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(p);}}let a=[...r.roles.filter(l=>l.required)].sort((l,p)=>{let d=l.sovPosition??999,f=p.sovPosition??999;return d-f});for(let l of a){o.push({type:"role",role:l.role,optional:false});let p,d;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)p=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(u);let c=a.map(l=>`{${l.role}}`).join(" ");return {id:`${r.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`{event} ${n.primary} ${c} ${t.primary}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(a.map(l=>[l.role,{fromRole:l.role}]))}}}function li(r,e,t,n,i){let o=[],a=[...r.roles.filter(m=>m.required)].sort((m,v)=>{let y=m.sovPosition??999,g=v.sovPosition??999;return y-g}),u=a[0];o.push({type:"role",role:u.role,optional:false});let c;if(u.markerOverride&&u.markerOverride[e.code]!==void 0)c=u.markerOverride[e.code];else {let m=e.roleMarkers[u.role];m&&(c=m.primary);}if(c&&o.push({type:"literal",value:c}),o.push({type:"role",role:"event",optional:false}),n.position==="after"){let m=n.primary.split(/\s+/);if(m.length>1)for(let v of m)o.push({type:"literal",value:v});else {let v=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(v);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(l);let p=a[1];o.push({type:"role",role:p.role,optional:false});let d,f;if(p.markerOverride&&p.markerOverride[e.code]!==void 0)d=p.markerOverride[e.code];else {let m=e.roleMarkers[p.role];m&&(d=m.primary,f=m.alternatives);}if(d){let m=f?{type:"literal",value:d,alternatives:f}:{type:"literal",value:d};o.push(m);}return {id:`${r.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{${u.role}} {event} ${n.primary} ${t.primary} {${p.role}}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},[u.role]:{fromRole:u.role},[p.role]:{fromRole:p.role}}}}function Qe(r,e,t,n,i){let o=[];if(n.position==="before"){let u=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(u);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;return a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),{id:`${r.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`${n.primary} {event} ${t.primary} {patient} ${a?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ci(r,e,t,n,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;if(a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),n.position==="before"){let u=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(u);}return o.push({type:"role",role:"event",optional:false}),{id:`${r.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`${t.primary} {patient} ${a?.primary||""} {destination?} ${n.primary} {event}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function pi(r,e,t,n,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let u=[...r.roles.filter(l=>l.required)].sort((l,p)=>{let d=l.svoPosition??999,f=p.svoPosition??999;return d-f});for(let l of u){let p,d;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)p=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:l.role,optional:false});}if(n.position==="before"){let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}o.push({type:"role",role:"event",optional:false});let c=u.map(l=>`{${l.role}}`).join(" ");return {id:`${r.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${t.primary} ${c} ${n.primary} {event}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(u.map(l=>[l.role,{fromRole:l.role}]))}}}function Ze(r,e,t,n,i){let o=[];if(n.position==="before"){let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};o.push(l);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let u=[...r.roles.filter(l=>l.required)].sort((l,p)=>{let d=l.svoPosition??999,f=p.svoPosition??999;return d-f});for(let l of u){let p,d;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)p=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:l.role,optional:false});}let c=u.map(l=>`{${l.role}}`).join(" ");return {id:`${r.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`${n.primary} {event} ${t.primary} ${c}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(u.map(l=>[l.role,{fromRole:l.role}]))}}}function di(r,e,t,n,i){let o=[],s=e.eventHandler?.negationMarker;if(n.position==="before"){let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.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:false});let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(a),o.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&o.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),{id:`${r.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${n.primary} ${s?.primary||""} {event} ${t.primary} {patient} ${u?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function fi(r,e,t,n){let i=[];i.push({type:"literal",value:"and",alternatives:["then"]}),i.push({type:"role",role:"event",optional:false});let o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(o),i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&i.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${r.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`[proclitic?] {event} ${t.primary} {patient} ${s?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var ee={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function yt(r,e,t=ee){let n=`${r.action}-${e.code}-generated`,i=t.basePriority??100,o=e.keywords[r.action];if(!o)throw new Error(`No keyword translation for '${r.action}' in ${e.code}`);let s=vi(r,e,o),a=gt(r,e),u=Si(r,e,o);return {id:n,language:e.code,command:r.action,priority:i,template:{format:u,tokens:s},extraction:a}}function mi(r,e,t=ee){if(r.roles.filter(a=>!a.required).length===0)return null;let i=r.roles.filter(a=>a.required),o={...r,roles:i};return {...yt(o,e,t),id:`${r.action}-${e.code}-generated-simple`,priority:(t.basePriority??100)-5,extraction:gt(r,e)}}function hi(r,e,t=ee){let n=[];if(n.push(yt(r,e,t)),t.generateSimpleVariants){let i=mi(r,e,t);i&&n.push(i);}return n}function vt(r,e=ee){let t=[],n=Yn();for(let i of n){if(!r.keywords[i.action])continue;let o=hi(i,r,e);if(t.push(...o),r.eventHandler?.eventMarker){let s=yi(i,r,e);t.push(...s);}}return t}function yi(r,e,t=ee){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let n=[],i=e.eventHandler.eventMarker,o=e.keywords[r.action];if(!o)return [];let a=r.roles.filter(u=>u.required).length===2;if(e.wordOrder==="SOV")if(a)n.push(ui(r,e,o,i,t)),n.push(li(r,e,o,i,t));else {n.push(ri(r,e,o,i,t)),n.push(ni(r,e,o,i,t));let u=e.roleMarkers.destination;u&&u.primary!==i.primary&&n.push(ii(r,e,o,i,t));let c=i.primary.split(/\s+/),l=i.alternatives?.some(d=>!d.includes(" ")&&d.length>1);c.length>1&&l&&n.push(oi(r,e,o,i,t)),n.push(si(r,e,o,i,t));let p=ai(r,e,o,t);p&&n.push(p);}else e.wordOrder==="VSO"?a?(n.push(Ze(r,e,o,i,t)),n.push(pi(r,e,o,i,t))):(n.push(Qe(r,e,o,i,t)),n.push(ci(r,e,o,i,t)),e.eventHandler?.negationMarker&&n.push(di(r,e,o,i,t)),e.tokenization?.prefixes&&n.push(fi(r,e,o,t))):a?n.push(Ze(r,e,o,i,t)):n.push(Qe(r,e,o,i,t));return n}function vi(r,e,t){let n=[],i=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},o=gi(r,e);switch(e.wordOrder){case "SVO":n.push(i),n.push(...o);break;case "SOV":n.push(...o),n.push(i);break;case "VSO":n.push(i),n.push(...o);break;default:n.push(i),n.push(...o);}return n}function gi(r,e){let t=[],n=ht(r.roles,e.wordOrder);for(let i of n){let o=Ei(i,e);i.required?t.push(...o):t.push({type:"group",optional:true,tokens:o});}return t}function Ei(r,e){let t=[],n=r.markerOverride?.[e.code],i=e.roleMarkers[r.role],o={type:"role",role:r.role,optional:!r.required,expectedTypes:r.expectedTypes};if(n!==void 0)(i?.position??"before")==="before"?(n&&t.push({type:"literal",value:n}),t.push(o)):(t.push(o),n&&t.push({type:"literal",value:n}));else if(i)if(i.position==="before"){if(i.primary){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}t.push(o);}else {t.push(o);let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}else t.push(o);return t}function bi(r,e){let t={};for(let n of r.roles){let i=n.markerOverride?.[e.code],o=e.roleMarkers[n.role];i!==void 0?t[n.role]=i?{marker:i}:{}:o&&o.primary?t[n.role]=o.alternatives?{marker:o.primary,markerAlternatives:o.alternatives}:{marker:o.primary}:t[n.role]={};}return t}function gt(r,e){let t=bi(r,e),n={};for(let i of r.roles){let o=t[i.role]||{};!i.required&&i.default?n[i.role]={...o,default:i.default}:n[i.role]=o;}return n}function Si(r,e,t){let n=[],o=ht(r.roles,e.wordOrder).map(s=>{let a=ti(s,e),u="";return a&&a.primary?a.position==="before"?u=`${a.primary} {${s.role}}`:u=`{${s.role}} ${a.primary}`:u=`{${s.role}}`,s.required?u:`[${u}]`});switch(e.wordOrder){case "SVO":case "VSO":n.push(t.primary,...o);break;case "SOV":n.push(...o,t.primary);break;default:n.push(t.primary,...o);}return n.join(" ")}function ce(r){let e=r.getAttribute("data-lang");if(e)return we(e);let t=r.getAttribute("data-hyperscript-lang")??r.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return we(t);let n=typeof document<"u"?document.documentElement?.lang:null;return n&&n!=="en"?we(n):null}function we(r){return r.split("-")[0].toLowerCase()}var Et={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],blur:[["patient",""]],break:[],call:[["patient",""]],clone:[["patient",""],["destination","into"]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","to"]],on:[["event",""],["source","from"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],return:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["patient",""]],while:[["condition",""]]};function re(r){switch(r.kind){case "event-handler":return Ti(r);case "compound":return Ci(r);default:return wi(r)}}function Ti(r){let e=["on"],t=r.roles.get("event");t&&e.push(te(t));let n=r.roles.get("source");if(n&&e.push("from",te(n)),r.body&&r.body.length>0){let i=r.body.map(re);e.push(i.join(" then "));}return e.join(" ")}function Ci(r){let e=r.chainType==="async"?"async":r.chainType;return r.statements.map(re).join(` ${e} `)}function wi(r){let e=Et[r.action];if(e){let n=[r.action];for(let[i,o]of e){let s=r.roles.get(i);s&&(i==="destination"&&s.type==="reference"&&s.value==="me"||(o&&n.push(o),n.push(te(s))));}return n.join(" ")}let t=[r.action];for(let[,n]of r.roles)t.push(te(n));return t.join(" ")}function te(r){switch(r.type){case "literal":return typeof r.value=="string"&&r.dataType==="string"?`"${r.value}"`:String(r.value);case "selector":return r.value;case "reference":return r.value;case "property-path":return ki(r);case "expression":return r.raw;case "flag":return r.enabled?`+${r.name}`:`~${r.name}`}}function ki(r){let e=te(r.object),t=r.property;if(r.object.type==="reference")switch(r.object.value){case "me":return `my ${t}`;case "it":return `its ${t}`;case "you":return `your ${t}`}return `${e}'s ${t}`}var St=.5,xi={confidenceThreshold:St,strategy:"semantic",fallbackToOriginal:true};function Ai(r,e){return typeof r=="number"?r:r[e]??r["*"]??St}var ke=null;function Ri(){return ke||(ke=ft()),ke}function xe(r,e,t={}){let n={...xi,...t},i=bt(r,e,n);if(i!==null)return i;let o=Ni(r);if(o){let s=bt(o.commands,e,n);if(s!==null)return o.prefix+s}return r}function bt(r,e,t){if(t.strategy==="semantic"||t.strategy==="auto"){let n=Ai(t.confidenceThreshold,e),i=Tt(r,e,n);if(i!==null)return i}if((t.strategy==="auto"||t.strategy==="i18n")&&t.i18nToEnglish){let n=Oi(r,e,t.i18nToEnglish);if(n!==null)return n}return null}var Pi=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Ni(r){let e=r.match(Pi);if(!e)return null;let t=e[1],n=r.slice(t.length);return n?{prefix:t,commands:n}:null}function Tt(r,e,t){try{let n=Ii(r,e);if(n.length>1)return Mi(n,e,t);let i=Ri();if(!i.supportsLanguage(e))return null;let o=i.analyze(r,e);if(!mt(o,t))return null;if(o.node)return re(o.node);let s=Ce(r,e);return re(s)}catch{return null}}function Oi(r,e,t){try{let n=t(r,e);return n!==r?n:null}catch{return null}}function _i(r){let e=["then"],t=D(r);if(t?.keywords?.then){let n=t.keywords.then;if(n.primary&&n.primary!=="then"&&e.push(n.primary),n.alternatives)for(let i of n.alternatives)e.includes(i)||e.push(i);}return e}function Ii(r,e){let n=_i(e).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\s+(?:${n.join("|")})\\s+`,"i"),o=r.split(`
4
+ `).map(a=>a.trim()).filter(a=>a.length>0),s=[];for(let a of o){let u=a.split(i);s.push(...u);}return s}function Mi(r,e,t){let n=[];for(let i of r){let o=Tt(i.trim(),e,t);if(o===null)return null;n.push(o);}return n.join(" then ")}function Ae(r={}){return function(t){let{internals:n}=t,i=n.runtime,o=i.getScript.bind(i);i.getScript=function(s){let a=o(s);if(!a)return null;let u=Li(s,r);if(!u||u==="en")return a;let c=xe(a,u,r);return r.debug&&c!==a&&console.log(`[hyperscript-i18n] ${u}: "${a}" \u2192 "${c}"`),c};}}function Li(r,e){if(e.languageAttribute){let n=r.getAttribute(e.languageAttribute);if(n)return n.split("-")[0].toLowerCase()}let t=ce(r);return t||(e.defaultLanguage??null)}function Ct(r,e,t={}){return e==="en"?r:xe(r,e,t)}ut(r=>vt(r));function wt(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Ae()),Di());}function Di(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let t=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(t).forEach(n=>{let i=e.getInternalData(n);i.initialized&&(i.initialized=false);}),e.processNode(document.body);}var zo=["ru"];wt();exports.plugin=Ae;exports.preprocess=Ct;exports.resolveLanguage=ce;exports.supportedLanguages=zo;return exports;})({});