@lokascript/hyperscript-adapter 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +183 -3
  2. package/dist/hyperscript-i18n-ar.global.js +4 -4
  3. package/dist/hyperscript-i18n-bn.global.js +4 -4
  4. package/dist/hyperscript-i18n-de.global.js +4 -4
  5. package/dist/hyperscript-i18n-east-asian.global.js +4 -4
  6. package/dist/hyperscript-i18n-en.global.js +6 -6
  7. package/dist/hyperscript-i18n-es.global.js +4 -4
  8. package/dist/hyperscript-i18n-fr.global.js +4 -4
  9. package/dist/hyperscript-i18n-he.global.js +4 -4
  10. package/dist/hyperscript-i18n-hi.global.js +4 -4
  11. package/dist/hyperscript-i18n-id.global.js +4 -4
  12. package/dist/hyperscript-i18n-it.global.js +4 -4
  13. package/dist/hyperscript-i18n-ja.global.js +4 -4
  14. package/dist/hyperscript-i18n-ko.global.js +4 -4
  15. package/dist/hyperscript-i18n-ms.global.js +5 -5
  16. package/dist/hyperscript-i18n-pl.global.js +4 -4
  17. package/dist/hyperscript-i18n-pt.global.js +4 -4
  18. package/dist/hyperscript-i18n-qu.global.js +4 -4
  19. package/dist/hyperscript-i18n-ru.global.js +4 -4
  20. package/dist/hyperscript-i18n-slavic.global.js +4 -4
  21. package/dist/hyperscript-i18n-south-asian.global.js +4 -4
  22. package/dist/hyperscript-i18n-southeast-asian.global.js +4 -4
  23. package/dist/hyperscript-i18n-sw.global.js +4 -4
  24. package/dist/hyperscript-i18n-th.global.js +5 -5
  25. package/dist/hyperscript-i18n-tl.global.js +4 -4
  26. package/dist/hyperscript-i18n-tr.global.js +4 -4
  27. package/dist/hyperscript-i18n-uk.global.js +4 -4
  28. package/dist/hyperscript-i18n-vi.global.js +5 -5
  29. package/dist/hyperscript-i18n-western.global.js +4 -4
  30. package/dist/hyperscript-i18n-zh.global.js +4 -4
  31. package/dist/hyperscript-i18n.global.js +24 -24
  32. package/dist/hyperscript-i18n.global.js.map +1 -1
  33. package/package.json +2 -2
  34. package/src/generated/syntax-table.ts +0 -1
@@ -1,5 +1,5 @@
1
1
  var HyperscriptI18n=(function(exports){'use strict';function le(t,e){return e?{type:"literal",value:t,dataType:e}:{type:"literal",value:t}}function rr(t,e){return e?{type:"selector",value:t,selectorKind:e}:{type:"selector",value:t}}function Ve(t){return {type:"reference",value:t}}function tr(t,e){return {type:"property-path",object:t,property:e}}var rt=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function Er(t,e=rt){return e.has(t)}var Ii=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}]`,a=new Date().toISOString();switch(t){case "debug":console.debug(`${a} ${i} DEBUG:`,e,...r);break;case "info":console.info(`${a} ${i} INFO:`,e,...r);break;case "warn":console.warn(`${a} ${i} WARN:`,e,...r);break;case "error":console.error(`${a} ${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 ji(t){return new Ii(t)}function Be(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 $i(t,e){return t?.possessive?.keywords?.[e]}var qe=class Te{constructor(){this.logger=ji("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 a=e.mark(),n=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,n);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(n.entries()).map(([u,l])=>[u,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(a),null;let s=this.calculateConfidence(r,n);return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-a.position,confidence:s}}matchBest(e,r,i){let a=[];for(let o of r){let s=e.mark(),u=this.matchPattern(e,o,i);u&&a.push(u),e.reset(s);}if(a.length===0)return null;a.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 n=a[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,i,a){let n=r[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 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 m=e.peek();if(this.logger.debug(" >> Current input token:",m?JSON.stringify({type:m.type,value:m.value,kind:m.kind}):"EOF"),c.type==="role"&&c.greedy){let E=this.collectStopMarkers(r,l+1);if(a)for(let h of a)E.add(h);let y=[];for(;!e.isAtEnd();){let h=e.peek();if(!h||this.isStopMarker(h,E))break;y.push(h.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 E=this.collectStopMarkers(r,l+1);if(a)for(let h of a)E.add(h);if(this.matchGroupToken(e,c,i,E)){s=null,u=null;continue}if(this.isOptional(c))continue;return false}let d=c.type==="role"&&c.optional===true,p=d?e.mark():null;if(c.type==="role"&&!d){let E=l+1<r.length?r[l+1]:null;if(E?.type==="literal"){let y=e.peek();if(y&&this.getMatchType(y,E.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 h=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}}let v=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Match result:",v),v){d?(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 E=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",E),E)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 a=this.getMatchType(i,r.value);if(this.logger.debug(" >>> matchType for",i.value,"vs",r.value,":",a),a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let o=this.getMatchType(i,n);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 a=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",a?JSON.stringify({value:a.value,kind:a.kind}):"null"),!a)return r.optional||false;let n=this.tryMatchPossessiveExpression(e);if(n)return r.expectedTypes&&r.expectedTypes.length>0&&!Be(n.type,r.expectedTypes)?r.optional||false:(i.set(r.role,n),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Be(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&&!Be(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&&!Be(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&&!Be(l.type,r.expectedTypes)?r.optional||false:(i.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",a?JSON.stringify({value:a.value,kind:a.kind}):"null");let c=this.tokenToSemanticValue(a);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&&!Be(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,a=this.safeToLowerCase(i),n=$i(this.currentProfile,a);if(!n)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()),tr(Ve(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 r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(i),null;e.advance();let n=e.peek();if(!n||n.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<Te.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}.${n.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 a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(i),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(i),null;e.advance();let o=`${r.value}.${n.value}`,s=1;for(;!e.isAtEnd()&&s<Te.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<Te.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 r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="'s")return e.reset(i),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(i),null):(e.advance(),tr(rr(r.value),n.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 a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(i),null;let n=e.peek(1);n&&n.kind,e.advance();let o=a.value.slice(1);return tr(rr(r.value),o)}matchGroupToken(e,r,i,a){let n=e.mark(),o=new Set(i.keys());if(this.matchTokenSequence(e,r.tokens,i,a))return true;e.reset(n);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<=Te.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,a))return true;e.reset(n);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 a=r;a<e.length;a++){let n=e[a];if(n.type==="literal"){if(i.add(n.value.toLowerCase()),n.alternatives)for(let o of n.alternatives)i.add(o.toLowerCase());break}if(n.type==="group"){for(let o of n.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(!n.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 rr(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return le(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Ve(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return le(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return le(a,"string")}if(e==="true")return le(true,"boolean");if(e==="false")return le(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?le(e,"duration"):le(a,"number")}let i=parseFloat(e);return isNaN(i)?le(e,"string"):le(i,"number")}applyExtractionRules(e,r){for(let[i,a]of Object.entries(e.extraction))r.has(i)||(a.value!==void 0?r.set(i,{type:"literal",value:a.value}):a.default&&r.set(i,a.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let i=0,a=0,n=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")a+=1,r.has(l.role)&&(i+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let m=n(c.role),d=.8;a+=d,r.has(c.role)?i+=d:m&&(i+=d*.6);}}let o=a>0?i/a: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 a of r.alternatives)if(i.has(a))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let i=0,a={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 r.entries()){let s=a[n];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(Te.ENGLISH_NOISE_WORDS.has(i)){let a=e.mark();e.advance();let n=e.peek();if(n&&n.kind==="selector")return;e.reset(a);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(i=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return i?r:void 0}};qe.MAX_MARKER_SCAN=3;qe.MAX_PROPERTY_DEPTH=10;qe.MAX_METHOD_ARGS=20;qe.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Vi=qe;new Vi;var ce=class{constructor(){this.name="string-literal";}canExtract(t,e){let r=t[e];return r==="'"&&e>0&&/[\p{L}\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 n=1;for(;e+n<t.length;){if(t[e+n]==="\u201D")return n++,{value:t.substring(e,e+n),length:n};n++;}return null}if(r==="\u2018"){let n=1;for(;e+n<t.length;){if(t[e+n]==="\u2019")return n++,{value:t.substring(e,e+n),length:n};n++;}return null}let i=1,a=false;for(;e+i<t.length;){let n=t[e+i];if(a){a=false,i++;continue}if(n==="\\"){a=true,i++;continue}if(n===r)return i++,{value:t.substring(e,e+i),length:i};i++;}return null}},me=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 a=t.substring(e,e+r),n=e+r;if(n<t.length){let o=t.slice(n),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:a+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:a+"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:a+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:a+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:a,length:r}}};function Wi(t){return "setContext"in t&&typeof t.setContext=="function"}function qi(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 ie=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 U(t,e){return {start:t,end:e}}function G(t,e,r,i){if(typeof t=="object"){let{value:n,kind:o,position:s,normalized:u,stem:l,stemConfidence:c,metadata:m}=t;return {value:n,kind:o,position:s,...u!==void 0&&{normalized:u},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...m!==void 0&&{metadata:m}}}let a=t;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof i=="string")return {value:a,kind:e,position:r,normalized:i};if(i){let{normalized:n,stem:o,stemConfidence:s,metadata:u}=i;return {value:a,kind:e,position:r,...n!==void 0&&{normalized:n},...o!==void 0&&{stem:o},...s!==void 0&&{stemConfidence:s},...u!==void 0&&{metadata:u}}}return {value:a,kind:e,position:r}}function We(t){return /\s/.test(t)}function Ki(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function Hi(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function we(t){return /\d/.test(t)}function ar(t){return t.replace(/[\u064b-\u0652\u0670]/g,"")}function Ui(t){return /[a-zA-Z]/.test(t)}function te(t){return /[a-zA-Z0-9_-]/.test(t)}function Gi(t,e){if(e>=t.length)return null;let r=t[e];if(!Ki(r))return null;let i=e,a="";if(r==="#"||r==="."){for(a+=t[i++];i<t.length&&te(t[i]);)a+=t[i++];if(a.length<=1)return null;if(i<t.length&&t[i]==="."&&r==="#"){let o=i+1;for(;o<t.length&&te(t[o]);)o++;if(o<t.length&&t[o]==="(")return a}}else if(r==="["){let n=1,o=false,s=null,u=false;for(a+=t[i++];i<t.length&&n>0;){let l=t[i];a+=l,u?u=false:l==="\\"?u=true:o?l===s&&(o=false,s=null):l==='"'||l==="'"||l==="`"?(o=true,s=l):l==="["?n++:l==="]"&&n--,i++;}if(n!==0)return null}else if(r==="@"){for(a+=t[i++];i<t.length&&te(t[i]);)a+=t[i++];if(a.length<=1)return null}else if(r==="*"){for(a+=t[i++];i<t.length&&te(t[i]);)a+=t[i++];if(a.length<=1)return null}else if(r==="<"){if(a+=t[i++],i>=t.length||!Ui(t[i]))return null;for(;i<t.length&&te(t[i]);)a+=t[i++];for(;i<t.length;){let n=t[i];if(n==="."){if(a+=t[i++],i>=t.length||!te(t[i]))return null;for(;i<t.length&&te(t[i]);)a+=t[i++];}else if(n==="#"){if(a+=t[i++],i>=t.length||!te(t[i]))return null;for(;i<t.length&&te(t[i]);)a+=t[i++];}else if(n==="["){let o=1,s=false,u=null,l=false;for(a+=t[i++];i<t.length&&o>0;){let c=t[i];a+=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&&We(t[i]);)a+=t[i++];if(i<t.length&&t[i]==="/")for(a+=t[i++];i<t.length&&We(t[i]);)a+=t[i++];if(i>=t.length||t[i]!==">")return null;a+=t[i++];}return a||null}function Zi(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 We(i)||i==="*"||!te(i)}function Yi(t,e){if(e>=t.length)return null;let r=t[e];if(!Hi(r)||r==="'"&&Zi(t,e))return null;let a={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!a)return null;let n=e+1,o=r,s=false;for(;n<t.length;){let u=t[n];if(o+=u,s)s=false;else if(u==="\\")s=true;else if(u===a)return o;n++;}return o}function Xi(t,e){if(e>=t.length)return false;let r=t[e],i=t[e+1]||"",a=t[e+2]||"";if(r==="/"&&i!=="/"&&/[a-zA-Z0-9._-]/.test(i)||r==="/"&&i==="/"&&/[a-zA-Z]/.test(a)||r==="."&&(i==="/"||i==="."&&a==="/"))return true;let n=t.slice(e,e+8).toLowerCase();return !!(n.startsWith("http://")||n.startsWith("https://"))}function Ji(t,e){if(!Xi(t,e))return null;let r=e,i="",a=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<t.length;){let n=t[r];if(n==="#"){if(i.length>0&&/[a-zA-Z0-9/.]$/.test(i))for(i+=n,r++;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)i+=t[r++];break}if(a.test(n))i+=n,r++;else break}return i.length<2?null:i}function Qi(t,e){if(e>=t.length)return null;let r=t[e];if(!we(r)&&r!=="-"&&r!=="+")return null;let i=e,a="";if((t[i]==="-"||t[i]==="+")&&(a+=t[i++]),i>=t.length||!we(t[i]))return null;for(;i<t.length&&we(t[i]);)a+=t[i++];if(i<t.length&&t[i]===".")for(a+=t[i++];i<t.length&&we(t[i]);)a+=t[i++];return i<t.length&&(t.slice(i,i+2)==="ms"?a+="ms":(t[i]==="s"||t[i]==="m"||t[i]==="h")&&(a+=t[i])),a}var ea=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(ea);var ra=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 ta(t){return t.includes("-")&&/^[\p{L}\p{N}_]+(-[\p{L}\p{N}_]+)+$/u.test(t)}var ia=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],nr=class ir{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){Wi(e)&&e.setContext(qi(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&&We(e[i]);)i++;if(i>=e.length)break;let a=this.tryMultiWordKeyword(e,i);if(a){r.push(a),i=a.position.end;continue}let n=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,m={};if(s.metadata)for(let[p,f]of Object.entries(s.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(m[p]=f);let d={};u&&(d.normalized=u),l&&(d.stem=l),c!==void 0&&(d.stemConfidence=c),Object.keys(m).length>0&&(d.metadata=m),r.push(G(s.value,this.classifyToken(s.value),U(i,i+s.length),Object.keys(d).length>0?d:void 0)),i+=s.length,n=true;break}}if(!n){let o=e[i],s=this.classifyUnknownChar(o);r.push(G(o,s,U(i,i+1))),i++;}}return new ie(this.mergeColonQualifiedNames(r),this.language)}mergeColonQualifiedNames(e){let r=[];for(let i of e){let a=r[r.length-1];if(a&&ir.ASCII_WORD.test(a.value)&&ir.COLON_QUALIFIER.test(i.value)&&a.position.end===i.position.start){let n=a.value+i.value;r[r.length-1]=G(n,this.classifyToken(n),U(a.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 a=i[i.length-1],n=a&&a.position.end<r;if(a&&!n&&(a.kind==="identifier"||a.kind==="keyword"||a.kind==="selector"))return i.push(G(".","operator",U(r,r+1))),true;let u=r+1;for(;u<e.length&&te(e[u]);)u++;return u<e.length&&e[u]==="("?(i.push(G(".","operator",U(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let i=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[a,n]of Object.entries(e.keywords))if(i.set(n.primary,{native:n.primary,normalized:n.normalized||a}),n.alternatives)for(let o of n.alternatives)i.set(o,{native:o,normalized:n.normalized||a});}if(e.references){for(let[a,n]of Object.entries(e.references))i.set(n,{native:n,normalized:a});for(let a of Object.keys(e.references))i.has(a)||i.set(a,{native:a,normalized:a});}if(e.roleMarkers){for(let[a,n]of Object.entries(e.roleMarkers))if(n.primary&&i.set(n.primary,{native:n.primary,normalized:a}),n.alternatives)for(let o of n.alternatives)i.set(o,{native:o,normalized:a});}if(e.possessive?.keywords)for(let[a,n]of Object.entries(e.possessive.keywords))i.set(a,{native:a,normalized:n});for(let a of ia)i.has(a)||i.set(a,{native:a,normalized:a});for(let a of r)i.set(a.native,a);this.profileKeywords=Array.from(i.values()).sort((a,n)=>n.native.length-a.native.length),this.multiWordKeywords=this.profileKeywords.filter(a=>(a.native.includes(" ")||ta(a.native))&&!ra.has(a.normalized)),this.profileKeywordMap=new Map;for(let a of this.profileKeywords){this.profileKeywordMap.set(a.native.toLowerCase(),a);let n=this.removeDiacritics(a.native);n!==a.native&&!this.profileKeywordMap.has(n.toLowerCase())&&this.profileKeywordMap.set(n.toLowerCase(),a);}}removeDiacritics(e){return ar(e)}tryProfileKeyword(e,r){for(let i of this.profileKeywords)if(e.slice(r).startsWith(i.native))return G(i.native,"keyword",U(r,r+i.native.length),i.normalized);return null}tryMultiWordKeyword(e,r,i=a=>/[\p{L}\p{N}_]/u.test(a)){if(this.multiWordKeywords.length===0)return null;let a=e.slice(r);for(let n of this.multiWordKeywords){if(!a.startsWith(n.native))continue;let o=e[r+n.native.length];if(!(o!==void 0&&i(o)))return G(n.native,"keyword",U(r,r+n.native.length),n.normalized)}return null}isKeywordStart(e,r){let i=e.slice(r);return this.profileKeywords.some(a=>i.startsWith(a.native))}isKeywordStartAtBoundary(e,r,i=a=>/[\p{L}\p{N}_]/u.test(a)){let a=e.slice(r);return this.profileKeywords.some(n=>{if(!a.startsWith(n.native))return false;let o=e[r+n.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 a=this.tryNormalize(e);if(!a)return null;let n=this.lookupKeyword(a.stem);if(!n)return null;let o={normalized:n.normalized,stem:a.stem,stemConfidence:a.confidence};return G(e,"keyword",U(r,i),o)}trySelector(e,r){let i=Gi(e,r);return i?G(i,"selector",U(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 a=i[0].replace(/(\s|\.)$/,""),n=a.slice(1).split("(")[0],o=i[1];return {...G(a,"event-modifier",U(r,r+a.length)),metadata:{modifierName:n,value:o?n==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let i=Yi(e,r);return i?G(i,"literal",U(r,r+i.length)):null}tryNumber(e,r){let i=Qi(e,r);return i?G(i,"literal",U(r,r+i.length)):null}tryMatchTimeUnit(e,r,i,a=false){let n=r;if(a)for(;n<e.length&&We(e[n]);)n++;let o=e.slice(n);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(te(c))continue}return {suffix:s.suffix,endPos:n+s.length}}}return null}parseBaseNumber(e,r,i=true){let a=r,n="";if(i&&(e[a]==="-"||e[a]==="+")&&(n+=e[a++]),a>=e.length||!we(e[a]))return null;for(;a<e.length&&we(e[a]);)n+=e[a++];if(a<e.length&&e[a]===".")for(n+=e[a++];a<e.length&&we(e[a]);)n+=e[a++];return !n||n==="-"||n==="+"?null:{number:n,endPos:a}}tryNumberWithTimeUnits(e,r,i,a={}){let{allowSign:n=true,skipWhitespace:o=false}=a,s=this.parseBaseNumber(e,r,n);if(!s)return null;let{number:u,endPos:l}=s,c=[...i,...ir.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,o);return m&&(u+=m.suffix,l=m.endPos),G(u,"literal",U(r,l))}tryUrl(e,r){let i=Ji(e,r);return i?G(i,"url",U(r,r+i.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!te(e[r+1]))return null;let i=r+1;for(;i<e.length&&te(e[i]);)i++;let a=e.slice(r,i);return G(a,"identifier",U(r,i))}tryOperator(e,r){let i=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(i))return G(i,"operator",U(r,r+2));let a=e[r];return ["<",">","!","+","-","*","/","="].includes(a)?G(a,"operator",U(r,r+1)):["(",")","{","}",",",";",":"].includes(a)?G(a,"punctuation",U(r,r+1)):null}tryMultiCharParticle(e,r,i){for(let a of i)if(e.slice(r,r+a.length)===a)return G(a,"particle",U(r,r+a.length));return null}};nr.ASCII_WORD=/^[A-Za-z_][A-Za-z0-9_]*$/;nr.COLON_QUALIFIER=/^:[A-Za-z_][A-Za-z0-9_]*$/;nr.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 de=nr;function at(t){return {stem:t,confidence:1}}function nt(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}var aa=Object.defineProperty,na=Object.getOwnPropertyNames,xt=(t,e)=>function(){return t&&(e=(0, t[na(t)[0]])(t=0)),e},oa=(t,e)=>{for(var r in e)aa(t,r,{get:e[r],enumerable:true});};function ot(t,e){return t.replace(/\{(\w+)\}/g,(r,i)=>String(e[i]??`{${i}}`))}function ae(t,e,r={},i){let a=St[t],n=ot(a,r),o=Bt[t],s=o?ot(o,r):void 0;return {code:t,message:n,severity:e,...i&&{role:i},...s&&{suggestion:s}}}var F,St,Bt,sa=xt({"src/generators/schema-error-codes.ts"(){F={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"},St={[F.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[F.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[F.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[F.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[F.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[F.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.",[F.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.",[F.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[F.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[F.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[F.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[F.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[F.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[F.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[F.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[F.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[F.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Bt={[F.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[F.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[F.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[F.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[F.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[F.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[F.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[F.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[F.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[F.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[F.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[F.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[F.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[F.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),Tt={};oa(Tt,{SchemaErrorCodes:()=>F,formatValidationResults:()=>fa,getValidationStats:()=>ya,validateAllKeywordCollisions:()=>Ea,validateAllSchemas:()=>pa,validateCommandSchema:()=>Ft,validateKeywordCollisions:()=>Rt,validateRoleValues:()=>ha});function ua(t,e){return {action:t,items:e}}function Ft(t){let e=[];for(let i of t.roles)i.expectedTypes.includes("literal")&&i.expectedTypes.includes("selector")&&(i.role==="patient"&&Cr.has(t.action)?e.push(ae(F.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:i.role,command:t.action},i.role)):e.push(ae(F.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:i.role},i.role))),i.expectedTypes.length>3&&!Cr.has(t.action)&&e.push(ae(F.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(ae(F.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:i.role},i.role)));switch(t.action){case "transition":la(t,e);break;case "on":ca(t,e);break;case "if":case "unless":ma(t,e);break;case "repeat":case "for":case "while":da(t,e);break}return t.roles.filter(i=>i.required).length===0&&(Ot.has(t.action)?e.push(ae(F.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(ae(F.NO_REQUIRED_ROLES,"warning",{}))),ua(t.action,e)}function la(t,e){let r=t.roles.find(a=>a.role==="patient"),i=t.roles.find(a=>a.role==="goal");r&&!i&&e.push(ae(F.TRANSITION_MISSING_GOAL,"error",{}));}function ca(t,e){let r=t.roles.find(i=>i.role==="event");r||e.push(ae(F.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(ae(F.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function ma(t,e){let r=t.roles.find(i=>i.role==="condition");r||e.push(ae(F.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(ae(F.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function da(t,e){t.action==="for"?t.roles.find(i=>i.role==="source")||e.push(ae(F.FOR_LOOP_MISSING_SOURCE,"warning",{})):t.action==="while"&&(t.roles.find(i=>i.role==="condition")||e.push(ae(F.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function pa(t,e={}){let r=new Map,{includeNotes:i=false}=e;for(let[a,n]of Object.entries(t)){let o=Ft(n),s=o.items.some(l=>l.severity==="warning"||l.severity==="error"),u=i&&o.items.some(l=>l.severity==="note");(s||u)&&r.set(a,o);}return r}function fa(t,e={}){let r=[],{showNotes:i=false,showCodes:a=true}=e;for(let[n,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 ${n}:`);for(let c of s){let m=a?` [${c.code}]`:"";r.push(` ERROR${m}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(u.length>0){r.push(` \u26A0\uFE0F ${n}:`);for(let c of u){let m=a?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(i&&l.length>0){r.push(` \u2139\uFE0F ${n}:`);for(let c of l){let m=a?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`);}}}return r.join(`
2
- `)}function ya(t){let e=0,r=0,i=0,a={};for(let n of t.values())for(let o of n.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&i++,a[o.code]=(a[o.code]||0)+1;return {totalCommands:t.size,errors:e,warnings:r,notes:i,byCode:a}}function ha(t,e){let r=[];for(let i of e){let a=t.roles.find(n=>n.role===i.role);a&&(a.expectedTypes.length>0&&!a.expectedTypes.includes(i.type)&&(a.expectedTypes.includes("expression")||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects type [${a.expectedTypes.join(", ")}], got '${i.type}'`,code:F.VALUE_TYPE_MISMATCH})),i.type==="selector"&&i.selectorKind&&a.selectorKinds&&a.selectorKinds.length>0&&(a.selectorKinds.includes(i.selectorKind)||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects selector kind [${a.selectorKinds.join(", ")}], got '${i.selectorKind}'`,code:F.SELECTOR_KIND_MISMATCH})));}return r}function va(t){if(t.length!==2)return false;let[e,r]=[...t].sort();return Pt.some(([i,a])=>i===e&&a===r)}function Rt(t){let e=[];if(!t.keywords)return {language:t.code,collisions:e};let r=new Map;for(let[a,n]of Object.entries(t.keywords)){if(!n||!n.primary)continue;let o=r.get(n.primary)||[];if(o.push({command:a,isPrimary:true}),r.set(n.primary,o),n.alternatives)for(let s of n.alternatives){let u=r.get(s)||[];u.push({command:a,isPrimary:false}),r.set(s,u);}}for(let[a,n]of r){let o=[...new Set(n.map(l=>l.command))];if(o.length<=1||va(o))continue;let s=n.filter(l=>l.isPrimary).length,u;s>=2?u="primary-primary":s===1?u="primary-alternative":u="alternative-alternative",e.push({keyword:a,commands:o.sort(),type:u});}let i={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((a,n)=>i[a.type]-i[n.type]),{language:t.code,collisions:e}}function Ea(t){let e=[];for(let[,r]of Object.entries(t)){let i=Rt(r);i.collisions.length>0&&e.push(i);}return e.sort((r,i)=>r.language.localeCompare(i.language))}var Cr,Ot,Pt,ga=xt({"src/generators/schema-validator.ts"(){sa(),Cr=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Ot=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint","live","eventsource","socket","worker","intercept"]),Pt=[["change","changes"]];}});function De(t){let e=t.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function xe(t){let e=t.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function Se(t,e){return Rr(t,e,"source")}function Fr(t,e){return Rr(t,e,"destination")}function za(t,e){return Rr(t,e,"patient")}function Rr(t,e,r){if(!e||!t.roles.some(n=>n.role===r))return [];let i=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},a={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[a,i]:[i,a]}]}var ka={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:["selector","reference"],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)"}},wa={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"}},ba={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:["selector","reference"],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"}},Ca={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into",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"}},Aa={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","expression","reference"],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>"}},Da={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>"}},xa={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Sa={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}]},Ba={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ta={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Fa={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ra={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Oa={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:"duration"}},roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Pa={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:"duration"}},roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},_a={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"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],widenTypeVariants:[{role:"event",types:["literal","expression"],idSuffix:"expr-event",excludeLanguages:["ko"]}]},Na={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},La={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}]},Ma={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}]},Ia={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"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},ja={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"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},$a={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"],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"}}]},Va={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"],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"}}]},Wa={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"],svoPosition:1,sovPosition:1}]},qa={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:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",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}]},Ka={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:["selector","reference"],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"}}]},Ha={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}]},Ua={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}]},Ga={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Za={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"],svoPosition:1,sovPosition:1}]},Ya={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"}}]},Xa={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}]},Ja={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}]},Qa={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},en={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"'},rn={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"}}]},tn={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}]},an={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",ast:{},roles:[]},Or={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"},nn={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to",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"]}}],rolePrefixLiteralVariants:[{role:"destination",literal:Or,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},on={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}]},sn={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"}}]},un={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ln={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},cn={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},mn={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:["selector","reference"],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"}}]},dn={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},pn={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},fn={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}]},yn={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},hn={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},vn={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}]},En={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"],svoPosition:1,sovPosition:1}]},gn={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}]},zn={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",ast:{},hasBody:true,roles:[]},kn={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:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},wn={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"],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"}}]},bn={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",ast:{},hasBody:true,roles:[]},Cn={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}]},An={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}]},Dn={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},xn={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"},Pr={role:"manner",description:"Run the swap inside a `document.startViewTransition()` (`using view transition`)",required:false,expectedTypes:["literal","expression"],valueShape:"keyword",markerOverride:xn},Sn={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:["selector","reference"],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"}},{...Pr,svoPosition:4,sovPosition:4}]},Bn={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:["selector","reference"],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"}},{...Pr,svoPosition:3,sovPosition:3}]},Tn={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:false,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Fn={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Rn={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},On={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Pn={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}]},_n={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"}}]},Nn={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"},Ln={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:Or}]},Mn={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:Or}]},In={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:Nn},{...Pr,svoPosition:2,sovPosition:2}]},jn={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:ka,add:wa,remove:ba,put:Ca,set:Aa,show:Oa,hide:Pa,on:_a,trigger:Na,wait:La,fetch:Ma,increment:Ia,decrement:ja,append:$a,prepend:Va,log:Wa,get:qa,take:Ka,make:Ha,halt:Ua,settle:Ga,throw:Za,send:Ya,if:Xa,unless:Ja,else:Qa,repeat:en,for:rn,while:tn,continue:an,go:nn,scroll:_n,push:Ln,replace:Mn,process:In,transition:on,clone:sn,focus:un,blur:ln,empty:cn,open:mn,close:dn,select:pn,clear:fn,reset:yn,breakpoint:hn,call:vn,return:En,js:gn,async:zn,tell:kn,default:wn,init:bn,behavior:Cn,install:An,measure:Dn,swap:Sn,morph:Bn,beep:Tn,break:Fn,copy:Rn,exit:On,pick:Pn,render:jn,bind:Da,live:xa,when:Sa,eventsource:Ba,socket:Ta,worker:Fa,intercept:Ra,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function re(t){return ue[t]}function $n(){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(()=>(ga(),Tt)).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(`
3
- These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(t=>{console.debug("Schema validation skipped:",t);});var Ae=new Map,ve=new Map,He=new Map,Ar=null;function _t(t,e){let r={...t};for(let i of Object.keys(e)){let a=e[i],n=t[i];a!==void 0&&(typeof a=="object"&&a!==null&&!Array.isArray(a)&&typeof n=="object"&&n!==null&&!Array.isArray(n)?r[i]=_t(n,a):r[i]=a);}return r}function Vn(t,e){return _t(t,e)}function _r(t){if(!t.extends)return t;let e=ve.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=_r(e);return Vn(r,t)}function ye(t,e,r){Ae.set(t,e),ve.set(t,r),He.delete(t);}function Nt(t){Ar=t;}var st=new Map;function Pe(t){return t.split("-")[0]}function _e(t){return t.includes("-")}function Wn(t){let e=Ae.get(t);if(!e&&_e(t)){let r=Pe(t);e=Ae.get(r);}if(!e){let r=Array.from(Ae.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 qn(t){let e=ve.get(t);if(!e&&_e(t)){let r=Pe(t);e=ve.get(r);}if(!e){let r=Array.from(ve.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 _r(e)}function P(t){let e=ve.get(t);return !e&&_e(t)&&(e=ve.get(Pe(t))),e?_r(e):void 0}function Kn(){return Array.from(Ae.keys())}function Lt(t){if(Ae.has(t)&&ve.has(t))return true;if(_e(t)){let e=Pe(t);return Ae.has(e)&&ve.has(e)}return false}function Hn(t,e){return Wn(e).tokenize(t)}function he(t){let e=He.get(t);if(!e&&_e(t)&&(e=He.get(Pe(t))),e)return e;let r=st.get(t);if(!r&&_e(t)&&(r=st.get(Pe(t))),r)return He.set(t,r),r;if(!Ar)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let i=qn(t),a=Ar(i);return He.set(t,a),a}var Mt={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function ke(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 q(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}function Fe(t){return Er(t)}function se(t){return {type:"reference",value:t}}function go(t,e){return e?{...t,position:e}:t}function be(t,e,r){return r?{type:"property-path",object:t,property:e,access:r}:{type:"property-path",object:t,property:e}}function ee(t,e,r){let i={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...i,metadata:r}:i}function Ke(t,e,r,i,a,n){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),a!==void 0&&a.length>0&&(s.parameterNames=a),s}function zo(t,e,r,i,a){let n={kind:"behavior",action:"behavior",roles:new Map,name:t,parameters:e,eventHandlers:r};return i!==void 0&&i.length>0&&(n.initBlock=i),a!==void 0&&(n.metadata=a),n}function ko(t,e,r,i){let a={kind:"def",action:"def",roles:new Map,name:t,parameters:e,body:r};return i!==void 0&&(a.metadata=i),a}function Dr(t,e,r,i,a){let n={kind:"feature",action:t,roles:a??new Map,body:e};return r!==void 0&&(n.name=r),i!==void 0&&(n.metadata=i),n}function Ue(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 wo(t,e,r,i){let a=new Map;a.set("condition",t);let n={kind:"conditional",action:"if",roles:a,thenBranch:e};return r!==void 0&&(n.elseBranch=r),i!==void 0&&(n.metadata=i),n}function or(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 bo(t,e){let r=t.markerOverride?.[e.code],i=e.roleMarkers[t.role];if(r!==void 0){let a=Co(t,e.code,r);return {primary:r,...a&&{alternatives:a},position:i?.position??"before",isOverride:true}}if(i&&i.primary){let a={primary:i.primary,position:i.position,isOverride:false};return i.alternatives&&(a.alternatives=i.alternatives),a}return null}function Co(t,e,r){let i=t.markerLegacy?.[e];if(!i?.length)return;let a=[...new Set(i)].filter(n=>n&&n!==r);return a.length?a:void 0}function Ee(t,e,r){let i=t.markerLegacy?.[e]??[],a=t.methodCarrier?[]:t.markerVariants?.[e]??[],n=[...new Set([...i,...a])].filter(o=>o&&o!==r);return n.length?n:void 0}var It=new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]);function pe(t,e){let r=t.possessive?.keywords?.[e];if(r)return r;let i=t.possessive?.specialForms;if(i){for(let[a,n]of Object.entries(i))if(n===e)return a}}function gr(t){return Mt.possessive?.specialForms?.[t]??`${t}'s`}var Nr={ar:{\u0642\u064A\u0645\u0629:"value"},bn:{\u0985\u0995\u09CD\u09B7\u09AE:"disabled","\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"},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"}},Ao={ar:{\u0643\u0640:"as"},bn:{\u09B9\u09BF\u09B8\u09BE\u09AC\u09C7:"as"},de:{als:"as"},es:{como:"as"},fr:{comme:"as"},hi:{\u0915\u0947_\u0930\u0942\u092A_\u092E\u0947\u0902:"as"},id:{sebagai:"as"},it:{come:"as"},ja:{\u3068\u3057\u3066:"as"},ko:{\uB85C:"as"},ms:{sebagai:"as"},pl:{jako:"as"},pt:{como:"as"},qu:{hina:"as"},ru:{\u043A\u0430\u043A:"as"},sw:{kuwa:"as"},tl:{bilang:"as"},tr:{olarak:"as"},uk:{\u044F\u043A:"as"},vi:{nh\u01B0:"as"},zh:{\u4F5C\u4E3A:"as"}},jt={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 xr(t,e){let r=e.value.toLowerCase(),i=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||i==="of"||i==="source")return true;let a=t?.code?jt[t.code]:void 0;return !!a&&a.has(r)}var xo={destination:"in",source:"from"},So={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"])},Bo=new Set(["in","into","at","within","inside"]);function To(t,e){let r=e.value.toLowerCase();if((t?.code?So[t.code]:void 0)?.has(r))return "in";let a=e.normalized??e.value,n=a.toLowerCase();return Bo.has(n)?"in":xo[n]??a}var zr=new Set(["first","last","next","previous","random","closest"]),Fo={bn:{\u09B6\u09C7\u09B7:"last"}},Lr=new Set(Object.keys(ue).map(t=>t.toLowerCase()));function $t(t,e,r,i){let a=t[e];if(!a)return null;let n=(a.normalized??a.value).toLowerCase(),o=t[e+1],s=r?.code&&o?.kind==="selector"&&o.value.startsWith("<")?Fo[r.code]?.[a.value.toLowerCase()]:void 0;if(!zr.has(n)&&!zr.has(a.value.toLowerCase())&&s===void 0)return null;let u=[{text:s??a.normalized??a.value,token:a}],l=e+1,c=t[l];if(!c||c.kind!=="selector")return null;u.push({text:c.value,token:c}),l++;let m=0;for(;m++<8;){let f=t[l];if(f&&f.kind==="selector"&&f.value.startsWith("."))u.push({text:f.value,token:f}),l++;else break}let d=t[l],p=t[l+1];return d&&p&&p.kind==="selector"&&(d.kind==="keyword"||d.kind==="particle"||d.kind==="identifier")&&!zr.has((d.normalized??d.value).toLowerCase())&&!Lr.has((d.normalized??d.value).toLowerCase())&&!(i?.(d)===true&&i(t[l+2])!==true)&&(u.push({text:To(r,d),token:d}),u.push({text:p.value,token:p}),l+=2),{parts:u,consumed:l-e}}function Ro(t,e){let r=Ao[t];return r?r[e.toLowerCase()]??e:e}function fe(t,e){let r=Nr[t];return r?r[e.toLowerCase()]??e:e}function Oo(t,e){return Nr[t]?.[e.toLowerCase()]!==void 0}function Po(t,e){let r=[e.value,e.normalized].filter(Boolean);for(let i of r){let a=pe(t,i)??pe(t,i.toLowerCase());if(a)return a}}function Vt(t){return t.kind==="literal"||t.kind==="operator"||t.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(t.value)}function _o(t,e){let r=t?.references;if(!r)return false;let i=Object.values(r).filter(n=>typeof n=="string").map(n=>n.toLowerCase());return [e.value,e.normalized].filter(Boolean).some(n=>i.includes(n.toLowerCase()))}function lt(t,e){return Vt(t)?fe(e,t.value)!==t.value?true:t.kind==="identifier":false}var No={ar:{\u0647\u0648:{beforePredicate:"is"}},hi:{\u0939\u0948:{beforePredicate:"is"},\u0928\u0939\u0940\u0902:{beforeBareIdentifier:"no"}},th:{\u0E40\u0E1B\u0E47\u0E19:{beforeTypeName:"as",beforePredicate:"is"}},ja:{\u7A7A:{afterCopula:"empty"}},zh:{\u6CA1\u6709:{beforeBareIdentifier:"no"}},tl:{walang:{beforeBareIdentifier:"no"},may:{afterSubject:"exists"}},bn:{\u0986\u099B\u09C7:{afterSubject:"exists"}},tr:{var:{afterSubject:"exists"}}},Lo=new Set(["empty","null","undefined","true","false"]),Wt=new Set(["Number","Int","Float","String","Date","Array","Object","JSON","json","FormData","HTML","Fragment","Values"]);function Mo(t,e,r,i){let a=No[t],n=a?.[e.value]??a?.[e.value.toLowerCase()];if(n){if(n.beforeTypeName&&i?.kind==="identifier"&&Wt.has(i.value))return n.beforeTypeName;if(n.beforePredicate&&i&&(i.kind==="literal"||i.kind==="keyword"&&Lo.has((i.normalized??"").toLowerCase())))return n.beforePredicate;if(n.beforeBareIdentifier&&i?.kind==="identifier"&&/^[A-Za-z_]\w*$/.test(i.value))return n.beforeBareIdentifier;if(n.afterSubject&&(r?.kind==="selector"||r?.kind==="reference"))return n.afterSubject;if(n.afterCopula&&r?.kind==="keyword"&&(r.normalized??"").toLowerCase()==="is")return n.afterCopula}}function Oe(t,e){let r=e?.code??"en",i="",a,n=(s,u)=>{if(a===void 0){i=s,a=u;return}let c=a.position?.end!==void 0&&u.position?.start!==void 0&&a.position.end===u.position.start&&(s.startsWith(".")||s.startsWith("!"));i+=(c?"":" ")+s,a=u;},o=s=>s.kind==="keyword"?s.normalized??s.value:s.value;for(let s=0;s<t.length;s++){let u=t[s],l=e?Po(e,u):void 0,c=t[s+1];if(u.value==="'"&&a!==void 0&&c?.value==="s"&&u.position?.end!==void 0&&c.position?.start===u.position.end){i+="'s",a=c;let v=t[s+2];v&&fe(r,v.value)!==v.value?(n(fe(r,v.value),v),s+=2):s+=1;continue}if(l!==void 0&&c){let v=e?.possessive?.connectors,E=!!v?.length&&v.some(k=>{let A=k.toLowerCase();return A===c.value.toLowerCase()||A===(c.normalized??"").toLowerCase()}),y=E?s+2:s+1,h=t[y];if(h&&lt(h,r)){n(gr(l),u),n(fe(r,h.value),h),s=y;continue}if(E&&h&&/^\.[a-zA-Z_]\w*$/.test(h.value)&&c.position?.end!==void 0&&h.position?.start!==void 0&&c.position.end===h.position.start){n(gr(l),u),n(fe(r,h.value.slice(1)),h),s=y;continue}if(!E&&/^\.[a-zA-Z_]\w*$/.test(c.value)&&u.position?.end!==void 0&&c.position?.start!==void 0&&u.position.end===c.position.start&&!_o(e,u)){n(gr(l),u),n(fe(r,c.value.slice(1)),c),s+=1;continue}}let m=t[s+2];if(c&&m&&m.kind==="selector"&&xr(e,c)&&Vt(u)){n(fe(r,u.value),u),n("of",c),n(m.value,m),s+=2;continue}if(u.kind==="selector"&&c&&m&&xr(e,c)&&lt(m,r)&&fe(r,m.value)!==m.value){n(fe(r,m.value),m),n("of",c),n(u.value,u),s+=2;continue}let d=$t(t,s,e);if(d){for(let v of d.parts)n(v.text,v.token);s+=d.consumed-1;continue}let p=Mo(r,u,t[s-1],c);if(p!==void 0){n(p,u);continue}let f=Ro(r,u.value);if(f!==u.value){n(f,u);continue}n(o(u),u);}return i.trim()}var qt=[{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 ct(t,e,r,i){let a=qt.find(o=>o.lang===t);if(!a)return false;let n=(o,s)=>(o??"").toLowerCase()===s.toLowerCase();return n(e,a.end)&&n(r,a.at)&&n(i,a.of)}function Io(t,e){let r=qt.find(a=>a.lang===t);if(!r)return false;let i=e.toLowerCase();return i===r.at.toLowerCase()||i===r.of.toLowerCase()||i===r.end.toLowerCase()}var Kt={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 jo(t){return Kt[t]}function mt(t,e){return Kt[e]?.has(t.toLowerCase())??false}var Ht=96,$o=/^[A-Za-z_][\w-]*$/,Vo=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function Ut(t,e){let r=t.peek(e);return !!r&&r.kind==="identifier"&&Vo.test(r.value)}function Gt(t,e){let r=t.peek(e);if(!r||r.kind!=="identifier"&&r.kind!=="keyword"||!$o.test(r.value))return false;let i=t.peek(e+1),a=t.peek(e+2);return !!i&&i.value===":"&&!!a}function dt(t,e=0){return Ut(t,e)||Gt(t,e)}function Wo(t){let e=t.peek();if(!e||e.value!=="{"&&e.value!=="(")return null;let r="",i=-1,a=0,n=0;for(;!t.isAtEnd()&&n++<Ht;){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==="(")a++;else if((o.value==="}"||o.value===")")&&(a--,a===0))return r}return null}function pt(t){let e=t.peek();return e?e.value==="{"||e.value==="("?Wo(t):e.value===","||e.value===":"?null:(t.advance(),e.value):null}function Ge(t,e){let r=t.mark(),i=[];if(e!==void 0){let n=t.peek();if(!n||n.value!==":"||!t.peek(1))return null;t.advance();let o=pt(t);if(o===null)return t.reset(r),null;i.push(`${e}:${o}`);}else if(!dt(t))return null;let a=0;for(;a++<Ht;){let n=t.peek();if(!n)break;if(n.value===","){if(i.length===0||!dt(t,1))break;t.advance();continue}if(Ut(t,0)){i.push(t.advance().value);continue}if(!Gt(t,0))break;let o=t.advance().value;t.advance();let s=pt(t);if(s===null)return t.reset(r),null;i.push(`${o}:${s}`);}return i.length===0?(t.reset(r),null):`{${i.join(", ")}}`}var sr=.8,qo=.6,Ko=.15,Ho=.5,ft=.15,yt=.1,ht=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"]),Uo={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"]},Go=class{calculate(t){return this.calculateWithBreakdown(t).final}calculateWithBreakdown(t){let e=this.scoreRoleCoverage(t),r=this.scoreStemPenalty(t),i=this.scoreLanguageBoost(t),a=this.scoreLanguageAdjustment(t),n=e;return n=Math.max(Ho,n+r),n=Math.min(1,n+i),n=Math.max(0,Math.min(1,n+a)),{roleCoverage:e,stemPenalty:r,languageBoost:i,languageAdjustment:a,final:n}}scoreRoleCoverage(t){let{pattern:e,captured:r}=t,i=0,a=0,n=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)?(a+=1,i+=1):u(l.role)||(a+=1);else if(l.type==="group")for(let c of l.tokens)c.type==="role"&&(r.has(c.role)?(a+=sr,i+=sr):u(c.role)||(a+=sr,n(c.role)&&(i+=sr*qo)));return a>0?i/a:1}scoreStemPenalty(t){let{stemMatchCount:e,totalKeywordMatches:r}=t;return e<=0||r<=0?0:-(e/r)*Ko}scoreLanguageBoost(t){let{pattern:e}=t;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:ht.has(r.value)||r.alternatives?.some(i=>ht.has(i))?ft:0}scoreLanguageAdjustment(t){let{pattern:e,captured:r}=t;if(e.language!=="ar")return 0;let i=0;for(let[a,n]of r.entries()){let o=Uo[a];if(!o||o.length===0)continue;let s="metadata"in n?n.metadata:void 0;s&&typeof s.prepositionValue=="string"&&(o.includes(s.prepositionValue)?i+=.1:i-=.1);}return Math.max(-yt,Math.min(yt,i))}},Zo=new Go,Yo=new Set(Object.values(ue).filter(t=>t.bareKeyword===true).map(t=>t.action));function Xo(t){return t.startsWith("*")||t.startsWith("@")}var J=class L{constructor(e){this.matchCache=new Map,this.roleStarts=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Zo;}matchPattern(e,r){let i=e.mark(),a=new Map;if(this.currentProfile=P(r.language),this.currentPatternCommand=r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,this.roleStarts=new Map,!this.matchTokenSequence(e,r.template.tokens,a))return e.reset(i),null;let o=this.confidenceModel.calculate({pattern:r,captured:a,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-i.position,confidence:o,roleStarts:this.roleStarts}}matchBest(e,r){this.matchCache.clear();let i=[],a=e.position();for(let o of r){let s=e.mark(),u=`${a}:${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 n=i[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,i,a){let n=r[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 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),this.shouldTrySkippingVerbSlot(l,e,r[u+1]??a)){let m=e.mark(),d=new Map(i);if(this.matchTokenSequence(e,r.slice(u+1),d,a)&&this.atClauseEnd(e)){i.clear();for(let[p,f]of d)i.set(p,f);return true}e.reset(m);}let c=this.matchPatternToken(e,l,i,r[u+1]??a);if(s=l.type==="role"&&l.role==="event"?2:Math.max(0,s-1),!c){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,i){if(r.has("source"))return;let a=e.peek(),n=e.peek(1);if(!a||!n||this.patternTokenWouldMatch(i,a))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(m=>m.toLowerCase()===c)},u=o?.position;if(u!=="after"&&s(a)&&n.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(u==="after"&&a.kind==="selector"&&s(n)){let l=this.tokenToSemanticValue(a);e.advance(),e.advance(),l&&r.set("source",l);}}matchPatternToken(e,r,i,a){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":{let n=e.position(),o=this.matchRoleToken(e,r,i,a);return o&&i.has(r.role)&&this.roleStarts.set(r.role,n),o}case "group":return this.matchGroupToken(e,r,i,a);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(!i)return false;let a=this.getMatchType(i,r.value);if(a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let o=this.getMatchType(i,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let n of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(n.includes(o)&&this.tryMatchShatteredCompound(e,n,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let i=e.mark(),a=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;a.push(o.value),e.advance();let s=e.peek();if(!s||s.value!=="-")break;e.advance(),a.push("-");}if(a.length<3||a[a.length-1]==="-")return e.reset(i),null;let n=a.join("").toLowerCase();for(let[o,s]of Object.entries(r.keywords))if(s.primary.toLowerCase()===n||s.alternatives?.some(u=>u.toLowerCase()===n))return q(o);return e.reset(i),null}tryMatchShatteredCompound(e,r,i){let a=r.split(i);if(a.length<2||a.some(o=>o.length===0))return false;let n=e.mark();for(let o=0;o<a.length;o++){if(o>0){let u=e.peek();if(!u||u.value!==i)return e.reset(n),false;e.advance();}let s=e.peek();if(!s||s.kind!=="identifier"&&s.kind!=="keyword"&&s.kind!=="particle"||s.value.toLowerCase()!==a[o].toLowerCase())return e.reset(n),false;e.advance();}return true}matchRoleToken(e,r,i,a){let n=e.position(),o=i.get(r.role);return this.matchRoleTokenCore(e,r,i,a)?(this.absorbTrailingConversion(e,r,i,a,n),this.absorbTrailingConditionOperand(e,r,i,a,n),this.stampCaptureSpan(e,r.role,i,n,o),true):false}stampCaptureSpan(e,r,i,a,n){let o=i.get(r);if(!o||o===n||o.position||e.position()<=a)return;let s=e.tokens[a],u=e.tokens[e.position()-1];!s||!u||i.set(r,go(o,{start:s.position.start,end:u.position.end}));}absorbTrailingConditionOperand(e,r,i,a,n){if(r.role!=="condition"||!i.has("condition")||e.position()<=n||a!==void 0||this.currentPatternCommand!=="on")return;let o=e.peek();if(!o)return;let s=L.CONDITION_OPERATOR_WORDS;if(!s.has((o.normalized??"").toLowerCase())&&!s.has(o.value.toLowerCase())||this.patternTokenWouldMatch(a,o))return;e.advance();let u=e.peek();u&&(u.kind==="selector"||u.kind==="identifier"||u.kind==="literal")&&!Lr.has((u.normalized??u.value).toLowerCase())&&e.advance();let l=Oe(e.tokens.slice(n,e.position()),this.currentProfile);i.set("condition",{type:"expression",raw:l,value:l});}conversionRunLength(e){let r=e.peek();if(!r||(r.normalized??r.value).toLowerCase()!=="as"&&r.value.toLowerCase()!=="as")return 0;let a=e.peek(1);return !a||!Wt.has(a.value)?0:2}absorbTrailingConversion(e,r,i,a,n){if(r.role==="event"||r.role==="action"||!i.has(r.role)||e.position()<=n||this.conversionRunLength(e)!==2||this.patternTokenWouldMatch(a,e.peek()))return;e.advance(),e.advance();let o=Oe(e.tokens.slice(n,e.position()),this.currentProfile);i.set(r.role,{type:"expression",raw:o,value:o});}matchRoleTokenCore(e,r,i,a){this.skipNoiseWords(e);let n=e.peek();if(!n)return r.optional||false;if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let y=this.tryFoldHyphenActionKeyword(e);if(y)return i.set(r.role,y),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!L.tokenLooksLikeEvent(n))return r.optional||false;let y=(n.normalized??n.value).toLowerCase();if(L.POSITIONAL_OR_SCOPE_KEYWORDS.has(y)||this.currentProfile&&(pe(this.currentProfile,n.value)??pe(this.currentProfile,y))!==void 0||n.value.includes("?."))return r.optional||false}if(r.role==="event"){let y=(n.normalized??n.value).toLowerCase();if(L.STRUCTURAL_NEVER_EVENT.has(y))return r.optional||false}if(n.kind==="keyword"){let y=(n.normalized??n.value).toLowerCase();if(y==="then"||y==="end"&&e.peek(1)?.kind!=="selector"||mt(n.value,this.currentProfile?.code??"")||(r.role==="quantity"||r.role==="event"&&this.currentPatternCommand==="repeat")&&(n.normalized??n.value).toLowerCase()in ue)return r.optional||false}if(r.role==="duration"){let y=(n.normalized??n.value).toLowerCase();if(L.POSITIONAL_OR_SCOPE_KEYWORDS.has(y))return r.optional||false}if(r.optional&&r.role!=="event"&&r.role!=="action"&&r.valueShape!=="keyword"&&n.kind==="keyword"&&(n.normalized??n.value).toLowerCase()in ue&&(a===void 0||this.patternTokenWouldMatch(a,n)))return true;let o=this.tryMatchPositionalExpression(e,a);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!or(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let s=this.tryMatchCaretScopeExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!or(s.type,r.expectedTypes)?r.optional||false:(i.set(r.role,s),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let y=this.tryMatchBeepPrefixExpression(e);if(y)return i.set(r.role,y),true;let h=this.tryMatchHyphenatedWord(e);if(h)return i.set(r.role,h),true;let k=this.tryMatchOperatorRunExpression(e);if(k)return i.set(r.role,k),true}if(this.currentPatternCommand==="pick"&&r.role==="patient"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let y=this.tryMatchPickRangeExpression(e);if(y)return i.set(r.role,y),true}if(r.expectedTypes?.includes("property-path")){let y=this.tryMatchOfPossessiveExpression(e);if(y)return i.set(r.role,y),true;let h=this.tryMatchPostNominalPossessiveExpression(e);if(h)return i.set(r.role,h),true}let u=this.tryMatchPossessiveExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(u.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,u),true);let l=this.tryMatchMethodCallExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(l.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,l),true);let m=r.role==="event"&&this.currentPatternCommand==="on"||L.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(m)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(m.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,m),true);let d=this.tryMatchPossessiveSelectorExpression(e);if(d)return r.expectedTypes&&r.expectedTypes.length>0&&!or(d.type,r.expectedTypes)?r.optional||false:(i.set(r.role,d),true);let p=r.role!=="condition",f=this.tryMatchPropertyAccessExpression(e,p);if(f)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(f.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,f),true);let v=this.tryMatchSelectorPropertyExpression(e);if(v)return r.expectedTypes&&r.expectedTypes.length>0&&!or(v.type,r.expectedTypes)?r.optional||false:(i.set(r.role,v),true);if(n.kind==="identifier"&&n.value==="{"){let y=r.expectedTypes,k=y?.length===1&&y[0]==="expression"?this.tryMatchBraceRunExpression(e):!y?.length||y.includes("literal")?this.tryMatchBraceRunLiteral(e):null;if(k)return i.set(r.role,k),true}if(r.role==="style"&&r.expectedTypes?.length===1&&r.expectedTypes[0]==="expression"){let y=Ge(e);if(y)return i.set(r.role,{type:"expression",raw:y}),true}let E=this.tokenToSemanticValue(n);if(!E)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(E.type)){let y=E.type==="selector"&&String(E.value).startsWith("@"),h=r.expectedTypes.some(k=>k==="expression"||k==="reference");if(!(y&&h))return r.optional||false}if(r.valueShape==="keyword"&&E.type==="expression"?i.set(r.role,q(String(E.raw??""))):i.set(r.role,E),e.advance(),r.role==="event"){let y=e.peek();y&&y.kind==="selector"&&y.value.startsWith("[")&&"value"in E&&(i.set(r.role,q(`${String(E.value)}${y.value}`)),e.advance());let h=e.peek();if(h&&(h.kind==="particle"||h.kind==="keyword")&&(h.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(a,h)){let k=e.peek(1);if(k&&(k.kind==="selector"||k.kind==="identifier")){e.advance();let A=this.tokenToSemanticValue(e.advance());A&&!i.has("source")&&i.set("source",A);}}}return true}shouldTrySkippingVerbSlot(e,r,i){let a=e.type==="group"&&e.optional?e.tokens.every(s=>s.type==="role")?e.tokens[0]:void 0:e;if(!a||a.type!=="role"||!a.optional||a.role==="event"||a.role==="action"||a.valueShape==="keyword")return false;let n=r.peek();if(!n||n.kind!=="keyword"||i===void 0)return false;let o=this.patternTokenWouldMatch(i,n);return (n.normalized??n.value).toLowerCase()in ue?!o:o}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:mt(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=$t(e.tokens,e.position(),this.currentProfile,a=>a===void 0?false:this.patternTokenWouldMatch(r,a));if(!i)return null;for(let a=0;a<i.consumed;a++)e.advance();return {type:"expression",raw:i.parts.map(a=>a.text).join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let i=e.peek(1),a=e.peek(2),n=(i?.normalized??"").toLowerCase(),o=!!i&&(i.value.toLowerCase()==="on"||n==="destination"||n==="on");return !i||!a||a.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${a.value}`})}isOfPossessiveMarker(e){return xr(this.currentProfile,e)}static isBareWordToken(e){return !!e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.value)}static tokensAdjacent(e,r){return e?.position?.end!==void 0&&r?.position?.start!==void 0&&e.position.end===r.position.start}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 n=e.mark(),o=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(n),null;for(;;){let u=e.peek();if(!u||!L.RUN_OPERATORS.has(u.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(l);break}}let s=Oe(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:s,value:s}}tryMatchHyphenatedWord(e){let r=e.peek();if(!L.isBareWordToken(r))return null;let i=1,a=[r.value];for(;;){let n=e.peek(i),o=e.peek(i+1);if(!n||n.value!=="-"||!L.isBareWordToken(o)||!L.tokensAdjacent(e.peek(i-1),n)||!L.tokensAdjacent(n,o))break;a.push(o.value),i+=2;}if(a.length<2)return null;for(let n=0;n<i;n++)e.advance();return q(a.join("-"),"string")}tryMatchOperatorRunExpression(e){let r=e.mark(),i=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let a=1;for(;;){let o=e.peek();if(!o||!L.RUN_OPERATORS.has(o.value))break;let s=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(s);break}a++;}if(a<2)return e.reset(r),null;let n=Oe(e.tokens.slice(i,e.position()),this.currentProfile);return {type:"expression",raw:n,value:n}}static rangeSeparatorFor(e){let[r]=L.PICK_RANGE_SEPARATORS_BY_LANG[e]??[];return r}isPickRangeSeparator(e){let r=(e.normalized??e.value).toLowerCase();if(L.PICK_RANGE_SEPARATORS.has(r))return true;let i=this.currentProfile?.code;return i?L.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 a=e.peek();if(!a||!this.isPickRangeSeparator(a)||(e.advance(),!this.tryConsumePickRangeOperand(e)))return e.reset(r),null;let n=e.peek();n&&L.PICK_RANGE_MODES.has((n.normalized??n.value).toLowerCase())&&e.advance();let o=e.tokens.slice(i,e.position()),[s,,u,l]=o,c=d=>d.kind==="keyword"?d.normalized??d.value:d.value,m=`${c(s)} to ${c(u)}`;return l&&(m+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:m,value:m}}tryConsumePickRangeOperand(e){let r=e.peek();if(!r)return false;let i=(r.normalized??r.value).toLowerCase();if(this.isPickRangeSeparator(r))return false;let a=i==="start"||i==="end";return r.kind==="literal"||r.kind==="identifier"||r.kind==="keyword"&&a?(e.advance(),true):false}tryConsumeRunOperand(e){let r=e.peek();if(!r)return false;if(r.value==="("){let i=e.mark(),a=0;for(;!e.isAtEnd();){let n=e.advance();if(n.value==="(")a++;else if(n.value===")"&&(a--,a===0))return true}return e.reset(i),false}return this.tryMatchPossessiveExpression(e)?true:(r.kind==="literal"||r.kind==="identifier"||r.kind==="selector"||r.kind==="keyword")&&!L.RUN_OPERATORS.has(r.value)&&r.value!==")"?(e.advance(),true):false}isPossessorToken(e){if(!this.currentProfile)return false;for(let r of [e.value,e.normalized].filter(Boolean))if(pe(this.currentProfile,r)??pe(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?fe(this.currentProfile.code,e):e}tryMatchOfPossessiveExpression(e){let r=e.peek();if(!r||r.kind!=="selector"&&!this.isBareWordPropertyHead(r))return null;let i=e.mark();e.advance();let a=e.peek();if(!a||!this.isOfPossessiveMarker(a))return e.reset(i),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"||Xo(n.value)?(e.reset(i),null):(e.advance(),be(ke(n.value),this.toEnglishProperty(r.value),"possessive"))}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=[r.value,r.normalized].filter(Boolean),a;for(let u of i)if(a=pe(this.currentProfile,u)??pe(this.currentProfile,u.toLowerCase()),a)break;if(!a)return null;let n=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(m=>m.toLowerCase()===l||m.toLowerCase()===c)&&e.advance();}}let s=e.peek();if(!s||Io(this.currentProfile.code,s.value))return e.reset(n),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&&L.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 m=e.peek();if(m?.kind==="selector"&&m.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(m.value)){l+=m.value,e.advance();continue}if(m?.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 m="",d=0,p=0;for(;!e.isAtEnd()&&p++<L.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;m+=f.value,e.advance();for(let v of f.value)v==="("?d++:v===")"&&d--;if(d<=0)break}l+=m;}return be(se(a),l,"possessive")}return e.reset(n),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 n=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(n),null;let l;for(let c of [u.value,u.normalized].filter(Boolean))if(l=pe(this.currentProfile,c)??pe(this.currentProfile,c.toLowerCase()),l)break;return l?(e.advance(),be(se(l),s,"possessive")):(e.reset(n),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())}isRoleMarkerConcept(e){return It.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&&Yo.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 a=["{"],n=1,o=0;for(;!e.isAtEnd()&&o++<L.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(s.value==="{")n++;else if(s.value==="}"&&(n--,n===0))return a.push("}"),q(a.join(" "));a.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(),a="",n=-1,o=0,s=0;for(;!e.isAtEnd()&&s++<L.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(n>=0&&u.position.start>n&&(a+=" ".repeat(u.position.start-n)),a+=u.value,n=u.position.end,u.value==="{")o++;else if(u.value==="}"&&(o--,o===0))return {type:"expression",raw:a}}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 a=e.mark();e.advance();let n=e.advance(),o="",s=n.position?.end,u=false,l=0;for(;!e.isAtEnd()&&l++<L.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),u=true;break}let m=s!==void 0&&c.position?.start===s;o+=(o===""||m?"":" ")+c.value,s=c.position?.end,e.advance();}return u?{type:"expression",raw:`${r.value}(${o})`}:(e.reset(a),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(i),null;e.advance();let n=e.peek();if(!n||n.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<L.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}.${n.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e,r=true){let i=e.peek();if(!i||i.kind!=="identifier"&&i.kind!=="keyword")return null;let a=e.mark();e.advance();let n=i.value.toLowerCase(),o=e.peek();if((i.kind==="identifier"||L.PROPERTY_ACCESS_BASES.has(n))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let p=i.value,f=[],v=0;for(;v<L.MAX_PROPERTY_DEPTH;){let h=e.peek();if(h&&h.kind==="selector"&&/^\.[a-zA-Z_]/.test(h.value))p+=`.${h.value.slice(1)}`,f.push(h.value.slice(1)),e.advance(),v++;else break}let E=e.peek(),y=!!E&&E.value.startsWith("(");if(r&&!y&&f.length>0&&Fe(n))return be(se(n),f.join("."),"dot");if(y){let h=e.mark(),k=[],A=0,D=false;for(;!e.isAtEnd();){let C=e.peek();if(!C)break;if(C.value==="(")A++;else if(C.value===")"){if(k.push(C.value),e.advance(),A--,A===0&&(D=true),D)break;continue}k.push(C.value),e.advance();}D?p+=k.join(""):e.reset(h);}return {type:"expression",raw:p}}let s=e.peek();if(!s||s.kind!=="operator"||s.value!==".")return e.reset(a),null;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")return e.reset(a),null;e.advance();let l=`${i.value}.${u.value}`,c=1;for(;!e.isAtEnd()&&c<L.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 m=e.peek();if(m&&m.kind==="punctuation"&&m.value==="("){e.advance();let p=[],f=0;for(;!e.isAtEnd()&&p.length<L.MAX_METHOD_ARGS;){let E=e.peek();if(!E)break;if(E.kind==="punctuation"&&E.value===")"){if(f===0){e.advance();break}f--;}if(E.kind==="punctuation"&&E.value==="("&&f++,E.kind==="punctuation"&&E.value===","){e.advance();continue}p.push(E.value),e.advance();}return {type:"expression",raw:`${l}(${p.join(", ")})`}}let d=i.value.toLowerCase();if(r&&Fe(d)){let p=l.split(".").slice(1).join(".");return be(se(d),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 a=e.peek(),n=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!a&&a.kind==="punctuation"&&a.value==="'s",s=!!a&&a.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",u=(()=>{if(!this.currentPatternCommand||(a?.normalized??"").toLowerCase()!=="source")return false;let f=ue[this.currentPatternCommand];return !!f&&f.roles.some(v=>v.role==="source")})(),l=!!a&&!!n&&n!=="'s"&&a.value===n&&(a.kind==="particle"||a.kind==="punctuation"||a.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 m=c.kind==="selector"&&c.value.startsWith("*"),d=c.kind==="keyword"&&!!this.currentProfile&&Oo(this.currentProfile.code,c.value);return c.kind==="identifier"||m||d||(o||s)&&(c.kind==="selector"||c.kind==="keyword")?(e.advance(),be(ke(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 a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(i),null;let n=e.peek(1);n&&n.kind,e.advance();let o=a.value.slice(1);return be(ke(r.value),o,"dot")}matchGroupToken(e,r,i,a){let n=e.mark(),o=new Map(i),s=this.matchTokenSequence(e,r.tokens,i,a);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(n.position,e.position()).some(d=>u.some(p=>this.getMatchType(d,p)!=="none"))||(s=false));}if(!s){e.reset(n);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=ar(e.value).toLowerCase();if(i&&i===ar(r).toLowerCase())return "case-insensitive"}return "none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return ke(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Fe(r)?se(r):q(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return ke(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return se(e.value);let i=e.value.toLowerCase();return Fe(i)?se(i):{type:"expression",raw:e.value};case "url":return q(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return q(a,"string")}if(e==="true")return q(true,"boolean");if(e==="false")return q(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?q(e,"duration"):q(a,"number")}let i=parseFloat(e);return isNaN(i)?q(e,"string"):q(i,"number")}applyExtractionRules(e,r){for(let[i,a]of Object.entries(e.extraction)){let n=r.get(i);if(n){if(a.transform){let o=n.type==="literal"?String(n.value):String(n.raw??"");r.set(i,a.transform(o));}}else a.value!==void 0?r.set(i,{type:"literal",value:a.value}):a.default&&r.set(i,{...a.default,implicit:true});}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=r.value.toLowerCase();if(L.ENGLISH_NOISE_WORDS.has(i)){let a=e.mark();e.advance();let n=e.peek();if(n&&(n.kind==="selector"||n.kind==="identifier"))return;let o=e.peek(1);if(n&&n.kind==="keyword"&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value))return;let s=n?(n.normalized??n.value).toLowerCase():"";if(n&&L.POSITIONAL_OR_SCOPE_KEYWORDS.has(s))return;let u=e.peek(1),l=u?(u.normalized??u.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&L.COMMAND_ACTION_KEYWORDS.has(l),m=!u||u.kind==="particle"||L.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(n&&n.kind==="keyword"&&this.currentProfile?.code!=="en"&&Fe(s)&&m||n&&n.kind==="keyword"&&this.currentProfile?.code==="en"&&Fe(s))return;e.reset(a);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(i=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return i?r:void 0}};J.CONDITION_OPERATOR_WORDS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);J.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);J.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then","while"]);J.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);J.COMMAND_ACTION_KEYWORDS=Lr;J.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);J.RUN_OPERATORS=new Set(["+","-","*","/"]);J.PICK_RANGE_SEPARATORS=new Set(["to"]);J.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"])};J.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);J.MAX_BRACE_RUN_TOKENS=64;J.MAX_PROPERTY_DEPTH=10;J.MAX_METHOD_ARGS=20;J.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);J.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Zt=J,oe=new Zt;function Z(t,e){return Hn(t,e)}function Yt(){return Kn()}var Xt={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"])},Jo=new Set(Object.values(Xt).flatMap(t=>[...t]));function Sr(t,e){let r=(t.normalized??t.value).toLowerCase();if(r==="or")return true;let i=e===void 0?Jo:Xt[e];return i?i.has(t.value)||i.has(r):false}var Ie=["if","unless","repeat","for","while"],lr=/^[A-Z][A-Za-z0-9_]*$/;function K(t,e){let r=new Set([e]),a=P(t)?.keywords?.[e];if(a){a.primary&&r.add(a.primary.toLowerCase());for(let n of a.alternatives??[])r.add(n.toLowerCase());}return r}function $(t,e){return e.has(t.value.toLowerCase())?true:t.normalized?e.has(t.normalized.toLowerCase()):false}var Qo=new Set(Ie);function Xe(t,e){let r=t.normalized?.toLowerCase();return r?Qo.has(r):e.some(i=>$(t,i))}var vt=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),es=new Set(["destination","source","style","patient","on","from","to"]);function Ze(t){if(!t||t.kind==="selector")return false;let e=(t.normalized??t.value).toLowerCase(),r=t.value.toLowerCase();return !(vt.has(e)||vt.has(r)||es.has(e))}var Et=new Set(["ja","ko"]);function Ne(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 Jt(t,e){let r=[],i=e.position.end,a=t.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(a){i=e.position.end+a[0].length;for(let n of a[1].split(/[,\u060c\u3001]/)){let o=n.trim();o&&r.push(o);}}return {parameters:r,headerEnd:i}}function cr(t,e,r){let i=e+1;if(i>=t.length)return -1;let a=Ne(P(r)?.roleMarkers?.patient);return a.size>0&&$(t[i],a)&&i++,i<t.length?i:-1}var Qt=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function rs(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 ts(t,e,r){let i=P(r);if(i?.wordOrder!=="SOV"||!Qt.test(t[0].value)||e!==rs(t))return false;let a=Ne(i.roleMarkers?.patient);return a.size===0?false:$(t[e-1],a)}function is(t,e,r){if(!P(e))return null;let i=K(e,"behavior"),a=K(e,"def"),n=t.toLowerCase(),o=[...i].some(m=>n.includes(m)),s=/\bdef\b/.test(n)||[...a].some(m=>m!=="def"&&n.includes(m));if(!o&&!s)return null;let u=Z(t,e).tokens;if(u.length<2)return null;if($(u[0],i))return gt(t,e,u,r,0);let l=u.findIndex((m,d)=>d>0&&$(m,i));if(l>0&&lr.test(u[0].value))return gt(t,e,u,r,l);if($(u[0],a))return zt(t,e,u,r,0);let c=u.findIndex((m,d)=>d>0&&$(m,a));return c>0&&ts(u,c,e)?zt(t,e,u,r,c):null}function as(t,e,r){let i=P(e);if(!i)return null;let a=i.wordOrder!=="SOV",n=Et.has(e)?Ne(i.roleMarkers?.event):new Set,o=Et.has(e)?Ne(i.keywords?.on):new Set,s=n.size>0&&o.size>0,u=K(e,"end"),l=K(e,"on"),c=t.toLowerCase(),m=[...u].some(C=>c.includes(C)),d=(a||s)&&(()=>{let C=0;for(let g of l)if(g){for(let b=c.indexOf(g);b>=0;b=c.indexOf(g,b+g.length))if(++C>=2)return true}return false})();if(!m&&!d)return null;let p=Z(t,e).tokens;if(p.length<2)return null;let f=Ie.map(C=>K(e,C)),v=C=>Xe(C,f),E=C=>$(C,u),y=[],h=0,k=0;for(let C=0;C<p.length;C++){let g=p[C];if(E(g)){if(h>0){h--;continue}let b=t.slice(p[k].position.start,g.position.start).trim();b&&y.push(b),k=C+1;}else if(v(g))h++;else if(a&&h===0&&C>k&&$(g,l)&&Ze(p[C+1])){let b=t.slice(p[k].position.start,g.position.start).trim();b&&y.push(b),k=C;}else if(s&&h===0&&C-1>k&&$(g,n)&&p[C+1]!==void 0&&$(p[C+1],o)){let b=p[C-1],S=t.slice(p[k].position.start,b.position.start).trim();S&&y.push(S),k=C-1;}}if(k<p.length){let C=t.slice(p[k].position.start).trim();C&&y.push(C);}if(y.length<2)return null;let A=[],D=[];for(let C of y){let g;try{g=r.statement(C,e);}catch{return null}if(!g||g.kind!=="event-handler")return null;let b=g;if(A.push(b),!b.body||b.body.length===0)return null;D.push(b.metadata?.confidence??.75);}return Ue(A,"then",{sourceLanguage:e,confidence:Le(D),sourceText:t})}function Le(t){return t.length>0?t.reduce((e,r)=>e+r,0)/t.length:0}function mr(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 gt(t,e,r,i,a){let n=a>0,o=n?0:cr(r,a,e);if(o<0)return null;let s=r[o],u=s.value;if(!lr.test(u))return null;let{parameters:l,headerEnd:c}=Jt(t,s),m=n?a+1:r.findIndex(b=>b.position.start>=c);m<=o&&(m=o+1);let d=K(e,"init"),p=K(e,"end"),f=Ie.map(b=>K(e,b)),v=b=>Xe(b,f),E=b=>$(b,p),y=[],h=[],k=[],A=false,D=0,C=m;for(let b=m;b<r.length;b++){let S=r[b];if(E(S)){if(D>0){D--;continue}if(b===C){A=true;break}if($(r[C],d)){let z=t.slice(r[C].position.end,S.position.start).trim();if(z)try{let w=mr(i.body(z,e));h.push(...w),k.push(Le(w.map(x=>x.metadata?.confidence??.75)));}catch{k.push(0);}}else {let z=t.slice(r[C].position.start,S.position.start).trim();try{let w=i.statement(z,e);if(w&&w.kind==="event-handler"){let x=w;y.push(x);let R=!x.body||x.body.length===0;k.push(R?.2:x.metadata?.confidence??.75);}else k.push(0);}catch{k.push(0);}}C=b+1;}else v(S)&&D++;}if(y.length===0&&h.length===0)return null;let g=(A?1:.8)*Le(k);return zo(u,l,y,h.length>0?h:void 0,{sourceLanguage:e,confidence:g,sourceText:t})}function zt(t,e,r,i,a){let n=a>0,o=n?0:cr(r,a,e);if(o<0)return null;let s=r[o],u=s.value;if(!Qt.test(u))return null;let{parameters:l,headerEnd:c}=Jt(t,s),m=n?a+1:r.findIndex(g=>g.position.start>=c);m<=o&&(m=o+1);let d=K(e,"end"),p=Ie.map(g=>K(e,g)),f=g=>Xe(g,p),v=g=>$(g,d),E=0,y=-1;for(let g=m;g<r.length;g++)if(v(r[g])){if(E===0){y=g;break}E--;}else f(r[g])&&E++;let h=r[m]?.position.start??c,k=y>=0?r[y].position.start:t.length,A=t.slice(h,k).trim();if(!A)return null;let D;try{D=mr(i.body(A,e));}catch{return null}if(D.length===0)return null;let C=Le(D.map(g=>g.metadata?.confidence??.75));return y<0&&(C*=.8),ko(u,l,D,{sourceLanguage:e,confidence:C,sourceText:t})}var Br=["live","eventsource","socket","worker","intercept"],ns=new Set(["intercept"]),Mr=new Set(["eventsource","socket","worker"]),os=new Set(["eventsource","socket"]),ss=new Set(["worker"]),us=6,ls=2;function cs(t,e){for(let i of Br)if($(t[0],K(e,i)))return {action:i,keywordIdx:0};if(P(e)?.wordOrder!=="SOV")return null;let r=Math.min(t.length,us);for(let i=1;i<r;i++)for(let a of Br)if(a!=="live"&&$(t[i],K(e,a))&&!(Mr.has(a)&&!lr.test(t[0].value))&&!(a==="intercept"&&i>ls))return {action:a,keywordIdx:i};return null}function ms(t,e,r){let i=Ne(P(r)?.roleMarkers?.source);return i.size===0||e+1>=t.length?0:$(t[e],i)||$(t[e+1],i)?2:0}function ei(t){let e=K(t,"on");e.add("when");let r=P(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 ds(t,e,r){let i=P(r)?.eventHandler,a=[i?.eventMarker?.primary,...i?.eventMarker?.alternatives??[],...i?.temporalMarkers??[]].filter(o=>!!o&&/\s/.test(o)),n=1;for(let o of a){let s=o.toLowerCase().split(/\s+/),u=e-s.length+1;u<0||s.every((l,c)=>t[u+c]?.value.toLowerCase()===l)&&(n=Math.max(n,s.length));}return n}function ps(t,e,r,i,a){if(t==="live")return r+1;if(r>0){let l=r+1;return t==="eventsource"&&(l+=ms(e,l,i)),l}let n=cr(e,r,i);if(n<0)return -1;if(t==="worker")return n+1;let o=ei(i),s=Ne(P(i)?.roleMarkers?.event),u=a>=0?a:e.length;for(let l=n+1;l<u;l++){if(!$(e[l],o))continue;if(Ze(e[l+1]))return l;if(l>n+2&&s.size>0&&$(e[l-1],s)&&Ze(e[l-2]))return l-2;let c=ds(e,l,i);if(c>1&&l-c>n&&Ze(e[l-c]))return l-c;if(l>n+1&&Ze(e[l-1]))return l-1}return u}function fs(t,e,r,i){if(!Mr.has(t))return;let a=r>0?0:cr(e,r,i);if(!(a<0))return e[a].value}function ys(t,e,r){if(!P(e))return null;let i=t.toLowerCase(),a=false;for(let u of [...Br,"changes"]){for(let l of K(e,u))if(l&&i.includes(l)){a=true;break}if(a)break}if(!a)return null;let n=Z(t,e).tokens;if(n.length<2)return null;let o=gs(n,e);if(o>=0)return ks(t,e,n,r,o);let s=cs(n,e);return s?hs(t,e,n,r,s.action,s.keywordIdx):null}function hs(t,e,r,i,a,n){let o=K(e,"end"),s=Ie.map(A=>K(e,A)),u=A=>Xe(A,s),l=A=>$(A,o),c=fs(a,r,n,e);if(Mr.has(a)&&(!c||!lr.test(c)))return null;let m=A=>({sourceLanguage:e,confidence:A,sourceText:t}),d=Tr(r,n+1,l,u);if(ns.has(a))return d>=0&&d!==r.length-1?null:Dr(a,[],c,m(d>=0?1:.8));let p=ps(a,r,n,e,d);if(p<0||p>r.length)return null;let f=[],v=[],E=false,y=ss.has(a);if(y||os.has(a)){let A=y?"def":"event-handler",D=0,C=p;for(let g=p;g<r.length;g++){let b=r[g];if(l(b)){if(D>0){D--;continue}if(E=true,g===C)break;let S=y?b.position.end:b.position.start,z=t.slice(r[C].position.start,S).trim();try{let w=i.statement(z,e);if(w&&w.kind===A){let x=w;f.push(x);let R=!x.body||x.body.length===0;v.push(R?.2:x.metadata?.confidence??.75);}else v.push(0);}catch{v.push(0);}C=g+1;}else u(b)&&D++;}}else {let A=Tr(r,p,l,u);E=A>=0;let D=A>=0?r[A].position.start:t.length,C=t.slice(r[p].position.start,D).trim();if(!C)return null;try{f.push(...mr(i.body(C,e)));}catch{return null}if(f.length===0)return null;v.push(...f.map(g=>g.metadata?.confidence??.75));}if(f.length===0&&!E)return null;let h=E?1:.8,k=v.length>0?h*Le(v):h;return Dr(a,f,c,m(k))}var vs=new Set([...Object.keys(ue),"then","else"]);function Es(t){let e=K(t,"when");for(let r of ei(t))e.add(r);return e}function gs(t,e){if(t.length<3||!$(t[0],Es(e)))return -1;let r=K(e,"changes"),i=K(e,"end");for(let a=2;a<t.length;a++){let n=t[a];if(n.kind==="literal")continue;if($(n,r))return a;if($(n,i))return -1;let o=(n.normalized??n.value).toLowerCase();if(n.kind==="keyword"&&vs.has(o))return -1}return -1}function zs(t,e,r){if(r==="en"){let a=e[0],n=e[e.length-1];return {type:"expression",raw:t.slice(a.position.start,n.position.end).trim()}}let i=e.map(a=>Sr(a,r)?{...a,kind:"keyword",normalized:"or"}:a);return {type:"expression",raw:Oe(i,P(r))}}function ks(t,e,r,i,a){let n=K(e,"end"),o=Ie.map(h=>K(e,h)),s=h=>Xe(h,o),u=h=>$(h,n),l=a+1;if(l>=r.length)return null;let c=Tr(r,l,u,s),m=c>=0;if(m&&c!==r.length-1)return null;let d=m?r[c].position.start:t.length,p=t.slice(r[l].position.start,d).trim();if(!p)return null;let f;try{f=mr(i.body(p,e));}catch{return null}if(f.length===0)return null;let v=zs(t,r.slice(1,a),e),y=(m?1:.8)*Le(f.map(h=>h.metadata?.confidence??.75));return Dr("when",f,void 0,{sourceLanguage:e,confidence:y,sourceText:t},new Map([["condition",v]]))}function Tr(t,e,r,i){let a=0;for(let n=e;n<t.length;n++)if(r(t[n])){if(a===0)return n;a--;}else i(t[n])&&a++;return -1}var ze={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"}};Object.fromEntries(Object.entries(ze).map(([t,e])=>{let r={};for(let[i,a]of Object.entries(e))a in r||(r[a]=i);return [t,r]}));var As={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},Ds=[["\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"]],xs=/^(\d+)(ms|s|m)?$/,Ss=new Set(["selector","literal","url","event-modifier"]);function Bs(t){let e=t.match(xs);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 Ts(t){for(let e=1;e<t.length;e++){let r=t[e];if(Ss.has(r.kind))continue;let i=r.value.toLowerCase(),a=As[i];if(a){let n=0;for(let o=e+1;o<t.length;o++){let s=t[o],u=Bs(s.value);if(u!==null)return {modifiers:{[a]:u},start:r.position.start,end:s.position.end};if(s.kind==="selector"||s.kind==="literal"||s.kind==="url"||++n>2)break}continue}for(let n of Ds){if(n[0]!==i||e+n.length>t.length)continue;let o=true;for(let s=1;s<n.length;s++)if(t[e+s].value.toLowerCase()!==n[s]){o=false;break}if(o)return {modifiers:{once:true},start:r.position.start,end:t[e+n.length-1].position.end}}}return null}new Set(Object.values(Nr).flatMap(t=>Object.values(t)));var Ce=new Set(["if","unless","while","repeat","for"]),wr=new Set(["then","end","else","if","unless","while","for","repeat","and"]),qs=new Set(["first","last","next","previous","random","closest"]),Re=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"]),wt=class extends Error{constructor(t,e,r,i){super(t),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=i;}};function V(t,e,r){return {message:t,severity:e,source:"semantic-parser",...r&&{code:r}}}function W(t,e){return e.length===0?t:{...t,diagnostics:e}}var ur=120;function Ks(t,e,r){let i=e.tokens.length;if(t.consumedTokens>=i)return null;let a=e.tokens[t.consumedTokens],n=e.tokens[i-1];if(!a||!n)return null;let o=r.slice(a.position.start,n.position.end);if(!o.trim())return null;let s=o.length>ur?`${o.slice(0,ur)}\u2026`:o,u=i-t.consumedTokens;return `pattern ${t.pattern.id} left ${u} token(s) unconsumed: "${s}"`}var Hs=new Set(["to","from","into","onto","with","as","at","of","in","on","by","and","or","then","end","else","the","a","an","async"]);function br(t){let e=[],r=new Set((t.diagnostics??[]).map(a=>`${a.code}|${a.message}`)),i=a=>{if(!a||typeof a!="object")return;if(a!==t)for(let o of a.diagnostics??[]){if(o.code!=="unconsumed-input")continue;let s=`${o.code}|${o.message}`;r.has(s)||(r.add(s),e.push(o));}let n=a;for(let o of ti){let s=n[o];if(Array.isArray(s))for(let u of s)i(u);}};return i(t),e.length===0?t:W(t,[...t.diagnostics??[],...e])}function bt(t){if(t.length>=2){let e=t[0];if((e==='"'||e==="'")&&t.endsWith(e))return t.slice(1,-1)}return t}var ti=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function ii(t,e){if(!t||typeof t!="object")return t;if(t.action&&t.roles instanceof Map){let i=re(t.action),a=i?.primaryRole;if(i&&a&&a!=="patient"&&!i.roles.some(n=>n.role==="patient")&&t.roles.has("patient")&&!t.roles.has(a)){let n=t.roles,o=n.get("patient");o!==void 0&&(n.delete("patient"),n.set(a,o));}if(t.action==="tell"){let n=t.roles,o=n.get("patient"),s=n.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!s||s.type==="literal")&&(n.delete("patient"),n.set("destination",o));}if(t.action==="transition"){let n=t.roles,o=n.get("goal");o&&o.type==="literal"&&o.dataType==="duration"&&!n.has("duration")&&(n.delete("goal"),n.set("duration",o));}if(t.action==="fetch"){let n=t.roles,o=n.get("patient"),s=n.get("source");o&&s&&(o.type==="literal"||o.type==="expression")&&s.type==="expression"&&!n.has("style")&&(n.delete("patient"),n.set("style",s),n.set("source",o));}if(t.action==="transition"){let n=t.roles,o=n.get("destination");o&&o.type==="literal"&&!n.has("goal")&&(n.delete("destination"),n.set("goal",o));let s=n.get("patient");s&&s.type==="literal"&&typeof s.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(s.value)&&n.set("patient",{type:"expression",raw:s.value});}if(t.action==="morph"){let n=t.roles,o=n.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(o.value)&&n.set("patient",{type:"expression",raw:o.value});}if(t.action==="wait"){let n=t.roles;if(!n.has("event")){let o=n.get("duration"),s=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof s=="string"&&Re.has(s.toLowerCase())&&(n.delete("duration"),n.set("event",{type:"literal",value:s,dataType:"string"}));}}if(t.kind==="command"&&t.action!=="on"){let n=t.roles,o=n.get("event");if(o&&o.type==="expression"){let s=o.raw;typeof s=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(s)&&n.set("event",{type:"literal",value:s,dataType:"string"});}}if(e?.size){let n=t.roles;for(let o of ["destination","source"]){let s=n.get(o);s&&s.type==="literal"&&typeof s.value=="string"&&e.has(s.value)&&n.set(o,{type:"expression",raw:s.value});}}}let r=t;for(let i of ti){let a=r[i];if(Array.isArray(a))for(let n of a)ii(n,e);}return t}var Q=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=ii(this.parseInternal(e,r),this.boundIdentifiers),a=this.coverageFrames[this.coverageFrames.length-1];if(a.length>0&&(i=W(i,[...i.diagnostics??[],...a])),this.parseDepth===1&&(i=br(i),i.kind==="event-handler")){let n={node:i,input:e},o=n.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(n.node,n.input,r)??this.reclaimEventCompoundTail(n.node,n.input,r)??this.reclaimResponseTypeTail(n.node,n.input,r)??this.reclaimCapturedDestinationTail(n.node,n.input,r);if(!l)break;n=l;}let s=this.reclaimEventCompoundTail(n.node,n.input,r);s&&(n=s),i=n.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=P(e)?.roleMarkers;if(i){for(let a of Object.values(i))if(a){if(a.primary)for(let n of a.primary.toLowerCase().split(/\s+/))r.add(n);for(let n of a.alternatives??[])for(let o of n.toLowerCase().split(/\s+/))r.add(o);}}for(let a of B.LEAKED_RENDER_MARKERS[e]??[])r.add(a.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 Hs.has(i)?true:B.getCoverageMarkerSurfaces(r).has(e.value.toLowerCase())}recordDroppedTokens(e,r,i){if(e.length===0)return;let a=this.coverageFrames[this.coverageFrames.length-1];if(!a||!e.some(s=>!this.isCoverageResidueToken(s,r)))return;let n=e.map(s=>s.value).join(" ").trim();if(!n)return;let o=n.length>ur?`${n.slice(0,ur)}\u2026`:n;a.push(V(`${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=is(e,r,{statement:(z,w)=>this.parse(z,w),body:(z,w)=>this.parseStatements(z,w)});if(i)return i;let a=ys(e,r,{statement:(z,w)=>this.parse(z,w),body:(z,w)=>this.parseStatements(z,w)});if(a)return a;let n=as(e,r,{statement:(z,w)=>this.parse(z,w),body:(z,w)=>this.parseStatements(z,w)});if(n)return n;let{modifiers:o,remainingInput:s}=this.extractStandaloneModifiers(e,r),u=s||e,c=this.stripAsyncModifier(u,r).remainingInput??u,d=this.stripDoNotThrowModifier(c,r).remainingInput??c,p=[],f=Z(d,r);this.positionSource=d;{let z=f.mark(),w=this.consumeJsBlock(f,r);if(w&&f.isAtEnd())return W(w,p);f.reset(z);}let v=he(r);if(v.length===0)throw new wt(`No patterns available for language: ${r}`,r,d,[V(`No patterns registered for language '${r}'`,"error","no-patterns")]);let E=[...v].sort((z,w)=>w.priority-z.priority);{let z=f.tokens;if(P(r)?.wordOrder==="VSO"&&z.length>=4&&z[0]?.normalized==="source"){let w=z.findIndex(x=>x.normalized==="on");if(w>=2&&w+1<z.length){let x=d.slice(z[0].position.start,z[w].position.start).trim(),R=z[w+1].position.end,T=d.slice(z[w].position.start,R)+" "+x+d.slice(R);if(T!==d)try{let O=this.parse(T,r);if(O&&O.kind==="event-handler"){let N=o?this.applyModifiers(O,o):O;return W(N,p)}}catch{}}}}{let z=f.tokens,w=z[0]?.normalized==="if";for(let x=0;w&&x+3<z.length;x++){let R=(z[x+3]?.normalized??z[x+3]?.value??"").toLowerCase();if(z[x]?.normalized==="source"&&z[x+2]?.normalized==="on"&&B.KNOWN_EVENTS.has(R)){let T=(d.slice(0,z[x].position.start).trimEnd()+" "+d.slice(z[x+1].position.end).trimStart()).trim();if(T&&T!==d)try{let O=this.parse(T,r);if(O&&O.kind==="event-handler"){let N=o?this.applyModifiers(O,o):O;return W(N,p)}}catch{}break}}}{let z=f.tokens;for(let w=1;w<z.length-1;w++){let x=z[w];if(!Sr(x,r))continue;let R=z[w+1],T=(R.normalized??R.value).toLowerCase();if(!B.KNOWN_EVENTS.has(T))break;let O=w+1,N=z[w+2];N&&N.kind==="selector"&&N.value.startsWith("[")&&(O=w+2);let I=z[w].position.start,j=z[O].position.end,_=(d.slice(0,I).trimEnd()+" "+d.slice(j).trimStart()).trim();if(_&&_!==d)try{let Y=this.parse(_,r);if(Y&&Y.kind==="event-handler"){Y.additionalEvents=[{type:"literal",value:T}];let X=o?this.applyModifiers(Y,o):Y;return W(X,p)}}catch{}break}}{let z=Ts(f.tokens);if(z){let w=(d.slice(0,z.start).trimEnd()+" "+d.slice(z.end).trimStart()).trim();if(w&&w!==d)try{let x=this.parse(w,r);if(x&&x.kind==="event-handler"){let R=this.applyModifiers(x,{...o??{},...z.modifiers});return W(R,p)}}catch{}}}let y=E.filter(z=>z.command==="on"),h=f.mark(),k=oe.matchBest(f,y);if(k){p.push(V(`event pattern matched: ${k.pattern.id} (confidence: ${k.confidence.toFixed(2)})`,"info","pattern-match"));let z=false;if(/^event-[a-z]+-bare$/.test(k.pattern.id)){let w=k.captured.get("event"),x=(w?.raw??w?.value??"").toString().toLowerCase(),R=ze[r],T=B.KNOWN_EVENTS.has(x)||!!R&&Object.keys(R).some(O=>O.toLowerCase()===x);if(x&&!T){let O=this.trySOVEventExtraction(d,r,E);if(O){p.push(V(`bare-event mis-anchor on "${x}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let N=o?this.applyModifiers(O,o):O;return W(N,p)}if(w?.type==="reference"||w?.type==="expression"){f.reset(h);let N=E.filter(j=>j.command!=="on"),I=oe.matchBest(f,N);f.reset(h),I&&I.pattern.command!=="on"?(z=true,p.push(V(`bare-event mis-anchor on reference "${x}" rejected; command ${I.pattern.command} preferred`,"info","stage-bare-event-guard"))):oe.matchBest(f,y);}}}if(!z){let w=this.buildEventHandler(k,f,r),x=o?this.applyModifiers(w,o):w;return W(x,p)}}p.push(V(`event patterns: ${y.length} tried, no match`,"info","stage-event"));let A=this.tryTrailingEventExtraction(d,r,E);if(A){p.push(V("trailing event extraction succeeded","info","stage-trailing-event"));let z=o?this.applyModifiers(A,o):A;return W(z,p)}let D=E.filter(z=>z.command!=="on"),C=this.tryParseUnlessGuard(f,D,r);if(C&&C.length>0){let z=C.length===1?C[0]:Ue(C,"then",{sourceLanguage:r,confidence:1});return W(z,p)}let g=oe.matchBest(f,D);if(g){if(Ce.has(g.pattern.command)){let w=this.trySOVEventExtraction(d,r,E);if(w){p.push(V(`SOV event extraction preferred over bare ${g.pattern.command} command`,"info","stage-sov-loop"));let R=o?this.applyModifiers(w,o):w;return W(R,p)}let x=this.tryMidStreamEventExtraction(d,r,E);if(x){p.push(V(`mid-stream event extraction preferred over bare ${g.pattern.command} command`,"info","stage-midstream-loop"));let R=o?this.applyModifiers(x,o):x;return W(R,p)}}else if(B.KNOWN_EVENTS.has(g.pattern.command)&&this.hasSOVEventMarkerHead(d,r)){let w=this.trySOVEventExtraction(d,r,E);if(w){p.push(V(`SOV event extraction preferred over command-homonym event ${g.pattern.command}`,"info","stage-sov-homonym"));let x=o?this.applyModifiers(w,o):w;return W(x,p)}}else if(P(r)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(d,r,E);if(w){p.push(V(`mid-stream event extraction preferred over bare ${g.pattern.command} command`,"info","stage-midstream-cmd"));let x=o?this.applyModifiers(w,o):w;return W(x,p)}}if(g.consumedTokens<f.tokens.length&&P(r)?.wordOrder==="SOV"){let w=this.trySOVEventExtraction(d,r,E);if(w){p.push(V(`SOV event extraction preferred over partial ${g.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let x=o?this.applyModifiers(w,o):w;return W(x,p)}}if(g.consumedTokens<f.tokens.length&&!Ce.has(g.pattern.command)){let w=this.tryTopLevelCommandSequence(f,D,r);if(w)return p.push(V(`top-level command sequence: ${w.statements.length} commands`,"info","stage-top-level-sequence")),W(w,p)}p.push(V(`command pattern matched: ${g.pattern.id} (confidence: ${g.confidence.toFixed(2)})`,"info","pattern-match"));let z=Ks(g,f,d);return z&&p.push(V(z,"warning","unconsumed-input")),W(this.buildCommand(g,r),p)}if(p.push(V(`command patterns: ${D.length} tried, no match`,"info","stage-command")),!d.includes(`
4
- `)&&P(r)?.wordOrder==="VSO"){let z=this.tryMidStreamEventExtraction(d,r,E);if(z){p.push(V("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let w=o?this.applyModifiers(z,o):z;return W(w,p)}}let b=this.trySOVEventExtraction(d,r,E);if(b){p.push(V("SOV event extraction succeeded","info","stage-sov"));let z=o?this.applyModifiers(b,o):b;return W(z,p)}p.push(V("SOV event extraction: no event keyword found","info","stage-sov"));let S=this.tryCompoundCommandParsing(f,D,r);if(S)return p.push(V("compound command parsing succeeded","info","stage-compound")),W(S,p);throw p.push(V("compound parsing: no then-keywords or no command matches","info","stage-compound")),p.push(V(`all parse stages exhausted for "${d}"`,"error","parse-failed")),new wt(`Could not parse input in ${r}: ${d}`,r,d,p)}parseStatements(e,r){let i=Z(e,r),a=he(r).filter(n=>n.command!=="on").sort((n,o)=>o.priority-n.priority);this.coverageFrames.push([]);try{let n=this.parseBodyWithClauses(i,a,r),o=this.coverageFrames[this.coverageFrames.length-1];if(o.length>0&&n.length>0){let s=n[n.length-1];n[n.length-1]=W(s,[...s.diagnostics??[],...o]);}return n}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Yt()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let i={};for(let[n,o]of e.captured)i[n]=o;let a=ee(e.pattern.command,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(a),a}buildEventHandler(e,r,i){if(!e)throw new Error("No match to build event handler from");let a=e.captured.get("event");if(!a)throw new Error("Event handler pattern matched but no event captured");{let d=a.type==="expression"?a.raw:a.type==="literal"?a.value:void 0;if(typeof d=="string"&&/^[^\s()[\]{}:]+$/.test(d)){let p=ze[i]?.[d];p?a={type:"literal",value:p,dataType:"string"}:a.type==="expression"&&B.KNOWN_EVENTS.has(d.toLowerCase())&&(a={type:"literal",value:d.toLowerCase(),dataType:"string"});}}let n=oe.extractEventModifiers(r),o=e.captured.get("source");o&&e.pattern.id.endsWith("source")&&!(o.type==="reference"&&o.value==="me")&&(n={...n??{},from:o});let s=this.extractOrConjunctionEvents(r,i),u=a;s.length>0&&a.type==="literal"&&(u={type:"literal",value:[String(a.value),...s.map(p=>String("value"in p?p.value:""))].join(" or ")});let l,c=e.captured.get("action");if(c&&c.type==="literal"&&c.value==="if"){let d=r.tokens,p=-1;for(let f=r.position()-1;f>=0;f--){let v=d[f],E=(v.normalized??v.value).toLowerCase();if(this.isIfKeyword(E,i)){p=f;break}}if(p>=0){let f=he(i).filter(A=>A.command!=="on").sort((A,D)=>D.priority-A.priority),v=d.slice(p);if(e.pattern.id.endsWith("vso-verb-first")&&u.type==="literal"){let A=String(u.value??"").split("[")[0].trim().toLowerCase(),D=v.findIndex((C,g)=>{if(g===0||A==="")return false;let b=(C.normalized??C.value).toLowerCase(),S=v[g-1];return b===A&&S.kind==="keyword"&&(S.normalized??"").toLowerCase()==="on"});if(D>0){let C=v[D+1],g=C&&C.kind==="selector"&&C.value.startsWith("[")?1:0;v=[...v.slice(0,D-1),...v.slice(D+1+g)];}}let E=new ie(v,i),y=this.coverageMark(),h=this.parseBodyWithClauses(E,f,i);if(h.some(A=>A.kind==="conditional")||h.length===1&&h[0]?.kind==="compound"&&h[0].statements.some(A=>A.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return Ke(u,h,n,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(y);}}if(c&&c.type==="literal"&&String(c.value)!=="js"&&re(String(c.value))!==void 0){let d=c.value,p={};for(let[g,b]of e.captured)g!=="event"&&g!=="action"&&g!=="continues"&&(p[g]=b);if(d==="repeat"){let g=r.peek(),b=z=>(z.normalized??z.value).toLowerCase();if(g&&g.kind==="keyword"&&b(g)==="forever")p.loopType={type:"literal",value:"forever"},delete p.patient,r.advance();else if(g&&g.kind==="keyword"&&b(g)==="event"){r.advance();let z=r.peek();if(z)for(p.event={type:"literal",value:b(z)},p.loopType={type:"literal",value:"until-event"},delete p.patient;!r.isAtEnd();){let w=r.peek();if(!w||w.kind==="conjunction"||w.kind==="keyword"&&(this.isThenKeyword(w.value,i)||this.isEndKeyword(w.value,i)))break;r.advance();}}let S=p.patient;S&&S.type==="reference"&&S.value==="me"&&delete p.patient;}let f=ee(d,p,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence});this.registerBoundIdentifiers(f);let v=[];if(!Ce.has(d)||d==="repeat"||d==="while"){let g=e.pattern.id.includes("verb-first"),b=r.tokens,S=r.position(),z=R=>R.kind==="conjunction"||R.kind==="keyword"&&(this.isThenKeyword(R.value,i)||this.isEndKeyword(R.value,i)),w=new Set;{let R=P(i)?.keywords?.[d];R?.primary&&w.add(R.primary.toLowerCase());for(let T of R?.alternatives??[])w.add(T.toLowerCase());}let x=-1;for(let R=S-1;R>=0;R--){let T=b[R];if(z(T))break;if((T.normalized??T.value).toLowerCase()===d||w.has(T.value.toLowerCase())){x=R;break}}if(x>=0){let R=S;for(;R<b.length&&!z(b[R]);)R++;let T=b.slice(x,R),O=T;if(g){let N=String(a.value??"").toLowerCase(),I=T.findIndex(j=>(j.normalized??j.value).toLowerCase()===N);if(I<0)O=null;else {let j=T[I-1],_=j&&j.kind==="keyword"&&j.normalized?.toLowerCase()==="on"?I-1:I;O=[...T.slice(0,_),...T.slice(I+1)];}}if(O&&O.length>1){let N=he(i).filter(M=>M.command!=="on").sort((M,H)=>H.priority-M.priority),I=this.coverageMark(),j=this.parseClause(O,N,i),_=j[0],Y=M=>M!==null&&typeof M=="object"&&typeof M.type=="string"?M.type:typeof M,X=re(d),yr=X?.primaryRole,Xr=M=>M==="patient"&&yr&&yr!=="patient"&&!X?.roles.some(H=>H.role==="patient")?yr:M,Oi=(M,H)=>{if(!Ce.has(d)||!X)return false;let ge=X.roles.find($e=>$e.role===Xr(M));return ge?ge.expectedTypes.length>0&&!ge.expectedTypes.includes(Y(H)):true},hr=(M,H)=>M==="patient"&&!!X&&!X.roles.some(ge=>ge.role==="patient")&&Y(H)==="literal"&&It.has(String(H.value??"").toLowerCase()),vr=M=>M!==null&&typeof M=="object"&&M.implicit===true,Pi=!!_&&_.kind==="command"&&Object.entries(p).every(([M,H])=>{if(vr(H)||Oi(M,H)||hr(M,H))return true;let ge=_.roles.get(Xr(M));if(ge!==void 0&&Y(ge)===Y(H))return true;if(M==="patient"&&d==="pick"&&Y(H)==="literal"){let $e=_.roles.get("method"),Qr=Y($e),et=Qr==="literal"?String($e.value):Qr==="expression"?String($e.raw):void 0;return et!==void 0&&et===String(H.value)}return false}),Jr=_?.metadata?.patternId??"",_i=!Ce.has(d)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(Jr),Ni=/^repeat-.*-(times|for-in|while-head|until-head)$/.test(Jr);if((j.length===1||Ni&&j.length>1)&&_&&_.kind==="command"&&(_.action===d||d==="while"&&_.action==="repeat"&&/-while-head$/.test(_.metadata?.patternId??""))&&Pi&&_i&&(_.roles.size>Object.entries(p).filter(([M,H])=>!hr(M,H)).length||[..._.roles.values()].filter(M=>!vr(M)).length>Object.entries(p).filter(([M,H])=>!hr(M,H)&&!vr(H)).length))for(f=_,v=j.slice(1);r.position()<R;)r.advance();else this.coverageRollback(I);}}}if(!Ce.has(d)){let g=f;if(re(d)?.roles.some(T=>T.role==="quantity"&&!T.required)&&!g.roles.has("quantity")){let T=r.peek();T&&/^-?\d+(\.\d+)?$/.test(T.value)&&(f=ee(d,{...Object.fromEntries(g.roles),quantity:{type:"literal",value:parseFloat(T.value),dataType:"number"}},g.metadata),r.advance());}let S=f;if(re(d)?.roles.some(T=>T.role==="duration"&&!T.required)&&!S.roles.has("duration")){let T=/^\d+(\.\d+)?(ms|s)$/i,O=r.peek(),N=false;if(O&&O.kind==="particle"){let I=r.peek(1);I&&T.test(I.value)&&(N=true,O=I);}O&&T.test(O.value)&&(f=ee(d,{...Object.fromEntries(S.roles),duration:{type:"literal",value:O.value,dataType:"string"}},S.metadata),N&&r.advance(),r.advance(),this.consumeForPostposition(r,i));}let w=f,x=re(d);if(x?.roles.find(T=>T.role==="responseType"&&!T.required)&&!w.roles.has("responseType")){let T=_=>typeof _=="string"&&B.RESPONSE_TYPE_WORDS.has(_.toLowerCase()),O=(_,Y)=>{let X=Object.fromEntries(w.roles);Y&&delete X.destination,X.responseType={type:"expression",raw:_},f=ee(d,X,w.metadata);},N=w.roles.get("destination"),I=x?.roles.find(_=>_.role==="destination"),j=N?.raw??N?.value;if(N&&I&&!I.expectedTypes.includes(N.type)&&T(j))O(j,true);else {let _=r.peek();_&&T(_.value)&&(O(_.value,false),r.advance());}}if(d==="wait"){let T=f;if(!T.roles.has("event")){let O=r.peek();if(O&&Re.has(O.value.toLowerCase())){let N=Object.fromEntries(T.roles),I=N.duration;I&&I.type!=="literal"&&I.type!=="expression"&&delete N.duration;let j=N.patient;j&&j.type==="reference"&&j.value==="me"&&delete N.patient,N.event={type:"literal",value:O.value,dataType:"string"},f=ee(d,N,T.metadata),r.advance(),this.consumeForPostposition(r,i);}}}this.tryAttachTrailingRole(r,f,i),this.tryAttachTrailingStyle(r,f,i),this.tryAttachTrailingExpressionRole(r,f,i);}let E=e.captured.get("continues"),y=E?.type==="literal"&&E.value==="then",h=r.peek(),k=!!h&&this.isThenKeyword(h.value,i),D=Ce.has(d)&&!!h&&!this.isEndKeyword(h.value,i),C=!!h&&!this.isEndKeyword(h.value,i);if(y||k||D||C){let g=he(i).filter(z=>z.command!=="on").sort((z,w)=>w.priority-z.priority),b=he(i).filter(z=>z.id.startsWith("grammar-")&&z.id.includes("-continuation")).sort((z,w)=>w.priority-z.priority),S=this.parseBodyWithGrammarPatterns(r,g,b,i);S.length>0?l=[f,...v,...S]:l=[f,...v];}else l=[f,...v],r.isAtEnd()||this.recordDroppedTokens(r.tokens.slice(r.position()),i,"handler body tail");}else {let d=he(i).filter(f=>f.command!=="on").sort((f,v)=>v.priority-f.priority),p=c?e.roleStarts?.get("action"):void 0;if(p!==void 0&&p<r.position()){let f=new ie(r.tokens.slice(p),i);for(l=this.parseBodyWithClauses(f,d,i);!r.isAtEnd();)r.advance();}else l=this.parseBodyWithClauses(r,d,i);}let m=l.length>1?[Ue(l,"then",{sourceLanguage:i})]:l;return Ke(u,m,n,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,i){let a=[],n=[],o=0,s=[];for(;!e.isAtEnd();){let u=e.peek();if(!u)break;if(n.length===0){let f=this.consumeJsBlock(e,i)??this.consumeVerbFinalJsBlock(e,i);if(f){a.push(f);continue}let v=this.tryParseConditionalBlock(e,r,i);if(v){a.push(v);continue}let E=this.tryParseUnlessGuard(e,r,i);if(E){a.push(...E);continue}}let l=u.kind==="conjunction"||u.kind==="keyword"&&this.isThenKeyword(u.value,i),c=n[n.length-1],m=e.peek(1),d=c?.value.toLowerCase()==="at"&&m?.value.toLowerCase()==="of"||ct(i,u.value,c?.value,m?.value),p=u.kind==="keyword"&&this.isEndKeyword(u.value,i)&&!d;if(p&&o>0){o--,s.pop(),n.push({...u,metadata:{...u.metadata,closesTrackedBlock:true}}),e.advance();continue}if(l&&s.includes("if")){n.push(u),e.advance();continue}if(l){if(n.length>0){let f=this.parseClause(n,r,i);a.push(...f),n.length=0,o=f.filter(v=>{let E=v;return (E.action==="for"||E.action==="repeat"||E.action==="while")&&(!Array.isArray(E.body)||E.body.length===0)}).length,s.length=0;for(let v=0;v<o;v++)s.push("other");}e.advance();continue}if(p){e.advance();let f=[];for(;!e.isAtEnd();){let v=e.peek();if(!v||v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,i)||this.isEndKeyword(v.value,i)))break;f.push(v),e.advance();}if(f.length>0){let v=this.coverageMark(),E=n.length>0?this.parseClause(n,r,i):[];E.length===0&&n.length>0?(this.coverageRollback(v),a.push(...this.parseClause([...n,...f],r,i))):(a.push(...E),a.push(...this.parseClause(f,r,i)));}else if(n.length>0){let v=this.parseClause(n,r,i);a.push(...v);}n.length=0;break}if(u.kind==="keyword"){let f=(u.normalized??u.value).toLowerCase();(this.isIfKeyword(f,i)||this.isUnlessKeyword(f,i)||f==="while"||f==="for"||f==="repeat")&&(o++,s.push(this.isIfKeyword(f,i)?"if":"other"));}n.push(u),e.advance();}if(n.length>0){let u=this.parseClause(n,r,i);a.push(...u);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),i,"body stream tail"),this.foldFrontedWhileIntoRepeat(a,i);for(let u=a.length-1;u>=0;u--){let l=a[u];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&a.splice(u,1);}return a.length>1?[Ue(a,"then",{sourceLanguage:i})]:a}tryTopLevelCommandSequence(e,r,i){let a=this.coverageMark(),n;try{let l=new ie(e.tokens,i);n=this.parseBodyWithClauses(l,r,i);}catch{return this.coverageRollback(a),null}if(n.length!==1||n[0].kind!=="compound")return this.coverageRollback(a),null;let o=n[0];if(o.statements.length<2)return this.coverageRollback(a),null;let s=o.statements.map(l=>l.metadata?.confidence??.75),u=s.reduce((l,c)=>l+c,0)/s.length;return Ue(o.statements,o.chainType,{sourceLanguage:i,confidence:u})}foldFrontedWhileIntoRepeat(e,r){for(let i=0;i+1<e.length;i++){let a=e[i],n=e[i+1];if(a.kind!=="command"||a.action!=="while"||n.kind!=="command"||n.action!=="repeat")continue;let o=a.roles.get("condition");if(!o||n.roles.has("condition")||Array.isArray(a.body)||Array.isArray(n.body))continue;let s=new Map(n.roles);s.set("condition",o),s.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(i,2,{...n,roles:s,metadata:{...n.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(n.metadata?.confidence??0,a.metadata?.confidence??0)}});}}parseClause(e,r,i){if(e.length===0)return [];let a=null,n=e,o=e[e.length-1];if(o&&e.length>=2){let y=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(y,i)&&(a="unless",n=e.slice(0,-1));}let s=null;if(a&&n.length>=3){let y=P(i),h=y?B.buildVerbLookup(y):null;if(h)for(let k=1;k<n.length-1;k++){let A=n[k],D=h.get(A.value.toLowerCase())??(A.normalized?h.get(A.normalized.toLowerCase()):void 0);if(D&&!B.CONDITION_OPERATORS.has(D)){s=n.slice(0,k),n=n.slice(k);break}}}let u=new ie(n,i),l=[],c=this.coverageMark(),m=0,d=[],p=s,f=()=>{if(d.length===0)return;let y=d.slice();if(d.length=0,a&&l.length===0&&p===null){p=y;return}let h=y[0];if(!(h&&(h.kind==="identifier"||h.kind==="selector"||h.kind==="literal"||h.kind==="reference"))){this.recordDroppedTokens(y,i,"body clause");return}let A=false;for(let D of this.parseSOVClauseByVerbAnchoring(y,i)){let C=D.action,g=D.roles;C&&re(C)&&g instanceof Map&&g.size>0&&(l.push(D),A=true);}A||this.recordDroppedTokens(y,i,"body clause");};for(;!u.isAtEnd();){let y=u.peek(),h=!!y&&y.normalized?.toLowerCase()==="repeat",k=u.mark(),A=oe.matchBest(u,r);if(h&&A&&A.pattern.command!=="repeat"){u.reset(k),f(),l.push(ee("repeat",{},{sourceLanguage:i,confidence:.6})),m++,u.advance();continue}if(A&&A.pattern.command==="if"){let D=u.mark(),C=d.length;for(u.reset(k);!u.isAtEnd();){let b=u.peek();if(!b||this.isIfKeyword((b.normalized??b.value).toLowerCase(),i))break;d.push(b),u.advance();}let g=this.tryParseConditionalBlock(u,r,i);if(g){f(),l.push(g),m++;continue}d.length=C,u.reset(D);}if(A){f();let D=this.buildCommand(A,i);l.push(D),m++,this.tryAttachTrailingRole(u,D,i),this.tryAttachTrailingStyle(u,D,i),this.tryAttachTrailingExpressionRole(u,D,i),this.tryAttachTrailingDuration(u,D);}else {let D=u.peek();D&&D.normalized?.toLowerCase()==="repeat"?(f(),l.push(ee("repeat",{},{sourceLanguage:i,confidence:.6})),m++):D&&d.push(D),u.advance();}}f();let v=l;if(m===0){let y=this.parseSOVClauseByVerbAnchoring(n,i);y.length>0&&(this.coverageRollback(c),v=y);}let E=p;return a&&v.length>0&&E&&E.length>0?[ee(a,{condition:{type:"expression",raw:this.joinTokenText(E,i)}},{sourceLanguage:i,patternId:`${a}-${i}-trailing-guard`,confidence:.85}),...v]:a&&E&&E.length>0&&v.length===0?[ee(a,{condition:{type:"expression",raw:this.joinTokenText(E,i)}},{sourceLanguage:i,patternId:`${a}-${i}-trailing-guard`,confidence:.85})]:v}tryAttachTrailingDuration(e,r){let i=r.roles;if(i.has("duration")||!re(r.action)?.roles.some(o=>o.role==="duration"&&!o.required))return;let n=e.peek();!n||!/^\d+(?:\.\d+)?(?:ms|s|m|h)$/.test(n.value)||(i.set("duration",q(n.value,"duration")),e.advance());}tryAttachTrailingRole(e,r,i){let a=re(r.action);if(!a)return;let n=P(i);if(!n)return;let o=r.roles,s=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let m=(l.normalized??l.value).toLowerCase();return wr.has(m)?false:m==="body"||m==="it"||m==="you"||m==="result"||m==="document"||m==="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(!a.roles.some(E=>E.role===l))continue;let m=n.roleMarkers?.[l];if(!m)continue;let d=o.get(l);if(d&&!(d.type==="reference"&&d.value==="me"))continue;let p=E=>{if(!E||E.kind!=="particle"&&E.kind!=="keyword")return false;let y=E.value.toLowerCase();return m.primary?.toLowerCase()===y?true:c?false:(E.normalized??"").toLowerCase()===l?true:!!m.alternatives?.some(h=>h.toLowerCase()===y)},f=e.peek(),v=e.peek(1);if(!f||!v)return;if(c&&m.position==="after"){let E=e.peek(2),y=(f.normalized??f.value).toLowerCase();if(qs.has(y)&&v.kind==="selector"&&p(E)){o.set(l,{type:"expression",raw:`${y} ${v.value}`}),e.advance(),e.advance(),e.advance();return}}if(m.position==="after"){if(s(f,c)&&p(v)){let E=this.tokenToSemanticValue(f);e.advance(),e.advance(),E&&o.set(l,E);return}if(c&&s(f,c)){let E=e.peek(2),y=e.peek(3);if((v.normalized??v.value).toLowerCase()==="in"&&E&&!p(E)&&p(y)){let h=this.tokenToSemanticValue(f);e.advance(),e.advance(),e.advance(),e.advance(),h&&o.set(l,h);return}}}else if(p(f)&&s(v,c)){e.advance();let E=this.tokenToSemanticValue(e.advance());E&&o.set(l,E);return}}}tryAttachTrailingStyle(e,r,i){if(r.action!=="fetch"&&r.action!=="render")return;let a=r.roles;if(!re(r.action)?.roles.some(y=>y.role==="style"))return;let o=a.get("style");if(o){if(o.type==="expression"&&typeof o.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(o.raw)&&e.peek()?.value===":"){let y=Ge(e,o.raw);y&&a.set("style",{type:"expression",raw:y});}this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(r.action==="fetch"){let y=a.get("patient"),h=a.get("source");if(y&&h&&(y.type==="literal"||y.type==="expression")&&h.type==="expression"&&typeof h.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(h.raw)&&e.peek()?.value===":"){let k=Ge(e,h.raw);k&&(a.set("source",{type:"expression",raw:k}),this.tryAttachResponseTypeAfterStyle(e,r,i));return}}let u=P(i)?.roleMarkers?.style;if(!u)return;if(u.position==="before"){let y=new Set([u.primary,...u.alternatives??[]].map(D=>D.toLowerCase())),h=e.peek();if(!h||!y.has(h.value.toLowerCase()))return;let k=e.mark();e.advance();let A=Ge(e);if(!A){e.reset(k);return}a.set("style",{type:"expression",raw:A}),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)),m=24,d=-1,p=0;for(let y=0;y<m;y++){let h=e.peek(y);if(!h||c(h))break;if(h.value==="("||h.value==="{"?p++:(h.value===")"||h.value==="}")&&(p=Math.max(0,p-1)),p===0&&(h.kind==="particle"||h.kind==="keyword")&&l.has(h.value.toLowerCase())){d=y;break}}if(d<=0)return;let f=[];for(let y=0;y<d;y++){let h=e.peek(y);h&&f.push(h);}if(f.length===1&&B.RESPONSE_TYPE_WORDS.has(f[0].value.toLowerCase()))return;let v=new ie(f,i),E=Ge(v);a.set("style",{type:"expression",raw:E&&v.isAtEnd()?E:this.joinTokenText(f,i)});for(let y=0;y<=d;y++)e.advance();this.tryAttachResponseTypeAfterStyle(e,r,i);}tryAttachResponseTypeAfterStyle(e,r,i){let a=r.roles;if(a.has("responseType")||!re(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=>{a.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((m,d)=>e.peek(d)?.value.toLowerCase()===m)){for(let m=0;m<c.length;m++)e.advance();break}}}tryAttachTrailingExpressionRole(e,r,i){let a=r.action,n=a==="js"?{role:"patient",terminator:"boundary"}:a==="go"||a==="scroll"?{role:"destination",terminator:"destination-marker"}:null;if(!n)return;let o=r.roles,s=o.get(n.role);if(a==="go"&&s&&s.type==="expression"&&String(s.raw).toLowerCase()==="url"){let y=e.peek();if(y&&!wr.has((y.normalized??y.value).toLowerCase())){let k=this.tokenToSemanticValue(y);if(k.type==="literal"||k.type==="selector"){o.set(n.role,k),o.set("method",{type:"literal",value:"url"}),e.advance();return}}let h=o.get("patient");if(h&&(h.type==="literal"||h.type==="selector")){o.set(n.role,h),o.set("method",{type:"literal",value:"url"}),o.delete("patient");return}}if(a==="go"&&s&&s.type==="expression"){let y=/^url\s+(\S+)$/i.exec(String(s.raw??""));if(y){let h=y[1].replace(/^["']|["']$/g,"");o.set(n.role,{type:"literal",value:h,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(a==="go"&&!s){let y=o.get("patient");if(y&&y.type==="expression"&&String(y.raw).toLowerCase()==="url"){let h=e.peek();if(h&&!wr.has((h.normalized??h.value).toLowerCase())){let k=this.tokenToSemanticValue(h);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(s&&!(s.type==="reference"&&s.value==="me"))return;let u=P(i);if(!u)return;let l=null;if(n.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)),m=24,d=[],p=0,f=false;for(let y=0;y<m;y++){let h=e.peek(y);if(!h||c(h))break;if(h.value==="("||h.value==="{"?p++:(h.value===")"||h.value==="}")&&(p=Math.max(0,p-1)),l!==null&&p===0&&(h.kind==="particle"||h.kind==="keyword")&&h.value.toLowerCase()===l){f=true;break}d.push(h);}if(d.length===0||l!==null&&!f)return;let v=d.length+(f?1:0);if(a==="go"&&d.length===2&&d[0].value.toLowerCase()==="url"){let y=this.tokenToSemanticValue(d[1]);if(y.type==="literal"||y.type==="selector"){o.set(n.role,y),o.set("method",{type:"literal",value:"url"});let h=o.get("patient");h&&h.type==="reference"&&h.value==="me"&&!re(a)?.roles.some(k=>k.role==="patient")&&o.delete("patient");for(let k=0;k<v;k++)e.advance();return}}let E=d;if(a==="js"){let y=u.keywords?.js,h=A=>[y?.primary,...y?.alternatives??[]].some(D=>!!D&&D.length>A.value.length&&D.includes(A.value)),k=0;for(;k<E.length&&h(E[k]);)k++;if(E=E.slice(k),E.length===0)return}if(o.set(n.role,{type:"expression",raw:this.joinTokenText(E,i)}),n.role!=="patient"){let y=o.get("patient");y&&y.type==="reference"&&y.value==="me"&&!re(a)?.roles.some(h=>h.role==="patient")&&o.delete("patient");}for(let y=0;y<v;y++)e.advance();}static buildVerbLookup(e){let r=new Map;for(let[i,a]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(i)&&(r.set(a.primary.toLowerCase(),i),a.alternatives))for(let n of a.alternatives)r.set(n.toLowerCase(),i);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[i,a]of Object.entries(e.roleMarkers)){if(!a)continue;if((i!=="event"||!r.has(a.primary))&&r.set(a.primary,i),a.alternatives)for(let o of a.alternatives)r.has(o)||r.set(o,i);}return r}parseSOVClauseByVerbAnchoring(e,r){let i=P(r);if(!i||i.wordOrder!=="SOV")return [];let a=B.buildVerbLookup(i),n=B.buildMarkerToRoleLookup(i),o=[],s=0;for(;s<e.length;){let u=-1,l="";for(let f=s;f<e.length;f++){let v=e[f];if(n.has(v.value))continue;let E=a.get(v.value.toLowerCase()),y=v.normalized?a.get(v.normalized.toLowerCase()):void 0,h=E||y;if(h){u=f,l=h;break}}if(u===-1)break;let c=e.slice(s,u),m=e.length;for(let f=u+1;f<e.length;f++){let v=e[f];if(v.kind==="conjunction"||this.isThenKeyword(v.value,r)){m=f;break}if(f>u+1&&!n.has(v.value)&&(a.get(v.value.toLowerCase())||(v.normalized?a.get(v.normalized.toLowerCase()):void 0))){m=f;break}}let d=e.slice(u+1,m),p=this.extractRolesFromMarkedTokens(c,d,n,l,r);if(o.push(ee(l,p,{sourceLanguage:r,confidence:.7})),s=m,s<e.length){let f=e[s];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&s++;}}return o}extractRolesFromMarkedTokens(e,r,i,a,n){let o={},s=(l,c)=>{let m=this.isEndKeyword(l.value,n),d=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !m&&!d?false:l.metadata?.closesTrackedBlock===true||m?true:!(c&&c.kind==="selector")},u=l=>{let c=[];for(let m=0;m<l.length;m++){let d=l[m];if(s(d,l[m+1]))continue;let p=i.get(d.value);if(p&&d.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c,n);if(f){let v=this.mapRoleForCommand(p,a,o);v&&(o[v]=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&&re(a)?.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 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(o=>o.kind!=="whitespace");if(i.length===0)return null;if(i.length>=2&&(i[0].kind==="selector"||/^[#.@*<]/.test(i[0].value))){let o=i.findIndex((s,u)=>u>0&&(s.normalized??s.value).toLowerCase()==="in");o>0&&(i=i.slice(0,o));}if(i.length===1)return this.tokenToSemanticValue(i[0]);let a=i.map(o=>o.value).join(""),n=i[0];return n.kind==="selector"||n.value.startsWith("#")||n.value.startsWith(".")||n.value.startsWith("@")||n.value.startsWith("*")?ke(a):n.kind==="literal"||n.value.startsWith('"')||n.value.startsWith("'")?q(bt(a),"string"):n.kind==="reference"?se(a):q(this.joinTokenText(i,r))}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return ke(r);if(r.startsWith('"')||r.startsWith("'"))return q(bt(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return q(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return q(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return q(false);if(r.length>1&&(r.startsWith(":")||r.startsWith("$")))return se(r);let i=e.normalized?.toLowerCase();return i==="me"||i==="it"||i==="you"||i==="result"||i==="body"?se(i):e.kind==="reference"?se(e.normalized||"me"):q(r)}parseBodyWithGrammarPatterns(e,r,i,a){let n=[],o=[],s=false,u=()=>{if(!s&&o.length>0){let m=this.parseSOVClauseByVerbAnchoring(o,a);n.push(...m),m.length===0&&this.recordDroppedTokens(o,a,"fused body walk");}else o.length>0&&this.recordDroppedTokens(o,a,"fused body walk");o=[],s=false;},l=0,c=()=>{let m=0;for(let d of n){let p=d;(p.action==="for"||p.action==="repeat"||p.action==="while")&&(!Array.isArray(p.body)||p.body.length===0)&&m++;}return m-l};for(;!e.isAtEnd();){let m=e.peek();if(m&&this.isThenKeyword(m.value,a)){u(),e.advance();continue}if(m&&this.isEndKeyword(m.value,a)){let p=e.peek(-1),f=e.peek(1);if(!ct(a,m.value,p?.value,f?.value)){if(u(),c()>0){l++,e.advance();continue}e.advance();break}}if(m&&!s&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),a)){u();let p=this.tryParseConditionalBlock(e,r,a);if(p){n.push(p),s=true;continue}}let d=false;if(i.length>0){let p=oe.matchBest(e,i);if(p){let f=p.pattern.command,v={};for(let[h,k]of p.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(v[h]=k);let E=ee(f,v,{sourceLanguage:a,patternId:p.pattern.id});n.push(E),d=true,s=true;let y=p.captured.get("continues");if(y&&y.type==="literal"&&y.value==="then")continue}}if(!d){let p=e.mark(),f=oe.matchBest(e,r);if(f){if(f.pattern.command==="if"){let E=e.mark();for(e.reset(p);!e.isAtEnd();){let h=e.peek();if(!h||this.isIfKeyword((h.normalized??h.value).toLowerCase(),a))break;e.advance();}let y=this.tryParseConditionalBlock(e,r,a);if(y){u(),n.push(y),s=true;continue}e.reset(E);}let v=this.buildCommand(f,a);n.push(v),this.tryAttachTrailingRole(e,v,a),d=true,s=true;}}d||(m&&o.push(m),e.advance());}u(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),a,"fused body walk");for(let m=n.length-1;m>=0;m--){let d=n[m];d.kind==="command"&&d.action==="for"&&(!(d.roles instanceof Map)||d.roles.size===0)&&(!Array.isArray(d.body)||d.body.length===0)&&n.splice(m,1);}return n}tryCompoundCommandParsing(e,r,i){let a=e.tokens,n=a.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,i)),o=a.some(c=>this.isElseKeyword(c.value,i));if(!n&&!o)return null;let s=new ie(a,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 a=false;try{let n=Z(r,"en").tokens;a=n.length===1&&n[0]?.kind==="keyword";}catch{a=false;}return B.enEventKeywordCache.set(r,a),a}matchEventMarkerPhrase(e,r,i){let a=B.SOV_EVENT_MARKER_PHRASES[i];if(!a)return 0;for(let n of a)if(n.every((o,s)=>e[r+s]?.value===o))return n.length;return 0}hasSOVEventMarkerHead(e,r){let i=B.SOV_EVENT_MARKERS[r];if(i===void 0)return false;let{tokens:a}=Z(e,r),n=ze[r],o=new Set;if(n)for(let s of Object.keys(n))o.add(s.toLowerCase());for(let s=0;s<a.length;s++){let u=a[s],l=u.value.toLowerCase(),c=u.normalized?.toLowerCase();if(!(!!c&&(B.KNOWN_EVENTS.has(c)||Re.has(c))||B.KNOWN_EVENTS.has(l)||Re.has(l)||o.has(l)))continue;let d=this.matchEventParamPhrase(a,s+1).len,p=a[s+1+d];if(p&&(p.kind==="particle"||p.kind==="keyword")&&i.has(p.value)||this.matchEventMarkerPhrase(a,s+1+d,r)>0)return true}return false}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let i=[];for(let a=r+1;a<e.length;a++){let n=e[a].value;if(n===")")return {len:a-r+1,names:i};if(n!==","){if(e[a].kind!=="identifier")break;i.push(n);}}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 a=e.value.toLowerCase();return r.has(a)||!!i&&r.has(i)}tryTrailingEventExtraction(e,r,i){let a=Z(e,r).tokens;if(a.length<3)return null;let n=ze[r],o=new Set;if(n)for(let A of Object.keys(n))o.add(A.toLowerCase());let s=a.length-2,u=a[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))return null;let c=a[a.length-1],m=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&B.KNOWN_EVENTS.has(d)||B.KNOWN_EVENTS.has(m)||o.has(m)))return null;let f=d&&B.KNOWN_EVENTS.has(d)?d:n?.[m]??m,v=a.slice(0,s);if(v.length===0)return null;let E=i.filter(A=>A.command!=="on"),y=new ie(v,r),h=this.coverageMark(),k=this.parseBodyWithClauses(y,E,r);return k.length===0?(this.coverageRollback(h),null):Ke({type:"literal",value:f},k,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,i){let a=Z(e,r).tokens;if(a.length<3)return null;let n=ze[r],o=new Set;if(n)for(let s of Object.keys(n))o.add(s.toLowerCase());for(let s=0;s<a.length-1;s++){let u=a[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))continue;let c=a[s+1],m=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&B.KNOWN_EVENTS.has(d)||B.KNOWN_EVENTS.has(m)||o.has(m)))continue;let f=d&&B.KNOWN_EVENTS.has(d)?d:n?.[m]??m,v=a.filter((A,D)=>D!==s&&D!==s+1);if(v.length===0)return null;let E=i.filter(A=>A.command!=="on"),y=new ie(v,r),h=this.coverageMark(),k=this.parseBodyWithClauses(y,E,r);return k.length===0?(this.coverageRollback(h),null):Ke({type:"literal",value:f},k,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,i){let a=B.SOV_EVENT_MARKERS[r];if(!a)return null;let o=Z(e,r).tokens,s=ze[r],u=new Set;if(s)for(let C of Object.keys(s))u.add(C.toLowerCase());let l=B.SOV_SOURCE_MARKERS[r],c=-1,m="",d="",p=1,f=[];for(let C=0;C<o.length;C++){let g=o[C],b=g.value.toLowerCase(),S=b,z="",w=b.indexOf("[");w>0&&(S=b.slice(0,w),z=g.value.slice(w));let x=g.normalized?.toLowerCase(),R=x&&(B.KNOWN_EVENTS.has(x)||Re.has(x)),T=u.has(b)||u.has(S),O=B.KNOWN_EVENTS.has(S)||Re.has(S);if(R||T||O){let N=o[C-1];if(N&&(N.normalized??N.value).toLowerCase()==="event")continue;let I;R?I=x:T?I=s?.[b]??s?.[S]??S:I=S;let j=this.matchEventParamPhrase(o,C+1);if(a.size>0){let _=1+j.len,Y=o[C+_];Y&&Y.kind==="selector"&&Y.value.startsWith("[")&&(_+=1);let X=o[C+_];if(X&&(X.kind==="particle"||X.kind==="keyword")&&a.has(X.value)){c=C,m=I,d=z||(_===j.len+2?o[C+_-1].value:""),p=_+1,f=j.names;break}}else {c=C,m=I,d=z,p=1+j.len+this.matchEventMarkerPhrase(o,C+1+j.len,r),f=j.names;break}}}if(c===-1){let C=new Set(i.filter(g=>g.command!=="on").map(g=>g.command));for(let g=0;g<o.length;g++){let b=o[g];if(b.kind==="identifier")if(a.size>0){let S=1,z=o[g+1];z&&z.kind==="selector"&&z.value.startsWith("[")&&(S=2);let w=o[g+S];if(w&&(w.kind==="particle"||w.kind==="keyword")&&a.has(w.value)){c=g,m=b.value,d=S===2?o[g+1].value:"",p=S+1;break}}else {let S=this.matchEventMarkerPhrase(o,g+1,r);if(S>0){c=g,m=b.value,d="",p=1+S;break}let z=o[g+1];if(z&&z.kind==="keyword"&&z.normalized!=null&&C.has(z.normalized)){c=g,m=b.value,d="",p=1;break}}}}if(c===-1)return null;let v=new Set;for(let C=c;C<c+p;C++)v.add(C);if(l){let C=c+p;if(C<o.length){let g=o[C];if((g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value))v.add(C);else if(this.isStrippableSourceRef(g,l.windowTokens)){let b=o[C+1];b&&(b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value)&&(v.add(C),v.add(C+1));}}if(c>=2){let g=o[c-1];(g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(v.add(c-2),v.add(c-1));}for(let g=0;g<c;g++){let b=o[g],S=b.value.toLowerCase(),z=b.normalized?.toLowerCase();if(l.windowTokens.has(S)||z&&l.windowTokens.has(z)){v.add(g);break}}}let E=o.filter((C,g)=>!v.has(g));if(E.length===0)return null;let y=i.filter(C=>C.command!=="on"),h=new ie(E,r),k=this.coverageMark(),A=this.parseBodyWithClauses(h,y,r);if(A.length===0)return this.coverageRollback(k),null;let D={sourceLanguage:r,confidence:.75};return d&&(D.keyFilter=d),Ke(B.isEnEventKeyword(m)?{type:"literal",value:m}:{type:"expression",raw:m},A,void 0,D,f)}profileKeywordMatches(e,r,i){let a=P(e)?.keywords?.[r];return a?a.primary?.toLowerCase()===i?true:!!a.alternatives?.some(n=>n.toLowerCase()===i):false}consumeForPostposition(e,r){let i=e.peek();if(!i)return;let a=(i.normalized??"").toLowerCase(),n=P(r)?.keywords?.for;(a==="for"||i.value===n?.primary||(n?.alternatives??[]).includes(i.value))&&e.advance();}isThenKeyword(e,r){let i=e.toLowerCase(),n={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\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 n?n.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(),a=jo(r);return a?i==="end"||a.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=P(r)?.roleMarkers?.patient;if(!i?.primary)return false;let a=e.value.toLowerCase();return i.primary.toLowerCase()===a?true:!!i.alternatives?.some(n=>n.toLowerCase()===a)}isJsBlockTerminator(e,r){return this.isEndKeyword(e,r)||this.profileKeywordMatches(r,"end",e.toLowerCase())}consumeVerbFinalJsBlock(e,r){let i=e.mark(),a=0,n=-1;for(;;){let c=e.peek(a);if(!c||this.isThenKeyword(c.value,r)||this.isJsBlockTerminator(c.value,r))break;if(this.isJsKeyword(c)){let m=e.peek(a+1),d=!!m&&c.position?.end!==void 0&&c.position.end===m.position?.start&&this.profileKeywordMatches(r,"js",`${c.value}${m.value}`.toLowerCase()),p=e.peek(a+(d?2:1));if(a>0&&p&&this.isJsBlockTerminator(p.value,r)){n=a;break}}a++;}if(n<=0)return null;let o=[];for(let c=0;c<n;c++){let m=e.peek(c);m&&o.push(m);}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<n;c++)e.advance();e.advance();let l=e.peek();return l&&!this.isJsBlockTerminator(l.value,r)&&e.advance(),e.advance(),ee("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 a=e.mark(),n=[];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}n.push(c);}if(!u)return e.reset(a),null;let l=this.rawJsBody(n);return ee("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,a=this.positionSource;if(a!==void 0&&r!==void 0&&i!==void 0){let o=a.slice(r,i),s=u=>u.replace(/\s+/g,"");if(s(o)===s(e.map(u=>u.value).join("")))return o.trim()}let n="";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&&(n+=" "),n+=e[o].value;}return n.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 a=e.peek();if(!a||!this.isUnlessKeyword((a.normalized??a.value).toLowerCase(),i))return null;let n=e.mark(),o=this.tryParseConditionalBlock(e,r,i,true);if(!o||o.kind!=="conditional")return e.reset(n),null;let s=o;if(s.elseBranch&&s.elseBranch.length>0)return e.reset(n),null;let u=s.roles.get("condition");return u?[ee("unless",{condition:u},{sourceLanguage:i,patternId:`unless-${i}-guard`,confidence:1}),...s.thenBranch]:(e.reset(n),null)}isBlockEndToken(e,r,i){return this.isEndKeyword(e.value,i)?true:e.kind!=="keyword"||(e.normalized??"").toLowerCase()!=="end"?false:!(r&&r.kind==="selector")}tryParseConditionalBlock(e,r,i,a=false){let n=e.peek();if(!n)return null;let o=(n.normalized??n.value).toLowerCase();if(!this.isIfKeyword(o,i)&&!(a&&this.isUnlessKeyword(o,i)))return null;let s=e.mark(),u=this.coverageMark();e.advance();let l=[],c=0;for(;!e.isAtEnd();){let b=e.peek();if(!b)break;let S=(b.normalized??b.value).toLowerCase();if(this.isIfKeyword(S,i)||this.isUnlessKeyword(S,i)){c++,l.push(b),e.advance();continue}if(this.isBlockEndToken(b,e.peek(1)??void 0,i)){if(c===0){e.advance();break}c--,l.push(b),e.advance();continue}l.push(b),e.advance();}if(l.length===0)return e.reset(s),this.coverageRollback(u),null;let m=P(i),d=m?.wordOrder==="SOV"?B.buildVerbLookup(m):null,p=0,f=0,v=[];for(;p<l.length;p++){let b=l[p],S=(b.normalized??b.value).toLowerCase();if(this.isIfKeyword(S,i)||this.isUnlessKeyword(S,i)?f++:this.isBlockEndToken(b,l[p+1],i)&&f--,f===0&&this.isThenKeyword(b.value,i)){p++;break}if(f===0&&v.length>0){let z=(l[p-1].normalized??l[p-1].value).toLowerCase(),w=l[p-1].value.toLowerCase(),x=(b.normalized??b.value).toLowerCase(),R=B.CONDITION_COPULAS.has(z)||B.CONDITION_COPULAS_SURFACE.has(w)&&B.CONDITION_PREDICATES.has(x),T=d!==null&&d.has(b.value.toLowerCase())&&!B.CONDITION_PREDICATES.has(x),O=/^\.[a-zA-Z_]\w*$/.test(b.value)&&l[p-1].position?.end!==void 0&&b.position?.start!==void 0&&l[p-1].position.end===b.position.start;if(!B.CONDITION_OPERATORS.has(x)&&!O&&(!R||T)&&(this.tokensBeginCommand(l.slice(p),r,i)||this.sovCommandStartsAt(l.slice(p),d)))break}v.push(b);}if(v.length===0)return e.reset(s),this.coverageRollback(u),null;let y=[],h=[],k=false,A=0;for(;p<l.length;p++){let b=l[p],S=(b.normalized??b.value).toLowerCase();if(this.isIfKeyword(S,i)||this.isUnlessKeyword(S,i)?A++:this.isBlockEndToken(b,l[p+1],i)&&A--,A===0&&!k&&this.isElseKeyword(b.value,i)){k=true;continue}(k?h:y).push(b);}let D={type:"expression",raw:this.joinTokenText(v,i)},C=this.parseBranch(y,r,i),g=h.length>0?this.parseBranch(h,r,i):void 0;return C.length===0&&(!g||g.length===0)?(e.reset(s),this.coverageRollback(u),null):wo(D,C,g,{sourceLanguage:i,patternId:`conditional-${i}-folded`,confidence:1})}joinTokenText(e,r){return Oe(e,P(r))}tokensBeginCommand(e,r,i){if(e.length===0)return false;let a=new ie(e,i);return oe.matchBest(a,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let i=s=>r.has(s.value.toLowerCase())||!!s.normalized&&r.has(s.normalized.toLowerCase()),a=s=>s.kind==="identifier"||s.kind==="selector"||s.kind==="literal"||s.kind==="reference",n=0,o=0;for(;n+1<e.length;){let s=e[n],u=e[n+1];if(!a(s)||u.kind!=="particle")break;o+=1,n+=2;let l=e[n];if(o>=1&&l&&i(l))return true}return false}parseBranch(e,r,i){if(e.length===0)return [];let a=new ie(e,i),n=this.parseBodyWithClauses(a,r,i);return n.length===1&&n[0]?.kind==="compound"?n[0].statements:n}extractStandaloneModifiers(e,r){let a=Z(e,r).tokens;if(a.length===0)return {modifiers:null,remainingInput:null};let o=a[0].value.toLowerCase(),s=B.STANDALONE_MODIFIERS[o];if(!s)return {modifiers:null,remainingInput:null};let u={},l=1;if(s==="once")u.once=true;else {let p=1;if(p<a.length){let f=a[p],v=a[p+1],E=f.kind==="identifier"&&v?.kind==="literal"&&/^\d+(ms|s|m)?$/.test(v.value);(f.kind==="keyword"||f.kind==="particle"||E)&&(p++,l++);}if(p<a.length){let f=a[p];if(f.kind==="literal"){let v=f.value.match(/^(\d+)(ms|s|m)?$/);if(v){let E=parseInt(v[1],10),y=v[2]||"ms";y==="s"?E*=1e3:y==="m"&&(E*=6e4),u[s]=E,l=p+1;}}}u[s]||(u[s]=s==="debounce"?300:100);}let c=a.slice(l);if(c.length===0)return {modifiers:null,remainingInput:null};let m=c[0].position.start,d=e.slice(m);return {modifiers:u,remainingInput:d}}stripAsyncModifier(e,r){let i=P(r)?.keywords?.async,a=new Set(["async"]);i?.primary&&a.add(i.primary.toLowerCase()),i?.alternatives?.forEach(l=>a.add(l.toLowerCase()));let n=Z(e,r).tokens,o=n.findIndex(l=>a.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let s=n[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 a=0;a<i.length-1;a++){if(i[a].value.toLowerCase()!=="do")continue;let n=-1;for(let l=a+1;l<=a+5&&l<i.length;l++){let c=i[l];if(c.normalized?.toLowerCase()==="throw"){n=l;break}let m=c.kind;if(m==="selector"||m==="literal"||m==="reference"||m==="conjunction")break}if(n===-1)continue;let o=i[a].position.start,s=i[n].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 a=/unconsumed: "(.*)"$/.exec(i.message)?.[1];return !a||a.replace(/\s+/g," ").trim()!==r})}}reclaimDanglingFromTail(e,r,i){let a=B.droppedTokenCount,n=B.unconsumedSpans(e);if(n.length===0)return null;let o=a(e),s=P(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 m=l[c];if(m.normalized!=="source"&&!u.has(m.value))continue;let d=s?.position==="after"?c-1:c+1,p=l[d];if(!p||p.kind!=="identifier"&&p.kind!=="keyword")continue;let f=Math.min(m.position.start,p.position.start),v=Math.max(m.position.end,p.position.end),E=r.slice(f,v).replace(/\s+/g," ").trim();if(!n.some(h=>h===E||h.includes(E)))continue;let y=(r.slice(0,f).trimEnd()+" "+r.slice(v).trimStart()).trim();if(!(!y||y===r))try{let h=this.parse(y,i);if(!h||h.kind!=="event-handler")continue;let k=br(h);if(a(k)<o)return {node:{...k,eventModifiers:{...k.eventModifiers,from:{type:"literal",value:p.value,dataType:"string"}}},input:y}}catch{}}return null}reclaimEventCompoundTail(e,r,i){let a=B.unconsumedSpans(e);if(a.length===0)return null;let n=ze[i];if(!n)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=m=>m.replace(/\s+/g," ").trim(),c=Z(r,i).tokens;for(let m of a)for(let d=1;d<c.length;d++)for(let p=d;p<c.length;p++){let f=l(r.slice(c[d].position.start,c[p].position.end));if(f.length>m.length)break;if(f!==m)continue;let v=c[d-1];if((n[v.value]??v.normalized)!==u)break;let y=l(r.slice(v.position.start,c[p].position.end)),h=n[y];if(!h)break;return o.set("event",{type:"literal",value:h,dataType:"string"}),{node:B.withoutSpanDiagnostics(e,m),input:r}}return null}reclaimResponseTypeTail(e,r,i){let a=B.unconsumedSpans(e);if(a.length===0)return null;let n=B.AS_MARKERS_BEFORE[i];if(!n)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],m=u[l+1];if(!n.some(f=>c.value.toLowerCase()===f)||!B.RESPONSE_TYPE_WORDS.has(m.value.toLowerCase()))continue;let d=o(r.slice(c.position.start,m.position.end));if(!a.includes(d))continue;let p=(r.slice(0,c.position.start).trimEnd()+" "+r.slice(m.position.end).trimStart()).trim();if(!(!p||p===r))try{let f=this.parse(p,i);if(!f||f.kind!=="event-handler")continue;let v=br(f);if(B.droppedTokenCount(v)>=s)continue;let E=B.findResponseTypeTarget(v);if(!E)continue;return E.roles.set("responseType",{type:"expression",raw:m.value}),{node:v,input:p}}catch{}}return null}static findResponseTypeTarget(e){let r=null,i=a=>{if(!a||typeof a!="object"||r)return;if(a.kind==="command"){let o=a;if(re(o.action)?.roles.some(u=>u.role==="responseType"&&!u.required)&&!o.roles.has("responseType")){r=o;return}}let n=a;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let s=n[o];Array.isArray(s)&&s.forEach(u=>i(u));}};return i(e),r}reclaimCapturedDestinationTail(e,r,i){let a=B.unconsumedSpans(e);if(a.length===0)return null;let n=P(i)?.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 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],m=u[l+1],d=o.has(c.value)&&m.normalized==="me",p=c.normalized==="me"&&o.has(m.value);if(!d&&!p)continue;let f=s(r.slice(c.position.start,m.position.end));if(!a.includes(f))continue;let v=false,E=y=>{if(!y||typeof y!="object"||v)return;if(y.kind==="command"){let k=y.roles.get("destination");if(k?.type==="reference"&&k.value==="me"){v=true;return}}let h=y;for(let k of ["body","statements","thenBranch","elseBranch","commands"]){let A=h[k];Array.isArray(A)&&A.forEach(D=>E(D));}};if(E(e),!!v)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 a=e.mark(),n=e.peek();if(!n)break;if(!Sr(n,r)){e.reset(a);break}e.advance();let o=e.peek();if(!o){e.reset(a);break}let s=(o.normalized||o.value).toLowerCase();e.advance(),i.push({type:"literal",value:s});}return i}};Q.coverageMarkerSurfaces=new Map;Q.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};Q.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"]};Q.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};Q.enEventKeywordCache=new Map;Q.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);Q.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);Q.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"])};Q.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};Q.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"])}};Q.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);Q.CONDITION_COPULAS_SURFACE=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948"]);Q.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);Q.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Q.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};var Us=Q,Gs=new Us;function Zs(t,e){return Gs.parse(t,e)}function Ys(t,e){try{let r=Z(t,e),i=he(e);if(i.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let a=[...i].sort((l,c)=>c.priority-l.priority),n=a.filter(l=>l.command==="on"),o=oe.matchBest(r,n);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=a.filter(l=>l.command!=="on"),u=oe.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 ai(t,e){try{let i=Zs(t,e);if(i)return {node:i,confidence:i.metadata?.confidence??.8,error:void 0,tokensConsumed:Z(t,e).tokens.length}}catch{}let r=Ys(t,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function ni(t,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...t].sort((i,a)=>{let n=i[r]??99,o=a[r]??99;return n-o})}function Me(t,e){let r,i;if(t.markerOverride&&t.markerOverride[e.code]!==void 0)r=t.markerOverride[e.code],i=r?Ee(t,e.code,r):void 0;else {let a=e.roleMarkers[t.role];if(a){r=a.primary;let n=Ee(t,e.code,r)??[],o=[...new Set([...a.alternatives??[],...n])].filter(s=>s!==r);i=o.length?o:void 0;}}return {marker:r,alternatives:i}}function Je(t,e,r){r.roles.find(a=>a.role==="scope"&&!a.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 jr(t,e,r,i){si(t,e,r,i,"manner",{requireMarker:true});}function oi(t,e,r,i){si(t,e,r,i,"recipient",{requireMarker:false});}function si(t,e,r,i,a,n){let o=r.roles.find(u=>u.role===a&&!u.required);if(!o)return;let s=o.markerOverride?.[i];n.requireMarker&&!s||(t.push({type:"group",optional:true,tokens:[...(s?s.split(/\s+/):[]).map(u=>({type:"literal",value:u})),{type:"role",role:a,optional:true,expectedTypes:o.expectedTypes,...o.valueShape!==void 0?{valueShape:o.valueShape}:{}}]}),e[a]={fromRole:a});}function ui(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 li(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:a,alternatives:n}=Me(i,e),o={type:"role",role:r,optional:false,...i.valueShape!==void 0?{valueShape:i.valueShape}:{}};if(!a)return [o];let s=a.split(/\s+/).filter(Boolean),u={type:"group",optional:true,tokens:s.map(c=>({type:"literal",value:c,...s.length===1&&n?.length?{alternatives:n}:{}}))};return (e.roleMarkers[r]?.position??"before")==="after"?[o,u]:[u,o]}function ci(t,e,r,i,a){for(let n of r.roles)n.required||a.has(n.role)||e[n.role]||!(n.markerOverride?.[i.code]??i.roleMarkers[n.role]?.primary)&&n.valueShape===void 0||(t.push({type:"group",optional:true,tokens:pi(n,i)}),e[n.role]=n.default?{fromRole:n.role,default:n.default}:{fromRole:n.role});}function Xs(t,e,r,i,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let f=i.primary.split(/\s+/);if(f.length>1)for(let v of f)n.push({type:"literal",value:v});else {let v=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(v);}}let o=ui(t),s=e.roleMarkers.destination,u=t.roles.some(f=>f.role==="destination");s&&u&&o!=="destination"&&n.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"&&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(...li(t,e,o));let m=e.roleMarkers.patient;if(m&&o==="patient"){let f=m.alternatives?{type:"literal",value:m.primary,alternatives:m.alternatives}:{type:"literal",value:m.primary};n.push(f);}let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(d),o!=="source"&&n.push(...Se(t,e.roleMarkers.source)),o!=="destination"&&n.push(...Fr(t,e.roleMarkers.destination));let p={action:{value:t.action},event:{fromRole:"event"},[o]:{fromRole:o},...o==="destination"?{}:De(t),...o==="source"?{}:xe(t)};return ci(n,p,t,e,new Set(["event",o,"destination","source"])),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`{event} ${i.primary} {destination?} {${o}} ${m?.primary||""} ${r.primary}`,tokens:n},extraction:p}}function Js(t,e,r,i,a){let n=[],o=t.action==="swap",s=o?"destination":"patient";n.push({type:"role",role:s,optional:false});let u=e.roleMarkers.patient;if(u){let d=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};n.push(d);}if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let d=i.primary.split(/\s+/);if(d.length>1)for(let p of d)n.push({type:"literal",value:p});else {let p=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(p);}}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(l),n.push(...Se(t,e.roleMarkers.source));let c=e.roleMarkers.destination;if(o&&c){let d=t.roles.find(p=>p.role==="patient")?.markerOverride?.[e.code];if(d&&d!==c.primary){let p=c.alternatives??[];p.includes(d)||(c={...c,alternatives:[...p,d]});}}n.push(...o?za(t,c):Fr(t,c));let m={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...o?{}:De(t),...xe(t)};return oi(n,m,t,e.code),jr(n,m,t,e.code),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`{patient} ${u?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:n},extraction:m}}function Qs(t,e,r,i,a){let n=t.roles.find(m=>m.role==="source");if(!n)return null;let{marker:o,alternatives:s}=Me(n,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,...n.expectedTypes?{expectedTypes:n.expectedTypes}:{},...n.valueShape!==void 0?{valueShape:n.valueShape}:{}});for(let m of o.split(/\s+/))l.push(s&&o.split(/\s+/).length===1?{type:"literal",value:m,alternatives:s}:{type:"literal",value:m});if(l.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let d of m)l.push({type:"literal",value:d});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 oi(l,c,t,e.code),jr(l,c,t,e.code),{id:`${t.action}-event-${e.code}-sov-source-fronted`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{patient} ${u?.primary||""} {source} ${o} {event} ${i.primary} ${r.primary}`,tokens:l},extraction:c}}function eu(t,e,r,i,a){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 s=e.roleMarkers.destination;if(s&&(n.push({type:"role",role:"destination",optional:false}),n.push(s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary})),n.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)n.push({type:"literal",value:c});else {let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(c);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),{id:`${t.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(a.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${s?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function ru(t,e,r,i,a){let n=[];n.push({type:"role",role:"event",optional:false});let o=i.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&n.push({type:"literal",value:o[0],alternatives:o.slice(1)});let s=e.roleMarkers.destination;s&&n.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}]}),n.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};n.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(l),n.push(...Se(t,e.roleMarkers.source)),n.push(...Fr(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(a.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...De(t),...xe(t)}}}function tu(t,e,r,i,a){let n=[];if(n.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)n.push({type:"literal",value:u});else {let u=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(u);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(o),{id:`${t.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{event} ${i.primary} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function iu(t,e,r,i){let a=e.eventHandler?.temporalMarkers;if(!a||a.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:a[0],alternatives:a.slice(1)}),n.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};n.push(u);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),{id:`${t.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(i.basePriority??100)+49,template:{format:`{event} ${a[0]} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function au(t,e,r,i,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let d of m)n.push({type:"literal",value:d});else {let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(d);}}let s=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.sovPosition??999,f=d.sovPosition??999;return p-f});for(let m of s){n.push({type:"role",role:m.role,optional:false});let{marker:d,alternatives:p}=Me(m,e);if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};n.push(f);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u);let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Je(n,c,t),{id:`${t.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`{event} ${i.primary} ${l} ${r.primary}`,tokens:n},extraction:c}}function nu(t,e,r,i,a){let n=[],s=[...t.roles.filter(c=>c.required)].sort((c,m)=>{let d=c.sovPosition??999,p=m.sovPosition??999;return d-p});for(let c of s){n.push({type:"role",role:c.role,optional:false});let{marker:m,alternatives:d}=Me(c,e);m&&n.push(d?{type:"literal",value:m,alternatives:d}:{type:"literal",value:m});}if(n.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),n.push({type:"role",role:"event",optional:false}),i.position==="after"){let c=i.primary.split(/\s+/);if(c.length>1)for(let m of c)n.push({type:"literal",value:m});else n.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 Je(n,l,t),{id:`${t.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(a.basePriority??100)+40,template:{format:`${u} ${r.primary} {event} ${i.primary}`,tokens:n},extraction:l}}function ou(t,e,r,i,a){let n=[],s=[...t.roles.filter(E=>E.required)].sort((E,y)=>{let h=E.sovPosition??999,k=y.sovPosition??999;return h-k}),u=s[0];n.push({type:"role",role:u.role,optional:false});let{marker:l,alternatives:c}=Me(u,e);if(l){let E=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};n.push(E);}if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let E=i.primary.split(/\s+/);if(E.length>1)for(let y of E)n.push({type:"literal",value:y});else {let y=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(y);}}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(m);let d=s[1];n.push({type:"role",role:d.role,optional:false});let{marker:p,alternatives:f}=Me(d,e);if(p){let E=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};n.push(E);}let v={action:{value:t.action},event:{fromRole:"event"},[u.role]:{fromRole:u.role},[d.role]:{fromRole:d.role}};return Je(n,v,t),{id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{${u.role}} {event} ${i.primary} ${r.primary} {${d.role}}`,tokens:n},extraction:v}}function mi(t,e,r){let i=Ee(t,e.code,r.primary)??[],a=[...new Set([...r.alternatives??[],...i])].filter(n=>n!==r.primary);return a.length?a:void 0}function Ct(t,e,r,i,a){let n=[];if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(m);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=ui(t);n.push(...li(t,e,s));let u=e.roleMarkers.destination,l=t.roles.some(m=>m.role==="destination");u&&l&&s!=="destination"&&n.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"&&n.push(...Se(t,e.roleMarkers.source));let c={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...s==="destination"?{}:De(t),...s==="source"?{}:xe(t)};return ci(n,c,t,e,new Set(["event",s,"destination","source"])),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`${i.primary} {event} ${r.primary} {${s}} ${u?.primary||""} {destination?}`,tokens:n},extraction:c}}function su(t,e,r,i,a){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=t.action==="swap";n.push({type:"role",role:s?"destination":"patient",optional:false});let u=s?void 0:e.roleMarkers.destination;if(u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),n.push(...Se(t,e.roleMarkers.source)),i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(c);}if(n.push({type:"role",role:"event",optional:false}),s){let c=t.roles.find(m=>m.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:t.action},event:{fromRole:"event"},[s?"destination":"patient"]:{fromRole:s?"destination":"patient"},...s?{}:De(t),...xe(t)};return jr(n,l,t,e.code),{id:`${t.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${i.primary} {event}`,tokens:n},extraction:l}}function uu(t,e,r,i,a){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let u=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.svoPosition??999,f=d.svoPosition??999;return p-f});for(let m of u){let d,p;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)d=m.markerOverride[e.code],p=d?Ee(m,e.code,d):void 0;else {let f=e.roleMarkers[m.role];f&&(d=f.primary,p=mi(m,e,f));}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};n.push(f);}n.push({type:"role",role:m.role,optional:false});}if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(m);}n.push({type:"role",role:"event",optional:false});let l=u.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Je(n,c,t),{id:`${t.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${r.primary} ${l} ${i.primary} {event}`,tokens:n},extraction:c}}function At(t,e,r,i,a){let n=[];if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(m);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let u=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.svoPosition??999,f=d.svoPosition??999;return p-f});for(let m of u){let d,p;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)d=m.markerOverride[e.code],p=d?Ee(m,e.code,d):void 0;else {let f=e.roleMarkers[m.role];f&&(d=f.primary,p=mi(m,e,f));}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};n.push(f);}n.push({type:"role",role:m.role,optional:false});}let l=u.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Je(n,c,t),{id:`${t.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`${i.primary} {event} ${r.primary} ${l}`,tokens:n},extraction:c}}function lu(t,e,r,i,a){let n=[],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};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 s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(s),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),n.push(...Se(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${i.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...De(t),...xe(t)}}}function cu(t,e,r,i){let a=[];a.push({type:"literal",value:"and",alternatives:["then"]}),a.push({type:"role",role:"event",optional:false});let n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(n),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&a.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}]}),a.push(...Se(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:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...De(t),...xe(t)}}}var je={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Ye(t,e,r=je){let i=`${t.action}-${e.code}-generated`,a=r.basePriority??100,n=e.keywords[t.action];if(!n)throw new Error(`No keyword translation for '${t.action}' in ${e.code}`);let o=fu(t,e,n),s=$r(t,e),u=Eu(t,e,n);return {id:i,language:e.code,command:t.action,priority:a,template:{format:u,tokens:o},extraction:s}}function mu(t,e,r=je){if(t.roles.filter(s=>!s.required).length===0)return null;let a=t.roles.filter(s=>s.required),n={...t,roles:a};return {...Ye(n,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:$r(t,e)}}function Dt(t,e,r=je){if(e.wordOrder!=="SOV")return null;let i=t.roles.filter(s=>s.required);if(i.length!==1)return null;let a=e.keywords[t.action];if(!a)return null;let n=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.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:`${a.primary} <${i[0].role}>`,tokens:[n,...o]},extraction:$r(t,e)}}function du(t,e,r=je){let i=[];if(i.push(Ye(t,e,r)),r.generateSimpleVariants){let a=mu(t,e,r);a&&i.push(a);}for(let a of t.omitRoleVariants??[]){let n={...t,roles:t.roles.filter(s=>s.role!==a)},o=Ye(n,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-no-${a}`,priority:(r.basePriority??100)-8});}for(let a of t.widenTypeVariants??[]){if(a.excludeLanguages?.includes(e.code))continue;let n={...t,roles:t.roles.map(s=>s.role===a.role?{...s,expectedTypes:[...a.types]}:s)},o=Ye(n,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-${a.idSuffix}`,priority:(r.basePriority??100)-(a.priorityDelta??15)});}if(r.generateVerbFirstVariants!==false){let a=Dt(t,e,r);a&&i.push(a);}for(let a of t.rolePrefixLiteralVariants??[]){let n=a.literal[e.code];if(!n)continue;let{rolePrefixLiteralVariants:o,...s}=t,u={...s,roles:t.roles.map(d=>d.role===a.role?{...d,valuePrefixLiteral:{[e.code]:n}}:d)},l=a.priorityDelta??5,c=a.methodCarrier?{[a.methodCarrier]:{value:n}}:{},m=Ye(u,e,r);if(i.push({...m,id:`${t.action}-${e.code}-generated-${a.idSuffix}`,priority:(r.basePriority??100)+l,extraction:{...m.extraction,...c}}),r.generateVerbFirstVariants!==false){let d=Dt(u,e,r);d&&i.push({...d,id:`${t.action}-${e.code}-generated-verb-first-${a.idSuffix}`,priority:(r.basePriority??100)-20+l,extraction:{...d.extraction,...c}});}}return i}function di(t,e=je){let r=[],i=$n();for(let a of i){if(!t.keywords[a.action])continue;let n=du(a,t,e);if(r.push(...n),t.eventHandler?.eventMarker){let o=pu(a,t,e);r.push(...o);}}return r}function pu(t,e,r=je){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let i=[],a=e.eventHandler.eventMarker,n=e.keywords[t.action];if(!n)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(au(t,e,n,a,r)),i.push(ou(t,e,n,a,r)),i.push(nu(t,e,n,a,r));else {i.push(Xs(t,e,n,a,r)),i.push(Js(t,e,n,a,r));let u=Qs(t,e,n,a,r);u&&i.push(u);let l=e.roleMarkers.destination;l&&l.primary!==a.primary&&i.push(eu(t,e,n,a,r));let c=a.primary.split(/\s+/),m=a.alternatives?.some(p=>!p.includes(" ")&&p.length>1);c.length>1&&m&&i.push(ru(t,e,n,a,r)),i.push(tu(t,e,n,a,r));let d=iu(t,e,n,r);d&&i.push(d);}else e.wordOrder==="VSO"?s?(i.push(At(t,e,n,a,r)),i.push(uu(t,e,n,a,r))):(i.push(Ct(t,e,n,a,r)),i.push(su(t,e,n,a,r)),e.eventHandler?.negationMarker&&i.push(lu(t,e,n,a,r)),e.tokenization?.prefixes&&i.push(cu(t,e,n,r))):s?i.push(At(t,e,n,a,r)):i.push(Ct(t,e,n,a,r));return i}function fu(t,e,r){let i=[],a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},n=hu(t,e);switch(e.wordOrder){case "SVO":i.push(a),i.push(...n);break;case "SOV":i.push(...n),i.push(a);break;case "VSO":i.push(a),i.push(...n);break;default:i.push(a),i.push(...n);}return yu(i)}function yu(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 a=[...i.alternatives??[],...r.alternatives??[]];a.length&&(e[e.length-1]={...i,alternatives:[...new Set(a)]});continue}e.push(r);}return e}function hu(t,e){let r=[],i=ni(t.roles,e.wordOrder);for(let a of i){let n=pi(a,e);a.required?r.push(...n):r.push({type:"group",optional:true,tokens:n});}return r}function pi(t,e){let r=[],i=t.markerOverride?.[e.code],a=e.roleMarkers[t.role],n=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,m=a?.position??(e.wordOrder==="SOV"&&!c?"after":"before"),d=t.markerOptional?.[e.code]===true,p=f=>{let v=l.length===1?Ee(t,e.code,f)??[]:[],E={type:"literal",value:f,...v.length?{alternatives:v}:{},...n?{renderSuppress:true}:{}};r.push(d?{type:"group",optional:true,tokens:[E]}:E);};if(m==="before"){for(let f of l)p(f);u();}else {u();for(let f of l)p(f);}}else if(a){let l=()=>{let m=[...new Set([...a.alternatives??[],...Ee(t,e.code,a.primary)??[]])].filter(d=>d!==a.primary);return {type:"literal",value:a.primary,...m.length?{alternatives:m}:{},...n?{renderSuppress:true}:{}}},c=m=>{if(!e.markersOptional&&!t.markerOptional?.[e.code]){r.push(m);return}r.push({type:"group",optional:true,...e.markersOptional&&!t.markerOptional?.[e.code]?{renderRequired:true}:{},tokens:[m]});};a.position==="before"?(a.primary&&c(l()),u()):(u(),c(l()));}else u();return r}function vu(t,e){let r={};for(let i of t.roles){let a=i.markerOverride?.[e.code],n=e.roleMarkers[i.role];if(i.valuePrefixLiteral?.[e.code])r[i.role]={marker:i.valuePrefixLiteral[e.code]};else if(a!==void 0)if(!a)r[i.role]={};else {let s=!/\s/.test(a.trim())?Ee(i,e.code,a)??[]:[];r[i.role]=s.length?{marker:a,markerAlternatives:s}:{marker:a};}else if(n&&n.primary){let o=[...new Set([...n.alternatives??[],...Ee(i,e.code,n.primary)??[]])].filter(s=>s!==n.primary);r[i.role]=o.length?{marker:n.primary,markerAlternatives:o}:{marker:n.primary};}else r[i.role]={};}return r}function $r(t,e){let r=vu(t,e),i={};for(let a of t.roles){let n=r[a.role]||{};!a.required&&a.default?i[a.role]={...n,default:a.default}:i[a.role]=n;}return i}function Eu(t,e,r){let i=[],n=ni(t.roles,e.wordOrder).map(o=>{let s=bo(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,...n);break;case "SOV":i.push(...n,r.primary);break;default:i.push(r.primary,...n);}return i.join(" ")}var gu=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),a=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(i,{result:r,createdAt:a,lastAccessed:a});}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 gu;var hi={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"]}},zu=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],ku=class{constructor(t=zu){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}},wu="()[]{},:;",bu=class{constructor(t=wu){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 Vr(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function fi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=Vr(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=Vr(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=Vr(t,a+1);return t.slice(e,n)}a++;}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 Cu=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?fi(t,e)!==null:false}extract(t,e){let r=fi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Au=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},Du=["http://","https://","//","./","../","/"];function xu(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function Su(t,e){let r=t.slice(e),i=Du.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=xu(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var Bu=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=Su(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Tu=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"}}}},Fu=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 Ru(){let t=/[a-zA-Z]/;return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:Ou,isIdentifierChar:yi}=Ru(),Pu=class{constructor(){this.name="indonesian-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Ou(t[e])}extract(t,e){if(!this.context)throw new Error("IndonesianKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&yi(t[r]);)i+=t[r++];if(this.context&&r<t.length&&t[r]==="_"){let l=r,c=i;for(;l<t.length&&(t[l]==="_"||yi(t[l]));)c+=t[l++];this.context.lookupKeyword(c.toLowerCase())&&(i=c,r=l);}if(!i)return null;let a=i.toLowerCase(),n=Fu.has(a),o=this.context.lookupKeyword(a),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:n}}}};function _u(){return [new Pu]}function Nu(){return [new Bu,new Au,new Tu,new Cu]}var Lu=new Set(["di","ke","dari","pada","dengan","tanpa","untuk","oleh","antara","sebelum","sesudah","setelah","selama","sampai","hingga","sejak","menuju","tentang","terhadap","melalui","dalam","luar"]),Mu=[{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"}],Iu=class extends de{constructor(){super(),this.language="id",this.direction="ltr",this.initializeKeywordsFromProfile(hi,Mu),this.registerExtractors(Nu()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(_u()),this.registerExtractor(new ku),this.registerExtractor(new bu);}classifyToken(t){let e=t.toLowerCase();return Lu.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"}},ju=new Iu;ye("id",ju,hi);var Ei={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"}}},$u=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Vu=class{constructor(t=$u){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}},Wu="()[]{},:;",qu=class{constructor(t=Wu){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 Wr(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function vi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=Wr(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=Wr(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=Wr(t,a+1);return t.slice(e,n)}a++;}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 Ku=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?vi(t,e)!==null:false}extract(t,e){let r=vi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Hu=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},Uu=["http://","https://","//","./","../","/"];function Gu(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function Zu(t,e){let r=t.slice(e),i=Uu.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=Gu(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var Yu=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=Zu(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Xu=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 Ju(t){return /[a-zA-Z_]/.test(t)}function Qu(t){return /[a-zA-Z0-9_]/.test(t)}var el=class{constructor(){this.name="malay-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Ju(t[e])}extract(t,e){if(!this.context)throw new Error("MalayKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&Qu(t[r]);)i+=t[r++];if(!i)return null;let a=i.toLowerCase(),n=this.context.lookupKeyword(a),o=n&&n.normalized!==n.native?n.normalized:void 0;return {value:i,length:i.length,metadata:{normalized:o}}}};function rl(){return [new el]}function tl(){return [new Yu,new Hu,new Xu,new Ku]}var il=[{native:"benar",normalized:"true"},{native:"salah",normalized:"false"},{native:"kosong",normalized:"null"},{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"}],al=class extends de{constructor(){super(),this.language="ms",this.direction="ltr",this.initializeKeywordsFromProfile(Ei,il),this.registerExtractors(tl()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(rl()),this.registerExtractor(new Vu),this.registerExtractor(new qu);}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"}},nl=new al;ye("ms",nl,Ei);var zi={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 ol(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:t==="\xF1"||t==="\xD1"}function sl(t){for(let e of t)if(ol(e))return true;return false}var ul=[{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}],ll=[{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}],cl=["um","in"],ml=[{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 dl(t){let e=t.toLowerCase();if(e.length<5)return null;let r=0;for(let i=0;i<e.length;i++){let a=e[i];if(!"aeiou".includes(a))r=i+1;else break}if(r===0)return null;for(let i of cl){let a=r;if(e.slice(a,a+i.length)===i){let n=e.slice(0,r)+e.slice(a+i.length);if(n.length>=3)return {stem:n,infix:i}}}return null}function pl(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 a=e.slice(2);if(a.length>=2&&a[0]===r)return {stem:a,reduplicated:true}}return {stem:e,reduplicated:false}}var fl=class{constructor(){this.language="tl";}isNormalizable(t){return !(!sl(t)||t.length<2)}normalize(t){let e=t.toLowerCase(),r=1,i=[],a=[],n=[];for(let l of ul)if(e.startsWith(l.pattern)){let c=e.slice(l.pattern.length),m=l.minRemaining??2;if(c.length>=m){e=c,r-=l.confidencePenalty,i.push(l.pattern),n.push(`prefix:${l.pattern}`);break}}if(i.length===0){for(let l of ll)if(e.startsWith(l.pattern)){let c=e.slice(l.pattern.length),m=l.minRemaining??2;if(c.length>=m){e=c,r-=l.confidencePenalty,i.push(l.pattern),n.push(`prefix:${l.pattern}`);break}}}let o=pl(e);o.reduplicated&&o.stem.length>=2&&(e=o.stem,r-=.1,n.push("reduplication:CV"));let s=dl(e),u=false;if(s&&s.stem.length>=2&&(e=s.stem,r-=.18,n.push(`infix:${s.infix}`),u=true),!u){for(let l of ml)if(e.endsWith(l.pattern)){let c=e.slice(0,-l.pattern.length);if(c.length>=2){e=c,r-=l.confidencePenalty,a.push(l.pattern),n.push(`suffix:${l.pattern}`);break}}}return r=Math.max(.5,r),i.length===0&&a.length===0&&n.length===0?at(t):nt(e,r,{removedPrefixes:i,removedSuffixes:a,appliedRules:n})}},yl=new fl,hl=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],vl=class{constructor(t=hl){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}},El="()[]{},:;",gl=class{constructor(t=El){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 qr(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function gi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=qr(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=qr(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=qr(t,a+1);return t.slice(e,n)}a++;}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 zl=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?gi(t,e)!==null:false}extract(t,e){let r=gi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},kl=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},wl=["http://","https://","//","./","../","/"];function bl(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function Cl(t,e){let r=t.slice(e),i=wl.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=bl(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var Al=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=Cl(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Dl=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 xl(t){return /[a-zA-Z_]/.test(t)}function Sl(t){return /[a-zA-Z0-9_]/.test(t)}var Bl=new Set(["sa","ng","para","mula","hanggang","gaya","tulad","kasama","para sa"]),Tl=class{constructor(){this.name="tagalog-keyword";}setContext(t){this.context=t;}canExtract(t,e){return xl(t[e])}extract(t,e){if(!this.context)throw new Error("TagalogKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&Sl(t[r]);)i+=t[r++];if(!i)return null;let a=i.toLowerCase(),n=Bl.has(a),o=this.context.lookupKeyword(a),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:n}}}};function Fl(){return [new Tl]}function Rl(){return [new Al,new kl,new Dl,new zl]}var Ol=[{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"}],Pl=class extends de{constructor(){super(),this.language="tl",this.direction="ltr",this.initializeKeywordsFromProfile(zi,Ol),this.setNormalizer(yl),this.registerExtractors(Rl()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(Fl()),this.registerExtractor(new vl),this.registerExtractor(new gl);}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"}},_l=new Pl;ye("tl",_l,zi);var wi={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"]}},Nl=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Ll=class{constructor(t=Nl){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}},Ml="()[]{},:;",Il=class{constructor(t=Ml){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 Kr(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function ki(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=Kr(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=Kr(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=Kr(t,a+1);return t.slice(e,n)}a++;}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 jl=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?ki(t,e)!==null:false}extract(t,e){let r=ki(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},$l=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},Vl=["http://","https://","//","./","../","/"];function Wl(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function ql(t,e){let r=t.slice(e),i=Vl.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=Wl(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var Kl=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=ql(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Hl=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 Qe(t){let e=t.charCodeAt(0);return e>=3584&&e<=3711}function Hr(t){return /[a-zA-Z0-9_]/.test(t)}var Ul=class{constructor(){this.name="thai-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Qe(t[e])||Hr(t[e])}extract(t,e){if(!this.context)throw new Error("ThaiKeywordExtractor: context not set");let r=t[e];return Qe(r)?this.extractThaiWord(t,e):Hr(r)?this.extractAsciiWord(t,e):null}extractThaiWord(t,e){if(!this.context)return null;let r=null,i=e,a="";for(;i<t.length&&Qe(t[i]);){a+=t[i],i++;let s=this.context.lookupKeyword(a);s&&(r={word:a,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 n=e,o="";for(;n<t.length&&Qe(t[n])&&!(o.length>0&&this.isKeywordStart(t,n));)o+=t[n],n++;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&&Hr(t[r]);)i+=t[r++];if(!i)return null;let a=i.toLowerCase(),n=this.context.lookupKeyword(a),o=n&&n.normalized!==n.native?n.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&&Qe(t[r]);){if(i+=t[r],r++,this.context.lookupKeyword(i))return true;if(i.length>10)break}return false}};function Gl(){return [new Ul]}function Zl(){return [new Kl,new $l,new Hl,new jl]}var Yl=[{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"}],Xl=class extends de{constructor(){super(),this.language="th",this.direction="ltr",this.initializeKeywordsFromProfile(wi,Yl),this.registerExtractors(Zl()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(Gl()),this.registerExtractor(new Ll),this.registerExtractor(new Il);}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"}},Jl=new Xl;ye("th",Jl,wi);var Ci={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 Ql(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:ec,isIdentifierChar:rc}=Ql(/[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]/),tc=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"]),ic=class{constructor(){this.name="vietnamese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return ec(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,a="";for(;i<t.length&&rc(t[i]);)a+=t[i++];if(!a)return null;let n=a.toLowerCase(),o=tc.has(n),s=this.context.lookupKeyword(n),u=s&&s.normalized!==s.native?s.normalized:void 0;return {value:a,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 n=e+i.length;if(n>=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[n])){let o=this.context.lookupKeyword(i);return {value:t.slice(e,n),length:i.length,metadata:{normalized:o?.normalized,isPreposition:false}}}}return null}};function ac(){return [new ic]}var nc=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],oc=class{constructor(t=nc){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}},sc="()[]{},:;",uc=class{constructor(t=sc){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 Ur(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function bi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=Ur(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=Ur(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=Ur(t,a+1);return t.slice(e,n)}a++;}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 lc=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?bi(t,e)!==null:false}extract(t,e){let r=bi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},cc=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},mc=["http://","https://","//","./","../","/"];function dc(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function pc(t,e){let r=t.slice(e),i=mc.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=dc(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var fc=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=pc(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},yc=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 hc(){return [new fc,new cc,new yc,new lc]}var vc=[{native:"\u0111\xFAng",normalized:"true"},{native:"sai",normalized:"false"},{native:"null",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:"r\u1ED7ng",normalized:"empty"},{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"}],Ec=class extends de{constructor(){super(),this.language="vi",this.direction="ltr",this.initializeKeywordsFromProfile(Ci,vc),this.registerExtractors(hc()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(ac()),this.registerExtractor(new oc),this.registerExtractor(new uc);}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"}},gc=new Ec;ye("vi",gc,Ci);function pr(t){let e=t.getAttribute("data-lang");if(e)return dr(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return dr(r);let i=t.closest?.("[lang]")?.getAttribute("lang");if(i)return dr(i);let a=typeof document<"u"?document.documentElement?.lang:null;return a&&a!=="en"?dr(a):null}function dr(t){return t.split("-")[0].toLowerCase()}var Ai={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],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",""]],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 zc=new Set(["repeat","for","while","tell"]),kc=new Set(["js"]);function fr(t){switch(t.kind){case "event-handler":return wc(t);case "compound":return bc(t);default:return Cc(t)}}function wc(t){let e=["on"],r=t.roles.get("event");r&&e.push(r.type==="literal"?String(r.value):er(r));let i=t.roles.get("source");if(i&&e.push("from",er(i)),t.body&&t.body.length>0){let a=t.body.map(fr);e.push(a.join(" "));}return e.join(" ")}function bc(t){let e=t.chainType==="async"?"async":t.chainType,r=t.statements.map(fr),i=r[0]??"";for(let a=1;a<r.length;a++){let n=t.statements[a-1],o=t.statements[a],s=n.kind==="command"&&zc.has(n.action),u=n.kind==="command"&&n.action==="bind"&&o.kind==="command"&&o.action==="bind";n.kind==="command"&&kc.has(n.action)&&(i+=" end"),i+=(s||u?" ":` ${e} `)+r[a];}return i}function Cc(t){let e=Ai[t.action];if(e){let i=[t.action];for(let[a,n]of e){let o=t.roles.get(a);o&&((a==="destination"||a==="source")&&o.type==="reference"&&o.value==="me"||(n&&i.push(n),i.push(er(o))));}return i.join(" ")}let r=[t.action];for(let[,i]of t.roles)r.push(er(i));return r.join(" ")}function er(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 Ac(t);case "expression":return t.raw;case "flag":return t.enabled?`+${t.name}`:`~${t.name}`}}function Ac(t){let e=er(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 Dc={confidenceThreshold:.5,strategy:"semantic"};function xc(t,e){return typeof t=="number"?t:t[e]??t["*"]??.5}var Sc=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Bc(t){let e=t.match(Sc);if(!e)return null;let r=e[1],i=t.slice(r.length);return i?{prefix:r,commands:i}:null}function Di(t){function e(a,n,o){try{return t.isLanguageRegistered(n)?t.translateSingle(a,n,o):null}catch{return null}}function r(a,n,o){try{let s=o(a,n);return s!==a?s:null}catch{return null}}function i(a,n,o){if(o.strategy==="semantic"||o.strategy==="auto"){let s=xc(o.confidenceThreshold,n),u=e(a,n,s);if(u!==null)return u}if((o.strategy==="auto"||o.strategy==="i18n")&&o.i18nToEnglish){let s=r(a,n,o.i18nToEnglish);if(s!==null)return s}return null}return function(n,o,s={}){if(o==="en")return n;let u={...Dc,...s},l=i(n,o,u);if(l!==null)return l;let c=Bc(n);if(c){let m=i(c.commands,o,u);if(m!==null)return c.prefix+m}return n}}var Gr=Di({isLanguageRegistered:Lt,translateSingle(t,e,r){let i=ai(t,e);return i.confidence<r||!i.node?null:fr(i.node)}});var Zr=new WeakSet;function Tc(t){return (t.config?.attributes??"_, script, data-script").split(",").map(r=>r.trim()).filter(Boolean)}function Fc(t,e){for(let r of e)if(t.hasAttribute(r))return r;return null}function xi(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=Tc(t),i=[...r.map(n=>`[${n}]`),'script[type="text/hyperscript"]'].join(", "),a=n=>{if(Zr.has(n))return;if(n instanceof HTMLScriptElement&&n.type==="text/hyperscript"){let l=n.textContent??"";if(!l)return;let c=e(l,n);Zr.add(n),c!=null&&c!==l&&(n.textContent=c);return}let o=Fc(n,r);if(!o)return;let s=n.getAttribute(o);if(!s)return;let u=e(s,n);Zr.add(n),u!=null&&u!==s&&n.setAttribute(o,u);};t.addBeforeProcessHook(n=>{!n||typeof n.querySelectorAll!="function"||(typeof n.matches=="function"&&n.matches(i)&&a(n),n.querySelectorAll(i).forEach(a));});}function Bi(t,e){if(typeof t.parse!="function")return true;try{let r=t.parse(e);return !r?.errors||r.errors.length===0}catch{return false}}var Si=new Set;function Ti(t,e,r){Si.has(t)||(Si.add(t),console.warn(`[hyperscript-i18n] Translation for lang="${t}" rendered hyperscript the host parser rejects \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 Yr(t={}){return function(r){let i=r;xi(i,(a,n)=>{let o=Rc(n,t);if(!o||o==="en")return a;let s=Gr(a,o,t);if(s!==a){if(t.validateWithHost!==false&&!Bi(i,s))return t.debug?console.log(`[hyperscript-i18n] ${o}: host rejected "${s}" \u2014 keeping "${a}"`):Ti(o,a,s),a;t.debug&&console.log(`[hyperscript-i18n] ${o}: "${a}" \u2192 "${s}"`);}return s});}}function Rc(t,e){if(e.languageAttribute){let i=t.getAttribute(e.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let r=pr(t);return r||(e.defaultLanguage??null)}function Fi(t,e,r={}){return e==="en"?t:Gr(t,e,r)}Nt(t=>di(t));function Ri(){typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(Yr());}var ld=["id","ms","tl","th","vi"];Ri();
5
- exports.plugin=Yr;exports.preprocess=Fi;exports.resolveLanguage=pr;exports.supportedLanguages=ld;return exports;})({});
2
+ `)}function ya(t){let e=0,r=0,i=0,a={};for(let n of t.values())for(let o of n.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&i++,a[o.code]=(a[o.code]||0)+1;return {totalCommands:t.size,errors:e,warnings:r,notes:i,byCode:a}}function ha(t,e){let r=[];for(let i of e){let a=t.roles.find(n=>n.role===i.role);a&&(a.expectedTypes.length>0&&!a.expectedTypes.includes(i.type)&&(a.expectedTypes.includes("expression")||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects type [${a.expectedTypes.join(", ")}], got '${i.type}'`,code:F.VALUE_TYPE_MISMATCH})),i.type==="selector"&&i.selectorKind&&a.selectorKinds&&a.selectorKinds.length>0&&(a.selectorKinds.includes(i.selectorKind)||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects selector kind [${a.selectorKinds.join(", ")}], got '${i.selectorKind}'`,code:F.SELECTOR_KIND_MISMATCH})));}return r}function va(t){if(t.length!==2)return false;let[e,r]=[...t].sort();return Pt.some(([i,a])=>i===e&&a===r)}function Rt(t){let e=[];if(!t.keywords)return {language:t.code,collisions:e};let r=new Map;for(let[a,n]of Object.entries(t.keywords)){if(!n||!n.primary)continue;let o=r.get(n.primary)||[];if(o.push({command:a,isPrimary:true}),r.set(n.primary,o),n.alternatives)for(let s of n.alternatives){let u=r.get(s)||[];u.push({command:a,isPrimary:false}),r.set(s,u);}}for(let[a,n]of r){let o=[...new Set(n.map(l=>l.command))];if(o.length<=1||va(o))continue;let s=n.filter(l=>l.isPrimary).length,u;s>=2?u="primary-primary":s===1?u="primary-alternative":u="alternative-alternative",e.push({keyword:a,commands:o.sort(),type:u});}let i={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((a,n)=>i[a.type]-i[n.type]),{language:t.code,collisions:e}}function Ea(t){let e=[];for(let[,r]of Object.entries(t)){let i=Rt(r);i.collisions.length>0&&e.push(i);}return e.sort((r,i)=>r.language.localeCompare(i.language))}var Cr,Ot,Pt,ga=xt({"src/generators/schema-validator.ts"(){sa(),Cr=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Ot=new Set(["compound","else","halt","continue","init","settle","focus","blur","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint","live","eventsource","socket","worker","intercept"]),Pt=[["change","changes"]];}});function De(t){let e=t.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function xe(t){let e=t.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function Se(t,e){return Rr(t,e,"source")}function Fr(t,e){return Rr(t,e,"destination")}function za(t,e){return Rr(t,e,"patient")}function Rr(t,e,r){if(!e||!t.roles.some(n=>n.role===r))return [];let i=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},a={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[a,i]:[i,a]}]}var ka={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:["selector","reference"],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)"}},wa={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"}},ba={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:["selector","reference"],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"}},Ca={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into",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"}},Aa={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","expression","reference"],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>"}},Da={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>"}},xa={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Sa={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}]},Ba={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ta={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Fa={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ra={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Oa={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:"duration"}},roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Pa={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:"duration"}},roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},_a={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"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],widenTypeVariants:[{role:"event",types:["literal","expression"],idSuffix:"expr-event",excludeLanguages:["ko"]}]},Na={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},La={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}]},Ma={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}]},Ia={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"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},ja={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"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},$a={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"],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"}}]},Va={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"],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"}}]},Wa={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"],svoPosition:1,sovPosition:1}]},qa={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:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",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}]},Ka={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:["selector","reference"],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"}}]},Ha={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}]},Ua={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}]},Ga={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Za={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"],svoPosition:1,sovPosition:1}]},Ya={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"}}]},Xa={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}]},Ja={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}]},Qa={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},en={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"'},rn={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"}}]},tn={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}]},an={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",ast:{},roles:[]},Or={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"},nn={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to",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"]}}],rolePrefixLiteralVariants:[{role:"destination",literal:Or,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},on={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}]},sn={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"}}]},un={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ln={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},cn={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},mn={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:["selector","reference"],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"}}]},dn={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},pn={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},fn={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}]},yn={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},hn={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},vn={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}]},En={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"],svoPosition:1,sovPosition:1}]},gn={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}]},zn={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:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},kn={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"],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"}}]},wn={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",ast:{},hasBody:true,roles:[]},bn={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}]},Cn={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}]},An={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:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Dn={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"},Pr={role:"manner",description:"Run the swap inside a `document.startViewTransition()` (`using view transition`)",required:false,expectedTypes:["literal","expression"],valueShape:"keyword",markerOverride:Dn},xn={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:["selector","reference"],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"}},{...Pr,svoPosition:4,sovPosition:4}]},Sn={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:["selector","reference"],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"}},{...Pr,svoPosition:3,sovPosition:3}]},Bn={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}]},Tn={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Fn={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Rn={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},On={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}]},Pn={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"}}]},_n={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"},Nn={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:Or}]},Ln={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:Or}]},Mn={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:_n},{...Pr,svoPosition:2,sovPosition:2}]},In={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:ka,add:wa,remove:ba,put:Ca,set:Aa,show:Oa,hide:Pa,on:_a,trigger:Na,wait:La,fetch:Ma,increment:Ia,decrement:ja,append:$a,prepend:Va,log:Wa,get:qa,take:Ka,make:Ha,halt:Ua,settle:Ga,throw:Za,send:Ya,if:Xa,unless:Ja,else:Qa,repeat:en,for:rn,while:tn,continue:an,go:nn,scroll:Pn,push:Nn,replace:Ln,process:Mn,transition:on,clone:sn,focus:un,blur:ln,empty:cn,open:mn,close:dn,select:pn,clear:fn,reset:yn,breakpoint:hn,call:vn,return:En,js:gn,tell:zn,default:kn,init:wn,behavior:bn,install:Cn,measure:An,swap:xn,morph:Sn,beep:Bn,break:Tn,copy:Fn,exit:Rn,pick:On,render:In,bind:Da,live:xa,when:Sa,eventsource:Ba,socket:Ta,worker:Fa,intercept:Ra,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function re(t){return ue[t]}function jn(){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(()=>(ga(),Tt)).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(`
3
+ These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(t=>{console.debug("Schema validation skipped:",t);});var Ae=new Map,ve=new Map,He=new Map,Ar=null;function _t(t,e){let r={...t};for(let i of Object.keys(e)){let a=e[i],n=t[i];a!==void 0&&(typeof a=="object"&&a!==null&&!Array.isArray(a)&&typeof n=="object"&&n!==null&&!Array.isArray(n)?r[i]=_t(n,a):r[i]=a);}return r}function $n(t,e){return _t(t,e)}function _r(t){if(!t.extends)return t;let e=ve.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=_r(e);return $n(r,t)}function ye(t,e,r){Ae.set(t,e),ve.set(t,r),He.delete(t);}function Nt(t){Ar=t;}var st=new Map;function Pe(t){return t.split("-")[0]}function _e(t){return t.includes("-")}function Vn(t){let e=Ae.get(t);if(!e&&_e(t)){let r=Pe(t);e=Ae.get(r);}if(!e){let r=Array.from(Ae.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 Wn(t){let e=ve.get(t);if(!e&&_e(t)){let r=Pe(t);e=ve.get(r);}if(!e){let r=Array.from(ve.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 _r(e)}function P(t){let e=ve.get(t);return !e&&_e(t)&&(e=ve.get(Pe(t))),e?_r(e):void 0}function qn(){return Array.from(Ae.keys())}function Lt(t){if(Ae.has(t)&&ve.has(t))return true;if(_e(t)){let e=Pe(t);return Ae.has(e)&&ve.has(e)}return false}function Kn(t,e){return Vn(e).tokenize(t)}function he(t){let e=He.get(t);if(!e&&_e(t)&&(e=He.get(Pe(t))),e)return e;let r=st.get(t);if(!r&&_e(t)&&(r=st.get(Pe(t))),r)return He.set(t,r),r;if(!Ar)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let i=Wn(t),a=Ar(i);return He.set(t,a),a}var Mt={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function ke(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 q(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}function Fe(t){return Er(t)}function se(t){return {type:"reference",value:t}}function Eo(t,e){return e?{...t,position:e}:t}function be(t,e,r){return r?{type:"property-path",object:t,property:e,access:r}:{type:"property-path",object:t,property:e}}function ee(t,e,r){let i={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...i,metadata:r}:i}function Ke(t,e,r,i,a,n){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),a!==void 0&&a.length>0&&(s.parameterNames=a),s}function go(t,e,r,i,a){let n={kind:"behavior",action:"behavior",roles:new Map,name:t,parameters:e,eventHandlers:r};return i!==void 0&&i.length>0&&(n.initBlock=i),a!==void 0&&(n.metadata=a),n}function zo(t,e,r,i){let a={kind:"def",action:"def",roles:new Map,name:t,parameters:e,body:r};return i!==void 0&&(a.metadata=i),a}function Dr(t,e,r,i,a){let n={kind:"feature",action:t,roles:a??new Map,body:e};return r!==void 0&&(n.name=r),i!==void 0&&(n.metadata=i),n}function Ue(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 ko(t,e,r,i){let a=new Map;a.set("condition",t);let n={kind:"conditional",action:"if",roles:a,thenBranch:e};return r!==void 0&&(n.elseBranch=r),i!==void 0&&(n.metadata=i),n}function or(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 wo(t,e){let r=t.markerOverride?.[e.code],i=e.roleMarkers[t.role];if(r!==void 0){let a=bo(t,e.code,r);return {primary:r,...a&&{alternatives:a},position:i?.position??"before",isOverride:true}}if(i&&i.primary){let a={primary:i.primary,position:i.position,isOverride:false};return i.alternatives&&(a.alternatives=i.alternatives),a}return null}function bo(t,e,r){let i=t.markerLegacy?.[e];if(!i?.length)return;let a=[...new Set(i)].filter(n=>n&&n!==r);return a.length?a:void 0}function Ee(t,e,r){let i=t.markerLegacy?.[e]??[],a=t.methodCarrier?[]:t.markerVariants?.[e]??[],n=[...new Set([...i,...a])].filter(o=>o&&o!==r);return n.length?n:void 0}var It=new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]);function pe(t,e){let r=t.possessive?.keywords?.[e];if(r)return r;let i=t.possessive?.specialForms;if(i){for(let[a,n]of Object.entries(i))if(n===e)return a}}function gr(t){return Mt.possessive?.specialForms?.[t]??`${t}'s`}var Nr={ar:{\u0642\u064A\u0645\u0629:"value"},bn:{\u0985\u0995\u09CD\u09B7\u09AE:"disabled","\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"},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"}},Co={ar:{\u0643\u0640:"as"},bn:{\u09B9\u09BF\u09B8\u09BE\u09AC\u09C7:"as"},de:{als:"as"},es:{como:"as"},fr:{comme:"as"},hi:{\u0915\u0947_\u0930\u0942\u092A_\u092E\u0947\u0902:"as"},id:{sebagai:"as"},it:{come:"as"},ja:{\u3068\u3057\u3066:"as"},ko:{\uB85C:"as"},ms:{sebagai:"as"},pl:{jako:"as"},pt:{como:"as"},qu:{hina:"as"},ru:{\u043A\u0430\u043A:"as"},sw:{kuwa:"as"},tl:{bilang:"as"},tr:{olarak:"as"},uk:{\u044F\u043A:"as"},vi:{nh\u01B0:"as"},zh:{\u4F5C\u4E3A:"as"}},jt={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 xr(t,e){let r=e.value.toLowerCase(),i=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||i==="of"||i==="source")return true;let a=t?.code?jt[t.code]:void 0;return !!a&&a.has(r)}var Do={destination:"in",source:"from"},xo={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"])},So=new Set(["in","into","at","within","inside"]);function Bo(t,e){let r=e.value.toLowerCase();if((t?.code?xo[t.code]:void 0)?.has(r))return "in";let a=e.normalized??e.value,n=a.toLowerCase();return So.has(n)?"in":Do[n]??a}var zr=new Set(["first","last","next","previous","random","closest"]),To={bn:{\u09B6\u09C7\u09B7:"last"}},Lr=new Set(Object.keys(ue).map(t=>t.toLowerCase()));function $t(t,e,r,i){let a=t[e];if(!a)return null;let n=(a.normalized??a.value).toLowerCase(),o=t[e+1],s=r?.code&&o?.kind==="selector"&&o.value.startsWith("<")?To[r.code]?.[a.value.toLowerCase()]:void 0;if(!zr.has(n)&&!zr.has(a.value.toLowerCase())&&s===void 0)return null;let u=[{text:s??a.normalized??a.value,token:a}],l=e+1,c=t[l];if(!c||c.kind!=="selector")return null;u.push({text:c.value,token:c}),l++;let m=0;for(;m++<8;){let f=t[l];if(f&&f.kind==="selector"&&f.value.startsWith("."))u.push({text:f.value,token:f}),l++;else break}let d=t[l],p=t[l+1];return d&&p&&p.kind==="selector"&&(d.kind==="keyword"||d.kind==="particle"||d.kind==="identifier")&&!zr.has((d.normalized??d.value).toLowerCase())&&!Lr.has((d.normalized??d.value).toLowerCase())&&!(i?.(d)===true&&i(t[l+2])!==true)&&(u.push({text:Bo(r,d),token:d}),u.push({text:p.value,token:p}),l+=2),{parts:u,consumed:l-e}}function Fo(t,e){let r=Co[t];return r?r[e.toLowerCase()]??e:e}function fe(t,e){let r=Nr[t];return r?r[e.toLowerCase()]??e:e}function Ro(t,e){return Nr[t]?.[e.toLowerCase()]!==void 0}function Oo(t,e){let r=[e.value,e.normalized].filter(Boolean);for(let i of r){let a=pe(t,i)??pe(t,i.toLowerCase());if(a)return a}}function Vt(t){return t.kind==="literal"||t.kind==="operator"||t.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(t.value)}function Po(t,e){let r=t?.references;if(!r)return false;let i=Object.values(r).filter(n=>typeof n=="string").map(n=>n.toLowerCase());return [e.value,e.normalized].filter(Boolean).some(n=>i.includes(n.toLowerCase()))}function lt(t,e){return Vt(t)?fe(e,t.value)!==t.value?true:t.kind==="identifier":false}var _o={ar:{\u0647\u0648:{beforePredicate:"is"}},hi:{\u0939\u0948:{beforePredicate:"is"},\u0928\u0939\u0940\u0902:{beforeBareIdentifier:"no"}},th:{\u0E40\u0E1B\u0E47\u0E19:{beforeTypeName:"as",beforePredicate:"is"}},ja:{\u7A7A:{afterCopula:"empty"}},zh:{\u6CA1\u6709:{beforeBareIdentifier:"no"}},tl:{walang:{beforeBareIdentifier:"no"},may:{afterSubject:"exists"}},bn:{\u0986\u099B\u09C7:{afterSubject:"exists"}},tr:{var:{afterSubject:"exists"}}},No=new Set(["empty","null","undefined","true","false"]),Wt=new Set(["Number","Int","Float","String","Date","Array","Object","JSON","json","FormData","HTML","Fragment","Values"]);function Lo(t,e,r,i){let a=_o[t],n=a?.[e.value]??a?.[e.value.toLowerCase()];if(n){if(n.beforeTypeName&&i?.kind==="identifier"&&Wt.has(i.value))return n.beforeTypeName;if(n.beforePredicate&&i&&(i.kind==="literal"||i.kind==="keyword"&&No.has((i.normalized??"").toLowerCase())))return n.beforePredicate;if(n.beforeBareIdentifier&&i?.kind==="identifier"&&/^[A-Za-z_]\w*$/.test(i.value))return n.beforeBareIdentifier;if(n.afterSubject&&(r?.kind==="selector"||r?.kind==="reference"))return n.afterSubject;if(n.afterCopula&&r?.kind==="keyword"&&(r.normalized??"").toLowerCase()==="is")return n.afterCopula}}function Oe(t,e){let r=e?.code??"en",i="",a,n=(s,u)=>{if(a===void 0){i=s,a=u;return}let c=a.position?.end!==void 0&&u.position?.start!==void 0&&a.position.end===u.position.start&&(s.startsWith(".")||s.startsWith("!"));i+=(c?"":" ")+s,a=u;},o=s=>s.kind==="keyword"?s.normalized??s.value:s.value;for(let s=0;s<t.length;s++){let u=t[s],l=e?Oo(e,u):void 0,c=t[s+1];if(u.value==="'"&&a!==void 0&&c?.value==="s"&&u.position?.end!==void 0&&c.position?.start===u.position.end){i+="'s",a=c;let v=t[s+2];v&&fe(r,v.value)!==v.value?(n(fe(r,v.value),v),s+=2):s+=1;continue}if(l!==void 0&&c){let v=e?.possessive?.connectors,E=!!v?.length&&v.some(k=>{let A=k.toLowerCase();return A===c.value.toLowerCase()||A===(c.normalized??"").toLowerCase()}),y=E?s+2:s+1,h=t[y];if(h&&lt(h,r)){n(gr(l),u),n(fe(r,h.value),h),s=y;continue}if(E&&h&&/^\.[a-zA-Z_]\w*$/.test(h.value)&&c.position?.end!==void 0&&h.position?.start!==void 0&&c.position.end===h.position.start){n(gr(l),u),n(fe(r,h.value.slice(1)),h),s=y;continue}if(!E&&/^\.[a-zA-Z_]\w*$/.test(c.value)&&u.position?.end!==void 0&&c.position?.start!==void 0&&u.position.end===c.position.start&&!Po(e,u)){n(gr(l),u),n(fe(r,c.value.slice(1)),c),s+=1;continue}}let m=t[s+2];if(c&&m&&m.kind==="selector"&&xr(e,c)&&Vt(u)){n(fe(r,u.value),u),n("of",c),n(m.value,m),s+=2;continue}if(u.kind==="selector"&&c&&m&&xr(e,c)&&lt(m,r)&&fe(r,m.value)!==m.value){n(fe(r,m.value),m),n("of",c),n(u.value,u),s+=2;continue}let d=$t(t,s,e);if(d){for(let v of d.parts)n(v.text,v.token);s+=d.consumed-1;continue}let p=Lo(r,u,t[s-1],c);if(p!==void 0){n(p,u);continue}let f=Fo(r,u.value);if(f!==u.value){n(f,u);continue}n(o(u),u);}return i.trim()}var qt=[{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 ct(t,e,r,i){let a=qt.find(o=>o.lang===t);if(!a)return false;let n=(o,s)=>(o??"").toLowerCase()===s.toLowerCase();return n(e,a.end)&&n(r,a.at)&&n(i,a.of)}function Mo(t,e){let r=qt.find(a=>a.lang===t);if(!r)return false;let i=e.toLowerCase();return i===r.at.toLowerCase()||i===r.of.toLowerCase()||i===r.end.toLowerCase()}var Kt={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 Io(t){return Kt[t]}function mt(t,e){return Kt[e]?.has(t.toLowerCase())??false}var Ht=96,jo=/^[A-Za-z_][\w-]*$/,$o=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function Ut(t,e){let r=t.peek(e);return !!r&&r.kind==="identifier"&&$o.test(r.value)}function Gt(t,e){let r=t.peek(e);if(!r||r.kind!=="identifier"&&r.kind!=="keyword"||!jo.test(r.value))return false;let i=t.peek(e+1),a=t.peek(e+2);return !!i&&i.value===":"&&!!a}function dt(t,e=0){return Ut(t,e)||Gt(t,e)}function Vo(t){let e=t.peek();if(!e||e.value!=="{"&&e.value!=="(")return null;let r="",i=-1,a=0,n=0;for(;!t.isAtEnd()&&n++<Ht;){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==="(")a++;else if((o.value==="}"||o.value===")")&&(a--,a===0))return r}return null}function pt(t){let e=t.peek();return e?e.value==="{"||e.value==="("?Vo(t):e.value===","||e.value===":"?null:(t.advance(),e.value):null}function Ge(t,e){let r=t.mark(),i=[];if(e!==void 0){let n=t.peek();if(!n||n.value!==":"||!t.peek(1))return null;t.advance();let o=pt(t);if(o===null)return t.reset(r),null;i.push(`${e}:${o}`);}else if(!dt(t))return null;let a=0;for(;a++<Ht;){let n=t.peek();if(!n)break;if(n.value===","){if(i.length===0||!dt(t,1))break;t.advance();continue}if(Ut(t,0)){i.push(t.advance().value);continue}if(!Gt(t,0))break;let o=t.advance().value;t.advance();let s=pt(t);if(s===null)return t.reset(r),null;i.push(`${o}:${s}`);}return i.length===0?(t.reset(r),null):`{${i.join(", ")}}`}var sr=.8,Wo=.6,qo=.15,Ko=.5,ft=.15,yt=.1,ht=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"]),Ho={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"]},Uo=class{calculate(t){return this.calculateWithBreakdown(t).final}calculateWithBreakdown(t){let e=this.scoreRoleCoverage(t),r=this.scoreStemPenalty(t),i=this.scoreLanguageBoost(t),a=this.scoreLanguageAdjustment(t),n=e;return n=Math.max(Ko,n+r),n=Math.min(1,n+i),n=Math.max(0,Math.min(1,n+a)),{roleCoverage:e,stemPenalty:r,languageBoost:i,languageAdjustment:a,final:n}}scoreRoleCoverage(t){let{pattern:e,captured:r}=t,i=0,a=0,n=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)?(a+=1,i+=1):u(l.role)||(a+=1);else if(l.type==="group")for(let c of l.tokens)c.type==="role"&&(r.has(c.role)?(a+=sr,i+=sr):u(c.role)||(a+=sr,n(c.role)&&(i+=sr*Wo)));return a>0?i/a:1}scoreStemPenalty(t){let{stemMatchCount:e,totalKeywordMatches:r}=t;return e<=0||r<=0?0:-(e/r)*qo}scoreLanguageBoost(t){let{pattern:e}=t;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:ht.has(r.value)||r.alternatives?.some(i=>ht.has(i))?ft:0}scoreLanguageAdjustment(t){let{pattern:e,captured:r}=t;if(e.language!=="ar")return 0;let i=0;for(let[a,n]of r.entries()){let o=Ho[a];if(!o||o.length===0)continue;let s="metadata"in n?n.metadata:void 0;s&&typeof s.prepositionValue=="string"&&(o.includes(s.prepositionValue)?i+=.1:i-=.1);}return Math.max(-yt,Math.min(yt,i))}},Go=new Uo,Zo=new Set(Object.values(ue).filter(t=>t.bareKeyword===true).map(t=>t.action));function Yo(t){return t.startsWith("*")||t.startsWith("@")}var J=class L{constructor(e){this.matchCache=new Map,this.roleStarts=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Go;}matchPattern(e,r){let i=e.mark(),a=new Map;if(this.currentProfile=P(r.language),this.currentPatternCommand=r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,this.roleStarts=new Map,!this.matchTokenSequence(e,r.template.tokens,a))return e.reset(i),null;let o=this.confidenceModel.calculate({pattern:r,captured:a,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-i.position,confidence:o,roleStarts:this.roleStarts}}matchBest(e,r){this.matchCache.clear();let i=[],a=e.position();for(let o of r){let s=e.mark(),u=`${a}:${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 n=i[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,i,a){let n=r[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 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),this.shouldTrySkippingVerbSlot(l,e,r[u+1]??a)){let m=e.mark(),d=new Map(i);if(this.matchTokenSequence(e,r.slice(u+1),d,a)&&this.atClauseEnd(e)){i.clear();for(let[p,f]of d)i.set(p,f);return true}e.reset(m);}let c=this.matchPatternToken(e,l,i,r[u+1]??a);if(s=l.type==="role"&&l.role==="event"?2:Math.max(0,s-1),!c){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,i){if(r.has("source"))return;let a=e.peek(),n=e.peek(1);if(!a||!n||this.patternTokenWouldMatch(i,a))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(m=>m.toLowerCase()===c)},u=o?.position;if(u!=="after"&&s(a)&&n.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(u==="after"&&a.kind==="selector"&&s(n)){let l=this.tokenToSemanticValue(a);e.advance(),e.advance(),l&&r.set("source",l);}}matchPatternToken(e,r,i,a){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":{let n=e.position(),o=this.matchRoleToken(e,r,i,a);return o&&i.has(r.role)&&this.roleStarts.set(r.role,n),o}case "group":return this.matchGroupToken(e,r,i,a);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(!i)return false;let a=this.getMatchType(i,r.value);if(a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let o=this.getMatchType(i,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let n of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(n.includes(o)&&this.tryMatchShatteredCompound(e,n,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let i=e.mark(),a=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;a.push(o.value),e.advance();let s=e.peek();if(!s||s.value!=="-")break;e.advance(),a.push("-");}if(a.length<3||a[a.length-1]==="-")return e.reset(i),null;let n=a.join("").toLowerCase();for(let[o,s]of Object.entries(r.keywords))if(s.primary.toLowerCase()===n||s.alternatives?.some(u=>u.toLowerCase()===n))return q(o);return e.reset(i),null}tryMatchShatteredCompound(e,r,i){let a=r.split(i);if(a.length<2||a.some(o=>o.length===0))return false;let n=e.mark();for(let o=0;o<a.length;o++){if(o>0){let u=e.peek();if(!u||u.value!==i)return e.reset(n),false;e.advance();}let s=e.peek();if(!s||s.kind!=="identifier"&&s.kind!=="keyword"&&s.kind!=="particle"||s.value.toLowerCase()!==a[o].toLowerCase())return e.reset(n),false;e.advance();}return true}matchRoleToken(e,r,i,a){let n=e.position(),o=i.get(r.role);return this.matchRoleTokenCore(e,r,i,a)?(this.absorbTrailingConversion(e,r,i,a,n),this.absorbTrailingConditionOperand(e,r,i,a,n),this.stampCaptureSpan(e,r.role,i,n,o),true):false}stampCaptureSpan(e,r,i,a,n){let o=i.get(r);if(!o||o===n||o.position||e.position()<=a)return;let s=e.tokens[a],u=e.tokens[e.position()-1];!s||!u||i.set(r,Eo(o,{start:s.position.start,end:u.position.end}));}absorbTrailingConditionOperand(e,r,i,a,n){if(r.role!=="condition"||!i.has("condition")||e.position()<=n||a!==void 0||this.currentPatternCommand!=="on")return;let o=e.peek();if(!o)return;let s=L.CONDITION_OPERATOR_WORDS;if(!s.has((o.normalized??"").toLowerCase())&&!s.has(o.value.toLowerCase())||this.patternTokenWouldMatch(a,o))return;e.advance();let u=e.peek();u&&(u.kind==="selector"||u.kind==="identifier"||u.kind==="literal")&&!Lr.has((u.normalized??u.value).toLowerCase())&&e.advance();let l=Oe(e.tokens.slice(n,e.position()),this.currentProfile);i.set("condition",{type:"expression",raw:l,value:l});}conversionRunLength(e){let r=e.peek();if(!r||(r.normalized??r.value).toLowerCase()!=="as"&&r.value.toLowerCase()!=="as")return 0;let a=e.peek(1);return !a||!Wt.has(a.value)?0:2}absorbTrailingConversion(e,r,i,a,n){if(r.role==="event"||r.role==="action"||!i.has(r.role)||e.position()<=n||this.conversionRunLength(e)!==2||this.patternTokenWouldMatch(a,e.peek()))return;e.advance(),e.advance();let o=Oe(e.tokens.slice(n,e.position()),this.currentProfile);i.set(r.role,{type:"expression",raw:o,value:o});}matchRoleTokenCore(e,r,i,a){this.skipNoiseWords(e);let n=e.peek();if(!n)return r.optional||false;if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let y=this.tryFoldHyphenActionKeyword(e);if(y)return i.set(r.role,y),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!L.tokenLooksLikeEvent(n))return r.optional||false;let y=(n.normalized??n.value).toLowerCase();if(L.POSITIONAL_OR_SCOPE_KEYWORDS.has(y)||this.currentProfile&&(pe(this.currentProfile,n.value)??pe(this.currentProfile,y))!==void 0||n.value.includes("?."))return r.optional||false}if(r.role==="event"){let y=(n.normalized??n.value).toLowerCase();if(L.STRUCTURAL_NEVER_EVENT.has(y))return r.optional||false}if(n.kind==="keyword"){let y=(n.normalized??n.value).toLowerCase();if(y==="then"||y==="end"&&e.peek(1)?.kind!=="selector"||mt(n.value,this.currentProfile?.code??"")||(r.role==="quantity"||r.role==="event"&&this.currentPatternCommand==="repeat")&&(n.normalized??n.value).toLowerCase()in ue)return r.optional||false}if(r.role==="duration"){let y=(n.normalized??n.value).toLowerCase();if(L.POSITIONAL_OR_SCOPE_KEYWORDS.has(y))return r.optional||false}if(r.optional&&r.role!=="event"&&r.role!=="action"&&r.valueShape!=="keyword"&&n.kind==="keyword"&&(n.normalized??n.value).toLowerCase()in ue&&(a===void 0||this.patternTokenWouldMatch(a,n)))return true;let o=this.tryMatchPositionalExpression(e,a);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!or(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let s=this.tryMatchCaretScopeExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!or(s.type,r.expectedTypes)?r.optional||false:(i.set(r.role,s),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let y=this.tryMatchBeepPrefixExpression(e);if(y)return i.set(r.role,y),true;let h=this.tryMatchHyphenatedWord(e);if(h)return i.set(r.role,h),true;let k=this.tryMatchOperatorRunExpression(e);if(k)return i.set(r.role,k),true}if(this.currentPatternCommand==="pick"&&r.role==="patient"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let y=this.tryMatchPickRangeExpression(e);if(y)return i.set(r.role,y),true}if(r.expectedTypes?.includes("property-path")){let y=this.tryMatchOfPossessiveExpression(e);if(y)return i.set(r.role,y),true;let h=this.tryMatchPostNominalPossessiveExpression(e);if(h)return i.set(r.role,h),true}let u=this.tryMatchPossessiveExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(u.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,u),true);let l=this.tryMatchMethodCallExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(l.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,l),true);let m=r.role==="event"&&this.currentPatternCommand==="on"||L.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(m)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(m.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,m),true);let d=this.tryMatchPossessiveSelectorExpression(e);if(d)return r.expectedTypes&&r.expectedTypes.length>0&&!or(d.type,r.expectedTypes)?r.optional||false:(i.set(r.role,d),true);let p=r.role!=="condition",f=this.tryMatchPropertyAccessExpression(e,p);if(f)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(f.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,f),true);let v=this.tryMatchSelectorPropertyExpression(e);if(v)return r.expectedTypes&&r.expectedTypes.length>0&&!or(v.type,r.expectedTypes)?r.optional||false:(i.set(r.role,v),true);if(n.kind==="identifier"&&n.value==="{"){let y=r.expectedTypes,k=y?.length===1&&y[0]==="expression"?this.tryMatchBraceRunExpression(e):!y?.length||y.includes("literal")?this.tryMatchBraceRunLiteral(e):null;if(k)return i.set(r.role,k),true}if(r.role==="style"&&r.expectedTypes?.length===1&&r.expectedTypes[0]==="expression"){let y=Ge(e);if(y)return i.set(r.role,{type:"expression",raw:y}),true}let E=this.tokenToSemanticValue(n);if(!E)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(E.type)){let y=E.type==="selector"&&String(E.value).startsWith("@"),h=r.expectedTypes.some(k=>k==="expression"||k==="reference");if(!(y&&h))return r.optional||false}if(r.valueShape==="keyword"&&E.type==="expression"?i.set(r.role,q(String(E.raw??""))):i.set(r.role,E),e.advance(),r.role==="event"){let y=e.peek();y&&y.kind==="selector"&&y.value.startsWith("[")&&"value"in E&&(i.set(r.role,q(`${String(E.value)}${y.value}`)),e.advance());let h=e.peek();if(h&&(h.kind==="particle"||h.kind==="keyword")&&(h.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(a,h)){let k=e.peek(1);if(k&&(k.kind==="selector"||k.kind==="identifier")){e.advance();let A=this.tokenToSemanticValue(e.advance());A&&!i.has("source")&&i.set("source",A);}}}return true}shouldTrySkippingVerbSlot(e,r,i){let a=e.type==="group"&&e.optional?e.tokens.every(s=>s.type==="role")?e.tokens[0]:void 0:e;if(!a||a.type!=="role"||!a.optional||a.role==="event"||a.role==="action"||a.valueShape==="keyword")return false;let n=r.peek();if(!n||n.kind!=="keyword"||i===void 0)return false;let o=this.patternTokenWouldMatch(i,n);return (n.normalized??n.value).toLowerCase()in ue?!o:o}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:mt(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=$t(e.tokens,e.position(),this.currentProfile,a=>a===void 0?false:this.patternTokenWouldMatch(r,a));if(!i)return null;for(let a=0;a<i.consumed;a++)e.advance();return {type:"expression",raw:i.parts.map(a=>a.text).join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let i=e.peek(1),a=e.peek(2),n=(i?.normalized??"").toLowerCase(),o=!!i&&(i.value.toLowerCase()==="on"||n==="destination"||n==="on");return !i||!a||a.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${a.value}`})}isOfPossessiveMarker(e){return xr(this.currentProfile,e)}static isBareWordToken(e){return !!e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.value)}static tokensAdjacent(e,r){return e?.position?.end!==void 0&&r?.position?.start!==void 0&&e.position.end===r.position.start}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 n=e.mark(),o=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(n),null;for(;;){let u=e.peek();if(!u||!L.RUN_OPERATORS.has(u.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(l);break}}let s=Oe(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:s,value:s}}tryMatchHyphenatedWord(e){let r=e.peek();if(!L.isBareWordToken(r))return null;let i=1,a=[r.value];for(;;){let n=e.peek(i),o=e.peek(i+1);if(!n||n.value!=="-"||!L.isBareWordToken(o)||!L.tokensAdjacent(e.peek(i-1),n)||!L.tokensAdjacent(n,o))break;a.push(o.value),i+=2;}if(a.length<2)return null;for(let n=0;n<i;n++)e.advance();return q(a.join("-"),"string")}tryMatchOperatorRunExpression(e){let r=e.mark(),i=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let a=1;for(;;){let o=e.peek();if(!o||!L.RUN_OPERATORS.has(o.value))break;let s=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(s);break}a++;}if(a<2)return e.reset(r),null;let n=Oe(e.tokens.slice(i,e.position()),this.currentProfile);return {type:"expression",raw:n,value:n}}static rangeSeparatorFor(e){let[r]=L.PICK_RANGE_SEPARATORS_BY_LANG[e]??[];return r}isPickRangeSeparator(e){let r=(e.normalized??e.value).toLowerCase();if(L.PICK_RANGE_SEPARATORS.has(r))return true;let i=this.currentProfile?.code;return i?L.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 a=e.peek();if(!a||!this.isPickRangeSeparator(a)||(e.advance(),!this.tryConsumePickRangeOperand(e)))return e.reset(r),null;let n=e.peek();n&&L.PICK_RANGE_MODES.has((n.normalized??n.value).toLowerCase())&&e.advance();let o=e.tokens.slice(i,e.position()),[s,,u,l]=o,c=d=>d.kind==="keyword"?d.normalized??d.value:d.value,m=`${c(s)} to ${c(u)}`;return l&&(m+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:m,value:m}}tryConsumePickRangeOperand(e){let r=e.peek();if(!r)return false;let i=(r.normalized??r.value).toLowerCase();if(this.isPickRangeSeparator(r))return false;let a=i==="start"||i==="end";return r.kind==="literal"||r.kind==="identifier"||r.kind==="keyword"&&a?(e.advance(),true):false}tryConsumeRunOperand(e){let r=e.peek();if(!r)return false;if(r.value==="("){let i=e.mark(),a=0;for(;!e.isAtEnd();){let n=e.advance();if(n.value==="(")a++;else if(n.value===")"&&(a--,a===0))return true}return e.reset(i),false}return this.tryMatchPossessiveExpression(e)?true:(r.kind==="literal"||r.kind==="identifier"||r.kind==="selector"||r.kind==="keyword")&&!L.RUN_OPERATORS.has(r.value)&&r.value!==")"?(e.advance(),true):false}isPossessorToken(e){if(!this.currentProfile)return false;for(let r of [e.value,e.normalized].filter(Boolean))if(pe(this.currentProfile,r)??pe(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?fe(this.currentProfile.code,e):e}tryMatchOfPossessiveExpression(e){let r=e.peek();if(!r||r.kind!=="selector"&&!this.isBareWordPropertyHead(r))return null;let i=e.mark();e.advance();let a=e.peek();if(!a||!this.isOfPossessiveMarker(a))return e.reset(i),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"||Yo(n.value)?(e.reset(i),null):(e.advance(),be(ke(n.value),this.toEnglishProperty(r.value),"possessive"))}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=[r.value,r.normalized].filter(Boolean),a;for(let u of i)if(a=pe(this.currentProfile,u)??pe(this.currentProfile,u.toLowerCase()),a)break;if(!a)return null;let n=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(m=>m.toLowerCase()===l||m.toLowerCase()===c)&&e.advance();}}let s=e.peek();if(!s||Mo(this.currentProfile.code,s.value))return e.reset(n),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&&L.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 m=e.peek();if(m?.kind==="selector"&&m.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(m.value)){l+=m.value,e.advance();continue}if(m?.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 m="",d=0,p=0;for(;!e.isAtEnd()&&p++<L.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;m+=f.value,e.advance();for(let v of f.value)v==="("?d++:v===")"&&d--;if(d<=0)break}l+=m;}return be(se(a),l,"possessive")}return e.reset(n),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 n=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(n),null;let l;for(let c of [u.value,u.normalized].filter(Boolean))if(l=pe(this.currentProfile,c)??pe(this.currentProfile,c.toLowerCase()),l)break;return l?(e.advance(),be(se(l),s,"possessive")):(e.reset(n),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())}isRoleMarkerConcept(e){return It.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&&Zo.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 a=["{"],n=1,o=0;for(;!e.isAtEnd()&&o++<L.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(s.value==="{")n++;else if(s.value==="}"&&(n--,n===0))return a.push("}"),q(a.join(" "));a.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(),a="",n=-1,o=0,s=0;for(;!e.isAtEnd()&&s++<L.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(n>=0&&u.position.start>n&&(a+=" ".repeat(u.position.start-n)),a+=u.value,n=u.position.end,u.value==="{")o++;else if(u.value==="}"&&(o--,o===0))return {type:"expression",raw:a}}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 a=e.mark();e.advance();let n=e.advance(),o="",s=n.position?.end,u=false,l=0;for(;!e.isAtEnd()&&l++<L.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),u=true;break}let m=s!==void 0&&c.position?.start===s;o+=(o===""||m?"":" ")+c.value,s=c.position?.end,e.advance();}return u?{type:"expression",raw:`${r.value}(${o})`}:(e.reset(a),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(i),null;e.advance();let n=e.peek();if(!n||n.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<L.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}.${n.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e,r=true){let i=e.peek();if(!i||i.kind!=="identifier"&&i.kind!=="keyword")return null;let a=e.mark();e.advance();let n=i.value.toLowerCase(),o=e.peek();if((i.kind==="identifier"||L.PROPERTY_ACCESS_BASES.has(n))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let p=i.value,f=[],v=0;for(;v<L.MAX_PROPERTY_DEPTH;){let h=e.peek();if(h&&h.kind==="selector"&&/^\.[a-zA-Z_]/.test(h.value))p+=`.${h.value.slice(1)}`,f.push(h.value.slice(1)),e.advance(),v++;else break}let E=e.peek(),y=!!E&&E.value.startsWith("(");if(r&&!y&&f.length>0&&Fe(n))return be(se(n),f.join("."),"dot");if(y){let h=e.mark(),k=[],A=0,D=false;for(;!e.isAtEnd();){let C=e.peek();if(!C)break;if(C.value==="(")A++;else if(C.value===")"){if(k.push(C.value),e.advance(),A--,A===0&&(D=true),D)break;continue}k.push(C.value),e.advance();}D?p+=k.join(""):e.reset(h);}return {type:"expression",raw:p}}let s=e.peek();if(!s||s.kind!=="operator"||s.value!==".")return e.reset(a),null;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")return e.reset(a),null;e.advance();let l=`${i.value}.${u.value}`,c=1;for(;!e.isAtEnd()&&c<L.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 m=e.peek();if(m&&m.kind==="punctuation"&&m.value==="("){e.advance();let p=[],f=0;for(;!e.isAtEnd()&&p.length<L.MAX_METHOD_ARGS;){let E=e.peek();if(!E)break;if(E.kind==="punctuation"&&E.value===")"){if(f===0){e.advance();break}f--;}if(E.kind==="punctuation"&&E.value==="("&&f++,E.kind==="punctuation"&&E.value===","){e.advance();continue}p.push(E.value),e.advance();}return {type:"expression",raw:`${l}(${p.join(", ")})`}}let d=i.value.toLowerCase();if(r&&Fe(d)){let p=l.split(".").slice(1).join(".");return be(se(d),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 a=e.peek(),n=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!a&&a.kind==="punctuation"&&a.value==="'s",s=!!a&&a.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",u=(()=>{if(!this.currentPatternCommand||(a?.normalized??"").toLowerCase()!=="source")return false;let f=ue[this.currentPatternCommand];return !!f&&f.roles.some(v=>v.role==="source")})(),l=!!a&&!!n&&n!=="'s"&&a.value===n&&(a.kind==="particle"||a.kind==="punctuation"||a.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 m=c.kind==="selector"&&c.value.startsWith("*"),d=c.kind==="keyword"&&!!this.currentProfile&&Ro(this.currentProfile.code,c.value);return c.kind==="identifier"||m||d||(o||s)&&(c.kind==="selector"||c.kind==="keyword")?(e.advance(),be(ke(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 a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(i),null;let n=e.peek(1);n&&n.kind,e.advance();let o=a.value.slice(1);return be(ke(r.value),o,"dot")}matchGroupToken(e,r,i,a){let n=e.mark(),o=new Map(i),s=this.matchTokenSequence(e,r.tokens,i,a);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(n.position,e.position()).some(d=>u.some(p=>this.getMatchType(d,p)!=="none"))||(s=false));}if(!s){e.reset(n);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=ar(e.value).toLowerCase();if(i&&i===ar(r).toLowerCase())return "case-insensitive"}return "none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return ke(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Fe(r)?se(r):q(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return ke(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return se(e.value);let i=e.value.toLowerCase();return Fe(i)?se(i):{type:"expression",raw:e.value};case "url":return q(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return q(a,"string")}if(e==="true")return q(true,"boolean");if(e==="false")return q(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?q(e,"duration"):q(a,"number")}let i=parseFloat(e);return isNaN(i)?q(e,"string"):q(i,"number")}applyExtractionRules(e,r){for(let[i,a]of Object.entries(e.extraction)){let n=r.get(i);if(n){if(a.transform){let o=n.type==="literal"?String(n.value):String(n.raw??"");r.set(i,a.transform(o));}}else a.value!==void 0?r.set(i,{type:"literal",value:a.value}):a.default&&r.set(i,{...a.default,implicit:true});}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=r.value.toLowerCase();if(L.ENGLISH_NOISE_WORDS.has(i)){let a=e.mark();e.advance();let n=e.peek();if(n&&(n.kind==="selector"||n.kind==="identifier"))return;let o=e.peek(1);if(n&&n.kind==="keyword"&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value))return;let s=n?(n.normalized??n.value).toLowerCase():"";if(n&&L.POSITIONAL_OR_SCOPE_KEYWORDS.has(s))return;let u=e.peek(1),l=u?(u.normalized??u.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&L.COMMAND_ACTION_KEYWORDS.has(l),m=!u||u.kind==="particle"||L.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(n&&n.kind==="keyword"&&this.currentProfile?.code!=="en"&&Fe(s)&&m||n&&n.kind==="keyword"&&this.currentProfile?.code==="en"&&Fe(s))return;e.reset(a);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(i=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return i?r:void 0}};J.CONDITION_OPERATOR_WORDS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);J.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);J.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then","while"]);J.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);J.COMMAND_ACTION_KEYWORDS=Lr;J.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);J.RUN_OPERATORS=new Set(["+","-","*","/"]);J.PICK_RANGE_SEPARATORS=new Set(["to"]);J.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"])};J.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);J.MAX_BRACE_RUN_TOKENS=64;J.MAX_PROPERTY_DEPTH=10;J.MAX_METHOD_ARGS=20;J.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);J.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Zt=J,oe=new Zt;function Z(t,e){return Kn(t,e)}function Yt(){return qn()}var Xt={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"])},Xo=new Set(Object.values(Xt).flatMap(t=>[...t]));function Sr(t,e){let r=(t.normalized??t.value).toLowerCase();if(r==="or")return true;let i=e===void 0?Xo:Xt[e];return i?i.has(t.value)||i.has(r):false}var Ie=["if","unless","repeat","for","while"],lr=/^[A-Z][A-Za-z0-9_]*$/;function K(t,e){let r=new Set([e]),a=P(t)?.keywords?.[e];if(a){a.primary&&r.add(a.primary.toLowerCase());for(let n of a.alternatives??[])r.add(n.toLowerCase());}return r}function $(t,e){return e.has(t.value.toLowerCase())?true:t.normalized?e.has(t.normalized.toLowerCase()):false}var Jo=new Set(Ie);function Xe(t,e){let r=t.normalized?.toLowerCase();return r?Jo.has(r):e.some(i=>$(t,i))}var vt=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Qo=new Set(["destination","source","style","patient","on","from","to"]);function Ze(t){if(!t||t.kind==="selector")return false;let e=(t.normalized??t.value).toLowerCase(),r=t.value.toLowerCase();return !(vt.has(e)||vt.has(r)||Qo.has(e))}var Et=new Set(["ja","ko"]);function Ne(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 Jt(t,e){let r=[],i=e.position.end,a=t.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(a){i=e.position.end+a[0].length;for(let n of a[1].split(/[,\u060c\u3001]/)){let o=n.trim();o&&r.push(o);}}return {parameters:r,headerEnd:i}}function cr(t,e,r){let i=e+1;if(i>=t.length)return -1;let a=Ne(P(r)?.roleMarkers?.patient);return a.size>0&&$(t[i],a)&&i++,i<t.length?i:-1}var Qt=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function es(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 rs(t,e,r){let i=P(r);if(i?.wordOrder!=="SOV"||!Qt.test(t[0].value)||e!==es(t))return false;let a=Ne(i.roleMarkers?.patient);return a.size===0?false:$(t[e-1],a)}function ts(t,e,r){if(!P(e))return null;let i=K(e,"behavior"),a=K(e,"def"),n=t.toLowerCase(),o=[...i].some(m=>n.includes(m)),s=/\bdef\b/.test(n)||[...a].some(m=>m!=="def"&&n.includes(m));if(!o&&!s)return null;let u=Z(t,e).tokens;if(u.length<2)return null;if($(u[0],i))return gt(t,e,u,r,0);let l=u.findIndex((m,d)=>d>0&&$(m,i));if(l>0&&lr.test(u[0].value))return gt(t,e,u,r,l);if($(u[0],a))return zt(t,e,u,r,0);let c=u.findIndex((m,d)=>d>0&&$(m,a));return c>0&&rs(u,c,e)?zt(t,e,u,r,c):null}function is(t,e,r){let i=P(e);if(!i)return null;let a=i.wordOrder!=="SOV",n=Et.has(e)?Ne(i.roleMarkers?.event):new Set,o=Et.has(e)?Ne(i.keywords?.on):new Set,s=n.size>0&&o.size>0,u=K(e,"end"),l=K(e,"on"),c=t.toLowerCase(),m=[...u].some(C=>c.includes(C)),d=(a||s)&&(()=>{let C=0;for(let g of l)if(g){for(let b=c.indexOf(g);b>=0;b=c.indexOf(g,b+g.length))if(++C>=2)return true}return false})();if(!m&&!d)return null;let p=Z(t,e).tokens;if(p.length<2)return null;let f=Ie.map(C=>K(e,C)),v=C=>Xe(C,f),E=C=>$(C,u),y=[],h=0,k=0;for(let C=0;C<p.length;C++){let g=p[C];if(E(g)){if(h>0){h--;continue}let b=t.slice(p[k].position.start,g.position.start).trim();b&&y.push(b),k=C+1;}else if(v(g))h++;else if(a&&h===0&&C>k&&$(g,l)&&Ze(p[C+1])){let b=t.slice(p[k].position.start,g.position.start).trim();b&&y.push(b),k=C;}else if(s&&h===0&&C-1>k&&$(g,n)&&p[C+1]!==void 0&&$(p[C+1],o)){let b=p[C-1],S=t.slice(p[k].position.start,b.position.start).trim();S&&y.push(S),k=C-1;}}if(k<p.length){let C=t.slice(p[k].position.start).trim();C&&y.push(C);}if(y.length<2)return null;let A=[],D=[];for(let C of y){let g;try{g=r.statement(C,e);}catch{return null}if(!g||g.kind!=="event-handler")return null;let b=g;if(A.push(b),!b.body||b.body.length===0)return null;D.push(b.metadata?.confidence??.75);}return Ue(A,"then",{sourceLanguage:e,confidence:Le(D),sourceText:t})}function Le(t){return t.length>0?t.reduce((e,r)=>e+r,0)/t.length:0}function mr(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 gt(t,e,r,i,a){let n=a>0,o=n?0:cr(r,a,e);if(o<0)return null;let s=r[o],u=s.value;if(!lr.test(u))return null;let{parameters:l,headerEnd:c}=Jt(t,s),m=n?a+1:r.findIndex(b=>b.position.start>=c);m<=o&&(m=o+1);let d=K(e,"init"),p=K(e,"end"),f=Ie.map(b=>K(e,b)),v=b=>Xe(b,f),E=b=>$(b,p),y=[],h=[],k=[],A=false,D=0,C=m;for(let b=m;b<r.length;b++){let S=r[b];if(E(S)){if(D>0){D--;continue}if(b===C){A=true;break}if($(r[C],d)){let z=t.slice(r[C].position.end,S.position.start).trim();if(z)try{let w=mr(i.body(z,e));h.push(...w),k.push(Le(w.map(x=>x.metadata?.confidence??.75)));}catch{k.push(0);}}else {let z=t.slice(r[C].position.start,S.position.start).trim();try{let w=i.statement(z,e);if(w&&w.kind==="event-handler"){let x=w;y.push(x);let R=!x.body||x.body.length===0;k.push(R?.2:x.metadata?.confidence??.75);}else k.push(0);}catch{k.push(0);}}C=b+1;}else v(S)&&D++;}if(y.length===0&&h.length===0)return null;let g=(A?1:.8)*Le(k);return go(u,l,y,h.length>0?h:void 0,{sourceLanguage:e,confidence:g,sourceText:t})}function zt(t,e,r,i,a){let n=a>0,o=n?0:cr(r,a,e);if(o<0)return null;let s=r[o],u=s.value;if(!Qt.test(u))return null;let{parameters:l,headerEnd:c}=Jt(t,s),m=n?a+1:r.findIndex(g=>g.position.start>=c);m<=o&&(m=o+1);let d=K(e,"end"),p=Ie.map(g=>K(e,g)),f=g=>Xe(g,p),v=g=>$(g,d),E=0,y=-1;for(let g=m;g<r.length;g++)if(v(r[g])){if(E===0){y=g;break}E--;}else f(r[g])&&E++;let h=r[m]?.position.start??c,k=y>=0?r[y].position.start:t.length,A=t.slice(h,k).trim();if(!A)return null;let D;try{D=mr(i.body(A,e));}catch{return null}if(D.length===0)return null;let C=Le(D.map(g=>g.metadata?.confidence??.75));return y<0&&(C*=.8),zo(u,l,D,{sourceLanguage:e,confidence:C,sourceText:t})}var Br=["live","eventsource","socket","worker","intercept"],as=new Set(["intercept"]),Mr=new Set(["eventsource","socket","worker"]),ns=new Set(["eventsource","socket"]),os=new Set(["worker"]),ss=6,us=2;function ls(t,e){for(let i of Br)if($(t[0],K(e,i)))return {action:i,keywordIdx:0};if(P(e)?.wordOrder!=="SOV")return null;let r=Math.min(t.length,ss);for(let i=1;i<r;i++)for(let a of Br)if(a!=="live"&&$(t[i],K(e,a))&&!(Mr.has(a)&&!lr.test(t[0].value))&&!(a==="intercept"&&i>us))return {action:a,keywordIdx:i};return null}function cs(t,e,r){let i=Ne(P(r)?.roleMarkers?.source);return i.size===0||e+1>=t.length?0:$(t[e],i)||$(t[e+1],i)?2:0}function ei(t){let e=K(t,"on");e.add("when");let r=P(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 ms(t,e,r){let i=P(r)?.eventHandler,a=[i?.eventMarker?.primary,...i?.eventMarker?.alternatives??[],...i?.temporalMarkers??[]].filter(o=>!!o&&/\s/.test(o)),n=1;for(let o of a){let s=o.toLowerCase().split(/\s+/),u=e-s.length+1;u<0||s.every((l,c)=>t[u+c]?.value.toLowerCase()===l)&&(n=Math.max(n,s.length));}return n}function ds(t,e,r,i,a){if(t==="live")return r+1;if(r>0){let l=r+1;return t==="eventsource"&&(l+=cs(e,l,i)),l}let n=cr(e,r,i);if(n<0)return -1;if(t==="worker")return n+1;let o=ei(i),s=Ne(P(i)?.roleMarkers?.event),u=a>=0?a:e.length;for(let l=n+1;l<u;l++){if(!$(e[l],o))continue;if(Ze(e[l+1]))return l;if(l>n+2&&s.size>0&&$(e[l-1],s)&&Ze(e[l-2]))return l-2;let c=ms(e,l,i);if(c>1&&l-c>n&&Ze(e[l-c]))return l-c;if(l>n+1&&Ze(e[l-1]))return l-1}return u}function ps(t,e,r,i){if(!Mr.has(t))return;let a=r>0?0:cr(e,r,i);if(!(a<0))return e[a].value}function fs(t,e,r){if(!P(e))return null;let i=t.toLowerCase(),a=false;for(let u of [...Br,"changes"]){for(let l of K(e,u))if(l&&i.includes(l)){a=true;break}if(a)break}if(!a)return null;let n=Z(t,e).tokens;if(n.length<2)return null;let o=Es(n,e);if(o>=0)return zs(t,e,n,r,o);let s=ls(n,e);return s?ys(t,e,n,r,s.action,s.keywordIdx):null}function ys(t,e,r,i,a,n){let o=K(e,"end"),s=Ie.map(A=>K(e,A)),u=A=>Xe(A,s),l=A=>$(A,o),c=ps(a,r,n,e);if(Mr.has(a)&&(!c||!lr.test(c)))return null;let m=A=>({sourceLanguage:e,confidence:A,sourceText:t}),d=Tr(r,n+1,l,u);if(as.has(a))return d>=0&&d!==r.length-1?null:Dr(a,[],c,m(d>=0?1:.8));let p=ds(a,r,n,e,d);if(p<0||p>r.length)return null;let f=[],v=[],E=false,y=os.has(a);if(y||ns.has(a)){let A=y?"def":"event-handler",D=0,C=p;for(let g=p;g<r.length;g++){let b=r[g];if(l(b)){if(D>0){D--;continue}if(E=true,g===C)break;let S=y?b.position.end:b.position.start,z=t.slice(r[C].position.start,S).trim();try{let w=i.statement(z,e);if(w&&w.kind===A){let x=w;f.push(x);let R=!x.body||x.body.length===0;v.push(R?.2:x.metadata?.confidence??.75);}else v.push(0);}catch{v.push(0);}C=g+1;}else u(b)&&D++;}}else {let A=Tr(r,p,l,u);E=A>=0;let D=A>=0?r[A].position.start:t.length,C=t.slice(r[p].position.start,D).trim();if(!C)return null;try{f.push(...mr(i.body(C,e)));}catch{return null}if(f.length===0)return null;v.push(...f.map(g=>g.metadata?.confidence??.75));}if(f.length===0&&!E)return null;let h=E?1:.8,k=v.length>0?h*Le(v):h;return Dr(a,f,c,m(k))}var hs=new Set([...Object.keys(ue),"then","else"]);function vs(t){let e=K(t,"when");for(let r of ei(t))e.add(r);return e}function Es(t,e){if(t.length<3||!$(t[0],vs(e)))return -1;let r=K(e,"changes"),i=K(e,"end");for(let a=2;a<t.length;a++){let n=t[a];if(n.kind==="literal")continue;if($(n,r))return a;if($(n,i))return -1;let o=(n.normalized??n.value).toLowerCase();if(n.kind==="keyword"&&hs.has(o))return -1}return -1}function gs(t,e,r){if(r==="en"){let a=e[0],n=e[e.length-1];return {type:"expression",raw:t.slice(a.position.start,n.position.end).trim()}}let i=e.map(a=>Sr(a,r)?{...a,kind:"keyword",normalized:"or"}:a);return {type:"expression",raw:Oe(i,P(r))}}function zs(t,e,r,i,a){let n=K(e,"end"),o=Ie.map(h=>K(e,h)),s=h=>Xe(h,o),u=h=>$(h,n),l=a+1;if(l>=r.length)return null;let c=Tr(r,l,u,s),m=c>=0;if(m&&c!==r.length-1)return null;let d=m?r[c].position.start:t.length,p=t.slice(r[l].position.start,d).trim();if(!p)return null;let f;try{f=mr(i.body(p,e));}catch{return null}if(f.length===0)return null;let v=gs(t,r.slice(1,a),e),y=(m?1:.8)*Le(f.map(h=>h.metadata?.confidence??.75));return Dr("when",f,void 0,{sourceLanguage:e,confidence:y,sourceText:t},new Map([["condition",v]]))}function Tr(t,e,r,i){let a=0;for(let n=e;n<t.length;n++)if(r(t[n])){if(a===0)return n;a--;}else i(t[n])&&a++;return -1}var ze={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"}};Object.fromEntries(Object.entries(ze).map(([t,e])=>{let r={};for(let[i,a]of Object.entries(e))a in r||(r[a]=i);return [t,r]}));var Cs={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},As=[["\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"]],Ds=/^(\d+)(ms|s|m)?$/,xs=new Set(["selector","literal","url","event-modifier"]);function Ss(t){let e=t.match(Ds);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 Bs(t){for(let e=1;e<t.length;e++){let r=t[e];if(xs.has(r.kind))continue;let i=r.value.toLowerCase(),a=Cs[i];if(a){let n=0;for(let o=e+1;o<t.length;o++){let s=t[o],u=Ss(s.value);if(u!==null)return {modifiers:{[a]:u},start:r.position.start,end:s.position.end};if(s.kind==="selector"||s.kind==="literal"||s.kind==="url"||++n>2)break}continue}for(let n of As){if(n[0]!==i||e+n.length>t.length)continue;let o=true;for(let s=1;s<n.length;s++)if(t[e+s].value.toLowerCase()!==n[s]){o=false;break}if(o)return {modifiers:{once:true},start:r.position.start,end:t[e+n.length-1].position.end}}}return null}new Set(Object.values(Nr).flatMap(t=>Object.values(t)));var Ce=new Set(["if","unless","while","repeat","for"]),wr=new Set(["then","end","else","if","unless","while","for","repeat","and"]),Ws=new Set(["first","last","next","previous","random","closest"]),Re=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"]),wt=class extends Error{constructor(t,e,r,i){super(t),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=i;}};function V(t,e,r){return {message:t,severity:e,source:"semantic-parser",...r&&{code:r}}}function W(t,e){return e.length===0?t:{...t,diagnostics:e}}var ur=120;function qs(t,e,r){let i=e.tokens.length;if(t.consumedTokens>=i)return null;let a=e.tokens[t.consumedTokens],n=e.tokens[i-1];if(!a||!n)return null;let o=r.slice(a.position.start,n.position.end);if(!o.trim())return null;let s=o.length>ur?`${o.slice(0,ur)}\u2026`:o,u=i-t.consumedTokens;return `pattern ${t.pattern.id} left ${u} token(s) unconsumed: "${s}"`}var Ks=new Set(["to","from","into","onto","with","as","at","of","in","on","by","and","or","then","end","else","the","a","an","async"]);function br(t){let e=[],r=new Set((t.diagnostics??[]).map(a=>`${a.code}|${a.message}`)),i=a=>{if(!a||typeof a!="object")return;if(a!==t)for(let o of a.diagnostics??[]){if(o.code!=="unconsumed-input")continue;let s=`${o.code}|${o.message}`;r.has(s)||(r.add(s),e.push(o));}let n=a;for(let o of ti){let s=n[o];if(Array.isArray(s))for(let u of s)i(u);}};return i(t),e.length===0?t:W(t,[...t.diagnostics??[],...e])}function bt(t){if(t.length>=2){let e=t[0];if((e==='"'||e==="'")&&t.endsWith(e))return t.slice(1,-1)}return t}var ti=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function ii(t,e){if(!t||typeof t!="object")return t;if(t.action&&t.roles instanceof Map){let i=re(t.action),a=i?.primaryRole;if(i&&a&&a!=="patient"&&!i.roles.some(n=>n.role==="patient")&&t.roles.has("patient")&&!t.roles.has(a)){let n=t.roles,o=n.get("patient");o!==void 0&&(n.delete("patient"),n.set(a,o));}if(t.action==="tell"){let n=t.roles,o=n.get("patient"),s=n.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!s||s.type==="literal")&&(n.delete("patient"),n.set("destination",o));}if(t.action==="transition"){let n=t.roles,o=n.get("goal");o&&o.type==="literal"&&o.dataType==="duration"&&!n.has("duration")&&(n.delete("goal"),n.set("duration",o));}if(t.action==="fetch"){let n=t.roles,o=n.get("patient"),s=n.get("source");o&&s&&(o.type==="literal"||o.type==="expression")&&s.type==="expression"&&!n.has("style")&&(n.delete("patient"),n.set("style",s),n.set("source",o));}if(t.action==="transition"){let n=t.roles,o=n.get("destination");o&&o.type==="literal"&&!n.has("goal")&&(n.delete("destination"),n.set("goal",o));let s=n.get("patient");s&&s.type==="literal"&&typeof s.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(s.value)&&n.set("patient",{type:"expression",raw:s.value});}if(t.action==="morph"){let n=t.roles,o=n.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(o.value)&&n.set("patient",{type:"expression",raw:o.value});}if(t.action==="wait"){let n=t.roles;if(!n.has("event")){let o=n.get("duration"),s=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof s=="string"&&Re.has(s.toLowerCase())&&(n.delete("duration"),n.set("event",{type:"literal",value:s,dataType:"string"}));}}if(t.kind==="command"&&t.action!=="on"){let n=t.roles,o=n.get("event");if(o&&o.type==="expression"){let s=o.raw;typeof s=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(s)&&n.set("event",{type:"literal",value:s,dataType:"string"});}}if(e?.size){let n=t.roles;for(let o of ["destination","source"]){let s=n.get(o);s&&s.type==="literal"&&typeof s.value=="string"&&e.has(s.value)&&n.set(o,{type:"expression",raw:s.value});}}}let r=t;for(let i of ti){let a=r[i];if(Array.isArray(a))for(let n of a)ii(n,e);}return t}var Q=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=ii(this.parseInternal(e,r),this.boundIdentifiers),a=this.coverageFrames[this.coverageFrames.length-1];if(a.length>0&&(i=W(i,[...i.diagnostics??[],...a])),this.parseDepth===1&&(i=br(i),i.kind==="event-handler")){let n={node:i,input:e},o=n.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(n.node,n.input,r)??this.reclaimEventCompoundTail(n.node,n.input,r)??this.reclaimResponseTypeTail(n.node,n.input,r)??this.reclaimCapturedDestinationTail(n.node,n.input,r);if(!l)break;n=l;}let s=this.reclaimEventCompoundTail(n.node,n.input,r);s&&(n=s),i=n.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=P(e)?.roleMarkers;if(i){for(let a of Object.values(i))if(a){if(a.primary)for(let n of a.primary.toLowerCase().split(/\s+/))r.add(n);for(let n of a.alternatives??[])for(let o of n.toLowerCase().split(/\s+/))r.add(o);}}for(let a of B.LEAKED_RENDER_MARKERS[e]??[])r.add(a.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 Ks.has(i)?true:B.getCoverageMarkerSurfaces(r).has(e.value.toLowerCase())}recordDroppedTokens(e,r,i){if(e.length===0)return;let a=this.coverageFrames[this.coverageFrames.length-1];if(!a||!e.some(s=>!this.isCoverageResidueToken(s,r)))return;let n=e.map(s=>s.value).join(" ").trim();if(!n)return;let o=n.length>ur?`${n.slice(0,ur)}\u2026`:n;a.push(V(`${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=ts(e,r,{statement:(z,w)=>this.parse(z,w),body:(z,w)=>this.parseStatements(z,w)});if(i)return i;let a=fs(e,r,{statement:(z,w)=>this.parse(z,w),body:(z,w)=>this.parseStatements(z,w)});if(a)return a;let n=is(e,r,{statement:(z,w)=>this.parse(z,w),body:(z,w)=>this.parseStatements(z,w)});if(n)return n;let{modifiers:o,remainingInput:s}=this.extractStandaloneModifiers(e,r),u=s||e,c=this.stripAsyncModifier(u,r).remainingInput??u,d=this.stripDoNotThrowModifier(c,r).remainingInput??c,p=[],f=Z(d,r);this.positionSource=d;{let z=f.mark(),w=this.consumeJsBlock(f,r);if(w&&f.isAtEnd())return W(w,p);f.reset(z);}let v=he(r);if(v.length===0)throw new wt(`No patterns available for language: ${r}`,r,d,[V(`No patterns registered for language '${r}'`,"error","no-patterns")]);let E=[...v].sort((z,w)=>w.priority-z.priority);{let z=f.tokens;if(P(r)?.wordOrder==="VSO"&&z.length>=4&&z[0]?.normalized==="source"){let w=z.findIndex(x=>x.normalized==="on");if(w>=2&&w+1<z.length){let x=d.slice(z[0].position.start,z[w].position.start).trim(),R=z[w+1].position.end,T=d.slice(z[w].position.start,R)+" "+x+d.slice(R);if(T!==d)try{let O=this.parse(T,r);if(O&&O.kind==="event-handler"){let N=o?this.applyModifiers(O,o):O;return W(N,p)}}catch{}}}}{let z=f.tokens,w=z[0]?.normalized==="if";for(let x=0;w&&x+3<z.length;x++){let R=(z[x+3]?.normalized??z[x+3]?.value??"").toLowerCase();if(z[x]?.normalized==="source"&&z[x+2]?.normalized==="on"&&B.KNOWN_EVENTS.has(R)){let T=(d.slice(0,z[x].position.start).trimEnd()+" "+d.slice(z[x+1].position.end).trimStart()).trim();if(T&&T!==d)try{let O=this.parse(T,r);if(O&&O.kind==="event-handler"){let N=o?this.applyModifiers(O,o):O;return W(N,p)}}catch{}break}}}{let z=f.tokens;for(let w=1;w<z.length-1;w++){let x=z[w];if(!Sr(x,r))continue;let R=z[w+1],T=(R.normalized??R.value).toLowerCase();if(!B.KNOWN_EVENTS.has(T))break;let O=w+1,N=z[w+2];N&&N.kind==="selector"&&N.value.startsWith("[")&&(O=w+2);let I=z[w].position.start,j=z[O].position.end,_=(d.slice(0,I).trimEnd()+" "+d.slice(j).trimStart()).trim();if(_&&_!==d)try{let Y=this.parse(_,r);if(Y&&Y.kind==="event-handler"){Y.additionalEvents=[{type:"literal",value:T}];let X=o?this.applyModifiers(Y,o):Y;return W(X,p)}}catch{}break}}{let z=Bs(f.tokens);if(z){let w=(d.slice(0,z.start).trimEnd()+" "+d.slice(z.end).trimStart()).trim();if(w&&w!==d)try{let x=this.parse(w,r);if(x&&x.kind==="event-handler"){let R=this.applyModifiers(x,{...o??{},...z.modifiers});return W(R,p)}}catch{}}}let y=E.filter(z=>z.command==="on"),h=f.mark(),k=oe.matchBest(f,y);if(k){p.push(V(`event pattern matched: ${k.pattern.id} (confidence: ${k.confidence.toFixed(2)})`,"info","pattern-match"));let z=false;if(/^event-[a-z]+-bare$/.test(k.pattern.id)){let w=k.captured.get("event"),x=(w?.raw??w?.value??"").toString().toLowerCase(),R=ze[r],T=B.KNOWN_EVENTS.has(x)||!!R&&Object.keys(R).some(O=>O.toLowerCase()===x);if(x&&!T){let O=this.trySOVEventExtraction(d,r,E);if(O){p.push(V(`bare-event mis-anchor on "${x}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let N=o?this.applyModifiers(O,o):O;return W(N,p)}if(w?.type==="reference"||w?.type==="expression"){f.reset(h);let N=E.filter(j=>j.command!=="on"),I=oe.matchBest(f,N);f.reset(h),I&&I.pattern.command!=="on"?(z=true,p.push(V(`bare-event mis-anchor on reference "${x}" rejected; command ${I.pattern.command} preferred`,"info","stage-bare-event-guard"))):oe.matchBest(f,y);}}}if(!z){let w=this.buildEventHandler(k,f,r),x=o?this.applyModifiers(w,o):w;return W(x,p)}}p.push(V(`event patterns: ${y.length} tried, no match`,"info","stage-event"));let A=this.tryTrailingEventExtraction(d,r,E);if(A){p.push(V("trailing event extraction succeeded","info","stage-trailing-event"));let z=o?this.applyModifiers(A,o):A;return W(z,p)}let D=E.filter(z=>z.command!=="on"),C=this.tryParseUnlessGuard(f,D,r);if(C&&C.length>0){let z=C.length===1?C[0]:Ue(C,"then",{sourceLanguage:r,confidence:1});return W(z,p)}let g=oe.matchBest(f,D);if(g){if(Ce.has(g.pattern.command)){let w=this.trySOVEventExtraction(d,r,E);if(w){p.push(V(`SOV event extraction preferred over bare ${g.pattern.command} command`,"info","stage-sov-loop"));let R=o?this.applyModifiers(w,o):w;return W(R,p)}let x=this.tryMidStreamEventExtraction(d,r,E);if(x){p.push(V(`mid-stream event extraction preferred over bare ${g.pattern.command} command`,"info","stage-midstream-loop"));let R=o?this.applyModifiers(x,o):x;return W(R,p)}}else if(B.KNOWN_EVENTS.has(g.pattern.command)&&this.hasSOVEventMarkerHead(d,r)){let w=this.trySOVEventExtraction(d,r,E);if(w){p.push(V(`SOV event extraction preferred over command-homonym event ${g.pattern.command}`,"info","stage-sov-homonym"));let x=o?this.applyModifiers(w,o):w;return W(x,p)}}else if(P(r)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(d,r,E);if(w){p.push(V(`mid-stream event extraction preferred over bare ${g.pattern.command} command`,"info","stage-midstream-cmd"));let x=o?this.applyModifiers(w,o):w;return W(x,p)}}if(g.consumedTokens<f.tokens.length&&P(r)?.wordOrder==="SOV"){let w=this.trySOVEventExtraction(d,r,E);if(w){p.push(V(`SOV event extraction preferred over partial ${g.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let x=o?this.applyModifiers(w,o):w;return W(x,p)}}if(g.consumedTokens<f.tokens.length&&!Ce.has(g.pattern.command)){let w=this.tryTopLevelCommandSequence(f,D,r);if(w)return p.push(V(`top-level command sequence: ${w.statements.length} commands`,"info","stage-top-level-sequence")),W(w,p)}p.push(V(`command pattern matched: ${g.pattern.id} (confidence: ${g.confidence.toFixed(2)})`,"info","pattern-match"));let z=qs(g,f,d);return z&&p.push(V(z,"warning","unconsumed-input")),W(this.buildCommand(g,r),p)}if(p.push(V(`command patterns: ${D.length} tried, no match`,"info","stage-command")),!d.includes(`
4
+ `)&&P(r)?.wordOrder==="VSO"){let z=this.tryMidStreamEventExtraction(d,r,E);if(z){p.push(V("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let w=o?this.applyModifiers(z,o):z;return W(w,p)}}let b=this.trySOVEventExtraction(d,r,E);if(b){p.push(V("SOV event extraction succeeded","info","stage-sov"));let z=o?this.applyModifiers(b,o):b;return W(z,p)}p.push(V("SOV event extraction: no event keyword found","info","stage-sov"));let S=this.tryCompoundCommandParsing(f,D,r);if(S)return p.push(V("compound command parsing succeeded","info","stage-compound")),W(S,p);throw p.push(V("compound parsing: no then-keywords or no command matches","info","stage-compound")),p.push(V(`all parse stages exhausted for "${d}"`,"error","parse-failed")),new wt(`Could not parse input in ${r}: ${d}`,r,d,p)}parseStatements(e,r){let i=Z(e,r),a=he(r).filter(n=>n.command!=="on").sort((n,o)=>o.priority-n.priority);this.coverageFrames.push([]);try{let n=this.parseBodyWithClauses(i,a,r),o=this.coverageFrames[this.coverageFrames.length-1];if(o.length>0&&n.length>0){let s=n[n.length-1];n[n.length-1]=W(s,[...s.diagnostics??[],...o]);}return n}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Yt()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let i={};for(let[n,o]of e.captured)i[n]=o;let a=ee(e.pattern.command,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(a),a}buildEventHandler(e,r,i){if(!e)throw new Error("No match to build event handler from");let a=e.captured.get("event");if(!a)throw new Error("Event handler pattern matched but no event captured");{let d=a.type==="expression"?a.raw:a.type==="literal"?a.value:void 0;if(typeof d=="string"&&/^[^\s()[\]{}:]+$/.test(d)){let p=ze[i]?.[d];p?a={type:"literal",value:p,dataType:"string"}:a.type==="expression"&&B.KNOWN_EVENTS.has(d.toLowerCase())&&(a={type:"literal",value:d.toLowerCase(),dataType:"string"});}}let n=oe.extractEventModifiers(r),o=e.captured.get("source");o&&e.pattern.id.endsWith("source")&&!(o.type==="reference"&&o.value==="me")&&(n={...n??{},from:o});let s=this.extractOrConjunctionEvents(r,i),u=a;s.length>0&&a.type==="literal"&&(u={type:"literal",value:[String(a.value),...s.map(p=>String("value"in p?p.value:""))].join(" or ")});let l,c=e.captured.get("action");if(c&&c.type==="literal"&&c.value==="if"){let d=r.tokens,p=-1;for(let f=r.position()-1;f>=0;f--){let v=d[f],E=(v.normalized??v.value).toLowerCase();if(this.isIfKeyword(E,i)){p=f;break}}if(p>=0){let f=he(i).filter(A=>A.command!=="on").sort((A,D)=>D.priority-A.priority),v=d.slice(p);if(e.pattern.id.endsWith("vso-verb-first")&&u.type==="literal"){let A=String(u.value??"").split("[")[0].trim().toLowerCase(),D=v.findIndex((C,g)=>{if(g===0||A==="")return false;let b=(C.normalized??C.value).toLowerCase(),S=v[g-1];return b===A&&S.kind==="keyword"&&(S.normalized??"").toLowerCase()==="on"});if(D>0){let C=v[D+1],g=C&&C.kind==="selector"&&C.value.startsWith("[")?1:0;v=[...v.slice(0,D-1),...v.slice(D+1+g)];}}let E=new ie(v,i),y=this.coverageMark(),h=this.parseBodyWithClauses(E,f,i);if(h.some(A=>A.kind==="conditional")||h.length===1&&h[0]?.kind==="compound"&&h[0].statements.some(A=>A.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return Ke(u,h,n,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(y);}}if(c&&c.type==="literal"&&String(c.value)!=="js"&&re(String(c.value))!==void 0){let d=c.value,p={};for(let[g,b]of e.captured)g!=="event"&&g!=="action"&&g!=="continues"&&(p[g]=b);if(d==="repeat"){let g=r.peek(),b=z=>(z.normalized??z.value).toLowerCase();if(g&&g.kind==="keyword"&&b(g)==="forever")p.loopType={type:"literal",value:"forever"},delete p.patient,r.advance();else if(g&&g.kind==="keyword"&&b(g)==="event"){r.advance();let z=r.peek();if(z)for(p.event={type:"literal",value:b(z)},p.loopType={type:"literal",value:"until-event"},delete p.patient;!r.isAtEnd();){let w=r.peek();if(!w||w.kind==="conjunction"||w.kind==="keyword"&&(this.isThenKeyword(w.value,i)||this.isEndKeyword(w.value,i)))break;r.advance();}}let S=p.patient;S&&S.type==="reference"&&S.value==="me"&&delete p.patient;}let f=ee(d,p,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence});this.registerBoundIdentifiers(f);let v=[];if(!Ce.has(d)||d==="repeat"||d==="while"){let g=e.pattern.id.includes("verb-first"),b=r.tokens,S=r.position(),z=R=>R.kind==="conjunction"||R.kind==="keyword"&&(this.isThenKeyword(R.value,i)||this.isEndKeyword(R.value,i)),w=new Set;{let R=P(i)?.keywords?.[d];R?.primary&&w.add(R.primary.toLowerCase());for(let T of R?.alternatives??[])w.add(T.toLowerCase());}let x=-1;for(let R=S-1;R>=0;R--){let T=b[R];if(z(T))break;if((T.normalized??T.value).toLowerCase()===d||w.has(T.value.toLowerCase())){x=R;break}}if(x>=0){let R=S;for(;R<b.length&&!z(b[R]);)R++;let T=b.slice(x,R),O=T;if(g){let N=String(a.value??"").toLowerCase(),I=T.findIndex(j=>(j.normalized??j.value).toLowerCase()===N);if(I<0)O=null;else {let j=T[I-1],_=j&&j.kind==="keyword"&&j.normalized?.toLowerCase()==="on"?I-1:I;O=[...T.slice(0,_),...T.slice(I+1)];}}if(O&&O.length>1){let N=he(i).filter(M=>M.command!=="on").sort((M,H)=>H.priority-M.priority),I=this.coverageMark(),j=this.parseClause(O,N,i),_=j[0],Y=M=>M!==null&&typeof M=="object"&&typeof M.type=="string"?M.type:typeof M,X=re(d),yr=X?.primaryRole,Xr=M=>M==="patient"&&yr&&yr!=="patient"&&!X?.roles.some(H=>H.role==="patient")?yr:M,Oi=(M,H)=>{if(!Ce.has(d)||!X)return false;let ge=X.roles.find($e=>$e.role===Xr(M));return ge?ge.expectedTypes.length>0&&!ge.expectedTypes.includes(Y(H)):true},hr=(M,H)=>M==="patient"&&!!X&&!X.roles.some(ge=>ge.role==="patient")&&Y(H)==="literal"&&It.has(String(H.value??"").toLowerCase()),vr=M=>M!==null&&typeof M=="object"&&M.implicit===true,Pi=!!_&&_.kind==="command"&&Object.entries(p).every(([M,H])=>{if(vr(H)||Oi(M,H)||hr(M,H))return true;let ge=_.roles.get(Xr(M));if(ge!==void 0&&Y(ge)===Y(H))return true;if(M==="patient"&&d==="pick"&&Y(H)==="literal"){let $e=_.roles.get("method"),Qr=Y($e),et=Qr==="literal"?String($e.value):Qr==="expression"?String($e.raw):void 0;return et!==void 0&&et===String(H.value)}return false}),Jr=_?.metadata?.patternId??"",_i=!Ce.has(d)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(Jr),Ni=/^repeat-.*-(times|for-in|while-head|until-head)$/.test(Jr);if((j.length===1||Ni&&j.length>1)&&_&&_.kind==="command"&&(_.action===d||d==="while"&&_.action==="repeat"&&/-while-head$/.test(_.metadata?.patternId??""))&&Pi&&_i&&(_.roles.size>Object.entries(p).filter(([M,H])=>!hr(M,H)).length||[..._.roles.values()].filter(M=>!vr(M)).length>Object.entries(p).filter(([M,H])=>!hr(M,H)&&!vr(H)).length))for(f=_,v=j.slice(1);r.position()<R;)r.advance();else this.coverageRollback(I);}}}if(!Ce.has(d)){let g=f;if(re(d)?.roles.some(T=>T.role==="quantity"&&!T.required)&&!g.roles.has("quantity")){let T=r.peek();T&&/^-?\d+(\.\d+)?$/.test(T.value)&&(f=ee(d,{...Object.fromEntries(g.roles),quantity:{type:"literal",value:parseFloat(T.value),dataType:"number"}},g.metadata),r.advance());}let S=f;if(re(d)?.roles.some(T=>T.role==="duration"&&!T.required)&&!S.roles.has("duration")){let T=/^\d+(\.\d+)?(ms|s)$/i,O=r.peek(),N=false;if(O&&O.kind==="particle"){let I=r.peek(1);I&&T.test(I.value)&&(N=true,O=I);}O&&T.test(O.value)&&(f=ee(d,{...Object.fromEntries(S.roles),duration:{type:"literal",value:O.value,dataType:"string"}},S.metadata),N&&r.advance(),r.advance(),this.consumeForPostposition(r,i));}let w=f,x=re(d);if(x?.roles.find(T=>T.role==="responseType"&&!T.required)&&!w.roles.has("responseType")){let T=_=>typeof _=="string"&&B.RESPONSE_TYPE_WORDS.has(_.toLowerCase()),O=(_,Y)=>{let X=Object.fromEntries(w.roles);Y&&delete X.destination,X.responseType={type:"expression",raw:_},f=ee(d,X,w.metadata);},N=w.roles.get("destination"),I=x?.roles.find(_=>_.role==="destination"),j=N?.raw??N?.value;if(N&&I&&!I.expectedTypes.includes(N.type)&&T(j))O(j,true);else {let _=r.peek();_&&T(_.value)&&(O(_.value,false),r.advance());}}if(d==="wait"){let T=f;if(!T.roles.has("event")){let O=r.peek();if(O&&Re.has(O.value.toLowerCase())){let N=Object.fromEntries(T.roles),I=N.duration;I&&I.type!=="literal"&&I.type!=="expression"&&delete N.duration;let j=N.patient;j&&j.type==="reference"&&j.value==="me"&&delete N.patient,N.event={type:"literal",value:O.value,dataType:"string"},f=ee(d,N,T.metadata),r.advance(),this.consumeForPostposition(r,i);}}}this.tryAttachTrailingRole(r,f,i),this.tryAttachTrailingStyle(r,f,i),this.tryAttachTrailingExpressionRole(r,f,i);}let E=e.captured.get("continues"),y=E?.type==="literal"&&E.value==="then",h=r.peek(),k=!!h&&this.isThenKeyword(h.value,i),D=Ce.has(d)&&!!h&&!this.isEndKeyword(h.value,i),C=!!h&&!this.isEndKeyword(h.value,i);if(y||k||D||C){let g=he(i).filter(z=>z.command!=="on").sort((z,w)=>w.priority-z.priority),b=he(i).filter(z=>z.id.startsWith("grammar-")&&z.id.includes("-continuation")).sort((z,w)=>w.priority-z.priority),S=this.parseBodyWithGrammarPatterns(r,g,b,i);S.length>0?l=[f,...v,...S]:l=[f,...v];}else l=[f,...v],r.isAtEnd()||this.recordDroppedTokens(r.tokens.slice(r.position()),i,"handler body tail");}else {let d=he(i).filter(f=>f.command!=="on").sort((f,v)=>v.priority-f.priority),p=c?e.roleStarts?.get("action"):void 0;if(p!==void 0&&p<r.position()){let f=new ie(r.tokens.slice(p),i);for(l=this.parseBodyWithClauses(f,d,i);!r.isAtEnd();)r.advance();}else l=this.parseBodyWithClauses(r,d,i);}let m=l.length>1?[Ue(l,"then",{sourceLanguage:i})]:l;return Ke(u,m,n,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,i){let a=[],n=[],o=0,s=[];for(;!e.isAtEnd();){let u=e.peek();if(!u)break;if(n.length===0){let f=this.consumeJsBlock(e,i)??this.consumeVerbFinalJsBlock(e,i);if(f){a.push(f);continue}let v=this.tryParseConditionalBlock(e,r,i);if(v){a.push(v);continue}let E=this.tryParseUnlessGuard(e,r,i);if(E){a.push(...E);continue}}let l=u.kind==="conjunction"||u.kind==="keyword"&&this.isThenKeyword(u.value,i),c=n[n.length-1],m=e.peek(1),d=c?.value.toLowerCase()==="at"&&m?.value.toLowerCase()==="of"||ct(i,u.value,c?.value,m?.value),p=u.kind==="keyword"&&this.isEndKeyword(u.value,i)&&!d;if(p&&o>0){o--,s.pop(),n.push({...u,metadata:{...u.metadata,closesTrackedBlock:true}}),e.advance();continue}if(l&&s.includes("if")){n.push(u),e.advance();continue}if(l){if(n.length>0){let f=this.parseClause(n,r,i);a.push(...f),n.length=0,o=f.filter(v=>{let E=v;return (E.action==="for"||E.action==="repeat"||E.action==="while")&&(!Array.isArray(E.body)||E.body.length===0)}).length,s.length=0;for(let v=0;v<o;v++)s.push("other");}e.advance();continue}if(p){e.advance();let f=[];for(;!e.isAtEnd();){let v=e.peek();if(!v||v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,i)||this.isEndKeyword(v.value,i)))break;f.push(v),e.advance();}if(f.length>0){let v=this.coverageMark(),E=n.length>0?this.parseClause(n,r,i):[];E.length===0&&n.length>0?(this.coverageRollback(v),a.push(...this.parseClause([...n,...f],r,i))):(a.push(...E),a.push(...this.parseClause(f,r,i)));}else if(n.length>0){let v=this.parseClause(n,r,i);a.push(...v);}n.length=0;break}if(u.kind==="keyword"){let f=(u.normalized??u.value).toLowerCase();(this.isIfKeyword(f,i)||this.isUnlessKeyword(f,i)||f==="while"||f==="for"||f==="repeat")&&(o++,s.push(this.isIfKeyword(f,i)?"if":"other"));}n.push(u),e.advance();}if(n.length>0){let u=this.parseClause(n,r,i);a.push(...u);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),i,"body stream tail"),this.foldFrontedWhileIntoRepeat(a,i);for(let u=a.length-1;u>=0;u--){let l=a[u];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&a.splice(u,1);}return a.length>1?[Ue(a,"then",{sourceLanguage:i})]:a}tryTopLevelCommandSequence(e,r,i){let a=this.coverageMark(),n;try{let l=new ie(e.tokens,i);n=this.parseBodyWithClauses(l,r,i);}catch{return this.coverageRollback(a),null}if(n.length!==1||n[0].kind!=="compound")return this.coverageRollback(a),null;let o=n[0];if(o.statements.length<2)return this.coverageRollback(a),null;let s=o.statements.map(l=>l.metadata?.confidence??.75),u=s.reduce((l,c)=>l+c,0)/s.length;return Ue(o.statements,o.chainType,{sourceLanguage:i,confidence:u})}foldFrontedWhileIntoRepeat(e,r){for(let i=0;i+1<e.length;i++){let a=e[i],n=e[i+1];if(a.kind!=="command"||a.action!=="while"||n.kind!=="command"||n.action!=="repeat")continue;let o=a.roles.get("condition");if(!o||n.roles.has("condition")||Array.isArray(a.body)||Array.isArray(n.body))continue;let s=new Map(n.roles);s.set("condition",o),s.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(i,2,{...n,roles:s,metadata:{...n.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(n.metadata?.confidence??0,a.metadata?.confidence??0)}});}}parseClause(e,r,i){if(e.length===0)return [];let a=null,n=e,o=e[e.length-1];if(o&&e.length>=2){let y=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(y,i)&&(a="unless",n=e.slice(0,-1));}let s=null;if(a&&n.length>=3){let y=P(i),h=y?B.buildVerbLookup(y):null;if(h)for(let k=1;k<n.length-1;k++){let A=n[k],D=h.get(A.value.toLowerCase())??(A.normalized?h.get(A.normalized.toLowerCase()):void 0);if(D&&!B.CONDITION_OPERATORS.has(D)){s=n.slice(0,k),n=n.slice(k);break}}}let u=new ie(n,i),l=[],c=this.coverageMark(),m=0,d=[],p=s,f=()=>{if(d.length===0)return;let y=d.slice();if(d.length=0,a&&l.length===0&&p===null){p=y;return}let h=y[0];if(!(h&&(h.kind==="identifier"||h.kind==="selector"||h.kind==="literal"||h.kind==="reference"))){this.recordDroppedTokens(y,i,"body clause");return}let A=false;for(let D of this.parseSOVClauseByVerbAnchoring(y,i)){let C=D.action,g=D.roles;C&&re(C)&&g instanceof Map&&g.size>0&&(l.push(D),A=true);}A||this.recordDroppedTokens(y,i,"body clause");};for(;!u.isAtEnd();){let y=u.peek(),h=!!y&&y.normalized?.toLowerCase()==="repeat",k=u.mark(),A=oe.matchBest(u,r);if(h&&A&&A.pattern.command!=="repeat"){u.reset(k),f(),l.push(ee("repeat",{},{sourceLanguage:i,confidence:.6})),m++,u.advance();continue}if(A&&A.pattern.command==="if"){let D=u.mark(),C=d.length;for(u.reset(k);!u.isAtEnd();){let b=u.peek();if(!b||this.isIfKeyword((b.normalized??b.value).toLowerCase(),i))break;d.push(b),u.advance();}let g=this.tryParseConditionalBlock(u,r,i);if(g){f(),l.push(g),m++;continue}d.length=C,u.reset(D);}if(A){f();let D=this.buildCommand(A,i);l.push(D),m++,this.tryAttachTrailingRole(u,D,i),this.tryAttachTrailingStyle(u,D,i),this.tryAttachTrailingExpressionRole(u,D,i),this.tryAttachTrailingDuration(u,D);}else {let D=u.peek();D&&D.normalized?.toLowerCase()==="repeat"?(f(),l.push(ee("repeat",{},{sourceLanguage:i,confidence:.6})),m++):D&&d.push(D),u.advance();}}f();let v=l;if(m===0){let y=this.parseSOVClauseByVerbAnchoring(n,i);y.length>0&&(this.coverageRollback(c),v=y);}let E=p;return a&&v.length>0&&E&&E.length>0?[ee(a,{condition:{type:"expression",raw:this.joinTokenText(E,i)}},{sourceLanguage:i,patternId:`${a}-${i}-trailing-guard`,confidence:.85}),...v]:a&&E&&E.length>0&&v.length===0?[ee(a,{condition:{type:"expression",raw:this.joinTokenText(E,i)}},{sourceLanguage:i,patternId:`${a}-${i}-trailing-guard`,confidence:.85})]:v}tryAttachTrailingDuration(e,r){let i=r.roles;if(i.has("duration")||!re(r.action)?.roles.some(o=>o.role==="duration"&&!o.required))return;let n=e.peek();!n||!/^\d+(?:\.\d+)?(?:ms|s|m|h)$/.test(n.value)||(i.set("duration",q(n.value,"duration")),e.advance());}tryAttachTrailingRole(e,r,i){let a=re(r.action);if(!a)return;let n=P(i);if(!n)return;let o=r.roles,s=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let m=(l.normalized??l.value).toLowerCase();return wr.has(m)?false:m==="body"||m==="it"||m==="you"||m==="result"||m==="document"||m==="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(!a.roles.some(E=>E.role===l))continue;let m=n.roleMarkers?.[l];if(!m)continue;let d=o.get(l);if(d&&!(d.type==="reference"&&d.value==="me"))continue;let p=E=>{if(!E||E.kind!=="particle"&&E.kind!=="keyword")return false;let y=E.value.toLowerCase();return m.primary?.toLowerCase()===y?true:c?false:(E.normalized??"").toLowerCase()===l?true:!!m.alternatives?.some(h=>h.toLowerCase()===y)},f=e.peek(),v=e.peek(1);if(!f||!v)return;if(c&&m.position==="after"){let E=e.peek(2),y=(f.normalized??f.value).toLowerCase();if(Ws.has(y)&&v.kind==="selector"&&p(E)){o.set(l,{type:"expression",raw:`${y} ${v.value}`}),e.advance(),e.advance(),e.advance();return}}if(m.position==="after"){if(s(f,c)&&p(v)){let E=this.tokenToSemanticValue(f);e.advance(),e.advance(),E&&o.set(l,E);return}if(c&&s(f,c)){let E=e.peek(2),y=e.peek(3);if((v.normalized??v.value).toLowerCase()==="in"&&E&&!p(E)&&p(y)){let h=this.tokenToSemanticValue(f);e.advance(),e.advance(),e.advance(),e.advance(),h&&o.set(l,h);return}}}else if(p(f)&&s(v,c)){e.advance();let E=this.tokenToSemanticValue(e.advance());E&&o.set(l,E);return}}}tryAttachTrailingStyle(e,r,i){if(r.action!=="fetch"&&r.action!=="render")return;let a=r.roles;if(!re(r.action)?.roles.some(y=>y.role==="style"))return;let o=a.get("style");if(o){if(o.type==="expression"&&typeof o.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(o.raw)&&e.peek()?.value===":"){let y=Ge(e,o.raw);y&&a.set("style",{type:"expression",raw:y});}this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(r.action==="fetch"){let y=a.get("patient"),h=a.get("source");if(y&&h&&(y.type==="literal"||y.type==="expression")&&h.type==="expression"&&typeof h.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(h.raw)&&e.peek()?.value===":"){let k=Ge(e,h.raw);k&&(a.set("source",{type:"expression",raw:k}),this.tryAttachResponseTypeAfterStyle(e,r,i));return}}let u=P(i)?.roleMarkers?.style;if(!u)return;if(u.position==="before"){let y=new Set([u.primary,...u.alternatives??[]].map(D=>D.toLowerCase())),h=e.peek();if(!h||!y.has(h.value.toLowerCase()))return;let k=e.mark();e.advance();let A=Ge(e);if(!A){e.reset(k);return}a.set("style",{type:"expression",raw:A}),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)),m=24,d=-1,p=0;for(let y=0;y<m;y++){let h=e.peek(y);if(!h||c(h))break;if(h.value==="("||h.value==="{"?p++:(h.value===")"||h.value==="}")&&(p=Math.max(0,p-1)),p===0&&(h.kind==="particle"||h.kind==="keyword")&&l.has(h.value.toLowerCase())){d=y;break}}if(d<=0)return;let f=[];for(let y=0;y<d;y++){let h=e.peek(y);h&&f.push(h);}if(f.length===1&&B.RESPONSE_TYPE_WORDS.has(f[0].value.toLowerCase()))return;let v=new ie(f,i),E=Ge(v);a.set("style",{type:"expression",raw:E&&v.isAtEnd()?E:this.joinTokenText(f,i)});for(let y=0;y<=d;y++)e.advance();this.tryAttachResponseTypeAfterStyle(e,r,i);}tryAttachResponseTypeAfterStyle(e,r,i){let a=r.roles;if(a.has("responseType")||!re(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=>{a.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((m,d)=>e.peek(d)?.value.toLowerCase()===m)){for(let m=0;m<c.length;m++)e.advance();break}}}tryAttachTrailingExpressionRole(e,r,i){let a=r.action,n=a==="js"?{role:"patient",terminator:"boundary"}:a==="go"||a==="scroll"?{role:"destination",terminator:"destination-marker"}:null;if(!n)return;let o=r.roles,s=o.get(n.role);if(a==="go"&&s&&s.type==="expression"&&String(s.raw).toLowerCase()==="url"){let y=e.peek();if(y&&!wr.has((y.normalized??y.value).toLowerCase())){let k=this.tokenToSemanticValue(y);if(k.type==="literal"||k.type==="selector"){o.set(n.role,k),o.set("method",{type:"literal",value:"url"}),e.advance();return}}let h=o.get("patient");if(h&&(h.type==="literal"||h.type==="selector")){o.set(n.role,h),o.set("method",{type:"literal",value:"url"}),o.delete("patient");return}}if(a==="go"&&s&&s.type==="expression"){let y=/^url\s+(\S+)$/i.exec(String(s.raw??""));if(y){let h=y[1].replace(/^["']|["']$/g,"");o.set(n.role,{type:"literal",value:h,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(a==="go"&&!s){let y=o.get("patient");if(y&&y.type==="expression"&&String(y.raw).toLowerCase()==="url"){let h=e.peek();if(h&&!wr.has((h.normalized??h.value).toLowerCase())){let k=this.tokenToSemanticValue(h);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(s&&!(s.type==="reference"&&s.value==="me"))return;let u=P(i);if(!u)return;let l=null;if(n.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)),m=24,d=[],p=0,f=false;for(let y=0;y<m;y++){let h=e.peek(y);if(!h||c(h))break;if(h.value==="("||h.value==="{"?p++:(h.value===")"||h.value==="}")&&(p=Math.max(0,p-1)),l!==null&&p===0&&(h.kind==="particle"||h.kind==="keyword")&&h.value.toLowerCase()===l){f=true;break}d.push(h);}if(d.length===0||l!==null&&!f)return;let v=d.length+(f?1:0);if(a==="go"&&d.length===2&&d[0].value.toLowerCase()==="url"){let y=this.tokenToSemanticValue(d[1]);if(y.type==="literal"||y.type==="selector"){o.set(n.role,y),o.set("method",{type:"literal",value:"url"});let h=o.get("patient");h&&h.type==="reference"&&h.value==="me"&&!re(a)?.roles.some(k=>k.role==="patient")&&o.delete("patient");for(let k=0;k<v;k++)e.advance();return}}let E=d;if(a==="js"){let y=u.keywords?.js,h=A=>[y?.primary,...y?.alternatives??[]].some(D=>!!D&&D.length>A.value.length&&D.includes(A.value)),k=0;for(;k<E.length&&h(E[k]);)k++;if(E=E.slice(k),E.length===0)return}if(o.set(n.role,{type:"expression",raw:this.joinTokenText(E,i)}),n.role!=="patient"){let y=o.get("patient");y&&y.type==="reference"&&y.value==="me"&&!re(a)?.roles.some(h=>h.role==="patient")&&o.delete("patient");}for(let y=0;y<v;y++)e.advance();}static buildVerbLookup(e){let r=new Map;for(let[i,a]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(i)&&(r.set(a.primary.toLowerCase(),i),a.alternatives))for(let n of a.alternatives)r.set(n.toLowerCase(),i);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[i,a]of Object.entries(e.roleMarkers)){if(!a)continue;if((i!=="event"||!r.has(a.primary))&&r.set(a.primary,i),a.alternatives)for(let o of a.alternatives)r.has(o)||r.set(o,i);}return r}parseSOVClauseByVerbAnchoring(e,r){let i=P(r);if(!i||i.wordOrder!=="SOV")return [];let a=B.buildVerbLookup(i),n=B.buildMarkerToRoleLookup(i),o=[],s=0;for(;s<e.length;){let u=-1,l="";for(let f=s;f<e.length;f++){let v=e[f];if(n.has(v.value))continue;let E=a.get(v.value.toLowerCase()),y=v.normalized?a.get(v.normalized.toLowerCase()):void 0,h=E||y;if(h){u=f,l=h;break}}if(u===-1)break;let c=e.slice(s,u),m=e.length;for(let f=u+1;f<e.length;f++){let v=e[f];if(v.kind==="conjunction"||this.isThenKeyword(v.value,r)){m=f;break}if(f>u+1&&!n.has(v.value)&&(a.get(v.value.toLowerCase())||(v.normalized?a.get(v.normalized.toLowerCase()):void 0))){m=f;break}}let d=e.slice(u+1,m),p=this.extractRolesFromMarkedTokens(c,d,n,l,r);if(o.push(ee(l,p,{sourceLanguage:r,confidence:.7})),s=m,s<e.length){let f=e[s];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&s++;}}return o}extractRolesFromMarkedTokens(e,r,i,a,n){let o={},s=(l,c)=>{let m=this.isEndKeyword(l.value,n),d=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !m&&!d?false:l.metadata?.closesTrackedBlock===true||m?true:!(c&&c.kind==="selector")},u=l=>{let c=[];for(let m=0;m<l.length;m++){let d=l[m];if(s(d,l[m+1]))continue;let p=i.get(d.value);if(p&&d.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c,n);if(f){let v=this.mapRoleForCommand(p,a,o);v&&(o[v]=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&&re(a)?.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 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(o=>o.kind!=="whitespace");if(i.length===0)return null;if(i.length>=2&&(i[0].kind==="selector"||/^[#.@*<]/.test(i[0].value))){let o=i.findIndex((s,u)=>u>0&&(s.normalized??s.value).toLowerCase()==="in");o>0&&(i=i.slice(0,o));}if(i.length===1)return this.tokenToSemanticValue(i[0]);let a=i.map(o=>o.value).join(""),n=i[0];return n.kind==="selector"||n.value.startsWith("#")||n.value.startsWith(".")||n.value.startsWith("@")||n.value.startsWith("*")?ke(a):n.kind==="literal"||n.value.startsWith('"')||n.value.startsWith("'")?q(bt(a),"string"):n.kind==="reference"?se(a):q(this.joinTokenText(i,r))}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return ke(r);if(r.startsWith('"')||r.startsWith("'"))return q(bt(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return q(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return q(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return q(false);if(r.length>1&&(r.startsWith(":")||r.startsWith("$")))return se(r);let i=e.normalized?.toLowerCase();return i==="me"||i==="it"||i==="you"||i==="result"||i==="body"?se(i):e.kind==="reference"?se(e.normalized||"me"):q(r)}parseBodyWithGrammarPatterns(e,r,i,a){let n=[],o=[],s=false,u=()=>{if(!s&&o.length>0){let m=this.parseSOVClauseByVerbAnchoring(o,a);n.push(...m),m.length===0&&this.recordDroppedTokens(o,a,"fused body walk");}else o.length>0&&this.recordDroppedTokens(o,a,"fused body walk");o=[],s=false;},l=0,c=()=>{let m=0;for(let d of n){let p=d;(p.action==="for"||p.action==="repeat"||p.action==="while")&&(!Array.isArray(p.body)||p.body.length===0)&&m++;}return m-l};for(;!e.isAtEnd();){let m=e.peek();if(m&&this.isThenKeyword(m.value,a)){u(),e.advance();continue}if(m&&this.isEndKeyword(m.value,a)){let p=e.peek(-1),f=e.peek(1);if(!ct(a,m.value,p?.value,f?.value)){if(u(),c()>0){l++,e.advance();continue}e.advance();break}}if(m&&!s&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),a)){u();let p=this.tryParseConditionalBlock(e,r,a);if(p){n.push(p),s=true;continue}}let d=false;if(i.length>0){let p=oe.matchBest(e,i);if(p){let f=p.pattern.command,v={};for(let[h,k]of p.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(v[h]=k);let E=ee(f,v,{sourceLanguage:a,patternId:p.pattern.id});n.push(E),d=true,s=true;let y=p.captured.get("continues");if(y&&y.type==="literal"&&y.value==="then")continue}}if(!d){let p=e.mark(),f=oe.matchBest(e,r);if(f){if(f.pattern.command==="if"){let E=e.mark();for(e.reset(p);!e.isAtEnd();){let h=e.peek();if(!h||this.isIfKeyword((h.normalized??h.value).toLowerCase(),a))break;e.advance();}let y=this.tryParseConditionalBlock(e,r,a);if(y){u(),n.push(y),s=true;continue}e.reset(E);}let v=this.buildCommand(f,a);n.push(v),this.tryAttachTrailingRole(e,v,a),d=true,s=true;}}d||(m&&o.push(m),e.advance());}u(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),a,"fused body walk");for(let m=n.length-1;m>=0;m--){let d=n[m];d.kind==="command"&&d.action==="for"&&(!(d.roles instanceof Map)||d.roles.size===0)&&(!Array.isArray(d.body)||d.body.length===0)&&n.splice(m,1);}return n}tryCompoundCommandParsing(e,r,i){let a=e.tokens,n=a.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,i)),o=a.some(c=>this.isElseKeyword(c.value,i));if(!n&&!o)return null;let s=new ie(a,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 a=false;try{let n=Z(r,"en").tokens;a=n.length===1&&n[0]?.kind==="keyword";}catch{a=false;}return B.enEventKeywordCache.set(r,a),a}matchEventMarkerPhrase(e,r,i){let a=B.SOV_EVENT_MARKER_PHRASES[i];if(!a)return 0;for(let n of a)if(n.every((o,s)=>e[r+s]?.value===o))return n.length;return 0}hasSOVEventMarkerHead(e,r){let i=B.SOV_EVENT_MARKERS[r];if(i===void 0)return false;let{tokens:a}=Z(e,r),n=ze[r],o=new Set;if(n)for(let s of Object.keys(n))o.add(s.toLowerCase());for(let s=0;s<a.length;s++){let u=a[s],l=u.value.toLowerCase(),c=u.normalized?.toLowerCase();if(!(!!c&&(B.KNOWN_EVENTS.has(c)||Re.has(c))||B.KNOWN_EVENTS.has(l)||Re.has(l)||o.has(l)))continue;let d=this.matchEventParamPhrase(a,s+1).len,p=a[s+1+d];if(p&&(p.kind==="particle"||p.kind==="keyword")&&i.has(p.value)||this.matchEventMarkerPhrase(a,s+1+d,r)>0)return true}return false}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let i=[];for(let a=r+1;a<e.length;a++){let n=e[a].value;if(n===")")return {len:a-r+1,names:i};if(n!==","){if(e[a].kind!=="identifier")break;i.push(n);}}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 a=e.value.toLowerCase();return r.has(a)||!!i&&r.has(i)}tryTrailingEventExtraction(e,r,i){let a=Z(e,r).tokens;if(a.length<3)return null;let n=ze[r],o=new Set;if(n)for(let A of Object.keys(n))o.add(A.toLowerCase());let s=a.length-2,u=a[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))return null;let c=a[a.length-1],m=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&B.KNOWN_EVENTS.has(d)||B.KNOWN_EVENTS.has(m)||o.has(m)))return null;let f=d&&B.KNOWN_EVENTS.has(d)?d:n?.[m]??m,v=a.slice(0,s);if(v.length===0)return null;let E=i.filter(A=>A.command!=="on"),y=new ie(v,r),h=this.coverageMark(),k=this.parseBodyWithClauses(y,E,r);return k.length===0?(this.coverageRollback(h),null):Ke({type:"literal",value:f},k,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,i){let a=Z(e,r).tokens;if(a.length<3)return null;let n=ze[r],o=new Set;if(n)for(let s of Object.keys(n))o.add(s.toLowerCase());for(let s=0;s<a.length-1;s++){let u=a[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))continue;let c=a[s+1],m=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&B.KNOWN_EVENTS.has(d)||B.KNOWN_EVENTS.has(m)||o.has(m)))continue;let f=d&&B.KNOWN_EVENTS.has(d)?d:n?.[m]??m,v=a.filter((A,D)=>D!==s&&D!==s+1);if(v.length===0)return null;let E=i.filter(A=>A.command!=="on"),y=new ie(v,r),h=this.coverageMark(),k=this.parseBodyWithClauses(y,E,r);return k.length===0?(this.coverageRollback(h),null):Ke({type:"literal",value:f},k,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,i){let a=B.SOV_EVENT_MARKERS[r];if(!a)return null;let o=Z(e,r).tokens,s=ze[r],u=new Set;if(s)for(let C of Object.keys(s))u.add(C.toLowerCase());let l=B.SOV_SOURCE_MARKERS[r],c=-1,m="",d="",p=1,f=[];for(let C=0;C<o.length;C++){let g=o[C],b=g.value.toLowerCase(),S=b,z="",w=b.indexOf("[");w>0&&(S=b.slice(0,w),z=g.value.slice(w));let x=g.normalized?.toLowerCase(),R=x&&(B.KNOWN_EVENTS.has(x)||Re.has(x)),T=u.has(b)||u.has(S),O=B.KNOWN_EVENTS.has(S)||Re.has(S);if(R||T||O){let N=o[C-1];if(N&&(N.normalized??N.value).toLowerCase()==="event")continue;let I;R?I=x:T?I=s?.[b]??s?.[S]??S:I=S;let j=this.matchEventParamPhrase(o,C+1);if(a.size>0){let _=1+j.len,Y=o[C+_];Y&&Y.kind==="selector"&&Y.value.startsWith("[")&&(_+=1);let X=o[C+_];if(X&&(X.kind==="particle"||X.kind==="keyword")&&a.has(X.value)){c=C,m=I,d=z||(_===j.len+2?o[C+_-1].value:""),p=_+1,f=j.names;break}}else {c=C,m=I,d=z,p=1+j.len+this.matchEventMarkerPhrase(o,C+1+j.len,r),f=j.names;break}}}if(c===-1){let C=new Set(i.filter(g=>g.command!=="on").map(g=>g.command));for(let g=0;g<o.length;g++){let b=o[g];if(b.kind==="identifier")if(a.size>0){let S=1,z=o[g+1];z&&z.kind==="selector"&&z.value.startsWith("[")&&(S=2);let w=o[g+S];if(w&&(w.kind==="particle"||w.kind==="keyword")&&a.has(w.value)){c=g,m=b.value,d=S===2?o[g+1].value:"",p=S+1;break}}else {let S=this.matchEventMarkerPhrase(o,g+1,r);if(S>0){c=g,m=b.value,d="",p=1+S;break}let z=o[g+1];if(z&&z.kind==="keyword"&&z.normalized!=null&&C.has(z.normalized)){c=g,m=b.value,d="",p=1;break}}}}if(c===-1)return null;let v=new Set;for(let C=c;C<c+p;C++)v.add(C);if(l){let C=c+p;if(C<o.length){let g=o[C];if((g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value))v.add(C);else if(this.isStrippableSourceRef(g,l.windowTokens)){let b=o[C+1];b&&(b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value)&&(v.add(C),v.add(C+1));}}if(c>=2){let g=o[c-1];(g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(v.add(c-2),v.add(c-1));}for(let g=0;g<c;g++){let b=o[g],S=b.value.toLowerCase(),z=b.normalized?.toLowerCase();if(l.windowTokens.has(S)||z&&l.windowTokens.has(z)){v.add(g);break}}}let E=o.filter((C,g)=>!v.has(g));if(E.length===0)return null;let y=i.filter(C=>C.command!=="on"),h=new ie(E,r),k=this.coverageMark(),A=this.parseBodyWithClauses(h,y,r);if(A.length===0)return this.coverageRollback(k),null;let D={sourceLanguage:r,confidence:.75};return d&&(D.keyFilter=d),Ke(B.isEnEventKeyword(m)?{type:"literal",value:m}:{type:"expression",raw:m},A,void 0,D,f)}profileKeywordMatches(e,r,i){let a=P(e)?.keywords?.[r];return a?a.primary?.toLowerCase()===i?true:!!a.alternatives?.some(n=>n.toLowerCase()===i):false}consumeForPostposition(e,r){let i=e.peek();if(!i)return;let a=(i.normalized??"").toLowerCase(),n=P(r)?.keywords?.for;(a==="for"||i.value===n?.primary||(n?.alternatives??[]).includes(i.value))&&e.advance();}isThenKeyword(e,r){let i=e.toLowerCase(),n={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\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 n?n.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(),a=Io(r);return a?i==="end"||a.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=P(r)?.roleMarkers?.patient;if(!i?.primary)return false;let a=e.value.toLowerCase();return i.primary.toLowerCase()===a?true:!!i.alternatives?.some(n=>n.toLowerCase()===a)}isJsBlockTerminator(e,r){return this.isEndKeyword(e,r)||this.profileKeywordMatches(r,"end",e.toLowerCase())}consumeVerbFinalJsBlock(e,r){let i=e.mark(),a=0,n=-1;for(;;){let c=e.peek(a);if(!c||this.isThenKeyword(c.value,r)||this.isJsBlockTerminator(c.value,r))break;if(this.isJsKeyword(c)){let m=e.peek(a+1),d=!!m&&c.position?.end!==void 0&&c.position.end===m.position?.start&&this.profileKeywordMatches(r,"js",`${c.value}${m.value}`.toLowerCase()),p=e.peek(a+(d?2:1));if(a>0&&p&&this.isJsBlockTerminator(p.value,r)){n=a;break}}a++;}if(n<=0)return null;let o=[];for(let c=0;c<n;c++){let m=e.peek(c);m&&o.push(m);}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<n;c++)e.advance();e.advance();let l=e.peek();return l&&!this.isJsBlockTerminator(l.value,r)&&e.advance(),e.advance(),ee("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 a=e.mark(),n=[];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}n.push(c);}if(!u)return e.reset(a),null;let l=this.rawJsBody(n);return ee("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,a=this.positionSource;if(a!==void 0&&r!==void 0&&i!==void 0){let o=a.slice(r,i),s=u=>u.replace(/\s+/g,"");if(s(o)===s(e.map(u=>u.value).join("")))return o.trim()}let n="";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&&(n+=" "),n+=e[o].value;}return n.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 a=e.peek();if(!a||!this.isUnlessKeyword((a.normalized??a.value).toLowerCase(),i))return null;let n=e.mark(),o=this.tryParseConditionalBlock(e,r,i,true);if(!o||o.kind!=="conditional")return e.reset(n),null;let s=o;if(s.elseBranch&&s.elseBranch.length>0)return e.reset(n),null;let u=s.roles.get("condition");return u?[ee("unless",{condition:u},{sourceLanguage:i,patternId:`unless-${i}-guard`,confidence:1}),...s.thenBranch]:(e.reset(n),null)}isBlockEndToken(e,r,i){return this.isEndKeyword(e.value,i)?true:e.kind!=="keyword"||(e.normalized??"").toLowerCase()!=="end"?false:!(r&&r.kind==="selector")}tryParseConditionalBlock(e,r,i,a=false){let n=e.peek();if(!n)return null;let o=(n.normalized??n.value).toLowerCase();if(!this.isIfKeyword(o,i)&&!(a&&this.isUnlessKeyword(o,i)))return null;let s=e.mark(),u=this.coverageMark();e.advance();let l=[],c=0;for(;!e.isAtEnd();){let b=e.peek();if(!b)break;let S=(b.normalized??b.value).toLowerCase();if(this.isIfKeyword(S,i)||this.isUnlessKeyword(S,i)){c++,l.push(b),e.advance();continue}if(this.isBlockEndToken(b,e.peek(1)??void 0,i)){if(c===0){e.advance();break}c--,l.push(b),e.advance();continue}l.push(b),e.advance();}if(l.length===0)return e.reset(s),this.coverageRollback(u),null;let m=P(i),d=m?.wordOrder==="SOV"?B.buildVerbLookup(m):null,p=0,f=0,v=[];for(;p<l.length;p++){let b=l[p],S=(b.normalized??b.value).toLowerCase();if(this.isIfKeyword(S,i)||this.isUnlessKeyword(S,i)?f++:this.isBlockEndToken(b,l[p+1],i)&&f--,f===0&&this.isThenKeyword(b.value,i)){p++;break}if(f===0&&v.length>0){let z=(l[p-1].normalized??l[p-1].value).toLowerCase(),w=l[p-1].value.toLowerCase(),x=(b.normalized??b.value).toLowerCase(),R=B.CONDITION_COPULAS.has(z)||B.CONDITION_COPULAS_SURFACE.has(w)&&B.CONDITION_PREDICATES.has(x),T=d!==null&&d.has(b.value.toLowerCase())&&!B.CONDITION_PREDICATES.has(x),O=/^\.[a-zA-Z_]\w*$/.test(b.value)&&l[p-1].position?.end!==void 0&&b.position?.start!==void 0&&l[p-1].position.end===b.position.start;if(!B.CONDITION_OPERATORS.has(x)&&!O&&(!R||T)&&(this.tokensBeginCommand(l.slice(p),r,i)||this.sovCommandStartsAt(l.slice(p),d)))break}v.push(b);}if(v.length===0)return e.reset(s),this.coverageRollback(u),null;let y=[],h=[],k=false,A=0;for(;p<l.length;p++){let b=l[p],S=(b.normalized??b.value).toLowerCase();if(this.isIfKeyword(S,i)||this.isUnlessKeyword(S,i)?A++:this.isBlockEndToken(b,l[p+1],i)&&A--,A===0&&!k&&this.isElseKeyword(b.value,i)){k=true;continue}(k?h:y).push(b);}let D={type:"expression",raw:this.joinTokenText(v,i)},C=this.parseBranch(y,r,i),g=h.length>0?this.parseBranch(h,r,i):void 0;return C.length===0&&(!g||g.length===0)?(e.reset(s),this.coverageRollback(u),null):ko(D,C,g,{sourceLanguage:i,patternId:`conditional-${i}-folded`,confidence:1})}joinTokenText(e,r){return Oe(e,P(r))}tokensBeginCommand(e,r,i){if(e.length===0)return false;let a=new ie(e,i);return oe.matchBest(a,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let i=s=>r.has(s.value.toLowerCase())||!!s.normalized&&r.has(s.normalized.toLowerCase()),a=s=>s.kind==="identifier"||s.kind==="selector"||s.kind==="literal"||s.kind==="reference",n=0,o=0;for(;n+1<e.length;){let s=e[n],u=e[n+1];if(!a(s)||u.kind!=="particle")break;o+=1,n+=2;let l=e[n];if(o>=1&&l&&i(l))return true}return false}parseBranch(e,r,i){if(e.length===0)return [];let a=new ie(e,i),n=this.parseBodyWithClauses(a,r,i);return n.length===1&&n[0]?.kind==="compound"?n[0].statements:n}extractStandaloneModifiers(e,r){let a=Z(e,r).tokens;if(a.length===0)return {modifiers:null,remainingInput:null};let o=a[0].value.toLowerCase(),s=B.STANDALONE_MODIFIERS[o];if(!s)return {modifiers:null,remainingInput:null};let u={},l=1;if(s==="once")u.once=true;else {let p=1;if(p<a.length){let f=a[p],v=a[p+1],E=f.kind==="identifier"&&v?.kind==="literal"&&/^\d+(ms|s|m)?$/.test(v.value);(f.kind==="keyword"||f.kind==="particle"||E)&&(p++,l++);}if(p<a.length){let f=a[p];if(f.kind==="literal"){let v=f.value.match(/^(\d+)(ms|s|m)?$/);if(v){let E=parseInt(v[1],10),y=v[2]||"ms";y==="s"?E*=1e3:y==="m"&&(E*=6e4),u[s]=E,l=p+1;}}}u[s]||(u[s]=s==="debounce"?300:100);}let c=a.slice(l);if(c.length===0)return {modifiers:null,remainingInput:null};let m=c[0].position.start,d=e.slice(m);return {modifiers:u,remainingInput:d}}stripAsyncModifier(e,r){let i=P(r)?.keywords?.async,a=new Set(["async"]);i?.primary&&a.add(i.primary.toLowerCase()),i?.alternatives?.forEach(l=>a.add(l.toLowerCase()));let n=Z(e,r).tokens,o=n.findIndex(l=>a.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let s=n[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 a=0;a<i.length-1;a++){if(i[a].value.toLowerCase()!=="do")continue;let n=-1;for(let l=a+1;l<=a+5&&l<i.length;l++){let c=i[l];if(c.normalized?.toLowerCase()==="throw"){n=l;break}let m=c.kind;if(m==="selector"||m==="literal"||m==="reference"||m==="conjunction")break}if(n===-1)continue;let o=i[a].position.start,s=i[n].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 a=/unconsumed: "(.*)"$/.exec(i.message)?.[1];return !a||a.replace(/\s+/g," ").trim()!==r})}}reclaimDanglingFromTail(e,r,i){let a=B.droppedTokenCount,n=B.unconsumedSpans(e);if(n.length===0)return null;let o=a(e),s=P(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 m=l[c];if(m.normalized!=="source"&&!u.has(m.value))continue;let d=s?.position==="after"?c-1:c+1,p=l[d];if(!p||p.kind!=="identifier"&&p.kind!=="keyword")continue;let f=Math.min(m.position.start,p.position.start),v=Math.max(m.position.end,p.position.end),E=r.slice(f,v).replace(/\s+/g," ").trim();if(!n.some(h=>h===E||h.includes(E)))continue;let y=(r.slice(0,f).trimEnd()+" "+r.slice(v).trimStart()).trim();if(!(!y||y===r))try{let h=this.parse(y,i);if(!h||h.kind!=="event-handler")continue;let k=br(h);if(a(k)<o)return {node:{...k,eventModifiers:{...k.eventModifiers,from:{type:"literal",value:p.value,dataType:"string"}}},input:y}}catch{}}return null}reclaimEventCompoundTail(e,r,i){let a=B.unconsumedSpans(e);if(a.length===0)return null;let n=ze[i];if(!n)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=m=>m.replace(/\s+/g," ").trim(),c=Z(r,i).tokens;for(let m of a)for(let d=1;d<c.length;d++)for(let p=d;p<c.length;p++){let f=l(r.slice(c[d].position.start,c[p].position.end));if(f.length>m.length)break;if(f!==m)continue;let v=c[d-1];if((n[v.value]??v.normalized)!==u)break;let y=l(r.slice(v.position.start,c[p].position.end)),h=n[y];if(!h)break;return o.set("event",{type:"literal",value:h,dataType:"string"}),{node:B.withoutSpanDiagnostics(e,m),input:r}}return null}reclaimResponseTypeTail(e,r,i){let a=B.unconsumedSpans(e);if(a.length===0)return null;let n=B.AS_MARKERS_BEFORE[i];if(!n)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],m=u[l+1];if(!n.some(f=>c.value.toLowerCase()===f)||!B.RESPONSE_TYPE_WORDS.has(m.value.toLowerCase()))continue;let d=o(r.slice(c.position.start,m.position.end));if(!a.includes(d))continue;let p=(r.slice(0,c.position.start).trimEnd()+" "+r.slice(m.position.end).trimStart()).trim();if(!(!p||p===r))try{let f=this.parse(p,i);if(!f||f.kind!=="event-handler")continue;let v=br(f);if(B.droppedTokenCount(v)>=s)continue;let E=B.findResponseTypeTarget(v);if(!E)continue;return E.roles.set("responseType",{type:"expression",raw:m.value}),{node:v,input:p}}catch{}}return null}static findResponseTypeTarget(e){let r=null,i=a=>{if(!a||typeof a!="object"||r)return;if(a.kind==="command"){let o=a;if(re(o.action)?.roles.some(u=>u.role==="responseType"&&!u.required)&&!o.roles.has("responseType")){r=o;return}}let n=a;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let s=n[o];Array.isArray(s)&&s.forEach(u=>i(u));}};return i(e),r}reclaimCapturedDestinationTail(e,r,i){let a=B.unconsumedSpans(e);if(a.length===0)return null;let n=P(i)?.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 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],m=u[l+1],d=o.has(c.value)&&m.normalized==="me",p=c.normalized==="me"&&o.has(m.value);if(!d&&!p)continue;let f=s(r.slice(c.position.start,m.position.end));if(!a.includes(f))continue;let v=false,E=y=>{if(!y||typeof y!="object"||v)return;if(y.kind==="command"){let k=y.roles.get("destination");if(k?.type==="reference"&&k.value==="me"){v=true;return}}let h=y;for(let k of ["body","statements","thenBranch","elseBranch","commands"]){let A=h[k];Array.isArray(A)&&A.forEach(D=>E(D));}};if(E(e),!!v)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 a=e.mark(),n=e.peek();if(!n)break;if(!Sr(n,r)){e.reset(a);break}e.advance();let o=e.peek();if(!o){e.reset(a);break}let s=(o.normalized||o.value).toLowerCase();e.advance(),i.push({type:"literal",value:s});}return i}};Q.coverageMarkerSurfaces=new Map;Q.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};Q.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"]};Q.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};Q.enEventKeywordCache=new Map;Q.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);Q.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);Q.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"])};Q.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};Q.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"])}};Q.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);Q.CONDITION_COPULAS_SURFACE=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948"]);Q.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);Q.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Q.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};var Hs=Q,Us=new Hs;function Gs(t,e){return Us.parse(t,e)}function Zs(t,e){try{let r=Z(t,e),i=he(e);if(i.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let a=[...i].sort((l,c)=>c.priority-l.priority),n=a.filter(l=>l.command==="on"),o=oe.matchBest(r,n);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=a.filter(l=>l.command!=="on"),u=oe.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 ai(t,e){try{let i=Gs(t,e);if(i)return {node:i,confidence:i.metadata?.confidence??.8,error:void 0,tokensConsumed:Z(t,e).tokens.length}}catch{}let r=Zs(t,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function ni(t,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...t].sort((i,a)=>{let n=i[r]??99,o=a[r]??99;return n-o})}function Me(t,e){let r,i;if(t.markerOverride&&t.markerOverride[e.code]!==void 0)r=t.markerOverride[e.code],i=r?Ee(t,e.code,r):void 0;else {let a=e.roleMarkers[t.role];if(a){r=a.primary;let n=Ee(t,e.code,r)??[],o=[...new Set([...a.alternatives??[],...n])].filter(s=>s!==r);i=o.length?o:void 0;}}return {marker:r,alternatives:i}}function Je(t,e,r){r.roles.find(a=>a.role==="scope"&&!a.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 jr(t,e,r,i){si(t,e,r,i,"manner",{requireMarker:true});}function oi(t,e,r,i){si(t,e,r,i,"recipient",{requireMarker:false});}function si(t,e,r,i,a,n){let o=r.roles.find(u=>u.role===a&&!u.required);if(!o)return;let s=o.markerOverride?.[i];n.requireMarker&&!s||(t.push({type:"group",optional:true,tokens:[...(s?s.split(/\s+/):[]).map(u=>({type:"literal",value:u})),{type:"role",role:a,optional:true,expectedTypes:o.expectedTypes,...o.valueShape!==void 0?{valueShape:o.valueShape}:{}}]}),e[a]={fromRole:a});}function ui(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 li(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:a,alternatives:n}=Me(i,e),o={type:"role",role:r,optional:false,...i.valueShape!==void 0?{valueShape:i.valueShape}:{}};if(!a)return [o];let s=a.split(/\s+/).filter(Boolean),u={type:"group",optional:true,tokens:s.map(c=>({type:"literal",value:c,...s.length===1&&n?.length?{alternatives:n}:{}}))};return (e.roleMarkers[r]?.position??"before")==="after"?[o,u]:[u,o]}function ci(t,e,r,i,a){for(let n of r.roles)n.required||a.has(n.role)||e[n.role]||!(n.markerOverride?.[i.code]??i.roleMarkers[n.role]?.primary)&&n.valueShape===void 0||(t.push({type:"group",optional:true,tokens:pi(n,i)}),e[n.role]=n.default?{fromRole:n.role,default:n.default}:{fromRole:n.role});}function Ys(t,e,r,i,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let f=i.primary.split(/\s+/);if(f.length>1)for(let v of f)n.push({type:"literal",value:v});else {let v=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(v);}}let o=ui(t),s=e.roleMarkers.destination,u=t.roles.some(f=>f.role==="destination");s&&u&&o!=="destination"&&n.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"&&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(...li(t,e,o));let m=e.roleMarkers.patient;if(m&&o==="patient"){let f=m.alternatives?{type:"literal",value:m.primary,alternatives:m.alternatives}:{type:"literal",value:m.primary};n.push(f);}let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(d),o!=="source"&&n.push(...Se(t,e.roleMarkers.source)),o!=="destination"&&n.push(...Fr(t,e.roleMarkers.destination));let p={action:{value:t.action},event:{fromRole:"event"},[o]:{fromRole:o},...o==="destination"?{}:De(t),...o==="source"?{}:xe(t)};return ci(n,p,t,e,new Set(["event",o,"destination","source"])),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`{event} ${i.primary} {destination?} {${o}} ${m?.primary||""} ${r.primary}`,tokens:n},extraction:p}}function Xs(t,e,r,i,a){let n=[],o=t.action==="swap",s=o?"destination":"patient";n.push({type:"role",role:s,optional:false});let u=e.roleMarkers.patient;if(u){let d=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};n.push(d);}if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let d=i.primary.split(/\s+/);if(d.length>1)for(let p of d)n.push({type:"literal",value:p});else {let p=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(p);}}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(l),n.push(...Se(t,e.roleMarkers.source));let c=e.roleMarkers.destination;if(o&&c){let d=t.roles.find(p=>p.role==="patient")?.markerOverride?.[e.code];if(d&&d!==c.primary){let p=c.alternatives??[];p.includes(d)||(c={...c,alternatives:[...p,d]});}}n.push(...o?za(t,c):Fr(t,c));let m={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...o?{}:De(t),...xe(t)};return oi(n,m,t,e.code),jr(n,m,t,e.code),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`{patient} ${u?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:n},extraction:m}}function Js(t,e,r,i,a){let n=t.roles.find(m=>m.role==="source");if(!n)return null;let{marker:o,alternatives:s}=Me(n,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,...n.expectedTypes?{expectedTypes:n.expectedTypes}:{},...n.valueShape!==void 0?{valueShape:n.valueShape}:{}});for(let m of o.split(/\s+/))l.push(s&&o.split(/\s+/).length===1?{type:"literal",value:m,alternatives:s}:{type:"literal",value:m});if(l.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let d of m)l.push({type:"literal",value:d});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 oi(l,c,t,e.code),jr(l,c,t,e.code),{id:`${t.action}-event-${e.code}-sov-source-fronted`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{patient} ${u?.primary||""} {source} ${o} {event} ${i.primary} ${r.primary}`,tokens:l},extraction:c}}function Qs(t,e,r,i,a){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 s=e.roleMarkers.destination;if(s&&(n.push({type:"role",role:"destination",optional:false}),n.push(s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary})),n.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)n.push({type:"literal",value:c});else {let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(c);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),{id:`${t.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(a.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${s?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function eu(t,e,r,i,a){let n=[];n.push({type:"role",role:"event",optional:false});let o=i.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&n.push({type:"literal",value:o[0],alternatives:o.slice(1)});let s=e.roleMarkers.destination;s&&n.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}]}),n.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};n.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(l),n.push(...Se(t,e.roleMarkers.source)),n.push(...Fr(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(a.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...De(t),...xe(t)}}}function ru(t,e,r,i,a){let n=[];if(n.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)n.push({type:"literal",value:u});else {let u=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(u);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(o),{id:`${t.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{event} ${i.primary} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function tu(t,e,r,i){let a=e.eventHandler?.temporalMarkers;if(!a||a.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:a[0],alternatives:a.slice(1)}),n.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};n.push(u);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),{id:`${t.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(i.basePriority??100)+49,template:{format:`{event} ${a[0]} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function iu(t,e,r,i,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let d of m)n.push({type:"literal",value:d});else {let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(d);}}let s=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.sovPosition??999,f=d.sovPosition??999;return p-f});for(let m of s){n.push({type:"role",role:m.role,optional:false});let{marker:d,alternatives:p}=Me(m,e);if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};n.push(f);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u);let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Je(n,c,t),{id:`${t.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`{event} ${i.primary} ${l} ${r.primary}`,tokens:n},extraction:c}}function au(t,e,r,i,a){let n=[],s=[...t.roles.filter(c=>c.required)].sort((c,m)=>{let d=c.sovPosition??999,p=m.sovPosition??999;return d-p});for(let c of s){n.push({type:"role",role:c.role,optional:false});let{marker:m,alternatives:d}=Me(c,e);m&&n.push(d?{type:"literal",value:m,alternatives:d}:{type:"literal",value:m});}if(n.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),n.push({type:"role",role:"event",optional:false}),i.position==="after"){let c=i.primary.split(/\s+/);if(c.length>1)for(let m of c)n.push({type:"literal",value:m});else n.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 Je(n,l,t),{id:`${t.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(a.basePriority??100)+40,template:{format:`${u} ${r.primary} {event} ${i.primary}`,tokens:n},extraction:l}}function nu(t,e,r,i,a){let n=[],s=[...t.roles.filter(E=>E.required)].sort((E,y)=>{let h=E.sovPosition??999,k=y.sovPosition??999;return h-k}),u=s[0];n.push({type:"role",role:u.role,optional:false});let{marker:l,alternatives:c}=Me(u,e);if(l){let E=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};n.push(E);}if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let E=i.primary.split(/\s+/);if(E.length>1)for(let y of E)n.push({type:"literal",value:y});else {let y=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(y);}}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(m);let d=s[1];n.push({type:"role",role:d.role,optional:false});let{marker:p,alternatives:f}=Me(d,e);if(p){let E=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};n.push(E);}let v={action:{value:t.action},event:{fromRole:"event"},[u.role]:{fromRole:u.role},[d.role]:{fromRole:d.role}};return Je(n,v,t),{id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{${u.role}} {event} ${i.primary} ${r.primary} {${d.role}}`,tokens:n},extraction:v}}function mi(t,e,r){let i=Ee(t,e.code,r.primary)??[],a=[...new Set([...r.alternatives??[],...i])].filter(n=>n!==r.primary);return a.length?a:void 0}function Ct(t,e,r,i,a){let n=[];if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(m);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=ui(t);n.push(...li(t,e,s));let u=e.roleMarkers.destination,l=t.roles.some(m=>m.role==="destination");u&&l&&s!=="destination"&&n.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"&&n.push(...Se(t,e.roleMarkers.source));let c={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...s==="destination"?{}:De(t),...s==="source"?{}:xe(t)};return ci(n,c,t,e,new Set(["event",s,"destination","source"])),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`${i.primary} {event} ${r.primary} {${s}} ${u?.primary||""} {destination?}`,tokens:n},extraction:c}}function ou(t,e,r,i,a){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=t.action==="swap";n.push({type:"role",role:s?"destination":"patient",optional:false});let u=s?void 0:e.roleMarkers.destination;if(u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),n.push(...Se(t,e.roleMarkers.source)),i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(c);}if(n.push({type:"role",role:"event",optional:false}),s){let c=t.roles.find(m=>m.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:t.action},event:{fromRole:"event"},[s?"destination":"patient"]:{fromRole:s?"destination":"patient"},...s?{}:De(t),...xe(t)};return jr(n,l,t,e.code),{id:`${t.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${i.primary} {event}`,tokens:n},extraction:l}}function su(t,e,r,i,a){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let u=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.svoPosition??999,f=d.svoPosition??999;return p-f});for(let m of u){let d,p;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)d=m.markerOverride[e.code],p=d?Ee(m,e.code,d):void 0;else {let f=e.roleMarkers[m.role];f&&(d=f.primary,p=mi(m,e,f));}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};n.push(f);}n.push({type:"role",role:m.role,optional:false});}if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(m);}n.push({type:"role",role:"event",optional:false});let l=u.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Je(n,c,t),{id:`${t.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${r.primary} ${l} ${i.primary} {event}`,tokens:n},extraction:c}}function At(t,e,r,i,a){let n=[];if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(m);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let u=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.svoPosition??999,f=d.svoPosition??999;return p-f});for(let m of u){let d,p;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)d=m.markerOverride[e.code],p=d?Ee(m,e.code,d):void 0;else {let f=e.roleMarkers[m.role];f&&(d=f.primary,p=mi(m,e,f));}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};n.push(f);}n.push({type:"role",role:m.role,optional:false});}let l=u.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Je(n,c,t),{id:`${t.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`${i.primary} {event} ${r.primary} ${l}`,tokens:n},extraction:c}}function uu(t,e,r,i,a){let n=[],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};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 s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(s),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),n.push(...Se(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${i.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...De(t),...xe(t)}}}function lu(t,e,r,i){let a=[];a.push({type:"literal",value:"and",alternatives:["then"]}),a.push({type:"role",role:"event",optional:false});let n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(n),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&a.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}]}),a.push(...Se(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:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...De(t),...xe(t)}}}var je={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Ye(t,e,r=je){let i=`${t.action}-${e.code}-generated`,a=r.basePriority??100,n=e.keywords[t.action];if(!n)throw new Error(`No keyword translation for '${t.action}' in ${e.code}`);let o=pu(t,e,n),s=$r(t,e),u=vu(t,e,n);return {id:i,language:e.code,command:t.action,priority:a,template:{format:u,tokens:o},extraction:s}}function cu(t,e,r=je){if(t.roles.filter(s=>!s.required).length===0)return null;let a=t.roles.filter(s=>s.required),n={...t,roles:a};return {...Ye(n,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:$r(t,e)}}function Dt(t,e,r=je){if(e.wordOrder!=="SOV")return null;let i=t.roles.filter(s=>s.required);if(i.length!==1)return null;let a=e.keywords[t.action];if(!a)return null;let n=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.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:`${a.primary} <${i[0].role}>`,tokens:[n,...o]},extraction:$r(t,e)}}function mu(t,e,r=je){let i=[];if(i.push(Ye(t,e,r)),r.generateSimpleVariants){let a=cu(t,e,r);a&&i.push(a);}for(let a of t.omitRoleVariants??[]){let n={...t,roles:t.roles.filter(s=>s.role!==a)},o=Ye(n,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-no-${a}`,priority:(r.basePriority??100)-8});}for(let a of t.widenTypeVariants??[]){if(a.excludeLanguages?.includes(e.code))continue;let n={...t,roles:t.roles.map(s=>s.role===a.role?{...s,expectedTypes:[...a.types]}:s)},o=Ye(n,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-${a.idSuffix}`,priority:(r.basePriority??100)-(a.priorityDelta??15)});}if(r.generateVerbFirstVariants!==false){let a=Dt(t,e,r);a&&i.push(a);}for(let a of t.rolePrefixLiteralVariants??[]){let n=a.literal[e.code];if(!n)continue;let{rolePrefixLiteralVariants:o,...s}=t,u={...s,roles:t.roles.map(d=>d.role===a.role?{...d,valuePrefixLiteral:{[e.code]:n}}:d)},l=a.priorityDelta??5,c=a.methodCarrier?{[a.methodCarrier]:{value:n}}:{},m=Ye(u,e,r);if(i.push({...m,id:`${t.action}-${e.code}-generated-${a.idSuffix}`,priority:(r.basePriority??100)+l,extraction:{...m.extraction,...c}}),r.generateVerbFirstVariants!==false){let d=Dt(u,e,r);d&&i.push({...d,id:`${t.action}-${e.code}-generated-verb-first-${a.idSuffix}`,priority:(r.basePriority??100)-20+l,extraction:{...d.extraction,...c}});}}return i}function di(t,e=je){let r=[],i=jn();for(let a of i){if(!t.keywords[a.action])continue;let n=mu(a,t,e);if(r.push(...n),t.eventHandler?.eventMarker){let o=du(a,t,e);r.push(...o);}}return r}function du(t,e,r=je){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let i=[],a=e.eventHandler.eventMarker,n=e.keywords[t.action];if(!n)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(iu(t,e,n,a,r)),i.push(nu(t,e,n,a,r)),i.push(au(t,e,n,a,r));else {i.push(Ys(t,e,n,a,r)),i.push(Xs(t,e,n,a,r));let u=Js(t,e,n,a,r);u&&i.push(u);let l=e.roleMarkers.destination;l&&l.primary!==a.primary&&i.push(Qs(t,e,n,a,r));let c=a.primary.split(/\s+/),m=a.alternatives?.some(p=>!p.includes(" ")&&p.length>1);c.length>1&&m&&i.push(eu(t,e,n,a,r)),i.push(ru(t,e,n,a,r));let d=tu(t,e,n,r);d&&i.push(d);}else e.wordOrder==="VSO"?s?(i.push(At(t,e,n,a,r)),i.push(su(t,e,n,a,r))):(i.push(Ct(t,e,n,a,r)),i.push(ou(t,e,n,a,r)),e.eventHandler?.negationMarker&&i.push(uu(t,e,n,a,r)),e.tokenization?.prefixes&&i.push(lu(t,e,n,r))):s?i.push(At(t,e,n,a,r)):i.push(Ct(t,e,n,a,r));return i}function pu(t,e,r){let i=[],a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},n=yu(t,e);switch(e.wordOrder){case "SVO":i.push(a),i.push(...n);break;case "SOV":i.push(...n),i.push(a);break;case "VSO":i.push(a),i.push(...n);break;default:i.push(a),i.push(...n);}return fu(i)}function fu(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 a=[...i.alternatives??[],...r.alternatives??[]];a.length&&(e[e.length-1]={...i,alternatives:[...new Set(a)]});continue}e.push(r);}return e}function yu(t,e){let r=[],i=ni(t.roles,e.wordOrder);for(let a of i){let n=pi(a,e);a.required?r.push(...n):r.push({type:"group",optional:true,tokens:n});}return r}function pi(t,e){let r=[],i=t.markerOverride?.[e.code],a=e.roleMarkers[t.role],n=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,m=a?.position??(e.wordOrder==="SOV"&&!c?"after":"before"),d=t.markerOptional?.[e.code]===true,p=f=>{let v=l.length===1?Ee(t,e.code,f)??[]:[],E={type:"literal",value:f,...v.length?{alternatives:v}:{},...n?{renderSuppress:true}:{}};r.push(d?{type:"group",optional:true,tokens:[E]}:E);};if(m==="before"){for(let f of l)p(f);u();}else {u();for(let f of l)p(f);}}else if(a){let l=()=>{let m=[...new Set([...a.alternatives??[],...Ee(t,e.code,a.primary)??[]])].filter(d=>d!==a.primary);return {type:"literal",value:a.primary,...m.length?{alternatives:m}:{},...n?{renderSuppress:true}:{}}},c=m=>{if(!e.markersOptional&&!t.markerOptional?.[e.code]){r.push(m);return}r.push({type:"group",optional:true,...e.markersOptional&&!t.markerOptional?.[e.code]?{renderRequired:true}:{},tokens:[m]});};a.position==="before"?(a.primary&&c(l()),u()):(u(),c(l()));}else u();return r}function hu(t,e){let r={};for(let i of t.roles){let a=i.markerOverride?.[e.code],n=e.roleMarkers[i.role];if(i.valuePrefixLiteral?.[e.code])r[i.role]={marker:i.valuePrefixLiteral[e.code]};else if(a!==void 0)if(!a)r[i.role]={};else {let s=!/\s/.test(a.trim())?Ee(i,e.code,a)??[]:[];r[i.role]=s.length?{marker:a,markerAlternatives:s}:{marker:a};}else if(n&&n.primary){let o=[...new Set([...n.alternatives??[],...Ee(i,e.code,n.primary)??[]])].filter(s=>s!==n.primary);r[i.role]=o.length?{marker:n.primary,markerAlternatives:o}:{marker:n.primary};}else r[i.role]={};}return r}function $r(t,e){let r=hu(t,e),i={};for(let a of t.roles){let n=r[a.role]||{};!a.required&&a.default?i[a.role]={...n,default:a.default}:i[a.role]=n;}return i}function vu(t,e,r){let i=[],n=ni(t.roles,e.wordOrder).map(o=>{let s=wo(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,...n);break;case "SOV":i.push(...n,r.primary);break;default:i.push(r.primary,...n);}return i.join(" ")}var Eu=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),a=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(i,{result:r,createdAt:a,lastAccessed:a});}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 Eu;var hi={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"]}},gu=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],zu=class{constructor(t=gu){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}},ku="()[]{},:;",wu=class{constructor(t=ku){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 Vr(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function fi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=Vr(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=Vr(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=Vr(t,a+1);return t.slice(e,n)}a++;}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 bu=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?fi(t,e)!==null:false}extract(t,e){let r=fi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Cu=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},Au=["http://","https://","//","./","../","/"];function Du(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function xu(t,e){let r=t.slice(e),i=Au.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=Du(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var Su=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=xu(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Bu=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"}}}},Tu=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 Fu(){let t=/[a-zA-Z]/;return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:Ru,isIdentifierChar:yi}=Fu(),Ou=class{constructor(){this.name="indonesian-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Ru(t[e])}extract(t,e){if(!this.context)throw new Error("IndonesianKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&yi(t[r]);)i+=t[r++];if(this.context&&r<t.length&&t[r]==="_"){let l=r,c=i;for(;l<t.length&&(t[l]==="_"||yi(t[l]));)c+=t[l++];this.context.lookupKeyword(c.toLowerCase())&&(i=c,r=l);}if(!i)return null;let a=i.toLowerCase(),n=Tu.has(a),o=this.context.lookupKeyword(a),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:n}}}};function Pu(){return [new Ou]}function _u(){return [new Su,new Cu,new Bu,new bu]}var Nu=new Set(["di","ke","dari","pada","dengan","tanpa","untuk","oleh","antara","sebelum","sesudah","setelah","selama","sampai","hingga","sejak","menuju","tentang","terhadap","melalui","dalam","luar"]),Lu=[{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"}],Mu=class extends de{constructor(){super(),this.language="id",this.direction="ltr",this.initializeKeywordsFromProfile(hi,Lu),this.registerExtractors(_u()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(Pu()),this.registerExtractor(new zu),this.registerExtractor(new wu);}classifyToken(t){let e=t.toLowerCase();return Nu.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"}},Iu=new Mu;ye("id",Iu,hi);var Ei={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"}}},ju=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],$u=class{constructor(t=ju){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}},Vu="()[]{},:;",Wu=class{constructor(t=Vu){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 Wr(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function vi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=Wr(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=Wr(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=Wr(t,a+1);return t.slice(e,n)}a++;}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 qu=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?vi(t,e)!==null:false}extract(t,e){let r=vi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Ku=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},Hu=["http://","https://","//","./","../","/"];function Uu(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function Gu(t,e){let r=t.slice(e),i=Hu.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=Uu(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var Zu=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=Gu(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Yu=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 Xu(t){return /[a-zA-Z_]/.test(t)}function Ju(t){return /[a-zA-Z0-9_]/.test(t)}var Qu=class{constructor(){this.name="malay-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Xu(t[e])}extract(t,e){if(!this.context)throw new Error("MalayKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&Ju(t[r]);)i+=t[r++];if(!i)return null;let a=i.toLowerCase(),n=this.context.lookupKeyword(a),o=n&&n.normalized!==n.native?n.normalized:void 0;return {value:i,length:i.length,metadata:{normalized:o}}}};function el(){return [new Qu]}function rl(){return [new Zu,new Ku,new Yu,new qu]}var tl=[{native:"benar",normalized:"true"},{native:"salah",normalized:"false"},{native:"kosong",normalized:"null"},{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"}],il=class extends de{constructor(){super(),this.language="ms",this.direction="ltr",this.initializeKeywordsFromProfile(Ei,tl),this.registerExtractors(rl()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(el()),this.registerExtractor(new $u),this.registerExtractor(new Wu);}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"}},al=new il;ye("ms",al,Ei);var zi={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 nl(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:t==="\xF1"||t==="\xD1"}function ol(t){for(let e of t)if(nl(e))return true;return false}var sl=[{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}],ul=[{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}],ll=["um","in"],cl=[{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 ml(t){let e=t.toLowerCase();if(e.length<5)return null;let r=0;for(let i=0;i<e.length;i++){let a=e[i];if(!"aeiou".includes(a))r=i+1;else break}if(r===0)return null;for(let i of ll){let a=r;if(e.slice(a,a+i.length)===i){let n=e.slice(0,r)+e.slice(a+i.length);if(n.length>=3)return {stem:n,infix:i}}}return null}function dl(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 a=e.slice(2);if(a.length>=2&&a[0]===r)return {stem:a,reduplicated:true}}return {stem:e,reduplicated:false}}var pl=class{constructor(){this.language="tl";}isNormalizable(t){return !(!ol(t)||t.length<2)}normalize(t){let e=t.toLowerCase(),r=1,i=[],a=[],n=[];for(let l of sl)if(e.startsWith(l.pattern)){let c=e.slice(l.pattern.length),m=l.minRemaining??2;if(c.length>=m){e=c,r-=l.confidencePenalty,i.push(l.pattern),n.push(`prefix:${l.pattern}`);break}}if(i.length===0){for(let l of ul)if(e.startsWith(l.pattern)){let c=e.slice(l.pattern.length),m=l.minRemaining??2;if(c.length>=m){e=c,r-=l.confidencePenalty,i.push(l.pattern),n.push(`prefix:${l.pattern}`);break}}}let o=dl(e);o.reduplicated&&o.stem.length>=2&&(e=o.stem,r-=.1,n.push("reduplication:CV"));let s=ml(e),u=false;if(s&&s.stem.length>=2&&(e=s.stem,r-=.18,n.push(`infix:${s.infix}`),u=true),!u){for(let l of cl)if(e.endsWith(l.pattern)){let c=e.slice(0,-l.pattern.length);if(c.length>=2){e=c,r-=l.confidencePenalty,a.push(l.pattern),n.push(`suffix:${l.pattern}`);break}}}return r=Math.max(.5,r),i.length===0&&a.length===0&&n.length===0?at(t):nt(e,r,{removedPrefixes:i,removedSuffixes:a,appliedRules:n})}},fl=new pl,yl=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],hl=class{constructor(t=yl){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}},vl="()[]{},:;",El=class{constructor(t=vl){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 qr(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function gi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=qr(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=qr(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=qr(t,a+1);return t.slice(e,n)}a++;}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 gl=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?gi(t,e)!==null:false}extract(t,e){let r=gi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},zl=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},kl=["http://","https://","//","./","../","/"];function wl(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function bl(t,e){let r=t.slice(e),i=kl.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=wl(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var Cl=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=bl(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Al=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 Dl(t){return /[a-zA-Z_]/.test(t)}function xl(t){return /[a-zA-Z0-9_]/.test(t)}var Sl=new Set(["sa","ng","para","mula","hanggang","gaya","tulad","kasama","para sa"]),Bl=class{constructor(){this.name="tagalog-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Dl(t[e])}extract(t,e){if(!this.context)throw new Error("TagalogKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&xl(t[r]);)i+=t[r++];if(!i)return null;let a=i.toLowerCase(),n=Sl.has(a),o=this.context.lookupKeyword(a),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:n}}}};function Tl(){return [new Bl]}function Fl(){return [new Cl,new zl,new Al,new gl]}var Rl=[{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"}],Ol=class extends de{constructor(){super(),this.language="tl",this.direction="ltr",this.initializeKeywordsFromProfile(zi,Rl),this.setNormalizer(fl),this.registerExtractors(Fl()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(Tl()),this.registerExtractor(new hl),this.registerExtractor(new El);}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"}},Pl=new Ol;ye("tl",Pl,zi);var wi={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"]}},_l=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Nl=class{constructor(t=_l){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}},Ll="()[]{},:;",Ml=class{constructor(t=Ll){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 Kr(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function ki(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=Kr(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=Kr(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=Kr(t,a+1);return t.slice(e,n)}a++;}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 Il=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?ki(t,e)!==null:false}extract(t,e){let r=ki(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},jl=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},$l=["http://","https://","//","./","../","/"];function Vl(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function Wl(t,e){let r=t.slice(e),i=$l.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=Vl(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var ql=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=Wl(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Kl=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 Qe(t){let e=t.charCodeAt(0);return e>=3584&&e<=3711}function Hr(t){return /[a-zA-Z0-9_]/.test(t)}var Hl=class{constructor(){this.name="thai-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Qe(t[e])||Hr(t[e])}extract(t,e){if(!this.context)throw new Error("ThaiKeywordExtractor: context not set");let r=t[e];return Qe(r)?this.extractThaiWord(t,e):Hr(r)?this.extractAsciiWord(t,e):null}extractThaiWord(t,e){if(!this.context)return null;let r=null,i=e,a="";for(;i<t.length&&Qe(t[i]);){a+=t[i],i++;let s=this.context.lookupKeyword(a);s&&(r={word:a,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 n=e,o="";for(;n<t.length&&Qe(t[n])&&!(o.length>0&&this.isKeywordStart(t,n));)o+=t[n],n++;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&&Hr(t[r]);)i+=t[r++];if(!i)return null;let a=i.toLowerCase(),n=this.context.lookupKeyword(a),o=n&&n.normalized!==n.native?n.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&&Qe(t[r]);){if(i+=t[r],r++,this.context.lookupKeyword(i))return true;if(i.length>10)break}return false}};function Ul(){return [new Hl]}function Gl(){return [new ql,new jl,new Kl,new Il]}var Zl=[{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"}],Yl=class extends de{constructor(){super(),this.language="th",this.direction="ltr",this.initializeKeywordsFromProfile(wi,Zl),this.registerExtractors(Gl()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(Ul()),this.registerExtractor(new Nl),this.registerExtractor(new Ml);}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"}},Xl=new Yl;ye("th",Xl,wi);var Ci={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 Jl(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:Ql,isIdentifierChar:ec}=Jl(/[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]/),rc=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"]),tc=class{constructor(){this.name="vietnamese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Ql(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,a="";for(;i<t.length&&ec(t[i]);)a+=t[i++];if(!a)return null;let n=a.toLowerCase(),o=rc.has(n),s=this.context.lookupKeyword(n),u=s&&s.normalized!==s.native?s.normalized:void 0;return {value:a,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 n=e+i.length;if(n>=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[n])){let o=this.context.lookupKeyword(i);return {value:t.slice(e,n),length:i.length,metadata:{normalized:o?.normalized,isPreposition:false}}}}return null}};function ic(){return [new tc]}var ac=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],nc=class{constructor(t=ac){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}},oc="()[]{},:;",sc=class{constructor(t=oc){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 Ur(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 a=r+i[0].length;if(t[a]==="("){let n=0,o=a;for(;o<t.length;){if(t[o]==="(")n++;else if(t[o]===")"&&(n--,n===0)){o++;break}o++;}if(n!==0)break;a=o;}r=a;}return r}function bi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let a=Ur(t,e+i[0].length);return t.slice(e,a)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let a=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!a)return null;let n=Ur(t,e+a[0].length);return t.slice(e,n)}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,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0)){let n=Ur(t,a+1);return t.slice(e,n)}a++;}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 uc=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?bi(t,e)!==null:false}extract(t,e){let r=bi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},lc=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],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}},cc=["http://","https://","//","./","../","/"];function mc(t,e){let r=1;for(let i=e;i<t.length;i++){let a=t[i];if(a==="{")r++;else if(a==="}"&&--r===0)return i+1}return -1}function dc(t,e){let r=t.slice(e),i=cc.find(n=>r.startsWith(n));if(!i)return null;let a=i.length;for(;a<r.length;){let n=r[a];if(n==="$"&&r[a+1]==="{"){let o=mc(r,a+2);if(o!==-1){a=o;continue}}if(/\s/.test(n))break;a++;}return r.slice(0,a)}var pc=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=dc(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},fc=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 yc(){return [new pc,new lc,new fc,new uc]}var hc=[{native:"\u0111\xFAng",normalized:"true"},{native:"sai",normalized:"false"},{native:"null",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:"r\u1ED7ng",normalized:"empty"},{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"}],vc=class extends de{constructor(){super(),this.language="vi",this.direction="ltr",this.initializeKeywordsFromProfile(Ci,hc),this.registerExtractors(yc()),this.registerExtractor(new ce),this.registerExtractor(new me),this.registerExtractors(ic()),this.registerExtractor(new nc),this.registerExtractor(new sc);}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"}},Ec=new vc;ye("vi",Ec,Ci);function pr(t){let e=t.getAttribute("data-lang");if(e)return dr(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return dr(r);let i=t.closest?.("[lang]")?.getAttribute("lang");if(i)return dr(i);let a=typeof document<"u"?document.documentElement?.lang:null;return a&&a!=="en"?dr(a):null}function dr(t){return t.split("-")[0].toLowerCase()}var Ai={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",""]],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 gc=new Set(["repeat","for","while","tell"]),zc=new Set(["js"]);function fr(t){switch(t.kind){case "event-handler":return kc(t);case "compound":return wc(t);default:return bc(t)}}function kc(t){let e=["on"],r=t.roles.get("event");r&&e.push(r.type==="literal"?String(r.value):er(r));let i=t.roles.get("source");if(i&&e.push("from",er(i)),t.body&&t.body.length>0){let a=t.body.map(fr);e.push(a.join(" "));}return e.join(" ")}function wc(t){let e=t.chainType==="async"?"async":t.chainType,r=t.statements.map(fr),i=r[0]??"";for(let a=1;a<r.length;a++){let n=t.statements[a-1],o=t.statements[a],s=n.kind==="command"&&gc.has(n.action),u=n.kind==="command"&&n.action==="bind"&&o.kind==="command"&&o.action==="bind";n.kind==="command"&&zc.has(n.action)&&(i+=" end"),i+=(s||u?" ":` ${e} `)+r[a];}return i}function bc(t){let e=Ai[t.action];if(e){let i=[t.action];for(let[a,n]of e){let o=t.roles.get(a);o&&((a==="destination"||a==="source")&&o.type==="reference"&&o.value==="me"||(n&&i.push(n),i.push(er(o))));}return i.join(" ")}let r=[t.action];for(let[,i]of t.roles)r.push(er(i));return r.join(" ")}function er(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 Cc(t);case "expression":return t.raw;case "flag":return t.enabled?`+${t.name}`:`~${t.name}`}}function Cc(t){let e=er(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 Ac={confidenceThreshold:.5,strategy:"semantic"};function Dc(t,e){return typeof t=="number"?t:t[e]??t["*"]??.5}var xc=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Sc(t){let e=t.match(xc);if(!e)return null;let r=e[1],i=t.slice(r.length);return i?{prefix:r,commands:i}:null}function Di(t){function e(a,n,o){try{return t.isLanguageRegistered(n)?t.translateSingle(a,n,o):null}catch{return null}}function r(a,n,o){try{let s=o(a,n);return s!==a?s:null}catch{return null}}function i(a,n,o){if(o.strategy==="semantic"||o.strategy==="auto"){let s=Dc(o.confidenceThreshold,n),u=e(a,n,s);if(u!==null)return u}if((o.strategy==="auto"||o.strategy==="i18n")&&o.i18nToEnglish){let s=r(a,n,o.i18nToEnglish);if(s!==null)return s}return null}return function(n,o,s={}){if(o==="en")return n;let u={...Ac,...s},l=i(n,o,u);if(l!==null)return l;let c=Sc(n);if(c){let m=i(c.commands,o,u);if(m!==null)return c.prefix+m}return n}}var Gr=Di({isLanguageRegistered:Lt,translateSingle(t,e,r){let i=ai(t,e);return i.confidence<r||!i.node?null:fr(i.node)}});var Zr=new WeakSet;function Bc(t){return (t.config?.attributes??"_, script, data-script").split(",").map(r=>r.trim()).filter(Boolean)}function Tc(t,e){for(let r of e)if(t.hasAttribute(r))return r;return null}function xi(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=Bc(t),i=[...r.map(n=>`[${n}]`),'script[type="text/hyperscript"]'].join(", "),a=n=>{if(Zr.has(n))return;if(n instanceof HTMLScriptElement&&n.type==="text/hyperscript"){let l=n.textContent??"";if(!l)return;let c=e(l,n);Zr.add(n),c!=null&&c!==l&&(n.textContent=c);return}let o=Tc(n,r);if(!o)return;let s=n.getAttribute(o);if(!s)return;let u=e(s,n);Zr.add(n),u!=null&&u!==s&&n.setAttribute(o,u);};t.addBeforeProcessHook(n=>{!n||typeof n.querySelectorAll!="function"||(typeof n.matches=="function"&&n.matches(i)&&a(n),n.querySelectorAll(i).forEach(a));});}function Bi(t,e){if(typeof t.parse!="function")return true;try{let r=t.parse(e);return !r?.errors||r.errors.length===0}catch{return false}}var Si=new Set;function Ti(t,e,r){Si.has(t)||(Si.add(t),console.warn(`[hyperscript-i18n] Translation for lang="${t}" rendered hyperscript the host parser rejects \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 Yr(t={}){return function(r){let i=r;xi(i,(a,n)=>{let o=Fc(n,t);if(!o||o==="en")return a;let s=Gr(a,o,t);if(s!==a){if(t.validateWithHost!==false&&!Bi(i,s))return t.debug?console.log(`[hyperscript-i18n] ${o}: host rejected "${s}" \u2014 keeping "${a}"`):Ti(o,a,s),a;t.debug&&console.log(`[hyperscript-i18n] ${o}: "${a}" \u2192 "${s}"`);}return s});}}function Fc(t,e){if(e.languageAttribute){let i=t.getAttribute(e.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let r=pr(t);return r||(e.defaultLanguage??null)}function Fi(t,e,r={}){return e==="en"?t:Gr(t,e,r)}Nt(t=>di(t));function Ri(){typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(Yr());}var ud=["id","ms","tl","th","vi"];Ri();
5
+ exports.plugin=Yr;exports.preprocess=Fi;exports.resolveLanguage=pr;exports.supportedLanguages=ud;return exports;})({});