@hyperscript-tools/multilingual 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +203 -1
- package/dist/hyperscript-i18n-ar.global.js +6 -6
- package/dist/hyperscript-i18n-bn.global.js +6 -6
- package/dist/hyperscript-i18n-de.global.js +6 -6
- package/dist/hyperscript-i18n-east-asian.global.js +6 -6
- package/dist/hyperscript-i18n-en.global.js +8 -8
- package/dist/hyperscript-i18n-es.global.js +6 -6
- package/dist/hyperscript-i18n-fr.global.js +6 -6
- package/dist/hyperscript-i18n-he.global.js +6 -6
- package/dist/hyperscript-i18n-hi.global.js +6 -6
- package/dist/hyperscript-i18n-id.global.js +6 -6
- package/dist/hyperscript-i18n-it.global.js +6 -6
- package/dist/hyperscript-i18n-ja.global.js +6 -6
- package/dist/hyperscript-i18n-ko.global.js +6 -6
- package/dist/hyperscript-i18n-lite.global.js +2 -2
- package/dist/hyperscript-i18n-ms.global.js +6 -6
- package/dist/hyperscript-i18n-pl.global.js +6 -6
- package/dist/hyperscript-i18n-pt.global.js +6 -6
- package/dist/hyperscript-i18n-qu.global.js +6 -6
- package/dist/hyperscript-i18n-ru.global.js +6 -6
- package/dist/hyperscript-i18n-slavic.global.js +6 -6
- package/dist/hyperscript-i18n-south-asian.global.js +6 -6
- package/dist/hyperscript-i18n-southeast-asian.global.js +6 -6
- package/dist/hyperscript-i18n-sw.global.js +6 -6
- package/dist/hyperscript-i18n-th.global.js +6 -6
- package/dist/hyperscript-i18n-tl.global.js +6 -6
- package/dist/hyperscript-i18n-tr.global.js +6 -6
- package/dist/hyperscript-i18n-uk.global.js +6 -6
- package/dist/hyperscript-i18n-vi.global.js +6 -6
- package/dist/hyperscript-i18n-western.global.js +6 -6
- package/dist/hyperscript-i18n-zh.global.js +6 -6
- package/dist/hyperscript-i18n.global.js +28 -28
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var HyperscriptI18n=(function(exports){'use strict';function Ce(t,e){return e?{type:"literal",value:t,dataType:e}:{type:"literal",value:t}}function Fr(t,e){return e?{type:"selector",value:t,selectorKind:e}:{type:"selector",value:t}}function mr(t){return {type:"reference",value:t}}function Or(t,e){return {type:"property-path",object:t,property:e}}var Ut=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function it(t,e=Ut){return e.has(t)}var ba=class{constructor(t){this.namespace=t,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let t=process.env.DEBUG||"";return t==="*"||t.includes("framework:*")||t.includes(`framework:${this.namespace}`)}return false}log(t,e,...r){if(!this.enabled)return;let i=`[framework:${this.namespace}]`,n=new Date().toISOString();switch(t){case "debug":console.debug(`${n} ${i} DEBUG:`,e,...r);break;case "info":console.info(`${n} ${i} INFO:`,e,...r);break;case "warn":console.warn(`${n} ${i} WARN:`,e,...r);break;case "error":console.error(`${n} ${i} ERROR:`,e,...r);break}}debug(t,...e){this.log("debug",t,...e);}info(t,...e){this.log("info",t,...e);}warn(t,...e){this.log("warn",t,...e);}error(t,...e){this.log("error",t,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function Ca(t){return new ba(t)}function Je(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 Aa(t,e){return t?.possessive?.keywords?.[e]}var fr=class Qe{constructor(){this.logger=Ca("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,i){let n=e.mark(),a=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let u=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)u.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",u),this.logger.debug("Profile code:",i?.code);}this.currentProfile=i,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(r.template.tokens,null,2));let o=this.matchTokenSequence(e,r.template.tokens,a);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(a.entries()).map(([u,l])=>[u,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(n),null;let s=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-n.position,confidence:s}}matchBest(e,r,i){let n=[];for(let o of r){let s=e.mark(),u=this.matchPattern(e,o,i);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;if(u!==0)return u;let l=s.confidence-o.confidence;return Math.abs(l)>.001?l:s.consumedTokens-o.consumedTokens});let a=n[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,i,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let s=null,u=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let d=e.peek();if(this.logger.debug(" >> Current input token:",d?JSON.stringify({type:d.type,value:d.value,kind:d.kind}):"EOF"),c.type==="role"&&c.greedy){let v=this.collectStopMarkers(r,l+1);if(n)for(let E of n)v.add(E);let y=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||this.isStopMarker(E,v))break;y.push(E.value),e.advance();}if(y.length>0){i.set(c.role,{type:"expression",raw:y.join(" ")}),s=null,u=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let v=this.collectStopMarkers(r,l+1);if(n)for(let E of n)v.add(E);if(this.matchGroupToken(e,c,i,v)){s=null,u=null;continue}if(this.isOptional(c))continue;return false}let m=c.type==="role"&&c.optional===true,p=m?e.mark():null;if(c.type==="role"&&!m){let v=l+1<r.length?r[l+1]:null;if(v?.type==="literal"){let y=e.peek();if(y&&this.getMatchType(y,v.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(c))continue;if(s&&u){this.logger.debug(" >> BACKTRACKING: undoing optional role",u),e.reset(s),i.delete(u),s=null,u=null;let E=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",E),E)continue}return false}}}let h=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Match result:",h),h){m?(s=p,u=c.role):(s=null,u=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(s&&u){this.logger.debug(" >> BACKTRACKING: undoing optional role",u),e.reset(s),i.delete(u),s=null,u=null;let v=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",v),v)continue}return false}}return true}matchPatternToken(e,r,i){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,i);case "group":return this.matchGroupToken(e,r,i);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",i?JSON.stringify({type:i.type,value:i.value,kind:i.kind}):"null"),!i)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let n=this.getMatchType(i,r.value);if(this.logger.debug(" >>> matchType for",i.value,"vs",r.value,":",n),n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(i,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,i){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",r.role),this.logger.debug(" >>> matchRoleToken: expected types",r.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",r.optional),this.skipNoiseWords(e);let n=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null"),!n)return r.optional||false;let a=this.tryMatchPossessiveExpression(e);if(a)return r.expectedTypes&&r.expectedTypes.length>0&&!Je(a.type,r.expectedTypes)?r.optional||false:(i.set(r.role,a),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Je(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let s=this.tryMatchPossessiveSelectorExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!Je(s.type,r.expectedTypes)?r.optional||false:(i.set(r.role,s),true);let u=this.tryMatchPropertyAccessExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Je(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!Je(l.type,r.expectedTypes)?r.optional||false:(i.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null");let c=this.tokenToSemanticValue(n);return this.logger.debug(" >>> tokenToSemanticValue returned:",c?JSON.stringify(c):"null"),c?(this.logger.debug(" >>> Validating type:",c.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!Je(c.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),i.set(r.role,c),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=r.normalized||r.value,n=this.safeToLowerCase(i),a=Aa(this.currentProfile,n);if(!a)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 l=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),Or(mr(a),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(i),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<Qe.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}s.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=`${r.value}.${a.value}`,s=1;for(;!e.isAtEnd()&&s<Qe.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,s++;}let u=e.peek();if(u&&u.kind==="punctuation"&&u.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<Qe.MAX_METHOD_ARGS;){let m=e.peek();if(!m)break;if(m.kind==="punctuation"&&m.value===")"){if(c===0){e.advance();break}c--;}if(m.kind==="punctuation"&&m.value==="("&&c++,m.kind==="punctuation"&&m.value===","){e.advance();continue}l.push(m.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="punctuation"||n.value!=="'s")return e.reset(i),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"&&a.kind!=="identifier"?(e.reset(i),null):(e.advance(),Or(Fr(r.value),a.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(i),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return Or(Fr(r.value),o)}matchGroupToken(e,r,i,n){let a=e.mark(),o=new Set(i.keys());if(this.matchTokenSequence(e,r.tokens,i,n))return true;e.reset(a);for(let l of i.keys())o.has(l)||i.delete(l);if(!r.optional)return false;let u=this.getGroupLeadingMarker(r);if(u)for(let l=1;l<=Qe.MAX_MARKER_SCAN;l++){let c=e.peek(l);if(!c)break;if((c.normalized||c.value).toLowerCase()===u){this.logger.debug(" >> MARKER SCAN: found",u,"at offset",l,"- skipping intervening tokens");for(let p=0;p<l;p++)e.advance();if(this.matchTokenSequence(e,r.tokens,i,n))return true;e.reset(a);for(let p of i.keys())o.has(p)||i.delete(p);break}}return true}getGroupLeadingMarker(e){let r=e.tokens[0];return r?.type==="literal"?r.value.toLowerCase():null}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"&&this.safeToLowerCase(e.value)===r.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,r){let i=new Set;for(let n=r;n<e.length;n++){let a=e[n];if(a.type==="literal"){if(i.add(a.value.toLowerCase()),a.alternatives)for(let o of a.alternatives)i.add(o.toLowerCase());break}if(a.type==="group"){for(let o of a.tokens)if(o.type==="literal"){if(i.add(o.value.toLowerCase()),o.alternatives)for(let s of o.alternatives)i.add(s.toLowerCase());break}if(!a.optional)break}}return i}isStopMarker(e,r){return r.size===0?false:!!(r.has(e.value.toLowerCase())||e.normalized&&r.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return Fr(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return Ce(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return mr(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return Ce(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let n=e.slice(1,-1);return Ce(n,"string")}if(e==="true")return Ce(true,"boolean");if(e==="false")return Ce(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?Ce(e,"duration"):Ce(n,"number")}let i=parseFloat(e);return isNaN(i)?Ce(e,"string"):Ce(i,"number")}applyExtractionRules(e,r){for(let[i,n]of Object.entries(e.extraction))r.has(i)||(n.value!==void 0?r.set(i,{type:"literal",value:n.value}):n.default&&r.set(i,n.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let i=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")n+=1,r.has(l.role)&&(i+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let d=a(c.role),m=.8;n+=m,r.has(c.role)?i+=m:d&&(i+=m*.6);}}let o=n>0?i/n:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let s=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+s);let u=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+u)),o}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let r=e.template.tokens[0];if(!r||r.type!=="literal")return 0;let i=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(i.has(r.value))return .15;if(r.alternatives){for(let n of r.alternatives)if(i.has(n))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let i=0,n={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[a,o]of r.entries()){let s=n[a];if(!s||s.length===0)continue;let u="metadata"in o?o.metadata:void 0;if(u&&typeof u.prepositionValue=="string"){let l=u.prepositionValue;s.includes(l)?i+=.1:i-=.1;}}return Math.max(-0.1,Math.min(.1,i))}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=this.safeToLowerCase(r.value);if(Qe.ENGLISH_NOISE_WORDS.has(i)){let n=e.mark();e.advance();let a=e.peek();if(a&&a.kind==="selector")return;e.reset(n);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(i=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return i?r:void 0}};fr.MAX_MARKER_SCAN=3;fr.MAX_PROPERTY_DEPTH=10;fr.MAX_METHOD_ARGS=20;fr.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Sa=fr;new Sa;var Ae=class{constructor(){this.name="string-literal";}canExtract(t,e){let r=t[e];return r==="'"&&e>0&&/[\p{L}\p{M}\p{N}_)\]]/u.test(t[e-1])?false:r==='"'||r==="'"||r==="`"||r==="\u201C"||r==="\u2018"}extract(t,e){let r=t[e];if(r==="\u201C"){let a=1;for(;e+a<t.length;){if(t[e+a]==="\u201D")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}if(r==="\u2018"){let a=1;for(;e+a<t.length;){if(t[e+a]==="\u2019")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}let i=1,n=false;for(;e+i<t.length;){let a=t[e+i];if(n){n=false,i++;continue}if(a==="\\"){n=true,i++;continue}if(a===r)return i++,{value:t.substring(e,e+i),length:i};i++;}return null}},Se=class{constructor(){this.name="number";}canExtract(t,e){return /\d/.test(t[e])}extract(t,e){let r=0,i=false;for(;e+r<t.length;){let o=t[e+r];if(/\d/.test(o))r++;else if(o==="."&&!i)i=true,r++;else break}if(r===0)return null;let n=t.substring(e,e+r),a=e+r;if(a<t.length){let o=t.slice(a),s=[{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 l of s)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:n+"ms",length:r+2,metadata:{hasTimeUnit:true}};let u=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of u)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:n+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:n,length:r}}};function xa(t){return "setContext"in t&&typeof t.setContext=="function"}function Da(t){let e={language:t.language,direction:t.direction,lookupKeyword:t.lookupKeyword.bind(t),isKeyword:t.isKeyword.bind(t),isKeywordStart:t.isKeywordStart.bind(t),...t.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:t.isKeywordStartAtBoundary.bind(t)}:{}};return t.normalizer?{...e,normalizer:t.normalizer}:e}var oe=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 ee(t,e){return {start:t,end:e}}function re(t,e,r,i){if(typeof t=="object"){let{value:a,kind:o,position:s,normalized:u,stem:l,stemConfidence:c,metadata:d}=t;return {value:a,kind:o,position:s,...u!==void 0&&{normalized:u},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...d!==void 0&&{metadata:d}}}let n=t;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof i=="string")return {value:n,kind:e,position:r,normalized:i};if(i){let{normalized:a,stem:o,stemConfidence:s,metadata:u}=i;return {value:n,kind:e,position:r,...a!==void 0&&{normalized:a},...o!==void 0&&{stem:o},...s!==void 0&&{stemConfidence:s},...u!==void 0&&{metadata:u}}}return {value:n,kind:e,position:r}}function pr(t){return /\s/.test(t)}function Ba(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function Ta(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function We(t){return /\d/.test(t)}function Pr(t){return t.replace(/[\u064b-\u0652\u0670]/g,"")}function Fa(t){return /[a-zA-Z]/.test(t)}function pe(t){return /[a-zA-Z0-9_-]/.test(t)}function Oa(t,e){if(e>=t.length)return null;let r=t[e];if(!Ba(r))return null;let i=e,n="";if(r==="#"||r==="."){for(n+=t[i++];i<t.length&&pe(t[i]);)n+=t[i++];if(n.length<=1)return null;if(i<t.length&&t[i]==="."&&r==="#"){let o=i+1;for(;o<t.length&&pe(t[o]);)o++;if(o<t.length&&t[o]==="(")return n}}else if(r==="["){let a=1,o=false,s=null,u=false;for(n+=t[i++];i<t.length&&a>0;){let l=t[i];n+=l,u?u=false:l==="\\"?u=true:o?l===s&&(o=false,s=null):l==='"'||l==="'"||l==="`"?(o=true,s=l):l==="["?a++:l==="]"&&a--,i++;}if(a!==0)return null}else if(r==="@"){for(n+=t[i++];i<t.length&&pe(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="*"){for(n+=t[i++];i<t.length&&pe(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="<"){if(n+=t[i++],i>=t.length||!Fa(t[i]))return null;for(;i<t.length&&pe(t[i]);)n+=t[i++];for(;i<t.length;){let a=t[i];if(a==="."){if(n+=t[i++],i>=t.length||!pe(t[i]))return null;for(;i<t.length&&pe(t[i]);)n+=t[i++];}else if(a==="#"){if(n+=t[i++],i>=t.length||!pe(t[i]))return null;for(;i<t.length&&pe(t[i]);)n+=t[i++];}else if(a==="["){let o=1,s=false,u=null,l=false;for(n+=t[i++];i<t.length&&o>0;){let c=t[i];n+=c,l?l=false:c==="\\"?l=true:s?c===u&&(s=false,u=null):c==='"'||c==="'"||c==="`"?(s=true,u=c):c==="["?o++:c==="]"&&o--,i++;}if(o!==0)return null}else break}for(;i<t.length&&pr(t[i]);)n+=t[i++];if(i<t.length&&t[i]==="/")for(n+=t[i++];i<t.length&&pr(t[i]);)n+=t[i++];if(i>=t.length||t[i]!==">")return null;n+=t[i++];}return n||null}function Ra(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 i=t[e+2];return pr(i)||i==="*"||!pe(i)}function Pa(t,e){if(e>=t.length)return null;let r=t[e];if(!Ta(r)||r==="'"&&Ra(t,e))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!n)return null;let a=e+1,o=r,s=false;for(;a<t.length;){let u=t[a];if(o+=u,s)s=false;else if(u==="\\")s=true;else if(u===n)return o;a++;}return o}function La(t,e){if(e>=t.length)return false;let r=t[e],i=t[e+1]||"",n=t[e+2]||"";if(r==="/"&&i!=="/"&&/[a-zA-Z0-9._-]/.test(i)||r==="/"&&i==="/"&&/[a-zA-Z]/.test(n)||r==="."&&(i==="/"||i==="."&&n==="/"))return true;let a=t.slice(e,e+8).toLowerCase();return !!(a.startsWith("http://")||a.startsWith("https://"))}function Na(t,e){if(!La(t,e))return null;let r=e,i="",n=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<t.length;){let a=t[r];if(a==="#"){if(i.length>0&&/[a-zA-Z0-9/.]$/.test(i))for(i+=a,r++;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)i+=t[r++];break}if(n.test(a))i+=a,r++;else break}return i.length<2?null:i}function _a(t,e){if(e>=t.length)return null;let r=t[e];if(!We(r)&&r!=="-"&&r!=="+")return null;let i=e,n="";if((t[i]==="-"||t[i]==="+")&&(n+=t[i++]),i>=t.length||!We(t[i]))return null;for(;i<t.length&&We(t[i]);)n+=t[i++];if(i<t.length&&t[i]===".")for(n+=t[i++];i<t.length&&We(t[i]);)n+=t[i++];return i<t.length&&(t.slice(i,i+2)==="ms"?n+="ms":(t[i]==="s"||t[i]==="m"||t[i]==="h")&&(n+=t[i])),n}var Ma=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Ma);var Ia=new Set(["patient","destination","source","style","event","eventMarker","agent","goal","manner","into","from","to","with","at","of","as","by","in","on","over","under","between","through","without"]);function $a(t){return t.includes("-")&&/^[\p{L}\p{N}_]+(-[\p{L}\p{N}_]+)+$/u.test(t)}var ja=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],Lr=class Rr{constructor(){this.profileKeywords=[],this.multiWordKeywords=[],this.profileKeywordMap=new Map,this.rawExtraEntries=[],this.extractors=[];}getExtraKeywordEntries(){return this.rawExtraEntries}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){xa(e)&&e.setContext(Da(this)),this.extractors.push(e);}registerExtractors(e){for(let r of e)this.registerExtractor(r);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let r=[],i=0;for(;i<e.length;){for(;i<e.length&&pr(e[i]);)i++;if(i>=e.length)break;let n=this.tryMultiWordKeyword(e,i);if(n){r.push(n),i=n.position.end;continue}let a=false;for(let o of this.extractors)if(o.canExtract(e,i)){let s=o.extract(e,i);if(s){let u=s.metadata?.normalized,l=s.metadata?.stem,c=s.metadata?.stemConfidence,d={};if(s.metadata)for(let[p,f]of Object.entries(s.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(d[p]=f);let m={};u&&(m.normalized=u),l&&(m.stem=l),c!==void 0&&(m.stemConfidence=c),Object.keys(d).length>0&&(m.metadata=d),r.push(re(s.value,this.classifyToken(s.value),ee(i,i+s.length),Object.keys(m).length>0?m:void 0)),i+=s.length,a=true;break}}if(!a){let o=e[i],s=this.classifyUnknownChar(o);r.push(re(o,s,ee(i,i+1))),i++;}}return new oe(this.mergeColonQualifiedNames(r),this.language)}mergeColonQualifiedNames(e){let r=[];for(let i of e){let n=r[r.length-1];if(n&&Rr.ASCII_WORD.test(n.value)&&Rr.COLON_QUALIFIER.test(i.value)&&n.position.end===i.position.start){let a=n.value+i.value;r[r.length-1]=re(a,this.classifyToken(a),ee(n.position.start,i.position.end));continue}r.push(i);}return r}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,i){if(e[r]!==".")return false;let n=i[i.length-1],a=n&&n.position.end<r;if(n&&!a&&(n.kind==="identifier"||n.kind==="keyword"||n.kind==="selector"))return i.push(re(".","operator",ee(r,r+1))),true;let u=r+1;for(;u<e.length&&pe(e[u]);)u++;return u<e.length&&e[u]==="("?(i.push(re(".","operator",ee(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let i=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[n,a]of Object.entries(e.keywords))if(i.set(a.primary,{native:a.primary,normalized:a.normalized||n}),a.alternatives)for(let o of a.alternatives)i.set(o,{native:o,normalized:a.normalized||n});}if(e.references){for(let[n,a]of Object.entries(e.references))i.set(a,{native:a,normalized:n});for(let n of Object.keys(e.references))i.has(n)||i.set(n,{native:n,normalized:n});}if(e.roleMarkers){for(let[n,a]of Object.entries(e.roleMarkers))if(a.primary&&i.set(a.primary,{native:a.primary,normalized:n}),a.alternatives)for(let o of a.alternatives)i.set(o,{native:o,normalized:n});}if(e.possessive?.keywords)for(let[n,a]of Object.entries(e.possessive.keywords))i.set(n,{native:n,normalized:a});for(let n of ja)i.has(n)||i.set(n,{native:n,normalized:n});for(let n of r)i.set(n.native,n);this.profileKeywords=Array.from(i.values()).sort((n,a)=>a.native.length-n.native.length),this.multiWordKeywords=this.profileKeywords.filter(n=>(n.native.includes(" ")||$a(n.native))&&!Ia.has(n.normalized)),this.profileKeywordMap=new Map;for(let n of this.profileKeywords){this.profileKeywordMap.set(n.native.toLowerCase(),n);let a=this.removeDiacritics(n.native);a!==n.native&&!this.profileKeywordMap.has(a.toLowerCase())&&this.profileKeywordMap.set(a.toLowerCase(),n);}}removeDiacritics(e){return Pr(e)}tryProfileKeyword(e,r){for(let i of this.profileKeywords)if(e.slice(r).startsWith(i.native))return re(i.native,"keyword",ee(r,r+i.native.length),i.normalized);return null}tryMultiWordKeyword(e,r,i=n=>/[\p{L}\p{N}_]/u.test(n)){if(this.multiWordKeywords.length===0)return null;let n=e.slice(r);for(let a of this.multiWordKeywords){if(!n.startsWith(a.native))continue;let o=e[r+a.native.length];if(!(o!==void 0&&i(o)))return re(a.native,"keyword",ee(r,r+a.native.length),a.normalized)}return null}isKeywordStart(e,r){let i=e.slice(r);return this.profileKeywords.some(n=>i.startsWith(n.native))}isKeywordStartAtBoundary(e,r,i=n=>/[\p{L}\p{N}_]/u.test(n)){let n=e.slice(r);return this.profileKeywords.some(a=>{if(!n.startsWith(a.native))return false;let o=e[r+a.native.length];return o===void 0||!i(o)})}lookupKeyword(e){let r=this.profileKeywordMap.get(e.toLowerCase());if(r)return r;let i=this.removeDiacritics(e);if(i!==e)return this.profileKeywordMap.get(i.toLowerCase())}isKeyword(e){return this.lookupKeyword(e)!==void 0}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,i){let n=this.tryNormalize(e);if(!n)return null;let a=this.lookupKeyword(n.stem);if(!a)return null;let o={normalized:a.normalized,stem:n.stem,stemConfidence:n.confidence};return re(e,"keyword",ee(r,i),o)}trySelector(e,r){let i=Oa(e,r);return i?re(i,"selector",ee(r,r+i.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let i=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!i)return null;let n=i[0].replace(/(\s|\.)$/,""),a=n.slice(1).split("(")[0],o=i[1];return {...re(n,"event-modifier",ee(r,r+n.length)),metadata:{modifierName:a,value:o?a==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let i=Pa(e,r);return i?re(i,"literal",ee(r,r+i.length)):null}tryNumber(e,r){let i=_a(e,r);return i?re(i,"literal",ee(r,r+i.length)):null}tryMatchTimeUnit(e,r,i,n=false){let a=r;if(n)for(;a<e.length&&pr(e[a]);)a++;let o=e.slice(a);for(let s of i){let u=o.slice(0,s.length);if(s.caseInsensitive?u.toLowerCase()===s.pattern.toLowerCase():u===s.pattern){if(s.notFollowedBy&&(o[s.length]||"")===s.notFollowedBy)continue;if(s.checkBoundary){let c=o[s.length]||"";if(pe(c))continue}return {suffix:s.suffix,endPos:a+s.length}}}return null}parseBaseNumber(e,r,i=true){let n=r,a="";if(i&&(e[n]==="-"||e[n]==="+")&&(a+=e[n++]),n>=e.length||!We(e[n]))return null;for(;n<e.length&&We(e[n]);)a+=e[n++];if(n<e.length&&e[n]===".")for(a+=e[n++];n<e.length&&We(e[n]);)a+=e[n++];return !a||a==="-"||a==="+"?null:{number:a,endPos:n}}tryNumberWithTimeUnits(e,r,i,n={}){let{allowSign:a=true,skipWhitespace:o=false}=n,s=this.parseBaseNumber(e,r,a);if(!s)return null;let{number:u,endPos:l}=s,c=[...i,...Rr.STANDARD_TIME_UNITS],d=this.tryMatchTimeUnit(e,l,c,o);return d&&(u+=d.suffix,l=d.endPos),re(u,"literal",ee(r,l))}tryUrl(e,r){let i=Na(e,r);return i?re(i,"url",ee(r,r+i.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!pe(e[r+1]))return null;let i=r+1;for(;i<e.length&&pe(e[i]);)i++;let n=e.slice(r,i);return re(n,"identifier",ee(r,i))}tryOperator(e,r){let i=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(i))return re(i,"operator",ee(r,r+2));let n=e[r];return ["<",">","!","+","-","*","/","="].includes(n)?re(n,"operator",ee(r,r+1)):["(",")","{","}",",",";",":"].includes(n)?re(n,"punctuation",ee(r,r+1)):null}tryMultiCharParticle(e,r,i){for(let n of i)if(e.slice(r,r+n.length)===n)return re(n,"particle",ee(r,r+n.length));return null}};Lr.ASCII_WORD=/^[A-Za-z_][A-Za-z0-9_]*$/;Lr.COLON_QUALIFIER=/^:[A-Za-z_][A-Za-z0-9_]*$/;Lr.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 xe=Lr;function Yt(t){return {stem:t,confidence:1}}function Xt(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}var Va=Object.defineProperty,Wa=Object.getOwnPropertyNames,_i=(t,e)=>function(){return t&&(e=(0, t[Wa(t)[0]])(t=0)),e},qa=(t,e)=>{for(var r in e)Va(t,r,{get:e[r],enumerable:true});};function Jt(t,e){return t.replace(/\{(\w+)\}/g,(r,i)=>String(e[i]??`{${i}}`))}function ve(t,e,r={},i){let n=Mi[t],a=Jt(n,r),o=Ii[t],s=o?Jt(o,r):void 0;return {code:t,message:a,severity:e,...i&&{role:i},...s&&{suggestion:s}}}var P,Mi,Ii,Ka=_i({"src/generators/schema-error-codes.ts"(){P={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"},Mi={[P.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[P.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[P.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[P.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[P.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[P.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.",[P.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.",[P.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[P.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[P.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[P.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[P.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[P.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[P.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[P.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[P.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[P.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Ii={[P.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[P.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[P.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[P.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[P.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[P.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[P.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[P.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[P.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[P.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[P.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[P.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[P.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[P.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),$i={};qa($i,{SchemaErrorCodes:()=>P,formatValidationResults:()=>Ja,getValidationStats:()=>Qa,validateAllKeywordCollisions:()=>to,validateAllSchemas:()=>Xa,validateCommandSchema:()=>ji,validateKeywordCollisions:()=>Vi,validateRoleValues:()=>eo});function Ha(t,e){return {action:t,items:e}}function ji(t){let e=[];for(let i of t.roles)i.expectedTypes.includes("literal")&&i.expectedTypes.includes("selector")&&(i.role==="patient"&&dt.has(t.action)?e.push(ve(P.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:i.role,command:t.action},i.role)):e.push(ve(P.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:i.role},i.role))),i.expectedTypes.length>3&&!dt.has(t.action)&&e.push(ve(P.TOO_MANY_EXPECTED_TYPES,"warning",{role:i.role,count:i.expectedTypes.length},i.role));for(let i of t.roles)i.selectorKinds&&i.selectorKinds.length>0&&(i.expectedTypes.includes("selector")||e.push(ve(P.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:i.role},i.role)));switch(t.action){case "transition":Ua(t,e);break;case "on":Ga(t,e);break;case "if":case "unless":Za(t,e);break;case "repeat":case "for":case "while":Ya(t,e);break}return t.roles.filter(i=>i.required).length===0&&(Wi.has(t.action)?e.push(ve(P.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(ve(P.NO_REQUIRED_ROLES,"warning",{}))),Ha(t.action,e)}function Ua(t,e){let r=t.roles.find(n=>n.role==="patient"),i=t.roles.find(n=>n.role==="goal");r&&!i&&e.push(ve(P.TRANSITION_MISSING_GOAL,"error",{}));}function Ga(t,e){let r=t.roles.find(i=>i.role==="event");r||e.push(ve(P.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(ve(P.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Za(t,e){let r=t.roles.find(i=>i.role==="condition");r||e.push(ve(P.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(ve(P.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Ya(t,e){t.action==="for"?t.roles.find(i=>i.role==="source")||e.push(ve(P.FOR_LOOP_MISSING_SOURCE,"warning",{})):t.action==="while"&&(t.roles.find(i=>i.role==="condition")||e.push(ve(P.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Xa(t,e={}){let r=new Map,{includeNotes:i=false}=e;for(let[n,a]of Object.entries(t)){let o=ji(a),s=o.items.some(l=>l.severity==="warning"||l.severity==="error"),u=i&&o.items.some(l=>l.severity==="note");(s||u)&&r.set(n,o);}return r}function Ja(t,e={}){let r=[],{showNotes:i=false,showCodes:n=true}=e;for(let[a,o]of t){let s=o.items.filter(c=>c.severity==="error"),u=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(s.length>0){r.push(` \u274C ${a}:`);for(let c of s){let d=n?` [${c.code}]`:"";r.push(` ERROR${d}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(u.length>0){r.push(` \u26A0\uFE0F ${a}:`);for(let c of u){let d=n?` [${c.code}]`:"";r.push(` ${d?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(i&&l.length>0){r.push(` \u2139\uFE0F ${a}:`);for(let c of l){let d=n?` [${c.code}]`:"";r.push(` ${d?`${c.code}: `:""}${c.message}`);}}}return r.join(`
|
|
2
|
-
`)}function Qa(t){let e=0,r=0,i=0,n={};for(let a of t.values())for(let o of a.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&i++,n[o.code]=(n[o.code]||0)+1;return {totalCommands:t.size,errors:e,warnings:r,notes:i,byCode:n}}function eo(t,e){let r=[];for(let i of e){let n=t.roles.find(a=>a.role===i.role);n&&(n.expectedTypes.length>0&&!n.expectedTypes.includes(i.type)&&(n.expectedTypes.includes("expression")||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects type [${n.expectedTypes.join(", ")}], got '${i.type}'`,code:P.VALUE_TYPE_MISMATCH})),i.type==="selector"&&i.selectorKind&&n.selectorKinds&&n.selectorKinds.length>0&&(n.selectorKinds.includes(i.selectorKind)||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects selector kind [${n.selectorKinds.join(", ")}], got '${i.selectorKind}'`,code:P.SELECTOR_KIND_MISMATCH})));}return r}function ro(t){if(t.length!==2)return false;let[e,r]=[...t].sort();return qi.some(([i,n])=>i===e&&n===r)}function Vi(t){let e=[];if(!t.keywords)return {language:t.code,collisions:e};let r=new Map;for(let[n,a]of Object.entries(t.keywords)){if(!a||!a.primary)continue;let o=r.get(a.primary)||[];if(o.push({command:n,isPrimary:true}),r.set(a.primary,o),a.alternatives)for(let s of a.alternatives){let u=r.get(s)||[];u.push({command:n,isPrimary:false}),r.set(s,u);}}for(let[n,a]of r){let o=[...new Set(a.map(l=>l.command))];if(o.length<=1||ro(o))continue;let s=a.filter(l=>l.isPrimary).length,u;s>=2?u="primary-primary":s===1?u="primary-alternative":u="alternative-alternative",e.push({keyword:n,commands:o.sort(),type:u});}let i={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((n,a)=>i[n.type]-i[a.type]),{language:t.code,collisions:e}}function to(t){let e=[];for(let[,r]of Object.entries(t)){let i=Vi(r);i.collisions.length>0&&e.push(i);}return e.sort((r,i)=>r.language.localeCompare(i.language))}var dt,Wi,qi,io=_i({"src/generators/schema-validator.ts"(){Ka(),dt=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Wi=new Set(["compound","else","halt","continue","init","settle","focus","blur","show","hide","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint","live","eventsource","socket","worker","intercept"]),qi=[["change","changes"]];}});var zt=["is not really equal to","is really equal to","is greater than or equal to","is less than or equal to","is not equal to","is equal to","is greater than","is less than","is not really","is really","is not equal","is equal","is not in","is in","is not","is","am not in","am in","am","does not match","do not match","does not contain","does not contains","do not contain","does not include","does not precede","does not follow","precedes","follows","really equals","equals","matches","match","contains","contain","includes","include","has","have","in"],wt=["is not empty","is empty","does not exist"],kt=["is not an","is not a","is an","is a"],no=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),ao=new Set(["and","or","not","no"]),oo=new Set(["true","false","null","undefined"]),so=new Set(zt.map(t=>t.slice(t.lastIndexOf(" ")+1))),uo=new Set(["next","previous","closest","first","last"]),lo=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function Ki(t){let e=[],r=0,i=1,n=1;function a(){if(e.length===0)return true;let f=e[e.length-1];return f.type==="IDENTIFIER"&&so.has(f.value.toLowerCase())||f.type==="IDENTIFIER"&&uo.has(f.value.toLowerCase())||f.type==="IDENTIFIER"&&f.value.toLowerCase()==="of"?true:["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(f.type)}function o(f=0){return t[r+f]??""}function s(){let f=t[r];return r++,f===`
|
|
3
|
-
`?(i++,n=1):n++,f}function u(){for(;r<t.length&&/\s/.test(t[r]);)s();}function l(f){let h="";for(;r<t.length&&f(t[r]);)h+=s();return h}function c(f){let h=f;for(s();r<t.length&&t[r]!==f;)t[r]==="\\"&&r+1<t.length&&(h+=s()),h+=s();return r<t.length&&(h+=s()),h}function d(){let f="`";for(s();r<t.length&&t[r]!=="`";)t[r]==="\\"&&r+1<t.length&&(f+=s()),f+=s();return r<t.length&&(f+=s()),f}function m(){let f="<";for(s();r<t.length&&(f+=s(),!f.endsWith("/>")););return f}function p(f,h,v){return {type:f,value:h,start:v,end:r,line:i,column:n-h.length}}for(;r<t.length&&(u(),!(r>=t.length));){let f=r,h=o();if(h==="'"&&o(1)==="s"&&!/\w/.test(o(2))){s(),s(),e.push(p("POSSESSIVE","'s",f));continue}if(h==='"'||h==="'"){let v=c(h);e.push(p("STRING",v,f));continue}if(h==="`"){let v=d();e.push(p("TEMPLATE_LITERAL",v,f));continue}if(h==="<"&&/[a-zA-Z.#\[]/.test(o(1))){let v=m();e.push(p("QUERY_SELECTOR",v,f));continue}if(h==="#"&&a()){s();let v=l(y=>/[\w-]/.test(y));e.push(p("ID_SELECTOR","#"+v,f));continue}if(h==="."&&/[a-zA-Z_-]/.test(o(1))&&a()){s();let v=l(y=>/[\w-]/.test(y));e.push(p("CLASS_SELECTOR","."+v,f));continue}if(h==="@"&&/[a-zA-Z_]/.test(o(1))){s();let v=l(y=>/[\w-]/.test(y));e.push(p("ATTRIBUTE_REF","@"+v,f));continue}if(h==="["&&a()&&o(1)==="@"){let y="";for(y+=s();r<t.length&&t[r]!=="]";)t[r]==='"'||t[r]==="'"?y+=c(t[r]):y+=s();r<t.length&&(y+=s()),e.push(p("ATTRIBUTE_SELECTOR",y,f));continue}if(h==="["){s(),e.push(p("LBRACKET","[",f));continue}if(h==="]"){s(),e.push(p("RBRACKET","]",f));continue}if(/\d/.test(h)){let v=l(z=>/[\d.]/.test(z)),y=r,E=l(z=>/[a-zA-Z]/.test(z));lo.has(E)?e.push(p("TIME_EXPRESSION",v+E,f)):(r=y,e.push(p("NUMBER",v,f)));continue}if(h==="("){s(),e.push(p("LPAREN","(",f));continue}if(h===")"){s(),e.push(p("RPAREN",")",f));continue}if(h==="{"){s(),e.push(p("LBRACE","{",f));continue}if(h==="}"){s(),e.push(p("RBRACE","}",f));continue}if(h===","){s(),e.push(p("COMMA",",",f));continue}if(h===":"){s(),e.push(p("COLON",":",f));continue}if(h==="."){s(),e.push(p("DOT",".",f));continue}if(h==="|"){s(),e.push(p("PIPE","|",f));continue}if(h==="+"||h==="-"||h==="*"||h==="/"||h==="%"){s(),e.push(p("OPERATOR",h,f));continue}if(h==="="||h==="!"||h==="<"||h===">"){let v=s();o()==="="&&(v+=s()),(v==="=="||v==="!=")&&o()==="="&&(v+=s()),e.push(p("COMPARISON",v,f));continue}if(/[a-zA-Z_$]/.test(h)){let v=l(E=>/[\w$]/.test(E)),y=v.toLowerCase();no.has(y)?e.push(p("CONTEXT_VAR",v,f)):ao.has(y)?e.push(p("LOGICAL",v,f)):oo.has(y)?e.push(p("BOOLEAN",v,f)):e.push(p("IDENTIFIER",v,f));continue}s();}return e.push(p("EOF","",r)),e}var co=new Set(["my","its","your"]),mo={my:"me",its:"it",your:"you"},po=new Set(["is","matches","match","contains","in","exists","does"]),fo=new Set(["next","previous","closest","first","last"]),ho=[...wt,...kt,...zt].map(t=>[t,t.split(" ")]),yo=class{constructor(){this.tokens=[],this.current=0;}parse(t){try{return this.tokens=Ki(t),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(e){return {success:false,error:e instanceof Error?e.message:"Parse error"}}}peek(){return this.tokens[this.current]??{type:"EOF",value:"",start:0,end:0}}peekAt(t){return this.tokens[this.current+t]??{type:"EOF",value:"",start:0,end:0}}previous(){return this.tokens[this.current-1]??{type:"EOF",value:"",start:0,end:0}}isAtEnd(){return this.peek().type==="EOF"}advance(){return this.isAtEnd()||this.current++,this.previous()}check(t){return this.peek().type===t}checkValue(t){return this.peek().value.toLowerCase()===t.toLowerCase()}match(...t){for(let e of t)if(this.check(e))return this.advance(),true;return false}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.checkValue("or");){let e=this.advance().value,r=this.parseAnd();t=this.createBinaryExpression(e,t,r);}return t}parseAnd(){let t=this.parseEquality();for(;this.checkValue("and");){let e=this.advance().value,r=this.parseEquality();t=this.createBinaryExpression(e,t,r);}return t}parseEquality(){let t=this.parseComparison();for(;;){if(this.match("COMPARISON")){let r=this.previous().value;t=this.createBinaryExpression(r,t,this.parseComparison());continue}let e=this.matchComparisonPhrase();if(e===void 0)break;if(wt.includes(e))t=this.createPostfixUnary(e,t);else if(kt.includes(e))t=this.parseTypeCheck(t,e.startsWith("is not"));else {let r=e==="match"?"matches":e;t=this.createBinaryExpression(r,t,this.parseComparison());}}return t}matchComparisonPhrase(){for(let[t,e]of ho)if(e.every((r,i)=>this.peekAt(i).value.toLowerCase()===r)){for(let r=0;r<e.length;r++)this.advance();return t}}parseTypeCheck(t,e){let r=this.advance();if(r.type==="EOF")throw new Error(`Expected a type name after 'is ${e?"not ":""}a'`);let i=true;return this.peek().value==="!"&&(this.advance(),i=false),{type:"typeCheckExpression",value:t,typeName:r.value,nullOk:i,negated:e,start:t.start,end:this.previous().end}}parseComparison(){let t=this.parseAddition();for(;this.check("COMPARISON");){let e=this.advance().value,r=this.parseAddition();t=this.createBinaryExpression(e,t,r);}return t}parseAddition(){let t=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let e=this.advance().value,r=this.parseMultiplication();t=this.createBinaryExpression(e,t,r);}return t}parseMultiplication(){let t=this.parseConversion();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%"||this.checkValue("mod");){let e=this.advance().value.toLowerCase(),r=this.parseConversion();t=this.createBinaryExpression(e,t,r);}return t}parseConversion(){let t=this.parseUnary();for(;this.checkValue("as")&&this.conversionTypeAt(1)!==void 0;)for(this.advance(),t=this.createAsExpression(t,this.parseConversionType());this.check("PIPE")&&this.conversionTypeAt(1)!==void 0;)this.advance(),t=this.createAsExpression(t,this.parseConversionType());return t}conversionTypeAt(t){let e=this.peekAt(t).value.toLowerCase(),r=e==="a"||e==="an"?t+1:t;return this.peekAt(r).type==="IDENTIFIER"?r:void 0}parseConversionType(){let t=this.conversionTypeAt(0)??0;for(let n=0;n<t;n++)this.advance();let e=this.advance(),r=this.peekAt(1).type;if(!this.check("COLON")||r!=="NUMBER"&&r!=="IDENTIFIER")return e;this.advance();let i=this.advance();return {...e,value:`${e.value}:${i.value}`,end:i.end}}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let t=this.advance().value,e=this.parseUnary();return this.createUnaryExpression(t,e)}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance();t=this.createMemberExpression(t,this.createIdentifier(e.value,e),false);}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance();t=this.createPossessiveExpression(t,this.createIdentifier(e.value,e));}else break;else if(this.match("LPAREN")){let e=this.parseArguments();t=this.createCallExpression(t,e);}else if(this.match("LBRACKET")){let e=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");t=this.createMemberExpression(t,e,true);}else if(t.type==="identifier"&&co.has(t.name)&&this.check("IDENTIFIER")&&!po.has(this.peek().value.toLowerCase())){let e=this.advance(),r=t,i={...r,name:mo[r.name]??r.name};t=this.createMemberExpression(i,this.createIdentifier(e.value,e),false);}else if(this.checkValue("exists")&&this.peekAt(1).type!=="LPAREN")this.advance(),t=this.createPostfixUnary("exists",t);else break;return t}parsePrimary(){let t=this.peek();if(this.checkValue("the")&&(this.peekAt(1).type==="IDENTIFIER"||this.peekAt(1).type==="CONTEXT_VAR")&&this.peekAt(2).value.toLowerCase()==="of")return this.advance(),this.parsePropertyOf(this.advance(),t,false);if(this.match("NUMBER"))return this.createLiteral(parseFloat(t.value),"number",t);if(this.match("STRING")){let e=t.value.slice(1,-1);return this.createLiteral(e,"string",t)}if(this.match("BOOLEAN")){let e=t.value==="true"?true:t.value==="false"?false:t.value==="null"?null:void 0,r={true:"boolean",false:"boolean",null:"null",undefined:"undefined"};return this.createLiteral(e,r[t.value]??"string",t)}if(this.match("TEMPLATE_LITERAL")){let e=t.value;return {type:"templateLiteral",value:e.length>=2&&e.startsWith("`")&&e.endsWith("`")?e.slice(1,-1):e,start:t.start,end:t.end,line:t.line,column:t.column}}if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(t);if(this.match("ID_SELECTOR"))return this.createSelector(t.value,"id",t);if(this.match("CLASS_SELECTOR"))return this.createSelector(t.value,"class",t);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(t.value,"attribute",t);if(this.match("ATTRIBUTE_REF")){let e={type:"attributeAccess",attributeName:t.value.slice(1),start:t.start,end:t.end};return this.checkValue("of")?(this.advance(),this.createBinaryExpression("of",e,this.parseConversion())):e}if(this.match("QUERY_SELECTOR")){let e=t.value.slice(1,-2);return this.createSelector(e,"query",t)}if(this.match("CONTEXT_VAR"))return this.createIdentifier(t.value,t);if(this.match("IDENTIFIER")){if(fo.has(t.value.toLowerCase())&&(this.check("CLASS_SELECTOR")||this.check("ID_SELECTOR")||this.check("QUERY_SELECTOR"))){let e=this.advance(),r=e.type==="QUERY_SELECTOR"?e.value.slice(1,-2):e.value,i=e.type==="CLASS_SELECTOR"?"class":e.type==="ID_SELECTOR"?"id":"query";return {type:"callExpression",callee:this.createIdentifier(t.value,t),arguments:[this.createSelector(r,i,e)],start:t.start,end:e.end}}return this.checkValue("of")?this.parsePropertyOf(t,t):this.createIdentifier(t.value,t)}if(this.match("LPAREN")){let e=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return e}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${t.value}`)}parsePropertyOf(t,e,r=true){this.advance();let i=r?this.parseConversion():this.parseUnary();return {type:"propertyOfExpression",property:this.createIdentifier(t.value,t),target:i,start:e.start,end:this.previous().end}}parseArguments(){let t=[];if(!this.check("RPAREN"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return t}parseArrayLiteral(){let t=[],e=this.previous().start;if(!this.check("RBRACKET"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return {type:"arrayLiteral",elements:t,start:e,end:this.previous().end}}parseObjectLiteral(){let t=[],e=this.previous().start;if(!this.check("RBRACE"))do{let r;if(this.check("STRING"))r=this.advance().value.slice(1,-1);else if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR"))r=this.advance().value;else throw new Error("Expected property name");if(!this.match("COLON"))throw new Error("Expected : after property name");let i=this.parseExpression();t.push({key:r,value:i});}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return {type:"objectLiteral",properties:t.map(r=>({type:"objectProperty",key:{type:"identifier",name:r.key},value:r.value})),start:e,end:this.previous().end}}parseTimeExpression(t){let e=t.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!e)throw new Error(`Invalid time expression: ${t.value}`);let r=parseFloat(e[1]),i=e[2].toLowerCase();return {type:"timeExpression",value:r,unit:i,raw:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createLiteral(t,e,r){return {type:"literal",value:t,dataType:e,raw:r.value,start:r.start,end:r.end,line:r.line,column:r.column}}createSelector(t,e,r){return {type:"selector",value:t,selector:t,selectorType:e,start:r.start,end:r.end,line:r.line,column:r.column}}createIdentifier(t,e){return {type:"identifier",name:t,start:e.start,end:e.end,line:e.line,column:e.column}}createMemberExpression(t,e,r){return {type:"memberExpression",object:t,property:e,computed:r,start:t.start,end:this.previous().end}}createPossessiveExpression(t,e){return {type:"possessiveExpression",object:t,property:e,start:t.start,end:this.previous().end}}createBinaryExpression(t,e,r){return {type:"binaryExpression",operator:t,left:e,right:r,start:e.start,end:r.end}}createAsExpression(t,e){return {type:"asExpression",expression:t,targetType:this.createIdentifier(e.value,e),start:t.start,end:e.end}}createUnaryExpression(t,e){return {type:"unaryExpression",operator:t,operand:e,prefix:true,start:this.previous().start,end:e.end}}createPostfixUnary(t,e){return {type:"unaryExpression",operator:t,operand:e,prefix:false,start:e.start,end:this.previous().end}}createCallExpression(t,e){return {type:"callExpression",callee:t,arguments:e,start:t.start,end:this.previous().end}}};function vo(t){return new yo().parse(t)}function Ue(t){let e=t.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function Ge(t){let e=t.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function Ze(t,e){return Ct(t,e,"source")}function bt(t,e){return Ct(t,e,"destination")}function Eo(t,e){return Ct(t,e,"patient")}function Ct(t,e,r){if(!e||!t.roles.some(a=>a.role===r))return [];let i=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},n={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[n,i]:[i,n]}]}var te=["selector","reference","expression"],go={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination",for:"duration"}},argSkipTokens:["on"],roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2,markerOptional:{zh:true}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}},{role:"duration",description:"How long the class stays on before reverting (`toggle .a for 2s`)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3,valueShape:"time",markerOverride:{en:"for",ja:"\u9593",ko:"\uB3D9\uC548"}}],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)"}},zo={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector","literal"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",es:"a",ar:"\u0625\u0644\u0649",zh:"\u5230",fr:"\xE0",de:"zu",pt:"a",he:"\u05D0\u05DC",id:"ke",it:"a",sw:"kwa"},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","dans"],de:["auf","in"],pt:["em","para"],he:["\u05E2\u05DC","\u05D1","\u05DC"],id:["pada","di"],it:["in","su"],sw:["kwenye"]}}],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"}},wo={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source"}},targetRole:"source",argSkipTokens:["from"],roles:[{role:"patient",description:"The class/attribute to remove, or the element to remove",required:true,expectedTypes:te,svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],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"}},At={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","property-path"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"into",ar:"\u0641\u064A",zh:"\u5230",fr:"dans",de:"in",he:"\u05D1",id:"ke",sw:"kwa"},markerVariants:{en:["before","after"]},markerLegacy:{ar:["\u0639\u0644\u0649","\u0625\u0644\u0649","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","\xE0"],de:["auf","zu"],he:["\u05E2\u05DC","\u05D0\u05DC","\u05DC"],id:["pada","di"],sw:["kwenye"]},methodCarrier:"method"}],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"}},ko={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient",on:"scope"}},argSkipTokens:["to"],roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",th:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B",zh:"\u628A"},markerOptional:{zh:true}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","selector","expression","reference","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",th:"\u0E43\u0E19",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902",zh:"\u5230"},markerVariants:{tr:["e","a","ye","ya"],zh:["\u4E3A","\u70BA","\u6210"]}},{role:"scope",description:"The element(s) the attribute/property is set on (defaults to me)",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3,markerOverride:{en:"on",es:"on",pt:"on",fr:"on",de:"on",it:"on",id:"on",ms:"on",sw:"on",tl:"on",zh:"on",vi:"on",ru:"on",uk:"on",pl:"on",th:"on",he:"on",ar:"on",ja:"on",ko:"on",tr:"on",hi:"on",bn:"on",qu:"on"}}],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>"}},bo={action:"bind",description:"Reactively bind a variable to an element or property value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to bind",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",it:"",id:"",ms:"",vi:"",ru:"",uk:"",pl:"",th:"",zh:"",he:"",ar:"",sw:"",tl:"",ja:"\u3092",ko:"\uB97C",tr:"i",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"source",description:"The element or property to bind to",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"zu",it:"in",id:"ke",ms:"ke",vi:"v\xE0o",ru:"\u0432",uk:"\u0432",pl:"do",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",zh:"\u5230",he:"\u05DC",sw:"kwa",th:"\u0E43\u0E19",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"}}],errorCodes:["MISSING_TARGET","MISSING_VALUE","INVALID_SYNTAX"],recoveryHints:{MISSING_TARGET:"Add a variable to bind: bind $name to #input",MISSING_VALUE:'Add "to <element>" to specify the binding source',INVALID_SYNTAX:"Use syntax: bind <variable> to <element>"}},Co={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ao={action:"when",description:"Reactive observer: re-run the body when a watched expression changes",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,structuralOnly:true,roles:[{role:"condition",description:"The watched expression (`or`-separated expressions watch each)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1}]},So={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},xo={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Do={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Bo={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},To={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:["style","duration"]}},roles:[{role:"patient",description:"The element to show",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"The hide/show strategy (`with opacity`, `with *opacity`)",required:false,expectedTypes:["expression","selector"],svoPosition:2,sovPosition:2}]},Fo={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:["style","duration"]}},roles:[{role:"patient",description:"The element to hide",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"The hide/show strategy (`with opacity`, `with *opacity`)",required:false,expectedTypes:["expression","selector"],svoPosition:2,sovPosition:2}]},Oo={action:"on",description:"Handle an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{from:"source"}},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","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],widenTypeVariants:[{role:"event",types:["literal","expression"],idSuffix:"expr-event",excludeLanguages:["ko"]}]},Ro={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{on:"destination"}},argSkipTokens:["on"],roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2,markerVariants:{hi:["\u0915\u094B"],qu:["ta"],bn:["\u0995\u09C7"]},markerOverride:{bn:"\u0995\u09C7",hi:"\u0915\u094B"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Po={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Lo={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",ast:{args:["source"],modifiers:{with:["style","method"],as:"responseType",body:"patient"},isBlocking:true},roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"style",description:"Request options object (method, headers, body, credentials\u2026)",required:false,expectedTypes:["expression"],valueShape:"object",svoPosition:2,sovPosition:2},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:3,sovPosition:3,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:5,sovPosition:5}]},No={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal","selector","expression","reference","property-path"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},_o={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal","selector","expression","reference","property-path"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},Mo={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Io={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},$o={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:1}]},jo={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",ast:{args:[["source","patient"]]},roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",he:"\u05D0\u05EA",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},Vo={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source",for:"recipient"}},argSkipTokens:["from"],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 all current holders)",required:false,expectedTypes:te,svoPosition:2,sovPosition:1},{role:"recipient",description:"The element the class moves ONTO (`take .active from .tab for me`)",required:false,expectedTypes:["reference"],svoPosition:3,sovPosition:3,valueShape:"reference",markerOverride:{en:"for"}}]},Wo={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},qo={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",ast:{args:[],modifiers:{the:"patient"}},argSkipTokens:["the"],roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Ko={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",ast:{args:[["destination","patient"]],isBlocking:true},roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ho={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression","property-path"],svoPosition:1,sovPosition:1}]},Uo={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{to:"destination",detail:"patient"}},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","expression"],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"}}]},Go={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Zo={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Yo={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Xo={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",ast:{args:[["quantity","patient"]]},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"'},Jo={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{in:"source"}},hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference","expression"],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",es:"en",fr:"en",de:"in",it:"in",pt:"dentro",id:"dalam",ms:"dalam",pl:"w",ru:"\u0432",uk:"\u0443",sw:"ndani",th:"\u0E43\u0E19",vi:"trong",ar:"\u0641\u064A",tl:"sa_loob",he:"in",zh:"\u5728"}}]},Qo={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},es={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",ast:{},roles:[]},Hr={en:"url",es:"url",pt:"url",fr:"url",de:"url",it:"url",ja:"url",ko:"url",zh:"url",ar:"url",he:"url",hi:"url",bn:"url",tr:"url",ru:"url",uk:"url",pl:"url",id:"url",vi:"url",th:"url",ms:"url",tl:"url",sw:"url",qu:"url"},rs=Object.fromEntries(Object.keys(Hr).map(t=>[t,"in new"])),ts={action:"go",description:"Navigate to a URL, or scroll to an element",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to, or the element to scroll to",required:true,expectedTypes:["literal",...te],svoPosition:1,sovPosition:1,markerOverride:{en:"to",es:"a",ar:"\u0625\u0644\u0649",fr:"\xE0",de:"zu",pt:"para",he:"\u05D0\u05DC",hi:"\u092A\u0930",id:"ke",it:"a",ru:"\u043D\u0430",sw:"kwa",uk:"\u043D\u0430"},renderOverride:{en:"",zh:"",vi:"",th:""},markerOptional:{en:true,zh:true,vi:true,th:true},markerVariants:{zh:["\u628A"]},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],fr:["sur","dans"],de:["auf","in"],pt:["em","a"],he:["\u05E2\u05DC","\u05D1","\u05DC","\u05D0\u05EA"],hi:["\u092E\u0947\u0902"],id:["pada","di"],it:["in","su"],ru:["\u0432","\u043A"],sw:["kwenye"],uk:["\u0432","\u0434\u043E"]}},{role:"manner",description:"Open the URL in a new window (`in new window`)",required:false,expectedTypes:["reference","literal","expression"],valueShape:"keyword",svoPosition:2,sovPosition:2,markerOverride:rs}],rolePrefixLiteralVariants:[{role:"destination",literal:Hr,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},is={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"goal",over:"duration",on:"destination"}},omitRoleVariants:["goal"],roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal","expression","selector"],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:"kwa",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"zu",he:"\u05E2\u05DC",it:"in",ja:"\u306B",ko:"\uC5D0",ms:"ke",pl:"do",ru:"\u0432",th:"\u0E43\u0E19",tr:"e",uk:"\u0432",vi:"v\xE0o",zh:"\u5230",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}]},ns={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",ast:{args:[["source","patient"]],modifiers:{into:"destination"}},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"}}]},as={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","patient"]]},roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},os={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","patient"]]},roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ss={action:"empty",description:"Remove all children from an element (sets innerHTML to empty)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to empty (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},us={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{as:"style"}},roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}}]},ls={action:"close",description:"Close a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to close (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},cs={action:"select",description:"Select the contents of a text field or DOM element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element whose contents to select (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ds={action:"clear",description:"Clear a variable, local, or input element",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The variable or element to clear (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ms={action:"reset",description:"Reset a <form> element to its default values",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The form element to reset (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ps={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},fs={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],markerOptional:{he:true,zh:true},svoPosition:1,sovPosition:1}]},hs={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference","property-path"],svoPosition:1,sovPosition:1}]},ys={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},vs={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",ast:{args:[["destination","patient"]]},hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:te,svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},Es={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient"}},roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta",ja:"\u3092",ko:"\uB97C",tr:"i",hi:"\u0915\u094B",de:"",es:"",fr:"",it:"",pt:"",pl:"",ru:"",uk:"",vi:"",id:"",ms:"",th:"",zh:"\u628A",he:"\u05D0\u05EA"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",ja:"\u306B",ko:"\uC5D0",tr:"e",hi:"\u092E\u0947\u0902",de:"zu",es:"a",fr:"\xE0",it:"in",pt:"para",pl:"do",ru:"\u0432",uk:"\u0432",vi:"v\xE0o",id:"ke",ms:"ke",th:"\u0E43\u0E19",zh:"\u5230",he:"\u05E2\u05DC"}}]},gs={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",ast:{},hasBody:true,roles:[]},zs={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},ws={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination"}},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}]},ks={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{of:["destination","source"]}},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:te,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},bs={en:"using view",es:"using view",pt:"using view",fr:"using view",de:"using view",it:"using view",ja:"using view",ko:"using view",zh:"using view",ar:"using view",he:"using view",hi:"using view",bn:"using view",tr:"using view",ru:"using view",uk:"using view",pl:"using view",id:"using view",vi:"using view",th:"using view",ms:"using view",tl:"using view",sw:"using view",qu:"using view"},St={role:"manner",description:"Run the swap inside a `document.startViewTransition()` (`using view transition`)",required:false,expectedTypes:["literal","expression"],valueShape:"keyword",markerOverride:bs},Cs={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",ast:{args:["method","destination","patient"],modifiers:{viewTransition:"manner"}},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:te,svoPosition:2,sovPosition:1,markerOverride:{en:"of",es:"",fr:"",pt:"",it:"",de:"",pl:"",ru:"",uk:"",id:"",ms:"",sw:"",th:"",vi:"",he:"\u05D0\u05EA",zh:"\u628A",tl:""}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with",es:"con",fr:"avec",pt:"com",it:"con",de:"mit",pl:"z",ru:"\u0441",uk:"\u0437",id:"dengan",ms:"dengan",sw:"na",th:"\u0E14\u0E49\u0E27\u0E22",vi:"v\u1EDBi",he:"\u05E2\u05DD",zh:"\u7528",hi:"\u0938\u0947",bn:"\u09A6\u09BF\u09AF\u09BC\u09C7",tr:"ile",qu:"wan",ar:"\u0628\u0640",tl:"nang"}},{...St,svoPosition:4,sovPosition:4}]},As={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",ast:{args:[["source","destination"]],modifiers:{on:"patient",viewTransition:"manner"}},roles:[{role:"patient",description:"The element to morph",required:true,expectedTypes:te,svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"destination",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}},{...St,svoPosition:3,sovPosition:3}]},Ss={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}]},xs={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Ds={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","property-path"],svoPosition:1,sovPosition:1}]},Bs={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Ts={action:"pick",description:"Select item(s), character(s), a range, first/last/random N, or regex matches from a root",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The range/count/index/regex argument to pick",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The root to pick from (with "of"/"from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Fs={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",ast:{args:["destination"]},argSkipTokens:["of","the","top","bottom","middle","center","nearest","left","right","smoothly","instantly"],roles:[{role:"destination",description:"The element to scroll to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},Os={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},Rs={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:Hr}]},Ps={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:Hr}]},Ls={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{viewTransition:"manner"}},roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Os},{...St,svoPosition:2,sovPosition:2}]},Ns={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"],valueShape:"object",svoPosition:2,sovPosition:1}]},ue={toggle:go,add:zo,remove:wo,put:At,set:ko,show:To,hide:Fo,on:Oo,trigger:Ro,wait:Po,fetch:Lo,increment:No,decrement:_o,append:Mo,prepend:Io,log:$o,get:jo,take:Vo,make:Wo,halt:qo,settle:Ko,throw:Ho,send:Uo,if:Go,unless:Zo,else:Yo,repeat:Xo,for:Jo,while:Qo,continue:es,go:ts,scroll:Fs,push:Rs,replace:Ps,process:Ls,transition:is,clone:ns,focus:as,blur:os,empty:ss,open:us,close:ls,select:cs,clear:ds,reset:ms,breakpoint:ps,call:fs,return:hs,js:ys,tell:vs,default:Es,init:gs,behavior:zs,install:ws,measure:ks,swap:Cs,morph:As,beep:Ss,break:xs,copy:Ds,exit:Bs,pick:Ts,render:Ns,bind:bo,live:Co,when:Ao,eventsource:So,socket:xo,worker:Do,intercept:Bo,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function se(t){return ue[t]}function _s(){return Object.values(ue).filter(t=>t.structuralOnly!==true&&(t.roles.length>0||t.bareKeyword===true))}typeof process<"u"&&process.env.LOKASCRIPT_SCHEMA_VALIDATION==="1"&&Promise.resolve().then(()=>(io(),$i)).then(({validateAllSchemas:t,formatValidationResults:e})=>{let r=t(ue);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
|
|
4
|
-
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);});var Hi=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document","true","false","null","undefined","empty"]),Ke=new Map,_e=new Map,vr=new Map,mt=null;function Ui(t,e){let r={...t};for(let i of Object.keys(e)){let n=e[i],a=t[i];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?r[i]=Ui(a,n):r[i]=n);}return r}function Ms(t,e){return Ui(t,e)}function xt(t){if(!t.extends)return t;let e=_e.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=xt(e);return Ms(r,t)}function Pe(t,e,r){Ke.set(t,e),_e.set(t,r),vr.delete(t);}function Gi(t){mt=t;}var Qt=new Map;function nr(t){return t.split("-")[0]}function ar(t){return t.includes("-")}function Is(t){let e=Ke.get(t);if(!e&&ar(t)){let r=nr(t);e=Ke.get(r);}if(!e){let r=Array.from(Ke.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 $s(t){let e=_e.get(t);if(!e&&ar(t)){let r=nr(t);e=_e.get(r);}if(!e){let r=Array.from(_e.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 xt(e)}function O(t){let e=_e.get(t);return !e&&ar(t)&&(e=_e.get(nr(t))),e?xt(e):void 0}function js(){return Array.from(Ke.keys())}function Zi(t){if(Ke.has(t)&&_e.has(t))return true;if(ar(t)){let e=nr(t);return Ke.has(e)&&_e.has(e)}return false}function Vs(t,e){let i=Is(e).tokenize(t);return e==="en"?i:qs(i,e)}var Yi=()=>false;function Ws(t){Yi=t;}function qs(t,e){let r=t.tokens,i=[],n=false;for(let a=0;a<r.length;a++){let o=r[a],s=r[a-1],u=a+2;for(;u<r.length&&r[u]?.value!==")"&&r[u-1].position.end===r[u].position.start;)u++;let l=r.slice(a+1,u),c=l.map(p=>p.value).join(""),d=l[0],m=l[l.length-1];if(o.value==="("&&d&&m&&r[u]?.value===")"&&/^[\p{L}_$][\p{L}\p{M}\p{N}_$]*$/u.test(c)&&!(d.kind!=="particle"&&Hi.has((d.normalized??d.value).toLowerCase()))&&Yi(c,e)&&o.position.end===d.position.start&&m.position.end===r[u].position.start&&!(s&&s.position.end===o.position.start&&/[\p{L}\p{N}_)\]]$/u.test(s.value))){i.push({value:`(${c})`,kind:"identifier",position:{...o.position,end:r[u].position.end}}),a=u,n=true;continue}i.push(o);}return n?new oe(i,e):t}function me(t){let e=vr.get(t);if(!e&&ar(t)&&(e=vr.get(nr(t))),e)return e;let r=Qt.get(t);if(!r&&ar(t)&&(r=Qt.get(nr(t))),r)return vr.set(t,r),r;if(!mt)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let i=$s(t),n=mt(i);return vr.set(t,n),n}var Xi={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function Re(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 Y(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}function Ji(t){if(t==="true")return Y(true,"boolean");if(t==="false")return Y(false,"boolean");if(t==="null")return {type:"expression",raw:"null"}}function Oe(t){return it(t)}function be(t){return {type:"reference",value:t}}function Qi(t,e){return e?{...t,position:e}:t}function Le(t,e,r){return r?{type:"property-path",object:t,property:e,access:r}:{type:"property-path",object:t,property:e}}function de(t,e,r){let i={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...i,metadata:r}:i}function hr(t,e,r,i,n,a){let o=new Map;o.set("event",t);let s={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(s.eventModifiers=r),i!==void 0&&(s.metadata=i),n!==void 0&&n.length>0&&(s.parameterNames=n),s}function yu(t,e,r,i,n){let a={kind:"behavior",action:"behavior",roles:new Map,name:t,parameters:e,eventHandlers:r};return i!==void 0&&i.length>0&&(a.initBlock=i),n!==void 0&&(a.metadata=n),a}function vu(t,e,r,i){let n={kind:"def",action:"def",roles:new Map,name:t,parameters:e,body:r};return i!==void 0&&(n.metadata=i),n}function pt(t,e,r,i,n){let a={kind:"feature",action:t,roles:n??new Map,body:e};return r!==void 0&&(a.name=r),i!==void 0&&(a.metadata=i),a}function er(t,e="then",r){let i={kind:"compound",action:"compound",roles:new Map,statements:t,chainType:e};return r!==void 0&&(i.metadata=r),i}function Eu(t,e,r,i){let n=new Map;n.set("condition",t);let a={kind:"conditional",action:"if",roles:n,thenBranch:e};return r!==void 0&&(a.elseBranch=r),i!==void 0&&(a.metadata=i),a}function gu(t,e,r,i,n){let a={kind:"loop",action:t,loopVariant:e,roles:new Map(Object.entries(r)),body:i};return n?.loopVariable&&(a.loopVariable=n.loopVariable),n?.indexVariable&&(a.indexVariable=n.indexVariable),n?.metadata&&(a.metadata=n.metadata),a}function Nr(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)):t==="expression"?e.some(r=>["selector","reference","expression"].includes(r)):false}function zu(t,e){let r=t.markerOverride?.[e.code],i=e.roleMarkers[t.role];if(r!==void 0){let n=wu(t,e.code,r);return {primary:r,...n&&{alternatives:n},position:i?.position??"before",isOverride:true}}if(i&&i.primary){let n={primary:i.primary,position:i.position,isOverride:false};return i.alternatives&&(n.alternatives=i.alternatives),n}return null}function wu(t,e,r){let i=t.markerLegacy?.[e];if(!i?.length)return;let n=[...new Set(i)].filter(a=>a&&a!==r);return n.length?n:void 0}function Me(t,e,r){let i=t.markerLegacy?.[e]??[],n=t.methodCarrier?[]:t.markerVariants?.[e]??[],a=[...new Set([...i,...n])].filter(o=>o&&o!==r);return a.length?a:void 0}var Cr=new Set(["destination","source","patient","object","event","eventmarker","manner","instrument","style"]);function De(t,e){let r=t.possessive?.keywords?.[e];if(r)return r;let i=t.possessive?.specialForms;if(i){for(let[n,a]of Object.entries(i))if(a===e)return n}}function nt(t){return Xi.possessive?.specialForms?.[t]??`${t}'s`}var Ur=new Set(["+","-","*","/","%","<",">","<=",">=","==","!=","===","!=="]),en=new Set(["<",">","<=",">=","==","!=","===","!=="]),$e=new Set([...Ur,"mod"]),ku=/^[<>=!+\-*/%]+$/,rn={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\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","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"])};function bu(t){return rn[t]}function Gr(t,e){return rn[e]?.has(t.toLowerCase())??false}var tn={ar:["\u0645\u0631\u0627\u062A","\u0645\u0631\u0629"],bn:["\u09AC\u09BE\u09B0"],de:["mal","Mal"],es:["veces","vez"],fr:["fois"],he:["\u05E4\u05E2\u05DE\u05D9\u05DD","\u05E4\u05E2\u05DD"],hi:["\u092C\u093E\u0930"],id:["kali"],it:["volte","volta"],ja:["\u56DE","\u5EA6"],ko:["\uBC88","\uD68C"],ms:["kali"],pl:["razy","raz"],pt:["vezes","vez"],qu:["kuti"],ru:["\u0440\u0430\u0437","\u0440\u0430\u0437\u0430"],sw:["mara"],th:["\u0E04\u0E23\u0E31\u0E49\u0E07"],tl:["beses"],tr:["kez","kere","defa"],uk:["\u0440\u0430\u0437\u0456\u0432","\u0440\u0430\u0437\u0438","\u0440\u0430\u0437"],vi:["l\u1EA7n"],zh:["\u6B21","\u904D"]},Dt={ar:{\u0642\u064A\u0645\u0629:"value"},bn:{\u0985\u0995\u09CD\u09B7\u09AE:"disabled",\u0986\u0987\u09A1\u09BF:"id","\u099A\u09C7\u0995 \u0995\u09B0\u09BE":"checked",\u09A6\u09C8\u09B0\u09CD\u0998\u09CD\u09AF:"length",\u09AE\u09BE\u09A8:"value"},de:{wert:"value"},es:{valor:"value"},fr:{valeur:"value"},hi:{\u0905\u0915\u094D\u0937\u092E:"disabled",\u091A\u0947\u0915:"checked",\u091B\u093F\u092A\u093E:"hidden",\u092E\u093E\u0928:"value"},id:{nilai:"value"},it:{valore:"value"},ja:{\u5024:"value"},ko:{\uAC12:"value"},ms:{dilumpuhkan:"disabled",ditanda:"checked",nilai:"value",panjang:"length"},pl:{warto\u015B\u0107:"value"},pt:{valor:"value"},qu:{chanin:"value"},ru:{\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435:"value",\u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u043E:"disabled",\u043E\u0442\u043C\u0435\u0447\u0435\u043D\u043E:"checked",\u0441\u043A\u0440\u044B\u0442\u043E:"hidden"},sw:{thamani:"value"},th:{\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27:"length",\u0E04\u0E48\u0E32:"value",\u0E1B\u0E34\u0E14\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19:"disabled",\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E41\u0E25\u0E49\u0E27:"checked",\u0E44\u0E2D\u0E14\u0E35:"id"},tl:{haba:"length",halaga:"value",hindi_pinagana:"disabled",naka_tsek:"checked"},tr:{de\u011Fer:"value"},uk:{\u0432\u0438\u043C\u043A\u043D\u0435\u043D\u043E:"disabled",\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F:"value",\u043F\u043E\u0437\u043D\u0430\u0447\u0435\u043D\u043E:"checked",\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u043D\u043E:"hidden"},vi:{\u1EA9n:"hidden","\u0111\u01B0\u1EE3c ch\u1ECDn":"checked","gi\xE1 tr\u1ECB":"value","v\xF4 hi\u1EC7u":"disabled"},zh:{\u503C:"value"}},Cu={ar:{\u0623\u0648:"or",\u0643\u0640:"as",\u0644\u064A\u0633:"not",\u0648:"and",\u064A\u062D\u062A\u0648\u064A:"contains",\u064A\u0633\u0627\u0648\u064A:"equals",\u064A\u0634\u0645\u0644:"includes"},bn:{\u0985\u09A5\u09AC\u09BE:"or",\u098F\u09AC\u0982:"and",\u09A8\u09BE:"not",\u09B9\u09BF\u09B8\u09BE\u09AC\u09C7:"as"},de:{als:"as",beinhaltet:"includes",enth\u00E4lt:"contains",gleicht:"equals",nicht:"not",oder:"or",und:"and"},es:{como:"as",contiene:"contains",iguala:"equals",incluye:"includes",no:"not",o:"or",y:"and"},fr:{comme:"as",contient:"contains",\u00E9gale:"equals",et:"and",inclut:"includes",non:"not",ou:"or"},he:{\u05D5\u05D2\u05DD:"and"},hi:{\u0914\u0930:"and",\u0915\u0947_\u0930\u0942\u092A_\u092E\u0947\u0902:"as",\u0928\u0939\u0940\u0902:"not",\u092C\u0930\u093E\u092C\u0930:"equals",\u092E\u0947\u0902_\u0939\u0948:"includes",\u092F\u093E:"or",\u0936\u093E\u092E\u093F\u0932:"contains"},id:{atau:"or",berisi:"contains",bukan:"not",dan:"and",sama:"equals",sebagai:"as",termasuk:"includes"},it:{come:"as",contiene:"contains",e:"and",include:"includes",non:"not",o:"or",uguale:"equals"},ja:{\u305D\u3057\u3066:"and",\u3067\u306F\u306A\u3044:"not",\u3068\u3057\u3066:"as",\u307E\u305F\u306F:"or",\u542B\u3080:"contains",\u542B\u3081\u308B:"includes",\u7B49\u3057\u3044:"equals"},ko:{\uAC19\uB2E4:"equals",\uADF8\uB9AC\uACE0:"and",\uB610\uB294:"or",\uB85C:"as",\uC544\uB2C8:"not",\uD3EC\uD568:"contains",\uD3EC\uD568\uD558\uB2E4:"includes"},ms:{atau:"or",bukan:"not",dan:"and",mengandungi:"contains",sama:"equals",sebagai:"as",termasuk:"includes"},pl:{i:"and",jako:"as",lub:"or",nie:"not",obejmuje:"includes","r\xF3wna si\u0119":"equals",zawiera:"contains"},pt:{como:"as",cont\u00E9m:"contains",e:"and",igual:"equals",inclui:"includes",n\u00E3o:"not",ou:"or"},qu:{churasqa:"includes",hina:"as",hinallataq:"and",kikin:"equals",ukupi_kan:"contains",utaq:"or"},ru:{\u0432\u043A\u043B\u044E\u0447\u0430\u0435\u0442:"includes",\u0438:"and",\u0438\u043B\u0438:"or",\u043A\u0430\u043A:"as",\u043D\u0435:"not",\u0440\u0430\u0432\u043D\u043E:"equals",\u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442:"contains"},sw:{au:"or",ina:"contains",kuwa:"as",pamoja:"includes",sawa:"equals",si:"not"},th:{\u0E44\u0E21\u0E48:"not",\u0E41\u0E25\u0E30:"and",\u0E2B\u0E23\u0E37\u0E2D:"or"},tl:{at:"and",bilang:"as",hindi:"not",katumbas:"equals",naglalaman:"contains",o:"or"},tr:{de\u011Fil:"not",e\u015Fittir:"equals",i\u00E7erir:"contains",olarak:"as",ve:"and",veya:"or"},uk:{\u0430\u0431\u043E:"or",\u0432\u043A\u043B\u044E\u0447\u0430\u0454:"includes",\u0434\u043E\u0440\u0456\u0432\u043D\u044E\u0454:"equals",\u0456:"and",\u043C\u0456\u0441\u0442\u0438\u0442\u044C:"contains",\u043D\u0435:"not",\u044F\u043A:"as"},vi:{b\u1EB1ng:"equals",ch\u1EE9a:"contains",ho\u1EB7c:"or",kh\u00F4ng:"not",nh\u01B0:"as",v\u00E0:"and"},zh:{\u4F5C\u4E3A:"as",\u5305\u542B:"contains",\u5305\u62EC:"includes",\u548C:"and",\u6216:"or",\u7B49\u4E8E:"equals",\u975E:"not"}},nn={ms:new Set(["daripada"]),sw:new Set(["ya"]),vi:new Set(["c\u1EE7a"]),zh:new Set(["\u7684"]),it:new Set(["di"]),pl:new Set(["z"]),uk:new Set(["\u0437"]),th:new Set(["\u0E02\u0E2D\u0E07"]),ar:new Set(["\u0644\u0640"]),ja:new Set(["\u306E"]),ko:new Set(["\uC758"]),bn:new Set(["\u09B0"]),hi:new Set(["\u0915\u093E"]),qu:new Set(["pa"]),tr:new Set(["nin","n\u0131n","nun","n\xFCn","in","\u0131n","un","\xFCn"])};function Ve(t,e){let r=e.value.toLowerCase(),i=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||i==="of"||i==="source")return true;let n=t?.code?nn[t.code]:void 0;return !!n&&n.has(r)}var Au={destination:"in",source:"from"},an={ar:new Set(["\u0639\u0646\u062F","\u0641\u064A"]),bn:new Set(["\u098F","\u09A4\u09C7"]),de:new Set(["bei"]),es:new Set(["en"]),fr:new Set(["dans","en","\xE0"]),he:new Set(["\u05DC\u05EA\u05D5\u05DA"]),hi:new Set(["\u092A\u0930","\u092E\u0947\u0902"]),id:new Set(["dalam","di","ke_dalam"]),it:new Set(["a"]),ja:new Set(["\u3067","\u306E\u4E2D","\u3078"]),ko:new Set(["\uC548\uC5D0","\uC5D0","\uC73C\uB85C"]),ms:new Set(["dalam","di","ke_dalam"]),pl:new Set(["do","przy","w"]),pt:new Set(["dentro","em"]),qu:new Set(["pi","ukupi"]),ru:new Set(["\u0432","\u0443"]),sw:new Set(["katika","ndani"]),th:new Set(["\u0E17\u0E35\u0E48","\u0E43\u0E19"]),tl:new Set(["papasok_sa","sa","sa_loob"]),tr:new Set(["de","i\xE7inde","i\xE7ine"]),uk:new Set(["\u0432","\u0443"]),vi:new Set(["trong","t\u1EA1i","v\xE0o"]),zh:new Set(["\u5728","\u8FDB\u5165"])},on=new Set(["in","into","at","within","inside"]);function Su(t,e){let r=e.value.toLowerCase();if((t?.code?an[t.code]:void 0)?.has(r))return "in";let n=e.normalized??e.value,a=n.toLowerCase();return on.has(a)?"in":Au[a]??n}function xu(t,e){return e.value.toLowerCase()==="in"||(t?.code?an[t.code]:void 0)?.has(e.value.toLowerCase())?true:on.has((e.normalized??e.value).toLowerCase())}var Du=new Set(["me","it","you","body","document","target","result"]);function Bu(t,e){let r=t[e];if(!r)return null;if(r.kind==="selector")return /^[*@]/.test(r.value)?null:{kind:"selector",parts:[{text:r.value,token:r}],consumed:1};let i=(r.normalized??r.value).toLowerCase();if(Du.has(i))return {kind:"reference",parts:[{text:i,token:r}],consumed:1};let n=t[e+1];return i==="closest"&&n?.kind==="selector"&&!/^[*@]/.test(n.value)?{kind:"closest",parts:[{text:"closest",token:r},{text:n.value,token:n}],consumed:2}:null}function sn(t,e,r,i){let n=t[e];if(!n||!xu(r,n))return null;let a=Bu(t,e+1);if(!a)return null;let o=t[e+1+a.consumed];return i?.(n)===true&&i(o)!==true?null:{marker:n,scope:a}}var at=new Set(["first","last","next","previous","random","closest"]),Tu={bn:{\u09B6\u09C7\u09B7:"last"}},lr=new Set(Object.keys(ue).map(t=>t.toLowerCase()));function wr(t,e,r,i){let n=t[e];if(!n)return null;let a=(n.normalized??n.value).toLowerCase(),o=t[e+1],s=r?.code&&o?.kind==="selector"&&o.value.startsWith("<")?Tu[r.code]?.[n.value.toLowerCase()]:void 0;if(!at.has(a)&&!at.has(n.value.toLowerCase())&&s===void 0)return null;let u=[{text:s??n.normalized??n.value,token:n}],l=e+1,c=t[l];if(!c||c.kind!=="selector"||en.has(c.value))return null;u.push({text:c.value,token:c}),l++;let d=0;for(;d++<8;){let f=t[l];if(f&&f.kind==="selector"&&f.value.startsWith("."))u.push({text:f.value,token:f}),l++;else break}let m=t[l],p=t[l+1];if(m&&p&&p.kind==="selector"&&!/^[*@]/.test(p.value)&&(m.kind==="keyword"||m.kind==="particle"||m.kind==="identifier")&&!at.has((m.normalized??m.value).toLowerCase())&&!lr.has((m.normalized??m.value).toLowerCase())&&!(i?.(m)===true&&i(t[l+2])!==true))u.push({text:Su(r,m),token:m}),u.push({text:p.value,token:p}),l+=2;else {let f=sn(t,l,r,i);f&&f.scope.kind!=="selector"&&(u.push({text:"in",token:f.marker},...f.scope.parts),l+=1+f.scope.consumed);}return {parts:u,consumed:l-e}}function He(t,e){let r=Cu[t];return r?r[e.toLowerCase()]??e:e}function he(t,e){let r=Dt[t];return r?r[e.toLowerCase()]??e:e}function ti(t,e){return Dt[t]?.[e.toLowerCase()]!==void 0}function Fu(t,e){let r=[e.value,e.normalized].filter(Boolean);for(let i of r){let n=De(t,i)??De(t,i.toLowerCase());if(n)return n}}function un(t){return t.kind==="literal"||t.kind==="operator"||t.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(t.value)}function Ou(t,e){let r=t?.references;if(!r)return false;let i=Object.values(r).filter(a=>typeof a=="string").map(a=>a.toLowerCase());return [e.value,e.normalized].filter(Boolean).some(a=>i.includes(a.toLowerCase()))}function tr(t,e){return un(t)?he(e,t.value)!==t.value?true:t.kind==="identifier":false}var Ru=new Set(["true","false","null","undefined","me","my","it","its","you","your","result","event","target","body","detail","document","window"]);function ln(t){return t.kind==="literal"||t.kind==="selector"||t.kind==="reference"?true:t.kind==="identifier"?Lu.test(t.value):t.kind==="keyword"&&Ru.has((t.normalized??t.value).toLowerCase())}function ii(t){return !!t&&(t.value===")"||t.value==="]"||ln(t))}function ft(t){if(!t)return false;if(/^[([-]$/.test(t.value)||ln(t))return true;let e=(t.normalized??"").toLowerCase();return t.kind==="keyword"&&(e==="not"||e==="no")}var Pu=/^\.[\p{L}_-][\p{L}\p{N}_-]*$/u,Lu=/^(?:[:$]?[\p{L}_][\p{L}\p{M}\p{N}_]*|\([\p{L}_$][\p{L}\p{M}\p{N}_$]*\))$/u,U={beforeClassRef:"has"},Nu={ar:{\u0647\u0648:{beforePredicate:"is",afterOperand:"is"},\u0641\u0627\u0631\u063A:{afterCopula:"empty"}},hi:{\u0939\u0948:{beforePredicate:"is",beforeClassRef:"has",afterOperand:"is"},\u0916\u093E\u0932\u0940:{afterCopula:"empty"}},id:{kosong:{afterCopula:"empty"},punya:U},th:{\u0E40\u0E1B\u0E47\u0E19:{beforeTypeName:"as",beforePredicate:"is",afterOperand:"is"},\u0E27\u0E48\u0E32\u0E07:{afterCopula:"empty"},\u0E21\u0E35:U},ja:{\u7A7A:{afterCopula:"empty"},\u3042\u308B:U},sw:{tupu:{afterCopula:"empty",otherwise:"null"},na:{betweenOperands:"and"},ana:U,nina:U},zh:{\u6CA1\u6709:{beforeBareIdentifier:"no",beforeSelector:"no"},\u6709:U},tl:{walang:{beforeBareIdentifier:"no",beforeSelector:"no"},may:{afterSubject:"exists",beforeClassRef:"has"}},bn:{\u0986\u099B\u09C7:{afterSubject:"exists",beforeClassRef:"has"},\u0986\u099B\u09BF:U},qu:{mana:{beforeOperand:"not"},chusaq:{afterCopula:"empty"},kachkan:U,kachkani:U},tr:{var:{afterSubject:"exists",beforeClassRef:"has"},bo\u015F:{afterCopula:"empty"}},de:{hat:U,habe:U},es:{tiene:U,tengo:U},fr:{a:U,ai:U},it:{ha:U,ho:U},ko:{\uC788\uB2E4:U},ms:{ada:U},pl:{ma:U,mam:U},pt:{tem:U,tenho:U},ru:{\u0438\u043C\u0435\u0435\u0442:U,\u0438\u043C\u0435\u044E:U},uk:{\u043C\u0430\u0454:U,\u043C\u0430\u044E:U},vi:{c\u00F3:U}},_u=new Set(["text","json","html","response","blob","arraybuffer"]),Mu=new Set(["empty","null","undefined","true","false"]),cn=new Set(["Number","Int","Float","String","Boolean","Date","Array","Object","JSON","json","JSONString","FormData","FormEncoded","HTML","Fragment","Values","Values:Form","Values:JSON","Set","Map","Keys","Entries","Reversed","Unique","Flat"]);function kr(t){return cn.has(t)||/^Fixed(?::\d+)?$/.test(t)||/^[A-Z][A-Za-z0-9_]*(?::[A-Za-z0-9_]+)?$/.test(t)}function dn(t,e,r,i,n,a){let o=ht(t,e);if(!o)return;if(o.beforeTypeName&&i?.kind==="identifier"&&a?.value!=="("&&(cn.has(i.value)||_u.has(i.value.toLowerCase())))return o.beforeTypeName;if(o.beforePredicate&&i&&(i.kind==="literal"||i.kind==="keyword"&&Mu.has((i.normalized??"").toLowerCase())))return o.beforePredicate;if(o.afterCopula&&n!==void 0&&["is","not","does","do"].includes(n.toLowerCase()))return o.afterCopula;if(o.beforeBareIdentifier&&i?.kind==="identifier"&&/^[A-Za-z_]\w*$/.test(i.value))return o.beforeBareIdentifier;let s=!!i&&br(i,t)&&Ne({prev:e,beforePrev:r,next:a},t);if(o.beforeOperand&&(ft(i)||s))return o.beforeOperand;if(o.beforeSelector&&i?.kind==="selector")return o.beforeSelector;if(o.beforeClassRef&&i&&Pu.test(i.value))return o.beforeClassRef;if(o.afterSubject&&(r?.kind==="selector"||r?.kind==="reference"))return o.afterSubject;let u=!!r&&br(r,t)&&n===r.value;return o.betweenOperands&&(ii(r)||u)&&ft(i)?o.betweenOperands:o.afterOperand&&(ii(r)||r?.value==="}")?o.afterOperand:o.otherwise}function ht(t,e){let r=Nu[t];return r?.[e.value]??r?.[e.value.toLowerCase()]}function Iu(t,e,r,i){return dn(t,e,r,i,void 0,void 0)}function $u(t){return ku.test(t)||t==="("||t==="["||t===","}function ju(t){return Ur.has(t)&&t!=="-"||t===")"||t==="]"||t===","}var Vu=new Set(["is","am","contains","contain","matches","match","has","have","includes","include","exists","exist","mod"]);function mn(t,e,r,i){let n=e.kind==="keyword"?(e.normalized??"").toLowerCase():He(t,e.value).toLowerCase();if(n!=="and"&&n!=="or")return false;if(r===void 0||r!==void 0&&$u(r.value))return true;if(i===void 0)return false;if(ju(i.value))return true;let a=i.kind==="keyword"?(i.normalized??i.value).toLowerCase():He(t,i.value).toLowerCase();return Vu.has(a)}var Wu=new Set(["include","contain","match","exist"]);function pn(t){let e=t?.toLowerCase();return e==="is"||e==="not"}function fn(t,e,r){let i=e[r],n=e[r-1];return !i||!n||i.value.toLowerCase()!=="in"?false:pn(or(t,n,e[r-2],i,void 0))}function or(t,e,r,i,n,a){if(n?.toLowerCase()==="equal"&&e.value.toLowerCase()==="to")return "to";if(pn(n)&&e.value.toLowerCase()==="in")return "in";if(n?.toLowerCase()==="not"&&Wu.has(e.value.toLowerCase()))return e.value.toLowerCase();let o=dn(t,e,r,i,n,a);if(o!==void 0)return o;if(mn(t,e,r,i))return e.value;let s=He(t,e.value);if(s!==e.value)return s;if(e.kind!=="keyword")return e.value;let u=(e.normalized??e.value).toLowerCase();return u!=="event"&&Cr.has(u)||br(e,t)&&Ne({prev:r,next:i,afterNext:a},t)?e.value:e.normalized??e.value}function hn(t,e,r,i){let n=t[e],a=t[e+1];if(!n||!a||!un(n)||!Ve(r,a)||!tr(n,i))return;if(t[e+2]?.kind==="selector")return e+2;let o=e;for(;t[o]!==void 0&&t[o+1]!==void 0&&Ve(r,t[o+1])&&tr(t[o],i);)o+=2;return o>e+2&&t[o]?.kind==="selector"?o:void 0}var qu=new Set(["if","unless","while","until","for","when","where","is","not","no","and","or","as"]);function Ku(t){let e=(t.normalized??t.value).toLowerCase();return e==="event"||Oe(e)?false:qu.has(e)||Cr.has(e)}function br(t,e){return t.kind!=="keyword"?false:(t.normalized??t.value).toLowerCase()==="end"||Gr(t.value,e)}function ye(t,e){return {prev:t[e-1],beforePrev:t[e-2],third:t[e-3],next:t[e+1],afterNext:t[e+2]}}var Hu=new Set(["and","or","is","times"]),Uu=new Set(["if","unless","while","until","is","and","or","in"]),Gu=t=>Object.prototype.hasOwnProperty.call(ue,t);function ot(t){if(t.kind!=="keyword"&&!(t.normalized&&t.normalized!==t.value))return;let e=(t.normalized??t.value).toLowerCase();return Gu(e)?e:void 0}var ni=new WeakMap;function ai(t,e,r=false){let i;try{i=me(t);}catch{return new Set}let n=ni.get(i);n||(n=new Map,ni.set(i,n));let a=r?`${e} before a role pair`:e,o=n.get(a);if(!o){o=new Set;for(let s of i){if(s.command!==e)continue;let[u,l,c,d]=s.template.tokens;if(!(u?.type!=="literal"||l?.type!=="literal")&&!(r&&(c?.type!=="role"||d?.type!=="role")))for(let m of [l.value,...l.alternatives??[]])o.add(m.toLowerCase());}n.set(a,o);}return o}var oi=new WeakMap;function Zu(t){let e;try{e=me(t);}catch{return new Set}let r=oi.get(e);if(!r){let i=new Set(Object.values(O(t)?.roleMarkers??{}).flatMap(a=>a?[a.primary,...a.alternatives??[]]:[]).map(a=>a.toLowerCase())),n=new Set;for(let a of e){if(a.command!=="repeat")continue;let o=a.template.tokens;o.forEach((s,u)=>{if(!(s.type!=="literal"||o[u+1]?.type!=="role"))for(let l of [s.value,...s.alternatives??[]])i.has(l.toLowerCase())||n.add(l.toLowerCase());});}r=n,oi.set(e,r);}return r}function si(t){return t.kind==="particle"?true:t.kind==="keyword"&&Cr.has((t.normalized??"").toLowerCase())}function ui(t,e){return t.kind==="keyword"&&t.normalized?t.normalized.toLowerCase():He(e,t.value).toLowerCase()}function Ne(t,e){let{prev:r,beforePrev:i,next:n,afterNext:a}=t;if(n){if($e.has(n.value)||Hu.has((n.normalized??n.value).toLowerCase())||n.value==="'"&&a?.value.toLowerCase()==="s")return true;let f=ht(e,n)?.betweenOperands;if((f==="and"||f==="or")&&ft(a))return true}let o=O(e),s=!!o&&o.markingStrategy!=="preposition";if(s&&n?.kind==="particle"&&a?.kind!=="particle")return true;if(!r)return false;if(Ur.has(r.value))return true;let u=ui(r,e);if(u==="not"||u==="no"||ht(e,r)?.beforeOperand==="not")return true;let l=o?.wordOrder!=="SOV",c=t.third?ot(t.third):void 0;if(c&&i&&ai(e,c,true).has(i.value.toLowerCase()))return true;let d=i&&l?ot(i):void 0;if(d&&!ai(e,d).has(r.value.toLowerCase())||i&&!s&&si(i))return false;if(Uu.has(u))return true;let m=!!i&&ui(i,e)!=="repeat"&&!!tn[e]?.includes(r.value);if(Zu(e).has(r.value.toLowerCase())&&(l||u!=="repeat")&&!m)return true;let p=l?ot(r):void 0;return p&&ue[p].roles.some(f=>f.required)?true:!s&&si(r)}function yn(t){if(t.kind==="keyword")return Ku(t)?"structure":lr.has((t.normalized??t.value).toLowerCase())?"verb":void 0}function Te(t,e){let r=e?.code??"en",[i]=t;if(t.length===1&&i&&(yn(i)||br(i,r)))return i.value;let n="",a,o,s=(u,l)=>{if(o=u,a===void 0){n=u,a=l;return}let d=a.position?.end!==void 0&&l.position?.start!==void 0&&a.position.end===l.position.start&&(u.startsWith(".")||u.startsWith("!"));n+=(d?"":" ")+u,a=l;};for(let u=0;u<t.length;u++){let l=t[u],c=e?Fu(e,l):void 0,d=t[u+1];if(l.value===":"&&a!==void 0&&o!==void 0&&d!==void 0&&a.position?.end===l.position?.start&&l.position?.end===d.position?.start&&kr(`${o}:${d.value}`)){n+=`:${d.value}`,o=`${o}:${d.value}`,a=d,u+=1;continue}if(l.value==="'"&&a!==void 0&&d?.value==="s"&&l.position?.end!==void 0&&d.position?.start===l.position.end){n+="'s",a=d;let y=t[u+2];y&&he(r,y.value)!==y.value?(s(he(r,y.value),y),u+=2):u+=1;continue}let m=e?.possessive,p=t[u+2];if(m?.markerPosition==="between"&&m.marker&&l.kind==="selector"&&d?.value===m.marker&&p!==void 0&&tr(p,r)){s(`${l.value}'s`,l),s(he(r,p.value),p),u+=2;continue}if(d?.value.toLowerCase()==="of"&&he(r,l.value)!==l.value&&tr(l,r)){s(he(r,l.value),l);continue}if(c!==void 0&&d){let y=e?.possessive?.connectors,E=!!y?.length&&y.some(g=>{let A=g.toLowerCase();return A===d.value.toLowerCase()||A===(d.normalized??"").toLowerCase()}),z=E?u+2:u+1,k=t[z];if(k&&tr(k,r)){s(nt(c),l),s(he(r,k.value),k),u=z;continue}if(E&&k&&/^\.[a-zA-Z_]\w*$/.test(k.value)&&d.position?.end!==void 0&&k.position?.start!==void 0&&d.position.end===k.position.start){s(nt(c),l),s(he(r,k.value.slice(1)),k),u=z;continue}if(!E&&/^\.[a-zA-Z_]\w*$/.test(d.value)&&l.position?.end!==void 0&&d.position?.start!==void 0&&l.position.end===d.position.start&&!Ou(e,l)){s(nt(c),l),s(he(r,d.value.slice(1)),d),u+=1;continue}}let f=t[u+2],h=hn(t,u,e,r);if(h!==void 0){for(let y=u;y<h;y+=2)s(he(r,t[y].value),t[y]),s("of",t[y+1]);s(t[h].value,t[h]),u=h;continue}if(l.kind==="selector"&&d&&f&&Ve(e,d)&&tr(f,r)&&he(r,f.value)!==f.value){s(he(r,f.value),f),s("of",d),s(l.value,l),u+=2;continue}let v=wr(t,u,e);if(v){for(let y of v.parts)s(y.text,y.token);u+=v.consumed-1;continue}s(or(r,l,t[u-1],d,o,t[u+2]),l);}return n.trim()}function Yu(t){if(!t)return true;if(t.kind!=="keyword")return false;let e=(t.normalized??t.value).toLowerCase();return e==="then"||e==="end"||e==="else"}function vn(t){return !!t&&$e.has(t.value)}var Xu=class{constructor(t,e,r,i,n){this.patternToken=e,this.afterLiteral=r,this.nextPatternToken=i,this.wouldMatch=n;let a=t.position();this.token=t.tokens[a],this.prev=t.tokens[a-1],this.next=t.tokens[a+1],this.place=ye(t.tokens,a);}get lastSlot(){return this.nextPatternToken===void 0}get tokenIsMarker(){return this.tokenIsMarkerMemo??(this.tokenIsMarkerMemo=this.wouldMatch(this.nextPatternToken,this.token)),this.tokenIsMarkerMemo}get beforeRole(){return this.nextPatternToken?.type==="role"}get nextIsMarker(){return this.nextIsMarkerMemo??(this.nextIsMarkerMemo=this.next!==void 0&&this.wouldMatch(this.nextPatternToken,this.next)),this.nextIsMarkerMemo}get clauseEndsAfter(){return Yu(this.next)}};function Ju(t){let e=t.token.value.toLowerCase();if(e!=="a"&&e!=="an")return false;let r=t.next;return r!==void 0&&(Ur.has(r.value)||t.nextIsMarker)}function Bt(t){return t.kind==="keyword"&&lr.has((t.normalized??t.value).toLowerCase())}function Qu(t,e){let r=t.token;if(r.kind!=="keyword")return false;let i=(r.normalized??r.value).toLowerCase();return i==="then"?true:(i==="end"&&t.next?.kind!=="selector"||Gr(r.value,e))&&!Ne(t.place,e)}function el(t,e){return br(t.token,e)&&Ne(t.place,e)}function En(t){return t.afterLiteral&&(t.clauseEndsAfter||t.nextIsMarker)}function rl(t,e){let r=t.patternToken.role;return r!=="quantity"&&!(r==="event"&&e==="repeat")?false:Bt(t.token)&&!En(t)&&!t.nextIsMarker}function tl(t){let e=t.patternToken;return !e.optional||e.role==="event"||e.role==="action"||e.valueShape==="keyword"||!Bt(t.token)?false:(t.lastSlot||t.tokenIsMarker)&&!En(t)}function il(t,e,r,i){let n=t.type==="group"&&t.optional?t.tokens.every(o=>o.type==="role")?t.tokens[0]:void 0:t;if(!n||n.type!=="role"||!n.optional||n.role==="event"||n.role==="action"||n.valueShape==="keyword"||!e||e.kind!=="keyword"||r===void 0)return false;let a=i(r,e);return Bt(e)?!a:a}function nl(t){return lr.has((t.normalized??t.value).toLowerCase())}function al(t,e){return t?.kind==="particle"&&!!e&&["selector","literal","identifier"].includes(e.kind)&&!vn(e)}function ol(t){if(t.token.kind!=="particle")return false;let e=t.next;return e!==void 0&&t.nextIsMarker&&(e.kind==="particle"||t.prev?.kind==="particle")||t.afterLiteral&&t.beforeRole||t.clauseEndsAfter}function sl(t,e){let r=t.patternToken;if(r.role==="event"||r.role==="action"||r.valueShape==="keyword")return false;let i=r.expectedTypes;if(i?.length&&!i.some(a=>a==="expression"||a==="reference"))return false;let n=yn(t.token);return n==="structure"?true:n!=="verb"||(t.token.normalized??t.token.value).toLowerCase()==="empty"?false:!e?.hasBody&&!e?.roles.some(a=>a.role==="event")}function ul(t){let e=(t.normalized||t.value).toLowerCase();if(e==="empty")return Ji("null");if(e==="a"||e==="an")return {type:"expression",raw:t.value}}function ll(t,e,r){return t.kind==="particle"&&(e||vn(r))}function gn(t,e){let r=t[e];return r?.kind==="particle"&&t[e-1]?.value.toLowerCase()==="of"&&/^[\p{L}_$][\p{L}\p{M}\p{N}_$]*$/u.test(r.value)}var li=new Set(["is","am","are","be","was","were","not","no"]),cl=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948","\u0928\u0939\u0940\u0902","mana"]),zn=new Set(["empty","null","undefined"]);function dl(t,e,r,i){let n=(t.normalized??t.value).toLowerCase(),a=t.value.toLowerCase(),o=(e.normalized??e.value).toLowerCase();return (li.has(n)||li.has(He(i,a))||cl.has(a)&&zn.has(o))&&!r}var ml=new Set(["'s","a","am","an","and","as","closest","contain","contains","do","does","empty","equal","equals","exist","exists","false","first","greater","has","have","in","include","includes","is","it","its","last","less","match","matches","me","mod","my","next","no","not","null","of","or","previous","really","some","than","the","true","undefined","you","your","result","target","body","detail"]),pl=new Set(["am","and","as","contain","contains","do","does","empty","equal","equals","exist","exists","greater","has","have","in","include","includes","is","less","match","matches","mod","no","not","of","or","really","some","than"]),ci=/\s+as\s+([A-Za-z]\w*)!?\s*$/;function wn(t){let e=t;for(let n=ci.exec(e);n;n=ci.exec(e)){if(!kr(n[1]??""))return false;e=e.slice(0,n.index);}let r=e.replace(/"[^"]*"|'[^']*'/g,"");if(/["']/.test(r.replace(/'s\b/g,""))||/[^\x00-\x7F]/.test(r))return false;let i=vo(e);return !i.success||i.consumed===void 0||i.consumed!==Ki(e).length-1?false:fl(i.node).every(kr)}function fl(t){let e=[],r=i=>{if(Array.isArray(i)){i.forEach(r);return}if(!i||typeof i!="object")return;let n=i;n.type==="asExpression"&&e.push(String(n.targetType?.name??"")),Object.values(i).forEach(r);};return r(t),e}function Er(t,e){return t?.position?.end!==void 0&&e?.position?.start!==void 0&&t.position.end===e.position.start}var hl=new Set(["is","not","really","am","or"]);function kn(t,e,r){let i=n=>{let a=t[n];return a?or(r,a,t[n-1],t[n+1],void 0).toLowerCase():""};return i(e)==="to"&&i(e-1)==="equal"&&hl.has(i(e-2))}function yl(t){return t.value==="a"}var vl=new Set(["event","window","document"]);function El(t,e,r){let i=t[e],n=t[e-1];return !i||!n||!Ve(r,n)?false:vl.has((i.normalized??i.value).toLowerCase())}function gl(t,e){if(t.kind==="conjunction")return true;if(t.kind==="keyword"){let r=(t.normalized??t.value).toLowerCase();if(r==="then"||r==="end"||r==="else"||Gr(t.value,e.profile?.code??""))return true}return e.owes(t)}function di(t,e,r){let i=r.profile?.code??"en";if(fn(i,t,e)||gn(t,e)||kn(t,e,i)||yl(t[e]))return false;let n=t[e];return gl(n,r)||r.commandMarkers.has(n.value.toLowerCase())}function zl(t,e,r){let i=t[e],n=t[e-1],a=r.profile?.code??"en";if(i.kind==="literal"||i.value==="'"&&t[e+1]?.value==="s"||i.value==="s"&&n?.value==="'")return true;if(i.kind==="selector"){if(!i.value.startsWith(".")||!n||Er(n,i)||$e.has(n.value)||/^[([,]$/.test(n.value)||Ve(r.profile,n))return true;let s=or(a,n,t[e-2],i,void 0).toLowerCase();return pl.has(s)}if($e.has(i.value)||/^[()[\],.!<>=+\-*/%]+$/.test(i.value)||Ve(r.profile,i)||mn(a,i,n,t[e+1])||fn(a,t,e)||gn(t,e)||El(t,e,r.profile)||kn(t,e,a))return true;let o=or(a,i,n,t[e+1],void 0).toLowerCase();return o==="as"&&r.hasResponseType?false:ml.has(o)?true:i.kind==="identifier"&&/^(?:[\p{L}_$][\p{L}\p{M}\p{N}_$]*('s)?|\([\p{L}_$][\p{L}\p{M}\p{N}_$]*\))$/u.test(i.value)}function wl(t,e,r){if(!t[e]||di(t,e,r))return [];let i=e;for(;i<t.length&&!di(t,i,r)&&zl(t,i,r);)i++;let n=[];for(let a=i;a>e;a--)n.push(a);return n}function kl(t,e,r){let i=[],n=e;for(;;){let a=t[n];if(!a)break;if(a.value==="'"&&t[n+1]?.value==="s"&&t[n+2])n+=3;else if(/.'s$/.test(t[n-1]?.value??""))n+=1;else if(Ve(r,a)&&t[n+1])n+=2;else break;i.push(n);}return i.reverse()}function bl(t,e,r,i){for(let n of r){let a=Te(t.slice(e,n),i);if(wn(a))return {end:n,raw:a}}}[...At.roles.find(t=>t.role==="destination")?.expectedTypes??[]];[...At.roles.find(t=>t.role==="patient")?.expectedTypes??[]];var bn=[{lang:"es",verb:"poner",verbAlts:["pon","colocar","put"],at:"en",end:"fin",of:"de"},{lang:"fr",verb:"mettre",at:"\xE0",end:"fin",of:"de"},{lang:"pt",verb:"colocar",at:"em",end:"fim",of:"de"},{lang:"it",verb:"mettere",at:"a",end:"fine",of:"di"},{lang:"de",verb:"setzen",at:"bei",end:"ende",of:"von"},{lang:"sw",verb:"weka",at:"katika",end:"mwisho",of:"ya"},{lang:"id",verb:"taruh",verbAlts:["letakkan","masukkan","tempatkan"],at:"di",end:"akhir",of:"dari"},{lang:"ms",verb:"letak",at:"di",end:"tamat",of:"daripada"},{lang:"vi",verb:"\u0111\u1EB7t",at:"t\u1EA1i",end:"k\u1EBFt th\xFAc",of:"c\u1EE7a"},{lang:"pl",verb:"umie\u015B\u0107",at:"przy",end:"koniec",of:"z"},{lang:"ru",verb:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",at:"\u0443",end:"\u043A\u043E\u043D\u0435\u0446",of:"\u0438\u0437"},{lang:"uk",verb:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",at:"\u0432",end:"\u043A\u0456\u043D\u0435\u0446\u044C",of:"\u0437"},{lang:"th",verb:"\u0E43\u0E2A\u0E48",at:"\u0E17\u0E35\u0E48",end:"\u0E08\u0E1A",of:"\u0E02\u0E2D\u0E07"},{lang:"tl",verb:"ilagay",at:"sa",end:"wakas",of:"ng"},{lang:"ar",verb:"\u0636\u0639",at:"\u0639\u0646\u062F",end:"\u0627\u0644\u0646\u0647\u0627\u064A\u0629",of:"\u0645\u0646"},{lang:"zh",verb:"\u653E\u7F6E",verbAlts:["\u653E","\u653E\u5165"],patientPrefix:"\u628A",at:"\u5728",end:"\u7ED3\u675F",of:"\u7684"},{lang:"he",verb:"\u05E9\u05D9\u05DD",patientPrefix:"\u05D0\u05EA",at:"at",end:"\u05E1\u05D5\u05E3",of:"of"},{lang:"tr",verb:"koy",sov:true,objMarker:"i",at:"de",end:"son",of:"nin"},{lang:"ja",verb:"\u7F6E\u304F",sov:true,objMarker:"\u3092",at:"\u3067",end:"\u7D42\u308F\u308A",of:"\u306E"},{lang:"ko",verb:"\uB123\uB2E4",sov:true,objMarker:"\uB97C",at:"\uC5D0",end:"\uB05D",of:"\uC758"},{lang:"hi",verb:"\u0930\u0916\u0947\u0902",verbAlts:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],sov:true,objMarker:"\u0915\u094B",at:"\u092A\u0930",end:"\u0938\u092E\u093E\u092A\u094D\u0924",of:"\u0915\u093E"},{lang:"bn",verb:"\u09B0\u09BE\u0996\u09C1\u09A8",verbAlts:["\u09B0\u09BE\u0996"],sov:true,objMarker:"\u0995\u09C7",at:"\u098F",end:"\u09B6\u09C7\u09B7",of:"\u09B0"},{lang:"qu",verb:"churay",sov:true,objMarker:"ta",at:"pi",end:"tukuy",of:"pa"}];function st(t,e,r,i){let n=bn.find(o=>o.lang===t);if(!n)return false;let a=(o,s)=>(o??"").toLowerCase()===s.toLowerCase();return a(e,n.end)&&a(r,n.at)&&a(i,n.of)}function Cl(t,e){let r=bn.find(n=>n.lang===t);if(!r)return false;let i=e.toLowerCase();return i===r.at.toLowerCase()||i===r.of.toLowerCase()||i===r.end.toLowerCase()}var Cn=96,Al=/^[A-Za-z_][\w-]*$/,Sl=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function An(t,e){let r=t.peek(e);return !!r&&r.kind==="identifier"&&Sl.test(r.value)}function Sn(t,e){let r=t.peek(e);if(!r||r.kind!=="identifier"&&r.kind!=="keyword"||!Al.test(r.value))return false;let i=t.peek(e+1),n=t.peek(e+2);return !!i&&i.value===":"&&!!n}function mi(t,e=0){return An(t,e)||Sn(t,e)}function xl(t){let e=t.peek();if(!e||e.value!=="{"&&e.value!=="(")return null;let r="",i=-1,n=0,a=0;for(;!t.isAtEnd()&&a++<Cn;){let o=t.advance();if(!o)break;if(i>=0&&o.position.start>i&&(r+=" ".repeat(o.position.start-i)),r+=o.value,i=o.position.end,o.value==="{"||o.value==="(")n++;else if((o.value==="}"||o.value===")")&&(n--,n===0))return r}return null}function pi(t){let e=t.peek();return e?e.value==="{"||e.value==="("?xl(t):e.value===","||e.value===":"?null:(t.advance(),e.value):null}function gr(t,e){let r=t.mark(),i=[];if(e!==void 0){let a=t.peek();if(!a||a.value!==":"||!t.peek(1))return null;t.advance();let o=pi(t);if(o===null)return t.reset(r),null;i.push(`${e}:${o}`);}else if(!mi(t))return null;let n=0;for(;n++<Cn;){let a=t.peek();if(!a)break;if(a.value===","){if(i.length===0||!mi(t,1))break;t.advance();continue}if(An(t,0)){i.push(t.advance().value);continue}if(!Sn(t,0))break;let o=t.advance().value;t.advance();let s=pi(t);if(s===null)return t.reset(r),null;i.push(`${o}:${s}`);}return i.length===0?(t.reset(r),null):`{${i.join(", ")}}`}function jr(t){switch(t.kind){case "selector":return Re(t.value);case "literal":return Dl(t.value);case "keyword":{let r=ul(t);if(r)return r;let i=(t.normalized||t.value).toLowerCase();return Oe(i)?be(i):Ji(i)??Y(t.normalized||t.value)}case "identifier":if(t.value.startsWith("@"))return Re(t.value);if(t.value.startsWith(":")||t.value.startsWith("$"))return be(t.value);let e=t.value.toLowerCase();return Oe(e)?be(e):{type:"expression",raw:t.value};case "url":{let r=Y(t.value,"string");return t.value.includes("${")?{...r,interpolates:true}:r}default:return null}}function Dl(t){if(t.startsWith('"')||t.startsWith("'")||t.startsWith("`")||t.startsWith("\u300C")){let i=t.slice(1,-1);return Y(i,"string")}if(t==="true")return Y(true,"boolean");if(t==="false")return Y(false,"boolean");let e=t.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let i=parseFloat(e[1]);return e[2]?Y(t,"duration"):Y(i,"number")}let r=parseFloat(t);return isNaN(r)?Y(t,"string"):Y(r,"number")}var _r=.8,Bl=.6,Tl=.15,Fl=.5,fi=.15,hi=.1,yi=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"]),Ol={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"]},Rl=class{calculate(t){return this.calculateWithBreakdown(t).final}calculateWithBreakdown(t){let e=this.scoreRoleCoverage(t),r=this.scoreStemPenalty(t),i=this.scoreLanguageBoost(t),n=this.scoreLanguageAdjustment(t),a=e;return a=Math.max(Fl,a+r),a=Math.min(1,a+i),a=Math.max(0,Math.min(1,a+n)),{roleCoverage:e,stemPenalty:r,languageBoost:i,languageAdjustment:n,final:a}}scoreRoleCoverage(t){let{pattern:e,captured:r}=t,i=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0,o=e.command==="on"?e.extraction?.action?.value:void 0,s=ue[o??e.command]?.roles,u=l=>s?.find(c=>c.role===l)?.valueShape!==void 0;for(let l of e.template.tokens)if(l.type==="role")r.has(l.role)?(n+=1,i+=1):u(l.role)||(n+=1);else if(l.type==="group")for(let c of l.tokens)c.type==="role"&&(r.has(c.role)?(n+=_r,i+=_r):u(c.role)||(n+=_r,a(c.role)&&(i+=_r*Bl)));return n>0?i/n:1}scoreStemPenalty(t){let{stemMatchCount:e,totalKeywordMatches:r}=t;return e<=0||r<=0?0:-(e/r)*Tl}scoreLanguageBoost(t){let{pattern:e}=t;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:yi.has(r.value)||r.alternatives?.some(i=>yi.has(i))?fi:0}scoreLanguageAdjustment(t){let{pattern:e,captured:r}=t;if(e.language!=="ar")return 0;let i=0;for(let[n,a]of r.entries()){let o=Ol[n];if(!o||o.length===0)continue;let s="metadata"in a?a.metadata:void 0;s&&typeof s.prepositionValue=="string"&&(o.includes(s.prepositionValue)?i+=.1:i-=.1);}return Math.max(-hi,Math.min(hi,i))}},Pl=new Rl,Ll=new Set(Object.values(ue).filter(t=>t.bareKeyword===true).map(t=>t.action));function Nl(t){return t.startsWith("*")||t.startsWith("@")}var ie=class ${constructor(e){this.patternRest=[],this.slotAfterLiteral=false,this.wouldMatch=(r,i)=>this.patternTokenWouldMatch(r,i),this.matchCache=new Map,this.roleStarts=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Pl;}matchPattern(e,r){let i=e.mark(),n=new Map;if(this.currentProfile=O(r.language),this.currentPatternCommand=r.command,this.currentRoleCommand=r.extraction?.action?.value??r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,this.roleStarts=new Map,this.eventSource=void 0,this.patternRest=[],!this.matchTokenSequence(e,r.template.tokens,n))return e.reset(i),null;let o=this.confidenceModel.calculate({pattern:r,captured:n,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-i.position,confidence:o,roleStarts:this.roleStarts,...this.eventSource?{eventSource:this.eventSource}:{}}}matchBest(e,r){this.matchCache.clear();let i=[],n=e.position();for(let o of r){let s=e.mark(),u=`${n}:${o.id}`,l;this.matchCache.has(u)?l=this.matchCache.get(u):(l=this.matchPattern(e,o),this.matchCache.set(u,l)),l&&i.push(l),e.reset(s);}if(i.length===0)return null;i.sort((o,s)=>{let u=s.pattern.priority-o.pattern.priority;return u!==0?u:s.confidence-o.confidence});let a=i[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,i,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let s=0;for(let u=0;u<r.length;u++){let l=r[u];if(s>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,i,l),il(l,e.peek(),r[u+1]??n,this.wouldMatch)){let m=e.mark(),p=new Map(i);if(this.matchTokenSequence(e,r.slice(u+1),p,n)&&this.atClauseEnd(e)){i.clear();for(let[f,h]of p)i.set(f,h);return true}e.reset(m);}let c=this.patternRest;this.patternRest=[...r.slice(u+1),...c],this.slotAfterLiteral=l.type==="role"&&r[u-1]?.type==="literal";let d=this.matchPatternToken(e,l,i,r[u+1]??n);if(this.patternRest=c,s=l.type==="role"&&l.role==="event"?2:Math.max(0,s-1),!d){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,i){if(r.has("source")||this.eventSource)return;let n=e.peek(),a=e.peek(1);if(!n||!a||this.patternTokenWouldMatch(i,n))return;let o=this.currentProfile?.roleMarkers?.source,s=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let c=l.value.toLowerCase();return o.primary?.toLowerCase()===c?true:!!o.alternatives?.some(d=>d.toLowerCase()===c)},u=o?.position;if(u!=="after"&&s(n)){let l=this.sourceNounValue(a);if(!l)return;e.advance(),e.advance(),this.eventSource=l;return}if(u==="after"&&s(a)){let l=this.sourceNounValue(n);if(!l)return;e.advance(),e.advance(),this.eventSource=l;}}sourceNounValue(e){if(e.kind==="selector")return this.tokenToSemanticValue(e)??void 0;if(e.kind!=="keyword"&&e.kind!=="identifier")return;let r=(e.normalized??e.value).toLowerCase();if(r!=="me"){if(Oe(r))return {type:"reference",value:r};if(e.kind==="identifier"&&/^[A-Za-z_$][\w$]*$/.test(e.value))return {type:"expression",raw:e.value}}}matchPatternToken(e,r,i,n){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":{let a=e.position(),o=this.matchRoleToken(e,r,i,n);return o&&i.has(r.role)&&this.roleStarts.set(r.role,a),o}case "group":return this.matchGroupToken(e,r,i,n);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(!i)return false;let n=this.getMatchType(i,r.value);if(n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(i,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let a of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(a.includes(o)&&this.tryMatchShatteredCompound(e,a,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let i=e.mark(),n=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;n.push(o.value),e.advance();let s=e.peek();if(!s||s.value!=="-")break;e.advance(),n.push("-");}if(n.length<3||n[n.length-1]==="-")return e.reset(i),null;let a=n.join("").toLowerCase();for(let[o,s]of Object.entries(r.keywords))if(s.primary.toLowerCase()===a||s.alternatives?.some(u=>u.toLowerCase()===a))return Y(o);return e.reset(i),null}tryMatchShatteredCompound(e,r,i){let n=r.split(i);if(n.length<2||n.some(o=>o.length===0))return false;let a=e.mark();for(let o=0;o<n.length;o++){if(o>0){let u=e.peek();if(!u||u.value!==i)return e.reset(a),false;e.advance();}let s=e.peek();if(!s||s.kind!=="identifier"&&s.kind!=="keyword"&&s.kind!=="particle"||s.value.toLowerCase()!==n[o].toLowerCase())return e.reset(a),false;e.advance();}return true}matchRoleToken(e,r,i,n){let a=e.position(),o=i.get(r.role);return this.matchRoleTokenCore(e,r,i,n)?(this.absorbTrailingConversion(e,r,i,n,a),this.absorbTrailingConditionOperand(e,r,i,n,a),this.absorbExpressionTail(e,r,i,n,a),this.stampCaptureSpan(e,r.role,i,a,o),true):false}absorbExpressionTail(e,r,i,n,a){if(r.role==="event"||r.role==="action"||this.isClassNameSlot(r)||!i.has(r.role)||e.position()<=a)return;let o=r.expectedTypes;if(o&&o.length>0&&!o.includes("expression"))return;let s=$.boundedByMarker(n)?wl(e.tokens,e.position(),this.extentContext()):kl(e.tokens,e.position(),this.currentProfile),u=bl(e.tokens,a,s,this.currentProfile);if(u){for(;e.position()<u.end;)e.advance();i.set(r.role,{type:"expression",raw:u.raw,value:u.raw});}}extentContext(){let e=this.restLiterals();return {profile:this.currentProfile,owes:r=>e.some(i=>this.patternTokenWouldMatch(i,r)),commandMarkers:this.commandMarkers(),hasResponseType:!!this.currentSchema()?.roles.some(r=>r.role==="responseType")}}isClassNameSlot(e){return e.role==="patient"&&["add","remove","toggle","take"].includes(this.currentRoleCommand??"")}isObjectValueSlot(e){let r=this.currentRoleCommand;return e.role==="source"?r==="get":e.role==="patient"&&(r==="put"||r==="set")}static boundedByMarker(e){return !e||e.type==="literal"?true:e.type==="group"?e.tokens[0]?.type==="literal":false}restLiterals(){let e=[],r=i=>{for(let n of i)n.type==="literal"?e.push(n):n.type==="group"&&r(n.tokens);};return r(this.patternRest),e}currentSchema(){let e=this.currentRoleCommand;if(!(!e||!(e in ue)))return ue[e]}commandMarkers(){let e=this.currentSchema(),r=this.currentProfile,i=new Set;if(!e||!r)return i;for(let n of e.roles){let a=n.markerOverride?.[r.code];if(a){i.add(a.toLowerCase());continue}let o=r.roleMarkers[n.role];if(o){i.add(o.primary.toLowerCase());for(let s of o.alternatives??[])i.add(s.toLowerCase());}}return i.delete(""),i}stampCaptureSpan(e,r,i,n,a){let o=i.get(r);if(!o||o===a||o.position||e.position()<=n)return;let s=e.tokens[n],u=e.tokens[e.position()-1];!s||!u||i.set(r,Qi(o,{start:s.position.start,end:u.position.end}));}absorbTrailingConditionOperand(e,r,i,n,a){if(r.role!=="condition"||!i.has("condition")||e.position()<=a)return;let o=this.currentPatternCommand==="repeat";if(!o&&(n!==void 0||this.currentPatternCommand!=="on"))return;let s=$.CONDITION_OPERATOR_WORDS,u=m=>{let p=(m.normalized??"").toLowerCase(),f=m.value.toLowerCase();if(s.has(p)||s.has(f))return true;let h=$.LOOP_CONDITION_OPERATORS;return o&&(h.has(f)||h.has(p))},l=m=>!!m&&(m.kind==="selector"||m.kind==="identifier"||m.kind==="literal")&&!u(m)&&!lr.has((m.normalized??m.value).toLowerCase())&&!this.patternTokenWouldMatch(n,m),c=false;for(;;){let m=e.peek();if(!m||!u(m)||this.patternTokenWouldMatch(n,m))break;e.advance(),c=true;let p=e.peek();if(l(p)){e.advance();for(let f=e.peek();!(!f||!/^\.[a-zA-Z_]\w*$/.test(f.value)||f.position.start!==p.position.end);f=e.peek())e.advance(),p=f;}if(!o)break}if(!c)return;let d=Te(e.tokens.slice(a,e.position()),this.currentProfile);i.set("condition",{type:"expression",raw:d,value:d});}conversionRunLength(e){let r=e.peek();if(!r||(r.normalized??r.value).toLowerCase()!=="as"&&r.value.toLowerCase()!=="as")return 0;let n=this.conversionTypeLength(e,1);if(n===0)return 0;for(n+=1;;){if(e.peek(n)?.value!=="|")return n;let a=this.conversionTypeLength(e,n+1);if(a===0)return n;n+=1+a;}}conversionTypeLength(e,r){let i=e.peek(r)?.value.toLowerCase(),n=i==="a"||i==="an"?r+1:r,a=e.peek(n);if(!a)return 0;let o=e.peek(n+1),s=e.peek(n+2);return o?.value===":"&&s&&Er(a,o)&&Er(o,s)&&kr(`${a.value}:${s.value}`)?n-r+3:kr(a.value)?n-r+1:0}absorbTrailingConversion(e,r,i,n,a){if(r.role==="event"||r.role==="action"||!i.has(r.role)||e.position()<=a)return;let o=this.conversionRunLength(e);if(o===0||this.patternTokenWouldMatch(n,e.peek()))return;for(let u=0;u<o;u++)e.advance();let s=Te(e.tokens.slice(a,e.position()),this.currentProfile);i.set(r.role,{type:"expression",raw:s,value:s});}matchRoleTokenCore(e,r,i,n){this.skipNoiseWords(e,r,n);let a=e.peek();if(!a)return r.optional||false;let o=this.slotAt(e,r,n);if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let g=this.tryFoldHyphenActionKeyword(e);if(g)return i.set(r.role,g),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!$.tokenLooksLikeEvent(a))return r.optional||false;let g=(a.normalized??a.value).toLowerCase();if($.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||$.VISIBILITY_STRATEGIES.has(g)||this.currentProfile&&(De(this.currentProfile,a.value)??De(this.currentProfile,g))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let g=(a.normalized??a.value).toLowerCase();if($.STRUCTURAL_NEVER_EVENT.has(g))return r.optional||false}if(Qu(o,this.currentProfile?.code??"")||rl(o,this.currentPatternCommand))return r.optional||false;if(r.role==="duration"){let g=(a.normalized??a.value).toLowerCase();if($.POSITIONAL_OR_SCOPE_KEYWORDS.has(g))return r.optional||false}if(tl(o))return true;if(this.roleAcceptsPropertyPath(r)){let g=this.tryMatchPositionalPossessiveExpression(e,n);if(g)return i.set(r.role,g),true}let s=this.tryMatchPositionalExpression(e,n);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!Nr(s.type,r.expectedTypes)?r.optional||false:(i.set(r.role,s),true);let u=this.tryMatchCaretScopeExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Nr(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);let l=this.tryMatchParenReceiverCall(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,l),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let g=this.tryMatchBeepPrefixExpression(e);if(g)return i.set(r.role,g),true;let A=this.tryMatchHyphenatedWord(e);if(A)return i.set(r.role,A),true;let b=this.isWrittenTarget(r)?null:this.tryMatchOperatorRunExpression(e);if(b)return i.set(r.role,b),true}if(this.currentPatternCommand==="pick"&&r.role==="patient"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let g=this.tryMatchPickRangeExpression(e);if(g)return i.set(r.role,g),true}if(this.roleAcceptsPropertyPath(r)){let g=this.tryMatchOfPossessiveExpression(e,n);if(g)return i.set(r.role,g),true;let A=this.tryMatchPostNominalPossessiveExpression(e);if(A)return i.set(r.role,A),true}let c=this.tryMatchPossessiveExpression(e);if(c)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(c.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,c),true);let d=this.tryMatchMethodCallExpression(e);if(d)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(d.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,d),true);let p=r.role==="event"&&this.currentPatternCommand==="on"||$.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")||this.isWrittenTarget(r)?null:this.tryMatchBareCallExpression(e);if(p)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(p.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,p),true);let f=this.tryMatchPossessiveSelectorExpression(e);if(f)return r.expectedTypes&&r.expectedTypes.length>0&&!Nr(f.type,r.expectedTypes)?r.optional||false:(i.set(r.role,f),true);let h=r.role!=="condition",v=this.tryMatchPropertyAccessExpression(e,h);if(v)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(v.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,v),true);let y=this.tryMatchSelectorPropertyExpression(e);if(y)return r.expectedTypes&&r.expectedTypes.length>0&&!Nr(y.type,r.expectedTypes)?r.optional||false:(i.set(r.role,y),true);if(a.value==="("&&r.role!=="event"&&r.role!=="action"&&(!r.expectedTypes?.length||r.expectedTypes.some(g=>g==="expression"||g==="selector"||g==="reference"))){let g=this.tryMatchParenGroupExpression(e);if(g)return i.set(r.role,g),true}if(a.kind==="identifier"&&a.value==="{"){let g=r.expectedTypes,b=g?.length===1&&g[0]==="expression"||this.isObjectValueSlot(r)?this.tryMatchBraceRunExpression(e):!g?.length||g.includes("literal")?this.tryMatchBraceRunLiteral(e):null;if(b)return i.set(r.role,b),true}if(r.role==="style"&&r.expectedTypes?.length===1&&r.expectedTypes[0]==="expression"){let g=gr(e);if(g)return i.set(r.role,{type:"expression",raw:g}),true}if(ol(o)||sl(o,this.currentSchema())||el(o,this.currentProfile?.code??""))return i.set(r.role,{type:"expression",raw:a.value}),e.advance(),true;let E=this.tokenToSemanticValue(a);if(!E)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(E.type)){let g=E.type==="selector"&&String(E.value).startsWith("@"),A=r.expectedTypes.some(b=>b==="expression"||b==="reference");if(!(g&&A))return r.optional||false}r.valueShape==="keyword"&&E.type==="expression"?i.set(r.role,Y(String(E.raw??""))):i.set(r.role,E),e.advance();let z=this.isClassNameSlot(r);if(E.type==="selector"&&(E.value.startsWith("<")||E.value.startsWith(".")&&!z)&&r.role!=="event"){let g=sn(e.tokens,e.position(),this.currentProfile,A=>A===void 0?false:this.patternTokenWouldMatch(n,A));if(g){let[A,b]=g.scope.parts,S=g.scope.kind==="reference"?be(A.text):g.scope.kind==="closest"?{type:"expression",raw:`closest ${b.text}`}:this.tokenToSemanticValue(A.token);for(let D=0;D<1+g.scope.consumed;D++)e.advance();i.set(r.role,{...E,scope:S});}}if(r.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&g.position.start===a.position.end&&"value"in E&&(i.set(r.role,Y(`${String(E.value)}${g.value}`)),e.advance());let A=e.peek();if(A&&(A.kind==="particle"||A.kind==="keyword")&&(A.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(n,A)){let b=e.peek(1),S=b?this.sourceNounValue(b):void 0;S&&!this.eventSource&&(e.advance(),e.advance(),this.eventSource=S);}}return true}atClauseEnd(e){let r=e.peek();if(!r||r.kind==="conjunction")return true;if(r.kind!=="keyword")return false;let i=(r.normalized??r.value).toLowerCase();return i==="then"||i==="end"?true:Gr(r.value,this.currentProfile?.code??"")}patternTokenWouldMatch(e,r){return e?e.type==="literal"?this.getMatchType(r,e.value)!=="none"?true:!!e.alternatives?.some(i=>this.getMatchType(r,i)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],r):false:false}tryMatchPositionalExpression(e,r){let i=wr(e.tokens,e.position(),this.currentProfile,n=>n===void 0?false:this.patternTokenWouldMatch(r,n));if(!i)return null;for(let n=0;n<i.consumed;n++)e.advance();return {type:"expression",raw:i.parts.map(n=>n.text).join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let i=e.peek(1),n=e.peek(2),a=(i?.normalized??"").toLowerCase(),o=!!i&&(i.value.toLowerCase()==="on"||a==="destination"||a==="on");return !i||!n||n.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${n.value}`})}isOfPossessiveMarker(e){return Ve(this.currentProfile,e)}logicalConnectiveOf(e){let r=e.peek();if(!r)return;let i=this.currentProfile?.code??"en",n=u=>u==="and"||u==="or"||u==="not",a=He(i,r.value).toLowerCase();if(n(a))return a;if(this.commandMarkers().has(r.value.toLowerCase()))return;let o=e.position(),s=Iu(i,r,e.tokens[o-1],e.tokens[o+1]);return s&&n(s)?s:void 0}tryConsumeRunPhrase(e){let r=this.currentProfile?.code??"en",i=e.tokens,n=e.position(),a=[],o;for(let s=0;s<6&&n+s<i.length;s++){let u=i[n+s],l=or(r,u,i[n+s-1],i[n+s+1],o).toLowerCase();a.push(l),o=l;}for(let[s,u]of $.RUN_PHRASES)if(s.every((l,c)=>a[c]===l)){for(let l=0;l<s.length;l++)e.advance();return u}}slotAt(e,r,i){return new Xu(e,r,this.slotAfterLiteral,i,this.wouldMatch)}static isBareWordToken(e){return !!e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.value)}tryMatchBeepPrefixExpression(e){let r=e.peek(),i=e.peek(1);if(!r||!i||i.value!=="!"||(r.normalized??r.value).toLowerCase()!=="beep"||!(r.position?.end!==void 0&&i.position?.start!==void 0&&r.position.end===i.position.start))return null;let a=e.mark(),o=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(a),null;for(;;){let u=e.peek();if(!u||!$e.has(u.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e,true)){e.reset(l);break}}let s=Te(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:s,value:s}}tryMatchHyphenatedWord(e){let r=e.peek();if(!$.isBareWordToken(r))return null;let i=1,n=[r.value];for(;;){let a=e.peek(i),o=e.peek(i+1);if(!a||a.value!=="-"||!$.isBareWordToken(o)||!Er(e.peek(i-1),a)||!Er(a,o))break;n.push(o.value),i+=2;}if(n.length<2)return null;for(let a=0;a<i;a++)e.advance();return Y(n.join("-"),"string")}tryMatchOperatorRunExpression(e){let r=e.mark(),i=e.position(),n=e.peek(),a=!!n&&(this.logicalConnectiveOf(e)==="not"||n.value==="-");if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let o=1;for(;;){let u=e.peek();if(!u)break;let l=this.logicalConnectiveOf(e),c=(l==="and"||l==="or")&&this.currentRoleCommand!=="wait",d=e.mark();if(c||$e.has(u.value))e.advance();else {let m=this.tryConsumeRunPhrase(e);if(m===void 0)break;if(m==="none"){o++;continue}}if(!this.tryConsumeRunOperand(e,true,c)){e.reset(d);break}o++;}if(o<2&&!a)return e.reset(r),null;let s=Te(e.tokens.slice(i,e.position()),this.currentProfile);return {type:"expression",raw:s,value:s}}static rangeSeparatorFor(e){let[r]=$.PICK_RANGE_SEPARATORS_BY_LANG[e]??[];return r}isPickRangeSeparator(e){let r=(e.normalized??e.value).toLowerCase();if($.PICK_RANGE_SEPARATORS.has(r))return true;let i=this.currentProfile?.code;return i?$.PICK_RANGE_SEPARATORS_BY_LANG[i]?.has(e.value.toLowerCase())??false:false}tryMatchPickRangeExpression(e){let r=e.mark(),i=e.position();if(!this.tryConsumePickRangeOperand(e))return e.reset(r),null;let n=e.peek();if(!n||!this.isPickRangeSeparator(n)||(e.advance(),!this.tryConsumePickRangeOperand(e)))return e.reset(r),null;let a=e.peek();a&&$.PICK_RANGE_MODES.has((a.normalized??a.value).toLowerCase())&&e.advance();let o=e.tokens.slice(i,e.position()),[s,,u,l]=o,c=m=>m.kind==="keyword"?m.normalized??m.value:m.value,d=`${c(s)} to ${c(u)}`;return l&&(d+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:d,value:d}}tryConsumePickRangeOperand(e){let r=e.peek();if(!r)return false;let i=(r.normalized??r.value).toLowerCase();if(this.isPickRangeSeparator(r))return false;let n=i==="start"||i==="end";return r.kind==="literal"||r.kind==="identifier"||r.kind==="keyword"&&n?(e.advance(),true):false}tryConsumeRunOperand(e,r=false,i=false){let n=e.peek();if(!n)return false;if(this.logicalConnectiveOf(e)==="not"){let o=e.mark();return e.advance(),al(e.peek()??void 0,e.peek(1)??void 0)?(e.reset(o),false):this.tryConsumeRunOperand(e,true,i)?true:(e.reset(o),false)}if(n.value==="-"){let o=e.mark();return e.advance(),this.tryConsumeRunOperand(e,true,i)?true:(e.reset(o),false)}if(i&&nl(n))return false;if(ll(n,r,e.peek(1)??void 0))return e.advance(),true;if(n.value==="("){let o=e.mark(),s=0;for(;!e.isAtEnd();){let u=e.advance();if(u.value==="(")s++;else if(u.value===")"&&(s--,s===0))return true}return e.reset(o),false}if(this.tryMatchPossessiveExpression(e))return true;if(n.value.toLowerCase()==="the"){let o=e.mark();if(e.advance(),this.tryConsumeRunOperand(e,r,i))return true;e.reset(o);}if(this.tryMatchOfPossessiveExpression(e)||this.tryMatchPossessiveSelectorExpression(e)||this.tryMatchPropertyAccessExpression(e,true)||this.tryMatchSelectorPropertyExpression(e))return true;let a=(n.normalized??"").toLowerCase();return (n.kind==="literal"||n.kind==="identifier"||n.kind==="selector"||n.kind==="keyword")&&!$e.has(n.value)&&!["then","else"].includes(a)&&(a!=="end"||this.endWordIsValueAt(e))&&n.value!==")"?(e.advance(),true):false}endWordIsValueAt(e){return Ne(ye(e.tokens,e.position()),this.currentProfile?.code??"")}isPossessorToken(e){if(!this.currentProfile)return false;for(let r of [e.value,e.normalized].filter(Boolean))if(De(this.currentProfile,r)??De(this.currentProfile,r.toLowerCase()))return true;return false}isBareWordPropertyHead(e){return e.kind!=="identifier"||/^[$:@#.*]/.test(e.value)||this.isStructuralKeyword(e.value)||e.normalized&&this.isStructuralKeyword(e.normalized)||e.normalized&&this.isRoleMarkerConcept(e.normalized)?false:!this.isPossessorToken(e)}toEnglishProperty(e){return this.currentProfile?he(this.currentProfile.code,e):e}roleAcceptsPropertyPath(e){if(e.type!=="role")return false;if(e.expectedTypes)return e.expectedTypes.includes("property-path");let r=this.currentRoleCommand;return r?ue[r]?.roles.find(a=>a.role===e.role)?.expectedTypes?.includes("property-path")??false:false}tryMatchOfPossessiveExpression(e,r){let i=e.peek();if(!i||!(i.kind==="selector"?/^[*@]/.test(i.value):this.isBareWordPropertyHead(i)))return null;let a=e.position(),o=e.mark();e.advance();let s=e.peek();if(!s||!this.isOfPossessiveMarker(s))return e.reset(o),null;e.advance(),e.peek()?.value.toLowerCase()==="the"&&e.advance();let u=wr(e.tokens,e.position(),this.currentProfile,c=>c===void 0?false:this.patternTokenWouldMatch(r,c));if(u){for(let c=0;c<u.consumed;c++)e.advance();return Le({type:"expression",raw:u.parts.map(c=>c.text).join(" ")},this.toEnglishProperty(i.value),"possessive")}let l=e.peek();if(!l||l.kind!=="selector"||Nl(l.value)){if(e.reset(o),this.patternTokenWouldMatch(r,s))return null;let c=this.currentProfile?.code??"en",d=hn(e.tokens,a,this.currentProfile,c);if(d===void 0)return null;for(;e.position()<=d;)e.advance();let m=Te(e.tokens.slice(a,d+1),this.currentProfile);return {type:"expression",raw:m,value:m}}return e.advance(),Le(Re(l.value),this.toEnglishProperty(i.value),"possessive")}tryMatchPositionalPossessiveExpression(e,r){let i=this.currentProfile,n=i?.possessive?.marker;if(!i||!n||i.possessive?.markerPosition!=="between"||i.code==="th")return null;let a=wr(e.tokens,e.position(),i,l=>l===void 0?false:this.patternTokenWouldMatch(r,l));if(!a)return null;let o=e.peek(a.consumed),s=e.peek(a.consumed+1);if(!o||o.value!==n)return null;let u=!!s&&(this.isBareWordPropertyHead(s)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="keyword"&&ti(i.code,s.value));if(!s||!u)return null;for(let l=0;l<a.consumed+2;l++)e.advance();return Le({type:"expression",raw:a.parts.map(l=>l.text).join(" ")},this.toEnglishProperty(s.value),"possessive")}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=[r.value,r.normalized].filter(Boolean),n;for(let u of i)if(n=De(this.currentProfile,u)??De(this.currentProfile,u.toLowerCase()),n)break;if(!n)return null;let a=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let u=e.peek();if(u){let l=u.value.toLowerCase(),c=(u.normalized??"").toLowerCase();o.some(d=>d.toLowerCase()===l||d.toLowerCase()===c)&&e.advance();}}let s=e.peek();if(!s||Cl(this.currentProfile.code,s.value))return e.reset(a),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)&&!(s.normalized&&this.isStructuralKeyword(s.normalized))&&!(s.normalized&&this.isRoleMarkerConcept(s.normalized))&&!(s.normalized&&$.COMMAND_ACTION_KEYWORDS.has(s.normalized.toLowerCase()))||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)),u=this.toEnglishProperty(u);let l=u;for(;;){let d=e.peek();if(d?.kind==="selector"&&d.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(d.value)){l+=d.value,e.advance();continue}if(d?.value==="?"){let m=e.peek(1);if(m?.kind==="selector"&&m.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(m.value)){l+=`?${m.value}`,e.advance(),e.advance();continue}}break}let c=e.peek();if(c&&c.value.startsWith("(")){let d="",m=0,p=0;for(;!e.isAtEnd()&&p++<$.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;d+=f.value,e.advance();for(let h of f.value)h==="("?m++:h===")"&&m--;if(m<=0)break}l+=d;}return Le(be(n),l,"possessive")}return e.reset(a),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=e.peek();if(!r)return null;let i=r.kind==="selector"&&r.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(r.value);if(!(r.kind==="identifier"&&!this.isStructuralKeyword(r.value)&&!(r.normalized&&this.isStructuralKeyword(r.normalized))&&!(r.normalized&&this.isRoleMarkerConcept(r.normalized))||r.kind==="selector"&&(r.value.startsWith("*")||r.value.startsWith("@"))||i)||this.isPossessorToken(r))return null;let a=e.mark(),o=r.value;i&&(o=o.substring(1)),e.advance(),o=this.toEnglishProperty(o);let s=o;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)s+=e.peek().value,e.advance();let u=e.peek();if(!u)return e.reset(a),null;let l;for(let d of [u.value,u.normalized].filter(Boolean))if(l=De(this.currentProfile,d)??De(this.currentProfile,d.toLowerCase()),l)break;if(!l)return e.reset(a),null;let c=e.mark();return this.tryMatchPossessiveExpression(e)?(e.reset(a),null):(e.reset(c),e.advance(),Le(be(l),s,"possessive"))}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())}isRoleMarkerConcept(e){return Cr.has(e.toLowerCase())}static tokenLooksLikeEvent(e){if(e.kind==="selector"||e.kind==="url"||e.kind==="literal")return false;let r=e.value;if(/[/#@*]/.test(r)||r.startsWith('"')||r.startsWith("'")||r.startsWith("`"))return false;let i=e.normalized?.toLowerCase();return !(i&&Ll.has(i)||i==="me"||i==="it"||i==="you")}tryMatchBraceRunLiteral(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let i=e.mark();e.advance();let n=["{"],a=1,o=0;for(;!e.isAtEnd()&&o++<$.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(s.value==="{")a++;else if(s.value==="}"&&(a--,a===0))return n.push("}"),Y(n.join(" "));n.push(s.value);}return e.reset(i),null}tryMatchBraceRunExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let i=e.mark(),n="",a=-1,o=0,s=0;for(;!e.isAtEnd()&&s++<$.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(a>=0&&u.position.start>a&&(n+=" ".repeat(u.position.start-a)),n+=u.value,a=u.position.end,u.value==="{")o++;else if(u.value==="}"&&(o--,o===0))return {type:"expression",raw:n}}return e.reset(i),null}tryMatchBareCallExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(r.value))return null;let i=e.peek(1);if(!i||i.value!=="(")return null;let n=e.mark();e.advance();let a=e.advance(),o="",s=a.position?.end,u=false,l=0;for(;!e.isAtEnd()&&l++<$.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),u=true;break}let d=s!==void 0&&c.position?.start===s;o+=(o===""||d?"":" ")+c.value,s=c.position?.end,e.advance();}return u?{type:"expression",raw:`${r.value}(${o})`}:(e.reset(n),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(i),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<$.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}s.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${s.join(", ")})`}}tryMatchParenReceiverCall(e){if(e.peek()?.value!=="(")return null;let r=e.mark(),i=[];e.advance();let n=1;for(;!e.isAtEnd()&&i.length<=$.MAX_METHOD_ARGS*4;){let c=e.peek();if(e.advance(),c.value==="(")n++;else if(c.value===")"&&--n===0)break;i.push(c);}let a=e.tokens[e.position()-1],o=e.peek();if(n!==0||i.length===0||!o||o.kind!=="selector"||!/^\.[A-Za-z_$][\w$]*$/.test(o.value)||!$.abuts(a,o))return e.reset(r),null;e.advance();let s=e.peek();if(s?.value!=="("||!$.abuts(o,s))return e.reset(r),null;let u=this.consumeCallParens(e);return u===null?(e.reset(r),null):{type:"expression",raw:`(${Te(i,this.currentProfile)})${o.value}${u}`}}tryMatchParenGroupExpression(e){if(e.peek()?.value!=="(")return null;let r=e.mark();e.advance();let i=[],n=1;for(;!e.isAtEnd();){let l=e.peek();if(e.advance(),l.value==="(")n++;else if(l.value===")"&&--n===0)break;i.push(l);}let a=e.tokens[e.position()-1],o=e.peek(),s=!!o&&(o.value==="'"||$e.has(o.value)||$.abuts(a,o)&&(o.value.startsWith(".")||o.value==="("));if(n!==0||i.length===0||s)return e.reset(r),null;let u=`(${Te(i,this.currentProfile)})`;return {type:"expression",raw:u,value:u}}static abuts(e,r){return !!e&&!!r&&e.position.end===r.position.start}consumeCallParens(e){let r=e.mark(),i=[],n=0;for(;!e.isAtEnd();){let a=e.peek();if(!a)break;if(i.push(a.value),e.advance(),a.value==="(")n++;else if(a.value===")"&&--n===0)return i.join("")}return e.reset(r),null}tryMatchPropertyAccessExpression(e,r=true){let i=e.peek();if(!i||i.kind!=="identifier"&&i.kind!=="keyword")return null;let n=e.mark();e.advance();let a=i.value.toLowerCase(),o=e.peek();if((i.kind==="identifier"||$.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)&&o.position.start===i.position.end){let p=i.value,f=[],h=0;for(;h<$.MAX_PROPERTY_DEPTH;){let E=e.peek();if(E&&E.kind==="selector"&&/^\.[a-zA-Z_]/.test(E.value))p+=`.${E.value.slice(1)}`,f.push(E.value.slice(1)),e.advance(),h++;else break}let v=e.peek(),y=!!v&&v.value.startsWith("(");return r&&!y&&f.length>0&&Oe(a)?Le(be(a),f.join("."),"dot"):(y&&(p+=this.consumeCallParens(e)??""),{type:"expression",raw:p})}let s=e.peek();if(!s||s.kind!=="operator"||s.value!==".")return e.reset(n),null;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")return e.reset(n),null;e.advance();let l=`${i.value}.${u.value}`,c=1;for(;!e.isAtEnd()&&c<$.MAX_PROPERTY_DEPTH;){let p=e.peek();if(!p||p.kind!=="operator"||p.value!==".")break;e.advance();let f=e.peek();if(!f||f.kind!=="identifier")break;e.advance(),l+=`.${f.value}`,c++;}let d=e.peek();if(d&&d.kind==="punctuation"&&d.value==="("){e.advance();let p=[],f=0;for(;!e.isAtEnd()&&p.length<$.MAX_METHOD_ARGS;){let v=e.peek();if(!v)break;if(v.kind==="punctuation"&&v.value===")"){if(f===0){e.advance();break}f--;}if(v.kind==="punctuation"&&v.value==="("&&f++,v.kind==="punctuation"&&v.value===","){e.advance();continue}p.push(v.value),e.advance();}return {type:"expression",raw:`${l}(${p.join(", ")})`}}let m=i.value.toLowerCase();if(r&&Oe(m)){let p=l.split(".").slice(1).join(".");return Le(be(m),p,"dot")}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek(),a=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!n&&n.kind==="punctuation"&&n.value==="'s",s=!!n&&n.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",u=(()=>{if(!this.currentPatternCommand||(n?.normalized??"").toLowerCase()!=="source")return false;let f=ue[this.currentPatternCommand];return !!f&&f.roles.some(h=>h.role==="source")})(),l=!!n&&!!a&&a!=="'s"&&n.value===a&&(n.kind==="particle"||n.kind==="punctuation"||n.kind==="identifier")&&!u;if(!o&&!l&&!s)return e.reset(i),null;e.advance(),s&&e.advance();let c=e.peek();if(!c)return e.reset(i),null;let d=c.kind==="selector"&&c.value.startsWith("*"),m=c.kind==="keyword"&&!!this.currentProfile&&ti(this.currentProfile.code,c.value);return c.kind==="identifier"||d||m||(o||s)&&(c.kind==="selector"||c.kind==="keyword")?(e.advance(),Le(Re(r.value),this.toEnglishProperty(c.value),"possessive")):(e.reset(i),null)}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(i),null;e.advance();let a=[n.value.slice(1)],o=n;for(let u=e.peek();u&&u.kind==="selector"&&/^\.[a-zA-Z_]/.test(u.value)&&a.length<$.MAX_PROPERTY_DEPTH;u=e.peek())a.push(u.value.slice(1)),o=u,e.advance();let s=e.peek();if(s?.value==="("&&$.abuts(o,s)){let u=this.consumeCallParens(e);if(u!==null)return {type:"expression",raw:`${r.value}.${a.join(".")}${u}`}}return Le(Re(r.value),a.join("."),"dot")}matchGroupToken(e,r,i,n){let a=e.mark(),o=new Map(i),s=this.matchTokenSequence(e,r.tokens,i,n);if(s){let u=[];for(let l of r.tokens)if(l.type==="group"&&l.renderRequired)for(let c of l.tokens)c.type==="literal"&&u.push(c.value,...c.alternatives??[]);u.length>0&&[...i.keys()].some(c=>!o.has(c))&&(e.tokens.slice(a.position,e.position()).some(m=>u.some(p=>this.getMatchType(m,p)!=="none"))||(s=false));}if(!s){e.reset(a);for(let u of i.keys())o.has(u)||i.delete(u);for(let[u,l]of o)i.get(u)!==l&&i.set(u,l);return r.optional||false}return true}getMatchType(e,r){if(e.value===r)return "exact";if(e.normalized===r)return "normalized";if(e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7)return "stem";if(e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase())return "case-insensitive";if(e.kind==="keyword"){let i=Pr(e.value).toLowerCase();if(i&&i===Pr(r).toLowerCase())return "case-insensitive"}return "none"}isWrittenTarget(e){return $.WRITTEN_ROLE[this.currentRoleCommand??""]===e.role}tokenToSemanticValue(e){return jr(e)}applyExtractionRules(e,r){for(let[i,n]of Object.entries(e.extraction)){let a=r.get(i);if(a){if(n.transform){let o=a.type==="literal"?String(a.value):String(a.raw??"");r.set(i,n.transform(o));}}else n.value!==void 0?r.set(i,{type:"literal",value:n.value}):n.default&&r.set(i,{...n.default,implicit:true});}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e,r,i){let n=e.peek();if(!n)return;let a=n.value.toLowerCase();if($.ENGLISH_NOISE_WORDS.has(a)){if(Ju(this.slotAt(e,r,i)))return;let o=e.mark();e.advance();let s=e.peek();if(s&&(s.kind==="selector"||s.kind==="identifier"))return;let u=e.peek(1);if(s&&s.kind==="keyword"&&u&&u.kind==="selector"&&/^\.[a-zA-Z_]/.test(u.value))return;let l=s?(s.normalized??s.value).toLowerCase():"";if(s&&$.POSITIONAL_OR_SCOPE_KEYWORDS.has(l))return;let c=e.peek(1),d=c?(c.normalized??c.value).toLowerCase():"",m=this.currentProfile?.wordOrder!=="SOV"&&$.COMMAND_ACTION_KEYWORDS.has(d),p=!c||c.kind==="particle"||$.CLAUSE_BOUNDARY_KEYWORDS.has(d)||m;if(s&&s.kind==="keyword"&&this.currentProfile?.code!=="en"&&Oe(l)&&p||s&&s.kind==="keyword"&&this.currentProfile?.code==="en"&&Oe(l))return;e.reset(o);}a==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(i=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return i?r:void 0}};ie.CONDITION_OPERATOR_WORDS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);ie.LOOP_CONDITION_OPERATORS=new Set([...en,"and","or"]);ie.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);ie.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then","while"]);ie.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);ie.COMMAND_ACTION_KEYWORDS=lr;ie.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);ie.RUN_PHRASES=[...wt.map(t=>[t.split(" "),"none"]),...kt.map(t=>[t.split(" "),"type"]),...zt.filter(t=>!/^(in|am|has|have)$|^am /.test(t)).map(t=>[t.split(" "),"operand"]),[["exists"],"none"]];ie.PICK_RANGE_SEPARATORS=new Set(["to"]);ie.PICK_RANGE_SEPARATORS_BY_LANG={ar:new Set(["\u0625\u0644\u0649"]),bn:new Set(["\u09A5\u09C7\u0995\u09C7"]),de:new Set(["zu","bis"]),es:new Set(["a"]),fr:new Set(["\xE0"]),he:new Set(["\u05E2\u05DC","\u05E2\u05D3"]),hi:new Set(["\u0938\u0947"]),id:new Set(["ke"]),it:new Set(["in","a"]),ja:new Set(["\u304B\u3089"]),ko:new Set(["\uBD80\uD130"]),ms:new Set(["ke"]),pl:new Set(["do"]),pt:new Set(["para","a"]),qu:new Set(["kama"]),ru:new Set(["\u0432","\u0434\u043E"]),sw:new Set(["kwa","hadi"]),th:new Set(["\u0E43\u0E19","\u0E16\u0E36\u0E07"]),tl:new Set(["sa"]),tr:new Set(["ile"]),uk:new Set(["\u0432","\u0434\u043E"]),vi:new Set(["v\xE0o","\u0111\u1EBFn"]),zh:new Set(["\u5230"])};ie.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);ie.VISIBILITY_STRATEGIES=new Set(["display","visibility","opacity","twdisplay","twvisibility","twopacity"]);ie.MAX_BRACE_RUN_TOKENS=64;ie.MAX_PROPERTY_DEPTH=10;ie.MAX_METHOD_ARGS=20;ie.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);ie.WRITTEN_ROLE={increment:"patient",decrement:"patient",set:"destination"};ie.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var xn=ie,ke=new xn;function Z(t,e){return Vs(t,e)}function Dn(){return js()}var Wr={ar:new Set(["\u0623\u0648"]),bn:new Set(["\u0985\u09A5\u09AC\u09BE"]),de:new Set(["oder"]),en:new Set(["or"]),es:new Set(["o"]),fr:new Set(["ou"]),he:new Set(["\u05D0\u05D5"]),hi:new Set(["\u092F\u093E"]),id:new Set(["atau"]),it:new Set(["o"]),ja:new Set(["\u307E\u305F\u306F"]),ko:new Set(["\uB610\uB294"]),ms:new Set(["atau"]),pl:new Set(["lub"]),pt:new Set(["ou"]),qu:new Set(["utaq"]),ru:new Set(["\u0438\u043B\u0438"]),sw:new Set(["au"]),th:new Set(["\u0E2B\u0E23\u0E37\u0E2D"]),tl:new Set(["o"]),tr:new Set(["veya"]),uk:new Set(["\u0430\u0431\u043E"]),vi:new Set(["ho\u1EB7c"]),zh:new Set(["\u6216"])},_l=new Set(Object.values(Wr).flatMap(t=>[...t]));function Vr(t,e){let r=(t.normalized??t.value).toLowerCase();if(r==="or")return true;let i=e===void 0?_l:Wr[e];return i?i.has(t.value)||i.has(r):false}var Bn=["if","unless","repeat","for","while"],Zr=/^[A-Z][A-Za-z0-9_]*$/;function Q(t,e){let r=new Set([e]),n=O(t)?.keywords?.[e];if(n){n.primary&&r.add(n.primary.toLowerCase());for(let a of n.alternatives??[])r.add(a.toLowerCase());}return r}function V(t,e){return e.has(t.value.toLowerCase())?true:t.normalized?e.has(t.normalized.toLowerCase()):false}var Ml=new Set(Bn);function Ar(t){return {byAction:Bn.map(e=>[e,Q(t,e)]),elseForms:Q(t,"else"),inForms:Q(t,"in")}}function vi(t,e){if(!t)return;let r=t.normalized?.toLowerCase();return r?Ml.has(r)?r:void 0:e.byAction.find(([,i])=>V(t,i))?.[0]}function Sr(t,e,r){let i=t[e],n=vi(i,r);if(!n||n==="while")return false;let a=t[e-1];if(n==="for"){if(vi(a,r)==="repeat")return false;if(i.value.toLowerCase()==="for"){let o=t[e+2];return !!o&&(V(o,r.inForms)||o.normalized==="in")}}return !(n==="if"&&a&&V(a,r.elseForms))}var Ei=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Il=new Set(["destination","source","style","patient","on","from","to"]);function ir(t){if(!t||t.kind==="selector")return false;let e=(t.normalized??t.value).toLowerCase(),r=t.value.toLowerCase();return !(Ei.has(e)||Ei.has(r)||Il.has(e))}var $l=t=>Object.prototype.hasOwnProperty.call(ue,t);function Tn(t){return t.flatMap(e=>e.type==="literal"?[e.value,...e.alternatives??[]].map(r=>r.toLowerCase()):e.type==="group"?Tn(e.tokens):[])}var jl=new Set(["toggle","trigger"]);function Fn(t){return t.flatMap((e,r)=>{if(e.type==="group")return Fn(e.tokens);if(e.type!=="literal")return [];let i=t[r+1];return [{words:[e.value,...e.alternatives??[]].map(n=>n.toLowerCase()),role:i?.type==="role"?i.role:void 0}]})}function Vl(t,e,r,i){return t.some((n,a)=>{if(!n.words.includes(e)||!n.role||!i.has(n.role))return false;let o=0;for(let s of r){let u=t.findIndex((l,c)=>c>=o&&c<a&&l.words.includes(s));if(u<0)return false;o=u+1;}return true})}function Wl(t,e,r,i,n){let a=t[r].value.toLowerCase();for(let o=r-1;o>e;o--){let s=t[o];if(n(s)||s.value.toLowerCase()===a)return false;let u=(s.normalized??s.value).toLowerCase();if(!$l(u))continue;let l=me(i).filter(d=>d.command===u);if(jl.has(u))return l.some(d=>Tn(d.template.tokens).includes(a));let c=new Set((ue[u]?.roles??[]).filter(d=>d.required).map(d=>d.role));return l.some(d=>{let m=Fn(d.template.tokens),p=new Set(m.flatMap(h=>h.words)),f=t.slice(o+1,r).map(h=>h.value.toLowerCase()).filter(h=>p.has(h));return Vl(m,a,f,c)})}return false}var gi=new Set(["ja","ko"]);function je(t){let e=new Set;t?.primary&&e.add(t.primary.toLowerCase());for(let r of t?.alternatives??[])e.add(r.toLowerCase());return e}function On(t,e){let r=[],i=e.position.end,n=t.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(n){i=e.position.end+n[0].length;for(let a of n[1].split(/[,\u060c\u3001]/)){let o=a.trim();o&&r.push(o);}}return {parameters:r,headerEnd:i}}function xr(t,e,r){let i=e+1;if(i>=t.length)return -1;let n=je(O(r)?.roleMarkers?.patient);return n.size>0&&V(t[i],n)&&i++,i<t.length?i:-1}var Rn=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function ql(t){let e=1;if(t[1]?.value==="("){let r=0,i=1;for(;i<t.length;i++)if(t[i].value==="(")r++;else if(t[i].value===")"&&--r===0)break;if(i>=t.length)return -1;e=i+1;}return e+1}function Kl(t,e,r){let i=O(r);if(i?.wordOrder!=="SOV"||!Rn.test(t[0].value)||e!==ql(t))return false;let n=je(i.roleMarkers?.patient);return n.size===0?false:V(t[e-1],n)}function Hl(t,e,r){if(!O(e))return null;let i=Q(e,"behavior"),n=Q(e,"def"),a=t.toLowerCase(),o=[...i].some(d=>a.includes(d)),s=/\bdef\b/.test(a)||[...n].some(d=>d!=="def"&&a.includes(d));if(!o&&!s)return null;let u=Z(t,e).tokens;if(u.length<2)return null;if(V(u[0],i))return zi(t,e,u,r,0);let l=u.findIndex((d,m)=>m>0&&V(d,i));if(l>0&&Zr.test(u[0].value))return zi(t,e,u,r,l);if(V(u[0],n))return wi(t,e,u,r,0);let c=u.findIndex((d,m)=>m>0&&V(d,n));return c>0&&Kl(u,c,e)?wi(t,e,u,r,c):null}function Ul(t,e,r){let i=O(e);if(!i)return null;let n=i.wordOrder!=="SOV",a=gi.has(e)?je(i.roleMarkers?.event):new Set,o=gi.has(e)?je(i.keywords?.on):new Set,s=a.size>0&&o.size>0,u=s?je(i.roleMarkers?.source):new Set,l=Q(e,"end"),c=Q(e,"on"),d=Q(e,"then"),m=t.toLowerCase(),p=[...l].some(S=>m.includes(S)),f=(n||s)&&(()=>{let S=0;for(let D of c)if(D){for(let w=m.indexOf(D);w>=0;w=m.indexOf(D,w+D.length))if(++S>=2)return true}return false})();if(!p&&!f)return null;let h=Z(t,e).tokens;if(h.length<2)return null;let v=Ar(e),y=S=>Sr(h,S,v),E=S=>V(S,l),z=[],k=0,g=0;for(let S=0;S<h.length;S++){let D=h[S];if(E(D)){if(k>0){k--;continue}let w=t.slice(h[g].position.start,D.position.start).trim();w&&z.push(w),g=S+1;}else if(y(S))k++;else if(n&&k===0&&S>g&&V(D,c)&&ir(h[S+1])&&!(h[S+2]&&V(h[S+2],d))&&!Wl(h,g,S,e,w=>E(w)||V(w,d))){let w=t.slice(h[g].position.start,D.position.start).trim();w&&z.push(w),g=S;}else if(s&&k===0&&S-1>g&&V(D,a)&&h[S+1]!==void 0&&V(h[S+1],o)){let w=h[S-1],C=h.slice(g,S-1);if(!(C.length===2&&V(C[1],u))){let R=t.slice(h[g].position.start,w.position.start).trim();R&&z.push(R),g=S-1;}}}if(g<h.length){let S=t.slice(h[g].position.start).trim();S&&z.push(S);}if(z.length<2)return null;let A=[],b=[];for(let S of z){let D;try{D=r.statement(S,e);}catch{return null}if(!D||D.kind!=="event-handler")return null;let w=D;if(A.push(w),!w.body||w.body.length===0)return null;b.push(w.metadata?.confidence??.75);}return er(A,"then",{sourceLanguage:e,confidence:sr(b),sourceText:t})}function sr(t){return t.length>0?t.reduce((e,r)=>e+r,0)/t.length:0}function Yr(t){let e=[];for(let r of t){let i=r.statements;r.kind==="compound"&&Array.isArray(i)?e.push(...i):e.push(r);}return e}function zi(t,e,r,i,n){let a=n>0,o=a?0:xr(r,n,e);if(o<0)return null;let s=r[o],u=s.value;if(!Zr.test(u))return null;let{parameters:l,headerEnd:c}=On(t,s),d=a?n+1:r.findIndex(C=>C.position.start>=c);d<=o&&(d=o+1);let m=Q(e,"init"),p=Q(e,"end"),f=Ar(e),h=C=>Sr(r,C,f),v=C=>V(C,p),y=O(e)?.wordOrder!=="SOV",E=y?Gl(e):new Set,z=C=>{let x=t.slice(r[D].position.end,r[C].position.start).trim();if(x)try{let R=Yr(i.body(x,e));g.push(...R),A.push(sr(R.map(M=>M.metadata?.confidence??.75)));}catch{A.push(0);}},k=[],g=[],A=[],b=false,S=0,D=d;for(let C=d;C<r.length;C++){let x=r[C];if(v(x)){if(S>0){S--;continue}if(C===D){b=true;break}if(V(r[D],m))z(C);else {let R=t.slice(r[D].position.start,x.position.start).trim();try{let M=i.statement(R,e);if(M&&M.kind==="event-handler"){let F=M;k.push(F);let T=!F.body||F.body.length===0;A.push(T?.2:F.metadata?.confidence??.75);}else A.push(0);}catch{A.push(0);}}D=C+1;}else h(C)?S++:y&&S===0&&C>D&&V(r[D],m)&&E.has(x.value.toLowerCase())&&(r[C+1]?.kind==="identifier"||r[C+1]?.kind==="keyword")&&ir(r[C+1])&&(z(C),D=C);}if(k.length===0&&g.length===0)return null;let w=(b?1:.8)*sr(A);return yu(u,l,k,g.length>0?g:void 0,{sourceLanguage:e,confidence:w,sourceText:t})}function Gl(t){let e=new Set;for(let r of me(t))if(!(r.command!=="on"||/-event-/i.test(r.id)))for(let i of r.template.tokens){if(i.type==="role"&&i.role==="event")break;if(i.type==="literal")for(let n of [i.value,...i.alternatives??[]])e.add(n.toLowerCase());}return e}function wi(t,e,r,i,n){let a=n>0,o=a?0:xr(r,n,e);if(o<0)return null;let s=r[o],u=s.value;if(!Rn.test(u))return null;let{parameters:l,headerEnd:c}=On(t,s),d=a?n+1:r.findIndex(b=>b.position.start>=c);d<=o&&(d=o+1);let m=Q(e,"end"),p=Ar(e),f=b=>Sr(r,b,p),h=b=>V(b,m),v=0,y=-1;for(let b=d;b<r.length;b++)if(h(r[b])){if(v===0){y=b;break}v--;}else f(b)&&v++;let E=r[d]?.position.start??c,z=y>=0?r[y].position.start:t.length,k=t.slice(E,z).trim();if(!k)return null;let g;try{g=Yr(i.body(k,e));}catch{return null}if(g.length===0)return null;let A=sr(g.map(b=>b.metadata?.confidence??.75));return y<0&&(A*=.8),vu(u,l,g,{sourceLanguage:e,confidence:A,sourceText:t})}var yt=["live","eventsource","socket","worker","intercept"],Zl=new Set(["intercept"]),Tt=new Set(["eventsource","socket","worker"]),Yl=new Set(["eventsource","socket"]),Xl=new Set(["worker"]),Jl=6,Ql=2;function ec(t,e){for(let i of yt)if(V(t[0],Q(e,i)))return {action:i,keywordIdx:0};if(O(e)?.wordOrder!=="SOV")return null;let r=Math.min(t.length,Jl);for(let i=1;i<r;i++)for(let n of yt)if(n!=="live"&&V(t[i],Q(e,n))&&!(Tt.has(n)&&!Zr.test(t[0].value))&&!(n==="intercept"&&i>Ql))return {action:n,keywordIdx:i};return null}function rc(t,e,r){let i=je(O(r)?.roleMarkers?.source);return i.size===0||e+1>=t.length?0:V(t[e],i)||V(t[e+1],i)?2:0}function Pn(t){let e=Q(t,"on");e.add("when");let r=O(t)?.eventHandler;if(r?.keyword){e.add(r.keyword.primary.toLowerCase());for(let i of r.keyword.alternatives??[])e.add(i.toLowerCase());}for(let i of r?.temporalMarkers??[])e.add(i.toLowerCase());return e}function tc(t,e,r){let i=O(r)?.eventHandler,n=[i?.eventMarker?.primary,...i?.eventMarker?.alternatives??[],...i?.temporalMarkers??[]].filter(o=>!!o&&/\s/.test(o)),a=1;for(let o of n){let s=o.toLowerCase().split(/\s+/),u=e-s.length+1;u<0||s.every((l,c)=>t[u+c]?.value.toLowerCase()===l)&&(a=Math.max(a,s.length));}return a}function ic(t,e,r,i,n){if(t==="live")return r+1;if(r>0){let l=r+1;return t==="eventsource"&&(l+=rc(e,l,i)),l}let a=xr(e,r,i);if(a<0)return -1;if(t==="worker")return a+1;let o=Pn(i),s=je(O(i)?.roleMarkers?.event),u=n>=0?n:e.length;for(let l=a+1;l<u;l++){if(!V(e[l],o))continue;if(ir(e[l+1]))return l;if(l>a+2&&s.size>0&&V(e[l-1],s)&&ir(e[l-2]))return l-2;let c=tc(e,l,i);if(c>1&&l-c>a&&ir(e[l-c]))return l-c;if(l>a+1&&ir(e[l-1]))return l-1}return u}function nc(t,e,r,i){if(!Tt.has(t))return;let n=r>0?0:xr(e,r,i);if(!(n<0))return e[n].value}function ac(t,e,r){if(!O(e))return null;let i=t.toLowerCase(),n=false;for(let u of [...yt,"changes"]){for(let l of Q(e,u))if(l&&i.includes(l)){n=true;break}if(n)break}if(!n)return null;let a=Z(t,e).tokens;if(a.length<2)return null;let o=cc(a,e);if(o>=0)return mc(t,e,a,r,o);let s=ec(a,e);return s?oc(t,e,a,r,s.action,s.keywordIdx):null}function oc(t,e,r,i,n,a){let o=Q(e,"end"),s=Ar(e),u=g=>Sr(r,g,s),l=g=>V(g,o),c=nc(n,r,a,e);if(Tt.has(n)&&(!c||!Zr.test(c)))return null;let d=g=>({sourceLanguage:e,confidence:g,sourceText:t}),m=vt(r,a+1,l,u);if(Zl.has(n))return m>=0&&m!==r.length-1?null:pt(n,[],c,d(m>=0?1:.8));let p=ic(n,r,a,e,m);if(p<0||p>r.length)return null;let f=[],h=[],v=false,y=Xl.has(n);if(y||Yl.has(n)){let g=y?"def":"event-handler",A=0,b=p;for(let S=p;S<r.length;S++){let D=r[S];if(l(D)){if(A>0){A--;continue}if(v=true,S===b)break;let w=y?D.position.end:D.position.start,C=t.slice(r[b].position.start,w).trim();try{let x=i.statement(C,e);if(x&&x.kind===g){let R=x;f.push(R);let M=!R.body||R.body.length===0;h.push(M?.2:R.metadata?.confidence??.75);}else h.push(0);}catch{h.push(0);}b=S+1;}else u(S)&&A++;}}else {let g=vt(r,p,l,u);v=g>=0;let A=g>=0?r[g].position.start:t.length,b=t.slice(r[p].position.start,A).trim();if(!b)return null;try{f.push(...Yr(i.body(b,e)));}catch{return null}if(f.length===0)return null;h.push(...f.map(S=>S.metadata?.confidence??.75));}if(f.length===0&&!v)return null;let E=v?1:.8,z=h.length>0?E*sr(h):E,k=sc(n,t,r,a,p,e);return pt(n,f,c,d(z),k?new Map([["source",k]]):void 0)}function sc(t,e,r,i,n,a){if(t!=="eventsource"&&t!=="socket"||i!==0)return;let o=xr(r,i,a);if(o<0)return;let s=o+1,u=Math.min(n,r.length)-1;if(t==="eventsource"){let c=je(O(a)?.roleMarkers?.source),d=m=>!!m&&(V(m,c)||(m.normalized??"").toLowerCase()==="source");d(r[s])?s++:d(r[u])&&u--;}if(s>u)return;let l=e.slice(r[s].position.start,r[u].position.end).trim();return l?{type:"expression",raw:l}:void 0}var uc=new Set([...Object.keys(ue),"then","else"]);function lc(t){let e=Q(t,"when");for(let r of Pn(t))e.add(r);return e}function cc(t,e){if(t.length<3||!V(t[0],lc(e)))return -1;let r=Q(e,"changes"),i=Q(e,"end");for(let n=2;n<t.length;n++){let a=t[n];if(a.kind==="literal")continue;if(V(a,r))return n;if(V(a,i))return -1;let o=(a.normalized??a.value).toLowerCase();if(a.kind==="keyword"&&uc.has(o))return -1}return -1}function dc(t,e,r){if(r==="en"){let n=e[0],a=e[e.length-1];return {type:"expression",raw:t.slice(n.position.start,a.position.end).trim()}}let i=e.map(n=>Vr(n,r)?{...n,kind:"keyword",normalized:"or"}:n);return {type:"expression",raw:Te(i,O(r))}}function mc(t,e,r,i,n){let a=Q(e,"end"),o=Ar(e),s=E=>Sr(r,E,o),u=E=>V(E,a),l=n+1;if(l>=r.length)return null;let c=vt(r,l,u,s),d=c>=0;if(d&&c!==r.length-1)return null;let m=d?r[c].position.start:t.length,p=t.slice(r[l].position.start,m).trim();if(!p)return null;let f;try{f=Yr(i.body(p,e));}catch{return null}if(f.length===0)return null;let h=dc(t,r.slice(1,n),e),y=(d?1:.8)*sr(f.map(E=>E.metadata?.confidence??.75));return pt("when",f,void 0,{sourceLanguage:e,confidence:y,sourceText:t},new Map([["condition",h]]))}function vt(t,e,r,i){let n=0;for(let a=e;a<t.length;a++)if(r(t[a])){if(n===0)return a;n--;}else i(a)&&n++;return -1}var Fe={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",\uB9C8\uC6B0\uC2A4\uC5D4\uD130:"mouseenter",\uB9C8\uC6B0\uC2A4\uB9AC\uBE0C:"mouseleave",\uB9C8\uC6B0\uC2A4\uBB34\uBE0C:"mousemove",\uD0A4\uD504\uB808\uC2A4:"keypress",\uD130\uCE58\uC885\uB8CC:"touchend",\uD130\uCE58\uCDE8\uC18C:"touchcancel"},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",\u307C\u304B\u3057:"blur"},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",\u062A\u0631\u0643\u064A\u0632:"focus","\u0645\u0641\u062A\u0627\u062D \u0623\u0633\u0641\u0644":"keydown","\u0645\u0641\u062A\u0627\u062D \u0623\u0639\u0644\u0649":"keyup","\u0641\u0623\u0631\u0629 \u0641\u0648\u0642":"mouseover","\u062A\u063A\u064A\u064A\u0631 \u062D\u062C\u0645":"resize"},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",cambiar:"change",enfocar:"focus",desenfocar:"blur",cargar:"load",desplazar:"scroll",dobleclic:"dblclick",rat\u00F3nentrar:"mouseenter",rat\u00F3nsalir:"mouseleave",rat\u00F3nmover:"mousemove",teclapresar:"keypress",descargar:"unload",toqueempezar:"touchstart",toqueterminar:"touchend",toquemover:"touchmove",toquecancelar:"touchcancel"},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",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll",bulan\u0131k:"blur",farebas:"mousedown",fareb\u0131rak:"mouseup",kayd\u0131r:"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",duploClique:"dblclick",mouseEntrar:"mouseenter",mouseSair:"mouseleave",mouseMover:"mousemove",teclaPressionar:"keypress",descarregar:"unload",toqueIn\u00EDcio:"touchstart",toqueFim:"touchend",toqueMover:"touchmove",toqueCancelar:"touchcancel"},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",\u6309\u952E\u6309\u4E0B:"keydown",\u9F20\u6807\u79FB\u52A8:"mousemove",\u5378\u8F7D:"unload",\u8C03\u6574\u5927\u5C0F:"resize",\u89E6\u6478\u5F00\u59CB:"touchstart",\u89E6\u6478\u79FB\u52A8:"touchmove"},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",flou:"blur",doubleclic:"dblclick",sourisentrer:"mouseenter",sourissortir:"mouseleave",sourisbouger:"mousemove",touchepress\u00E9e:"keypress",d\u00E9charger:"unload",touchercommencer:"touchstart",toucherfin:"touchend",toucherbouger:"touchmove",toucherannuler:"touchcancel"},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","taste unten":"keydown","taste oben":"keyup","maus dr\xFCber":"mouseover","maus weg":"mouseout",doppelklick:"dblclick",mauseintreten:"mouseenter",mausverlassen:"mouseleave",mausbewegen:"mousemove",tastedr\u00FCcken:"keypress",entladen:"unload",ber\u00FChrungstart:"touchstart",ber\u00FChrungend:"touchend",ber\u00FChrungbewegen:"touchmove",ber\u00FChrungabbrechen:"touchcancel"},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",tekan_tombol:"keydown",keyup:"keyup",arahkan:"mouseover",tinggalkan:"mouseout",bongkar:"unload"},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",kambiay:"change",apachiy:"submit",kachay:"submit",apaykachay:"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",bonyeza:"click",ingizo:"input",kitufe_shuka:"keydown",kitufe_juu:"keyup",panya_nje:"mouseout",wasilisha:"submit","sogeza juu":"mouseover",shuka:"unload"},vi:{"\u0111\u1ED5i k\xEDch th\u01B0\u1EDBc":"resize"}};function Ln(t,e){let r=Fe[e];return r&&r[t]?r[t]:t.toLowerCase()}function pc(t,e){let r=Fe[e];return r?Object.keys(r).filter(i=>r[i]===t):[]}var fc=Object.fromEntries(Object.entries(Fe).map(([t,e])=>{let r={};for(let[i,n]of Object.entries(e))n in r||(r[n]=i);return [t,r]})),hc={ar:new Set(["mouseover"]),bn:new Set(["resize"]),de:new Set(["keydown","keyup","load","mouseout","mouseover"]),fr:new Set(["blur"]),id:new Set(["input","keyup","mouseout","mouseover"]),ja:new Set(["keypress","mousedown","mouseup","resize"]),qu:new Set(["change","focus","load","resize","submit"]),sw:new Set(["change","click","input","keydown","keyup","mouseout","mouseover","submit"]),tr:new Set(["keydown","keyup","load","mousedown","mouseout","mouseover","mouseup","resize","scroll"]),zh:new Set(["focus","keyup","mouseout","mouseover"])};function Nn(t,e){return hc[e]?.has(t)?t:fc[e]?.[t]??t}var yc=new Set(["the","to","on","with","into","from","at"]),ki=/^[A-Za-z_$][\w$]*$/,vc=64;function bi(t){let e="";for(let r=0;r<t.length;r++){let i=t[r],n=t[r-1];n&&i.position.start>n.position.end&&(e+=" "),e+=i.value;}return e}function Ec(t,e){let r=0;for(let i=e;i<t.length&&i-e<=vc;i++){let n=t[i].value;if(n==="(")r++;else if(n===")"&&(r--,r===0))return i+1}return -1}function Ci(t,e){return e.position.start===t.position.end}function gc(t,e,r,i){let n=t[e];if(!n||n.kind!=="identifier"&&n.kind!=="keyword"||!ki.test(n.value)||i(n))return null;let a=e+1,o=n.value;for(;t[a]?.kind==="selector"&&/^\.[A-Za-z_$][\w$]*$/.test(t[a].value)&&Ci(t[a-1],t[a]);)o+=t[a].value,a++;let s=a>e+1,u=t[a];if(!u||u.value!=="("||!Ci(t[a-1],u))return null;let l=Ec(t,a);if(l<0)return null;let c=o+bi(t.slice(a,l));if(s)return {text:`call ${c}`,consumed:l-e};let d=l,p=t[d]?.value.toLowerCase(),f=null;if(p==="me")f="me",d++;else if(p!==void 0&&yc.has(p)){d++,t[d]?.value.toLowerCase()==="the"&&d++;let h=t[d];if(!h)return null;let v=wr(t,d,r);if(v)f=`(${bi(t.slice(d,d+v.consumed))})`,d+=v.consumed;else if(h.kind==="selector"&&h.value.startsWith("#")&&!/[.[:\s]/.test(h.value.slice(1)))f=h.value,d++;else if(h.kind==="selector"&&/^[.<]/.test(h.value))f=`(${h.value})`,d++;else if((h.kind==="keyword"||h.kind==="identifier")&&ki.test(h.value)&&(Oe(h.value.toLowerCase())||h.kind==="identifier"))f=h.value,d++;else return null}return {text:f?`call ${f}.${c}`:`call ${c}`,consumed:d-e}}var zc={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},wc=[["\u043E\u0434\u0438\u043D","_","\u0440\u0430\u0437"],["\u043E\u0434\u0438\u043D_\u0440\u0430\u0437"],["\u043E\u0434\u043D\u0430\u0436\u0434\u044B"],["m\u1ED9t","l\u1EA7n"],["once"]],kc=/^(\d+)(ms|s|m)?$/,bc=new Set(["selector","literal","url","event-modifier"]);function Cc(t){let e=t.match(kc);if(!e)return null;let r=parseInt(e[1],10),i=e[2]||"ms";return i==="s"?r*=1e3:i==="m"&&(r*=6e4),r}function Ac(t){for(let e=1;e<t.length;e++){let r=t[e];if(bc.has(r.kind))continue;let i=r.value.toLowerCase(),n=zc[i];if(n){let a=0;for(let o=e+1;o<t.length;o++){let s=t[o],u=Cc(s.value);if(u!==null)return {modifiers:{[n]:u},start:r.position.start,end:s.position.end};if(s.kind==="selector"||s.kind==="literal"||s.kind==="url"||++a>2)break}continue}for(let a of wc){if(a[0]!==i||e+a.length>t.length)continue;let o=true;for(let s=1;s<a.length;s++)if(t[e+s].value.toLowerCase()!==a[s]){o=false;break}if(o)return {modifiers:{once:true},start:r.position.start,end:t[e+a.length-1].position.end}}}return null}function Sc(t,e){try{let r=Z(t,e),i=me(e);if(i.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let n=[...i].sort((l,c)=>c.priority-l.priority),a=n.filter(l=>l.command==="on"),o=ke.matchBest(r,a);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let s=n.filter(l=>l.command!=="on"),u=ke.matchBest(r,s);return u?{confidence:u.confidence,parseSuccess:!0,patternId:u.pattern.id,action:u.pattern.command,tokensConsumed:u.consumedTokens}:{confidence:0,parseSuccess:!1,error:`Could not match any patterns for: ${t}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function _n(t,e){try{let i=a0(t,e);if(i)return {node:i,confidence:i.metadata?.confidence??.8,error:void 0,tokensConsumed:Z(t,e).tokens.length}}catch{}let r=Sc(t,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}new Set(Object.values(Dt).flatMap(t=>Object.values(t)));var Wc=new Set(["a","an","the"]),xi=new Map;function qc(t){let e=xi.get(t);return e||(e=new Set(Object.values(ue).flatMap(r=>r.roles.flatMap(i=>[i.markerOverride?.[t],...i.markerVariants?.[t]??[]].filter(n=>typeof n=="string"&&n.length>0)))),xi.set(t,e)),e}function Kc(t,e){let r=Z(t,e).tokens,i=r[0];if(r.length!==1||!i)return {collision:"structure",word:"words"};let n=i.normalized!==t?i.normalized:void 0;if(i.kind==="keyword"&&Hi.has(n??""))return {collision:"pronoun",word:"pronoun",sense:n};if(i.kind==="identifier"&&!n){if(qc(e).has(t))return {collision:"structure",word:"marker"};let a=He(e,t);return a!==t?{collision:"structure",word:"connective",sense:a}:Wc.has(t.toLowerCase())?{collision:"structure",word:"article"}:null}return i.kind==="particle"?{collision:"structure",word:"marker"}:{collision:"structure",word:"keyword",sense:n}}function Hc(t,e){let r=`${e}\0${t}`,i=Di.get(r);return i===void 0&&(i=Kc(t,e)?.collision??null,Di.set(r,i)),i}var Di=new Map;Ws((t,e)=>Hc(t,e)==="structure");var qe=new Set(["if","unless","while","repeat","for"]),Mn=new Set(["repeat","for"]),rr={kind:"loop-close"};function Ft(t){return t===rr}function gt(t){if(Ft(t)||t.kind!=="command"||!Mn.has(t.action))return false;let e=t.body;return !(Array.isArray(e)&&e.length>0)}function Uc(t){switch(t.type){case "expression":return t.raw;case "literal":return String(t.value);case "reference":return t.value;default:return}}function Mr(t,e){for(let r=e-1;r>=0;r--)if(t[r].kind!=="particle")return t[r]}function lt(t){return t.kind!=="keyword"&&t.kind!=="identifier"?false:(t.normalized??t.value).toLowerCase()==="repeat"}function Ir(t){let e=0;for(let r of t)gt(r)?e++:Ft(r)&&e>0&&e--;return e}var ct=new Set(["then","end","else","if","unless","while","for","repeat","and"]),Gc=new Set(["first","last","next","previous","random","closest"]),Zc=new Set(["me","my","i","it","its","you","your","result"]),Bi=new Set(["top","middle","bottom","left","center","right","nearest"]),Yc=new Set(["smoothly","instantly"]);function Xc(t,e){if(!e)return false;let r=e.value.toLowerCase();switch(t.type){case "selector":return t.value.toLowerCase()===r;case "reference":return t.value===(e.normalized??e.value).toLowerCase()||t.value===r;case "expression":return t.raw.toLowerCase().split(/\s+/)[0]===r;default:return String("value"in t?t.value:"").toLowerCase()===r}}var yr=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function Jc(t){let e=(t.normalized??t.value).toLowerCase();return e==="document"||e==="window"||e==="me"||e==="body"?be(e):t.kind==="selector"?Re(t.value):{type:"expression",raw:t.value}}var Ti=new Map;function Fi(t){let e=Ti.get(t);return e||(e=new Set(me(t).map(r=>r.command).filter(r=>r!=="on")),Ti.set(t,e)),e}var Be=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),Oi=class extends Error{constructor(t,e,r,i){super(t),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=i;}};function G(t,e,r){return {message:t,severity:e,source:"semantic-parser",...r&&{code:r}}}function q(t,e){return e.length===0?t:{...t,diagnostics:e}}var Kr=120;function Qc(t,e,r){let i=e.tokens.length;if(t.consumedTokens>=i)return null;let n=e.tokens[t.consumedTokens],a=e.tokens[i-1];if(!n||!a)return null;let o=r.slice(n.position.start,a.position.end);if(!o.trim())return null;let s=o.length>Kr?`${o.slice(0,Kr)}\u2026`:o,u=i-t.consumedTokens;return `pattern ${t.pattern.id} left ${u} token(s) unconsumed: "${s}"`}var Ri=/^repeat-.*-(times|for-in|while-head|until-head|until-condition-head)$/,e0=new Set(["forever","times","for","while","until","until-event"]),r0=new Set(["to","from","into","onto","with","as","at","of","in","on","by","and","or","then","end","else","the","a","an","async"]);function $r(t){let e=[],r=new Set((t.diagnostics??[]).map(n=>`${n.code}|${n.message}`)),i=n=>{if(!n||typeof n!="object")return;if(n!==t)for(let o of n.diagnostics??[]){if(o.code!=="unconsumed-input")continue;let s=`${o.code}|${o.message}`;r.has(s)||(r.add(s),e.push(o));}let a=n;for(let o of In){let s=a[o];if(Array.isArray(s))for(let u of s)i(u);}};return i(t),e.length===0?t:q(t,[...t.diagnostics??[],...e])}function t0(t){if(t.length>=2){let e=t[0];if((e==='"'||e==="'")&&t.endsWith(e))return t.slice(1,-1)}return t}var In=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function $n(t,e,r){if(!t||typeof t!="object")return t;if(t.action&&t.roles instanceof Map){let n=se(t.action),a=n?.primaryRole;if(n&&a&&a!=="patient"&&!n.roles.some(o=>o.role==="patient")&&t.roles.has("patient")&&!t.roles.has(a)){let o=t.roles,s=o.get("patient");s!==void 0&&(o.delete("patient"),o.set(a,s));}if(t.action==="tell"){let o=t.roles,s=o.get("patient"),u=o.get("destination");s&&(s.type==="selector"||s.type==="reference")&&(!u||u.type==="literal")&&(o.delete("patient"),o.set("destination",s));}if(t.action==="transition"){let o=t.roles,s=o.get("goal");s&&s.type==="literal"&&s.dataType==="duration"&&!o.has("duration")&&(o.delete("goal"),o.set("duration",s));}if(t.action==="fetch"){let o=t.roles,s=o.get("patient"),u=o.get("source");s&&u&&(s.type==="literal"||s.type==="expression")&&u.type==="expression"&&!o.has("style")&&(o.delete("patient"),o.set("style",u),o.set("source",s));}if(t.action==="transition"){let o=t.roles,s=o.get("destination");s&&s.type==="literal"&&!o.has("goal")&&(o.delete("destination"),o.set("goal",s));let u=o.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(u.value)&&o.set("patient",{type:"expression",raw:u.value});}if(t.action==="morph"){let o=t.roles,s=o.get("patient");s&&s.type==="literal"&&typeof s.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(s.value)&&o.set("patient",{type:"expression",raw:s.value});}if(t.action==="wait"){let o=t.roles;if(!o.has("event")){let s=o.get("duration"),u=s?.type==="expression"?s.raw:s?.type==="literal"?s.value:void 0,l=typeof u=="string"&&r?Ln(u,r):"";typeof u=="string"&&Be.has(u.toLowerCase())?(o.delete("duration"),o.set("event",{type:"literal",value:u,dataType:"string"})):Be.has(l)&&(o.delete("duration"),o.set("event",{type:"literal",value:l,dataType:"string"}));}}if(t.kind==="command"&&t.action!=="on"){let o=t.roles,s=o.get("event");if(s&&s.type==="expression"){let u=s.raw;typeof u=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(u)&&o.set("event",{type:"literal",value:u,dataType:"string"});}}if(e?.size){let o=t.roles;for(let s of ["destination","source"]){let u=o.get(s);u&&u.type==="literal"&&typeof u.value=="string"&&e.has(u.value)&&o.set(s,{type:"expression",raw:u.value});}}}let i=t;for(let n of In){let a=i[n];if(Array.isArray(a))for(let o of a)$n(o,e,r);}return t}var Ee=class B{constructor(){this.parseDepth=0,this.coverageFrames=[],this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++,this.coverageFrames.push([]);try{let i=$n(this.parseInternal(e,r),this.boundIdentifiers,r),n=this.coverageFrames[this.coverageFrames.length-1];if(n.length>0&&(i=q(i,[...i.diagnostics??[],...n])),this.parseDepth===1&&(i=$r(i),i.kind==="event-handler")){let a={node:i,input:e},o=a.node.eventModifiers;if(o&&(o.once||o.debounce!==void 0||o.throttle!==void 0))for(let u=0;u<4;u++){let l=this.reclaimDanglingFromTail(a.node,a.input,r)??this.reclaimEventCompoundTail(a.node,a.input,r)??this.reclaimResponseTypeTail(a.node,a.input,r)??this.reclaimCapturedDestinationTail(a.node,a.input,r);if(!l)break;a=l;}let s=this.reclaimEventCompoundTail(a.node,a.input,r);s&&(a=s),i=a.node;}return i}finally{this.coverageFrames.pop(),this.parseDepth--;}}coverageMark(){let e=this.coverageFrames[this.coverageFrames.length-1];return e?e.length:0}coverageRollback(e){let r=this.coverageFrames[this.coverageFrames.length-1];r&&r.length>e&&(r.length=e);}static getCoverageMarkerSurfaces(e){let r=B.coverageMarkerSurfaces.get(e);if(!r){r=new Set;let i=O(e)?.roleMarkers;if(i){for(let n of Object.values(i))if(n){if(n.primary)for(let a of n.primary.toLowerCase().split(/\s+/))r.add(a);for(let a of n.alternatives??[])for(let o of a.toLowerCase().split(/\s+/))r.add(o);}}for(let n of B.LEAKED_RENDER_MARKERS[e]??[])r.add(n.toLowerCase());B.coverageMarkerSurfaces.set(e,r);}return r}isCoverageResidueToken(e,r){if(e.kind==="particle"||e.kind==="conjunction"||e.metadata?.closesTrackedBlock||this.isThenKeyword(e.value,r)||this.isEndKeyword(e.value,r)||this.isElseKeyword(e.value,r))return true;let i=(e.normalized??e.value).toLowerCase();return r0.has(i)?true:B.getCoverageMarkerSurfaces(r).has(e.value.toLowerCase())}recordDroppedTokens(e,r,i){if(e.length===0)return;let n=this.coverageFrames[this.coverageFrames.length-1];if(!n||!e.some(s=>!this.isCoverageResidueToken(s,r)))return;let a=e.map(s=>s.value).join(" ").trim();if(!a)return;let o=a.length>Kr?`${a.slice(0,Kr)}\u2026`:a;n.push(G(`${i} left ${e.length} token(s) unconsumed: "${o}"`,"warning","unconsumed-input"));}registerBoundIdentifiers(e){let r=e.action==="repeat"||e.action==="for"?"patient":e.action==="set"?"destination":null;if(!r)return;let i=e.roles.get(r);i?.type==="expression"&&typeof i.raw=="string"&&/^[A-Za-z_]\w*$/.test(i.raw)&&this.boundIdentifiers.add(i.raw);}parseInternal(e,r){let i=Hl(e,r,{statement:(w,C)=>this.parse(w,C),body:(w,C)=>this.parseStatements(w,C)});if(i)return i;let n=ac(e,r,{statement:(w,C)=>this.parse(w,C),body:(w,C)=>this.parseStatements(w,C)});if(n)return n;let a=Ul(e,r,{statement:(w,C)=>this.parse(w,C),body:(w,C)=>this.parseStatements(w,C)});if(a)return a;let{modifiers:o,remainingInput:s}=this.extractStandaloneModifiers(e,r),u=s||e,c=this.stripAsyncModifier(u,r).remainingInput??u,m=this.stripDoNotThrowModifier(c,r).remainingInput??c,p=[],f=Z(m,r);this.positionSource=m;{let w=f.mark(),C=this.consumeJsBlock(f,r);if(C&&f.isAtEnd())return q(C,p);f.reset(w);}let h=me(r);if(h.length===0)throw new Oi(`No patterns available for language: ${r}`,r,m,[G(`No patterns registered for language '${r}'`,"error","no-patterns")]);let v=[...h].sort((w,C)=>C.priority-w.priority);{let w=f.tokens;if(O(r)?.wordOrder==="VSO"&&w.length>=4&&w[0]?.normalized==="source"){let C=w.findIndex(x=>x.normalized==="on");if(C>=2&&C+1<w.length){let x=m.slice(w[0].position.start,w[C].position.start).trim(),R=w[C+1].position.end,M=m.slice(w[C].position.start,R)+" "+x+m.slice(R);if(M!==m)try{let F=this.parse(M,r);if(F&&F.kind==="event-handler"){let T=o?this.applyModifiers(F,o):F;return q(T,p)}}catch{}}}}{let w=f.tokens,C=w[0]?.normalized==="if";for(let x=0;C&&x+3<w.length;x++){let R=(w[x+3]?.normalized??w[x+3]?.value??"").toLowerCase();if(w[x]?.normalized==="source"&&w[x+2]?.normalized==="on"&&B.KNOWN_EVENTS.has(R)){let M=(m.slice(0,w[x].position.start).trimEnd()+" "+m.slice(w[x+1].position.end).trimStart()).trim();if(M&&M!==m)try{let F=this.parse(M,r);if(F&&F.kind==="event-handler"){let T=o?this.applyModifiers(F,o):F;return q(T,p)}}catch{}break}}}{let w=this.tryDoNotThrow(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=this.tryTellTo(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=this.tryScrollModifiers(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=this.tryLoopIndex(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=this.tryWaitAlternatives(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=f.tokens,C=Fi(r);for(let x=0;x+1<w.length;x++){let R=w[x];if(this.isBodyCommandWord(R,C))break;if(w[x+1].value!=="(")continue;let M=(R.normalized??R.value).toLowerCase();if(!(B.KNOWN_EVENTS.has(M)||Be.has(M))&&R.kind!=="identifier")continue;let T=this.matchEventParamPhrase(w,x+1);if(T.len===0)continue;let N=w[x+T.len],K=(m.slice(0,w[x+1].position.start).trimEnd()+" "+m.slice(N.position.end).trimStart()).trim();try{let _=this.parse(K,r);if(_?.kind==="event-handler"){let I=this.reclaimEventCompoundTail($r(_),K,r);I&&(_=I.node);}let j=_?.roles.get("event"),fe=(j?.type==="expression"?j.raw:j&&"value"in j?String(j.value):void 0)?.toLowerCase(),H=m.slice(0,w[x+1].position.start).trimEnd().toLowerCase(),L=fe===R.value.toLowerCase()||fe===M||fe!==void 0&&pc(fe,r).some(I=>H.endsWith(I.toLowerCase()));if(_?.kind==="event-handler"&&L){_.parameterNames=T.names;let I=o?this.applyModifiers(_,o):_;return q(I,p)}}catch{}}}{let w=f.tokens,C=Fi(r);for(let x=1;x<w.length-1;x++){let R=w[x];if(this.isBodyCommandWord(R,C))break;if(!Vr(R,r))continue;let M=w[x+1],F=(M.normalized??M.value).toLowerCase();if(!B.KNOWN_EVENTS.has(F))break;let T=x+1,N=w[x+2];N&&N.kind==="selector"&&N.value.startsWith("[")&&(T=x+2);let K=w[x].position.start,_=w[T].position.end,j=(m.slice(0,K).trimEnd()+" "+m.slice(_).trimStart()).trim();if(j&&j!==m)try{let ne=this.parse(j,r);if(ne&&ne.kind==="event-handler"){ne.additionalEvents=[{type:"literal",value:T>x+1?F+N.value:F}];let fe=o?this.applyModifiers(ne,o):ne;return q(fe,p)}}catch{}break}}{let w=Ac(f.tokens);if(w){let C=(m.slice(0,w.start).trimEnd()+" "+m.slice(w.end).trimStart()).trim();if(C&&C!==m)try{let x=this.parse(C,r);if(x&&x.kind==="event-handler"){let R=this.applyModifiers(x,{...o??{},...w.modifiers});return q(R,p)}}catch{}}}let y=v.filter(w=>w.command==="on"),E=f.mark(),z=ke.matchBest(f,y);if(z){p.push(G(`event pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match"));let w=false;if(/^event-[a-z]+-bare$/.test(z.pattern.id)){let C=z.captured.get("event"),x=(C?.raw??C?.value??"").toString().toLowerCase(),R=Fe[r],M=B.KNOWN_EVENTS.has(x)||!!R&&Object.keys(R).some(F=>F.toLowerCase()===x);if(x&&!M){let F=this.trySOVEventExtraction(m,r,v);if(F){p.push(G(`bare-event mis-anchor on "${x}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let T=o?this.applyModifiers(F,o):F;return q(T,p)}if(C?.type==="reference"||C?.type==="expression"){f.reset(E);let T=v.filter(K=>K.command!=="on"),N=ke.matchBest(f,T);f.reset(E),N&&N.pattern.command!=="on"?(w=true,p.push(G(`bare-event mis-anchor on reference "${x}" rejected; command ${N.pattern.command} preferred`,"info","stage-bare-event-guard"))):ke.matchBest(f,y);}}}if(!w){let C=this.buildEventHandler(z,f,r),x=o?this.applyModifiers(C,o):C;return q(x,p)}}p.push(G(`event patterns: ${y.length} tried, no match`,"info","stage-event"));let k=this.tryTrailingEventExtraction(m,r,v);if(k){p.push(G("trailing event extraction succeeded","info","stage-trailing-event"));let w=o?this.applyModifiers(k,o):k;return q(w,p)}let g=v.filter(w=>w.command!=="on"),A=this.tryParseUnlessGuard(f,g,r);if(A&&A.length>0){let w=A.length===1?A[0]:er(A,"then",{sourceLanguage:r,confidence:1});return q(w,p)}let b=ke.matchBest(f,g);if(b){if(qe.has(b.pattern.command)){let C=this.trySOVEventExtraction(m,r,v);if(C){p.push(G(`SOV event extraction preferred over bare ${b.pattern.command} command`,"info","stage-sov-loop"));let R=o?this.applyModifiers(C,o):C;return q(R,p)}let x=this.tryMidStreamEventExtraction(m,r,v);if(x){p.push(G(`mid-stream event extraction preferred over bare ${b.pattern.command} command`,"info","stage-midstream-loop"));let R=o?this.applyModifiers(x,o):x;return q(R,p)}}else if(B.KNOWN_EVENTS.has(b.pattern.command)&&this.hasSOVEventMarkerHead(m,r)){let C=this.trySOVEventExtraction(m,r,v);if(C){p.push(G(`SOV event extraction preferred over command-homonym event ${b.pattern.command}`,"info","stage-sov-homonym"));let x=o?this.applyModifiers(C,o):C;return q(x,p)}}else if(O(r)?.wordOrder==="VSO"){let C=this.tryMidStreamEventExtraction(m,r,v);if(C){p.push(G(`mid-stream event extraction preferred over bare ${b.pattern.command} command`,"info","stage-midstream-cmd"));let x=o?this.applyModifiers(C,o):C;return q(x,p)}}if(b.consumedTokens<f.tokens.length&&O(r)?.wordOrder==="SOV"){let C=this.trySOVEventExtraction(m,r,v);if(C){p.push(G(`SOV event extraction preferred over partial ${b.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let x=o?this.applyModifiers(C,o):C;return q(x,p)}}if(b.consumedTokens<f.tokens.length&&Mn.has(b.pattern.command)){let C=this.tryTopLevelLoop(f,g,r);if(C)return p.push(G(`top-level loop: ${C.kind}`,"info","stage-top-level-loop")),q(C,p)}if(b.consumedTokens<f.tokens.length&&!qe.has(b.pattern.command)){let C=this.tryTopLevelCommandSequence(f,g,r);if(C)return p.push(G(`top-level command sequence: ${C.statements.length} commands`,"info","stage-top-level-sequence")),q(C,p)}if(b.consumedTokens<f.tokens.length&&(b.pattern.command==="if"||b.pattern.command==="unless")){let C=this.tryCompoundCommandParsing(f,g,r);if(C)return p.push(G("conditional with a trailing body","info","stage-compound")),q(C,p)}p.push(G(`command pattern matched: ${b.pattern.id} (confidence: ${b.confidence.toFixed(2)})`,"info","pattern-match"));let w=Qc(b,f,m);return w&&p.push(G(w,"warning","unconsumed-input")),q(this.buildCommand(b,r),p)}if(p.push(G(`command patterns: ${g.length} tried, no match`,"info","stage-command")),!m.includes(`
|
|
5
|
-
`)&&O(r)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(m,r,v);if(w){p.push(G("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let C=o?this.applyModifiers(w,o):w;return q(C,p)}}let S=this.trySOVEventExtraction(m,r,v);if(S){p.push(G("SOV event extraction succeeded","info","stage-sov"));let w=o?this.applyModifiers(S,o):S;return q(w,p)}p.push(G("SOV event extraction: no event keyword found","info","stage-sov"));let D=this.tryCompoundCommandParsing(f,g,r);if(D)return p.push(G("compound command parsing succeeded","info","stage-compound")),q(D,p);if(p.push(G("compound parsing: no then-keywords or no command matches","info","stage-compound")),r==="en"){let w=Z(m,r),C=this.tryParsePseudoCommand(w,g,r);if(C&&w.isAtEnd())return p.push(G("pseudo-command parsed as call","info","stage-pseudo")),q(C,p)}throw p.push(G(`all parse stages exhausted for "${m}"`,"error","parse-failed")),new Oi(`Could not parse input in ${r}: ${m}`,r,m,p)}tryParsePseudoCommand(e,r,i){if(i!=="en")return null;let n=gc(e.tokens,e.position(),O(i),s=>!!se((s.normalized??s.value).toLowerCase()));if(!n)return null;let a=Z(n.text,i),o=ke.matchBest(a,r.filter(s=>s.command==="call"));if(!o||!a.isAtEnd())return null;for(let s=0;s<n.consumed;s++)e.advance();return this.buildCommand(o,i)}parseStatements(e,r){let i=Z(e,r),n=me(r).filter(a=>a.command!=="on").sort((a,o)=>o.priority-a.priority);this.coverageFrames.push([]);try{let a=this.parseBodyWithClauses(i,n,r),o=this.coverageFrames[this.coverageFrames.length-1];if(o.length>0&&a.length>0){let s=a[a.length-1];a[a.length-1]=q(s,[...s.diagnostics??[],...o]);}return a}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Dn()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let i={};for(let[a,o]of e.captured)i[a]=o;let n=de(e.pattern.command,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(n),n}buildEventHandler(e,r,i){if(!e)throw new Error("No match to build event handler from");let n=e.captured.get("event");if(!n)throw new Error("Event handler pattern matched but no event captured");{let z=n.type==="expression"?n.raw:n.type==="literal"?n.value:void 0;if(typeof z=="string"&&/^[^\s()[\]{}:]+$/.test(z)){let k=Fe[i]?.[z];k?n={type:"literal",value:k,dataType:"string"}:n.type==="expression"&&B.KNOWN_EVENTS.has(z.toLowerCase())&&(n={type:"literal",value:z.toLowerCase(),dataType:"string"});}}let a=ke.extractEventModifiers(r),o=z=>!(z.type==="reference"&&z.value==="me")&&z.implicit!==true,s=e.captured.get("source"),u=e.pattern.command==="on"&&/^(on|event)-/.test(e.pattern.id),l=false;s&&(e.pattern.id.endsWith("source")||u)&&o(s)&&(a={...a??{},from:s},l=true);let c;if(e.eventSource&&!l){let z=e.captured.get("action"),k=z?.type==="literal"?se(String(z.value)):void 0;O(i)?.roleMarkers?.source?.position==="after"&&k?.roles.some(A=>A.role==="source")&&!e.captured.has("source")?c=e.eventSource:o(e.eventSource)&&(a={...a??{},from:e.eventSource});}let d=e.captured.get("event")?.position,m=r.tokens[r.position()-1],f=d!==void 0&&m!==void 0&&m.position.end>d.end?[]:this.extractOrConjunctionEvents(r,i),h=n;f.length>0&&n.type==="literal"&&(h={type:"literal",value:[String(n.value),...f.map(k=>String("value"in k?k.value:""))].join(" or ")});let v,y=e.captured.get("action");if(y&&y.type==="literal"&&y.value==="if"){let z=r.tokens,k=-1;for(let g=r.position()-1;g>=0;g--){let A=z[g],b=(A.normalized??A.value).toLowerCase();if(this.isIfKeyword(b,i)){k=g;break}}for(;k>0;){let g=z[k-1];if(!this.isIfKeyword((g.normalized??g.value).toLowerCase(),i))break;k--;}if(k>=0){let g=me(i).filter(C=>C.command!=="on").sort((C,x)=>x.priority-C.priority),A=z.slice(k);if(e.pattern.id.endsWith("vso-verb-first")&&h.type==="literal"){let C=String(h.value??"").split("[")[0].trim().toLowerCase(),x=A.findIndex((R,M)=>{if(M===0||C==="")return false;let F=(R.normalized??R.value).toLowerCase(),T=A[M-1];return F===C&&T.kind==="keyword"&&(T.normalized??"").toLowerCase()==="on"});if(x>0){let R=A[x+1],M=R&&R.kind==="selector"&&R.value.startsWith("[")?1:0;A=[...A.slice(0,x-1),...A.slice(x+1+M)];}}let b=new oe(A,i),S=this.coverageMark(),D=this.parseBodyWithClauses(b,g,i);if(D.some(C=>C.kind==="conditional")||D.length===1&&D[0]?.kind==="compound"&&D[0].statements.some(C=>C.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return hr(h,D,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(S);}}if(y&&y.type==="literal"&&String(y.value)!=="js"&&se(String(y.value))!==void 0){let z=y.value,k={};for(let[T,N]of e.captured)if(T!=="event"&&T!=="action"&&T!=="continues"){if(T==="source"&&l)continue;k[T]=N;}if(c&&(k.source=c),z==="repeat"){let T=r.peek(),N=_=>(_.normalized??_.value).toLowerCase();if(T&&T.kind==="keyword"&&N(T)==="forever")k.loopType={type:"literal",value:"forever"},delete k.patient,r.advance();else if(T&&T.kind==="keyword"&&N(T)==="event"){r.advance();let _=r.peek();if(_)for(k.event={type:"literal",value:N(_)},k.loopType={type:"literal",value:"until-event"},delete k.patient;!r.isAtEnd();){let j=r.peek();if(!j||j.kind==="conjunction"||j.kind==="keyword"&&(this.isThenKeyword(j.value,i)||this.isEndKeyword(j.value,i)))break;r.advance();}}let K=k.patient;K&&K.type==="reference"&&K.value==="me"&&delete k.patient;}let g=de(z,k,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence});this.registerBoundIdentifiers(g);let A=[];if(!qe.has(z)||z==="repeat"||z==="while"){let T=e.pattern.id.includes("verb-first"),N=r.tokens,K=r.position(),_=L=>{let I=N[L];if(I.kind==="conjunction")return true;if(I.kind!=="keyword")return false;let X=ye(N,L);return this.isThenAt(I,X,i)||this.isEndKeyword(I.value,i)&&!Ne(X,i)},j=z==="repeat"||z==="while",ne=L=>_(L)||j&&this.isBlockEndToken(N[L],ye(N,L),i),fe=new Set;{let L=O(i)?.keywords?.[z];L?.primary&&fe.add(L.primary.toLowerCase());for(let I of L?.alternatives??[])fe.add(I.toLowerCase());}let H=-1;for(let L=K-1;L>=0;L--){let I=N[L];if(_(L))break;if((I.normalized??I.value).toLowerCase()===z||fe.has(I.value.toLowerCase())){H=L;break}}if(H>=0){let L=K,I=0;for(;L<N.length;){let ae=N[L],ze=Mr(N,L);if(j&&this.isIfKeyword((ae.normalized??ae.value).toLowerCase(),i)&&!(ze&&this.isElseKeyword(ze.value,i)))I++;else if(I>0)this.isBlockEndToken(ae,ye(N,L),i)&&I--;else if(ne(L))break;L++;}let X=N.slice(H,L),ge=X;if(T){let ae=String(n.value??"").toLowerCase(),ze=X.findIndex(le=>(le.normalized??le.value).toLowerCase()===ae);if(ze<0)ge=null;else {let le=X[ze-1],ce=le&&le.kind==="keyword"&&le.normalized?.toLowerCase()==="on"?ze-1:ze;ge=[...X.slice(0,ce),...X.slice(ze+1)];}}if(ge&&ge.length>1){let ae=me(i).filter(W=>W.command!=="on").sort((W,J)=>J.priority-W.priority),ze=this.coverageMark(),le=this.parseClause(ge,ae,i),ce=le[0],Ye=W=>W!==null&&typeof W=="object"&&typeof W.type=="string"?W.type:typeof W,Xe=se(z),et=Xe?.primaryRole,Wt=W=>W==="patient"&&et&&et!=="patient"&&!Xe?.roles.some(J=>J.role==="patient")?et:W,va=(W,J)=>{if(!qe.has(z)||!Xe)return false;let Ie=Xe.roles.find(dr=>dr.role===Wt(W));return Ie?Ie.expectedTypes.length>0&&!Ie.expectedTypes.includes(Ye(J)):true},rt=(W,J)=>W==="patient"&&!!Xe&&!Xe.roles.some(Ie=>Ie.role==="patient")&&Ye(J)==="literal"&&Cr.has(String(J.value??"").toLowerCase()),tt=W=>W!==null&&typeof W=="object"&&W.implicit===true,Ea=!!ce&&ce.kind==="command"&&Object.entries(k).every(([W,J])=>{if(tt(J)||va(W,J)||rt(W,J))return true;let Ie=ce.roles.get(Wt(W));if(Ie!==void 0&&Ye(Ie)===Ye(J))return true;if(W==="patient"&&z==="pick"&&Ye(J)==="literal"){let dr=ce.roles.get("method"),Kt=Ye(dr),Ht=Kt==="literal"?String(dr.value):Kt==="expression"?String(dr.raw):void 0;return Ht!==void 0&&Ht===String(J.value)}return false}),qt=ce?.metadata?.patternId??"",ga=!qe.has(z)||Ri.test(qt),za=Ri.test(qt);if((le.length===1||za&&le.length>1)&&ce&&ce.kind==="command"&&(ce.action===z||z==="while"&&ce.action==="repeat"&&/-while-head$/.test(ce.metadata?.patternId??""))&&Ea&&ga&&(ce.roles.size>Object.entries(k).filter(([W,J])=>!rt(W,J)).length||[...ce.roles.values()].filter(W=>!tt(W)).length>Object.entries(k).filter(([W,J])=>!rt(W,J)&&!tt(J)).length))for(g=ce,A=le.slice(1);r.position()<L;)r.advance();else this.coverageRollback(ze);}}}if(!qe.has(z)){let T=g;if(se(z)?.roles.some(H=>H.role==="quantity"&&!H.required)&&!T.roles.has("quantity")){let H=r.peek();H&&/^-?\d+(\.\d+)?$/.test(H.value)&&(g=de(z,{...Object.fromEntries(T.roles),quantity:{type:"literal",value:parseFloat(H.value),dataType:"number"}},T.metadata),r.advance());}let K=g;if(se(z)?.roles.some(H=>H.role==="duration"&&!H.required)&&!K.roles.has("duration")){let H=/^\d+(\.\d+)?(ms|s)$/i,L=r.peek(),I=false;if(L&&L.kind==="particle"){let X=r.peek(1);X&&H.test(X.value)&&(I=true,L=X);}L&&H.test(L.value)&&(g=de(z,{...Object.fromEntries(K.roles),duration:{type:"literal",value:L.value,dataType:"string"}},K.metadata),I&&r.advance(),r.advance(),this.consumeForPostposition(r,i));}let j=g,ne=se(z);if(ne?.roles.find(H=>H.role==="responseType"&&!H.required)&&!j.roles.has("responseType")){let H=ae=>typeof ae=="string"&&B.RESPONSE_TYPE_WORDS.has(ae.toLowerCase()),L=(ae,ze)=>{let le=Object.fromEntries(j.roles);ze&&delete le.destination,le.responseType={type:"expression",raw:ae},g=de(z,le,j.metadata);},I=j.roles.get("destination"),X=ne?.roles.find(ae=>ae.role==="destination"),ge=I?.raw??I?.value;if(I&&X&&!X.expectedTypes.includes(I.type)&&H(ge))L(ge,true);else {let ae=r.peek();ae&&H(ae.value)&&(L(ae.value,false),r.advance());}}if(z==="wait"){let H=g;if(!H.roles.has("event")){let L=r.peek();if(L&&Be.has(L.value.toLowerCase())){let I=Object.fromEntries(H.roles),X=I.duration;X&&X.type!=="literal"&&X.type!=="expression"&&delete I.duration;let ge=I.patient;ge&&ge.type==="reference"&&ge.value==="me"&&delete I.patient,I.event={type:"literal",value:L.value,dataType:"string"},g=de(z,I,H.metadata),r.advance(),this.consumeForPostposition(r,i);}}}this.tryAttachTrailingRole(r,g,i),this.tryAttachTrailingStyle(r,g,i),this.tryAttachTrailingExpressionRole(r,g,i),this.tryAttachNewWindow(r,g);}let b=e.captured.get("continues"),S=b?.type==="literal"&&b.value==="then",D=r.peek(),w=!!D&&this.isThenKeyword(D.value,i),x=qe.has(z)&&!!D&&!this.isEndKeyword(D.value,i),R=!!D&&!this.isEndKeyword(D.value,i),M=[g,...A],F=!!D&&this.isEndKeyword(D.value,i)&&Ir(M)>0&&r.peek(1)!==null;if(F&&(r.advance(),M.push(rr)),S||w||x||R||F){let T=me(i).filter(_=>_.command!=="on").sort((_,j)=>j.priority-_.priority),N=me(i).filter(_=>_.id.startsWith("grammar-")&&_.id.includes("-continuation")).sort((_,j)=>j.priority-_.priority),K=this.parseBodyWithGrammarPatterns(r,T,N,i,M);v=this.foldLoopBlocks([...M,...K]);}else v=this.foldLoopBlocks(M),r.isAtEnd()||this.recordDroppedTokens(r.tokens.slice(r.position()),i,"handler body tail");}else {let z=me(i).filter(g=>g.command!=="on").sort((g,A)=>A.priority-g.priority),k=y?e.roleStarts?.get("action"):void 0;if(k!==void 0&&k<r.position()){let g=new oe(r.tokens.slice(k),i);for(v=this.parseBodyWithClauses(g,z,i);!r.isAtEnd();)r.advance();}else v=this.parseBodyWithClauses(r,z,i);}let E=v.length>1?[er(v,"then",{sourceLanguage:i})]:v;return hr(h,E,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,i){let n=[],a=[],o=0,s=[],u=(c=0)=>{let d=Ir(n);o=d+c,s.length=0;for(let m=0;m<d;m++)s.push("loop");for(let m=0;m<c;m++)s.push("while");};for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(a.length===0){let z=this.consumeJsBlock(e,i)??this.consumeVerbFinalJsBlock(e,i);if(z){n.push(z);continue}let k=this.tryParseConditionalBlock(e,r,i);if(k){n.push(k);continue}let g=this.tryParseUnlessGuard(e,r,i);if(g){n.push(...g);continue}}let d=c.kind==="conjunction"||c.kind==="keyword"&&this.isThenAt(c,ye(e.tokens,e.position()),i),m=a[a.length-1],p=e.peek(1),f=m?.value.toLowerCase()==="at"&&p?.value.toLowerCase()==="of"||st(i,c.value,m?.value,p?.value),h=c.kind==="keyword"&&this.isEndKeyword(c.value,i)&&!f&&!Ne(ye(e.tokens,e.position()),i);if((h||!f&&this.isBlockEndToken(c,ye(e.tokens,e.position()),i))&&s.every(z=>z==="loop")&&this.closeLoopAtEnd(e,a,n,r,i)){a.length=0,u();continue}if(h&&o>0){o--,s.pop(),a.push({...c,metadata:{...c.metadata,closesTrackedBlock:true}}),e.advance();continue}if(d&&s.includes("if")){a.push(c),e.advance();continue}if(d){if(a.length>0){let z=this.parseClause(a,r,i);n.push(...z),a.length=0,u(z.filter(k=>{let g=k;return g.action==="while"&&(!Array.isArray(g.body)||g.body.length===0)}).length);}e.advance();continue}if(h){e.advance();let z=[];for(;!e.isAtEnd();){let k=e.peek();if(!k||k.kind==="conjunction"||k.kind==="keyword"&&(this.isThenKeyword(k.value,i)||this.isEndKeyword(k.value,i)))break;z.push(k),e.advance();}if(z.length>0){let k=this.coverageMark(),g=a.length>0?this.parseClause(a,r,i):[];g.length===0&&a.length>0?(this.coverageRollback(k),n.push(...this.parseClause([...a,...z],r,i))):(n.push(...g),n.push(...this.parseClause(z,r,i)));}else if(a.length>0){let k=this.parseClause(a,r,i);n.push(...k);}a.length=0;break}let y=(c.normalized??c.value).toLowerCase(),E=lt(c);if(c.kind==="keyword"||E){let z=this.isIfKeyword(y,i),k=Mr(a,a.length);(y==="for"||y==="while")&&k&<(k)||z&&k&&this.isElseKeyword(k.value,i)||(E&&s[s.length-1]==="while"?s[s.length-1]="loop":(z||this.isUnlessKeyword(y,i)||y==="while"||y==="for"||E)&&(o++,s.push(z?"if":E||y==="for"?"loop":y==="while"?"while":"other")));}a.push(c),e.advance();}if(a.length>0){let c=this.parseClause(a,r,i);n.push(...c);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),i,"body stream tail"),this.foldFrontedWhileIntoRepeat(n,i);for(let c=n.length-1;c>=0;c--){let d=n[c];d.kind==="command"&&d.action==="for"&&(!(d.roles instanceof Map)||d.roles.size===0)&&(!Array.isArray(d.body)||d.body.length===0)&&n.splice(c,1);}let l=this.foldLoopBlocks(n);return l.length>1?[er(l,"then",{sourceLanguage:i})]:l}closeLoopAtEnd(e,r,i,n,a){let o=Ir(i);if(r.length===0)return o===0?false:(i.push(rr),e.advance(),true);let s=this.coverageMark(),u=this.parseClause([...r],n,a);return u.length===0||o+u.filter(gt).length===0?(this.coverageRollback(s),false):(i.push(...u,rr),e.advance(),true)}foldLoopBlocks(e){let r=[],i=[],n=o=>{(i.length>0?i[i.length-1].body:r).push(o);},a=o=>{let s=i.pop();s&&n(this.buildLoopNode(s.head,s.body,o));};for(let o of e)Ft(o)?a(true):gt(o)?i.push({head:o,body:[]}):n(o);for(;i.length>0;)a(false);return r}buildLoopNode(e,r,i=false){if(r.length===0&&!i)return e;let n=e.roles.get("loopType");if(n?.type==="literal"&&typeof n.value=="number"){let d=new Map(e.roles);return d.set("quantity",n),d.set("loopType",{type:"literal",value:"times"}),this.buildLoopNode({...e,roles:d},r,i)}let a=n?.type==="literal"?String(n.value):void 0,o=e.action==="for"||a==="for"?"for":a==="times"||a==="while"||a==="forever"?a:a==="until"||a==="until-event"?"until":e.roles.has("quantity")?"times":"forever",s=o==="for"?e.roles.get("patient"):void 0,u=s?Uc(s):void 0,l=new Map(e.roles),c=l.get("quantity");return (o==="while"||o==="until")&&c&&!l.has("condition")&&(l.set("condition",c),l.delete("quantity")),gu(e.action==="for"?"for":"repeat",o,Object.fromEntries(l),r,{...u?{loopVariable:u}:{},...e.metadata?{metadata:e.metadata}:{}})}tryTopLevelLoop(e,r,i){let n=this.coverageMark(),a;try{let s=new oe(e.tokens,i);a=this.parseBodyWithClauses(s,r,i);}catch{return this.coverageRollback(n),null}let[o]=a;if(a.length===1&&o.kind==="loop")return o;if(a.length===1&&o.kind==="compound"){let s=o;if(s.statements[0]?.kind==="loop"){let u=s.statements.map(l=>l.metadata?.confidence??.75);return er(s.statements,s.chainType,{sourceLanguage:i,confidence:u.reduce((l,c)=>l+c,0)/u.length})}}return this.coverageRollback(n),null}tryTopLevelCommandSequence(e,r,i){let n=this.coverageMark(),a;try{let l=new oe(e.tokens,i);a=this.parseBodyWithClauses(l,r,i);}catch{return this.coverageRollback(n),null}if(a.length!==1||a[0].kind!=="compound")return this.coverageRollback(n),null;let o=a[0];if(o.statements.length<2)return this.coverageRollback(n),null;let s=o.statements.map(l=>l.metadata?.confidence??.75),u=s.reduce((l,c)=>l+c,0)/s.length;return er(o.statements,o.chainType,{sourceLanguage:i,confidence:u})}foldFrontedWhileIntoRepeat(e,r){for(let i=0;i+1<e.length;i++){let n=e[i],a=e[i+1];if(n.kind!=="command"||n.action!=="while"||a.kind!=="command"||a.action!=="repeat")continue;let o=n.roles.get("condition");if(!o||a.roles.has("condition")||Array.isArray(n.body)||Array.isArray(a.body))continue;let s=new Map(a.roles);s.set("condition",o),s.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(i,2,{...a,roles:s,metadata:{...a.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(a.metadata?.confidence??0,n.metadata?.confidence??0)}});}}takeRepeatCount(e,r,i){if(O(i)?.wordOrder==="SOV"){let o=B.countBeforeVerb(r,i);if(o<0)return;let s=r[o];return r.length=o,s}let n=e.mark();e.peek()?.kind==="particle"&&e.advance();let a=e.peek();if(a&&B.countsBefore(a,e.peek(1),i))return e.advance(),e.advance(),a;if(!B.isCountToken(a)){e.reset(n);return}return e.advance(),e.peek()?.kind==="identifier"&&e.advance(),a}static isCountToken(e){let r=e?.kind==="literal"?jr(e):null;return r?.type==="literal"&&typeof r.value=="number"}static countsBefore(e,r,i){return !e||!r||!tn[i]?.includes(r.value)?false:e.kind==="identifier"||B.isCountToken(e)}static countBeforeVerb(e,r){let i=B.isCountToken,n=e.length;return e[n-1]?.kind==="particle"&&n--,B.countsBefore(e[n-2],e[n-1],r)?n-2:(e[n-1]?.kind==="identifier"&&i(e[n-2])&&n--,i(e[n-1])?n-1:-1)}loopHeadReadsBody(e,r,i){if(O(i)?.wordOrder!=="SOV")return false;if(B.countBeforeVerb(r,i)>=0)return true;let n=e.captured.get("loopType");return n?.type==="literal"&&typeof n.value!="number"&&!e0.has(String(n.value))}bareRepeatHead(e,r){let i=e?jr(e):null;return de("repeat",e&&i?{loopType:Y("times"),quantity:Qi(i,{start:e.position.start,end:e.position.end})}:{},{sourceLanguage:r,confidence:.6})}parseClause(e,r,i){if(e.length===0)return [];let n=null,a=e,o=e[e.length-1];if(o&&e.length>=2){let y=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(y,i)&&(n="unless",a=e.slice(0,-1));}let s=null;if(n&&a.length>=3){let y=O(i),E=y?B.buildVerbLookup(y):null;if(E)for(let z=1;z<a.length-1;z++){let k=a[z],g=E.get(k.value.toLowerCase())??(k.normalized?E.get(k.normalized.toLowerCase()):void 0);if(g&&!B.CONDITION_OPERATORS.has(g)){s=a.slice(0,z),a=a.slice(z);break}}}let u=new oe(a,i),l=[],c=this.coverageMark(),d=0,m=[],p=s,f=()=>{if(m.length===0)return;let y=m.slice();if(m.length=0,n&&l.length===0&&p===null){p=y;return}let E=y[0];if(!(E&&(E.kind==="identifier"||E.kind==="selector"||E.kind==="literal"||E.kind==="reference"))){this.recordDroppedTokens(y,i,"body clause");return}let k=false;for(let g of this.parseSOVClauseByVerbAnchoring(y,i)){let A=g.action,b=g.roles;A&&se(A)&&b instanceof Map&&b.size>0&&(l.push(g),k=true);}k||this.recordDroppedTokens(y,i,"body clause");};for(;!u.isAtEnd();){let y=u.peek(),E=!!y&&y.normalized?.toLowerCase()==="repeat",z=u.mark(),k=ke.matchBest(u,r);if(E&&k&&(k.pattern.command!=="repeat"||this.loopHeadReadsBody(k,m,i))){u.reset(z),u.advance();let g=this.takeRepeatCount(u,m,i);f(),l.push(this.bareRepeatHead(g,i)),d++;continue}if(!k&&y&&this.isIfKeyword((y.normalized??y.value).toLowerCase(),i)){let g=this.tryParseConditionalBlock(u,r,i);if(g){f(),l.push(g),d++;continue}}if(k&&k.pattern.command==="if"){let g=u.mark(),A=m.length;for(u.reset(z);!u.isAtEnd();){let S=u.peek();if(!S||this.isIfKeyword((S.normalized??S.value).toLowerCase(),i))break;m.push(S),u.advance();}let b=this.tryParseConditionalBlock(u,r,i);if(b){f(),l.push(b),d++;continue}m.length=A,u.reset(g);}if(k){f();let g=this.buildCommand(k,i);l.push(g),d++,this.tryAttachTrailingRole(u,g,i),this.tryAttachTrailingStyle(u,g,i),this.tryAttachTrailingExpressionRole(u,g,i),this.tryAttachTrailingDuration(u,g);}else {let g=m.length===0?this.tryParsePseudoCommand(u,r,i):null;if(g){f(),l.push(g),d++;continue}let A=u.peek(),b=A?.kind==="identifier"&&A.value.toLowerCase()==="repeat";if(A&&(A.normalized?.toLowerCase()==="repeat"||b)){let S=u.mark();u.advance();let D=this.takeRepeatCount(u,m,i);if(D||!b){f(),l.push(this.bareRepeatHead(D,i)),d++;continue}u.reset(S);}A&&m.push(A),u.advance();}}f();let h=l;if(d===0){let y=this.parseSOVClauseByVerbAnchoring(a,i);y.length>0&&(this.coverageRollback(c),h=y);}let v=p;return n&&h.length>0&&v&&v.length>0?[de(n,{condition:{type:"expression",raw:this.joinTokenText(v,i)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85}),...h]:n&&v&&v.length>0&&h.length===0?[de(n,{condition:{type:"expression",raw:this.joinTokenText(v,i)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85})]:h}tryAttachTrailingDuration(e,r){let i=r.roles;if(i.has("duration")||!se(r.action)?.roles.some(o=>o.role==="duration"&&!o.required))return;let a=e.peek();!a||!/^\d+(?:\.\d+)?(?:ms|s|m|h)$/.test(a.value)||(i.set("duration",Y(a.value,"duration")),e.advance());}tryAttachNewWindow(e,r){let i=r.roles;if(r.action!=="go"||i.has("manner"))return;let[n,a,o]=[e.peek(),e.peek(1),e.peek(2)];if(!(n?.value.toLowerCase()!=="in"||a?.value.toLowerCase()!=="new")&&!(!o||(o.normalized??o.value).toLowerCase()!=="window")){i.set("manner",be("window"));for(let s=0;s<3;s++)e.advance();}}tryAttachTrailingRole(e,r,i){let n=se(r.action);if(!n)return;let a=O(i);if(!a)return;let o=r.roles,s=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let d=(l.normalized??l.value).toLowerCase();return ct.has(d)?false:d==="body"||d==="it"||d==="you"||d==="result"||d==="document"||d==="window"||this.boundIdentifiers.has(l.value)?true:c?false:l.kind==="identifier"||l.kind==="reference"},u=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:c}of u){if(!n.roles.some(v=>v.role===l))continue;let d=a.roleMarkers?.[l];if(!d)continue;let m=o.get(l);if(m&&!(m.type==="reference"&&m.value==="me"))continue;let p=v=>{if(!v||v.kind!=="particle"&&v.kind!=="keyword")return false;let y=v.value.toLowerCase();return d.primary?.toLowerCase()===y?true:c?false:(v.normalized??"").toLowerCase()===l?true:!!d.alternatives?.some(E=>E.toLowerCase()===y)},f=e.peek(),h=e.peek(1);if(!f||!h)return;if(c&&d.position==="after"){let v=e.peek(2),y=(f.normalized??f.value).toLowerCase();if(Gc.has(y)&&h.kind==="selector"&&p(v)){o.set(l,{type:"expression",raw:`${y} ${h.value}`}),e.advance(),e.advance(),e.advance();return}}if(d.position==="after"){if(s(f,c)&&p(h)){let v=this.tokenToSemanticValue(f);e.advance(),e.advance(),v&&o.set(l,v);return}if(c&&s(f,c)){let v=e.peek(2),y=e.peek(3);if((h.normalized??h.value).toLowerCase()==="in"&&v&&!p(v)&&p(y)){let E=this.tokenToSemanticValue(f);e.advance(),e.advance(),e.advance(),e.advance(),E&&o.set(l,E);return}}}else if(p(f)&&s(h,c)){e.advance();let v=this.tokenToSemanticValue(e.advance());v&&o.set(l,v);return}}}tryAttachTrailingStyle(e,r,i){if(r.action!=="fetch"&&r.action!=="render")return;let n=r.roles;if(!se(r.action)?.roles.some(y=>y.role==="style"))return;let o=n.get("style");if(o){if(o.type==="expression"&&typeof o.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(o.raw)&&e.peek()?.value===":"){let y=gr(e,o.raw);y&&n.set("style",{type:"expression",raw:y});}this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(r.action==="fetch"){let y=n.get("patient"),E=n.get("source");if(y&&E&&(y.type==="literal"||y.type==="expression")&&E.type==="expression"&&typeof E.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(E.raw)&&e.peek()?.value===":"){let z=gr(e,E.raw);z&&(n.set("source",{type:"expression",raw:z}),this.tryAttachResponseTypeAfterStyle(e,r,i));return}}let u=O(i)?.roleMarkers?.style;if(!u)return;if(u.position==="before"){let y=new Set([u.primary,...u.alternatives??[]].map(g=>g.toLowerCase())),E=e.peek();if(!E||!y.has(E.value.toLowerCase()))return;let z=e.mark();e.advance();let k=gr(e);if(!k){e.reset(z);return}n.set("style",{type:"expression",raw:k}),this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(u.position!=="after")return;let l=new Set([u.primary,...u.alternatives??[]].map(y=>y.toLowerCase())),c=y=>y.kind==="conjunction"||y.kind==="keyword"&&(this.isThenKeyword(y.value,i)||this.isEndKeyword(y.value,i)),d=24,m=-1,p=0;for(let y=0;y<d;y++){let E=e.peek(y);if(!E||c(E))break;if(E.value==="("||E.value==="{"?p++:(E.value===")"||E.value==="}")&&(p=Math.max(0,p-1)),p===0&&(E.kind==="particle"||E.kind==="keyword")&&l.has(E.value.toLowerCase())){m=y;break}}if(m<=0)return;let f=[];for(let y=0;y<m;y++){let E=e.peek(y);E&&f.push(E);}if(f.length===1&&B.RESPONSE_TYPE_WORDS.has(f[0].value.toLowerCase()))return;let h=new oe(f,i),v=gr(h);n.set("style",{type:"expression",raw:v&&h.isAtEnd()?v:this.joinTokenText(f,i)});for(let y=0;y<=m;y++)e.advance();this.tryAttachResponseTypeAfterStyle(e,r,i);}tryAttachResponseTypeAfterStyle(e,r,i){let n=r.roles;if(n.has("responseType")||!se(r.action)?.roles.some(c=>c.role==="responseType"&&!c.required))return;let o=c=>!!c&&B.RESPONSE_TYPE_WORDS.has(c.toLowerCase()),s=e.peek();if(!s)return;let u=c=>{n.set("responseType",{type:"expression",raw:c});};if(B.AS_MARKERS_BEFORE[i]?.some(c=>s.value.toLowerCase()===c)){let c=e.peek(1);c&&o(c.value)&&(e.advance(),e.advance(),u(c.value));return}if(o(s.value)){e.advance(),u(s.value);for(let c of B.AS_MARKERS_AFTER[i]??[])if(c.every((d,m)=>e.peek(m)?.value.toLowerCase()===d)){for(let d=0;d<c.length;d++)e.advance();break}}}tryAttachTrailingExpressionRole(e,r,i){let n=r.action,a=n==="js"?{role:"patient",terminator:"boundary"}:n==="go"||n==="scroll"?{role:"destination",terminator:"destination-marker"}:null;if(!a)return;let o=r.roles,s=o.get(a.role);if(n==="go"&&s&&s.type==="expression"&&String(s.raw).toLowerCase()==="url"){let y=e.peek();if(y&&!ct.has((y.normalized??y.value).toLowerCase())){let z=this.tokenToSemanticValue(y);if(z.type==="literal"||z.type==="selector"){o.set(a.role,z),o.set("method",{type:"literal",value:"url"}),e.advance();return}}let E=o.get("patient");if(E&&(E.type==="literal"||E.type==="selector")){o.set(a.role,E),o.set("method",{type:"literal",value:"url"}),o.delete("patient");return}}if(n==="go"&&s&&s.type==="expression"){let y=/^url\s+(\S+)$/i.exec(String(s.raw??""));if(y){let E=y[1].replace(/^["']|["']$/g,"");o.set(a.role,{type:"literal",value:E,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(n==="go"&&!s){let y=o.get("patient");if(y&&y.type==="expression"&&String(y.raw).toLowerCase()==="url"){let E=e.peek();if(E&&!ct.has((E.normalized??E.value).toLowerCase())){let z=this.tokenToSemanticValue(E);if(z.type==="literal"||z.type==="selector"){o.set(a.role,z),o.set("method",{type:"literal",value:"url"}),o.delete("patient"),e.advance();return}}}}if(s&&!(s.type==="reference"&&s.value==="me"))return;let u=O(i);if(!u)return;let l=null;if(a.terminator==="destination-marker"){let y=u.roleMarkers?.destination;if(!y||y.position!=="after")return;l=y.primary.toLowerCase();}let c=y=>y.kind==="conjunction"||y.kind==="keyword"&&(this.isThenKeyword(y.value,i)||this.isEndKeyword(y.value,i)),d=24,m=[],p=0,f=false;for(let y=0;y<d;y++){let E=e.peek(y);if(!E||c(E))break;if(E.value==="("||E.value==="{"?p++:(E.value===")"||E.value==="}")&&(p=Math.max(0,p-1)),l!==null&&p===0&&(E.kind==="particle"||E.kind==="keyword")&&E.value.toLowerCase()===l){f=true;break}m.push(E);}if(m.length===0||l!==null&&!f)return;let h=m.length+(f?1:0);if(n==="go"&&m.length===2&&m[0].value.toLowerCase()==="url"){let y=this.tokenToSemanticValue(m[1]);if(y.type==="literal"||y.type==="selector"){o.set(a.role,y),o.set("method",{type:"literal",value:"url"});let E=o.get("patient");E&&E.type==="reference"&&E.value==="me"&&!se(n)?.roles.some(z=>z.role==="patient")&&o.delete("patient");for(let z=0;z<h;z++)e.advance();return}}let v=m;if(n==="js"){let y=u.keywords?.js,E=k=>[y?.primary,...y?.alternatives??[]].some(g=>!!g&&g.length>k.value.length&&g.includes(k.value)),z=0;for(;z<v.length&&E(v[z]);)z++;if(v=v.slice(z),v.length===0)return}if(o.set(a.role,{type:"expression",raw:this.joinTokenText(v,i)}),a.role!=="patient"){let y=o.get("patient");y&&y.type==="reference"&&y.value==="me"&&!se(n)?.roles.some(E=>E.role==="patient")&&o.delete("patient");}for(let y=0;y<h;y++)e.advance();}static buildVerbLookup(e){let r=new Map;for(let[i,n]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(i)&&(r.set(n.primary.toLowerCase(),i),n.alternatives))for(let a of n.alternatives)r.set(a.toLowerCase(),i);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[i,n]of Object.entries(e.roleMarkers)){if(!n)continue;if((i!=="event"||!r.has(n.primary))&&r.set(n.primary,i),n.alternatives)for(let o of n.alternatives)r.has(o)||r.set(o,i);}return r}parseSOVClauseByVerbAnchoring(e,r){let i=O(r);if(!i||i.wordOrder!=="SOV")return [];let n=B.buildVerbLookup(i),a=B.buildMarkerToRoleLookup(i),o=[],s=0;for(;s<e.length;){let u=-1,l="";for(let f=s;f<e.length;f++){let h=e[f];if(a.has(h.value))continue;let v=n.get(h.value.toLowerCase()),y=h.normalized?n.get(h.normalized.toLowerCase()):void 0,E=v||y;if(E){u=f,l=E;break}}if(u===-1)break;let c=e.slice(s,u),d=e.length;for(let f=u+1;f<e.length;f++){let h=e[f];if(h.kind==="conjunction"||this.isThenKeyword(h.value,r)){d=f;break}if(f>u+1&&!a.has(h.value)&&(n.get(h.value.toLowerCase())||(h.normalized?n.get(h.normalized.toLowerCase()):void 0))){d=f;break}}let m=e.slice(u+1,d),p=this.extractRolesFromMarkedTokens(c,m,a,l,r);if(o.push(de(l,p,{sourceLanguage:r,confidence:.7})),s=d,s<e.length){let f=e[s];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&s++;}}return o}extractRolesFromMarkedTokens(e,r,i,n,a){let o={},s=(l,c)=>{let d=this.isEndKeyword(l.value,a),m=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !d&&!m?false:l.metadata?.closesTrackedBlock===true||d?true:!(c&&c.kind==="selector")},u=l=>{let c=[];for(let d=0;d<l.length;d++){let m=l[d];if(s(m,l[d+1]))continue;let p=i.get(m.value);if(p&&m.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c,a);if(f){let h=this.mapRoleForCommand(p,n,o);h&&(o[h]=f);}c=[];}else c.push(m);}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!o.duration&&se(n)?.roles.some(m=>m.role==="duration"))o.duration={type:"literal",value:c[0].value,dataType:"string"};else {let m=this.tokensToSemanticValue(c,a);m&&(o.patient?o.destination||(o.destination=m):o.patient=m);}};return u(e),u(r),o}mapRoleForCommand(e,r,i){return r==="set"&&(e==="patient"?e="destination":e==="destination"&&(e="patient")),i[e]?e==="patient"&&!i.destination?"destination":e==="destination"&&!i.patient?"patient":e==="source"&&!i.source?"source":null:e}tokensToSemanticValue(e,r){if(e.length===0)return null;let i=e.filter(s=>s.kind!=="whitespace");if(i.length===0)return null;if(i.length>=2&&(i[0].kind==="selector"||/^[#.@*<]/.test(i[0].value))){let s=i.findIndex((u,l)=>l>0&&(u.normalized??u.value).toLowerCase()==="in");s>0&&(i=i.slice(0,s));}if(i.length===1)return this.tokenToSemanticValue(i[0]);let n=this.joinTokenText(i,r);if(wn(n))return {type:"expression",raw:n};let a=i.map(s=>s.value).join(""),o=i[0];return o.kind==="selector"||o.value.startsWith("#")||o.value.startsWith(".")||o.value.startsWith("@")||o.value.startsWith("*")?Re(a):o.kind==="literal"||o.value.startsWith('"')||o.value.startsWith("'")?Y(t0(a),"string"):o.kind==="reference"?be(a):Y(n)}tokenToSemanticValue(e){return jr(e)??Y(e.value)}parseBodyWithGrammarPatterns(e,r,i,n,a=[]){let o=[],s=()=>Ir([...a,...o]),u=[],l=false,c=()=>{if(!l&&u.length>0){let p=this.parseSOVClauseByVerbAnchoring(u,n);o.push(...p),p.length===0&&this.recordDroppedTokens(u,n,"fused body walk");}else u.length>0&&this.recordDroppedTokens(u,n,"fused body walk");u=[],l=false;},d=0,m=()=>o.filter(p=>{let f=p;return f.action==="while"&&(!Array.isArray(f.body)||f.body.length===0)}).length-d;for(;!e.isAtEnd();){let p=e.peek();if(p&&this.isThenKeyword(p.value,n)){c(),e.advance();continue}if(p&&s()>0&&!this.isEndKeyword(p.value,n)&&this.isBlockEndToken(p,ye(e.tokens,e.position()),n)&&!st(n,p.value,e.peek(-1)?.value,e.peek(1)?.value)){c(),o.push(rr),e.advance();continue}if(p&&this.isEndKeyword(p.value,n)){let h=e.peek(-1),v=e.peek(1);if(!st(n,p.value,h?.value,v?.value)){if(c(),s()>0){o.push(rr),e.advance();continue}if(m()>0){d++,e.advance();continue}e.advance();break}}if(p&&!l&&this.isIfKeyword((p.normalized??p.value).toLowerCase(),n)){c();let h=this.tryParseConditionalBlock(e,r,n);if(h){o.push(h),l=true;continue}}let f=false;if(i.length>0){let h=ke.matchBest(e,i);if(h){let v=h.pattern.command,y={};for(let[k,g]of h.captured)k!=="event"&&k!=="action"&&k!=="continues"&&(y[k]=g);let E=de(v,y,{sourceLanguage:n,patternId:h.pattern.id});o.push(E),f=true,l=true;let z=h.captured.get("continues");if(z&&z.type==="literal"&&z.value==="then")continue}}if(!f){let h=e.mark(),v=ke.matchBest(e,r);if(v){if(v.pattern.command==="if"){let E=e.mark();for(e.reset(h);!e.isAtEnd();){let k=e.peek();if(!k||this.isIfKeyword((k.normalized??k.value).toLowerCase(),n))break;e.advance();}let z=this.tryParseConditionalBlock(e,r,n);if(z){c(),o.push(z),l=true;continue}e.reset(E);}let y=this.buildCommand(v,n);o.push(y),this.tryAttachTrailingRole(e,y,n),f=true,l=true;}}f||(p&&u.push(p),e.advance());}c(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),n,"fused body walk");for(let p=o.length-1;p>=0;p--){let f=o[p];f.kind==="command"&&f.action==="for"&&(!(f.roles instanceof Map)||f.roles.size===0)&&(!Array.isArray(f.body)||f.body.length===0)&&o.splice(p,1);}return o}tryCompoundCommandParsing(e,r,i){let n=e.tokens,a=n.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,i)),o=n.some(c=>this.isElseKeyword(c.value,i));if(!a&&!o)return null;let s=new oe(n,i),u=this.coverageMark(),l=this.parseBodyWithClauses(s,r,i);return l.length===0?(this.coverageRollback(u),null):l[0]}static isEnEventKeyword(e){if(typeof e!="string")return false;let r=e.toLowerCase(),i=B.enEventKeywordCache.get(r);if(i!==void 0)return i;let n=false;try{let a=Z(r,"en").tokens;n=a.length===1&&a[0]?.kind==="keyword";}catch{n=false;}return B.enEventKeywordCache.set(r,n),n}matchEventMarkerPhrase(e,r,i){let n=B.SOV_EVENT_MARKER_PHRASES[i];if(!n)return 0;for(let a of n)if(a.every((o,s)=>e[r+s]?.value===o))return a.length;return 0}hasSOVEventMarkerHead(e,r){let i=B.SOV_EVENT_MARKERS[r];if(i===void 0)return false;let{tokens:n}=Z(e,r),a=Fe[r],o=new Set;if(a)for(let s of Object.keys(a))o.add(s.toLowerCase());for(let s=0;s<n.length;s++){let u=n[s],l=u.value.toLowerCase(),c=u.normalized?.toLowerCase();if(!(!!c&&(B.KNOWN_EVENTS.has(c)||Be.has(c))||B.KNOWN_EVENTS.has(l)||Be.has(l)||o.has(l)))continue;let m=this.matchEventParamPhrase(n,s+1).len,p=n[s+1+m];if(p&&(p.kind==="particle"||p.kind==="keyword")&&i.has(p.value)||this.matchEventMarkerPhrase(n,s+1+m,r)>0)return true}return false}tryScrollModifiers(e,r,i){let n=p=>p?.value.toLowerCase()??"",a=-1,o=-1;for(let p=0;p<e.length&&a<0;p++){let f=n(e[p])==="the"?p+1:p;Bi.has(n(e[f]))&&(Bi.has(n(e[f+1]))&&f++,!(n(e[f+1])!=="of"||!e[f+2])&&(a=p,o=f+1));}let s=a<0?e.findIndex(p=>Yc.has(n(p))):-1;if(a<0&&s<0)return null;let u=a>=0?a:s,l=a>=0?o:s,c=r.slice(0,e[u].position.start).trimEnd(),d=r.slice(e[l].position.end).trimStart(),m=c?c.length+1:0;try{let p=this.parse(c?`${c} ${d}`:d,i),f=[],h=E=>{if(!E)return;E.kind==="command"&&(E.action==="go"||E.action==="scroll")&&f.push(E);let z=E;for(let k of yr){let g=z[k];Array.isArray(g)&&g.forEach(A=>h(A));}};h(p??void 0);let v=E=>E.roles.get("destination")?.position?.start??-1,y=E=>f.filter(z=>v(z)>=0&&v(z)<=E).reduce((z,k)=>!z||v(k)>v(z)?k:z,void 0);if(!p)return null;if(a>=0){let E=y(m),z=E?.roles.get("destination"),k=e[o+1];if(!E||!z||!Xc(z,k))return null;let g=e.slice(a,o).map(A=>A.value.toLowerCase());E.scrollPosition=g.join(" ");}else {let E=y(e[s].position.start-1);if(!E)return null;E.scrollBehavior=n(e[s]);}return p}catch{return null}}tryDoNotThrow(e,r,i){let n=u=>u?.value.toLowerCase(),a=e.findIndex((u,l)=>n(u)==="do"&&n(e[l+1])==="not"&&n(e[l+2])==="throw");if(a<0)return null;let o=e[a].position.start,s=(r.slice(0,e[a].position.start).trimEnd()+" "+r.slice(e[a+2].position.end).trimStart()).trim();try{let u=this.parse(s,i),l=[],c=p=>{if(!p)return;p.kind==="command"&&p.action==="fetch"&&l.push(p);let f=p;for(let h of yr){let v=f[h];Array.isArray(v)&&v.forEach(y=>c(y));}};c(u??void 0);let d=p=>p.roles.get("source")?.position?.start??-1,m=l.filter(p=>d(p)>=0&&d(p)<o).reduce((p,f)=>!p||d(f)>d(p)?f:p,void 0);return !u||!m?null:(m.doNotThrow=!0,u)}catch{return null}}tryTellTo(e,r,i){let n=u=>(u.normalized??u.value).toLowerCase()==="tell",a=e.findIndex(n);if(a<0)return null;let o=O(i)?.roleMarkers?.destination,s=new Set([o?.primary,...o?.alternatives??[]].filter(u=>!!u));for(let u=a+1;u<e.length;u++){if(e[u].value.toLowerCase()!=="to")continue;let l=e[u].position.start,c=(r.slice(0,l).trimEnd()+" "+r.slice(e[u].position.end).trimStart()).trim();try{let d=this.parse(c,i);if(!d)continue;let m=[],p=E=>{if(!E)return;E.kind==="command"&&m.push(E);let z=E;for(let k of yr){let g=z[k];Array.isArray(g)&&g.forEach(A=>p(A));}};p(d);let f=E=>E.roles.get("destination")?.position?.start??-1,h=m.filter(E=>E.action==="tell"&&f(E)>=0&&f(E)<l).reduce((E,z)=>!E||f(z)>f(E)?z:E,void 0);if(!h)continue;let v=h.roles.get("destination")?.position?.end??-1;if(v<0||!e.filter(E=>E.position.start>=v&&E.position.start<l).every(E=>n(E)||s.has(E.value)))continue;return h.tellTo=!0,d}catch{continue}}return null}tryLoopIndex(e,r,i){let n=l=>l?.value.toLowerCase(),a=new Set;for(let l of me(i))if(!(l.command!=="repeat"&&l.command!=="for")){for(let c of l.template.tokens)if(c.type==="literal")for(let d of [c.value,...c.alternatives??[]])a.add(d.toLowerCase());}let o=l=>a.has(l.value.toLowerCase()),s=O(i)?.roleMarkers?.style?.primary?.toLowerCase(),u=l=>n(l)==="with"||!!s&&n(l)===s;for(let l=0;l+1<e.length;l++){let c=u(e[l])&&n(e[l+1])==="index",d=n(e[l])==="index";if(!c&&!d)continue;let m=e[l].position.start,p=(r.slice(0,m).trimEnd()+" "+r.slice(e[l+1].position.end).trimStart()).trim();try{let f=this.parse(p,i);if(!f)continue;let h=[],v=b=>{if(!b)return;b.kind==="loop"&&h.push(b);let S=b;for(let D of yr){let w=S[D];Array.isArray(w)&&w.forEach(C=>v(C));}};v(f);let y=b=>Math.max(-1,...[...b.roles.values()].map(S=>S.position?.end??-1).filter(S=>S<=m)),E=h.filter(b=>y(b)>=0).reduce((b,S)=>!b||y(S)>y(b)?S:b,void 0);if(!E)continue;let z=e.filter(b=>b.position.start>=y(E)&&b.position.start<m),k=E.roles.get("quantity"),g=k?.type==="literal"&&typeof k.value=="number"?k.position?.end:void 0,A=g===void 0?void 0:e.find(b=>b.position.start>=g);if(!z.every(b=>b===A||o(b)))continue;return E.indexVariable=c?"index":e[l+1].value,c&&(E.indexWith=!0),f}catch{continue}}return null}tryWaitAlternatives(e,r,i){let n=v=>!!v&&(v.normalized??v.value).toLowerCase()==="wait";if(!e.some(v=>n(v)))return null;let a=v=>(v.normalized??v.value).toLowerCase(),o=v=>{if(!v)return;let y=z=>B.KNOWN_EVENTS.has(z)||Be.has(z);if(y(a(v)))return a(v);let E=Ln(v.value,i);return y(E)?E:void 0},s=v=>o(v)!==void 0,u=v=>!!v&&/^\d+(?:\.\d+)?(?:ms|s)$/.test(v.value),l=O(i)?.roleMarkers?.source,c=new Set([l?.primary,...l?.alternatives??[]].filter(Boolean).map(v=>v.toLowerCase())),d=v=>!!v&&((v.normalized??"")==="source"||c.has(v.value.toLowerCase())),m=l?.position!=="after",p=O(i)?.wordOrder==="SOV",f=(v,y)=>p?n(e[y])||e[y]?.kind==="particle"&&n(e[y+1]):n(e[v-1])||n(e[v-2]),h=v=>{let y=Nn(o(e[v]),i).split(/\s+/);return y.length<2||e[v].value!==y[0]?1:y.every((E,z)=>z===0||e[v+z]?.value===E)?y.length:1};for(let v=0;v<e.length;v++){if(!s(e[v]))continue;let y=[],E=v+h(v),z=this.matchEventParamPhrase(e,E);y.push(z.names.length>0?{event:o(e[v]),params:z.names}:{event:o(e[v])});let k=E+z.len;for(;Vr(e[k]??{value:""},i);){let F=e[k+1];if(s(F)){let T=k+1+h(k+1),N=this.matchEventParamPhrase(e,T);y.push(N.names.length>0?{event:o(F),params:N.names}:{event:o(F)}),k=T+N.len;}else if(u(F))y.push({duration:F.value}),k+=2;else break}let g=k,A,b;if(m&&d(e[k])&&e[k+1]?(A=[k,k+1],b=e[k+1]):!m&&e[k]&&d(e[k+1])&&(A=[k,k+1],b=e[k]),!(y.length>1||z.names.length>0||!!A))continue;let D=A?A[1]+1:g;if(!f(v,D))continue;let w=[];g>E&&w.push([e[E-1].position.end,e[g-1].position.end]),A&&w.push([e[A[0]].position.start,e[A[1]].position.end]),w.sort((F,T)=>F[0]-T[0]);let C="",x=0;for(let[F,T]of w)C+=r.slice(x,F)+" ",x=T;C=(C+r.slice(x)).replace(/\s+/g," ").trim();let R=y[0],M=0;for(let F=0;F<v;F++)o(e[F])===R.event&&f(F,F+1)&&M++;try{let F=this.parse(C,i),T=[],N=_=>{if(!_)return;let j=_.roles?.get("event"),ne=j?.type==="expression"?j.raw:j&&"value"in j?String(j.value):void 0;_.kind==="command"&&_.action==="wait"&&ne?.toLowerCase()===R.event&&T.push(_);let fe=_;for(let H of yr){let L=fe[H];Array.isArray(L)&&L.forEach(I=>N(I));}};N(F??void 0);let K=T[M];if(!F||!K)continue;return K.waitAlternatives=y,b&&(K.waitSource=Jc(b)),F}catch{}}return null}isBodyCommandWord(e,r){let i=(e.normalized??e.value).toLowerCase();return e.kind==="keyword"&&r.has(i)&&!B.KNOWN_EVENTS.has(i)&&!Be.has(i)}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let i=[];for(let n=r+1;n<e.length;n++){let a=e[n].value;if(a===")")return e[r-1]?.position?.end!==e[r]?.position?.start&&e[n+1]?.kind==="particle"?{len:0,names:[]}:{len:n-r+1,names:i};if(a===",")continue;let o=e[n].kind;if(o!=="identifier"&&o!=="keyword"||!/^[A-Za-z_$][\w$]*$/.test(a))break;let s=(e[n].normalized??a).toLowerCase();if(o==="keyword"&&Zc.has(s))break;i.push(a);}return {len:0,names:[]}}isStrippableSourceRef(e,r){if(!e)return false;let i=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(i==="me"||i==="i"||i==="it"))return true;let n=e.value.toLowerCase();return r.has(n)||!!i&&r.has(i)}tryTrailingEventExtraction(e,r,i){let n=Z(e,r).tokens;if(n.length<3)return null;let a=Fe[r],o=new Set;if(a)for(let k of Object.keys(a))o.add(k.toLowerCase());let s=n.length-2,u=n[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))return null;let c=n[n.length-1],d=c.value.toLowerCase(),m=c.normalized?.toLowerCase();if(!(!!m&&B.KNOWN_EVENTS.has(m)||B.KNOWN_EVENTS.has(d)||o.has(d)))return null;let f=m&&B.KNOWN_EVENTS.has(m)?m:a?.[d]??d,h=n.slice(0,s);if(h.length===0)return null;let v=i.filter(k=>k.command!=="on"),y=new oe(h,r),E=this.coverageMark(),z=this.parseBodyWithClauses(y,v,r);return z.length===0?(this.coverageRollback(E),null):hr({type:"literal",value:f},z,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,i){let n=Z(e,r).tokens;if(n.length<3)return null;let a=Fe[r],o=new Set;if(a)for(let s of Object.keys(a))o.add(s.toLowerCase());for(let s=0;s<n.length-1;s++){let u=n[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))continue;let c=n[s+1],d=c.value.toLowerCase(),m=c.normalized?.toLowerCase();if(!(!!m&&B.KNOWN_EVENTS.has(m)||B.KNOWN_EVENTS.has(d)||o.has(d)))continue;let f=m&&B.KNOWN_EVENTS.has(m)?m:a?.[d]??d,h=n.filter((k,g)=>g!==s&&g!==s+1);if(h.length===0)return null;let v=i.filter(k=>k.command!=="on"),y=new oe(h,r),E=this.coverageMark(),z=this.parseBodyWithClauses(y,v,r);return z.length===0?(this.coverageRollback(E),null):hr({type:"literal",value:f},z,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,i){let n=B.SOV_EVENT_MARKERS[r];if(!n)return null;let o=Z(e,r).tokens,s=Fe[r],u=new Set;if(s)for(let A of Object.keys(s))u.add(A.toLowerCase());let l=B.SOV_SOURCE_MARKERS[r],c=-1,d="",m="",p=1,f=[];for(let A=0;A<o.length;A++){let b=o[A],S=b.value.toLowerCase(),D=S,w="",C=S.indexOf("[");C>0&&(D=S.slice(0,C),w=b.value.slice(C));let x=b.normalized?.toLowerCase(),R=x&&(B.KNOWN_EVENTS.has(x)||Be.has(x)),M=u.has(S)||u.has(D),F=B.KNOWN_EVENTS.has(D)||Be.has(D);if(R||M||F){let T=o[A-1];if(T&&(T.normalized??T.value).toLowerCase()==="event")continue;let N;R?N=x:M?N=s?.[S]??s?.[D]??D:N=D;let K=this.matchEventParamPhrase(o,A+1);if(n.size>0){let _=1+K.len,j=o[A+_];j&&j.kind==="selector"&&j.value.startsWith("[")&&(_+=1);let ne=o[A+_];if(ne&&(ne.kind==="particle"||ne.kind==="keyword")&&n.has(ne.value)){c=A,d=N,m=w||(_===K.len+2?o[A+_-1].value:""),p=_+1,f=K.names;break}}else {c=A,d=N,m=w,p=1+K.len+this.matchEventMarkerPhrase(o,A+1+K.len,r),f=K.names;break}}}if(c===-1){let A=new Set(i.filter(b=>b.command!=="on").map(b=>b.command));for(let b=0;b<o.length;b++){let S=o[b];if(S.kind==="identifier")if(n.size>0){let D=1,w=o[b+1];w&&w.kind==="selector"&&w.value.startsWith("[")&&(D=2);let C=o[b+D];if(C&&(C.kind==="particle"||C.kind==="keyword")&&n.has(C.value)){c=b,d=S.value,m=D===2?o[b+1].value:"",p=D+1;break}}else {let D=this.matchEventMarkerPhrase(o,b+1,r);if(D>0){c=b,d=S.value,m="",p=1+D;break}let w=o[b+1];if(w&&w.kind==="keyword"&&w.normalized!=null&&A.has(w.normalized)){c=b,d=S.value,m="",p=1;break}}}}if(c===-1)return null;let h=new Set;for(let A=c;A<c+p;A++)h.add(A);if(l){let A=c+p;if(A<o.length){let b=o[A];if((b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value))h.add(A);else if(this.isStrippableSourceRef(b,l.windowTokens)){let S=o[A+1];S&&(S.kind==="particle"||S.kind==="keyword")&&l.markers.has(S.value)&&(h.add(A),h.add(A+1));}}if(c>=2){let b=o[c-1];(b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(h.add(c-2),h.add(c-1));}for(let b=0;b<c;b++){let S=o[b],D=S.value.toLowerCase(),w=S.normalized?.toLowerCase();if(l.windowTokens.has(D)||w&&l.windowTokens.has(w)){h.add(b);break}}}let v=o.filter((A,b)=>!h.has(b));if(v.length===0)return null;let y=i.filter(A=>A.command!=="on"),E=new oe(v,r),z=this.coverageMark(),k=this.parseBodyWithClauses(E,y,r);if(k.length===0)return this.coverageRollback(z),null;let g={sourceLanguage:r,confidence:.75};return m&&(g.keyFilter=m),hr(B.isEnEventKeyword(d)?{type:"literal",value:d}:{type:"expression",raw:d},k,void 0,g,f)}profileKeywordMatches(e,r,i){let n=O(e)?.keywords?.[r];return n?n.primary?.toLowerCase()===i?true:!!n.alternatives?.some(a=>a.toLowerCase()===i):false}consumeForPostposition(e,r){let i=e.peek();if(!i)return;let n=(i.normalized??"").toLowerCase(),a=O(r)?.keywords?.for;(n==="for"||i.value===a?.primary||(a?.alternatives??[]).includes(i.value))&&e.advance();}isThenAt(e,r,i){return this.isThenKeyword(e.value,i)?!(this.isEndKeyword(e.value,i)&&Ne(r,i)):false}isThenKeyword(e,r){let i=e.toLowerCase(),a={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B"]),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\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),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"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[r];return a?a.has(i):i==="then"||this.profileKeywordMatches(r,"then",i)}isElseKeyword(e,r){let i=e.toLowerCase();return i==="else"?true:this.profileKeywordMatches(r,"else",i)}isEndKeyword(e,r){let i=e.toLowerCase(),n=bu(r);return n?i==="end"||n.has(i):i==="end"||this.profileKeywordMatches(r,"end",i)}isJsKeyword(e){let r=(e.normalized??e.value).toLowerCase();return r==="js"||this.profileKeywordMatches("en","js",r)}isPatientMarker(e,r){let i=O(r)?.roleMarkers?.patient;if(!i?.primary)return false;let n=e.value.toLowerCase();return i.primary.toLowerCase()===n?true:!!i.alternatives?.some(a=>a.toLowerCase()===n)}isJsBlockTerminator(e,r){return this.isEndKeyword(e,r)||this.profileKeywordMatches(r,"end",e.toLowerCase())}consumeVerbFinalJsBlock(e,r){let i=e.mark(),n=0,a=-1;for(;;){let c=e.peek(n);if(!c||this.isThenKeyword(c.value,r)||this.isJsBlockTerminator(c.value,r))break;if(this.isJsKeyword(c)){let d=e.peek(n+1),m=!!d&&c.position?.end!==void 0&&c.position.end===d.position?.start&&this.profileKeywordMatches(r,"js",`${c.value}${d.value}`.toLowerCase()),p=e.peek(n+(m?2:1));if(n>0&&p&&this.isJsBlockTerminator(p.value,r)){a=n;break}}n++;}if(a<=0)return null;let o=[];for(let c=0;c<a;c++){let d=e.peek(c);d&&o.push(d);}let s=o[o.length-1];if(s&&this.isPatientMarker(s,r)&&o.pop(),o.length===0)return e.reset(i),null;let u=this.rawJsBody(o);for(let c=0;c<a;c++)e.advance();e.advance();let l=e.peek();return l&&!this.isJsBlockTerminator(l.value,r)&&e.advance(),e.advance(),de("js",{patient:{type:"expression",raw:u||"()"}},{sourceLanguage:r,patternId:`js-opaque-final-${r}`,confidence:1})}consumeJsBlock(e,r){let i=e.peek();if(!i||!this.isJsKeyword(i))return null;let n=e.mark(),a=[];e.advance();let o=e.peek();o&&i.position?.end!==void 0&&i.position.end===o.position?.start&&this.profileKeywordMatches(r,"js",`${i.value}${o.value}`.toLowerCase())&&e.advance();let s=e.peek();s&&this.isPatientMarker(s,r)&&e.advance();let u=false;for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(e.advance(),this.isJsBlockTerminator(c.value,r)){u=true;break}a.push(c);}if(!u)return e.reset(n),null;let l=this.rawJsBody(a);return de("js",{patient:{type:"expression",raw:l||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}rawJsBody(e){if(e.length===0)return "";let r=e[0].position?.start,i=e[e.length-1].position?.end,n=this.positionSource;if(n!==void 0&&r!==void 0&&i!==void 0){let o=n.slice(r,i),s=u=>u.replace(/\s+/g,"");if(s(o)===s(e.map(u=>u.value).join("")))return o.trim()}let a="";for(let o=0;o<e.length;o++){let s=e[o-1],u=s?.position?.end!==void 0&&e[o].position?.start===s.position.end;o>0&&!u&&(a+=" "),a+=e[o].value;}return a.trim()}isIfKeyword(e,r){let i=e.toLowerCase();return i==="if"?true:this.profileKeywordMatches(r,"if",i)}isUnlessKeyword(e,r){let i=e.toLowerCase();return i==="unless"?true:this.profileKeywordMatches(r,"unless",i)}tryParseUnlessGuard(e,r,i){let n=e.peek();if(!n||!this.isUnlessKeyword((n.normalized??n.value).toLowerCase(),i))return null;let a=e.mark(),o=this.tryParseConditionalBlock(e,r,i,true);if(!o||o.kind!=="conditional")return e.reset(a),null;let s=o;if(s.elseBranch&&s.elseBranch.length>0)return e.reset(a),null;let u=s.roles.get("condition");return u?[de("unless",{condition:u},{sourceLanguage:i,patternId:`unless-${i}-guard`,confidence:1}),...s.thenBranch]:(e.reset(a),null)}isBlockEndToken(e,r,i){let n=r.next;return (this.isEndKeyword(e.value,i)||e.kind==="keyword"&&(e.normalized??"").toLowerCase()==="end"&&!(n&&n.kind==="selector"))&&!Ne(r,i)}opensNestedBlock(e,r,i){let n=(e.normalized??e.value).toLowerCase();return this.isIfKeyword(n,i)?!(r&&this.isElseKeyword(r.value,i)):this.isUnlessKeyword(n,i)?true:n==="repeat"?e.kind==="keyword"||e.kind==="identifier":n!=="for"||e.kind!=="keyword"?false:!(r&<(r))}tryParseConditionalBlock(e,r,i,n=false){let a=e.peek();if(!a)return null;let o=(a.normalized??a.value).toLowerCase();if(!this.isIfKeyword(o,i)&&!(n&&this.isUnlessKeyword(o,i)))return null;let s=e.mark(),u=this.coverageMark();e.advance();let l=e.tokens,c=e.position(),d=[],m=0;for(;!e.isAtEnd();){let w=e.peek();if(!w)break;if(d.length>0&&this.opensNestedBlock(w,Mr(d,d.length),i)){m++,d.push(w),e.advance();continue}if(this.isBlockEndToken(w,ye(e.tokens,e.position()),i)){if(m===0){e.advance();break}m--,d.push(w),e.advance();continue}d.push(w),e.advance();}if(d.length===0)return e.reset(s),this.coverageRollback(u),null;let p=O(i),f=p?.wordOrder==="SOV"?B.buildVerbLookup(p):null,h=0,v=0,y=[];for(;h<d.length;h++){let w=d[h],C=(w.normalized??w.value).toLowerCase();if(h>0&&(this.isIfKeyword(C,i)||this.isUnlessKeyword(C,i))?v++:this.isBlockEndToken(w,ye(l,c+h),i)&&v--,v===0&&this.isThenAt(w,ye(l,c+h),i)){h++;break}if(v===0&&y.length>0){let x=(w.normalized??w.value).toLowerCase(),R=dl(d[h-1],w,y.length===1,i),M=f!==null&&f.has(w.value.toLowerCase())&&!zn.has(x),F=/^\.[a-zA-Z_]\w*$/.test(w.value)&&d[h-1].position?.end!==void 0&&w.position?.start!==void 0&&d[h-1].position.end===w.position.start;if(!B.CONDITION_OPERATORS.has(x)&&!F&&(!R||M)&&(this.tokensBeginCommand(d.slice(h),r,i)||this.sovCommandStartsAt(d.slice(h),f)))break}y.push(w);}if(y.length===0)return e.reset(s),this.coverageRollback(u),null;let z=[],k=[],g=false,A=0;for(;h<d.length;h++){let w=d[h];if(this.opensNestedBlock(w,Mr(d,h),i)?A++:this.isBlockEndToken(w,ye(l,c+h),i)&&A--,A===0&&!g&&this.isElseKeyword(w.value,i)){g=true;continue}(g?k:z).push(w);}let b={type:"expression",raw:this.joinTokenText(y,i)},S=this.parseBranch(z,r,i),D=k.length>0?this.parseBranch(k,r,i):void 0;return S.length===0&&(!D||D.length===0)?(e.reset(s),this.coverageRollback(u),null):Eu(b,S,D,{sourceLanguage:i,patternId:`conditional-${i}-folded`,confidence:1})}joinTokenText(e,r){return Te(e,O(r))}tokensBeginCommand(e,r,i){if(e.length===0)return false;let n=new oe(e,i);return ke.matchBest(n,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let i=s=>r.has(s.value.toLowerCase())||!!s.normalized&&r.has(s.normalized.toLowerCase()),n=s=>s.kind==="identifier"||s.kind==="selector"||s.kind==="literal"||s.kind==="reference",a=0,o=0;for(;a+1<e.length;){let s=e[a],u=e[a+1];if(!n(s)||u.kind!=="particle")break;o+=1,a+=2;let l=e[a];if(o>=1&&l&&i(l))return true}return false}parseBranch(e,r,i){if(e.length===0)return [];let n=new oe(e,i),a=this.parseBodyWithClauses(n,r,i);return a.length===1&&a[0]?.kind==="compound"?a[0].statements:a}extractStandaloneModifiers(e,r){let n=Z(e,r).tokens;if(n.length===0)return {modifiers:null,remainingInput:null};let o=n[0].value.toLowerCase(),s=h=>n[h]?.value.toLowerCase(),u=h=>!!n[h]&&n[h].kind!=="selector";if(o==="on"&&s(1)==="first"&&n.length>2)return {modifiers:{once:true,onceAsFirst:true},remainingInput:e.slice(0,n[1].position.start)+e.slice(n[2].position.start)};if(o==="first"&&u(1))return {modifiers:{once:true,onceAsFirst:true},remainingInput:e.slice(n[1].position.start)};let l=B.STANDALONE_MODIFIERS[o];if(!l)return {modifiers:null,remainingInput:null};let c={},d=1;if(l==="once")c.once=true;else {let h=1;if(h<n.length){let v=n[h],y=n[h+1],E=v.kind==="identifier"&&y?.kind==="literal"&&/^\d+(ms|s|m)?$/.test(y.value);(v.kind==="keyword"||v.kind==="particle"||E)&&(h++,d++);}if(h<n.length){let v=n[h];if(v.kind==="literal"){let y=v.value.match(/^(\d+)(ms|s|m)?$/);if(y){let E=parseInt(y[1],10),z=y[2]||"ms";z==="s"?E*=1e3:z==="m"&&(E*=6e4),c[l]=E,d=h+1;}}}c[l]||(c[l]=l==="debounce"?300:100);}let m=n.slice(d);if(m.length===0)return {modifiers:null,remainingInput:null};let p=m[0].position.start,f=e.slice(p);return {modifiers:c,remainingInput:f}}stripAsyncModifier(e,r){let i=O(r)?.keywords?.async,n=new Set(["async"]);i?.primary&&n.add(i.primary.toLowerCase()),i?.alternatives?.forEach(l=>n.add(l.toLowerCase()));let a=Z(e,r).tokens,o=a.findIndex(l=>n.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let s=a[o],u=(e.slice(0,s.position.start)+e.slice(s.position.end)).replace(/\s{2,}/g," ").trim();return u.length===0?{remainingInput:null}:{remainingInput:u}}stripDoNotThrowModifier(e,r){let i=Z(e,r).tokens;for(let n=0;n<i.length-1;n++){if(i[n].value.toLowerCase()!=="do")continue;let a=-1;for(let l=n+1;l<=n+5&&l<i.length;l++){let c=i[l];if(c.normalized?.toLowerCase()==="throw"){a=l;break}let d=c.kind;if(d==="selector"||d==="literal"||d==="reference"||d==="conjunction")break}if(a===-1)continue;let o=i[n].position.start,s=i[a].position.end,u=(e.slice(0,o)+e.slice(s)).replace(/\s{2,}/g," ").trim();return u.length===0?{remainingInput:null}:{remainingInput:u}}return {remainingInput:null}}static droppedTokenCount(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").reduce((r,i)=>r+(parseInt(/left (\d+) token/.exec(i.message)?.[1]??"0",10)||0),0)}static unconsumedSpans(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").map(r=>/unconsumed: "(.*)"$/.exec(r.message)?.[1]).filter(r=>!!r).map(r=>r.replace(/\s+/g," ").trim())}static withoutSpanDiagnostics(e,r){return {...e,diagnostics:(e.diagnostics??[]).filter(i=>{if(i.code!=="unconsumed-input")return true;let n=/unconsumed: "(.*)"$/.exec(i.message)?.[1];return !n||n.replace(/\s+/g," ").trim()!==r})}}static sourceNounValue(e){if(e.kind==="selector")return Re(e.value);let r=(e.normalized??e.value).toLowerCase();return Oe(r)?{type:"reference",value:r}:{type:"literal",value:e.value,dataType:"string"}}reclaimDanglingFromTail(e,r,i){let n=B.droppedTokenCount,a=B.unconsumedSpans(e);if(a.length===0)return null;let o=n(e),s=O(i)?.roleMarkers?.source,u=new Set;s?.primary&&u.add(s.primary),s?.alternatives?.forEach(c=>u.add(c));let l=Z(r,i).tokens;for(let c=0;c<l.length;c++){let d=l[c];if(d.normalized!=="source"&&!u.has(d.value))continue;let m=s?.position==="after"?c-1:c+1,p=l[m];if(!p||p.kind!=="identifier"&&p.kind!=="keyword")continue;let f=Math.min(d.position.start,p.position.start),h=Math.max(d.position.end,p.position.end),v=r.slice(f,h).replace(/\s+/g," ").trim();if(!a.some(E=>E===v||E.includes(v)))continue;let y=(r.slice(0,f).trimEnd()+" "+r.slice(h).trimStart()).trim();if(!(!y||y===r))try{let E=this.parse(y,i);if(!E||E.kind!=="event-handler")continue;let z=$r(E);if(n(z)<o)return {node:{...z,eventModifiers:{...z.eventModifiers,from:B.sourceNounValue(p)}},input:y}}catch{}}return null}reclaimEventCompoundTail(e,r,i){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=Fe[i];if(!a)return null;let o=e.roles,s=o.get("event"),u=s?.type==="literal"&&typeof s.value=="string"?s.value:null;if(!u)return null;let l=d=>d.replace(/\s+/g," ").trim(),c=Z(r,i).tokens;for(let d of n)for(let m=1;m<c.length;m++)for(let p=m;p<c.length;p++){let f=l(r.slice(c[m].position.start,c[p].position.end));if(f.length>d.length)break;if(f!==d)continue;let h=c[m-1];if((a[h.value]??h.normalized)!==u)break;let y=l(r.slice(h.position.start,c[p].position.end)),E=a[y];if(!E)break;return o.set("event",{type:"literal",value:E,dataType:"string"}),{node:B.withoutSpanDiagnostics(e,d),input:r}}return null}reclaimResponseTypeTail(e,r,i){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=B.AS_MARKERS_BEFORE[i];if(!a)return null;let o=l=>l.replace(/\s+/g," ").trim(),s=B.droppedTokenCount(e),u=Z(r,i).tokens;for(let l=0;l+1<u.length;l++){let c=u[l],d=u[l+1];if(!a.some(f=>c.value.toLowerCase()===f)||!B.RESPONSE_TYPE_WORDS.has(d.value.toLowerCase()))continue;let m=o(r.slice(c.position.start,d.position.end));if(!n.includes(m))continue;let p=(r.slice(0,c.position.start).trimEnd()+" "+r.slice(d.position.end).trimStart()).trim();if(!(!p||p===r))try{let f=this.parse(p,i);if(!f||f.kind!=="event-handler")continue;let h=$r(f);if(B.droppedTokenCount(h)>=s)continue;let v=B.findResponseTypeTarget(h);if(!v)continue;return v.roles.set("responseType",{type:"expression",raw:d.value}),{node:h,input:p}}catch{}}return null}static findResponseTypeTarget(e){let r=null,i=n=>{if(!n||typeof n!="object"||r)return;if(n.kind==="command"){let o=n;if(se(o.action)?.roles.some(u=>u.role==="responseType"&&!u.required)&&!o.roles.has("responseType")){r=o;return}}let a=n;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let s=a[o];Array.isArray(s)&&s.forEach(u=>i(u));}};return i(e),r}reclaimCapturedDestinationTail(e,r,i){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=O(i)?.roleMarkers?.destination,o=new Set;if(a?.primary&&o.add(a.primary),a?.alternatives?.forEach(l=>o.add(l)),o.size===0)return null;let s=l=>l.replace(/\s+/g," ").trim(),u=Z(r,i).tokens;for(let l=0;l+1<u.length;l++){let c=u[l],d=u[l+1],m=o.has(c.value)&&d.normalized==="me",p=c.normalized==="me"&&o.has(d.value);if(!m&&!p)continue;let f=s(r.slice(c.position.start,d.position.end));if(!n.includes(f))continue;let h=false,v=y=>{if(!y||typeof y!="object"||h)return;if(y.kind==="command"){let z=y.roles.get("destination");if(z?.type==="reference"&&z.value==="me"){h=true;return}}let E=y;for(let z of ["body","statements","thenBranch","elseBranch","commands"]){let k=E[z];Array.isArray(k)&&k.forEach(g=>v(g));}};if(v(e),!!h)return {node:B.withoutSpanDiagnostics(e,f),input:r}}return null}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let i=[];for(;;){let n=e.mark(),a=e.peek();if(!a)break;if(!Vr(a,r)){e.reset(n);break}e.advance();let o=e.peek();if(!o){e.reset(n);break}let s=o.normalized||o.value;e.advance(),i.push({type:"literal",value:s});}return i}};Ee.coverageMarkerSurfaces=new Map;Ee.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};Ee.AS_MARKERS_BEFORE={en:["as"],es:["como"],fr:["comme"],pt:["como"],it:["come"],de:["als"],id:["sebagai"],ms:["sebagai","sbg"],sw:["kuwa","kama"],th:["\u0E40\u0E1B\u0E47\u0E19"],vi:["nh\u01B0"],tl:["bilang"],he:["\u05DB"],ar:["\u0643\u0640"],pl:["jako"],ru:["\u043A\u0430\u043A"],uk:["\u044F\u043A"],zh:["\u7684","\u4F5C\u4E3A","\u5F53\u4F5C"]};Ee.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};Ee.enEventKeywordCache=new Map;Ee.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);Ee.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);Ee.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"]),hi:new Set(["\u092A\u0930"])};Ee.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};Ee.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"])},hi:{markers:new Set(["\u0938\u0947"]),windowTokens:new Set(["\u0935\u093F\u0902\u0921\u094B","\u0926\u0938\u094D\u0924\u093E\u0935\u0947\u091C\u093C","window","document"])}};Ee.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Ee.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};var i0=Ee,n0=new i0;function a0(t,e){return n0.parse(t,e)}function jn(t,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...t].sort((i,n)=>{let a=i[r]??99,o=n[r]??99;return a-o})}function ur(t,e){let r,i;if(t.markerOverride&&t.markerOverride[e.code]!==void 0)r=t.markerOverride[e.code],i=r?Me(t,e.code,r):void 0;else {let n=e.roleMarkers[t.role];if(n){r=n.primary;let a=Me(t,e.code,r)??[],o=[...new Set([...n.alternatives??[],...a])].filter(s=>s!==r);i=o.length?o:void 0;}}return {marker:r,alternatives:i}}function Dr(t,e,r){r.roles.find(n=>n.role==="scope"&&!n.required)&&(t.push({type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}),e.scope={fromRole:"scope"});}function Ot(t,e,r,i){Wn(t,e,r,i,"manner",{requireMarker:true});}function Vn(t,e,r,i){Wn(t,e,r,i,"recipient",{requireMarker:false});}function Wn(t,e,r,i,n,a){let o=r.roles.find(u=>u.role===n&&!u.required);if(!o)return;let s=o.markerOverride?.[i];a.requireMarker&&!s||(t.push({type:"group",optional:true,tokens:[...(s?s.split(/\s+/):[]).map(u=>({type:"literal",value:u})),{type:"role",role:n,optional:true,expectedTypes:o.expectedTypes,...o.valueShape!==void 0?{valueShape:o.valueShape}:{}}]}),e[n]={fromRole:n});}function qn(t){if(t.roles.some(i=>i.role==="patient"))return "patient";let e=t.roles.filter(i=>i.required),r=e.find(i=>i.role===t.primaryRole)??e[0];return !r||r.role==="event"?"patient":r.role}function Kn(t,e,r){let i=t.roles.find(c=>c.role===r);if(!i||r==="patient")return [{type:"role",role:r,optional:false}];let{marker:n,alternatives:a}=ur(i,e),o={type:"role",role:r,optional:false,...i.valueShape!==void 0?{valueShape:i.valueShape}:{}};if(!n)return [o];let s=n.split(/\s+/).filter(Boolean),u={type:"group",optional:true,tokens:s.map(c=>({type:"literal",value:c,...s.length===1&&a?.length?{alternatives:a}:{}}))};return (e.roleMarkers[r]?.position??"before")==="after"?[o,u]:[u,o]}function Hn(t,e,r,i,n){for(let a of r.roles)a.required||n.has(a.role)||e[a.role]||!(a.markerOverride?.[i.code]??i.roleMarkers[a.role]?.primary)&&a.valueShape===void 0||(t.push({type:"group",optional:true,tokens:Zn(a,i)}),e[a.role]=a.default?{fromRole:a.role,default:a.default}:{fromRole:a.role});}function o0(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let f=i.primary.split(/\s+/);if(f.length>1)for(let h of f)a.push({type:"literal",value:h});else {let h=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(h);}}let o=qn(t),s=e.roleMarkers.destination,u=t.roles.some(f=>f.role==="destination");s&&u&&o!=="destination"&&a.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}]});let l=e.roleMarkers.source,c=t.roles.some(f=>f.role==="source");l&&c&&o!=="source"&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"source",optional:true},l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary}]}),a.push(...Kn(t,e,o));let d=e.roleMarkers.patient;if(d&&o==="patient"){let f=d.alternatives?{type:"literal",value:d.primary,alternatives:d.alternatives}:{type:"literal",value:d.primary};a.push(f);}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(m),o!=="source"&&a.push(...Ze(t,e.roleMarkers.source)),o!=="destination"&&a.push(...bt(t,e.roleMarkers.destination));let p={action:{value:t.action},event:{fromRole:"event"},[o]:{fromRole:o},...o==="destination"?{}:Ue(t),...o==="source"?{}:Ge(t)};return Hn(a,p,t,e,new Set(["event",o,"destination","source"])),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`{event} ${i.primary} {destination?} {${o}} ${d?.primary||""} ${r.primary}`,tokens:a},extraction:p}}function s0(t,e,r,i,n){let a=[],o=t.action==="swap",s=o?"destination":"patient";a.push({type:"role",role:s,optional:false});let u=e.roleMarkers.patient;if(u){let m=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(m);}if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let p of m)a.push({type:"literal",value:p});else {let p=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(p);}}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(l),a.push(...Ze(t,e.roleMarkers.source));let c=e.roleMarkers.destination;if(o&&c){let m=t.roles.find(p=>p.role==="patient")?.markerOverride?.[e.code];if(m&&m!==c.primary){let p=c.alternatives??[];p.includes(m)||(c={...c,alternatives:[...p,m]});}}a.push(...o?Eo(t,c):bt(t,c));let d={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...o?{}:Ue(t),...Ge(t)};return Vn(a,d,t,e.code),Ot(a,d,t,e.code),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`{patient} ${u?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:d}}function u0(t,e,r,i,n){let a=t.roles.find(d=>d.role==="source");if(!a)return null;let{marker:o,alternatives:s}=ur(a,e),u=e.roleMarkers.patient;if(!o||o===i.primary||o===u?.primary)return null;let l=[];l.push({type:"role",role:"patient",optional:false}),u&&l.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}),l.push({type:"role",role:"source",optional:false,...a.expectedTypes?{expectedTypes:a.expectedTypes}:{},...a.valueShape!==void 0?{valueShape:a.valueShape}:{}});for(let d of o.split(/\s+/))l.push(s&&o.split(/\s+/).length===1?{type:"literal",value:d,alternatives:s}:{type:"literal",value:d});if(l.push({type:"role",role:"event",optional:false}),i.position==="after"){let d=i.primary.split(/\s+/);if(d.length>1)for(let m of d)l.push({type:"literal",value:m});else l.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}l.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary});let c={action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},source:{fromRole:"source"}};return Vn(l,c,t,e.code),Ot(l,c,t,e.code),{id:`${t.action}-event-${e.code}-sov-source-fronted`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{patient} ${u?.primary||""} {source} ${o} {event} ${i.primary} ${r.primary}`,tokens:l},extraction:c}}function l0(t,e,r,i,n){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}let s=e.roleMarkers.destination;if(s&&(a.push({type:"role",role:"destination",optional:false}),a.push(s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary})),a.push({type:"role",role:"event",optional:false}),i.position==="after"){let l=i.primary.split(/\s+/);if(l.length>1)for(let c of l)a.push({type:"literal",value:c});else {let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(u),{id:`${t.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${s?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function c0(t,e,r,i,n){let a=[];a.push({type:"role",role:"event",optional:false});let o=i.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&a.push({type:"literal",value:o[0],alternatives:o.slice(1)});let s=e.roleMarkers.destination;s&&a.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}]}),a.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};a.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(l),a.push(...Ze(t,e.roleMarkers.source)),a.push(...bt(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(n.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ue(t),...Ge(t)}}}function d0(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let s=i.primary.split(/\s+/);if(s.length>1)for(let u of s)a.push({type:"literal",value:u});else {let u=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(u);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(o),{id:`${t.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function m0(t,e,r,i){let n=e.eventHandler?.temporalMarkers;if(!n||n.length===0)return null;let a=[];a.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),a.push({type:"literal",value:n[0],alternatives:n.slice(1)}),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let u=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(u);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),{id:`${t.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(i.basePriority??100)+49,template:{format:`{event} ${n[0]} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function p0(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let d=i.primary.split(/\s+/);if(d.length>1)for(let m of d)a.push({type:"literal",value:m});else {let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(m);}}let s=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.sovPosition??999,f=m.sovPosition??999;return p-f});for(let d of s){a.push({type:"role",role:d.role,optional:false});let{marker:m,alternatives:p}=ur(d,e);if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u);let l=s.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(d=>[d.role,{fromRole:d.role}]))};return Dr(a,c,t),{id:`${t.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`{event} ${i.primary} ${l} ${r.primary}`,tokens:a},extraction:c}}function f0(t,e,r,i,n){let a=[],s=[...t.roles.filter(c=>c.required)].sort((c,d)=>{let m=c.sovPosition??999,p=d.sovPosition??999;return m-p});for(let c of s){a.push({type:"role",role:c.role,optional:false});let{marker:d,alternatives:m}=ur(c,e);d&&a.push(m?{type:"literal",value:d,alternatives:m}:{type:"literal",value:d});}if(a.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),a.push({type:"role",role:"event",optional:false}),i.position==="after"){let c=i.primary.split(/\s+/);if(c.length>1)for(let d of c)a.push({type:"literal",value:d});else a.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}let u=s.map(c=>`{${c.role}}`).join(" "),l={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))};return Dr(a,l,t),{id:`${t.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`${u} ${r.primary} {event} ${i.primary}`,tokens:a},extraction:l}}function h0(t,e,r,i,n){let a=[],s=[...t.roles.filter(v=>v.required)].sort((v,y)=>{let E=v.sovPosition??999,z=y.sovPosition??999;return E-z}),u=s[0];a.push({type:"role",role:u.role,optional:false});let{marker:l,alternatives:c}=ur(u,e);if(l){let v=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};a.push(v);}if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let v=i.primary.split(/\s+/);if(v.length>1)for(let y of v)a.push({type:"literal",value:y});else {let y=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(y);}}let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(d);let m=s[1];a.push({type:"role",role:m.role,optional:false});let{marker:p,alternatives:f}=ur(m,e);if(p){let v=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};a.push(v);}let h={action:{value:t.action},event:{fromRole:"event"},[u.role]:{fromRole:u.role},[m.role]:{fromRole:m.role}};return Dr(a,h,t),{id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{${u.role}} {event} ${i.primary} ${r.primary} {${m.role}}`,tokens:a},extraction:h}}function Un(t,e,r){let i=Me(t,e.code,r.primary)??[],n=[...new Set([...r.alternatives??[],...i])].filter(a=>a!==r.primary);return n.length?n:void 0}function Pi(t,e,r,i,n){let a=[];if(i.position==="before"){let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=qn(t);a.push(...Kn(t,e,s));let u=e.roleMarkers.destination,l=t.roles.some(d=>d.role==="destination");u&&l&&s!=="destination"&&a.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}]}),s!=="source"&&a.push(...Ze(t,e.roleMarkers.source));let c={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...s==="destination"?{}:Ue(t),...s==="source"?{}:Ge(t)};return Hn(a,c,t,e,new Set(["event",s,"destination","source"])),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`${i.primary} {event} ${r.primary} {${s}} ${u?.primary||""} {destination?}`,tokens:a},extraction:c}}function y0(t,e,r,i,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=t.action==="swap";a.push({type:"role",role:s?"destination":"patient",optional:false});let u=s?void 0:e.roleMarkers.destination;if(u&&a.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}]}),a.push(...Ze(t,e.roleMarkers.source)),i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}if(a.push({type:"role",role:"event",optional:false}),s){let c=t.roles.find(d=>d.role==="patient")?.markerOverride?.[e.code];c&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:c},{type:"role",role:"patient",optional:false}]});}let l={action:{value:t.action},event:{fromRole:"event"},[s?"destination":"patient"]:{fromRole:s?"destination":"patient"},...s?{}:Ue(t),...Ge(t)};return Ot(a,l,t,e.code),{id:`${t.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${i.primary} {event}`,tokens:a},extraction:l}}function v0(t,e,r,i,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.svoPosition??999,f=m.svoPosition??999;return p-f});for(let d of u){let m,p;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)m=d.markerOverride[e.code],p=m?Me(d,e.code,m):void 0;else {let f=e.roleMarkers[d.role];f&&(m=f.primary,p=Un(d,e,f));}if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}a.push({type:"role",role:d.role,optional:false});}if(i.position==="before"){let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let l=u.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(d=>[d.role,{fromRole:d.role}]))};return Dr(a,c,t),{id:`${t.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${r.primary} ${l} ${i.primary} {event}`,tokens:a},extraction:c}}function Li(t,e,r,i,n){let a=[];if(i.position==="before"){let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.svoPosition??999,f=m.svoPosition??999;return p-f});for(let d of u){let m,p;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)m=d.markerOverride[e.code],p=m?Me(d,e.code,m):void 0;else {let f=e.roleMarkers[d.role];f&&(m=f.primary,p=Un(d,e,f));}if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}a.push({type:"role",role:d.role,optional:false});}let l=u.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(d=>[d.role,{fromRole:d.role}]))};return Dr(a,c,t),{id:`${t.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`${i.primary} {event} ${r.primary} ${l}`,tokens:a},extraction:c}}function E0(t,e,r,i,n){let a=[],o=e.eventHandler?.negationMarker;if(i.position==="before"){let l=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}a.push({type:"role",role:"event",optional:false});let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(s),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&a.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}]}),a.push(...Ze(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${i.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ue(t),...Ge(t)}}}function g0(t,e,r,i){let n=[];n.push({type:"literal",value:"and",alternatives:["then"]}),n.push({type:"role",role:"event",optional:false});let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(a),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&n.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),n.push(...Ze(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ue(t),...Ge(t)}}}var cr={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function zr(t,e,r=cr){let i=`${t.action}-${e.code}-generated`,n=r.basePriority??100,a=e.keywords[t.action];if(!a)throw new Error(`No keyword translation for '${t.action}' in ${e.code}`);let o=b0(t,e,a),s=Rt(t,e),u=x0(t,e,a);return {id:i,language:e.code,command:t.action,priority:n,template:{format:u,tokens:o},extraction:s}}function z0(t,e,r=cr){if(t.roles.filter(s=>!s.required).length===0)return null;let n=t.roles.filter(s=>s.required),a={...t,roles:n};return {...zr(a,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:Rt(t,e)}}function Ni(t,e,r=cr){if(e.wordOrder!=="SOV")return null;let i=t.roles.filter(s=>s.required);if(i.length!==1)return null;let n=e.keywords[t.action];if(!n)return null;let a=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary},o=i.flatMap(s=>{let u=s.valuePrefixLiteral?.[e.code],l={type:"role",role:s.role,optional:false,expectedTypes:s.expectedTypes};return u?[{type:"literal",value:u},l]:[l]});return {id:`${t.action}-${e.code}-generated-verb-first`,language:e.code,command:t.action,priority:(r.basePriority??100)-20,template:{format:`${n.primary} <${i[0].role}>`,tokens:[a,...o]},extraction:Rt(t,e)}}function w0(t,e,r=cr){let i=[];if(i.push(zr(t,e,r)),r.generateSimpleVariants){let n=z0(t,e,r);n&&i.push(n);}for(let n of t.omitRoleVariants??[]){let a={...t,roles:t.roles.filter(s=>s.role!==n)},o=zr(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-no-${n}`,priority:(r.basePriority??100)-8});}for(let n of t.widenTypeVariants??[]){if(n.excludeLanguages?.includes(e.code))continue;let a={...t,roles:t.roles.map(s=>s.role===n.role?{...s,expectedTypes:[...n.types]}:s)},o=zr(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)-(n.priorityDelta??15)});}if(r.generateVerbFirstVariants!==false){let n=Ni(t,e,r);n&&i.push(n);}for(let n of t.rolePrefixLiteralVariants??[]){let a=n.literal[e.code];if(!a)continue;let{rolePrefixLiteralVariants:o,...s}=t,u={...s,roles:t.roles.map(m=>m.role===n.role?{...m,valuePrefixLiteral:{[e.code]:a}}:m)},l=n.priorityDelta??5,c=n.methodCarrier?{[n.methodCarrier]:{value:a}}:{},d=zr(u,e,r);if(i.push({...d,id:`${t.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)+l,extraction:{...d.extraction,...c}}),r.generateVerbFirstVariants!==false){let m=Ni(u,e,r);m&&i.push({...m,id:`${t.action}-${e.code}-generated-verb-first-${n.idSuffix}`,priority:(r.basePriority??100)-20+l,extraction:{...m.extraction,...c}});}}return i}function Gn(t,e=cr){let r=[],i=_s();for(let n of i){if(!t.keywords[n.action])continue;let a=w0(n,t,e);if(r.push(...a),t.eventHandler?.eventMarker){let o=k0(n,t,e);r.push(...o);}}return r}function k0(t,e,r=cr){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let i=[],n=e.eventHandler.eventMarker,a=e.keywords[t.action];if(!a)return [];if(t.roles.length===0)return [];if(t.action==="js")return [];let s=t.roles.filter(u=>u.required).length===2;if(e.wordOrder==="SOV")if(s)i.push(p0(t,e,a,n,r)),i.push(h0(t,e,a,n,r)),i.push(f0(t,e,a,n,r));else {i.push(o0(t,e,a,n,r)),i.push(s0(t,e,a,n,r));let u=u0(t,e,a,n,r);u&&i.push(u);let l=e.roleMarkers.destination;l&&l.primary!==n.primary&&i.push(l0(t,e,a,n,r));let c=n.primary.split(/\s+/),d=n.alternatives?.some(p=>!p.includes(" ")&&p.length>1);c.length>1&&d&&i.push(c0(t,e,a,n,r)),i.push(d0(t,e,a,n,r));let m=m0(t,e,a,r);m&&i.push(m);}else e.wordOrder==="VSO"?s?(i.push(Li(t,e,a,n,r)),i.push(v0(t,e,a,n,r))):(i.push(Pi(t,e,a,n,r)),i.push(y0(t,e,a,n,r)),e.eventHandler?.negationMarker&&i.push(E0(t,e,a,n,r)),e.tokenization?.prefixes&&i.push(g0(t,e,a,r))):s?i.push(Li(t,e,a,n,r)):i.push(Pi(t,e,a,n,r));return i}function b0(t,e,r){let i=[],n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=A0(t,e);switch(e.wordOrder){case "SVO":i.push(n),i.push(...a);break;case "SOV":i.push(...a),i.push(n);break;case "VSO":i.push(n),i.push(...a);break;default:i.push(n),i.push(...a);}return C0(i)}function C0(t){let e=[];for(let r of t){let i=e[e.length-1];if(i&&i.type==="literal"&&r.type==="literal"&&i.value===r.value){let n=[...i.alternatives??[],...r.alternatives??[]];n.length&&(e[e.length-1]={...i,alternatives:[...new Set(n)]});continue}e.push(r);}return e}function A0(t,e){let r=[],i=jn(t.roles,e.wordOrder);for(let n of i){let a=Zn(n,e);n.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function Zn(t,e){let r=[],i=t.markerOverride?.[e.code],n=e.roleMarkers[t.role],a=t.renderOverride?.[e.code]==="",o={type:"role",role:t.role,optional:!t.required,expectedTypes:t.expectedTypes,...t.valueShape!==void 0?{valueShape:t.valueShape}:{}},s=t.valuePrefixLiteral?.[e.code],u=()=>{s&&r.push({type:"literal",value:s}),r.push(o);};if(i!==void 0){let l=i?i.split(/\s+/).filter(Boolean):[],c=i!==void 0&&i===t.markerOverride?.en,d=n?.position??(e.wordOrder==="SOV"&&!c?"after":"before"),m=t.markerOptional?.[e.code]===true,p=f=>{let h=l.length===1?Me(t,e.code,f)??[]:[],v={type:"literal",value:f,...h.length?{alternatives:h}:{},...a?{renderSuppress:true}:{}};r.push(m?{type:"group",optional:true,tokens:[v]}:v);};if(d==="before"){for(let f of l)p(f);u();}else {u();for(let f of l)p(f);}}else if(n){let l=()=>{let d=[...new Set([...n.alternatives??[],...Me(t,e.code,n.primary)??[]])].filter(m=>m!==n.primary);return {type:"literal",value:n.primary,...d.length?{alternatives:d}:{},...a?{renderSuppress:true}:{}}},c=d=>{if(!e.markersOptional&&!t.markerOptional?.[e.code]){r.push(d);return}r.push({type:"group",optional:true,...e.markersOptional&&!t.markerOptional?.[e.code]?{renderRequired:true}:{},tokens:[d]});};n.position==="before"?(n.primary&&c(l()),u()):(u(),c(l()));}else u();return r}function S0(t,e){let r={};for(let i of t.roles){let n=i.markerOverride?.[e.code],a=e.roleMarkers[i.role];if(i.valuePrefixLiteral?.[e.code])r[i.role]={marker:i.valuePrefixLiteral[e.code]};else if(n!==void 0)if(!n)r[i.role]={};else {let s=!/\s/.test(n.trim())?Me(i,e.code,n)??[]:[];r[i.role]=s.length?{marker:n,markerAlternatives:s}:{marker:n};}else if(a&&a.primary){let o=[...new Set([...a.alternatives??[],...Me(i,e.code,a.primary)??[]])].filter(s=>s!==a.primary);r[i.role]=o.length?{marker:a.primary,markerAlternatives:o}:{marker:a.primary};}else r[i.role]={};}return r}function Rt(t,e){let r=S0(t,e),i={};for(let n of t.roles){let a=r[n.role]||{};!n.required&&n.default?i[n.role]={...a,default:n.default}:i[n.role]=a;}return i}function x0(t,e,r){let i=[],a=jn(t.roles,e.wordOrder).map(o=>{let s=zu(o,e),u="";return s&&s.primary?s.position==="before"?u=`${s.primary} {${o.role}}`:u=`{${o.role}} ${s.primary}`:u=`{${o.role}}`,o.required?u:`[${u}]`});switch(e.wordOrder){case "SVO":case "VSO":i.push(r.primary,...a);break;case "SOV":i.push(...a,r.primary);break;default:i.push(r.primary,...a);}return i.join(" ")}var D0=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),i=this.cache.get(r);if(!i){this.stats.misses++;return}if(this.isExpired(i)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),i.lastAccessed=Date.now(),this.cache.set(r,i),this.stats.hits++,i.result}set(t,e,r){if(!this.config.enabled||r!==null&&typeof r=="object"&&"confidence"in r&&r.confidence===0)return;let i=this.makeKey(t,e),n=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(i,{result:r,createdAt:n,lastAccessed:n});}has(t,e){if(!this.config.enabled)return false;let r=this.makeKey(t,e),i=this.cache.get(r);return i?this.isExpired(i)?(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}}};new D0;var Jn={code:"id",name:"Indonesian",nativeName:"Bahasa Indonesia",regions:["priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,verb:{position:"start",subjectDrop:true},references:{me:"saya",it:"itu",you:"anda",result:"hasil",event:"peristiwa",target:"target",body:"badan",document:"dokumen",window:"jendela",detail:"detail"},possessive:{marker:"",markerPosition:"after-object",usePossessiveAdjectives:true,specialForms:{me:"saya",it:"nya",you:"anda"},keywords:{saya:"me",aku:"me",ku:"me",my:"me",anda:"you",kamu:"you",mu:"you",nya:"it",dia:"it",miliknya:"it"},connectors:["punya"]},roleMarkers:{destination:{primary:"pada",alternatives:["ke","di"],position:"before"},source:{primary:"dari",position:"before"},patient:{primary:"",position:"before"},style:{primary:"dengan",position:"before"}},keywords:{toggle:{primary:"alihkan",normalized:"toggle"},add:{primary:"tambah",alternatives:["tambahkan"],normalized:"add"},remove:{primary:"hapus",alternatives:["buang","hilangkan"],normalized:"remove"},put:{primary:"taruh",alternatives:["letakkan","masukkan"],normalized:"put"},append:{primary:"sisipkan",normalized:"append"},prepend:{primary:"awali",normalized:"prepend"},take:{primary:"ambil",normalized:"take"},make:{primary:"buat",alternatives:["bikin","ciptakan"],normalized:"make"},clone:{primary:"klon",alternatives:["tiru"],normalized:"clone"},swap:{primary:"tukar",alternatives:["ganti"],normalized:"swap"},morph:{primary:"ubah",alternatives:["transformasi"],normalized:"morph"},set:{primary:"atur",alternatives:["tetapkan"],normalized:"set"},get:{primary:"dapatkan",alternatives:["peroleh"],normalized:"get"},increment:{primary:"tingkatkan",alternatives:["naikkan"],normalized:"increment"},decrement:{primary:"turunkan",alternatives:["kurangi"],normalized:"decrement"},log:{primary:"catat",alternatives:["rekam","cetak"],normalized:"log"},show:{primary:"tampilkan",alternatives:["perlihatkan"],normalized:"show"},hide:{primary:"sembunyikan",alternatives:["tutup"],normalized:"hide"},transition:{primary:"transisi",alternatives:["animasikan"],normalized:"transition"},on:{primary:"pada",alternatives:["saat"],normalized:"on"},trigger:{primary:"picu",alternatives:["jalankan"],normalized:"trigger"},send:{primary:"kirim",alternatives:["kirimkan"],normalized:"send"},focus:{primary:"fokus",alternatives:["fokuskan"],normalized:"focus"},blur:{primary:"blur",normalized:"blur"},empty:{primary:"kosongkan",alternatives:["kosong"],normalized:"empty"},open:{primary:"buka",normalized:"open"},close:{primary:"tutupkan",normalized:"close"},select:{primary:"tandai",normalized:"select"},clear:{primary:"bersihkan",normalized:"clear"},reset:{primary:"setel-ulang",alternatives:["reset"],normalized:"reset"},breakpoint:{primary:"titik-henti",normalized:"breakpoint"},go:{primary:"pergi",alternatives:["pindah","navigasi"],normalized:"go"},scroll:{primary:"gulir",alternatives:["gulung"],normalized:"scroll"},push:{primary:"dorong",alternatives:["push"],normalized:"push"},replace:{primary:"ganti_url",alternatives:["gantikan_url"],normalized:"replace"},process:{primary:"proses",normalized:"process"},wait:{primary:"tunggu",normalized:"wait"},fetch:{primary:"muat",normalized:"fetch"},settle:{primary:"stabilkan",normalized:"settle"},if:{primary:"jika",alternatives:["kalau","bila"],normalized:"if"},unless:{primary:"kecuali",normalized:"unless"},when:{primary:"ketika",normalized:"when"},changes:{primary:"berubah",normalized:"changes"},where:{primary:"di_mana",normalized:"where"},else:{primary:"selainnya",alternatives:["lainnya"],normalized:"else"},repeat:{primary:"ulangi",normalized:"repeat"},for:{primary:"untuk",normalized:"for"},while:{primary:"selama",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"lanjutkan",alternatives:["terus"],normalized:"continue"},halt:{primary:"hentikan",alternatives:["berhenti"],normalized:"halt"},throw:{primary:"lempar",normalized:"throw"},call:{primary:"panggil",normalized:"call"},return:{primary:"kembalikan",alternatives:["kembali"],normalized:"return"},then:{primary:"lalu",alternatives:["kemudian","setelah itu"],normalized:"then"},and:{primary:"dan",alternatives:["juga","serta"],normalized:"and"},matches:{primary:"cocok",normalized:"matches"},end:{primary:"selesai",alternatives:["akhir","tamat"],normalized:"end"},js:{primary:"js",alternatives:["javascript"],normalized:"js"},async:{primary:"asinkron",normalized:"async"},tell:{primary:"katakan",alternatives:["beritahu"],normalized:"tell"},default:{primary:"bawaan",normalized:"default"},init:{primary:"inisialisasi",alternatives:["mulai"],normalized:"init"},behavior:{primary:"perilaku",normalized:"behavior"},install:{primary:"pasang",alternatives:["instal"],normalized:"install"},measure:{primary:"ukur",normalized:"measure"},beep:{primary:"bunyi",normalized:"beep"},break:{primary:"putuskan",normalized:"break"},copy:{primary:"salin",normalized:"copy"},exit:{primary:"keluar",normalized:"exit"},pick:{primary:"pilih",normalized:"pick"},render:{primary:"olah",normalized:"render"},into:{primary:"ke dalam",normalized:"into"},before:{primary:"sebelum",normalized:"before"},after:{primary:"sesudah",alternatives:["setelah"],normalized:"after"},click:{primary:"klik",alternatives:["tekan"],normalized:"click"},hover:{primary:"hover",alternatives:["arahkan"],normalized:"hover"},submit:{primary:"ajukan",normalized:"submit"},input:{primary:"masuk",alternatives:["input","masukan"],normalized:"input"},change:{primary:"berubah",normalized:"change"},until:{primary:"sampai",normalized:"until"},event:{primary:"peristiwa",alternatives:["event"],normalized:"event"},from:{primary:"dari",normalized:"from"},connect:{primary:"sambungkan",alternatives:["hubungkan","koneksi"],normalized:"connect"},stream:{primary:"alirkan",alternatives:["streaming"],normalized:"stream"},live:{primary:"langsung",alternatives:["live"],normalized:"live"},socket:{primary:"soket",alternatives:["socket","websocket"],normalized:"socket"},bind:{primary:"ikat",alternatives:["kaitkan","bind"],normalized:"bind"},intercept:{primary:"cegat",alternatives:["tangkap","intercept"],normalized:"intercept"},worker:{primary:"pekerja",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["sumber peristiwa"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"pada",alternatives:["ketika","saat"],normalized:"on"},sourceMarker:{primary:"dari",position:"before"},conditionalKeyword:{primary:"ketika",alternatives:["saat","waktu"]},eventMarker:{primary:"saat",alternatives:["ketika","pada"],position:"before"},temporalMarkers:["ketika","saat"]}},B0=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],T0=class{constructor(t=B0){this.name="operator",this.operators=[...t].sort((e,r)=>r.length-e.length);}canExtract(t,e){return this.operators.some(r=>t.startsWith(r,e))}extract(t,e){for(let r of this.operators)if(t.startsWith(r,e))return {value:r,length:r.length};return null}},F0="()[]{},:;",O0=class{constructor(t=F0){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Pt(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function Yn(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Pt(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Pt(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Pt(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var R0=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Yn(t,e)!==null:false}extract(t,e){let r=Yn(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},P0=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},L0=["http://","https://","//","./","../","/"];function N0(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function _0(t,e){let r=t.slice(e),i=L0.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=N0(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var M0=class{constructor(){this.name="url";}canExtract(t,e){let r=t.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(t,e){let r=_0(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},I0=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&e+1<t.length&&/[a-zA-Z_]/.test(t[e+1])}extract(t,e){if(!this.canExtract(t,e))return null;let r=1;for(;e+r<t.length&&/[a-zA-Z0-9_]/.test(t[e+r]);)r++;return {value:t.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}},$0=new Set(["di","ke","dari","pada","dengan","tanpa","untuk","oleh","antara","sebelum","sesudah","setelah","selama","sampai","hingga","sejak","menuju","tentang","terhadap","melalui","dalam","luar"]);function j0(){let t=/[a-zA-Z]/;return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:V0,isIdentifierChar:Xn}=j0(),W0=class{constructor(){this.name="indonesian-keyword";}setContext(t){this.context=t;}canExtract(t,e){return V0(t[e])}extract(t,e){if(!this.context)throw new Error("IndonesianKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&Xn(t[r]);)i+=t[r++];if(this.context&&r<t.length&&t[r]==="_"){let l=r,c=i;for(;l<t.length&&(t[l]==="_"||Xn(t[l]));)c+=t[l++];this.context.lookupKeyword(c.toLowerCase())&&(i=c,r=l);}if(!i)return null;let n=i.toLowerCase(),a=$0.has(n),o=this.context.lookupKeyword(n),s=o&&o.normalized!==o.native?o.normalized:void 0,u;if(!o&&this.context.normalizer){let l=this.context.normalizer.normalize(i);if(l.stem!==i&&l.confidence>=.7){let c=this.context.lookupKeyword(l.stem);c&&(u=c.normalized);}}return {value:i,length:r-e,metadata:{normalized:s||u,isPreposition:a}}}};function q0(){return [new W0]}function K0(){return [new M0,new P0,new I0,new R0]}var H0=new Set(["di","ke","dari","pada","dengan","tanpa","untuk","oleh","antara","sebelum","sesudah","setelah","selama","sampai","hingga","sejak","menuju","tentang","terhadap","melalui","dalam","luar"]),U0=[{native:"ubah_ukuran",normalized:"resize"},{native:"tidak_ada",normalized:"no"},{native:"benar",normalized:"true"},{native:"salah",normalized:"false"},{native:"null",normalized:"null"},{native:"kosong",normalized:"null"},{native:"tidakdidefinisikan",normalized:"undefined"},{native:"tidak_terdefinisi",normalized:"undefined"},{native:"pertama",normalized:"first"},{native:"terakhir",normalized:"last"},{native:"berikutnya",normalized:"next"},{native:"sebelumnya",normalized:"previous"},{native:"terdekat",normalized:"closest"},{native:"induk",normalized:"parent"},{native:"klik",normalized:"click"},{native:"click",normalized:"click"},{native:"ubah",normalized:"change"},{native:"kirim",normalized:"submit"},{native:"tekan",normalized:"keydown"},{native:"arahkan",normalized:"mouseover"},{native:"tinggalkan",normalized:"mouseout"},{native:"kabur",normalized:"blur"},{native:"muat",normalized:"load"},{native:"gulir",normalized:"scroll"},{native:"input",normalized:"input"},{native:"milik",normalized:"my"},{native:"detik",normalized:"s"},{native:"milidetik",normalized:"ms"},{native:"menit",normalized:"m"},{native:"jam",normalized:"h"},{native:"atau",normalized:"or"},{native:"tidak",normalized:"not"},{native:"adalah",normalized:"is"},{native:"ada",normalized:"exists"},{native:"inklusif",normalized:"inclusive"},{native:"eksklusif",normalized:"exclusive"},{native:"karakter",normalized:"characters"},{native:"acak",normalized:"random"}],G0=class extends xe{constructor(){super(),this.language="id",this.direction="ltr",this.initializeKeywordsFromProfile(Jn,U0),this.registerExtractors(K0()),this.registerExtractor(new Ae),this.registerExtractor(new Se),this.registerExtractors(q0()),this.registerExtractor(new T0),this.registerExtractor(new O0);}classifyToken(t){let e=t.toLowerCase();return H0.has(e)?"particle":this.isKeyword(e)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(t)?"event-modifier":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},Z0=new G0;Pe("id",Z0,Jn);var ea={code:"ms",name:"Malay",nativeName:"Melayu",direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"base",verb:{position:"start",subjectDrop:true},references:{me:"saya",it:"ia",you:"kamu",result:"hasil",event:"peristiwa",target:"sasaran",body:"badan",document:"dokumen",window:"tetingkap",detail:"perincian"},possessive:{marker:"",markerPosition:"after-object",keywords:{saya:"me",saya_punya:"me",aku:"me",awak:"you",kamu:"you",anda:"you",dia:"it",ia:"it",nya:"it","-ku":"me","-mu":"you","-nya":"it"}},roleMarkers:{destination:{primary:"ke",alternatives:["pada"],position:"before"},source:{primary:"dari",position:"before"},patient:{primary:"",position:"before"},style:{primary:"dengan",position:"before"}},keywords:{toggle:{primary:"togol",alternatives:["tukar"],normalized:"toggle"},add:{primary:"tambah",normalized:"add"},remove:{primary:"buang",alternatives:["padam"],normalized:"remove"},put:{primary:"letak",alternatives:["letakkan"],normalized:"put"},append:{primary:"tambah_hujung",normalized:"append"},prepend:{primary:"tambah_mula",normalized:"prepend"},take:{primary:"ambil",normalized:"take"},make:{primary:"buat",alternatives:["cipta"],normalized:"make"},clone:{primary:"klon",alternatives:[],normalized:"clone"},swap:{primary:"tukar_tempat",normalized:"swap"},morph:{primary:"ubah_bentuk",normalized:"morph"},set:{primary:"tetapkan",alternatives:["setkan"],normalized:"set"},get:{primary:"dapatkan",alternatives:[],normalized:"get"},increment:{primary:"tambah_satu",normalized:"increment"},decrement:{primary:"kurang_satu",normalized:"decrement"},log:{primary:"catat",alternatives:["log"],normalized:"log"},show:{primary:"tunjuk",alternatives:[],normalized:"show"},hide:{primary:"sembunyi",alternatives:["sorok"],normalized:"hide"},transition:{primary:"peralihan",normalized:"transition"},on:{primary:"apabila",alternatives:["ketika"],normalized:"on"},trigger:{primary:"cetuskan",normalized:"trigger"},send:{primary:"hantar",normalized:"send"},focus:{primary:"fokus",normalized:"focus"},blur:{primary:"kabur",normalized:"blur"},empty:{primary:"kosongkan",alternatives:["kosong"],normalized:"empty"},open:{primary:"buka",normalized:"open"},close:{primary:"tutup",normalized:"close"},select:{primary:"tandai",normalized:"select"},clear:{primary:"bersihkan",normalized:"clear"},reset:{primary:"set-semula",alternatives:["reset"],normalized:"reset"},breakpoint:{primary:"titik-henti",normalized:"breakpoint"},go:{primary:"pergi",alternatives:["pindah"],normalized:"go"},scroll:{primary:"tatal",alternatives:["skrol","scroll"],normalized:"scroll"},push:{primary:"tolak",alternatives:["push"],normalized:"push"},replace:{primary:"ganti_url",alternatives:["gantikan_url"],normalized:"replace"},process:{primary:"proses",normalized:"process"},wait:{primary:"tunggu",normalized:"wait"},fetch:{primary:"ambil_dari",alternatives:["muat"],normalized:"fetch"},settle:{primary:"selesai",normalized:"settle"},if:{primary:"jika",alternatives:["kalau"],normalized:"if"},unless:{primary:"kecuali",normalized:"unless"},when:{primary:"bila",normalized:"when"},changes:{primary:"berubah",normalized:"changes"},where:{primary:"di_mana",normalized:"where"},else:{primary:"kalau_tidak",alternatives:["jika_tidak"],normalized:"else"},repeat:{primary:"ulang",normalized:"repeat"},for:{primary:"untuk",normalized:"for"},while:{primary:"selagi",alternatives:["semasa"],normalized:"while"},forever:{primary:"selamanya",normalized:"forever",alternatives:["forever"]},continue:{primary:"teruskan",normalized:"continue"},halt:{primary:"henti",alternatives:["berhenti"],normalized:"halt"},throw:{primary:"lempar",normalized:"throw"},call:{primary:"panggil",normalized:"call"},return:{primary:"pulang",alternatives:["kembali"],normalized:"return"},then:{primary:"kemudian",alternatives:["lepas_itu"],normalized:"then"},and:{primary:"dan",normalized:"and"},matches:{primary:"sepadan",normalized:"matches"},exists:{primary:"wujud",normalized:"exists"},is:{primary:"adalah",normalized:"is"},no:{primary:"tiada",normalized:"no"},end:{primary:"tamat",alternatives:["habis"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"tak_segerak",normalized:"async"},tell:{primary:"beritahu",normalized:"tell"},default:{primary:"lalai",normalized:"default"},init:{primary:"mula",alternatives:["mulakan"],normalized:"init"},behavior:{primary:"kelakuan",normalized:"behavior"},install:{primary:"pasang",normalized:"install"},measure:{primary:"ukur",normalized:"measure"},beep:{primary:"bunyi",normalized:"beep"},break:{primary:"pecah",normalized:"break"},copy:{primary:"salin",normalized:"copy"},exit:{primary:"keluar",normalized:"exit"},pick:{primary:"pilih",normalized:"pick"},render:{primary:"papar",normalized:"render"},into:{primary:"ke_dalam",normalized:"into"},before:{primary:"sebelum",normalized:"before"},after:{primary:"selepas",alternatives:["lepas"],normalized:"after"},until:{primary:"sehingga",alternatives:["sampai"],normalized:"until"},event:{primary:"peristiwa",normalized:"event"},from:{primary:"dari",normalized:"from"},connect:{primary:"sambung",alternatives:["hubungkan"],normalized:"connect"},stream:{primary:"strim",alternatives:["penstriman","aliran"],normalized:"stream"},live:{primary:"langsung",alternatives:["siaran-langsung"],normalized:"live"},socket:{primary:"soket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"ikat",alternatives:["kaitkan","bind"],normalized:"bind"},intercept:{primary:"pintas",alternatives:["cegat","intercept"],normalized:"intercept"},worker:{primary:"pekerja",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["sumber_peristiwa"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"apabila",alternatives:["ketika"],normalized:"on"},sourceMarker:{primary:"dari",position:"before"},eventMarker:{primary:"apabila",alternatives:["ketika"],position:"before"}}},Y0=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],X0=class{constructor(t=Y0){this.name="operator",this.operators=[...t].sort((e,r)=>r.length-e.length);}canExtract(t,e){return this.operators.some(r=>t.startsWith(r,e))}extract(t,e){for(let r of this.operators)if(t.startsWith(r,e))return {value:r,length:r.length};return null}},J0="()[]{},:;",Q0=class{constructor(t=J0){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Lt(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function Qn(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Lt(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Lt(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Lt(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var ed=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Qn(t,e)!==null:false}extract(t,e){let r=Qn(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},rd=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},td=["http://","https://","//","./","../","/"];function id(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function nd(t,e){let r=t.slice(e),i=td.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=id(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var ad=class{constructor(){this.name="url";}canExtract(t,e){let r=t.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(t,e){let r=nd(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},od=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&e+1<t.length&&/[a-zA-Z_]/.test(t[e+1])}extract(t,e){if(!this.canExtract(t,e))return null;let r=1;for(;e+r<t.length&&/[a-zA-Z0-9_]/.test(t[e+r]);)r++;return {value:t.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function sd(t){return /[a-zA-Z_]/.test(t)}function ud(t){return /[a-zA-Z0-9_]/.test(t)}var ld=class{constructor(){this.name="malay-keyword";}setContext(t){this.context=t;}canExtract(t,e){return sd(t[e])}extract(t,e){if(!this.context)throw new Error("MalayKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&ud(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=this.context.lookupKeyword(n),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:i.length,metadata:{normalized:o}}}};function cd(){return [new ld]}function dd(){return [new ad,new rd,new od,new ed]}var md=[{native:"benar",normalized:"true"},{native:"salah",normalized:"false"},{native:"kosong",normalized:"empty"},{native:"tak_tentu",normalized:"undefined"},{native:"pertama",normalized:"first"},{native:"terakhir",normalized:"last"},{native:"seterusnya",normalized:"next"},{native:"sebelumnya",normalized:"previous"},{native:"terdekat",normalized:"closest"},{native:"induk",normalized:"parent"},{native:"klik",normalized:"click"},{native:"berubah",normalized:"change"},{native:"ubah",normalized:"change"},{native:"hantar",normalized:"submit"},{native:"input",normalized:"input"},{native:"masuk",normalized:"input"},{native:"muat",normalized:"load"},{native:"tatal",normalized:"scroll"},{native:"hover",normalized:"hover"},{native:"inklusif",normalized:"inclusive"},{native:"eksklusif",normalized:"exclusive"},{native:"aksara",normalized:"characters"},{native:"rawak",normalized:"random"}],pd=class extends xe{constructor(){super(),this.language="ms",this.direction="ltr",this.initializeKeywordsFromProfile(ea,md),this.registerExtractors(dd()),this.registerExtractor(new Ae),this.registerExtractor(new Se),this.registerExtractors(cd()),this.registerExtractor(new X0),this.registerExtractor(new Q0);}classifyToken(t){return this.isKeyword(t)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(t)?"event-modifier":t.startsWith(".")||t.startsWith("#")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith(":")?"identifier":t.startsWith('"')||t.startsWith("'")||/^-?\d/.test(t)?"literal":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},fd=new pd;Pe("ms",fd,ea);var ta={code:"tl",name:"Tagalog",nativeName:"Tagalog",direction:"ltr",script:"latin",wordOrder:"VSO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"base",verb:{position:"start",subjectDrop:true},references:{me:"ako",it:"ito",you:"ikaw",result:"resulta",event:"pangyayari",target:"target",body:"katawan",document:"dokumento",window:"bintana",detail:"detalye"},possessive:{marker:"ng",markerPosition:"between",keywords:{ko:"me",akin:"me",aking:"me",mo:"you",iyo:"you",niya:"it",nito:"it",kaniya:"it"}},roleMarkers:{destination:{primary:"sa",alternatives:["bago","matapos"],position:"before"},source:{primary:"mula_sa",position:"before"},patient:{primary:"",position:"before"},style:{primary:"nang",position:"before"}},keywords:{toggle:{primary:"palitan",alternatives:["itoggle"],normalized:"toggle"},add:{primary:"idagdag",alternatives:["magdagdag"],normalized:"add"},remove:{primary:"alisin",alternatives:["tanggalin"],normalized:"remove"},put:{primary:"ilagay",alternatives:["maglagay"],normalized:"put"},append:{primary:"idagdag_sa_dulo",normalized:"append"},prepend:{primary:"idagdag_sa_simula",normalized:"prepend"},take:{primary:"kumuha",normalized:"take"},make:{primary:"gumawa",alternatives:["lumikha"],normalized:"make"},clone:{primary:"i-clone",normalized:"clone"},swap:{primary:"palitan_pwesto",alternatives:["magpalit"],normalized:"swap"},morph:{primary:"baguhin",normalized:"morph"},set:{primary:"itakda",alternatives:["magtakda"],normalized:"set"},get:{primary:"kunin",normalized:"get"},increment:{primary:"dagdagan",alternatives:["taasan"],normalized:"increment"},decrement:{primary:"bawasan",alternatives:["ibaba"],normalized:"decrement"},log:{primary:"itala",normalized:"log"},show:{primary:"ipakita",alternatives:["magpakita"],normalized:"show"},hide:{primary:"itago",alternatives:["magtago"],normalized:"hide"},transition:{primary:"lumipat",normalized:"transition"},on:{primary:"kapag",normalized:"on"},trigger:{primary:"palitawin",alternatives:["magpatugtog"],normalized:"trigger"},send:{primary:"ipadala",alternatives:["magpadala"],normalized:"send"},focus:{primary:"ituon",normalized:"focus"},blur:{primary:"alisin_tuon",normalized:"blur"},empty:{primary:"walang-laman",alternatives:["alisin-laman","walang_laman"],normalized:"empty"},open:{primary:"buksan",normalized:"open"},close:{primary:"isara",normalized:"close"},select:{primary:"piliin",normalized:"select"},clear:{primary:"burahin",normalized:"clear"},reset:{primary:"i-reset",normalized:"reset"},breakpoint:{primary:"breakpoint",normalized:"breakpoint"},go:{primary:"pumunta",alternatives:["punta"],normalized:"go"},scroll:{primary:"iscroll",alternatives:["mag_scroll","scroll"],normalized:"scroll"},push:{primary:"itulak",alternatives:["ipush"],normalized:"push"},replace:{primary:"palitan_url",alternatives:["ireplace"],normalized:"replace"},process:{primary:"iproseso",alternatives:["proseso"],normalized:"process"},wait:{primary:"maghintay",alternatives:["hintay"],normalized:"wait"},fetch:{primary:"kuhanin_mula",alternatives:["kunin_mula"],normalized:"fetch"},settle:{primary:"magpatahimik",normalized:"settle"},if:{primary:"kung",normalized:"if"},unless:{primary:"maliban_kung",normalized:"unless"},when:{primary:"tuwing",normalized:"when"},changes:{primary:"nagbabago",normalized:"changes"},where:{primary:"kung_saan",normalized:"where"},else:{primary:"kung_hindi",alternatives:["kundi"],normalized:"else"},repeat:{primary:"ulitin",alternatives:["paulit-ulit"],normalized:"repeat"},for:{primary:"para_sa",normalized:"for"},while:{primary:"habang",normalized:"while"},forever:{primary:"magpakailanman",normalized:"forever",alternatives:["forever"]},continue:{primary:"magpatuloy",normalized:"continue"},halt:{primary:"itigil",alternatives:["huminto"],normalized:"halt"},throw:{primary:"ihagis",alternatives:["itapon"],normalized:"throw"},call:{primary:"tawagin",alternatives:["tawagan","tumawag"],normalized:"call"},return:{primary:"ibalik",alternatives:["bumalik"],normalized:"return"},then:{primary:"pagkatapos",alternatives:["saka"],normalized:"then"},and:{primary:"at",normalized:"and"},matches:{primary:"tumutugma",normalized:"matches"},is:{primary:"ay",normalized:"is"},end:{primary:"wakas",alternatives:["tapos"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"async",alternatives:["sabay"],normalized:"async"},tell:{primary:"sabihin",alternatives:["magsabi"],normalized:"tell"},default:{primary:"pamantayan",alternatives:["default","unang_halaga"],normalized:"default"},init:{primary:"simulan",alternatives:["magsimula"],normalized:"init"},behavior:{primary:"ugali",alternatives:["kilos"],normalized:"behavior"},install:{primary:"ikabit",alternatives:["mag-install"],normalized:"install"},measure:{primary:"sukatin",normalized:"measure"},beep:{primary:"tunog",normalized:"beep"},break:{primary:"putulin",normalized:"break"},copy:{primary:"kopyahin",normalized:"copy"},exit:{primary:"lumabas",normalized:"exit"},pick:{primary:"pumili",normalized:"pick"},render:{primary:"irender",normalized:"render"},into:{primary:"sa",normalized:"into"},before:{primary:"bago",normalized:"before"},after:{primary:"matapos",normalized:"after"},until:{primary:"hanggang",normalized:"until"},event:{primary:"pangyayari",normalized:"event"},from:{primary:"mula",alternatives:["galing"],normalized:"from"},connect:{primary:"ikonekta",alternatives:["kumonekta","connect"],normalized:"connect"},stream:{primary:"i-stream",alternatives:["stream","agos"],normalized:"stream"},live:{primary:"live",alternatives:["tuwiran","direkta"],normalized:"live"},socket:{primary:"socket",alternatives:["websocket"],normalized:"socket"},worker:{primary:"worker",alternatives:["manggagawa"],normalized:"worker"},eventsource:{primary:"eventsource",normalized:"eventsource"},intercept:{primary:"intercept",alternatives:["harangin","humarang"],normalized:"intercept"},bind:{primary:"itali",alternatives:["iugnay","bind"],normalized:"bind"}},eventHandler:{keyword:{primary:"kapag",normalized:"on"},sourceMarker:{primary:"mula_sa",alternatives:["galing_sa"],position:"before"},eventMarker:{primary:"kapag",position:"before"}}};function hd(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:t==="\xF1"||t==="\xD1"}function yd(t){for(let e of t)if(hd(e))return true;return false}var vd=[{pattern:"magpapa",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"magpa",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"ipang",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"ipag",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"nagpa",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3}],Ed=[{pattern:"mag",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"nag",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"mang",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"nang",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"ma",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"na",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"i",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"pa",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3}],gd=["um","in"],zd=[{pattern:"hin",confidencePenalty:.18,type:"patient-focus"},{pattern:"in",confidencePenalty:.18,type:"patient-focus"},{pattern:"han",confidencePenalty:.18,type:"locative-focus"},{pattern:"an",confidencePenalty:.18,type:"locative-focus"}];function wd(t){let e=t.toLowerCase();if(e.length<5)return null;let r=0;for(let i=0;i<e.length;i++){let n=e[i];if(!"aeiou".includes(n))r=i+1;else break}if(r===0)return null;for(let i of gd){let n=r;if(e.slice(n,n+i.length)===i){let a=e.slice(0,r)+e.slice(n+i.length);if(a.length>=3)return {stem:a,infix:i}}}return null}function kd(t){let e=t.toLowerCase();if(e.length<4)return {stem:e,reduplicated:false};let r=e[0],i=e[1];if(!"aeiou".includes(r)&&"aeiou".includes(i)){let n=e.slice(2);if(n.length>=2&&n[0]===r)return {stem:n,reduplicated:true}}return {stem:e,reduplicated:false}}var bd=class{constructor(){this.language="tl";}isNormalizable(t){return !(!yd(t)||t.length<2)}normalize(t){let e=t.toLowerCase(),r=1,i=[],n=[],a=[];for(let l of vd)if(e.startsWith(l.pattern)){let c=e.slice(l.pattern.length),d=l.minRemaining??2;if(c.length>=d){e=c,r-=l.confidencePenalty,i.push(l.pattern),a.push(`prefix:${l.pattern}`);break}}if(i.length===0){for(let l of Ed)if(e.startsWith(l.pattern)){let c=e.slice(l.pattern.length),d=l.minRemaining??2;if(c.length>=d){e=c,r-=l.confidencePenalty,i.push(l.pattern),a.push(`prefix:${l.pattern}`);break}}}let o=kd(e);o.reduplicated&&o.stem.length>=2&&(e=o.stem,r-=.1,a.push("reduplication:CV"));let s=wd(e),u=false;if(s&&s.stem.length>=2&&(e=s.stem,r-=.18,a.push(`infix:${s.infix}`),u=true),!u){for(let l of zd)if(e.endsWith(l.pattern)){let c=e.slice(0,-l.pattern.length);if(c.length>=2){e=c,r-=l.confidencePenalty,n.push(l.pattern),a.push(`suffix:${l.pattern}`);break}}}return r=Math.max(.5,r),i.length===0&&n.length===0&&a.length===0?Yt(t):Xt(e,r,{removedPrefixes:i,removedSuffixes:n,appliedRules:a})}},Cd=new bd,Ad=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Sd=class{constructor(t=Ad){this.name="operator",this.operators=[...t].sort((e,r)=>r.length-e.length);}canExtract(t,e){return this.operators.some(r=>t.startsWith(r,e))}extract(t,e){for(let r of this.operators)if(t.startsWith(r,e))return {value:r,length:r.length};return null}},xd="()[]{},:;",Dd=class{constructor(t=xd){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Nt(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function ra(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Nt(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Nt(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Nt(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var Bd=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?ra(t,e)!==null:false}extract(t,e){let r=ra(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Td=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},Fd=["http://","https://","//","./","../","/"];function Od(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function Rd(t,e){let r=t.slice(e),i=Fd.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=Od(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var Pd=class{constructor(){this.name="url";}canExtract(t,e){let r=t.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(t,e){let r=Rd(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Ld=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&e+1<t.length&&/[a-zA-Z_]/.test(t[e+1])}extract(t,e){if(!this.canExtract(t,e))return null;let r=1;for(;e+r<t.length&&/[a-zA-Z0-9_]/.test(t[e+r]);)r++;return {value:t.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function Nd(t){return /[a-zA-Z_]/.test(t)}function _d(t){return /[a-zA-Z0-9_]/.test(t)}var Md=new Set(["sa","ng","para","mula","hanggang","gaya","tulad","kasama","para sa"]),Id=class{constructor(){this.name="tagalog-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Nd(t[e])}extract(t,e){if(!this.context)throw new Error("TagalogKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&_d(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=Md.has(n),o=this.context.lookupKeyword(n),s=o&&o.normalized!==o.native?o.normalized:void 0,u;if(!o&&this.context.normalizer){let l=this.context.normalizer.normalize(i);if(l.stem!==i&&l.confidence>=.7){let c=this.context.lookupKeyword(l.stem);c&&(u=c.normalized);}}return {value:i,length:i.length,metadata:{normalized:s||u,isPreposition:a}}}};function $d(){return [new Id]}function jd(){return [new Pd,new Td,new Ld,new Bd]}var Vd=[{native:"totoo",normalized:"true"},{native:"mali",normalized:"false"},{native:"wala",normalized:"null"},{native:"hindi_tinukoy",normalized:"undefined"},{native:"una",normalized:"first"},{native:"huli",normalized:"last"},{native:"susunod",normalized:"next"},{native:"nakaraan",normalized:"previous"},{native:"pinakamalapit",normalized:"closest"},{native:"magulang",normalized:"parent"},{native:"pindot",normalized:"click"},{native:"pagbabago",normalized:"change"},{native:"isumite",normalized:"submit"},{native:"input",normalized:"input"},{native:"karga",normalized:"load"},{native:"mag_scroll",normalized:"scroll"},{native:"kasama",normalized:"inclusive"},{native:"bukod",normalized:"exclusive"},{native:"karakter",normalized:"characters"},{native:"random",normalized:"random"}],Wd=class extends xe{constructor(){super(),this.language="tl",this.direction="ltr",this.initializeKeywordsFromProfile(ta,Vd),this.setNormalizer(Cd),this.registerExtractors(jd()),this.registerExtractor(new Ae),this.registerExtractor(new Se),this.registerExtractors($d()),this.registerExtractor(new Sd),this.registerExtractor(new Dd);}classifyToken(t){return this.isKeyword(t)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(t)?"event-modifier":t.startsWith(".")||t.startsWith("#")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith(":")?"identifier":t.startsWith('"')||t.startsWith("'")||/^-?\d/.test(t)?"literal":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},qd=new Wd;Pe("tl",qd,ta);var na={code:"th",name:"Thai",nativeName:"\u0E44\u0E17\u0E22",direction:"ltr",script:"thai",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:false,defaultVerbForm:"base",verb:{position:"second",subjectDrop:true},references:{me:"\u0E09\u0E31\u0E19",it:"\u0E21\u0E31\u0E19",you:"\u0E04\u0E38\u0E13",result:"\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C",event:"\u0E40\u0E2B\u0E15\u0E38\u0E01\u0E32\u0E23\u0E13\u0E4C",target:"\u0E40\u0E1B\u0E49\u0E32\u0E2B\u0E21\u0E32\u0E22",body:"\u0E1A\u0E2D\u0E14\u0E35\u0E49"},possessive:{marker:"\u0E02\u0E2D\u0E07",markerPosition:"between",keywords:{\u0E02\u0E2D\u0E07\u0E09\u0E31\u0E19:"me",\u0E02\u0E2D\u0E07\u0E1C\u0E21:"me",\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13:"you",\u0E02\u0E2D\u0E07\u0E21\u0E31\u0E19:"it",\u0E02\u0E2D\u0E07\u0E40\u0E02\u0E32:"it",\u0E02\u0E2D\u0E07\u0E40\u0E18\u0E2D:"it"}},roleMarkers:{patient:{primary:"",position:"before"},destination:{primary:"\u0E43\u0E19",alternatives:["\u0E44\u0E1B\u0E22\u0E31\u0E07"],position:"before"},source:{primary:"\u0E08\u0E32\u0E01",position:"before"},style:{primary:"\u0E14\u0E49\u0E27\u0E22",position:"before"}},keywords:{toggle:{primary:"\u0E2A\u0E25\u0E31\u0E1A",alternatives:[],normalized:"toggle"},add:{primary:"\u0E40\u0E1E\u0E34\u0E48\u0E21",alternatives:[],normalized:"add"},remove:{primary:"\u0E25\u0E1A",alternatives:["\u0E25\u0E1A\u0E2D\u0E2D\u0E01"],normalized:"remove"},put:{primary:"\u0E43\u0E2A\u0E48",alternatives:["\u0E27\u0E32\u0E07"],normalized:"put"},append:{primary:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E17\u0E49\u0E32\u0E22",alternatives:[],normalized:"append"},prepend:{primary:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E2B\u0E19\u0E49\u0E32",alternatives:[],normalized:"prepend"},take:{primary:"\u0E23\u0E31\u0E1A",alternatives:[],normalized:"take"},make:{primary:"\u0E2A\u0E23\u0E49\u0E32\u0E07",alternatives:[],normalized:"make"},clone:{primary:"\u0E42\u0E04\u0E25\u0E19",alternatives:["\u0E2A\u0E33\u0E40\u0E19\u0E32"],normalized:"clone"},swap:{primary:"\u0E2A\u0E25\u0E31\u0E1A\u0E17\u0E35\u0E48",alternatives:[],normalized:"swap"},morph:{primary:"\u0E41\u0E1B\u0E25\u0E07\u0E23\u0E48\u0E32\u0E07",alternatives:[],normalized:"morph"},set:{primary:"\u0E15\u0E31\u0E49\u0E07",alternatives:["\u0E01\u0E33\u0E2B\u0E19\u0E14"],normalized:"set"},get:{primary:"\u0E23\u0E31\u0E1A\u0E04\u0E48\u0E32",alternatives:[],normalized:"get"},increment:{primary:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E04\u0E48\u0E32",alternatives:[],normalized:"increment"},decrement:{primary:"\u0E25\u0E14\u0E04\u0E48\u0E32",alternatives:[],normalized:"decrement"},log:{primary:"\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01",alternatives:[],normalized:"log"},show:{primary:"\u0E41\u0E2A\u0E14\u0E07",alternatives:[],normalized:"show"},hide:{primary:"\u0E0B\u0E48\u0E2D\u0E19",alternatives:[],normalized:"hide"},transition:{primary:"\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E1C\u0E48\u0E32\u0E19",alternatives:[],normalized:"transition"},on:{primary:"\u0E40\u0E21\u0E37\u0E48\u0E2D",alternatives:["\u0E15\u0E2D\u0E19"],normalized:"on"},trigger:{primary:"\u0E17\u0E23\u0E34\u0E01\u0E40\u0E01\u0E2D\u0E23\u0E4C",alternatives:[],normalized:"trigger"},send:{primary:"\u0E2A\u0E48\u0E07",alternatives:[],normalized:"send"},focus:{primary:"\u0E42\u0E1F\u0E01\u0E31\u0E2A",alternatives:[],normalized:"focus"},blur:{primary:"\u0E40\u0E1A\u0E25\u0E2D",alternatives:[],normalized:"blur"},empty:{primary:"\u0E25\u0E49\u0E32\u0E07",alternatives:["\u0E17\u0E33\u0E43\u0E2B\u0E49\u0E27\u0E48\u0E32\u0E07","\u0E27\u0E48\u0E32\u0E07"],normalized:"empty"},open:{primary:"\u0E40\u0E1B\u0E34\u0E14",normalized:"open"},close:{primary:"\u0E1B\u0E34\u0E14",normalized:"close"},select:{primary:"\u0E17\u0E33\u0E40\u0E04\u0E23\u0E37\u0E48\u0E2D\u0E07\u0E2B\u0E21\u0E32\u0E22",normalized:"select"},clear:{primary:"\u0E40\u0E04\u0E25\u0E35\u0E22\u0E23\u0E4C",normalized:"clear"},reset:{primary:"\u0E23\u0E35\u0E40\u0E0B\u0E47\u0E15",normalized:"reset"},breakpoint:{primary:"\u0E08\u0E38\u0E14\u0E1E\u0E31\u0E01",normalized:"breakpoint"},click:{primary:"\u0E04\u0E25\u0E34\u0E01",normalized:"click"},hover:{primary:"\u0E42\u0E2E\u0E40\u0E27\u0E2D\u0E23\u0E4C",alternatives:["\u0E27\u0E32\u0E07\u0E40\u0E21\u0E32\u0E2A\u0E4C"],normalized:"hover"},submit:{primary:"\u0E22\u0E37\u0E48\u0E19",alternatives:["\u0E2A\u0E48\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25"],normalized:"submit"},input:{primary:"\u0E1B\u0E49\u0E2D\u0E19",alternatives:["\u0E01\u0E23\u0E2D\u0E01"],normalized:"input"},changes:{primary:"\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19",normalized:"changes"},change:{primary:"\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19",alternatives:["\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07"],normalized:"change"},go:{primary:"\u0E44\u0E1B",alternatives:["\u0E44\u0E1B\u0E17\u0E35\u0E48"],normalized:"go"},scroll:{primary:"\u0E40\u0E25\u0E37\u0E48\u0E2D\u0E19",normalized:"scroll"},push:{primary:"\u0E14\u0E31\u0E19",alternatives:["\u0E1C\u0E25\u0E31\u0E01"],normalized:"push"},replace:{primary:"\u0E41\u0E17\u0E19\u0E17\u0E35\u0E48",alternatives:["\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19-url"],normalized:"replace"},process:{primary:"\u0E1B\u0E23\u0E30\u0E21\u0E27\u0E25\u0E1C\u0E25",alternatives:["\u0E08\u0E31\u0E14\u0E01\u0E32\u0E23"],normalized:"process"},wait:{primary:"\u0E23\u0E2D",alternatives:[],normalized:"wait"},fetch:{primary:"\u0E14\u0E36\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",alternatives:[],normalized:"fetch"},settle:{primary:"\u0E04\u0E07\u0E17\u0E35\u0E48",alternatives:[],normalized:"settle"},if:{primary:"\u0E16\u0E49\u0E32",alternatives:["\u0E2B\u0E32\u0E01"],normalized:"if"},unless:{primary:"unless",normalized:"unless"},when:{primary:"\u0E02\u0E13\u0E30\u0E17\u0E35\u0E48",normalized:"when"},where:{primary:"\u0E17\u0E35\u0E48\u0E44\u0E2B\u0E19",normalized:"where"},else:{primary:"\u0E44\u0E21\u0E48\u0E07\u0E31\u0E49\u0E19",alternatives:["\u0E44\u0E21\u0E48\u0E40\u0E0A\u0E48\u0E19\u0E19\u0E31\u0E49\u0E19"],normalized:"else"},repeat:{primary:"\u0E17\u0E33\u0E0B\u0E49\u0E33",alternatives:[],normalized:"repeat"},for:{primary:"\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A",alternatives:[],normalized:"for"},while:{primary:"\u0E43\u0E19\u0E02\u0E13\u0E30\u0E17\u0E35\u0E48",alternatives:[],normalized:"while"},forever:{primary:"\u0E15\u0E25\u0E2D\u0E14\u0E44\u0E1B",normalized:"forever",alternatives:["forever"]},continue:{primary:"\u0E15\u0E48\u0E2D\u0E44\u0E1B",alternatives:[],normalized:"continue"},halt:{primary:"\u0E2B\u0E22\u0E38\u0E14",alternatives:[],normalized:"halt"},throw:{primary:"\u0E42\u0E22\u0E19",alternatives:[],normalized:"throw"},call:{primary:"\u0E40\u0E23\u0E35\u0E22\u0E01",alternatives:[],normalized:"call"},return:{primary:"\u0E04\u0E37\u0E19\u0E04\u0E48\u0E32",alternatives:["\u0E01\u0E25\u0E31\u0E1A"],normalized:"return"},then:{primary:"\u0E41\u0E25\u0E49\u0E27",alternatives:[],normalized:"then"},and:{primary:"\u0E41\u0E25\u0E30",alternatives:[],normalized:"and"},exists:{primary:"\u0E21\u0E35\u0E2D\u0E22\u0E39\u0E48",normalized:"exists"},end:{primary:"\u0E08\u0E1A",alternatives:[],normalized:"end"},js:{primary:"\u0E40\u0E08\u0E40\u0E2D\u0E2A",alternatives:["js"],normalized:"js"},async:{primary:"\u0E2D\u0E30\u0E0B\u0E34\u0E07\u0E04\u0E4C",alternatives:[],normalized:"async"},tell:{primary:"\u0E1A\u0E2D\u0E01",alternatives:[],normalized:"tell"},default:{primary:"\u0E04\u0E48\u0E32\u0E40\u0E23\u0E34\u0E48\u0E21\u0E15\u0E49\u0E19",alternatives:[],normalized:"default"},init:{primary:"\u0E40\u0E23\u0E34\u0E48\u0E21\u0E15\u0E49\u0E19",alternatives:[],normalized:"init"},behavior:{primary:"\u0E1E\u0E24\u0E15\u0E34\u0E01\u0E23\u0E23\u0E21",alternatives:[],normalized:"behavior"},install:{primary:"\u0E15\u0E34\u0E14\u0E15\u0E31\u0E49\u0E07",alternatives:[],normalized:"install"},measure:{primary:"\u0E27\u0E31\u0E14",alternatives:[],normalized:"measure"},beep:{primary:"\u0E1A\u0E35\u0E4A\u0E1A",alternatives:[],normalized:"beep"},break:{primary:"\u0E02\u0E31\u0E14\u0E08\u0E31\u0E07\u0E2B\u0E27\u0E30",alternatives:[],normalized:"break"},copy:{primary:"\u0E04\u0E31\u0E14\u0E25\u0E2D\u0E01",alternatives:[],normalized:"copy"},exit:{primary:"\u0E2D\u0E2D\u0E01",alternatives:[],normalized:"exit"},pick:{primary:"\u0E40\u0E25\u0E37\u0E2D\u0E01",alternatives:[],normalized:"pick"},render:{primary:"\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25",alternatives:[],normalized:"render"},into:{primary:"\u0E43\u0E19",alternatives:[],normalized:"into"},before:{primary:"\u0E01\u0E48\u0E2D\u0E19",alternatives:[],normalized:"before"},after:{primary:"\u0E2B\u0E25\u0E31\u0E07",alternatives:[],normalized:"after"},until:{primary:"\u0E08\u0E19\u0E16\u0E36\u0E07",alternatives:[],normalized:"until"},event:{primary:"\u0E40\u0E2B\u0E15\u0E38\u0E01\u0E32\u0E23\u0E13\u0E4C",alternatives:[],normalized:"event"},from:{primary:"\u0E08\u0E32\u0E01",normalized:"from"},connect:{primary:"\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D",alternatives:["\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21"],normalized:"connect"},stream:{primary:"\u0E2A\u0E15\u0E23\u0E35\u0E21",alternatives:["\u0E2A\u0E15\u0E23\u0E35\u0E21\u0E21\u0E34\u0E48\u0E07","\u0E01\u0E23\u0E30\u0E41\u0E2A"],normalized:"stream"},live:{primary:"\u0E44\u0E25\u0E1F\u0E4C",alternatives:["\u0E2A\u0E14","\u0E16\u0E48\u0E32\u0E22\u0E17\u0E2D\u0E14\u0E2A\u0E14"],normalized:"live"},socket:{primary:"\u0E0B\u0E47\u0E2D\u0E01\u0E40\u0E01\u0E47\u0E15",alternatives:["websocket","\u0E40\u0E27\u0E47\u0E1A\u0E0B\u0E47\u0E2D\u0E01\u0E40\u0E01\u0E47\u0E15","socket"],normalized:"socket"},intercept:{primary:"\u0E14\u0E31\u0E01\u0E08\u0E31\u0E1A",alternatives:["intercept","\u0E2A\u0E01\u0E31\u0E14\u0E01\u0E31\u0E49\u0E19"],normalized:"intercept"},worker:{primary:"\u0E40\u0E27\u0E34\u0E23\u0E4C\u0E01\u0E40\u0E01\u0E2D\u0E23\u0E4C",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u0E2D\u0E35\u0E40\u0E27\u0E19\u0E15\u0E4C\u0E0B\u0E2D\u0E23\u0E4C\u0E2A"],normalized:"eventsource"},bind:{primary:"\u0E1C\u0E39\u0E01",alternatives:["bind"],normalized:"bind"}},tokenization:{boundaryStrategy:"character"},eventHandler:{keyword:{primary:"\u0E40\u0E21\u0E37\u0E48\u0E2D",alternatives:["\u0E15\u0E2D\u0E19"],normalized:"on"},sourceMarker:{primary:"\u0E08\u0E32\u0E01",position:"before"},eventMarker:{primary:"\u0E40\u0E21\u0E37\u0E48\u0E2D",alternatives:["\u0E15\u0E2D\u0E19"],position:"before"},temporalMarkers:["\u0E40\u0E21\u0E37\u0E48\u0E2D","\u0E15\u0E2D\u0E19"]}},Kd=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Hd=class{constructor(t=Kd){this.name="operator",this.operators=[...t].sort((e,r)=>r.length-e.length);}canExtract(t,e){return this.operators.some(r=>t.startsWith(r,e))}extract(t,e){for(let r of this.operators)if(t.startsWith(r,e))return {value:r,length:r.length};return null}},Ud="()[]{},:;",Gd=class{constructor(t=Ud){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function _t(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function ia(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=_t(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=_t(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=_t(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var Zd=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?ia(t,e)!==null:false}extract(t,e){let r=ia(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Yd=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},Xd=["http://","https://","//","./","../","/"];function Jd(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function Qd(t,e){let r=t.slice(e),i=Xd.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=Jd(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var em=class{constructor(){this.name="url";}canExtract(t,e){let r=t.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(t,e){let r=Qd(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},rm=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&e+1<t.length&&/[a-zA-Z_]/.test(t[e+1])}extract(t,e){if(!this.canExtract(t,e))return null;let r=1;for(;e+r<t.length&&/[a-zA-Z0-9_]/.test(t[e+r]);)r++;return {value:t.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function Br(t){let e=t.charCodeAt(0);return e>=3584&&e<=3711}function Mt(t){return /[a-zA-Z0-9_]/.test(t)}var tm=class{constructor(){this.name="thai-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Br(t[e])||Mt(t[e])}extract(t,e){if(!this.context)throw new Error("ThaiKeywordExtractor: context not set");let r=t[e];return Br(r)?this.extractThaiWord(t,e):Mt(r)?this.extractAsciiWord(t,e):null}extractThaiWord(t,e){if(!this.context)return null;let r=null,i=e,n="";for(;i<t.length&&Br(t[i]);){n+=t[i],i++;let s=this.context.lookupKeyword(n);s&&(r={word:n,entry:s});}if(r){let s=r.entry.normalized!==r.entry.native?r.entry.normalized:void 0;return {value:r.word,length:r.word.length,metadata:{normalized:s}}}let a=e,o="";for(;a<t.length&&Br(t[a])&&!(o.length>0&&this.isKeywordStart(t,a));)o+=t[a],a++;return o?{value:o,length:o.length,metadata:{}}:null}extractAsciiWord(t,e){if(!this.context)return null;let r=e,i="";for(;r<t.length&&Mt(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=this.context.lookupKeyword(n),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:i.length,metadata:{normalized:o}}}isKeywordStart(t,e){if(!this.context)return false;let r=e,i="";for(;r<t.length&&Br(t[r]);){if(i+=t[r],r++,this.context.lookupKeyword(i))return true;if(i.length>10)break}return false}};function im(){return [new tm]}function nm(){return [new em,new Yd,new rm,new Zd]}var am=[{native:"\u0E08\u0E23\u0E34\u0E07",normalized:"true"},{native:"\u0E40\u0E17\u0E47\u0E08",normalized:"false"},{native:"\u0E27\u0E48\u0E32\u0E07",normalized:"null"},{native:"\u0E44\u0E21\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14",normalized:"undefined"},{native:"\u0E41\u0E23\u0E01",normalized:"first"},{native:"\u0E2A\u0E38\u0E14\u0E17\u0E49\u0E32\u0E22",normalized:"last"},{native:"\u0E16\u0E31\u0E14\u0E44\u0E1B",normalized:"next"},{native:"\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32",normalized:"previous"},{native:"\u0E43\u0E01\u0E25\u0E49\u0E2A\u0E38\u0E14",normalized:"closest"},{native:"\u0E15\u0E49\u0E19\u0E17\u0E32\u0E07",normalized:"parent"},{native:"\u0E04\u0E25\u0E34\u0E01",normalized:"click"},{native:"\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07",normalized:"change"},{native:"\u0E2A\u0E48\u0E07",normalized:"submit"},{native:"\u0E2D\u0E34\u0E19\u0E1E\u0E38\u0E15",normalized:"input"},{native:"\u0E42\u0E2B\u0E25\u0E14",normalized:"load"},{native:"\u0E40\u0E25\u0E37\u0E48\u0E2D\u0E19",normalized:"scroll"},{native:"\u0E1B\u0E23\u0E31\u0E1A\u0E02\u0E19\u0E32\u0E14",normalized:"resize"},{native:"\u0E40\u0E27\u0E25\u0E32",normalized:"when"},{native:"\u0E44\u0E1B\u0E22\u0E31\u0E07",normalized:"to"},{native:"\u0E14\u0E49\u0E27\u0E22",normalized:"with"},{native:"\u0E41\u0E25\u0E30",normalized:"and"},{native:"\u0E23\u0E27\u0E21",normalized:"inclusive"},{native:"\u0E22\u0E01\u0E40\u0E27\u0E49\u0E19",normalized:"exclusive"},{native:"\u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30",normalized:"characters"},{native:"\u0E2A\u0E38\u0E48\u0E21",normalized:"random"}],om=class extends xe{constructor(){super(),this.language="th",this.direction="ltr",this.initializeKeywordsFromProfile(na,am),this.registerExtractors(nm()),this.registerExtractor(new Ae),this.registerExtractor(new Se),this.registerExtractors(im()),this.registerExtractor(new Hd),this.registerExtractor(new Gd);}classifyToken(t){return this.isKeyword(t)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(t)?"event-modifier":t.startsWith(".")||t.startsWith("#")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith(":")?"identifier":t.startsWith('"')||t.startsWith("'")||/^-?\d/.test(t)?"literal":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},sm=new om;Pe("th",sm,na);var um=new Set(["true","false","null","undefined","me","my","it","its","you","your","result","event","target","body"]);function oa(t){return t.kind==="literal"||t.kind==="selector"||t.kind==="reference"?true:t.kind==="identifier"?/^[:$]?[\p{L}_][\p{L}\p{M}\p{N}_]*$/u.test(t.value):t.kind==="keyword"&&um.has((t.normalized??"").toLowerCase())}function lm(t){return !!t&&(/^[([-]$/.test(t.value)||oa(t))}function cm(t){return !!t&&(t.value===")"||t.value==="]"||oa(t))}function dm(t,e,r){let i=t.tokens;if(!i.some(a=>a.value===e))return t;let n=[];return i.forEach((a,o)=>{if(a.value!==e||!lm(i[o+1])||cm(i[o-1])){n.push(a);return}let s=e.indexOf(" ");for(let[u,l]of [[e.slice(0,s),0],[e.slice(s+1),s+1]]){let c=a.position.start+l;for(let d of r(u))n.push({...d,position:{start:d.position.start+c,end:d.position.end+c}});}}),new oe(n,t.language)}var sa={code:"vi",name:"Vietnamese",nativeName:"Ti\u1EBFng Vi\u1EC7t",direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"base",verb:{position:"start",subjectDrop:true},references:{me:"t\xF4i",it:"n\xF3",you:"b\u1EA1n",result:"k\u1EBFt qu\u1EA3",event:"s\u1EF1 ki\u1EC7n",target:"m\u1EE5c ti\xEAu",body:"body"},possessive:{marker:"c\u1EE7a",markerPosition:"between",specialForms:{me:"c\u1EE7a t\xF4i",it:"c\u1EE7a n\xF3",you:"c\u1EE7a b\u1EA1n"},keywords:{"c\u1EE7a t\xF4i":"me",my:"me","c\u1EE7a b\u1EA1n":"you","c\u1EE7a anh":"you","c\u1EE7a ch\u1ECB":"you","c\u1EE7a n\xF3":"it"}},roleMarkers:{destination:{primary:"v\xE0o",alternatives:["cho","\u0111\u1EBFn"],position:"before"},source:{primary:"t\u1EEB",alternatives:["kh\u1ECFi"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"v\u1EDBi",position:"before"}},keywords:{toggle:{primary:"chuy\u1EC3n \u0111\u1ED5i",alternatives:["b\u1EADt t\u1EAFt","chuy\u1EC3n"],normalized:"toggle"},add:{primary:"th\xEAm",alternatives:["b\u1ED5 sung"],normalized:"add"},remove:{primary:"x\xF3a",alternatives:["g\u1EE1 b\u1ECF","lo\u1EA1i b\u1ECF","b\u1ECF"],normalized:"remove"},put:{primary:"\u0111\u1EB7t",alternatives:["\u0111\u1EC3","\u0111\u01B0a"],normalized:"put"},append:{primary:"n\u1ED1i",normalized:"append"},prepend:{primary:"th\xEAm v\xE0o \u0111\u1EA7u",normalized:"prepend"},take:{primary:"l\u1EA5y",normalized:"take"},make:{primary:"t\u1EA1o",normalized:"make"},clone:{primary:"nh\xE2n b\u1EA3n",normalized:"clone"},swap:{primary:"ho\xE1n \u0111\u1ED5i",normalized:"swap"},morph:{primary:"bi\u1EBFn \u0111\u1ED5i",normalized:"morph"},set:{primary:"g\xE1n",alternatives:["thi\u1EBFt l\u1EADp"],normalized:"set"},get:{primary:"l\u1EA5y gi\xE1 tr\u1ECB",alternatives:["nh\u1EADn"],normalized:"get"},increment:{primary:"t\u0103ng",alternatives:["t\u0103ng l\xEAn"],normalized:"increment"},decrement:{primary:"gi\u1EA3m",alternatives:["gi\u1EA3m \u0111i"],normalized:"decrement"},log:{primary:"in ra",normalized:"log"},show:{primary:"hi\u1EC3n th\u1ECB",alternatives:["hi\u1EC7n"],normalized:"show"},hide:{primary:"\u1EA9n",alternatives:["che","gi\u1EA5u"],normalized:"hide"},transition:{primary:"chuy\u1EC3n ti\u1EBFp",normalized:"transition"},on:{primary:"khi",alternatives:["tr\xEAn"],normalized:"on"},trigger:{primary:"k\xEDch ho\u1EA1t",normalized:"trigger"},send:{primary:"g\u1EEDi",normalized:"send"},focus:{primary:"t\u1EADp trung",normalized:"focus"},blur:{primary:"m\u1EA5t t\u1EADp trung",normalized:"blur"},empty:{primary:"l\xE0m-r\u1ED7ng",alternatives:["tr\u1ED1ng"],normalized:"empty"},open:{primary:"m\u1EDF",normalized:"open"},close:{primary:"\u0111\xF3ng",normalized:"close"},select:{primary:"\u0111\xE1nh-d\u1EA5u",normalized:"select"},clear:{primary:"t\u1EA9y",normalized:"clear"},reset:{primary:"\u0111\u1EB7t-l\u1EA1i",normalized:"reset"},breakpoint:{primary:"\u0111i\u1EC3m-d\u1EEBng",normalized:"breakpoint"},click:{primary:"nh\u1EA5p",alternatives:["b\u1EA5m"],normalized:"click"},hover:{primary:"di chu\u1ED9t",alternatives:["r\xEA chu\u1ED9t"],normalized:"hover"},submit:{primary:"n\u1ED9p",alternatives:[],normalized:"submit"},input:{primary:"nh\u1EADp",alternatives:["nh\u1EADp li\u1EC7u"],normalized:"input"},changes:{primary:"thay \u0111\u1ED5i",normalized:"changes"},change:{primary:"thay \u0111\u1ED5i",alternatives:["\u0111\u1ED5i"],normalized:"change"},go:{primary:"\u0111i \u0111\u1EBFn",alternatives:["\u0111i"],normalized:"go"},scroll:{primary:"cu\u1ED9n",normalized:"scroll"},push:{primary:"\u0111\u1EA9y",alternatives:["push"],normalized:"push"},replace:{primary:"thay_th\u1EBF",alternatives:["thay_the"],normalized:"replace"},process:{primary:"x\u1EED_l\xFD",alternatives:["xu_ly"],normalized:"process"},wait:{primary:"ch\u1EDD",alternatives:["\u0111\u1EE3i","ch\u1EDD \u0111\u1EE3i"],normalized:"wait"},fetch:{primary:"t\u1EA3i",normalized:"fetch"},settle:{primary:"\u1ED5n \u0111\u1ECBnh",normalized:"settle"},if:{primary:"n\u1EBFu",normalized:"if"},unless:{primary:"tr\u1EEB khi",alternatives:["tr\u1EEB_khi"],normalized:"unless"},when:{primary:"l\xFAc",normalized:"when"},where:{primary:"\u1EDF_\u0111\xE2u",normalized:"where"},else:{primary:"kh\xF4ng th\xEC",alternatives:["n\u1EBFu kh\xF4ng"],normalized:"else"},repeat:{primary:"l\u1EB7p l\u1EA1i",normalized:"repeat"},for:{primary:"v\u1EDBi m\u1ED7i",normalized:"for"},while:{primary:"trong khi",normalized:"while"},forever:{primary:"m\xE3i m\xE3i",normalized:"forever",alternatives:["forever"]},continue:{primary:"ti\u1EBFp t\u1EE5c",normalized:"continue"},halt:{primary:"d\u1EEBng",alternatives:["d\u1EEBng l\u1EA1i"],normalized:"halt"},throw:{primary:"n\xE9m",normalized:"throw"},call:{primary:"g\u1ECDi",normalized:"call"},return:{primary:"tr\u1EA3 v\u1EC1",normalized:"return"},then:{primary:"r\u1ED3i",alternatives:["sau \u0111\xF3","th\xEC"],normalized:"then"},and:{primary:"v\xE0",normalized:"and"},matches:{primary:"kh\u1EDBp",normalized:"matches"},end:{primary:"k\u1EBFt th\xFAc",normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"b\u1EA5t \u0111\u1ED3ng b\u1ED9",normalized:"async"},tell:{primary:"n\xF3i v\u1EDBi",normalized:"tell"},default:{primary:"m\u1EB7c \u0111\u1ECBnh",normalized:"default"},init:{primary:"kh\u1EDFi t\u1EA1o",normalized:"init"},behavior:{primary:"h\xE0nh vi",normalized:"behavior"},install:{primary:"c\xE0i \u0111\u1EB7t",normalized:"install"},measure:{primary:"\u0111o l\u01B0\u1EDDng",normalized:"measure"},beep:{primary:"beep",normalized:"beep"},break:{primary:"ng\u1EAFt",normalized:"break"},copy:{primary:"sao ch\xE9p",normalized:"copy"},exit:{primary:"tho\xE1t",alternatives:["tho\xE1t ra"],normalized:"exit"},pick:{primary:"ch\u1ECDn",normalized:"pick"},render:{primary:"k\u1EBFt xu\u1EA5t",normalized:"render"},into:{primary:"v\xE0o",alternatives:["v\xE0o trong"],normalized:"into"},before:{primary:"tr\u01B0\u1EDBc",alternatives:["tr\u01B0\u1EDBc khi"],normalized:"before"},after:{primary:"sau",alternatives:["sau khi"],normalized:"after"},until:{primary:"cho \u0111\u1EBFn khi",normalized:"until"},event:{primary:"s\u1EF1 ki\u1EC7n",normalized:"event"},from:{primary:"t\u1EEB",alternatives:["kh\u1ECFi"],normalized:"from"},connect:{primary:"k\u1EBFt-n\u1ED1i",alternatives:["k\u1EBFt-n\u1ED1i-t\u1EDBi"],normalized:"connect"},stream:{primary:"truy\u1EC1n-ph\xE1t",alternatives:["ph\xE1t","lu\u1ED3ng"],normalized:"stream"},live:{primary:"tr\u1EF1c-ti\u1EBFp",alternatives:["ph\xE1t-tr\u1EF1c-ti\u1EBFp","live"],normalized:"live"},socket:{primary:"socket",alternatives:["\u1ED5-c\u1EAFm","websocket"],normalized:"socket"},bind:{primary:"r\xE0ng bu\u1ED9c",alternatives:["li\xEAn k\u1EBFt","bind"],normalized:"bind"},intercept:{primary:"ch\u1EB7n",alternatives:["ch\u1EB7n b\u1EAFt","intercept"],normalized:"intercept"},worker:{primary:"worker",alternatives:["c\xF4ng nh\xE2n"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["ngu\u1ED3n s\u1EF1 ki\u1EC7n"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"khi",alternatives:["tr\xEAn"],normalized:"on"},sourceMarker:{primary:"tr\xEAn",alternatives:["t\u1EA1i"],position:"before"},eventMarker:{primary:"khi",alternatives:["l\xFAc"],position:"before"},temporalMarkers:["khi","l\xFAc"]}};function mm(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:pm,isIdentifierChar:fm}=mm(/[a-zA-Z\u00e0\u00e1\u1ea3\u00e3\u1ea1\u0103\u1eb1\u1eaf\u1eb3\u1eb5\u1eb7\u00e2\u1ea7\u1ea5\u1ea9\u1eab\u1ead\u00e8\u00e9\u1ebb\u1ebd\u1eb9\u00ea\u1ec1\u1ebf\u1ec3\u1ec5\u1ec7\u00ec\u00ed\u1ec9\u0129\u1ecb\u00f2\u00f3\u1ecf\u00f5\u1ecd\u00f4\u1ed3\u1ed1\u1ed5\u1ed7\u1ed9\u01a1\u1edd\u1edb\u1edf\u1ee1\u1ee3\u00f9\u00fa\u1ee7\u0169\u1ee5\u01b0\u1eeb\u1ee9\u1eed\u1eef\u1ef1\u1ef3\u00fd\u1ef7\u1ef9\u1ef5\u0111\u00c0\u00c1\u1ea2\u00c3\u1ea0\u0102\u1eb0\u1eae\u1eb2\u1eb4\u1eb6\u00c2\u1ea6\u1ea4\u1ea8\u1eaa\u1eac\u00c8\u00c9\u1eba\u1ebc\u1eb8\u00ca\u1ec0\u1ebe\u1ec2\u1ec4\u1ec6\u00cc\u00cd\u1ec8\u0128\u1eca\u00d2\u00d3\u1ece\u00d5\u1ecc\u00d4\u1ed2\u1ed0\u1ed4\u1ed6\u1ed8\u01a0\u1edc\u1eda\u1ede\u1ee0\u1ee2\u00d9\u00da\u1ee6\u0168\u1ee4\u01af\u1eea\u1ee8\u1eec\u1eee\u1ef0\u1ef2\u00dd\u1ef6\u1ef8\u1ef4\u0110]/),hm=new Set(["trong","ngo\xE0i","tr\xEAn","d\u01B0\u1EDBi","v\xE0o","ra","\u0111\u1EBFn","t\u1EEB","v\u1EDBi","cho","b\u1EDFi","qua","tr\u01B0\u1EDBc","sau","gi\u1EEFa","b\xEAn","theo","v\u1EC1","t\u1EDBi","l\xEAn","xu\u1ED1ng"]),ym=class{constructor(){this.name="vietnamese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return pm(t[e])}extract(t,e){if(!this.context)throw new Error("VietnameseKeywordExtractor: context not set");let r=this.tryMultiWordPhrase(t,e);if(r)return r;let i=e,n="";for(;i<t.length&&fm(t[i]);)n+=t[i++];if(!n)return null;let a=n.toLowerCase(),o=hm.has(a),s=this.context.lookupKeyword(a),u=s&&s.normalized!==s.native?s.normalized:void 0;return {value:n,length:i-e,metadata:{normalized:u,isPreposition:o}}}tryMultiWordPhrase(t,e){if(!this.context)return null;let r=["v\xE0o trong","s\u1EF1 ki\u1EC7n"];for(let i of r)if(t.slice(e,e+i.length).toLowerCase()===i.toLowerCase()){let a=e+i.length;if(a>=t.length||!/[a-zA-Z\u00e0\u00e1\u1ea3\u00e3\u1ea1\u0103\u1eb1\u1eaf\u1eb3\u1eb5\u1eb7\u00e2\u1ea7\u1ea5\u1ea9\u1eab\u1ead\u00e8\u00e9\u1ebb\u1ebd\u1eb9\u00ea\u1ec1\u1ebf\u1ec3\u1ec5\u1ec7\u00ec\u00ed\u1ec9\u0129\u1ecb\u00f2\u00f3\u1ecf\u00f5\u1ecd\u00f4\u1ed3\u1ed1\u1ed5\u1ed7\u1ed9\u01a1\u1edd\u1edb\u1edf\u1ee1\u1ee3\u00f9\u00fa\u1ee7\u0169\u1ee5\u01b0\u1eeb\u1ee9\u1eed\u1eef\u1ef1\u1ef3\u00fd\u1ef7\u1ef9\u1ef5\u0111]/.test(t[a])){let o=this.context.lookupKeyword(i);return {value:t.slice(e,a),length:i.length,metadata:{normalized:o?.normalized,isPreposition:false}}}}return null}};function vm(){return [new ym]}var Em=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],gm=class{constructor(t=Em){this.name="operator",this.operators=[...t].sort((e,r)=>r.length-e.length);}canExtract(t,e){return this.operators.some(r=>t.startsWith(r,e))}extract(t,e){for(let r of this.operators)if(t.startsWith(r,e))return {value:r,length:r.length};return null}},zm="()[]{},:;",wm=class{constructor(t=zm){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function It(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function aa(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=It(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=It(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=It(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var km=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?aa(t,e)!==null:false}extract(t,e){let r=aa(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},bm=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},Cm=["http://","https://","//","./","../","/"];function Am(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function Sm(t,e){let r=t.slice(e),i=Cm.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=Am(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var xm=class{constructor(){this.name="url";}canExtract(t,e){let r=t.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(t,e){let r=Sm(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Dm=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&e+1<t.length&&/[a-zA-Z_]/.test(t[e+1])}extract(t,e){if(!this.canExtract(t,e))return null;let r=1;for(;e+r<t.length&&/[a-zA-Z0-9_]/.test(t[e+r]);)r++;return {value:t.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function Bm(){return [new xm,new bm,new Dm,new km]}var Tm=[{native:"\u0111\xFAng",normalized:"true"},{native:"sai",normalized:"false"},{native:"null",normalized:"null"},{native:"r\u1ED7ng",normalized:"null"},{native:"kh\xF4ng x\xE1c \u0111\u1ECBnh",normalized:"undefined"},{native:"\u0111\u1EA7u ti\xEAn",normalized:"first"},{native:"cu\u1ED1i c\xF9ng",normalized:"last"},{native:"ti\u1EBFp theo",normalized:"next"},{native:"tr\u01B0\u1EDBc \u0111\xF3",normalized:"previous"},{native:"g\u1EA7n nh\u1EA5t",normalized:"closest"},{native:"cha",normalized:"parent"},{native:"nh\u1EA5p",normalized:"click"},{native:"nh\u1EA5p chu\u1ED9t",normalized:"click"},{native:"click",normalized:"click"},{native:"nh\u1EA5p \u0111\xFAp",normalized:"dblclick"},{native:"nh\u1EADp",normalized:"input"},{native:"thay \u0111\u1ED5i",normalized:"change"},{native:"g\u1EEDi bi\u1EC3u m\u1EABu",normalized:"submit"},{native:"ph\xEDm xu\u1ED1ng",normalized:"keydown"},{native:"ph\xEDm l\xEAn",normalized:"keyup"},{native:"chu\u1ED9t v\xE0o",normalized:"mouseover"},{native:"chu\u1ED9t ra",normalized:"mouseout"},{native:"t\u1EA3i trang",normalized:"load"},{native:"cu\u1ED9n",normalized:"scroll"},{native:"c\u1EE7a t\xF4i",normalized:"my"},{native:"c\u1EE7a n\xF3",normalized:"its"},{native:"gi\xE2y",normalized:"s"},{native:"mili gi\xE2y",normalized:"ms"},{native:"ph\xFAt",normalized:"m"},{native:"gi\u1EDD",normalized:"h"},{native:"th\xEAm v\xE0o cu\u1ED1i",normalized:"append"},{native:"nh\xE2n b\u1EA3n",normalized:"clone"},{native:"t\u1EA1o ra",normalized:"make"},{native:"\u0111\u1EB7t gi\xE1 tr\u1ECB",normalized:"set"},{native:"gi\xE1 tr\u1ECB",normalized:"value"},{native:"ghi nh\u1EADt k\xFD",normalized:"log"},{native:"chuy\u1EC3n t\u1EDBi",normalized:"go"},{native:"ng\u01B0\u1EE3c l\u1EA1i",normalized:"else"},{native:"l\u1EB7p",normalized:"repeat"},{native:"ho\u1EB7c",normalized:"or"},{native:"kh\xF4ng",normalized:"not"},{native:"l\xE0",normalized:"is"},{native:"t\u1ED3n t\u1EA1i",normalized:"exists"},{native:"javascript",normalized:"js"},{native:"bao g\u1ED3m",normalized:"inclusive"},{native:"lo\u1EA1i tr\u1EEB",normalized:"exclusive"},{native:"k\xFD t\u1EF1",normalized:"characters"},{native:"ng\u1EABu nhi\xEAn",normalized:"random"}],Fm=class extends xe{constructor(){super(),this.language="vi",this.direction="ltr",this.initializeKeywordsFromProfile(sa,Tm),this.registerExtractors(Bm()),this.registerExtractor(new Ae),this.registerExtractor(new Se),this.registerExtractors(vm()),this.registerExtractor(new gm),this.registerExtractor(new wm);}tokenize(t){return dm(super.tokenize(t),"n\u1EBFu kh\xF4ng",e=>super.tokenize(e).tokens)}classifyToken(t){let e=t.toLowerCase();return this.isKeyword(e)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(t)?"event-modifier":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},Om=new Fm;Pe("vi",Om,sa);function Jr(t){let e=t.getAttribute("data-lang");if(e)return Xr(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return Xr(r);let i=t.closest?.("[lang]")?.getAttribute("lang");if(i)return Xr(i);let n=typeof document<"u"?document.documentElement?.lang:null;return n&&n!=="en"?Xr(n):null}function Xr(t){return t.split("-")[0].toLowerCase()}var ua={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],beep:[["patient",""]],behavior:[["patient",""]],bind:[["destination",""],["source","to"]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],eventsource:[],exit:[],fetch:[["source",""],["style","with"],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""],["manner","in new"]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],intercept:[],js:[["patient",""]],live:[],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["patient",""],["destination","to"],["manner","using view"]],on:[["event",""],["source","from"]],open:[["patient",""],["style","as"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"],["manner","using view"]],push:[["patient","url"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],replace:[["patient","url"]],reset:[["patient",""]],return:[["patient",""]],scroll:[["destination","to"]],select:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"],["scope","on"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],socket:[],swap:[["method",""],["destination","of"],["patient","with"],["manner","using view"]],take:[["patient",""],["source","from"],["recipient","for"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"],["duration","for"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],when:[["condition",""]],while:[["condition",""]],worker:[]};var Rm=new Set(["repeat","for","while","tell"]),Pm=new Set(["js"]);function Qr(t){switch(t.kind){case "event-handler":return Nm(t);case "compound":return la(t);case "loop":return Lm(t);default:return _m(t)}}function Lm(t){let e={kind:"command",action:t.action,roles:t.roles};return la({statements:[e,...t.body],chainType:"then"})}function Nm(t){let e=["on"],r=t.roles.get("event");r&&e.push(r.type==="literal"?String(r.value):Tr(r));let i=t.roles.get("source");if(i&&e.push("from",Tr(i)),t.body&&t.body.length>0){let n=t.body.map(Qr);e.push(n.join(" "));}return e.join(" ")}function la(t){let e=t.chainType==="async"?"async":t.chainType,r=t.statements.map(Qr),i=r[0]??"";for(let n=1;n<r.length;n++){let a=t.statements[n-1],o=t.statements[n],s=a.kind==="command"&&Rm.has(a.action),u=a.kind==="command"&&a.action==="bind"&&o.kind==="command"&&o.action==="bind";a.kind==="command"&&Pm.has(a.action)&&(i+=" end"),i+=(s||u?" ":` ${e} `)+r[n];}return i}function _m(t){let e=ua[t.action];if(e){let i=[t.action];for(let[n,a]of e){let o=t.roles.get(n);o&&((n==="destination"||n==="source")&&o.type==="reference"&&o.value==="me"||(a&&i.push(a),i.push(Tr(o))));}return i.join(" ")}let r=[t.action];for(let[,i]of t.roles)r.push(Tr(i));return r.join(" ")}function Tr(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 Mm(t);case "expression":return t.raw;case "flag":return t.enabled?`+${t.name}`:`~${t.name}`}}function Mm(t){let e=Tr(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 Im={confidenceThreshold:.5,strategy:"semantic"};function $m(t,e){return typeof t=="number"?t:t[e]??t["*"]??.5}var jm=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Vm(t){let e=t.match(jm);if(!e)return null;let r=e[1],i=t.slice(r.length);return i?{prefix:r,commands:i}:null}function ca(t){function e(n,a,o){try{return t.isLanguageRegistered(a)?t.translateSingle(n,a,o):null}catch{return null}}function r(n,a,o){try{let s=o(n,a);return s!==n?s:null}catch{return null}}function i(n,a,o){if(o.strategy==="semantic"||o.strategy==="auto"){let s=$m(o.confidenceThreshold,a),u=e(n,a,s);if(u!==null)return u}if((o.strategy==="auto"||o.strategy==="i18n")&&o.i18nToEnglish){let s=r(n,a,o.i18nToEnglish);if(s!==null)return s}return null}return function(a,o,s={}){if(o==="en")return a;let u={...Im,...s},l=i(a,o,u);if(l!==null)return l;let c=Vm(a);if(c){let d=i(c.commands,o,u);if(d!==null)return c.prefix+d}return a}}var $t=ca({isLanguageRegistered:Zi,translateSingle(t,e,r){let i=_n(t,e);return i.confidence<r||!i.node?null:Qr(i.node)}});var jt=new WeakSet;function Wm(t){return (t.config?.attributes??"_, script, data-script").split(",").map(r=>r.trim()).filter(Boolean)}function qm(t,e){for(let r of e)if(t.hasAttribute(r))return r;return null}function da(t,e){if(typeof t.addBeforeProcessHook!="function"){console.warn("[hyperscript-i18n] _hyperscript.addBeforeProcessHook is unavailable \u2014 this build of _hyperscript.org is not supported. Load a current version from https://unpkg.com/hyperscript.org.");return}let r=Wm(t),i=[...r.map(a=>`[${a}]`),'script[type="text/hyperscript"]'].join(", "),n=a=>{if(jt.has(a))return;if(a instanceof HTMLScriptElement&&a.type==="text/hyperscript"){let l=a.textContent??"";if(!l)return;let c=e(l,a);jt.add(a),c!=null&&c!==l&&(a.textContent=c);return}let o=qm(a,r);if(!o)return;let s=a.getAttribute(o);if(!s)return;let u=e(s,a);jt.add(a),u!=null&&u!==s&&a.setAttribute(o,u);};t.addBeforeProcessHook(a=>{!a||typeof a.querySelectorAll!="function"||(typeof a.matches=="function"&&a.matches(i)&&n(a),a.querySelectorAll(i).forEach(n));});}var Km=new Set(["me","my","i","it","its","you","your"]);function Hm(t){for(let e of t?.features??[])for(let r of e.events??[])if(typeof r.on=="string"&&Km.has(r.on.toLowerCase()))return r.on}function pa(t,e){if(typeof t.parse!="function")return true;try{let r=t.parse(e);return r?.errors&&r.errors.length>0?!1:Hm(r)===void 0}catch{return false}}var ma=new Set;function fa(t,e,r){ma.has(t)||(ma.add(t),console.warn(`[hyperscript-i18n] Translation for lang="${t}" rendered hyperscript the host parser rejects (or reads as a handler for an event named like me/it/you) \u2014 falling back to the original text. Source: "${e.length>60?e.slice(0,60)+"\u2026":e}" \u2192 "${r.length>60?r.slice(0,60)+"\u2026":r}". Further elements in this language stay quiet \u2014 enable { debug: true } for per-element detail.`));}function Vt(t={}){return function(r){let i=r;da(i,(n,a)=>{let o=Um(a,t);if(!o||o==="en")return n;let s=$t(n,o,t);if(s!==n){if(t.validateWithHost!==false&&!pa(i,s))return t.debug?console.log(`[hyperscript-i18n] ${o}: host rejected "${s}" \u2014 keeping "${n}"`):fa(o,n,s),n;t.debug&&console.log(`[hyperscript-i18n] ${o}: "${n}" \u2192 "${s}"`);}return s});}}function Um(t,e){if(e.languageAttribute){let i=t.getAttribute(e.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let r=Jr(t);return r||(e.defaultLanguage??null)}function ha(t,e,r={}){return e==="en"?t:$t(t,e,r)}Gi(t=>Gn(t));function ya(){typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(Vt());}var Mh=["id","ms","tl","th","vi"];ya();
|
|
6
|
-
exports.plugin=
|
|
1
|
+
var HyperscriptI18n=(function(exports){'use strict';function Be(r,e){return e?{type:"literal",value:r,dataType:e}:{type:"literal",value:r}}function It(r,e){return e?{type:"selector",value:r,selectorKind:e}:{type:"selector",value:r}}function gt(r){return {type:"reference",value:r}}function $t(r,e){return {type:"property-path",object:r,property:e}}var da=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function mr(r,e=da){return e.has(r)}var Gn=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 a=`[framework:${this.namespace}]`,i=new Date().toISOString();switch(r){case "debug":console.debug(`${i} ${a} DEBUG:`,e,...t);break;case "info":console.info(`${i} ${a} INFO:`,e,...t);break;case "warn":console.warn(`${i} ${a} WARN:`,e,...t);break;case "error":console.error(`${i} ${a} 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 Zn(r){return new Gn(r)}function rt(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 Yn(r,e){return r?.possessive?.keywords?.[e]}var wt=class at{constructor(){this.logger=Zn("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,t,a){let i=e.mark(),n=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 s=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)s.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",s),this.logger.debug("Profile code:",a?.code);}this.currentProfile=a,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 o=this.matchTokenSequence(e,t.template.tokens,n);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(n.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(i),null;let u=this.calculateConfidence(t,n);return this.applyExtractionRules(t,n),{pattern:t,captured:n,consumedTokens:e.position()-i.position,confidence:u}}matchBest(e,t,a){let i=[];for(let o of t){let u=e.mark(),s=this.matchPattern(e,o,a);s&&i.push(s),e.reset(u);}if(i.length===0)return null;i.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let n=i[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,t,a,i){let n=t[0],o=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=null,s=null;for(let l=0;l<t.length;l++){let c=t[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,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"),c.type==="role"&&c.greedy){let h=this.collectStopMarkers(t,l+1);if(i)for(let E of i)h.add(E);let v=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||this.isStopMarker(E,h))break;v.push(E.value),e.advance();}if(v.length>0){a.set(c.role,{type:"expression",raw:v.join(" ")}),u=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let h=this.collectStopMarkers(t,l+1);if(i)for(let E of i)h.add(E);if(this.matchGroupToken(e,c,a,h)){u=null,s=null;continue}if(this.isOptional(c))continue;return false}let d=c.type==="role"&&c.optional===true,m=d?e.mark():null;if(c.type==="role"&&!d){let h=l+1<t.length?t[l+1]:null;if(h?.type==="literal"){let v=e.peek();if(v&&this.getMatchType(v,h.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(c))continue;if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),a.delete(s),u=null,s=null;let E=this.matchPatternToken(e,c,a);if(this.logger.debug(" >> Backtrack retry result:",E),E)continue}return false}}}let y=this.matchPatternToken(e,c,a);if(this.logger.debug(" >> Match result:",y),y){d?(u=m,s=c.role):(u=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),a.delete(s),u=null,s=null;let h=this.matchPatternToken(e,c,a);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}return true}matchPatternToken(e,t,a){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,a);case "group":return this.matchGroupToken(e,t,a);default:return false}}matchLiteralToken(e,t){let a=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",t.value),this.logger.debug(" >>> matchLiteralToken: got token",a?JSON.stringify({type:a.type,value:a.value,kind:a.kind}):"null"),!a)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let i=this.getMatchType(a,t.value);if(this.logger.debug(" >>> matchType for",a.value,"vs",t.value,":",i),i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let n of t.alternatives){let o=this.getMatchType(a,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,a){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 n=this.tryMatchPossessiveExpression(e);if(n)return t.expectedTypes&&t.expectedTypes.length>0&&!rt(n.type,t.expectedTypes)?t.optional||false:(a.set(t.role,n),true);let o=this.tryMatchMethodCallExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!rt(o.type,t.expectedTypes)?t.optional||false:(a.set(t.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!rt(u.type,t.expectedTypes)?t.optional||false:(a.set(t.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!rt(s.type,t.expectedTypes)?t.optional||false:(a.set(t.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!rt(l.type,t.expectedTypes)?t.optional||false:(a.set(t.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null");let c=this.tokenToSemanticValue(i);return this.logger.debug(" >>> tokenToSemanticValue returned:",c?JSON.stringify(c):"null"),c?(this.logger.debug(" >>> Validating type:",c.type,"against expected:",t.expectedTypes),t.expectedTypes&&t.expectedTypes.length>0&&!rt(c.type,t.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",t.optional||false),t.optional||false):(this.logger.debug(" >>> Type validation PASSED"),a.set(t.role,c),e.advance(),true)):t.optional||false}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let a=t.normalized||t.value,i=this.safeToLowerCase(a),n=Yn(this.currentProfile,i);if(!n)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),$t(gt(n),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let a=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(a),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(a),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(a),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<at.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${t.value}.${n.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let a=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(a),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(a),null;e.advance();let o=`${t.value}.${n.value}`,u=1;for(;!e.isAtEnd()&&u<at.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<at.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(c===0){e.advance();break}c--;}if(d.kind==="punctuation"&&d.value==="("&&c++,d.kind==="punctuation"&&d.value===","){e.advance();continue}l.push(d.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let a=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(a),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(a),null):(e.advance(),$t(It(t.value),n.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||typeof t.value!="string"||!t.value.startsWith("#"))return null;let a=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(a),null;let n=e.peek(1);n&&n.kind,e.advance();let o=i.value.slice(1);return $t(It(t.value),o)}matchGroupToken(e,t,a,i){let n=e.mark(),o=new Set(a.keys());if(this.matchTokenSequence(e,t.tokens,a,i))return true;e.reset(n);for(let l of a.keys())o.has(l)||a.delete(l);if(!t.optional)return false;let s=this.getGroupLeadingMarker(t);if(s)for(let l=1;l<=at.MAX_MARKER_SCAN;l++){let c=e.peek(l);if(!c)break;if((c.normalized||c.value).toLowerCase()===s){this.logger.debug(" >> MARKER SCAN: found",s,"at offset",l,"- skipping intervening tokens");for(let m=0;m<l;m++)e.advance();if(this.matchTokenSequence(e,t.tokens,a,i))return true;e.reset(n);for(let m of a.keys())o.has(m)||a.delete(m);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 a=new Set;for(let i=t;i<e.length;i++){let n=e[i];if(n.type==="literal"){if(a.add(n.value.toLowerCase()),n.alternatives)for(let o of n.alternatives)a.add(o.toLowerCase());break}if(n.type==="group"){for(let o of n.tokens)if(o.type==="literal"){if(a.add(o.value.toLowerCase()),o.alternatives)for(let u of o.alternatives)a.add(u.toLowerCase());break}if(!n.optional)break}}return a}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 It(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=e.normalized||e.value;this.safeToLowerCase(t);return Be(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return gt(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return Be(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 Be(i,"string")}if(e==="true")return Be(true,"boolean");if(e==="false")return Be(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?Be(e,"duration"):Be(i,"number")}let a=parseFloat(e);return isNaN(a)?Be(e,"string"):Be(a,"number")}applyExtractionRules(e,t){for(let[a,i]of Object.entries(e.extraction))t.has(a)||(i.value!==void 0?t.set(a,{type:"literal",value:i.value}):i.default&&t.set(a,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,t){let a=0,i=0,n=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")i+=1,t.has(l.role)&&(a+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let p=n(c.role),d=.8;i+=d,t.has(c.role)?a+=d:p&&(a+=d*.6);}}let o=i>0?a/i:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let u=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+u);let s=this.arabicPrepositionDisambiguation(e,t);return o=Math.max(0,Math.min(1,o+s)),o}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let a=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(a.has(t.value))return .15;if(t.alternatives){for(let i of t.alternatives)if(a.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let a=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[n,o]of t.entries()){let u=i[n];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?a+=.1:a-=.1;}}return Math.max(-0.1,Math.min(.1,a))}skipNoiseWords(e){let t=e.peek();if(!t)return;let a=this.safeToLowerCase(t.value);if(at.ENGLISH_NOISE_WORDS.has(a)){let i=e.mark();e.advance();let n=e.peek();if(n&&n.kind==="selector")return;e.reset(i);}a==="class"&&e.advance();}extractEventModifiers(e){let t={},a=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let n=i.metadata;if(!n)break;switch(a=true,n.modifierName){case "once":t.once=true;break;case "debounce":typeof n.value=="number"&&(t.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(t.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(t.queue=n.value);break}e.advance();}return a?t:void 0}};wt.MAX_MARKER_SCAN=3;wt.MAX_PROPERTY_DEPTH=10;wt.MAX_METHOD_ARGS=20;wt.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Xn=wt;new Xn;var Se=class{constructor(){this.name="string-literal";}canExtract(r,e){let t=r[e];return t==="'"&&e>0&&/[\p{L}\p{M}\p{N}_)\]]/u.test(r[e-1])?false:t==='"'||t==="'"||t==="`"||t==="\u201C"||t==="\u2018"}extract(r,e){let t=r[e];if(t==="\u201C"){let n=1;for(;e+n<r.length;){if(r[e+n]==="\u201D")return n++,{value:r.substring(e,e+n),length:n};n++;}return null}if(t==="\u2018"){let n=1;for(;e+n<r.length;){if(r[e+n]==="\u2019")return n++,{value:r.substring(e,e+n),length:n};n++;}return null}let a=1,i=false;for(;e+a<r.length;){let n=r[e+a];if(i){i=false,a++;continue}if(n==="\\"){i=true,a++;continue}if(n===t)return a++,{value:r.substring(e,e+a),length:a};a++;}return null}},Te=class{constructor(){this.name="number";}canExtract(r,e){return /\d/.test(r[e])}extract(r,e){let t=0,a=false;for(;e+t<r.length;){let o=r[e+t];if(/\d/.test(o))t++;else if(o==="."&&!a)a=true,t++;else break}if(t===0)return null;let i=r.substring(e,e+t),n=e+t;if(n<r.length){let o=r.slice(n),u=[{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 l of u)if(o.startsWith(l.pattern))return {value:i+l.suffix,length:t+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:i+"ms",length:t+2,metadata:{hasTimeUnit:true}};let s=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of s)if(o.startsWith(l.pattern))return {value:i+l.suffix,length:t+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:i+o[0],length:t+1,metadata:{hasTimeUnit:true}}}return {value:i,length:t}}};function Jn(r){return "setContext"in r&&typeof r.setContext=="function"}function Qn(r){let e={language:r.language,direction:r.direction,lookupKeyword:r.lookupKeyword.bind(r),isKeyword:r.isKeyword.bind(r),isKeywordStart:r.isKeywordStart.bind(r),...r.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:r.isKeywordStartAtBoundary.bind(r)}:{}};return r.normalizer?{...e,normalizer:r.normalizer}:e}var se=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 ee(r,e){return {start:r,end:e}}function te(r,e,t,a){if(typeof r=="object"){let{value:n,kind:o,position:u,normalized:s,stem:l,stemConfidence:c,metadata:p}=r;return {value:n,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...p!==void 0&&{metadata:p}}}let i=r;if(!e||!t)throw new Error("createToken requires kind and position parameters");if(typeof a=="string")return {value:i,kind:e,position:t,normalized:a};if(a){let{normalized:n,stem:o,stemConfidence:u,metadata:s}=a;return {value:i,kind:e,position:t,...n!==void 0&&{normalized:n},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:i,kind:e,position:t}}function kt(r){return /\s/.test(r)}function eo(r){return r==="#"||r==="."||r==="["||r==="@"||r==="*"||r==="<"}function to(r){return r==='"'||r==="'"||r==="`"||r==="\u300C"||r==="\u300D"}function Ue(r){return /\d/.test(r)}function Wt(r){return r.replace(/[\u064b-\u0652\u0670]/g,"")}function ro(r){return /[a-zA-Z]/.test(r)}function ve(r){return /[a-zA-Z0-9_-]/.test(r)}function ao(r,e){if(e>=r.length)return null;let t=r[e];if(!eo(t))return null;let a=e,i="";if(t==="#"||t==="."){for(i+=r[a++];a<r.length&&ve(r[a]);)i+=r[a++];if(i.length<=1)return null;if(a<r.length&&r[a]==="."&&t==="#"){let o=a+1;for(;o<r.length&&ve(r[o]);)o++;if(o<r.length&&r[o]==="(")return i}}else if(t==="["){let n=1,o=false,u=null,s=false;for(i+=r[a++];a<r.length&&n>0;){let l=r[a];i+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?n++:l==="]"&&n--,a++;}if(n!==0)return null}else if(t==="@"){for(i+=r[a++];a<r.length&&ve(r[a]);)i+=r[a++];if(i.length<=1)return null}else if(t==="*"){for(i+=r[a++];a<r.length&&ve(r[a]);)i+=r[a++];if(i.length<=1)return null}else if(t==="<"){if(i+=r[a++],a>=r.length||!ro(r[a]))return null;for(;a<r.length&&ve(r[a]);)i+=r[a++];for(;a<r.length;){let n=r[a];if(n==="."){if(i+=r[a++],a>=r.length||!ve(r[a]))return null;for(;a<r.length&&ve(r[a]);)i+=r[a++];}else if(n==="#"){if(i+=r[a++],a>=r.length||!ve(r[a]))return null;for(;a<r.length&&ve(r[a]);)i+=r[a++];}else if(n==="["){let o=1,u=false,s=null,l=false;for(i+=r[a++];a<r.length&&o>0;){let c=r[a];i+=c,l?l=false:c==="\\"?l=true:u?c===s&&(u=false,s=null):c==='"'||c==="'"||c==="`"?(u=true,s=c):c==="["?o++:c==="]"&&o--,a++;}if(o!==0)return null}else break}for(;a<r.length&&kt(r[a]);)i+=r[a++];if(a<r.length&&r[a]==="/")for(i+=r[a++];a<r.length&&kt(r[a]);)i+=r[a++];if(a>=r.length||r[a]!==">")return null;i+=r[a++];}return i||null}function io(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 a=r[e+2];return kt(a)||a==="*"||!ve(a)}function no(r,e){if(e>=r.length)return null;let t=r[e];if(!to(t)||t==="'"&&io(r,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!i)return null;let n=e+1,o=t,u=false;for(;n<r.length;){let s=r[n];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===i)return o;n++;}return o}function oo(r,e){if(e>=r.length)return false;let t=r[e],a=r[e+1]||"",i=r[e+2]||"";if(t==="/"&&a!=="/"&&/[a-zA-Z0-9._-]/.test(a)||t==="/"&&a==="/"&&/[a-zA-Z]/.test(i)||t==="."&&(a==="/"||a==="."&&i==="/"))return true;let n=r.slice(e,e+8).toLowerCase();return !!(n.startsWith("http://")||n.startsWith("https://"))}function uo(r,e){if(!oo(r,e))return null;let t=e,a="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<r.length;){let n=r[t];if(n==="#"){if(a.length>0&&/[a-zA-Z0-9/.]$/.test(a))for(a+=n,t++;t<r.length&&/[a-zA-Z0-9_-]/.test(r[t]);)a+=r[t++];break}if(i.test(n))a+=n,t++;else break}return a.length<2?null:a}function so(r,e){if(e>=r.length)return null;let t=r[e];if(!Ue(t)&&t!=="-"&&t!=="+")return null;let a=e,i="";if((r[a]==="-"||r[a]==="+")&&(i+=r[a++]),a>=r.length||!Ue(r[a]))return null;for(;a<r.length&&Ue(r[a]);)i+=r[a++];if(a<r.length&&r[a]===".")for(i+=r[a++];a<r.length&&Ue(r[a]);)i+=r[a++];return a<r.length&&(r.slice(a,a+2)==="ms"?i+="ms":(r[a]==="s"||r[a]==="m"||r[a]==="h")&&(i+=r[a])),i}var lo=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(lo);var co=new Set(["patient","destination","source","style","event","eventMarker","agent","goal","manner","into","from","to","with","at","of","as","by","in","on","over","under","between","through","without"]);function po(r){return r.includes("-")&&/^[\p{L}\p{N}_]+(-[\p{L}\p{N}_]+)+$/u.test(r)}var mo=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],qt=class jt{constructor(){this.profileKeywords=[],this.multiWordKeywords=[],this.profileKeywordMap=new Map,this.rawExtraEntries=[],this.extractors=[];}getExtraKeywordEntries(){return this.rawExtraEntries}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){Jn(e)&&e.setContext(Qn(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=[],a=0;for(;a<e.length;){for(;a<e.length&&kt(e[a]);)a++;if(a>=e.length)break;let i=this.tryMultiWordKeyword(e,a);if(i){t.push(i),a=i.position.end;continue}let n=false;for(let o of this.extractors)if(o.canExtract(e,a)){let u=o.extract(e,a);if(u){let s=u.metadata?.normalized,l=u.metadata?.stem,c=u.metadata?.stemConfidence,p={};if(u.metadata)for(let[m,f]of Object.entries(u.metadata))m!=="normalized"&&m!=="stem"&&m!=="stemConfidence"&&(p[m]=f);let d={};s&&(d.normalized=s),l&&(d.stem=l),c!==void 0&&(d.stemConfidence=c),Object.keys(p).length>0&&(d.metadata=p),t.push(te(u.value,this.classifyToken(u.value),ee(a,a+u.length),Object.keys(d).length>0?d:void 0)),a+=u.length,n=true;break}}if(!n){let o=e[a],u=this.classifyUnknownChar(o);t.push(te(o,u,ee(a,a+1))),a++;}}return new se(this.mergeColonQualifiedNames(t),this.language)}mergeColonQualifiedNames(e){let t=[];for(let a of e){let i=t[t.length-1];if(i&&jt.ASCII_WORD.test(i.value)&&jt.COLON_QUALIFIER.test(a.value)&&i.position.end===a.position.start){let n=i.value+a.value;t[t.length-1]=te(n,this.classifyToken(n),ee(i.position.start,a.position.end));continue}t.push(a);}return t}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,t,a){if(e[t]!==".")return false;let i=a[a.length-1],n=i&&i.position.end<t;if(i&&!n&&(i.kind==="identifier"||i.kind==="keyword"||i.kind==="selector"))return a.push(te(".","operator",ee(t,t+1))),true;let s=t+1;for(;s<e.length&&ve(e[s]);)s++;return s<e.length&&e[s]==="("?(a.push(te(".","operator",ee(t,t+1))),true):false}initializeKeywordsFromProfile(e,t=[]){let a=new Map;if(this.rawExtraEntries=t,e.keywords){for(let[i,n]of Object.entries(e.keywords))if(a.set(n.primary,{native:n.primary,normalized:n.normalized||i}),n.alternatives)for(let o of n.alternatives)a.set(o,{native:o,normalized:n.normalized||i});}if(e.references){for(let[i,n]of Object.entries(e.references))a.set(n,{native:n,normalized:i});for(let i of Object.keys(e.references))a.has(i)||a.set(i,{native:i,normalized:i});}if(e.roleMarkers){for(let[i,n]of Object.entries(e.roleMarkers))if(n.primary&&a.set(n.primary,{native:n.primary,normalized:i}),n.alternatives)for(let o of n.alternatives)a.set(o,{native:o,normalized:i});}if(e.possessive?.keywords)for(let[i,n]of Object.entries(e.possessive.keywords))a.set(i,{native:i,normalized:n});for(let i of mo)a.has(i)||a.set(i,{native:i,normalized:i});for(let i of t)a.set(i.native,i);this.profileKeywords=Array.from(a.values()).sort((i,n)=>n.native.length-i.native.length),this.multiWordKeywords=this.profileKeywords.filter(i=>(i.native.includes(" ")||po(i.native))&&!co.has(i.normalized)),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let n=this.removeDiacritics(i.native);n!==i.native&&!this.profileKeywordMap.has(n.toLowerCase())&&this.profileKeywordMap.set(n.toLowerCase(),i);}}removeDiacritics(e){return Wt(e)}tryProfileKeyword(e,t){for(let a of this.profileKeywords)if(e.slice(t).startsWith(a.native))return te(a.native,"keyword",ee(t,t+a.native.length),a.normalized);return null}tryMultiWordKeyword(e,t,a=i=>/[\p{L}\p{N}_]/u.test(i)){if(this.multiWordKeywords.length===0)return null;let i=e.slice(t);for(let n of this.multiWordKeywords){if(!i.startsWith(n.native))continue;let o=e[t+n.native.length];if(!(o!==void 0&&a(o)))return te(n.native,"keyword",ee(t,t+n.native.length),n.normalized)}return null}isKeywordStart(e,t){let a=e.slice(t);return this.profileKeywords.some(i=>a.startsWith(i.native))}isKeywordStartAtBoundary(e,t,a=i=>/[\p{L}\p{N}_]/u.test(i)){let i=e.slice(t);return this.profileKeywords.some(n=>{if(!i.startsWith(n.native))return false;let o=e[t+n.native.length];return o===void 0||!a(o)})}lookupKeyword(e){let t=this.profileKeywordMap.get(e.toLowerCase());if(t)return t;let a=this.removeDiacritics(e);if(a!==e)return this.profileKeywordMap.get(a.toLowerCase())}isKeyword(e){return this.lookupKeyword(e)!==void 0}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,a){let i=this.tryNormalize(e);if(!i)return null;let n=this.lookupKeyword(i.stem);if(!n)return null;let o={normalized:n.normalized,stem:i.stem,stemConfidence:i.confidence};return te(e,"keyword",ee(t,a),o)}trySelector(e,t){let a=ao(e,t);return a?te(a,"selector",ee(t,t+a.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let a=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!a)return null;let i=a[0].replace(/(\s|\.)$/,""),n=i.slice(1).split("(")[0],o=a[1];return {...te(i,"event-modifier",ee(t,t+i.length)),metadata:{modifierName:n,value:o?n==="queue"?o:parseInt(o,10):void 0}}}tryString(e,t){let a=no(e,t);return a?te(a,"literal",ee(t,t+a.length)):null}tryNumber(e,t){let a=so(e,t);return a?te(a,"literal",ee(t,t+a.length)):null}tryMatchTimeUnit(e,t,a,i=false){let n=t;if(i)for(;n<e.length&&kt(e[n]);)n++;let o=e.slice(n);for(let u of a){let s=o.slice(0,u.length);if(u.caseInsensitive?s.toLowerCase()===u.pattern.toLowerCase():s===u.pattern){if(u.notFollowedBy&&(o[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let c=o[u.length]||"";if(ve(c))continue}return {suffix:u.suffix,endPos:n+u.length}}}return null}parseBaseNumber(e,t,a=true){let i=t,n="";if(a&&(e[i]==="-"||e[i]==="+")&&(n+=e[i++]),i>=e.length||!Ue(e[i]))return null;for(;i<e.length&&Ue(e[i]);)n+=e[i++];if(i<e.length&&e[i]===".")for(n+=e[i++];i<e.length&&Ue(e[i]);)n+=e[i++];return !n||n==="-"||n==="+"?null:{number:n,endPos:i}}tryNumberWithTimeUnits(e,t,a,i={}){let{allowSign:n=true,skipWhitespace:o=false}=i,u=this.parseBaseNumber(e,t,n);if(!u)return null;let{number:s,endPos:l}=u,c=[...a,...jt.STANDARD_TIME_UNITS],p=this.tryMatchTimeUnit(e,l,c,o);return p&&(s+=p.suffix,l=p.endPos),te(s,"literal",ee(t,l))}tryUrl(e,t){let a=uo(e,t);return a?te(a,"url",ee(t,t+a.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!ve(e[t+1]))return null;let a=t+1;for(;a<e.length&&ve(e[a]);)a++;let i=e.slice(t,a);return te(i,"identifier",ee(t,a))}tryOperator(e,t){let a=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(a))return te(a,"operator",ee(t,t+2));let i=e[t];return ["<",">","!","+","-","*","/","="].includes(i)?te(i,"operator",ee(t,t+1)):["(",")","{","}",",",";",":"].includes(i)?te(i,"punctuation",ee(t,t+1)):null}tryMultiCharParticle(e,t,a){for(let i of a)if(e.slice(t,t+i.length)===i)return te(i,"particle",ee(t,t+i.length));return null}};qt.ASCII_WORD=/^[A-Za-z_][A-Za-z0-9_]*$/;qt.COLON_QUALIFIER=/^:[A-Za-z_][A-Za-z0-9_]*$/;qt.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 Fe=qt;function ya(r){return {stem:r,confidence:1}}function va(r,e,t){return t?{stem:r,confidence:e,metadata:t}:{stem:r,confidence:e}}var fo=Object.defineProperty,yo=Object.getOwnPropertyNames,ii=(r,e)=>function(){return r&&(e=(0, r[yo(r)[0]])(r=0)),e},vo=(r,e)=>{for(var t in e)fo(r,t,{get:e[t],enumerable:true});};function ha(r,e){return r.replace(/\{(\w+)\}/g,(t,a)=>String(e[a]??`{${a}}`))}function we(r,e,t={},a){let i=ni[r],n=ha(i,t),o=oi[r],u=o?ha(o,t):void 0;return {code:r,message:n,severity:e,...a&&{role:a},...u&&{suggestion:u}}}var R,ni,oi,ho=ii({"src/generators/schema-error-codes.ts"(){R={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"},ni={[R.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[R.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[R.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[R.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[R.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[R.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.",[R.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.",[R.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[R.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[R.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[R.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[R.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[R.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[R.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[R.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[R.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[R.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},oi={[R.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[R.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[R.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[R.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[R.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[R.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[R.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[R.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[R.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[R.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[R.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[R.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[R.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[R.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),ui={};vo(ui,{SchemaErrorCodes:()=>R,formatValidationResults:()=>Co,getValidationStats:()=>Ao,validateAllKeywordCollisions:()=>Bo,validateAllSchemas:()=>bo,validateCommandSchema:()=>si,validateKeywordCollisions:()=>li,validateRoleValues:()=>xo});function Eo(r,e){return {action:r,items:e}}function si(r){let e=[];for(let a of r.roles)a.expectedTypes.includes("literal")&&a.expectedTypes.includes("selector")&&(a.role==="patient"&&zr.has(r.action)?e.push(we(R.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:a.role,command:r.action},a.role)):e.push(we(R.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:a.role},a.role))),a.expectedTypes.length>3&&!zr.has(r.action)&&e.push(we(R.TOO_MANY_EXPECTED_TYPES,"warning",{role:a.role,count:a.expectedTypes.length},a.role));for(let a of r.roles)a.selectorKinds&&a.selectorKinds.length>0&&(a.expectedTypes.includes("selector")||e.push(we(R.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:a.role},a.role)));switch(r.action){case "transition":go(r,e);break;case "on":ko(r,e);break;case "if":case "unless":wo(r,e);break;case "repeat":case "for":case "while":zo(r,e);break}return r.roles.filter(a=>a.required).length===0&&(ci.has(r.action)?e.push(we(R.NO_REQUIRED_ROLES_EXPECTED,"note",{command:r.action})):e.push(we(R.NO_REQUIRED_ROLES,"warning",{}))),Eo(r.action,e)}function go(r,e){let t=r.roles.find(i=>i.role==="patient"),a=r.roles.find(i=>i.role==="goal");t&&!a&&e.push(we(R.TRANSITION_MISSING_GOAL,"error",{}));}function ko(r,e){let t=r.roles.find(a=>a.role==="event");t||e.push(we(R.EVENT_HANDLER_MISSING_EVENT,"warning",{})),t&&!t.required&&e.push(we(R.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function wo(r,e){let t=r.roles.find(a=>a.role==="condition");t||e.push(we(R.CONDITIONAL_MISSING_CONDITION,"warning",{})),t&&!t.required&&e.push(we(R.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function zo(r,e){r.action==="for"?r.roles.find(a=>a.role==="source")||e.push(we(R.FOR_LOOP_MISSING_SOURCE,"warning",{})):r.action==="while"&&(r.roles.find(a=>a.role==="condition")||e.push(we(R.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function bo(r,e={}){let t=new Map,{includeNotes:a=false}=e;for(let[i,n]of Object.entries(r)){let o=si(n),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=a&&o.items.some(l=>l.severity==="note");(u||s)&&t.set(i,o);}return t}function Co(r,e={}){let t=[],{showNotes:a=false,showCodes:i=true}=e;for(let[n,o]of r){let u=o.items.filter(c=>c.severity==="error"),s=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(u.length>0){t.push(` \u274C ${n}:`);for(let c of u){let p=i?` [${c.code}]`:"";t.push(` ERROR${p}: ${c.message}`),c.suggestion&&t.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(s.length>0){t.push(` \u26A0\uFE0F ${n}:`);for(let c of s){let p=i?` [${c.code}]`:"";t.push(` ${p?`${c.code}: `:""}${c.message}`),c.suggestion&&t.push(` \u{1F4A1} ${c.suggestion}`);}}if(a&&l.length>0){t.push(` \u2139\uFE0F ${n}:`);for(let c of l){let p=i?` [${c.code}]`:"";t.push(` ${p?`${c.code}: `:""}${c.message}`);}}}return t.join(`
|
|
2
|
+
`)}function Ao(r){let e=0,t=0,a=0,i={};for(let n of r.values())for(let o of n.items)o.severity==="error"?e++:o.severity==="warning"?t++:o.severity==="note"&&a++,i[o.code]=(i[o.code]||0)+1;return {totalCommands:r.size,errors:e,warnings:t,notes:a,byCode:i}}function xo(r,e){let t=[];for(let a of e){let i=r.roles.find(n=>n.role===a.role);i&&(i.expectedTypes.length>0&&!i.expectedTypes.includes(a.type)&&(i.expectedTypes.includes("expression")||t.push({level:"error",role:a.role,message:`${r.action}.${a.role} expects type [${i.expectedTypes.join(", ")}], got '${a.type}'`,code:R.VALUE_TYPE_MISMATCH})),a.type==="selector"&&a.selectorKind&&i.selectorKinds&&i.selectorKinds.length>0&&(i.selectorKinds.includes(a.selectorKind)||t.push({level:"error",role:a.role,message:`${r.action}.${a.role} expects selector kind [${i.selectorKinds.join(", ")}], got '${a.selectorKind}'`,code:R.SELECTOR_KIND_MISMATCH})));}return t}function Do(r){if(r.length!==2)return false;let[e,t]=[...r].sort();return pi.some(([a,i])=>a===e&&i===t)}function li(r){let e=[];if(!r.keywords)return {language:r.code,collisions:e};let t=new Map;for(let[i,n]of Object.entries(r.keywords)){if(!n||!n.primary)continue;let o=t.get(n.primary)||[];if(o.push({command:i,isPrimary:true}),t.set(n.primary,o),n.alternatives)for(let u of n.alternatives){let s=t.get(u)||[];s.push({command:i,isPrimary:false}),t.set(u,s);}}for(let[i,n]of t){let o=[...new Set(n.map(l=>l.command))];if(o.length<=1||Do(o))continue;let u=n.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:i,commands:o.sort(),type:s});}let a={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((i,n)=>a[i.type]-a[n.type]),{language:r.code,collisions:e}}function Bo(r){let e=[];for(let[,t]of Object.entries(r)){let a=li(t);a.collisions.length>0&&e.push(a);}return e.sort((t,a)=>t.language.localeCompare(a.language))}var zr,ci,pi,So=ii({"src/generators/schema-validator.ts"(){ho(),zr=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),ci=new Set(["compound","else","halt","continue","init","settle","focus","blur","show","hide","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint","live","eventsource","socket","worker","intercept"]),pi=[["change","changes"]];}});function To(){return [{id:"toggle-bn-full",language:"bn",command:"toggle",priority:100,template:{format:"{patient} \u0995\u09C7 \u099F\u0997\u09B2 \u0995\u09B0\u09C1\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u099F\u0997\u09B2",alternatives:["\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8"]},{type:"literal",value:"\u0995\u09B0\u09C1\u09A8"}]},extraction:{patient:{position:0}}},{id:"toggle-bn-simple",language:"bn",command:"toggle",priority:90,template:{format:"\u099F\u0997\u09B2 {patient}",tokens:[{type:"literal",value:"\u099F\u0997\u09B2",alternatives:["\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"toggle-bn-with-dest",language:"bn",command:"toggle",priority:95,template:{format:"{destination} \u098F {patient} \u0995\u09C7 \u099F\u0997\u09B2 \u0995\u09B0\u09C1\u09A8",tokens:[{type:"role",role:"destination"},{type:"literal",value:"\u098F",alternatives:["\u09A4\u09C7"]},{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u099F\u0997\u09B2",alternatives:["\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8"]},{type:"literal",value:"\u0995\u09B0\u09C1\u09A8"}]},extraction:{destination:{position:0},patient:{position:2}}}]}function Fo(){return [{id:"toggle-en-full",language:"en",command:"toggle",priority:100,template:{format:"toggle {patient} on {target}",tokens:[{type:"literal",value:"toggle"},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"on",alternatives:["from"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"on",markerAlternatives:["from"],default:{type:"reference",value:"me"}}}},{id:"toggle-en-simple",language:"en",command:"toggle",priority:90,template:{format:"toggle {patient}",tokens:[{type:"literal",value:"toggle"},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function Po(){return [{id:"toggle-es-full",language:"es",command:"toggle",priority:100,template:{format:"alternar {patient} en {target}",tokens:[{type:"literal",value:"alternar",alternatives:["cambiar","toggle"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"en",alternatives:["sobre","de"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"en",markerAlternatives:["sobre","de"],default:{type:"reference",value:"me"}}}},{id:"toggle-es-simple",language:"es",command:"toggle",priority:90,template:{format:"alternar {patient}",tokens:[{type:"literal",value:"alternar",alternatives:["cambiar","toggle"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function Oo(){return [{id:"toggle-hi-full",language:"hi",command:"toggle",priority:100,template:{format:"{patient} \u0915\u094B {destination} \u092A\u0930 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"role",role:"destination"},{type:"literal",value:"\u092A\u0930"},{type:"literal",value:"\u091F\u0949\u0917\u0932",alternatives:["\u092C\u0926\u0932\u0947\u0902","\u092C\u0926\u0932"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0915\u0930\u0947\u0902",alternatives:["\u0915\u0930\u094B"]}]}]},extraction:{patient:{position:0},destination:{marker:"\u0915\u094B",position:2}}},{id:"toggle-hi-simple",language:"hi",command:"toggle",priority:90,template:{format:"{patient} \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u091F\u0949\u0917\u0932",alternatives:["\u092C\u0926\u0932\u0947\u0902","\u092C\u0926\u0932"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0915\u0930\u0947\u0902",alternatives:["\u0915\u0930\u094B"]}]}]},extraction:{patient:{position:0},destination:{default:{type:"reference",value:"me"}}}},{id:"toggle-hi-bare",language:"hi",command:"toggle",priority:80,template:{format:"\u091F\u0949\u0917\u0932 {patient}",tokens:[{type:"literal",value:"\u091F\u0949\u0917\u0932",alternatives:["\u092C\u0926\u0932\u0947\u0902","\u092C\u0926\u0932"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function Ro(){return [{id:"toggle-it-full",language:"it",command:"toggle",priority:100,template:{format:"commutare {patient} su {target}",tokens:[{type:"literal",value:"commutare",alternatives:["alternare","toggle","cambiare"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"su",alternatives:["in","di"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"su",markerAlternatives:["in","di"],default:{type:"reference",value:"me"}}}},{id:"toggle-it-simple",language:"it",command:"toggle",priority:90,template:{format:"commutare {patient}",tokens:[{type:"literal",value:"commutare",alternatives:["alternare","toggle","cambiare"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function Lo(){return [{id:"toggle-pl-full",language:"pl",command:"toggle",priority:100,template:{format:"prze\u0142\u0105cz {patient} na {destination}",tokens:[{type:"literal",value:"prze\u0142\u0105cz",alternatives:["przelacz","prze\u0142\u0105czaj"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"na",alternatives:["w","dla"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"na",markerAlternatives:["w","dla"],default:{type:"reference",value:"me"}}}},{id:"toggle-pl-simple",language:"pl",command:"toggle",priority:90,template:{format:"prze\u0142\u0105cz {patient}",tokens:[{type:"literal",value:"prze\u0142\u0105cz",alternatives:["przelacz","prze\u0142\u0105czaj"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function _o(){return [{id:"toggle-qu-sov",language:"qu",command:"toggle",priority:100,template:{format:"{patient} ta t'ikray",tokens:[{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"literal",value:"t'ikray",alternatives:["tikray","kutichiy"]}]},extraction:{patient:{position:0}}},{id:"toggle-qu-simple",language:"qu",command:"toggle",priority:90,template:{format:"t'ikray {patient}",tokens:[{type:"literal",value:"t'ikray",alternatives:["tikray","kutichiy"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"toggle-qu-with-dest",language:"qu",command:"toggle",priority:95,template:{format:"{destination} pi {patient} ta t'ikray",tokens:[{type:"role",role:"destination"},{type:"literal",value:"pi"},{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"literal",value:"t'ikray",alternatives:["tikray","kutichiy"]}]},extraction:{destination:{position:0},patient:{position:2}}},{id:"toggle-qu-dest-man",language:"qu",command:"toggle",priority:93,template:{format:"{destination} man {patient} ta t'ikray",tokens:[{type:"role",role:"destination"},{type:"literal",value:"man"},{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"literal",value:"t'ikray",alternatives:["tikray","kutichiy"]}]},extraction:{destination:{position:0},patient:{position:2}}},{id:"toggle-qu-patient-first-dest",language:"qu",command:"toggle",priority:102,template:{format:"{patient} ta {destination} man t'ikray",tokens:[{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"role",role:"destination"},{type:"literal",value:"man",alternatives:["pa"]},{type:"literal",value:"t'ikray",alternatives:["tikray","kutichiy"]}]},extraction:{patient:{position:0},destination:{position:2}}}]}function No(){return [{id:"toggle-ru-full",language:"ru",command:"toggle",priority:100,template:{format:"\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C {patient} \u043D\u0430 {destination}",tokens:[{type:"literal",value:"\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C",alternatives:["\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u043D\u0430",alternatives:["\u0432","\u0434\u043B\u044F"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"\u043D\u0430",markerAlternatives:["\u0432","\u0434\u043B\u044F"],default:{type:"reference",value:"me"}}}},{id:"toggle-ru-simple",language:"ru",command:"toggle",priority:90,template:{format:"\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C {patient}",tokens:[{type:"literal",value:"\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C",alternatives:["\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function Mo(){return [{id:"toggle-th-simple",language:"th",command:"toggle",priority:90,template:{format:"\u0E2A\u0E25\u0E31\u0E1A {patient}",tokens:[{type:"literal",value:"\u0E2A\u0E25\u0E31\u0E1A"},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"toggle-th-with-dest",language:"th",command:"toggle",priority:95,template:{format:"\u0E2A\u0E25\u0E31\u0E1A {patient} \u0E43\u0E19 {destination}",tokens:[{type:"literal",value:"\u0E2A\u0E25\u0E31\u0E1A"},{type:"role",role:"patient"},{type:"literal",value:"\u0E43\u0E19"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"\u0E43\u0E19",position:3}}}]}function Io(){return [{id:"toggle-uk-full",language:"uk",command:"toggle",priority:100,template:{format:"\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0443\u0442\u0438 {patient} \u043D\u0430 {destination}",tokens:[{type:"literal",value:"\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0443\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0438"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u043D\u0430",alternatives:["\u0432","\u0434\u043B\u044F"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"\u043D\u0430",markerAlternatives:["\u0432","\u0434\u043B\u044F"],default:{type:"reference",value:"me"}}}},{id:"toggle-uk-simple",language:"uk",command:"toggle",priority:90,template:{format:"\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0443\u0442\u0438 {patient}",tokens:[{type:"literal",value:"\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0443\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0438"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function $o(){return [{id:"toggle-vi-full",language:"vi",command:"toggle",priority:100,template:{format:"chuy\u1EC3n \u0111\u1ED5i {patient} tr\xEAn {target}",tokens:[{type:"literal",value:"chuy\u1EC3n \u0111\u1ED5i",alternatives:["chuy\u1EC3n","b\u1EADt t\u1EAFt"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"tr\xEAn",alternatives:["t\u1EA1i","\u1EDF"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"tr\xEAn",markerAlternatives:["t\u1EA1i","\u1EDF"],default:{type:"reference",value:"me"}}}},{id:"toggle-vi-simple",language:"vi",command:"toggle",priority:90,template:{format:"chuy\u1EC3n \u0111\u1ED5i {patient}",tokens:[{type:"literal",value:"chuy\u1EC3n \u0111\u1ED5i",alternatives:["chuy\u1EC3n","b\u1EADt t\u1EAFt"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function jo(){return [{id:"toggle-zh-full",language:"zh",command:"toggle",priority:100,template:{format:"\u5207\u6362 {patient} \u5728 {target}",tokens:[{type:"literal",value:"\u5207\u6362"},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u5728",alternatives:["\u5230","\u4E8E"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"\u5728",markerAlternatives:["\u5230","\u4E8E"],default:{type:"reference",value:"me"}}}},{id:"toggle-zh-simple",language:"zh",command:"toggle",priority:90,template:{format:"\u5207\u6362 {patient}",tokens:[{type:"literal",value:"\u5207\u6362"},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}},{id:"toggle-zh-ba",language:"zh",command:"toggle",priority:95,template:{format:"\u628A {patient} \u5207\u6362",tokens:[{type:"literal",value:"\u628A"},{type:"role",role:"patient"},{type:"literal",value:"\u5207\u6362"}]},extraction:{patient:{marker:"\u628A"},destination:{default:{type:"reference",value:"me"}}}},{id:"toggle-zh-full-ba",language:"zh",command:"toggle",priority:98,template:{format:"\u5728 {target} \u628A {patient} \u5207\u6362",tokens:[{type:"literal",value:"\u5728",alternatives:["\u5230","\u4E8E"]},{type:"role",role:"destination"},{type:"literal",value:"\u628A"},{type:"role",role:"patient"},{type:"literal",value:"\u5207\u6362"}]},extraction:{destination:{marker:"\u5728",markerAlternatives:["\u5230","\u4E8E"]},patient:{marker:"\u628A"}}}]}function Wo(r){switch(r){case "bn":return To();case "en":return Fo();case "es":return Po();case "hi":return Oo();case "it":return Ro();case "pl":return Lo();case "qu":return _o();case "ru":return No();case "th":return Mo();case "uk":return Io();case "vi":return $o();case "zh":return jo();default:return []}}function qo(r){return []}function Xe(r){let e=r.roles.find(t=>t.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function Je(r){let e=r.roles.find(t=>t.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function Qe(r,e){return Or(r,e,"source")}function Pr(r,e){return Or(r,e,"destination")}function Vo(r,e){return Or(r,e,"patient")}function Or(r,e,t){if(!e||!r.roles.some(n=>n.role===t))return [];let a=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},i={type:"role",role:t,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[i,a]:[a,i]}]}var re=["selector","reference","expression"],Ko={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination",for:"duration"}},argSkipTokens:["on"],roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2,markerOptional:{zh:true}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}},{role:"duration",description:"How long the class stays on before reverting (`toggle .a for 2s`)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3,valueShape:"time",markerOverride:{en:"for",ja:"\u9593",ko:"\uB3D9\uC548"}}],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)"}},Ho={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector","literal"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",es:"a",ar:"\u0625\u0644\u0649",zh:"\u5230",fr:"\xE0",de:"zu",pt:"a",he:"\u05D0\u05DC",id:"ke",it:"a",sw:"kwa"},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","dans"],de:["auf","in"],pt:["em","para"],he:["\u05E2\u05DC","\u05D1","\u05DC"],id:["pada","di"],it:["in","su"],sw:["kwenye"]}}],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"}},Uo={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source"}},targetRole:"source",argSkipTokens:["from"],roles:[{role:"patient",description:"The class/attribute to remove, or the element to remove",required:true,expectedTypes:re,svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],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"}},Rr={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","property-path"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"into",ar:"\u0641\u064A",zh:"\u5230",fr:"dans",de:"in",he:"\u05D1",id:"ke",sw:"kwa"},markerVariants:{en:["before","after"]},markerLegacy:{ar:["\u0639\u0644\u0649","\u0625\u0644\u0649","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","\xE0"],de:["auf","zu"],he:["\u05E2\u05DC","\u05D0\u05DC","\u05DC"],id:["pada","di"],sw:["kwenye"]},methodCarrier:"method"}],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"}},Lr={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient",on:"scope"}},argSkipTokens:["to"],roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",th:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B",zh:"\u628A"},markerOptional:{zh:true}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","selector","expression","reference","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",th:"\u0E43\u0E19",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902",zh:"\u5230"},markerVariants:{tr:["e","a","ye","ya"],zh:["\u4E3A","\u70BA","\u6210"]}},{role:"scope",description:"The element(s) the attribute/property is set on (defaults to me)",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3,markerOverride:{en:"on",es:"on",pt:"on",fr:"on",de:"on",it:"on",id:"on",ms:"on",sw:"on",tl:"on",zh:"on",vi:"on",ru:"on",uk:"on",pl:"on",th:"on",he:"on",ar:"on",ja:"on",ko:"on",tr:"on",hi:"on",bn:"on",qu:"on"}}],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>"}},Go={action:"bind",description:"Reactively bind a variable to an element or property value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to bind",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",it:"",id:"",ms:"",vi:"",ru:"",uk:"",pl:"",th:"",zh:"",he:"",ar:"",sw:"",tl:"",ja:"\u3092",ko:"\uB97C",tr:"i",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"source",description:"The element or property to bind to",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"zu",it:"in",id:"ke",ms:"ke",vi:"v\xE0o",ru:"\u0432",uk:"\u0432",pl:"do",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",zh:"\u5230",he:"\u05DC",sw:"kwa",th:"\u0E43\u0E19",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"}}],errorCodes:["MISSING_TARGET","MISSING_VALUE","INVALID_SYNTAX"],recoveryHints:{MISSING_TARGET:"Add a variable to bind: bind $name to #input",MISSING_VALUE:'Add "to <element>" to specify the binding source',INVALID_SYNTAX:"Use syntax: bind <variable> to <element>"}},Zo={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Yo={action:"when",description:"Reactive observer: re-run the body when a watched expression changes",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,structuralOnly:true,roles:[{role:"condition",description:"The watched expression (`or`-separated expressions watch each)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1}]},Xo={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Jo={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Qo={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},eu={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},di={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:["style","duration"]}},roles:[{role:"patient",description:"The element to show",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"The hide/show strategy (`with opacity`, `with *opacity`)",required:false,expectedTypes:["expression","selector"],svoPosition:2,sovPosition:2}]},mi={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:["style","duration"]}},roles:[{role:"patient",description:"The element to hide",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"The hide/show strategy (`with opacity`, `with *opacity`)",required:false,expectedTypes:["expression","selector"],svoPosition:2,sovPosition:2}]},tu={action:"on",description:"Handle an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{from:"source"}},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","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],widenTypeVariants:[{role:"event",types:["literal","expression"],idSuffix:"expr-event",excludeLanguages:["ko"]}]},ru={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{on:"destination"}},argSkipTokens:["on"],roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2,markerVariants:{hi:["\u0915\u094B"],qu:["ta"],bn:["\u0995\u09C7"]},markerOverride:{bn:"\u0995\u09C7",hi:"\u0915\u094B"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},au={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},iu={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",ast:{args:["source"],modifiers:{with:["style","method"],as:"responseType",body:"patient"},isBlocking:true},roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"style",description:"Request options object (method, headers, body, credentials\u2026)",required:false,expectedTypes:["expression"],valueShape:"object",svoPosition:2,sovPosition:2},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:3,sovPosition:3,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:5,sovPosition:5}]},nu={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal","selector","expression","reference","property-path"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},ou={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal","selector","expression","reference","property-path"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},uu={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},su={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},lu={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:1}]},fi={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",ast:{args:[["source","patient"]]},roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",he:"\u05D0\u05EA",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},cu={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source",for:"recipient"}},argSkipTokens:["from"],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 all current holders)",required:false,expectedTypes:re,svoPosition:2,sovPosition:1},{role:"recipient",description:"The element the class moves ONTO (`take .active from .tab for me`)",required:false,expectedTypes:["reference"],svoPosition:3,sovPosition:3,valueShape:"reference",markerOverride:{en:"for"}}]},pu={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},du={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",ast:{args:[],modifiers:{the:"patient"}},argSkipTokens:["the"],roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},mu={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",ast:{args:[["destination","patient"]],isBlocking:true},roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},fu={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression","property-path"],svoPosition:1,sovPosition:1}]},yu={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{to:"destination",detail:"patient"}},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","expression"],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"}}]},vu={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},hu={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Eu={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},gu={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",ast:{args:[["quantity","patient"]]},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"'},ku={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{in:"source"}},hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference","expression"],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",es:"en",fr:"en",de:"in",it:"in",pt:"dentro",id:"dalam",ms:"dalam",pl:"w",ru:"\u0432",uk:"\u0443",sw:"ndani",th:"\u0E43\u0E19",vi:"trong",ar:"\u0641\u064A",tl:"sa_loob",he:"in",zh:"\u5728"}}]},wu={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},zu={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",ast:{},roles:[]},tr={en:"url",es:"url",pt:"url",fr:"url",de:"url",it:"url",ja:"url",ko:"url",zh:"url",ar:"url",he:"url",hi:"url",bn:"url",tr:"url",ru:"url",uk:"url",pl:"url",id:"url",vi:"url",th:"url",ms:"url",tl:"url",sw:"url",qu:"url"},bu=Object.fromEntries(Object.keys(tr).map(r=>[r,"in new"])),Cu={action:"go",description:"Navigate to a URL, or scroll to an element",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to, or the element to scroll to",required:true,expectedTypes:["literal",...re],svoPosition:1,sovPosition:1,markerOverride:{en:"to",es:"a",ar:"\u0625\u0644\u0649",fr:"\xE0",de:"zu",pt:"para",he:"\u05D0\u05DC",hi:"\u092A\u0930",id:"ke",it:"a",ru:"\u043D\u0430",sw:"kwa",uk:"\u043D\u0430"},renderOverride:{en:"",zh:"",vi:"",th:""},markerOptional:{en:true,zh:true,vi:true,th:true},markerVariants:{zh:["\u628A"]},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],fr:["sur","dans"],de:["auf","in"],pt:["em","a"],he:["\u05E2\u05DC","\u05D1","\u05DC","\u05D0\u05EA"],hi:["\u092E\u0947\u0902"],id:["pada","di"],it:["in","su"],ru:["\u0432","\u043A"],sw:["kwenye"],uk:["\u0432","\u0434\u043E"]}},{role:"manner",description:"Open the URL in a new window (`in new window`)",required:false,expectedTypes:["reference","literal","expression"],valueShape:"keyword",svoPosition:2,sovPosition:2,markerOverride:bu}],rolePrefixLiteralVariants:[{role:"destination",literal:tr,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},Au={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"goal",over:"duration",on:"destination"}},omitRoleVariants:["goal"],roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal","expression","selector"],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:"kwa",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"zu",he:"\u05E2\u05DC",it:"in",ja:"\u306B",ko:"\uC5D0",ms:"ke",pl:"do",ru:"\u0432",th:"\u0E43\u0E19",tr:"e",uk:"\u0432",vi:"v\xE0o",zh:"\u5230",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}]},xu={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",ast:{args:[["source","patient"]],modifiers:{into:"destination"}},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"}}]},Du={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","patient"]]},roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Bu={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","patient"]]},roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Su={action:"empty",description:"Remove all children from an element (sets innerHTML to empty)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to empty (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Tu={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{as:"style"}},roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}}]},Fu={action:"close",description:"Close a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to close (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Pu={action:"select",description:"Select the contents of a text field or DOM element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element whose contents to select (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ou={action:"clear",description:"Clear a variable, local, or input element",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The variable or element to clear (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ru={action:"reset",description:"Reset a <form> element to its default values",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The form element to reset (defaults to me)",required:false,expectedTypes:re,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Lu={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},_u={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],markerOptional:{he:true,zh:true},svoPosition:1,sovPosition:1}]},Nu={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference","property-path"],svoPosition:1,sovPosition:1}]},Mu={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Iu={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",ast:{args:[["destination","patient"]]},hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:re,svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},$u={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient"}},roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta",ja:"\u3092",ko:"\uB97C",tr:"i",hi:"\u0915\u094B",de:"",es:"",fr:"",it:"",pt:"",pl:"",ru:"",uk:"",vi:"",id:"",ms:"",th:"",zh:"\u628A",he:"\u05D0\u05EA"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",ja:"\u306B",ko:"\uC5D0",tr:"e",hi:"\u092E\u0947\u0902",de:"zu",es:"a",fr:"\xE0",it:"in",pt:"para",pl:"do",ru:"\u0432",uk:"\u0432",vi:"v\xE0o",id:"ke",ms:"ke",th:"\u0E43\u0E19",zh:"\u5230",he:"\u05E2\u05DC"}}]},ju={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",ast:{},hasBody:true,roles:[]},Wu={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},qu={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination"}},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}]},Vu={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{of:["destination","source"]}},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:re,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Ku={en:"using view",es:"using view",pt:"using view",fr:"using view",de:"using view",it:"using view",ja:"using view",ko:"using view",zh:"using view",ar:"using view",he:"using view",hi:"using view",bn:"using view",tr:"using view",ru:"using view",uk:"using view",pl:"using view",id:"using view",vi:"using view",th:"using view",ms:"using view",tl:"using view",sw:"using view",qu:"using view"},_r={role:"manner",description:"Run the swap inside a `document.startViewTransition()` (`using view transition`)",required:false,expectedTypes:["literal","expression"],valueShape:"keyword",markerOverride:Ku},Hu={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",ast:{args:["method","destination","patient"],modifiers:{viewTransition:"manner"}},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:re,svoPosition:2,sovPosition:1,markerOverride:{en:"of",es:"",fr:"",pt:"",it:"",de:"",pl:"",ru:"",uk:"",id:"",ms:"",sw:"",th:"",vi:"",he:"\u05D0\u05EA",zh:"\u628A",tl:""}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with",es:"con",fr:"avec",pt:"com",it:"con",de:"mit",pl:"z",ru:"\u0441",uk:"\u0437",id:"dengan",ms:"dengan",sw:"na",th:"\u0E14\u0E49\u0E27\u0E22",vi:"v\u1EDBi",he:"\u05E2\u05DD",zh:"\u7528",hi:"\u0938\u0947",bn:"\u09A6\u09BF\u09AF\u09BC\u09C7",tr:"ile",qu:"wan",ar:"\u0628\u0640",tl:"nang"}},{..._r,svoPosition:4,sovPosition:4}]},Uu={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",ast:{args:[["source","destination"]],modifiers:{on:"patient",viewTransition:"manner"}},roles:[{role:"patient",description:"The element to morph",required:true,expectedTypes:re,svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"destination",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}},{..._r,svoPosition:3,sovPosition:3}]},Gu={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}]},Zu={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Yu={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","property-path"],svoPosition:1,sovPosition:1}]},Xu={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Ju={action:"pick",description:"Select item(s), character(s), a range, first/last/random N, or regex matches from a root",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The range/count/index/regex argument to pick",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The root to pick from (with "of"/"from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Qu={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",ast:{args:["destination"]},argSkipTokens:["of","the","top","bottom","middle","center","nearest","left","right","smoothly","instantly"],roles:[{role:"destination",description:"The element to scroll to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},es={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},ts={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:tr}]},rs={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:tr}]},as={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{viewTransition:"manner"}},roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:es},{..._r,svoPosition:2,sovPosition:2}]},is={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"],valueShape:"object",svoPosition:2,sovPosition:1}]},le={toggle:Ko,add:Ho,remove:Uo,put:Rr,set:Lr,show:di,hide:mi,on:tu,trigger:ru,wait:au,fetch:iu,increment:nu,decrement:ou,append:uu,prepend:su,log:lu,get:fi,take:cu,make:pu,halt:du,settle:mu,throw:fu,send:yu,if:vu,unless:hu,else:Eu,repeat:gu,for:ku,while:wu,continue:zu,go:Cu,scroll:Qu,push:ts,replace:rs,process:as,transition:Au,clone:xu,focus:Du,blur:Bu,empty:Su,open:Tu,close:Fu,select:Pu,clear:Ou,reset:Ru,breakpoint:Lu,call:_u,return:Nu,js:Mu,tell:Iu,default:$u,init:ju,behavior:Wu,install:qu,measure:Vu,swap:Hu,morph:Uu,beep:Gu,break:Zu,copy:Yu,exit:Xu,pick:Ju,render:is,bind:Go,live:Zo,when:Yo,eventsource:Xo,socket:Jo,worker:Qo,intercept:eu,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function ue(r){return le[r]}function ns(){return Object.values(le).filter(r=>r.structuralOnly!==true&&(r.roles.length>0||r.bareKeyword===true))}typeof process<"u"&&process.env.LOKASCRIPT_SCHEMA_VALIDATION==="1"&&Promise.resolve().then(()=>(So(),ui)).then(({validateAllSchemas:r,formatValidationResults:e})=>{let t=r(le);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 Bt=[...Rr.roles.find(r=>r.role==="destination")?.expectedTypes??[]],fr=[...Rr.roles.find(r=>r.role==="patient")?.expectedTypes??[]];function os(){return [{id:"put-bn-before",language:"bn",command:"put",priority:105,template:{format:"{patient} before {destination} \u0995\u09C7 \u09B0\u09BE\u0996\u09C1\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"before"},{type:"role",role:"destination"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u09B0\u09BE\u0996\u09C1\u09A8",alternatives:["\u09B0\u09BE\u0996"]}]},extraction:{patient:{position:0},destination:{marker:"before"},manner:{default:{type:"literal",value:"before"}}}},{id:"put-bn-after",language:"bn",command:"put",priority:105,template:{format:"{patient} after {destination} \u0995\u09C7 \u09B0\u09BE\u0996\u09C1\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"after"},{type:"role",role:"destination"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u09B0\u09BE\u0996\u09C1\u09A8",alternatives:["\u09B0\u09BE\u0996"]}]},extraction:{patient:{position:0},destination:{marker:"after"},manner:{default:{type:"literal",value:"after"}}}},{id:"put-bn-full",language:"bn",command:"put",priority:100,template:{format:"{patient} \u0995\u09C7 {destination} \u098F \u09B0\u09BE\u0996\u09C1\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"role",role:"destination"},{type:"literal",value:"\u098F",alternatives:["\u09A4\u09C7"]},{type:"literal",value:"\u09B0\u09BE\u0996\u09C1\u09A8",alternatives:["\u09B0\u09BE\u0996"]}]},extraction:{patient:{position:0},destination:{marker:"\u098F",position:2}}},{id:"put-bn-simple",language:"bn",command:"put",priority:90,template:{format:"\u09B0\u09BE\u0996\u09C1\u09A8 {patient} {destination} \u098F",tokens:[{type:"literal",value:"\u09B0\u09BE\u0996\u09C1\u09A8",alternatives:["\u09B0\u09BE\u0996"]},{type:"role",role:"patient"},{type:"role",role:"destination"},{type:"literal",value:"\u098F",alternatives:["\u09A4\u09C7"]}]},extraction:{patient:{position:1},destination:{position:2}}}]}function us(){return [{id:"put-en-into",language:"en",command:"put",priority:100,template:{format:"put {patient} into {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"into",alternatives:["in","to"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"into",markerAlternatives:["in","to"]}}},{id:"put-en-before",language:"en",command:"put",priority:95,template:{format:"put {patient} before {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"before"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"before"},manner:{default:{type:"literal",value:"before"}}}},{id:"put-en-after",language:"en",command:"put",priority:95,template:{format:"put {patient} after {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"after"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"after"},manner:{default:{type:"literal",value:"after"}}}},{id:"put-en-at-end",language:"en",command:"put",priority:96,template:{format:"put {patient} at end of {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"at"},{type:"literal",value:"end"},{type:"literal",value:"of"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{position:5},manner:{default:{type:"literal",value:"at end of"}}}},{id:"put-en-at-start",language:"en",command:"put",priority:96,template:{format:"put {patient} at start of {destination}",tokens:[{type:"literal",value:"put"},{type:"role",role:"patient"},{type:"literal",value:"at"},{type:"literal",value:"start"},{type:"literal",value:"of"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{position:5},manner:{default:{type:"literal",value:"at start of"}}}}]}function ss(){return [{id:"put-es-full",language:"es",command:"put",priority:100,template:{format:"poner {patient} en {destination}",tokens:[{type:"literal",value:"poner",alternatives:["pon","colocar","put"]},{type:"role",role:"patient"},{type:"literal",value:"en",alternatives:["dentro de","a"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"en",markerAlternatives:["dentro de","a"]}}},{id:"put-es-before",language:"es",command:"put",priority:95,template:{format:"poner {patient} antes de {destination}",tokens:[{type:"literal",value:"poner",alternatives:["pon","colocar"]},{type:"role",role:"patient"},{type:"literal",value:"antes de",alternatives:["antes"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"antes de",markerAlternatives:["antes"]},manner:{default:{type:"literal",value:"before"}}}},{id:"put-es-after",language:"es",command:"put",priority:95,template:{format:"poner {patient} despu\xE9s de {destination}",tokens:[{type:"literal",value:"poner",alternatives:["pon","colocar"]},{type:"role",role:"patient"},{type:"literal",value:"despu\xE9s de",alternatives:["despues de","despu\xE9s"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"despu\xE9s de",markerAlternatives:["despues de","despu\xE9s"]},manner:{default:{type:"literal",value:"after"}}}}]}function ls(){return [{id:"put-hi-before",language:"hi",command:"put",priority:106,template:{format:"{patient} before {destination} \u0915\u094B \u0930\u0916\u0947\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"before"},{type:"role",role:"destination"},{type:"literal",value:"\u0915\u094B"},{type:"literal",value:"\u0930\u0916\u0947\u0902",alternatives:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"]}]},extraction:{patient:{position:0},destination:{marker:"before"},manner:{default:{type:"literal",value:"before"}}}},{id:"put-hi-after",language:"hi",command:"put",priority:106,template:{format:"{patient} after {destination} \u0915\u094B \u0930\u0916\u0947\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"after"},{type:"role",role:"destination"},{type:"literal",value:"\u0915\u094B"},{type:"literal",value:"\u0930\u0916\u0947\u0902",alternatives:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"]}]},extraction:{patient:{position:0},destination:{marker:"after"},manner:{default:{type:"literal",value:"after"}}}},{id:"put-hi-verb-medial",language:"hi",command:"put",priority:105,template:{format:"{patient} \u0915\u094B \u0930\u0916\u0947\u0902 {destination} \u092E\u0947\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"literal",value:"\u0930\u0916\u0947\u0902",alternatives:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"]},{type:"role",role:"destination"},{type:"literal",value:"\u092E\u0947\u0902"}]},extraction:{patient:{position:0},destination:{marker:"\u092E\u0947\u0902",position:3}}},{id:"put-hi-full",language:"hi",command:"put",priority:100,template:{format:"{patient} \u0915\u094B {destination} \u092E\u0947\u0902 \u0930\u0916\u0947\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"role",role:"destination"},{type:"literal",value:"\u092E\u0947\u0902"},{type:"literal",value:"\u0930\u0916\u0947\u0902",alternatives:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"]}]},extraction:{patient:{position:0},destination:{marker:"\u092E\u0947\u0902",position:3}}},{id:"put-hi-simple",language:"hi",command:"put",priority:90,template:{format:"{patient} \u0930\u0916\u0947\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0930\u0916\u0947\u0902",alternatives:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"]}]},extraction:{patient:{position:0},destination:{default:{type:"reference",value:"me"}}}},{id:"put-hi-bare",language:"hi",command:"put",priority:80,template:{format:"\u0930\u0916\u0947\u0902 {patient}",tokens:[{type:"literal",value:"\u0930\u0916\u0947\u0902",alternatives:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function cs(){return [{id:"put-id-full",language:"id",command:"put",priority:100,template:{format:"taruh {patient} ke dalam {destination}",tokens:[{type:"literal",value:"taruh",alternatives:["letakkan","masukkan","tempatkan","put"]},{type:"role",role:"patient",expectedTypes:fr},{type:"literal",value:"ke"},{type:"literal",value:"dalam",alternatives:["di"]},{type:"role",role:"destination",expectedTypes:Bt}]},extraction:{patient:{position:1},destination:{position:4}}},{id:"put-id-simple-ke",language:"id",command:"put",priority:95,template:{format:"taruh {patient} ke {destination}",tokens:[{type:"literal",value:"taruh",alternatives:["letakkan","masukkan","tempatkan"]},{type:"role",role:"patient",expectedTypes:fr},{type:"literal",value:"ke",alternatives:["di","pada"]},{type:"role",role:"destination",expectedTypes:Bt}]},extraction:{patient:{position:1},destination:{position:3}}},{id:"put-id-di",language:"id",command:"put",priority:90,template:{format:"taruh {patient} di {destination}",tokens:[{type:"literal",value:"taruh",alternatives:["letakkan","masukkan"]},{type:"role",role:"patient",expectedTypes:fr},{type:"literal",value:"di"},{type:"role",role:"destination",expectedTypes:Bt}]},extraction:{patient:{position:1},destination:{position:3}}}]}function ps(){return [{id:"put-it-full",language:"it",command:"put",priority:100,template:{format:"mettere {patient} in {target}",tokens:[{type:"literal",value:"mettere",alternatives:["metti","inserire","put"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"in",alternatives:["dentro","nel"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"in",markerAlternatives:["dentro","nel"]}}},{id:"put-it-before",language:"it",command:"put",priority:105,template:{format:"mettere {patient} prima {target}",tokens:[{type:"literal",value:"mettere",alternatives:["metti","inserire","put"]},{type:"role",role:"patient"},{type:"literal",value:"prima"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"prima"},manner:{default:{type:"literal",value:"before"}}}},{id:"put-it-after",language:"it",command:"put",priority:105,template:{format:"mettere {patient} dopo {target}",tokens:[{type:"literal",value:"mettere",alternatives:["metti","inserire","put"]},{type:"role",role:"patient"},{type:"literal",value:"dopo"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"dopo"},manner:{default:{type:"literal",value:"after"}}}},{id:"put-it-simple",language:"it",command:"put",priority:90,template:{format:"mettere {patient}",tokens:[{type:"literal",value:"mettere",alternatives:["metti","inserire","put"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function ds(){return [{id:"put-pl-full",language:"pl",command:"put",priority:100,template:{format:"umie\u015B\u0107 {patient} w {destination}",tokens:[{type:"literal",value:"umie\u015B\u0107",alternatives:["umiesc","wstaw","w\u0142\xF3\u017C","wloz"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"w",alternatives:["do","na"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"w",markerAlternatives:["do","na"]}}},{id:"put-pl-before",language:"pl",command:"put",priority:105,template:{format:"umie\u015B\u0107 {patient} przed {destination}",tokens:[{type:"literal",value:"umie\u015B\u0107",alternatives:["umiesc","wstaw"]},{type:"role",role:"patient"},{type:"literal",value:"przed"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"przed"},manner:{default:{type:"literal",value:"before"}}}},{id:"put-pl-after",language:"pl",command:"put",priority:105,template:{format:"umie\u015B\u0107 {patient} po {destination}",tokens:[{type:"literal",value:"umie\u015B\u0107",alternatives:["umiesc","wstaw"]},{type:"role",role:"patient"},{type:"literal",value:"po"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"po"},manner:{default:{type:"literal",value:"after"}}}}]}function ms(){return [{id:"put-ru-full",language:"ru",command:"put",priority:100,template:{format:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C {patient} \u0432 {destination}",tokens:[{type:"literal",value:"\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"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0432",alternatives:["\u0432\u043E","\u043D\u0430"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"\u0432",markerAlternatives:["\u0432\u043E","\u043D\u0430"]}}},{id:"put-ru-before",language:"ru",command:"put",priority:105,template:{format:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C {patient} \u043F\u0435\u0440\u0435\u0434 {destination}",tokens:[{type:"literal",value:"\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"]},{type:"role",role:"patient"},{type:"literal",value:"\u043F\u0435\u0440\u0435\u0434",alternatives:["\u0434\u043E"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"\u043F\u0435\u0440\u0435\u0434",markerAlternatives:["\u0434\u043E"]},manner:{default:{type:"literal",value:"before"}}}},{id:"put-ru-after",language:"ru",command:"put",priority:105,template:{format:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C {patient} \u043F\u043E\u0441\u043B\u0435 {destination}",tokens:[{type:"literal",value:"\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"]},{type:"role",role:"patient"},{type:"literal",value:"\u043F\u043E\u0441\u043B\u0435"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"\u043F\u043E\u0441\u043B\u0435"},manner:{default:{type:"literal",value:"after"}}}}]}function fs(){return [{id:"put-th-full",language:"th",command:"put",priority:100,template:{format:"\u0E43\u0E2A\u0E48 {patient} \u0E43\u0E19 {destination}",tokens:[{type:"literal",value:"\u0E43\u0E2A\u0E48",alternatives:["\u0E27\u0E32\u0E07"]},{type:"role",role:"patient"},{type:"literal",value:"\u0E43\u0E19"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"\u0E43\u0E19",position:3}}},{id:"put-th-before",language:"th",command:"put",priority:105,template:{format:"\u0E43\u0E2A\u0E48 {patient} \u0E01\u0E48\u0E2D\u0E19 {destination}",tokens:[{type:"literal",value:"\u0E43\u0E2A\u0E48",alternatives:["\u0E27\u0E32\u0E07"]},{type:"role",role:"patient"},{type:"literal",value:"\u0E01\u0E48\u0E2D\u0E19"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"\u0E01\u0E48\u0E2D\u0E19"},manner:{default:{type:"literal",value:"before"}}}},{id:"put-th-after",language:"th",command:"put",priority:105,template:{format:"\u0E43\u0E2A\u0E48 {patient} \u0E2B\u0E25\u0E31\u0E07 {destination}",tokens:[{type:"literal",value:"\u0E43\u0E2A\u0E48",alternatives:["\u0E27\u0E32\u0E07"]},{type:"role",role:"patient"},{type:"literal",value:"\u0E2B\u0E25\u0E31\u0E07"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"\u0E2B\u0E25\u0E31\u0E07"},manner:{default:{type:"literal",value:"after"}}}}]}function ys(){return [{id:"put-uk-full",language:"uk",command:"put",priority:100,template:{format:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438 {patient} \u0432 {destination}",tokens:[{type:"literal",value:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",alternatives:["\u043F\u043E\u043A\u043B\u0430\u0434\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438\u0442\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u0438","\u0432\u0441\u0442\u0430\u0432"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0432",alternatives:["\u0443","\u043D\u0430"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"\u0432",markerAlternatives:["\u0443","\u043D\u0430"]}}},{id:"put-uk-before",language:"uk",command:"put",priority:105,template:{format:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438 {patient} \u043F\u0435\u0440\u0435\u0434 {destination}",tokens:[{type:"literal",value:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",alternatives:["\u043F\u043E\u043A\u043B\u0430\u0434\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438\u0442\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438"]},{type:"role",role:"patient"},{type:"literal",value:"\u043F\u0435\u0440\u0435\u0434",alternatives:["\u0434\u043E"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"\u043F\u0435\u0440\u0435\u0434",markerAlternatives:["\u0434\u043E"]},manner:{default:{type:"literal",value:"before"}}}},{id:"put-uk-after",language:"uk",command:"put",priority:105,template:{format:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438 {patient} \u043F\u0456\u0441\u043B\u044F {destination}",tokens:[{type:"literal",value:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",alternatives:["\u043F\u043E\u043A\u043B\u0430\u0434\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438\u0442\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438"]},{type:"role",role:"patient"},{type:"literal",value:"\u043F\u0456\u0441\u043B\u044F"},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"\u043F\u0456\u0441\u043B\u044F"},manner:{default:{type:"literal",value:"after"}}}}]}function vs(){return [{id:"put-vi-into",language:"vi",command:"put",priority:100,template:{format:"\u0111\u1EB7t {patient} v\xE0o {target}",tokens:[{type:"literal",value:"\u0111\u1EB7t",alternatives:["\u0111\u1EC3","\u0111\u01B0a"]},{type:"role",role:"patient"},{type:"literal",value:"v\xE0o",alternatives:["v\xE0o trong"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"v\xE0o",markerAlternatives:["v\xE0o trong"]}}},{id:"put-vi-before",language:"vi",command:"put",priority:105,template:{format:"\u0111\u1EB7t {patient} tr\u01B0\u1EDBc {target}",tokens:[{type:"literal",value:"\u0111\u1EB7t",alternatives:["\u0111\u1EC3","\u0111\u01B0a"]},{type:"role",role:"patient"},{type:"literal",value:"tr\u01B0\u1EDBc",alternatives:["tr\u01B0\u1EDBc khi"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"tr\u01B0\u1EDBc",markerAlternatives:["tr\u01B0\u1EDBc khi"]},manner:{default:{type:"literal",value:"before"}}}},{id:"put-vi-after",language:"vi",command:"put",priority:105,template:{format:"\u0111\u1EB7t {patient} sau {target}",tokens:[{type:"literal",value:"\u0111\u1EB7t",alternatives:["\u0111\u1EC3","\u0111\u01B0a"]},{type:"role",role:"patient"},{type:"literal",value:"sau",alternatives:["sau khi"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"sau",markerAlternatives:["sau khi"]},manner:{default:{type:"literal",value:"after"}}}}]}function hs(){return [...["before","after"].map(r=>{let e=r==="before"?"\xF1awpaqpi":"qhepapi";return {id:`put-qu-${r}`,language:"qu",command:"put",priority:105,template:{format:`{patient} ${e} {destination} ta churay`,tokens:[{type:"role",role:"patient"},{type:"literal",value:e,alternatives:[r]},{type:"role",role:"destination"},{type:"group",optional:true,tokens:[{type:"literal",value:"ta"}]},{type:"literal",value:"churay",alternatives:["tiyachiy"]}]},extraction:{patient:{position:0},destination:{position:2},manner:{default:{type:"literal",value:r}}}}}),{id:"put-qu-patient-first",language:"qu",command:"put",priority:96,template:{format:"{patient} ta {destination} man churay",tokens:[{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"role",role:"destination"},{type:"literal",value:"man"},{type:"literal",value:"churay",alternatives:["tiyachiy"]}]},extraction:{patient:{position:0},destination:{position:2}}}]}function Es(){return [{id:"put-zh-full",language:"zh",command:"put",priority:100,template:{format:"\u653E\u7F6E {patient} \u5230 {destination}",tokens:[{type:"literal",value:"\u653E\u7F6E",alternatives:["\u653E","\u653E\u5165","\u7F6E\u5165","put"]},{type:"role",role:"patient",expectedTypes:["literal","selector","reference","expression"]},{type:"literal",value:"\u5230",alternatives:["\u5728","\u4E8E","\u5165"]},{type:"role",role:"destination",expectedTypes:Bt}]},extraction:{patient:{position:1},destination:{position:3}}},{id:"put-zh-ba",language:"zh",command:"put",priority:95,template:{format:"\u628A {patient} \u653E\u7F6E \u5230 {destination}",tokens:[{type:"literal",value:"\u628A"},{type:"role",role:"patient",expectedTypes:["literal","selector","reference","expression"]},{type:"literal",value:"\u653E\u7F6E",alternatives:["\u653E\u5230","\u653E\u5728","\u653E\u5165","\u653E","\u7F6E\u5165"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u5230",alternatives:["\u5728","\u4E8E","\u5165"]}]},{type:"role",role:"destination",expectedTypes:Bt}]},extraction:{patient:{position:1},destination:{marker:"\u5230",markerAlternatives:["\u5728","\u4E8E","\u5165"]}}}]}var gs=[{lang:"ar",verb:"\u0636\u0639",verbAlts:["\u0627\u062C\u0639\u0644"],before:"\u0642\u0628\u0644",after:"\u0628\u0639\u062F"},{lang:"de",verb:"setzen",before:"vor",after:"nach"},{lang:"fr",verb:"mettre",before:"avant",after:"apr\xE8s"},{lang:"he",verb:"\u05E9\u05D9\u05DD",patientPrefix:"\u05D0\u05EA",before:"\u05DC\u05E4\u05E0\u05D9",after:"\u05D0\u05D7\u05E8\u05D9"},{lang:"id",verb:"taruh",verbAlts:["letakkan","masukkan","tempatkan"],before:"sebelum",after:"setelah"},{lang:"ms",verb:"letak",before:"sebelum",after:"selepas"},{lang:"pt",verb:"colocar",before:"antes",after:"depois"},{lang:"sw",verb:"weka",before:"kabla",after:"baada"},{lang:"tl",verb:"ilagay",verbAlts:["maglagay"],before:"bago",after:"matapos"},{lang:"zh",verb:"\u653E\u7F6E",verbAlts:["\u653E","\u653E\u5165"],patientPrefix:"\u628A",patientPrefixOptional:true,before:"\u4E4B\u524D",after:"\u4E4B\u540E"}],Nr=[{lang:"es",verb:"poner",verbAlts:["pon","colocar","put"],at:"en",end:"fin",of:"de"},{lang:"fr",verb:"mettre",at:"\xE0",end:"fin",of:"de"},{lang:"pt",verb:"colocar",at:"em",end:"fim",of:"de"},{lang:"it",verb:"mettere",at:"a",end:"fine",of:"di"},{lang:"de",verb:"setzen",at:"bei",end:"ende",of:"von"},{lang:"sw",verb:"weka",at:"katika",end:"mwisho",of:"ya"},{lang:"id",verb:"taruh",verbAlts:["letakkan","masukkan","tempatkan"],at:"di",end:"akhir",of:"dari"},{lang:"ms",verb:"letak",at:"di",end:"tamat",of:"daripada"},{lang:"vi",verb:"\u0111\u1EB7t",at:"t\u1EA1i",end:"k\u1EBFt th\xFAc",of:"c\u1EE7a"},{lang:"pl",verb:"umie\u015B\u0107",at:"przy",end:"koniec",of:"z"},{lang:"ru",verb:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",at:"\u0443",end:"\u043A\u043E\u043D\u0435\u0446",of:"\u0438\u0437"},{lang:"uk",verb:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",at:"\u0432",end:"\u043A\u0456\u043D\u0435\u0446\u044C",of:"\u0437"},{lang:"th",verb:"\u0E43\u0E2A\u0E48",at:"\u0E17\u0E35\u0E48",end:"\u0E08\u0E1A",of:"\u0E02\u0E2D\u0E07"},{lang:"tl",verb:"ilagay",at:"sa",end:"wakas",of:"ng"},{lang:"ar",verb:"\u0636\u0639",at:"\u0639\u0646\u062F",end:"\u0627\u0644\u0646\u0647\u0627\u064A\u0629",of:"\u0645\u0646"},{lang:"zh",verb:"\u653E\u7F6E",verbAlts:["\u653E","\u653E\u5165"],patientPrefix:"\u628A",at:"\u5728",end:"\u7ED3\u675F",of:"\u7684"},{lang:"he",verb:"\u05E9\u05D9\u05DD",patientPrefix:"\u05D0\u05EA",at:"at",end:"\u05E1\u05D5\u05E3",of:"of"},{lang:"tr",verb:"koy",sov:true,objMarker:"i",at:"de",end:"son",of:"nin"},{lang:"ja",verb:"\u7F6E\u304F",sov:true,objMarker:"\u3092",at:"\u3067",end:"\u7D42\u308F\u308A",of:"\u306E"},{lang:"ko",verb:"\uB123\uB2E4",sov:true,objMarker:"\uB97C",at:"\uC5D0",end:"\uB05D",of:"\uC758"},{lang:"hi",verb:"\u0930\u0916\u0947\u0902",verbAlts:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],sov:true,objMarker:"\u0915\u094B",at:"\u092A\u0930",end:"\u0938\u092E\u093E\u092A\u094D\u0924",of:"\u0915\u093E"},{lang:"bn",verb:"\u09B0\u09BE\u0996\u09C1\u09A8",verbAlts:["\u09B0\u09BE\u0996"],sov:true,objMarker:"\u0995\u09C7",at:"\u098F",end:"\u09B6\u09C7\u09B7",of:"\u09B0"},{lang:"qu",verb:"churay",sov:true,objMarker:"ta",at:"pi",end:"tukuy",of:"pa"}];function yr(r,e,t,a){let i=Nr.find(o=>o.lang===r);if(!i)return false;let n=(o,u)=>(o??"").toLowerCase()===u.toLowerCase();return n(e,i.end)&&n(t,i.at)&&n(a,i.of)}function ks(r,e){let t=Nr.find(i=>i.lang===r);if(!t)return false;let a=e.toLowerCase();return a===t.at.toLowerCase()||a===t.of.toLowerCase()||a===t.end.toLowerCase()}function ws(r){let e=Nr.find(n=>n.lang===r);if(!e)return [];let t=[],a=e.verbAlts?{type:"literal",value:e.verb,alternatives:e.verbAlts}:{type:"literal",value:e.verb},i=n=>{t.push({type:"literal",value:n});};return e.sov?(t.push({type:"role",role:"patient"}),i(e.at),i(e.end),i(e.of),t.push({type:"role",role:"destination"}),e.objMarker&&t.push({type:"literal",value:e.objMarker}),t.push(a)):(t.push(a),e.patientPrefix&&t.push({type:"literal",value:e.patientPrefix}),t.push({type:"role",role:"patient"}),i(e.at),i(e.end),i(e.of),t.push({type:"role",role:"destination"})),[{id:`put-${e.lang}-at-end`,language:e.lang,command:"put",priority:110,template:{format:`put {patient} ${e.at} ${e.end} ${e.of} {destination}`,tokens:t},extraction:{manner:{default:{type:"literal",value:"at end of"}}}}]}function zs(){return ["before","after"].map(r=>{let e=r==="before"?"\u524D\u306B":"\u5F8C\u306B",t=r==="before"?"\u524D":"\u5F8C";return {id:`put-ja-${r}`,language:"ja",command:"put",priority:105,template:{format:`{patient} ${e} {destination} \u3092 \u7F6E\u304F`,tokens:[{type:"role",role:"patient"},{type:"literal",value:e,alternatives:[t]},{type:"role",role:"destination"},{type:"literal",value:"\u3092"},{type:"literal",value:"\u7F6E\u304F",alternatives:["\u5165\u308C\u308B"]}]},extraction:{patient:{position:0},destination:{position:2},manner:{default:{type:"literal",value:r}}}}})}function bs(){return ["before","after"].map(r=>{let e=r==="before"?"\uC804\uC5D0":"\uD6C4\uC5D0";return {id:`put-ko-${r}`,language:"ko",command:"put",priority:105,template:{format:`{patient} ${e} {destination} \uB97C \uB123\uB2E4`,tokens:[{type:"role",role:"patient"},{type:"literal",value:e},{type:"role",role:"destination"},{type:"literal",value:"\uB97C",alternatives:["\uC744"]},{type:"literal",value:"\uB123\uB2E4",alternatives:["\uB123\uAE30","\uB193\uAE30"]}]},extraction:{patient:{position:0},destination:{position:2},manner:{default:{type:"literal",value:r}}}}})}function Cs(){let r=(e,t)=>({id:`put-tr-${e}`,language:"tr",command:"put",priority:105,template:{format:`{patient} ${t} {destination} i koy`,tokens:[{type:"role",role:"patient"},{type:"literal",value:t},{type:"role",role:"destination"},{type:"group",optional:true,tokens:[{type:"literal",value:"i",alternatives:["\u0131","u","\xFC","yi","y\u0131","yu","y\xFC"]}]},{type:"literal",value:"koy",alternatives:["koymak"]}]},extraction:{patient:{position:0},destination:{position:2},manner:{default:{type:"literal",value:e}}}});return [r("before","\xF6nce"),r("after","sonra")]}function As(r){let e=gs.find(t=>t.lang===r);return e?["before","after"].map(t=>{let a=e[t],i=[e.verbAlts?{type:"literal",value:e.verb,alternatives:e.verbAlts}:{type:"literal",value:e.verb}];return e.patientPrefix&&i.push(e.patientPrefixOptional?{type:"group",optional:true,tokens:[{type:"literal",value:e.patientPrefix}]}:{type:"literal",value:e.patientPrefix}),i.push({type:"role",role:"patient"},{type:"literal",value:a},{type:"role",role:"destination"}),{id:`put-${e.lang}-${t}`,language:e.lang,command:"put",priority:105,template:{format:`${e.verb} {patient} ${a} {destination}`,tokens:i},extraction:{patient:{position:e.patientPrefix&&!e.patientPrefixOptional?2:1},destination:{marker:a},manner:{default:{type:"literal",value:t}}}}}):[]}function xs(r){let e=As(r),t=ws(r);switch(r){case "bn":return [...os(),...t];case "en":return us();case "es":return [...ss(),...t];case "hi":return [...ls(),...t];case "id":return [...cs(),...e,...t];case "it":return [...ps(),...t];case "ja":return [...zs(),...t];case "ko":return [...bs(),...t];case "tr":return [...Cs(),...t];case "pl":return [...ds(),...t];case "ru":return [...ms(),...t];case "qu":return [...hs(),...t];case "th":return [...fs(),...t];case "uk":return [...ys(),...t];case "vi":return [...vs(),...t];case "zh":return [...Es(),...e,...t];default:return [...e,...t]}}var Re={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",\uB9C8\uC6B0\uC2A4\uC5D4\uD130:"mouseenter",\uB9C8\uC6B0\uC2A4\uB9AC\uBE0C:"mouseleave",\uB9C8\uC6B0\uC2A4\uBB34\uBE0C:"mousemove",\uD0A4\uD504\uB808\uC2A4:"keypress",\uD130\uCE58\uC885\uB8CC:"touchend",\uD130\uCE58\uCDE8\uC18C:"touchcancel"},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",\u307C\u304B\u3057:"blur"},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",\u062A\u0631\u0643\u064A\u0632:"focus","\u0645\u0641\u062A\u0627\u062D \u0623\u0633\u0641\u0644":"keydown","\u0645\u0641\u062A\u0627\u062D \u0623\u0639\u0644\u0649":"keyup","\u0641\u0623\u0631\u0629 \u0641\u0648\u0642":"mouseover","\u062A\u063A\u064A\u064A\u0631 \u062D\u062C\u0645":"resize"},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",cambiar:"change",enfocar:"focus",desenfocar:"blur",cargar:"load",desplazar:"scroll",dobleclic:"dblclick",rat\u00F3nentrar:"mouseenter",rat\u00F3nsalir:"mouseleave",rat\u00F3nmover:"mousemove",teclapresar:"keypress",descargar:"unload",toqueempezar:"touchstart",toqueterminar:"touchend",toquemover:"touchmove",toquecancelar:"touchcancel"},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",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll",bulan\u0131k:"blur",farebas:"mousedown",fareb\u0131rak:"mouseup",kayd\u0131r:"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",duploClique:"dblclick",mouseEntrar:"mouseenter",mouseSair:"mouseleave",mouseMover:"mousemove",teclaPressionar:"keypress",descarregar:"unload",toqueIn\u00EDcio:"touchstart",toqueFim:"touchend",toqueMover:"touchmove",toqueCancelar:"touchcancel"},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",\u6309\u952E\u6309\u4E0B:"keydown",\u9F20\u6807\u79FB\u52A8:"mousemove",\u5378\u8F7D:"unload",\u8C03\u6574\u5927\u5C0F:"resize",\u89E6\u6478\u5F00\u59CB:"touchstart",\u89E6\u6478\u79FB\u52A8:"touchmove"},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",flou:"blur",doubleclic:"dblclick",sourisentrer:"mouseenter",sourissortir:"mouseleave",sourisbouger:"mousemove",touchepress\u00E9e:"keypress",d\u00E9charger:"unload",touchercommencer:"touchstart",toucherfin:"touchend",toucherbouger:"touchmove",toucherannuler:"touchcancel"},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","taste unten":"keydown","taste oben":"keyup","maus dr\xFCber":"mouseover","maus weg":"mouseout",doppelklick:"dblclick",mauseintreten:"mouseenter",mausverlassen:"mouseleave",mausbewegen:"mousemove",tastedr\u00FCcken:"keypress",entladen:"unload",ber\u00FChrungstart:"touchstart",ber\u00FChrungend:"touchend",ber\u00FChrungbewegen:"touchmove",ber\u00FChrungabbrechen:"touchcancel"},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",tekan_tombol:"keydown",keyup:"keyup",arahkan:"mouseover",tinggalkan:"mouseout",bongkar:"unload"},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",kambiay:"change",apachiy:"submit",kachay:"submit",apaykachay:"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",bonyeza:"click",ingizo:"input",kitufe_shuka:"keydown",kitufe_juu:"keyup",panya_nje:"mouseout",wasilisha:"submit","sogeza juu":"mouseover",shuka:"unload"},vi:{"\u0111\u1ED5i k\xEDch th\u01B0\u1EDBc":"resize"}};function yi(r,e){let t=Re[e];return t&&t[r]?t[r]:r.toLowerCase()}function Ds(r,e){let t=Re[e];return t?Object.keys(t).filter(a=>t[a]===r):[]}var Bs=Object.fromEntries(Object.entries(Re).map(([r,e])=>{let t={};for(let[a,i]of Object.entries(e))i in t||(t[i]=a);return [r,t]})),Ss={ar:new Set(["mouseover"]),bn:new Set(["resize"]),de:new Set(["keydown","keyup","load","mouseout","mouseover"]),fr:new Set(["blur"]),id:new Set(["input","keyup","mouseout","mouseover"]),ja:new Set(["keypress","mousedown","mouseup","resize"]),qu:new Set(["change","focus","load","resize","submit"]),sw:new Set(["change","click","input","keydown","keyup","mouseout","mouseover","submit"]),tr:new Set(["keydown","keyup","load","mousedown","mouseout","mouseover","mouseup","resize","scroll"]),zh:new Set(["focus","keyup","mouseout","mouseover"])};function vi(r,e){return Ss[e]?.has(r)?r:Bs[e]?.[r]??r}function Ts(){return [{id:"event-handler-ko-sov",language:"ko",command:"on",priority:110,template:{format:"{event} \uD560 \uB54C",tokens:[{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:"\uD560"},{type:"literal",value:"\uB54C"}]},extraction:{event:{position:0},source:{default:{type:"reference",value:"me"}}}},{id:"event-handler-ko-with-source",language:"ko",command:"on",priority:108,template:{format:"{source} \uC5D0\uC11C {event} \uD560 \uB54C",tokens:[{type:"role",role:"source",expectedTypes:["selector","reference","expression"]},{type:"literal",value:"\uC5D0\uC11C"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:"\uD560"},{type:"literal",value:"\uB54C"}]},extraction:{source:{position:0},event:{position:2}}}]}function Fs(){return [{id:"event-handler-bn-sov",language:"bn",command:"on",priority:100,template:{format:"{event} \u09A4\u09C7 {action}",tokens:[{type:"role",role:"event"},{type:"literal",value:"\u09A4\u09C7",alternatives:["\u098F"]},{type:"role",role:"action"}]},extraction:{event:{position:0},action:{position:2}}},{id:"event-handler-bn-with-source",language:"bn",command:"on",priority:95,template:{format:"{source} \u09A5\u09C7\u0995\u09C7 {event} \u09A4\u09C7 {action}",tokens:[{type:"role",role:"source"},{type:"literal",value:"\u09A5\u09C7\u0995\u09C7"},{type:"role",role:"event"},{type:"literal",value:"\u09A4\u09C7",alternatives:["\u098F"]},{type:"role",role:"action"}]},extraction:{source:{position:0},event:{marker:"\u09A4\u09C7",position:2},action:{position:4}}},{id:"event-handler-bn-when",language:"bn",command:"on",priority:90,template:{format:"\u09AF\u0996\u09A8 {event} {action}",tokens:[{type:"literal",value:"\u09AF\u0996\u09A8"},{type:"role",role:"event"},{type:"role",role:"action"}]},extraction:{event:{position:1},action:{position:2}}}]}function Ps(){return [{id:"event-de-wenn-source",language:"de",command:"on",priority:115,template:{format:"wenn {event} von {source} {body}",tokens:[{type:"literal",value:"wenn",alternatives:["falls","sobald"]},{type:"role",role:"event"},{type:"literal",value:"von",alternatives:["aus"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"von",markerAlternatives:["aus"]}}},{id:"event-de-wenn",language:"de",command:"on",priority:105,template:{format:"wenn {event} {body}",tokens:[{type:"literal",value:"wenn",alternatives:["falls","sobald"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-de-bei-source",language:"de",command:"on",priority:110,template:{format:"bei {event} von {source} {body}",tokens:[{type:"literal",value:"bei",alternatives:["beim"]},{type:"role",role:"event"},{type:"literal",value:"von",alternatives:["aus"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"von",markerAlternatives:["aus"]}}},{id:"event-de-bei",language:"de",command:"on",priority:100,template:{format:"bei {event} {body}",tokens:[{type:"literal",value:"bei",alternatives:["beim"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-de-auf",language:"de",command:"on",priority:95,template:{format:"auf {event} {body}",tokens:[{type:"literal",value:"auf"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-de-im-falle",language:"de",command:"on",priority:90,template:{format:"im Falle von {event} {body}",tokens:[{type:"literal",value:"im Falle von",alternatives:["im Fall von"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Os(){return [{id:"event-en-source",language:"en",command:"on",priority:110,template:{format:"on {event} from {source} {body}",tokens:[{type:"literal",value:"on"},{type:"role",role:"event"},{type:"literal",value:"from"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"from"}}},{id:"event-en-standard",language:"en",command:"on",priority:100,template:{format:"on {event} {body}",tokens:[{type:"literal",value:"on"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-en-upon",language:"en",command:"on",priority:98,template:{format:"upon {event} {body}",tokens:[{type:"literal",value:"upon"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-en-if",language:"en",command:"on",priority:95,template:{format:"if {event} {body}",tokens:[{type:"literal",value:"if"},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Rs(){return [{id:"event-es-native-al-source",language:"es",command:"on",priority:115,template:{format:"al {event} en {source} {body}",tokens:[{type:"literal",value:"al"},{type:"role",role:"event"},{type:"literal",value:"en",alternatives:["de"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"en",markerAlternatives:["de"]}}},{id:"event-es-cuando-source",language:"es",command:"on",priority:112,template:{format:"cuando {event} en {source} {body}",tokens:[{type:"literal",value:"cuando"},{type:"role",role:"event"},{type:"literal",value:"en",alternatives:["de"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"en",markerAlternatives:["de"]}}},{id:"event-es-native-al",language:"es",command:"on",priority:108,template:{format:"al {event} {body}",tokens:[{type:"literal",value:"al"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-es-standard",language:"es",command:"on",priority:100,template:{format:"en {event} {body}",tokens:[{type:"literal",value:"en",alternatives:["al","cuando"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-es-source",language:"es",command:"on",priority:110,template:{format:"en {event} desde {source} {body}",tokens:[{type:"literal",value:"en",alternatives:["al"]},{type:"role",role:"event"},{type:"literal",value:"desde",alternatives:["de"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"desde",markerAlternatives:["de"]}}},{id:"event-es-when",language:"es",command:"on",priority:95,template:{format:"cuando {event} {body}",tokens:[{type:"literal",value:"cuando"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-es-conditional-si",language:"es",command:"on",priority:85,template:{format:"si {event} {body}",tokens:[{type:"literal",value:"si"},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Ls(){return [{id:"event-fr-quand-source",language:"fr",command:"on",priority:115,template:{format:"quand {event} de {source} {body}",tokens:[{type:"literal",value:"quand",alternatives:["lorsque"]},{type:"role",role:"event"},{type:"literal",value:"de",alternatives:["depuis"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"de",markerAlternatives:["depuis"]}}},{id:"event-fr-quand",language:"fr",command:"on",priority:105,template:{format:"quand {event} {body}",tokens:[{type:"literal",value:"quand",alternatives:["lorsque"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-fr-sur-source",language:"fr",command:"on",priority:110,template:{format:"sur {event} de {source} {body}",tokens:[{type:"literal",value:"sur",alternatives:["lors de"]},{type:"role",role:"event"},{type:"literal",value:"de",alternatives:["depuis"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"de",markerAlternatives:["depuis"]}}},{id:"event-fr-sur",language:"fr",command:"on",priority:100,template:{format:"sur {event} {body}",tokens:[{type:"literal",value:"sur",alternatives:["lors de"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-fr-si",language:"fr",command:"on",priority:95,template:{format:"si {event} {body}",tokens:[{type:"literal",value:"si"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-fr-a",language:"fr",command:"on",priority:90,template:{format:"\xE0 {event} {body}",tokens:[{type:"literal",value:"\xE0",alternatives:["au"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function _s(){return [{id:"event-hi-standard",language:"hi",command:"on",priority:100,template:{format:"{event} \u092A\u0930",tokens:[{type:"role",role:"event"},{type:"literal",value:"\u092A\u0930",alternatives:["\u092E\u0947\u0902","\u091C\u092C"]}]},extraction:{event:{position:0}}},{id:"event-hi-with-source",language:"hi",command:"on",priority:95,template:{format:"{source} \u0938\u0947 {event} \u092A\u0930",tokens:[{type:"role",role:"source"},{type:"literal",value:"\u0938\u0947"},{type:"role",role:"event"},{type:"literal",value:"\u092A\u0930",alternatives:["\u092E\u0947\u0902","\u091C\u092C"]}]},extraction:{source:{position:0},event:{marker:"\u0938\u0947",position:2}}},{id:"event-hi-when",language:"hi",command:"on",priority:95,template:{format:"\u091C\u092C {event} {body}",tokens:[{type:"literal",value:"\u091C\u092C"},{type:"role",role:"event",expectedTypes:["reference","expression","selector"]}]},extraction:{event:{position:1}}},{id:"event-hi-bare",language:"hi",command:"on",priority:80,template:{format:"{event}",tokens:[{type:"role",role:"event"}]},extraction:{event:{position:0}}}]}function Ns(){return [{id:"event-id-ketika-source",language:"id",command:"on",priority:115,template:{format:"ketika {event} dari {source} {body}",tokens:[{type:"literal",value:"ketika",alternatives:["saat","waktu"]},{type:"role",role:"event"},{type:"literal",value:"dari"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"dari"}}},{id:"event-id-ketika",language:"id",command:"on",priority:105,template:{format:"ketika {event} {body}",tokens:[{type:"literal",value:"ketika",alternatives:["saat","waktu"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-id-pada-source",language:"id",command:"on",priority:110,template:{format:"pada {event} dari {source} {body}",tokens:[{type:"literal",value:"pada"},{type:"role",role:"event"},{type:"literal",value:"dari"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"dari"}}},{id:"event-id-pada",language:"id",command:"on",priority:100,template:{format:"pada {event} {body}",tokens:[{type:"literal",value:"pada"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-id-jika",language:"id",command:"on",priority:95,template:{format:"jika {event} {body}",tokens:[{type:"literal",value:"jika",alternatives:["kalau","apabila"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-id-bila",language:"id",command:"on",priority:90,template:{format:"bila {event} {body}",tokens:[{type:"literal",value:"bila"},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Ms(){return [{id:"event-handler-it-full",language:"it",command:"on",priority:100,template:{format:"su {event} {action}",tokens:[{type:"literal",value:"su",alternatives:["quando","al","on"]},{type:"role",role:"event"},{type:"role",role:"action"}]},extraction:{event:{position:1},action:{position:2}}},{id:"event-handler-it-from",language:"it",command:"on",priority:95,template:{format:"su {event} da {source} {action}",tokens:[{type:"literal",value:"su",alternatives:["quando","al","on"]},{type:"role",role:"event"},{type:"literal",value:"da",alternatives:["di"]},{type:"role",role:"source"},{type:"role",role:"action"}]},extraction:{event:{position:1},source:{marker:"da",markerAlternatives:["di"]},action:{position:-1}}}]}function Is(){return [{id:"event-ms-apabila",language:"ms",command:"on",priority:100,template:{format:"apabila {event} {body}",tokens:[{type:"literal",value:"apabila",alternatives:["bila","ketika"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-ms-apabila-source",language:"ms",command:"on",priority:110,template:{format:"apabila {event} dari {source} {body}",tokens:[{type:"literal",value:"apabila",alternatives:["bila","ketika"]},{type:"role",role:"event"},{type:"literal",value:"dari"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"dari"}}}]}function $s(){return [{id:"event-handler-pl-full",language:"pl",command:"on",priority:100,template:{format:"gdy {event} na {source}",tokens:[{type:"literal",value:"gdy",alternatives:["kiedy","przy","na"]},{type:"role",role:"event"},{type:"group",optional:true,tokens:[{type:"literal",value:"na",alternatives:["w","przy","z"]},{type:"role",role:"source"}]}]},extraction:{event:{position:1},source:{marker:"na",markerAlternatives:["w","przy","z"],default:{type:"reference",value:"me"}}}},{id:"event-handler-pl-simple",language:"pl",command:"on",priority:90,template:{format:"gdy {event}",tokens:[{type:"literal",value:"gdy",alternatives:["kiedy","przy","na"]},{type:"role",role:"event"}]},extraction:{event:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function js(){return [{id:"event-pt-ao-source",language:"pt",command:"on",priority:115,template:{format:"ao {event} em {source} {body}",tokens:[{type:"literal",value:"ao",alternatives:["\xE0"]},{type:"role",role:"event"},{type:"literal",value:"em",alternatives:["de","no","na"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"em",markerAlternatives:["de","no","na"]}}},{id:"event-pt-quando-source",language:"pt",command:"on",priority:110,template:{format:"quando {event} de {source} {body}",tokens:[{type:"literal",value:"quando"},{type:"role",role:"event"},{type:"literal",value:"de",alternatives:["em","no","na"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"de",markerAlternatives:["em","no","na"]}}},{id:"event-pt-ao",language:"pt",command:"on",priority:105,template:{format:"ao {event} {body}",tokens:[{type:"literal",value:"ao",alternatives:["\xE0"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-pt-quando",language:"pt",command:"on",priority:100,template:{format:"quando {event} {body}",tokens:[{type:"literal",value:"quando"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-pt-em",language:"pt",command:"on",priority:95,template:{format:"em {event} {body}",tokens:[{type:"literal",value:"em",alternatives:["no","na"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-pt-se",language:"pt",command:"on",priority:90,template:{format:"se {event} {body}",tokens:[{type:"literal",value:"se"},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Ws(){return [{id:"event-qu-maykama",language:"qu",command:"on",priority:115,template:{format:"[{source} manta] maykama {event} {body}",tokens:[{type:"group",optional:true,tokens:[{type:"role",role:"source",expectedTypes:["selector","reference","expression"]},{type:"literal",value:"manta",alternatives:["-manta"]}]},{type:"literal",value:"maykama"},{type:"role",role:"event"}]},extraction:{event:{position:2},source:{position:0}}},{id:"event-qu-kaqtin",language:"qu",command:"on",priority:105,template:{format:"{event} kaqtin {body}",tokens:[{type:"role",role:"event"},{type:"literal",value:"kaqtin",alternatives:["qtin","ptin"]}]},extraction:{event:{position:0}}},{id:"event-qu-standard",language:"qu",command:"on",priority:100,template:{format:"{event} pi {body}",tokens:[{type:"role",role:"event"},{type:"literal",value:"pi",alternatives:["kaqpi","kaqpim"]}]},extraction:{event:{position:0}}}]}function qs(){return [{id:"event-handler-ru-full",language:"ru",command:"on",priority:100,template:{format:"\u043F\u0440\u0438 {event} \u043D\u0430 {source}",tokens:[{type:"literal",value:"\u043F\u0440\u0438",alternatives:["\u043A\u043E\u0433\u0434\u0430"]},{type:"role",role:"event"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u043D\u0430",alternatives:["\u0432","\u043E\u0442"]},{type:"role",role:"source"}]}]},extraction:{event:{position:1},source:{marker:"\u043D\u0430",markerAlternatives:["\u0432","\u043E\u0442"],default:{type:"reference",value:"me"}}}},{id:"event-handler-ru-simple",language:"ru",command:"on",priority:90,template:{format:"\u043F\u0440\u0438 {event}",tokens:[{type:"literal",value:"\u043F\u0440\u0438",alternatives:["\u043A\u043E\u0433\u0434\u0430"]},{type:"role",role:"event"}]},extraction:{event:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function Vs(){return [{id:"event-sw-unapo-source",language:"sw",command:"on",priority:115,template:{format:"unapo {event} kutoka {source} {body}",tokens:[{type:"literal",value:"unapo",alternatives:["wakati wa","wakati"]},{type:"role",role:"event"},{type:"literal",value:"kutoka"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"kutoka"}}},{id:"event-sw-unapo",language:"sw",command:"on",priority:105,template:{format:"unapo {event} {body}",tokens:[{type:"literal",value:"unapo",alternatives:["wakati wa","wakati"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-sw-kwa-source",language:"sw",command:"on",priority:110,template:{format:"kwa {event} kutoka {source} {body}",tokens:[{type:"literal",value:"kwa"},{type:"role",role:"event"},{type:"literal",value:"kutoka"},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"kutoka"}}},{id:"event-sw-kwa",language:"sw",command:"on",priority:100,template:{format:"kwa {event} {body}",tokens:[{type:"literal",value:"kwa"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-sw-ikiwa",language:"sw",command:"on",priority:95,template:{format:"ikiwa {event} {body}",tokens:[{type:"literal",value:"ikiwa",alternatives:["kama"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-sw-baada-ya",language:"sw",command:"on",priority:90,template:{format:"baada ya {event} {body}",tokens:[{type:"literal",value:"baada ya"},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Ks(){return [{id:"event-handler-th-svo",language:"th",command:"on",priority:100,template:{format:"\u0E40\u0E21\u0E37\u0E48\u0E2D {event} {action}",tokens:[{type:"literal",value:"\u0E40\u0E21\u0E37\u0E48\u0E2D",alternatives:["\u0E15\u0E2D\u0E19"]},{type:"role",role:"event"},{type:"role",role:"action"}]},extraction:{event:{position:1},action:{position:2}}},{id:"event-handler-th-with-source",language:"th",command:"on",priority:110,template:{format:"\u0E40\u0E21\u0E37\u0E48\u0E2D {event} \u0E08\u0E32\u0E01 {source} {action}",tokens:[{type:"literal",value:"\u0E40\u0E21\u0E37\u0E48\u0E2D",alternatives:["\u0E15\u0E2D\u0E19"]},{type:"role",role:"event"},{type:"literal",value:"\u0E08\u0E32\u0E01"},{type:"role",role:"source"},{type:"role",role:"action"}]},extraction:{event:{position:1},source:{marker:"\u0E08\u0E32\u0E01",position:3},action:{position:4}}}]}function Mr(r){let e=r.verbAlts?{type:"literal",value:r.verb,alternatives:r.verbAlts}:{type:"literal",value:r.verb},t=r.eventMarkerAlts?{type:"literal",value:r.eventMarker,alternatives:r.eventMarkerAlts}:{type:"literal",value:r.eventMarker};return ["before","after"].map(a=>{let i={type:"literal",value:a==="before"?r.before:r.after},n={type:"role",role:"patient"},o={type:"role",role:"destination"},u={type:"role",role:"event"},s=r.order==="verb-first"?[e,n,i,o,t,u]:[t,u,e,n,i,o],l=r.order==="verb-first"?{action:{value:"put"},patient:{position:1},destination:{position:3},event:{position:5},manner:{default:{type:"literal",value:a}}}:{action:{value:"put"},event:{position:1},patient:{position:3},destination:{position:5},manner:{default:{type:"literal",value:a}}};return {id:`put-event-${r.lang}-vso-${a}`,language:r.lang,command:"on",priority:160,template:{format:`${r.lang} put ${a}`,tokens:s},extraction:l}})}function Hs(){return [...Mr({lang:"tl",verb:"ilagay",verbAlts:["maglagay"],eventMarker:"kapag",eventMarkerAlts:["sa"],before:"bago",after:"matapos",order:"verb-first"}),{id:"event-tl-kapag-source",language:"tl",command:"on",priority:115,template:{format:"kapag {event} mula_sa {source} {body}",tokens:[{type:"literal",value:"kapag",alternatives:["sa"]},{type:"role",role:"event"},{type:"literal",value:"mula_sa",alternatives:["galing_sa"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"mula_sa"}}},{id:"event-tl-kapag",language:"tl",command:"on",priority:105,template:{format:"kapag {event} {body}",tokens:[{type:"literal",value:"kapag",alternatives:["sa"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Us(){return [...Mr({lang:"uk",verb:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",verbAlts:["\u043F\u043E\u043A\u043B\u0430\u0434\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438\u0442\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u0438","\u0432\u0441\u0442\u0430\u0432"],eventMarker:"\u043F\u0440\u0438",eventMarkerAlts:["\u043A\u043E\u043B\u0438"],before:"\u0434\u043E",after:"\u043F\u0456\u0441\u043B\u044F",order:"event-first"}),{id:"event-handler-uk-full",language:"uk",command:"on",priority:100,template:{format:"\u043F\u0440\u0438 {event} \u043D\u0430 {source}",tokens:[{type:"literal",value:"\u043F\u0440\u0438",alternatives:["\u043A\u043E\u043B\u0438"]},{type:"role",role:"event"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u043D\u0430",alternatives:["\u0432","\u0432\u0456\u0434"]},{type:"role",role:"source"}]}]},extraction:{event:{position:1},source:{marker:"\u043D\u0430",markerAlternatives:["\u0432","\u0432\u0456\u0434"],default:{type:"reference",value:"me"}}}},{id:"event-handler-uk-simple",language:"uk",command:"on",priority:90,template:{format:"\u043F\u0440\u0438 {event}",tokens:[{type:"literal",value:"\u043F\u0440\u0438",alternatives:["\u043A\u043E\u043B\u0438"]},{type:"role",role:"event"}]},extraction:{event:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function Gs(){return [{id:"event-handler-vi-full",language:"vi",command:"on",priority:100,template:{format:"khi {event} tr\xEAn {source}",tokens:[{type:"literal",value:"khi",alternatives:["l\xFAc","tr\xEAn"]},{type:"role",role:"event"},{type:"group",optional:true,tokens:[{type:"literal",value:"tr\xEAn",alternatives:["t\u1EA1i"]},{type:"role",role:"source"}]}]},extraction:{event:{position:1},source:{marker:"tr\xEAn",markerAlternatives:["t\u1EA1i"],default:{type:"reference",value:"me"}}}},{id:"event-handler-vi-simple",language:"vi",command:"on",priority:90,template:{format:"khi {event}",tokens:[{type:"literal",value:"khi",alternatives:["l\xFAc","tr\xEAn"]},{type:"role",role:"event"}]},extraction:{event:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function Zs(){return [{id:"event-zh-temporal-source",language:"zh",command:"on",priority:115,template:{format:"{event} \u7684\u65F6\u5019 \u4ECE {source} {body}",tokens:[{type:"role",role:"event"},{type:"literal",value:"\u7684\u65F6\u5019",alternatives:["\u65F6\u5019","\u65F6"]},{type:"literal",value:"\u4ECE",alternatives:["\u5728"]},{type:"role",role:"source"}]},extraction:{event:{position:0},source:{marker:"\u4ECE",markerAlternatives:["\u5728"]}}},{id:"event-zh-source",language:"zh",command:"on",priority:110,template:{format:"\u5F53 {event} \u4ECE {source} {body}",tokens:[{type:"literal",value:"\u5F53"},{type:"role",role:"event"},{type:"literal",value:"\u4ECE",alternatives:["\u5728"]},{type:"role",role:"source"}]},extraction:{event:{position:1},source:{marker:"\u4ECE",markerAlternatives:["\u5728"]}}},{id:"event-zh-immediate-source",language:"zh",command:"on",priority:112,template:{format:"\u4E00 {event} \u4ECE {source} \u5C31 {body}",tokens:[{type:"literal",value:"\u4E00"},{type:"role",role:"event"},{type:"literal",value:"\u4ECE",alternatives:["\u5728"]},{type:"role",role:"source"},{type:"literal",value:"\u5C31"}]},extraction:{event:{position:1},source:{marker:"\u4ECE",markerAlternatives:["\u5728"]}}},{id:"event-zh-immediate",language:"zh",command:"on",priority:108,template:{format:"\u4E00 {event} \u5C31 {body}",tokens:[{type:"literal",value:"\u4E00"},{type:"role",role:"event"},{type:"literal",value:"\u5C31"}]},extraction:{event:{position:1}}},{id:"event-zh-temporal",language:"zh",command:"on",priority:105,template:{format:"{event} \u7684\u65F6\u5019 {body}",tokens:[{type:"role",role:"event"},{type:"literal",value:"\u7684\u65F6\u5019",alternatives:["\u65F6\u5019","\u65F6"]}]},extraction:{event:{position:0}}},{id:"event-zh-whenever",language:"zh",command:"on",priority:103,template:{format:"\u6BCF\u5F53 {event} {body}",tokens:[{type:"literal",value:"\u6BCF\u5F53",alternatives:["\u6BCF\u6B21"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-zh-circumfix",language:"zh",command:"on",priority:106,template:{format:"\u5F53 {event} \u65F6 {body}",tokens:[{type:"literal",value:"\u5F53"},{type:"role",role:"event"},{type:"literal",value:"\u65F6",alternatives:["\u7684\u65F6\u5019","\u65F6\u5019"]}]},extraction:{event:{position:1}}},{id:"event-zh-standard",language:"zh",command:"on",priority:100,template:{format:"\u5F53 {event} {body}",tokens:[{type:"literal",value:"\u5F53"},{type:"role",role:"event"}]},extraction:{event:{position:1}}},{id:"event-zh-completion",language:"zh",command:"on",priority:95,template:{format:"{event} \u4E86 {body}",tokens:[{type:"role",role:"event"},{type:"literal",value:"\u4E86"}]},extraction:{event:{position:0}}},{id:"event-zh-conditional",language:"zh",command:"on",priority:90,template:{format:"\u5982\u679C {event} {body}",tokens:[{type:"literal",value:"\u5982\u679C",alternatives:["\u82E5","\u5047\u5982"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Ys(){return [{id:"event-ja-when",language:"ja",command:"on",priority:95,template:{format:"\u3068\u304D {event} {body}",tokens:[{type:"literal",value:"\u3068\u304D",alternatives:["\u6642","\u3068\u304D\u306B"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Xs(){return [{id:"event-tr-when",language:"tr",command:"on",priority:95,template:{format:"iken {event} {body}",tokens:[{type:"literal",value:"iken",alternatives:["durumunda","oldu\u011Funda"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Js(){return [...Mr({lang:"ar",verb:"\u0636\u0639",verbAlts:["\u0627\u062C\u0639\u0644"],eventMarker:"\u0639\u0646\u062F",eventMarkerAlts:["\u0641\u064A","\u0644\u062F\u0649","\u0639\u0646\u062F\u0645\u0627","\u062D\u064A\u0646","\u062D\u064A\u0646\u0645\u0627","\u0644\u0645\u0651\u0627","\u0644\u0645\u0627"],before:"\u0642\u0628\u0644",after:"\u0628\u0639\u062F",order:"verb-first"}),{id:"event-ar-when",language:"ar",command:"on",priority:95,template:{format:"\u0639\u0646\u062F\u0645\u0627 {event} {body}",tokens:[{type:"literal",value:"\u0639\u0646\u062F\u0645\u0627",alternatives:["\u062D\u064A\u0646","\u0644\u0645\u0651\u0627"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function Qs(){return [{id:"event-he-when",language:"he",command:"on",priority:95,template:{format:"\u05DB\u05D0\u05E9\u05E8 {event} {body}",tokens:[{type:"literal",value:"\u05DB\u05D0\u05E9\u05E8",alternatives:["\u05DB\u05E9"]},{type:"role",role:"event"}]},extraction:{event:{position:1}}}]}function el(r){switch(r){case "bn":return Fs();case "ko":return Ts();case "de":return Ps();case "en":return Os();case "es":return Rs();case "fr":return Ls();case "hi":return _s();case "id":return Ns();case "it":return Ms();case "ms":return Is();case "pl":return $s();case "pt":return js();case "qu":return Ws();case "ru":return qs();case "sw":return Vs();case "th":return Ks();case "tl":return Hs();case "uk":return Us();case "vi":return Gs();case "zh":return Zs();case "ja":return Ys();case "tr":return Xs();case "ar":return Js();case "he":return Qs();default:return []}}function tl(r){return []}function rl(){return [{id:"add-bn-full",language:"bn",command:"add",priority:100,template:{format:"{patient} \u0995\u09C7 \u09AF\u09CB\u0997 \u0995\u09B0\u09C1\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u09AF\u09CB\u0997"},{type:"literal",value:"\u0995\u09B0\u09C1\u09A8"}]},extraction:{patient:{position:0}}},{id:"add-bn-simple",language:"bn",command:"add",priority:90,template:{format:"\u09AF\u09CB\u0997 {patient}",tokens:[{type:"literal",value:"\u09AF\u09CB\u0997"},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"add-bn-with-dest",language:"bn",command:"add",priority:95,template:{format:"{destination} \u098F {patient} \u0995\u09C7 \u09AF\u09CB\u0997 \u0995\u09B0\u09C1\u09A8",tokens:[{type:"role",role:"destination"},{type:"literal",value:"\u098F",alternatives:["\u09A4\u09C7"]},{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u09AF\u09CB\u0997"},{type:"literal",value:"\u0995\u09B0\u09C1\u09A8"}]},extraction:{destination:{position:0},patient:{position:2}}}]}function al(){return [{id:"add-hi-full",language:"hi",command:"add",priority:100,template:{format:"{patient} \u0915\u094B {destination} \u092E\u0947\u0902 \u091C\u094B\u0921\u093C\u0947\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"role",role:"destination"},{type:"literal",value:"\u092E\u0947\u0902"},{type:"literal",value:"\u091C\u094B\u0921\u093C\u0947\u0902",alternatives:["\u091C\u094B\u0921\u093C"]}]},extraction:{patient:{position:0},destination:{marker:"\u092E\u0947\u0902",position:3}}},{id:"add-hi-simple",language:"hi",command:"add",priority:90,template:{format:"{patient} \u091C\u094B\u0921\u093C\u0947\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u091C\u094B\u0921\u093C\u0947\u0902",alternatives:["\u091C\u094B\u0921\u093C"]}]},extraction:{patient:{position:0},destination:{default:{type:"reference",value:"me"}}}},{id:"add-hi-bare",language:"hi",command:"add",priority:80,template:{format:"\u091C\u094B\u0921\u093C\u0947\u0902 {patient}",tokens:[{type:"literal",value:"\u091C\u094B\u0921\u093C\u0947\u0902",alternatives:["\u091C\u094B\u0921\u093C"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function il(){return [{id:"add-it-full",language:"it",command:"add",priority:100,template:{format:"aggiungere {patient} a {target}",tokens:[{type:"literal",value:"aggiungere",alternatives:["aggiungi","add"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"a",alternatives:["su","in"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"a",markerAlternatives:["su","in"],default:{type:"reference",value:"me"}}}},{id:"add-it-simple",language:"it",command:"add",priority:90,template:{format:"aggiungere {patient}",tokens:[{type:"literal",value:"aggiungere",alternatives:["aggiungi","add"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function nl(){return [{id:"add-pl-full",language:"pl",command:"add",priority:100,template:{format:"dodaj {patient} do {destination}",tokens:[{type:"literal",value:"dodaj"},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"do",alternatives:["na","w"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"do",markerAlternatives:["na","w"],default:{type:"reference",value:"me"}}}},{id:"add-pl-simple",language:"pl",command:"add",priority:90,template:{format:"dodaj {patient}",tokens:[{type:"literal",value:"dodaj"},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function ol(){return [{id:"add-qu-sov",language:"qu",command:"add",priority:100,template:{format:"{patient} ta yapay",tokens:[{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"literal",value:"yapay",alternatives:["yapaykuy"]}]},extraction:{patient:{position:0}}},{id:"add-qu-simple",language:"qu",command:"add",priority:90,template:{format:"yapay {patient}",tokens:[{type:"literal",value:"yapay",alternatives:["yapaykuy"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"add-qu-patient-first",language:"qu",command:"add",priority:96,template:{format:"{patient} ta {destination} man yapay",tokens:[{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"role",role:"destination"},{type:"literal",value:"man"},{type:"literal",value:"yapay",alternatives:["yapaykuy"]}]},extraction:{patient:{position:0},destination:{position:2}}},{id:"add-qu-with-dest",language:"qu",command:"add",priority:95,template:{format:"{destination} man {patient} ta yapay",tokens:[{type:"role",role:"destination"},{type:"literal",value:"man"},{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"literal",value:"yapay",alternatives:["yapaykuy"]}]},extraction:{destination:{position:0},patient:{position:2}}}]}function ul(){return [{id:"add-ru-full",language:"ru",command:"add",priority:100,template:{format:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C {patient} \u043A {destination}",tokens:[{type:"literal",value:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C",alternatives:["\u0434\u043E\u0431\u0430\u0432\u044C"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u043A",alternatives:["\u043D\u0430","\u0432"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"\u043A",markerAlternatives:["\u043D\u0430","\u0432"],default:{type:"reference",value:"me"}}}},{id:"add-ru-simple",language:"ru",command:"add",priority:90,template:{format:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C {patient}",tokens:[{type:"literal",value:"\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C",alternatives:["\u0434\u043E\u0431\u0430\u0432\u044C"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function sl(){return []}function ll(){return [{id:"add-uk-full",language:"uk",command:"add",priority:100,template:{format:"\u0434\u043E\u0434\u0430\u0442\u0438 {patient} \u0434\u043E {destination}",tokens:[{type:"literal",value:"\u0434\u043E\u0434\u0430\u0442\u0438",alternatives:["\u0434\u043E\u0434\u0430\u0439"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0434\u043E",alternatives:["\u043D\u0430","\u0432"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"\u0434\u043E",markerAlternatives:["\u043D\u0430","\u0432"],default:{type:"reference",value:"me"}}}},{id:"add-uk-simple",language:"uk",command:"add",priority:90,template:{format:"\u0434\u043E\u0434\u0430\u0442\u0438 {patient}",tokens:[{type:"literal",value:"\u0434\u043E\u0434\u0430\u0442\u0438",alternatives:["\u0434\u043E\u0434\u0430\u0439"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function cl(){return [{id:"add-vi-full",language:"vi",command:"add",priority:100,template:{format:"th\xEAm {patient} v\xE0o {target}",tokens:[{type:"literal",value:"th\xEAm",alternatives:["b\u1ED5 sung"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"v\xE0o",alternatives:["cho"]},{type:"role",role:"destination"}]}]},extraction:{patient:{position:1},destination:{marker:"v\xE0o",markerAlternatives:["cho"],default:{type:"reference",value:"me"}}}},{id:"add-vi-simple",language:"vi",command:"add",priority:90,template:{format:"th\xEAm {patient}",tokens:[{type:"literal",value:"th\xEAm",alternatives:["b\u1ED5 sung"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function pl(){return [{id:"add-zh-full",language:"zh",command:"add",priority:100,template:{format:"\u7ED9 {destination} \u6DFB\u52A0 {patient}",tokens:[{type:"literal",value:"\u7ED9",alternatives:["\u70BA","\u4E3A"]},{type:"role",role:"destination"},{type:"literal",value:"\u6DFB\u52A0",alternatives:["\u52A0","\u589E\u52A0","\u52A0\u4E0A"]},{type:"role",role:"patient"}]},extraction:{destination:{position:1},patient:{position:3}}},{id:"add-zh-simple",language:"zh",command:"add",priority:90,template:{format:"\u6DFB\u52A0 {patient}",tokens:[{type:"literal",value:"\u6DFB\u52A0",alternatives:["\u52A0","\u589E\u52A0"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}},{id:"add-zh-ba",language:"zh",command:"add",priority:95,template:{format:"\u628A {patient} \u6DFB\u52A0\u5230 {destination}",tokens:[{type:"literal",value:"\u628A"},{type:"role",role:"patient"},{type:"literal",value:"\u6DFB\u52A0\u5230",alternatives:["\u52A0\u5230","\u589E\u52A0\u5230"]},{type:"role",role:"destination"}]},extraction:{patient:{position:1},destination:{marker:"\u6DFB\u52A0\u5230",markerAlternatives:["\u52A0\u5230","\u589E\u52A0\u5230"]}}}]}function dl(r){switch(r){case "bn":return rl();case "hi":return al();case "it":return il();case "pl":return nl();case "qu":return ol();case "ru":return ul();case "th":return sl();case "uk":return ll();case "vi":return cl();case "zh":return pl();default:return []}}function ml(){return [{id:"remove-bn-simple",language:"bn",command:"remove",priority:90,template:{format:"\u09B8\u09B0\u09BE\u09A8 {patient}",tokens:[{type:"literal",value:"\u09B8\u09B0\u09BE\u09A8",alternatives:["\u09AE\u09C1\u099B\u09C1\u09A8"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"remove-bn-with-source",language:"bn",command:"remove",priority:95,template:{format:"{source} \u09A5\u09C7\u0995\u09C7 {patient} \u0995\u09C7 \u09B8\u09B0\u09BE\u09A8",tokens:[{type:"role",role:"source"},{type:"literal",value:"\u09A5\u09C7\u0995\u09C7"},{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u09B8\u09B0\u09BE\u09A8",alternatives:["\u09AE\u09C1\u099B\u09C1\u09A8"]}]},extraction:{source:{position:0},patient:{position:2}}}]}function fl(){return [{id:"remove-hi-full",language:"hi",command:"remove",priority:100,template:{format:"{patient} \u0915\u094B {source} \u0938\u0947 \u0939\u091F\u093E\u090F\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"role",role:"source"},{type:"literal",value:"\u0938\u0947"},{type:"literal",value:"\u0939\u091F\u093E\u090F\u0902",alternatives:["\u0939\u091F\u093E","\u092E\u093F\u091F\u093E\u090F\u0902"]}]},extraction:{patient:{position:0},source:{marker:"\u0938\u0947",position:3}}},{id:"remove-hi-simple",language:"hi",command:"remove",priority:90,template:{format:"{patient} \u0939\u091F\u093E\u090F\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0939\u091F\u093E\u090F\u0902",alternatives:["\u0939\u091F\u093E","\u092E\u093F\u091F\u093E\u090F\u0902"]}]},extraction:{patient:{position:0},source:{default:{type:"reference",value:"me"}}}},{id:"remove-hi-bare",language:"hi",command:"remove",priority:80,template:{format:"\u0939\u091F\u093E\u090F\u0902 {patient}",tokens:[{type:"literal",value:"\u0939\u091F\u093E\u090F\u0902",alternatives:["\u0939\u091F\u093E","\u092E\u093F\u091F\u093E\u090F\u0902"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function yl(){return [{id:"remove-it-full",language:"it",command:"remove",priority:100,template:{format:"rimuovere {patient} da {source}",tokens:[{type:"literal",value:"rimuovere",alternatives:["rimuovi","eliminare","togliere","remove"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"da",alternatives:["di"]},{type:"role",role:"source"}]}]},extraction:{patient:{position:1},source:{marker:"da",markerAlternatives:["di"],default:{type:"reference",value:"me"}}}},{id:"remove-it-simple",language:"it",command:"remove",priority:90,template:{format:"rimuovere {patient}",tokens:[{type:"literal",value:"rimuovere",alternatives:["rimuovi","eliminare","togliere","remove"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function vl(){return [{id:"remove-pl-full",language:"pl",command:"remove",priority:100,template:{format:"usu\u0144 {patient} z {source}",tokens:[{type:"literal",value:"usu\u0144",alternatives:["usun","wyczy\u015B\u0107","wyczysc"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"z",alternatives:["od","ze"]},{type:"role",role:"source"}]}]},extraction:{patient:{position:1},source:{marker:"z",markerAlternatives:["od","ze"],default:{type:"reference",value:"me"}}}},{id:"remove-pl-simple",language:"pl",command:"remove",priority:90,template:{format:"usu\u0144 {patient}",tokens:[{type:"literal",value:"usu\u0144",alternatives:["usun","wyczy\u015B\u0107","wyczysc"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function hl(){return [{id:"remove-qu-sov",language:"qu",command:"remove",priority:100,template:{format:"{patient} ta qichuy",tokens:[{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"literal",value:"qichuy",alternatives:["hurquy","anchuchiy"]}]},extraction:{patient:{position:0}}},{id:"remove-qu-simple",language:"qu",command:"remove",priority:90,template:{format:"qichuy {patient}",tokens:[{type:"literal",value:"qichuy",alternatives:["hurquy","anchuchiy"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"remove-qu-patient-first",language:"qu",command:"remove",priority:96,template:{format:"{patient} ta {source} manta qichuy",tokens:[{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"role",role:"source"},{type:"literal",value:"manta"},{type:"literal",value:"qichuy",alternatives:["hurquy","anchuchiy"]}]},extraction:{patient:{position:0},source:{position:2}}},{id:"remove-qu-with-source",language:"qu",command:"remove",priority:95,template:{format:"{source} manta {patient} ta qichuy",tokens:[{type:"role",role:"source"},{type:"literal",value:"manta"},{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"literal",value:"qichuy",alternatives:["hurquy","anchuchiy"]}]},extraction:{source:{position:0},patient:{position:2}}}]}function El(){return [{id:"remove-ru-full",language:"ru",command:"remove",priority:100,template:{format:"\u0443\u0434\u0430\u043B\u0438\u0442\u044C {patient} \u0438\u0437 {source}",tokens:[{type:"literal",value:"\u0443\u0434\u0430\u043B\u0438\u0442\u044C",alternatives:["\u0443\u0434\u0430\u043B\u0438","\u0443\u0431\u0440\u0430\u0442\u044C","\u0443\u0431\u0435\u0440\u0438"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0438\u0437",alternatives:["\u043E\u0442","\u0441"]},{type:"role",role:"source"}]}]},extraction:{patient:{position:1},source:{marker:"\u0438\u0437",markerAlternatives:["\u043E\u0442","\u0441"],default:{type:"reference",value:"me"}}}},{id:"remove-ru-simple",language:"ru",command:"remove",priority:90,template:{format:"\u0443\u0434\u0430\u043B\u0438\u0442\u044C {patient}",tokens:[{type:"literal",value:"\u0443\u0434\u0430\u043B\u0438\u0442\u044C",alternatives:["\u0443\u0434\u0430\u043B\u0438","\u0443\u0431\u0440\u0430\u0442\u044C","\u0443\u0431\u0435\u0440\u0438"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function gl(){return [{id:"remove-th-simple",language:"th",command:"remove",priority:90,template:{format:"\u0E25\u0E1A {patient}",tokens:[{type:"literal",value:"\u0E25\u0E1A",alternatives:["\u0E25\u0E1A\u0E2D\u0E2D\u0E01"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"remove-th-with-source",language:"th",command:"remove",priority:95,template:{format:"\u0E25\u0E1A {patient} \u0E08\u0E32\u0E01 {source}",tokens:[{type:"literal",value:"\u0E25\u0E1A",alternatives:["\u0E25\u0E1A\u0E2D\u0E2D\u0E01"]},{type:"role",role:"patient"},{type:"literal",value:"\u0E08\u0E32\u0E01"},{type:"role",role:"source"}]},extraction:{patient:{position:1},source:{marker:"\u0E08\u0E32\u0E01",position:3}}}]}function kl(){return [{id:"remove-uk-full",language:"uk",command:"remove",priority:100,template:{format:"\u0432\u0438\u0434\u0430\u043B\u0438\u0442\u0438 {patient} \u0437 {source}",tokens:[{type:"literal",value:"\u0432\u0438\u0434\u0430\u043B\u0438\u0442\u0438",alternatives:["\u0432\u0438\u0434\u0430\u043B\u0438","\u043F\u0440\u0438\u0431\u0440\u0430\u0442\u0438","\u043F\u0440\u0438\u0431\u0435\u0440\u0438"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0437",alternatives:["\u0432\u0456\u0434","\u0456\u0437"]},{type:"role",role:"source"}]}]},extraction:{patient:{position:1},source:{marker:"\u0437",markerAlternatives:["\u0432\u0456\u0434","\u0456\u0437"],default:{type:"reference",value:"me"}}}},{id:"remove-uk-simple",language:"uk",command:"remove",priority:90,template:{format:"\u0432\u0438\u0434\u0430\u043B\u0438\u0442\u0438 {patient}",tokens:[{type:"literal",value:"\u0432\u0438\u0434\u0430\u043B\u0438\u0442\u0438",alternatives:["\u0432\u0438\u0434\u0430\u043B\u0438","\u043F\u0440\u0438\u0431\u0440\u0430\u0442\u0438","\u043F\u0440\u0438\u0431\u0435\u0440\u0438"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function wl(){return [{id:"remove-vi-full",language:"vi",command:"remove",priority:100,template:{format:"x\xF3a {patient} kh\u1ECFi {target}",tokens:[{type:"literal",value:"x\xF3a",alternatives:["g\u1EE1 b\u1ECF","lo\u1EA1i b\u1ECF","b\u1ECF"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"kh\u1ECFi",alternatives:["t\u1EEB"]},{type:"role",role:"source"}]}]},extraction:{patient:{position:1},source:{marker:"kh\u1ECFi",markerAlternatives:["t\u1EEB"],default:{type:"reference",value:"me"}}}},{id:"remove-vi-simple",language:"vi",command:"remove",priority:90,template:{format:"x\xF3a {patient}",tokens:[{type:"literal",value:"x\xF3a",alternatives:["g\u1EE1 b\u1ECF","lo\u1EA1i b\u1ECF","b\u1ECF"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},source:{default:{type:"reference",value:"me"}}}}]}function zl(){return [{id:"remove-zh-full",language:"zh",command:"remove",priority:100,template:{format:"\u4ECE {destination} \u5220\u9664 {patient}",tokens:[{type:"literal",value:"\u4ECE",alternatives:["\u5F9E"]},{type:"role",role:"destination"},{type:"literal",value:"\u5220\u9664",alternatives:["\u522A\u9664","\u79FB\u9664","\u53BB\u6389"]},{type:"role",role:"patient"}]},extraction:{destination:{position:1},patient:{position:3}}},{id:"remove-zh-simple",language:"zh",command:"remove",priority:90,template:{format:"\u5220\u9664 {patient}",tokens:[{type:"literal",value:"\u5220\u9664",alternatives:["\u522A\u9664","\u79FB\u9664","\u53BB\u6389"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},destination:{default:{type:"reference",value:"me"}}}},{id:"remove-zh-ba",language:"zh",command:"remove",priority:95,template:{format:"\u628A {patient} \u4ECE {destination} \u5220\u9664",tokens:[{type:"literal",value:"\u628A"},{type:"role",role:"patient"},{type:"literal",value:"\u4ECE",alternatives:["\u5F9E"]},{type:"role",role:"destination"},{type:"literal",value:"\u5220\u9664",alternatives:["\u522A\u9664","\u79FB\u9664"]}]},extraction:{patient:{position:1},destination:{position:3}}}]}function bl(r){switch(r){case "bn":return ml();case "hi":return fl();case "it":return yl();case "pl":return vl();case "qu":return hl();case "ru":return El();case "th":return gl();case "uk":return kl();case "vi":return wl();case "zh":return zl();default:return []}}var Cl=[...di.roles.find(r=>r.role==="patient")?.expectedTypes??[]];function Al(){return [{id:"show-bn-full",language:"bn",command:"show",priority:100,template:{format:"{patient} \u0995\u09C7 \u09A6\u09C7\u0996\u09BE\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u09A6\u09C7\u0996\u09BE\u09A8",alternatives:["\u09A6\u09C7\u0996\u09BE\u0993"]}]},extraction:{patient:{position:0}}},{id:"show-bn-simple",language:"bn",command:"show",priority:90,template:{format:"\u09A6\u09C7\u0996\u09BE\u09A8 {patient}",tokens:[{type:"literal",value:"\u09A6\u09C7\u0996\u09BE\u09A8",alternatives:["\u09A6\u09C7\u0996\u09BE\u0993"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function xl(){return [{id:"show-de-full",language:"de",command:"show",priority:100,template:{format:"zeige {patient}",tokens:[{type:"literal",value:"zeige",alternatives:["zeigen","anzeigen","show"]},{type:"role",role:"patient",expectedTypes:Cl},{type:"group",optional:true,tokens:[{type:"literal",value:"mit"},{type:"role",role:"style",expectedTypes:["expression","selector"]}]}]},extraction:{patient:{position:1},style:{marker:"mit"}}}]}function Dl(){return [{id:"show-fr-full",language:"fr",command:"show",priority:100,template:{format:"afficher {patient}",tokens:[{type:"literal",value:"afficher",alternatives:["montrer","pr\xE9senter","show"]},{type:"role",role:"patient",expectedTypes:["selector","reference"]},{type:"group",optional:true,tokens:[{type:"literal",value:"avec"},{type:"role",role:"style",expectedTypes:["expression","selector"]}]}]},extraction:{patient:{position:1},style:{marker:"avec"}}}]}function Bl(){return [{id:"show-hi-full",language:"hi",command:"show",priority:100,template:{format:"{patient} \u0915\u094B \u0926\u093F\u0916\u093E\u090F\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"literal",value:"\u0926\u093F\u0916\u093E\u090F\u0902",alternatives:["\u0926\u093F\u0916\u093E"]}]},extraction:{patient:{position:0}}},{id:"show-hi-simple",language:"hi",command:"show",priority:90,template:{format:"\u0926\u093F\u0916\u093E\u090F\u0902 {patient}",tokens:[{type:"literal",value:"\u0926\u093F\u0916\u093E\u090F\u0902",alternatives:["\u0926\u093F\u0916\u093E"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"show-hi-bare",language:"hi",command:"show",priority:80,template:{format:"\u0926\u093F\u0916\u093E\u090F\u0902",tokens:[{type:"literal",value:"\u0926\u093F\u0916\u093E\u090F\u0902",alternatives:["\u0926\u093F\u0916\u093E"]}]},extraction:{patient:{default:{type:"reference",value:"me"}}}}]}function Sl(){return [{id:"show-it-full",language:"it",command:"show",priority:100,template:{format:"mostrare {patient} con {style}",tokens:[{type:"literal",value:"mostrare",alternatives:["mostra","visualizzare","show"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"con"},{type:"role",role:"style"}]}]},extraction:{patient:{position:1},style:{marker:"con"}}},{id:"show-it-simple",language:"it",command:"show",priority:90,template:{format:"mostrare {patient}",tokens:[{type:"literal",value:"mostrare",alternatives:["mostra","visualizzare","show"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Tl(){return [{id:"show-pl-full",language:"pl",command:"show",priority:100,template:{format:"poka\u017C {patient} z {style}",tokens:[{type:"literal",value:"poka\u017C",alternatives:["pokaz","wy\u015Bwietl","wyswietl"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"z",alternatives:["ze","jako"]},{type:"role",role:"style"}]}]},extraction:{patient:{position:1},style:{marker:"z",markerAlternatives:["ze","jako"]}}},{id:"show-pl-simple",language:"pl",command:"show",priority:90,template:{format:"poka\u017C {patient}",tokens:[{type:"literal",value:"poka\u017C",alternatives:["pokaz","wy\u015Bwietl","wyswietl"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Fl(){return [{id:"show-ru-full",language:"ru",command:"show",priority:100,template:{format:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C {patient} \u0441 {style}",tokens:[{type:"literal",value:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C",alternatives:["\u043F\u043E\u043A\u0430\u0436\u0438"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0441",alternatives:["\u0441\u043E","\u043A\u0430\u043A"]},{type:"role",role:"style"}]}]},extraction:{patient:{position:1},style:{marker:"\u0441",markerAlternatives:["\u0441\u043E","\u043A\u0430\u043A"]}}},{id:"show-ru-simple",language:"ru",command:"show",priority:90,template:{format:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C {patient}",tokens:[{type:"literal",value:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C",alternatives:["\u043F\u043E\u043A\u0430\u0436\u0438"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Pl(){return [{id:"show-th-simple",language:"th",command:"show",priority:100,template:{format:"\u0E41\u0E2A\u0E14\u0E07 {patient}",tokens:[{type:"literal",value:"\u0E41\u0E2A\u0E14\u0E07"},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0E14\u0E49\u0E27\u0E22"},{type:"role",role:"style",expectedTypes:["expression","selector"]}]}]},extraction:{patient:{position:1},style:{marker:"\u0E14\u0E49\u0E27\u0E22"}}}]}function Ol(){return [{id:"show-uk-full",language:"uk",command:"show",priority:100,template:{format:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438 {patient} \u0437 {style}",tokens:[{type:"literal",value:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438",alternatives:["\u043F\u043E\u043A\u0430\u0436\u0438"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0437",alternatives:["\u0456\u0437","\u044F\u043A"]},{type:"role",role:"style"}]}]},extraction:{patient:{position:1},style:{marker:"\u0437",markerAlternatives:["\u0456\u0437","\u044F\u043A"]}}},{id:"show-uk-simple",language:"uk",command:"show",priority:90,template:{format:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438 {patient}",tokens:[{type:"literal",value:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438",alternatives:["\u043F\u043E\u043A\u0430\u0436\u0438"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Rl(){return [{id:"show-vi-full",language:"vi",command:"show",priority:100,template:{format:"hi\u1EC3n th\u1ECB {patient} v\u1EDBi {effect}",tokens:[{type:"literal",value:"hi\u1EC3n th\u1ECB",alternatives:["hi\u1EC7n"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"v\u1EDBi"},{type:"role",role:"style"}]}]},extraction:{patient:{position:1},style:{marker:"v\u1EDBi"}}},{id:"show-vi-simple",language:"vi",command:"show",priority:90,template:{format:"hi\u1EC3n th\u1ECB {patient}",tokens:[{type:"literal",value:"hi\u1EC3n th\u1ECB",alternatives:["hi\u1EC7n"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Ll(){return [{id:"show-zh-full",language:"zh",command:"show",priority:100,template:{format:"\u663E\u793A {patient}",tokens:[{type:"literal",value:"\u663E\u793A",alternatives:["\u986F\u793A","\u5C55\u793A","\u5448\u73B0","\u5448\u73FE"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"show-zh-ba",language:"zh",command:"show",priority:95,template:{format:"\u628A {patient} \u663E\u793A",tokens:[{type:"literal",value:"\u628A"},{type:"role",role:"patient"},{type:"literal",value:"\u663E\u793A",alternatives:["\u986F\u793A","\u5C55\u793A"]}]},extraction:{patient:{position:1}}},{id:"show-zh-with-\u7ED9",language:"zh",command:"show",priority:90,template:{format:"\u7ED9 {destination} \u663E\u793A {patient}",tokens:[{type:"literal",value:"\u7ED9",alternatives:["\u7D66"]},{type:"role",role:"destination"},{type:"literal",value:"\u663E\u793A",alternatives:["\u986F\u793A"]},{type:"role",role:"patient"}]},extraction:{destination:{position:1},patient:{position:3}}}]}function _l(r){switch(r){case "bn":return Al();case "de":return xl();case "fr":return Dl();case "hi":return Bl();case "it":return Sl();case "pl":return Tl();case "ru":return Fl();case "th":return Pl();case "uk":return Ol();case "vi":return Rl();case "zh":return Ll();default:return []}}var Nl=[...mi.roles.find(r=>r.role==="patient")?.expectedTypes??[]];function Ml(){return [{id:"hide-bn-full",language:"bn",command:"hide",priority:100,template:{format:"{patient} \u0995\u09C7 \u09B2\u09C1\u0995\u09BE\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u09B2\u09C1\u0995\u09BE\u09A8",alternatives:["\u09B2\u09C1\u0995\u09BE\u0993"]}]},extraction:{patient:{position:0}}},{id:"hide-bn-simple",language:"bn",command:"hide",priority:90,template:{format:"\u09B2\u09C1\u0995\u09BE\u09A8 {patient}",tokens:[{type:"literal",value:"\u09B2\u09C1\u0995\u09BE\u09A8",alternatives:["\u09B2\u09C1\u0995\u09BE\u0993"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Il(){return [{id:"hide-de-full",language:"de",command:"hide",priority:100,template:{format:"verstecke {patient}",tokens:[{type:"literal",value:"verstecke",alternatives:["verstecken","verberge","verbergen","hide"]},{type:"role",role:"patient",expectedTypes:Nl},{type:"group",optional:true,tokens:[{type:"literal",value:"mit"},{type:"role",role:"style",expectedTypes:["expression","selector"]}]}]},extraction:{patient:{position:1},style:{marker:"mit"}}}]}function $l(){return [{id:"hide-hi-full",language:"hi",command:"hide",priority:100,template:{format:"{patient} \u0915\u094B \u091B\u093F\u092A\u093E\u090F\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"literal",value:"\u091B\u093F\u092A\u093E\u090F\u0902",alternatives:["\u091B\u093F\u092A\u093E"]}]},extraction:{patient:{position:0}}},{id:"hide-hi-simple",language:"hi",command:"hide",priority:90,template:{format:"\u091B\u093F\u092A\u093E\u090F\u0902 {patient}",tokens:[{type:"literal",value:"\u091B\u093F\u092A\u093E\u090F\u0902",alternatives:["\u091B\u093F\u092A\u093E"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"hide-hi-bare",language:"hi",command:"hide",priority:80,template:{format:"\u091B\u093F\u092A\u093E\u090F\u0902",tokens:[{type:"literal",value:"\u091B\u093F\u092A\u093E\u090F\u0902",alternatives:["\u091B\u093F\u092A\u093E"]}]},extraction:{patient:{default:{type:"reference",value:"me"}}}}]}function jl(){return [{id:"hide-it-full",language:"it",command:"hide",priority:100,template:{format:"nascondere {patient} con {style}",tokens:[{type:"literal",value:"nascondere",alternatives:["nascondi","hide"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"con"},{type:"role",role:"style"}]}]},extraction:{patient:{position:1},style:{marker:"con"}}},{id:"hide-it-simple",language:"it",command:"hide",priority:90,template:{format:"nascondere {patient}",tokens:[{type:"literal",value:"nascondere",alternatives:["nascondi","hide"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Wl(){return [{id:"hide-pl-full",language:"pl",command:"hide",priority:100,template:{format:"ukryj {patient} z {style}",tokens:[{type:"literal",value:"ukryj",alternatives:["schowaj","zas\u0142o\u0144","zaslon"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"z",alternatives:["ze","jako"]},{type:"role",role:"style",expectedTypes:["literal"]}]}]},extraction:{patient:{position:1},style:{marker:"z",markerAlternatives:["ze","jako"]}}},{id:"hide-pl-simple",language:"pl",command:"hide",priority:90,template:{format:"ukryj {patient}",tokens:[{type:"literal",value:"ukryj",alternatives:["schowaj","zas\u0142o\u0144","zaslon"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function ql(){return [{id:"hide-ru-full",language:"ru",command:"hide",priority:100,template:{format:"\u0441\u043A\u0440\u044B\u0442\u044C {patient} \u0441 {style}",tokens:[{type:"literal",value:"\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"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0441",alternatives:["\u0441\u043E","\u043A\u0430\u043A"]},{type:"role",role:"style"}]}]},extraction:{patient:{position:1},style:{marker:"\u0441",markerAlternatives:["\u0441\u043E","\u043A\u0430\u043A"]}}},{id:"hide-ru-simple",language:"ru",command:"hide",priority:90,template:{format:"\u0441\u043A\u0440\u044B\u0442\u044C {patient}",tokens:[{type:"literal",value:"\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"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Vl(){return [{id:"hide-th-simple",language:"th",command:"hide",priority:100,template:{format:"\u0E0B\u0E48\u0E2D\u0E19 {patient}",tokens:[{type:"literal",value:"\u0E0B\u0E48\u0E2D\u0E19"},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0E14\u0E49\u0E27\u0E22"},{type:"role",role:"style",expectedTypes:["expression","selector"]}]}]},extraction:{patient:{position:1},style:{marker:"\u0E14\u0E49\u0E27\u0E22"}}}]}function Kl(){return [{id:"hide-uk-full",language:"uk",command:"hide",priority:100,template:{format:"\u0441\u0445\u043E\u0432\u0430\u0442\u0438 {patient} \u0437 {style}",tokens:[{type:"literal",value:"\u0441\u0445\u043E\u0432\u0430\u0442\u0438",alternatives:["\u0441\u0445\u043E\u0432\u0430\u0439","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0442\u0438","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0439"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0437",alternatives:["\u0456\u0437","\u044F\u043A"]},{type:"role",role:"style",expectedTypes:["literal"]}]}]},extraction:{patient:{position:1},style:{marker:"\u0437",markerAlternatives:["\u0456\u0437","\u044F\u043A"]}}},{id:"hide-uk-simple",language:"uk",command:"hide",priority:90,template:{format:"\u0441\u0445\u043E\u0432\u0430\u0442\u0438 {patient}",tokens:[{type:"literal",value:"\u0441\u0445\u043E\u0432\u0430\u0442\u0438",alternatives:["\u0441\u0445\u043E\u0432\u0430\u0439","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0442\u0438","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0439"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Hl(){return [{id:"hide-vi-full",language:"vi",command:"hide",priority:100,template:{format:"\u1EA9n {patient} v\u1EDBi {effect}",tokens:[{type:"literal",value:"\u1EA9n",alternatives:["che","gi\u1EA5u"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"v\u1EDBi"},{type:"role",role:"style"}]}]},extraction:{patient:{position:1},style:{marker:"v\u1EDBi"}}},{id:"hide-vi-simple",language:"vi",command:"hide",priority:90,template:{format:"\u1EA9n {patient}",tokens:[{type:"literal",value:"\u1EA9n",alternatives:["che","gi\u1EA5u"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function Ul(){return [{id:"hide-zh-full",language:"zh",command:"hide",priority:100,template:{format:"\u9690\u85CF {patient}",tokens:[{type:"literal",value:"\u9690\u85CF",alternatives:["\u96B1\u85CF","\u85CF\u8D77","\u85CF"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"hide-zh-ba",language:"zh",command:"hide",priority:95,template:{format:"\u628A {patient} \u9690\u85CF",tokens:[{type:"literal",value:"\u628A"},{type:"role",role:"patient"},{type:"literal",value:"\u9690\u85CF",alternatives:["\u96B1\u85CF","\u85CF\u8D77"]}]},extraction:{patient:{position:1}}},{id:"hide-zh-from",language:"zh",command:"hide",priority:90,template:{format:"\u4ECE {destination} \u9690\u85CF {patient}",tokens:[{type:"literal",value:"\u4ECE",alternatives:["\u5F9E"]},{type:"role",role:"destination"},{type:"literal",value:"\u9690\u85CF",alternatives:["\u96B1\u85CF"]},{type:"role",role:"patient"}]},extraction:{destination:{position:1},patient:{position:3}}}]}function Gl(r){switch(r){case "bn":return Ml();case "de":return Il();case "hi":return $l();case "it":return jl();case "pl":return Wl();case "ru":return ql();case "th":return Vl();case "uk":return Kl();case "vi":return Hl();case "zh":return Ul();default:return []}}var ye=[...Lr.roles.find(r=>r.role==="patient")?.expectedTypes??[]];function Zl(){return [{id:"set-bn-full",language:"bn",command:"set",priority:100,template:{format:"{destination} \u0995\u09C7 {patient} \u09A4\u09C7 \u09B8\u09C7\u099F",tokens:[{type:"role",role:"destination"},{type:"literal",value:"\u0995\u09C7"},{type:"role",role:"patient"},{type:"literal",value:"\u09A4\u09C7",alternatives:["\u098F"]},{type:"literal",value:"\u09B8\u09C7\u099F",alternatives:["\u09A8\u09BF\u09B0\u09CD\u09A7\u09BE\u09B0\u09A3"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0995\u09B0\u09C1\u09A8"}]}]},extraction:{destination:{position:0},patient:{marker:"\u09A4\u09C7",position:2}}},{id:"set-bn-simple",language:"bn",command:"set",priority:90,template:{format:"\u09B8\u09C7\u099F {destination} {patient}",tokens:[{type:"literal",value:"\u09B8\u09C7\u099F",alternatives:["\u09A8\u09BF\u09B0\u09CD\u09A7\u09BE\u09B0\u09A3"]},{type:"role",role:"destination"},{type:"role",role:"patient"}]},extraction:{destination:{position:1},patient:{position:2}}}]}function Yl(){return [{id:"set-de-full",language:"de",command:"set",priority:100,template:{format:"setze {destination} auf {patient}",tokens:[{type:"literal",value:"setze",alternatives:["set"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"auf",alternatives:["zu","an"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:1},patient:{position:3}}},{id:"set-de-festlegen-auf",language:"de",command:"set",priority:99,template:{format:"festlegen auf {destination} {patient}",tokens:[{type:"literal",value:"festlegen",alternatives:["einstellen"]},{type:"literal",value:"auf",alternatives:["an"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:2},patient:{position:3}}},{id:"set-de-equals",language:"de",command:"set",priority:95,template:{format:"{destination} = {patient}",tokens:[{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"="},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:0},patient:{position:2}}}]}function Xl(){return [{id:"set-es-full",language:"es",command:"set",priority:100,template:{format:"establecer {destination} a {patient}",tokens:[{type:"literal",value:"establecer",alternatives:["fijar","definir","poner","set"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"a",alternatives:["en","como"]},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]}]},extraction:{destination:{position:1},patient:{position:3}}},{id:"set-es-prep-first",language:"es",command:"set",priority:95,template:{format:"establecer en {destination} {patient}",tokens:[{type:"literal",value:"establecer",alternatives:["fijar","definir","poner","set"]},{type:"literal",value:"en",alternatives:["a"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]}]},extraction:{destination:{position:2},patient:{position:3}}},{id:"set-es-equals",language:"es",command:"set",priority:95,template:{format:"{destination} = {patient}",tokens:[{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"="},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]}]},extraction:{destination:{position:0},patient:{position:2}}}]}function Jl(){return [{id:"set-fr-full",language:"fr",command:"set",priority:100,template:{format:"d\xE9finir {destination} \xE0 {patient}",tokens:[{type:"literal",value:"d\xE9finir",alternatives:["definir","fixer","set"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"\xE0",alternatives:["a","sur","comme"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:1},patient:{position:3}}},{id:"set-fr-sur-direct",language:"fr",command:"set",priority:98,template:{format:"d\xE9finir sur {destination} {patient}",tokens:[{type:"literal",value:"d\xE9finir",alternatives:["definir","mettre","fixer"]},{type:"literal",value:"sur",alternatives:["\xE0","en"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:2},patient:{position:3}}},{id:"set-fr-equals",language:"fr",command:"set",priority:95,template:{format:"{destination} = {patient}",tokens:[{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"="},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:0},patient:{position:2}}}]}function Ql(){return [{id:"set-hi-full",language:"hi",command:"set",priority:100,template:{format:"{destination} \u0915\u094B {patient} \u0938\u0947\u091F \u0915\u0930\u0947\u0902",tokens:[{type:"role",role:"destination"},{type:"literal",value:"\u0915\u094B"},{type:"role",role:"patient"},{type:"literal",value:"\u0938\u0947\u091F",alternatives:["\u0928\u093F\u0930\u094D\u0927\u093E\u0930\u093F\u0924"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0915\u0930\u0947\u0902",alternatives:["\u0915\u0930\u094B"]}]}]},extraction:{destination:{position:0},patient:{marker:"\u0915\u094B",position:2}}},{id:"set-hi-simple",language:"hi",command:"set",priority:90,template:{format:"\u0938\u0947\u091F {destination} {patient}",tokens:[{type:"literal",value:"\u0938\u0947\u091F",alternatives:["\u0928\u093F\u0930\u094D\u0927\u093E\u0930\u093F\u0924"]},{type:"role",role:"destination"},{type:"role",role:"patient"}]},extraction:{destination:{position:1},patient:{position:2}}}]}function e0(){return [{id:"set-id-full",language:"id",command:"set",priority:100,template:{format:"atur {destination} ke {patient}",tokens:[{type:"literal",value:"atur",alternatives:["tetapkan","setel","set"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"ke",alternatives:["menjadi","jadi","pada"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:1},patient:{position:3}}},{id:"set-id-pada-direct",language:"id",command:"set",priority:98,template:{format:"atur pada {destination} {patient}",tokens:[{type:"literal",value:"atur",alternatives:["tetapkan","setel"]},{type:"literal",value:"pada",alternatives:["ke","di"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:2},patient:{position:3}}},{id:"set-id-equals",language:"id",command:"set",priority:95,template:{format:"{destination} = {patient}",tokens:[{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"="},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:0},patient:{position:2}}}]}function t0(){return [{id:"set-ms-full",language:"ms",command:"set",priority:100,template:{format:"tetapkan {destination} ke {patient}",tokens:[{type:"literal",value:"tetapkan",alternatives:["setkan","set"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"ke",alternatives:["kepada","menjadi","jadi"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:1},patient:{position:3}}}]}function r0(){return [{id:"set-it-full",language:"it",command:"set",priority:100,template:{format:"impostare {destination} a {patient}",tokens:[{type:"literal",value:"impostare",alternatives:["imposta","set","definire"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"a",alternatives:["su","come","in"]},{type:"role",role:"patient"}]}]},extraction:{destination:{position:1},patient:{marker:"a",markerAlternatives:["su","come","in"]}}},{id:"set-it-simple",language:"it",command:"set",priority:90,template:{format:"impostare {destination}",tokens:[{type:"literal",value:"impostare",alternatives:["imposta","set"]},{type:"role",role:"destination"}]},extraction:{destination:{position:1}}}]}function a0(){return [{id:"set-pl-full",language:"pl",command:"set",priority:100,template:{format:"ustaw {destination} na {patient}",tokens:[{type:"literal",value:"ustaw",alternatives:["okre\u015Bl","okresl","przypisz"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"na",alternatives:["do","jako"]},{type:"role",role:"patient"}]}]},extraction:{destination:{position:1},patient:{marker:"na",markerAlternatives:["do","jako"]}}},{id:"set-pl-simple",language:"pl",command:"set",priority:90,template:{format:"ustaw {destination}",tokens:[{type:"literal",value:"ustaw",alternatives:["okre\u015Bl","okresl"]},{type:"role",role:"destination"}]},extraction:{destination:{position:1}}}]}function i0(){return [{id:"set-pt-full",language:"pt",command:"set",priority:100,template:{format:"definir {destination} para {patient}",tokens:[{type:"literal",value:"definir",alternatives:["estabelecer","set"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"para",alternatives:["como","a","em"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:1},patient:{position:3}}},{id:"set-pt-em-direct",language:"pt",command:"set",priority:98,template:{format:"definir em {destination} {patient}",tokens:[{type:"literal",value:"definir",alternatives:["estabelecer"]},{type:"literal",value:"em",alternatives:["para","a"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:2},patient:{position:3}}},{id:"set-pt-equals",language:"pt",command:"set",priority:95,template:{format:"{destination} = {patient}",tokens:[{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"="},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:0},patient:{position:2}}}]}function n0(){return [{id:"set-ru-full",language:"ru",command:"set",priority:100,template:{format:"\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C {destination} \u0432 {patient}",tokens:[{type:"literal",value:"\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"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0432",alternatives:["\u043D\u0430","\u043A\u0430\u043A"]},{type:"role",role:"patient"}]}]},extraction:{destination:{position:1},patient:{marker:"\u0432",markerAlternatives:["\u043D\u0430","\u043A\u0430\u043A"]}}},{id:"set-ru-simple",language:"ru",command:"set",priority:90,template:{format:"\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C {destination}",tokens:[{type:"literal",value:"\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"]},{type:"role",role:"destination"}]},extraction:{destination:{position:1}}}]}function o0(){return [{id:"set-sw-kwa",language:"sw",command:"set",priority:100,template:{format:"seti {destination} kwa {patient}",tokens:[{type:"literal",value:"seti",alternatives:["weka thamani"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"kwa",alternatives:["kwenye"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{position:1},patient:{marker:"kwa",markerAlternatives:["kwenye"]}}}]}function u0(){return [{id:"set-th-simple",language:"th",command:"set",priority:100,template:{format:"\u0E15\u0E31\u0E49\u0E07 {destination} \u0E43\u0E19 {patient}",tokens:[{type:"literal",value:"\u0E15\u0E31\u0E49\u0E07",alternatives:["\u0E01\u0E33\u0E2B\u0E19\u0E14","\u0E15\u0E31\u0E49\u0E07\u0E04\u0E48\u0E32"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0E43\u0E19",alternatives:["\u0E40\u0E1B\u0E47\u0E19"]},{type:"role",role:"patient"}]}]},extraction:{destination:{position:1},patient:{marker:"\u0E43\u0E19",markerAlternatives:["\u0E40\u0E1B\u0E47\u0E19"]}}}]}function s0(){return [{id:"set-uk-full",language:"uk",command:"set",priority:100,template:{format:"\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0438 {destination} \u0432 {patient}",tokens:[{type:"literal",value:"\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0438",alternatives:["\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0437\u0430\u0434\u0430\u0442\u0438","\u0437\u0430\u0434\u0430\u0439"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0432",alternatives:["\u043D\u0430","\u044F\u043A"]},{type:"role",role:"patient"}]}]},extraction:{destination:{position:1},patient:{marker:"\u0432",markerAlternatives:["\u043D\u0430","\u044F\u043A"]}}},{id:"set-uk-simple",language:"uk",command:"set",priority:90,template:{format:"\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0438 {destination}",tokens:[{type:"literal",value:"\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0438",alternatives:["\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0437\u0430\u0434\u0430\u0442\u0438","\u0437\u0430\u0434\u0430\u0439"]},{type:"role",role:"destination"}]},extraction:{destination:{position:1}}}]}function l0(){return [{id:"set-he-full",language:"he",command:"set",priority:100,template:{format:"\u05E7\u05D1\u05E2 \u05D0\u05EA {destination} \u05E2\u05DC {patient}",tokens:[{type:"literal",value:"\u05E7\u05D1\u05E2",alternatives:["\u05D4\u05D2\u05D3\u05E8"]},{type:"literal",value:"\u05D0\u05EA"},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"\u05E2\u05DC",alternatives:["\u05D1","\u05D0\u05DC","\u05DC","\u05DB"]},{type:"role",role:"patient",expectedTypes:ye}]},extraction:{destination:{marker:"\u05D0\u05EA"},patient:{marker:"\u05E2\u05DC",markerAlternatives:["\u05D1","\u05D0\u05DC","\u05DC","\u05DB"]}}}]}function c0(){return [{id:"set-vi-vao",language:"vi",command:"set",priority:101,template:{format:"g\xE1n {destination} v\xE0o {patient}",tokens:[{type:"literal",value:"g\xE1n",alternatives:["thi\u1EBFt l\u1EADp","\u0111\u1EB7t gi\xE1 tr\u1ECB"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"v\xE0o",alternatives:["cho","\u0111\u1EBFn"]},{type:"role",role:"patient",expectedTypes:["literal","expression","reference","selector"]}]},extraction:{destination:{position:1},patient:{marker:"v\xE0o",markerAlternatives:["cho","\u0111\u1EBFn"]}}},{id:"set-vi-full",language:"vi",command:"set",priority:100,template:{format:"g\xE1n {destination} th\xE0nh {patient}",tokens:[{type:"literal",value:"g\xE1n",alternatives:["thi\u1EBFt l\u1EADp","\u0111\u1EB7t gi\xE1 tr\u1ECB"]},{type:"role",role:"patient"},{type:"literal",value:"th\xE0nh",alternatives:["b\u1EB1ng","l\xE0"]},{type:"role",role:"goal"}]},extraction:{patient:{position:1},goal:{marker:"th\xE0nh",markerAlternatives:["b\u1EB1ng","l\xE0"]}}},{id:"set-vi-simple",language:"vi",command:"set",priority:90,template:{format:"\u0111\u1EB7t {destination} l\xE0 {patient}",tokens:[{type:"literal",value:"\u0111\u1EB7t"},{type:"role",role:"patient"},{type:"literal",value:"l\xE0"},{type:"role",role:"goal"}]},extraction:{patient:{position:1},goal:{marker:"l\xE0"}}}]}function p0(){return [{id:"set-zh-full",language:"zh",command:"set",priority:100,template:{format:"\u8BBE\u7F6E {destination} \u5230 {patient}",tokens:[{type:"literal",value:"\u8BBE\u7F6E",alternatives:["\u8A2D\u7F6E","\u8BBE\u5B9A","\u8A2D\u5B9A"]},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"\u5230",alternatives:["\u4E3A","\u70BA","\u6210"]},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]}]},extraction:{destination:{position:1},patient:{marker:"\u5230",markerAlternatives:["\u4E3A","\u70BA","\u6210"]}}},{id:"set-zh-ba",language:"zh",command:"set",priority:95,template:{format:"\u628A {destination} \u8BBE\u7F6E \u5230 {patient}",tokens:[{type:"literal",value:"\u628A"},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"\u8BBE\u7F6E",alternatives:["\u8A2D\u7F6E","\u8BBE\u5B9A","\u8A2D\u5B9A","\u8BBE\u7F6E\u4E3A","\u8A2D\u7F6E\u70BA","\u8BBE\u5B9A\u4E3A","\u8A2D\u5B9A\u70BA"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u5230",alternatives:["\u4E3A","\u70BA","\u6210"]}]},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]}]},extraction:{destination:{position:1},patient:{marker:"\u5230",markerAlternatives:["\u4E3A","\u70BA","\u6210"]}}},{id:"set-zh-vba",language:"zh",command:"set",priority:96,template:{format:"\u8BBE\u7F6E \u628A {destination} \u5230 {patient}",tokens:[{type:"literal",value:"\u8BBE\u7F6E",alternatives:["\u8A2D\u7F6E","\u8BBE\u5B9A","\u8A2D\u5B9A"]},{type:"literal",value:"\u628A"},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u5230",alternatives:["\u4E3A","\u70BA","\u6210"]}]},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]}]},extraction:{destination:{position:2},patient:{marker:"\u5230",markerAlternatives:["\u4E3A","\u70BA","\u6210"]}}},{id:"set-zh-simple",language:"zh",command:"set",priority:90,template:{format:"{destination} = {patient}",tokens:[{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"="},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]}]},extraction:{destination:{position:0},patient:{position:2}}}]}function d0(){return [{id:"set-qu-oblique-source",language:"qu",command:"set",priority:105,template:{format:"{destination} ta {source} manta {patient} man churanay",tokens:[{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"ta"},{type:"role",role:"source",expectedTypes:["selector","reference","expression"]},{type:"literal",value:"manta"},{type:"role",role:"patient",expectedTypes:["literal","expression","reference"]},{type:"literal",value:"man"},{type:"literal",value:"churanay",alternatives:["kamaykuy"]}]},extraction:{destination:{position:0},source:{position:2},patient:{position:4}}}]}function oe(r){return r.map(e=>e.extraction?.scope?e:{...e,template:{...e.template,tokens:[...e.template.tokens,{type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}]},extraction:{...e.extraction,scope:{marker:"on"}}})}function m0(r){switch(r){case "bn":return oe(Zl());case "de":return oe(Yl());case "es":return oe(Xl());case "fr":return oe(Jl());case "he":return oe(l0());case "hi":return oe(Ql());case "id":return oe(e0());case "ms":return oe(t0());case "it":return oe(r0());case "pl":return oe(a0());case "pt":return oe(i0());case "qu":return oe(d0());case "ru":return oe(n0());case "sw":return oe(o0());case "th":return oe(u0());case "uk":return oe(s0());case "vi":return oe(c0());case "zh":return oe(p0());default:return []}}var hi=[...fi.roles.find(r=>r.role==="source")?.expectedTypes??[]];function f0(){return [{id:"get-bn-full",language:"bn",command:"get",priority:100,template:{format:"{source} \u09A5\u09C7\u0995\u09C7 \u09AA\u09BE\u09A8",tokens:[{type:"role",role:"source"},{type:"literal",value:"\u09A5\u09C7\u0995\u09C7"},{type:"literal",value:"\u09AA\u09BE\u09A8"}]},extraction:{source:{position:0}}},{id:"get-bn-simple",language:"bn",command:"get",priority:90,template:{format:"\u09AA\u09BE\u09A8 {source}",tokens:[{type:"literal",value:"\u09AA\u09BE\u09A8"},{type:"role",role:"source"}]},extraction:{source:{position:1}}}]}function y0(){return [{id:"get-de-full",language:"de",command:"get",priority:100,template:{format:"hole {source}",tokens:[{type:"literal",value:"hole",alternatives:["holen","get","bekomme","bekommen"]},{type:"role",role:"source",expectedTypes:hi}]},extraction:{source:{position:1}}}]}function v0(){return [{id:"get-hi-full",language:"hi",command:"get",priority:100,template:{format:"{source} \u0938\u0947 \u092A\u094D\u0930\u093E\u092A\u094D\u0924 \u0915\u0930\u0947\u0902",tokens:[{type:"role",role:"source"},{type:"literal",value:"\u0938\u0947"},{type:"literal",value:"\u092A\u094D\u0930\u093E\u092A\u094D\u0924",alternatives:["\u092A\u093E\u090F\u0902"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0915\u0930\u0947\u0902",alternatives:["\u0915\u0930\u094B"]}]}]},extraction:{source:{position:0}}},{id:"get-hi-simple",language:"hi",command:"get",priority:90,template:{format:"\u092A\u094D\u0930\u093E\u092A\u094D\u0924 {source}",tokens:[{type:"literal",value:"\u092A\u094D\u0930\u093E\u092A\u094D\u0924",alternatives:["\u092A\u093E\u090F\u0902"]},{type:"role",role:"source"}]},extraction:{source:{position:1}}}]}function h0(){return [{id:"get-it-full",language:"it",command:"get",priority:100,template:{format:"ottenere {patient} da {source}",tokens:[{type:"literal",value:"ottenere",alternatives:["ottieni","get"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"da",alternatives:["di"]},{type:"role",role:"source"}]}]},extraction:{patient:{position:1},source:{marker:"da",markerAlternatives:["di"]}}},{id:"get-it-simple",language:"it",command:"get",priority:90,template:{format:"ottenere {patient}",tokens:[{type:"literal",value:"ottenere",alternatives:["ottieni","get"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function E0(){return [{id:"get-pl-full",language:"pl",command:"get",priority:100,template:{format:"uzyskaj {patient} z {source}",tokens:[{type:"literal",value:"uzyskaj"},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"z",alternatives:["od","ze"]},{type:"role",role:"source"}]}]},extraction:{patient:{position:1},source:{marker:"z",markerAlternatives:["od","ze"]}}},{id:"get-pl-simple",language:"pl",command:"get",priority:90,template:{format:"uzyskaj {patient}",tokens:[{type:"literal",value:"uzyskaj"},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function g0(){return [{id:"get-ru-full",language:"ru",command:"get",priority:100,template:{format:"\u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C {patient} \u0438\u0437 {source}",tokens:[{type:"literal",value:"\u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C",alternatives:["\u043F\u043E\u043B\u0443\u0447\u0438"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0438\u0437",alternatives:["\u043E\u0442","\u0441"]},{type:"role",role:"source"}]}]},extraction:{patient:{position:1},source:{marker:"\u0438\u0437",markerAlternatives:["\u043E\u0442","\u0441"]}}},{id:"get-ru-simple",language:"ru",command:"get",priority:90,template:{format:"\u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C {patient}",tokens:[{type:"literal",value:"\u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C",alternatives:["\u043F\u043E\u043B\u0443\u0447\u0438"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function k0(){return [{id:"get-th-simple",language:"th",command:"get",priority:100,template:{format:"\u0E23\u0E31\u0E1A\u0E04\u0E48\u0E32 {source}",tokens:[{type:"literal",value:"\u0E23\u0E31\u0E1A\u0E04\u0E48\u0E32"},{type:"role",role:"source"}]},extraction:{source:{position:1}}}]}function w0(){return [{id:"get-uk-full",language:"uk",command:"get",priority:100,template:{format:"\u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438 {patient} \u0437 {source}",tokens:[{type:"literal",value:"\u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438",alternatives:["\u043E\u0442\u0440\u0438\u043C\u0430\u0439"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0437",alternatives:["\u0432\u0456\u0434","\u0456\u0437"]},{type:"role",role:"source"}]}]},extraction:{patient:{position:1},source:{marker:"\u0437",markerAlternatives:["\u0432\u0456\u0434","\u0456\u0437"]}}},{id:"get-uk-simple",language:"uk",command:"get",priority:90,template:{format:"\u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438 {patient}",tokens:[{type:"literal",value:"\u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438",alternatives:["\u043E\u0442\u0440\u0438\u043C\u0430\u0439"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function z0(){return [{id:"get-vi-full",language:"vi",command:"get",priority:92,template:{format:"l\u1EA5y gi\xE1 tr\u1ECB c\u1EE7a {target}",tokens:[{type:"literal",value:"l\u1EA5y gi\xE1 tr\u1ECB",alternatives:["nh\u1EADn"]},{type:"group",optional:true,tokens:[{type:"literal",value:"c\u1EE7a"}]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"get-vi-simple",language:"vi",command:"get",priority:90,template:{format:"l\u1EA5y gi\xE1 tr\u1ECB {target}",tokens:[{type:"literal",value:"l\u1EA5y gi\xE1 tr\u1ECB",alternatives:["nh\u1EADn"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function b0(){return [{id:"get-zh-ba",language:"zh",command:"get",priority:105,template:{format:"\u83B7\u53D6 \u628A {source}",tokens:[{type:"literal",value:"\u83B7\u53D6",alternatives:["\u83B7\u5F97","\u53D6\u5F97"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u628A",alternatives:["\u4ECE","\u7531"]}]},{type:"role",role:"source",expectedTypes:hi}]},extraction:{source:{marker:"\u628A",markerAlternatives:["\u4ECE","\u7531"]}}}]}function C0(r){switch(r){case "bn":return f0();case "de":return y0();case "zh":return b0();case "hi":return v0();case "it":return h0();case "pl":return E0();case "ru":return g0();case "th":return k0();case "uk":return w0();case "vi":return z0();default:return []}}var lt=["selector","reference","expression","property-path"];function A0(){return [{id:"increment-bn-full",language:"bn",command:"increment",priority:100,template:{format:"{patient} \u0995\u09C7 \u09AC\u09C3\u09A6\u09CD\u09A7\u09BF \u0995\u09B0\u09C1\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u09AC\u09C3\u09A6\u09CD\u09A7\u09BF",alternatives:["\u09AC\u09BE\u09A1\u09BC\u09BE\u09A8"]},{type:"literal",value:"\u0995\u09B0\u09C1\u09A8"}]},extraction:{patient:{position:0}}},{id:"increment-bn-with-quantity",language:"bn",command:"increment",priority:95,template:{format:"{patient} \u0995\u09C7 {quantity} \u09A6\u09BF\u09AF\u09BC\u09C7 \u09AC\u09C3\u09A6\u09CD\u09A7\u09BF \u0995\u09B0\u09C1\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"role",role:"quantity"},{type:"literal",value:"\u09A6\u09BF\u09AF\u09BC\u09C7"},{type:"literal",value:"\u09AC\u09C3\u09A6\u09CD\u09A7\u09BF",alternatives:["\u09AC\u09BE\u09A1\u09BC\u09BE\u09A8"]},{type:"literal",value:"\u0995\u09B0\u09C1\u09A8"}]},extraction:{patient:{position:0},quantity:{marker:"\u09A6\u09BF\u09AF\u09BC\u09C7",position:2}}},{id:"increment-bn-simple",language:"bn",command:"increment",priority:90,template:{format:"\u09AC\u09C3\u09A6\u09CD\u09A7\u09BF {patient}",tokens:[{type:"literal",value:"\u09AC\u09C3\u09A6\u09CD\u09A7\u09BF",alternatives:["\u09AC\u09BE\u09A1\u09BC\u09BE\u09A8"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function x0(){let r=["erhoehe","erh\xF6hen","inkrementiere","inkrementieren","increment"];return [{id:"increment-de-with-quantity",language:"de",command:"increment",priority:105,template:{format:"erh\xF6he {patient} um {quantity}",tokens:[{type:"literal",value:"erh\xF6he",alternatives:r},{type:"role",role:"patient",expectedTypes:lt},{type:"literal",value:"um"},{type:"role",role:"quantity"}]},extraction:{patient:{position:1},quantity:{marker:"um",position:3}}},{id:"increment-de-full",language:"de",command:"increment",priority:100,template:{format:"erh\xF6he {patient}",tokens:[{type:"literal",value:"erh\xF6he",alternatives:r},{type:"role",role:"patient",expectedTypes:lt}]},extraction:{patient:{position:1}}}]}function D0(){return [{id:"increment-hi-full",language:"hi",command:"increment",priority:100,template:{format:"{patient} \u0915\u094B \u092C\u0922\u093C\u093E\u090F\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"literal",value:"\u092C\u0922\u093C\u093E\u090F\u0902",alternatives:["\u092C\u0922\u093C\u093E"]}]},extraction:{patient:{position:0}}},{id:"increment-hi-with-quantity",language:"hi",command:"increment",priority:95,template:{format:"{patient} \u0915\u094B {quantity} \u0938\u0947 \u092C\u0922\u093C\u093E\u090F\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"role",role:"quantity"},{type:"literal",value:"\u0938\u0947"},{type:"literal",value:"\u092C\u0922\u093C\u093E\u090F\u0902",alternatives:["\u092C\u0922\u093C\u093E"]}]},extraction:{patient:{position:0},quantity:{marker:"\u0938\u0947",position:2}}},{id:"increment-hi-simple",language:"hi",command:"increment",priority:90,template:{format:"\u092C\u0922\u093C\u093E\u090F\u0902 {patient}",tokens:[{type:"literal",value:"\u092C\u0922\u093C\u093E\u090F\u0902",alternatives:["\u092C\u0922\u093C\u093E"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function B0(){return [{id:"increment-it-full",language:"it",command:"increment",priority:100,template:{format:"incrementare {patient} di {quantity}",tokens:[{type:"literal",value:"incrementare",alternatives:["incrementa","aumentare","increment"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"di",alternatives:["per"]},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"di",markerAlternatives:["per"],default:{type:"literal",value:1}}}},{id:"increment-it-simple",language:"it",command:"increment",priority:90,template:{format:"incrementare {patient}",tokens:[{type:"literal",value:"incrementare",alternatives:["incrementa","aumentare","increment"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:1}}}}]}function S0(){return [{id:"increment-pl-full",language:"pl",command:"increment",priority:100,template:{format:"zwi\u0119ksz {patient} o {quantity}",tokens:[{type:"literal",value:"zwi\u0119ksz",alternatives:["zwieksz","podnie\u015B","podnies"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"o"},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"o",default:{type:"literal",value:1}}}},{id:"increment-pl-simple",language:"pl",command:"increment",priority:90,template:{format:"zwi\u0119ksz {patient}",tokens:[{type:"literal",value:"zwi\u0119ksz",alternatives:["zwieksz","podnie\u015B","podnies"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:1}}}}]}function T0(){return [{id:"increment-ru-full",language:"ru",command:"increment",priority:100,template:{format:"\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C {patient} \u043D\u0430 {quantity}",tokens:[{type:"literal",value:"\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C",alternatives:["\u0443\u0432\u0435\u043B\u0438\u0447\u044C"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u043D\u0430"},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"\u043D\u0430",default:{type:"literal",value:1}}}},{id:"increment-ru-simple",language:"ru",command:"increment",priority:90,template:{format:"\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C {patient}",tokens:[{type:"literal",value:"\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C",alternatives:["\u0443\u0432\u0435\u043B\u0438\u0447\u044C"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:1}}}}]}function F0(){return [{id:"increment-th-simple",language:"th",command:"increment",priority:90,template:{format:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E04\u0E48\u0E32 {patient}",tokens:[{type:"literal",value:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E04\u0E48\u0E32"},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"increment-th-with-quantity",language:"th",command:"increment",priority:95,template:{format:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E04\u0E48\u0E32 {patient} \u0E14\u0E49\u0E27\u0E22 {quantity}",tokens:[{type:"literal",value:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E04\u0E48\u0E32"},{type:"role",role:"patient"},{type:"literal",value:"\u0E14\u0E49\u0E27\u0E22"},{type:"role",role:"quantity"}]},extraction:{patient:{position:1},quantity:{marker:"\u0E14\u0E49\u0E27\u0E22",position:3}}}]}function P0(){return [{id:"increment-uk-full",language:"uk",command:"increment",priority:100,template:{format:"\u0437\u0431\u0456\u043B\u044C\u0448\u0438\u0442\u0438 {patient} \u043D\u0430 {quantity}",tokens:[{type:"literal",value:"\u0437\u0431\u0456\u043B\u044C\u0448\u0438\u0442\u0438",alternatives:["\u0437\u0431\u0456\u043B\u044C\u0448"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u043D\u0430"},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"\u043D\u0430",default:{type:"literal",value:1}}}},{id:"increment-uk-simple",language:"uk",command:"increment",priority:90,template:{format:"\u0437\u0431\u0456\u043B\u044C\u0448\u0438\u0442\u0438 {patient}",tokens:[{type:"literal",value:"\u0437\u0431\u0456\u043B\u044C\u0448\u0438\u0442\u0438",alternatives:["\u0437\u0431\u0456\u043B\u044C\u0448"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:1}}}}]}function O0(){return [{id:"increment-vi-full",language:"vi",command:"increment",priority:100,template:{format:"t\u0103ng {target} th\xEAm {amount}",tokens:[{type:"literal",value:"t\u0103ng",alternatives:["t\u0103ng l\xEAn"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"th\xEAm",alternatives:["l\xEAn"]},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"th\xEAm",markerAlternatives:["l\xEAn"],default:{type:"literal",value:1}}}},{id:"increment-vi-simple",language:"vi",command:"increment",priority:90,template:{format:"t\u0103ng {target}",tokens:[{type:"literal",value:"t\u0103ng",alternatives:["t\u0103ng l\xEAn"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:1}}}}]}function R0(){return [{id:"increment-qu-sov",language:"qu",command:"increment",priority:100,template:{format:"{patient} ta yapachiy",tokens:[{type:"role",role:"patient"},{type:"literal",value:"ta"},{type:"literal",value:"yapachiy"}]},extraction:{patient:{position:0},quantity:{default:{type:"literal",value:1}}}},{id:"increment-qu-simple",language:"qu",command:"increment",priority:90,template:{format:"yapachiy {patient}",tokens:[{type:"literal",value:"yapachiy"},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:1}}}}]}function L0(){return [{id:"increment-zh-full",language:"zh",command:"increment",priority:100,template:{format:"\u589E\u52A0 {patient}",tokens:[{type:"literal",value:"\u589E\u52A0",alternatives:["\u9012\u589E","\u52A0","\u589E","increment"]},{type:"role",role:"patient",expectedTypes:lt}]},extraction:{patient:{position:1}}}]}function _0(r){switch(r){case "bn":return A0();case "de":return x0();case "hi":return D0();case "it":return B0();case "pl":return S0();case "ru":return T0();case "th":return F0();case "uk":return P0();case "qu":return R0();case "vi":return O0();case "zh":return L0();default:return []}}function N0(){return [{id:"decrement-bn-full",language:"bn",command:"decrement",priority:100,template:{format:"{patient} \u0995\u09C7 \u09B9\u09CD\u09B0\u09BE\u09B8 \u0995\u09B0\u09C1\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"literal",value:"\u09B9\u09CD\u09B0\u09BE\u09B8",alternatives:["\u0995\u09AE\u09BE\u09A8"]},{type:"literal",value:"\u0995\u09B0\u09C1\u09A8"}]},extraction:{patient:{position:0}}},{id:"decrement-bn-with-quantity",language:"bn",command:"decrement",priority:95,template:{format:"{patient} \u0995\u09C7 {quantity} \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B9\u09CD\u09B0\u09BE\u09B8 \u0995\u09B0\u09C1\u09A8",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0995\u09C7"},{type:"role",role:"quantity"},{type:"literal",value:"\u09A6\u09BF\u09AF\u09BC\u09C7"},{type:"literal",value:"\u09B9\u09CD\u09B0\u09BE\u09B8",alternatives:["\u0995\u09AE\u09BE\u09A8"]},{type:"literal",value:"\u0995\u09B0\u09C1\u09A8"}]},extraction:{patient:{position:0},quantity:{marker:"\u09A6\u09BF\u09AF\u09BC\u09C7",position:2}}},{id:"decrement-bn-simple",language:"bn",command:"decrement",priority:90,template:{format:"\u09B9\u09CD\u09B0\u09BE\u09B8 {patient}",tokens:[{type:"literal",value:"\u09B9\u09CD\u09B0\u09BE\u09B8",alternatives:["\u0995\u09AE\u09BE\u09A8"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function M0(){let r=["verringern","dekrementiere","dekrementieren","reduziere","decrement"];return [{id:"decrement-de-with-quantity",language:"de",command:"decrement",priority:105,template:{format:"verringere {patient} um {quantity}",tokens:[{type:"literal",value:"verringere",alternatives:r},{type:"role",role:"patient",expectedTypes:lt},{type:"literal",value:"um"},{type:"role",role:"quantity"}]},extraction:{patient:{position:1},quantity:{marker:"um",position:3}}},{id:"decrement-de-full",language:"de",command:"decrement",priority:100,template:{format:"verringere {patient}",tokens:[{type:"literal",value:"verringere",alternatives:r},{type:"role",role:"patient",expectedTypes:lt}]},extraction:{patient:{position:1}}}]}function I0(){return [{id:"decrement-hi-full",language:"hi",command:"decrement",priority:100,template:{format:"{patient} \u0915\u094B \u0918\u091F\u093E\u090F\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"literal",value:"\u0918\u091F\u093E\u090F\u0902",alternatives:["\u0918\u091F\u093E"]}]},extraction:{patient:{position:0}}},{id:"decrement-hi-with-quantity",language:"hi",command:"decrement",priority:95,template:{format:"{patient} \u0915\u094B {quantity} \u0938\u0947 \u0918\u091F\u093E\u090F\u0902",tokens:[{type:"role",role:"patient"},{type:"literal",value:"\u0915\u094B"},{type:"role",role:"quantity"},{type:"literal",value:"\u0938\u0947"},{type:"literal",value:"\u0918\u091F\u093E\u090F\u0902",alternatives:["\u0918\u091F\u093E"]}]},extraction:{patient:{position:0},quantity:{marker:"\u0938\u0947",position:2}}},{id:"decrement-hi-simple",language:"hi",command:"decrement",priority:90,template:{format:"\u0918\u091F\u093E\u090F\u0902 {patient}",tokens:[{type:"literal",value:"\u0918\u091F\u093E\u090F\u0902",alternatives:["\u0918\u091F\u093E"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}}]}function $0(){return [{id:"decrement-it-full",language:"it",command:"decrement",priority:100,template:{format:"decrementare {patient} di {quantity}",tokens:[{type:"literal",value:"decrementare",alternatives:["decrementa","diminuire","decrement"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"di",alternatives:["per"]},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"di",markerAlternatives:["per"],default:{type:"literal",value:"1"}}}},{id:"decrement-it-simple",language:"it",command:"decrement",priority:90,template:{format:"decrementare {patient}",tokens:[{type:"literal",value:"decrementare",alternatives:["decrementa","diminuire","decrement"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:"1"}}}}]}function j0(){return [{id:"decrement-pl-full",language:"pl",command:"decrement",priority:100,template:{format:"zmniejsz {patient} o {quantity}",tokens:[{type:"literal",value:"zmniejsz",alternatives:["obni\u017C","obniz"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"o"},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"o",default:{type:"literal",value:1}}}},{id:"decrement-pl-simple",language:"pl",command:"decrement",priority:90,template:{format:"zmniejsz {patient}",tokens:[{type:"literal",value:"zmniejsz",alternatives:["obni\u017C","obniz"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:1}}}}]}function W0(){return [{id:"decrement-ru-full",language:"ru",command:"decrement",priority:100,template:{format:"\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C {patient} \u043D\u0430 {quantity}",tokens:[{type:"literal",value:"\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C",alternatives:["\u0443\u043C\u0435\u043D\u044C\u0448\u0438"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u043D\u0430"},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"\u043D\u0430",default:{type:"literal",value:1}}}},{id:"decrement-ru-simple",language:"ru",command:"decrement",priority:90,template:{format:"\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C {patient}",tokens:[{type:"literal",value:"\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C",alternatives:["\u0443\u043C\u0435\u043D\u044C\u0448\u0438"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:1}}}}]}function q0(){return [{id:"decrement-th-simple",language:"th",command:"decrement",priority:90,template:{format:"\u0E25\u0E14\u0E04\u0E48\u0E32 {patient}",tokens:[{type:"literal",value:"\u0E25\u0E14\u0E04\u0E48\u0E32"},{type:"role",role:"patient"}]},extraction:{patient:{position:1}}},{id:"decrement-th-with-quantity",language:"th",command:"decrement",priority:95,template:{format:"\u0E25\u0E14\u0E04\u0E48\u0E32 {patient} \u0E14\u0E49\u0E27\u0E22 {quantity}",tokens:[{type:"literal",value:"\u0E25\u0E14\u0E04\u0E48\u0E32"},{type:"role",role:"patient"},{type:"literal",value:"\u0E14\u0E49\u0E27\u0E22"},{type:"role",role:"quantity"}]},extraction:{patient:{position:1},quantity:{marker:"\u0E14\u0E49\u0E27\u0E22",position:3}}}]}function V0(){return [{id:"decrement-uk-full",language:"uk",command:"decrement",priority:100,template:{format:"\u0437\u043C\u0435\u043D\u0448\u0438\u0442\u0438 {patient} \u043D\u0430 {quantity}",tokens:[{type:"literal",value:"\u0437\u043C\u0435\u043D\u0448\u0438\u0442\u0438",alternatives:["\u0437\u043C\u0435\u043D\u0448"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u043D\u0430"},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"\u043D\u0430",default:{type:"literal",value:1}}}},{id:"decrement-uk-simple",language:"uk",command:"decrement",priority:90,template:{format:"\u0437\u043C\u0435\u043D\u0448\u0438\u0442\u0438 {patient}",tokens:[{type:"literal",value:"\u0437\u043C\u0435\u043D\u0448\u0438\u0442\u0438",alternatives:["\u0437\u043C\u0435\u043D\u0448"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:1}}}}]}function K0(){return [{id:"decrement-vi-full",language:"vi",command:"decrement",priority:100,template:{format:"gi\u1EA3m {target} \u0111i {amount}",tokens:[{type:"literal",value:"gi\u1EA3m",alternatives:["gi\u1EA3m \u0111i"]},{type:"role",role:"patient"},{type:"group",optional:true,tokens:[{type:"literal",value:"\u0111i",alternatives:["xu\u1ED1ng"]},{type:"role",role:"quantity"}]}]},extraction:{patient:{position:1},quantity:{marker:"\u0111i",markerAlternatives:["xu\u1ED1ng"],default:{type:"literal",value:"1"}}}},{id:"decrement-vi-simple",language:"vi",command:"decrement",priority:90,template:{format:"gi\u1EA3m {target}",tokens:[{type:"literal",value:"gi\u1EA3m",alternatives:["gi\u1EA3m \u0111i"]},{type:"role",role:"patient"}]},extraction:{patient:{position:1},quantity:{default:{type:"literal",value:"1"}}}}]}function H0(){return [{id:"decrement-zh-full",language:"zh",command:"decrement",priority:100,template:{format:"\u51CF\u5C11 {patient}",tokens:[{type:"literal",value:"\u51CF\u5C11",alternatives:["\u9012\u51CF","\u51CF","\u964D\u4F4E","decrement"]},{type:"role",role:"patient",expectedTypes:lt}]},extraction:{patient:{position:1}}}]}function U0(r){switch(r){case "bn":return N0();case "de":return M0();case "hi":return I0();case "it":return $0();case "pl":return j0();case "ru":return W0();case "th":return q0();case "uk":return V0();case "vi":return K0();case "zh":return H0();default:return []}}function G0(){return [{id:"wait-zh-ba",language:"zh",command:"wait",priority:105,template:{format:"\u7B49\u5F85 \u628A {duration}",tokens:[{type:"literal",value:"\u7B49\u5F85",alternatives:["\u7B49","\u7A0D\u5019"]},{type:"literal",value:"\u628A"},{type:"role",role:"duration",expectedTypes:["literal","expression"]}]},extraction:{duration:{position:2}}}]}function Z0(){return [{id:"wait-he-et",language:"he",command:"wait",priority:105,template:{format:"\u05D7\u05DB\u05D4 \u05D0\u05EA {duration}",tokens:[{type:"literal",value:"\u05D7\u05DB\u05D4",alternatives:["\u05D4\u05DE\u05EA\u05DF"]},{type:"literal",value:"\u05D0\u05EA"},{type:"role",role:"duration",expectedTypes:["literal","expression"]}]},extraction:{duration:{position:2}}}]}function Y0(){return [{id:"wait-ar-from-first",language:"ar",command:"wait",priority:105,template:{format:"\u0627\u0646\u062A\u0638\u0631 \u0645\u0646 {source} {duration}",tokens:[{type:"literal",value:"\u0627\u0646\u062A\u0638\u0631",alternatives:["\u0627\u0646\u062A\u0638\u0631\u064A"]},{type:"literal",value:"\u0645\u0646"},{type:"role",role:"source",expectedTypes:["expression","reference"]},{type:"role",role:"duration",expectedTypes:["expression","literal"]}]},extraction:{source:{position:2},duration:{position:3}}}]}function X0(){return [{id:"wait-en-for-event",language:"en",command:"wait",priority:110,template:{format:"wait for {event}",tokens:[{type:"literal",value:"wait"},{type:"literal",value:"for"},{type:"role",role:"event",expectedTypes:["literal","expression"]}]},extraction:{event:{position:2}}}]}function J0(){return [{id:"wait-tl-from-first",language:"tl",command:"wait",priority:105,template:{format:"maghintay mula_sa {source} {duration}",tokens:[{type:"literal",value:"maghintay",alternatives:["hintay"]},{type:"literal",value:"mula_sa",alternatives:["galing_sa"]},{type:"role",role:"source",expectedTypes:["expression","reference"]},{type:"role",role:"duration",expectedTypes:["expression","literal"]}]},extraction:{source:{position:2},duration:{position:3}}}]}function Xt(r,e,t,a,i,n,o){let u=()=>({type:"group",optional:true,tokens:[{type:"literal",value:"("},...Array.from({length:n},(s,l)=>[...l>0?[{type:"literal",value:","}]:[],{type:"role",role:"condition",expectedTypes:["expression","literal","reference"]}]).flat(),{type:"literal",value:")"}]});return {id:r,language:e,command:"wait",priority:105,template:{format:`{source} ${a} {duration} ${i} {patient} ${t}`,tokens:[{type:"role",role:"source",expectedTypes:["expression","reference"]},{type:"literal",value:a,...o?{alternatives:o}:{}},{type:"role",role:"duration",expectedTypes:["expression","literal"]},u(),{type:"literal",value:i},{type:"role",role:"patient",expectedTypes:["expression","literal"]},u(),{type:"literal",value:t}]},extraction:{source:{position:0},duration:{position:2}}}}function Ea(r,e,t,a,i,n,o){let u=()=>({type:"group",optional:true,tokens:[{type:"literal",value:"("},...Array.from({length:o},(l,c)=>[...c>0?[{type:"literal",value:","}]:[],{type:"role",role:"condition",expectedTypes:["expression","literal","reference"]}]).flat(),{type:"literal",value:")"}]}),s=()=>({type:"group",optional:true,tokens:[{type:"literal",value:i}]});return {id:r,language:e,command:"wait",priority:105,template:{format:`${t} {duration} ${a} [${i}] {patient} [${i}] {source} ${n}`,tokens:[{type:"literal",value:t},{type:"role",role:"duration",expectedTypes:["expression","literal"]},u(),{type:"literal",value:a},s(),{type:"role",role:"patient",expectedTypes:["expression","literal"]},u(),s(),{type:"role",role:"source",expectedTypes:["expression","reference"]},{type:"literal",value:n}]},extraction:{duration:{position:1},source:{position:8}}}}function Q0(){return [Ea("wait-bn-or-run","bn","\u0985\u09AA\u09C7\u0995\u09CD\u09B7\u09BE","\u0985\u09A5\u09AC\u09BE","\u099C\u09A8\u09CD\u09AF","\u09A5\u09C7\u0995\u09C7",1),Ea("wait-bn-or-run-2arg","bn","\u0985\u09AA\u09C7\u0995\u09CD\u09B7\u09BE","\u0985\u09A5\u09AC\u09BE","\u099C\u09A8\u09CD\u09AF","\u09A5\u09C7\u0995\u09C7",2)]}function ec(){return [Xt("wait-tr-or-run","tr","bekle","den","veya",1,["dan","ten","tan"]),Xt("wait-tr-or-run-2arg","tr","bekle","den","veya",2,["dan","ten","tan"])]}function tc(){return [Xt("wait-qu-or-run","qu","suyay","manta","utaq",1),Xt("wait-qu-or-run-2arg","qu","suyay","manta","utaq",2)]}function rc(r){switch(r){case "en":return X0();case "zh":return G0();case "he":return Z0();case "ar":return Y0();case "bn":return Q0();case "tl":return J0();case "tr":return ec();case "qu":return tc();default:return []}}var Ei=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document","true","false","null","undefined","empty"]),Ze=new Map,je=new Map,Ct=new Map,br=null;function gi(r,e){let t={...r};for(let a of Object.keys(e)){let i=e[a],n=r[a];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof n=="object"&&n!==null&&!Array.isArray(n)?t[a]=gi(n,i):t[a]=i);}return t}function ac(r,e){return gi(r,e)}function Ir(r){if(!r.extends)return r;let e=je.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=Ir(e);return ac(t,r)}function Me(r,e,t){Ze.set(r,e),je.set(r,t),Ct.delete(r);}function $r(r){br=r;}var ga=new Map;function ct(r){return r.split("-")[0]}function pt(r){return r.includes("-")}function ic(r){let e=Ze.get(r);if(!e&&pt(r)){let t=ct(r);e=Ze.get(t);}if(!e){let t=Array.from(Ze.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 nc(r){let e=je.get(r);if(!e&&pt(r)){let t=ct(r);e=je.get(t);}if(!e){let t=Array.from(je.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 Ir(e)}function T(r){let e=je.get(r);return !e&&pt(r)&&(e=je.get(ct(r))),e?Ir(e):void 0}function oc(){return Array.from(Ze.keys())}function ki(r){if(Ze.has(r)&&je.has(r))return true;if(pt(r)){let e=ct(r);return Ze.has(e)&&je.has(e)}return false}function uc(r,e){let a=ic(e).tokenize(r);return e==="en"?a:lc(a,e)}var wi=()=>false;function sc(r){wi=r;}function lc(r,e){let t=r.tokens,a=[],i=false;for(let n=0;n<t.length;n++){let o=t[n],u=t[n-1],s=n+2;for(;s<t.length&&t[s]?.value!==")"&&t[s-1].position.end===t[s].position.start;)s++;let l=t.slice(n+1,s),c=l.map(m=>m.value).join(""),p=l[0],d=l[l.length-1];if(o.value==="("&&p&&d&&t[s]?.value===")"&&/^[\p{L}_$][\p{L}\p{M}\p{N}_$]*$/u.test(c)&&!(p.kind!=="particle"&&Ei.has((p.normalized??p.value).toLowerCase()))&&wi(c,e)&&o.position.end===p.position.start&&d.position.end===t[s].position.start&&!(u&&u.position.end===o.position.start&&/[\p{L}\p{N}_)\]]$/u.test(u.value))){a.push({value:`(${c})`,kind:"identifier",position:{...o.position,end:t[s].position.end}}),n=s,i=true;continue}a.push(o);}return i?new se(a,e):r}function fe(r){let e=Ct.get(r);if(!e&&pt(r)&&(e=Ct.get(ct(r))),e)return e;let t=ga.get(r);if(!t&&pt(r)&&(t=ga.get(ct(r))),t)return Ct.set(r,t),t;if(!br)throw new Error(`No patterns registered for language '${r}'. Either import the language module or set a pattern generator.`);let a=nc(r),i=br(a);return Ct.set(r,i),i}function yt(r){let e=T(r)?.roleMarkers?.style;if(!e?.primary)return null;let t={type:"literal",value:e.primary,...e.alternatives?.length?{alternatives:e.alternatives}:{}},a={type:"role",role:"style",expectedTypes:["expression"]};return {token:{type:"group",optional:true,tokens:e.position==="after"?[a,t]:[t,a]},extraction:{marker:e.primary,...e.alternatives?.length?{markerAlternatives:e.alternatives}:{}}}}function pc(){let r=yt("zh");return [{id:"fetch-zh-ba",language:"zh",command:"fetch",priority:105,template:{format:"\u6293\u53D6 \u628A {source} \u7684 {responseType}",tokens:[{type:"literal",value:"\u6293\u53D6",alternatives:["\u53D6"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u628A",alternatives:["\u4ECE","\u7531"]}]},{type:"role",role:"source",expectedTypes:["literal","expression"]},...r?[r.token]:[],{type:"group",optional:true,tokens:[{type:"literal",value:"\u7684",alternatives:["\u4F5C\u4E3A","\u5F53\u4F5C"]},{type:"role",role:"responseType",expectedTypes:["literal","expression"]}]}]},extraction:{source:{marker:"\u628A",markerAlternatives:["\u4ECE","\u7531"]},...r?{style:r.extraction}:{},responseType:{marker:"\u7684",markerAlternatives:["\u4F5C\u4E3A","\u5F53\u4F5C"]}}}]}function dc(){let r=yt("ms");return [{id:"fetch-ms",language:"ms",command:"fetch",priority:105,template:{format:"ambil_dari dari {source} sebagai {responseType}",tokens:[{type:"literal",value:"ambil_dari",alternatives:["muat","ambil"]},{type:"group",optional:true,tokens:[{type:"literal",value:"dari"}]},{type:"role",role:"source",expectedTypes:["literal","expression"]},...r?[r.token]:[],{type:"group",optional:true,tokens:[{type:"literal",value:"sebagai",alternatives:["sbg"]},{type:"role",role:"responseType",expectedTypes:["literal","expression"]}]}]},extraction:{source:{marker:"dari"},...r?{style:r.extraction}:{},responseType:{marker:"sebagai",markerAlternatives:["sbg"]}}}]}function mc(){let r=yt("fr");return [{id:"fetch-fr",language:"fr",command:"fetch",priority:105,template:{format:"chercher de {source} comme {responseType}",tokens:[{type:"literal",value:"chercher",alternatives:["r\xE9cup\xE9rer"]},{type:"group",optional:true,tokens:[{type:"literal",value:"de"}]},{type:"role",role:"source",expectedTypes:["literal","expression"]},...r?[r.token]:[],{type:"group",optional:true,tokens:[{type:"literal",value:"comme"},{type:"role",role:"responseType",expectedTypes:["literal","expression"]}]}]},extraction:{source:{marker:"de"},responseType:{marker:"comme"},...r?{style:r.extraction}:{}}}]}function fc(){let r=yt("pt");return [{id:"fetch-pt",language:"pt",command:"fetch",priority:105,template:{format:"buscar de {source} como {responseType}",tokens:[{type:"literal",value:"buscar"},{type:"group",optional:true,tokens:[{type:"literal",value:"de"}]},{type:"role",role:"source",expectedTypes:["literal","expression"]},...r?[r.token]:[],{type:"group",optional:true,tokens:[{type:"literal",value:"como"},{type:"role",role:"responseType",expectedTypes:["literal","expression"]}]}]},extraction:{source:{marker:"de"},responseType:{marker:"como"},...r?{style:r.extraction}:{}}}]}function Ee(r,e,t,a,i,n,o,u){let s=yt(e);return {id:r,language:e,command:"fetch",priority:105,template:{format:`${t} ${a} {source} ${i} {responseType}`,tokens:[{type:"literal",value:t,...n?{alternatives:n}:{}},{type:"group",optional:true,tokens:[{type:"literal",value:a,...o?{alternatives:o}:{}}]},{type:"role",role:"source",expectedTypes:["literal","expression"]},...s?[s.token]:[],{type:"group",optional:true,tokens:[{type:"literal",value:i,...u?{alternatives:u}:{}},{type:"role",role:"responseType",expectedTypes:["literal","expression"]}]}]},extraction:{source:{marker:a,...o?{markerAlternatives:o}:{}},...s?{style:s.extraction}:{},responseType:{marker:i,...u?{markerAlternatives:u}:{}}}}}function it(r,e,t,a,i,n,o,u){let s=yt(e),l=[{type:"role",role:"responseType",expectedTypes:["literal","expression"]}];o&&l.push({type:"literal",value:o,...u?{alternatives:u}:{}});let c={type:"group",optional:true,tokens:l};return {id:r,language:e,command:"fetch",priority:105,template:{format:`{source} ${a} ${t}`,tokens:[{type:"role",role:"source",expectedTypes:["literal","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:a,...n?{alternatives:n}:{}}]},...s?[s.token]:[],{type:"literal",value:t,...i?{alternatives:i}:{}},c]},extraction:{source:{marker:a,...n?{markerAlternatives:n}:{}},...s?{style:s.extraction}:{},responseType:o?{marker:o,...u?{markerAlternatives:u}:{}}:{}}}}function yc(r){switch(r){case "zh":return pc();case "ms":return dc();case "fr":return mc();case "pt":return fc();case "es":return [Ee("fetch-es","es","buscar","de","como")];case "pl":return [Ee("fetch-pl","pl","pobierz","z","jako")];case "id":return [Ee("fetch-id","id","muat","dari","sebagai",["ambil"])];case "sw":return [Ee("fetch-sw","sw","leta","kutoka","kuwa",void 0,void 0,["kama"])];case "he":return [Ee("fetch-he","he","\u05D4\u05D1\u05D0","\u05DE","\u05DB",["\u05D8\u05E2\u05DF"],["\u05D0\u05EA"])];case "de":return [Ee("fetch-de","de","abrufen","von","als",["laden"])];case "ru":return [Ee("fetch-ru","ru","\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C","\u0438\u0437","\u043A\u0430\u043A",["\u0437\u0430\u0433\u0440\u0443\u0437\u0438"])];case "uk":return [Ee("fetch-uk","uk","\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438","\u0437","\u044F\u043A",["\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436"])];case "it":return [Ee("fetch-it","it","recuperare","da","come")];case "vi":return [Ee("fetch-vi","vi","t\u1EA3i","t\u1EEB","nh\u01B0")];case "th":return [Ee("fetch-th","th","\u0E14\u0E36\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25","\u0E08\u0E32\u0E01","\u0E40\u0E1B\u0E47\u0E19")];case "ar":return [Ee("fetch-ar","ar","\u0627\u062D\u0636\u0631","\u0645\u0646","\u0643\u0640",["\u062C\u0644\u0628"])];case "tl":return [Ee("fetch-tl","tl","kuhanin_mula","mula_sa","bilang",["kunin_mula"])];case "ja":return [it("fetch-ja-sov","ja","\u30D5\u30A7\u30C3\u30C1","\u3092")];case "ko":return [it("fetch-ko-sov","ko","\uD328\uCE58","\uC744",["\uAC00\uC838\uC624\uAE30"],["\uB97C"],"\uB85C",["\uC73C\uB85C"])];case "tr":return [it("fetch-tr-sov","tr","getir","i",void 0,["\u0131","u","\xFC","yi","y\u0131","yu","y\xFC"],"olarak")];case "hi":return [it("fetch-hi-sov","hi","\u0932\u093E\u090F\u0902","\u0915\u094B")];case "qu":return [it("fetch-qu-sov","qu","apamuy","ta",["taripakaramuy"],void 0,"hina")];case "bn":return [it("fetch-bn-sov","bn","\u0986\u09A8\u09C1\u09A8","\u0995\u09C7")];default:return []}}var jr={ar:["\u0645\u0631\u0627\u062A","\u0645\u0631\u0629"],bn:["\u09AC\u09BE\u09B0"],de:["mal","Mal"],es:["veces","vez"],fr:["fois"],he:["\u05E4\u05E2\u05DE\u05D9\u05DD","\u05E4\u05E2\u05DD"],hi:["\u092C\u093E\u0930"],id:["kali"],it:["volte","volta"],ja:["\u56DE","\u5EA6"],ko:["\uBC88","\uD68C"],ms:["kali"],pl:["razy","raz"],pt:["vezes","vez"],qu:["kuti"],ru:["\u0440\u0430\u0437","\u0440\u0430\u0437\u0430"],sw:["mara"],th:["\u0E04\u0E23\u0E31\u0E49\u0E07"],tl:["beses"],tr:["kez","kere","defa"],uk:["\u0440\u0430\u0437\u0456\u0432","\u0440\u0430\u0437\u0438","\u0440\u0430\u0437"],vi:["l\u1EA7n"],zh:["\u6B21","\u904D"]},Wr=["literal","expression","reference","property-path"];function zi(r,e){let t=[...jr[r]??[],"times"].filter(a=>a!==e);return {type:"literal",value:e,alternatives:t}}function vc(r,e,t,a){let i=[];return i.push({type:"literal",value:e}),a&&i.push({type:"literal",value:a}),i.push({type:"role",role:"quantity",expectedTypes:Wr}),i.push(zi(r,t)),{id:`repeat-${r}-times`,language:r,command:"repeat",priority:110,template:{format:`${e}${a?" "+a:""} {quantity} ${t}`,tokens:i},extraction:{loopType:{default:{type:"literal",value:"times"}}}}}var hc=[["es","repetir","veces"],["de","wiederholen","mal"],["fr","r\xE9p\xE9ter","fois"],["it","ripetere","volte"],["pt","repetir","vezes"],["ru","\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C","\u0440\u0430\u0437"],["uk","\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0438","\u0440\u0430\u0437\u0456\u0432"],["pl","powt\xF3rz","razy"],["ar","\u0643\u0631\u0631","\u0645\u0631\u0627\u062A"],["he","\u05D7\u05D6\u05D5\u05E8","\u05E4\u05E2\u05DE\u05D9\u05DD","\u05D0\u05EA"],["id","ulangi","kali"],["ms","ulang","kali"],["sw","rudia","mara"],["th","\u0E17\u0E33\u0E0B\u0E49\u0E33","\u0E04\u0E23\u0E31\u0E49\u0E07"],["vi","l\u1EB7p l\u1EA1i","l\u1EA7n"],["tl","ulitin","beses"],["zh","\u91CD\u590D","\u6B21","\u628A"]];function Ec(r,e,t,a){return {id:`repeat-${r}-times`,language:r,command:"repeat",priority:110,template:{format:`{quantity} ${e} ${t} ${a}`,tokens:[{type:"role",role:"quantity",expectedTypes:Wr},zi(r,e),{type:"literal",value:t},{type:"literal",value:a,alternatives:["repeat"]}]},extraction:{loopType:{default:{type:"literal",value:"times"}}}}}var gc=[["ja","\u56DE","\u3092","\u7E70\u308A\u8FD4\u3057"],["ko","\uBC88","\uB97C","\uBC18\uBCF5"],["tr","kez","i","tekrarla"],["hi","\u092C\u093E\u0930","\u0915\u094B","\u0926\u094B\u0939\u0930\u093E\u090F\u0902"],["bn","\u09AC\u09BE\u09B0","\u0995\u09C7","\u09AA\u09C1\u09A8\u09B0\u09BE\u09AC\u09C3\u09A4\u09CD\u09A4\u09BF"],["qu","kuti","ta","kutipay"]];function kc(r,e,t){return {id:`repeat-${r}-word-first-times`,language:r,command:"repeat",priority:109,template:{format:`${e} ${t} {quantity}`,tokens:[{type:"literal",value:e},{type:"literal",value:t},{type:"role",role:"quantity",expectedTypes:Wr}]},extraction:{loopType:{default:{type:"literal",value:"times"}}}}}function wc(r,e){let t=[{type:"literal",value:"repeat"}];if(e.forWords&&e.forWords.length>0)if(e.requireForWords)for(let a of e.forWords)t.push({type:"literal",value:a});else t.push({type:"group",optional:true,tokens:e.forWords.map(a=>({type:"literal",value:a}))});t.push({type:"role",role:"patient",expectedTypes:["expression","reference"]});for(let a of e.inWords)t.push({type:"literal",value:a});return t.push({type:"role",role:"source",expectedTypes:["selector","expression","reference"]}),{id:`repeat-${r}-for-in`,language:r,command:"repeat",priority:110,template:{format:`repeat [${(e.forWords??[]).join(" ")}] {patient} ${e.inWords.join(" ")} {source}`,tokens:t},extraction:{loopType:{default:{type:"literal",value:"for"}}}}}var zc=[["en",{forWords:["for"],inWords:["in"],requireForWords:true}],["es",{forWords:["para"],inWords:["en"]}],["pt",{forWords:["para"],inWords:["dentro"]}],["fr",{forWords:["pour"],inWords:["en"]}],["it",{forWords:["per"],inWords:["in"]}],["de",{forWords:["f\xFCr"],inWords:["in"]}],["ru",{forWords:["\u0434\u043B\u044F"],inWords:["\u0432"]}],["uk",{forWords:["\u0434\u043B\u044F"],inWords:["\u0443"]}],["pl",{forWords:["dla"],inWords:["w"]}],["ar",{forWords:["\u0644\u0643\u0644"],inWords:["\u0641\u064A"]}],["he",{forWords:["\u05E2\u05D1\u05D5\u05E8","\u05D0\u05EA"],inWords:["in"]}],["hi",{inWords:["\u092E\u0947\u0902"]}],["bn",{inWords:["\u098F"]}],["ja",{inWords:["\u306E\u4E2D"]}],["ko",{inWords:["\uC548\uC5D0"]}],["zh",{forWords:["\u4E3A","\u628A"],inWords:["\u5728"]}],["tr",{inWords:["i\xE7inde"]}],["id",{forWords:["untuk"],inWords:["dalam"]}],["ms",{forWords:["untuk"],inWords:["dalam"]}],["sw",{forWords:["kwa"],inWords:["ndani"]}],["th",{forWords:["\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A"],inWords:["\u0E43\u0E19"]}],["vi",{forWords:["v\u1EDBi m\u1ED7i"],inWords:["trong"]}],["tl",{forWords:["para_sa"],inWords:["sa_loob"]}],["qu",{inWords:["ukupi"]}]];function bc(r,e){let t=[{type:"literal",value:"repeat"}];for(let a of e.pre??[])t.push({type:"literal",value:a});return t.push({type:"literal",value:e.whileWord}),t.push({type:"role",role:"condition",expectedTypes:["property-path","expression"]}),{id:`repeat-${r}-while-head`,language:r,command:"repeat",priority:110,template:{format:`repeat ${(e.pre??[]).join(" ")} ${e.whileWord} {condition}`,tokens:t},extraction:{loopType:{default:{type:"literal",value:"while"}}}}}function Cc(r,e){return {id:`repeat-${r}-while-head`,language:r,command:"repeat",priority:110,template:{format:`${e.whileWord} {condition} ${e.verb}`,tokens:[{type:"literal",value:e.whileWord},{type:"role",role:"condition",expectedTypes:["property-path","expression"]},{type:"literal",value:e.verb}]},extraction:{loopType:{default:{type:"literal",value:"while"}}}}}var Ac=[["ja",{whileWord:"\u306E\u9593",verb:"\u7E70\u308A\u8FD4\u3057"}],["ko",{whileWord:"\uB3D9\uC548",verb:"\uBC18\uBCF5"}],["tr",{whileWord:"s\xFCresince",verb:"tekrarla"}],["hi",{whileWord:"\u091C\u092C \u0924\u0915",verb:"\u0926\u094B\u0939\u0930\u093E\u090F\u0902"}],["bn",{whileWord:"\u09AF\u09A4\u0995\u09CD\u09B7\u09A3",verb:"\u09AA\u09C1\u09A8\u09B0\u09BE\u09AC\u09C3\u09A4\u09CD\u09A4\u09BF"}],["qu",{whileWord:"kaykamaqa",verb:"kutipay"}]],xc=[["en",{whileWord:"while"}],["es",{whileWord:"mientras"}],["pt",{whileWord:"enquanto"}],["fr",{whileWord:"tantque"}],["it",{whileWord:"mentre"}],["de",{whileWord:"w\xE4hrend"}],["ru",{whileWord:"\u043F\u043E\u043A\u0430"}],["uk",{whileWord:"\u043F\u043E\u043A\u0438"}],["pl",{whileWord:"dop\xF3ki"}],["ar",{whileWord:"\u0628\u064A\u0646\u0645\u0627"}],["he",{pre:["\u05D0\u05EA"],whileWord:"\u05DB\u05DC \u05E2\u05D5\u05D3"}],["zh",{pre:["\u628A"],whileWord:"\u5F53"}],["id",{whileWord:"selama"}],["ms",{whileWord:"selagi"}],["sw",{whileWord:"wakati"}],["th",{whileWord:"\u0E43\u0E19\u0E02\u0E13\u0E30\u0E17\u0E35\u0E48"}],["vi",{whileWord:"trong khi"}],["tl",{whileWord:"habang"}]];function bi(r,e){let t=[{type:"literal",value:"repeat"}];for(let a of e.pre??[])t.push({type:"literal",value:a});return t.push({type:"literal",value:e.untilWord}),t.push({type:"role",role:"condition",expectedTypes:["property-path","expression"]}),{id:`repeat-${r}-until-condition-head`,language:r,command:"repeat",priority:105,template:{format:`repeat ${(e.pre??[]).join(" ")} ${e.untilWord} {condition}`,tokens:t},extraction:{loopType:{default:{type:"literal",value:"until"}}}}}function Dc(r,e){return {id:`repeat-${r}-until-condition-head`,language:r,command:"repeat",priority:105,template:{format:`${e.untilWord} {condition} ${e.verb}`,tokens:[{type:"literal",value:e.untilWord},{type:"role",role:"condition",expectedTypes:["property-path","expression"]},{type:"literal",value:e.verb}]},extraction:{loopType:{default:{type:"literal",value:"until"}}}}}function Bc(r,e){let t=[{type:"literal",value:"repeat"}];for(let a of e.pre??[])t.push({type:"literal",value:a});return t.push({type:"literal",value:e.untilWord}),e.preEvent&&t.push({type:"literal",value:e.preEvent}),t.push({type:"literal",value:e.eventWord}),t.push({type:"role",role:"event",expectedTypes:["literal","expression"]}),t.push({type:"group",optional:true,tokens:[{type:"literal",value:e.fromWord},{type:"role",role:"source",expectedTypes:["selector","reference","expression"]}]}),{id:`repeat-${r}-until-head`,language:r,command:"repeat",priority:110,template:{format:`repeat ${e.untilWord} ${e.eventWord} {event} [${e.fromWord} {source}]`,tokens:t},extraction:{loopType:{default:{type:"literal",value:"until-event"}}}}}var Sc=[["ja",{untilWord:"\u307E\u3067",verb:"\u7E70\u308A\u8FD4\u3057"}],["ko",{untilWord:"\uAE4C\uC9C0",verb:"\uBC18\uBCF5"}],["tr",{untilWord:"kadar",verb:"tekrarla"}],["hi",{untilWord:"\u0924\u0915",verb:"\u0926\u094B\u0939\u0930\u093E\u090F\u0902"}],["bn",{untilWord:"\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4",verb:"\u09AA\u09C1\u09A8\u09B0\u09BE\u09AC\u09C3\u09A4\u09CD\u09A4\u09BF"}],["qu",{untilWord:"kama",verb:"kutipay"}]],Tc=[["es",{untilWord:"hasta",eventWord:"evento",fromWord:"de"}],["pt",{untilWord:"at\xE9",eventWord:"evento",fromWord:"de"}],["fr",{untilWord:"jusqu\xE0",eventWord:"\xE9v\xE9nement",fromWord:"de"}],["it",{untilWord:"fino",eventWord:"evento",fromWord:"da"}],["de",{untilWord:"bis",eventWord:"ereignis",fromWord:"von"}],["ru",{untilWord:"\u0434\u043E",eventWord:"\u0441\u043E\u0431\u044B\u0442\u0438\u0435",fromWord:"\u0438\u0437"}],["uk",{untilWord:"\u0434\u043E",eventWord:"\u043F\u043E\u0434\u0456\u044F",fromWord:"\u0437"}],["pl",{untilWord:"a\u017C",eventWord:"zdarzenie",fromWord:"z"}],["ar",{untilWord:"\u062D\u062A\u0649",eventWord:"\u062D\u062F\u062B",fromWord:"\u0645\u0646"}],["he",{untilWord:"\u05E2\u05D3",preEvent:"\u05D0\u05EA",eventWord:"\u05D0\u05D9\u05E8\u05D5\u05E2",fromWord:"\u05DE"}],["id",{untilWord:"sampai",eventWord:"peristiwa",fromWord:"dari"}],["ms",{untilWord:"sehingga",eventWord:"peristiwa",fromWord:"dari"}],["sw",{untilWord:"hadi",eventWord:"tukio",fromWord:"kutoka"}],["th",{untilWord:"\u0E08\u0E19\u0E16\u0E36\u0E07",eventWord:"\u0E40\u0E2B\u0E15\u0E38\u0E01\u0E32\u0E23\u0E13\u0E4C",fromWord:"\u0E08\u0E32\u0E01"}],["vi",{untilWord:"cho \u0111\u1EBFn khi",eventWord:"s\u1EF1 ki\u1EC7n",fromWord:"t\u1EEB"}],["tl",{untilWord:"hanggang",eventWord:"pangyayari",fromWord:"mula_sa"}],["zh",{pre:["\u628A"],untilWord:"\u76F4\u5230",eventWord:"\u4E8B\u4EF6",fromWord:"\u4ECE"}]];function Fc(r,e){return {id:`repeat-${r}-until-head`,language:r,command:"repeat",priority:110,template:{format:`${e.untilWord} ${e.eventWord} {event} ${e.objMarker} repeat [{source} ${e.fromWord}]`,tokens:[{type:"literal",value:e.untilWord},{type:"literal",value:e.eventWord},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:e.objMarker},{type:"literal",value:"repeat"},{type:"group",optional:true,tokens:[{type:"role",role:"source",expectedTypes:["selector","reference","expression"]},{type:"literal",value:e.fromWord}]}]},extraction:{loopType:{default:{type:"literal",value:"until-event"}}}}}function Pc(r,e){return {id:`repeat-${r}-until-head-verb-final`,language:r,command:"repeat",priority:111,template:{format:`${e.untilWord} ${e.eventWord} {event} ${e.objMarker} {source} ${e.fromWord} repeat`,tokens:[{type:"literal",value:e.untilWord},{type:"literal",value:e.eventWord},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:e.objMarker},{type:"role",role:"source",expectedTypes:["selector","reference","expression"]},{type:"literal",value:e.fromWord},{type:"literal",value:"repeat"}]},extraction:{loopType:{default:{type:"literal",value:"until-event"}}}}}var Oc={id:"repeat-qu-midclause-until-head",language:"qu",command:"repeat",priority:109,template:{format:"until event {event} ta {source} manta repeat",tokens:[{type:"literal",value:"until"},{type:"literal",value:"event"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:"ta"},{type:"role",role:"source",expectedTypes:["selector","reference","expression"]},{type:"literal",value:"manta"},{type:"literal",value:"repeat"}]},extraction:{loopType:{default:{type:"literal",value:"until-event"}}}},Rc=[["hi",{untilWord:"\u0924\u0915",eventWord:"\u0918\u091F\u0928\u093E",objMarker:"\u0915\u094B",fromWord:"\u0938\u0947"}],["bn",{untilWord:"\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4",eventWord:"\u0998\u099F\u09A8\u09BE",objMarker:"\u0995\u09C7",fromWord:"\u09A5\u09C7\u0995\u09C7"}],["ja",{untilWord:"\u307E\u3067",eventWord:"\u30A4\u30D9\u30F3\u30C8",objMarker:"\u3092",fromWord:"\u304B\u3089"}],["ko",{untilWord:"\uAE4C\uC9C0",eventWord:"\uC774\uBCA4\uD2B8",objMarker:"\uB97C",fromWord:"\uC5D0\uC11C"}],["tr",{untilWord:"kadar",eventWord:"olay",objMarker:"i",fromWord:"den"}]],Lc={id:"repeat-qu-until-head",language:"qu",command:"repeat",priority:110,template:{format:"hayk _ a until event {event} ta {source} manta repeat",tokens:[{type:"literal",value:"hayk"},{type:"literal",value:"_"},{type:"literal",value:"a"},{type:"literal",value:"until"},{type:"literal",value:"event"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:"ta"},{type:"role",role:"source",expectedTypes:["selector","reference","expression"]},{type:"literal",value:"manta"},{type:"literal",value:"repeat"}]},extraction:{loopType:{default:{type:"literal",value:"until-event"}}}};function _c(r,e){return {id:`for-${r}-sov-basic`,language:r,command:"for",priority:105,template:{format:`{patient} ${e.inWords.join(" ")} {source} [${e.objMarker}] ${e.forVerb}`,tokens:[{type:"role",role:"patient",expectedTypes:["expression","reference"]},...e.inWords.map(t=>({type:"literal",value:t})),{type:"role",role:"source",expectedTypes:["selector","expression","reference"]},{type:"group",optional:true,tokens:[{type:"literal",value:e.objMarker}]},{type:"literal",value:e.forVerb}]},extraction:{patient:{position:0}}}}var Nc=[["ja",{inWords:["\u306E\u4E2D"],objMarker:"\u3092",forVerb:"\u305F\u3081\u306B"}],["ko",{inWords:["\uC548\uC5D0"],objMarker:"\uB97C",forVerb:"\uAC01\uAC01"}],["tr",{inWords:["i\xE7inde"],objMarker:"i",forVerb:"i\xE7in"}],["qu",{inWords:["ukupi"],objMarker:"ta",forVerb:"sapankaq"}],["bn",{inWords:["\u098F"],objMarker:"\u0995\u09C7",forVerb:"\u099C\u09A8\u09CD\u09AF"}],["hi",{inWords:["\u092E\u0947\u0902"],objMarker:"\u0915\u094B",forVerb:"\u0939\u0947\u0924\u0941"}]],Cr=new Map,ce=(r,e)=>{let t=Cr.get(r);t?t.push(e):Cr.set(r,[e]);};for(let[r,e,t,a]of hc)ce(r,vc(r,e,t,a));for(let[r,e,t,a]of gc)ce(r,Ec(r,e,t,a));ce("sw",kc("sw","rudia","mara"));for(let[r,e]of zc)ce(r,wc(r,e));for(let[r,e]of Nc)ce(r,_c(r,e));for(let[r,e]of xc)ce(r,bc(r,e));for(let[r,e]of Ac)ce(r,Cc(r,e));for(let[r,e]of Tc)ce(r,Bc(r,e)),ce(r,bi(r,e));ce("en",bi("en",{untilWord:"until"}));for(let[r,e]of Sc)ce(r,Dc(r,e));for(let[r,e]of Rc)ce(r,Fc(r,e)),r==="tr"&&ce(r,Pc(r,e));var Mc={id:"repeat-qu-canonical-until-head",language:"qu",command:"repeat",priority:110,template:{format:"kama ruway {event} ta repeat [{source} manta]",tokens:[{type:"literal",value:"kama"},{type:"literal",value:"ruway"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:"ta"},{type:"literal",value:"repeat"},{type:"group",optional:true,tokens:[{type:"role",role:"source",expectedTypes:["selector","reference","expression"]},{type:"literal",value:"manta"}]}]},extraction:{loopType:{default:{type:"literal",value:"until-event"}}}};ce("qu",Mc);ce("qu",Lc);ce("qu",Oc);function Ic(r){return Cr.get(r)??[]}function $c(){return [{id:"append-en-full",language:"en",command:"append",priority:100,template:{format:"append {patient} to {destination}",tokens:[{type:"literal",value:"append"},{type:"role",role:"patient",expectedTypes:["literal","selector","expression"]},{type:"literal",value:"to"},{type:"role",role:"destination",expectedTypes:["selector","reference"]}]},extraction:{patient:{position:1},destination:{marker:"to"}}}]}function jc(r){switch(r){case "en":return $c();default:return []}}function Wc(){return [{id:"prepend-en-full",language:"en",command:"prepend",priority:100,template:{format:"prepend {patient} to {destination}",tokens:[{type:"literal",value:"prepend"},{type:"role",role:"patient",expectedTypes:["literal","selector","expression"]},{type:"literal",value:"to"},{type:"role",role:"destination",expectedTypes:["selector","reference"]}]},extraction:{patient:{position:1},destination:{marker:"to"}}}]}function qc(r){switch(r){case "en":return Wc();default:return []}}function Vc(){return [{id:"trigger-en-full",language:"en",command:"trigger",priority:100,template:{format:"trigger {event} on {destination}",tokens:[{type:"literal",value:"trigger"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"destination",expectedTypes:["selector","reference"]}]}]},extraction:{event:{position:1},destination:{marker:"on",default:{type:"reference",value:"me"}}}},{id:"trigger-en-simple",language:"en",command:"trigger",priority:90,template:{format:"trigger {event}",tokens:[{type:"literal",value:"trigger"},{type:"role",role:"event",expectedTypes:["literal","expression"]}]},extraction:{event:{position:1},destination:{default:{type:"reference",value:"me"}}}}]}function Kc(){return [{id:"trigger-zh-ba",language:"zh",command:"trigger",priority:105,template:{format:"\u89E6\u53D1 \u628A {event} \u5728 {destination}",tokens:[{type:"literal",value:"\u89E6\u53D1",alternatives:["\u89F8\u767C"]},{type:"literal",value:"\u628A"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u5728",alternatives:["\u5230","\u4E8E"]},{type:"role",role:"destination",expectedTypes:["selector","reference","expression"]}]}]},extraction:{event:{position:2},destination:{marker:"\u5728",markerAlternatives:["\u5230","\u4E8E"],default:{type:"reference",value:"me"}}}}]}function Hc(){return [{id:"trigger-he-et",language:"he",command:"trigger",priority:105,template:{format:"\u05D4\u05E4\u05E2\u05DC \u05D0\u05EA {event} \u05E2\u05DC {destination}",tokens:[{type:"literal",value:"\u05D4\u05E4\u05E2\u05DC",alternatives:["\u05E9\u05D2\u05E8"]},{type:"literal",value:"\u05D0\u05EA"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u05E2\u05DC",alternatives:["\u05DC","\u05D0\u05DC"]},{type:"role",role:"destination",expectedTypes:["selector","reference","expression"]}]}]},extraction:{event:{position:2},destination:{marker:"\u05E2\u05DC",markerAlternatives:["\u05DC","\u05D0\u05DC"],default:{type:"reference",value:"me"}}}}]}function Uc(){return [{id:"trigger-qu-event-first-verb-final",language:"qu",command:"trigger",priority:105,template:{format:"{event} ta [{destination} man] trigger",tokens:[{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:"ta"},{type:"group",optional:true,tokens:[{type:"role",role:"destination",expectedTypes:["selector","reference","expression"]},{type:"literal",value:"man"}]},{type:"literal",value:"trigger"}]},extraction:{destination:{default:{type:"reference",value:"me"}}}}]}function Gc(r){switch(r){case "en":return Vc();case "zh":return Kc();case "he":return Hc();case "qu":return Uc();default:return []}}function Zc(){return [{id:"send-zh-ba",language:"zh",command:"send",priority:105,template:{format:"\u53D1\u9001 \u628A {event} \u5230 {destination}",tokens:[{type:"literal",value:"\u53D1\u9001",alternatives:["\u767C\u9001","\u4F20\u9001","\u50B3\u9001"]},{type:"literal",value:"\u628A"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u5230",alternatives:["\u7ED9","\u7D66","\u5411"]},{type:"role",role:"destination",expectedTypes:["selector","reference","expression"]}]}]},extraction:{event:{position:2},destination:{marker:"\u5230",markerAlternatives:["\u7ED9","\u7D66","\u5411"],default:{type:"reference",value:"me"}}}}]}function Yc(){return [{id:"send-he-et",language:"he",command:"send",priority:105,template:{format:"\u05E9\u05DC\u05D7 \u05D0\u05EA {event} \u05E2\u05DC {destination}",tokens:[{type:"literal",value:"\u05E9\u05DC\u05D7"},{type:"literal",value:"\u05D0\u05EA"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:"\u05E2\u05DC",alternatives:["\u05DC","\u05D0\u05DC"]},{type:"role",role:"destination",expectedTypes:["selector","reference","expression"]}]}]},extraction:{event:{position:2},destination:{marker:"\u05E2\u05DC",markerAlternatives:["\u05DC","\u05D0\u05DC"],default:{type:"reference",value:"me"}}}}]}function Xc(r){switch(r){case "zh":return Zc();case "he":return Yc();default:return []}}function Ne(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 Y(r,e){let t={type:"literal",value:r};return e!==void 0?{type:"literal",value:r,dataType:e}:t}function Ci(r){if(r==="true")return Y(true,"boolean");if(r==="false")return Y(false,"boolean");if(r==="null")return {type:"expression",raw:"null"}}function _e(r){return mr(r)}function De(r){return {type:"reference",value:r}}function Ai(r,e){return e?{...r,position:e}:r}function Ie(r,e,t){return t?{type:"property-path",object:r,property:e,access:t}:{type:"property-path",object:r,property:e}}function me(r,e,t){let a={kind:"command",action:r,roles:new Map(Object.entries(e))};return t!==void 0?{...a,metadata:t}:a}function zt(r,e,t,a,i,n){let o=new Map;o.set("event",r);let u={kind:"event-handler",action:"on",roles:o,body:e};return t!==void 0&&(u.eventModifiers=t),a!==void 0&&(u.metadata=a),i!==void 0&&i.length>0&&(u.parameterNames=i),u}function Jc(r,e,t,a,i){let n={kind:"behavior",action:"behavior",roles:new Map,name:r,parameters:e,eventHandlers:t};return a!==void 0&&a.length>0&&(n.initBlock=a),i!==void 0&&(n.metadata=i),n}function Qc(r,e,t,a){let i={kind:"def",action:"def",roles:new Map,name:r,parameters:e,body:t};return a!==void 0&&(i.metadata=a),i}function Ar(r,e,t,a,i){let n={kind:"feature",action:r,roles:i??new Map,body:e};return t!==void 0&&(n.name=t),a!==void 0&&(n.metadata=a),n}function nt(r,e="then",t){let a={kind:"compound",action:"compound",roles:new Map,statements:r,chainType:e};return t!==void 0&&(a.metadata=t),a}function ep(r,e,t,a){let i=new Map;i.set("condition",r);let n={kind:"conditional",action:"if",roles:i,thenBranch:e};return t!==void 0&&(n.elseBranch=t),a!==void 0&&(n.metadata=a),n}function tp(r,e,t,a,i){let n={kind:"loop",action:r,loopVariant:e,roles:new Map(Object.entries(t)),body:a};return i?.loopVariable&&(n.loopVariable=i.loopVariable),i?.indexVariable&&(n.indexVariable=i.indexVariable),i?.metadata&&(n.metadata=i.metadata),n}function xi(r){let e=T(r)?.keywords?.pick,t=e?.primary;if(!t||t.toLowerCase()==="pick")return {type:"literal",value:"pick"};let a=[...e?.alternatives??[],"pick"];return {type:"literal",value:t,alternatives:a}}var rp=new Set(["character","characters","item","items"]),Di=r=>{if(rp.has(r))return {type:"expression",raw:r};let e=Number(r);return Y(r!==""&&!Number.isNaN(e)?e:r)};function ap(r,e){let t=[xi(r)];return e.objectMarkers?.length&&t.push({type:"group",optional:true,tokens:[{type:"literal",value:e.objectMarkers[0],...e.objectMarkers.length>1?{alternatives:e.objectMarkers.slice(1)}:{}}]}),t.push({type:"role",role:"method",expectedTypes:["literal","expression"]},{type:"role",role:"patient",expectedTypes:["literal","expression"]},{type:"literal",value:e.srcMarker,...e.srcAlternatives?.length?{alternatives:e.srcAlternatives}:{}},{type:"role",role:"source",expectedTypes:["selector","reference","expression"]}),{id:`pick-${r}-variant`,language:r,command:"pick",priority:110,template:{format:`pick {method} {patient} ${e.srcMarker} {source}`,tokens:t},extraction:{method:{position:1,transform:Di},patient:{position:2},source:{marker:e.srcMarker,...e.srcAlternatives?.length?{markerAlternatives:e.srcAlternatives}:{}}}}}var ip={ar:{srcMarker:"\u0645\u0646"},de:{srcMarker:"von",srcAlternatives:["aus"]},es:{srcMarker:"de"},fr:{srcMarker:"de"},he:{srcMarker:"of",srcAlternatives:["\u05E9\u05DC","\u05DE"],objectMarkers:["\u05D0\u05EA"]},id:{srcMarker:"dari"},it:{srcMarker:"di",srcAlternatives:["da"]},ms:{srcMarker:"daripada",srcAlternatives:["dari"]},pl:{srcMarker:"z"},pt:{srcMarker:"de"},ru:{srcMarker:"\u0438\u0437"},sw:{srcMarker:"ya",srcAlternatives:["kutoka"]},th:{srcMarker:"\u0E02\u0E2D\u0E07",srcAlternatives:["\u0E08\u0E32\u0E01"]},tl:{srcMarker:"ng",srcAlternatives:["mula"]},uk:{srcMarker:"\u0437"},vi:{srcMarker:"c\u1EE7a",srcAlternatives:["t\u1EEB"]},zh:{srcMarker:"\u7684",objectMarkers:["\u628A"]}};function np(r,e){return {id:`pick-${r}-variant-sov`,language:r,command:"pick",priority:110,template:{format:`{source} ${e.genitive} {method} {patient} ${e.patientMarker} pick`,tokens:[{type:"role",role:"source",expectedTypes:["selector","reference","expression"]},{type:"literal",value:e.genitive},{type:"role",role:"method",expectedTypes:["literal","expression"]},{type:"role",role:"patient",expectedTypes:["literal","expression"]},{type:"group",optional:true,tokens:[{type:"literal",value:e.patientMarker}]},xi(r)]},extraction:{source:{position:0},method:{position:2,transform:Di},patient:{position:3}}}}var op={bn:{genitive:"\u09B0",patientMarker:"\u0995\u09C7"},hi:{genitive:"\u0915\u093E",patientMarker:"\u0915\u094B"},ja:{genitive:"\u306E",patientMarker:"\u3092"},ko:{genitive:"\uC758",patientMarker:"\uB97C"},qu:{genitive:"pa",patientMarker:"ta"},tr:{genitive:"nin",patientMarker:"i"}};function up(r){let e=ip[r];if(e)return [ap(r,e)];let t=op[r];return t?[np(r,t)]:[]}var sp={id:"fetch-en-with-response-type",language:"en",command:"fetch",priority:90,template:{format:"fetch {source} as {responseType}",tokens:[{type:"literal",value:"fetch"},{type:"role",role:"source",expectedTypes:["literal","expression"]},{type:"literal",value:"as"},{type:"role",role:"responseType",expectedTypes:["literal","expression"]}]},extraction:{source:{position:1},responseType:{marker:"as"}}},lp={id:"fetch-en-with-options-as",language:"en",command:"fetch",priority:95,template:{format:"fetch {source} with {style} as {responseType}",tokens:[{type:"literal",value:"fetch"},{type:"role",role:"source",expectedTypes:["literal","expression"]},{type:"literal",value:"with",alternatives:["by","using"]},{type:"role",role:"style",expectedTypes:["expression"]},{type:"literal",value:"as"},{type:"role",role:"responseType",expectedTypes:["literal","expression"]}]},extraction:{source:{position:1},style:{marker:"with"},responseType:{marker:"as"}}},cp={id:"fetch-en-with-options",language:"en",command:"fetch",priority:93,template:{format:"fetch {source} with {style}",tokens:[{type:"literal",value:"fetch"},{type:"role",role:"source",expectedTypes:["literal","expression"]},{type:"literal",value:"with",alternatives:["by","using"]},{type:"role",role:"style",expectedTypes:["expression"]}]},extraction:{source:{position:1},style:{marker:"with"}}},pp={id:"fetch-en-simple",language:"en",command:"fetch",priority:80,template:{format:"fetch {source}",tokens:[{type:"literal",value:"fetch"},{type:"role",role:"source"}]},extraction:{source:{position:1}}},dp=[lp,cp,sp,pp],rr={type:"group",optional:true,tokens:[{type:"literal",value:"using"},{type:"literal",value:"view"},{type:"role",role:"manner",optional:true,expectedTypes:["literal","expression"],valueShape:"keyword"}]},mp={id:"swap-en-handcrafted",language:"en",command:"swap",priority:110,template:{format:"swap {method} {destination} [using view {manner}]",tokens:[{type:"literal",value:"swap"},{type:"role",role:"method"},{type:"role",role:"destination"},rr]},extraction:{method:{position:1},destination:{position:2}}},fp={id:"swap-en-element",language:"en",command:"swap",priority:120,template:{format:"swap {destination} with {patient} [using view {manner}]",tokens:[{type:"literal",value:"swap"},{type:"role",role:"destination"},{type:"literal",value:"with"},{type:"role",role:"patient"},rr]},extraction:{}},yp={id:"swap-en-strategy-of",language:"en",command:"swap",priority:140,template:{format:"swap {method} of {destination} with {patient} [using view {manner}]",tokens:[{type:"literal",value:"swap"},{type:"role",role:"method"},{type:"literal",value:"of"},{type:"role",role:"destination"},{type:"literal",value:"with"},{type:"role",role:"patient"},rr]},extraction:{}},vp={id:"swap-en-strategy",language:"en",command:"swap",priority:130,template:{format:"swap {method} {destination} with {patient} [using view {manner}]",tokens:[{type:"literal",value:"swap"},{type:"role",role:"method"},{type:"role",role:"destination"},{type:"literal",value:"with"},{type:"role",role:"patient"},rr]},extraction:{}},hp=[yp,vp,fp,mp],Ep={id:"repeat-en-until-event-from",language:"en",command:"repeat",priority:120,template:{format:"repeat until event {event} from {source}",tokens:[{type:"literal",value:"repeat"},{type:"literal",value:"until"},{type:"literal",value:"event"},{type:"role",role:"event",expectedTypes:["literal","expression"]},{type:"literal",value:"from"},{type:"role",role:"source",expectedTypes:["selector","reference","expression"]}]},extraction:{event:{marker:"event"},source:{marker:"from"},loopType:{default:{type:"literal",value:"until-event"}}}},gp={id:"repeat-en-until-event",language:"en",command:"repeat",priority:110,template:{format:"repeat until event {event}",tokens:[{type:"literal",value:"repeat"},{type:"literal",value:"until"},{type:"literal",value:"event"},{type:"role",role:"event",expectedTypes:["literal","expression"]}]},extraction:{event:{marker:"event"},loopType:{default:{type:"literal",value:"until-event"}}}},kp=[Ep,gp],wp=[...Lr.roles.find(r=>r.role==="patient")?.expectedTypes??[]],zp={id:"set-en-possessive",language:"en",command:"set",priority:100,template:{format:"set {destination} to {patient} [on {scope}]",tokens:[{type:"literal",value:"set"},{type:"role",role:"destination",expectedTypes:["property-path","selector","reference","expression"]},{type:"literal",value:"to"},{type:"role",role:"patient",expectedTypes:wp},{type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}]},extraction:{destination:{position:1},patient:{marker:"to"},scope:{marker:"on"}}},bp=[zp],Cp={id:"for-en-basic",language:"en",command:"for",priority:100,template:{format:"for {patient} in {source}",tokens:[{type:"literal",value:"for"},{type:"role",role:"patient",expectedTypes:["expression","reference"]},{type:"literal",value:"in"},{type:"role",role:"source",expectedTypes:["selector","expression","reference"]}]},extraction:{patient:{position:1},source:{marker:"in"}}},Ap={id:"if-en-basic",language:"en",command:"if",priority:100,template:{format:"if {condition}",tokens:[{type:"literal",value:"if"},{type:"role",role:"condition",expectedTypes:["expression","reference","selector"]}]},extraction:{condition:{position:1}}},xp={id:"unless-en-basic",language:"en",command:"unless",priority:100,template:{format:"unless {condition}",tokens:[{type:"literal",value:"unless"},{type:"role",role:"condition",expectedTypes:["expression","reference","selector"]}]},extraction:{condition:{position:1}}},Dp=[Cp,Ap,xp],Bp={id:"temporal-en-in",language:"en",command:"wait",priority:95,template:{format:"in {duration}",tokens:[{type:"literal",value:"in"},{type:"role",role:"duration",expectedTypes:["literal","expression"]}]},extraction:{duration:{position:1}}},Sp={id:"temporal-en-after",language:"en",command:"wait",priority:95,template:{format:"after {duration}",tokens:[{type:"literal",value:"after"},{type:"role",role:"duration",expectedTypes:["literal","expression"]}]},extraction:{duration:{position:1}}},Tp=[Bp,Sp],Fp=[...dp,...hp,...kp,...bp,...Dp,...Tp];function Pp(){return Fp}function Bi(r,e){let t=e==="SOV"?"sovPosition":"svoPosition";return [...r].sort((a,i)=>{let n=a[t]??99,o=i[t]??99;return n-o})}function Op(r,e){let t=r.markerOverride?.[e.code],a=e.roleMarkers[r.role];if(t!==void 0){let i=Rp(r,e.code,t);return {primary:t,...i&&{alternatives:i},position:a?.position??"before",isOverride:true}}if(a&&a.primary){let i={primary:a.primary,position:a.position,isOverride:false};return a.alternatives&&(i.alternatives=a.alternatives),i}return null}function Rp(r,e,t){let a=r.markerLegacy?.[e];if(!a?.length)return;let i=[...new Set(a)].filter(n=>n&&n!==t);return i.length?i:void 0}function We(r,e,t){let a=r.markerLegacy?.[e]??[],i=r.methodCarrier?[]:r.markerVariants?.[e]??[],n=[...new Set([...a,...i])].filter(o=>o&&o!==t);return n.length?n:void 0}var Pt=new Set(["destination","source","patient","object","event","eventmarker","manner","instrument","style"]);function dt(r,e){let t,a;if(r.markerOverride&&r.markerOverride[e.code]!==void 0)t=r.markerOverride[e.code],a=t?We(r,e.code,t):void 0;else {let i=e.roleMarkers[r.role];if(i){t=i.primary;let n=We(r,e.code,t)??[],o=[...new Set([...i.alternatives??[],...n])].filter(u=>u!==t);a=o.length?o:void 0;}}return {marker:t,alternatives:a}}function Ot(r,e,t){t.roles.find(i=>i.role==="scope"&&!i.required)&&(r.push({type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}),e.scope={fromRole:"scope"});}function qr(r,e,t,a){Ti(r,e,t,a,"manner",{requireMarker:true});}function Si(r,e,t,a){Ti(r,e,t,a,"recipient",{requireMarker:false});}function Ti(r,e,t,a,i,n){let o=t.roles.find(s=>s.role===i&&!s.required);if(!o)return;let u=o.markerOverride?.[a];n.requireMarker&&!u||(r.push({type:"group",optional:true,tokens:[...(u?u.split(/\s+/):[]).map(s=>({type:"literal",value:s})),{type:"role",role:i,optional:true,expectedTypes:o.expectedTypes,...o.valueShape!==void 0?{valueShape:o.valueShape}:{}}]}),e[i]={fromRole:i});}function Fi(r){if(r.roles.some(a=>a.role==="patient"))return "patient";let e=r.roles.filter(a=>a.required),t=e.find(a=>a.role===r.primaryRole)??e[0];return !t||t.role==="event"?"patient":t.role}function Pi(r,e,t){let a=r.roles.find(c=>c.role===t);if(!a||t==="patient")return [{type:"role",role:t,optional:false}];let{marker:i,alternatives:n}=dt(a,e),o={type:"role",role:t,optional:false,...a.valueShape!==void 0?{valueShape:a.valueShape}:{}};if(!i)return [o];let u=i.split(/\s+/).filter(Boolean),s={type:"group",optional:true,tokens:u.map(c=>({type:"literal",value:c,...u.length===1&&n?.length?{alternatives:n}:{}}))};return (e.roleMarkers[t]?.position??"before")==="after"?[o,s]:[s,o]}function Oi(r,e,t,a,i){for(let n of t.roles)n.required||i.has(n.role)||e[n.role]||!(n.markerOverride?.[a.code]??a.roleMarkers[n.role]?.primary)&&n.valueShape===void 0||(r.push({type:"group",optional:true,tokens:Li(n,a)}),e[n.role]=n.default?{fromRole:n.role,default:n.default}:{fromRole:n.role});}function Lp(r,e,t,a,i){let n=[];if(n.push({type:"role",role:"event",optional:false}),a.position==="after"){let f=a.primary.split(/\s+/);if(f.length>1)for(let y of f)n.push({type:"literal",value:y});else {let y=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(y);}}let o=Fi(r),u=e.roleMarkers.destination,s=r.roles.some(f=>f.role==="destination");u&&s&&o!=="destination"&&n.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}]});let l=e.roleMarkers.source,c=r.roles.some(f=>f.role==="source");l&&c&&o!=="source"&&n.push({type:"group",optional:true,tokens:[{type:"role",role:"source",optional:true},l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary}]}),n.push(...Pi(r,e,o));let p=e.roleMarkers.patient;if(p&&o==="patient"){let f=p.alternatives?{type:"literal",value:p.primary,alternatives:p.alternatives}:{type:"literal",value:p.primary};n.push(f);}let d=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(d),o!=="source"&&n.push(...Qe(r,e.roleMarkers.source)),o!=="destination"&&n.push(...Pr(r,e.roleMarkers.destination));let m={action:{value:r.action},event:{fromRole:"event"},[o]:{fromRole:o},...o==="destination"?{}:Xe(r),...o==="source"?{}:Je(r)};return Oi(n,m,r,e,new Set(["event",o,"destination","source"])),{id:`${r.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`{event} ${a.primary} {destination?} {${o}} ${p?.primary||""} ${t.primary}`,tokens:n},extraction:m}}function _p(r,e,t,a,i){let n=[],o=r.action==="swap",u=o?"destination":"patient";n.push({type:"role",role:u,optional:false});let s=e.roleMarkers.patient;if(s){let d=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};n.push(d);}if(n.push({type:"role",role:"event",optional:false}),a.position==="after"){let d=a.primary.split(/\s+/);if(d.length>1)for(let m of d)n.push({type:"literal",value:m});else {let m=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(m);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l),n.push(...Qe(r,e.roleMarkers.source));let c=e.roleMarkers.destination;if(o&&c){let d=r.roles.find(m=>m.role==="patient")?.markerOverride?.[e.code];if(d&&d!==c.primary){let m=c.alternatives??[];m.includes(d)||(c={...c,alternatives:[...m,d]});}}n.push(...o?Vo(r,c):Pr(r,c));let p={action:{value:r.action},event:{fromRole:"event"},[u]:{fromRole:u},...o?{}:Xe(r),...Je(r)};return Si(n,p,r,e.code),qr(n,p,r,e.code),{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} ${a.primary} ${t.primary}`,tokens:n},extraction:p}}function Np(r,e,t,a,i){let n=r.roles.find(p=>p.role==="source");if(!n)return null;let{marker:o,alternatives:u}=dt(n,e),s=e.roleMarkers.patient;if(!o||o===a.primary||o===s?.primary)return null;let l=[];l.push({type:"role",role:"patient",optional:false}),s&&l.push(s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}),l.push({type:"role",role:"source",optional:false,...n.expectedTypes?{expectedTypes:n.expectedTypes}:{},...n.valueShape!==void 0?{valueShape:n.valueShape}:{}});for(let p of o.split(/\s+/))l.push(u&&o.split(/\s+/).length===1?{type:"literal",value:p,alternatives:u}:{type:"literal",value:p});if(l.push({type:"role",role:"event",optional:false}),a.position==="after"){let p=a.primary.split(/\s+/);if(p.length>1)for(let d of p)l.push({type:"literal",value:d});else l.push(a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary});}l.push(t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary});let c={action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},source:{fromRole:"source"}};return Si(l,c,r,e.code),qr(l,c,r,e.code),{id:`${r.action}-event-${e.code}-sov-source-fronted`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{patient} ${s?.primary||""} {source} ${o} {event} ${a.primary} ${t.primary}`,tokens:l},extraction:c}}function Mp(r,e,t,a,i){let n=[];n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(l);}let u=e.roleMarkers.destination;if(u&&(n.push({type:"role",role:"destination",optional:false}),n.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),n.push({type:"role",role:"event",optional:false}),a.position==="after"){let l=a.primary.split(/\s+/);if(l.length>1)for(let c of l)n.push({type:"literal",value:c});else {let c=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(c);}}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return n.push(s),{id:`${r.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${a.primary} ${t.primary}`,tokens:n},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function Ip(r,e,t,a,i){let n=[];n.push({type:"role",role:"event",optional:false});let o=a.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&n.push({type:"literal",value:o[0],alternatives:o.slice(1)});let u=e.roleMarkers.destination;u&&n.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}]}),n.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};n.push(c);}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return n.push(l),n.push(...Qe(r,e.roleMarkers.source)),n.push(...Pr(r,e.roleMarkers.destination)),{id:`${r.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(i.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${t.primary}`,tokens:n},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Xe(r),...Je(r)}}}function $p(r,e,t,a,i){let n=[];if(n.push({type:"role",role:"event",optional:false}),a.position==="after"){let u=a.primary.split(/\s+/);if(u.length>1)for(let s of u)n.push({type:"literal",value:s});else {let s=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(s);}}let o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return n.push(o),{id:`${r.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{event} ${a.primary} ${t.primary}`,tokens:n},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function jp(r,e,t,a){let i=e.eventHandler?.temporalMarkers;if(!i||i.length===0)return null;let n=[];n.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&n.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),n.push({type:"literal",value:i[0],alternatives:i.slice(1)}),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(s);}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return n.push(u),{id:`${r.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(a.basePriority??100)+49,template:{format:`{event} ${i[0]} {patient} ${t.primary}`,tokens:n},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function Wp(r,e,t,a,i){let n=[];if(n.push({type:"role",role:"event",optional:false}),a.position==="after"){let p=a.primary.split(/\s+/);if(p.length>1)for(let d of p)n.push({type:"literal",value:d});else {let d=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(d);}}let u=[...r.roles.filter(p=>p.required)].sort((p,d)=>{let m=p.sovPosition??999,f=d.sovPosition??999;return m-f});for(let p of u){n.push({type:"role",role:p.role,optional:false});let{marker:d,alternatives:m}=dt(p,e);if(d){let f=m?{type:"literal",value:d,alternatives:m}:{type:"literal",value:d};n.push(f);}}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);let l=u.map(p=>`{${p.role}}`).join(" "),c={action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(u.map(p=>[p.role,{fromRole:p.role}]))};return Ot(n,c,r),{id:`${r.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`{event} ${a.primary} ${l} ${t.primary}`,tokens:n},extraction:c}}function qp(r,e,t,a,i){let n=[],u=[...r.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.sovPosition??999,m=p.sovPosition??999;return d-m});for(let c of u){n.push({type:"role",role:c.role,optional:false});let{marker:p,alternatives:d}=dt(c,e);p&&n.push(d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p});}if(n.push(t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary}),n.push({type:"role",role:"event",optional:false}),a.position==="after"){let c=a.primary.split(/\s+/);if(c.length>1)for(let p of c)n.push({type:"literal",value:p});else n.push(a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary});}let s=u.map(c=>`{${c.role}}`).join(" "),l={action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))};return Ot(n,l,r),{id:`${r.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`${s} ${t.primary} {event} ${a.primary}`,tokens:n},extraction:l}}function Vp(r,e,t,a,i){let n=[],u=[...r.roles.filter(h=>h.required)].sort((h,v)=>{let E=h.sovPosition??999,k=v.sovPosition??999;return E-k}),s=u[0];n.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:c}=dt(s,e);if(l){let h=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};n.push(h);}if(n.push({type:"role",role:"event",optional:false}),a.position==="after"){let h=a.primary.split(/\s+/);if(h.length>1)for(let v of h)n.push({type:"literal",value:v});else {let v=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(v);}}let p=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(p);let d=u[1];n.push({type:"role",role:d.role,optional:false});let{marker:m,alternatives:f}=dt(d,e);if(m){let h=f?{type:"literal",value:m,alternatives:f}:{type:"literal",value:m};n.push(h);}let y={action:{value:r.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[d.role]:{fromRole:d.role}};return Ot(n,y,r),{id:`${r.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{${s.role}} {event} ${a.primary} ${t.primary} {${d.role}}`,tokens:n},extraction:y}}function Ri(r,e,t){let a=We(r,e.code,t.primary)??[],i=[...new Set([...t.alternatives??[],...a])].filter(n=>n!==t.primary);return i.length?i:void 0}function ka(r,e,t,a,i){let n=[];if(a.position==="before"){let p=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(p);}n.push({type:"role",role:"event",optional:false});let o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(o);let u=Fi(r);n.push(...Pi(r,e,u));let s=e.roleMarkers.destination,l=r.roles.some(p=>p.role==="destination");s&&l&&u!=="destination"&&n.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}]}),u!=="source"&&n.push(...Qe(r,e.roleMarkers.source));let c={action:{value:r.action},event:{fromRole:"event"},[u]:{fromRole:u},...u==="destination"?{}:Xe(r),...u==="source"?{}:Je(r)};return Oi(n,c,r,e,new Set(["event",u,"destination","source"])),{id:`${r.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`${a.primary} {event} ${t.primary} {${u}} ${s?.primary||""} {destination?}`,tokens:n},extraction:c}}function Kp(r,e,t,a,i){let n=[],o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(o);let u=r.action==="swap";n.push({type:"role",role:u?"destination":"patient",optional:false});let s=u?void 0:e.roleMarkers.destination;if(s&&n.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}]}),n.push(...Qe(r,e.roleMarkers.source)),a.position==="before"){let c=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(c);}if(n.push({type:"role",role:"event",optional:false}),u){let c=r.roles.find(p=>p.role==="patient")?.markerOverride?.[e.code];c&&n.push({type:"group",optional:true,tokens:[{type:"literal",value:c},{type:"role",role:"patient",optional:false}]});}let l={action:{value:r.action},event:{fromRole:"event"},[u?"destination":"patient"]:{fromRole:u?"destination":"patient"},...u?{}:Xe(r),...Je(r)};return qr(n,l,r,e.code),{id:`${r.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`${t.primary} {patient} ${s?.primary||""} {destination?} ${a.primary} {event}`,tokens:n},extraction:l}}function Hp(r,e,t,a,i){let n=[],o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(o);let s=[...r.roles.filter(p=>p.required)].sort((p,d)=>{let m=p.svoPosition??999,f=d.svoPosition??999;return m-f});for(let p of s){let d,m;if(p.markerOverride&&p.markerOverride[e.code]!==void 0)d=p.markerOverride[e.code],m=d?We(p,e.code,d):void 0;else {let f=e.roleMarkers[p.role];f&&(d=f.primary,m=Ri(p,e,f));}if(d){let f=m?{type:"literal",value:d,alternatives:m}:{type:"literal",value:d};n.push(f);}n.push({type:"role",role:p.role,optional:false});}if(a.position==="before"){let p=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(p);}n.push({type:"role",role:"event",optional:false});let l=s.map(p=>`{${p.role}}`).join(" "),c={action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(s.map(p=>[p.role,{fromRole:p.role}]))};return Ot(n,c,r),{id:`${r.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${t.primary} ${l} ${a.primary} {event}`,tokens:n},extraction:c}}function wa(r,e,t,a,i){let n=[];if(a.position==="before"){let p=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(p);}n.push({type:"role",role:"event",optional:false});let o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(o);let s=[...r.roles.filter(p=>p.required)].sort((p,d)=>{let m=p.svoPosition??999,f=d.svoPosition??999;return m-f});for(let p of s){let d,m;if(p.markerOverride&&p.markerOverride[e.code]!==void 0)d=p.markerOverride[e.code],m=d?We(p,e.code,d):void 0;else {let f=e.roleMarkers[p.role];f&&(d=f.primary,m=Ri(p,e,f));}if(d){let f=m?{type:"literal",value:d,alternatives:m}:{type:"literal",value:d};n.push(f);}n.push({type:"role",role:p.role,optional:false});}let l=s.map(p=>`{${p.role}}`).join(" "),c={action:{value:r.action},event:{fromRole:"event"},...Object.fromEntries(s.map(p=>[p.role,{fromRole:p.role}]))};return Ot(n,c,r),{id:`${r.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`${a.primary} {event} ${t.primary} ${l}`,tokens:n},extraction:c}}function Up(r,e,t,a,i){let n=[],o=e.eventHandler?.negationMarker;if(a.position==="before"){let l=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};n.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(l);}n.push({type:"role",role:"event",optional:false});let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(u),n.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&n.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}]}),n.push(...Qe(r,e.roleMarkers.source)),{id:`${r.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${a.primary} ${o?.primary||""} {event} ${t.primary} {patient} ${s?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Xe(r),...Je(r)}}}function Gp(r,e,t,a){let i=[];i.push({type:"literal",value:"and",alternatives:["then"]}),i.push({type:"role",role:"event",optional:false});let n=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(n),i.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&i.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),i.push(...Qe(r,e.roleMarkers.source)),{id:`${r.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`[proclitic?] {event} ${t.primary} {patient} ${o?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:r.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Xe(r),...Je(r)}}}var vt={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function At(r,e,t=vt){let a=`${r.action}-${e.code}-generated`,i=t.basePriority??100,n=e.keywords[r.action];if(!n)throw new Error(`No keyword translation for '${r.action}' in ${e.code}`);let o=Jp(r,e,n),u=Kr(r,e),s=rd(r,e,n);return {id:a,language:e.code,command:r.action,priority:i,template:{format:s,tokens:o},extraction:u}}function Zp(r,e,t=vt){if(r.roles.filter(u=>!u.required).length===0)return null;let i=r.roles.filter(u=>u.required),n={...r,roles:i};return {...At(n,e,t),id:`${r.action}-${e.code}-generated-simple`,priority:(t.basePriority??100)-5,extraction:Kr(r,e)}}function za(r,e,t=vt){if(e.wordOrder!=="SOV")return null;let a=r.roles.filter(u=>u.required);if(a.length!==1)return null;let i=e.keywords[r.action];if(!i)return null;let n=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary},o=a.flatMap(u=>{let s=u.valuePrefixLiteral?.[e.code],l={type:"role",role:u.role,optional:false,expectedTypes:u.expectedTypes};return s?[{type:"literal",value:s},l]:[l]});return {id:`${r.action}-${e.code}-generated-verb-first`,language:e.code,command:r.action,priority:(t.basePriority??100)-20,template:{format:`${i.primary} <${a[0].role}>`,tokens:[n,...o]},extraction:Kr(r,e)}}function Yp(r,e,t=vt){let a=[];if(a.push(At(r,e,t)),t.generateSimpleVariants){let i=Zp(r,e,t);i&&a.push(i);}for(let i of r.omitRoleVariants??[]){let n={...r,roles:r.roles.filter(u=>u.role!==i)},o=At(n,e,t);a.push({...o,id:`${r.action}-${e.code}-generated-no-${i}`,priority:(t.basePriority??100)-8});}for(let i of r.widenTypeVariants??[]){if(i.excludeLanguages?.includes(e.code))continue;let n={...r,roles:r.roles.map(u=>u.role===i.role?{...u,expectedTypes:[...i.types]}:u)},o=At(n,e,t);a.push({...o,id:`${r.action}-${e.code}-generated-${i.idSuffix}`,priority:(t.basePriority??100)-(i.priorityDelta??15)});}if(t.generateVerbFirstVariants!==false){let i=za(r,e,t);i&&a.push(i);}for(let i of r.rolePrefixLiteralVariants??[]){let n=i.literal[e.code];if(!n)continue;let{rolePrefixLiteralVariants:o,...u}=r,s={...u,roles:r.roles.map(d=>d.role===i.role?{...d,valuePrefixLiteral:{[e.code]:n}}:d)},l=i.priorityDelta??5,c=i.methodCarrier?{[i.methodCarrier]:{value:n}}:{},p=At(s,e,t);if(a.push({...p,id:`${r.action}-${e.code}-generated-${i.idSuffix}`,priority:(t.basePriority??100)+l,extraction:{...p.extraction,...c}}),t.generateVerbFirstVariants!==false){let d=za(s,e,t);d&&a.push({...d,id:`${r.action}-${e.code}-generated-verb-first-${i.idSuffix}`,priority:(t.basePriority??100)-20+l,extraction:{...d.extraction,...c}});}}return a}function Vr(r,e=vt){let t=[],a=ns();for(let i of a){if(!r.keywords[i.action])continue;let n=Yp(i,r,e);if(t.push(...n),r.eventHandler?.eventMarker){let o=Xp(i,r,e);t.push(...o);}}return t}function Xp(r,e,t=vt){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let a=[],i=e.eventHandler.eventMarker,n=e.keywords[r.action];if(!n)return [];if(r.roles.length===0)return [];if(r.action==="js")return [];let u=r.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)a.push(Wp(r,e,n,i,t)),a.push(Vp(r,e,n,i,t)),a.push(qp(r,e,n,i,t));else {a.push(Lp(r,e,n,i,t)),a.push(_p(r,e,n,i,t));let s=Np(r,e,n,i,t);s&&a.push(s);let l=e.roleMarkers.destination;l&&l.primary!==i.primary&&a.push(Mp(r,e,n,i,t));let c=i.primary.split(/\s+/),p=i.alternatives?.some(m=>!m.includes(" ")&&m.length>1);c.length>1&&p&&a.push(Ip(r,e,n,i,t)),a.push($p(r,e,n,i,t));let d=jp(r,e,n,t);d&&a.push(d);}else e.wordOrder==="VSO"?u?(a.push(wa(r,e,n,i,t)),a.push(Hp(r,e,n,i,t))):(a.push(ka(r,e,n,i,t)),a.push(Kp(r,e,n,i,t)),e.eventHandler?.negationMarker&&a.push(Up(r,e,n,i,t)),e.tokenization?.prefixes&&a.push(Gp(r,e,n,t))):u?a.push(wa(r,e,n,i,t)):a.push(ka(r,e,n,i,t));return a}function Jp(r,e,t){let a=[],i=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},n=ed(r,e);switch(e.wordOrder){case "SVO":a.push(i),a.push(...n);break;case "SOV":a.push(...n),a.push(i);break;case "VSO":a.push(i),a.push(...n);break;default:a.push(i),a.push(...n);}return Qp(a)}function Qp(r){let e=[];for(let t of r){let a=e[e.length-1];if(a&&a.type==="literal"&&t.type==="literal"&&a.value===t.value){let i=[...a.alternatives??[],...t.alternatives??[]];i.length&&(e[e.length-1]={...a,alternatives:[...new Set(i)]});continue}e.push(t);}return e}function ed(r,e){let t=[],a=Bi(r.roles,e.wordOrder);for(let i of a){let n=Li(i,e);i.required?t.push(...n):t.push({type:"group",optional:true,tokens:n});}return t}function Li(r,e){let t=[],a=r.markerOverride?.[e.code],i=e.roleMarkers[r.role],n=r.renderOverride?.[e.code]==="",o={type:"role",role:r.role,optional:!r.required,expectedTypes:r.expectedTypes,...r.valueShape!==void 0?{valueShape:r.valueShape}:{}},u=r.valuePrefixLiteral?.[e.code],s=()=>{u&&t.push({type:"literal",value:u}),t.push(o);};if(a!==void 0){let l=a?a.split(/\s+/).filter(Boolean):[],c=a!==void 0&&a===r.markerOverride?.en,p=i?.position??(e.wordOrder==="SOV"&&!c?"after":"before"),d=r.markerOptional?.[e.code]===true,m=f=>{let y=l.length===1?We(r,e.code,f)??[]:[],h={type:"literal",value:f,...y.length?{alternatives:y}:{},...n?{renderSuppress:true}:{}};t.push(d?{type:"group",optional:true,tokens:[h]}:h);};if(p==="before"){for(let f of l)m(f);s();}else {s();for(let f of l)m(f);}}else if(i){let l=()=>{let p=[...new Set([...i.alternatives??[],...We(r,e.code,i.primary)??[]])].filter(d=>d!==i.primary);return {type:"literal",value:i.primary,...p.length?{alternatives:p}:{},...n?{renderSuppress:true}:{}}},c=p=>{if(!e.markersOptional&&!r.markerOptional?.[e.code]){t.push(p);return}t.push({type:"group",optional:true,...e.markersOptional&&!r.markerOptional?.[e.code]?{renderRequired:true}:{},tokens:[p]});};i.position==="before"?(i.primary&&c(l()),s()):(s(),c(l()));}else s();return t}function td(r,e){let t={};for(let a of r.roles){let i=a.markerOverride?.[e.code],n=e.roleMarkers[a.role];if(a.valuePrefixLiteral?.[e.code])t[a.role]={marker:a.valuePrefixLiteral[e.code]};else if(i!==void 0)if(!i)t[a.role]={};else {let u=!/\s/.test(i.trim())?We(a,e.code,i)??[]:[];t[a.role]=u.length?{marker:i,markerAlternatives:u}:{marker:i};}else if(n&&n.primary){let o=[...new Set([...n.alternatives??[],...We(a,e.code,n.primary)??[]])].filter(u=>u!==n.primary);t[a.role]=o.length?{marker:n.primary,markerAlternatives:o}:{marker:n.primary};}else t[a.role]={};}return t}function Kr(r,e){let t=td(r,e),a={};for(let i of r.roles){let n=t[i.role]||{};!i.required&&i.default?a[i.role]={...n,default:i.default}:a[i.role]=n;}return a}function rd(r,e,t){let a=[],n=Bi(r.roles,e.wordOrder).map(o=>{let u=Op(o,e),s="";return u&&u.primary?u.position==="before"?s=`${u.primary} {${o.role}}`:s=`{${o.role}} ${u.primary}`:s=`{${o.role}}`,o.required?s:`[${s}]`});switch(e.wordOrder){case "SVO":case "VSO":a.push(t.primary,...n);break;case "SOV":a.push(...n,t.primary);break;default:a.push(t.primary,...n);}return a.join(" ")}var ad=[Wo,qo,xs,el,dl,bl,_l,Gl,m0,C0,_0,U0,rc,yc,Ic,jc,qc,Gc,Xc,up,tl],ba=new Map;function id(r){let e=ba.get(r);if(e)return e;let t=T(r);if(!t)return [];let a=Vr(t);return ba.set(r,a),a}function nd(r){let e=ad.flatMap(t=>t(r));return r==="en"&&e.push(...Pp()),e.push(...id(r)),e.map(ud)}var od=new Set(["on.source"]);function ud(r){let e=ue(r.command);if(!e)return r;let t;for(let a of e.roles){if(a.required||!a.default||od.has(`${r.command}.${a.role}`))continue;let i=r.extraction?.[a.role];i?.default!==void 0||i?.value!==void 0||(t??(t={...r.extraction}),t[a.role]={...i,default:a.default});}return t?{...r,extraction:t}:r}function sd(r){return nd(r.code)}$r(sd);var Hr=["is not really equal to","is really equal to","is greater than or equal to","is less than or equal to","is not equal to","is equal to","is greater than","is less than","is not really","is really","is not equal","is equal","is not in","is in","is not","is","am not in","am in","am","does not match","do not match","does not contain","does not contains","do not contain","does not include","does not precede","does not follow","precedes","follows","really equals","equals","matches","match","contains","contain","includes","include","has","have","in"],Ur=["is not empty","is empty","does not exist"],Gr=["is not an","is not a","is an","is a"],ld=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),cd=new Set(["and","or","not","no"]),pd=new Set(["true","false","null","undefined"]),dd=new Set(Hr.map(r=>r.slice(r.lastIndexOf(" ")+1))),md=new Set(["next","previous","closest","first","last"]),fd=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function _i(r){let e=[],t=0,a=1,i=1;function n(){if(e.length===0)return true;let f=e[e.length-1];return f.type==="IDENTIFIER"&&dd.has(f.value.toLowerCase())||f.type==="IDENTIFIER"&&md.has(f.value.toLowerCase())||f.type==="IDENTIFIER"&&f.value.toLowerCase()==="of"?true:["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(f.type)}function o(f=0){return r[t+f]??""}function u(){let f=r[t];return t++,f===`
|
|
4
|
+
`?(a++,i=1):i++,f}function s(){for(;t<r.length&&/\s/.test(r[t]);)u();}function l(f){let y="";for(;t<r.length&&f(r[t]);)y+=u();return y}function c(f){let y=f;for(u();t<r.length&&r[t]!==f;)r[t]==="\\"&&t+1<r.length&&(y+=u()),y+=u();return t<r.length&&(y+=u()),y}function p(){let f="`";for(u();t<r.length&&r[t]!=="`";)r[t]==="\\"&&t+1<r.length&&(f+=u()),f+=u();return t<r.length&&(f+=u()),f}function d(){let f="<";for(u();t<r.length&&(f+=u(),!f.endsWith("/>")););return f}function m(f,y,h){return {type:f,value:y,start:h,end:t,line:a,column:i-y.length}}for(;t<r.length&&(s(),!(t>=r.length));){let f=t,y=o();if(y==="'"&&o(1)==="s"&&!/\w/.test(o(2))){u(),u(),e.push(m("POSSESSIVE","'s",f));continue}if(y==='"'||y==="'"){let h=c(y);e.push(m("STRING",h,f));continue}if(y==="`"){let h=p();e.push(m("TEMPLATE_LITERAL",h,f));continue}if(y==="<"&&/[a-zA-Z.#\[]/.test(o(1))){let h=d();e.push(m("QUERY_SELECTOR",h,f));continue}if(y==="#"&&n()){u();let h=l(v=>/[\w-]/.test(v));e.push(m("ID_SELECTOR","#"+h,f));continue}if(y==="."&&/[a-zA-Z_-]/.test(o(1))&&n()){u();let h=l(v=>/[\w-]/.test(v));e.push(m("CLASS_SELECTOR","."+h,f));continue}if(y==="@"&&/[a-zA-Z_]/.test(o(1))){u();let h=l(v=>/[\w-]/.test(v));e.push(m("ATTRIBUTE_REF","@"+h,f));continue}if(y==="["&&n()&&o(1)==="@"){let v="";for(v+=u();t<r.length&&r[t]!=="]";)r[t]==='"'||r[t]==="'"?v+=c(r[t]):v+=u();t<r.length&&(v+=u()),e.push(m("ATTRIBUTE_SELECTOR",v,f));continue}if(y==="["){u(),e.push(m("LBRACKET","[",f));continue}if(y==="]"){u(),e.push(m("RBRACKET","]",f));continue}if(/\d/.test(y)){let h=l(k=>/[\d.]/.test(k)),v=t,E=l(k=>/[a-zA-Z]/.test(k));fd.has(E)?e.push(m("TIME_EXPRESSION",h+E,f)):(t=v,e.push(m("NUMBER",h,f)));continue}if(y==="("){u(),e.push(m("LPAREN","(",f));continue}if(y===")"){u(),e.push(m("RPAREN",")",f));continue}if(y==="{"){u(),e.push(m("LBRACE","{",f));continue}if(y==="}"){u(),e.push(m("RBRACE","}",f));continue}if(y===","){u(),e.push(m("COMMA",",",f));continue}if(y===":"){u(),e.push(m("COLON",":",f));continue}if(y==="."){u(),e.push(m("DOT",".",f));continue}if(y==="|"){u(),e.push(m("PIPE","|",f));continue}if(y==="+"||y==="-"||y==="*"||y==="/"||y==="%"){u(),e.push(m("OPERATOR",y,f));continue}if(y==="="||y==="!"||y==="<"||y===">"){let h=u();o()==="="&&(h+=u()),(h==="=="||h==="!=")&&o()==="="&&(h+=u()),e.push(m("COMPARISON",h,f));continue}if(/[a-zA-Z_$]/.test(y)){let h=l(E=>/[\w$]/.test(E)),v=h.toLowerCase();ld.has(v)?e.push(m("CONTEXT_VAR",h,f)):cd.has(v)?e.push(m("LOGICAL",h,f)):pd.has(v)?e.push(m("BOOLEAN",h,f)):e.push(m("IDENTIFIER",h,f));continue}u();}return e.push(m("EOF","",t)),e}var yd=new Set(["my","its","your"]),vd={my:"me",its:"it",your:"you"},hd=new Set(["is","matches","match","contains","in","exists","does"]),Ed=new Set(["next","previous","closest","first","last"]),gd=[...Ur,...Gr,...Hr].map(r=>[r,r.split(" ")]),kd=class{constructor(){this.tokens=[],this.current=0;}parse(r){try{return this.tokens=_i(r),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(e){return {success:false,error:e instanceof Error?e.message:"Parse error"}}}peek(){return this.tokens[this.current]??{type:"EOF",value:"",start:0,end:0}}peekAt(r){return this.tokens[this.current+r]??{type:"EOF",value:"",start:0,end:0}}previous(){return this.tokens[this.current-1]??{type:"EOF",value:"",start:0,end:0}}isAtEnd(){return this.peek().type==="EOF"}advance(){return this.isAtEnd()||this.current++,this.previous()}check(r){return this.peek().type===r}checkValue(r){return this.peek().value.toLowerCase()===r.toLowerCase()}match(...r){for(let e of r)if(this.check(e))return this.advance(),true;return false}parseExpression(){return this.parseOr()}parseOr(){let r=this.parseAnd();for(;this.checkValue("or");){let e=this.advance().value,t=this.parseAnd();r=this.createBinaryExpression(e,r,t);}return r}parseAnd(){let r=this.parseEquality();for(;this.checkValue("and");){let e=this.advance().value,t=this.parseEquality();r=this.createBinaryExpression(e,r,t);}return r}parseEquality(){let r=this.parseComparison();for(;;){if(this.match("COMPARISON")){let t=this.previous().value;r=this.createBinaryExpression(t,r,this.parseComparison());continue}let e=this.matchComparisonPhrase();if(e===void 0)break;if(Ur.includes(e))r=this.createPostfixUnary(e,r);else if(Gr.includes(e))r=this.parseTypeCheck(r,e.startsWith("is not"));else {let t=e==="match"?"matches":e;r=this.createBinaryExpression(t,r,this.parseComparison());}}return r}matchComparisonPhrase(){for(let[r,e]of gd)if(e.every((t,a)=>this.peekAt(a).value.toLowerCase()===t)){for(let t=0;t<e.length;t++)this.advance();return r}}parseTypeCheck(r,e){let t=this.advance();if(t.type==="EOF")throw new Error(`Expected a type name after 'is ${e?"not ":""}a'`);let a=true;return this.peek().value==="!"&&(this.advance(),a=false),{type:"typeCheckExpression",value:r,typeName:t.value,nullOk:a,negated:e,start:r.start,end:this.previous().end}}parseComparison(){let r=this.parseAddition();for(;this.check("COMPARISON");){let e=this.advance().value,t=this.parseAddition();r=this.createBinaryExpression(e,r,t);}return r}parseAddition(){let r=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let e=this.advance().value,t=this.parseMultiplication();r=this.createBinaryExpression(e,r,t);}return r}parseMultiplication(){let r=this.parseConversion();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%"||this.checkValue("mod");){let e=this.advance().value.toLowerCase(),t=this.parseConversion();r=this.createBinaryExpression(e,r,t);}return r}parseConversion(){let r=this.parseUnary();for(;this.checkValue("as")&&this.conversionTypeAt(1)!==void 0;)for(this.advance(),r=this.createAsExpression(r,this.parseConversionType());this.check("PIPE")&&this.conversionTypeAt(1)!==void 0;)this.advance(),r=this.createAsExpression(r,this.parseConversionType());return r}conversionTypeAt(r){let e=this.peekAt(r).value.toLowerCase(),t=e==="a"||e==="an"?r+1:r;return this.peekAt(t).type==="IDENTIFIER"?t:void 0}parseConversionType(){let r=this.conversionTypeAt(0)??0;for(let i=0;i<r;i++)this.advance();let e=this.advance(),t=this.peekAt(1).type;if(!this.check("COLON")||t!=="NUMBER"&&t!=="IDENTIFIER")return e;this.advance();let a=this.advance();return {...e,value:`${e.value}:${a.value}`,end:a.end}}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let r=this.advance().value,e=this.parseUnary();return this.createUnaryExpression(r,e)}return this.parsePostfix()}parsePostfix(){let r=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance();r=this.createMemberExpression(r,this.createIdentifier(e.value,e),false);}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance();r=this.createPossessiveExpression(r,this.createIdentifier(e.value,e));}else break;else if(this.match("LPAREN")){let e=this.parseArguments();r=this.createCallExpression(r,e);}else if(this.match("LBRACKET")){let e=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");r=this.createMemberExpression(r,e,true);}else if(r.type==="identifier"&&yd.has(r.name)&&this.check("IDENTIFIER")&&!hd.has(this.peek().value.toLowerCase())){let e=this.advance(),t=r,a={...t,name:vd[t.name]??t.name};r=this.createMemberExpression(a,this.createIdentifier(e.value,e),false);}else if(this.checkValue("exists")&&this.peekAt(1).type!=="LPAREN")this.advance(),r=this.createPostfixUnary("exists",r);else break;return r}parsePrimary(){let r=this.peek();if(this.checkValue("the")&&(this.peekAt(1).type==="IDENTIFIER"||this.peekAt(1).type==="CONTEXT_VAR")&&this.peekAt(2).value.toLowerCase()==="of")return this.advance(),this.parsePropertyOf(this.advance(),r,false);if(this.match("NUMBER"))return this.createLiteral(parseFloat(r.value),"number",r);if(this.match("STRING")){let e=r.value.slice(1,-1);return this.createLiteral(e,"string",r)}if(this.match("BOOLEAN")){let e=r.value==="true"?true:r.value==="false"?false:r.value==="null"?null:void 0,t={true:"boolean",false:"boolean",null:"null",undefined:"undefined"};return this.createLiteral(e,t[r.value]??"string",r)}if(this.match("TEMPLATE_LITERAL")){let e=r.value;return {type:"templateLiteral",value:e.length>=2&&e.startsWith("`")&&e.endsWith("`")?e.slice(1,-1):e,start:r.start,end:r.end,line:r.line,column:r.column}}if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(r);if(this.match("ID_SELECTOR"))return this.createSelector(r.value,"id",r);if(this.match("CLASS_SELECTOR"))return this.createSelector(r.value,"class",r);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(r.value,"attribute",r);if(this.match("ATTRIBUTE_REF")){let e={type:"attributeAccess",attributeName:r.value.slice(1),start:r.start,end:r.end};return this.checkValue("of")?(this.advance(),this.createBinaryExpression("of",e,this.parseConversion())):e}if(this.match("QUERY_SELECTOR")){let e=r.value.slice(1,-2);return this.createSelector(e,"query",r)}if(this.match("CONTEXT_VAR"))return this.createIdentifier(r.value,r);if(this.match("IDENTIFIER")){if(Ed.has(r.value.toLowerCase())&&(this.check("CLASS_SELECTOR")||this.check("ID_SELECTOR")||this.check("QUERY_SELECTOR"))){let e=this.advance(),t=e.type==="QUERY_SELECTOR"?e.value.slice(1,-2):e.value,a=e.type==="CLASS_SELECTOR"?"class":e.type==="ID_SELECTOR"?"id":"query";return {type:"callExpression",callee:this.createIdentifier(r.value,r),arguments:[this.createSelector(t,a,e)],start:r.start,end:e.end}}return this.checkValue("of")?this.parsePropertyOf(r,r):this.createIdentifier(r.value,r)}if(this.match("LPAREN")){let e=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return e}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${r.value}`)}parsePropertyOf(r,e,t=true){this.advance();let a=t?this.parseConversion():this.parseUnary();return {type:"propertyOfExpression",property:this.createIdentifier(r.value,r),target:a,start:e.start,end:this.previous().end}}parseArguments(){let r=[];if(!this.check("RPAREN"))do r.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return r}parseArrayLiteral(){let r=[],e=this.previous().start;if(!this.check("RBRACKET"))do r.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return {type:"arrayLiteral",elements:r,start:e,end:this.previous().end}}parseObjectLiteral(){let r=[],e=this.previous().start;if(!this.check("RBRACE"))do{let t;if(this.check("STRING"))t=this.advance().value.slice(1,-1);else if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR"))t=this.advance().value;else throw new Error("Expected property name");if(!this.match("COLON"))throw new Error("Expected : after property name");let a=this.parseExpression();r.push({key:t,value:a});}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return {type:"objectLiteral",properties:r.map(t=>({type:"objectProperty",key:{type:"identifier",name:t.key},value:t.value})),start:e,end:this.previous().end}}parseTimeExpression(r){let e=r.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!e)throw new Error(`Invalid time expression: ${r.value}`);let t=parseFloat(e[1]),a=e[2].toLowerCase();return {type:"timeExpression",value:t,unit:a,raw:r.value,start:r.start,end:r.end,line:r.line,column:r.column}}createLiteral(r,e,t){return {type:"literal",value:r,dataType:e,raw:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createSelector(r,e,t){return {type:"selector",value:r,selector:r,selectorType:e,start:t.start,end:t.end,line:t.line,column:t.column}}createIdentifier(r,e){return {type:"identifier",name:r,start:e.start,end:e.end,line:e.line,column:e.column}}createMemberExpression(r,e,t){return {type:"memberExpression",object:r,property:e,computed:t,start:r.start,end:this.previous().end}}createPossessiveExpression(r,e){return {type:"possessiveExpression",object:r,property:e,start:r.start,end:this.previous().end}}createBinaryExpression(r,e,t){return {type:"binaryExpression",operator:r,left:e,right:t,start:e.start,end:t.end}}createAsExpression(r,e){return {type:"asExpression",expression:r,targetType:this.createIdentifier(e.value,e),start:r.start,end:e.end}}createUnaryExpression(r,e){return {type:"unaryExpression",operator:r,operand:e,prefix:true,start:this.previous().start,end:e.end}}createPostfixUnary(r,e){return {type:"unaryExpression",operator:r,operand:e,prefix:false,start:e.start,end:this.previous().end}}createCallExpression(r,e){return {type:"callExpression",callee:r,arguments:e,start:r.start,end:this.previous().end}}};function wd(r){return new kd().parse(r)}var Ni={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function Vt(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)):r==="expression"?e.some(t=>["selector","reference","expression"].includes(t)):false}function Pe(r,e){let t=r.possessive?.keywords?.[e];if(t)return t;let a=r.possessive?.specialForms;if(a){for(let[i,n]of Object.entries(a))if(n===e)return i}}function vr(r){return Ni.possessive?.specialForms?.[r]??`${r}'s`}var ar=new Set(["+","-","*","/","%","<",">","<=",">=","==","!=","===","!=="]),Mi=new Set(["<",">","<=",">=","==","!=","===","!=="]),Ve=new Set([...ar,"mod"]),Hd=/^[<>=!+\-*/%]+$/,Ii={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\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","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"])};function Ud(r){return Ii[r]}function ir(r,e){return Ii[e]?.has(r.toLowerCase())??false}var Zr={ar:{\u0642\u064A\u0645\u0629:"value"},bn:{\u0985\u0995\u09CD\u09B7\u09AE:"disabled",\u0986\u0987\u09A1\u09BF:"id","\u099A\u09C7\u0995 \u0995\u09B0\u09BE":"checked",\u09A6\u09C8\u09B0\u09CD\u0998\u09CD\u09AF:"length",\u09AE\u09BE\u09A8:"value"},de:{wert:"value"},es:{valor:"value"},fr:{valeur:"value"},hi:{\u0905\u0915\u094D\u0937\u092E:"disabled",\u091A\u0947\u0915:"checked",\u091B\u093F\u092A\u093E:"hidden",\u092E\u093E\u0928:"value"},id:{nilai:"value"},it:{valore:"value"},ja:{\u5024:"value"},ko:{\uAC12:"value"},ms:{dilumpuhkan:"disabled",ditanda:"checked",nilai:"value",panjang:"length"},pl:{warto\u015B\u0107:"value"},pt:{valor:"value"},qu:{chanin:"value"},ru:{\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435:"value",\u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u043E:"disabled",\u043E\u0442\u043C\u0435\u0447\u0435\u043D\u043E:"checked",\u0441\u043A\u0440\u044B\u0442\u043E:"hidden"},sw:{thamani:"value"},th:{\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27:"length",\u0E04\u0E48\u0E32:"value",\u0E1B\u0E34\u0E14\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19:"disabled",\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E41\u0E25\u0E49\u0E27:"checked",\u0E44\u0E2D\u0E14\u0E35:"id"},tl:{haba:"length",halaga:"value",hindi_pinagana:"disabled",naka_tsek:"checked"},tr:{de\u011Fer:"value"},uk:{\u0432\u0438\u043C\u043A\u043D\u0435\u043D\u043E:"disabled",\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F:"value",\u043F\u043E\u0437\u043D\u0430\u0447\u0435\u043D\u043E:"checked",\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u043D\u043E:"hidden"},vi:{\u1EA9n:"hidden","\u0111\u01B0\u1EE3c ch\u1ECDn":"checked","gi\xE1 tr\u1ECB":"value","v\xF4 hi\u1EC7u":"disabled"},zh:{\u503C:"value"}},Gd={ar:{\u0623\u0648:"or",\u0643\u0640:"as",\u0644\u064A\u0633:"not",\u0648:"and",\u064A\u062D\u062A\u0648\u064A:"contains",\u064A\u0633\u0627\u0648\u064A:"equals",\u064A\u0634\u0645\u0644:"includes"},bn:{\u0985\u09A5\u09AC\u09BE:"or",\u098F\u09AC\u0982:"and",\u09A8\u09BE:"not",\u09B9\u09BF\u09B8\u09BE\u09AC\u09C7:"as"},de:{als:"as",beinhaltet:"includes",enth\u00E4lt:"contains",gleicht:"equals",nicht:"not",oder:"or",und:"and"},es:{como:"as",contiene:"contains",iguala:"equals",incluye:"includes",no:"not",o:"or",y:"and"},fr:{comme:"as",contient:"contains",\u00E9gale:"equals",et:"and",inclut:"includes",non:"not",ou:"or"},he:{\u05D5\u05D2\u05DD:"and"},hi:{\u0914\u0930:"and",\u0915\u0947_\u0930\u0942\u092A_\u092E\u0947\u0902:"as",\u0928\u0939\u0940\u0902:"not",\u092C\u0930\u093E\u092C\u0930:"equals",\u092E\u0947\u0902_\u0939\u0948:"includes",\u092F\u093E:"or",\u0936\u093E\u092E\u093F\u0932:"contains"},id:{atau:"or",berisi:"contains",bukan:"not",dan:"and",sama:"equals",sebagai:"as",termasuk:"includes"},it:{come:"as",contiene:"contains",e:"and",include:"includes",non:"not",o:"or",uguale:"equals"},ja:{\u305D\u3057\u3066:"and",\u3067\u306F\u306A\u3044:"not",\u3068\u3057\u3066:"as",\u307E\u305F\u306F:"or",\u542B\u3080:"contains",\u542B\u3081\u308B:"includes",\u7B49\u3057\u3044:"equals"},ko:{\uAC19\uB2E4:"equals",\uADF8\uB9AC\uACE0:"and",\uB610\uB294:"or",\uB85C:"as",\uC544\uB2C8:"not",\uD3EC\uD568:"contains",\uD3EC\uD568\uD558\uB2E4:"includes"},ms:{atau:"or",bukan:"not",dan:"and",mengandungi:"contains",sama:"equals",sebagai:"as",termasuk:"includes"},pl:{i:"and",jako:"as",lub:"or",nie:"not",obejmuje:"includes","r\xF3wna si\u0119":"equals",zawiera:"contains"},pt:{como:"as",cont\u00E9m:"contains",e:"and",igual:"equals",inclui:"includes",n\u00E3o:"not",ou:"or"},qu:{churasqa:"includes",hina:"as",hinallataq:"and",kikin:"equals",ukupi_kan:"contains",utaq:"or"},ru:{\u0432\u043A\u043B\u044E\u0447\u0430\u0435\u0442:"includes",\u0438:"and",\u0438\u043B\u0438:"or",\u043A\u0430\u043A:"as",\u043D\u0435:"not",\u0440\u0430\u0432\u043D\u043E:"equals",\u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442:"contains"},sw:{au:"or",ina:"contains",kuwa:"as",pamoja:"includes",sawa:"equals",si:"not"},th:{\u0E44\u0E21\u0E48:"not",\u0E41\u0E25\u0E30:"and",\u0E2B\u0E23\u0E37\u0E2D:"or"},tl:{at:"and",bilang:"as",hindi:"not",katumbas:"equals",naglalaman:"contains",o:"or"},tr:{de\u011Fil:"not",e\u015Fittir:"equals",i\u00E7erir:"contains",olarak:"as",ve:"and",veya:"or"},uk:{\u0430\u0431\u043E:"or",\u0432\u043A\u043B\u044E\u0447\u0430\u0454:"includes",\u0434\u043E\u0440\u0456\u0432\u043D\u044E\u0454:"equals",\u0456:"and",\u043C\u0456\u0441\u0442\u0438\u0442\u044C:"contains",\u043D\u0435:"not",\u044F\u043A:"as"},vi:{b\u1EB1ng:"equals",ch\u1EE9a:"contains",ho\u1EB7c:"or",kh\u00F4ng:"not",nh\u01B0:"as",v\u00E0:"and"},zh:{\u4F5C\u4E3A:"as",\u5305\u542B:"contains",\u5305\u62EC:"includes",\u548C:"and",\u6216:"or",\u7B49\u4E8E:"equals",\u975E:"not"}},$i={ms:new Set(["daripada"]),sw:new Set(["ya"]),vi:new Set(["c\u1EE7a"]),zh:new Set(["\u7684"]),it:new Set(["di"]),pl:new Set(["z"]),uk:new Set(["\u0437"]),th:new Set(["\u0E02\u0E2D\u0E07"]),ar:new Set(["\u0644\u0640"]),ja:new Set(["\u306E"]),ko:new Set(["\uC758"]),bn:new Set(["\u09B0"]),hi:new Set(["\u0915\u093E"]),qu:new Set(["pa"]),tr:new Set(["nin","n\u0131n","nun","n\xFCn","in","\u0131n","un","\xFCn"])};function He(r,e){let t=e.value.toLowerCase(),a=(e.normalized??"").toLowerCase();if(t==="of"||t==="ng"||a==="of"||a==="source")return true;let i=r?.code?$i[r.code]:void 0;return !!i&&i.has(t)}var Zd={destination:"in",source:"from"},ji={ar:new Set(["\u0639\u0646\u062F","\u0641\u064A"]),bn:new Set(["\u098F","\u09A4\u09C7"]),de:new Set(["bei"]),es:new Set(["en"]),fr:new Set(["dans","en","\xE0"]),he:new Set(["\u05DC\u05EA\u05D5\u05DA"]),hi:new Set(["\u092A\u0930","\u092E\u0947\u0902"]),id:new Set(["dalam","di","ke_dalam"]),it:new Set(["a"]),ja:new Set(["\u3067","\u306E\u4E2D","\u3078"]),ko:new Set(["\uC548\uC5D0","\uC5D0","\uC73C\uB85C"]),ms:new Set(["dalam","di","ke_dalam"]),pl:new Set(["do","przy","w"]),pt:new Set(["dentro","em"]),qu:new Set(["pi","ukupi"]),ru:new Set(["\u0432","\u0443"]),sw:new Set(["katika","ndani"]),th:new Set(["\u0E17\u0E35\u0E48","\u0E43\u0E19"]),tl:new Set(["papasok_sa","sa","sa_loob"]),tr:new Set(["de","i\xE7inde","i\xE7ine"]),uk:new Set(["\u0432","\u0443"]),vi:new Set(["trong","t\u1EA1i","v\xE0o"]),zh:new Set(["\u5728","\u8FDB\u5165"])},Wi=new Set(["in","into","at","within","inside"]);function Yd(r,e){let t=e.value.toLowerCase();if((r?.code?ji[r.code]:void 0)?.has(t))return "in";let i=e.normalized??e.value,n=i.toLowerCase();return Wi.has(n)?"in":Zd[n]??i}function Xd(r,e){return e.value.toLowerCase()==="in"||(r?.code?ji[r.code]:void 0)?.has(e.value.toLowerCase())?true:Wi.has((e.normalized??e.value).toLowerCase())}var Jd=new Set(["me","it","you","body","document","target","result"]);function Qd(r,e){let t=r[e];if(!t)return null;if(t.kind==="selector")return /^[*@]/.test(t.value)?null:{kind:"selector",parts:[{text:t.value,token:t}],consumed:1};let a=(t.normalized??t.value).toLowerCase();if(Jd.has(a))return {kind:"reference",parts:[{text:a,token:t}],consumed:1};let i=r[e+1];return a==="closest"&&i?.kind==="selector"&&!/^[*@]/.test(i.value)?{kind:"closest",parts:[{text:"closest",token:t},{text:i.value,token:i}],consumed:2}:null}function qi(r,e,t,a){let i=r[e];if(!i||!Xd(t,i))return null;let n=Qd(r,e+1);if(!n)return null;let o=r[e+1+n.consumed];return a?.(i)===true&&a(o)!==true?null:{marker:i,scope:n}}var hr=new Set(["first","last","next","previous","random","closest"]),em={bn:{\u09B6\u09C7\u09B7:"last"}},ht=new Set(Object.keys(le).map(r=>r.toLowerCase()));function St(r,e,t,a){let i=r[e];if(!i)return null;let n=(i.normalized??i.value).toLowerCase(),o=r[e+1],u=t?.code&&o?.kind==="selector"&&o.value.startsWith("<")?em[t.code]?.[i.value.toLowerCase()]:void 0;if(!hr.has(n)&&!hr.has(i.value.toLowerCase())&&u===void 0)return null;let s=[{text:u??i.normalized??i.value,token:i}],l=e+1,c=r[l];if(!c||c.kind!=="selector"||Mi.has(c.value))return null;s.push({text:c.value,token:c}),l++;let p=0;for(;p++<8;){let f=r[l];if(f&&f.kind==="selector"&&f.value.startsWith("."))s.push({text:f.value,token:f}),l++;else break}let d=r[l],m=r[l+1];if(d&&m&&m.kind==="selector"&&!/^[*@]/.test(m.value)&&(d.kind==="keyword"||d.kind==="particle"||d.kind==="identifier")&&!hr.has((d.normalized??d.value).toLowerCase())&&!ht.has((d.normalized??d.value).toLowerCase())&&!(a?.(d)===true&&a(r[l+2])!==true))s.push({text:Yd(t,d),token:d}),s.push({text:m.value,token:m}),l+=2;else {let f=qi(r,l,t,a);f&&f.scope.kind!=="selector"&&(s.push({text:"in",token:f.marker},...f.scope.parts),l+=1+f.scope.consumed);}return {parts:s,consumed:l-e}}function Ye(r,e){let t=Gd[r];return t?t[e.toLowerCase()]??e:e}function ge(r,e){let t=Zr[r];return t?t[e.toLowerCase()]??e:e}function xa(r,e){return Zr[r]?.[e.toLowerCase()]!==void 0}function tm(r,e){let t=[e.value,e.normalized].filter(Boolean);for(let a of t){let i=Pe(r,a)??Pe(r,a.toLowerCase());if(i)return i}}function Vi(r){return r.kind==="literal"||r.kind==="operator"||r.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(r.value)}function rm(r,e){let t=r?.references;if(!t)return false;let a=Object.values(t).filter(n=>typeof n=="string").map(n=>n.toLowerCase());return [e.value,e.normalized].filter(Boolean).some(n=>a.includes(n.toLowerCase()))}function ut(r,e){return Vi(r)?ge(e,r.value)!==r.value?true:r.kind==="identifier":false}var am=new Set(["true","false","null","undefined","me","my","it","its","you","your","result","event","target","body","detail","document","window"]);function Ki(r){return r.kind==="literal"||r.kind==="selector"||r.kind==="reference"?true:r.kind==="identifier"?nm.test(r.value):r.kind==="keyword"&&am.has((r.normalized??r.value).toLowerCase())}function Da(r){return !!r&&(r.value===")"||r.value==="]"||Ki(r))}function xr(r){if(!r)return false;if(/^[([-]$/.test(r.value)||Ki(r))return true;let e=(r.normalized??"").toLowerCase();return r.kind==="keyword"&&(e==="not"||e==="no")}var im=/^\.[\p{L}_-][\p{L}\p{N}_-]*$/u,nm=/^(?:[:$]?[\p{L}_][\p{L}\p{M}\p{N}_]*|\([\p{L}_$][\p{L}\p{M}\p{N}_$]*\))$/u,U={beforeClassRef:"has"},om={ar:{\u0647\u0648:{beforePredicate:"is",afterOperand:"is"},\u0641\u0627\u0631\u063A:{afterCopula:"empty"}},hi:{\u0939\u0948:{beforePredicate:"is",beforeClassRef:"has",afterOperand:"is"},\u0916\u093E\u0932\u0940:{afterCopula:"empty"}},id:{kosong:{afterCopula:"empty"},punya:U},th:{\u0E40\u0E1B\u0E47\u0E19:{beforeTypeName:"as",beforePredicate:"is",afterOperand:"is"},\u0E27\u0E48\u0E32\u0E07:{afterCopula:"empty"},\u0E21\u0E35:U},ja:{\u7A7A:{afterCopula:"empty"},\u3042\u308B:U},sw:{tupu:{afterCopula:"empty",otherwise:"null"},na:{betweenOperands:"and"},ana:U,nina:U},zh:{\u6CA1\u6709:{beforeBareIdentifier:"no",beforeSelector:"no"},\u6709:U},tl:{walang:{beforeBareIdentifier:"no",beforeSelector:"no"},may:{afterSubject:"exists",beforeClassRef:"has"}},bn:{\u0986\u099B\u09C7:{afterSubject:"exists",beforeClassRef:"has"},\u0986\u099B\u09BF:U},qu:{mana:{beforeOperand:"not"},chusaq:{afterCopula:"empty"},kachkan:U,kachkani:U},tr:{var:{afterSubject:"exists",beforeClassRef:"has"},bo\u015F:{afterCopula:"empty"}},de:{hat:U,habe:U},es:{tiene:U,tengo:U},fr:{a:U,ai:U},it:{ha:U,ho:U},ko:{\uC788\uB2E4:U},ms:{ada:U},pl:{ma:U,mam:U},pt:{tem:U,tenho:U},ru:{\u0438\u043C\u0435\u0435\u0442:U,\u0438\u043C\u0435\u044E:U},uk:{\u043C\u0430\u0454:U,\u043C\u0430\u044E:U},vi:{c\u00F3:U}},um=new Set(["text","json","html","response","blob","arraybuffer"]),sm=new Set(["empty","null","undefined","true","false"]),Hi=new Set(["Number","Int","Float","String","Boolean","Date","Array","Object","JSON","json","JSONString","FormData","FormEncoded","HTML","Fragment","Values","Values:Form","Values:JSON","Set","Map","Keys","Entries","Reversed","Unique","Flat"]);function Tt(r){return Hi.has(r)||/^Fixed(?::\d+)?$/.test(r)||/^[A-Z][A-Za-z0-9_]*(?::[A-Za-z0-9_]+)?$/.test(r)}function Ui(r,e,t,a,i,n){let o=Dr(r,e);if(!o)return;if(o.beforeTypeName&&a?.kind==="identifier"&&n?.value!=="("&&(Hi.has(a.value)||um.has(a.value.toLowerCase())))return o.beforeTypeName;if(o.beforePredicate&&a&&(a.kind==="literal"||a.kind==="keyword"&&sm.has((a.normalized??"").toLowerCase())))return o.beforePredicate;if(o.afterCopula&&i!==void 0&&["is","not","does","do"].includes(i.toLowerCase()))return o.afterCopula;if(o.beforeBareIdentifier&&a?.kind==="identifier"&&/^[A-Za-z_]\w*$/.test(a.value))return o.beforeBareIdentifier;let u=!!a&&Ft(a,r)&&$e({prev:e,beforePrev:t,next:n},r);if(o.beforeOperand&&(xr(a)||u))return o.beforeOperand;if(o.beforeSelector&&a?.kind==="selector")return o.beforeSelector;if(o.beforeClassRef&&a&&im.test(a.value))return o.beforeClassRef;if(o.afterSubject&&(t?.kind==="selector"||t?.kind==="reference"))return o.afterSubject;let s=!!t&&Ft(t,r)&&i===t.value;return o.betweenOperands&&(Da(t)||s)&&xr(a)?o.betweenOperands:o.afterOperand&&(Da(t)||t?.value==="}")?o.afterOperand:o.otherwise}function Dr(r,e){let t=om[r];return t?.[e.value]??t?.[e.value.toLowerCase()]}function lm(r,e,t,a){return Ui(r,e,t,a,void 0,void 0)}function cm(r){return Hd.test(r)||r==="("||r==="["||r===","}function pm(r){return ar.has(r)&&r!=="-"||r===")"||r==="]"||r===","}var dm=new Set(["is","am","contains","contain","matches","match","has","have","includes","include","exists","exist","mod"]);function Gi(r,e,t,a){let i=e.kind==="keyword"?(e.normalized??"").toLowerCase():Ye(r,e.value).toLowerCase();if(i!=="and"&&i!=="or")return false;if(t===void 0||t!==void 0&&cm(t.value))return true;if(a===void 0)return false;if(pm(a.value))return true;let n=a.kind==="keyword"?(a.normalized??a.value).toLowerCase():Ye(r,a.value).toLowerCase();return dm.has(n)}var mm=new Set(["include","contain","match","exist"]);function Zi(r){let e=r?.toLowerCase();return e==="is"||e==="not"}function Yi(r,e,t){let a=e[t],i=e[t-1];return !a||!i||a.value.toLowerCase()!=="in"?false:Zi(mt(r,i,e[t-2],a,void 0))}function mt(r,e,t,a,i,n){if(i?.toLowerCase()==="equal"&&e.value.toLowerCase()==="to")return "to";if(Zi(i)&&e.value.toLowerCase()==="in")return "in";if(i?.toLowerCase()==="not"&&mm.has(e.value.toLowerCase()))return e.value.toLowerCase();let o=Ui(r,e,t,a,i,n);if(o!==void 0)return o;if(Gi(r,e,t,a))return e.value;let u=Ye(r,e.value);if(u!==e.value)return u;if(e.kind!=="keyword")return e.value;let s=(e.normalized??e.value).toLowerCase();return s!=="event"&&Pt.has(s)||Ft(e,r)&&$e({prev:t,next:a,afterNext:n},r)?e.value:e.normalized??e.value}function Xi(r,e,t,a){let i=r[e],n=r[e+1];if(!i||!n||!Vi(i)||!He(t,n)||!ut(i,a))return;if(r[e+2]?.kind==="selector")return e+2;let o=e;for(;r[o]!==void 0&&r[o+1]!==void 0&&He(t,r[o+1])&&ut(r[o],a);)o+=2;return o>e+2&&r[o]?.kind==="selector"?o:void 0}var fm=new Set(["if","unless","while","until","for","when","where","is","not","no","and","or","as"]);function ym(r){let e=(r.normalized??r.value).toLowerCase();return e==="event"||_e(e)?false:fm.has(e)||Pt.has(e)}function Ft(r,e){return r.kind!=="keyword"?false:(r.normalized??r.value).toLowerCase()==="end"||ir(r.value,e)}function ke(r,e){return {prev:r[e-1],beforePrev:r[e-2],third:r[e-3],next:r[e+1],afterNext:r[e+2]}}var vm=new Set(["and","or","is","times"]),hm=new Set(["if","unless","while","until","is","and","or","in"]),Em=r=>Object.prototype.hasOwnProperty.call(le,r);function Er(r){if(r.kind!=="keyword"&&!(r.normalized&&r.normalized!==r.value))return;let e=(r.normalized??r.value).toLowerCase();return Em(e)?e:void 0}var Ba=new WeakMap;function Sa(r,e,t=false){let a;try{a=fe(r);}catch{return new Set}let i=Ba.get(a);i||(i=new Map,Ba.set(a,i));let n=t?`${e} before a role pair`:e,o=i.get(n);if(!o){o=new Set;for(let u of a){if(u.command!==e)continue;let[s,l,c,p]=u.template.tokens;if(!(s?.type!=="literal"||l?.type!=="literal")&&!(t&&(c?.type!=="role"||p?.type!=="role")))for(let d of [l.value,...l.alternatives??[]])o.add(d.toLowerCase());}i.set(n,o);}return o}var Ta=new WeakMap;function gm(r){let e;try{e=fe(r);}catch{return new Set}let t=Ta.get(e);if(!t){let a=new Set(Object.values(T(r)?.roleMarkers??{}).flatMap(n=>n?[n.primary,...n.alternatives??[]]:[]).map(n=>n.toLowerCase())),i=new Set;for(let n of e){if(n.command!=="repeat")continue;let o=n.template.tokens;o.forEach((u,s)=>{if(!(u.type!=="literal"||o[s+1]?.type!=="role"))for(let l of [u.value,...u.alternatives??[]])a.has(l.toLowerCase())||i.add(l.toLowerCase());});}t=i,Ta.set(e,t);}return t}function Fa(r){return r.kind==="particle"?true:r.kind==="keyword"&&Pt.has((r.normalized??"").toLowerCase())}function Pa(r,e){return r.kind==="keyword"&&r.normalized?r.normalized.toLowerCase():Ye(e,r.value).toLowerCase()}function $e(r,e){let{prev:t,beforePrev:a,next:i,afterNext:n}=r;if(i){if(Ve.has(i.value)||vm.has((i.normalized??i.value).toLowerCase())||i.value==="'"&&n?.value.toLowerCase()==="s")return true;let f=Dr(e,i)?.betweenOperands;if((f==="and"||f==="or")&&xr(n))return true}let o=T(e),u=!!o&&o.markingStrategy!=="preposition";if(u&&i?.kind==="particle"&&n?.kind!=="particle")return true;if(!t)return false;if(ar.has(t.value))return true;let s=Pa(t,e);if(s==="not"||s==="no"||Dr(e,t)?.beforeOperand==="not")return true;let l=o?.wordOrder!=="SOV",c=r.third?Er(r.third):void 0;if(c&&a&&Sa(e,c,true).has(a.value.toLowerCase()))return true;let p=a&&l?Er(a):void 0;if(p&&!Sa(e,p).has(t.value.toLowerCase())||a&&!u&&Fa(a))return false;if(hm.has(s))return true;let d=!!a&&Pa(a,e)!=="repeat"&&!!jr[e]?.includes(t.value);if(gm(e).has(t.value.toLowerCase())&&(l||s!=="repeat")&&!d)return true;let m=l?Er(t):void 0;return m&&le[m].roles.some(f=>f.required)?true:!u&&Fa(t)}function Ji(r){if(r.kind==="keyword")return ym(r)?"structure":ht.has((r.normalized??r.value).toLowerCase())?"verb":void 0}function Le(r,e){let t=e?.code??"en",[a]=r;if(r.length===1&&a&&(Ji(a)||Ft(a,t)))return a.value;let i="",n,o,u=(s,l)=>{if(o=s,n===void 0){i=s,n=l;return}let p=n.position?.end!==void 0&&l.position?.start!==void 0&&n.position.end===l.position.start&&(s.startsWith(".")||s.startsWith("!"));i+=(p?"":" ")+s,n=l;};for(let s=0;s<r.length;s++){let l=r[s],c=e?tm(e,l):void 0,p=r[s+1];if(l.value===":"&&n!==void 0&&o!==void 0&&p!==void 0&&n.position?.end===l.position?.start&&l.position?.end===p.position?.start&&Tt(`${o}:${p.value}`)){i+=`:${p.value}`,o=`${o}:${p.value}`,n=p,s+=1;continue}if(l.value==="'"&&n!==void 0&&p?.value==="s"&&l.position?.end!==void 0&&p.position?.start===l.position.end){i+="'s",n=p;let v=r[s+2];v&&ge(t,v.value)!==v.value?(u(ge(t,v.value),v),s+=2):s+=1;continue}let d=e?.possessive,m=r[s+2];if(d?.markerPosition==="between"&&d.marker&&l.kind==="selector"&&p?.value===d.marker&&m!==void 0&&ut(m,t)){u(`${l.value}'s`,l),u(ge(t,m.value),m),s+=2;continue}if(p?.value.toLowerCase()==="of"&&ge(t,l.value)!==l.value&&ut(l,t)){u(ge(t,l.value),l);continue}if(c!==void 0&&p){let v=e?.possessive?.connectors,E=!!v?.length&&v.some(g=>{let A=g.toLowerCase();return A===p.value.toLowerCase()||A===(p.normalized??"").toLowerCase()}),k=E?s+2:s+1,z=r[k];if(z&&ut(z,t)){u(vr(c),l),u(ge(t,z.value),z),s=k;continue}if(E&&z&&/^\.[a-zA-Z_]\w*$/.test(z.value)&&p.position?.end!==void 0&&z.position?.start!==void 0&&p.position.end===z.position.start){u(vr(c),l),u(ge(t,z.value.slice(1)),z),s=k;continue}if(!E&&/^\.[a-zA-Z_]\w*$/.test(p.value)&&l.position?.end!==void 0&&p.position?.start!==void 0&&l.position.end===p.position.start&&!rm(e,l)){u(vr(c),l),u(ge(t,p.value.slice(1)),p),s+=1;continue}}let f=r[s+2],y=Xi(r,s,e,t);if(y!==void 0){for(let v=s;v<y;v+=2)u(ge(t,r[v].value),r[v]),u("of",r[v+1]);u(r[y].value,r[y]),s=y;continue}if(l.kind==="selector"&&p&&f&&He(e,p)&&ut(f,t)&&ge(t,f.value)!==f.value){u(ge(t,f.value),f),u("of",p),u(l.value,l),s+=2;continue}let h=St(r,s,e);if(h){for(let v of h.parts)u(v.text,v.token);s+=h.consumed-1;continue}u(mt(t,l,r[s-1],p,o,r[s+2]),l);}return i.trim()}function km(r){if(!r)return true;if(r.kind!=="keyword")return false;let e=(r.normalized??r.value).toLowerCase();return e==="then"||e==="end"||e==="else"}function Qi(r){return !!r&&Ve.has(r.value)}var wm=class{constructor(r,e,t,a,i){this.patternToken=e,this.afterLiteral=t,this.nextPatternToken=a,this.wouldMatch=i;let n=r.position();this.token=r.tokens[n],this.prev=r.tokens[n-1],this.next=r.tokens[n+1],this.place=ke(r.tokens,n);}get lastSlot(){return this.nextPatternToken===void 0}get tokenIsMarker(){return this.tokenIsMarkerMemo??(this.tokenIsMarkerMemo=this.wouldMatch(this.nextPatternToken,this.token)),this.tokenIsMarkerMemo}get beforeRole(){return this.nextPatternToken?.type==="role"}get nextIsMarker(){return this.nextIsMarkerMemo??(this.nextIsMarkerMemo=this.next!==void 0&&this.wouldMatch(this.nextPatternToken,this.next)),this.nextIsMarkerMemo}get clauseEndsAfter(){return km(this.next)}};function zm(r){let e=r.token.value.toLowerCase();if(e!=="a"&&e!=="an")return false;let t=r.next;return t!==void 0&&(ar.has(t.value)||r.nextIsMarker)}function Yr(r){return r.kind==="keyword"&&ht.has((r.normalized??r.value).toLowerCase())}function bm(r,e){let t=r.token;if(t.kind!=="keyword")return false;let a=(t.normalized??t.value).toLowerCase();return a==="then"?true:(a==="end"&&r.next?.kind!=="selector"||ir(t.value,e))&&!$e(r.place,e)}function Cm(r,e){return Ft(r.token,e)&&$e(r.place,e)}function en(r){return r.afterLiteral&&(r.clauseEndsAfter||r.nextIsMarker)}function Am(r,e){let t=r.patternToken.role;return t!=="quantity"&&!(t==="event"&&e==="repeat")?false:Yr(r.token)&&!en(r)&&!r.nextIsMarker}function xm(r){let e=r.patternToken;return !e.optional||e.role==="event"||e.role==="action"||e.valueShape==="keyword"||!Yr(r.token)?false:(r.lastSlot||r.tokenIsMarker)&&!en(r)}function Dm(r,e,t,a){let i=r.type==="group"&&r.optional?r.tokens.every(o=>o.type==="role")?r.tokens[0]:void 0:r;if(!i||i.type!=="role"||!i.optional||i.role==="event"||i.role==="action"||i.valueShape==="keyword"||!e||e.kind!=="keyword"||t===void 0)return false;let n=a(t,e);return Yr(e)?!n:n}function Bm(r){return ht.has((r.normalized??r.value).toLowerCase())}function Sm(r,e){return r?.kind==="particle"&&!!e&&["selector","literal","identifier"].includes(e.kind)&&!Qi(e)}function Tm(r){if(r.token.kind!=="particle")return false;let e=r.next;return e!==void 0&&r.nextIsMarker&&(e.kind==="particle"||r.prev?.kind==="particle")||r.afterLiteral&&r.beforeRole||r.clauseEndsAfter}function Fm(r,e){let t=r.patternToken;if(t.role==="event"||t.role==="action"||t.valueShape==="keyword")return false;let a=t.expectedTypes;if(a?.length&&!a.some(n=>n==="expression"||n==="reference"))return false;let i=Ji(r.token);return i==="structure"?true:i!=="verb"||(r.token.normalized??r.token.value).toLowerCase()==="empty"?false:!e?.hasBody&&!e?.roles.some(n=>n.role==="event")}function Pm(r){let e=(r.normalized||r.value).toLowerCase();if(e==="empty")return Ci("null");if(e==="a"||e==="an")return {type:"expression",raw:r.value}}function Om(r,e,t){return r.kind==="particle"&&(e||Qi(t))}function tn(r,e){let t=r[e];return t?.kind==="particle"&&r[e-1]?.value.toLowerCase()==="of"&&/^[\p{L}_$][\p{L}\p{M}\p{N}_$]*$/u.test(t.value)}var Oa=new Set(["is","am","are","be","was","were","not","no"]),Rm=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948","\u0928\u0939\u0940\u0902","mana"]),rn=new Set(["empty","null","undefined"]);function Lm(r,e,t,a){let i=(r.normalized??r.value).toLowerCase(),n=r.value.toLowerCase(),o=(e.normalized??e.value).toLowerCase();return (Oa.has(i)||Oa.has(Ye(a,n))||Rm.has(n)&&rn.has(o))&&!t}var _m=new Set(["'s","a","am","an","and","as","closest","contain","contains","do","does","empty","equal","equals","exist","exists","false","first","greater","has","have","in","include","includes","is","it","its","last","less","match","matches","me","mod","my","next","no","not","null","of","or","previous","really","some","than","the","true","undefined","you","your","result","target","body","detail"]),Nm=new Set(["am","and","as","contain","contains","do","does","empty","equal","equals","exist","exists","greater","has","have","in","include","includes","is","less","match","matches","mod","no","not","of","or","really","some","than"]),Ra=/\s+as\s+([A-Za-z]\w*)!?\s*$/;function an(r){let e=r;for(let i=Ra.exec(e);i;i=Ra.exec(e)){if(!Tt(i[1]??""))return false;e=e.slice(0,i.index);}let t=e.replace(/"[^"]*"|'[^']*'/g,"");if(/["']/.test(t.replace(/'s\b/g,""))||/[^\x00-\x7F]/.test(t))return false;let a=wd(e);return !a.success||a.consumed===void 0||a.consumed!==_i(e).length-1?false:Mm(a.node).every(Tt)}function Mm(r){let e=[],t=a=>{if(Array.isArray(a)){a.forEach(t);return}if(!a||typeof a!="object")return;let i=a;i.type==="asExpression"&&e.push(String(i.targetType?.name??"")),Object.values(a).forEach(t);};return t(r),e}function xt(r,e){return r?.position?.end!==void 0&&e?.position?.start!==void 0&&r.position.end===e.position.start}var Im=new Set(["is","not","really","am","or"]);function nn(r,e,t){let a=i=>{let n=r[i];return n?mt(t,n,r[i-1],r[i+1],void 0).toLowerCase():""};return a(e)==="to"&&a(e-1)==="equal"&&Im.has(a(e-2))}function $m(r){return r.value==="a"}var jm=new Set(["event","window","document"]);function Wm(r,e,t){let a=r[e],i=r[e-1];return !a||!i||!He(t,i)?false:jm.has((a.normalized??a.value).toLowerCase())}function qm(r,e){if(r.kind==="conjunction")return true;if(r.kind==="keyword"){let t=(r.normalized??r.value).toLowerCase();if(t==="then"||t==="end"||t==="else"||ir(r.value,e.profile?.code??""))return true}return e.owes(r)}function La(r,e,t){let a=t.profile?.code??"en";if(Yi(a,r,e)||tn(r,e)||nn(r,e,a)||$m(r[e]))return false;let i=r[e];return qm(i,t)||t.commandMarkers.has(i.value.toLowerCase())}function Vm(r,e,t){let a=r[e],i=r[e-1],n=t.profile?.code??"en";if(a.kind==="literal"||a.value==="'"&&r[e+1]?.value==="s"||a.value==="s"&&i?.value==="'")return true;if(a.kind==="selector"){if(!a.value.startsWith(".")||!i||xt(i,a)||Ve.has(i.value)||/^[([,]$/.test(i.value)||He(t.profile,i))return true;let u=mt(n,i,r[e-2],a,void 0).toLowerCase();return Nm.has(u)}if(Ve.has(a.value)||/^[()[\],.!<>=+\-*/%]+$/.test(a.value)||He(t.profile,a)||Gi(n,a,i,r[e+1])||Yi(n,r,e)||tn(r,e)||Wm(r,e,t.profile)||nn(r,e,n))return true;let o=mt(n,a,i,r[e+1],void 0).toLowerCase();return o==="as"&&t.hasResponseType?false:_m.has(o)?true:a.kind==="identifier"&&/^(?:[\p{L}_$][\p{L}\p{M}\p{N}_$]*('s)?|\([\p{L}_$][\p{L}\p{M}\p{N}_$]*\))$/u.test(a.value)}function Km(r,e,t){if(!r[e]||La(r,e,t))return [];let a=e;for(;a<r.length&&!La(r,a,t)&&Vm(r,a,t);)a++;let i=[];for(let n=a;n>e;n--)i.push(n);return i}function Hm(r,e,t){let a=[],i=e;for(;;){let n=r[i];if(!n)break;if(n.value==="'"&&r[i+1]?.value==="s"&&r[i+2])i+=3;else if(/.'s$/.test(r[i-1]?.value??""))i+=1;else if(He(t,n)&&r[i+1])i+=2;else break;a.push(i);}return a.reverse()}function Um(r,e,t,a){for(let i of t){let n=Le(r.slice(e,i),a);if(an(n))return {end:i,raw:n}}}var on=96,Gm=/^[A-Za-z_][\w-]*$/,Zm=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function un(r,e){let t=r.peek(e);return !!t&&t.kind==="identifier"&&Zm.test(t.value)}function sn(r,e){let t=r.peek(e);if(!t||t.kind!=="identifier"&&t.kind!=="keyword"||!Gm.test(t.value))return false;let a=r.peek(e+1),i=r.peek(e+2);return !!a&&a.value===":"&&!!i}function _a(r,e=0){return un(r,e)||sn(r,e)}function Ym(r){let e=r.peek();if(!e||e.value!=="{"&&e.value!=="(")return null;let t="",a=-1,i=0,n=0;for(;!r.isAtEnd()&&n++<on;){let o=r.advance();if(!o)break;if(a>=0&&o.position.start>a&&(t+=" ".repeat(o.position.start-a)),t+=o.value,a=o.position.end,o.value==="{"||o.value==="(")i++;else if((o.value==="}"||o.value===")")&&(i--,i===0))return t}return null}function Na(r){let e=r.peek();return e?e.value==="{"||e.value==="("?Ym(r):e.value===","||e.value===":"?null:(r.advance(),e.value):null}function Dt(r,e){let t=r.mark(),a=[];if(e!==void 0){let n=r.peek();if(!n||n.value!==":"||!r.peek(1))return null;r.advance();let o=Na(r);if(o===null)return r.reset(t),null;a.push(`${e}:${o}`);}else if(!_a(r))return null;let i=0;for(;i++<on;){let n=r.peek();if(!n)break;if(n.value===","){if(a.length===0||!_a(r,1))break;r.advance();continue}if(un(r,0)){a.push(r.advance().value);continue}if(!sn(r,0))break;let o=r.advance().value;r.advance();let u=Na(r);if(u===null)return r.reset(t),null;a.push(`${o}:${u}`);}return a.length===0?(r.reset(t),null):`{${a.join(", ")}}`}function Zt(r){switch(r.kind){case "selector":return Ne(r.value);case "literal":return Xm(r.value);case "keyword":{let t=Pm(r);if(t)return t;let a=(r.normalized||r.value).toLowerCase();return _e(a)?De(a):Ci(a)??Y(r.normalized||r.value)}case "identifier":if(r.value.startsWith("@"))return Ne(r.value);if(r.value.startsWith(":")||r.value.startsWith("$"))return De(r.value);let e=r.value.toLowerCase();return _e(e)?De(e):{type:"expression",raw:r.value};case "url":{let t=Y(r.value,"string");return r.value.includes("${")?{...t,interpolates:true}:t}default:return null}}function Xm(r){if(r.startsWith('"')||r.startsWith("'")||r.startsWith("`")||r.startsWith("\u300C")){let a=r.slice(1,-1);return Y(a,"string")}if(r==="true")return Y(true,"boolean");if(r==="false")return Y(false,"boolean");let e=r.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let a=parseFloat(e[1]);return e[2]?Y(r,"duration"):Y(a,"number")}let t=parseFloat(r);return isNaN(t)?Y(r,"string"):Y(t,"number")}var Kt=.8,Jm=.6,Qm=.15,ef=.5,Ma=.15,Ia=.1,$a=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"]),tf={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"]},rf=class{calculate(r){return this.calculateWithBreakdown(r).final}calculateWithBreakdown(r){let e=this.scoreRoleCoverage(r),t=this.scoreStemPenalty(r),a=this.scoreLanguageBoost(r),i=this.scoreLanguageAdjustment(r),n=e;return n=Math.max(ef,n+t),n=Math.min(1,n+a),n=Math.max(0,Math.min(1,n+i)),{roleCoverage:e,stemPenalty:t,languageBoost:a,languageAdjustment:i,final:n}}scoreRoleCoverage(r){let{pattern:e,captured:t}=r,a=0,i=0,n=l=>e.extraction?.[l]?.default!==void 0,o=e.command==="on"?e.extraction?.action?.value:void 0,u=le[o??e.command]?.roles,s=l=>u?.find(c=>c.role===l)?.valueShape!==void 0;for(let l of e.template.tokens)if(l.type==="role")t.has(l.role)?(i+=1,a+=1):s(l.role)||(i+=1);else if(l.type==="group")for(let c of l.tokens)c.type==="role"&&(t.has(c.role)?(i+=Kt,a+=Kt):s(c.role)||(i+=Kt,n(c.role)&&(a+=Kt*Jm)));return i>0?a/i:1}scoreStemPenalty(r){let{stemMatchCount:e,totalKeywordMatches:t}=r;return e<=0||t<=0?0:-(e/t)*Qm}scoreLanguageBoost(r){let{pattern:e}=r;if(e.language!=="ar")return 0;let t=e.template.tokens[0];return !t||t.type!=="literal"?0:$a.has(t.value)||t.alternatives?.some(a=>$a.has(a))?Ma:0}scoreLanguageAdjustment(r){let{pattern:e,captured:t}=r;if(e.language!=="ar")return 0;let a=0;for(let[i,n]of t.entries()){let o=tf[i];if(!o||o.length===0)continue;let u="metadata"in n?n.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?a+=.1:a-=.1);}return Math.max(-Ia,Math.min(Ia,a))}},af=new rf,nf=new Set(Object.values(le).filter(r=>r.bareKeyword===true).map(r=>r.action));function of(r){return r.startsWith("*")||r.startsWith("@")}var ae=class ${constructor(e){this.patternRest=[],this.slotAfterLiteral=false,this.wouldMatch=(t,a)=>this.patternTokenWouldMatch(t,a),this.matchCache=new Map,this.roleStarts=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??af;}matchPattern(e,t){let a=e.mark(),i=new Map;if(this.currentProfile=T(t.language),this.currentPatternCommand=t.command,this.currentRoleCommand=t.extraction?.action?.value??t.command,this.stemMatchCount=0,this.totalKeywordMatches=0,this.roleStarts=new Map,this.eventSource=void 0,this.patternRest=[],!this.matchTokenSequence(e,t.template.tokens,i))return e.reset(a),null;let o=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()-a.position,confidence:o,roleStarts:this.roleStarts,...this.eventSource?{eventSource:this.eventSource}:{}}}matchBest(e,t){this.matchCache.clear();let a=[],i=e.position();for(let o of t){let u=e.mark(),s=`${i}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&a.push(l),e.reset(u);}if(a.length===0)return null;a.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.confidence-o.confidence});let n=a[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,t,a,i){let n=t[0],o=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=0;for(let s=0;s<t.length;s++){let l=t[s];if(u>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,a,l),Dm(l,e.peek(),t[s+1]??i,this.wouldMatch)){let d=e.mark(),m=new Map(a);if(this.matchTokenSequence(e,t.slice(s+1),m,i)&&this.atClauseEnd(e)){a.clear();for(let[f,y]of m)a.set(f,y);return true}e.reset(d);}let c=this.patternRest;this.patternRest=[...t.slice(s+1),...c],this.slotAfterLiteral=l.type==="role"&&t[s-1]?.type==="literal";let p=this.matchPatternToken(e,l,a,t[s+1]??i);if(this.patternRest=c,u=l.type==="role"&&l.role==="event"?2:Math.max(0,u-1),!p){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,t,a){if(t.has("source")||this.eventSource)return;let i=e.peek(),n=e.peek(1);if(!i||!n||this.patternTokenWouldMatch(a,i))return;let o=this.currentProfile?.roleMarkers?.source,u=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let c=l.value.toLowerCase();return o.primary?.toLowerCase()===c?true:!!o.alternatives?.some(p=>p.toLowerCase()===c)},s=o?.position;if(s!=="after"&&u(i)){let l=this.sourceNounValue(n);if(!l)return;e.advance(),e.advance(),this.eventSource=l;return}if(s==="after"&&u(n)){let l=this.sourceNounValue(i);if(!l)return;e.advance(),e.advance(),this.eventSource=l;}}sourceNounValue(e){if(e.kind==="selector")return this.tokenToSemanticValue(e)??void 0;if(e.kind!=="keyword"&&e.kind!=="identifier")return;let t=(e.normalized??e.value).toLowerCase();if(t!=="me"){if(_e(t))return {type:"reference",value:t};if(e.kind==="identifier"&&/^[A-Za-z_$][\w$]*$/.test(e.value))return {type:"expression",raw:e.value}}}matchPatternToken(e,t,a,i){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":{let n=e.position(),o=this.matchRoleToken(e,t,a,i);return o&&a.has(t.role)&&this.roleStarts.set(t.role,n),o}case "group":return this.matchGroupToken(e,t,a,i);default:return false}}matchLiteralToken(e,t){let a=e.peek();if(!a)return false;let i=this.getMatchType(a,t.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let n of t.alternatives){let o=this.getMatchType(a,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let n of [t.value,...t.alternatives??[]])for(let o of ["-","_"])if(n.includes(o)&&this.tryMatchShatteredCompound(e,n,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let t=this.currentProfile;if(!t)return null;let a=e.mark(),i=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;i.push(o.value),e.advance();let u=e.peek();if(!u||u.value!=="-")break;e.advance(),i.push("-");}if(i.length<3||i[i.length-1]==="-")return e.reset(a),null;let n=i.join("").toLowerCase();for(let[o,u]of Object.entries(t.keywords))if(u.primary.toLowerCase()===n||u.alternatives?.some(s=>s.toLowerCase()===n))return Y(o);return e.reset(a),null}tryMatchShatteredCompound(e,t,a){let i=t.split(a);if(i.length<2||i.some(o=>o.length===0))return false;let n=e.mark();for(let o=0;o<i.length;o++){if(o>0){let s=e.peek();if(!s||s.value!==a)return e.reset(n),false;e.advance();}let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword"&&u.kind!=="particle"||u.value.toLowerCase()!==i[o].toLowerCase())return e.reset(n),false;e.advance();}return true}matchRoleToken(e,t,a,i){let n=e.position(),o=a.get(t.role);return this.matchRoleTokenCore(e,t,a,i)?(this.absorbTrailingConversion(e,t,a,i,n),this.absorbTrailingConditionOperand(e,t,a,i,n),this.absorbExpressionTail(e,t,a,i,n),this.stampCaptureSpan(e,t.role,a,n,o),true):false}absorbExpressionTail(e,t,a,i,n){if(t.role==="event"||t.role==="action"||this.isClassNameSlot(t)||!a.has(t.role)||e.position()<=n)return;let o=t.expectedTypes;if(o&&o.length>0&&!o.includes("expression"))return;let u=$.boundedByMarker(i)?Km(e.tokens,e.position(),this.extentContext()):Hm(e.tokens,e.position(),this.currentProfile),s=Um(e.tokens,n,u,this.currentProfile);if(s){for(;e.position()<s.end;)e.advance();a.set(t.role,{type:"expression",raw:s.raw,value:s.raw});}}extentContext(){let e=this.restLiterals();return {profile:this.currentProfile,owes:t=>e.some(a=>this.patternTokenWouldMatch(a,t)),commandMarkers:this.commandMarkers(),hasResponseType:!!this.currentSchema()?.roles.some(t=>t.role==="responseType")}}isClassNameSlot(e){return e.role==="patient"&&["add","remove","toggle","take"].includes(this.currentRoleCommand??"")}isObjectValueSlot(e){let t=this.currentRoleCommand;return e.role==="source"?t==="get":e.role==="patient"&&(t==="put"||t==="set")}static boundedByMarker(e){return !e||e.type==="literal"?true:e.type==="group"?e.tokens[0]?.type==="literal":false}restLiterals(){let e=[],t=a=>{for(let i of a)i.type==="literal"?e.push(i):i.type==="group"&&t(i.tokens);};return t(this.patternRest),e}currentSchema(){let e=this.currentRoleCommand;if(!(!e||!(e in le)))return le[e]}commandMarkers(){let e=this.currentSchema(),t=this.currentProfile,a=new Set;if(!e||!t)return a;for(let i of e.roles){let n=i.markerOverride?.[t.code];if(n){a.add(n.toLowerCase());continue}let o=t.roleMarkers[i.role];if(o){a.add(o.primary.toLowerCase());for(let u of o.alternatives??[])a.add(u.toLowerCase());}}return a.delete(""),a}stampCaptureSpan(e,t,a,i,n){let o=a.get(t);if(!o||o===n||o.position||e.position()<=i)return;let u=e.tokens[i],s=e.tokens[e.position()-1];!u||!s||a.set(t,Ai(o,{start:u.position.start,end:s.position.end}));}absorbTrailingConditionOperand(e,t,a,i,n){if(t.role!=="condition"||!a.has("condition")||e.position()<=n)return;let o=this.currentPatternCommand==="repeat";if(!o&&(i!==void 0||this.currentPatternCommand!=="on"))return;let u=$.CONDITION_OPERATOR_WORDS,s=d=>{let m=(d.normalized??"").toLowerCase(),f=d.value.toLowerCase();if(u.has(m)||u.has(f))return true;let y=$.LOOP_CONDITION_OPERATORS;return o&&(y.has(f)||y.has(m))},l=d=>!!d&&(d.kind==="selector"||d.kind==="identifier"||d.kind==="literal")&&!s(d)&&!ht.has((d.normalized??d.value).toLowerCase())&&!this.patternTokenWouldMatch(i,d),c=false;for(;;){let d=e.peek();if(!d||!s(d)||this.patternTokenWouldMatch(i,d))break;e.advance(),c=true;let m=e.peek();if(l(m)){e.advance();for(let f=e.peek();!(!f||!/^\.[a-zA-Z_]\w*$/.test(f.value)||f.position.start!==m.position.end);f=e.peek())e.advance(),m=f;}if(!o)break}if(!c)return;let p=Le(e.tokens.slice(n,e.position()),this.currentProfile);a.set("condition",{type:"expression",raw:p,value:p});}conversionRunLength(e){let t=e.peek();if(!t||(t.normalized??t.value).toLowerCase()!=="as"&&t.value.toLowerCase()!=="as")return 0;let i=this.conversionTypeLength(e,1);if(i===0)return 0;for(i+=1;;){if(e.peek(i)?.value!=="|")return i;let n=this.conversionTypeLength(e,i+1);if(n===0)return i;i+=1+n;}}conversionTypeLength(e,t){let a=e.peek(t)?.value.toLowerCase(),i=a==="a"||a==="an"?t+1:t,n=e.peek(i);if(!n)return 0;let o=e.peek(i+1),u=e.peek(i+2);return o?.value===":"&&u&&xt(n,o)&&xt(o,u)&&Tt(`${n.value}:${u.value}`)?i-t+3:Tt(n.value)?i-t+1:0}absorbTrailingConversion(e,t,a,i,n){if(t.role==="event"||t.role==="action"||!a.has(t.role)||e.position()<=n)return;let o=this.conversionRunLength(e);if(o===0||this.patternTokenWouldMatch(i,e.peek()))return;for(let s=0;s<o;s++)e.advance();let u=Le(e.tokens.slice(n,e.position()),this.currentProfile);a.set(t.role,{type:"expression",raw:u,value:u});}matchRoleTokenCore(e,t,a,i){this.skipNoiseWords(e,t,i);let n=e.peek();if(!n)return t.optional||false;let o=this.slotAt(e,t,i);if(t.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let g=this.tryFoldHyphenActionKeyword(e);if(g)return a.set(t.role,g),true}if(t.role==="event"&&this.currentPatternCommand==="on"){if(!$.tokenLooksLikeEvent(n))return t.optional||false;let g=(n.normalized??n.value).toLowerCase();if($.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||$.VISIBILITY_STRATEGIES.has(g)||this.currentProfile&&(Pe(this.currentProfile,n.value)??Pe(this.currentProfile,g))!==void 0||n.value.includes("?."))return t.optional||false}if(t.role==="event"){let g=(n.normalized??n.value).toLowerCase();if($.STRUCTURAL_NEVER_EVENT.has(g))return t.optional||false}if(bm(o,this.currentProfile?.code??"")||Am(o,this.currentPatternCommand))return t.optional||false;if(t.role==="duration"){let g=(n.normalized??n.value).toLowerCase();if($.POSITIONAL_OR_SCOPE_KEYWORDS.has(g))return t.optional||false}if(xm(o))return true;if(this.roleAcceptsPropertyPath(t)){let g=this.tryMatchPositionalPossessiveExpression(e,i);if(g)return a.set(t.role,g),true}let u=this.tryMatchPositionalExpression(e,i);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!Vt(u.type,t.expectedTypes)?t.optional||false:(a.set(t.role,u),true);let s=this.tryMatchCaretScopeExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!Vt(s.type,t.expectedTypes)?t.optional||false:(a.set(t.role,s),true);let l=this.tryMatchParenReceiverCall(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes("expression")?t.optional||false:(a.set(t.role,l),true);if(t.role!=="event"&&(!t.expectedTypes||t.expectedTypes.includes("expression"))){let g=this.tryMatchBeepPrefixExpression(e);if(g)return a.set(t.role,g),true;let A=this.tryMatchHyphenatedWord(e);if(A)return a.set(t.role,A),true;let b=this.isWrittenTarget(t)?null:this.tryMatchOperatorRunExpression(e);if(b)return a.set(t.role,b),true}if(this.currentPatternCommand==="pick"&&t.role==="patient"&&(!t.expectedTypes||t.expectedTypes.includes("expression"))){let g=this.tryMatchPickRangeExpression(e);if(g)return a.set(t.role,g),true}if(this.roleAcceptsPropertyPath(t)){let g=this.tryMatchOfPossessiveExpression(e,i);if(g)return a.set(t.role,g),true;let A=this.tryMatchPostNominalPossessiveExpression(e);if(A)return a.set(t.role,A),true}let c=this.tryMatchPossessiveExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(c.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(a.set(t.role,c),true);let p=this.tryMatchMethodCallExpression(e);if(p)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(p.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(a.set(t.role,p),true);let m=t.role==="event"&&this.currentPatternCommand==="on"||$.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")||this.isWrittenTarget(t)?null:this.tryMatchBareCallExpression(e);if(m)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(m.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(a.set(t.role,m),true);let f=this.tryMatchPossessiveSelectorExpression(e);if(f)return t.expectedTypes&&t.expectedTypes.length>0&&!Vt(f.type,t.expectedTypes)?t.optional||false:(a.set(t.role,f),true);let y=t.role!=="condition",h=this.tryMatchPropertyAccessExpression(e,y);if(h)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(h.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(a.set(t.role,h),true);let v=this.tryMatchSelectorPropertyExpression(e);if(v)return t.expectedTypes&&t.expectedTypes.length>0&&!Vt(v.type,t.expectedTypes)?t.optional||false:(a.set(t.role,v),true);if(n.value==="("&&t.role!=="event"&&t.role!=="action"&&(!t.expectedTypes?.length||t.expectedTypes.some(g=>g==="expression"||g==="selector"||g==="reference"))){let g=this.tryMatchParenGroupExpression(e);if(g)return a.set(t.role,g),true}if(n.kind==="identifier"&&n.value==="{"){let g=t.expectedTypes,b=g?.length===1&&g[0]==="expression"||this.isObjectValueSlot(t)?this.tryMatchBraceRunExpression(e):!g?.length||g.includes("literal")?this.tryMatchBraceRunLiteral(e):null;if(b)return a.set(t.role,b),true}if(t.role==="style"&&t.expectedTypes?.length===1&&t.expectedTypes[0]==="expression"){let g=Dt(e);if(g)return a.set(t.role,{type:"expression",raw:g}),true}if(Tm(o)||Fm(o,this.currentSchema())||Cm(o,this.currentProfile?.code??""))return a.set(t.role,{type:"expression",raw:n.value}),e.advance(),true;let E=this.tokenToSemanticValue(n);if(!E)return t.optional||false;if(t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(E.type)){let g=E.type==="selector"&&String(E.value).startsWith("@"),A=t.expectedTypes.some(b=>b==="expression"||b==="reference");if(!(g&&A))return t.optional||false}t.valueShape==="keyword"&&E.type==="expression"?a.set(t.role,Y(String(E.raw??""))):a.set(t.role,E),e.advance();let k=this.isClassNameSlot(t);if(E.type==="selector"&&(E.value.startsWith("<")||E.value.startsWith(".")&&!k)&&t.role!=="event"){let g=qi(e.tokens,e.position(),this.currentProfile,A=>A===void 0?false:this.patternTokenWouldMatch(i,A));if(g){let[A,b]=g.scope.parts,x=g.scope.kind==="reference"?De(A.text):g.scope.kind==="closest"?{type:"expression",raw:`closest ${b.text}`}:this.tokenToSemanticValue(A.token);for(let B=0;B<1+g.scope.consumed;B++)e.advance();a.set(t.role,{...E,scope:x});}}if(t.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&g.position.start===n.position.end&&"value"in E&&(a.set(t.role,Y(`${String(E.value)}${g.value}`)),e.advance());let A=e.peek();if(A&&(A.kind==="particle"||A.kind==="keyword")&&(A.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(i,A)){let b=e.peek(1),x=b?this.sourceNounValue(b):void 0;x&&!this.eventSource&&(e.advance(),e.advance(),this.eventSource=x);}}return true}atClauseEnd(e){let t=e.peek();if(!t||t.kind==="conjunction")return true;if(t.kind!=="keyword")return false;let a=(t.normalized??t.value).toLowerCase();return a==="then"||a==="end"?true:ir(t.value,this.currentProfile?.code??"")}patternTokenWouldMatch(e,t){return e?e.type==="literal"?this.getMatchType(t,e.value)!=="none"?true:!!e.alternatives?.some(a=>this.getMatchType(t,a)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],t):false:false}tryMatchPositionalExpression(e,t){let a=St(e.tokens,e.position(),this.currentProfile,i=>i===void 0?false:this.patternTokenWouldMatch(t,i));if(!a)return null;for(let i=0;i<a.consumed;i++)e.advance();return {type:"expression",raw:a.parts.map(i=>i.text).join(" ")}}tryMatchCaretScopeExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"||!t.value.startsWith("^"))return null;let a=e.peek(1),i=e.peek(2),n=(a?.normalized??"").toLowerCase(),o=!!a&&(a.value.toLowerCase()==="on"||n==="destination"||n==="on");return !a||!i||i.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${t.value} on ${i.value}`})}isOfPossessiveMarker(e){return He(this.currentProfile,e)}logicalConnectiveOf(e){let t=e.peek();if(!t)return;let a=this.currentProfile?.code??"en",i=s=>s==="and"||s==="or"||s==="not",n=Ye(a,t.value).toLowerCase();if(i(n))return n;if(this.commandMarkers().has(t.value.toLowerCase()))return;let o=e.position(),u=lm(a,t,e.tokens[o-1],e.tokens[o+1]);return u&&i(u)?u:void 0}tryConsumeRunPhrase(e){let t=this.currentProfile?.code??"en",a=e.tokens,i=e.position(),n=[],o;for(let u=0;u<6&&i+u<a.length;u++){let s=a[i+u],l=mt(t,s,a[i+u-1],a[i+u+1],o).toLowerCase();n.push(l),o=l;}for(let[u,s]of $.RUN_PHRASES)if(u.every((l,c)=>n[c]===l)){for(let l=0;l<u.length;l++)e.advance();return s}}slotAt(e,t,a){return new wm(e,t,this.slotAfterLiteral,a,this.wouldMatch)}static isBareWordToken(e){return !!e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.value)}tryMatchBeepPrefixExpression(e){let t=e.peek(),a=e.peek(1);if(!t||!a||a.value!=="!"||(t.normalized??t.value).toLowerCase()!=="beep"||!(t.position?.end!==void 0&&a.position?.start!==void 0&&t.position.end===a.position.start))return null;let n=e.mark(),o=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(n),null;for(;;){let s=e.peek();if(!s||!Ve.has(s.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e,true)){e.reset(l);break}}let u=Le(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:u,value:u}}tryMatchHyphenatedWord(e){let t=e.peek();if(!$.isBareWordToken(t))return null;let a=1,i=[t.value];for(;;){let n=e.peek(a),o=e.peek(a+1);if(!n||n.value!=="-"||!$.isBareWordToken(o)||!xt(e.peek(a-1),n)||!xt(n,o))break;i.push(o.value),a+=2;}if(i.length<2)return null;for(let n=0;n<a;n++)e.advance();return Y(i.join("-"),"string")}tryMatchOperatorRunExpression(e){let t=e.mark(),a=e.position(),i=e.peek(),n=!!i&&(this.logicalConnectiveOf(e)==="not"||i.value==="-");if(!this.tryConsumeRunOperand(e))return e.reset(t),null;let o=1;for(;;){let s=e.peek();if(!s)break;let l=this.logicalConnectiveOf(e),c=(l==="and"||l==="or")&&this.currentRoleCommand!=="wait",p=e.mark();if(c||Ve.has(s.value))e.advance();else {let d=this.tryConsumeRunPhrase(e);if(d===void 0)break;if(d==="none"){o++;continue}}if(!this.tryConsumeRunOperand(e,true,c)){e.reset(p);break}o++;}if(o<2&&!n)return e.reset(t),null;let u=Le(e.tokens.slice(a,e.position()),this.currentProfile);return {type:"expression",raw:u,value:u}}static rangeSeparatorFor(e){let[t]=$.PICK_RANGE_SEPARATORS_BY_LANG[e]??[];return t}isPickRangeSeparator(e){let t=(e.normalized??e.value).toLowerCase();if($.PICK_RANGE_SEPARATORS.has(t))return true;let a=this.currentProfile?.code;return a?$.PICK_RANGE_SEPARATORS_BY_LANG[a]?.has(e.value.toLowerCase())??false:false}tryMatchPickRangeExpression(e){let t=e.mark(),a=e.position();if(!this.tryConsumePickRangeOperand(e))return e.reset(t),null;let i=e.peek();if(!i||!this.isPickRangeSeparator(i)||(e.advance(),!this.tryConsumePickRangeOperand(e)))return e.reset(t),null;let n=e.peek();n&&$.PICK_RANGE_MODES.has((n.normalized??n.value).toLowerCase())&&e.advance();let o=e.tokens.slice(a,e.position()),[u,,s,l]=o,c=d=>d.kind==="keyword"?d.normalized??d.value:d.value,p=`${c(u)} to ${c(s)}`;return l&&(p+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:p,value:p}}tryConsumePickRangeOperand(e){let t=e.peek();if(!t)return false;let a=(t.normalized??t.value).toLowerCase();if(this.isPickRangeSeparator(t))return false;let i=a==="start"||a==="end";return t.kind==="literal"||t.kind==="identifier"||t.kind==="keyword"&&i?(e.advance(),true):false}tryConsumeRunOperand(e,t=false,a=false){let i=e.peek();if(!i)return false;if(this.logicalConnectiveOf(e)==="not"){let o=e.mark();return e.advance(),Sm(e.peek()??void 0,e.peek(1)??void 0)?(e.reset(o),false):this.tryConsumeRunOperand(e,true,a)?true:(e.reset(o),false)}if(i.value==="-"){let o=e.mark();return e.advance(),this.tryConsumeRunOperand(e,true,a)?true:(e.reset(o),false)}if(a&&Bm(i))return false;if(Om(i,t,e.peek(1)??void 0))return e.advance(),true;if(i.value==="("){let o=e.mark(),u=0;for(;!e.isAtEnd();){let s=e.advance();if(s.value==="(")u++;else if(s.value===")"&&(u--,u===0))return true}return e.reset(o),false}if(this.tryMatchPossessiveExpression(e))return true;if(i.value.toLowerCase()==="the"){let o=e.mark();if(e.advance(),this.tryConsumeRunOperand(e,t,a))return true;e.reset(o);}if(this.tryMatchOfPossessiveExpression(e)||this.tryMatchPossessiveSelectorExpression(e)||this.tryMatchPropertyAccessExpression(e,true)||this.tryMatchSelectorPropertyExpression(e))return true;let n=(i.normalized??"").toLowerCase();return (i.kind==="literal"||i.kind==="identifier"||i.kind==="selector"||i.kind==="keyword")&&!Ve.has(i.value)&&!["then","else"].includes(n)&&(n!=="end"||this.endWordIsValueAt(e))&&i.value!==")"?(e.advance(),true):false}endWordIsValueAt(e){return $e(ke(e.tokens,e.position()),this.currentProfile?.code??"")}isPossessorToken(e){if(!this.currentProfile)return false;for(let t of [e.value,e.normalized].filter(Boolean))if(Pe(this.currentProfile,t)??Pe(this.currentProfile,t.toLowerCase()))return true;return false}isBareWordPropertyHead(e){return e.kind!=="identifier"||/^[$:@#.*]/.test(e.value)||this.isStructuralKeyword(e.value)||e.normalized&&this.isStructuralKeyword(e.normalized)||e.normalized&&this.isRoleMarkerConcept(e.normalized)?false:!this.isPossessorToken(e)}toEnglishProperty(e){return this.currentProfile?ge(this.currentProfile.code,e):e}roleAcceptsPropertyPath(e){if(e.type!=="role")return false;if(e.expectedTypes)return e.expectedTypes.includes("property-path");let t=this.currentRoleCommand;return t?le[t]?.roles.find(n=>n.role===e.role)?.expectedTypes?.includes("property-path")??false:false}tryMatchOfPossessiveExpression(e,t){let a=e.peek();if(!a||!(a.kind==="selector"?/^[*@]/.test(a.value):this.isBareWordPropertyHead(a)))return null;let n=e.position(),o=e.mark();e.advance();let u=e.peek();if(!u||!this.isOfPossessiveMarker(u))return e.reset(o),null;e.advance(),e.peek()?.value.toLowerCase()==="the"&&e.advance();let s=St(e.tokens,e.position(),this.currentProfile,c=>c===void 0?false:this.patternTokenWouldMatch(t,c));if(s){for(let c=0;c<s.consumed;c++)e.advance();return Ie({type:"expression",raw:s.parts.map(c=>c.text).join(" ")},this.toEnglishProperty(a.value),"possessive")}let l=e.peek();if(!l||l.kind!=="selector"||of(l.value)){if(e.reset(o),this.patternTokenWouldMatch(t,u))return null;let c=this.currentProfile?.code??"en",p=Xi(e.tokens,n,this.currentProfile,c);if(p===void 0)return null;for(;e.position()<=p;)e.advance();let d=Le(e.tokens.slice(n,p+1),this.currentProfile);return {type:"expression",raw:d,value:d}}return e.advance(),Ie(Ne(l.value),this.toEnglishProperty(a.value),"possessive")}tryMatchPositionalPossessiveExpression(e,t){let a=this.currentProfile,i=a?.possessive?.marker;if(!a||!i||a.possessive?.markerPosition!=="between"||a.code==="th")return null;let n=St(e.tokens,e.position(),a,l=>l===void 0?false:this.patternTokenWouldMatch(t,l));if(!n)return null;let o=e.peek(n.consumed),u=e.peek(n.consumed+1);if(!o||o.value!==i)return null;let s=!!u&&(this.isBareWordPropertyHead(u)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="keyword"&&xa(a.code,u.value));if(!u||!s)return null;for(let l=0;l<n.consumed+2;l++)e.advance();return Ie({type:"expression",raw:n.parts.map(l=>l.text).join(" ")},this.toEnglishProperty(u.value),"possessive")}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let a=[t.value,t.normalized].filter(Boolean),i;for(let s of a)if(i=Pe(this.currentProfile,s)??Pe(this.currentProfile,s.toLowerCase()),i)break;if(!i)return null;let n=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let s=e.peek();if(s){let l=s.value.toLowerCase(),c=(s.normalized??"").toLowerCase();o.some(p=>p.toLowerCase()===l||p.toLowerCase()===c)&&e.advance();}}let u=e.peek();if(!u||ks(this.currentProfile.code,u.value))return e.reset(n),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)&&!(u.normalized&&this.isStructuralKeyword(u.normalized))&&!(u.normalized&&this.isRoleMarkerConcept(u.normalized))&&!(u.normalized&&$.COMMAND_ACTION_KEYWORDS.has(u.normalized.toLowerCase()))||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1)),s=this.toEnglishProperty(s);let l=s;for(;;){let p=e.peek();if(p?.kind==="selector"&&p.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(p.value)){l+=p.value,e.advance();continue}if(p?.value==="?"){let d=e.peek(1);if(d?.kind==="selector"&&d.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(d.value)){l+=`?${d.value}`,e.advance(),e.advance();continue}}break}let c=e.peek();if(c&&c.value.startsWith("(")){let p="",d=0,m=0;for(;!e.isAtEnd()&&m++<$.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;p+=f.value,e.advance();for(let y of f.value)y==="("?d++:y===")"&&d--;if(d<=0)break}l+=p;}return Ie(De(i),l,"possessive")}return e.reset(n),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let t=e.peek();if(!t)return null;let a=t.kind==="selector"&&t.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(t.value);if(!(t.kind==="identifier"&&!this.isStructuralKeyword(t.value)&&!(t.normalized&&this.isStructuralKeyword(t.normalized))&&!(t.normalized&&this.isRoleMarkerConcept(t.normalized))||t.kind==="selector"&&(t.value.startsWith("*")||t.value.startsWith("@"))||a)||this.isPossessorToken(t))return null;let n=e.mark(),o=t.value;a&&(o=o.substring(1)),e.advance(),o=this.toEnglishProperty(o);let u=o;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)u+=e.peek().value,e.advance();let s=e.peek();if(!s)return e.reset(n),null;let l;for(let p of [s.value,s.normalized].filter(Boolean))if(l=Pe(this.currentProfile,p)??Pe(this.currentProfile,p.toLowerCase()),l)break;if(!l)return e.reset(n),null;let c=e.mark();return this.tryMatchPossessiveExpression(e)?(e.reset(n),null):(e.reset(c),e.advance(),Ie(De(l),u,"possessive"))}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())}isRoleMarkerConcept(e){return Pt.has(e.toLowerCase())}static tokenLooksLikeEvent(e){if(e.kind==="selector"||e.kind==="url"||e.kind==="literal")return false;let t=e.value;if(/[/#@*]/.test(t)||t.startsWith('"')||t.startsWith("'")||t.startsWith("`"))return false;let a=e.normalized?.toLowerCase();return !(a&&nf.has(a)||a==="me"||a==="it"||a==="you")}tryMatchBraceRunLiteral(e){let t=e.peek();if(!t||t.kind!=="identifier"||t.value!=="{")return null;let a=e.mark();e.advance();let i=["{"],n=1,o=0;for(;!e.isAtEnd()&&o++<$.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(u.value==="{")n++;else if(u.value==="}"&&(n--,n===0))return i.push("}"),Y(i.join(" "));i.push(u.value);}return e.reset(a),null}tryMatchBraceRunExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"||t.value!=="{")return null;let a=e.mark(),i="",n=-1,o=0,u=0;for(;!e.isAtEnd()&&u++<$.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(n>=0&&s.position.start>n&&(i+=" ".repeat(s.position.start-n)),i+=s.value,n=s.position.end,s.value==="{")o++;else if(s.value==="}"&&(o--,o===0))return {type:"expression",raw:i}}return e.reset(a),null}tryMatchBareCallExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(t.value))return null;let a=e.peek(1);if(!a||a.value!=="(")return null;let i=e.mark();e.advance();let n=e.advance(),o="",u=n.position?.end,s=false,l=0;for(;!e.isAtEnd()&&l++<$.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),s=true;break}let p=u!==void 0&&c.position?.start===u;o+=(o===""||p?"":" ")+c.value,u=c.position?.end,e.advance();}return s?{type:"expression",raw:`${t.value}(${o})`}:(e.reset(i),null)}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let a=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(a),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(a),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(a),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<$.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${t.value}.${n.value}(${u.join(", ")})`}}tryMatchParenReceiverCall(e){if(e.peek()?.value!=="(")return null;let t=e.mark(),a=[];e.advance();let i=1;for(;!e.isAtEnd()&&a.length<=$.MAX_METHOD_ARGS*4;){let c=e.peek();if(e.advance(),c.value==="(")i++;else if(c.value===")"&&--i===0)break;a.push(c);}let n=e.tokens[e.position()-1],o=e.peek();if(i!==0||a.length===0||!o||o.kind!=="selector"||!/^\.[A-Za-z_$][\w$]*$/.test(o.value)||!$.abuts(n,o))return e.reset(t),null;e.advance();let u=e.peek();if(u?.value!=="("||!$.abuts(o,u))return e.reset(t),null;let s=this.consumeCallParens(e);return s===null?(e.reset(t),null):{type:"expression",raw:`(${Le(a,this.currentProfile)})${o.value}${s}`}}tryMatchParenGroupExpression(e){if(e.peek()?.value!=="(")return null;let t=e.mark();e.advance();let a=[],i=1;for(;!e.isAtEnd();){let l=e.peek();if(e.advance(),l.value==="(")i++;else if(l.value===")"&&--i===0)break;a.push(l);}let n=e.tokens[e.position()-1],o=e.peek(),u=!!o&&(o.value==="'"||Ve.has(o.value)||$.abuts(n,o)&&(o.value.startsWith(".")||o.value==="("));if(i!==0||a.length===0||u)return e.reset(t),null;let s=`(${Le(a,this.currentProfile)})`;return {type:"expression",raw:s,value:s}}static abuts(e,t){return !!e&&!!t&&e.position.end===t.position.start}consumeCallParens(e){let t=e.mark(),a=[],i=0;for(;!e.isAtEnd();){let n=e.peek();if(!n)break;if(a.push(n.value),e.advance(),n.value==="(")i++;else if(n.value===")"&&--i===0)return a.join("")}return e.reset(t),null}tryMatchPropertyAccessExpression(e,t=true){let a=e.peek();if(!a||a.kind!=="identifier"&&a.kind!=="keyword")return null;let i=e.mark();e.advance();let n=a.value.toLowerCase(),o=e.peek();if((a.kind==="identifier"||$.PROPERTY_ACCESS_BASES.has(n))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)&&o.position.start===a.position.end){let m=a.value,f=[],y=0;for(;y<$.MAX_PROPERTY_DEPTH;){let E=e.peek();if(E&&E.kind==="selector"&&/^\.[a-zA-Z_]/.test(E.value))m+=`.${E.value.slice(1)}`,f.push(E.value.slice(1)),e.advance(),y++;else break}let h=e.peek(),v=!!h&&h.value.startsWith("(");return t&&!v&&f.length>0&&_e(n)?Ie(De(n),f.join("."),"dot"):(v&&(m+=this.consumeCallParens(e)??""),{type:"expression",raw:m})}let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")return e.reset(i),null;e.advance();let s=e.peek();if(!s||s.kind!=="identifier")return e.reset(i),null;e.advance();let l=`${a.value}.${s.value}`,c=1;for(;!e.isAtEnd()&&c<$.MAX_PROPERTY_DEPTH;){let m=e.peek();if(!m||m.kind!=="operator"||m.value!==".")break;e.advance();let f=e.peek();if(!f||f.kind!=="identifier")break;e.advance(),l+=`.${f.value}`,c++;}let p=e.peek();if(p&&p.kind==="punctuation"&&p.value==="("){e.advance();let m=[],f=0;for(;!e.isAtEnd()&&m.length<$.MAX_METHOD_ARGS;){let h=e.peek();if(!h)break;if(h.kind==="punctuation"&&h.value===")"){if(f===0){e.advance();break}f--;}if(h.kind==="punctuation"&&h.value==="("&&f++,h.kind==="punctuation"&&h.value===","){e.advance();continue}m.push(h.value),e.advance();}return {type:"expression",raw:`${l}(${m.join(", ")})`}}let d=a.value.toLowerCase();if(t&&_e(d)){let m=l.split(".").slice(1).join(".");return Ie(De(d),m,"dot")}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let a=e.mark();e.advance();let i=e.peek(),n=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!i&&i.kind==="punctuation"&&i.value==="'s",u=!!i&&i.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(i?.normalized??"").toLowerCase()!=="source")return false;let f=le[this.currentPatternCommand];return !!f&&f.roles.some(y=>y.role==="source")})(),l=!!i&&!!n&&n!=="'s"&&i.value===n&&(i.kind==="particle"||i.kind==="punctuation"||i.kind==="identifier")&&!s;if(!o&&!l&&!u)return e.reset(a),null;e.advance(),u&&e.advance();let c=e.peek();if(!c)return e.reset(a),null;let p=c.kind==="selector"&&c.value.startsWith("*"),d=c.kind==="keyword"&&!!this.currentProfile&&xa(this.currentProfile.code,c.value);return c.kind==="identifier"||p||d||(o||u)&&(c.kind==="selector"||c.kind==="keyword")?(e.advance(),Ie(Ne(t.value),this.toEnglishProperty(c.value),"possessive")):(e.reset(a),null)}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let a=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(a),null;e.advance();let n=[i.value.slice(1)],o=i;for(let s=e.peek();s&&s.kind==="selector"&&/^\.[a-zA-Z_]/.test(s.value)&&n.length<$.MAX_PROPERTY_DEPTH;s=e.peek())n.push(s.value.slice(1)),o=s,e.advance();let u=e.peek();if(u?.value==="("&&$.abuts(o,u)){let s=this.consumeCallParens(e);if(s!==null)return {type:"expression",raw:`${t.value}.${n.join(".")}${s}`}}return Ie(Ne(t.value),n.join("."),"dot")}matchGroupToken(e,t,a,i){let n=e.mark(),o=new Map(a),u=this.matchTokenSequence(e,t.tokens,a,i);if(u){let s=[];for(let l of t.tokens)if(l.type==="group"&&l.renderRequired)for(let c of l.tokens)c.type==="literal"&&s.push(c.value,...c.alternatives??[]);s.length>0&&[...a.keys()].some(c=>!o.has(c))&&(e.tokens.slice(n.position,e.position()).some(d=>s.some(m=>this.getMatchType(d,m)!=="none"))||(u=false));}if(!u){e.reset(n);for(let s of a.keys())o.has(s)||a.delete(s);for(let[s,l]of o)a.get(s)!==l&&a.set(s,l);return t.optional||false}return true}getMatchType(e,t){if(e.value===t)return "exact";if(e.normalized===t)return "normalized";if(e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7)return "stem";if(e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase())return "case-insensitive";if(e.kind==="keyword"){let a=Wt(e.value).toLowerCase();if(a&&a===Wt(t).toLowerCase())return "case-insensitive"}return "none"}isWrittenTarget(e){return $.WRITTEN_ROLE[this.currentRoleCommand??""]===e.role}tokenToSemanticValue(e){return Zt(e)}applyExtractionRules(e,t){for(let[a,i]of Object.entries(e.extraction)){let n=t.get(a);if(n){if(i.transform){let o=n.type==="literal"?String(n.value):String(n.raw??"");t.set(a,i.transform(o));}}else i.value!==void 0?t.set(a,{type:"literal",value:i.value}):i.default&&t.set(a,{...i.default,implicit:true});}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e,t,a){let i=e.peek();if(!i)return;let n=i.value.toLowerCase();if($.ENGLISH_NOISE_WORDS.has(n)){if(zm(this.slotAt(e,t,a)))return;let o=e.mark();e.advance();let u=e.peek();if(u&&(u.kind==="selector"||u.kind==="identifier"))return;let s=e.peek(1);if(u&&u.kind==="keyword"&&s&&s.kind==="selector"&&/^\.[a-zA-Z_]/.test(s.value))return;let l=u?(u.normalized??u.value).toLowerCase():"";if(u&&$.POSITIONAL_OR_SCOPE_KEYWORDS.has(l))return;let c=e.peek(1),p=c?(c.normalized??c.value).toLowerCase():"",d=this.currentProfile?.wordOrder!=="SOV"&&$.COMMAND_ACTION_KEYWORDS.has(p),m=!c||c.kind==="particle"||$.CLAUSE_BOUNDARY_KEYWORDS.has(p)||d;if(u&&u.kind==="keyword"&&this.currentProfile?.code!=="en"&&_e(l)&&m||u&&u.kind==="keyword"&&this.currentProfile?.code==="en"&&_e(l))return;e.reset(o);}n==="class"&&e.advance();}extractEventModifiers(e){let t={},a=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let n=i.metadata;if(!n)break;switch(a=true,n.modifierName){case "once":t.once=true;break;case "debounce":typeof n.value=="number"&&(t.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(t.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(t.queue=n.value);break}e.advance();}return a?t:void 0}};ae.CONDITION_OPERATOR_WORDS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);ae.LOOP_CONDITION_OPERATORS=new Set([...Mi,"and","or"]);ae.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);ae.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then","while"]);ae.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);ae.COMMAND_ACTION_KEYWORDS=ht;ae.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);ae.RUN_PHRASES=[...Ur.map(r=>[r.split(" "),"none"]),...Gr.map(r=>[r.split(" "),"type"]),...Hr.filter(r=>!/^(in|am|has|have)$|^am /.test(r)).map(r=>[r.split(" "),"operand"]),[["exists"],"none"]];ae.PICK_RANGE_SEPARATORS=new Set(["to"]);ae.PICK_RANGE_SEPARATORS_BY_LANG={ar:new Set(["\u0625\u0644\u0649"]),bn:new Set(["\u09A5\u09C7\u0995\u09C7"]),de:new Set(["zu","bis"]),es:new Set(["a"]),fr:new Set(["\xE0"]),he:new Set(["\u05E2\u05DC","\u05E2\u05D3"]),hi:new Set(["\u0938\u0947"]),id:new Set(["ke"]),it:new Set(["in","a"]),ja:new Set(["\u304B\u3089"]),ko:new Set(["\uBD80\uD130"]),ms:new Set(["ke"]),pl:new Set(["do"]),pt:new Set(["para","a"]),qu:new Set(["kama"]),ru:new Set(["\u0432","\u0434\u043E"]),sw:new Set(["kwa","hadi"]),th:new Set(["\u0E43\u0E19","\u0E16\u0E36\u0E07"]),tl:new Set(["sa"]),tr:new Set(["ile"]),uk:new Set(["\u0432","\u0434\u043E"]),vi:new Set(["v\xE0o","\u0111\u1EBFn"]),zh:new Set(["\u5230"])};ae.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);ae.VISIBILITY_STRATEGIES=new Set(["display","visibility","opacity","twdisplay","twvisibility","twopacity"]);ae.MAX_BRACE_RUN_TOKENS=64;ae.MAX_PROPERTY_DEPTH=10;ae.MAX_METHOD_ARGS=20;ae.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);ae.WRITTEN_ROLE={increment:"patient",decrement:"patient",set:"destination"};ae.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var ln=ae,xe=new ln;function Z(r,e){return uc(r,e)}function cn(){return oc()}var Jt={ar:new Set(["\u0623\u0648"]),bn:new Set(["\u0985\u09A5\u09AC\u09BE"]),de:new Set(["oder"]),en:new Set(["or"]),es:new Set(["o"]),fr:new Set(["ou"]),he:new Set(["\u05D0\u05D5"]),hi:new Set(["\u092F\u093E"]),id:new Set(["atau"]),it:new Set(["o"]),ja:new Set(["\u307E\u305F\u306F"]),ko:new Set(["\uB610\uB294"]),ms:new Set(["atau"]),pl:new Set(["lub"]),pt:new Set(["ou"]),qu:new Set(["utaq"]),ru:new Set(["\u0438\u043B\u0438"]),sw:new Set(["au"]),th:new Set(["\u0E2B\u0E23\u0E37\u0E2D"]),tl:new Set(["o"]),tr:new Set(["veya"]),uk:new Set(["\u0430\u0431\u043E"]),vi:new Set(["ho\u1EB7c"]),zh:new Set(["\u6216"])},uf=new Set(Object.values(Jt).flatMap(r=>[...r]));function Yt(r,e){let t=(r.normalized??r.value).toLowerCase();if(t==="or")return true;let a=e===void 0?uf:Jt[e];return a?a.has(r.value)||a.has(t):false}var pn=["if","unless","repeat","for","while"],nr=/^[A-Z][A-Za-z0-9_]*$/;function Q(r,e){let t=new Set([e]),i=T(r)?.keywords?.[e];if(i){i.primary&&t.add(i.primary.toLowerCase());for(let n of i.alternatives??[])t.add(n.toLowerCase());}return t}function W(r,e){return e.has(r.value.toLowerCase())?true:r.normalized?e.has(r.normalized.toLowerCase()):false}var sf=new Set(pn);function Rt(r){return {byAction:pn.map(e=>[e,Q(r,e)]),elseForms:Q(r,"else"),inForms:Q(r,"in")}}function ja(r,e){if(!r)return;let t=r.normalized?.toLowerCase();return t?sf.has(t)?t:void 0:e.byAction.find(([,a])=>W(r,a))?.[0]}function Lt(r,e,t){let a=r[e],i=ja(a,t);if(!i||i==="while")return false;let n=r[e-1];if(i==="for"){if(ja(n,t)==="repeat")return false;if(a.value.toLowerCase()==="for"){let o=r[e+2];return !!o&&(W(o,t.inForms)||o.normalized==="in")}}return !(i==="if"&&n&&W(n,t.elseForms))}var Wa=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),lf=new Set(["destination","source","style","patient","on","from","to"]);function st(r){if(!r||r.kind==="selector")return false;let e=(r.normalized??r.value).toLowerCase(),t=r.value.toLowerCase();return !(Wa.has(e)||Wa.has(t)||lf.has(e))}var cf=r=>Object.prototype.hasOwnProperty.call(le,r);function dn(r){return r.flatMap(e=>e.type==="literal"?[e.value,...e.alternatives??[]].map(t=>t.toLowerCase()):e.type==="group"?dn(e.tokens):[])}var pf=new Set(["toggle","trigger"]);function mn(r){return r.flatMap((e,t)=>{if(e.type==="group")return mn(e.tokens);if(e.type!=="literal")return [];let a=r[t+1];return [{words:[e.value,...e.alternatives??[]].map(i=>i.toLowerCase()),role:a?.type==="role"?a.role:void 0}]})}function df(r,e,t,a){return r.some((i,n)=>{if(!i.words.includes(e)||!i.role||!a.has(i.role))return false;let o=0;for(let u of t){let s=r.findIndex((l,c)=>c>=o&&c<n&&l.words.includes(u));if(s<0)return false;o=s+1;}return true})}function mf(r,e,t,a,i){let n=r[t].value.toLowerCase();for(let o=t-1;o>e;o--){let u=r[o];if(i(u)||u.value.toLowerCase()===n)return false;let s=(u.normalized??u.value).toLowerCase();if(!cf(s))continue;let l=fe(a).filter(p=>p.command===s);if(pf.has(s))return l.some(p=>dn(p.template.tokens).includes(n));let c=new Set((le[s]?.roles??[]).filter(p=>p.required).map(p=>p.role));return l.some(p=>{let d=mn(p.template.tokens),m=new Set(d.flatMap(y=>y.words)),f=r.slice(o+1,t).map(y=>y.value.toLowerCase()).filter(y=>m.has(y));return df(d,n,f,c)})}return false}var qa=new Set(["ja","ko"]);function Ke(r){let e=new Set;r?.primary&&e.add(r.primary.toLowerCase());for(let t of r?.alternatives??[])e.add(t.toLowerCase());return e}function fn(r,e){let t=[],a=e.position.end,i=r.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(i){a=e.position.end+i[0].length;for(let n of i[1].split(/[,\u060c\u3001]/)){let o=n.trim();o&&t.push(o);}}return {parameters:t,headerEnd:a}}function _t(r,e,t){let a=e+1;if(a>=r.length)return -1;let i=Ke(T(t)?.roleMarkers?.patient);return i.size>0&&W(r[a],i)&&a++,a<r.length?a:-1}var yn=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function ff(r){let e=1;if(r[1]?.value==="("){let t=0,a=1;for(;a<r.length;a++)if(r[a].value==="(")t++;else if(r[a].value===")"&&--t===0)break;if(a>=r.length)return -1;e=a+1;}return e+1}function yf(r,e,t){let a=T(t);if(a?.wordOrder!=="SOV"||!yn.test(r[0].value)||e!==ff(r))return false;let i=Ke(a.roleMarkers?.patient);return i.size===0?false:W(r[e-1],i)}function vf(r,e,t){if(!T(e))return null;let a=Q(e,"behavior"),i=Q(e,"def"),n=r.toLowerCase(),o=[...a].some(p=>n.includes(p)),u=/\bdef\b/.test(n)||[...i].some(p=>p!=="def"&&n.includes(p));if(!o&&!u)return null;let s=Z(r,e).tokens;if(s.length<2)return null;if(W(s[0],a))return Va(r,e,s,t,0);let l=s.findIndex((p,d)=>d>0&&W(p,a));if(l>0&&nr.test(s[0].value))return Va(r,e,s,t,l);if(W(s[0],i))return Ka(r,e,s,t,0);let c=s.findIndex((p,d)=>d>0&&W(p,i));return c>0&&yf(s,c,e)?Ka(r,e,s,t,c):null}function hf(r,e,t){let a=T(e);if(!a)return null;let i=a.wordOrder!=="SOV",n=qa.has(e)?Ke(a.roleMarkers?.event):new Set,o=qa.has(e)?Ke(a.keywords?.on):new Set,u=n.size>0&&o.size>0,s=u?Ke(a.roleMarkers?.source):new Set,l=Q(e,"end"),c=Q(e,"on"),p=Q(e,"then"),d=r.toLowerCase(),m=[...l].some(x=>d.includes(x)),f=(i||u)&&(()=>{let x=0;for(let B of c)if(B){for(let w=d.indexOf(B);w>=0;w=d.indexOf(B,w+B.length))if(++x>=2)return true}return false})();if(!m&&!f)return null;let y=Z(r,e).tokens;if(y.length<2)return null;let h=Rt(e),v=x=>Lt(y,x,h),E=x=>W(x,l),k=[],z=0,g=0;for(let x=0;x<y.length;x++){let B=y[x];if(E(B)){if(z>0){z--;continue}if(y[x+1]&&W(y[x+1],p))continue;let w=r.slice(y[g].position.start,B.position.start).trim();w&&k.push(w),g=x+1;}else if(v(x))z++;else if(i&&z===0&&x>g&&W(B,c)&&st(y[x+1])&&!(y[x+2]&&W(y[x+2],p))&&!mf(y,g,x,e,w=>E(w)||W(w,p))){let w=r.slice(y[g].position.start,B.position.start).trim();w&&k.push(w),g=x;}else if(u&&z===0&&x-1>g&&W(B,n)&&y[x+1]!==void 0&&W(y[x+1],o)){let w=y[x-1],C=y.slice(g,x-1);if(!(C.length===2&&W(C[1],s))){let O=r.slice(y[g].position.start,w.position.start).trim();O&&k.push(O),g=x-1;}}}if(g<y.length){let x=r.slice(y[g].position.start).trim();x&&k.push(x);}if(k.length<2)return null;let A=[],b=[];for(let x of k){let B;try{B=t.statement(x,e);}catch{return null}if(!B||B.kind!=="event-handler")return null;let w=B;if(A.push(w),!w.body||w.body.length===0)return null;b.push(w.metadata?.confidence??.75);}return nt(A,"then",{sourceLanguage:e,confidence:ft(b),sourceText:r})}function ft(r){return r.length>0?r.reduce((e,t)=>e+t,0)/r.length:0}function or(r){let e=[];for(let t of r){let a=t.statements;t.kind==="compound"&&Array.isArray(a)?e.push(...a):e.push(t);}return e}function Va(r,e,t,a,i){let n=i>0,o=n?0:_t(t,i,e);if(o<0)return null;let u=t[o],s=u.value;if(!nr.test(s))return null;let{parameters:l,headerEnd:c}=fn(r,u),p=n?i+1:t.findIndex(C=>C.position.start>=c);p<=o&&(p=o+1);let d=Q(e,"init"),m=Q(e,"end"),f=Rt(e),y=C=>Lt(t,C,f),h=C=>W(C,m),v=T(e)?.wordOrder!=="SOV",E=v?Ef(e):new Set,k=C=>{let D=r.slice(t[B].position.end,t[C].position.start).trim();if(D)try{let O=or(a.body(D,e));g.push(...O),A.push(ft(O.map(M=>M.metadata?.confidence??.75)));}catch{A.push(0);}},z=[],g=[],A=[],b=false,x=0,B=p;for(let C=p;C<t.length;C++){let D=t[C];if(h(D)){if(x>0){x--;continue}if(C===B){b=true;break}if(W(t[B],d))k(C);else {let O=r.slice(t[B].position.start,D.position.start).trim();try{let M=a.statement(O,e);if(M&&M.kind==="event-handler"){let P=M;z.push(P);let F=!P.body||P.body.length===0;A.push(F?.2:P.metadata?.confidence??.75);}else A.push(0);}catch{A.push(0);}}B=C+1;}else y(C)?x++:v&&x===0&&C>B&&W(t[B],d)&&E.has(D.value.toLowerCase())&&(t[C+1]?.kind==="identifier"||t[C+1]?.kind==="keyword")&&st(t[C+1])&&(k(C),B=C);}if(z.length===0&&g.length===0)return null;let w=(b?1:.8)*ft(A);return Jc(s,l,z,g.length>0?g:void 0,{sourceLanguage:e,confidence:w,sourceText:r})}function Ef(r){let e=new Set;for(let t of fe(r))if(!(t.command!=="on"||/-event-/i.test(t.id)))for(let a of t.template.tokens){if(a.type==="role"&&a.role==="event")break;if(a.type==="literal")for(let i of [a.value,...a.alternatives??[]])e.add(i.toLowerCase());}return e}function Ka(r,e,t,a,i){let n=i>0,o=n?0:_t(t,i,e);if(o<0)return null;let u=t[o],s=u.value;if(!yn.test(s))return null;let{parameters:l,headerEnd:c}=fn(r,u),p=n?i+1:t.findIndex(b=>b.position.start>=c);p<=o&&(p=o+1);let d=Q(e,"end"),m=Rt(e),f=b=>Lt(t,b,m),y=b=>W(b,d),h=0,v=-1;for(let b=p;b<t.length;b++)if(y(t[b])){if(h===0){v=b;break}h--;}else f(b)&&h++;let E=t[p]?.position.start??c,k=v>=0?t[v].position.start:r.length,z=r.slice(E,k).trim();if(!z)return null;let g;try{g=or(a.body(z,e));}catch{return null}if(g.length===0)return null;let A=ft(g.map(b=>b.metadata?.confidence??.75));return v<0&&(A*=.8),Qc(s,l,g,{sourceLanguage:e,confidence:A,sourceText:r})}var Br=["live","eventsource","socket","worker","intercept"],gf=new Set(["intercept"]),Xr=new Set(["eventsource","socket","worker"]),kf=new Set(["eventsource","socket"]),wf=new Set(["worker"]),zf=6,bf=2;function Cf(r,e){for(let a of Br)if(W(r[0],Q(e,a)))return {action:a,keywordIdx:0};if(T(e)?.wordOrder!=="SOV")return null;let t=Math.min(r.length,zf);for(let a=1;a<t;a++)for(let i of Br)if(i!=="live"&&W(r[a],Q(e,i))&&!(Xr.has(i)&&!nr.test(r[0].value))&&!(i==="intercept"&&a>bf))return {action:i,keywordIdx:a};return null}function Af(r,e,t){let a=Ke(T(t)?.roleMarkers?.source);return a.size===0||e+1>=r.length?0:W(r[e],a)||W(r[e+1],a)?2:0}function vn(r){let e=Q(r,"on");e.add("when");let t=T(r)?.eventHandler;if(t?.keyword){e.add(t.keyword.primary.toLowerCase());for(let a of t.keyword.alternatives??[])e.add(a.toLowerCase());}for(let a of t?.temporalMarkers??[])e.add(a.toLowerCase());return e}function xf(r,e,t){let a=T(t)?.eventHandler,i=[a?.eventMarker?.primary,...a?.eventMarker?.alternatives??[],...a?.temporalMarkers??[]].filter(o=>!!o&&/\s/.test(o)),n=1;for(let o of i){let u=o.toLowerCase().split(/\s+/),s=e-u.length+1;s<0||u.every((l,c)=>r[s+c]?.value.toLowerCase()===l)&&(n=Math.max(n,u.length));}return n}function Df(r,e,t,a,i){if(r==="live")return t+1;if(t>0){let l=t+1;return r==="eventsource"&&(l+=Af(e,l,a)),l}let n=_t(e,t,a);if(n<0)return -1;if(r==="worker")return n+1;let o=vn(a),u=Ke(T(a)?.roleMarkers?.event),s=i>=0?i:e.length;for(let l=n+1;l<s;l++){if(!W(e[l],o))continue;if(st(e[l+1]))return l;if(l>n+2&&u.size>0&&W(e[l-1],u)&&st(e[l-2]))return l-2;let c=xf(e,l,a);if(c>1&&l-c>n&&st(e[l-c]))return l-c;if(l>n+1&&st(e[l-1]))return l-1}return s}function Bf(r,e,t,a){if(!Xr.has(r))return;let i=t>0?0:_t(e,t,a);if(!(i<0))return e[i].value}function Sf(r,e,t){if(!T(e))return null;let a=r.toLowerCase(),i=false;for(let s of [...Br,"changes"]){for(let l of Q(e,s))if(l&&a.includes(l)){i=true;break}if(i)break}if(!i)return null;let n=Z(r,e).tokens;if(n.length<2)return null;let o=Rf(n,e);if(o>=0)return _f(r,e,n,t,o);let u=Cf(n,e);return u?Tf(r,e,n,t,u.action,u.keywordIdx):null}function Tf(r,e,t,a,i,n){let o=Q(e,"end"),u=Rt(e),s=g=>Lt(t,g,u),l=g=>W(g,o),c=Bf(i,t,n,e);if(Xr.has(i)&&(!c||!nr.test(c)))return null;let p=g=>({sourceLanguage:e,confidence:g,sourceText:r}),d=Sr(t,n+1,l,s);if(gf.has(i))return d>=0&&d!==t.length-1?null:Ar(i,[],c,p(d>=0?1:.8));let m=Df(i,t,n,e,d);if(m<0||m>t.length)return null;let f=[],y=[],h=false,v=wf.has(i);if(v||kf.has(i)){let g=v?"def":"event-handler",A=0,b=m;for(let x=m;x<t.length;x++){let B=t[x];if(l(B)){if(A>0){A--;continue}if(h=true,x===b)break;let w=v?B.position.end:B.position.start,C=r.slice(t[b].position.start,w).trim();try{let D=a.statement(C,e);if(D&&D.kind===g){let O=D;f.push(O);let M=!O.body||O.body.length===0;y.push(M?.2:O.metadata?.confidence??.75);}else y.push(0);}catch{y.push(0);}b=x+1;}else s(x)&&A++;}}else {let g=Sr(t,m,l,s);h=g>=0;let A=g>=0?t[g].position.start:r.length,b=r.slice(t[m].position.start,A).trim();if(!b)return null;try{f.push(...or(a.body(b,e)));}catch{return null}if(f.length===0)return null;y.push(...f.map(x=>x.metadata?.confidence??.75));}if(f.length===0&&!h)return null;let E=h?1:.8,k=y.length>0?E*ft(y):E,z=Ff(i,r,t,n,m,e);return Ar(i,f,c,p(k),z?new Map([["source",z]]):void 0)}function Ff(r,e,t,a,i,n){if(r!=="eventsource"&&r!=="socket"||a!==0)return;let o=_t(t,a,n);if(o<0)return;let u=o+1,s=Math.min(i,t.length)-1;if(r==="eventsource"){let c=Ke(T(n)?.roleMarkers?.source),p=d=>!!d&&(W(d,c)||(d.normalized??"").toLowerCase()==="source");p(t[u])?u++:p(t[s])&&s--;}if(u>s)return;let l=e.slice(t[u].position.start,t[s].position.end).trim();return l?{type:"expression",raw:l}:void 0}var Pf=new Set([...Object.keys(le),"then","else"]);function Of(r){let e=Q(r,"when");for(let t of vn(r))e.add(t);return e}function Rf(r,e){if(r.length<3||!W(r[0],Of(e)))return -1;let t=Q(e,"changes"),a=Q(e,"end");for(let i=2;i<r.length;i++){let n=r[i];if(n.kind==="literal")continue;if(W(n,t))return i;if(W(n,a))return -1;let o=(n.normalized??n.value).toLowerCase();if(n.kind==="keyword"&&Pf.has(o))return -1}return -1}function Lf(r,e,t){if(t==="en"){let i=e[0],n=e[e.length-1];return {type:"expression",raw:r.slice(i.position.start,n.position.end).trim()}}let a=e.map(i=>Yt(i,t)?{...i,kind:"keyword",normalized:"or"}:i);return {type:"expression",raw:Le(a,T(t))}}function _f(r,e,t,a,i){let n=Q(e,"end"),o=Rt(e),u=E=>Lt(t,E,o),s=E=>W(E,n),l=i+1;if(l>=t.length)return null;let c=Sr(t,l,s,u),p=c>=0;if(p&&c!==t.length-1)return null;let d=p?t[c].position.start:r.length,m=r.slice(t[l].position.start,d).trim();if(!m)return null;let f;try{f=or(a.body(m,e));}catch{return null}if(f.length===0)return null;let y=Lf(r,t.slice(1,i),e),v=(p?1:.8)*ft(f.map(E=>E.metadata?.confidence??.75));return Ar("when",f,void 0,{sourceLanguage:e,confidence:v,sourceText:r},new Map([["condition",y]]))}function Sr(r,e,t,a){let i=0;for(let n=e;n<r.length;n++)if(t(r[n])){if(i===0)return n;i--;}else a(n)&&i++;return -1}var Nf=new Set(["the","to","on","with","into","from","at"]),Ha=/^[A-Za-z_$][\w$]*$/,Mf=64;function Ua(r){let e="";for(let t=0;t<r.length;t++){let a=r[t],i=r[t-1];i&&a.position.start>i.position.end&&(e+=" "),e+=a.value;}return e}function If(r,e){let t=0;for(let a=e;a<r.length&&a-e<=Mf;a++){let i=r[a].value;if(i==="(")t++;else if(i===")"&&(t--,t===0))return a+1}return -1}function Ga(r,e){return e.position.start===r.position.end}function $f(r,e,t,a){let i=r[e];if(!i||i.kind!=="identifier"&&i.kind!=="keyword"||!Ha.test(i.value)||a(i))return null;let n=e+1,o=i.value;for(;r[n]?.kind==="selector"&&/^\.[A-Za-z_$][\w$]*$/.test(r[n].value)&&Ga(r[n-1],r[n]);)o+=r[n].value,n++;let u=n>e+1,s=r[n];if(!s||s.value!=="("||!Ga(r[n-1],s))return null;let l=If(r,n);if(l<0)return null;let c=o+Ua(r.slice(n,l));if(u)return {text:`call ${c}`,consumed:l-e};let p=l,m=r[p]?.value.toLowerCase(),f=null;if(m==="me")f="me",p++;else if(m!==void 0&&Nf.has(m)){p++,r[p]?.value.toLowerCase()==="the"&&p++;let y=r[p];if(!y)return null;let h=St(r,p,t);if(h)f=`(${Ua(r.slice(p,p+h.consumed))})`,p+=h.consumed;else if(y.kind==="selector"&&y.value.startsWith("#")&&!/[.[:\s]/.test(y.value.slice(1)))f=y.value,p++;else if(y.kind==="selector"&&/^[.<]/.test(y.value))f=`(${y.value})`,p++;else if((y.kind==="keyword"||y.kind==="identifier")&&Ha.test(y.value)&&(_e(y.value.toLowerCase())||y.kind==="identifier"))f=y.value,p++;else return null}return {text:f?`call ${f}.${c}`:`call ${c}`,consumed:p-e}}var jf={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},Wf=[["\u043E\u0434\u0438\u043D","_","\u0440\u0430\u0437"],["\u043E\u0434\u0438\u043D_\u0440\u0430\u0437"],["\u043E\u0434\u043D\u0430\u0436\u0434\u044B"],["m\u1ED9t","l\u1EA7n"],["once"]],qf=/^(\d+)(ms|s|m)?$/,Vf=new Set(["selector","literal","url","event-modifier"]);function Kf(r){let e=r.match(qf);if(!e)return null;let t=parseInt(e[1],10),a=e[2]||"ms";return a==="s"?t*=1e3:a==="m"&&(t*=6e4),t}function Hf(r){for(let e=1;e<r.length;e++){let t=r[e];if(Vf.has(t.kind))continue;let a=t.value.toLowerCase(),i=jf[a];if(i){let n=0;for(let o=e+1;o<r.length;o++){let u=r[o],s=Kf(u.value);if(s!==null)return {modifiers:{[i]:s},start:t.position.start,end:u.position.end};if(u.kind==="selector"||u.kind==="literal"||u.kind==="url"||++n>2)break}continue}for(let n of Wf){if(n[0]!==a||e+n.length>r.length)continue;let o=true;for(let u=1;u<n.length;u++)if(r[e+u].value.toLowerCase()!==n[u]){o=false;break}if(o)return {modifiers:{once:true},start:t.position.start,end:r[e+n.length-1].position.end}}}return null}function Uf(r,e){try{let t=Z(r,e),a=fe(e);if(a.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let i=[...a].sort((l,c)=>c.priority-l.priority),n=i.filter(l=>l.command==="on"),o=xe.matchBest(t,n);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};t.reset(t.mark());let u=i.filter(l=>l.command!=="on"),s=xe.matchBest(t,u);return s?{confidence:s.confidence,parseSuccess:!0,patternId:s.pattern.id,action:s.pattern.command,tokensConsumed:s.consumedTokens}:{confidence:0,parseSuccess:!1,error:`Could not match any patterns for: ${r}`}}catch(t){return {confidence:0,parseSuccess:false,error:t instanceof Error?t.message:String(t)}}}function hn(r,e){try{let a=Dy(r,e);if(a)return {node:a,confidence:a.metadata?.confidence??.8,error:void 0,tokensConsumed:Z(r,e).tokens.length}}catch{}let t=Uf(r,e);return t.parseSuccess?{node:null,confidence:t.confidence,error:void 0,tokensConsumed:t.tokensConsumed}:{node:null,confidence:0,error:t.error}}new Set(Object.values(Zr).flatMap(r=>Object.values(r)));var cy=new Set(["a","an","the"]),Xa=new Map;function py(r){let e=Xa.get(r);return e||(e=new Set(Object.values(le).flatMap(t=>t.roles.flatMap(a=>[a.markerOverride?.[r],...a.markerVariants?.[r]??[]].filter(i=>typeof i=="string"&&i.length>0)))),Xa.set(r,e)),e}function dy(r,e){let t=Z(r,e).tokens,a=t[0];if(t.length!==1||!a)return {collision:"structure",word:"words"};let i=a.normalized!==r?a.normalized:void 0;if(a.kind==="keyword"&&Ei.has(i??""))return {collision:"pronoun",word:"pronoun",sense:i};if(a.kind==="identifier"&&!i){if(py(e).has(r))return {collision:"structure",word:"marker"};let n=Ye(e,r);return n!==r?{collision:"structure",word:"connective",sense:n}:cy.has(r.toLowerCase())?{collision:"structure",word:"article"}:null}return a.kind==="particle"?{collision:"structure",word:"marker"}:{collision:"structure",word:"keyword",sense:i}}function my(r,e){let t=`${e}\0${r}`,a=Ja.get(t);return a===void 0&&(a=dy(r,e)?.collision??null,Ja.set(t,a)),a}var Ja=new Map;sc((r,e)=>my(r,e)==="structure");var Ge=new Set(["if","unless","while","repeat","for"]),En=new Set(["repeat","for"]),ot={kind:"loop-close"};function Jr(r){return r===ot}function Fr(r){if(Jr(r)||r.kind!=="command"||!En.has(r.action))return false;let e=r.body;return !(Array.isArray(e)&&e.length>0)}function fy(r){switch(r.type){case "expression":return r.raw;case "literal":return String(r.value);case "reference":return r.value;default:return}}function Ht(r,e){for(let t=e-1;t>=0;t--)if(r[t].kind!=="particle")return r[t]}function kr(r){return r.kind!=="keyword"&&r.kind!=="identifier"?false:(r.normalized??r.value).toLowerCase()==="repeat"}function Ut(r){let e=0;for(let t of r)Fr(t)?e++:Jr(t)&&e>0&&e--;return e}var wr=new Set(["then","end","else","if","unless","while","for","repeat","and"]),yy=new Set(["first","last","next","previous","random","closest"]),vy=new Set(["me","my","i","it","its","you","your","result"]),Qa=new Set(["top","middle","bottom","left","center","right","nearest"]),hy=new Set(["smoothly","instantly"]);function Ey(r,e){if(!e)return false;let t=e.value.toLowerCase();switch(r.type){case "selector":return r.value.toLowerCase()===t;case "reference":return r.value===(e.normalized??e.value).toLowerCase()||r.value===t;case "expression":return r.raw.toLowerCase().split(/\s+/)[0]===t;default:return String("value"in r?r.value:"").toLowerCase()===t}}var bt=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function gy(r){let e=(r.normalized??r.value).toLowerCase();return e==="document"||e==="window"||e==="me"||e==="body"?De(e):r.kind==="selector"?Ne(r.value):{type:"expression",raw:r.value}}var ei=new Map;function ti(r){let e=ei.get(r);return e||(e=new Set(fe(r).map(t=>t.command).filter(t=>t!=="on")),ei.set(r,e)),e}var Oe=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),ri=class extends Error{constructor(r,e,t,a){super(r),this.name="SemanticParseError",this.language=e,this.input=t,this.diagnostics=a;}};function G(r,e,t){return {message:r,severity:e,source:"semantic-parser",...t&&{code:t}}}function V(r,e){return e.length===0?r:{...r,diagnostics:e}}var er=120;function ky(r,e,t){let a=e.tokens.length;if(r.consumedTokens>=a)return null;let i=e.tokens[r.consumedTokens],n=e.tokens[a-1];if(!i||!n)return null;let o=t.slice(i.position.start,n.position.end);if(!o.trim())return null;let u=o.length>er?`${o.slice(0,er)}\u2026`:o,s=a-r.consumedTokens;return `pattern ${r.pattern.id} left ${s} token(s) unconsumed: "${u}"`}var ai=/^repeat-.*-(times|for-in|while-head|until-head|until-condition-head)$/,wy=new Set(["forever","times","for","while","until","until-event"]),zy=new Set(["to","from","into","onto","with","as","at","of","in","on","by","and","or","then","end","else","the","a","an","async"]);function Gt(r){let e=[],t=new Set((r.diagnostics??[]).map(i=>`${i.code}|${i.message}`)),a=i=>{if(!i||typeof i!="object")return;if(i!==r)for(let o of i.diagnostics??[]){if(o.code!=="unconsumed-input")continue;let u=`${o.code}|${o.message}`;t.has(u)||(t.add(u),e.push(o));}let n=i;for(let o of gn){let u=n[o];if(Array.isArray(u))for(let s of u)a(s);}};return a(r),e.length===0?r:V(r,[...r.diagnostics??[],...e])}function by(r){if(r.length>=2){let e=r[0];if((e==='"'||e==="'")&&r.endsWith(e))return r.slice(1,-1)}return r}var gn=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function kn(r,e,t){if(!r||typeof r!="object")return r;if(r.action&&r.roles instanceof Map){let i=ue(r.action),n=i?.primaryRole;if(i&&n&&n!=="patient"&&!i.roles.some(o=>o.role==="patient")&&r.roles.has("patient")&&!r.roles.has(n)){let o=r.roles,u=o.get("patient");u!==void 0&&(o.delete("patient"),o.set(n,u));}if(r.action==="tell"){let o=r.roles,u=o.get("patient"),s=o.get("destination");u&&(u.type==="selector"||u.type==="reference")&&(!s||s.type==="literal")&&(o.delete("patient"),o.set("destination",u));}if(r.action==="transition"){let o=r.roles,u=o.get("goal");u&&u.type==="literal"&&u.dataType==="duration"&&!o.has("duration")&&(o.delete("goal"),o.set("duration",u));}if(r.action==="fetch"){let o=r.roles,u=o.get("patient"),s=o.get("source");u&&s&&(u.type==="literal"||u.type==="expression")&&s.type==="expression"&&!o.has("style")&&(o.delete("patient"),o.set("style",s),o.set("source",u));}if(r.action==="transition"){let o=r.roles,u=o.get("destination");u&&u.type==="literal"&&!o.has("goal")&&(o.delete("destination"),o.set("goal",u));let s=o.get("patient");s&&s.type==="literal"&&typeof s.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(s.value)&&o.set("patient",{type:"expression",raw:s.value});}if(r.action==="morph"){let o=r.roles,u=o.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(u.value)&&o.set("patient",{type:"expression",raw:u.value});}if(r.action==="wait"){let o=r.roles;if(!o.has("event")){let u=o.get("duration"),s=u?.type==="expression"?u.raw:u?.type==="literal"?u.value:void 0,l=typeof s=="string"&&t?yi(s,t):"";typeof s=="string"&&Oe.has(s.toLowerCase())?(o.delete("duration"),o.set("event",{type:"literal",value:s,dataType:"string"})):Oe.has(l)&&(o.delete("duration"),o.set("event",{type:"literal",value:l,dataType:"string"}));}}if(r.kind==="command"&&r.action!=="on"){let o=r.roles,u=o.get("event");if(u&&u.type==="expression"){let s=u.raw;typeof s=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(s)&&o.set("event",{type:"literal",value:s,dataType:"string"});}}if(e?.size){let o=r.roles;for(let u of ["destination","source"]){let s=o.get(u);s&&s.type==="literal"&&typeof s.value=="string"&&e.has(s.value)&&o.set(u,{type:"expression",raw:s.value});}}}let a=r;for(let i of gn){let n=a[i];if(Array.isArray(n))for(let o of n)kn(o,e,t);}return r}var Cy=/^[\p{L}_$][\p{L}\p{N}_$:.\-]*$/u,ze=class S{constructor(){this.parseDepth=0,this.coverageFrames=[],this.boundIdentifiers=new Set;}parse(e,t){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++,this.coverageFrames.push([]);try{let a=kn(this.parseInternal(e,t),this.boundIdentifiers,t),i=this.coverageFrames[this.coverageFrames.length-1];if(i.length>0&&(a=V(a,[...a.diagnostics??[],...i])),this.parseDepth===1&&(a=Gt(a),a.kind==="event-handler")){let n={node:a,input:e},o=n.node.eventModifiers;if(o&&(o.once||o.debounce!==void 0||o.throttle!==void 0))for(let s=0;s<4;s++){let l=this.reclaimDanglingFromTail(n.node,n.input,t)??this.reclaimEventCompoundTail(n.node,n.input,t)??this.reclaimResponseTypeTail(n.node,n.input,t)??this.reclaimCapturedDestinationTail(n.node,n.input,t);if(!l)break;n=l;}let u=this.reclaimEventCompoundTail(n.node,n.input,t);u&&(n=u),a=n.node;}return a}finally{this.coverageFrames.pop(),this.parseDepth--;}}coverageMark(){let e=this.coverageFrames[this.coverageFrames.length-1];return e?e.length:0}coverageRollback(e){let t=this.coverageFrames[this.coverageFrames.length-1];t&&t.length>e&&(t.length=e);}static getCoverageMarkerSurfaces(e){let t=S.coverageMarkerSurfaces.get(e);if(!t){t=new Set;let a=T(e)?.roleMarkers;if(a){for(let i of Object.values(a))if(i){if(i.primary)for(let n of i.primary.toLowerCase().split(/\s+/))t.add(n);for(let n of i.alternatives??[])for(let o of n.toLowerCase().split(/\s+/))t.add(o);}}for(let i of S.LEAKED_RENDER_MARKERS[e]??[])t.add(i.toLowerCase());S.coverageMarkerSurfaces.set(e,t);}return t}isCoverageResidueToken(e,t){if(e.kind==="particle"||e.kind==="conjunction"||e.metadata?.closesTrackedBlock||this.isThenKeyword(e.value,t)||this.isEndKeyword(e.value,t)||this.isElseKeyword(e.value,t))return true;let a=(e.normalized??e.value).toLowerCase();return zy.has(a)?true:S.getCoverageMarkerSurfaces(t).has(e.value.toLowerCase())}recordDroppedTokens(e,t,a){if(e.length===0)return;let i=this.coverageFrames[this.coverageFrames.length-1];if(!i||!e.some(u=>!this.isCoverageResidueToken(u,t)))return;let n=e.map(u=>u.value).join(" ").trim();if(!n)return;let o=n.length>er?`${n.slice(0,er)}\u2026`:n;i.push(G(`${a} left ${e.length} token(s) unconsumed: "${o}"`,"warning","unconsumed-input"));}registerBoundIdentifiers(e){let t=e.action==="repeat"||e.action==="for"?"patient":e.action==="set"?"destination":null;if(!t)return;let a=e.roles.get(t);a?.type==="expression"&&typeof a.raw=="string"&&/^[A-Za-z_]\w*$/.test(a.raw)&&this.boundIdentifiers.add(a.raw);}parseInternal(e,t){let a=vf(e,t,{statement:(w,C)=>this.parse(w,C),body:(w,C)=>this.parseStatements(w,C)});if(a)return a;let i=Sf(e,t,{statement:(w,C)=>this.parse(w,C),body:(w,C)=>this.parseStatements(w,C)});if(i)return i;let n=hf(e,t,{statement:(w,C)=>this.parse(w,C),body:(w,C)=>this.parseStatements(w,C)});if(n)return n;let{modifiers:o,remainingInput:u}=this.extractStandaloneModifiers(e,t),s=u||e,c=this.stripAsyncModifier(s,t).remainingInput??s,d=this.stripDoNotThrowModifier(c,t).remainingInput??c,m=[],f=Z(d,t);this.positionSource=d;{let w=f.mark(),C=this.consumeJsBlock(f,t);if(C&&f.isAtEnd())return V(C,m);f.reset(w);}let y=fe(t);if(y.length===0)throw new ri(`No patterns available for language: ${t}`,t,d,[G(`No patterns registered for language '${t}'`,"error","no-patterns")]);let h=[...y].sort((w,C)=>C.priority-w.priority);{let w=f.tokens;if(T(t)?.wordOrder==="VSO"&&w.length>=4&&w[0]?.normalized==="source"){let C=w.findIndex(D=>D.normalized==="on");if(C>=2&&C+1<w.length){let D=d.slice(w[0].position.start,w[C].position.start).trim(),O=w[C+1].position.end,M=d.slice(w[C].position.start,O)+" "+D+d.slice(O);if(M!==d)try{let P=this.parse(M,t);if(P&&P.kind==="event-handler"){let F=o?this.applyModifiers(P,o):P;return V(F,m)}}catch{}}}}{let w=f.tokens,C=w[0]?.normalized==="if";for(let D=0;C&&D+3<w.length;D++){let O=(w[D+3]?.normalized??w[D+3]?.value??"").toLowerCase();if(w[D]?.normalized==="source"&&w[D+2]?.normalized==="on"&&S.KNOWN_EVENTS.has(O)){let M=(d.slice(0,w[D].position.start).trimEnd()+" "+d.slice(w[D+1].position.end).trimStart()).trim();if(M&&M!==d)try{let P=this.parse(M,t);if(P&&P.kind==="event-handler"){let F=o?this.applyModifiers(P,o):P;return V(F,m)}}catch{}break}}}{let w=this.tryDoNotThrow(f.tokens,d,t);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return V(C,m)}}{let w=this.tryTellTo(f.tokens,d,t);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return V(C,m)}}{let w=this.tryScrollModifiers(f.tokens,d,t);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return V(C,m)}}{let w=this.tryLoopIndex(f.tokens,d,t);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return V(C,m)}}{let w=this.tryWaitAlternatives(f.tokens,d,t);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return V(C,m)}}{let w=f.tokens,C=ti(t);for(let D=0;D+1<w.length;D++){let O=w[D];if(this.isBodyCommandWord(O,C))break;if(w[D+1].value!=="(")continue;let M=(O.normalized??O.value).toLowerCase();if(!(S.KNOWN_EVENTS.has(M)||Oe.has(M))&&O.kind!=="identifier")continue;let F=this.matchEventParamPhrase(w,D+1);if(F.len===0)continue;let _=w[D+F.len],K=(d.slice(0,w[D+1].position.start).trimEnd()+" "+d.slice(_.position.end).trimStart()).trim();try{let N=this.parse(K,t);if(N?.kind==="event-handler"){let I=this.reclaimEventCompoundTail(Gt(N),K,t);I&&(N=I.node);}let j=N?.roles.get("event"),he=(j?.type==="expression"?j.raw:j&&"value"in j?String(j.value):void 0)?.toLowerCase(),H=d.slice(0,w[D+1].position.start).trimEnd().toLowerCase(),L=he===O.value.toLowerCase()||he===M||he!==void 0&&Ds(he,t).some(I=>H.endsWith(I.toLowerCase()));if(N?.kind==="event-handler"&&L){N.parameterNames=F.names;let I=o?this.applyModifiers(N,o):N;return V(I,m)}}catch{}}}{let w=f.tokens,C=ti(t);for(let D=1;D<w.length-1;D++){let O=w[D];if(this.isBodyCommandWord(O,C))break;if(!Yt(O,t))continue;let M=w[D+1],P=(M.normalized??M.value).toLowerCase();if(!S.KNOWN_EVENTS.has(P))break;let F=D+1,_=w[D+2];_&&_.kind==="selector"&&_.value.startsWith("[")&&(F=D+2);let K=w[D].position.start,N=w[F].position.end,j=(d.slice(0,K).trimEnd()+" "+d.slice(N).trimStart()).trim();if(j&&j!==d)try{let ie=this.parse(j,t);if(ie&&ie.kind==="event-handler"){ie.additionalEvents=[{type:"literal",value:F>D+1?P+_.value:P}];let he=o?this.applyModifiers(ie,o):ie;return V(he,m)}}catch{}break}}{let w=Hf(f.tokens);if(w){let C=(d.slice(0,w.start).trimEnd()+" "+d.slice(w.end).trimStart()).trim();if(C&&C!==d)try{let D=this.parse(C,t);if(D&&D.kind==="event-handler"){let O=this.applyModifiers(D,{...o??{},...w.modifiers});return V(O,m)}}catch{}}}let v=h.filter(w=>w.command==="on"),E=f.mark(),k=xe.matchBest(f,v);if(k){m.push(G(`event pattern matched: ${k.pattern.id} (confidence: ${k.confidence.toFixed(2)})`,"info","pattern-match"));let w=false;if(/^event-[a-z]+-bare$/.test(k.pattern.id)){let C=k.captured.get("event"),D=(C?.raw??C?.value??"").toString().toLowerCase(),O=Re[t],M=S.KNOWN_EVENTS.has(D)||!!O&&Object.keys(O).some(P=>P.toLowerCase()===D);if(D&&!M){let P=this.trySOVEventExtraction(d,t,h);if(P){m.push(G(`bare-event mis-anchor on "${D}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let F=o?this.applyModifiers(P,o):P;return V(F,m)}if(C?.type==="reference"||C?.type==="expression"){f.reset(E);let F=h.filter(K=>K.command!=="on"),_=xe.matchBest(f,F);f.reset(E),_&&_.pattern.command!=="on"?(w=true,m.push(G(`bare-event mis-anchor on reference "${D}" rejected; command ${_.pattern.command} preferred`,"info","stage-bare-event-guard"))):xe.matchBest(f,v);}}}if(!w){let C=this.buildEventHandler(k,f,t),D=o?this.applyModifiers(C,o):C;return V(D,m)}}m.push(G(`event patterns: ${v.length} tried, no match`,"info","stage-event"));let z=this.tryTrailingEventExtraction(d,t,h);if(z){m.push(G("trailing event extraction succeeded","info","stage-trailing-event"));let w=o?this.applyModifiers(z,o):z;return V(w,m)}let g=h.filter(w=>w.command!=="on"),A=this.tryParseUnlessGuard(f,g,t);if(A&&A.length>0){let w=A.length===1?A[0]:nt(A,"then",{sourceLanguage:t,confidence:1});return V(w,m)}let b=xe.matchBest(f,g);if(b){if(Ge.has(b.pattern.command)){let C=this.trySOVEventExtraction(d,t,h);if(C){m.push(G(`SOV event extraction preferred over bare ${b.pattern.command} command`,"info","stage-sov-loop"));let O=o?this.applyModifiers(C,o):C;return V(O,m)}let D=this.tryMidStreamEventExtraction(d,t,h);if(D){m.push(G(`mid-stream event extraction preferred over bare ${b.pattern.command} command`,"info","stage-midstream-loop"));let O=o?this.applyModifiers(D,o):D;return V(O,m)}}else if(S.KNOWN_EVENTS.has(b.pattern.command)&&this.hasSOVEventMarkerHead(d,t)){let C=this.trySOVEventExtraction(d,t,h);if(C){m.push(G(`SOV event extraction preferred over command-homonym event ${b.pattern.command}`,"info","stage-sov-homonym"));let D=o?this.applyModifiers(C,o):C;return V(D,m)}}else if(T(t)?.wordOrder==="VSO"){let C=this.tryMidStreamEventExtraction(d,t,h);if(C){m.push(G(`mid-stream event extraction preferred over bare ${b.pattern.command} command`,"info","stage-midstream-cmd"));let D=o?this.applyModifiers(C,o):C;return V(D,m)}}if(b.consumedTokens<f.tokens.length&&T(t)?.wordOrder==="SOV"){let C=this.trySOVEventExtraction(d,t,h);if(C){m.push(G(`SOV event extraction preferred over partial ${b.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let D=o?this.applyModifiers(C,o):C;return V(D,m)}}if(b.consumedTokens<f.tokens.length&&En.has(b.pattern.command)){let C=this.tryTopLevelLoop(f,g,t);if(C)return m.push(G(`top-level loop: ${C.kind}`,"info","stage-top-level-loop")),V(C,m)}if(b.consumedTokens<f.tokens.length&&!Ge.has(b.pattern.command)){let C=this.tryTopLevelCommandSequence(f,g,t);if(C)return m.push(G(`top-level command sequence: ${C.statements.length} commands`,"info","stage-top-level-sequence")),V(C,m)}if(b.consumedTokens<f.tokens.length&&(b.pattern.command==="if"||b.pattern.command==="unless")){let C=this.tryCompoundCommandParsing(f,g,t);if(C)return m.push(G("conditional with a trailing body","info","stage-compound")),V(C,m)}m.push(G(`command pattern matched: ${b.pattern.id} (confidence: ${b.confidence.toFixed(2)})`,"info","pattern-match"));let w=ky(b,f,d);return w&&m.push(G(w,"warning","unconsumed-input")),V(this.buildCommand(b,t),m)}if(m.push(G(`command patterns: ${g.length} tried, no match`,"info","stage-command")),!d.includes(`
|
|
5
|
+
`)&&T(t)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(d,t,h);if(w){m.push(G("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let C=o?this.applyModifiers(w,o):w;return V(C,m)}}let x=this.trySOVEventExtraction(d,t,h);if(x){m.push(G("SOV event extraction succeeded","info","stage-sov"));let w=o?this.applyModifiers(x,o):x;return V(w,m)}m.push(G("SOV event extraction: no event keyword found","info","stage-sov"));let B=this.tryCompoundCommandParsing(f,g,t);if(B)return m.push(G("compound command parsing succeeded","info","stage-compound")),V(B,m);if(m.push(G("compound parsing: no then-keywords or no command matches","info","stage-compound")),t==="en"){let w=Z(d,t),C=this.tryParsePseudoCommand(w,g,t);if(C&&w.isAtEnd())return m.push(G("pseudo-command parsed as call","info","stage-pseudo")),V(C,m)}throw m.push(G(`all parse stages exhausted for "${d}"`,"error","parse-failed")),new ri(`Could not parse input in ${t}: ${d}`,t,d,m)}tryParsePseudoCommand(e,t,a){if(a!=="en")return null;let i=$f(e.tokens,e.position(),T(a),u=>!!ue((u.normalized??u.value).toLowerCase()));if(!i)return null;let n=Z(i.text,a),o=xe.matchBest(n,t.filter(u=>u.command==="call"));if(!o||!n.isAtEnd())return null;for(let u=0;u<i.consumed;u++)e.advance();return this.buildCommand(o,a)}parseStatements(e,t){let a=Z(e,t),i=fe(t).filter(n=>n.command!=="on").sort((n,o)=>o.priority-n.priority);this.coverageFrames.push([]);try{let n=this.parseBodyWithClauses(a,i,t),o=this.coverageFrames[this.coverageFrames.length-1];if(o.length>0&&n.length>0){let u=n[n.length-1];n[n.length-1]=V(u,[...u.diagnostics??[],...o]);}return n}finally{this.coverageFrames.pop();}}canParse(e,t){try{return this.parse(e,t),!0}catch{return false}}supportedLanguages(){return cn()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let a={};for(let[n,o]of e.captured)a[n]=o;let i=me(e.pattern.command,a,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(i),i}buildEventHandler(e,t,a){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 k=i.type==="expression"?i.raw:i.type==="literal"?i.value:void 0;if(typeof k=="string"&&/^[^\s()[\]{}:]+$/.test(k)){let z=Re[a]?.[k];z?i={type:"literal",value:z,dataType:"string"}:i.type==="expression"&&S.KNOWN_EVENTS.has(k.toLowerCase())&&(i={type:"literal",value:k.toLowerCase(),dataType:"string"});}}let n=xe.extractEventModifiers(t),o=k=>!(k.type==="reference"&&k.value==="me")&&k.implicit!==true,u=e.captured.get("source"),s=e.pattern.command==="on"&&/^(on|event)-/.test(e.pattern.id),l=false;u&&(e.pattern.id.endsWith("source")||s)&&o(u)&&(n={...n??{},from:u},l=true);let c;if(e.eventSource&&!l){let k=e.captured.get("action"),z=k?.type==="literal"?ue(String(k.value)):void 0;T(a)?.roleMarkers?.source?.position==="after"&&z?.roles.some(A=>A.role==="source")&&!e.captured.has("source")?c=e.eventSource:o(e.eventSource)&&(n={...n??{},from:e.eventSource});}let p=e.captured.get("event")?.position,d=t.tokens[t.position()-1],f=p!==void 0&&d!==void 0&&d.position.end>p.end?[]:this.extractOrConjunctionEvents(t,a),y=i;f.length>0&&i.type==="literal"&&(y={type:"literal",value:[String(i.value),...f.map(z=>String("value"in z?z.value:""))].join(" or ")});let h,v=e.captured.get("action");if(v&&v.type==="literal"&&v.value==="if"){let k=t.tokens,z=-1;for(let g=t.position()-1;g>=0;g--){let A=k[g],b=(A.normalized??A.value).toLowerCase();if(this.isIfKeyword(b,a)){z=g;break}}for(;z>0;){let g=k[z-1];if(!this.isIfKeyword((g.normalized??g.value).toLowerCase(),a))break;z--;}if(z>=0){let g=fe(a).filter(C=>C.command!=="on").sort((C,D)=>D.priority-C.priority),A=k.slice(z);if(e.pattern.id.endsWith("vso-verb-first")&&y.type==="literal"){let C=String(y.value??"").split("[")[0].trim().toLowerCase(),D=A.findIndex((O,M)=>{if(M===0||C==="")return false;let P=(O.normalized??O.value).toLowerCase(),F=A[M-1];return P===C&&F.kind==="keyword"&&(F.normalized??"").toLowerCase()==="on"});if(D>0){let O=A[D+1],M=O&&O.kind==="selector"&&O.value.startsWith("[")?1:0;A=[...A.slice(0,D-1),...A.slice(D+1+M)];}}let b=new se(A,a),x=this.coverageMark(),B=this.parseBodyWithClauses(b,g,a);if(B.some(C=>C.kind==="conditional")||B.length===1&&B[0]?.kind==="compound"&&B[0].statements.some(C=>C.kind==="conditional")){for(;!t.isAtEnd();)t.advance();return zt(y,B,n,{sourceLanguage:a,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(x);}}if(v&&v.type==="literal"&&String(v.value)!=="js"&&ue(String(v.value))!==void 0){let k=v.value,z={};for(let[F,_]of e.captured)if(F!=="event"&&F!=="action"&&F!=="continues"){if(F==="source"&&l)continue;z[F]=_;}if(c&&(z.source=c),k==="repeat"){let F=t.peek(),_=N=>(N.normalized??N.value).toLowerCase();if(F&&F.kind==="keyword"&&_(F)==="forever")z.loopType={type:"literal",value:"forever"},delete z.patient,t.advance();else if(F&&F.kind==="keyword"&&_(F)==="event"){t.advance();let N=t.peek();if(N)for(z.event={type:"literal",value:_(N)},z.loopType={type:"literal",value:"until-event"},delete z.patient;!t.isAtEnd();){let j=t.peek();if(!j||j.kind==="conjunction"||j.kind==="keyword"&&(this.isThenKeyword(j.value,a)||this.isEndKeyword(j.value,a)))break;t.advance();}}let K=z.patient;K&&K.type==="reference"&&K.value==="me"&&delete z.patient;}let g=me(k,z,{sourceLanguage:a,patternId:e.pattern.id,confidence:e.confidence});this.registerBoundIdentifiers(g);let A=[];if(!Ge.has(k)||k==="repeat"||k==="while"){let F=e.pattern.id.includes("verb-first"),_=t.tokens,K=t.position(),N=L=>{let I=_[L];if(I.kind==="conjunction")return true;if(I.kind!=="keyword")return false;let X=ke(_,L);return this.isThenAt(I,X,a)||this.isEndKeyword(I.value,a)&&!$e(X,a)},j=k==="repeat"||k==="while",ie=L=>N(L)||j&&this.isBlockEndToken(_[L],ke(_,L),a),he=new Set;{let L=T(a)?.keywords?.[k];L?.primary&&he.add(L.primary.toLowerCase());for(let I of L?.alternatives??[])he.add(I.toLowerCase());}let H=-1;for(let L=K-1;L>=0;L--){let I=_[L];if(N(L))break;if((I.normalized??I.value).toLowerCase()===k||he.has(I.value.toLowerCase())){H=L;break}}if(H>=0){let L=K,I=0;for(;L<_.length;){let ne=_[L],Ce=Ht(_,L);if(j&&this.isIfKeyword((ne.normalized??ne.value).toLowerCase(),a)&&!(Ce&&this.isElseKeyword(Ce.value,a)))I++;else if(I>0)this.isBlockEndToken(ne,ke(_,L),a)&&I--;else if(ie(L))break;L++;}let X=_.slice(H,L),be=X;if(F){let ne=String(i.value??"").toLowerCase(),Ce=X.findIndex(pe=>(pe.normalized??pe.value).toLowerCase()===ne);if(Ce<0)be=null;else {let pe=X[Ce-1],de=pe&&pe.kind==="keyword"&&pe.normalized?.toLowerCase()==="on"?Ce-1:Ce;be=[...X.slice(0,de),...X.slice(Ce+1)];}}if(be&&be.length>1){let ne=fe(a).filter(q=>q.command!=="on").sort((q,J)=>J.priority-q.priority),Ce=this.coverageMark(),pe=this.parseClause(be,ne,a),de=pe[0],et=q=>q!==null&&typeof q=="object"&&typeof q.type=="string"?q.type:typeof q,tt=ue(k),cr=tt?.primaryRole,sa=q=>q==="patient"&&cr&&cr!=="patient"&&!tt?.roles.some(J=>J.role==="patient")?cr:q,Wn=(q,J)=>{if(!Ge.has(k)||!tt)return false;let qe=tt.roles.find(Et=>Et.role===sa(q));return qe?qe.expectedTypes.length>0&&!qe.expectedTypes.includes(et(J)):true},pr=(q,J)=>q==="patient"&&!!tt&&!tt.roles.some(qe=>qe.role==="patient")&&et(J)==="literal"&&Pt.has(String(J.value??"").toLowerCase()),dr=q=>q!==null&&typeof q=="object"&&q.implicit===true,qn=!!de&&de.kind==="command"&&Object.entries(z).every(([q,J])=>{if(dr(J)||Wn(q,J)||pr(q,J))return true;let qe=de.roles.get(sa(q));if(qe!==void 0&&et(qe)===et(J))return true;if(q==="patient"&&k==="pick"&&et(J)==="literal"){let Et=de.roles.get("method"),ca=et(Et),pa=ca==="literal"?String(Et.value):ca==="expression"?String(Et.raw):void 0;return pa!==void 0&&pa===String(J.value)}return false}),la=de?.metadata?.patternId??"",Vn=!Ge.has(k)||ai.test(la),Kn=ai.test(la);if((pe.length===1||Kn&&pe.length>1)&&de&&de.kind==="command"&&(de.action===k||k==="while"&&de.action==="repeat"&&/-while-head$/.test(de.metadata?.patternId??""))&&qn&&Vn&&(de.roles.size>Object.entries(z).filter(([q,J])=>!pr(q,J)).length||[...de.roles.values()].filter(q=>!dr(q)).length>Object.entries(z).filter(([q,J])=>!pr(q,J)&&!dr(J)).length))for(g=de,A=pe.slice(1);t.position()<L;)t.advance();else this.coverageRollback(Ce);}}}if(!Ge.has(k)){let F=g;if(ue(k)?.roles.some(H=>H.role==="quantity"&&!H.required)&&!F.roles.has("quantity")){let H=t.peek();H&&/^-?\d+(\.\d+)?$/.test(H.value)&&(g=me(k,{...Object.fromEntries(F.roles),quantity:{type:"literal",value:parseFloat(H.value),dataType:"number"}},F.metadata),t.advance());}let K=g;if(ue(k)?.roles.some(H=>H.role==="duration"&&!H.required)&&!K.roles.has("duration")){let H=/^\d+(\.\d+)?(ms|s)$/i,L=t.peek(),I=false;if(L&&L.kind==="particle"){let X=t.peek(1);X&&H.test(X.value)&&(I=true,L=X);}L&&H.test(L.value)&&(g=me(k,{...Object.fromEntries(K.roles),duration:{type:"literal",value:L.value,dataType:"string"}},K.metadata),I&&t.advance(),t.advance(),this.consumeForPostposition(t,a));}let j=g,ie=ue(k);if(ie?.roles.find(H=>H.role==="responseType"&&!H.required)&&!j.roles.has("responseType")){let H=ne=>typeof ne=="string"&&S.RESPONSE_TYPE_WORDS.has(ne.toLowerCase()),L=(ne,Ce)=>{let pe=Object.fromEntries(j.roles);Ce&&delete pe.destination,pe.responseType={type:"expression",raw:ne},g=me(k,pe,j.metadata);},I=j.roles.get("destination"),X=ie?.roles.find(ne=>ne.role==="destination"),be=I?.raw??I?.value;if(I&&X&&!X.expectedTypes.includes(I.type)&&H(be))L(be,true);else {let ne=t.peek();ne&&H(ne.value)&&(L(ne.value,false),t.advance());}}if(k==="wait"){let H=g;if(!H.roles.has("event")){let L=t.peek();if(L&&Oe.has(L.value.toLowerCase())){let I=Object.fromEntries(H.roles),X=I.duration;X&&X.type!=="literal"&&X.type!=="expression"&&delete I.duration;let be=I.patient;be&&be.type==="reference"&&be.value==="me"&&delete I.patient,I.event={type:"literal",value:L.value,dataType:"string"},g=me(k,I,H.metadata),t.advance(),this.consumeForPostposition(t,a);}}}this.tryAttachTrailingRole(t,g,a),this.tryAttachTrailingStyle(t,g,a),this.tryAttachTrailingExpressionRole(t,g,a),this.tryAttachNewWindow(t,g);}let b=e.captured.get("continues"),x=b?.type==="literal"&&b.value==="then",B=t.peek(),w=!!B&&this.isThenKeyword(B.value,a),D=Ge.has(k)&&!!B&&!this.isEndKeyword(B.value,a),O=!!B&&!this.isEndKeyword(B.value,a),M=[g,...A],P=!!B&&this.isEndKeyword(B.value,a)&&Ut(M)>0&&t.peek(1)!==null;if(P&&(t.advance(),M.push(ot)),x||w||D||O||P){let F=fe(a).filter(N=>N.command!=="on").sort((N,j)=>j.priority-N.priority),_=fe(a).filter(N=>N.id.startsWith("grammar-")&&N.id.includes("-continuation")).sort((N,j)=>j.priority-N.priority),K=this.parseBodyWithGrammarPatterns(t,F,_,a,M);h=this.foldLoopBlocks([...M,...K]);}else h=this.foldLoopBlocks(M),t.isAtEnd()||this.recordDroppedTokens(t.tokens.slice(t.position()),a,"handler body tail");}else {let k=fe(a).filter(g=>g.command!=="on").sort((g,A)=>A.priority-g.priority),z=v?e.roleStarts?.get("action"):void 0;if(z!==void 0&&z<t.position()){let g=new se(t.tokens.slice(z),a);for(h=this.parseBodyWithClauses(g,k,a);!t.isAtEnd();)t.advance();}else h=this.parseBodyWithClauses(t,k,a);}let E=h.length>1?[nt(h,"then",{sourceLanguage:a})]:h;return zt(y,E,n,{sourceLanguage:a,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,a){let i=[],n=[],o=0,u=[],s=(c=0)=>{let p=Ut(i);o=p+c,u.length=0;for(let d=0;d<p;d++)u.push("loop");for(let d=0;d<c;d++)u.push("while");};for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(n.length===0){let k=this.consumeJsBlock(e,a)??this.consumeVerbFinalJsBlock(e,a);if(k){i.push(k);continue}let z=this.tryParseConditionalBlock(e,t,a);if(z){i.push(z);continue}let g=this.tryParseUnlessGuard(e,t,a);if(g){i.push(...g);continue}}let p=c.kind==="conjunction"||c.kind==="keyword"&&this.isThenAt(c,ke(e.tokens,e.position()),a),d=n[n.length-1],m=e.peek(1),f=d?.value.toLowerCase()==="at"&&m?.value.toLowerCase()==="of"||yr(a,c.value,d?.value,m?.value),y=c.kind==="keyword"&&this.isEndKeyword(c.value,a)&&!f&&!$e(ke(e.tokens,e.position()),a);if((y||!f&&this.isBlockEndToken(c,ke(e.tokens,e.position()),a))&&u.every(k=>k==="loop")&&this.closeLoopAtEnd(e,n,i,t,a)){n.length=0,s();continue}if(y&&o>0){o--,u.pop(),n.push({...c,metadata:{...c.metadata,closesTrackedBlock:true}}),e.advance();continue}if(p&&u.includes("if")){n.push(c),e.advance();continue}if(p){if(n.length>0){let k=this.parseClause(n,t,a);i.push(...k),n.length=0,s(k.filter(z=>{let g=z;return g.action==="while"&&(!Array.isArray(g.body)||g.body.length===0)}).length);}e.advance();continue}if(y){e.advance();let k=[];for(;!e.isAtEnd();){let z=e.peek();if(!z||z.kind==="conjunction"||z.kind==="keyword"&&(this.isThenKeyword(z.value,a)||this.isEndKeyword(z.value,a)))break;k.push(z),e.advance();}if(k.length>0){let z=this.coverageMark(),g=n.length>0?this.parseClause(n,t,a):[];g.length===0&&n.length>0?(this.coverageRollback(z),i.push(...this.parseClause([...n,...k],t,a))):(i.push(...g),i.push(...this.parseClause(k,t,a)));}else if(n.length>0){let z=this.parseClause(n,t,a);i.push(...z);}n.length=0;break}let v=(c.normalized??c.value).toLowerCase(),E=kr(c);if(c.kind==="keyword"||E){let k=this.isIfKeyword(v,a),z=Ht(n,n.length);(v==="for"||v==="while")&&z&&kr(z)||k&&z&&this.isElseKeyword(z.value,a)||(E&&u[u.length-1]==="while"?u[u.length-1]="loop":(k||this.isUnlessKeyword(v,a)||v==="while"||v==="for"||E)&&(o++,u.push(k?"if":E||v==="for"?"loop":v==="while"?"while":"other")));}n.push(c),e.advance();}if(n.length>0){let c=this.parseClause(n,t,a);i.push(...c);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),a,"body stream tail"),this.foldFrontedWhileIntoRepeat(i,a);for(let c=i.length-1;c>=0;c--){let p=i[c];p.kind==="command"&&p.action==="for"&&(!(p.roles instanceof Map)||p.roles.size===0)&&(!Array.isArray(p.body)||p.body.length===0)&&i.splice(c,1);}let l=this.foldLoopBlocks(i);return l.length>1?[nt(l,"then",{sourceLanguage:a})]:l}closeLoopAtEnd(e,t,a,i,n){let o=Ut(a);if(t.length===0)return o===0?false:(a.push(ot),e.advance(),true);let u=this.coverageMark(),s=this.parseClause([...t],i,n);return s.length===0||o+s.filter(Fr).length===0?(this.coverageRollback(u),false):(a.push(...s,ot),e.advance(),true)}foldLoopBlocks(e){let t=[],a=[],i=o=>{(a.length>0?a[a.length-1].body:t).push(o);},n=o=>{let u=a.pop();u&&i(this.buildLoopNode(u.head,u.body,o));};for(let o of e)Jr(o)?n(true):Fr(o)?a.push({head:o,body:[]}):i(o);for(;a.length>0;)n(false);return t}buildLoopNode(e,t,a=false){if(t.length===0&&!a)return e;let i=e.roles.get("loopType");if(i?.type==="literal"&&typeof i.value=="number"){let p=new Map(e.roles);return p.set("quantity",i),p.set("loopType",{type:"literal",value:"times"}),this.buildLoopNode({...e,roles:p},t,a)}let n=i?.type==="literal"?String(i.value):void 0,o=e.action==="for"||n==="for"?"for":n==="times"||n==="while"||n==="forever"?n:n==="until"||n==="until-event"?"until":e.roles.has("quantity")?"times":"forever",u=o==="for"?e.roles.get("patient"):void 0,s=u?fy(u):void 0,l=new Map(e.roles),c=l.get("quantity");return (o==="while"||o==="until")&&c&&!l.has("condition")&&(l.set("condition",c),l.delete("quantity")),tp(e.action==="for"?"for":"repeat",o,Object.fromEntries(l),t,{...s?{loopVariable:s}:{},...e.metadata?{metadata:e.metadata}:{}})}tryTopLevelLoop(e,t,a){let i=this.coverageMark(),n;try{let u=new se(e.tokens,a);n=this.parseBodyWithClauses(u,t,a);}catch{return this.coverageRollback(i),null}let[o]=n;if(n.length===1&&o.kind==="loop")return o;if(n.length===1&&o.kind==="compound"){let u=o;if(u.statements[0]?.kind==="loop"){let s=u.statements.map(l=>l.metadata?.confidence??.75);return nt(u.statements,u.chainType,{sourceLanguage:a,confidence:s.reduce((l,c)=>l+c,0)/s.length})}}return this.coverageRollback(i),null}tryTopLevelCommandSequence(e,t,a){let i=this.coverageMark(),n;try{let l=new se(e.tokens,a);n=this.parseBodyWithClauses(l,t,a);}catch{return this.coverageRollback(i),null}if(n.length!==1||n[0].kind!=="compound")return this.coverageRollback(i),null;let o=n[0];if(o.statements.length<2)return this.coverageRollback(i),null;let u=o.statements.map(l=>l.metadata?.confidence??.75),s=u.reduce((l,c)=>l+c,0)/u.length;return nt(o.statements,o.chainType,{sourceLanguage:a,confidence:s})}foldFrontedWhileIntoRepeat(e,t){for(let a=0;a+1<e.length;a++){let i=e[a],n=e[a+1];if(i.kind!=="command"||i.action!=="while"||n.kind!=="command"||n.action!=="repeat")continue;let o=i.roles.get("condition");if(!o||n.roles.has("condition")||Array.isArray(i.body)||Array.isArray(n.body))continue;let u=new Map(n.roles);u.set("condition",o),u.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(a,2,{...n,roles:u,metadata:{...n.metadata,sourceLanguage:t,patternId:`repeat-${t}-fronted-while-fold`,confidence:Math.max(n.metadata?.confidence??0,i.metadata?.confidence??0)}});}}takeRepeatCount(e,t,a){if(T(a)?.wordOrder==="SOV"){let o=S.countBeforeVerb(t,a);if(o<0)return;let u=t[o];return t.length=o,u}let i=e.mark();e.peek()?.kind==="particle"&&e.advance();let n=e.peek();if(n&&S.countsBefore(n,e.peek(1),a))return e.advance(),e.advance(),n;if(!S.isCountToken(n)){e.reset(i);return}return e.advance(),e.peek()?.kind==="identifier"&&e.advance(),n}static isCountToken(e){let t=e?.kind==="literal"?Zt(e):null;return t?.type==="literal"&&typeof t.value=="number"}static countsBefore(e,t,a){return !e||!t||!jr[a]?.includes(t.value)?false:e.kind==="identifier"||S.isCountToken(e)}static countBeforeVerb(e,t){let a=S.isCountToken,i=e.length;return e[i-1]?.kind==="particle"&&i--,S.countsBefore(e[i-2],e[i-1],t)?i-2:(e[i-1]?.kind==="identifier"&&a(e[i-2])&&i--,a(e[i-1])?i-1:-1)}loopHeadReadsBody(e,t,a){if(T(a)?.wordOrder!=="SOV")return false;if(S.countBeforeVerb(t,a)>=0)return true;let i=e.captured.get("loopType");return i?.type==="literal"&&typeof i.value!="number"&&!wy.has(String(i.value))}bareRepeatHead(e,t){let a=e?Zt(e):null;return me("repeat",e&&a?{loopType:Y("times"),quantity:Ai(a,{start:e.position.start,end:e.position.end})}:{},{sourceLanguage:t,confidence:.6})}parseClause(e,t,a){if(e.length===0)return [];let i=null,n=e,o=e[e.length-1];if(o&&e.length>=2){let v=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(v,a)&&(i="unless",n=e.slice(0,-1));}let u=null;if(i&&n.length>=3){let v=T(a),E=v?S.buildVerbLookup(v):null;if(E)for(let k=1;k<n.length-1;k++){let z=n[k],g=E.get(z.value.toLowerCase())??(z.normalized?E.get(z.normalized.toLowerCase()):void 0);if(g&&!S.CONDITION_OPERATORS.has(g)){u=n.slice(0,k),n=n.slice(k);break}}}let s=new se(n,a),l=[],c=this.coverageMark(),p=0,d=[],m=u,f=()=>{if(d.length===0)return;let v=d.slice();if(d.length=0,i&&l.length===0&&m===null){m=v;return}let E=v[0];if(!(E&&(E.kind==="identifier"||E.kind==="selector"||E.kind==="literal"||E.kind==="reference"))){this.recordDroppedTokens(v,a,"body clause");return}let z=false;for(let g of this.parseSOVClauseByVerbAnchoring(v,a)){let A=g.action,b=g.roles;A&&ue(A)&&b instanceof Map&&b.size>0&&(l.push(g),z=true);}z||this.recordDroppedTokens(v,a,"body clause");};for(;!s.isAtEnd();){let v=s.peek(),E=!!v&&v.normalized?.toLowerCase()==="repeat",k=s.mark(),z=xe.matchBest(s,t);if(E&&z&&(z.pattern.command!=="repeat"||this.loopHeadReadsBody(z,d,a))){s.reset(k),s.advance();let g=this.takeRepeatCount(s,d,a);f(),l.push(this.bareRepeatHead(g,a)),p++;continue}if(!z&&v&&this.isIfKeyword((v.normalized??v.value).toLowerCase(),a)){let g=this.tryParseConditionalBlock(s,t,a);if(g){f(),l.push(g),p++;continue}}if(z&&z.pattern.command==="if"){let g=s.mark(),A=d.length;for(s.reset(k);!s.isAtEnd();){let x=s.peek();if(!x||this.isIfKeyword((x.normalized??x.value).toLowerCase(),a))break;d.push(x),s.advance();}let b=this.tryParseConditionalBlock(s,t,a);if(b){f(),l.push(b),p++;continue}d.length=A,s.reset(g);}if(z){f();let g=this.buildCommand(z,a);l.push(g),p++,this.tryAttachTrailingRole(s,g,a),this.tryAttachTrailingStyle(s,g,a),this.tryAttachTrailingExpressionRole(s,g,a),this.tryAttachTrailingDuration(s,g);}else {let g=d.length===0?this.tryParsePseudoCommand(s,t,a):null;if(g){f(),l.push(g),p++;continue}let A=s.peek(),b=A?.kind==="identifier"&&A.value.toLowerCase()==="repeat";if(A&&(A.normalized?.toLowerCase()==="repeat"||b)){let x=s.mark();s.advance();let B=this.takeRepeatCount(s,d,a);if(B||!b){f(),l.push(this.bareRepeatHead(B,a)),p++;continue}s.reset(x);}A&&d.push(A),s.advance();}}f();let y=l;if(p===0){let v=this.parseSOVClauseByVerbAnchoring(n,a);v.length>0&&(this.coverageRollback(c),y=v);}let h=m;return i&&y.length>0&&h&&h.length>0?[me(i,{condition:{type:"expression",raw:this.joinTokenText(h,a)}},{sourceLanguage:a,patternId:`${i}-${a}-trailing-guard`,confidence:.85}),...y]:i&&h&&h.length>0&&y.length===0?[me(i,{condition:{type:"expression",raw:this.joinTokenText(h,a)}},{sourceLanguage:a,patternId:`${i}-${a}-trailing-guard`,confidence:.85})]:y}tryAttachTrailingDuration(e,t){let a=t.roles;if(a.has("duration")||!ue(t.action)?.roles.some(o=>o.role==="duration"&&!o.required))return;let n=e.peek();!n||!/^\d+(?:\.\d+)?(?:ms|s|m|h)$/.test(n.value)||(a.set("duration",Y(n.value,"duration")),e.advance());}tryAttachNewWindow(e,t){let a=t.roles;if(t.action!=="go"||a.has("manner"))return;let[i,n,o]=[e.peek(),e.peek(1),e.peek(2)];if(!(i?.value.toLowerCase()!=="in"||n?.value.toLowerCase()!=="new")&&!(!o||(o.normalized??o.value).toLowerCase()!=="window")){a.set("manner",De("window"));for(let u=0;u<3;u++)e.advance();}}tryAttachTrailingRole(e,t,a){let i=ue(t.action);if(!i)return;let n=T(a);if(!n)return;let o=t.roles,u=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let p=(l.normalized??l.value).toLowerCase();return wr.has(p)?false:p==="body"||p==="it"||p==="you"||p==="result"||p==="document"||p==="window"||this.boundIdentifiers.has(l.value)?true:c?false:l.kind==="identifier"||l.kind==="reference"},s=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:c}of s){if(!i.roles.some(h=>h.role===l))continue;let p=n.roleMarkers?.[l];if(!p)continue;let d=o.get(l);if(d&&!(d.type==="reference"&&d.value==="me"))continue;let m=h=>{if(!h||h.kind!=="particle"&&h.kind!=="keyword")return false;let v=h.value.toLowerCase();return p.primary?.toLowerCase()===v?true:c?false:(h.normalized??"").toLowerCase()===l?true:!!p.alternatives?.some(E=>E.toLowerCase()===v)},f=e.peek(),y=e.peek(1);if(!f||!y)return;if(c&&p.position==="after"){let h=e.peek(2),v=(f.normalized??f.value).toLowerCase();if(yy.has(v)&&y.kind==="selector"&&m(h)){o.set(l,{type:"expression",raw:`${v} ${y.value}`}),e.advance(),e.advance(),e.advance();return}}if(p.position==="after"){if(u(f,c)&&m(y)){let h=this.tokenToSemanticValue(f);e.advance(),e.advance(),h&&o.set(l,h);return}if(c&&u(f,c)){let h=e.peek(2),v=e.peek(3);if((y.normalized??y.value).toLowerCase()==="in"&&h&&!m(h)&&m(v)){let E=this.tokenToSemanticValue(f);e.advance(),e.advance(),e.advance(),e.advance(),E&&o.set(l,E);return}}}else if(m(f)&&u(y,c)){e.advance();let h=this.tokenToSemanticValue(e.advance());h&&o.set(l,h);return}}}tryAttachTrailingStyle(e,t,a){if(t.action!=="fetch"&&t.action!=="render")return;let i=t.roles;if(!ue(t.action)?.roles.some(v=>v.role==="style"))return;let o=i.get("style");if(o){if(o.type==="expression"&&typeof o.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(o.raw)&&e.peek()?.value===":"){let v=Dt(e,o.raw);v&&i.set("style",{type:"expression",raw:v});}this.tryAttachResponseTypeAfterStyle(e,t,a);return}if(t.action==="fetch"){let v=i.get("patient"),E=i.get("source");if(v&&E&&(v.type==="literal"||v.type==="expression")&&E.type==="expression"&&typeof E.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(E.raw)&&e.peek()?.value===":"){let k=Dt(e,E.raw);k&&(i.set("source",{type:"expression",raw:k}),this.tryAttachResponseTypeAfterStyle(e,t,a));return}}let s=T(a)?.roleMarkers?.style;if(!s)return;if(s.position==="before"){let v=new Set([s.primary,...s.alternatives??[]].map(g=>g.toLowerCase())),E=e.peek();if(!E||!v.has(E.value.toLowerCase()))return;let k=e.mark();e.advance();let z=Dt(e);if(!z){e.reset(k);return}i.set("style",{type:"expression",raw:z}),this.tryAttachResponseTypeAfterStyle(e,t,a);return}if(s.position!=="after")return;let l=new Set([s.primary,...s.alternatives??[]].map(v=>v.toLowerCase())),c=v=>v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,a)||this.isEndKeyword(v.value,a)),p=24,d=-1,m=0;for(let v=0;v<p;v++){let E=e.peek(v);if(!E||c(E))break;if(E.value==="("||E.value==="{"?m++:(E.value===")"||E.value==="}")&&(m=Math.max(0,m-1)),m===0&&(E.kind==="particle"||E.kind==="keyword")&&l.has(E.value.toLowerCase())){d=v;break}}if(d<=0)return;let f=[];for(let v=0;v<d;v++){let E=e.peek(v);E&&f.push(E);}if(f.length===1&&S.RESPONSE_TYPE_WORDS.has(f[0].value.toLowerCase()))return;let y=new se(f,a),h=Dt(y);i.set("style",{type:"expression",raw:h&&y.isAtEnd()?h:this.joinTokenText(f,a)});for(let v=0;v<=d;v++)e.advance();this.tryAttachResponseTypeAfterStyle(e,t,a);}tryAttachResponseTypeAfterStyle(e,t,a){let i=t.roles;if(i.has("responseType")||!ue(t.action)?.roles.some(c=>c.role==="responseType"&&!c.required))return;let o=c=>!!c&&S.RESPONSE_TYPE_WORDS.has(c.toLowerCase()),u=e.peek();if(!u)return;let s=c=>{i.set("responseType",{type:"expression",raw:c});};if(S.AS_MARKERS_BEFORE[a]?.some(c=>u.value.toLowerCase()===c)){let c=e.peek(1);c&&o(c.value)&&(e.advance(),e.advance(),s(c.value));return}if(o(u.value)){e.advance(),s(u.value);for(let c of S.AS_MARKERS_AFTER[a]??[])if(c.every((p,d)=>e.peek(d)?.value.toLowerCase()===p)){for(let p=0;p<c.length;p++)e.advance();break}}}tryAttachTrailingExpressionRole(e,t,a){let i=t.action,n=i==="js"?{role:"patient",terminator:"boundary"}:i==="go"||i==="scroll"?{role:"destination",terminator:"destination-marker"}:null;if(!n)return;let o=t.roles,u=o.get(n.role);if(i==="go"&&u&&u.type==="expression"&&String(u.raw).toLowerCase()==="url"){let v=e.peek();if(v&&!wr.has((v.normalized??v.value).toLowerCase())){let k=this.tokenToSemanticValue(v);if(k.type==="literal"||k.type==="selector"){o.set(n.role,k),o.set("method",{type:"literal",value:"url"}),e.advance();return}}let E=o.get("patient");if(E&&(E.type==="literal"||E.type==="selector")){o.set(n.role,E),o.set("method",{type:"literal",value:"url"}),o.delete("patient");return}}if(i==="go"&&u&&u.type==="expression"){let v=/^url\s+(\S+)$/i.exec(String(u.raw??""));if(v){let E=v[1].replace(/^["']|["']$/g,"");o.set(n.role,{type:"literal",value:E,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(i==="go"&&!u){let v=o.get("patient");if(v&&v.type==="expression"&&String(v.raw).toLowerCase()==="url"){let E=e.peek();if(E&&!wr.has((E.normalized??E.value).toLowerCase())){let k=this.tokenToSemanticValue(E);if(k.type==="literal"||k.type==="selector"){o.set(n.role,k),o.set("method",{type:"literal",value:"url"}),o.delete("patient"),e.advance();return}}}}if(u&&!(u.type==="reference"&&u.value==="me"))return;let s=T(a);if(!s)return;let l=null;if(n.terminator==="destination-marker"){let v=s.roleMarkers?.destination;if(!v||v.position!=="after")return;l=v.primary.toLowerCase();}let c=v=>v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,a)||this.isEndKeyword(v.value,a)),p=24,d=[],m=0,f=false;for(let v=0;v<p;v++){let E=e.peek(v);if(!E||c(E))break;if(E.value==="("||E.value==="{"?m++:(E.value===")"||E.value==="}")&&(m=Math.max(0,m-1)),l!==null&&m===0&&(E.kind==="particle"||E.kind==="keyword")&&E.value.toLowerCase()===l){f=true;break}d.push(E);}if(d.length===0||l!==null&&!f)return;let y=d.length+(f?1:0);if(i==="go"&&d.length===2&&d[0].value.toLowerCase()==="url"){let v=this.tokenToSemanticValue(d[1]);if(v.type==="literal"||v.type==="selector"){o.set(n.role,v),o.set("method",{type:"literal",value:"url"});let E=o.get("patient");E&&E.type==="reference"&&E.value==="me"&&!ue(i)?.roles.some(k=>k.role==="patient")&&o.delete("patient");for(let k=0;k<y;k++)e.advance();return}}let h=d;if(i==="js"){let v=s.keywords?.js,E=z=>[v?.primary,...v?.alternatives??[]].some(g=>!!g&&g.length>z.value.length&&g.includes(z.value)),k=0;for(;k<h.length&&E(h[k]);)k++;if(h=h.slice(k),h.length===0)return}if(o.set(n.role,{type:"expression",raw:this.joinTokenText(h,a)}),n.role!=="patient"){let v=o.get("patient");v&&v.type==="reference"&&v.value==="me"&&!ue(i)?.roles.some(E=>E.role==="patient")&&o.delete("patient");}for(let v=0;v<y;v++)e.advance();}static buildVerbLookup(e){let t=new Map;for(let[a,i]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(a)&&(t.set(i.primary.toLowerCase(),a),i.alternatives))for(let n of i.alternatives)t.set(n.toLowerCase(),a);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[a,i]of Object.entries(e.roleMarkers)){if(!i)continue;if((a!=="event"||!t.has(i.primary))&&t.set(i.primary,a),i.alternatives)for(let o of i.alternatives)t.has(o)||t.set(o,a);}return t}parseSOVClauseByVerbAnchoring(e,t){let a=T(t);if(!a||a.wordOrder!=="SOV")return [];let i=S.buildVerbLookup(a),n=S.buildMarkerToRoleLookup(a),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let f=u;f<e.length;f++){let y=e[f];if(n.has(y.value))continue;let h=i.get(y.value.toLowerCase()),v=y.normalized?i.get(y.normalized.toLowerCase()):void 0,E=h||v;if(E){s=f,l=E;break}}if(s===-1)break;let c=e.slice(u,s),p=e.length;for(let f=s+1;f<e.length;f++){let y=e[f];if(y.kind==="conjunction"||this.isThenKeyword(y.value,t)){p=f;break}if(f>s+1&&!n.has(y.value)&&(i.get(y.value.toLowerCase())||(y.normalized?i.get(y.normalized.toLowerCase()):void 0))){p=f;break}}let d=e.slice(s+1,p),m=this.extractRolesFromMarkedTokens(c,d,n,l,t);if(o.push(me(l,m,{sourceLanguage:t,confidence:.7})),u=p,u<e.length){let f=e[u];(f.kind==="conjunction"||this.isThenKeyword(f.value,t))&&u++;}}return o}extractRolesFromMarkedTokens(e,t,a,i,n){let o={},u=(l,c)=>{let p=this.isEndKeyword(l.value,n),d=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !p&&!d?false:l.metadata?.closesTrackedBlock===true||p?true:!(c&&c.kind==="selector")},s=l=>{let c=[];for(let p=0;p<l.length;p++){let d=l[p];if(u(d,l[p+1]))continue;let m=a.get(d.value);if(m&&d.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c,n);if(f){let y=this.mapRoleForCommand(m,i,o);y&&(o[y]=f);}c=[];}else c.push(d);}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!o.duration&&ue(i)?.roles.some(d=>d.role==="duration"))o.duration={type:"literal",value:c[0].value,dataType:"string"};else {let d=this.tokensToSemanticValue(c,n);d&&(o.patient?o.destination||(o.destination=d):o.patient=d);}};return s(e),s(t),o}mapRoleForCommand(e,t,a){return t==="set"&&(e==="patient"?e="destination":e==="destination"&&(e="patient")),a[e]?e==="patient"&&!a.destination?"destination":e==="destination"&&!a.patient?"patient":e==="source"&&!a.source?"source":null:e}tokensToSemanticValue(e,t){if(e.length===0)return null;let a=e.filter(u=>u.kind!=="whitespace");if(a.length===0)return null;if(a.length>=2&&(a[0].kind==="selector"||/^[#.@*<]/.test(a[0].value))){let u=a.findIndex((s,l)=>l>0&&(s.normalized??s.value).toLowerCase()==="in");u>0&&(a=a.slice(0,u));}if(a.length===1)return this.tokenToSemanticValue(a[0]);let i=this.joinTokenText(a,t);if(an(i))return {type:"expression",raw:i};let n=a.map(u=>u.value).join(""),o=a[0];return o.kind==="selector"||o.value.startsWith("#")||o.value.startsWith(".")||o.value.startsWith("@")||o.value.startsWith("*")?Ne(n):o.kind==="literal"||o.value.startsWith('"')||o.value.startsWith("'")?Y(by(n),"string"):o.kind==="reference"?De(n):Y(i)}tokenToSemanticValue(e){return Zt(e)??Y(e.value)}parseBodyWithGrammarPatterns(e,t,a,i,n=[]){let o=[],u=()=>Ut([...n,...o]),s=[],l=false,c=()=>{if(!l&&s.length>0){let m=this.parseSOVClauseByVerbAnchoring(s,i);o.push(...m),m.length===0&&this.recordDroppedTokens(s,i,"fused body walk");}else s.length>0&&this.recordDroppedTokens(s,i,"fused body walk");s=[],l=false;},p=0,d=()=>o.filter(m=>{let f=m;return f.action==="while"&&(!Array.isArray(f.body)||f.body.length===0)}).length-p;for(;!e.isAtEnd();){let m=e.peek();if(m&&this.isThenKeyword(m.value,i)){c(),e.advance();continue}if(m&&u()>0&&!this.isEndKeyword(m.value,i)&&this.isBlockEndToken(m,ke(e.tokens,e.position()),i)&&!yr(i,m.value,e.peek(-1)?.value,e.peek(1)?.value)){c(),o.push(ot),e.advance();continue}if(m&&this.isEndKeyword(m.value,i)){let y=e.peek(-1),h=e.peek(1);if(!yr(i,m.value,y?.value,h?.value)){if(c(),u()>0){o.push(ot),e.advance();continue}if(d()>0){p++,e.advance();continue}e.advance();break}}if(m&&!l&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),i)){c();let y=this.tryParseConditionalBlock(e,t,i);if(y){o.push(y),l=true;continue}}let f=false;if(a.length>0){let y=xe.matchBest(e,a);if(y){let h=y.pattern.command,v={};for(let[z,g]of y.captured)z!=="event"&&z!=="action"&&z!=="continues"&&(v[z]=g);let E=me(h,v,{sourceLanguage:i,patternId:y.pattern.id});o.push(E),f=true,l=true;let k=y.captured.get("continues");if(k&&k.type==="literal"&&k.value==="then")continue}}if(!f){let y=e.mark(),h=xe.matchBest(e,t);if(h){if(h.pattern.command==="if"){let E=e.mark();for(e.reset(y);!e.isAtEnd();){let z=e.peek();if(!z||this.isIfKeyword((z.normalized??z.value).toLowerCase(),i))break;e.advance();}let k=this.tryParseConditionalBlock(e,t,i);if(k){c(),o.push(k),l=true;continue}e.reset(E);}let v=this.buildCommand(h,i);o.push(v),this.tryAttachTrailingRole(e,v,i),f=true,l=true;}}f||(m&&s.push(m),e.advance());}c(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),i,"fused body walk");for(let m=o.length-1;m>=0;m--){let f=o[m];f.kind==="command"&&f.action==="for"&&(!(f.roles instanceof Map)||f.roles.size===0)&&(!Array.isArray(f.body)||f.body.length===0)&&o.splice(m,1);}return o}tryCompoundCommandParsing(e,t,a){let i=e.tokens,n=i.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,a)),o=i.some(c=>this.isElseKeyword(c.value,a));if(!n&&!o)return null;let u=new se(i,a),s=this.coverageMark(),l=this.parseBodyWithClauses(u,t,a);return l.length===0?(this.coverageRollback(s),null):l[0]}static isEnEventKeyword(e){if(typeof e!="string")return false;let t=e.toLowerCase(),a=S.enEventKeywordCache.get(t);if(a!==void 0)return a;let i=false;try{let n=Z(t,"en").tokens;i=n.length===1&&n[0]?.kind==="keyword";}catch{i=false;}return S.enEventKeywordCache.set(t,i),i}matchEventMarkerPhrase(e,t,a){let i=S.SOV_EVENT_MARKER_PHRASES[a];if(!i)return 0;for(let n of i)if(n.every((o,u)=>e[t+u]?.value===o))return n.length;return 0}hasSOVEventMarkerHead(e,t){let a=S.SOV_EVENT_MARKERS[t];if(a===void 0)return false;let{tokens:i}=Z(e,t),n=Re[t],o=new Set;if(n)for(let u of Object.keys(n))o.add(u.toLowerCase());for(let u=0;u<i.length;u++){let s=i[u],l=s.value.toLowerCase(),c=s.normalized?.toLowerCase();if(!(!!c&&(S.KNOWN_EVENTS.has(c)||Oe.has(c))||S.KNOWN_EVENTS.has(l)||Oe.has(l)||o.has(l)))continue;let d=this.matchEventParamPhrase(i,u+1).len,m=i[u+1+d];if(m&&(m.kind==="particle"||m.kind==="keyword")&&a.has(m.value)||this.matchEventMarkerPhrase(i,u+1+d,t)>0)return true}return false}tryScrollModifiers(e,t,a){let i=m=>m?.value.toLowerCase()??"",n=-1,o=-1;for(let m=0;m<e.length&&n<0;m++){let f=i(e[m])==="the"?m+1:m;Qa.has(i(e[f]))&&(Qa.has(i(e[f+1]))&&f++,!(i(e[f+1])!=="of"||!e[f+2])&&(n=m,o=f+1));}let u=n<0?e.findIndex(m=>hy.has(i(m))):-1;if(n<0&&u<0)return null;let s=n>=0?n:u,l=n>=0?o:u,c=t.slice(0,e[s].position.start).trimEnd(),p=t.slice(e[l].position.end).trimStart(),d=c?c.length+1:0;try{let m=this.parse(c?`${c} ${p}`:p,a),f=[],y=E=>{if(!E)return;E.kind==="command"&&(E.action==="go"||E.action==="scroll")&&f.push(E);let k=E;for(let z of bt){let g=k[z];Array.isArray(g)&&g.forEach(A=>y(A));}};y(m??void 0);let h=E=>E.roles.get("destination")?.position?.start??-1,v=E=>f.filter(k=>h(k)>=0&&h(k)<=E).reduce((k,z)=>!k||h(z)>h(k)?z:k,void 0);if(!m)return null;if(n>=0){let E=v(d),k=E?.roles.get("destination"),z=e[o+1];if(!E||!k||!Ey(k,z))return null;let g=e.slice(n,o).map(A=>A.value.toLowerCase());E.scrollPosition=g.join(" ");}else {let E=v(e[u].position.start-1);if(!E)return null;E.scrollBehavior=i(e[u]);}return m}catch{return null}}tryDoNotThrow(e,t,a){let i=s=>s?.value.toLowerCase(),n=e.findIndex((s,l)=>i(s)==="do"&&i(e[l+1])==="not"&&i(e[l+2])==="throw");if(n<0)return null;let o=e[n].position.start,u=(t.slice(0,e[n].position.start).trimEnd()+" "+t.slice(e[n+2].position.end).trimStart()).trim();try{let s=this.parse(u,a),l=[],c=m=>{if(!m)return;m.kind==="command"&&m.action==="fetch"&&l.push(m);let f=m;for(let y of bt){let h=f[y];Array.isArray(h)&&h.forEach(v=>c(v));}};c(s??void 0);let p=m=>m.roles.get("source")?.position?.start??-1,d=l.filter(m=>p(m)>=0&&p(m)<o).reduce((m,f)=>!m||p(f)>p(m)?f:m,void 0);return !s||!d?null:(d.doNotThrow=!0,s)}catch{return null}}tryTellTo(e,t,a){let i=s=>(s.normalized??s.value).toLowerCase()==="tell",n=e.findIndex(i);if(n<0)return null;let o=T(a)?.roleMarkers?.destination,u=new Set([o?.primary,...o?.alternatives??[]].filter(s=>!!s));for(let s=n+1;s<e.length;s++){if(e[s].value.toLowerCase()!=="to")continue;let l=e[s].position.start,c=(t.slice(0,l).trimEnd()+" "+t.slice(e[s].position.end).trimStart()).trim();try{let p=this.parse(c,a);if(!p)continue;let d=[],m=E=>{if(!E)return;E.kind==="command"&&d.push(E);let k=E;for(let z of bt){let g=k[z];Array.isArray(g)&&g.forEach(A=>m(A));}};m(p);let f=E=>E.roles.get("destination")?.position?.start??-1,y=d.filter(E=>E.action==="tell"&&f(E)>=0&&f(E)<l).reduce((E,k)=>!E||f(k)>f(E)?k:E,void 0);if(!y)continue;let h=y.roles.get("destination")?.position?.end??-1;if(h<0||!e.filter(E=>E.position.start>=h&&E.position.start<l).every(E=>i(E)||u.has(E.value)))continue;return p}catch{continue}}return null}tryLoopIndex(e,t,a){let i=l=>l?.value.toLowerCase(),n=new Set;for(let l of fe(a))if(!(l.command!=="repeat"&&l.command!=="for")){for(let c of l.template.tokens)if(c.type==="literal")for(let p of [c.value,...c.alternatives??[]])n.add(p.toLowerCase());}let o=l=>n.has(l.value.toLowerCase()),u=T(a)?.roleMarkers?.style?.primary?.toLowerCase(),s=l=>i(l)==="with"||!!u&&i(l)===u;for(let l=0;l+1<e.length;l++){let c=s(e[l])&&i(e[l+1])==="index",p=i(e[l])==="index";if(!c&&!p)continue;let d=e[l].position.start,m=(t.slice(0,d).trimEnd()+" "+t.slice(e[l+1].position.end).trimStart()).trim();try{let f=this.parse(m,a);if(!f)continue;let y=[],h=b=>{if(!b)return;b.kind==="loop"&&y.push(b);let x=b;for(let B of bt){let w=x[B];Array.isArray(w)&&w.forEach(C=>h(C));}};h(f);let v=b=>Math.max(-1,...[...b.roles.values()].map(x=>x.position?.end??-1).filter(x=>x<=d)),E=y.filter(b=>v(b)>=0).reduce((b,x)=>!b||v(x)>v(b)?x:b,void 0);if(!E)continue;let k=e.filter(b=>b.position.start>=v(E)&&b.position.start<d),z=E.roles.get("quantity"),g=z?.type==="literal"&&typeof z.value=="number"?z.position?.end:void 0,A=g===void 0?void 0:e.find(b=>b.position.start>=g);if(!k.every(b=>b===A||o(b)))continue;return E.indexVariable=c?"index":e[l+1].value,f}catch{continue}}return null}tryWaitAlternatives(e,t,a){let i=h=>!!h&&(h.normalized??h.value).toLowerCase()==="wait";if(!e.some(h=>i(h)))return null;let n=h=>(h.normalized??h.value).toLowerCase(),o=h=>{if(!h)return;let v=k=>S.KNOWN_EVENTS.has(k)||Oe.has(k);if(v(n(h)))return n(h);let E=yi(h.value,a);return v(E)?E:void 0},u=h=>o(h)!==void 0,s=h=>!!h&&/^\d+(?:\.\d+)?(?:ms|s)$/.test(h.value),l=T(a)?.roleMarkers?.source,c=new Set([l?.primary,...l?.alternatives??[]].filter(Boolean).map(h=>h.toLowerCase())),p=h=>!!h&&((h.normalized??"")==="source"||c.has(h.value.toLowerCase())),d=l?.position!=="after",m=T(a)?.wordOrder==="SOV",f=(h,v)=>m?i(e[v])||e[v]?.kind==="particle"&&i(e[v+1]):i(e[h-1])||i(e[h-2]),y=h=>{let v=vi(o(e[h]),a).split(/\s+/);return v.length<2||e[h].value!==v[0]?1:v.every((E,k)=>k===0||e[h+k]?.value===E)?v.length:1};for(let h=0;h<e.length;h++){if(!u(e[h]))continue;let v=[],E=h+y(h),k=this.matchEventParamPhrase(e,E);v.push(k.names.length>0?{event:o(e[h]),params:k.names}:{event:o(e[h])});let z=E+k.len;for(;Yt(e[z]??{value:""},a);){let P=e[z+1];if(u(P)){let F=z+1+y(z+1),_=this.matchEventParamPhrase(e,F);v.push(_.names.length>0?{event:o(P),params:_.names}:{event:o(P)}),z=F+_.len;}else if(s(P))v.push({duration:P.value}),z+=2;else break}let g=z,A,b;if(d&&p(e[z])&&e[z+1]?(A=[z,z+1],b=e[z+1]):!d&&e[z]&&p(e[z+1])&&(A=[z,z+1],b=e[z]),!(v.length>1||k.names.length>0||!!A))continue;let B=A?A[1]+1:g;if(!f(h,B))continue;let w=[];g>E&&w.push([e[E-1].position.end,e[g-1].position.end]),A&&w.push([e[A[0]].position.start,e[A[1]].position.end]),w.sort((P,F)=>P[0]-F[0]);let C="",D=0;for(let[P,F]of w)C+=t.slice(D,P)+" ",D=F;C=(C+t.slice(D)).replace(/\s+/g," ").trim();let O=v[0],M=0;for(let P=0;P<h;P++)o(e[P])===O.event&&f(P,P+1)&&M++;try{let P=this.parse(C,a),F=[],_=N=>{if(!N)return;let j=N.roles?.get("event"),ie=j?.type==="expression"?j.raw:j&&"value"in j?String(j.value):void 0;N.kind==="command"&&N.action==="wait"&&ie?.toLowerCase()===O.event&&F.push(N);let he=N;for(let H of bt){let L=he[H];Array.isArray(L)&&L.forEach(I=>_(I));}};_(P??void 0);let K=F[M];if(!P||!K)continue;return K.waitAlternatives=v,b&&(K.waitSource=gy(b)),P}catch{}}return null}isBodyCommandWord(e,t){let a=(e.normalized??e.value).toLowerCase();return e.kind==="keyword"&&t.has(a)&&!S.KNOWN_EVENTS.has(a)&&!Oe.has(a)}matchEventParamPhrase(e,t){if(e[t]?.value!=="(")return {len:0,names:[]};let a=[];for(let i=t+1;i<e.length;i++){let n=e[i].value;if(n===")")return e[t-1]?.position?.end!==e[t]?.position?.start&&e[i+1]?.kind==="particle"?{len:0,names:[]}:{len:i-t+1,names:a};if(n===",")continue;let o=e[i].kind;if(o!=="identifier"&&o!=="keyword"||!/^[A-Za-z_$][\w$]*$/.test(n))break;let u=(e[i].normalized??n).toLowerCase();if(o==="keyword"&&vy.has(u))break;a.push(n);}return {len:0,names:[]}}isStrippableSourceRef(e,t){if(!e)return false;let a=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(a==="me"||a==="i"||a==="it"))return true;let i=e.value.toLowerCase();return t.has(i)||!!a&&t.has(a)}tryTrailingEventExtraction(e,t,a){let i=Z(e,t).tokens;if(i.length<3)return null;let n=Re[t],o=new Set;if(n)for(let z of Object.keys(n))o.add(z.toLowerCase());let u=i.length-2,s=i[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))return null;let c=i[i.length-1],p=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&S.KNOWN_EVENTS.has(d)||S.KNOWN_EVENTS.has(p)||o.has(p)))return null;let f=d&&S.KNOWN_EVENTS.has(d)?d:n?.[p]??p,y=i.slice(0,u);if(y.length===0)return null;let h=a.filter(z=>z.command!=="on"),v=new se(y,t),E=this.coverageMark(),k=this.parseBodyWithClauses(v,h,t);return k.length===0?(this.coverageRollback(E),null):zt({type:"literal",value:f},k,void 0,{sourceLanguage:t,confidence:.75})}tryMidStreamEventExtraction(e,t,a){let i=Z(e,t).tokens;if(i.length<3)return null;let n=Re[t],o=new Set;if(n)for(let u of Object.keys(n))o.add(u.toLowerCase());for(let u=0;u<i.length-1;u++){let s=i[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let c=i[u+1],p=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&S.KNOWN_EVENTS.has(d)||S.KNOWN_EVENTS.has(p)||o.has(p)))continue;let f=d&&S.KNOWN_EVENTS.has(d)?d:n?.[p]??p,y=i.filter((z,g)=>g!==u&&g!==u+1);if(y.length===0)return null;let h=a.filter(z=>z.command!=="on"),v=new se(y,t),E=this.coverageMark(),k=this.parseBodyWithClauses(v,h,t);return k.length===0?(this.coverageRollback(E),null):zt({type:"literal",value:f},k,void 0,{sourceLanguage:t,confidence:.75})}return null}trySOVEventExtraction(e,t,a){let i=S.SOV_EVENT_MARKERS[t];if(!i)return null;let o=Z(e,t).tokens,u=Re[t],s=new Set;if(u)for(let A of Object.keys(u))s.add(A.toLowerCase());let l=S.SOV_SOURCE_MARKERS[t],c=-1,p="",d="",m=1,f=[];for(let A=0;A<o.length;A++){let b=o[A],x=b.value.toLowerCase(),B=x,w="",C=x.indexOf("[");C>0&&(B=x.slice(0,C),w=b.value.slice(C));let D=b.normalized?.toLowerCase(),O=D&&(S.KNOWN_EVENTS.has(D)||Oe.has(D)),M=s.has(x)||s.has(B),P=S.KNOWN_EVENTS.has(B)||Oe.has(B);if(O||M||P){let F=o[A-1];if(F&&(F.normalized??F.value).toLowerCase()==="event")continue;let _;O?_=D:M?_=u?.[x]??u?.[B]??B:_=B;let K=this.matchEventParamPhrase(o,A+1);if(i.size>0){let N=1+K.len,j=o[A+N];j&&j.kind==="selector"&&j.value.startsWith("[")&&(N+=1);let ie=o[A+N];if(ie&&(ie.kind==="particle"||ie.kind==="keyword")&&i.has(ie.value)){c=A,p=_,d=w||(N===K.len+2?o[A+N-1].value:""),m=N+1,f=K.names;break}}else {c=A,p=_,d=w,m=1+K.len+this.matchEventMarkerPhrase(o,A+1+K.len,t),f=K.names;break}}}if(c===-1){let A=new Set(a.filter(b=>b.command!=="on").map(b=>b.command));for(let b=0;b<o.length;b++){let x=o[b];if(x.kind==="identifier"&&!x.value.startsWith("`")&&Cy.test(x.value))if(i.size>0){let B=1,w=o[b+1];w&&w.kind==="selector"&&w.value.startsWith("[")&&(B=2);let C=o[b+B];if(C&&(C.kind==="particle"||C.kind==="keyword")&&i.has(C.value)){c=b,p=x.value,d=B===2?o[b+1].value:"",m=B+1;break}}else {let B=this.matchEventMarkerPhrase(o,b+1,t);if(B>0){c=b,p=x.value,d="",m=1+B;break}let w=o[b+1];if(w&&w.kind==="keyword"&&w.normalized!=null&&A.has(w.normalized)){c=b,p=x.value,d="",m=1;break}}}}if(c===-1)return null;let y=new Set;for(let A=c;A<c+m;A++)y.add(A);if(l){let A=c+m;if(A<o.length){let b=o[A];if((b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value))y.add(A);else if(this.isStrippableSourceRef(b,l.windowTokens)){let x=o[A+1];x&&(x.kind==="particle"||x.kind==="keyword")&&l.markers.has(x.value)&&(y.add(A),y.add(A+1));}}if(c>=2){let b=o[c-1];(b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(y.add(c-2),y.add(c-1));}for(let b=0;b<c;b++){let x=o[b],B=x.value.toLowerCase(),w=x.normalized?.toLowerCase();if(l.windowTokens.has(B)||w&&l.windowTokens.has(w)){y.add(b);break}}}let h=o.filter((A,b)=>!y.has(b));if(h.length===0)return null;let v=a.filter(A=>A.command!=="on"),E=new se(h,t),k=this.coverageMark(),z=this.parseBodyWithClauses(E,v,t);if(z.length===0)return this.coverageRollback(k),null;let g={sourceLanguage:t,confidence:.75};return d&&(g.keyFilter=d),zt(S.isEnEventKeyword(p)?{type:"literal",value:p}:{type:"expression",raw:p},z,void 0,g,f)}profileKeywordMatches(e,t,a){let i=T(e)?.keywords?.[t];return i?i.primary?.toLowerCase()===a?true:!!i.alternatives?.some(n=>n.toLowerCase()===a):false}consumeForPostposition(e,t){let a=e.peek();if(!a)return;let i=(a.normalized??"").toLowerCase(),n=T(t)?.keywords?.for;(i==="for"||a.value===n?.primary||(n?.alternatives??[]).includes(a.value))&&e.advance();}isThenAt(e,t,a){return this.isThenKeyword(e.value,a)?!(this.isEndKeyword(e.value,a)&&$e(t,a)):false}isThenKeyword(e,t){let a=e.toLowerCase(),n={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B"]),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\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),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"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[t];return n?n.has(a):a==="then"||this.profileKeywordMatches(t,"then",a)}isElseKeyword(e,t){let a=e.toLowerCase();return a==="else"?true:this.profileKeywordMatches(t,"else",a)}isEndKeyword(e,t){let a=e.toLowerCase(),i=Ud(t);return i?a==="end"||i.has(a):a==="end"||this.profileKeywordMatches(t,"end",a)}isJsKeyword(e){let t=(e.normalized??e.value).toLowerCase();return t==="js"||this.profileKeywordMatches("en","js",t)}isPatientMarker(e,t){let a=T(t)?.roleMarkers?.patient;if(!a?.primary)return false;let i=e.value.toLowerCase();return a.primary.toLowerCase()===i?true:!!a.alternatives?.some(n=>n.toLowerCase()===i)}isJsBlockTerminator(e,t){return this.isEndKeyword(e,t)||this.profileKeywordMatches(t,"end",e.toLowerCase())}consumeVerbFinalJsBlock(e,t){let a=e.mark(),i=0,n=-1;for(;;){let c=e.peek(i);if(!c||this.isThenKeyword(c.value,t)||this.isJsBlockTerminator(c.value,t))break;if(this.isJsKeyword(c)){let p=e.peek(i+1),d=!!p&&c.position?.end!==void 0&&c.position.end===p.position?.start&&this.profileKeywordMatches(t,"js",`${c.value}${p.value}`.toLowerCase()),m=e.peek(i+(d?2:1));if(i>0&&m&&this.isJsBlockTerminator(m.value,t)){n=i;break}}i++;}if(n<=0)return null;let o=[];for(let c=0;c<n;c++){let p=e.peek(c);p&&o.push(p);}let u=o[o.length-1];if(u&&this.isPatientMarker(u,t)&&o.pop(),o.length===0)return e.reset(a),null;let s=this.rawJsBody(o);for(let c=0;c<n;c++)e.advance();e.advance();let l=e.peek();return l&&!this.isJsBlockTerminator(l.value,t)&&e.advance(),e.advance(),me("js",{patient:{type:"expression",raw:s||"()"}},{sourceLanguage:t,patternId:`js-opaque-final-${t}`,confidence:1})}consumeJsBlock(e,t){let a=e.peek();if(!a||!this.isJsKeyword(a))return null;let i=e.mark(),n=[];e.advance();let o=e.peek();o&&a.position?.end!==void 0&&a.position.end===o.position?.start&&this.profileKeywordMatches(t,"js",`${a.value}${o.value}`.toLowerCase())&&e.advance();let u=e.peek();u&&this.isPatientMarker(u,t)&&e.advance();let s=false;for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(e.advance(),this.isJsBlockTerminator(c.value,t)){s=true;break}n.push(c);}if(!s)return e.reset(i),null;let l=this.rawJsBody(n);return me("js",{patient:{type:"expression",raw:l||"()"}},{sourceLanguage:t,patternId:`js-opaque-${t}`,confidence:1})}rawJsBody(e){if(e.length===0)return "";let t=e[0].position?.start,a=e[e.length-1].position?.end,i=this.positionSource;if(i!==void 0&&t!==void 0&&a!==void 0){let o=i.slice(t,a),u=s=>s.replace(/\s+/g,"");if(u(o)===u(e.map(s=>s.value).join("")))return o.trim()}let n="";for(let o=0;o<e.length;o++){let u=e[o-1],s=u?.position?.end!==void 0&&e[o].position?.start===u.position.end;o>0&&!s&&(n+=" "),n+=e[o].value;}return n.trim()}isIfKeyword(e,t){let a=e.toLowerCase();return a==="if"?true:this.profileKeywordMatches(t,"if",a)}isUnlessKeyword(e,t){let a=e.toLowerCase();return a==="unless"?true:this.profileKeywordMatches(t,"unless",a)}tryParseUnlessGuard(e,t,a){let i=e.peek();if(!i||!this.isUnlessKeyword((i.normalized??i.value).toLowerCase(),a))return null;let n=e.mark(),o=this.tryParseConditionalBlock(e,t,a,true);if(!o||o.kind!=="conditional")return e.reset(n),null;let u=o;if(u.elseBranch&&u.elseBranch.length>0)return e.reset(n),null;let s=u.roles.get("condition");return s?[me("unless",{condition:s},{sourceLanguage:a,patternId:`unless-${a}-guard`,confidence:1}),...u.thenBranch]:(e.reset(n),null)}isBlockEndToken(e,t,a){let i=t.next;return (this.isEndKeyword(e.value,a)||e.kind==="keyword"&&(e.normalized??"").toLowerCase()==="end"&&!(i&&i.kind==="selector"))&&!$e(t,a)}opensNestedBlock(e,t,a){let i=(e.normalized??e.value).toLowerCase();return this.isIfKeyword(i,a)?!(t&&this.isElseKeyword(t.value,a)):this.isUnlessKeyword(i,a)?true:i==="repeat"?e.kind==="keyword"||e.kind==="identifier":i!=="for"||e.kind!=="keyword"?false:!(t&&kr(t))}tryParseConditionalBlock(e,t,a,i=false){let n=e.peek();if(!n)return null;let o=(n.normalized??n.value).toLowerCase();if(!this.isIfKeyword(o,a)&&!(i&&this.isUnlessKeyword(o,a)))return null;let u=e.mark(),s=this.coverageMark();e.advance();let l=e.tokens,c=e.position(),p=[],d=0;for(;!e.isAtEnd();){let w=e.peek();if(!w)break;if(p.length>0&&this.opensNestedBlock(w,Ht(p,p.length),a)){d++,p.push(w),e.advance();continue}if(this.isBlockEndToken(w,ke(e.tokens,e.position()),a)){if(d===0){e.advance();break}d--,p.push(w),e.advance();continue}p.push(w),e.advance();}if(p.length===0)return e.reset(u),this.coverageRollback(s),null;let m=T(a),f=m?.wordOrder==="SOV"?S.buildVerbLookup(m):null,y=0,h=0,v=[];for(;y<p.length;y++){let w=p[y],C=(w.normalized??w.value).toLowerCase();if(y>0&&(this.isIfKeyword(C,a)||this.isUnlessKeyword(C,a))?h++:this.isBlockEndToken(w,ke(l,c+y),a)&&h--,h===0&&this.isThenAt(w,ke(l,c+y),a)){y++;break}if(h===0&&v.length>0){let D=(w.normalized??w.value).toLowerCase(),O=Lm(p[y-1],w,v.length===1,a),M=f!==null&&f.has(w.value.toLowerCase())&&!rn.has(D),P=/^\.[a-zA-Z_]\w*$/.test(w.value)&&p[y-1].position?.end!==void 0&&w.position?.start!==void 0&&p[y-1].position.end===w.position.start;if(!S.CONDITION_OPERATORS.has(D)&&!P&&(!O||M)&&(this.tokensBeginCommand(p.slice(y),t,a)||this.sovCommandStartsAt(p.slice(y),f)))break}v.push(w);}if(v.length===0)return e.reset(u),this.coverageRollback(s),null;let k=[],z=[],g=false,A=0;for(;y<p.length;y++){let w=p[y];if(this.opensNestedBlock(w,Ht(p,y),a)?A++:this.isBlockEndToken(w,ke(l,c+y),a)&&A--,A===0&&!g&&this.isElseKeyword(w.value,a)){g=true;continue}(g?z:k).push(w);}let b={type:"expression",raw:this.joinTokenText(v,a)},x=this.parseBranch(k,t,a),B=z.length>0?this.parseBranch(z,t,a):void 0;return x.length===0&&(!B||B.length===0)?(e.reset(u),this.coverageRollback(s),null):ep(b,x,B,{sourceLanguage:a,patternId:`conditional-${a}-folded`,confidence:1})}joinTokenText(e,t){return Le(e,T(t))}tokensBeginCommand(e,t,a){if(e.length===0)return false;let i=new se(e,a);return xe.matchBest(i,t)!==null}sovCommandStartsAt(e,t){if(!t)return false;let a=u=>t.has(u.value.toLowerCase())||!!u.normalized&&t.has(u.normalized.toLowerCase()),i=u=>u.kind==="identifier"||u.kind==="selector"||u.kind==="literal"||u.kind==="reference",n=0,o=0;for(;n+1<e.length;){let u=e[n],s=e[n+1];if(!i(u)||s.kind!=="particle")break;o+=1,n+=2;let l=e[n];if(o>=1&&l&&a(l))return true}return false}parseBranch(e,t,a){if(e.length===0)return [];let i=new se(e,a),n=this.parseBodyWithClauses(i,t,a);return n.length===1&&n[0]?.kind==="compound"?n[0].statements:n}extractStandaloneModifiers(e,t){let i=Z(e,t).tokens;if(i.length===0)return {modifiers:null,remainingInput:null};let o=i[0].value.toLowerCase(),u=y=>i[y]?.value.toLowerCase(),s=y=>!!i[y]&&i[y].kind!=="selector";if(o==="on"&&u(1)==="first"&&i.length>2)return {modifiers:{once:true,onceAsFirst:true},remainingInput:e.slice(0,i[1].position.start)+e.slice(i[2].position.start)};if(o==="first"&&s(1))return {modifiers:{once:true,onceAsFirst:true},remainingInput:e.slice(i[1].position.start)};let l=S.STANDALONE_MODIFIERS[o];if(!l)return {modifiers:null,remainingInput:null};let c={},p=1;if(l==="once")c.once=true;else {let y=1;if(y<i.length){let h=i[y],v=i[y+1],E=h.kind==="identifier"&&v?.kind==="literal"&&/^\d+(ms|s|m)?$/.test(v.value);(h.kind==="keyword"||h.kind==="particle"||E)&&(y++,p++);}if(y<i.length){let h=i[y];if(h.kind==="literal"){let v=h.value.match(/^(\d+)(ms|s|m)?$/);if(v){let E=parseInt(v[1],10),k=v[2]||"ms";k==="s"?E*=1e3:k==="m"&&(E*=6e4),c[l]=E,p=y+1;}}}c[l]||(c[l]=l==="debounce"?300:100);}let d=i.slice(p);if(d.length===0)return {modifiers:null,remainingInput:null};let m=d[0].position.start,f=e.slice(m);return {modifiers:c,remainingInput:f}}stripAsyncModifier(e,t){let a=T(t)?.keywords?.async,i=new Set(["async"]);a?.primary&&i.add(a.primary.toLowerCase()),a?.alternatives?.forEach(l=>i.add(l.toLowerCase()));let n=Z(e,t).tokens,o=n.findIndex(l=>i.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let u=n[o],s=(e.slice(0,u.position.start)+e.slice(u.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,t){let a=Z(e,t).tokens;for(let i=0;i<a.length-1;i++){if(a[i].value.toLowerCase()!=="do")continue;let n=-1;for(let l=i+1;l<=i+5&&l<a.length;l++){let c=a[l];if(c.normalized?.toLowerCase()==="throw"){n=l;break}let p=c.kind;if(p==="selector"||p==="literal"||p==="reference"||p==="conjunction")break}if(n===-1)continue;let o=a[i].position.start,u=a[n].position.end,s=(e.slice(0,o)+e.slice(u)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}return {remainingInput:null}}static droppedTokenCount(e){return (e.diagnostics??[]).filter(t=>t.code==="unconsumed-input").reduce((t,a)=>t+(parseInt(/left (\d+) token/.exec(a.message)?.[1]??"0",10)||0),0)}static unconsumedSpans(e){return (e.diagnostics??[]).filter(t=>t.code==="unconsumed-input").map(t=>/unconsumed: "(.*)"$/.exec(t.message)?.[1]).filter(t=>!!t).map(t=>t.replace(/\s+/g," ").trim())}static withoutSpanDiagnostics(e,t){return {...e,diagnostics:(e.diagnostics??[]).filter(a=>{if(a.code!=="unconsumed-input")return true;let i=/unconsumed: "(.*)"$/.exec(a.message)?.[1];return !i||i.replace(/\s+/g," ").trim()!==t})}}static sourceNounValue(e){if(e.kind==="selector")return Ne(e.value);let t=(e.normalized??e.value).toLowerCase();return _e(t)?{type:"reference",value:t}:{type:"literal",value:e.value,dataType:"string"}}reclaimDanglingFromTail(e,t,a){let i=S.droppedTokenCount,n=S.unconsumedSpans(e);if(n.length===0)return null;let o=i(e),u=T(a)?.roleMarkers?.source,s=new Set;u?.primary&&s.add(u.primary),u?.alternatives?.forEach(c=>s.add(c));let l=Z(t,a).tokens;for(let c=0;c<l.length;c++){let p=l[c];if(p.normalized!=="source"&&!s.has(p.value))continue;let d=u?.position==="after"?c-1:c+1,m=l[d];if(!m||m.kind!=="identifier"&&m.kind!=="keyword")continue;let f=Math.min(p.position.start,m.position.start),y=Math.max(p.position.end,m.position.end),h=t.slice(f,y).replace(/\s+/g," ").trim();if(!n.some(E=>E===h||E.includes(h)))continue;let v=(t.slice(0,f).trimEnd()+" "+t.slice(y).trimStart()).trim();if(!(!v||v===t))try{let E=this.parse(v,a);if(!E||E.kind!=="event-handler")continue;let k=Gt(E);if(i(k)<o)return {node:{...k,eventModifiers:{...k.eventModifiers,from:S.sourceNounValue(m)}},input:v}}catch{}}return null}reclaimEventCompoundTail(e,t,a){let i=S.unconsumedSpans(e);if(i.length===0)return null;let n=Re[a];if(!n)return null;let o=e.roles,u=o.get("event"),s=u?.type==="literal"&&typeof u.value=="string"?u.value:null;if(!s)return null;let l=p=>p.replace(/\s+/g," ").trim(),c=Z(t,a).tokens;for(let p of i)for(let d=1;d<c.length;d++)for(let m=d;m<c.length;m++){let f=l(t.slice(c[d].position.start,c[m].position.end));if(f.length>p.length)break;if(f!==p)continue;let y=c[d-1];if((n[y.value]??y.normalized)!==s)break;let v=l(t.slice(y.position.start,c[m].position.end)),E=n[v];if(!E)break;return o.set("event",{type:"literal",value:E,dataType:"string"}),{node:S.withoutSpanDiagnostics(e,p),input:t}}return null}reclaimResponseTypeTail(e,t,a){let i=S.unconsumedSpans(e);if(i.length===0)return null;let n=S.AS_MARKERS_BEFORE[a];if(!n)return null;let o=l=>l.replace(/\s+/g," ").trim(),u=S.droppedTokenCount(e),s=Z(t,a).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],p=s[l+1];if(!n.some(f=>c.value.toLowerCase()===f)||!S.RESPONSE_TYPE_WORDS.has(p.value.toLowerCase()))continue;let d=o(t.slice(c.position.start,p.position.end));if(!i.includes(d))continue;let m=(t.slice(0,c.position.start).trimEnd()+" "+t.slice(p.position.end).trimStart()).trim();if(!(!m||m===t))try{let f=this.parse(m,a);if(!f||f.kind!=="event-handler")continue;let y=Gt(f);if(S.droppedTokenCount(y)>=u)continue;let h=S.findResponseTypeTarget(y);if(!h)continue;return h.roles.set("responseType",{type:"expression",raw:p.value}),{node:y,input:m}}catch{}}return null}static findResponseTypeTarget(e){let t=null,a=i=>{if(!i||typeof i!="object"||t)return;if(i.kind==="command"){let o=i;if(ue(o.action)?.roles.some(s=>s.role==="responseType"&&!s.required)&&!o.roles.has("responseType")){t=o;return}}let n=i;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let u=n[o];Array.isArray(u)&&u.forEach(s=>a(s));}};return a(e),t}reclaimCapturedDestinationTail(e,t,a){let i=S.unconsumedSpans(e);if(i.length===0)return null;let n=T(a)?.roleMarkers?.destination,o=new Set;if(n?.primary&&o.add(n.primary),n?.alternatives?.forEach(l=>o.add(l)),o.size===0)return null;let u=l=>l.replace(/\s+/g," ").trim(),s=Z(t,a).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],p=s[l+1],d=o.has(c.value)&&p.normalized==="me",m=c.normalized==="me"&&o.has(p.value);if(!d&&!m)continue;let f=u(t.slice(c.position.start,p.position.end));if(!i.includes(f))continue;let y=false,h=v=>{if(!v||typeof v!="object"||y)return;if(v.kind==="command"){let k=v.roles.get("destination");if(k?.type==="reference"&&k.value==="me"){y=true;return}}let E=v;for(let k of ["body","statements","thenBranch","elseBranch","commands"]){let z=E[k];Array.isArray(z)&&z.forEach(g=>h(g));}};if(h(e),!!y)return {node:S.withoutSpanDiagnostics(e,f),input:t}}return null}applyModifiers(e,t){return {...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let a=[];for(;;){let i=e.mark(),n=e.peek();if(!n)break;if(!Yt(n,t)){e.reset(i);break}e.advance();let o=e.peek();if(!o){e.reset(i);break}let u=o.normalized||o.value;e.advance(),a.push({type:"literal",value:u});}return a}};ze.coverageMarkerSurfaces=new Map;ze.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};ze.AS_MARKERS_BEFORE={en:["as"],es:["como"],fr:["comme"],pt:["como"],it:["come"],de:["als"],id:["sebagai"],ms:["sebagai","sbg"],sw:["kuwa","kama"],th:["\u0E40\u0E1B\u0E47\u0E19"],vi:["nh\u01B0"],tl:["bilang"],he:["\u05DB"],ar:["\u0643\u0640"],pl:["jako"],ru:["\u043A\u0430\u043A"],uk:["\u044F\u043A"],zh:["\u7684","\u4F5C\u4E3A","\u5F53\u4F5C"]};ze.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};ze.enEventKeywordCache=new Map;ze.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);ze.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);ze.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"]),hi:new Set(["\u092A\u0930"])};ze.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};ze.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"])},hi:{markers:new Set(["\u0938\u0947"]),windowTokens:new Set(["\u0935\u093F\u0902\u0921\u094B","\u0926\u0938\u094D\u0924\u093E\u0935\u0947\u091C\u093C","window","document"])}};ze.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);ze.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};var Ay=ze,xy=new Ay;function Dy(r,e){return xy.parse(r,e)}var By=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),a=this.cache.get(t);if(!a){this.stats.misses++;return}if(this.isExpired(a)){this.cache.delete(t),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(t),a.lastAccessed=Date.now(),this.cache.set(t,a),this.stats.hits++,a.result}set(r,e,t){if(!this.config.enabled||t!==null&&typeof t=="object"&&"confidence"in t&&t.confidence===0)return;let a=this.makeKey(r,e),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(a,{result:t,createdAt:i,lastAccessed:i});}has(r,e){if(!this.config.enabled)return false;let t=this.makeKey(r,e),a=this.cache.get(t);return a?this.isExpired(a)?(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}}};new By;var bn={code:"id",name:"Indonesian",nativeName:"Bahasa Indonesia",regions:["priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,verb:{position:"start",subjectDrop:true},references:{me:"saya",it:"itu",you:"anda",result:"hasil",event:"peristiwa",target:"target",body:"badan",document:"dokumen",window:"jendela",detail:"detail"},possessive:{marker:"",markerPosition:"after-object",usePossessiveAdjectives:true,specialForms:{me:"saya",it:"nya",you:"anda"},keywords:{saya:"me",aku:"me",ku:"me",my:"me",anda:"you",kamu:"you",mu:"you",nya:"it",dia:"it",miliknya:"it"},connectors:["punya"]},roleMarkers:{destination:{primary:"pada",alternatives:["ke","di"],position:"before"},source:{primary:"dari",position:"before"},patient:{primary:"",position:"before"},style:{primary:"dengan",position:"before"}},keywords:{toggle:{primary:"alihkan",normalized:"toggle"},add:{primary:"tambah",alternatives:["tambahkan"],normalized:"add"},remove:{primary:"hapus",alternatives:["buang","hilangkan"],normalized:"remove"},put:{primary:"taruh",alternatives:["letakkan","masukkan"],normalized:"put"},append:{primary:"sisipkan",normalized:"append"},prepend:{primary:"awali",normalized:"prepend"},take:{primary:"ambil",normalized:"take"},make:{primary:"buat",alternatives:["bikin","ciptakan"],normalized:"make"},clone:{primary:"klon",alternatives:["tiru"],normalized:"clone"},swap:{primary:"tukar",alternatives:["ganti"],normalized:"swap"},morph:{primary:"ubah",alternatives:["transformasi"],normalized:"morph"},set:{primary:"atur",alternatives:["tetapkan"],normalized:"set"},get:{primary:"dapatkan",alternatives:["peroleh"],normalized:"get"},increment:{primary:"tingkatkan",alternatives:["naikkan"],normalized:"increment"},decrement:{primary:"turunkan",alternatives:["kurangi"],normalized:"decrement"},log:{primary:"catat",alternatives:["rekam","cetak"],normalized:"log"},show:{primary:"tampilkan",alternatives:["perlihatkan"],normalized:"show"},hide:{primary:"sembunyikan",alternatives:["tutup"],normalized:"hide"},transition:{primary:"transisi",alternatives:["animasikan"],normalized:"transition"},on:{primary:"pada",alternatives:["saat"],normalized:"on"},trigger:{primary:"picu",alternatives:["jalankan"],normalized:"trigger"},send:{primary:"kirim",alternatives:["kirimkan"],normalized:"send"},focus:{primary:"fokus",alternatives:["fokuskan"],normalized:"focus"},blur:{primary:"blur",normalized:"blur"},empty:{primary:"kosongkan",alternatives:["kosong"],normalized:"empty"},open:{primary:"buka",normalized:"open"},close:{primary:"tutupkan",normalized:"close"},select:{primary:"tandai",normalized:"select"},clear:{primary:"bersihkan",normalized:"clear"},reset:{primary:"setel-ulang",alternatives:["reset"],normalized:"reset"},breakpoint:{primary:"titik-henti",normalized:"breakpoint"},go:{primary:"pergi",alternatives:["pindah","navigasi"],normalized:"go"},scroll:{primary:"gulir",alternatives:["gulung"],normalized:"scroll"},push:{primary:"dorong",alternatives:["push"],normalized:"push"},replace:{primary:"ganti_url",alternatives:["gantikan_url"],normalized:"replace"},process:{primary:"proses",normalized:"process"},wait:{primary:"tunggu",normalized:"wait"},fetch:{primary:"muat",normalized:"fetch"},settle:{primary:"stabilkan",normalized:"settle"},if:{primary:"jika",alternatives:["kalau","bila"],normalized:"if"},unless:{primary:"kecuali",normalized:"unless"},when:{primary:"ketika",normalized:"when"},changes:{primary:"berubah",normalized:"changes"},where:{primary:"di_mana",normalized:"where"},else:{primary:"selainnya",alternatives:["lainnya"],normalized:"else"},repeat:{primary:"ulangi",normalized:"repeat"},for:{primary:"untuk",normalized:"for"},while:{primary:"selama",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"lanjutkan",alternatives:["terus"],normalized:"continue"},halt:{primary:"hentikan",alternatives:["berhenti"],normalized:"halt"},throw:{primary:"lempar",normalized:"throw"},call:{primary:"panggil",normalized:"call"},return:{primary:"kembalikan",alternatives:["kembali"],normalized:"return"},then:{primary:"lalu",alternatives:["kemudian","setelah itu"],normalized:"then"},and:{primary:"dan",alternatives:["juga","serta"],normalized:"and"},matches:{primary:"cocok",normalized:"matches"},end:{primary:"selesai",alternatives:["akhir","tamat"],normalized:"end"},js:{primary:"js",alternatives:["javascript"],normalized:"js"},async:{primary:"asinkron",normalized:"async"},tell:{primary:"katakan",alternatives:["beritahu"],normalized:"tell"},default:{primary:"bawaan",normalized:"default"},init:{primary:"inisialisasi",alternatives:["mulai"],normalized:"init"},behavior:{primary:"perilaku",normalized:"behavior"},install:{primary:"pasang",alternatives:["instal"],normalized:"install"},measure:{primary:"ukur",normalized:"measure"},beep:{primary:"bunyi",normalized:"beep"},break:{primary:"putuskan",normalized:"break"},copy:{primary:"salin",normalized:"copy"},exit:{primary:"keluar",normalized:"exit"},pick:{primary:"pilih",normalized:"pick"},render:{primary:"olah",normalized:"render"},into:{primary:"ke dalam",normalized:"into"},before:{primary:"sebelum",normalized:"before"},after:{primary:"sesudah",alternatives:["setelah"],normalized:"after"},click:{primary:"klik",alternatives:["tekan"],normalized:"click"},hover:{primary:"hover",alternatives:["arahkan"],normalized:"hover"},submit:{primary:"ajukan",normalized:"submit"},input:{primary:"masuk",alternatives:["input","masukan"],normalized:"input"},change:{primary:"berubah",normalized:"change"},until:{primary:"sampai",normalized:"until"},event:{primary:"peristiwa",alternatives:["event"],normalized:"event"},from:{primary:"dari",normalized:"from"},connect:{primary:"sambungkan",alternatives:["hubungkan","koneksi"],normalized:"connect"},stream:{primary:"alirkan",alternatives:["streaming"],normalized:"stream"},live:{primary:"langsung",alternatives:["live"],normalized:"live"},socket:{primary:"soket",alternatives:["socket","websocket"],normalized:"socket"},bind:{primary:"ikat",alternatives:["kaitkan","bind"],normalized:"bind"},intercept:{primary:"cegat",alternatives:["tangkap","intercept"],normalized:"intercept"},worker:{primary:"pekerja",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["sumber peristiwa"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"pada",alternatives:["ketika","saat"],normalized:"on"},sourceMarker:{primary:"dari",position:"before"},conditionalKeyword:{primary:"ketika",alternatives:["saat","waktu"]},eventMarker:{primary:"saat",alternatives:["ketika","pada"],position:"before"},temporalMarkers:["ketika","saat"]}},Sy=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Ty=class{constructor(r=Sy){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}},Fy="()[]{},:;",Py=class{constructor(r=Fy){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 Qr(r,e){let t=e;for(;t<r.length&&r[t]===":";){let a=r.slice(t).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!a)break;let i=t+a[0].length;if(r[i]==="("){let n=0,o=i;for(;o<r.length;){if(r[o]==="(")n++;else if(r[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;i=o;}t=i;}return t}function wn(r,e){let t=r[e];if(t==="#"){let a=r.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!a)return null;let i=Qr(r,e+a[0].length);return r.slice(e,i)}if(t==="."){let a=r.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(a)return a[0];let i=r.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!i)return null;let n=Qr(r,e+i[0].length);return r.slice(e,n)}if(t==="@"){let a=r.slice(e).match(/^@[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="*"){let a=r.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="["){let a=0,i=e;for(;i<r.length;){if(r[i]==="["&&a++,r[i]==="]"&&(a--,a===0)){let n=Qr(r,i+1);return r.slice(e,n)}i++;}return null}if(t==="<"){let a=r.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return a?a[0]:null}return null}var Oy=class{constructor(){this.name="css-selector";}canExtract(r,e){let t=r[e];return t==="#"||t==="."||t==="["||t==="<"?true:t==="@"||t==="*"?wn(r,e)!==null:false}extract(r,e){let t=wn(r,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},Ry=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 a=t[0],i=a.slice(1).split("(")[0],n=t[1];return {value:a,length:a.length,metadata:{modifierName:i,value:n?i==="queue"?n:parseInt(n,10):void 0}}}},Ly=["http://","https://","//","./","../","/"];function _y(r,e){let t=1;for(let a=e;a<r.length;a++){let i=r[a];if(i==="{")t++;else if(i==="}"&&--t===0)return a+1}return -1}function Ny(r,e){let t=r.slice(e),a=Ly.find(n=>t.startsWith(n));if(!a)return null;let i=a.length;for(;i<t.length;){let n=t[i];if(n==="$"&&t[i+1]==="{"){let o=_y(t,i+2);if(o!==-1){i=o;continue}}if(/\s/.test(n))break;i++;}return t.slice(0,i)}var My=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=Ny(r,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},Iy=class{constructor(){this.name="variable-ref";}canExtract(r,e){let t=r[e];return (t===":"||t==="$"||t==="^")&&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"}}}},$y=new Set(["di","ke","dari","pada","dengan","tanpa","untuk","oleh","antara","sebelum","sesudah","setelah","selama","sampai","hingga","sejak","menuju","tentang","terhadap","melalui","dalam","luar"]);function jy(){let r=/[a-zA-Z]/;return {isLetter:a=>r.test(a),isIdentifierChar:a=>/[0-9]/.test(a)||r.test(a)}}var{isLetter:Wy,isIdentifierChar:zn}=jy(),qy=class{constructor(){this.name="indonesian-keyword";}setContext(r){this.context=r;}canExtract(r,e){return Wy(r[e])}extract(r,e){if(!this.context)throw new Error("IndonesianKeywordExtractor: context not set");let t=e,a="";for(;t<r.length&&zn(r[t]);)a+=r[t++];if(this.context&&t<r.length&&r[t]==="_"){let l=t,c=a;for(;l<r.length&&(r[l]==="_"||zn(r[l]));)c+=r[l++];this.context.lookupKeyword(c.toLowerCase())&&(a=c,t=l);}if(!a)return null;let i=a.toLowerCase(),n=$y.has(i),o=this.context.lookupKeyword(i),u=o&&o.normalized!==o.native?o.normalized:void 0,s;if(!o&&this.context.normalizer){let l=this.context.normalizer.normalize(a);if(l.stem!==a&&l.confidence>=.7){let c=this.context.lookupKeyword(l.stem);c&&(s=c.normalized);}}return {value:a,length:t-e,metadata:{normalized:u||s,isPreposition:n}}}};function Vy(){return [new qy]}function Ky(){return [new My,new Ry,new Iy,new Oy]}var Hy=new Set(["di","ke","dari","pada","dengan","tanpa","untuk","oleh","antara","sebelum","sesudah","setelah","selama","sampai","hingga","sejak","menuju","tentang","terhadap","melalui","dalam","luar"]),Uy=[{native:"ubah_ukuran",normalized:"resize"},{native:"tidak_ada",normalized:"no"},{native:"benar",normalized:"true"},{native:"salah",normalized:"false"},{native:"null",normalized:"null"},{native:"kosong",normalized:"null"},{native:"tidakdidefinisikan",normalized:"undefined"},{native:"tidak_terdefinisi",normalized:"undefined"},{native:"pertama",normalized:"first"},{native:"terakhir",normalized:"last"},{native:"berikutnya",normalized:"next"},{native:"sebelumnya",normalized:"previous"},{native:"terdekat",normalized:"closest"},{native:"induk",normalized:"parent"},{native:"klik",normalized:"click"},{native:"click",normalized:"click"},{native:"ubah",normalized:"change"},{native:"kirim",normalized:"submit"},{native:"tekan",normalized:"keydown"},{native:"arahkan",normalized:"mouseover"},{native:"tinggalkan",normalized:"mouseout"},{native:"kabur",normalized:"blur"},{native:"muat",normalized:"load"},{native:"gulir",normalized:"scroll"},{native:"input",normalized:"input"},{native:"milik",normalized:"my"},{native:"detik",normalized:"s"},{native:"milidetik",normalized:"ms"},{native:"menit",normalized:"m"},{native:"jam",normalized:"h"},{native:"atau",normalized:"or"},{native:"tidak",normalized:"not"},{native:"adalah",normalized:"is"},{native:"ada",normalized:"exists"},{native:"inklusif",normalized:"inclusive"},{native:"eksklusif",normalized:"exclusive"},{native:"karakter",normalized:"characters"},{native:"acak",normalized:"random"}],Gy=class extends Fe{constructor(){super(),this.language="id",this.direction="ltr",this.initializeKeywordsFromProfile(bn,Uy),this.registerExtractors(Ky()),this.registerExtractor(new Se),this.registerExtractor(new Te),this.registerExtractors(Vy()),this.registerExtractor(new Ty),this.registerExtractor(new Py);}classifyToken(r){let e=r.toLowerCase();return Hy.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":["==","!=","<=",">=","<",">","&&","||","!"].includes(r)?"operator":r.startsWith("/")||r.startsWith("./")||r.startsWith("http")?"url":"identifier"}},Zy=new Gy;Me("id",Zy,bn);var An={code:"ms",name:"Malay",nativeName:"Melayu",direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"base",verb:{position:"start",subjectDrop:true},references:{me:"saya",it:"ia",you:"kamu",result:"hasil",event:"peristiwa",target:"sasaran",body:"badan",document:"dokumen",window:"tetingkap",detail:"perincian"},possessive:{marker:"",markerPosition:"after-object",keywords:{saya:"me",saya_punya:"me",aku:"me",awak:"you",kamu:"you",anda:"you",dia:"it",ia:"it",nya:"it","-ku":"me","-mu":"you","-nya":"it"}},roleMarkers:{destination:{primary:"ke",alternatives:["pada"],position:"before"},source:{primary:"dari",position:"before"},patient:{primary:"",position:"before"},style:{primary:"dengan",position:"before"}},keywords:{toggle:{primary:"togol",alternatives:["tukar"],normalized:"toggle"},add:{primary:"tambah",normalized:"add"},remove:{primary:"buang",alternatives:["padam"],normalized:"remove"},put:{primary:"letak",alternatives:["letakkan"],normalized:"put"},append:{primary:"tambah_hujung",normalized:"append"},prepend:{primary:"tambah_mula",normalized:"prepend"},take:{primary:"ambil",normalized:"take"},make:{primary:"buat",alternatives:["cipta"],normalized:"make"},clone:{primary:"klon",alternatives:[],normalized:"clone"},swap:{primary:"tukar_tempat",normalized:"swap"},morph:{primary:"ubah_bentuk",normalized:"morph"},set:{primary:"tetapkan",alternatives:["setkan"],normalized:"set"},get:{primary:"dapatkan",alternatives:[],normalized:"get"},increment:{primary:"tambah_satu",normalized:"increment"},decrement:{primary:"kurang_satu",normalized:"decrement"},log:{primary:"catat",alternatives:["log"],normalized:"log"},show:{primary:"tunjuk",alternatives:[],normalized:"show"},hide:{primary:"sembunyi",alternatives:["sorok"],normalized:"hide"},transition:{primary:"peralihan",normalized:"transition"},on:{primary:"apabila",alternatives:["ketika"],normalized:"on"},trigger:{primary:"cetuskan",normalized:"trigger"},send:{primary:"hantar",normalized:"send"},focus:{primary:"fokus",normalized:"focus"},blur:{primary:"kabur",normalized:"blur"},empty:{primary:"kosongkan",alternatives:["kosong"],normalized:"empty"},open:{primary:"buka",normalized:"open"},close:{primary:"tutup",normalized:"close"},select:{primary:"tandai",normalized:"select"},clear:{primary:"bersihkan",normalized:"clear"},reset:{primary:"set-semula",alternatives:["reset"],normalized:"reset"},breakpoint:{primary:"titik-henti",normalized:"breakpoint"},go:{primary:"pergi",alternatives:["pindah"],normalized:"go"},scroll:{primary:"tatal",alternatives:["skrol","scroll"],normalized:"scroll"},push:{primary:"tolak",alternatives:["push"],normalized:"push"},replace:{primary:"ganti_url",alternatives:["gantikan_url"],normalized:"replace"},process:{primary:"proses",normalized:"process"},wait:{primary:"tunggu",normalized:"wait"},fetch:{primary:"ambil_dari",alternatives:["muat"],normalized:"fetch"},settle:{primary:"selesai",normalized:"settle"},if:{primary:"jika",alternatives:["kalau"],normalized:"if"},unless:{primary:"kecuali",normalized:"unless"},when:{primary:"bila",normalized:"when"},changes:{primary:"berubah",normalized:"changes"},where:{primary:"di_mana",normalized:"where"},else:{primary:"kalau_tidak",alternatives:["jika_tidak"],normalized:"else"},repeat:{primary:"ulang",normalized:"repeat"},for:{primary:"untuk",normalized:"for"},while:{primary:"selagi",alternatives:["semasa"],normalized:"while"},forever:{primary:"selamanya",normalized:"forever",alternatives:["forever"]},continue:{primary:"teruskan",normalized:"continue"},halt:{primary:"henti",alternatives:["berhenti"],normalized:"halt"},throw:{primary:"lempar",normalized:"throw"},call:{primary:"panggil",normalized:"call"},return:{primary:"pulang",alternatives:["kembali"],normalized:"return"},then:{primary:"kemudian",alternatives:["lepas_itu"],normalized:"then"},and:{primary:"dan",normalized:"and"},matches:{primary:"sepadan",normalized:"matches"},exists:{primary:"wujud",normalized:"exists"},is:{primary:"adalah",normalized:"is"},no:{primary:"tiada",normalized:"no"},end:{primary:"tamat",alternatives:["habis"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"tak_segerak",normalized:"async"},tell:{primary:"beritahu",normalized:"tell"},default:{primary:"lalai",normalized:"default"},init:{primary:"mula",alternatives:["mulakan"],normalized:"init"},behavior:{primary:"kelakuan",normalized:"behavior"},install:{primary:"pasang",normalized:"install"},measure:{primary:"ukur",normalized:"measure"},beep:{primary:"bunyi",normalized:"beep"},break:{primary:"pecah",normalized:"break"},copy:{primary:"salin",normalized:"copy"},exit:{primary:"keluar",normalized:"exit"},pick:{primary:"pilih",normalized:"pick"},render:{primary:"papar",normalized:"render"},into:{primary:"ke_dalam",normalized:"into"},before:{primary:"sebelum",normalized:"before"},after:{primary:"selepas",alternatives:["lepas"],normalized:"after"},until:{primary:"sehingga",alternatives:["sampai"],normalized:"until"},event:{primary:"peristiwa",normalized:"event"},from:{primary:"dari",normalized:"from"},connect:{primary:"sambung",alternatives:["hubungkan"],normalized:"connect"},stream:{primary:"strim",alternatives:["penstriman","aliran"],normalized:"stream"},live:{primary:"langsung",alternatives:["siaran-langsung"],normalized:"live"},socket:{primary:"soket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"ikat",alternatives:["kaitkan","bind"],normalized:"bind"},intercept:{primary:"pintas",alternatives:["cegat","intercept"],normalized:"intercept"},worker:{primary:"pekerja",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["sumber_peristiwa"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"apabila",alternatives:["ketika"],normalized:"on"},sourceMarker:{primary:"dari",position:"before"},eventMarker:{primary:"apabila",alternatives:["ketika"],position:"before"}}},Yy=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Xy=class{constructor(r=Yy){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}},Jy="()[]{},:;",Qy=class{constructor(r=Jy){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 ea(r,e){let t=e;for(;t<r.length&&r[t]===":";){let a=r.slice(t).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!a)break;let i=t+a[0].length;if(r[i]==="("){let n=0,o=i;for(;o<r.length;){if(r[o]==="(")n++;else if(r[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;i=o;}t=i;}return t}function Cn(r,e){let t=r[e];if(t==="#"){let a=r.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!a)return null;let i=ea(r,e+a[0].length);return r.slice(e,i)}if(t==="."){let a=r.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(a)return a[0];let i=r.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!i)return null;let n=ea(r,e+i[0].length);return r.slice(e,n)}if(t==="@"){let a=r.slice(e).match(/^@[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="*"){let a=r.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="["){let a=0,i=e;for(;i<r.length;){if(r[i]==="["&&a++,r[i]==="]"&&(a--,a===0)){let n=ea(r,i+1);return r.slice(e,n)}i++;}return null}if(t==="<"){let a=r.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return a?a[0]:null}return null}var ev=class{constructor(){this.name="css-selector";}canExtract(r,e){let t=r[e];return t==="#"||t==="."||t==="["||t==="<"?true:t==="@"||t==="*"?Cn(r,e)!==null:false}extract(r,e){let t=Cn(r,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},tv=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 a=t[0],i=a.slice(1).split("(")[0],n=t[1];return {value:a,length:a.length,metadata:{modifierName:i,value:n?i==="queue"?n:parseInt(n,10):void 0}}}},rv=["http://","https://","//","./","../","/"];function av(r,e){let t=1;for(let a=e;a<r.length;a++){let i=r[a];if(i==="{")t++;else if(i==="}"&&--t===0)return a+1}return -1}function iv(r,e){let t=r.slice(e),a=rv.find(n=>t.startsWith(n));if(!a)return null;let i=a.length;for(;i<t.length;){let n=t[i];if(n==="$"&&t[i+1]==="{"){let o=av(t,i+2);if(o!==-1){i=o;continue}}if(/\s/.test(n))break;i++;}return t.slice(0,i)}var nv=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=iv(r,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},ov=class{constructor(){this.name="variable-ref";}canExtract(r,e){let t=r[e];return (t===":"||t==="$"||t==="^")&&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 uv(r){return /[a-zA-Z_]/.test(r)}function sv(r){return /[a-zA-Z0-9_]/.test(r)}var lv=class{constructor(){this.name="malay-keyword";}setContext(r){this.context=r;}canExtract(r,e){return uv(r[e])}extract(r,e){if(!this.context)throw new Error("MalayKeywordExtractor: context not set");let t=e,a="";for(;t<r.length&&sv(r[t]);)a+=r[t++];if(!a)return null;let i=a.toLowerCase(),n=this.context.lookupKeyword(i),o=n&&n.normalized!==n.native?n.normalized:void 0;return {value:a,length:a.length,metadata:{normalized:o}}}};function cv(){return [new lv]}function pv(){return [new nv,new tv,new ov,new ev]}var dv=[{native:"benar",normalized:"true"},{native:"salah",normalized:"false"},{native:"kosong",normalized:"empty"},{native:"tak_tentu",normalized:"undefined"},{native:"pertama",normalized:"first"},{native:"terakhir",normalized:"last"},{native:"seterusnya",normalized:"next"},{native:"sebelumnya",normalized:"previous"},{native:"terdekat",normalized:"closest"},{native:"induk",normalized:"parent"},{native:"klik",normalized:"click"},{native:"berubah",normalized:"change"},{native:"ubah",normalized:"change"},{native:"hantar",normalized:"submit"},{native:"input",normalized:"input"},{native:"masuk",normalized:"input"},{native:"muat",normalized:"load"},{native:"tatal",normalized:"scroll"},{native:"hover",normalized:"hover"},{native:"inklusif",normalized:"inclusive"},{native:"eksklusif",normalized:"exclusive"},{native:"aksara",normalized:"characters"},{native:"rawak",normalized:"random"}],mv=class extends Fe{constructor(){super(),this.language="ms",this.direction="ltr",this.initializeKeywordsFromProfile(An,dv),this.registerExtractors(pv()),this.registerExtractor(new Se),this.registerExtractor(new Te),this.registerExtractors(cv()),this.registerExtractor(new Xy),this.registerExtractor(new Qy);}classifyToken(r){return this.isKeyword(r)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(r)?"event-modifier":r.startsWith(".")||r.startsWith("#")||r.startsWith("[")||r.startsWith("*")||r.startsWith("<")?"selector":r.startsWith(":")?"identifier":r.startsWith('"')||r.startsWith("'")||/^-?\d/.test(r)?"literal":r.startsWith("/")||r.startsWith("./")||r.startsWith("http")?"url":"identifier"}},fv=new mv;Me("ms",fv,An);var Dn={code:"tl",name:"Tagalog",nativeName:"Tagalog",direction:"ltr",script:"latin",wordOrder:"VSO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"base",verb:{position:"start",subjectDrop:true},references:{me:"ako",it:"ito",you:"ikaw",result:"resulta",event:"pangyayari",target:"target",body:"katawan",document:"dokumento",window:"bintana",detail:"detalye"},possessive:{marker:"ng",markerPosition:"between",keywords:{ko:"me",akin:"me",aking:"me",mo:"you",iyo:"you",niya:"it",nito:"it",kaniya:"it"}},roleMarkers:{destination:{primary:"sa",alternatives:["bago","matapos"],position:"before"},source:{primary:"mula_sa",position:"before"},patient:{primary:"",position:"before"},style:{primary:"nang",position:"before"}},keywords:{toggle:{primary:"palitan",alternatives:["itoggle"],normalized:"toggle"},add:{primary:"idagdag",alternatives:["magdagdag"],normalized:"add"},remove:{primary:"alisin",alternatives:["tanggalin"],normalized:"remove"},put:{primary:"ilagay",alternatives:["maglagay"],normalized:"put"},append:{primary:"idagdag_sa_dulo",normalized:"append"},prepend:{primary:"idagdag_sa_simula",normalized:"prepend"},take:{primary:"kumuha",normalized:"take"},make:{primary:"gumawa",alternatives:["lumikha"],normalized:"make"},clone:{primary:"i-clone",normalized:"clone"},swap:{primary:"palitan_pwesto",alternatives:["magpalit"],normalized:"swap"},morph:{primary:"baguhin",normalized:"morph"},set:{primary:"itakda",alternatives:["magtakda"],normalized:"set"},get:{primary:"kunin",normalized:"get"},increment:{primary:"dagdagan",alternatives:["taasan"],normalized:"increment"},decrement:{primary:"bawasan",alternatives:["ibaba"],normalized:"decrement"},log:{primary:"itala",normalized:"log"},show:{primary:"ipakita",alternatives:["magpakita"],normalized:"show"},hide:{primary:"itago",alternatives:["magtago"],normalized:"hide"},transition:{primary:"lumipat",normalized:"transition"},on:{primary:"kapag",normalized:"on"},trigger:{primary:"palitawin",alternatives:["magpatugtog"],normalized:"trigger"},send:{primary:"ipadala",alternatives:["magpadala"],normalized:"send"},focus:{primary:"ituon",normalized:"focus"},blur:{primary:"alisin_tuon",normalized:"blur"},empty:{primary:"walang-laman",alternatives:["alisin-laman","walang_laman"],normalized:"empty"},open:{primary:"buksan",normalized:"open"},close:{primary:"isara",normalized:"close"},select:{primary:"piliin",normalized:"select"},clear:{primary:"burahin",normalized:"clear"},reset:{primary:"i-reset",normalized:"reset"},breakpoint:{primary:"breakpoint",normalized:"breakpoint"},go:{primary:"pumunta",alternatives:["punta"],normalized:"go"},scroll:{primary:"iscroll",alternatives:["mag_scroll","scroll"],normalized:"scroll"},push:{primary:"itulak",alternatives:["ipush"],normalized:"push"},replace:{primary:"palitan_url",alternatives:["ireplace"],normalized:"replace"},process:{primary:"iproseso",alternatives:["proseso"],normalized:"process"},wait:{primary:"maghintay",alternatives:["hintay"],normalized:"wait"},fetch:{primary:"kuhanin_mula",alternatives:["kunin_mula"],normalized:"fetch"},settle:{primary:"magpatahimik",normalized:"settle"},if:{primary:"kung",normalized:"if"},unless:{primary:"maliban_kung",normalized:"unless"},when:{primary:"tuwing",normalized:"when"},changes:{primary:"nagbabago",normalized:"changes"},where:{primary:"kung_saan",normalized:"where"},else:{primary:"kung_hindi",alternatives:["kundi"],normalized:"else"},repeat:{primary:"ulitin",alternatives:["paulit-ulit"],normalized:"repeat"},for:{primary:"para_sa",normalized:"for"},while:{primary:"habang",normalized:"while"},forever:{primary:"magpakailanman",normalized:"forever",alternatives:["forever"]},continue:{primary:"magpatuloy",normalized:"continue"},halt:{primary:"itigil",alternatives:["huminto"],normalized:"halt"},throw:{primary:"ihagis",alternatives:["itapon"],normalized:"throw"},call:{primary:"tawagin",alternatives:["tawagan","tumawag"],normalized:"call"},return:{primary:"ibalik",alternatives:["bumalik"],normalized:"return"},then:{primary:"pagkatapos",alternatives:["saka"],normalized:"then"},and:{primary:"at",normalized:"and"},matches:{primary:"tumutugma",normalized:"matches"},is:{primary:"ay",normalized:"is"},end:{primary:"wakas",alternatives:["tapos"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"async",alternatives:["sabay"],normalized:"async"},tell:{primary:"sabihin",alternatives:["magsabi"],normalized:"tell"},default:{primary:"pamantayan",alternatives:["default","unang_halaga"],normalized:"default"},init:{primary:"simulan",alternatives:["magsimula"],normalized:"init"},behavior:{primary:"ugali",alternatives:["kilos"],normalized:"behavior"},install:{primary:"ikabit",alternatives:["mag-install"],normalized:"install"},measure:{primary:"sukatin",normalized:"measure"},beep:{primary:"tunog",normalized:"beep"},break:{primary:"putulin",normalized:"break"},copy:{primary:"kopyahin",normalized:"copy"},exit:{primary:"lumabas",normalized:"exit"},pick:{primary:"pumili",normalized:"pick"},render:{primary:"irender",normalized:"render"},into:{primary:"sa",normalized:"into"},before:{primary:"bago",normalized:"before"},after:{primary:"matapos",normalized:"after"},until:{primary:"hanggang",normalized:"until"},event:{primary:"pangyayari",normalized:"event"},from:{primary:"mula",alternatives:["galing"],normalized:"from"},connect:{primary:"ikonekta",alternatives:["kumonekta","connect"],normalized:"connect"},stream:{primary:"i-stream",alternatives:["stream","agos"],normalized:"stream"},live:{primary:"live",alternatives:["tuwiran","direkta"],normalized:"live"},socket:{primary:"socket",alternatives:["websocket"],normalized:"socket"},worker:{primary:"worker",alternatives:["manggagawa"],normalized:"worker"},eventsource:{primary:"eventsource",normalized:"eventsource"},intercept:{primary:"intercept",alternatives:["harangin","humarang"],normalized:"intercept"},bind:{primary:"itali",alternatives:["iugnay","bind"],normalized:"bind"}},eventHandler:{keyword:{primary:"kapag",normalized:"on"},sourceMarker:{primary:"mula_sa",alternatives:["galing_sa"],position:"before"},eventMarker:{primary:"kapag",position:"before"}}};function yv(r){let e=r.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:r==="\xF1"||r==="\xD1"}function vv(r){for(let e of r)if(yv(e))return true;return false}var hv=[{pattern:"magpapa",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"magpa",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"ipang",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"ipag",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"nagpa",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3}],Ev=[{pattern:"mag",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"nag",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"mang",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"nang",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"ma",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"na",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"i",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"pa",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3}],gv=["um","in"],kv=[{pattern:"hin",confidencePenalty:.18,type:"patient-focus"},{pattern:"in",confidencePenalty:.18,type:"patient-focus"},{pattern:"han",confidencePenalty:.18,type:"locative-focus"},{pattern:"an",confidencePenalty:.18,type:"locative-focus"}];function wv(r){let e=r.toLowerCase();if(e.length<5)return null;let t=0;for(let a=0;a<e.length;a++){let i=e[a];if(!"aeiou".includes(i))t=a+1;else break}if(t===0)return null;for(let a of gv){let i=t;if(e.slice(i,i+a.length)===a){let n=e.slice(0,t)+e.slice(i+a.length);if(n.length>=3)return {stem:n,infix:a}}}return null}function zv(r){let e=r.toLowerCase();if(e.length<4)return {stem:e,reduplicated:false};let t=e[0],a=e[1];if(!"aeiou".includes(t)&&"aeiou".includes(a)){let i=e.slice(2);if(i.length>=2&&i[0]===t)return {stem:i,reduplicated:true}}return {stem:e,reduplicated:false}}var bv=class{constructor(){this.language="tl";}isNormalizable(r){return !(!vv(r)||r.length<2)}normalize(r){let e=r.toLowerCase(),t=1,a=[],i=[],n=[];for(let l of hv)if(e.startsWith(l.pattern)){let c=e.slice(l.pattern.length),p=l.minRemaining??2;if(c.length>=p){e=c,t-=l.confidencePenalty,a.push(l.pattern),n.push(`prefix:${l.pattern}`);break}}if(a.length===0){for(let l of Ev)if(e.startsWith(l.pattern)){let c=e.slice(l.pattern.length),p=l.minRemaining??2;if(c.length>=p){e=c,t-=l.confidencePenalty,a.push(l.pattern),n.push(`prefix:${l.pattern}`);break}}}let o=zv(e);o.reduplicated&&o.stem.length>=2&&(e=o.stem,t-=.1,n.push("reduplication:CV"));let u=wv(e),s=false;if(u&&u.stem.length>=2&&(e=u.stem,t-=.18,n.push(`infix:${u.infix}`),s=true),!s){for(let l of kv)if(e.endsWith(l.pattern)){let c=e.slice(0,-l.pattern.length);if(c.length>=2){e=c,t-=l.confidencePenalty,i.push(l.pattern),n.push(`suffix:${l.pattern}`);break}}}return t=Math.max(.5,t),a.length===0&&i.length===0&&n.length===0?ya(r):va(e,t,{removedPrefixes:a,removedSuffixes:i,appliedRules:n})}},Cv=new bv,Av=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],xv=class{constructor(r=Av){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}},Dv="()[]{},:;",Bv=class{constructor(r=Dv){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 ta(r,e){let t=e;for(;t<r.length&&r[t]===":";){let a=r.slice(t).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!a)break;let i=t+a[0].length;if(r[i]==="("){let n=0,o=i;for(;o<r.length;){if(r[o]==="(")n++;else if(r[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;i=o;}t=i;}return t}function xn(r,e){let t=r[e];if(t==="#"){let a=r.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!a)return null;let i=ta(r,e+a[0].length);return r.slice(e,i)}if(t==="."){let a=r.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(a)return a[0];let i=r.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!i)return null;let n=ta(r,e+i[0].length);return r.slice(e,n)}if(t==="@"){let a=r.slice(e).match(/^@[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="*"){let a=r.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="["){let a=0,i=e;for(;i<r.length;){if(r[i]==="["&&a++,r[i]==="]"&&(a--,a===0)){let n=ta(r,i+1);return r.slice(e,n)}i++;}return null}if(t==="<"){let a=r.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return a?a[0]:null}return null}var Sv=class{constructor(){this.name="css-selector";}canExtract(r,e){let t=r[e];return t==="#"||t==="."||t==="["||t==="<"?true:t==="@"||t==="*"?xn(r,e)!==null:false}extract(r,e){let t=xn(r,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},Tv=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 a=t[0],i=a.slice(1).split("(")[0],n=t[1];return {value:a,length:a.length,metadata:{modifierName:i,value:n?i==="queue"?n:parseInt(n,10):void 0}}}},Fv=["http://","https://","//","./","../","/"];function Pv(r,e){let t=1;for(let a=e;a<r.length;a++){let i=r[a];if(i==="{")t++;else if(i==="}"&&--t===0)return a+1}return -1}function Ov(r,e){let t=r.slice(e),a=Fv.find(n=>t.startsWith(n));if(!a)return null;let i=a.length;for(;i<t.length;){let n=t[i];if(n==="$"&&t[i+1]==="{"){let o=Pv(t,i+2);if(o!==-1){i=o;continue}}if(/\s/.test(n))break;i++;}return t.slice(0,i)}var Rv=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=Ov(r,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},Lv=class{constructor(){this.name="variable-ref";}canExtract(r,e){let t=r[e];return (t===":"||t==="$"||t==="^")&&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 _v(r){return /[a-zA-Z_]/.test(r)}function Nv(r){return /[a-zA-Z0-9_]/.test(r)}var Mv=new Set(["sa","ng","para","mula","hanggang","gaya","tulad","kasama","para sa"]),Iv=class{constructor(){this.name="tagalog-keyword";}setContext(r){this.context=r;}canExtract(r,e){return _v(r[e])}extract(r,e){if(!this.context)throw new Error("TagalogKeywordExtractor: context not set");let t=e,a="";for(;t<r.length&&Nv(r[t]);)a+=r[t++];if(!a)return null;let i=a.toLowerCase(),n=Mv.has(i),o=this.context.lookupKeyword(i),u=o&&o.normalized!==o.native?o.normalized:void 0,s;if(!o&&this.context.normalizer){let l=this.context.normalizer.normalize(a);if(l.stem!==a&&l.confidence>=.7){let c=this.context.lookupKeyword(l.stem);c&&(s=c.normalized);}}return {value:a,length:a.length,metadata:{normalized:u||s,isPreposition:n}}}};function $v(){return [new Iv]}function jv(){return [new Rv,new Tv,new Lv,new Sv]}var Wv=[{native:"totoo",normalized:"true"},{native:"mali",normalized:"false"},{native:"wala",normalized:"null"},{native:"hindi_tinukoy",normalized:"undefined"},{native:"una",normalized:"first"},{native:"huli",normalized:"last"},{native:"susunod",normalized:"next"},{native:"nakaraan",normalized:"previous"},{native:"pinakamalapit",normalized:"closest"},{native:"magulang",normalized:"parent"},{native:"pindot",normalized:"click"},{native:"pagbabago",normalized:"change"},{native:"isumite",normalized:"submit"},{native:"input",normalized:"input"},{native:"karga",normalized:"load"},{native:"mag_scroll",normalized:"scroll"},{native:"kasama",normalized:"inclusive"},{native:"bukod",normalized:"exclusive"},{native:"karakter",normalized:"characters"},{native:"random",normalized:"random"}],qv=class extends Fe{constructor(){super(),this.language="tl",this.direction="ltr",this.initializeKeywordsFromProfile(Dn,Wv),this.setNormalizer(Cv),this.registerExtractors(jv()),this.registerExtractor(new Se),this.registerExtractor(new Te),this.registerExtractors($v()),this.registerExtractor(new xv),this.registerExtractor(new Bv);}classifyToken(r){return this.isKeyword(r)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(r)?"event-modifier":r.startsWith(".")||r.startsWith("#")||r.startsWith("[")||r.startsWith("*")||r.startsWith("<")?"selector":r.startsWith(":")?"identifier":r.startsWith('"')||r.startsWith("'")||/^-?\d/.test(r)?"literal":r.startsWith("/")||r.startsWith("./")||r.startsWith("http")?"url":"identifier"}},Vv=new qv;Me("tl",Vv,Dn);var Sn={code:"th",name:"Thai",nativeName:"\u0E44\u0E17\u0E22",direction:"ltr",script:"thai",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:false,defaultVerbForm:"base",verb:{position:"second",subjectDrop:true},references:{me:"\u0E09\u0E31\u0E19",it:"\u0E21\u0E31\u0E19",you:"\u0E04\u0E38\u0E13",result:"\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C",event:"\u0E40\u0E2B\u0E15\u0E38\u0E01\u0E32\u0E23\u0E13\u0E4C",target:"\u0E40\u0E1B\u0E49\u0E32\u0E2B\u0E21\u0E32\u0E22",body:"\u0E1A\u0E2D\u0E14\u0E35\u0E49"},possessive:{marker:"\u0E02\u0E2D\u0E07",markerPosition:"between",keywords:{\u0E02\u0E2D\u0E07\u0E09\u0E31\u0E19:"me",\u0E02\u0E2D\u0E07\u0E1C\u0E21:"me",\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13:"you",\u0E02\u0E2D\u0E07\u0E21\u0E31\u0E19:"it",\u0E02\u0E2D\u0E07\u0E40\u0E02\u0E32:"it",\u0E02\u0E2D\u0E07\u0E40\u0E18\u0E2D:"it"}},roleMarkers:{patient:{primary:"",position:"before"},destination:{primary:"\u0E43\u0E19",alternatives:["\u0E44\u0E1B\u0E22\u0E31\u0E07"],position:"before"},source:{primary:"\u0E08\u0E32\u0E01",position:"before"},style:{primary:"\u0E14\u0E49\u0E27\u0E22",position:"before"}},keywords:{toggle:{primary:"\u0E2A\u0E25\u0E31\u0E1A",alternatives:[],normalized:"toggle"},add:{primary:"\u0E40\u0E1E\u0E34\u0E48\u0E21",alternatives:[],normalized:"add"},remove:{primary:"\u0E25\u0E1A",alternatives:["\u0E25\u0E1A\u0E2D\u0E2D\u0E01"],normalized:"remove"},put:{primary:"\u0E43\u0E2A\u0E48",alternatives:["\u0E27\u0E32\u0E07"],normalized:"put"},append:{primary:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E17\u0E49\u0E32\u0E22",alternatives:[],normalized:"append"},prepend:{primary:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E2B\u0E19\u0E49\u0E32",alternatives:[],normalized:"prepend"},take:{primary:"\u0E23\u0E31\u0E1A",alternatives:[],normalized:"take"},make:{primary:"\u0E2A\u0E23\u0E49\u0E32\u0E07",alternatives:[],normalized:"make"},clone:{primary:"\u0E42\u0E04\u0E25\u0E19",alternatives:["\u0E2A\u0E33\u0E40\u0E19\u0E32"],normalized:"clone"},swap:{primary:"\u0E2A\u0E25\u0E31\u0E1A\u0E17\u0E35\u0E48",alternatives:[],normalized:"swap"},morph:{primary:"\u0E41\u0E1B\u0E25\u0E07\u0E23\u0E48\u0E32\u0E07",alternatives:[],normalized:"morph"},set:{primary:"\u0E15\u0E31\u0E49\u0E07",alternatives:["\u0E01\u0E33\u0E2B\u0E19\u0E14"],normalized:"set"},get:{primary:"\u0E23\u0E31\u0E1A\u0E04\u0E48\u0E32",alternatives:[],normalized:"get"},increment:{primary:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E04\u0E48\u0E32",alternatives:[],normalized:"increment"},decrement:{primary:"\u0E25\u0E14\u0E04\u0E48\u0E32",alternatives:[],normalized:"decrement"},log:{primary:"\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01",alternatives:[],normalized:"log"},show:{primary:"\u0E41\u0E2A\u0E14\u0E07",alternatives:[],normalized:"show"},hide:{primary:"\u0E0B\u0E48\u0E2D\u0E19",alternatives:[],normalized:"hide"},transition:{primary:"\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E1C\u0E48\u0E32\u0E19",alternatives:[],normalized:"transition"},on:{primary:"\u0E40\u0E21\u0E37\u0E48\u0E2D",alternatives:["\u0E15\u0E2D\u0E19"],normalized:"on"},trigger:{primary:"\u0E17\u0E23\u0E34\u0E01\u0E40\u0E01\u0E2D\u0E23\u0E4C",alternatives:[],normalized:"trigger"},send:{primary:"\u0E2A\u0E48\u0E07",alternatives:[],normalized:"send"},focus:{primary:"\u0E42\u0E1F\u0E01\u0E31\u0E2A",alternatives:[],normalized:"focus"},blur:{primary:"\u0E40\u0E1A\u0E25\u0E2D",alternatives:[],normalized:"blur"},empty:{primary:"\u0E25\u0E49\u0E32\u0E07",alternatives:["\u0E17\u0E33\u0E43\u0E2B\u0E49\u0E27\u0E48\u0E32\u0E07","\u0E27\u0E48\u0E32\u0E07"],normalized:"empty"},open:{primary:"\u0E40\u0E1B\u0E34\u0E14",normalized:"open"},close:{primary:"\u0E1B\u0E34\u0E14",normalized:"close"},select:{primary:"\u0E17\u0E33\u0E40\u0E04\u0E23\u0E37\u0E48\u0E2D\u0E07\u0E2B\u0E21\u0E32\u0E22",normalized:"select"},clear:{primary:"\u0E40\u0E04\u0E25\u0E35\u0E22\u0E23\u0E4C",normalized:"clear"},reset:{primary:"\u0E23\u0E35\u0E40\u0E0B\u0E47\u0E15",normalized:"reset"},breakpoint:{primary:"\u0E08\u0E38\u0E14\u0E1E\u0E31\u0E01",normalized:"breakpoint"},click:{primary:"\u0E04\u0E25\u0E34\u0E01",normalized:"click"},hover:{primary:"\u0E42\u0E2E\u0E40\u0E27\u0E2D\u0E23\u0E4C",alternatives:["\u0E27\u0E32\u0E07\u0E40\u0E21\u0E32\u0E2A\u0E4C"],normalized:"hover"},submit:{primary:"\u0E22\u0E37\u0E48\u0E19",alternatives:["\u0E2A\u0E48\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25"],normalized:"submit"},input:{primary:"\u0E1B\u0E49\u0E2D\u0E19",alternatives:["\u0E01\u0E23\u0E2D\u0E01"],normalized:"input"},changes:{primary:"\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19",normalized:"changes"},change:{primary:"\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19",alternatives:["\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07"],normalized:"change"},go:{primary:"\u0E44\u0E1B",alternatives:["\u0E44\u0E1B\u0E17\u0E35\u0E48"],normalized:"go"},scroll:{primary:"\u0E40\u0E25\u0E37\u0E48\u0E2D\u0E19",normalized:"scroll"},push:{primary:"\u0E14\u0E31\u0E19",alternatives:["\u0E1C\u0E25\u0E31\u0E01"],normalized:"push"},replace:{primary:"\u0E41\u0E17\u0E19\u0E17\u0E35\u0E48",alternatives:["\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19-url"],normalized:"replace"},process:{primary:"\u0E1B\u0E23\u0E30\u0E21\u0E27\u0E25\u0E1C\u0E25",alternatives:["\u0E08\u0E31\u0E14\u0E01\u0E32\u0E23"],normalized:"process"},wait:{primary:"\u0E23\u0E2D",alternatives:[],normalized:"wait"},fetch:{primary:"\u0E14\u0E36\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",alternatives:[],normalized:"fetch"},settle:{primary:"\u0E04\u0E07\u0E17\u0E35\u0E48",alternatives:[],normalized:"settle"},if:{primary:"\u0E16\u0E49\u0E32",alternatives:["\u0E2B\u0E32\u0E01"],normalized:"if"},unless:{primary:"unless",normalized:"unless"},when:{primary:"\u0E02\u0E13\u0E30\u0E17\u0E35\u0E48",normalized:"when"},where:{primary:"\u0E17\u0E35\u0E48\u0E44\u0E2B\u0E19",normalized:"where"},else:{primary:"\u0E44\u0E21\u0E48\u0E07\u0E31\u0E49\u0E19",alternatives:["\u0E44\u0E21\u0E48\u0E40\u0E0A\u0E48\u0E19\u0E19\u0E31\u0E49\u0E19"],normalized:"else"},repeat:{primary:"\u0E17\u0E33\u0E0B\u0E49\u0E33",alternatives:[],normalized:"repeat"},for:{primary:"\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A",alternatives:[],normalized:"for"},while:{primary:"\u0E43\u0E19\u0E02\u0E13\u0E30\u0E17\u0E35\u0E48",alternatives:[],normalized:"while"},forever:{primary:"\u0E15\u0E25\u0E2D\u0E14\u0E44\u0E1B",normalized:"forever",alternatives:["forever"]},continue:{primary:"\u0E15\u0E48\u0E2D\u0E44\u0E1B",alternatives:[],normalized:"continue"},halt:{primary:"\u0E2B\u0E22\u0E38\u0E14",alternatives:[],normalized:"halt"},throw:{primary:"\u0E42\u0E22\u0E19",alternatives:[],normalized:"throw"},call:{primary:"\u0E40\u0E23\u0E35\u0E22\u0E01",alternatives:[],normalized:"call"},return:{primary:"\u0E04\u0E37\u0E19\u0E04\u0E48\u0E32",alternatives:["\u0E01\u0E25\u0E31\u0E1A"],normalized:"return"},then:{primary:"\u0E41\u0E25\u0E49\u0E27",alternatives:[],normalized:"then"},and:{primary:"\u0E41\u0E25\u0E30",alternatives:[],normalized:"and"},exists:{primary:"\u0E21\u0E35\u0E2D\u0E22\u0E39\u0E48",normalized:"exists"},end:{primary:"\u0E08\u0E1A",alternatives:[],normalized:"end"},js:{primary:"\u0E40\u0E08\u0E40\u0E2D\u0E2A",alternatives:["js"],normalized:"js"},async:{primary:"\u0E2D\u0E30\u0E0B\u0E34\u0E07\u0E04\u0E4C",alternatives:[],normalized:"async"},tell:{primary:"\u0E1A\u0E2D\u0E01",alternatives:[],normalized:"tell"},default:{primary:"\u0E04\u0E48\u0E32\u0E40\u0E23\u0E34\u0E48\u0E21\u0E15\u0E49\u0E19",alternatives:[],normalized:"default"},init:{primary:"\u0E40\u0E23\u0E34\u0E48\u0E21\u0E15\u0E49\u0E19",alternatives:[],normalized:"init"},behavior:{primary:"\u0E1E\u0E24\u0E15\u0E34\u0E01\u0E23\u0E23\u0E21",alternatives:[],normalized:"behavior"},install:{primary:"\u0E15\u0E34\u0E14\u0E15\u0E31\u0E49\u0E07",alternatives:[],normalized:"install"},measure:{primary:"\u0E27\u0E31\u0E14",alternatives:[],normalized:"measure"},beep:{primary:"\u0E1A\u0E35\u0E4A\u0E1A",alternatives:[],normalized:"beep"},break:{primary:"\u0E02\u0E31\u0E14\u0E08\u0E31\u0E07\u0E2B\u0E27\u0E30",alternatives:[],normalized:"break"},copy:{primary:"\u0E04\u0E31\u0E14\u0E25\u0E2D\u0E01",alternatives:[],normalized:"copy"},exit:{primary:"\u0E2D\u0E2D\u0E01",alternatives:[],normalized:"exit"},pick:{primary:"\u0E40\u0E25\u0E37\u0E2D\u0E01",alternatives:[],normalized:"pick"},render:{primary:"\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25",alternatives:[],normalized:"render"},into:{primary:"\u0E43\u0E19",alternatives:[],normalized:"into"},before:{primary:"\u0E01\u0E48\u0E2D\u0E19",alternatives:[],normalized:"before"},after:{primary:"\u0E2B\u0E25\u0E31\u0E07",alternatives:[],normalized:"after"},until:{primary:"\u0E08\u0E19\u0E16\u0E36\u0E07",alternatives:[],normalized:"until"},event:{primary:"\u0E40\u0E2B\u0E15\u0E38\u0E01\u0E32\u0E23\u0E13\u0E4C",alternatives:[],normalized:"event"},from:{primary:"\u0E08\u0E32\u0E01",normalized:"from"},connect:{primary:"\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D",alternatives:["\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21"],normalized:"connect"},stream:{primary:"\u0E2A\u0E15\u0E23\u0E35\u0E21",alternatives:["\u0E2A\u0E15\u0E23\u0E35\u0E21\u0E21\u0E34\u0E48\u0E07","\u0E01\u0E23\u0E30\u0E41\u0E2A"],normalized:"stream"},live:{primary:"\u0E44\u0E25\u0E1F\u0E4C",alternatives:["\u0E2A\u0E14","\u0E16\u0E48\u0E32\u0E22\u0E17\u0E2D\u0E14\u0E2A\u0E14"],normalized:"live"},socket:{primary:"\u0E0B\u0E47\u0E2D\u0E01\u0E40\u0E01\u0E47\u0E15",alternatives:["websocket","\u0E40\u0E27\u0E47\u0E1A\u0E0B\u0E47\u0E2D\u0E01\u0E40\u0E01\u0E47\u0E15","socket"],normalized:"socket"},intercept:{primary:"\u0E14\u0E31\u0E01\u0E08\u0E31\u0E1A",alternatives:["intercept","\u0E2A\u0E01\u0E31\u0E14\u0E01\u0E31\u0E49\u0E19"],normalized:"intercept"},worker:{primary:"\u0E40\u0E27\u0E34\u0E23\u0E4C\u0E01\u0E40\u0E01\u0E2D\u0E23\u0E4C",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u0E2D\u0E35\u0E40\u0E27\u0E19\u0E15\u0E4C\u0E0B\u0E2D\u0E23\u0E4C\u0E2A"],normalized:"eventsource"},bind:{primary:"\u0E1C\u0E39\u0E01",alternatives:["bind"],normalized:"bind"}},tokenization:{boundaryStrategy:"character"},eventHandler:{keyword:{primary:"\u0E40\u0E21\u0E37\u0E48\u0E2D",alternatives:["\u0E15\u0E2D\u0E19"],normalized:"on"},sourceMarker:{primary:"\u0E08\u0E32\u0E01",position:"before"},eventMarker:{primary:"\u0E40\u0E21\u0E37\u0E48\u0E2D",alternatives:["\u0E15\u0E2D\u0E19"],position:"before"},temporalMarkers:["\u0E40\u0E21\u0E37\u0E48\u0E2D","\u0E15\u0E2D\u0E19"]}},Kv=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Hv=class{constructor(r=Kv){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}},Uv="()[]{},:;",Gv=class{constructor(r=Uv){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 ra(r,e){let t=e;for(;t<r.length&&r[t]===":";){let a=r.slice(t).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!a)break;let i=t+a[0].length;if(r[i]==="("){let n=0,o=i;for(;o<r.length;){if(r[o]==="(")n++;else if(r[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;i=o;}t=i;}return t}function Bn(r,e){let t=r[e];if(t==="#"){let a=r.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!a)return null;let i=ra(r,e+a[0].length);return r.slice(e,i)}if(t==="."){let a=r.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(a)return a[0];let i=r.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!i)return null;let n=ra(r,e+i[0].length);return r.slice(e,n)}if(t==="@"){let a=r.slice(e).match(/^@[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="*"){let a=r.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="["){let a=0,i=e;for(;i<r.length;){if(r[i]==="["&&a++,r[i]==="]"&&(a--,a===0)){let n=ra(r,i+1);return r.slice(e,n)}i++;}return null}if(t==="<"){let a=r.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return a?a[0]:null}return null}var Zv=class{constructor(){this.name="css-selector";}canExtract(r,e){let t=r[e];return t==="#"||t==="."||t==="["||t==="<"?true:t==="@"||t==="*"?Bn(r,e)!==null:false}extract(r,e){let t=Bn(r,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},Yv=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 a=t[0],i=a.slice(1).split("(")[0],n=t[1];return {value:a,length:a.length,metadata:{modifierName:i,value:n?i==="queue"?n:parseInt(n,10):void 0}}}},Xv=["http://","https://","//","./","../","/"];function Jv(r,e){let t=1;for(let a=e;a<r.length;a++){let i=r[a];if(i==="{")t++;else if(i==="}"&&--t===0)return a+1}return -1}function Qv(r,e){let t=r.slice(e),a=Xv.find(n=>t.startsWith(n));if(!a)return null;let i=a.length;for(;i<t.length;){let n=t[i];if(n==="$"&&t[i+1]==="{"){let o=Jv(t,i+2);if(o!==-1){i=o;continue}}if(/\s/.test(n))break;i++;}return t.slice(0,i)}var e4=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=Qv(r,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},t4=class{constructor(){this.name="variable-ref";}canExtract(r,e){let t=r[e];return (t===":"||t==="$"||t==="^")&&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 Nt(r){let e=r.charCodeAt(0);return e>=3584&&e<=3711}function aa(r){return /[a-zA-Z0-9_]/.test(r)}var r4=class{constructor(){this.name="thai-keyword";}setContext(r){this.context=r;}canExtract(r,e){return Nt(r[e])||aa(r[e])}extract(r,e){if(!this.context)throw new Error("ThaiKeywordExtractor: context not set");let t=r[e];return Nt(t)?this.extractThaiWord(r,e):aa(t)?this.extractAsciiWord(r,e):null}extractThaiWord(r,e){if(!this.context)return null;let t=null,a=e,i="";for(;a<r.length&&Nt(r[a]);){i+=r[a],a++;let u=this.context.lookupKeyword(i);u&&(t={word:i,entry:u});}if(t){let u=t.entry.normalized!==t.entry.native?t.entry.normalized:void 0;return {value:t.word,length:t.word.length,metadata:{normalized:u}}}let n=e,o="";for(;n<r.length&&Nt(r[n])&&!(o.length>0&&this.isKeywordStart(r,n));)o+=r[n],n++;return o?{value:o,length:o.length,metadata:{}}:null}extractAsciiWord(r,e){if(!this.context)return null;let t=e,a="";for(;t<r.length&&aa(r[t]);)a+=r[t++];if(!a)return null;let i=a.toLowerCase(),n=this.context.lookupKeyword(i),o=n&&n.normalized!==n.native?n.normalized:void 0;return {value:a,length:a.length,metadata:{normalized:o}}}isKeywordStart(r,e){if(!this.context)return false;let t=e,a="";for(;t<r.length&&Nt(r[t]);){if(a+=r[t],t++,this.context.lookupKeyword(a))return true;if(a.length>10)break}return false}};function a4(){return [new r4]}function i4(){return [new e4,new Yv,new t4,new Zv]}var n4=[{native:"\u0E08\u0E23\u0E34\u0E07",normalized:"true"},{native:"\u0E40\u0E17\u0E47\u0E08",normalized:"false"},{native:"\u0E27\u0E48\u0E32\u0E07",normalized:"null"},{native:"\u0E44\u0E21\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14",normalized:"undefined"},{native:"\u0E41\u0E23\u0E01",normalized:"first"},{native:"\u0E2A\u0E38\u0E14\u0E17\u0E49\u0E32\u0E22",normalized:"last"},{native:"\u0E16\u0E31\u0E14\u0E44\u0E1B",normalized:"next"},{native:"\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32",normalized:"previous"},{native:"\u0E43\u0E01\u0E25\u0E49\u0E2A\u0E38\u0E14",normalized:"closest"},{native:"\u0E15\u0E49\u0E19\u0E17\u0E32\u0E07",normalized:"parent"},{native:"\u0E04\u0E25\u0E34\u0E01",normalized:"click"},{native:"\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07",normalized:"change"},{native:"\u0E2A\u0E48\u0E07",normalized:"submit"},{native:"\u0E2D\u0E34\u0E19\u0E1E\u0E38\u0E15",normalized:"input"},{native:"\u0E42\u0E2B\u0E25\u0E14",normalized:"load"},{native:"\u0E40\u0E25\u0E37\u0E48\u0E2D\u0E19",normalized:"scroll"},{native:"\u0E1B\u0E23\u0E31\u0E1A\u0E02\u0E19\u0E32\u0E14",normalized:"resize"},{native:"\u0E40\u0E27\u0E25\u0E32",normalized:"when"},{native:"\u0E44\u0E1B\u0E22\u0E31\u0E07",normalized:"to"},{native:"\u0E14\u0E49\u0E27\u0E22",normalized:"with"},{native:"\u0E41\u0E25\u0E30",normalized:"and"},{native:"\u0E23\u0E27\u0E21",normalized:"inclusive"},{native:"\u0E22\u0E01\u0E40\u0E27\u0E49\u0E19",normalized:"exclusive"},{native:"\u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30",normalized:"characters"},{native:"\u0E2A\u0E38\u0E48\u0E21",normalized:"random"}],o4=class extends Fe{constructor(){super(),this.language="th",this.direction="ltr",this.initializeKeywordsFromProfile(Sn,n4),this.registerExtractors(i4()),this.registerExtractor(new Se),this.registerExtractor(new Te),this.registerExtractors(a4()),this.registerExtractor(new Hv),this.registerExtractor(new Gv);}classifyToken(r){return this.isKeyword(r)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(r)?"event-modifier":r.startsWith(".")||r.startsWith("#")||r.startsWith("[")||r.startsWith("*")||r.startsWith("<")?"selector":r.startsWith(":")?"identifier":r.startsWith('"')||r.startsWith("'")||/^-?\d/.test(r)?"literal":r.startsWith("/")||r.startsWith("./")||r.startsWith("http")?"url":"identifier"}},u4=new o4;Me("th",u4,Sn);var s4=new Set(["true","false","null","undefined","me","my","it","its","you","your","result","event","target","body"]);function Fn(r){return r.kind==="literal"||r.kind==="selector"||r.kind==="reference"?true:r.kind==="identifier"?/^[:$]?[\p{L}_][\p{L}\p{M}\p{N}_]*$/u.test(r.value):r.kind==="keyword"&&s4.has((r.normalized??"").toLowerCase())}function l4(r){return !!r&&(/^[([-]$/.test(r.value)||Fn(r))}function c4(r){return !!r&&(r.value===")"||r.value==="]"||Fn(r))}function p4(r,e,t){let a=r.tokens;if(!a.some(n=>n.value===e))return r;let i=[];return a.forEach((n,o)=>{if(n.value!==e||!l4(a[o+1])||c4(a[o-1])){i.push(n);return}let u=e.indexOf(" ");for(let[s,l]of [[e.slice(0,u),0],[e.slice(u+1),u+1]]){let c=n.position.start+l;for(let p of t(s))i.push({...p,position:{start:p.position.start+c,end:p.position.end+c}});}}),new se(i,r.language)}var Pn={code:"vi",name:"Vietnamese",nativeName:"Ti\u1EBFng Vi\u1EC7t",direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"base",verb:{position:"start",subjectDrop:true},references:{me:"t\xF4i",it:"n\xF3",you:"b\u1EA1n",result:"k\u1EBFt qu\u1EA3",event:"s\u1EF1 ki\u1EC7n",target:"m\u1EE5c ti\xEAu",body:"body"},possessive:{marker:"c\u1EE7a",markerPosition:"between",specialForms:{me:"c\u1EE7a t\xF4i",it:"c\u1EE7a n\xF3",you:"c\u1EE7a b\u1EA1n"},keywords:{"c\u1EE7a t\xF4i":"me",my:"me","c\u1EE7a b\u1EA1n":"you","c\u1EE7a anh":"you","c\u1EE7a ch\u1ECB":"you","c\u1EE7a n\xF3":"it"}},roleMarkers:{destination:{primary:"v\xE0o",alternatives:["cho","\u0111\u1EBFn"],position:"before"},source:{primary:"t\u1EEB",alternatives:["kh\u1ECFi"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"v\u1EDBi",position:"before"}},keywords:{toggle:{primary:"chuy\u1EC3n \u0111\u1ED5i",alternatives:["b\u1EADt t\u1EAFt","chuy\u1EC3n"],normalized:"toggle"},add:{primary:"th\xEAm",alternatives:["b\u1ED5 sung"],normalized:"add"},remove:{primary:"x\xF3a",alternatives:["g\u1EE1 b\u1ECF","lo\u1EA1i b\u1ECF","b\u1ECF"],normalized:"remove"},put:{primary:"\u0111\u1EB7t",alternatives:["\u0111\u1EC3","\u0111\u01B0a"],normalized:"put"},append:{primary:"n\u1ED1i",normalized:"append"},prepend:{primary:"th\xEAm v\xE0o \u0111\u1EA7u",normalized:"prepend"},take:{primary:"l\u1EA5y",normalized:"take"},make:{primary:"t\u1EA1o",normalized:"make"},clone:{primary:"nh\xE2n b\u1EA3n",normalized:"clone"},swap:{primary:"ho\xE1n \u0111\u1ED5i",normalized:"swap"},morph:{primary:"bi\u1EBFn \u0111\u1ED5i",normalized:"morph"},set:{primary:"g\xE1n",alternatives:["thi\u1EBFt l\u1EADp"],normalized:"set"},get:{primary:"l\u1EA5y gi\xE1 tr\u1ECB",alternatives:["nh\u1EADn"],normalized:"get"},increment:{primary:"t\u0103ng",alternatives:["t\u0103ng l\xEAn"],normalized:"increment"},decrement:{primary:"gi\u1EA3m",alternatives:["gi\u1EA3m \u0111i"],normalized:"decrement"},log:{primary:"in ra",normalized:"log"},show:{primary:"hi\u1EC3n th\u1ECB",alternatives:["hi\u1EC7n"],normalized:"show"},hide:{primary:"\u1EA9n",alternatives:["che","gi\u1EA5u"],normalized:"hide"},transition:{primary:"chuy\u1EC3n ti\u1EBFp",normalized:"transition"},on:{primary:"khi",alternatives:["tr\xEAn"],normalized:"on"},trigger:{primary:"k\xEDch ho\u1EA1t",normalized:"trigger"},send:{primary:"g\u1EEDi",normalized:"send"},focus:{primary:"t\u1EADp trung",normalized:"focus"},blur:{primary:"m\u1EA5t t\u1EADp trung",normalized:"blur"},empty:{primary:"l\xE0m-r\u1ED7ng",alternatives:["tr\u1ED1ng"],normalized:"empty"},open:{primary:"m\u1EDF",normalized:"open"},close:{primary:"\u0111\xF3ng",normalized:"close"},select:{primary:"\u0111\xE1nh-d\u1EA5u",normalized:"select"},clear:{primary:"t\u1EA9y",normalized:"clear"},reset:{primary:"\u0111\u1EB7t-l\u1EA1i",normalized:"reset"},breakpoint:{primary:"\u0111i\u1EC3m-d\u1EEBng",normalized:"breakpoint"},click:{primary:"nh\u1EA5p",alternatives:["b\u1EA5m"],normalized:"click"},hover:{primary:"di chu\u1ED9t",alternatives:["r\xEA chu\u1ED9t"],normalized:"hover"},submit:{primary:"n\u1ED9p",alternatives:[],normalized:"submit"},input:{primary:"nh\u1EADp",alternatives:["nh\u1EADp li\u1EC7u"],normalized:"input"},changes:{primary:"thay \u0111\u1ED5i",normalized:"changes"},change:{primary:"thay \u0111\u1ED5i",alternatives:["\u0111\u1ED5i"],normalized:"change"},go:{primary:"\u0111i \u0111\u1EBFn",alternatives:["\u0111i"],normalized:"go"},scroll:{primary:"cu\u1ED9n",normalized:"scroll"},push:{primary:"\u0111\u1EA9y",alternatives:["push"],normalized:"push"},replace:{primary:"thay_th\u1EBF",alternatives:["thay_the"],normalized:"replace"},process:{primary:"x\u1EED_l\xFD",alternatives:["xu_ly"],normalized:"process"},wait:{primary:"ch\u1EDD",alternatives:["\u0111\u1EE3i","ch\u1EDD \u0111\u1EE3i"],normalized:"wait"},fetch:{primary:"t\u1EA3i",normalized:"fetch"},settle:{primary:"\u1ED5n \u0111\u1ECBnh",normalized:"settle"},if:{primary:"n\u1EBFu",normalized:"if"},unless:{primary:"tr\u1EEB khi",alternatives:["tr\u1EEB_khi"],normalized:"unless"},when:{primary:"l\xFAc",normalized:"when"},where:{primary:"\u1EDF_\u0111\xE2u",normalized:"where"},else:{primary:"kh\xF4ng th\xEC",alternatives:["n\u1EBFu kh\xF4ng"],normalized:"else"},repeat:{primary:"l\u1EB7p l\u1EA1i",normalized:"repeat"},for:{primary:"v\u1EDBi m\u1ED7i",normalized:"for"},while:{primary:"trong khi",normalized:"while"},forever:{primary:"m\xE3i m\xE3i",normalized:"forever",alternatives:["forever"]},continue:{primary:"ti\u1EBFp t\u1EE5c",normalized:"continue"},halt:{primary:"d\u1EEBng",alternatives:["d\u1EEBng l\u1EA1i"],normalized:"halt"},throw:{primary:"n\xE9m",normalized:"throw"},call:{primary:"g\u1ECDi",normalized:"call"},return:{primary:"tr\u1EA3 v\u1EC1",normalized:"return"},then:{primary:"r\u1ED3i",alternatives:["sau \u0111\xF3","th\xEC"],normalized:"then"},and:{primary:"v\xE0",normalized:"and"},matches:{primary:"kh\u1EDBp",normalized:"matches"},end:{primary:"k\u1EBFt th\xFAc",normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"b\u1EA5t \u0111\u1ED3ng b\u1ED9",normalized:"async"},tell:{primary:"n\xF3i v\u1EDBi",normalized:"tell"},default:{primary:"m\u1EB7c \u0111\u1ECBnh",normalized:"default"},init:{primary:"kh\u1EDFi t\u1EA1o",normalized:"init"},behavior:{primary:"h\xE0nh vi",normalized:"behavior"},install:{primary:"c\xE0i \u0111\u1EB7t",normalized:"install"},measure:{primary:"\u0111o l\u01B0\u1EDDng",normalized:"measure"},beep:{primary:"beep",normalized:"beep"},break:{primary:"ng\u1EAFt",normalized:"break"},copy:{primary:"sao ch\xE9p",normalized:"copy"},exit:{primary:"tho\xE1t",alternatives:["tho\xE1t ra"],normalized:"exit"},pick:{primary:"ch\u1ECDn",normalized:"pick"},render:{primary:"k\u1EBFt xu\u1EA5t",normalized:"render"},into:{primary:"v\xE0o",alternatives:["v\xE0o trong"],normalized:"into"},before:{primary:"tr\u01B0\u1EDBc",alternatives:["tr\u01B0\u1EDBc khi"],normalized:"before"},after:{primary:"sau",alternatives:["sau khi"],normalized:"after"},until:{primary:"cho \u0111\u1EBFn khi",normalized:"until"},event:{primary:"s\u1EF1 ki\u1EC7n",normalized:"event"},from:{primary:"t\u1EEB",alternatives:["kh\u1ECFi"],normalized:"from"},connect:{primary:"k\u1EBFt-n\u1ED1i",alternatives:["k\u1EBFt-n\u1ED1i-t\u1EDBi"],normalized:"connect"},stream:{primary:"truy\u1EC1n-ph\xE1t",alternatives:["ph\xE1t","lu\u1ED3ng"],normalized:"stream"},live:{primary:"tr\u1EF1c-ti\u1EBFp",alternatives:["ph\xE1t-tr\u1EF1c-ti\u1EBFp","live"],normalized:"live"},socket:{primary:"socket",alternatives:["\u1ED5-c\u1EAFm","websocket"],normalized:"socket"},bind:{primary:"r\xE0ng bu\u1ED9c",alternatives:["li\xEAn k\u1EBFt","bind"],normalized:"bind"},intercept:{primary:"ch\u1EB7n",alternatives:["ch\u1EB7n b\u1EAFt","intercept"],normalized:"intercept"},worker:{primary:"worker",alternatives:["c\xF4ng nh\xE2n"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["ngu\u1ED3n s\u1EF1 ki\u1EC7n"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"khi",alternatives:["tr\xEAn"],normalized:"on"},sourceMarker:{primary:"tr\xEAn",alternatives:["t\u1EA1i"],position:"before"},eventMarker:{primary:"khi",alternatives:["l\xFAc"],position:"before"},temporalMarkers:["khi","l\xFAc"]}};function d4(r){return {isLetter:a=>r.test(a),isIdentifierChar:a=>/[0-9]/.test(a)||r.test(a)}}var{isLetter:m4,isIdentifierChar:f4}=d4(/[a-zA-Z\u00e0\u00e1\u1ea3\u00e3\u1ea1\u0103\u1eb1\u1eaf\u1eb3\u1eb5\u1eb7\u00e2\u1ea7\u1ea5\u1ea9\u1eab\u1ead\u00e8\u00e9\u1ebb\u1ebd\u1eb9\u00ea\u1ec1\u1ebf\u1ec3\u1ec5\u1ec7\u00ec\u00ed\u1ec9\u0129\u1ecb\u00f2\u00f3\u1ecf\u00f5\u1ecd\u00f4\u1ed3\u1ed1\u1ed5\u1ed7\u1ed9\u01a1\u1edd\u1edb\u1edf\u1ee1\u1ee3\u00f9\u00fa\u1ee7\u0169\u1ee5\u01b0\u1eeb\u1ee9\u1eed\u1eef\u1ef1\u1ef3\u00fd\u1ef7\u1ef9\u1ef5\u0111\u00c0\u00c1\u1ea2\u00c3\u1ea0\u0102\u1eb0\u1eae\u1eb2\u1eb4\u1eb6\u00c2\u1ea6\u1ea4\u1ea8\u1eaa\u1eac\u00c8\u00c9\u1eba\u1ebc\u1eb8\u00ca\u1ec0\u1ebe\u1ec2\u1ec4\u1ec6\u00cc\u00cd\u1ec8\u0128\u1eca\u00d2\u00d3\u1ece\u00d5\u1ecc\u00d4\u1ed2\u1ed0\u1ed4\u1ed6\u1ed8\u01a0\u1edc\u1eda\u1ede\u1ee0\u1ee2\u00d9\u00da\u1ee6\u0168\u1ee4\u01af\u1eea\u1ee8\u1eec\u1eee\u1ef0\u1ef2\u00dd\u1ef6\u1ef8\u1ef4\u0110]/),y4=new Set(["trong","ngo\xE0i","tr\xEAn","d\u01B0\u1EDBi","v\xE0o","ra","\u0111\u1EBFn","t\u1EEB","v\u1EDBi","cho","b\u1EDFi","qua","tr\u01B0\u1EDBc","sau","gi\u1EEFa","b\xEAn","theo","v\u1EC1","t\u1EDBi","l\xEAn","xu\u1ED1ng"]),v4=class{constructor(){this.name="vietnamese-keyword";}setContext(r){this.context=r;}canExtract(r,e){return m4(r[e])}extract(r,e){if(!this.context)throw new Error("VietnameseKeywordExtractor: context not set");let t=this.tryMultiWordPhrase(r,e);if(t)return t;let a=e,i="";for(;a<r.length&&f4(r[a]);)i+=r[a++];if(!i)return null;let n=i.toLowerCase(),o=y4.has(n),u=this.context.lookupKeyword(n),s=u&&u.normalized!==u.native?u.normalized:void 0;return {value:i,length:a-e,metadata:{normalized:s,isPreposition:o}}}tryMultiWordPhrase(r,e){if(!this.context)return null;let t=["v\xE0o trong","s\u1EF1 ki\u1EC7n"];for(let a of t)if(r.slice(e,e+a.length).toLowerCase()===a.toLowerCase()){let n=e+a.length;if(n>=r.length||!/[a-zA-Z\u00e0\u00e1\u1ea3\u00e3\u1ea1\u0103\u1eb1\u1eaf\u1eb3\u1eb5\u1eb7\u00e2\u1ea7\u1ea5\u1ea9\u1eab\u1ead\u00e8\u00e9\u1ebb\u1ebd\u1eb9\u00ea\u1ec1\u1ebf\u1ec3\u1ec5\u1ec7\u00ec\u00ed\u1ec9\u0129\u1ecb\u00f2\u00f3\u1ecf\u00f5\u1ecd\u00f4\u1ed3\u1ed1\u1ed5\u1ed7\u1ed9\u01a1\u1edd\u1edb\u1edf\u1ee1\u1ee3\u00f9\u00fa\u1ee7\u0169\u1ee5\u01b0\u1eeb\u1ee9\u1eed\u1eef\u1ef1\u1ef3\u00fd\u1ef7\u1ef9\u1ef5\u0111]/.test(r[n])){let o=this.context.lookupKeyword(a);return {value:r.slice(e,n),length:a.length,metadata:{normalized:o?.normalized,isPreposition:false}}}}return null}};function h4(){return [new v4]}var E4=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],g4=class{constructor(r=E4){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}},k4="()[]{},:;",w4=class{constructor(r=k4){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 ia(r,e){let t=e;for(;t<r.length&&r[t]===":";){let a=r.slice(t).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!a)break;let i=t+a[0].length;if(r[i]==="("){let n=0,o=i;for(;o<r.length;){if(r[o]==="(")n++;else if(r[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;i=o;}t=i;}return t}function Tn(r,e){let t=r[e];if(t==="#"){let a=r.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!a)return null;let i=ia(r,e+a[0].length);return r.slice(e,i)}if(t==="."){let a=r.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(a)return a[0];let i=r.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!i)return null;let n=ia(r,e+i[0].length);return r.slice(e,n)}if(t==="@"){let a=r.slice(e).match(/^@[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="*"){let a=r.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return a?a[0]:null}if(t==="["){let a=0,i=e;for(;i<r.length;){if(r[i]==="["&&a++,r[i]==="]"&&(a--,a===0)){let n=ia(r,i+1);return r.slice(e,n)}i++;}return null}if(t==="<"){let a=r.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return a?a[0]:null}return null}var z4=class{constructor(){this.name="css-selector";}canExtract(r,e){let t=r[e];return t==="#"||t==="."||t==="["||t==="<"?true:t==="@"||t==="*"?Tn(r,e)!==null:false}extract(r,e){let t=Tn(r,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},b4=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 a=t[0],i=a.slice(1).split("(")[0],n=t[1];return {value:a,length:a.length,metadata:{modifierName:i,value:n?i==="queue"?n:parseInt(n,10):void 0}}}},C4=["http://","https://","//","./","../","/"];function A4(r,e){let t=1;for(let a=e;a<r.length;a++){let i=r[a];if(i==="{")t++;else if(i==="}"&&--t===0)return a+1}return -1}function x4(r,e){let t=r.slice(e),a=C4.find(n=>t.startsWith(n));if(!a)return null;let i=a.length;for(;i<t.length;){let n=t[i];if(n==="$"&&t[i+1]==="{"){let o=A4(t,i+2);if(o!==-1){i=o;continue}}if(/\s/.test(n))break;i++;}return t.slice(0,i)}var D4=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=x4(r,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},B4=class{constructor(){this.name="variable-ref";}canExtract(r,e){let t=r[e];return (t===":"||t==="$"||t==="^")&&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 S4(){return [new D4,new b4,new B4,new z4]}var T4=[{native:"\u0111\xFAng",normalized:"true"},{native:"sai",normalized:"false"},{native:"null",normalized:"null"},{native:"r\u1ED7ng",normalized:"null"},{native:"kh\xF4ng x\xE1c \u0111\u1ECBnh",normalized:"undefined"},{native:"\u0111\u1EA7u ti\xEAn",normalized:"first"},{native:"cu\u1ED1i c\xF9ng",normalized:"last"},{native:"ti\u1EBFp theo",normalized:"next"},{native:"tr\u01B0\u1EDBc \u0111\xF3",normalized:"previous"},{native:"g\u1EA7n nh\u1EA5t",normalized:"closest"},{native:"cha",normalized:"parent"},{native:"nh\u1EA5p",normalized:"click"},{native:"nh\u1EA5p chu\u1ED9t",normalized:"click"},{native:"click",normalized:"click"},{native:"nh\u1EA5p \u0111\xFAp",normalized:"dblclick"},{native:"nh\u1EADp",normalized:"input"},{native:"thay \u0111\u1ED5i",normalized:"change"},{native:"g\u1EEDi bi\u1EC3u m\u1EABu",normalized:"submit"},{native:"ph\xEDm xu\u1ED1ng",normalized:"keydown"},{native:"ph\xEDm l\xEAn",normalized:"keyup"},{native:"chu\u1ED9t v\xE0o",normalized:"mouseover"},{native:"chu\u1ED9t ra",normalized:"mouseout"},{native:"t\u1EA3i trang",normalized:"load"},{native:"cu\u1ED9n",normalized:"scroll"},{native:"c\u1EE7a t\xF4i",normalized:"my"},{native:"c\u1EE7a n\xF3",normalized:"its"},{native:"gi\xE2y",normalized:"s"},{native:"mili gi\xE2y",normalized:"ms"},{native:"ph\xFAt",normalized:"m"},{native:"gi\u1EDD",normalized:"h"},{native:"th\xEAm v\xE0o cu\u1ED1i",normalized:"append"},{native:"nh\xE2n b\u1EA3n",normalized:"clone"},{native:"t\u1EA1o ra",normalized:"make"},{native:"\u0111\u1EB7t gi\xE1 tr\u1ECB",normalized:"set"},{native:"gi\xE1 tr\u1ECB",normalized:"value"},{native:"ghi nh\u1EADt k\xFD",normalized:"log"},{native:"chuy\u1EC3n t\u1EDBi",normalized:"go"},{native:"ng\u01B0\u1EE3c l\u1EA1i",normalized:"else"},{native:"l\u1EB7p",normalized:"repeat"},{native:"ho\u1EB7c",normalized:"or"},{native:"kh\xF4ng",normalized:"not"},{native:"l\xE0",normalized:"is"},{native:"t\u1ED3n t\u1EA1i",normalized:"exists"},{native:"javascript",normalized:"js"},{native:"bao g\u1ED3m",normalized:"inclusive"},{native:"lo\u1EA1i tr\u1EEB",normalized:"exclusive"},{native:"k\xFD t\u1EF1",normalized:"characters"},{native:"ng\u1EABu nhi\xEAn",normalized:"random"}],F4=class extends Fe{constructor(){super(),this.language="vi",this.direction="ltr",this.initializeKeywordsFromProfile(Pn,T4),this.registerExtractors(S4()),this.registerExtractor(new Se),this.registerExtractor(new Te),this.registerExtractors(h4()),this.registerExtractor(new g4),this.registerExtractor(new w4);}tokenize(r){return p4(super.tokenize(r),"n\u1EBFu kh\xF4ng",e=>super.tokenize(e).tokens)}classifyToken(r){let e=r.toLowerCase();return 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":["==","!=","<=",">=","<",">","&&","||","!"].includes(r)?"operator":r.startsWith("/")||r.startsWith("./")||r.startsWith("http")?"url":"identifier"}},P4=new F4;Me("vi",P4,Pn);function sr(r){let e=r.getAttribute("data-lang");if(e)return ur(e);let t=r.getAttribute("data-hyperscript-lang")??r.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return ur(t);let a=r.closest?.("[lang]")?.getAttribute("lang");if(a)return ur(a);let i=typeof document<"u"?document.documentElement?.lang:null;return i&&i!=="en"?ur(i):null}function ur(r){return r.split("-")[0].toLowerCase()}var On={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],beep:[["patient",""]],behavior:[["patient",""]],bind:[["destination",""],["source","to"]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],eventsource:[],exit:[],fetch:[["source",""],["style","with"],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""],["manner","in new"]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],intercept:[],js:[["patient",""]],live:[],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["patient",""],["destination","to"],["manner","using view"]],on:[["event",""],["source","from"]],open:[["patient",""],["style","as"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"],["manner","using view"]],push:[["patient","url"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],replace:[["patient","url"]],reset:[["patient",""]],return:[["patient",""]],scroll:[["destination","to"]],select:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"],["scope","on"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],socket:[],swap:[["method",""],["destination","of"],["patient","with"],["manner","using view"]],take:[["patient",""],["source","from"],["recipient","for"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"],["duration","for"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],when:[["condition",""]],while:[["condition",""]],worker:[]};var O4=new Set(["repeat","for","while","tell"]),R4=new Set(["js"]);function lr(r){switch(r.kind){case "event-handler":return _4(r);case "compound":return Rn(r);case "loop":return L4(r);default:return N4(r)}}function L4(r){let e={kind:"command",action:r.action,roles:r.roles};return Rn({statements:[e,...r.body],chainType:"then"})}function _4(r){let e=["on"],t=r.roles.get("event");t&&e.push(t.type==="literal"?String(t.value):Mt(t));let a=r.roles.get("source");if(a&&e.push("from",Mt(a)),r.body&&r.body.length>0){let i=r.body.map(lr);e.push(i.join(" "));}return e.join(" ")}function Rn(r){let e=r.chainType==="async"?"async":r.chainType,t=r.statements.map(lr),a=t[0]??"";for(let i=1;i<t.length;i++){let n=r.statements[i-1],o=r.statements[i],u=n.kind==="command"&&O4.has(n.action),s=n.kind==="command"&&n.action==="bind"&&o.kind==="command"&&o.action==="bind";n.kind==="command"&&R4.has(n.action)&&(a+=" end"),a+=(u||s?" ":` ${e} `)+t[i];}return a}function N4(r){let e=On[r.action];if(e){let a=[r.action];for(let[i,n]of e){let o=r.roles.get(i);o&&((i==="destination"||i==="source")&&o.type==="reference"&&o.value==="me"||(n&&a.push(n),a.push(Mt(o))));}return a.join(" ")}let t=[r.action];for(let[,a]of r.roles)t.push(Mt(a));return t.join(" ")}function Mt(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 M4(r);case "expression":return r.raw;case "flag":return r.enabled?`+${r.name}`:`~${r.name}`}}function M4(r){let e=Mt(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 I4={confidenceThreshold:.5,strategy:"semantic"};function $4(r,e){return typeof r=="number"?r:r[e]??r["*"]??.5}var j4=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function W4(r){let e=r.match(j4);if(!e)return null;let t=e[1],a=r.slice(t.length);return a?{prefix:t,commands:a}:null}function Ln(r){function e(i,n,o){try{return r.isLanguageRegistered(n)?r.translateSingle(i,n,o):null}catch{return null}}function t(i,n,o){try{let u=o(i,n);return u!==i?u:null}catch{return null}}function a(i,n,o){if(o.strategy==="semantic"||o.strategy==="auto"){let u=$4(o.confidenceThreshold,n),s=e(i,n,u);if(s!==null)return s}if((o.strategy==="auto"||o.strategy==="i18n")&&o.i18nToEnglish){let u=t(i,n,o.i18nToEnglish);if(u!==null)return u}return null}return function(n,o,u={}){if(o==="en")return n;let s={...I4,...u},l=a(n,o,s);if(l!==null)return l;let c=W4(n);if(c){let p=a(c.commands,o,s);if(p!==null)return c.prefix+p}return n}}var na=Ln({isLanguageRegistered:ki,translateSingle(r,e,t){let a=hn(r,e);return a.confidence<t||!a.node?null:lr(a.node)}});var oa=new WeakSet;function q4(r){return (r.config?.attributes??"_, script, data-script").split(",").map(t=>t.trim()).filter(Boolean)}function V4(r,e){for(let t of e)if(r.hasAttribute(t))return t;return null}function _n(r,e){if(typeof r.addSourceTransform=="function"){r.addSourceTransform(e);return}if(typeof r.addBeforeProcessHook!="function"){console.warn("[hyperscript-i18n] _hyperscript.addBeforeProcessHook is unavailable \u2014 this build of _hyperscript.org is not supported. Load a current version from https://unpkg.com/hyperscript.org.");return}let t=q4(r),a=[...t.map(n=>`[${n}]`),'script[type="text/hyperscript"]'].join(", "),i=n=>{if(oa.has(n))return;if(n instanceof HTMLScriptElement&&n.type==="text/hyperscript"){let l=n.textContent??"";if(!l)return;let c=e(l,n);oa.add(n),c!=null&&c!==l&&(n.textContent=c);return}let o=V4(n,t);if(!o)return;let u=n.getAttribute(o);if(!u)return;let s=e(u,n);oa.add(n),s!=null&&s!==u&&n.setAttribute(o,s);};r.addBeforeProcessHook(n=>{!n||typeof n.querySelectorAll!="function"||(typeof n.matches=="function"&&n.matches(a)&&i(n),n.querySelectorAll(a).forEach(i));});}var K4=new Set(["me","my","i","it","its","you","your"]);function H4(r){for(let e of r?.features??[])for(let t of e.events??[])if(typeof t.on=="string"&&K4.has(t.on.toLowerCase()))return t.on}function Mn(r,e){if(typeof r.parse!="function")return true;try{let t=r.parse(e);return t?.errors&&t.errors.length>0?!1:H4(t)===void 0}catch{return false}}var Nn=new Set;function In(r,e,t){Nn.has(r)||(Nn.add(r),console.warn(`[hyperscript-i18n] Translation for lang="${r}" rendered hyperscript the host parser rejects (or reads as a handler for an event named like me/it/you) \u2014 falling back to the original text. Source: "${e.length>60?e.slice(0,60)+"\u2026":e}" \u2192 "${t.length>60?t.slice(0,60)+"\u2026":t}". Further elements in this language stay quiet \u2014 enable { debug: true } for per-element detail.`));}function ua(r={}){return function(t){let a=t;_n(a,(i,n)=>{let o=U4(n,r);if(!o||o==="en")return i;let u=na(i,o,r);if(u!==i){if(r.validateWithHost!==false&&!Mn(a,u))return r.debug?console.log(`[hyperscript-i18n] ${o}: host rejected "${u}" \u2014 keeping "${i}"`):In(o,i,u),i;r.debug&&console.log(`[hyperscript-i18n] ${o}: "${i}" \u2192 "${u}"`);}return u});}}function U4(r,e){if(e.languageAttribute){let a=r.getAttribute(e.languageAttribute);if(a)return a.split("-")[0].toLowerCase()}let t=sr(r);return t||(e.defaultLanguage??null)}function $n(r,e,t={}){return e==="en"?r:na(r,e,t)}$r(r=>Vr(r));function jn(){typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(ua());}var L3=["id","ms","tl","th","vi"];jn();
|
|
6
|
+
exports.plugin=ua;exports.preprocess=$n;exports.resolveLanguage=sr;exports.supportedLanguages=L3;return exports;})({});
|