@hyperscript-tools/multilingual 3.1.1 → 3.3.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 +186 -1
  2. package/README.md +23 -20
  3. package/dist/hyperscript-i18n-ar.global.js +6 -5
  4. package/dist/hyperscript-i18n-bn.global.js +6 -5
  5. package/dist/hyperscript-i18n-de.global.js +6 -5
  6. package/dist/hyperscript-i18n-east-asian.global.js +6 -5
  7. package/dist/hyperscript-i18n-en.global.js +8 -7
  8. package/dist/hyperscript-i18n-es.global.js +6 -5
  9. package/dist/hyperscript-i18n-fr.global.js +6 -5
  10. package/dist/hyperscript-i18n-he.global.js +6 -5
  11. package/dist/hyperscript-i18n-hi.global.js +6 -5
  12. package/dist/hyperscript-i18n-id.global.js +6 -5
  13. package/dist/hyperscript-i18n-it.global.js +6 -5
  14. package/dist/hyperscript-i18n-ja.global.js +6 -5
  15. package/dist/hyperscript-i18n-ko.global.js +6 -5
  16. package/dist/hyperscript-i18n-lite.global.js +2 -2
  17. package/dist/hyperscript-i18n-ms.global.js +6 -5
  18. package/dist/hyperscript-i18n-pl.global.js +6 -5
  19. package/dist/hyperscript-i18n-pt.global.js +6 -5
  20. package/dist/hyperscript-i18n-qu.global.js +6 -5
  21. package/dist/hyperscript-i18n-ru.global.js +6 -5
  22. package/dist/hyperscript-i18n-slavic.global.js +6 -5
  23. package/dist/hyperscript-i18n-south-asian.global.js +6 -5
  24. package/dist/hyperscript-i18n-southeast-asian.global.js +6 -5
  25. package/dist/hyperscript-i18n-sw.global.js +6 -5
  26. package/dist/hyperscript-i18n-th.global.js +6 -5
  27. package/dist/hyperscript-i18n-tl.global.js +6 -5
  28. package/dist/hyperscript-i18n-tr.global.js +6 -5
  29. package/dist/hyperscript-i18n-uk.global.js +6 -5
  30. package/dist/hyperscript-i18n-vi.global.js +6 -5
  31. package/dist/hyperscript-i18n-western.global.js +6 -5
  32. package/dist/hyperscript-i18n-zh.global.js +6 -5
  33. package/dist/hyperscript-i18n.global.js +28 -27
  34. package/package.json +5 -3
@@ -1,5 +1,6 @@
1
- var HyperscriptI18n=(function(exports){'use strict';function de(t,e){return e?{type:"literal",value:t,dataType:e}:{type:"literal",value:t}}function tr(t,e){return e?{type:"selector",value:t,selectorKind:e}:{type:"selector",value:t}}function Ke(t){return {type:"reference",value:t}}function ir(t,e){return {type:"property-path",object:t,property:e}}var et=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function gr(t,e=et){return e.has(t)}var ji=class{constructor(t){this.namespace=t,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let t=process.env.DEBUG||"";return t==="*"||t.includes("framework:*")||t.includes(`framework:${this.namespace}`)}return false}log(t,e,...r){if(!this.enabled)return;let i=`[framework:${this.namespace}]`,n=new Date().toISOString();switch(t){case "debug":console.debug(`${n} ${i} DEBUG:`,e,...r);break;case "info":console.info(`${n} ${i} INFO:`,e,...r);break;case "warn":console.warn(`${n} ${i} WARN:`,e,...r);break;case "error":console.error(`${n} ${i} ERROR:`,e,...r);break}}debug(t,...e){this.log("debug",t,...e);}info(t,...e){this.log("info",t,...e);}warn(t,...e){this.log("warn",t,...e);}error(t,...e){this.log("error",t,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function $i(t){return new ji(t)}function Re(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 Vi(t,e){return t?.possessive?.keywords?.[e]}var He=class Oe{constructor(){this.logger=$i("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,i){let n=e.mark(),a=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let u=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)u.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",u),this.logger.debug("Profile code:",i?.code);}this.currentProfile=i,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(r.template.tokens,null,2));let o=this.matchTokenSequence(e,r.template.tokens,a);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(a.entries()).map(([u,l])=>[u,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(n),null;let s=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-n.position,confidence:s}}matchBest(e,r,i){let n=[];for(let o of r){let s=e.mark(),u=this.matchPattern(e,o,i);u&&n.push(u),e.reset(s);}if(n.length===0)return null;n.sort((o,s)=>{let u=s.pattern.priority-o.pattern.priority;if(u!==0)return u;let l=s.confidence-o.confidence;return Math.abs(l)>.001?l:s.consumedTokens-o.consumedTokens});let a=n[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,i,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let s=null,u=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let d=e.peek();if(this.logger.debug(" >> Current input token:",d?JSON.stringify({type:d.type,value:d.value,kind:d.kind}):"EOF"),c.type==="role"&&c.greedy){let E=this.collectStopMarkers(r,l+1);if(n)for(let h of n)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(n)for(let h of n)E.add(h);if(this.matchGroupToken(e,c,i,E)){s=null,u=null;continue}if(this.isOptional(c))continue;return false}let m=c.type==="role"&&c.optional===true,p=m?e.mark():null;if(c.type==="role"&&!m){let 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){m?(s=p,u=c.role):(s=null,u=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(s&&u){this.logger.debug(" >> BACKTRACKING: undoing optional role",u),e.reset(s),i.delete(u),s=null,u=null;let 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 n=this.getMatchType(i,r.value);if(this.logger.debug(" >>> matchType for",i.value,"vs",r.value,":",n),n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(i,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,i){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",r.role),this.logger.debug(" >>> matchRoleToken: expected types",r.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",r.optional),this.skipNoiseWords(e);let n=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null"),!n)return r.optional||false;let a=this.tryMatchPossessiveExpression(e);if(a)return r.expectedTypes&&r.expectedTypes.length>0&&!Re(a.type,r.expectedTypes)?r.optional||false:(i.set(r.role,a),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Re(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&&!Re(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&&!Re(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&&!Re(l.type,r.expectedTypes)?r.optional||false:(i.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null");let c=this.tokenToSemanticValue(n);return this.logger.debug(" >>> tokenToSemanticValue returned:",c?JSON.stringify(c):"null"),c?(this.logger.debug(" >>> Validating type:",c.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!Re(c.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),i.set(r.role,c),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=r.normalized||r.value,n=this.safeToLowerCase(i),a=Vi(this.currentProfile,n);if(!a)return null;let o=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(o),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let u=s.value;s.kind==="selector"&&u.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u)&&(u=u.substring(1));let l=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),ir(Ke(a),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(i),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<Oe.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}s.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=`${r.value}.${a.value}`,s=1;for(;!e.isAtEnd()&&s<Oe.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<Oe.MAX_METHOD_ARGS;){let m=e.peek();if(!m)break;if(m.kind==="punctuation"&&m.value===")"){if(c===0){e.advance();break}c--;}if(m.kind==="punctuation"&&m.value==="("&&c++,m.kind==="punctuation"&&m.value===","){e.advance();continue}l.push(m.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="punctuation"||n.value!=="'s")return e.reset(i),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"&&a.kind!=="identifier"?(e.reset(i),null):(e.advance(),ir(tr(r.value),a.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(i),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return ir(tr(r.value),o)}matchGroupToken(e,r,i,n){let a=e.mark(),o=new Set(i.keys());if(this.matchTokenSequence(e,r.tokens,i,n))return true;e.reset(a);for(let l of i.keys())o.has(l)||i.delete(l);if(!r.optional)return false;let u=this.getGroupLeadingMarker(r);if(u)for(let l=1;l<=Oe.MAX_MARKER_SCAN;l++){let c=e.peek(l);if(!c)break;if((c.normalized||c.value).toLowerCase()===u){this.logger.debug(" >> MARKER SCAN: found",u,"at offset",l,"- skipping intervening tokens");for(let p=0;p<l;p++)e.advance();if(this.matchTokenSequence(e,r.tokens,i,n))return true;e.reset(a);for(let p of i.keys())o.has(p)||i.delete(p);break}}return true}getGroupLeadingMarker(e){let r=e.tokens[0];return r?.type==="literal"?r.value.toLowerCase():null}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===r.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,r){let i=new Set;for(let n=r;n<e.length;n++){let a=e[n];if(a.type==="literal"){if(i.add(a.value.toLowerCase()),a.alternatives)for(let o of a.alternatives)i.add(o.toLowerCase());break}if(a.type==="group"){for(let o of a.tokens)if(o.type==="literal"){if(i.add(o.value.toLowerCase()),o.alternatives)for(let s of o.alternatives)i.add(s.toLowerCase());break}if(!a.optional)break}}return i}isStopMarker(e,r){return r.size===0?false:!!(r.has(e.value.toLowerCase())||e.normalized&&r.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return tr(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return de(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Ke(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return de(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let n=e.slice(1,-1);return de(n,"string")}if(e==="true")return de(true,"boolean");if(e==="false")return de(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?de(e,"duration"):de(n,"number")}let i=parseFloat(e);return isNaN(i)?de(e,"string"):de(i,"number")}applyExtractionRules(e,r){for(let[i,n]of Object.entries(e.extraction))r.has(i)||(n.value!==void 0?r.set(i,{type:"literal",value:n.value}):n.default&&r.set(i,n.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let i=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")n+=1,r.has(l.role)&&(i+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let d=a(c.role),m=.8;n+=m,r.has(c.role)?i+=m:d&&(i+=m*.6);}}let o=n>0?i/n:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let s=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+s);let u=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+u)),o}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let r=e.template.tokens[0];if(!r||r.type!=="literal")return 0;let i=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(i.has(r.value))return .15;if(r.alternatives){for(let n of r.alternatives)if(i.has(n))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let i=0,n={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[a,o]of r.entries()){let s=n[a];if(!s||s.length===0)continue;let u="metadata"in o?o.metadata:void 0;if(u&&typeof u.prepositionValue=="string"){let l=u.prepositionValue;s.includes(l)?i+=.1:i-=.1;}}return Math.max(-0.1,Math.min(.1,i))}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=this.safeToLowerCase(r.value);if(Oe.ENGLISH_NOISE_WORDS.has(i)){let n=e.mark();e.advance();let a=e.peek();if(a&&a.kind==="selector")return;e.reset(n);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(i=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return i?r:void 0}};He.MAX_MARKER_SCAN=3;He.MAX_PROPERTY_DEPTH=10;He.MAX_METHOD_ARGS=20;He.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Wi=He;new Wi;var Ee=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 a=1;for(;e+a<t.length;){if(t[e+a]==="\u201D")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}if(r==="\u2018"){let a=1;for(;e+a<t.length;){if(t[e+a]==="\u2019")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}let i=1,n=false;for(;e+i<t.length;){let a=t[e+i];if(n){n=false,i++;continue}if(a==="\\"){n=true,i++;continue}if(a===r)return i++,{value:t.substring(e,e+i),length:i};i++;}return null}},ge=class{constructor(){this.name="number";}canExtract(t,e){return /\d/.test(t[e])}extract(t,e){let r=0,i=false;for(;e+r<t.length;){let o=t[e+r];if(/\d/.test(o))r++;else if(o==="."&&!i)i=true,r++;else break}if(r===0)return null;let n=t.substring(e,e+r),a=e+r;if(a<t.length){let o=t.slice(a),s=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of s)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:n+"ms",length:r+2,metadata:{hasTimeUnit:true}};let u=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of u)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:n+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:n,length:r}}};function qi(t){return "setContext"in t&&typeof t.setContext=="function"}function Ki(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 ne=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:a,kind:o,position:s,normalized:u,stem:l,stemConfidence:c,metadata:d}=t;return {value:a,kind:o,position:s,...u!==void 0&&{normalized:u},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...d!==void 0&&{metadata:d}}}let n=t;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof i=="string")return {value:n,kind:e,position:r,normalized:i};if(i){let{normalized:a,stem:o,stemConfidence:s,metadata:u}=i;return {value:n,kind:e,position:r,...a!==void 0&&{normalized:a},...o!==void 0&&{stem:o},...s!==void 0&&{stemConfidence:s},...u!==void 0&&{metadata:u}}}return {value:n,kind:e,position:r}}function Ae(t){return /\s/.test(t)}function Hi(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function Ui(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function Ce(t){return /\d/.test(t)}function ar(t){return t.replace(/[\u064b-\u0652\u0670]/g,"")}function Gi(t){return /[a-zA-Z]/.test(t)}function ie(t){return /[a-zA-Z0-9_-]/.test(t)}function Yi(t,e){if(e>=t.length)return null;let r=t[e];if(!Hi(r))return null;let i=e,n="";if(r==="#"||r==="."){for(n+=t[i++];i<t.length&&ie(t[i]);)n+=t[i++];if(n.length<=1)return null;if(i<t.length&&t[i]==="."&&r==="#"){let o=i+1;for(;o<t.length&&ie(t[o]);)o++;if(o<t.length&&t[o]==="(")return n}}else if(r==="["){let a=1,o=false,s=null,u=false;for(n+=t[i++];i<t.length&&a>0;){let l=t[i];n+=l,u?u=false:l==="\\"?u=true:o?l===s&&(o=false,s=null):l==='"'||l==="'"||l==="`"?(o=true,s=l):l==="["?a++:l==="]"&&a--,i++;}if(a!==0)return null}else if(r==="@"){for(n+=t[i++];i<t.length&&ie(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="*"){for(n+=t[i++];i<t.length&&ie(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="<"){if(n+=t[i++],i>=t.length||!Gi(t[i]))return null;for(;i<t.length&&ie(t[i]);)n+=t[i++];for(;i<t.length;){let a=t[i];if(a==="."){if(n+=t[i++],i>=t.length||!ie(t[i]))return null;for(;i<t.length&&ie(t[i]);)n+=t[i++];}else if(a==="#"){if(n+=t[i++],i>=t.length||!ie(t[i]))return null;for(;i<t.length&&ie(t[i]);)n+=t[i++];}else if(a==="["){let o=1,s=false,u=null,l=false;for(n+=t[i++];i<t.length&&o>0;){let c=t[i];n+=c,l?l=false:c==="\\"?l=true:s?c===u&&(s=false,u=null):c==='"'||c==="'"||c==="`"?(s=true,u=c):c==="["?o++:c==="]"&&o--,i++;}if(o!==0)return null}else break}for(;i<t.length&&Ae(t[i]);)n+=t[i++];if(i<t.length&&t[i]==="/")for(n+=t[i++];i<t.length&&Ae(t[i]);)n+=t[i++];if(i>=t.length||t[i]!==">")return null;n+=t[i++];}return n||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 Ae(i)||i==="*"||!ie(i)}function Xi(t,e){if(e>=t.length)return null;let r=t[e];if(!Ui(r)||r==="'"&&Zi(t,e))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!n)return null;let a=e+1,o=r,s=false;for(;a<t.length;){let u=t[a];if(o+=u,s)s=false;else if(u==="\\")s=true;else if(u===n)return o;a++;}return o}function Ji(t,e){if(e>=t.length)return false;let r=t[e],i=t[e+1]||"",n=t[e+2]||"";if(r==="/"&&i!=="/"&&/[a-zA-Z0-9._-]/.test(i)||r==="/"&&i==="/"&&/[a-zA-Z]/.test(n)||r==="."&&(i==="/"||i==="."&&n==="/"))return true;let a=t.slice(e,e+8).toLowerCase();return !!(a.startsWith("http://")||a.startsWith("https://"))}function Qi(t,e){if(!Ji(t,e))return null;let r=e,i="",n=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<t.length;){let a=t[r];if(a==="#"){if(i.length>0&&/[a-zA-Z0-9/.]$/.test(i))for(i+=a,r++;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)i+=t[r++];break}if(n.test(a))i+=a,r++;else break}return i.length<2?null:i}function en(t,e){if(e>=t.length)return null;let r=t[e];if(!Ce(r)&&r!=="-"&&r!=="+")return null;let i=e,n="";if((t[i]==="-"||t[i]==="+")&&(n+=t[i++]),i>=t.length||!Ce(t[i]))return null;for(;i<t.length&&Ce(t[i]);)n+=t[i++];if(i<t.length&&t[i]===".")for(n+=t[i++];i<t.length&&Ce(t[i]);)n+=t[i++];return i<t.length&&(t.slice(i,i+2)==="ms"?n+="ms":(t[i]==="s"||t[i]==="m"||t[i]==="h")&&(n+=t[i])),n}var rn=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(rn);var tn=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 nn(t){return t.includes("-")&&/^[\p{L}\p{N}_]+(-[\p{L}\p{N}_]+)+$/u.test(t)}var an=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],or=class nr{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){qi(e)&&e.setContext(Ki(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&&Ae(e[i]);)i++;if(i>=e.length)break;let n=this.tryMultiWordKeyword(e,i);if(n){r.push(n),i=n.position.end;continue}let a=false;for(let o of this.extractors)if(o.canExtract(e,i)){let s=o.extract(e,i);if(s){let u=s.metadata?.normalized,l=s.metadata?.stem,c=s.metadata?.stemConfidence,d={};if(s.metadata)for(let[p,f]of Object.entries(s.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(d[p]=f);let m={};u&&(m.normalized=u),l&&(m.stem=l),c!==void 0&&(m.stemConfidence=c),Object.keys(d).length>0&&(m.metadata=d),r.push(G(s.value,this.classifyToken(s.value),U(i,i+s.length),Object.keys(m).length>0?m:void 0)),i+=s.length,a=true;break}}if(!a){let o=e[i],s=this.classifyUnknownChar(o);r.push(G(o,s,U(i,i+1))),i++;}}return new ne(this.mergeColonQualifiedNames(r),this.language)}mergeColonQualifiedNames(e){let r=[];for(let i of e){let n=r[r.length-1];if(n&&nr.ASCII_WORD.test(n.value)&&nr.COLON_QUALIFIER.test(i.value)&&n.position.end===i.position.start){let a=n.value+i.value;r[r.length-1]=G(a,this.classifyToken(a),U(n.position.start,i.position.end));continue}r.push(i);}return r}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,i){if(e[r]!==".")return false;let n=i[i.length-1],a=n&&n.position.end<r;if(n&&!a&&(n.kind==="identifier"||n.kind==="keyword"||n.kind==="selector"))return i.push(G(".","operator",U(r,r+1))),true;let u=r+1;for(;u<e.length&&ie(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[n,a]of Object.entries(e.keywords))if(i.set(a.primary,{native:a.primary,normalized:a.normalized||n}),a.alternatives)for(let o of a.alternatives)i.set(o,{native:o,normalized:a.normalized||n});}if(e.references){for(let[n,a]of Object.entries(e.references))i.set(a,{native:a,normalized:n});for(let n of Object.keys(e.references))i.has(n)||i.set(n,{native:n,normalized:n});}if(e.roleMarkers){for(let[n,a]of Object.entries(e.roleMarkers))if(a.primary&&i.set(a.primary,{native:a.primary,normalized:n}),a.alternatives)for(let o of a.alternatives)i.set(o,{native:o,normalized:n});}if(e.possessive?.keywords)for(let[n,a]of Object.entries(e.possessive.keywords))i.set(n,{native:n,normalized:a});for(let n of an)i.has(n)||i.set(n,{native:n,normalized:n});for(let n of r)i.set(n.native,n);this.profileKeywords=Array.from(i.values()).sort((n,a)=>a.native.length-n.native.length),this.multiWordKeywords=this.profileKeywords.filter(n=>(n.native.includes(" ")||nn(n.native))&&!tn.has(n.normalized)),this.profileKeywordMap=new Map;for(let n of this.profileKeywords){this.profileKeywordMap.set(n.native.toLowerCase(),n);let a=this.removeDiacritics(n.native);a!==n.native&&!this.profileKeywordMap.has(a.toLowerCase())&&this.profileKeywordMap.set(a.toLowerCase(),n);}}removeDiacritics(e){return 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=n=>/[\p{L}\p{N}_]/u.test(n)){if(this.multiWordKeywords.length===0)return null;let n=e.slice(r);for(let a of this.multiWordKeywords){if(!n.startsWith(a.native))continue;let o=e[r+a.native.length];if(!(o!==void 0&&i(o)))return G(a.native,"keyword",U(r,r+a.native.length),a.normalized)}return null}isKeywordStart(e,r){let i=e.slice(r);return this.profileKeywords.some(n=>i.startsWith(n.native))}isKeywordStartAtBoundary(e,r,i=n=>/[\p{L}\p{N}_]/u.test(n)){let n=e.slice(r);return this.profileKeywords.some(a=>{if(!n.startsWith(a.native))return false;let o=e[r+a.native.length];return o===void 0||!i(o)})}lookupKeyword(e){let r=this.profileKeywordMap.get(e.toLowerCase());if(r)return r;let i=this.removeDiacritics(e);if(i!==e)return this.profileKeywordMap.get(i.toLowerCase())}isKeyword(e){return this.lookupKeyword(e)!==void 0}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let r=this.normalizer.normalize(e);return r.stem!==e&&r.confidence>=.7?r:null}tryMorphKeywordMatch(e,r,i){let n=this.tryNormalize(e);if(!n)return null;let a=this.lookupKeyword(n.stem);if(!a)return null;let o={normalized:a.normalized,stem:n.stem,stemConfidence:n.confidence};return G(e,"keyword",U(r,i),o)}trySelector(e,r){let i=Yi(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 n=i[0].replace(/(\s|\.)$/,""),a=n.slice(1).split("(")[0],o=i[1];return {...G(n,"event-modifier",U(r,r+n.length)),metadata:{modifierName:a,value:o?a==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let i=Xi(e,r);return i?G(i,"literal",U(r,r+i.length)):null}tryNumber(e,r){let i=en(e,r);return i?G(i,"literal",U(r,r+i.length)):null}tryMatchTimeUnit(e,r,i,n=false){let a=r;if(n)for(;a<e.length&&Ae(e[a]);)a++;let o=e.slice(a);for(let s of i){let u=o.slice(0,s.length);if(s.caseInsensitive?u.toLowerCase()===s.pattern.toLowerCase():u===s.pattern){if(s.notFollowedBy&&(o[s.length]||"")===s.notFollowedBy)continue;if(s.checkBoundary){let c=o[s.length]||"";if(ie(c))continue}return {suffix:s.suffix,endPos:a+s.length}}}return null}parseBaseNumber(e,r,i=true){let n=r,a="";if(i&&(e[n]==="-"||e[n]==="+")&&(a+=e[n++]),n>=e.length||!Ce(e[n]))return null;for(;n<e.length&&Ce(e[n]);)a+=e[n++];if(n<e.length&&e[n]===".")for(a+=e[n++];n<e.length&&Ce(e[n]);)a+=e[n++];return !a||a==="-"||a==="+"?null:{number:a,endPos:n}}tryNumberWithTimeUnits(e,r,i,n={}){let{allowSign:a=true,skipWhitespace:o=false}=n,s=this.parseBaseNumber(e,r,a);if(!s)return null;let{number:u,endPos:l}=s,c=[...i,...nr.STANDARD_TIME_UNITS],d=this.tryMatchTimeUnit(e,l,c,o);return d&&(u+=d.suffix,l=d.endPos),G(u,"literal",U(r,l))}tryUrl(e,r){let i=Qi(e,r);return i?G(i,"url",U(r,r+i.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!ie(e[r+1]))return null;let i=r+1;for(;i<e.length&&ie(e[i]);)i++;let n=e.slice(r,i);return G(n,"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 n=e[r];return ["<",">","!","+","-","*","/","="].includes(n)?G(n,"operator",U(r,r+1)):["(",")","{","}",",",";",":"].includes(n)?G(n,"punctuation",U(r,r+1)):null}tryMultiCharParticle(e,r,i){for(let n of i)if(e.slice(r,r+n.length)===n)return G(n,"particle",U(r,r+n.length));return null}};or.ASCII_WORD=/^[A-Za-z_][A-Za-z0-9_]*$/;or.COLON_QUALIFIER=/^:[A-Za-z_][A-Za-z0-9_]*$/;or.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 ze=or;function se(t){return {stem:t,confidence:1}}function J(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}var it=class{constructor(t){this.language=t.language,this.config={minWordLength:3,minStemLength:2,...t};}normalize(t){let e=t.toLowerCase();if(this.isAlreadyNormalized(e))return se(t);if(this.config.reflexiveSuffixes){let r=this.tryReflexiveNormalization(e);if(r)return r}if(this.config.endings){let r=this.tryConjugationEndings(e);if(r)return r}if(this.config.suffixRules){let r=this.trySuffixRules(e);if(r)return r}if(this.config.prefixRules){let r=this.tryPrefixRules(e);if(r)return r}return se(t)}isAlreadyNormalized(t){return this.config.infinitiveEndings?this.config.infinitiveEndings.some(e=>t.endsWith(e)):false}tryReflexiveNormalization(t){let e=this.config.reflexiveSuffixes;if(!e)return null;for(let r of e){if(!t.endsWith(r))continue;let i=t.slice(0,-r.length);if(this.isAlreadyNormalized(i))return J(i,.88,{removedSuffixes:[r],conjugationType:"reflexive"});let n=this.tryConjugationEndings(i)||this.trySuffixRules(i);if(n&&n.stem!==i)return J(n.stem,n.confidence*.95,{removedSuffixes:[r,...n.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationEndings(t){let e=this.config.endings;if(!e)return null;let r=this.config.minStemLength??2;for(let i of e){if(!t.endsWith(i.ending))continue;let n=t.slice(0,-i.ending.length);if(n.length<r)continue;let a=n+i.stem;return J(a,i.confidence,{removedSuffixes:[i.ending],conjugationType:i.type})}return null}trySuffixRules(t){let e=this.config.suffixRules;if(!e)return null;let r=this.config.minStemLength??2;for(let i of e){if(!t.endsWith(i.pattern))continue;let n=t.slice(0,-i.pattern.length),a=i.minStemLength??r;if(n.length<a)continue;let o=n+(i.replacement||"");return J(o,i.confidence,{removedSuffixes:[i.pattern],...i.conjugationType&&{conjugationType:i.conjugationType}})}return null}tryPrefixRules(t){let e=this.config.prefixRules;if(!e)return null;for(let r of e){if(!t.startsWith(r.pattern))continue;let i=t.slice(r.pattern.length),n=r.minRemaining??this.config.minStemLength??2;if(!(i.length<n))return J(i,1-r.confidencePenalty,{removedPrefixes:[r.pattern]})}return null}};var on=Object.defineProperty,sn=Object.getOwnPropertyNames,At=(t,e)=>function(){return t&&(e=(0, t[sn(t)[0]])(t=0)),e},un=(t,e)=>{for(var r in e)on(t,r,{get:e[r],enumerable:true});};function nt(t,e){return t.replace(/\{(\w+)\}/g,(r,i)=>String(e[i]??`{${i}}`))}function ae(t,e,r={},i){let n=xt[t],a=nt(n,r),o=St[t],s=o?nt(o,r):void 0;return {code:t,message:a,severity:e,...i&&{role:i},...s&&{suggestion:s}}}var F,xt,St,ln=At({"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"},xt={[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."},St={[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."};}}),Dt={};un(Dt,{SchemaErrorCodes:()=>F,formatValidationResults:()=>hn,getValidationStats:()=>vn,validateAllKeywordCollisions:()=>zn,validateAllSchemas:()=>yn,validateCommandSchema:()=>Bt,validateKeywordCollisions:()=>Tt,validateRoleValues:()=>En});function cn(t,e){return {action:t,items:e}}function Bt(t){let e=[];for(let i of t.roles)i.expectedTypes.includes("literal")&&i.expectedTypes.includes("selector")&&(i.role==="patient"&&Ar.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&&!Ar.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":dn(t,e);break;case "on":mn(t,e);break;case "if":case "unless":pn(t,e);break;case "repeat":case "for":case "while":fn(t,e);break}return t.roles.filter(i=>i.required).length===0&&(Ft.has(t.action)?e.push(ae(F.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(ae(F.NO_REQUIRED_ROLES,"warning",{}))),cn(t.action,e)}function dn(t,e){let r=t.roles.find(n=>n.role==="patient"),i=t.roles.find(n=>n.role==="goal");r&&!i&&e.push(ae(F.TRANSITION_MISSING_GOAL,"error",{}));}function mn(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 pn(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 fn(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 yn(t,e={}){let r=new Map,{includeNotes:i=false}=e;for(let[n,a]of Object.entries(t)){let o=Bt(a),s=o.items.some(l=>l.severity==="warning"||l.severity==="error"),u=i&&o.items.some(l=>l.severity==="note");(s||u)&&r.set(n,o);}return r}function hn(t,e={}){let r=[],{showNotes:i=false,showCodes:n=true}=e;for(let[a,o]of t){let s=o.items.filter(c=>c.severity==="error"),u=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(s.length>0){r.push(` \u274C ${a}:`);for(let c of s){let d=n?` [${c.code}]`:"";r.push(` ERROR${d}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(u.length>0){r.push(` \u26A0\uFE0F ${a}:`);for(let c of u){let d=n?` [${c.code}]`:"";r.push(` ${d?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(i&&l.length>0){r.push(` \u2139\uFE0F ${a}:`);for(let c of l){let d=n?` [${c.code}]`:"";r.push(` ${d?`${c.code}: `:""}${c.message}`);}}}return r.join(`
2
- `)}function vn(t){let e=0,r=0,i=0,n={};for(let a of t.values())for(let o of a.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&i++,n[o.code]=(n[o.code]||0)+1;return {totalCommands:t.size,errors:e,warnings:r,notes:i,byCode:n}}function En(t,e){let r=[];for(let i of e){let n=t.roles.find(a=>a.role===i.role);n&&(n.expectedTypes.length>0&&!n.expectedTypes.includes(i.type)&&(n.expectedTypes.includes("expression")||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects type [${n.expectedTypes.join(", ")}], got '${i.type}'`,code:F.VALUE_TYPE_MISMATCH})),i.type==="selector"&&i.selectorKind&&n.selectorKinds&&n.selectorKinds.length>0&&(n.selectorKinds.includes(i.selectorKind)||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects selector kind [${n.selectorKinds.join(", ")}], got '${i.selectorKind}'`,code:F.SELECTOR_KIND_MISMATCH})));}return r}function gn(t){if(t.length!==2)return false;let[e,r]=[...t].sort();return Rt.some(([i,n])=>i===e&&n===r)}function Tt(t){let e=[];if(!t.keywords)return {language:t.code,collisions:e};let r=new Map;for(let[n,a]of Object.entries(t.keywords)){if(!a||!a.primary)continue;let o=r.get(a.primary)||[];if(o.push({command:n,isPrimary:true}),r.set(a.primary,o),a.alternatives)for(let s of a.alternatives){let u=r.get(s)||[];u.push({command:n,isPrimary:false}),r.set(s,u);}}for(let[n,a]of r){let o=[...new Set(a.map(l=>l.command))];if(o.length<=1||gn(o))continue;let s=a.filter(l=>l.isPrimary).length,u;s>=2?u="primary-primary":s===1?u="primary-alternative":u="alternative-alternative",e.push({keyword:n,commands:o.sort(),type:u});}let i={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((n,a)=>i[n.type]-i[a.type]),{language:t.code,collisions:e}}function zn(t){let e=[];for(let[,r]of Object.entries(t)){let i=Tt(r);i.collisions.length>0&&e.push(i);}return e.sort((r,i)=>r.language.localeCompare(i.language))}var Ar,Ft,Rt,kn=At({"src/generators/schema-validator.ts"(){ln(),Ar=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Ft=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"]),Rt=[["change","changes"]];}});function Be(t){let e=t.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function Te(t){let e=t.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function Fe(t,e){return Or(t,e,"source")}function Rr(t,e){return Or(t,e,"destination")}function wn(t,e){return Or(t,e,"patient")}function Or(t,e,r){if(!e||!t.roles.some(a=>a.role===r))return [];let i=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},n={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[n,i]:[i,n]}]}var bn={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)"}},Cn={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"}},An={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"}},xn={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"}},Sn={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>"}},Dn={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>"}},Bn={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Tn={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}]},Fn={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Rn={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},On={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Pn={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Nn={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}]},Ln={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}]},Mn={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"]}]},_n={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}]},In={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}]},jn={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}]},$n={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"}}]},Vn={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"}}]},Wn={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"}}]},qn={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"}}]},Kn={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}]},Hn={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}]},Un={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"}}]},Gn={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}]},Yn={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}]},Zn={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}]},Xn={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}]},Jn={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"}}]},Qn={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}]},ea={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}]},ra={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},ta={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"'},ia={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"}}]},na={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}]},aa={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",ast:{},roles:[]},Pr={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"},oa={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:Pr,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},sa={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}]},ua={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"}}]},la={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}]},ca={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}]},da={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}]},ma={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"}}]},pa={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}]},fa={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}]},ya={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}]},ha={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}]},va={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Ea={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}]},ga={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}]},za={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}]},ka={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"}}]},wa={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"}}]},ba={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",ast:{},hasBody:true,roles:[]},Ca={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}]},Aa={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}]},xa={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"}}]},Sa={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"},Nr={role:"manner",description:"Run the swap inside a `document.startViewTransition()` (`using view transition`)",required:false,expectedTypes:["literal","expression"],valueShape:"keyword",markerOverride:Sa},Da={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"}},{...Nr,svoPosition:4,sovPosition:4}]},Ba={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"}},{...Nr,svoPosition:3,sovPosition:3}]},Ta={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}]},Fa={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Ra={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}]},Oa={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Pa={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}]},Na={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"}}]},La={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"},Ma={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:Pr}]},_a={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:Pr}]},Ia={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:La},{...Nr,svoPosition:2,sovPosition:2}]},ja={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}]},ce={toggle:bn,add:Cn,remove:An,put:xn,set:Sn,show:Nn,hide:Ln,on:Mn,trigger:_n,wait:In,fetch:jn,increment:$n,decrement:Vn,append:Wn,prepend:qn,log:Kn,get:Hn,take:Un,make:Gn,halt:Yn,settle:Zn,throw:Xn,send:Jn,if:Qn,unless:ea,else:ra,repeat:ta,for:ia,while:na,continue:aa,go:oa,scroll:Na,push:Ma,replace:_a,process:Ia,transition:sa,clone:ua,focus:la,blur:ca,empty:da,open:ma,close:pa,select:fa,clear:ya,reset:ha,breakpoint:va,call:Ea,return:ga,js:za,tell:ka,default:wa,init:ba,behavior:Ca,install:Aa,measure:xa,swap:Da,morph:Ba,beep:Ta,break:Fa,copy:Ra,exit:Oa,pick:Pa,render:ja,bind:Dn,live:Bn,when:Tn,eventsource:Fn,socket:Rn,worker:On,intercept:Pn,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function te(t){return ce[t]}function $a(){return Object.values(ce).filter(t=>t.structuralOnly!==true&&(t.roles.length>0||t.bareKeyword===true))}typeof process<"u"&&process.env.LOKASCRIPT_SCHEMA_VALIDATION==="1"&&Promise.resolve().then(()=>(kn(),Dt)).then(({validateAllSchemas:t,formatValidationResults:e})=>{let r=t(ce);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 De=new Map,ye=new Map,Ge=new Map,xr=null;function Ot(t,e){let r={...t};for(let i of Object.keys(e)){let n=e[i],a=t[i];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?r[i]=Ot(a,n):r[i]=n);}return r}function Va(t,e){return Ot(t,e)}function Lr(t){if(!t.extends)return t;let e=ye.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=Lr(e);return Va(r,t)}function be(t,e,r){De.set(t,e),ye.set(t,r),Ge.delete(t);}function Pt(t){xr=t;}var at=new Map;function Me(t){return t.split("-")[0]}function _e(t){return t.includes("-")}function Wa(t){let e=De.get(t);if(!e&&_e(t)){let r=Me(t);e=De.get(r);}if(!e){let r=Array.from(De.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 qa(t){let e=ye.get(t);if(!e&&_e(t)){let r=Me(t);e=ye.get(r);}if(!e){let r=Array.from(ye.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 Lr(e)}function P(t){let e=ye.get(t);return !e&&_e(t)&&(e=ye.get(Me(t))),e?Lr(e):void 0}function Ka(){return Array.from(De.keys())}function Nt(t){if(De.has(t)&&ye.has(t))return true;if(_e(t)){let e=Me(t);return De.has(e)&&ye.has(e)}return false}function Ha(t,e){return Wa(e).tokenize(t)}function fe(t){let e=Ge.get(t);if(!e&&_e(t)&&(e=Ge.get(Me(t))),e)return e;let r=at.get(t);if(!r&&_e(t)&&(r=at.get(Me(t))),r)return Ge.set(t,r),r;if(!xr)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let i=qa(t),n=xr(i);return Ge.set(t,n),n}var Lt={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function we(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 Pe(t){return gr(t)}function le(t){return {type:"reference",value:t}}function go(t,e){return e?{...t,position:e}:t}function xe(t,e,r){return r?{type:"property-path",object:t,property:e,access:r}:{type:"property-path",object:t,property:e}}function re(t,e,r){let i={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...i,metadata:r}:i}function Ue(t,e,r,i,n,a){let o=new Map;o.set("event",t);let s={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(s.eventModifiers=r),i!==void 0&&(s.metadata=i),n!==void 0&&n.length>0&&(s.parameterNames=n),s}function zo(t,e,r,i,n){let a={kind:"behavior",action:"behavior",roles:new Map,name:t,parameters:e,eventHandlers:r};return i!==void 0&&i.length>0&&(a.initBlock=i),n!==void 0&&(a.metadata=n),a}function ko(t,e,r,i){let n={kind:"def",action:"def",roles:new Map,name:t,parameters:e,body:r};return i!==void 0&&(n.metadata=i),n}function Sr(t,e,r,i,n){let a={kind:"feature",action:t,roles:n??new Map,body:e};return r!==void 0&&(a.name=r),i!==void 0&&(a.metadata=i),a}function Ye(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 n=new Map;n.set("condition",t);let a={kind:"conditional",action:"if",roles:n,thenBranch:e};return r!==void 0&&(a.elseBranch=r),i!==void 0&&(a.metadata=i),a}function sr(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 n=Co(t,e.code,r);return {primary:r,...n&&{alternatives:n},position:i?.position??"before",isOverride:true}}if(i&&i.primary){let n={primary:i.primary,position:i.position,isOverride:false};return i.alternatives&&(n.alternatives=i.alternatives),n}return null}function Co(t,e,r){let i=t.markerLegacy?.[e];if(!i?.length)return;let n=[...new Set(i)].filter(a=>a&&a!==r);return n.length?n:void 0}function he(t,e,r){let i=t.markerLegacy?.[e]??[],n=t.methodCarrier?[]:t.markerVariants?.[e]??[],a=[...new Set([...i,...n])].filter(o=>o&&o!==r);return a.length?a:void 0}var Mt=new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]);function me(t,e){let r=t.possessive?.keywords?.[e];if(r)return r;let i=t.possessive?.specialForms;if(i){for(let[n,a]of Object.entries(i))if(a===e)return n}}function zr(t){return Lt.possessive?.specialForms?.[t]??`${t}'s`}var Mr={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"}},_t={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 Dr(t,e){let r=e.value.toLowerCase(),i=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||i==="of"||i==="source")return true;let n=t?.code?_t[t.code]:void 0;return !!n&&n.has(r)}var So={destination:"in",source:"from"},Do={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?Do[t.code]:void 0)?.has(r))return "in";let n=e.normalized??e.value,a=n.toLowerCase();return Bo.has(a)?"in":So[a]??n}var kr=new Set(["first","last","next","previous","random","closest"]),Fo={bn:{\u09B6\u09C7\u09B7:"last"}},_r=new Set(Object.keys(ce).map(t=>t.toLowerCase()));function It(t,e,r,i){let n=t[e];if(!n)return null;let a=(n.normalized??n.value).toLowerCase(),o=t[e+1],s=r?.code&&o?.kind==="selector"&&o.value.startsWith("<")?Fo[r.code]?.[n.value.toLowerCase()]:void 0;if(!kr.has(a)&&!kr.has(n.value.toLowerCase())&&s===void 0)return null;let u=[{text:s??n.normalized??n.value,token:n}],l=e+1,c=t[l];if(!c||c.kind!=="selector")return null;u.push({text:c.value,token:c}),l++;let d=0;for(;d++<8;){let f=t[l];if(f&&f.kind==="selector"&&f.value.startsWith("."))u.push({text:f.value,token:f}),l++;else break}let m=t[l],p=t[l+1];return m&&p&&p.kind==="selector"&&(m.kind==="keyword"||m.kind==="particle"||m.kind==="identifier")&&!kr.has((m.normalized??m.value).toLowerCase())&&!_r.has((m.normalized??m.value).toLowerCase())&&!(i?.(m)===true&&i(t[l+2])!==true)&&(u.push({text:To(r,m),token:m}),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 pe(t,e){let r=Mr[t];return r?r[e.toLowerCase()]??e:e}function Oo(t,e){return Mr[t]?.[e.toLowerCase()]!==void 0}function Po(t,e){let r=[e.value,e.normalized].filter(Boolean);for(let i of r){let n=me(t,i)??me(t,i.toLowerCase());if(n)return n}}function jt(t){return t.kind==="literal"||t.kind==="operator"||t.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(t.value)}function No(t,e){let r=t?.references;if(!r)return false;let i=Object.values(r).filter(a=>typeof a=="string").map(a=>a.toLowerCase());return [e.value,e.normalized].filter(Boolean).some(a=>i.includes(a.toLowerCase()))}function st(t,e){return jt(t)?pe(e,t.value)!==t.value?true:t.kind==="identifier":false}var Lo={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"}}},Mo=new Set(["empty","null","undefined","true","false"]),$t=new Set(["Number","Int","Float","String","Date","Array","Object","JSON","json","FormData","HTML","Fragment","Values"]);function _o(t,e,r,i){let n=Lo[t],a=n?.[e.value]??n?.[e.value.toLowerCase()];if(a){if(a.beforeTypeName&&i?.kind==="identifier"&&$t.has(i.value))return a.beforeTypeName;if(a.beforePredicate&&i&&(i.kind==="literal"||i.kind==="keyword"&&Mo.has((i.normalized??"").toLowerCase())))return a.beforePredicate;if(a.beforeBareIdentifier&&i?.kind==="identifier"&&/^[A-Za-z_]\w*$/.test(i.value))return a.beforeBareIdentifier;if(a.afterSubject&&(r?.kind==="selector"||r?.kind==="reference"))return a.afterSubject;if(a.afterCopula&&r?.kind==="keyword"&&(r.normalized??"").toLowerCase()==="is")return a.afterCopula}}function Le(t,e){let r=e?.code??"en",i="",n,a=(s,u)=>{if(n===void 0){i=s,n=u;return}let c=n.position?.end!==void 0&&u.position?.start!==void 0&&n.position.end===u.position.start&&(s.startsWith(".")||s.startsWith("!"));i+=(c?"":" ")+s,n=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==="'"&&n!==void 0&&c?.value==="s"&&u.position?.end!==void 0&&c.position?.start===u.position.end){i+="'s",n=c;let v=t[s+2];v&&pe(r,v.value)!==v.value?(a(pe(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&&st(h,r)){a(zr(l),u),a(pe(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){a(zr(l),u),a(pe(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&&!No(e,u)){a(zr(l),u),a(pe(r,c.value.slice(1)),c),s+=1;continue}}let d=t[s+2];if(c&&d&&d.kind==="selector"&&Dr(e,c)&&jt(u)){a(pe(r,u.value),u),a("of",c),a(d.value,d),s+=2;continue}if(u.kind==="selector"&&c&&d&&Dr(e,c)&&st(d,r)&&pe(r,d.value)!==d.value){a(pe(r,d.value),d),a("of",c),a(u.value,u),s+=2;continue}let m=It(t,s,e);if(m){for(let v of m.parts)a(v.text,v.token);s+=m.consumed-1;continue}let p=_o(r,u,t[s-1],c);if(p!==void 0){a(p,u);continue}let f=Ro(r,u.value);if(f!==u.value){a(f,u);continue}a(o(u),u);}return i.trim()}var Vt=[{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 ut(t,e,r,i){let n=Vt.find(o=>o.lang===t);if(!n)return false;let a=(o,s)=>(o??"").toLowerCase()===s.toLowerCase();return a(e,n.end)&&a(r,n.at)&&a(i,n.of)}function Io(t,e){let r=Vt.find(n=>n.lang===t);if(!r)return false;let i=e.toLowerCase();return i===r.at.toLowerCase()||i===r.of.toLowerCase()||i===r.end.toLowerCase()}var Wt={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 Wt[t]}function lt(t,e){return Wt[e]?.has(t.toLowerCase())??false}var qt=96,$o=/^[A-Za-z_][\w-]*$/,Vo=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function Kt(t,e){let r=t.peek(e);return !!r&&r.kind==="identifier"&&Vo.test(r.value)}function Ht(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),n=t.peek(e+2);return !!i&&i.value===":"&&!!n}function ct(t,e=0){return Kt(t,e)||Ht(t,e)}function Wo(t){let e=t.peek();if(!e||e.value!=="{"&&e.value!=="(")return null;let r="",i=-1,n=0,a=0;for(;!t.isAtEnd()&&a++<qt;){let o=t.advance();if(!o)break;if(i>=0&&o.position.start>i&&(r+=" ".repeat(o.position.start-i)),r+=o.value,i=o.position.end,o.value==="{"||o.value==="(")n++;else if((o.value==="}"||o.value===")")&&(n--,n===0))return r}return null}function dt(t){let e=t.peek();return e?e.value==="{"||e.value==="("?Wo(t):e.value===","||e.value===":"?null:(t.advance(),e.value):null}function Ze(t,e){let r=t.mark(),i=[];if(e!==void 0){let a=t.peek();if(!a||a.value!==":"||!t.peek(1))return null;t.advance();let o=dt(t);if(o===null)return t.reset(r),null;i.push(`${e}:${o}`);}else if(!ct(t))return null;let n=0;for(;n++<qt;){let a=t.peek();if(!a)break;if(a.value===","){if(i.length===0||!ct(t,1))break;t.advance();continue}if(Kt(t,0)){i.push(t.advance().value);continue}if(!Ht(t,0))break;let o=t.advance().value;t.advance();let s=dt(t);if(s===null)return t.reset(r),null;i.push(`${o}:${s}`);}return i.length===0?(t.reset(r),null):`{${i.join(", ")}}`}var ur=.8,qo=.6,Ko=.15,Ho=.5,mt=.15,pt=.1,ft=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),n=this.scoreLanguageAdjustment(t),a=e;return a=Math.max(Ho,a+r),a=Math.min(1,a+i),a=Math.max(0,Math.min(1,a+n)),{roleCoverage:e,stemPenalty:r,languageBoost:i,languageAdjustment:n,final:a}}scoreRoleCoverage(t){let{pattern:e,captured:r}=t,i=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0,o=e.command==="on"?e.extraction?.action?.value:void 0,s=ce[o??e.command]?.roles,u=l=>s?.find(c=>c.role===l)?.valueShape!==void 0;for(let l of e.template.tokens)if(l.type==="role")r.has(l.role)?(n+=1,i+=1):u(l.role)||(n+=1);else if(l.type==="group")for(let c of l.tokens)c.type==="role"&&(r.has(c.role)?(n+=ur,i+=ur):u(c.role)||(n+=ur,a(c.role)&&(i+=ur*qo)));return n>0?i/n: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:ft.has(r.value)||r.alternatives?.some(i=>ft.has(i))?mt:0}scoreLanguageAdjustment(t){let{pattern:e,captured:r}=t;if(e.language!=="ar")return 0;let i=0;for(let[n,a]of r.entries()){let o=Uo[n];if(!o||o.length===0)continue;let s="metadata"in a?a.metadata:void 0;s&&typeof s.prepositionValue=="string"&&(o.includes(s.prepositionValue)?i+=.1:i-=.1);}return Math.max(-pt,Math.min(pt,i))}},Yo=new Go,Zo=new Set(Object.values(ce).filter(t=>t.bareKeyword===true).map(t=>t.action));function Xo(t){return t.startsWith("*")||t.startsWith("@")}var Q=class M{constructor(e){this.matchCache=new Map,this.roleStarts=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Yo;}matchPattern(e,r){let i=e.mark(),n=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,n))return e.reset(i),null;let o=this.confidenceModel.calculate({pattern:r,captured:n,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-i.position,confidence:o,roleStarts:this.roleStarts}}matchBest(e,r){this.matchCache.clear();let i=[],n=e.position();for(let o of r){let s=e.mark(),u=`${n}:${o.id}`,l;this.matchCache.has(u)?l=this.matchCache.get(u):(l=this.matchPattern(e,o),this.matchCache.set(u,l)),l&&i.push(l),e.reset(s);}if(i.length===0)return null;i.sort((o,s)=>{let u=s.pattern.priority-o.pattern.priority;return u!==0?u:s.confidence-o.confidence});let a=i[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,i,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let s=0;for(let u=0;u<r.length;u++){let l=r[u];if(s>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,i,l),this.shouldTrySkippingVerbSlot(l,e,r[u+1]??n)){let d=e.mark(),m=new Map(i);if(this.matchTokenSequence(e,r.slice(u+1),m,n)&&this.atClauseEnd(e)){i.clear();for(let[p,f]of m)i.set(p,f);return true}e.reset(d);}let c=this.matchPatternToken(e,l,i,r[u+1]??n);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 n=e.peek(),a=e.peek(1);if(!n||!a||this.patternTokenWouldMatch(i,n))return;let o=this.currentProfile?.roleMarkers?.source,s=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let c=l.value.toLowerCase();return o.primary?.toLowerCase()===c?true:!!o.alternatives?.some(d=>d.toLowerCase()===c)},u=o?.position;if(u!=="after"&&s(n)&&a.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(u==="after"&&n.kind==="selector"&&s(a)){let l=this.tokenToSemanticValue(n);e.advance(),e.advance(),l&&r.set("source",l);}}matchPatternToken(e,r,i,n){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":{let a=e.position(),o=this.matchRoleToken(e,r,i,n);return o&&i.has(r.role)&&this.roleStarts.set(r.role,a),o}case "group":return this.matchGroupToken(e,r,i,n);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(!i)return false;let n=this.getMatchType(i,r.value);if(n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(i,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let a of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(a.includes(o)&&this.tryMatchShatteredCompound(e,a,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let i=e.mark(),n=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;n.push(o.value),e.advance();let s=e.peek();if(!s||s.value!=="-")break;e.advance(),n.push("-");}if(n.length<3||n[n.length-1]==="-")return e.reset(i),null;let a=n.join("").toLowerCase();for(let[o,s]of Object.entries(r.keywords))if(s.primary.toLowerCase()===a||s.alternatives?.some(u=>u.toLowerCase()===a))return q(o);return e.reset(i),null}tryMatchShatteredCompound(e,r,i){let n=r.split(i);if(n.length<2||n.some(o=>o.length===0))return false;let a=e.mark();for(let o=0;o<n.length;o++){if(o>0){let u=e.peek();if(!u||u.value!==i)return e.reset(a),false;e.advance();}let s=e.peek();if(!s||s.kind!=="identifier"&&s.kind!=="keyword"&&s.kind!=="particle"||s.value.toLowerCase()!==n[o].toLowerCase())return e.reset(a),false;e.advance();}return true}matchRoleToken(e,r,i,n){let a=e.position(),o=i.get(r.role);return this.matchRoleTokenCore(e,r,i,n)?(this.absorbTrailingConversion(e,r,i,n,a),this.absorbTrailingConditionOperand(e,r,i,n,a),this.stampCaptureSpan(e,r.role,i,a,o),true):false}stampCaptureSpan(e,r,i,n,a){let o=i.get(r);if(!o||o===a||o.position||e.position()<=n)return;let s=e.tokens[n],u=e.tokens[e.position()-1];!s||!u||i.set(r,go(o,{start:s.position.start,end:u.position.end}));}absorbTrailingConditionOperand(e,r,i,n,a){if(r.role!=="condition"||!i.has("condition")||e.position()<=a||n!==void 0||this.currentPatternCommand!=="on")return;let o=e.peek();if(!o)return;let s=M.CONDITION_OPERATOR_WORDS;if(!s.has((o.normalized??"").toLowerCase())&&!s.has(o.value.toLowerCase())||this.patternTokenWouldMatch(n,o))return;e.advance();let u=e.peek();u&&(u.kind==="selector"||u.kind==="identifier"||u.kind==="literal")&&!_r.has((u.normalized??u.value).toLowerCase())&&e.advance();let l=Le(e.tokens.slice(a,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 n=e.peek(1);return !n||!$t.has(n.value)?0:2}absorbTrailingConversion(e,r,i,n,a){if(r.role==="event"||r.role==="action"||!i.has(r.role)||e.position()<=a||this.conversionRunLength(e)!==2||this.patternTokenWouldMatch(n,e.peek()))return;e.advance(),e.advance();let o=Le(e.tokens.slice(a,e.position()),this.currentProfile);i.set(r.role,{type:"expression",raw:o,value:o});}matchRoleTokenCore(e,r,i,n){this.skipNoiseWords(e);let a=e.peek();if(!a)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(!M.tokenLooksLikeEvent(a))return r.optional||false;let y=(a.normalized??a.value).toLowerCase();if(M.POSITIONAL_OR_SCOPE_KEYWORDS.has(y)||this.currentProfile&&(me(this.currentProfile,a.value)??me(this.currentProfile,y))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let y=(a.normalized??a.value).toLowerCase();if(M.STRUCTURAL_NEVER_EVENT.has(y))return r.optional||false}if(a.kind==="keyword"){let y=(a.normalized??a.value).toLowerCase();if(y==="then"||y==="end"&&e.peek(1)?.kind!=="selector"||lt(a.value,this.currentProfile?.code??"")||(r.role==="quantity"||r.role==="event"&&this.currentPatternCommand==="repeat")&&(a.normalized??a.value).toLowerCase()in ce)return r.optional||false}if(r.role==="duration"){let y=(a.normalized??a.value).toLowerCase();if(M.POSITIONAL_OR_SCOPE_KEYWORDS.has(y))return r.optional||false}if(r.optional&&r.role!=="event"&&r.role!=="action"&&r.valueShape!=="keyword"&&a.kind==="keyword"&&(a.normalized??a.value).toLowerCase()in ce&&(n===void 0||this.patternTokenWouldMatch(n,a)))return true;let o=this.tryMatchPositionalExpression(e,n);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!sr(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&&!sr(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 d=r.role==="event"&&this.currentPatternCommand==="on"||M.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(d)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(d.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,d),true);let m=this.tryMatchPossessiveSelectorExpression(e);if(m)return r.expectedTypes&&r.expectedTypes.length>0&&!sr(m.type,r.expectedTypes)?r.optional||false:(i.set(r.role,m),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&&!sr(v.type,r.expectedTypes)?r.optional||false:(i.set(r.role,v),true);if(a.kind==="identifier"&&a.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=Ze(e);if(y)return i.set(r.role,{type:"expression",raw:y}),true}let E=this.tokenToSemanticValue(a);if(!E)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(E.type)){let 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(n,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 n=e.type==="group"&&e.optional?e.tokens.every(s=>s.type==="role")?e.tokens[0]:void 0:e;if(!n||n.type!=="role"||!n.optional||n.role==="event"||n.role==="action"||n.valueShape==="keyword")return false;let a=r.peek();if(!a||a.kind!=="keyword"||i===void 0)return false;let o=this.patternTokenWouldMatch(i,a);return (a.normalized??a.value).toLowerCase()in ce?!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:lt(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=It(e.tokens,e.position(),this.currentProfile,n=>n===void 0?false:this.patternTokenWouldMatch(r,n));if(!i)return null;for(let n=0;n<i.consumed;n++)e.advance();return {type:"expression",raw:i.parts.map(n=>n.text).join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let i=e.peek(1),n=e.peek(2),a=(i?.normalized??"").toLowerCase(),o=!!i&&(i.value.toLowerCase()==="on"||a==="destination"||a==="on");return !i||!n||n.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${n.value}`})}isOfPossessiveMarker(e){return Dr(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 a=e.mark(),o=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(a),null;for(;;){let u=e.peek();if(!u||!M.RUN_OPERATORS.has(u.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(l);break}}let s=Le(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:s,value:s}}tryMatchHyphenatedWord(e){let r=e.peek();if(!M.isBareWordToken(r))return null;let i=1,n=[r.value];for(;;){let a=e.peek(i),o=e.peek(i+1);if(!a||a.value!=="-"||!M.isBareWordToken(o)||!M.tokensAdjacent(e.peek(i-1),a)||!M.tokensAdjacent(a,o))break;n.push(o.value),i+=2;}if(n.length<2)return null;for(let a=0;a<i;a++)e.advance();return q(n.join("-"),"string")}tryMatchOperatorRunExpression(e){let r=e.mark(),i=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let n=1;for(;;){let o=e.peek();if(!o||!M.RUN_OPERATORS.has(o.value))break;let s=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(s);break}n++;}if(n<2)return e.reset(r),null;let a=Le(e.tokens.slice(i,e.position()),this.currentProfile);return {type:"expression",raw:a,value:a}}static rangeSeparatorFor(e){let[r]=M.PICK_RANGE_SEPARATORS_BY_LANG[e]??[];return r}isPickRangeSeparator(e){let r=(e.normalized??e.value).toLowerCase();if(M.PICK_RANGE_SEPARATORS.has(r))return true;let i=this.currentProfile?.code;return i?M.PICK_RANGE_SEPARATORS_BY_LANG[i]?.has(e.value.toLowerCase())??false:false}tryMatchPickRangeExpression(e){let r=e.mark(),i=e.position();if(!this.tryConsumePickRangeOperand(e))return e.reset(r),null;let n=e.peek();if(!n||!this.isPickRangeSeparator(n)||(e.advance(),!this.tryConsumePickRangeOperand(e)))return e.reset(r),null;let a=e.peek();a&&M.PICK_RANGE_MODES.has((a.normalized??a.value).toLowerCase())&&e.advance();let o=e.tokens.slice(i,e.position()),[s,,u,l]=o,c=m=>m.kind==="keyword"?m.normalized??m.value:m.value,d=`${c(s)} to ${c(u)}`;return l&&(d+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:d,value:d}}tryConsumePickRangeOperand(e){let r=e.peek();if(!r)return false;let i=(r.normalized??r.value).toLowerCase();if(this.isPickRangeSeparator(r))return false;let n=i==="start"||i==="end";return r.kind==="literal"||r.kind==="identifier"||r.kind==="keyword"&&n?(e.advance(),true):false}tryConsumeRunOperand(e){let r=e.peek();if(!r)return false;if(r.value==="("){let i=e.mark(),n=0;for(;!e.isAtEnd();){let a=e.advance();if(a.value==="(")n++;else if(a.value===")"&&(n--,n===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")&&!M.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(me(this.currentProfile,r)??me(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?pe(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 n=e.peek();if(!n||!this.isOfPossessiveMarker(n))return e.reset(i),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"||Xo(a.value)?(e.reset(i),null):(e.advance(),xe(we(a.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),n;for(let u of i)if(n=me(this.currentProfile,u)??me(this.currentProfile,u.toLowerCase()),n)break;if(!n)return null;let a=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let u=e.peek();if(u){let l=u.value.toLowerCase(),c=(u.normalized??"").toLowerCase();o.some(d=>d.toLowerCase()===l||d.toLowerCase()===c)&&e.advance();}}let s=e.peek();if(!s||Io(this.currentProfile.code,s.value))return e.reset(a),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)&&!(s.normalized&&this.isStructuralKeyword(s.normalized))&&!(s.normalized&&this.isRoleMarkerConcept(s.normalized))&&!(s.normalized&&M.COMMAND_ACTION_KEYWORDS.has(s.normalized.toLowerCase()))||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let u=s.value;s.kind==="selector"&&u.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u)&&(u=u.substring(1)),u=this.toEnglishProperty(u);let l=u;for(;;){let d=e.peek();if(d?.kind==="selector"&&d.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(d.value)){l+=d.value,e.advance();continue}if(d?.value==="?"){let m=e.peek(1);if(m?.kind==="selector"&&m.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(m.value)){l+=`?${m.value}`,e.advance(),e.advance();continue}}break}let c=e.peek();if(c&&c.value.startsWith("(")){let d="",m=0,p=0;for(;!e.isAtEnd()&&p++<M.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;d+=f.value,e.advance();for(let v of f.value)v==="("?m++:v===")"&&m--;if(m<=0)break}l+=d;}return xe(le(n),l,"possessive")}return e.reset(a),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=e.peek();if(!r)return null;let i=r.kind==="selector"&&r.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(r.value);if(!(r.kind==="identifier"&&!this.isStructuralKeyword(r.value)&&!(r.normalized&&this.isStructuralKeyword(r.normalized))&&!(r.normalized&&this.isRoleMarkerConcept(r.normalized))||r.kind==="selector"&&(r.value.startsWith("*")||r.value.startsWith("@"))||i)||this.isPossessorToken(r))return null;let a=e.mark(),o=r.value;i&&(o=o.substring(1)),e.advance(),o=this.toEnglishProperty(o);let s=o;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)s+=e.peek().value,e.advance();let u=e.peek();if(!u)return e.reset(a),null;let l;for(let c of [u.value,u.normalized].filter(Boolean))if(l=me(this.currentProfile,c)??me(this.currentProfile,c.toLowerCase()),l)break;return l?(e.advance(),xe(le(l),s,"possessive")):(e.reset(a),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 Mt.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 n=["{"],a=1,o=0;for(;!e.isAtEnd()&&o++<M.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(s.value==="{")a++;else if(s.value==="}"&&(a--,a===0))return n.push("}"),q(n.join(" "));n.push(s.value);}return e.reset(i),null}tryMatchBraceRunExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let i=e.mark(),n="",a=-1,o=0,s=0;for(;!e.isAtEnd()&&s++<M.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(a>=0&&u.position.start>a&&(n+=" ".repeat(u.position.start-a)),n+=u.value,a=u.position.end,u.value==="{")o++;else if(u.value==="}"&&(o--,o===0))return {type:"expression",raw:n}}return e.reset(i),null}tryMatchBareCallExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(r.value))return null;let i=e.peek(1);if(!i||i.value!=="(")return null;let n=e.mark();e.advance();let a=e.advance(),o="",s=a.position?.end,u=false,l=0;for(;!e.isAtEnd()&&l++<M.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),u=true;break}let d=s!==void 0&&c.position?.start===s;o+=(o===""||d?"":" ")+c.value,s=c.position?.end,e.advance();}return u?{type:"expression",raw:`${r.value}(${o})`}:(e.reset(n),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(i),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<M.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}s.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e,r=true){let i=e.peek();if(!i||i.kind!=="identifier"&&i.kind!=="keyword")return null;let n=e.mark();e.advance();let a=i.value.toLowerCase(),o=e.peek();if((i.kind==="identifier"||M.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let p=i.value,f=[],v=0;for(;v<M.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&&Pe(a))return xe(le(a),f.join("."),"dot");if(y){let h=e.mark(),k=[],A=0,x=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&&(x=true),x)break;continue}k.push(C.value),e.advance();}x?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(n),null;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")return e.reset(n),null;e.advance();let l=`${i.value}.${u.value}`,c=1;for(;!e.isAtEnd()&&c<M.MAX_PROPERTY_DEPTH;){let p=e.peek();if(!p||p.kind!=="operator"||p.value!==".")break;e.advance();let f=e.peek();if(!f||f.kind!=="identifier")break;e.advance(),l+=`.${f.value}`,c++;}let d=e.peek();if(d&&d.kind==="punctuation"&&d.value==="("){e.advance();let p=[],f=0;for(;!e.isAtEnd()&&p.length<M.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 m=i.value.toLowerCase();if(r&&Pe(m)){let p=l.split(".").slice(1).join(".");return xe(le(m),p,"dot")}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek(),a=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!n&&n.kind==="punctuation"&&n.value==="'s",s=!!n&&n.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",u=(()=>{if(!this.currentPatternCommand||(n?.normalized??"").toLowerCase()!=="source")return false;let f=ce[this.currentPatternCommand];return !!f&&f.roles.some(v=>v.role==="source")})(),l=!!n&&!!a&&a!=="'s"&&n.value===a&&(n.kind==="particle"||n.kind==="punctuation"||n.kind==="identifier")&&!u;if(!o&&!l&&!s)return e.reset(i),null;e.advance(),s&&e.advance();let c=e.peek();if(!c)return e.reset(i),null;let d=c.kind==="selector"&&c.value.startsWith("*"),m=c.kind==="keyword"&&!!this.currentProfile&&Oo(this.currentProfile.code,c.value);return c.kind==="identifier"||d||m||(o||s)&&(c.kind==="selector"||c.kind==="keyword")?(e.advance(),xe(we(r.value),this.toEnglishProperty(c.value),"possessive")):(e.reset(i),null)}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(i),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return xe(we(r.value),o,"dot")}matchGroupToken(e,r,i,n){let a=e.mark(),o=new Map(i),s=this.matchTokenSequence(e,r.tokens,i,n);if(s){let u=[];for(let l of r.tokens)if(l.type==="group"&&l.renderRequired)for(let c of l.tokens)c.type==="literal"&&u.push(c.value,...c.alternatives??[]);u.length>0&&[...i.keys()].some(c=>!o.has(c))&&(e.tokens.slice(a.position,e.position()).some(m=>u.some(p=>this.getMatchType(m,p)!=="none"))||(s=false));}if(!s){e.reset(a);for(let u of i.keys())o.has(u)||i.delete(u);for(let[u,l]of o)i.get(u)!==l&&i.set(u,l);return r.optional||false}return true}getMatchType(e,r){if(e.value===r)return "exact";if(e.normalized===r)return "normalized";if(e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7)return "stem";if(e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase())return "case-insensitive";if(e.kind==="keyword"){let i=ar(e.value).toLowerCase();if(i&&i===ar(r).toLowerCase())return "case-insensitive"}return "none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return we(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Pe(r)?le(r):q(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return we(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return le(e.value);let i=e.value.toLowerCase();return Pe(i)?le(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 n=e.slice(1,-1);return q(n,"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 n=parseFloat(r[1]);return r[2]?q(e,"duration"):q(n,"number")}let i=parseFloat(e);return isNaN(i)?q(e,"string"):q(i,"number")}applyExtractionRules(e,r){for(let[i,n]of Object.entries(e.extraction)){let a=r.get(i);if(a){if(n.transform){let o=a.type==="literal"?String(a.value):String(a.raw??"");r.set(i,n.transform(o));}}else n.value!==void 0?r.set(i,{type:"literal",value:n.value}):n.default&&r.set(i,{...n.default,implicit:true});}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=r.value.toLowerCase();if(M.ENGLISH_NOISE_WORDS.has(i)){let n=e.mark();e.advance();let a=e.peek();if(a&&(a.kind==="selector"||a.kind==="identifier"))return;let o=e.peek(1);if(a&&a.kind==="keyword"&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value))return;let s=a?(a.normalized??a.value).toLowerCase():"";if(a&&M.POSITIONAL_OR_SCOPE_KEYWORDS.has(s))return;let u=e.peek(1),l=u?(u.normalized??u.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&M.COMMAND_ACTION_KEYWORDS.has(l),d=!u||u.kind==="particle"||M.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(a&&a.kind==="keyword"&&this.currentProfile?.code!=="en"&&Pe(s)&&d||a&&a.kind==="keyword"&&this.currentProfile?.code==="en"&&Pe(s))return;e.reset(n);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(i=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return i?r:void 0}};Q.CONDITION_OPERATOR_WORDS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Q.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);Q.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then","while"]);Q.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);Q.COMMAND_ACTION_KEYWORDS=_r;Q.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);Q.RUN_OPERATORS=new Set(["+","-","*","/"]);Q.PICK_RANGE_SEPARATORS=new Set(["to"]);Q.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"])};Q.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);Q.MAX_BRACE_RUN_TOKENS=64;Q.MAX_PROPERTY_DEPTH=10;Q.MAX_METHOD_ARGS=20;Q.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);Q.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ut=Q,ue=new Ut;function Y(t,e){return Ha(t,e)}function Gt(){return Ka()}var Yt={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(Yt).flatMap(t=>[...t]));function Br(t,e){let r=(t.normalized??t.value).toLowerCase();if(r==="or")return true;let i=e===void 0?Jo:Yt[e];return i?i.has(t.value)||i.has(r):false}var Ve=["if","unless","repeat","for","while"],cr=/^[A-Z][A-Za-z0-9_]*$/;function K(t,e){let r=new Set([e]),n=P(t)?.keywords?.[e];if(n){n.primary&&r.add(n.primary.toLowerCase());for(let a of n.alternatives??[])r.add(a.toLowerCase());}return r}function $(t,e){return e.has(t.value.toLowerCase())?true:t.normalized?e.has(t.normalized.toLowerCase()):false}var Qo=new Set(Ve);function Qe(t,e){let r=t.normalized?.toLowerCase();return r?Qo.has(r):e.some(i=>$(t,i))}var yt=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 Xe(t){if(!t||t.kind==="selector")return false;let e=(t.normalized??t.value).toLowerCase(),r=t.value.toLowerCase();return !(yt.has(e)||yt.has(r)||es.has(e))}var ht=new Set(["ja","ko"]);function Ie(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 Zt(t,e){let r=[],i=e.position.end,n=t.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(n){i=e.position.end+n[0].length;for(let a of n[1].split(/[,\u060c\u3001]/)){let o=a.trim();o&&r.push(o);}}return {parameters:r,headerEnd:i}}function dr(t,e,r){let i=e+1;if(i>=t.length)return -1;let n=Ie(P(r)?.roleMarkers?.patient);return n.size>0&&$(t[i],n)&&i++,i<t.length?i:-1}var Xt=/^[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"||!Xt.test(t[0].value)||e!==rs(t))return false;let n=Ie(i.roleMarkers?.patient);return n.size===0?false:$(t[e-1],n)}function is(t,e,r){if(!P(e))return null;let i=K(e,"behavior"),n=K(e,"def"),a=t.toLowerCase(),o=[...i].some(d=>a.includes(d)),s=/\bdef\b/.test(a)||[...n].some(d=>d!=="def"&&a.includes(d));if(!o&&!s)return null;let u=Y(t,e).tokens;if(u.length<2)return null;if($(u[0],i))return vt(t,e,u,r,0);let l=u.findIndex((d,m)=>m>0&&$(d,i));if(l>0&&cr.test(u[0].value))return vt(t,e,u,r,l);if($(u[0],n))return Et(t,e,u,r,0);let c=u.findIndex((d,m)=>m>0&&$(d,n));return c>0&&ts(u,c,e)?Et(t,e,u,r,c):null}function ns(t,e,r){let i=P(e);if(!i)return null;let n=i.wordOrder!=="SOV",a=ht.has(e)?Ie(i.roleMarkers?.event):new Set,o=ht.has(e)?Ie(i.keywords?.on):new Set,s=a.size>0&&o.size>0,u=K(e,"end"),l=K(e,"on"),c=t.toLowerCase(),d=[...u].some(C=>c.includes(C)),m=(n||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(!d&&!m)return null;let p=Y(t,e).tokens;if(p.length<2)return null;let f=Ve.map(C=>K(e,C)),v=C=>Qe(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(n&&h===0&&C>k&&$(g,l)&&Xe(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,a)&&p[C+1]!==void 0&&$(p[C+1],o)){let b=p[C-1],D=t.slice(p[k].position.start,b.position.start).trim();D&&y.push(D),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=[],x=[];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;x.push(b.metadata?.confidence??.75);}return Ye(A,"then",{sourceLanguage:e,confidence:je(x),sourceText:t})}function je(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 vt(t,e,r,i,n){let a=n>0,o=a?0:dr(r,n,e);if(o<0)return null;let s=r[o],u=s.value;if(!cr.test(u))return null;let{parameters:l,headerEnd:c}=Zt(t,s),d=a?n+1:r.findIndex(b=>b.position.start>=c);d<=o&&(d=o+1);let m=K(e,"init"),p=K(e,"end"),f=Ve.map(b=>K(e,b)),v=b=>Qe(b,f),E=b=>$(b,p),y=[],h=[],k=[],A=false,x=0,C=d;for(let b=d;b<r.length;b++){let D=r[b];if(E(D)){if(x>0){x--;continue}if(b===C){A=true;break}if($(r[C],m)){let z=t.slice(r[C].position.end,D.position.start).trim();if(z)try{let w=mr(i.body(z,e));h.push(...w),k.push(je(w.map(S=>S.metadata?.confidence??.75)));}catch{k.push(0);}}else {let z=t.slice(r[C].position.start,D.position.start).trim();try{let w=i.statement(z,e);if(w&&w.kind==="event-handler"){let S=w;y.push(S);let R=!S.body||S.body.length===0;k.push(R?.2:S.metadata?.confidence??.75);}else k.push(0);}catch{k.push(0);}}C=b+1;}else v(D)&&x++;}if(y.length===0&&h.length===0)return null;let g=(A?1:.8)*je(k);return zo(u,l,y,h.length>0?h:void 0,{sourceLanguage:e,confidence:g,sourceText:t})}function Et(t,e,r,i,n){let a=n>0,o=a?0:dr(r,n,e);if(o<0)return null;let s=r[o],u=s.value;if(!Xt.test(u))return null;let{parameters:l,headerEnd:c}=Zt(t,s),d=a?n+1:r.findIndex(g=>g.position.start>=c);d<=o&&(d=o+1);let m=K(e,"end"),p=Ve.map(g=>K(e,g)),f=g=>Qe(g,p),v=g=>$(g,m),E=0,y=-1;for(let g=d;g<r.length;g++)if(v(r[g])){if(E===0){y=g;break}E--;}else f(r[g])&&E++;let h=r[d]?.position.start??c,k=y>=0?r[y].position.start:t.length,A=t.slice(h,k).trim();if(!A)return null;let x;try{x=mr(i.body(A,e));}catch{return null}if(x.length===0)return null;let C=je(x.map(g=>g.metadata?.confidence??.75));return y<0&&(C*=.8),ko(u,l,x,{sourceLanguage:e,confidence:C,sourceText:t})}var Tr=["live","eventsource","socket","worker","intercept"],as=new Set(["intercept"]),Ir=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 Tr)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 n of Tr)if(n!=="live"&&$(t[i],K(e,n))&&!(Ir.has(n)&&!cr.test(t[0].value))&&!(n==="intercept"&&i>ls))return {action:n,keywordIdx:i};return null}function ds(t,e,r){let i=Ie(P(r)?.roleMarkers?.source);return i.size===0||e+1>=t.length?0:$(t[e],i)||$(t[e+1],i)?2:0}function Jt(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,n=[i?.eventMarker?.primary,...i?.eventMarker?.alternatives??[],...i?.temporalMarkers??[]].filter(o=>!!o&&/\s/.test(o)),a=1;for(let o of n){let s=o.toLowerCase().split(/\s+/),u=e-s.length+1;u<0||s.every((l,c)=>t[u+c]?.value.toLowerCase()===l)&&(a=Math.max(a,s.length));}return a}function ps(t,e,r,i,n){if(t==="live")return r+1;if(r>0){let l=r+1;return t==="eventsource"&&(l+=ds(e,l,i)),l}let a=dr(e,r,i);if(a<0)return -1;if(t==="worker")return a+1;let o=Jt(i),s=Ie(P(i)?.roleMarkers?.event),u=n>=0?n:e.length;for(let l=a+1;l<u;l++){if(!$(e[l],o))continue;if(Xe(e[l+1]))return l;if(l>a+2&&s.size>0&&$(e[l-1],s)&&Xe(e[l-2]))return l-2;let c=ms(e,l,i);if(c>1&&l-c>a&&Xe(e[l-c]))return l-c;if(l>a+1&&Xe(e[l-1]))return l-1}return u}function fs(t,e,r,i){if(!Ir.has(t))return;let n=r>0?0:dr(e,r,i);if(!(n<0))return e[n].value}function ys(t,e,r){if(!P(e))return null;let i=t.toLowerCase(),n=false;for(let u of [...Tr,"changes"]){for(let l of K(e,u))if(l&&i.includes(l)){n=true;break}if(n)break}if(!n)return null;let a=Y(t,e).tokens;if(a.length<2)return null;let o=gs(a,e);if(o>=0)return ks(t,e,a,r,o);let s=cs(a,e);return s?hs(t,e,a,r,s.action,s.keywordIdx):null}function hs(t,e,r,i,n,a){let o=K(e,"end"),s=Ve.map(A=>K(e,A)),u=A=>Qe(A,s),l=A=>$(A,o),c=fs(n,r,a,e);if(Ir.has(n)&&(!c||!cr.test(c)))return null;let d=A=>({sourceLanguage:e,confidence:A,sourceText:t}),m=Fr(r,a+1,l,u);if(as.has(n))return m>=0&&m!==r.length-1?null:Sr(n,[],c,d(m>=0?1:.8));let p=ps(n,r,a,e,m);if(p<0||p>r.length)return null;let f=[],v=[],E=false,y=ss.has(n);if(y||os.has(n)){let A=y?"def":"event-handler",x=0,C=p;for(let g=p;g<r.length;g++){let b=r[g];if(l(b)){if(x>0){x--;continue}if(E=true,g===C)break;let D=y?b.position.end:b.position.start,z=t.slice(r[C].position.start,D).trim();try{let w=i.statement(z,e);if(w&&w.kind===A){let S=w;f.push(S);let R=!S.body||S.body.length===0;v.push(R?.2:S.metadata?.confidence??.75);}else v.push(0);}catch{v.push(0);}C=g+1;}else u(b)&&x++;}}else {let A=Fr(r,p,l,u);E=A>=0;let x=A>=0?r[A].position.start:t.length,C=t.slice(r[p].position.start,x).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*je(v):h;return Sr(n,f,c,d(k))}var vs=new Set([...Object.keys(ce),"then","else"]);function Es(t){let e=K(t,"when");for(let r of Jt(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 n=2;n<t.length;n++){let a=t[n];if(a.kind==="literal")continue;if($(a,r))return n;if($(a,i))return -1;let o=(a.normalized??a.value).toLowerCase();if(a.kind==="keyword"&&vs.has(o))return -1}return -1}function zs(t,e,r){if(r==="en"){let n=e[0],a=e[e.length-1];return {type:"expression",raw:t.slice(n.position.start,a.position.end).trim()}}let i=e.map(n=>Br(n,r)?{...n,kind:"keyword",normalized:"or"}:n);return {type:"expression",raw:Le(i,P(r))}}function ks(t,e,r,i,n){let a=K(e,"end"),o=Ve.map(h=>K(e,h)),s=h=>Qe(h,o),u=h=>$(h,a),l=n+1;if(l>=r.length)return null;let c=Fr(r,l,u,s),d=c>=0;if(d&&c!==r.length-1)return null;let m=d?r[c].position.start:t.length,p=t.slice(r[l].position.start,m).trim();if(!p)return null;let f;try{f=mr(i.body(p,e));}catch{return null}if(f.length===0)return null;let v=zs(t,r.slice(1,n),e),y=(d?1:.8)*je(f.map(h=>h.metadata?.confidence??.75));return Sr("when",f,void 0,{sourceLanguage:e,confidence:y,sourceText:t},new Map([["condition",v]]))}function Fr(t,e,r,i){let n=0;for(let a=e;a<t.length;a++)if(r(t[a])){if(n===0)return a;n--;}else i(t[a])&&n++;return -1}var ke={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(ke).map(([t,e])=>{let r={};for(let[i,n]of Object.entries(e))n in r||(r[n]=i);return [t,r]}));var As={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},xs=[["\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"]],Ss=/^(\d+)(ms|s|m)?$/,Ds=new Set(["selector","literal","url","event-modifier"]);function Bs(t){let e=t.match(Ss);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(Ds.has(r.kind))continue;let i=r.value.toLowerCase(),n=As[i];if(n){let a=0;for(let o=e+1;o<t.length;o++){let s=t[o],u=Bs(s.value);if(u!==null)return {modifiers:{[n]:u},start:r.position.start,end:s.position.end};if(s.kind==="selector"||s.kind==="literal"||s.kind==="url"||++a>2)break}continue}for(let a of xs){if(a[0]!==i||e+a.length>t.length)continue;let o=true;for(let s=1;s<a.length;s++)if(t[e+s].value.toLowerCase()!==a[s]){o=false;break}if(o)return {modifiers:{once:true},start:r.position.start,end:t[e+a.length-1].position.end}}}return null}new Set(Object.values(Mr).flatMap(t=>Object.values(t)));var Se=new Set(["if","unless","while","repeat","for"]),br=new Set(["then","end","else","if","unless","while","for","repeat","and"]),qs=new Set(["first","last","next","previous","random","closest"]),Ne=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"]),zt=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 lr=120;function Ks(t,e,r){let i=e.tokens.length;if(t.consumedTokens>=i)return null;let n=e.tokens[t.consumedTokens],a=e.tokens[i-1];if(!n||!a)return null;let o=r.slice(n.position.start,a.position.end);if(!o.trim())return null;let s=o.length>lr?`${o.slice(0,lr)}\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 Cr(t){let e=[],r=new Set((t.diagnostics??[]).map(n=>`${n.code}|${n.message}`)),i=n=>{if(!n||typeof n!="object")return;if(n!==t)for(let o of n.diagnostics??[]){if(o.code!=="unconsumed-input")continue;let s=`${o.code}|${o.message}`;r.has(s)||(r.add(s),e.push(o));}let a=n;for(let o of ei){let s=a[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 kt(t){if(t.length>=2){let e=t[0];if((e==='"'||e==="'")&&t.endsWith(e))return t.slice(1,-1)}return t}var ei=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function ri(t,e){if(!t||typeof t!="object")return t;if(t.action&&t.roles instanceof Map){let i=te(t.action),n=i?.primaryRole;if(i&&n&&n!=="patient"&&!i.roles.some(a=>a.role==="patient")&&t.roles.has("patient")&&!t.roles.has(n)){let a=t.roles,o=a.get("patient");o!==void 0&&(a.delete("patient"),a.set(n,o));}if(t.action==="tell"){let a=t.roles,o=a.get("patient"),s=a.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!s||s.type==="literal")&&(a.delete("patient"),a.set("destination",o));}if(t.action==="transition"){let a=t.roles,o=a.get("goal");o&&o.type==="literal"&&o.dataType==="duration"&&!a.has("duration")&&(a.delete("goal"),a.set("duration",o));}if(t.action==="fetch"){let a=t.roles,o=a.get("patient"),s=a.get("source");o&&s&&(o.type==="literal"||o.type==="expression")&&s.type==="expression"&&!a.has("style")&&(a.delete("patient"),a.set("style",s),a.set("source",o));}if(t.action==="transition"){let a=t.roles,o=a.get("destination");o&&o.type==="literal"&&!a.has("goal")&&(a.delete("destination"),a.set("goal",o));let s=a.get("patient");s&&s.type==="literal"&&typeof s.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(s.value)&&a.set("patient",{type:"expression",raw:s.value});}if(t.action==="morph"){let a=t.roles,o=a.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(o.value)&&a.set("patient",{type:"expression",raw:o.value});}if(t.action==="wait"){let a=t.roles;if(!a.has("event")){let o=a.get("duration"),s=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof s=="string"&&Ne.has(s.toLowerCase())&&(a.delete("duration"),a.set("event",{type:"literal",value:s,dataType:"string"}));}}if(t.kind==="command"&&t.action!=="on"){let a=t.roles,o=a.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)&&a.set("event",{type:"literal",value:s,dataType:"string"});}}if(e?.size){let a=t.roles;for(let o of ["destination","source"]){let s=a.get(o);s&&s.type==="literal"&&typeof s.value=="string"&&e.has(s.value)&&a.set(o,{type:"expression",raw:s.value});}}}let r=t;for(let i of ei){let n=r[i];if(Array.isArray(n))for(let a of n)ri(a,e);}return t}var ee=class B{constructor(){this.parseDepth=0,this.coverageFrames=[],this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++,this.coverageFrames.push([]);try{let i=ri(this.parseInternal(e,r),this.boundIdentifiers),n=this.coverageFrames[this.coverageFrames.length-1];if(n.length>0&&(i=W(i,[...i.diagnostics??[],...n])),this.parseDepth===1&&(i=Cr(i),i.kind==="event-handler")){let a={node:i,input:e},o=a.node.eventModifiers;if(o&&(o.once||o.debounce!==void 0||o.throttle!==void 0))for(let u=0;u<4;u++){let l=this.reclaimDanglingFromTail(a.node,a.input,r)??this.reclaimEventCompoundTail(a.node,a.input,r)??this.reclaimResponseTypeTail(a.node,a.input,r)??this.reclaimCapturedDestinationTail(a.node,a.input,r);if(!l)break;a=l;}let s=this.reclaimEventCompoundTail(a.node,a.input,r);s&&(a=s),i=a.node;}return i}finally{this.coverageFrames.pop(),this.parseDepth--;}}coverageMark(){let e=this.coverageFrames[this.coverageFrames.length-1];return e?e.length:0}coverageRollback(e){let r=this.coverageFrames[this.coverageFrames.length-1];r&&r.length>e&&(r.length=e);}static getCoverageMarkerSurfaces(e){let r=B.coverageMarkerSurfaces.get(e);if(!r){r=new Set;let i=P(e)?.roleMarkers;if(i){for(let n of Object.values(i))if(n){if(n.primary)for(let a of n.primary.toLowerCase().split(/\s+/))r.add(a);for(let a of n.alternatives??[])for(let o of a.toLowerCase().split(/\s+/))r.add(o);}}for(let n of B.LEAKED_RENDER_MARKERS[e]??[])r.add(n.toLowerCase());B.coverageMarkerSurfaces.set(e,r);}return r}isCoverageResidueToken(e,r){if(e.kind==="particle"||e.kind==="conjunction"||e.metadata?.closesTrackedBlock||this.isThenKeyword(e.value,r)||this.isEndKeyword(e.value,r)||this.isElseKeyword(e.value,r))return true;let i=(e.normalized??e.value).toLowerCase();return Hs.has(i)?true:B.getCoverageMarkerSurfaces(r).has(e.value.toLowerCase())}recordDroppedTokens(e,r,i){if(e.length===0)return;let n=this.coverageFrames[this.coverageFrames.length-1];if(!n||!e.some(s=>!this.isCoverageResidueToken(s,r)))return;let a=e.map(s=>s.value).join(" ").trim();if(!a)return;let o=a.length>lr?`${a.slice(0,lr)}\u2026`:a;n.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 n=ys(e,r,{statement:(z,w)=>this.parse(z,w),body:(z,w)=>this.parseStatements(z,w)});if(n)return n;let a=ns(e,r,{statement:(z,w)=>this.parse(z,w),body:(z,w)=>this.parseStatements(z,w)});if(a)return a;let{modifiers:o,remainingInput:s}=this.extractStandaloneModifiers(e,r),u=s||e,c=this.stripAsyncModifier(u,r).remainingInput??u,m=this.stripDoNotThrowModifier(c,r).remainingInput??c,p=[],f=Y(m,r);this.positionSource=m;{let z=f.mark(),w=this.consumeJsBlock(f,r);if(w&&f.isAtEnd())return W(w,p);f.reset(z);}let v=fe(r);if(v.length===0)throw new zt(`No patterns available for language: ${r}`,r,m,[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(S=>S.normalized==="on");if(w>=2&&w+1<z.length){let S=m.slice(z[0].position.start,z[w].position.start).trim(),R=z[w+1].position.end,T=m.slice(z[w].position.start,R)+" "+S+m.slice(R);if(T!==m)try{let O=this.parse(T,r);if(O&&O.kind==="event-handler"){let L=o?this.applyModifiers(O,o):O;return W(L,p)}}catch{}}}}{let z=f.tokens,w=z[0]?.normalized==="if";for(let S=0;w&&S+3<z.length;S++){let R=(z[S+3]?.normalized??z[S+3]?.value??"").toLowerCase();if(z[S]?.normalized==="source"&&z[S+2]?.normalized==="on"&&B.KNOWN_EVENTS.has(R)){let T=(m.slice(0,z[S].position.start).trimEnd()+" "+m.slice(z[S+1].position.end).trimStart()).trim();if(T&&T!==m)try{let O=this.parse(T,r);if(O&&O.kind==="event-handler"){let L=o?this.applyModifiers(O,o):O;return W(L,p)}}catch{}break}}}{let z=f.tokens;for(let w=1;w<z.length-1;w++){let S=z[w];if(!Br(S,r))continue;let R=z[w+1],T=(R.normalized??R.value).toLowerCase();if(!B.KNOWN_EVENTS.has(T))break;let O=w+1,L=z[w+2];L&&L.kind==="selector"&&L.value.startsWith("[")&&(O=w+2);let I=z[w].position.start,j=z[O].position.end,N=(m.slice(0,I).trimEnd()+" "+m.slice(j).trimStart()).trim();if(N&&N!==m)try{let Z=this.parse(N,r);if(Z&&Z.kind==="event-handler"){Z.additionalEvents=[{type:"literal",value:T}];let X=o?this.applyModifiers(Z,o):Z;return W(X,p)}}catch{}break}}{let z=Ts(f.tokens);if(z){let w=(m.slice(0,z.start).trimEnd()+" "+m.slice(z.end).trimStart()).trim();if(w&&w!==m)try{let S=this.parse(w,r);if(S&&S.kind==="event-handler"){let R=this.applyModifiers(S,{...o??{},...z.modifiers});return W(R,p)}}catch{}}}let y=E.filter(z=>z.command==="on"),h=f.mark(),k=ue.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"),S=(w?.raw??w?.value??"").toString().toLowerCase(),R=ke[r],T=B.KNOWN_EVENTS.has(S)||!!R&&Object.keys(R).some(O=>O.toLowerCase()===S);if(S&&!T){let O=this.trySOVEventExtraction(m,r,E);if(O){p.push(V(`bare-event mis-anchor on "${S}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let L=o?this.applyModifiers(O,o):O;return W(L,p)}if(w?.type==="reference"||w?.type==="expression"){f.reset(h);let L=E.filter(j=>j.command!=="on"),I=ue.matchBest(f,L);f.reset(h),I&&I.pattern.command!=="on"?(z=true,p.push(V(`bare-event mis-anchor on reference "${S}" rejected; command ${I.pattern.command} preferred`,"info","stage-bare-event-guard"))):ue.matchBest(f,y);}}}if(!z){let w=this.buildEventHandler(k,f,r),S=o?this.applyModifiers(w,o):w;return W(S,p)}}p.push(V(`event patterns: ${y.length} tried, no match`,"info","stage-event"));let A=this.tryTrailingEventExtraction(m,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 x=E.filter(z=>z.command!=="on"),C=this.tryParseUnlessGuard(f,x,r);if(C&&C.length>0){let z=C.length===1?C[0]:Ye(C,"then",{sourceLanguage:r,confidence:1});return W(z,p)}let g=ue.matchBest(f,x);if(g){if(Se.has(g.pattern.command)){let w=this.trySOVEventExtraction(m,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 S=this.tryMidStreamEventExtraction(m,r,E);if(S){p.push(V(`mid-stream event extraction preferred over bare ${g.pattern.command} command`,"info","stage-midstream-loop"));let R=o?this.applyModifiers(S,o):S;return W(R,p)}}else if(B.KNOWN_EVENTS.has(g.pattern.command)&&this.hasSOVEventMarkerHead(m,r)){let w=this.trySOVEventExtraction(m,r,E);if(w){p.push(V(`SOV event extraction preferred over command-homonym event ${g.pattern.command}`,"info","stage-sov-homonym"));let S=o?this.applyModifiers(w,o):w;return W(S,p)}}else if(P(r)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(m,r,E);if(w){p.push(V(`mid-stream event extraction preferred over bare ${g.pattern.command} command`,"info","stage-midstream-cmd"));let S=o?this.applyModifiers(w,o):w;return W(S,p)}}if(g.consumedTokens<f.tokens.length&&P(r)?.wordOrder==="SOV"){let w=this.trySOVEventExtraction(m,r,E);if(w){p.push(V(`SOV event extraction preferred over partial ${g.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let S=o?this.applyModifiers(w,o):w;return W(S,p)}}if(g.consumedTokens<f.tokens.length&&!Se.has(g.pattern.command)){let w=this.tryTopLevelCommandSequence(f,x,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,m);return z&&p.push(V(z,"warning","unconsumed-input")),W(this.buildCommand(g,r),p)}if(p.push(V(`command patterns: ${x.length} tried, no match`,"info","stage-command")),!m.includes(`
4
- `)&&P(r)?.wordOrder==="VSO"){let z=this.tryMidStreamEventExtraction(m,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(m,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 D=this.tryCompoundCommandParsing(f,x,r);if(D)return p.push(V("compound command parsing succeeded","info","stage-compound")),W(D,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 "${m}"`,"error","parse-failed")),new zt(`Could not parse input in ${r}: ${m}`,r,m,p)}parseStatements(e,r){let i=Y(e,r),n=fe(r).filter(a=>a.command!=="on").sort((a,o)=>o.priority-a.priority);this.coverageFrames.push([]);try{let a=this.parseBodyWithClauses(i,n,r),o=this.coverageFrames[this.coverageFrames.length-1];if(o.length>0&&a.length>0){let s=a[a.length-1];a[a.length-1]=W(s,[...s.diagnostics??[],...o]);}return a}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Gt()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let i={};for(let[a,o]of e.captured)i[a]=o;let n=re(e.pattern.command,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(n),n}buildEventHandler(e,r,i){if(!e)throw new Error("No match to build event handler from");let n=e.captured.get("event");if(!n)throw new Error("Event handler pattern matched but no event captured");{let m=n.type==="expression"?n.raw:n.type==="literal"?n.value:void 0;if(typeof m=="string"&&/^[^\s()[\]{}:]+$/.test(m)){let p=ke[i]?.[m];p?n={type:"literal",value:p,dataType:"string"}:n.type==="expression"&&B.KNOWN_EVENTS.has(m.toLowerCase())&&(n={type:"literal",value:m.toLowerCase(),dataType:"string"});}}let a=ue.extractEventModifiers(r),o=e.captured.get("source");o&&e.pattern.id.endsWith("source")&&!(o.type==="reference"&&o.value==="me")&&(a={...a??{},from:o});let s=this.extractOrConjunctionEvents(r,i),u=n;s.length>0&&n.type==="literal"&&(u={type:"literal",value:[String(n.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 m=r.tokens,p=-1;for(let f=r.position()-1;f>=0;f--){let v=m[f],E=(v.normalized??v.value).toLowerCase();if(this.isIfKeyword(E,i)){p=f;break}}if(p>=0){let f=fe(i).filter(A=>A.command!=="on").sort((A,x)=>x.priority-A.priority),v=m.slice(p);if(e.pattern.id.endsWith("vso-verb-first")&&u.type==="literal"){let A=String(u.value??"").split("[")[0].trim().toLowerCase(),x=v.findIndex((C,g)=>{if(g===0||A==="")return false;let b=(C.normalized??C.value).toLowerCase(),D=v[g-1];return b===A&&D.kind==="keyword"&&(D.normalized??"").toLowerCase()==="on"});if(x>0){let C=v[x+1],g=C&&C.kind==="selector"&&C.value.startsWith("[")?1:0;v=[...v.slice(0,x-1),...v.slice(x+1+g)];}}let E=new ne(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 Ue(u,h,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(y);}}if(c&&c.type==="literal"&&String(c.value)!=="js"&&te(String(c.value))!==void 0){let m=c.value,p={};for(let[g,b]of e.captured)g!=="event"&&g!=="action"&&g!=="continues"&&(p[g]=b);if(m==="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 D=p.patient;D&&D.type==="reference"&&D.value==="me"&&delete p.patient;}let f=re(m,p,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence});this.registerBoundIdentifiers(f);let v=[];if(!Se.has(m)||m==="repeat"||m==="while"){let g=e.pattern.id.includes("verb-first"),b=r.tokens,D=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?.[m];R?.primary&&w.add(R.primary.toLowerCase());for(let T of R?.alternatives??[])w.add(T.toLowerCase());}let S=-1;for(let R=D-1;R>=0;R--){let T=b[R];if(z(T))break;if((T.normalized??T.value).toLowerCase()===m||w.has(T.value.toLowerCase())){S=R;break}}if(S>=0){let R=D;for(;R<b.length&&!z(b[R]);)R++;let T=b.slice(S,R),O=T;if(g){let L=String(n.value??"").toLowerCase(),I=T.findIndex(j=>(j.normalized??j.value).toLowerCase()===L);if(I<0)O=null;else {let j=T[I-1],N=j&&j.kind==="keyword"&&j.normalized?.toLowerCase()==="on"?I-1:I;O=[...T.slice(0,N),...T.slice(I+1)];}}if(O&&O.length>1){let L=fe(i).filter(_=>_.command!=="on").sort((_,H)=>H.priority-_.priority),I=this.coverageMark(),j=this.parseClause(O,L,i),N=j[0],Z=_=>_!==null&&typeof _=="object"&&typeof _.type=="string"?_.type:typeof _,X=te(m),hr=X?.primaryRole,Zr=_=>_==="patient"&&hr&&hr!=="patient"&&!X?.roles.some(H=>H.role==="patient")?hr:_,Pi=(_,H)=>{if(!Se.has(m)||!X)return false;let ve=X.roles.find(qe=>qe.role===Zr(_));return ve?ve.expectedTypes.length>0&&!ve.expectedTypes.includes(Z(H)):true},vr=(_,H)=>_==="patient"&&!!X&&!X.roles.some(ve=>ve.role==="patient")&&Z(H)==="literal"&&Mt.has(String(H.value??"").toLowerCase()),Er=_=>_!==null&&typeof _=="object"&&_.implicit===true,Ni=!!N&&N.kind==="command"&&Object.entries(p).every(([_,H])=>{if(Er(H)||Pi(_,H)||vr(_,H))return true;let ve=N.roles.get(Zr(_));if(ve!==void 0&&Z(ve)===Z(H))return true;if(_==="patient"&&m==="pick"&&Z(H)==="literal"){let qe=N.roles.get("method"),Jr=Z(qe),Qr=Jr==="literal"?String(qe.value):Jr==="expression"?String(qe.raw):void 0;return Qr!==void 0&&Qr===String(H.value)}return false}),Xr=N?.metadata?.patternId??"",Li=!Se.has(m)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(Xr),Mi=/^repeat-.*-(times|for-in|while-head|until-head)$/.test(Xr);if((j.length===1||Mi&&j.length>1)&&N&&N.kind==="command"&&(N.action===m||m==="while"&&N.action==="repeat"&&/-while-head$/.test(N.metadata?.patternId??""))&&Ni&&Li&&(N.roles.size>Object.entries(p).filter(([_,H])=>!vr(_,H)).length||[...N.roles.values()].filter(_=>!Er(_)).length>Object.entries(p).filter(([_,H])=>!vr(_,H)&&!Er(H)).length))for(f=N,v=j.slice(1);r.position()<R;)r.advance();else this.coverageRollback(I);}}}if(!Se.has(m)){let g=f;if(te(m)?.roles.some(T=>T.role==="quantity"&&!T.required)&&!g.roles.has("quantity")){let T=r.peek();T&&/^-?\d+(\.\d+)?$/.test(T.value)&&(f=re(m,{...Object.fromEntries(g.roles),quantity:{type:"literal",value:parseFloat(T.value),dataType:"number"}},g.metadata),r.advance());}let D=f;if(te(m)?.roles.some(T=>T.role==="duration"&&!T.required)&&!D.roles.has("duration")){let T=/^\d+(\.\d+)?(ms|s)$/i,O=r.peek(),L=false;if(O&&O.kind==="particle"){let I=r.peek(1);I&&T.test(I.value)&&(L=true,O=I);}O&&T.test(O.value)&&(f=re(m,{...Object.fromEntries(D.roles),duration:{type:"literal",value:O.value,dataType:"string"}},D.metadata),L&&r.advance(),r.advance(),this.consumeForPostposition(r,i));}let w=f,S=te(m);if(S?.roles.find(T=>T.role==="responseType"&&!T.required)&&!w.roles.has("responseType")){let T=N=>typeof N=="string"&&B.RESPONSE_TYPE_WORDS.has(N.toLowerCase()),O=(N,Z)=>{let X=Object.fromEntries(w.roles);Z&&delete X.destination,X.responseType={type:"expression",raw:N},f=re(m,X,w.metadata);},L=w.roles.get("destination"),I=S?.roles.find(N=>N.role==="destination"),j=L?.raw??L?.value;if(L&&I&&!I.expectedTypes.includes(L.type)&&T(j))O(j,true);else {let N=r.peek();N&&T(N.value)&&(O(N.value,false),r.advance());}}if(m==="wait"){let T=f;if(!T.roles.has("event")){let O=r.peek();if(O&&Ne.has(O.value.toLowerCase())){let L=Object.fromEntries(T.roles),I=L.duration;I&&I.type!=="literal"&&I.type!=="expression"&&delete L.duration;let j=L.patient;j&&j.type==="reference"&&j.value==="me"&&delete L.patient,L.event={type:"literal",value:O.value,dataType:"string"},f=re(m,L,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),x=Se.has(m)&&!!h&&!this.isEndKeyword(h.value,i),C=!!h&&!this.isEndKeyword(h.value,i);if(y||k||x||C){let g=fe(i).filter(z=>z.command!=="on").sort((z,w)=>w.priority-z.priority),b=fe(i).filter(z=>z.id.startsWith("grammar-")&&z.id.includes("-continuation")).sort((z,w)=>w.priority-z.priority),D=this.parseBodyWithGrammarPatterns(r,g,b,i);D.length>0?l=[f,...v,...D]:l=[f,...v];}else l=[f,...v],r.isAtEnd()||this.recordDroppedTokens(r.tokens.slice(r.position()),i,"handler body tail");}else {let m=fe(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 ne(r.tokens.slice(p),i);for(l=this.parseBodyWithClauses(f,m,i);!r.isAtEnd();)r.advance();}else l=this.parseBodyWithClauses(r,m,i);}let d=l.length>1?[Ye(l,"then",{sourceLanguage:i})]:l;return Ue(u,d,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,i){let n=[],a=[],o=0,s=[];for(;!e.isAtEnd();){let u=e.peek();if(!u)break;if(a.length===0){let f=this.consumeJsBlock(e,i)??this.consumeVerbFinalJsBlock(e,i);if(f){n.push(f);continue}let v=this.tryParseConditionalBlock(e,r,i);if(v){n.push(v);continue}let E=this.tryParseUnlessGuard(e,r,i);if(E){n.push(...E);continue}}let l=u.kind==="conjunction"||u.kind==="keyword"&&this.isThenKeyword(u.value,i),c=a[a.length-1],d=e.peek(1),m=c?.value.toLowerCase()==="at"&&d?.value.toLowerCase()==="of"||ut(i,u.value,c?.value,d?.value),p=u.kind==="keyword"&&this.isEndKeyword(u.value,i)&&!m;if(p&&o>0){o--,s.pop(),a.push({...u,metadata:{...u.metadata,closesTrackedBlock:true}}),e.advance();continue}if(l&&s.includes("if")){a.push(u),e.advance();continue}if(l){if(a.length>0){let f=this.parseClause(a,r,i);n.push(...f),a.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=a.length>0?this.parseClause(a,r,i):[];E.length===0&&a.length>0?(this.coverageRollback(v),n.push(...this.parseClause([...a,...f],r,i))):(n.push(...E),n.push(...this.parseClause(f,r,i)));}else if(a.length>0){let v=this.parseClause(a,r,i);n.push(...v);}a.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"));}a.push(u),e.advance();}if(a.length>0){let u=this.parseClause(a,r,i);n.push(...u);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),i,"body stream tail"),this.foldFrontedWhileIntoRepeat(n,i);for(let u=n.length-1;u>=0;u--){let l=n[u];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&n.splice(u,1);}return n.length>1?[Ye(n,"then",{sourceLanguage:i})]:n}tryTopLevelCommandSequence(e,r,i){let n=this.coverageMark(),a;try{let l=new ne(e.tokens,i);a=this.parseBodyWithClauses(l,r,i);}catch{return this.coverageRollback(n),null}if(a.length!==1||a[0].kind!=="compound")return this.coverageRollback(n),null;let o=a[0];if(o.statements.length<2)return this.coverageRollback(n),null;let s=o.statements.map(l=>l.metadata?.confidence??.75),u=s.reduce((l,c)=>l+c,0)/s.length;return Ye(o.statements,o.chainType,{sourceLanguage:i,confidence:u})}foldFrontedWhileIntoRepeat(e,r){for(let i=0;i+1<e.length;i++){let n=e[i],a=e[i+1];if(n.kind!=="command"||n.action!=="while"||a.kind!=="command"||a.action!=="repeat")continue;let o=n.roles.get("condition");if(!o||a.roles.has("condition")||Array.isArray(n.body)||Array.isArray(a.body))continue;let s=new Map(a.roles);s.set("condition",o),s.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(i,2,{...a,roles:s,metadata:{...a.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(a.metadata?.confidence??0,n.metadata?.confidence??0)}});}}parseClause(e,r,i){if(e.length===0)return [];let n=null,a=e,o=e[e.length-1];if(o&&e.length>=2){let y=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(y,i)&&(n="unless",a=e.slice(0,-1));}let s=null;if(n&&a.length>=3){let y=P(i),h=y?B.buildVerbLookup(y):null;if(h)for(let k=1;k<a.length-1;k++){let A=a[k],x=h.get(A.value.toLowerCase())??(A.normalized?h.get(A.normalized.toLowerCase()):void 0);if(x&&!B.CONDITION_OPERATORS.has(x)){s=a.slice(0,k),a=a.slice(k);break}}}let u=new ne(a,i),l=[],c=this.coverageMark(),d=0,m=[],p=s,f=()=>{if(m.length===0)return;let y=m.slice();if(m.length=0,n&&l.length===0&&p===null){p=y;return}let 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 x of this.parseSOVClauseByVerbAnchoring(y,i)){let C=x.action,g=x.roles;C&&te(C)&&g instanceof Map&&g.size>0&&(l.push(x),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=ue.matchBest(u,r);if(h&&A&&A.pattern.command!=="repeat"){u.reset(k),f(),l.push(re("repeat",{},{sourceLanguage:i,confidence:.6})),d++,u.advance();continue}if(A&&A.pattern.command==="if"){let x=u.mark(),C=m.length;for(u.reset(k);!u.isAtEnd();){let b=u.peek();if(!b||this.isIfKeyword((b.normalized??b.value).toLowerCase(),i))break;m.push(b),u.advance();}let g=this.tryParseConditionalBlock(u,r,i);if(g){f(),l.push(g),d++;continue}m.length=C,u.reset(x);}if(A){f();let x=this.buildCommand(A,i);l.push(x),d++,this.tryAttachTrailingRole(u,x,i),this.tryAttachTrailingStyle(u,x,i),this.tryAttachTrailingExpressionRole(u,x,i),this.tryAttachTrailingDuration(u,x);}else {let x=u.peek();x&&x.normalized?.toLowerCase()==="repeat"?(f(),l.push(re("repeat",{},{sourceLanguage:i,confidence:.6})),d++):x&&m.push(x),u.advance();}}f();let v=l;if(d===0){let y=this.parseSOVClauseByVerbAnchoring(a,i);y.length>0&&(this.coverageRollback(c),v=y);}let E=p;return n&&v.length>0&&E&&E.length>0?[re(n,{condition:{type:"expression",raw:this.joinTokenText(E,i)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85}),...v]:n&&E&&E.length>0&&v.length===0?[re(n,{condition:{type:"expression",raw:this.joinTokenText(E,i)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85})]:v}tryAttachTrailingDuration(e,r){let i=r.roles;if(i.has("duration")||!te(r.action)?.roles.some(o=>o.role==="duration"&&!o.required))return;let a=e.peek();!a||!/^\d+(?:\.\d+)?(?:ms|s|m|h)$/.test(a.value)||(i.set("duration",q(a.value,"duration")),e.advance());}tryAttachTrailingRole(e,r,i){let n=te(r.action);if(!n)return;let a=P(i);if(!a)return;let o=r.roles,s=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let d=(l.normalized??l.value).toLowerCase();return br.has(d)?false:d==="body"||d==="it"||d==="you"||d==="result"||d==="document"||d==="window"||this.boundIdentifiers.has(l.value)?true:c?false:l.kind==="identifier"||l.kind==="reference"},u=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:c}of u){if(!n.roles.some(E=>E.role===l))continue;let d=a.roleMarkers?.[l];if(!d)continue;let m=o.get(l);if(m&&!(m.type==="reference"&&m.value==="me"))continue;let p=E=>{if(!E||E.kind!=="particle"&&E.kind!=="keyword")return false;let y=E.value.toLowerCase();return d.primary?.toLowerCase()===y?true:c?false:(E.normalized??"").toLowerCase()===l?true:!!d.alternatives?.some(h=>h.toLowerCase()===y)},f=e.peek(),v=e.peek(1);if(!f||!v)return;if(c&&d.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(d.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 n=r.roles;if(!te(r.action)?.roles.some(y=>y.role==="style"))return;let o=n.get("style");if(o){if(o.type==="expression"&&typeof o.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(o.raw)&&e.peek()?.value===":"){let y=Ze(e,o.raw);y&&n.set("style",{type:"expression",raw:y});}this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(r.action==="fetch"){let y=n.get("patient"),h=n.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=Ze(e,h.raw);k&&(n.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(x=>x.toLowerCase())),h=e.peek();if(!h||!y.has(h.value.toLowerCase()))return;let k=e.mark();e.advance();let A=Ze(e);if(!A){e.reset(k);return}n.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)),d=24,m=-1,p=0;for(let y=0;y<d;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())){m=y;break}}if(m<=0)return;let f=[];for(let y=0;y<m;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 ne(f,i),E=Ze(v);n.set("style",{type:"expression",raw:E&&v.isAtEnd()?E:this.joinTokenText(f,i)});for(let y=0;y<=m;y++)e.advance();this.tryAttachResponseTypeAfterStyle(e,r,i);}tryAttachResponseTypeAfterStyle(e,r,i){let n=r.roles;if(n.has("responseType")||!te(r.action)?.roles.some(c=>c.role==="responseType"&&!c.required))return;let o=c=>!!c&&B.RESPONSE_TYPE_WORDS.has(c.toLowerCase()),s=e.peek();if(!s)return;let u=c=>{n.set("responseType",{type:"expression",raw:c});};if(B.AS_MARKERS_BEFORE[i]?.some(c=>s.value.toLowerCase()===c)){let c=e.peek(1);c&&o(c.value)&&(e.advance(),e.advance(),u(c.value));return}if(o(s.value)){e.advance(),u(s.value);for(let c of B.AS_MARKERS_AFTER[i]??[])if(c.every((d,m)=>e.peek(m)?.value.toLowerCase()===d)){for(let d=0;d<c.length;d++)e.advance();break}}}tryAttachTrailingExpressionRole(e,r,i){let n=r.action,a=n==="js"?{role:"patient",terminator:"boundary"}:n==="go"||n==="scroll"?{role:"destination",terminator:"destination-marker"}:null;if(!a)return;let o=r.roles,s=o.get(a.role);if(n==="go"&&s&&s.type==="expression"&&String(s.raw).toLowerCase()==="url"){let y=e.peek();if(y&&!br.has((y.normalized??y.value).toLowerCase())){let k=this.tokenToSemanticValue(y);if(k.type==="literal"||k.type==="selector"){o.set(a.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(a.role,h),o.set("method",{type:"literal",value:"url"}),o.delete("patient");return}}if(n==="go"&&s&&s.type==="expression"){let y=/^url\s+(\S+)$/i.exec(String(s.raw??""));if(y){let h=y[1].replace(/^["']|["']$/g,"");o.set(a.role,{type:"literal",value:h,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(n==="go"&&!s){let y=o.get("patient");if(y&&y.type==="expression"&&String(y.raw).toLowerCase()==="url"){let h=e.peek();if(h&&!br.has((h.normalized??h.value).toLowerCase())){let k=this.tokenToSemanticValue(h);if(k.type==="literal"||k.type==="selector"){o.set(a.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(a.terminator==="destination-marker"){let y=u.roleMarkers?.destination;if(!y||y.position!=="after")return;l=y.primary.toLowerCase();}let c=y=>y.kind==="conjunction"||y.kind==="keyword"&&(this.isThenKeyword(y.value,i)||this.isEndKeyword(y.value,i)),d=24,m=[],p=0,f=false;for(let y=0;y<d;y++){let 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}m.push(h);}if(m.length===0||l!==null&&!f)return;let v=m.length+(f?1:0);if(n==="go"&&m.length===2&&m[0].value.toLowerCase()==="url"){let y=this.tokenToSemanticValue(m[1]);if(y.type==="literal"||y.type==="selector"){o.set(a.role,y),o.set("method",{type:"literal",value:"url"});let h=o.get("patient");h&&h.type==="reference"&&h.value==="me"&&!te(n)?.roles.some(k=>k.role==="patient")&&o.delete("patient");for(let k=0;k<v;k++)e.advance();return}}let E=m;if(n==="js"){let y=u.keywords?.js,h=A=>[y?.primary,...y?.alternatives??[]].some(x=>!!x&&x.length>A.value.length&&x.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(a.role,{type:"expression",raw:this.joinTokenText(E,i)}),a.role!=="patient"){let y=o.get("patient");y&&y.type==="reference"&&y.value==="me"&&!te(n)?.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,n]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(i)&&(r.set(n.primary.toLowerCase(),i),n.alternatives))for(let a of n.alternatives)r.set(a.toLowerCase(),i);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[i,n]of Object.entries(e.roleMarkers)){if(!n)continue;if((i!=="event"||!r.has(n.primary))&&r.set(n.primary,i),n.alternatives)for(let o of n.alternatives)r.has(o)||r.set(o,i);}return r}parseSOVClauseByVerbAnchoring(e,r){let i=P(r);if(!i||i.wordOrder!=="SOV")return [];let n=B.buildVerbLookup(i),a=B.buildMarkerToRoleLookup(i),o=[],s=0;for(;s<e.length;){let u=-1,l="";for(let f=s;f<e.length;f++){let v=e[f];if(a.has(v.value))continue;let E=n.get(v.value.toLowerCase()),y=v.normalized?n.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),d=e.length;for(let f=u+1;f<e.length;f++){let v=e[f];if(v.kind==="conjunction"||this.isThenKeyword(v.value,r)){d=f;break}if(f>u+1&&!a.has(v.value)&&(n.get(v.value.toLowerCase())||(v.normalized?n.get(v.normalized.toLowerCase()):void 0))){d=f;break}}let m=e.slice(u+1,d),p=this.extractRolesFromMarkedTokens(c,m,a,l,r);if(o.push(re(l,p,{sourceLanguage:r,confidence:.7})),s=d,s<e.length){let f=e[s];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&s++;}}return o}extractRolesFromMarkedTokens(e,r,i,n,a){let o={},s=(l,c)=>{let d=this.isEndKeyword(l.value,a),m=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !d&&!m?false:l.metadata?.closesTrackedBlock===true||d?true:!(c&&c.kind==="selector")},u=l=>{let c=[];for(let d=0;d<l.length;d++){let m=l[d];if(s(m,l[d+1]))continue;let p=i.get(m.value);if(p&&m.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c,a);if(f){let v=this.mapRoleForCommand(p,n,o);v&&(o[v]=f);}c=[];}else c.push(m);}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!o.duration&&te(n)?.roles.some(m=>m.role==="duration"))o.duration={type:"literal",value:c[0].value,dataType:"string"};else {let m=this.tokensToSemanticValue(c,a);m&&(o.patient?o.destination||(o.destination=m):o.patient=m);}};return u(e),u(r),o}mapRoleForCommand(e,r,i){return r==="set"&&(e==="patient"?e="destination":e==="destination"&&(e="patient")),i[e]?e==="patient"&&!i.destination?"destination":e==="destination"&&!i.patient?"patient":e==="source"&&!i.source?"source":null:e}tokensToSemanticValue(e,r){if(e.length===0)return null;let i=e.filter(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 n=i.map(o=>o.value).join(""),a=i[0];return a.kind==="selector"||a.value.startsWith("#")||a.value.startsWith(".")||a.value.startsWith("@")||a.value.startsWith("*")?we(n):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?q(kt(n),"string"):a.kind==="reference"?le(n):q(this.joinTokenText(i,r))}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return we(r);if(r.startsWith('"')||r.startsWith("'"))return q(kt(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 le(r);let i=e.normalized?.toLowerCase();return i==="me"||i==="it"||i==="you"||i==="result"||i==="body"?le(i):e.kind==="reference"?le(e.normalized||"me"):q(r)}parseBodyWithGrammarPatterns(e,r,i,n){let a=[],o=[],s=false,u=()=>{if(!s&&o.length>0){let d=this.parseSOVClauseByVerbAnchoring(o,n);a.push(...d),d.length===0&&this.recordDroppedTokens(o,n,"fused body walk");}else o.length>0&&this.recordDroppedTokens(o,n,"fused body walk");o=[],s=false;},l=0,c=()=>{let d=0;for(let m of a){let p=m;(p.action==="for"||p.action==="repeat"||p.action==="while")&&(!Array.isArray(p.body)||p.body.length===0)&&d++;}return d-l};for(;!e.isAtEnd();){let d=e.peek();if(d&&this.isThenKeyword(d.value,n)){u(),e.advance();continue}if(d&&this.isEndKeyword(d.value,n)){let p=e.peek(-1),f=e.peek(1);if(!ut(n,d.value,p?.value,f?.value)){if(u(),c()>0){l++,e.advance();continue}e.advance();break}}if(d&&!s&&this.isIfKeyword((d.normalized??d.value).toLowerCase(),n)){u();let p=this.tryParseConditionalBlock(e,r,n);if(p){a.push(p),s=true;continue}}let m=false;if(i.length>0){let p=ue.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=re(f,v,{sourceLanguage:n,patternId:p.pattern.id});a.push(E),m=true,s=true;let y=p.captured.get("continues");if(y&&y.type==="literal"&&y.value==="then")continue}}if(!m){let p=e.mark(),f=ue.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(),n))break;e.advance();}let y=this.tryParseConditionalBlock(e,r,n);if(y){u(),a.push(y),s=true;continue}e.reset(E);}let v=this.buildCommand(f,n);a.push(v),this.tryAttachTrailingRole(e,v,n),m=true,s=true;}}m||(d&&o.push(d),e.advance());}u(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),n,"fused body walk");for(let d=a.length-1;d>=0;d--){let m=a[d];m.kind==="command"&&m.action==="for"&&(!(m.roles instanceof Map)||m.roles.size===0)&&(!Array.isArray(m.body)||m.body.length===0)&&a.splice(d,1);}return a}tryCompoundCommandParsing(e,r,i){let n=e.tokens,a=n.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,i)),o=n.some(c=>this.isElseKeyword(c.value,i));if(!a&&!o)return null;let s=new ne(n,i),u=this.coverageMark(),l=this.parseBodyWithClauses(s,r,i);return l.length===0?(this.coverageRollback(u),null):l[0]}static isEnEventKeyword(e){if(typeof e!="string")return false;let r=e.toLowerCase(),i=B.enEventKeywordCache.get(r);if(i!==void 0)return i;let n=false;try{let a=Y(r,"en").tokens;n=a.length===1&&a[0]?.kind==="keyword";}catch{n=false;}return B.enEventKeywordCache.set(r,n),n}matchEventMarkerPhrase(e,r,i){let n=B.SOV_EVENT_MARKER_PHRASES[i];if(!n)return 0;for(let a of n)if(a.every((o,s)=>e[r+s]?.value===o))return a.length;return 0}hasSOVEventMarkerHead(e,r){let i=B.SOV_EVENT_MARKERS[r];if(i===void 0)return false;let{tokens:n}=Y(e,r),a=ke[r],o=new Set;if(a)for(let s of Object.keys(a))o.add(s.toLowerCase());for(let s=0;s<n.length;s++){let u=n[s],l=u.value.toLowerCase(),c=u.normalized?.toLowerCase();if(!(!!c&&(B.KNOWN_EVENTS.has(c)||Ne.has(c))||B.KNOWN_EVENTS.has(l)||Ne.has(l)||o.has(l)))continue;let m=this.matchEventParamPhrase(n,s+1).len,p=n[s+1+m];if(p&&(p.kind==="particle"||p.kind==="keyword")&&i.has(p.value)||this.matchEventMarkerPhrase(n,s+1+m,r)>0)return true}return false}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let i=[];for(let n=r+1;n<e.length;n++){let a=e[n].value;if(a===")")return {len:n-r+1,names:i};if(a!==","){if(e[n].kind!=="identifier")break;i.push(a);}}return {len:0,names:[]}}isStrippableSourceRef(e,r){if(!e)return false;let i=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(i==="me"||i==="i"||i==="it"))return true;let n=e.value.toLowerCase();return r.has(n)||!!i&&r.has(i)}tryTrailingEventExtraction(e,r,i){let n=Y(e,r).tokens;if(n.length<3)return null;let a=ke[r],o=new Set;if(a)for(let A of Object.keys(a))o.add(A.toLowerCase());let s=n.length-2,u=n[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))return null;let c=n[n.length-1],d=c.value.toLowerCase(),m=c.normalized?.toLowerCase();if(!(!!m&&B.KNOWN_EVENTS.has(m)||B.KNOWN_EVENTS.has(d)||o.has(d)))return null;let f=m&&B.KNOWN_EVENTS.has(m)?m:a?.[d]??d,v=n.slice(0,s);if(v.length===0)return null;let E=i.filter(A=>A.command!=="on"),y=new ne(v,r),h=this.coverageMark(),k=this.parseBodyWithClauses(y,E,r);return k.length===0?(this.coverageRollback(h),null):Ue({type:"literal",value:f},k,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,i){let n=Y(e,r).tokens;if(n.length<3)return null;let a=ke[r],o=new Set;if(a)for(let s of Object.keys(a))o.add(s.toLowerCase());for(let s=0;s<n.length-1;s++){let u=n[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))continue;let c=n[s+1],d=c.value.toLowerCase(),m=c.normalized?.toLowerCase();if(!(!!m&&B.KNOWN_EVENTS.has(m)||B.KNOWN_EVENTS.has(d)||o.has(d)))continue;let f=m&&B.KNOWN_EVENTS.has(m)?m:a?.[d]??d,v=n.filter((A,x)=>x!==s&&x!==s+1);if(v.length===0)return null;let E=i.filter(A=>A.command!=="on"),y=new ne(v,r),h=this.coverageMark(),k=this.parseBodyWithClauses(y,E,r);return k.length===0?(this.coverageRollback(h),null):Ue({type:"literal",value:f},k,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,i){let n=B.SOV_EVENT_MARKERS[r];if(!n)return null;let o=Y(e,r).tokens,s=ke[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,d="",m="",p=1,f=[];for(let C=0;C<o.length;C++){let g=o[C],b=g.value.toLowerCase(),D=b,z="",w=b.indexOf("[");w>0&&(D=b.slice(0,w),z=g.value.slice(w));let S=g.normalized?.toLowerCase(),R=S&&(B.KNOWN_EVENTS.has(S)||Ne.has(S)),T=u.has(b)||u.has(D),O=B.KNOWN_EVENTS.has(D)||Ne.has(D);if(R||T||O){let L=o[C-1];if(L&&(L.normalized??L.value).toLowerCase()==="event")continue;let I;R?I=S:T?I=s?.[b]??s?.[D]??D:I=D;let j=this.matchEventParamPhrase(o,C+1);if(n.size>0){let N=1+j.len,Z=o[C+N];Z&&Z.kind==="selector"&&Z.value.startsWith("[")&&(N+=1);let X=o[C+N];if(X&&(X.kind==="particle"||X.kind==="keyword")&&n.has(X.value)){c=C,d=I,m=z||(N===j.len+2?o[C+N-1].value:""),p=N+1,f=j.names;break}}else {c=C,d=I,m=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(n.size>0){let D=1,z=o[g+1];z&&z.kind==="selector"&&z.value.startsWith("[")&&(D=2);let w=o[g+D];if(w&&(w.kind==="particle"||w.kind==="keyword")&&n.has(w.value)){c=g,d=b.value,m=D===2?o[g+1].value:"",p=D+1;break}}else {let D=this.matchEventMarkerPhrase(o,g+1,r);if(D>0){c=g,d=b.value,m="",p=1+D;break}let z=o[g+1];if(z&&z.kind==="keyword"&&z.normalized!=null&&C.has(z.normalized)){c=g,d=b.value,m="",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],D=b.value.toLowerCase(),z=b.normalized?.toLowerCase();if(l.windowTokens.has(D)||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 ne(E,r),k=this.coverageMark(),A=this.parseBodyWithClauses(h,y,r);if(A.length===0)return this.coverageRollback(k),null;let x={sourceLanguage:r,confidence:.75};return m&&(x.keyFilter=m),Ue(B.isEnEventKeyword(d)?{type:"literal",value:d}:{type:"expression",raw:d},A,void 0,x,f)}profileKeywordMatches(e,r,i){let n=P(e)?.keywords?.[r];return n?n.primary?.toLowerCase()===i?true:!!n.alternatives?.some(a=>a.toLowerCase()===i):false}consumeForPostposition(e,r){let i=e.peek();if(!i)return;let n=(i.normalized??"").toLowerCase(),a=P(r)?.keywords?.for;(n==="for"||i.value===a?.primary||(a?.alternatives??[]).includes(i.value))&&e.advance();}isThenKeyword(e,r){let i=e.toLowerCase(),a={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 a?a.has(i):i==="then"||this.profileKeywordMatches(r,"then",i)}isElseKeyword(e,r){let i=e.toLowerCase();return i==="else"?true:this.profileKeywordMatches(r,"else",i)}isEndKeyword(e,r){let i=e.toLowerCase(),n=jo(r);return n?i==="end"||n.has(i):i==="end"||this.profileKeywordMatches(r,"end",i)}isJsKeyword(e){let r=(e.normalized??e.value).toLowerCase();return r==="js"||this.profileKeywordMatches("en","js",r)}isPatientMarker(e,r){let i=P(r)?.roleMarkers?.patient;if(!i?.primary)return false;let n=e.value.toLowerCase();return i.primary.toLowerCase()===n?true:!!i.alternatives?.some(a=>a.toLowerCase()===n)}isJsBlockTerminator(e,r){return this.isEndKeyword(e,r)||this.profileKeywordMatches(r,"end",e.toLowerCase())}consumeVerbFinalJsBlock(e,r){let i=e.mark(),n=0,a=-1;for(;;){let c=e.peek(n);if(!c||this.isThenKeyword(c.value,r)||this.isJsBlockTerminator(c.value,r))break;if(this.isJsKeyword(c)){let d=e.peek(n+1),m=!!d&&c.position?.end!==void 0&&c.position.end===d.position?.start&&this.profileKeywordMatches(r,"js",`${c.value}${d.value}`.toLowerCase()),p=e.peek(n+(m?2:1));if(n>0&&p&&this.isJsBlockTerminator(p.value,r)){a=n;break}}n++;}if(a<=0)return null;let o=[];for(let c=0;c<a;c++){let d=e.peek(c);d&&o.push(d);}let s=o[o.length-1];if(s&&this.isPatientMarker(s,r)&&o.pop(),o.length===0)return e.reset(i),null;let u=this.rawJsBody(o);for(let c=0;c<a;c++)e.advance();e.advance();let l=e.peek();return l&&!this.isJsBlockTerminator(l.value,r)&&e.advance(),e.advance(),re("js",{patient:{type:"expression",raw:u||"()"}},{sourceLanguage:r,patternId:`js-opaque-final-${r}`,confidence:1})}consumeJsBlock(e,r){let i=e.peek();if(!i||!this.isJsKeyword(i))return null;let n=e.mark(),a=[];e.advance();let o=e.peek();o&&i.position?.end!==void 0&&i.position.end===o.position?.start&&this.profileKeywordMatches(r,"js",`${i.value}${o.value}`.toLowerCase())&&e.advance();let s=e.peek();s&&this.isPatientMarker(s,r)&&e.advance();let u=false;for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(e.advance(),this.isJsBlockTerminator(c.value,r)){u=true;break}a.push(c);}if(!u)return e.reset(n),null;let l=this.rawJsBody(a);return re("js",{patient:{type:"expression",raw:l||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}rawJsBody(e){if(e.length===0)return "";let r=e[0].position?.start,i=e[e.length-1].position?.end,n=this.positionSource;if(n!==void 0&&r!==void 0&&i!==void 0){let o=n.slice(r,i),s=u=>u.replace(/\s+/g,"");if(s(o)===s(e.map(u=>u.value).join("")))return o.trim()}let a="";for(let o=0;o<e.length;o++){let s=e[o-1],u=s?.position?.end!==void 0&&e[o].position?.start===s.position.end;o>0&&!u&&(a+=" "),a+=e[o].value;}return a.trim()}isIfKeyword(e,r){let i=e.toLowerCase();return i==="if"?true:this.profileKeywordMatches(r,"if",i)}isUnlessKeyword(e,r){let i=e.toLowerCase();return i==="unless"?true:this.profileKeywordMatches(r,"unless",i)}tryParseUnlessGuard(e,r,i){let n=e.peek();if(!n||!this.isUnlessKeyword((n.normalized??n.value).toLowerCase(),i))return null;let a=e.mark(),o=this.tryParseConditionalBlock(e,r,i,true);if(!o||o.kind!=="conditional")return e.reset(a),null;let s=o;if(s.elseBranch&&s.elseBranch.length>0)return e.reset(a),null;let u=s.roles.get("condition");return u?[re("unless",{condition:u},{sourceLanguage:i,patternId:`unless-${i}-guard`,confidence:1}),...s.thenBranch]:(e.reset(a),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,n=false){let a=e.peek();if(!a)return null;let o=(a.normalized??a.value).toLowerCase();if(!this.isIfKeyword(o,i)&&!(n&&this.isUnlessKeyword(o,i)))return null;let s=e.mark(),u=this.coverageMark();e.advance();let l=[],c=0;for(;!e.isAtEnd();){let b=e.peek();if(!b)break;let D=(b.normalized??b.value).toLowerCase();if(this.isIfKeyword(D,i)||this.isUnlessKeyword(D,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 d=P(i),m=d?.wordOrder==="SOV"?B.buildVerbLookup(d):null,p=0,f=0,v=[];for(;p<l.length;p++){let b=l[p],D=(b.normalized??b.value).toLowerCase();if(this.isIfKeyword(D,i)||this.isUnlessKeyword(D,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(),S=(b.normalized??b.value).toLowerCase(),R=B.CONDITION_COPULAS.has(z)||B.CONDITION_COPULAS_SURFACE.has(w)&&B.CONDITION_PREDICATES.has(S),T=m!==null&&m.has(b.value.toLowerCase())&&!B.CONDITION_PREDICATES.has(S),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(S)&&!O&&(!R||T)&&(this.tokensBeginCommand(l.slice(p),r,i)||this.sovCommandStartsAt(l.slice(p),m)))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],D=(b.normalized??b.value).toLowerCase();if(this.isIfKeyword(D,i)||this.isUnlessKeyword(D,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 x={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(x,C,g,{sourceLanguage:i,patternId:`conditional-${i}-folded`,confidence:1})}joinTokenText(e,r){return Le(e,P(r))}tokensBeginCommand(e,r,i){if(e.length===0)return false;let n=new ne(e,i);return ue.matchBest(n,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let i=s=>r.has(s.value.toLowerCase())||!!s.normalized&&r.has(s.normalized.toLowerCase()),n=s=>s.kind==="identifier"||s.kind==="selector"||s.kind==="literal"||s.kind==="reference",a=0,o=0;for(;a+1<e.length;){let s=e[a],u=e[a+1];if(!n(s)||u.kind!=="particle")break;o+=1,a+=2;let l=e[a];if(o>=1&&l&&i(l))return true}return false}parseBranch(e,r,i){if(e.length===0)return [];let n=new ne(e,i),a=this.parseBodyWithClauses(n,r,i);return a.length===1&&a[0]?.kind==="compound"?a[0].statements:a}extractStandaloneModifiers(e,r){let n=Y(e,r).tokens;if(n.length===0)return {modifiers:null,remainingInput:null};let o=n[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<n.length){let f=n[p],v=n[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<n.length){let f=n[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=n.slice(l);if(c.length===0)return {modifiers:null,remainingInput:null};let d=c[0].position.start,m=e.slice(d);return {modifiers:u,remainingInput:m}}stripAsyncModifier(e,r){let i=P(r)?.keywords?.async,n=new Set(["async"]);i?.primary&&n.add(i.primary.toLowerCase()),i?.alternatives?.forEach(l=>n.add(l.toLowerCase()));let a=Y(e,r).tokens,o=a.findIndex(l=>n.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let s=a[o],u=(e.slice(0,s.position.start)+e.slice(s.position.end)).replace(/\s{2,}/g," ").trim();return u.length===0?{remainingInput:null}:{remainingInput:u}}stripDoNotThrowModifier(e,r){let i=Y(e,r).tokens;for(let n=0;n<i.length-1;n++){if(i[n].value.toLowerCase()!=="do")continue;let a=-1;for(let l=n+1;l<=n+5&&l<i.length;l++){let c=i[l];if(c.normalized?.toLowerCase()==="throw"){a=l;break}let d=c.kind;if(d==="selector"||d==="literal"||d==="reference"||d==="conjunction")break}if(a===-1)continue;let o=i[n].position.start,s=i[a].position.end,u=(e.slice(0,o)+e.slice(s)).replace(/\s{2,}/g," ").trim();return u.length===0?{remainingInput:null}:{remainingInput:u}}return {remainingInput:null}}static droppedTokenCount(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").reduce((r,i)=>r+(parseInt(/left (\d+) token/.exec(i.message)?.[1]??"0",10)||0),0)}static unconsumedSpans(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").map(r=>/unconsumed: "(.*)"$/.exec(r.message)?.[1]).filter(r=>!!r).map(r=>r.replace(/\s+/g," ").trim())}static withoutSpanDiagnostics(e,r){return {...e,diagnostics:(e.diagnostics??[]).filter(i=>{if(i.code!=="unconsumed-input")return true;let n=/unconsumed: "(.*)"$/.exec(i.message)?.[1];return !n||n.replace(/\s+/g," ").trim()!==r})}}reclaimDanglingFromTail(e,r,i){let n=B.droppedTokenCount,a=B.unconsumedSpans(e);if(a.length===0)return null;let o=n(e),s=P(i)?.roleMarkers?.source,u=new Set;s?.primary&&u.add(s.primary),s?.alternatives?.forEach(c=>u.add(c));let l=Y(r,i).tokens;for(let c=0;c<l.length;c++){let d=l[c];if(d.normalized!=="source"&&!u.has(d.value))continue;let m=s?.position==="after"?c-1:c+1,p=l[m];if(!p||p.kind!=="identifier"&&p.kind!=="keyword")continue;let f=Math.min(d.position.start,p.position.start),v=Math.max(d.position.end,p.position.end),E=r.slice(f,v).replace(/\s+/g," ").trim();if(!a.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=Cr(h);if(n(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 n=B.unconsumedSpans(e);if(n.length===0)return null;let a=ke[i];if(!a)return null;let o=e.roles,s=o.get("event"),u=s?.type==="literal"&&typeof s.value=="string"?s.value:null;if(!u)return null;let l=d=>d.replace(/\s+/g," ").trim(),c=Y(r,i).tokens;for(let d of n)for(let m=1;m<c.length;m++)for(let p=m;p<c.length;p++){let f=l(r.slice(c[m].position.start,c[p].position.end));if(f.length>d.length)break;if(f!==d)continue;let v=c[m-1];if((a[v.value]??v.normalized)!==u)break;let y=l(r.slice(v.position.start,c[p].position.end)),h=a[y];if(!h)break;return o.set("event",{type:"literal",value:h,dataType:"string"}),{node:B.withoutSpanDiagnostics(e,d),input:r}}return null}reclaimResponseTypeTail(e,r,i){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=B.AS_MARKERS_BEFORE[i];if(!a)return null;let o=l=>l.replace(/\s+/g," ").trim(),s=B.droppedTokenCount(e),u=Y(r,i).tokens;for(let l=0;l+1<u.length;l++){let c=u[l],d=u[l+1];if(!a.some(f=>c.value.toLowerCase()===f)||!B.RESPONSE_TYPE_WORDS.has(d.value.toLowerCase()))continue;let m=o(r.slice(c.position.start,d.position.end));if(!n.includes(m))continue;let p=(r.slice(0,c.position.start).trimEnd()+" "+r.slice(d.position.end).trimStart()).trim();if(!(!p||p===r))try{let f=this.parse(p,i);if(!f||f.kind!=="event-handler")continue;let v=Cr(f);if(B.droppedTokenCount(v)>=s)continue;let E=B.findResponseTypeTarget(v);if(!E)continue;return E.roles.set("responseType",{type:"expression",raw:d.value}),{node:v,input:p}}catch{}}return null}static findResponseTypeTarget(e){let r=null,i=n=>{if(!n||typeof n!="object"||r)return;if(n.kind==="command"){let o=n;if(te(o.action)?.roles.some(u=>u.role==="responseType"&&!u.required)&&!o.roles.has("responseType")){r=o;return}}let a=n;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let s=a[o];Array.isArray(s)&&s.forEach(u=>i(u));}};return i(e),r}reclaimCapturedDestinationTail(e,r,i){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=P(i)?.roleMarkers?.destination,o=new Set;if(a?.primary&&o.add(a.primary),a?.alternatives?.forEach(l=>o.add(l)),o.size===0)return null;let s=l=>l.replace(/\s+/g," ").trim(),u=Y(r,i).tokens;for(let l=0;l+1<u.length;l++){let c=u[l],d=u[l+1],m=o.has(c.value)&&d.normalized==="me",p=c.normalized==="me"&&o.has(d.value);if(!m&&!p)continue;let f=s(r.slice(c.position.start,d.position.end));if(!n.includes(f))continue;let 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(x=>E(x));}};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 n=e.mark(),a=e.peek();if(!a)break;if(!Br(a,r)){e.reset(n);break}e.advance();let o=e.peek();if(!o){e.reset(n);break}let s=(o.normalized||o.value).toLowerCase();e.advance(),i.push({type:"literal",value:s});}return i}};ee.coverageMarkerSurfaces=new Map;ee.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};ee.AS_MARKERS_BEFORE={en:["as"],es:["como"],fr:["comme"],pt:["como"],it:["come"],de:["als"],id:["sebagai"],ms:["sebagai","sbg"],sw:["kuwa","kama"],th:["\u0E40\u0E1B\u0E47\u0E19"],vi:["nh\u01B0"],tl:["bilang"],he:["\u05DB"],ar:["\u0643\u0640"],pl:["jako"],ru:["\u043A\u0430\u043A"],uk:["\u044F\u043A"],zh:["\u7684","\u4F5C\u4E3A","\u5F53\u4F5C"]};ee.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};ee.enEventKeywordCache=new Map;ee.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);ee.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);ee.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"]),hi:new Set(["\u092A\u0930"])};ee.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};ee.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])},hi:{markers:new Set(["\u0938\u0947"]),windowTokens:new Set(["\u0935\u093F\u0902\u0921\u094B","\u0926\u0938\u094D\u0924\u093E\u0935\u0947\u091C\u093C","window","document"])}};ee.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);ee.CONDITION_COPULAS_SURFACE=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948"]);ee.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);ee.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);ee.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};var Us=ee,Gs=new Us;function Ys(t,e){return Gs.parse(t,e)}function Zs(t,e){try{let r=Y(t,e),i=fe(e);if(i.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let n=[...i].sort((l,c)=>c.priority-l.priority),a=n.filter(l=>l.command==="on"),o=ue.matchBest(r,a);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let s=n.filter(l=>l.command!=="on"),u=ue.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 ti(t,e){try{let i=Ys(t,e);if(i)return {node:i,confidence:i.metadata?.confidence??.8,error:void 0,tokensConsumed:Y(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 ii(t,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...t].sort((i,n)=>{let a=i[r]??99,o=n[r]??99;return a-o})}function $e(t,e){let r,i;if(t.markerOverride&&t.markerOverride[e.code]!==void 0)r=t.markerOverride[e.code],i=r?he(t,e.code,r):void 0;else {let n=e.roleMarkers[t.role];if(n){r=n.primary;let a=he(t,e.code,r)??[],o=[...new Set([...n.alternatives??[],...a])].filter(s=>s!==r);i=o.length?o:void 0;}}return {marker:r,alternatives:i}}function er(t,e,r){r.roles.find(n=>n.role==="scope"&&!n.required)&&(t.push({type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}),e.scope={fromRole:"scope"});}function $r(t,e,r,i){ai(t,e,r,i,"manner",{requireMarker:true});}function ni(t,e,r,i){ai(t,e,r,i,"recipient",{requireMarker:false});}function ai(t,e,r,i,n,a){let o=r.roles.find(u=>u.role===n&&!u.required);if(!o)return;let s=o.markerOverride?.[i];a.requireMarker&&!s||(t.push({type:"group",optional:true,tokens:[...(s?s.split(/\s+/):[]).map(u=>({type:"literal",value:u})),{type:"role",role:n,optional:true,expectedTypes:o.expectedTypes,...o.valueShape!==void 0?{valueShape:o.valueShape}:{}}]}),e[n]={fromRole:n});}function oi(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 si(t,e,r){let i=t.roles.find(c=>c.role===r);if(!i||r==="patient")return [{type:"role",role:r,optional:false}];let{marker:n,alternatives:a}=$e(i,e),o={type:"role",role:r,optional:false,...i.valueShape!==void 0?{valueShape:i.valueShape}:{}};if(!n)return [o];let s=n.split(/\s+/).filter(Boolean),u={type:"group",optional:true,tokens:s.map(c=>({type:"literal",value:c,...s.length===1&&a?.length?{alternatives:a}:{}}))};return (e.roleMarkers[r]?.position??"before")==="after"?[o,u]:[u,o]}function ui(t,e,r,i,n){for(let a of r.roles)a.required||n.has(a.role)||e[a.role]||!(a.markerOverride?.[i.code]??i.roleMarkers[a.role]?.primary)&&a.valueShape===void 0||(t.push({type:"group",optional:true,tokens:di(a,i)}),e[a.role]=a.default?{fromRole:a.role,default:a.default}:{fromRole:a.role});}function Xs(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let f=i.primary.split(/\s+/);if(f.length>1)for(let v of f)a.push({type:"literal",value:v});else {let v=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(v);}}let o=oi(t),s=e.roleMarkers.destination,u=t.roles.some(f=>f.role==="destination");s&&u&&o!=="destination"&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]});let l=e.roleMarkers.source,c=t.roles.some(f=>f.role==="source");l&&c&&o!=="source"&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"source",optional:true},l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary}]}),a.push(...si(t,e,o));let d=e.roleMarkers.patient;if(d&&o==="patient"){let f=d.alternatives?{type:"literal",value:d.primary,alternatives:d.alternatives}:{type:"literal",value:d.primary};a.push(f);}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(m),o!=="source"&&a.push(...Fe(t,e.roleMarkers.source)),o!=="destination"&&a.push(...Rr(t,e.roleMarkers.destination));let p={action:{value:t.action},event:{fromRole:"event"},[o]:{fromRole:o},...o==="destination"?{}:Be(t),...o==="source"?{}:Te(t)};return ui(a,p,t,e,new Set(["event",o,"destination","source"])),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`{event} ${i.primary} {destination?} {${o}} ${d?.primary||""} ${r.primary}`,tokens:a},extraction:p}}function Js(t,e,r,i,n){let a=[],o=t.action==="swap",s=o?"destination":"patient";a.push({type:"role",role:s,optional:false});let u=e.roleMarkers.patient;if(u){let m=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(m);}if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let p of m)a.push({type:"literal",value:p});else {let p=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(p);}}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(l),a.push(...Fe(t,e.roleMarkers.source));let c=e.roleMarkers.destination;if(o&&c){let m=t.roles.find(p=>p.role==="patient")?.markerOverride?.[e.code];if(m&&m!==c.primary){let p=c.alternatives??[];p.includes(m)||(c={...c,alternatives:[...p,m]});}}a.push(...o?wn(t,c):Rr(t,c));let d={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...o?{}:Be(t),...Te(t)};return ni(a,d,t,e.code),$r(a,d,t,e.code),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`{patient} ${u?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:d}}function Qs(t,e,r,i,n){let a=t.roles.find(d=>d.role==="source");if(!a)return null;let{marker:o,alternatives:s}=$e(a,e),u=e.roleMarkers.patient;if(!o||o===i.primary||o===u?.primary)return null;let l=[];l.push({type:"role",role:"patient",optional:false}),u&&l.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}),l.push({type:"role",role:"source",optional:false,...a.expectedTypes?{expectedTypes:a.expectedTypes}:{},...a.valueShape!==void 0?{valueShape:a.valueShape}:{}});for(let d of o.split(/\s+/))l.push(s&&o.split(/\s+/).length===1?{type:"literal",value:d,alternatives:s}:{type:"literal",value:d});if(l.push({type:"role",role:"event",optional:false}),i.position==="after"){let d=i.primary.split(/\s+/);if(d.length>1)for(let m of d)l.push({type:"literal",value:m});else l.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}l.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary});let c={action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},source:{fromRole:"source"}};return ni(l,c,t,e.code),$r(l,c,t,e.code),{id:`${t.action}-event-${e.code}-sov-source-fronted`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{patient} ${u?.primary||""} {source} ${o} {event} ${i.primary} ${r.primary}`,tokens:l},extraction:c}}function eu(t,e,r,i,n){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}let s=e.roleMarkers.destination;if(s&&(a.push({type:"role",role:"destination",optional:false}),a.push(s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary})),a.push({type:"role",role:"event",optional:false}),i.position==="after"){let l=i.primary.split(/\s+/);if(l.length>1)for(let c of l)a.push({type:"literal",value:c});else {let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(u),{id:`${t.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${s?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function ru(t,e,r,i,n){let a=[];a.push({type:"role",role:"event",optional:false});let o=i.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&a.push({type:"literal",value:o[0],alternatives:o.slice(1)});let s=e.roleMarkers.destination;s&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let c=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(l),a.push(...Fe(t,e.roleMarkers.source)),a.push(...Rr(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(n.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Be(t),...Te(t)}}}function tu(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let s=i.primary.split(/\s+/);if(s.length>1)for(let u of s)a.push({type:"literal",value:u});else {let u=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(u);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(o),{id:`${t.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function iu(t,e,r,i){let n=e.eventHandler?.temporalMarkers;if(!n||n.length===0)return null;let a=[];a.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),a.push({type:"literal",value:n[0],alternatives:n.slice(1)}),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let u=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(u);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),{id:`${t.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(i.basePriority??100)+49,template:{format:`{event} ${n[0]} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function nu(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let d=i.primary.split(/\s+/);if(d.length>1)for(let m of d)a.push({type:"literal",value:m});else {let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(m);}}let s=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.sovPosition??999,f=m.sovPosition??999;return p-f});for(let d of s){a.push({type:"role",role:d.role,optional:false});let{marker:m,alternatives:p}=$e(d,e);if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u);let l=s.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(d=>[d.role,{fromRole:d.role}]))};return er(a,c,t),{id:`${t.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`{event} ${i.primary} ${l} ${r.primary}`,tokens:a},extraction:c}}function au(t,e,r,i,n){let a=[],s=[...t.roles.filter(c=>c.required)].sort((c,d)=>{let m=c.sovPosition??999,p=d.sovPosition??999;return m-p});for(let c of s){a.push({type:"role",role:c.role,optional:false});let{marker:d,alternatives:m}=$e(c,e);d&&a.push(m?{type:"literal",value:d,alternatives:m}:{type:"literal",value:d});}if(a.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),a.push({type:"role",role:"event",optional:false}),i.position==="after"){let c=i.primary.split(/\s+/);if(c.length>1)for(let d of c)a.push({type:"literal",value:d});else a.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}let u=s.map(c=>`{${c.role}}`).join(" "),l={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))};return er(a,l,t),{id:`${t.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`${u} ${r.primary} {event} ${i.primary}`,tokens:a},extraction:l}}function ou(t,e,r,i,n){let a=[],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];a.push({type:"role",role:u.role,optional:false});let{marker:l,alternatives:c}=$e(u,e);if(l){let E=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};a.push(E);}if(a.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)a.push({type:"literal",value:y});else {let y=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(y);}}let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(d);let m=s[1];a.push({type:"role",role:m.role,optional:false});let{marker:p,alternatives:f}=$e(m,e);if(p){let E=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};a.push(E);}let v={action:{value:t.action},event:{fromRole:"event"},[u.role]:{fromRole:u.role},[m.role]:{fromRole:m.role}};return er(a,v,t),{id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{${u.role}} {event} ${i.primary} ${r.primary} {${m.role}}`,tokens:a},extraction:v}}function li(t,e,r){let i=he(t,e.code,r.primary)??[],n=[...new Set([...r.alternatives??[],...i])].filter(a=>a!==r.primary);return n.length?n:void 0}function wt(t,e,r,i,n){let a=[];if(i.position==="before"){let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=oi(t);a.push(...si(t,e,s));let u=e.roleMarkers.destination,l=t.roles.some(d=>d.role==="destination");u&&l&&s!=="destination"&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),s!=="source"&&a.push(...Fe(t,e.roleMarkers.source));let c={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...s==="destination"?{}:Be(t),...s==="source"?{}:Te(t)};return ui(a,c,t,e,new Set(["event",s,"destination","source"])),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`${i.primary} {event} ${r.primary} {${s}} ${u?.primary||""} {destination?}`,tokens:a},extraction:c}}function su(t,e,r,i,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=t.action==="swap";a.push({type:"role",role:s?"destination":"patient",optional:false});let u=s?void 0:e.roleMarkers.destination;if(u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...Fe(t,e.roleMarkers.source)),i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}if(a.push({type:"role",role:"event",optional:false}),s){let c=t.roles.find(d=>d.role==="patient")?.markerOverride?.[e.code];c&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:c},{type:"role",role:"patient",optional:false}]});}let l={action:{value:t.action},event:{fromRole:"event"},[s?"destination":"patient"]:{fromRole:s?"destination":"patient"},...s?{}:Be(t),...Te(t)};return $r(a,l,t,e.code),{id:`${t.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${i.primary} {event}`,tokens:a},extraction:l}}function uu(t,e,r,i,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.svoPosition??999,f=m.svoPosition??999;return p-f});for(let d of u){let m,p;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)m=d.markerOverride[e.code],p=m?he(d,e.code,m):void 0;else {let f=e.roleMarkers[d.role];f&&(m=f.primary,p=li(d,e,f));}if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}a.push({type:"role",role:d.role,optional:false});}if(i.position==="before"){let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let l=u.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(d=>[d.role,{fromRole:d.role}]))};return er(a,c,t),{id:`${t.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${r.primary} ${l} ${i.primary} {event}`,tokens:a},extraction:c}}function bt(t,e,r,i,n){let a=[];if(i.position==="before"){let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.svoPosition??999,f=m.svoPosition??999;return p-f});for(let d of u){let m,p;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)m=d.markerOverride[e.code],p=m?he(d,e.code,m):void 0;else {let f=e.roleMarkers[d.role];f&&(m=f.primary,p=li(d,e,f));}if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}a.push({type:"role",role:d.role,optional:false});}let l=u.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(d=>[d.role,{fromRole:d.role}]))};return er(a,c,t),{id:`${t.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`${i.primary} {event} ${r.primary} ${l}`,tokens:a},extraction:c}}function lu(t,e,r,i,n){let a=[],o=e.eventHandler?.negationMarker;if(i.position==="before"){let l=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}a.push({type:"role",role:"event",optional:false});let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(s),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...Fe(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${i.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Be(t),...Te(t)}}}function cu(t,e,r,i){let n=[];n.push({type:"literal",value:"and",alternatives:["then"]}),n.push({type:"role",role:"event",optional:false});let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(a),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&n.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),n.push(...Fe(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Be(t),...Te(t)}}}var We={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Je(t,e,r=We){let i=`${t.action}-${e.code}-generated`,n=r.basePriority??100,a=e.keywords[t.action];if(!a)throw new Error(`No keyword translation for '${t.action}' in ${e.code}`);let o=fu(t,e,a),s=Vr(t,e),u=Eu(t,e,a);return {id:i,language:e.code,command:t.action,priority:n,template:{format:u,tokens:o},extraction:s}}function du(t,e,r=We){if(t.roles.filter(s=>!s.required).length===0)return null;let n=t.roles.filter(s=>s.required),a={...t,roles:n};return {...Je(a,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:Vr(t,e)}}function Ct(t,e,r=We){if(e.wordOrder!=="SOV")return null;let i=t.roles.filter(s=>s.required);if(i.length!==1)return null;let n=e.keywords[t.action];if(!n)return null;let a=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary},o=i.flatMap(s=>{let u=s.valuePrefixLiteral?.[e.code],l={type:"role",role:s.role,optional:false,expectedTypes:s.expectedTypes};return u?[{type:"literal",value:u},l]:[l]});return {id:`${t.action}-${e.code}-generated-verb-first`,language:e.code,command:t.action,priority:(r.basePriority??100)-20,template:{format:`${n.primary} <${i[0].role}>`,tokens:[a,...o]},extraction:Vr(t,e)}}function mu(t,e,r=We){let i=[];if(i.push(Je(t,e,r)),r.generateSimpleVariants){let n=du(t,e,r);n&&i.push(n);}for(let n of t.omitRoleVariants??[]){let a={...t,roles:t.roles.filter(s=>s.role!==n)},o=Je(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-no-${n}`,priority:(r.basePriority??100)-8});}for(let n of t.widenTypeVariants??[]){if(n.excludeLanguages?.includes(e.code))continue;let a={...t,roles:t.roles.map(s=>s.role===n.role?{...s,expectedTypes:[...n.types]}:s)},o=Je(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)-(n.priorityDelta??15)});}if(r.generateVerbFirstVariants!==false){let n=Ct(t,e,r);n&&i.push(n);}for(let n of t.rolePrefixLiteralVariants??[]){let a=n.literal[e.code];if(!a)continue;let{rolePrefixLiteralVariants:o,...s}=t,u={...s,roles:t.roles.map(m=>m.role===n.role?{...m,valuePrefixLiteral:{[e.code]:a}}:m)},l=n.priorityDelta??5,c=n.methodCarrier?{[n.methodCarrier]:{value:a}}:{},d=Je(u,e,r);if(i.push({...d,id:`${t.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)+l,extraction:{...d.extraction,...c}}),r.generateVerbFirstVariants!==false){let m=Ct(u,e,r);m&&i.push({...m,id:`${t.action}-${e.code}-generated-verb-first-${n.idSuffix}`,priority:(r.basePriority??100)-20+l,extraction:{...m.extraction,...c}});}}return i}function ci(t,e=We){let r=[],i=$a();for(let n of i){if(!t.keywords[n.action])continue;let a=mu(n,t,e);if(r.push(...a),t.eventHandler?.eventMarker){let o=pu(n,t,e);r.push(...o);}}return r}function pu(t,e,r=We){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let i=[],n=e.eventHandler.eventMarker,a=e.keywords[t.action];if(!a)return [];if(t.roles.length===0)return [];if(t.action==="js")return [];let s=t.roles.filter(u=>u.required).length===2;if(e.wordOrder==="SOV")if(s)i.push(nu(t,e,a,n,r)),i.push(ou(t,e,a,n,r)),i.push(au(t,e,a,n,r));else {i.push(Xs(t,e,a,n,r)),i.push(Js(t,e,a,n,r));let u=Qs(t,e,a,n,r);u&&i.push(u);let l=e.roleMarkers.destination;l&&l.primary!==n.primary&&i.push(eu(t,e,a,n,r));let c=n.primary.split(/\s+/),d=n.alternatives?.some(p=>!p.includes(" ")&&p.length>1);c.length>1&&d&&i.push(ru(t,e,a,n,r)),i.push(tu(t,e,a,n,r));let m=iu(t,e,a,r);m&&i.push(m);}else e.wordOrder==="VSO"?s?(i.push(bt(t,e,a,n,r)),i.push(uu(t,e,a,n,r))):(i.push(wt(t,e,a,n,r)),i.push(su(t,e,a,n,r)),e.eventHandler?.negationMarker&&i.push(lu(t,e,a,n,r)),e.tokenization?.prefixes&&i.push(cu(t,e,a,r))):s?i.push(bt(t,e,a,n,r)):i.push(wt(t,e,a,n,r));return i}function fu(t,e,r){let i=[],n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=hu(t,e);switch(e.wordOrder){case "SVO":i.push(n),i.push(...a);break;case "SOV":i.push(...a),i.push(n);break;case "VSO":i.push(n),i.push(...a);break;default:i.push(n),i.push(...a);}return 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 n=[...i.alternatives??[],...r.alternatives??[]];n.length&&(e[e.length-1]={...i,alternatives:[...new Set(n)]});continue}e.push(r);}return e}function hu(t,e){let r=[],i=ii(t.roles,e.wordOrder);for(let n of i){let a=di(n,e);n.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function di(t,e){let r=[],i=t.markerOverride?.[e.code],n=e.roleMarkers[t.role],a=t.renderOverride?.[e.code]==="",o={type:"role",role:t.role,optional:!t.required,expectedTypes:t.expectedTypes,...t.valueShape!==void 0?{valueShape:t.valueShape}:{}},s=t.valuePrefixLiteral?.[e.code],u=()=>{s&&r.push({type:"literal",value:s}),r.push(o);};if(i!==void 0){let l=i?i.split(/\s+/).filter(Boolean):[],c=i!==void 0&&i===t.markerOverride?.en,d=n?.position??(e.wordOrder==="SOV"&&!c?"after":"before"),m=t.markerOptional?.[e.code]===true,p=f=>{let v=l.length===1?he(t,e.code,f)??[]:[],E={type:"literal",value:f,...v.length?{alternatives:v}:{},...a?{renderSuppress:true}:{}};r.push(m?{type:"group",optional:true,tokens:[E]}:E);};if(d==="before"){for(let f of l)p(f);u();}else {u();for(let f of l)p(f);}}else if(n){let l=()=>{let d=[...new Set([...n.alternatives??[],...he(t,e.code,n.primary)??[]])].filter(m=>m!==n.primary);return {type:"literal",value:n.primary,...d.length?{alternatives:d}:{},...a?{renderSuppress:true}:{}}},c=d=>{if(!e.markersOptional&&!t.markerOptional?.[e.code]){r.push(d);return}r.push({type:"group",optional:true,...e.markersOptional&&!t.markerOptional?.[e.code]?{renderRequired:true}:{},tokens:[d]});};n.position==="before"?(n.primary&&c(l()),u()):(u(),c(l()));}else u();return r}function vu(t,e){let r={};for(let i of t.roles){let n=i.markerOverride?.[e.code],a=e.roleMarkers[i.role];if(i.valuePrefixLiteral?.[e.code])r[i.role]={marker:i.valuePrefixLiteral[e.code]};else if(n!==void 0)if(!n)r[i.role]={};else {let s=!/\s/.test(n.trim())?he(i,e.code,n)??[]:[];r[i.role]=s.length?{marker:n,markerAlternatives:s}:{marker:n};}else if(a&&a.primary){let o=[...new Set([...a.alternatives??[],...he(i,e.code,a.primary)??[]])].filter(s=>s!==a.primary);r[i.role]=o.length?{marker:a.primary,markerAlternatives:o}:{marker:a.primary};}else r[i.role]={};}return r}function Vr(t,e){let r=vu(t,e),i={};for(let n of t.roles){let a=r[n.role]||{};!n.required&&n.default?i[n.role]={...a,default:n.default}:i[n.role]=a;}return i}function Eu(t,e,r){let i=[],a=ii(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,...a);break;case "SOV":i.push(...a,r.primary);break;default:i.push(r.primary,...a);}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),n=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(i,{result:r,createdAt:n,lastAccessed:n});}has(t,e){if(!this.config.enabled)return false;let r=this.makeKey(t,e),i=this.cache.get(r);return i?this.isExpired(i)?(this.cache.delete(r),this.stats.expirations++,false):true:false}delete(t,e){let r=this.makeKey(t,e);return this.cache.delete(r)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let t=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:t>0?this.stats.hits/t:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(t){if(t.maxSize!==void 0)for(this.config.maxSize=t.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();t.ttlMs!==void 0&&(this.config.ttlMs=t.ttlMs),t.enabled!==void 0&&(this.config.enabled=t.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}};new gu;function zu(t){return /[\u00e1\u00e9\u00ed\u00f3\u00fa\u00fc\u00f1\u00c1\u00c9\u00cd\u00d3\u00da\u00dc\u00d1]/.test(t)}var ku=[{ending:"ando",stem:"ar",confidence:.88,type:"gerund"},{ending:"ado",stem:"ar",confidence:.88,type:"participle"},{ending:"ada",stem:"ar",confidence:.88,type:"participle"},{ending:"ados",stem:"ar",confidence:.88,type:"participle"},{ending:"adas",stem:"ar",confidence:.88,type:"participle"},{ending:"o",stem:"ar",confidence:.75,type:"present"},{ending:"as",stem:"ar",confidence:.82,type:"present"},{ending:"a",stem:"ar",confidence:.75,type:"present"},{ending:"amos",stem:"ar",confidence:.85,type:"present"},{ending:"\xE1is",stem:"ar",confidence:.85,type:"present"},{ending:"ais",stem:"ar",confidence:.82,type:"present"},{ending:"an",stem:"ar",confidence:.8,type:"present"},{ending:"\xE9",stem:"ar",confidence:.85,type:"past"},{ending:"aste",stem:"ar",confidence:.88,type:"past"},{ending:"\xF3",stem:"ar",confidence:.82,type:"past"},{ending:"amos",stem:"ar",confidence:.85,type:"past"},{ending:"asteis",stem:"ar",confidence:.88,type:"past"},{ending:"aron",stem:"ar",confidence:.88,type:"past"},{ending:"aba",stem:"ar",confidence:.88,type:"past"},{ending:"abas",stem:"ar",confidence:.88,type:"past"},{ending:"\xE1bamos",stem:"ar",confidence:.88,type:"past"},{ending:"abamos",stem:"ar",confidence:.85,type:"past"},{ending:"abais",stem:"ar",confidence:.88,type:"past"},{ending:"aban",stem:"ar",confidence:.88,type:"past"},{ending:"e",stem:"ar",confidence:.72,type:"subjunctive"},{ending:"es",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"emos",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"\xE9is",stem:"ar",confidence:.85,type:"subjunctive"},{ending:"eis",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"en",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"a",stem:"ar",confidence:.75,type:"imperative"},{ending:"ad",stem:"ar",confidence:.85,type:"imperative"},{ending:"ar",stem:"ar",confidence:.92,type:"dictionary"}],wu=[{ending:"iendo",stem:"er",confidence:.88,type:"gerund"},{ending:"ido",stem:"er",confidence:.85,type:"participle"},{ending:"ida",stem:"er",confidence:.85,type:"participle"},{ending:"idos",stem:"er",confidence:.85,type:"participle"},{ending:"idas",stem:"er",confidence:.85,type:"participle"},{ending:"o",stem:"er",confidence:.72,type:"present"},{ending:"es",stem:"er",confidence:.78,type:"present"},{ending:"e",stem:"er",confidence:.72,type:"present"},{ending:"emos",stem:"er",confidence:.85,type:"present"},{ending:"\xE9is",stem:"er",confidence:.85,type:"present"},{ending:"eis",stem:"er",confidence:.82,type:"present"},{ending:"en",stem:"er",confidence:.78,type:"present"},{ending:"\xED",stem:"er",confidence:.85,type:"past"},{ending:"iste",stem:"er",confidence:.88,type:"past"},{ending:"i\xF3",stem:"er",confidence:.85,type:"past"},{ending:"io",stem:"er",confidence:.82,type:"past"},{ending:"imos",stem:"er",confidence:.85,type:"past"},{ending:"isteis",stem:"er",confidence:.88,type:"past"},{ending:"ieron",stem:"er",confidence:.88,type:"past"},{ending:"\xEDa",stem:"er",confidence:.88,type:"past"},{ending:"ia",stem:"er",confidence:.85,type:"past"},{ending:"\xEDas",stem:"er",confidence:.88,type:"past"},{ending:"ias",stem:"er",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"er",confidence:.88,type:"past"},{ending:"iamos",stem:"er",confidence:.85,type:"past"},{ending:"\xEDais",stem:"er",confidence:.88,type:"past"},{ending:"iais",stem:"er",confidence:.85,type:"past"},{ending:"\xEDan",stem:"er",confidence:.88,type:"past"},{ending:"ian",stem:"er",confidence:.85,type:"past"},{ending:"er",stem:"er",confidence:.92,type:"dictionary"}],bu=[{ending:"iendo",stem:"ir",confidence:.88,type:"gerund"},{ending:"ido",stem:"ir",confidence:.85,type:"participle"},{ending:"ida",stem:"ir",confidence:.85,type:"participle"},{ending:"idos",stem:"ir",confidence:.85,type:"participle"},{ending:"idas",stem:"ir",confidence:.85,type:"participle"},{ending:"o",stem:"ir",confidence:.72,type:"present"},{ending:"es",stem:"ir",confidence:.78,type:"present"},{ending:"e",stem:"ir",confidence:.72,type:"present"},{ending:"imos",stem:"ir",confidence:.85,type:"present"},{ending:"\xEDs",stem:"ir",confidence:.85,type:"present"},{ending:"is",stem:"ir",confidence:.82,type:"present"},{ending:"en",stem:"ir",confidence:.78,type:"present"},{ending:"\xED",stem:"ir",confidence:.85,type:"past"},{ending:"iste",stem:"ir",confidence:.88,type:"past"},{ending:"i\xF3",stem:"ir",confidence:.85,type:"past"},{ending:"io",stem:"ir",confidence:.82,type:"past"},{ending:"imos",stem:"ir",confidence:.85,type:"past"},{ending:"isteis",stem:"ir",confidence:.88,type:"past"},{ending:"ieron",stem:"ir",confidence:.88,type:"past"},{ending:"\xEDa",stem:"ir",confidence:.88,type:"past"},{ending:"ia",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDas",stem:"ir",confidence:.88,type:"past"},{ending:"ias",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"ir",confidence:.88,type:"past"},{ending:"iamos",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDais",stem:"ir",confidence:.88,type:"past"},{ending:"iais",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDan",stem:"ir",confidence:.88,type:"past"},{ending:"ian",stem:"ir",confidence:.85,type:"past"},{ending:"ir",stem:"ir",confidence:.92,type:"dictionary"}],Cu=[...ku,...wu,...bu].sort((t,e)=>e.ending.length-t.ending.length),fi=class extends it{constructor(){super({language:"es",minWordLength:3,minStemLength:2,endings:Cu,reflexiveSuffixes:["se","me","te","nos","os"],infinitiveEndings:["ar","er","ir"]});}isNormalizable(t){if(t.length<3)return false;let e=t.toLowerCase();if(e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir")||e.endsWith("ando")||e.endsWith("iendo")||e.endsWith("ado")||e.endsWith("ido")||e.endsWith("arse")||e.endsWith("erse")||e.endsWith("irse"))return true;for(let r of t)if(zu(r))return true;return false}};new fi;var yi={code:"es",name:"Spanish",nativeName:"Espa\xF1ol",regions:["western","priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:true},references:{me:"yo",it:"ello",you:"t\xFA",result:"resultado",event:"evento",target:"objetivo",body:"cuerpo",document:"documento",window:"ventana",detail:"detalle"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"mi",it:"su",you:"tu"},keywords:{mi:"me",tu:"you",su:"it"}},roleMarkers:{destination:{primary:"en",alternatives:["sobre","a","hacia"],position:"before"},source:{primary:"de",alternatives:["desde"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"con",position:"before"}},keywords:{toggle:{primary:"alternar",alternatives:["conmutar","toggle"],normalized:"toggle"},add:{primary:"agregar",alternatives:["a\xF1adir"],normalized:"add"},remove:{primary:"quitar",alternatives:["eliminar","remover","sacar","borrar"],normalized:"remove"},put:{primary:"poner",alternatives:["colocar","pon"],normalized:"put"},append:{primary:"anexar",normalized:"append"},prepend:{primary:"anteponer",normalized:"prepend"},take:{primary:"tomar",normalized:"take"},make:{primary:"hacer",alternatives:["crear"],normalized:"make"},clone:{primary:"clonar",alternatives:["duplicar"],normalized:"clone"},swap:{primary:"intercambiar",alternatives:["permutar"],normalized:"swap"},morph:{primary:"transformar",alternatives:["convertir"],normalized:"morph"},set:{primary:"establecer",alternatives:["fijar","definir","establece"],normalized:"set"},get:{primary:"obtener",alternatives:["conseguir","obt\xE9n"],normalized:"get"},increment:{primary:"incrementar",alternatives:["aumentar"],normalized:"increment"},decrement:{primary:"decrementar",alternatives:["disminuir"],normalized:"decrement"},log:{primary:"registrar",alternatives:["imprimir"],normalized:"log"},show:{primary:"mostrar",alternatives:["ense\xF1ar","muestra"],normalized:"show"},hide:{primary:"ocultar",alternatives:["esconder"],normalized:"hide"},transition:{primary:"transici\xF3n",alternatives:["animar"],normalized:"transition"},on:{primary:"en",alternatives:["al"],normalized:"on"},trigger:{primary:"disparar",alternatives:["activar"],normalized:"trigger"},send:{primary:"enviar",alternatives:["env\xEDa"],normalized:"send"},focus:{primary:"enfoque",alternatives:["enfocar"],normalized:"focus"},blur:{primary:"p\xE9rdida de foco",alternatives:["perdida de foco","desenfoque","desenfocar"],normalized:"blur"},open:{primary:"abrir",normalized:"open"},close:{primary:"cerrar",normalized:"close"},select:{primary:"seleccionar",normalized:"select"},clear:{primary:"limpiar",normalized:"clear"},reset:{primary:"reiniciar",alternatives:["restablecer"],normalized:"reset"},breakpoint:{primary:"punto-interrupci\xF3n",alternatives:["punto-interrupcion"],normalized:"breakpoint"},click:{primary:"clic",alternatives:["hacer clic","click"],normalized:"click"},resize:{primary:"cambio de tama\xF1o",alternatives:["cambio de tamano","redimensionar"],normalized:"resize"},hover:{primary:"sobrevolar",alternatives:["pasar por encima"],normalized:"hover"},submit:{primary:"env\xEDo",alternatives:["envio","someter"],normalized:"submit"},input:{primary:"entrada",alternatives:["introducir"],normalized:"input"},change:{primary:"cambio",alternatives:["cambiar"],normalized:"change"},load:{primary:"carga",alternatives:["cargar"],normalized:"load"},scroll:{primary:"desplazamiento",alternatives:["desplazar"],normalized:"scroll"},keydown:{primary:"tecla pulsada",alternatives:["tecla presionada","tecla abajo"],normalized:"keydown"},keyup:{primary:"tecla soltada",alternatives:["tecla liberada","tecla arriba"],normalized:"keyup"},mouseover:{primary:"rat\xF3n encima",alternatives:["raton encima","mouse encima"],normalized:"mouseover"},mouseout:{primary:"rat\xF3n fuera",alternatives:["raton fuera","mouse fuera"],normalized:"mouseout"},mousedown:{primary:"rat\xF3n pulsado",alternatives:["raton pulsado","mouse presionado","rat\xF3n abajo","raton abajo","rat\xF3nabajo"],normalized:"mousedown"},mouseup:{primary:"rat\xF3n soltado",alternatives:["raton soltado","mouse soltado","rat\xF3n arriba","raton arriba","rat\xF3narriba"],normalized:"mouseup"},go:{primary:"ir",alternatives:["navegar","ve"],normalized:"go"},push:{primary:"empujar",alternatives:["push"],normalized:"push"},replace:{primary:"reemplazar",alternatives:["sustituir"],normalized:"replace"},process:{primary:"procesar",normalized:"process"},wait:{primary:"esperar",normalized:"wait"},fetch:{primary:"buscar",alternatives:["recuperar"],normalized:"fetch"},settle:{primary:"estabilizar",normalized:"settle"},if:{primary:"si",normalized:"if"},unless:{primary:"menos",alternatives:["a menos que","salvo"],normalized:"unless"},when:{primary:"cuando",normalized:"when"},changes:{primary:"cambia",normalized:"changes"},where:{primary:"donde",normalized:"where"},else:{primary:"sino",alternatives:["de lo contrario"],normalized:"else"},repeat:{primary:"repetir",normalized:"repeat"},for:{primary:"para",normalized:"for"},while:{primary:"mientras",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"continuar",normalized:"continue"},halt:{primary:"detener",alternatives:["parar"],normalized:"halt"},throw:{primary:"lanzar",alternatives:["arrojar"],normalized:"throw"},call:{primary:"llamar",normalized:"call"},return:{primary:"retornar",alternatives:["devolver"],normalized:"return"},then:{primary:"entonces",alternatives:["luego"],normalized:"then"},and:{primary:"y",alternatives:["adem\xE1s","tambi\xE9n"],normalized:"and"},or:{primary:"o",normalized:"or"},not:{primary:"no",normalized:"not"},is:{primary:"es",normalized:"is"},exists:{primary:"existe",normalized:"exists"},empty:{primary:"vac\xEDo",alternatives:["vacio"],normalized:"empty"},matches:{primary:"coincide",normalized:"matches"},no:{primary:"ning\xFAn",normalized:"no"},end:{primary:"fin",alternatives:["final","terminar"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"as\xEDncrono",alternatives:["asincrono"],normalized:"async"},tell:{primary:"decir",normalized:"tell"},default:{primary:"predeterminar",alternatives:["por defecto"],normalized:"default"},init:{primary:"inicio",alternatives:["inicializaci\xF3n","iniciar","inicializar"],normalized:"init"},behavior:{primary:"comportamiento",normalized:"behavior"},install:{primary:"instalar",normalized:"install"},measure:{primary:"medir",normalized:"measure"},beep:{primary:"pitido",normalized:"beep"},break:{primary:"romper",normalized:"break"},copy:{primary:"copiar",normalized:"copy"},exit:{primary:"salir",normalized:"exit"},pick:{primary:"escoger",normalized:"pick"},render:{primary:"renderizar",normalized:"render"},first:{primary:"primero",alternatives:["primera"],normalized:"first"},last:{primary:"\xFAltimo",alternatives:["ultima"],normalized:"last"},next:{primary:"siguiente",normalized:"next"},previous:{primary:"anterior",normalized:"previous"},closest:{primary:"cercano",normalized:"closest"},parent:{primary:"padre",normalized:"parent"},into:{primary:"dentro",alternatives:["adentro","dentro de"],normalized:"into"},before:{primary:"antes",alternatives:["antes de"],normalized:"before"},after:{primary:"despu\xE9s",alternatives:["despues","despu\xE9s de","despues de"],normalized:"after"},out:{primary:"fuera",alternatives:["fuera de"],normalized:"out"},until:{primary:"hasta",alternatives:["hasta que"],normalized:"until"},event:{primary:"evento",normalized:"event"},from:{primary:"de",alternatives:["desde"],normalized:"from"},connect:{primary:"conectar",alternatives:["conectarse"],normalized:"connect"},stream:{primary:"transmitir",alternatives:["flujo"],normalized:"stream"},live:{primary:"en-vivo",alternatives:["vivo","directo"],normalized:"live"},socket:{primary:"socket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"vincular",alternatives:["enlazar","bind"],normalized:"bind"},intercept:{primary:"interceptar",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"trabajador",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["fuente-de-eventos"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"al",alternatives:["cuando","en"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["desde"],position:"before"},eventMarker:{primary:"al",alternatives:["cuando","en"],position:"before"},temporalMarkers:["cuando","al"]}},Au=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],xu=class{constructor(t=Au){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}},Su="()[]{},:;",Du=class{constructor(t=Su){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 n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function mi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Wr(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Wr(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Wr(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var Bu=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?mi(t,e)!==null:false}extract(t,e){let r=mi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Tu=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},Fu=["http://","https://","//","./","../","/"];function Ru(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function Ou(t,e){let r=t.slice(e),i=Fu.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=Ru(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var Pu=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=Ou(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Nu=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 Lu(){return [new Pu,new Tu,new Nu,new Bu]}function Mu(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:pi,isIdentifierChar:_u}=Mu(/[a-zA-Z\u00e1\u00e9\u00ed\u00f3\u00fa\u00fc\u00f1\u00c1\u00c9\u00cd\u00d3\u00da\u00dc\u00d1]/),Iu=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),ju=class{constructor(){this.name="spanish-keyword";}setContext(t){this.context=t;}canExtract(t,e){return pi(t[e])}extract(t,e){if(!this.context)throw new Error("SpanishKeywordExtractor: context not set");let r=this.tryMultiWordPhrase(t,e);return r||this.extractSpanishWord(t,e)}tryMultiWordPhrase(t,e){if(!this.context)return null;let r=["de lo contrario","de lo normal","por defecto","de nuevo","de otra manera"];for(let i of r)if(t.slice(e,e+i.length).toLowerCase()===i.toLowerCase()){let a=e+i.length;if(a>=t.length||Ae(t[a])||!pi(t[a])){let o=this.context.lookupKeyword(i);return {value:t.slice(e,a),length:i.length,metadata:{normalized:o?.normalized,multiWord:true}}}}return null}extractSpanishWord(t,e){if(!this.context)return null;let r=e,i="";for(;r<t.length&&_u(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=Iu.has(n),o=this.context.lookupKeyword(i),s=o&&o.normalized!==o.native?o.normalized:void 0,u,l,c;if(!o&&this.context.normalizer){let d=this.context.normalizer.normalize(i);if(d.stem!==i&&d.confidence>=.7){let m=this.context.lookupKeyword(d.stem);m&&(u=m.normalized,l=d.stem,c=d.confidence);}}return {value:i,length:r-e,metadata:{normalized:s||u,stem:l,stemConfidence:c,isPreposition:a}}}};function $u(){return [new ju]}var Vu=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),Wu=[{native:"verdadero",normalized:"true"},{native:"falso",normalized:"false"},{native:"nulo",normalized:"null"},{native:"indefinido",normalized:"undefined"},{native:"segundo",normalized:"s"},{native:"segundos",normalized:"s"},{native:"milisegundo",normalized:"ms"},{native:"milisegundos",normalized:"ms"},{native:"minuto",normalized:"m"},{native:"minutos",normalized:"m"},{native:"hora",normalized:"h"},{native:"horas",normalized:"h"},{native:"m\xED",normalized:"me"},{native:"destino",normalized:"target"},{native:"inclusivo",normalized:"inclusive"},{native:"exclusivo",normalized:"exclusive"},{native:"caracteres",normalized:"characters"},{native:"aleatorio",normalized:"random"}],qu=class extends ze{constructor(){super(),this.language="es",this.direction="ltr",this.initializeKeywordsFromProfile(yi,Wu),this.setNormalizer(new fi),this.registerExtractors(Lu()),this.registerExtractor(new Ee),this.registerExtractor(new ge),this.registerExtractors($u()),this.registerExtractor(new xu),this.registerExtractor(new Du);}classifyToken(t){let e=t.toLowerCase();return Vu.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"}},Ku=new qu;be("es",Ku,yi);var Ei={code:"pt",name:"Portuguese",nativeName:"Portugu\xEAs",regions:["western","priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,verb:{position:"start",subjectDrop:true},references:{me:"eu",it:"ele",you:"voc\xEA",result:"resultado",event:"evento",target:"alvo",body:"corpo",document:"documento",window:"janela",detail:"detalhe"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"meu",it:"seu",you:"teu"},keywords:{meu:"me",minha:"me",teu:"you",tua:"you",seu:"it",sua:"it"}},roleMarkers:{destination:{primary:"em",alternatives:["para","a"],position:"before"},source:{primary:"de",alternatives:["desde"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"com",position:"before"}},keywords:{toggle:{primary:"alternar",alternatives:[],normalized:"toggle"},add:{primary:"adicionar",alternatives:["acrescentar"],normalized:"add"},remove:{primary:"remover",alternatives:["eliminar","apagar","remova"],normalized:"remove"},put:{primary:"colocar",alternatives:["p\xF4r","por","coloque"],normalized:"put"},append:{primary:"anexar",normalized:"append"},prepend:{primary:"preceder",normalized:"prepend"},take:{primary:"pegar",alternatives:["pegue"],normalized:"take"},make:{primary:"fazer",alternatives:["criar"],normalized:"make"},clone:{primary:"clonar",alternatives:[],normalized:"clone"},swap:{primary:"trocar",alternatives:["substituir"],normalized:"swap"},morph:{primary:"transformar",alternatives:["converter"],normalized:"morph"},set:{primary:"definir",alternatives:["configurar","defina"],normalized:"set"},get:{primary:"obter",alternatives:["obtenha"],normalized:"get"},increment:{primary:"incrementar",alternatives:["aumentar"],normalized:"increment"},decrement:{primary:"decrementar",alternatives:["diminuir"],normalized:"decrement"},log:{primary:"registrar",alternatives:["imprimir"],normalized:"log"},show:{primary:"mostrar",alternatives:["exibir"],normalized:"show"},hide:{primary:"ocultar",alternatives:["esconder","esconda"],normalized:"hide"},transition:{primary:"transi\xE7\xE3o",alternatives:["animar"],normalized:"transition"},on:{primary:"em",alternatives:["ao"],normalized:"on"},trigger:{primary:"disparar",alternatives:["ativar"],normalized:"trigger"},send:{primary:"enviar",normalized:"send"},focus:{primary:"foco",alternatives:["focar"],normalized:"focus"},blur:{primary:"perda de foco",alternatives:["desfocar"],normalized:"blur"},empty:{primary:"esvaziar",alternatives:["vazio"],normalized:"empty"},open:{primary:"abrir",normalized:"open"},close:{primary:"fechar",normalized:"close"},select:{primary:"selecionar",normalized:"select"},clear:{primary:"limpar",normalized:"clear"},reset:{primary:"redefinir",alternatives:["resetar"],normalized:"reset"},breakpoint:{primary:"ponto-interrup\xE7\xE3o",alternatives:["ponto-interrupcao"],normalized:"breakpoint"},go:{primary:"ir",alternatives:["navegar","v\xE1"],normalized:"go"},scroll:{primary:"rolagem",alternatives:["rolar","deslocamento","scroll"],normalized:"scroll"},push:{primary:"empurrar",alternatives:["push"],normalized:"push"},replace:{primary:"repor",alternatives:["recolocar"],normalized:"replace"},process:{primary:"processar",normalized:"process"},wait:{primary:"esperar",alternatives:["aguardar"],normalized:"wait"},fetch:{primary:"buscar",alternatives:["busque"],normalized:"fetch"},settle:{primary:"estabilizar",normalized:"settle"},if:{primary:"se",normalized:"if"},unless:{primary:"salvo",alternatives:["a_menos"],normalized:"unless"},when:{primary:"quando",normalized:"when"},changes:{primary:"muda",normalized:"changes"},where:{primary:"onde",normalized:"where"},else:{primary:"sen\xE3o",normalized:"else"},repeat:{primary:"repetir",normalized:"repeat"},for:{primary:"para",normalized:"for"},while:{primary:"enquanto",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"continuar",normalized:"continue"},halt:{primary:"parar",normalized:"halt"},throw:{primary:"lan\xE7ar",normalized:"throw"},call:{primary:"chamar",normalized:"call"},return:{primary:"retornar",alternatives:["devolver"],normalized:"return"},then:{primary:"ent\xE3o",alternatives:["logo"],normalized:"then"},and:{primary:"e",alternatives:["tamb\xE9m","al\xE9m disso"],normalized:"and"},matches:{primary:"corresponde",normalized:"matches"},exists:{primary:"existe",normalized:"exists"},is:{primary:"\xE9",normalized:"is"},no:{primary:"nenhum",normalized:"no"},end:{primary:"fim",alternatives:["final","t\xE9rmino"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"ass\xEDncrono",normalized:"async"},tell:{primary:"dizer",normalized:"tell"},default:{primary:"padr\xE3o",normalized:"default"},init:{primary:"inicializa\xE7\xE3o",alternatives:["iniciar","inicializar"],normalized:"init"},behavior:{primary:"comportamento",normalized:"behavior"},install:{primary:"instalar",normalized:"install"},measure:{primary:"medir",normalized:"measure"},beep:{primary:"apitar",normalized:"beep"},break:{primary:"interromper",normalized:"break"},copy:{primary:"copiar",normalized:"copy"},exit:{primary:"sair",normalized:"exit"},pick:{primary:"escolher",normalized:"pick"},render:{primary:"renderizar",normalized:"render"},into:{primary:"dentro",alternatives:["dentro de"],normalized:"into"},before:{primary:"antes",normalized:"before"},after:{primary:"depois",normalized:"after"},click:{primary:"clique",alternatives:["clicar"],normalized:"click"},resize:{primary:"redimensionamento",alternatives:["redimensionar"],normalized:"resize"},hover:{primary:"sobrevoar",alternatives:["passar"],normalized:"hover"},submit:{primary:"envio",alternatives:["submeter","submiss\xE3o"],normalized:"submit"},input:{primary:"entrada",alternatives:["inser\xE7\xE3o"],normalized:"input"},change:{primary:"altera\xE7\xE3o",alternatives:["mudan\xE7a"],normalized:"change"},mousedown:{primary:"mouse pressionado",alternatives:["rato pressionado","mouse baixo","mouseBaixo"],normalized:"mousedown"},mouseup:{primary:"mouse solto",alternatives:["mouse liberado","rato libertado","mouse cima","mouseCima"],normalized:"mouseup"},until:{primary:"at\xE9",normalized:"until"},event:{primary:"evento",normalized:"event"},from:{primary:"de",alternatives:["desde"],normalized:"from"},connect:{primary:"conectar",alternatives:["conex\xE3o"],normalized:"connect"},stream:{primary:"transmitir",alternatives:["fluxo"],normalized:"stream"},live:{primary:"ao-vivo",alternatives:["vivo","direto"],normalized:"live"},socket:{primary:"soquete",alternatives:["websocket"],normalized:"socket"},bind:{primary:"vincular",alternatives:["ligar","bind"],normalized:"bind"},intercept:{primary:"interceptar",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"trabalhador",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["fonte-de-eventos"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"em",alternatives:["ao"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["desde"],position:"before"},conditionalKeyword:{primary:"quando",alternatives:["se"]},eventMarker:{primary:"ao",alternatives:["no","em"],position:"before"},temporalMarkers:["quando","ao"]}};function Hu(t){return /[\u00e1\u00e0\u00e2\u00e3\u00e9\u00ea\u00ed\u00f3\u00f4\u00f5\u00fa\u00fc\u00e7\u00c1\u00c0\u00c2\u00c3\u00c9\u00ca\u00cd\u00d3\u00d4\u00d5\u00da\u00dc\u00c7]/.test(t)}function Uu(t){let e=t.toLowerCase();if(e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir")||e.endsWith("ando")||e.endsWith("endo")||e.endsWith("indo")||e.endsWith("ado")||e.endsWith("ido")||e.endsWith("ar-se")||e.endsWith("er-se")||e.endsWith("ir-se"))return true;for(let r of t)if(Hu(r))return true;return false}var hi=["-se","-me","-te","-nos","-vos"],Gu=[{ending:"ando",stem:"ar",confidence:.88,type:"gerund"},{ending:"ado",stem:"ar",confidence:.88,type:"participle"},{ending:"ada",stem:"ar",confidence:.88,type:"participle"},{ending:"ados",stem:"ar",confidence:.88,type:"participle"},{ending:"adas",stem:"ar",confidence:.88,type:"participle"},{ending:"o",stem:"ar",confidence:.75,type:"present"},{ending:"as",stem:"ar",confidence:.82,type:"present"},{ending:"a",stem:"ar",confidence:.75,type:"present"},{ending:"amos",stem:"ar",confidence:.85,type:"present"},{ending:"ais",stem:"ar",confidence:.85,type:"present"},{ending:"am",stem:"ar",confidence:.8,type:"present"},{ending:"ei",stem:"ar",confidence:.88,type:"past"},{ending:"aste",stem:"ar",confidence:.88,type:"past"},{ending:"ou",stem:"ar",confidence:.88,type:"past"},{ending:"\xE1mos",stem:"ar",confidence:.88,type:"past"},{ending:"amos",stem:"ar",confidence:.85,type:"past"},{ending:"astes",stem:"ar",confidence:.88,type:"past"},{ending:"aram",stem:"ar",confidence:.88,type:"past"},{ending:"ava",stem:"ar",confidence:.88,type:"past"},{ending:"avas",stem:"ar",confidence:.88,type:"past"},{ending:"\xE1vamos",stem:"ar",confidence:.88,type:"past"},{ending:"avamos",stem:"ar",confidence:.85,type:"past"},{ending:"\xE1veis",stem:"ar",confidence:.88,type:"past"},{ending:"aveis",stem:"ar",confidence:.85,type:"past"},{ending:"avam",stem:"ar",confidence:.88,type:"past"},{ending:"e",stem:"ar",confidence:.72,type:"subjunctive"},{ending:"es",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"emos",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"eis",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"em",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"a",stem:"ar",confidence:.75,type:"imperative"},{ending:"ai",stem:"ar",confidence:.85,type:"imperative"},{ending:"ar",stem:"ar",confidence:.92,type:"dictionary"}],Yu=[{ending:"endo",stem:"er",confidence:.88,type:"gerund"},{ending:"ido",stem:"er",confidence:.85,type:"participle"},{ending:"ida",stem:"er",confidence:.85,type:"participle"},{ending:"idos",stem:"er",confidence:.85,type:"participle"},{ending:"idas",stem:"er",confidence:.85,type:"participle"},{ending:"o",stem:"er",confidence:.72,type:"present"},{ending:"es",stem:"er",confidence:.78,type:"present"},{ending:"e",stem:"er",confidence:.72,type:"present"},{ending:"emos",stem:"er",confidence:.85,type:"present"},{ending:"eis",stem:"er",confidence:.82,type:"present"},{ending:"em",stem:"er",confidence:.78,type:"present"},{ending:"i",stem:"er",confidence:.85,type:"past"},{ending:"este",stem:"er",confidence:.88,type:"past"},{ending:"eu",stem:"er",confidence:.88,type:"past"},{ending:"emos",stem:"er",confidence:.85,type:"past"},{ending:"estes",stem:"er",confidence:.88,type:"past"},{ending:"eram",stem:"er",confidence:.88,type:"past"},{ending:"ia",stem:"er",confidence:.85,type:"past"},{ending:"ias",stem:"er",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"er",confidence:.88,type:"past"},{ending:"iamos",stem:"er",confidence:.85,type:"past"},{ending:"\xEDeis",stem:"er",confidence:.88,type:"past"},{ending:"ieis",stem:"er",confidence:.85,type:"past"},{ending:"iam",stem:"er",confidence:.85,type:"past"},{ending:"er",stem:"er",confidence:.92,type:"dictionary"}],Zu=[{ending:"indo",stem:"ir",confidence:.88,type:"gerund"},{ending:"ido",stem:"ir",confidence:.85,type:"participle"},{ending:"ida",stem:"ir",confidence:.85,type:"participle"},{ending:"idos",stem:"ir",confidence:.85,type:"participle"},{ending:"idas",stem:"ir",confidence:.85,type:"participle"},{ending:"o",stem:"ir",confidence:.72,type:"present"},{ending:"es",stem:"ir",confidence:.78,type:"present"},{ending:"e",stem:"ir",confidence:.72,type:"present"},{ending:"imos",stem:"ir",confidence:.85,type:"present"},{ending:"is",stem:"ir",confidence:.82,type:"present"},{ending:"em",stem:"ir",confidence:.78,type:"present"},{ending:"i",stem:"ir",confidence:.85,type:"past"},{ending:"iste",stem:"ir",confidence:.88,type:"past"},{ending:"iu",stem:"ir",confidence:.88,type:"past"},{ending:"imos",stem:"ir",confidence:.85,type:"past"},{ending:"istes",stem:"ir",confidence:.88,type:"past"},{ending:"iram",stem:"ir",confidence:.88,type:"past"},{ending:"ia",stem:"ir",confidence:.85,type:"past"},{ending:"ias",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"ir",confidence:.88,type:"past"},{ending:"iamos",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDeis",stem:"ir",confidence:.88,type:"past"},{ending:"ieis",stem:"ir",confidence:.85,type:"past"},{ending:"iam",stem:"ir",confidence:.85,type:"past"},{ending:"ir",stem:"ir",confidence:.92,type:"dictionary"}],Xu=[...Gu,...Yu,...Zu].sort((t,e)=>e.ending.length-t.ending.length),gi=class{constructor(){this.language="pt";}isNormalizable(t){return t.length<3?false:Uu(t)}normalize(t){let e=t.toLowerCase();if((e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir"))&&!hi.some(n=>e.endsWith(n)))return se(t);let r=this.tryReflexiveNormalization(e);if(r)return r;let i=this.tryConjugationNormalization(e);return i||se(t)}tryReflexiveNormalization(t){for(let e of hi)if(t.endsWith(e)){let r=t.slice(0,-e.length);if(r.endsWith("ar")||r.endsWith("er")||r.endsWith("ir"))return J(r,.88,{removedSuffixes:[e],conjugationType:"reflexive"});let i=this.tryConjugationNormalization(r);if(i&&i.stem!==r)return J(i.stem,i.confidence*.95,{removedSuffixes:[e,...i.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationNormalization(t){for(let e of Xu)if(t.endsWith(e.ending)){let r=t.slice(0,-e.ending.length);if(r.length<2)continue;let i=r+e.stem;return J(i,e.confidence,{removedSuffixes:[e.ending],conjugationType:e.type})}return null}},Ju=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Qu=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}},el="()[]{},:;",rl=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 n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function vi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=qr(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=qr(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=qr(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var tl=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}},il=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},nl=["http://","https://","//","./","../","/"];function al(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function ol(t,e){let r=t.slice(e),i=nl.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=al(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var sl=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=ol(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},ul=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 ll(){return [new sl,new il,new ul,new tl]}function cl(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:dl,isIdentifierChar:ml}=cl(/[a-zA-Z\u00e1\u00e2\u00e3\u00e9\u00ea\u00ed\u00f3\u00f4\u00f5\u00fa\u00e7\u00c1\u00c2\u00c3\u00c9\u00ca\u00cd\u00d3\u00d4\u00d5\u00da\u00c7]/),pl=new Set(["em","a","de","para","com","sem","por","sobre","entre","antes","depois","dentro","fora","ao","do","da","no","na"]),fl=class{constructor(){this.name="portuguese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return dl(t[e])}extract(t,e){if(!this.context)throw new Error("PortugueseKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&ml(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=pl.has(n),o=this.context.lookupKeyword(n),s=o&&o.normalized!==o.native?o.normalized:void 0,u,l,c;if(!o&&this.context.normalizer){let d=this.context.normalizer.normalize(i);if(d.stem!==i&&d.confidence>=.7){let m=this.context.lookupKeyword(d.stem);m&&(u=m.normalized,l=d.stem,c=d.confidence);}}return {value:i,length:r-e,metadata:{normalized:s||u,stem:l,stemConfidence:c,isPreposition:a}}}};function yl(){return [new fl]}var hl=new Set(["em","a","de","desde","at\xE9","ate","com","sem","por","para","sobre","entre","antes","depois","dentro","fora","ao","do","no","na"]),vl=[{native:"verdadeiro",normalized:"true"},{native:"falso",normalized:"false"},{native:"nulo",normalized:"null"},{native:"indefinido",normalized:"undefined"},{native:"primeiro",normalized:"first"},{native:"primeira",normalized:"first"},{native:"\xFAltimo",normalized:"last"},{native:"ultima",normalized:"last"},{native:"pr\xF3ximo",normalized:"next"},{native:"proximo",normalized:"next"},{native:"anterior",normalized:"previous"},{native:"maispr\xF3ximo",normalized:"closest"},{native:"maisproximo",normalized:"closest"},{native:"pai",normalized:"parent"},{native:"clique",normalized:"click"},{native:"click",normalized:"click"},{native:"entrada",normalized:"input"},{native:"mudan\xE7a",normalized:"change"},{native:"mudanca",normalized:"change"},{native:"envio",normalized:"submit"},{native:"tecla baixo",normalized:"keydown"},{native:"tecla cima",normalized:"keyup"},{native:"mouse sobre",normalized:"mouseover"},{native:"mouse fora",normalized:"mouseout"},{native:"foco",normalized:"focus"},{native:"desfoque",normalized:"blur"},{native:"carregar",normalized:"load"},{native:"rolagem",normalized:"scroll"},{native:"meu",normalized:"my"},{native:"minha",normalized:"my"},{native:"isso",normalized:"it"},{native:"segundo",normalized:"s"},{native:"segundos",normalized:"s"},{native:"milissegundo",normalized:"ms"},{native:"milissegundos",normalized:"ms"},{native:"minuto",normalized:"m"},{native:"minutos",normalized:"m"},{native:"hora",normalized:"h"},{native:"horas",normalized:"h"},{native:"senao",normalized:"else"},{native:"transicao",normalized:"transition"},{native:"ate",normalized:"until"},{native:"entao",normalized:"then"},{native:"lancar",normalized:"throw"},{native:"assincrono",normalized:"async"},{native:"padrao",normalized:"default"},{native:"at\xE9 que",normalized:"until"},{native:"dentro de",normalized:"into"},{native:"inclusivo",normalized:"inclusive"},{native:"exclusivo",normalized:"exclusive"},{native:"caracteres",normalized:"characters"},{native:"aleat\xF3rio",normalized:"random"}],El=class extends ze{constructor(){super(),this.language="pt",this.direction="ltr",this.initializeKeywordsFromProfile(Ei,vl),this.setNormalizer(new gi),this.registerExtractors(ll()),this.registerExtractor(new Ee),this.registerExtractor(new ge),this.registerExtractors(yl()),this.registerExtractor(new Qu),this.registerExtractor(new rl);}classifyToken(t){let e=t.toLowerCase();return hl.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":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},gl=new El;be("pt",gl,Ei);var ki={code:"fr",name:"French",nativeName:"Fran\xE7ais",regions:["western","priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:false},references:{me:"moi",it:"il",you:"toi",result:"r\xE9sultat",event:"\xE9v\xE9nement",target:"cible",body:"corps",document:"document",window:"fen\xEAtre",detail:"d\xE9tail"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"ma",it:"sa",you:"ta"},keywords:{mon:"me",ma:"me",mes:"me",ton:"you",ta:"you",tes:"you",son:"it",sa:"it",ses:"it"}},roleMarkers:{destination:{primary:"sur",alternatives:["\xE0","dans"],position:"before"},source:{primary:"de",alternatives:["depuis"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"avec",position:"before"}},keywords:{toggle:{primary:"basculer",alternatives:["alterner"],normalized:"toggle"},add:{primary:"ajouter",normalized:"add"},remove:{primary:"supprimer",alternatives:["enlever","retirer","retire"],normalized:"remove"},put:{primary:"mettre",alternatives:["placer","mets"],normalized:"put"},append:{primary:"annexer",normalized:"append"},prepend:{primary:"pr\xE9fixer",normalized:"prepend"},take:{primary:"prendre",normalized:"take"},make:{primary:"faire",alternatives:["cr\xE9er"],normalized:"make"},clone:{primary:"cloner",alternatives:["dupliquer"],normalized:"clone"},swap:{primary:"\xE9changer",alternatives:["permuter"],normalized:"swap"},morph:{primary:"transformer",alternatives:["m\xE9tamorphoser"],normalized:"morph"},set:{primary:"d\xE9finir",alternatives:["\xE9tablir"],normalized:"set"},get:{primary:"obtenir",alternatives:["obtiens"],normalized:"get"},increment:{primary:"incr\xE9menter",alternatives:["augmenter"],normalized:"increment"},decrement:{primary:"d\xE9cr\xE9menter",alternatives:["diminuer"],normalized:"decrement"},log:{primary:"enregistrer",alternatives:["journaliser"],normalized:"log"},show:{primary:"montrer",alternatives:["afficher","montre"],normalized:"show"},hide:{primary:"cacher",alternatives:["masquer"],normalized:"hide"},transition:{primary:"transition",alternatives:["animer"],normalized:"transition"},on:{primary:"sur",alternatives:["lors"],normalized:"on"},trigger:{primary:"d\xE9clencher",normalized:"trigger"},send:{primary:"envoyer",alternatives:["envoie"],normalized:"send"},focus:{primary:"focaliser",alternatives:["concentrer"],normalized:"focus"},blur:{primary:"perte de focus",alternatives:["d\xE9focaliser"],normalized:"blur"},empty:{primary:"vider",alternatives:["vide"],normalized:"empty"},open:{primary:"ouvrir",normalized:"open"},close:{primary:"fermer",normalized:"close"},select:{primary:"s\xE9lectionner",alternatives:["selectionner"],normalized:"select"},clear:{primary:"effacer",normalized:"clear"},reset:{primary:"r\xE9initialiser",alternatives:["reinitialiser"],normalized:"reset"},breakpoint:{primary:"point-arr\xEAt",alternatives:["point-arret"],normalized:"breakpoint"},go:{primary:"aller",alternatives:["naviguer","va"],normalized:"go"},scroll:{primary:"d\xE9filement",alternatives:["defilement","d\xE9filer","faire-d\xE9filer"],normalized:"scroll"},push:{primary:"pousser",normalized:"push"},replace:{primary:"remplacer",normalized:"replace"},process:{primary:"traiter",normalized:"process"},wait:{primary:"attendre",normalized:"wait"},fetch:{primary:"chercher",alternatives:["r\xE9cup\xE9rer","r\xE9cup\xE8re"],normalized:"fetch"},settle:{primary:"stabiliser",normalized:"settle"},if:{primary:"si",normalized:"if"},unless:{primary:"saufsi",normalized:"unless"},when:{primary:"quand",normalized:"when"},changes:{primary:"change",normalized:"changes"},where:{primary:"o\xF9",normalized:"where"},else:{primary:"sinon",normalized:"else"},repeat:{primary:"r\xE9p\xE9ter",normalized:"repeat"},for:{primary:"pour",normalized:"for"},while:{primary:"pendant",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"continuer",normalized:"continue"},halt:{primary:"arr\xEAter",alternatives:["stopper"],normalized:"halt"},throw:{primary:"lancer",normalized:"throw"},call:{primary:"appeler",normalized:"call"},return:{primary:"retourner",alternatives:["renvoyer"],normalized:"return"},then:{primary:"puis",alternatives:["ensuite","alors"],normalized:"then"},and:{primary:"et",alternatives:["aussi","\xE9galement"],normalized:"and"},matches:{primary:"correspond",normalized:"matches"},exists:{primary:"existe",normalized:"exists"},is:{primary:"est",normalized:"is"},no:{primary:"aucun",normalized:"no"},end:{primary:"fin",alternatives:["terminer","finir"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"asynchrone",normalized:"async"},tell:{primary:"dire",normalized:"tell"},default:{primary:"d\xE9faut",normalized:"default"},init:{primary:"initialiser",normalized:"init"},behavior:{primary:"comportement",normalized:"behavior"},install:{primary:"installer",normalized:"install"},measure:{primary:"mesurer",normalized:"measure"},beep:{primary:"bip",normalized:"beep"},break:{primary:"interrompre",normalized:"break"},copy:{primary:"copier",normalized:"copy"},exit:{primary:"sortir",normalized:"exit"},pick:{primary:"choisir",normalized:"pick"},render:{primary:"rendu",normalized:"render"},into:{primary:"dans",normalized:"into"},before:{primary:"avant",normalized:"before"},after:{primary:"apr\xE8s",normalized:"after"},click:{primary:"clic",alternatives:["clique"],normalized:"click"},resize:{primary:"redimensionnement",alternatives:["redimensionner"],normalized:"resize"},hover:{primary:"survol",alternatives:["survoler"],normalized:"hover"},submit:{primary:"soumission",alternatives:["soumettre"],normalized:"submit"},input:{primary:"saisie",alternatives:["entr\xE9e"],normalized:"input"},change:{primary:"changement",alternatives:["modifier","changer"],normalized:"change"},load:{primary:"charger",alternatives:["chargement"],normalized:"load"},until:{primary:"jusqu'\xE0",alternatives:["jusque"],normalized:"until"},event:{primary:"\xE9v\xE9nement",normalized:"event"},from:{primary:"de",alternatives:["depuis"],normalized:"from"},connect:{primary:"connecter",alternatives:["connexion"],normalized:"connect"},stream:{primary:"flux",alternatives:["streaming"],normalized:"stream"},live:{primary:"en-direct",alternatives:["direct","vif"],normalized:"live"},socket:{primary:"socket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"lier",alternatives:["relier","bind"],normalized:"bind"},intercept:{primary:"intercepter",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"travailleur",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["source-d-evenements"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"sur",alternatives:["lors"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["depuis"],position:"before"},conditionalKeyword:{primary:"quand",alternatives:["lorsque"]},eventMarker:{primary:"au",alternatives:["lors du","lors de","sur"],position:"before"},temporalMarkers:["quand","lorsque"]}};function zl(t){let e=t.toLowerCase();return !!(e.endsWith("er")||e.endsWith("ir")||e.endsWith("re")||e.endsWith("ant")||e.endsWith("\xE9")||e.endsWith("i")||e.endsWith("u")||/[\u00e0\u00e2\u00e4\u00e9\u00e8\u00ea\u00eb\u00ef\u00ee\u00f4\u00f9\u00fb\u00fc\u00ff\u00e7\u0153\u00e6]/i.test(t))}var kl=["toi","vous","nous"],wl=[{ending:"ant",stem:"er",confidence:.88,type:"gerund"},{ending:"\xE9",stem:"er",confidence:.88,type:"participle"},{ending:"\xE9e",stem:"er",confidence:.88,type:"participle"},{ending:"\xE9s",stem:"er",confidence:.88,type:"participle"},{ending:"\xE9es",stem:"er",confidence:.88,type:"participle"},{ending:"e",stem:"er",confidence:.75,type:"present"},{ending:"es",stem:"er",confidence:.78,type:"present"},{ending:"ons",stem:"er",confidence:.85,type:"present"},{ending:"ez",stem:"er",confidence:.85,type:"present"},{ending:"ent",stem:"er",confidence:.82,type:"present"},{ending:"ais",stem:"er",confidence:.82,type:"past"},{ending:"ait",stem:"er",confidence:.82,type:"past"},{ending:"ions",stem:"er",confidence:.85,type:"past"},{ending:"iez",stem:"er",confidence:.85,type:"past"},{ending:"aient",stem:"er",confidence:.85,type:"past"},{ending:"ai",stem:"er",confidence:.8,type:"past"},{ending:"as",stem:"er",confidence:.78,type:"past"},{ending:"a",stem:"er",confidence:.75,type:"past"},{ending:"\xE2mes",stem:"er",confidence:.88,type:"past"},{ending:"\xE2tes",stem:"er",confidence:.88,type:"past"},{ending:"\xE8rent",stem:"er",confidence:.88,type:"past"},{ending:"erai",stem:"er",confidence:.85,type:"future"},{ending:"eras",stem:"er",confidence:.85,type:"future"},{ending:"era",stem:"er",confidence:.82,type:"future"},{ending:"erons",stem:"er",confidence:.88,type:"future"},{ending:"erez",stem:"er",confidence:.88,type:"future"},{ending:"eront",stem:"er",confidence:.88,type:"future"},{ending:"erais",stem:"er",confidence:.85,type:"conditional"},{ending:"erait",stem:"er",confidence:.85,type:"conditional"},{ending:"erions",stem:"er",confidence:.88,type:"conditional"},{ending:"eriez",stem:"er",confidence:.88,type:"conditional"},{ending:"eraient",stem:"er",confidence:.88,type:"conditional"},{ending:"ions",stem:"er",confidence:.8,type:"subjunctive"},{ending:"iez",stem:"er",confidence:.8,type:"subjunctive"},{ending:"ons",stem:"er",confidence:.82,type:"imperative"},{ending:"ez",stem:"er",confidence:.82,type:"imperative"},{ending:"er",stem:"er",confidence:.92,type:"dictionary"}],bl=[{ending:"issant",stem:"ir",confidence:.88,type:"gerund"},{ending:"i",stem:"ir",confidence:.8,type:"participle"},{ending:"ie",stem:"ir",confidence:.82,type:"participle"},{ending:"is",stem:"ir",confidence:.78,type:"participle"},{ending:"ies",stem:"ir",confidence:.82,type:"participle"},{ending:"is",stem:"ir",confidence:.78,type:"present"},{ending:"it",stem:"ir",confidence:.78,type:"present"},{ending:"issons",stem:"ir",confidence:.88,type:"present"},{ending:"issez",stem:"ir",confidence:.88,type:"present"},{ending:"issent",stem:"ir",confidence:.88,type:"present"},{ending:"issais",stem:"ir",confidence:.85,type:"past"},{ending:"issait",stem:"ir",confidence:.85,type:"past"},{ending:"issions",stem:"ir",confidence:.88,type:"past"},{ending:"issiez",stem:"ir",confidence:.88,type:"past"},{ending:"issaient",stem:"ir",confidence:.88,type:"past"},{ending:"irai",stem:"ir",confidence:.85,type:"future"},{ending:"iras",stem:"ir",confidence:.85,type:"future"},{ending:"ira",stem:"ir",confidence:.82,type:"future"},{ending:"irons",stem:"ir",confidence:.88,type:"future"},{ending:"irez",stem:"ir",confidence:.88,type:"future"},{ending:"iront",stem:"ir",confidence:.88,type:"future"},{ending:"ir",stem:"ir",confidence:.9,type:"dictionary"}],Cl=[{ending:"ant",stem:"re",confidence:.82,type:"gerund"},{ending:"u",stem:"re",confidence:.8,type:"participle"},{ending:"ue",stem:"re",confidence:.82,type:"participle"},{ending:"us",stem:"re",confidence:.82,type:"participle"},{ending:"ues",stem:"re",confidence:.82,type:"participle"},{ending:"s",stem:"re",confidence:.72,type:"present"},{ending:"d",stem:"re",confidence:.75,type:"present"},{ending:"ons",stem:"re",confidence:.82,type:"present"},{ending:"ez",stem:"re",confidence:.82,type:"present"},{ending:"ent",stem:"re",confidence:.8,type:"present"},{ending:"re",stem:"re",confidence:.9,type:"dictionary"}],Al=[...wl,...bl,...Cl].sort((t,e)=>e.ending.length-t.ending.length),wi=class{constructor(){this.language="fr";}isNormalizable(t){return t.length<3?false:zl(t)}normalize(t){let e=t.toLowerCase();if((e.endsWith("er")||e.endsWith("ir")||e.endsWith("re"))&&e.length>=4)return se(t);let r=this.tryReflexiveNormalization(e);if(r)return r;let i=this.tryConjugationNormalization(e);return i||se(t)}tryReflexiveNormalization(t){for(let e of kl){let r="-"+e;if(t.endsWith(r)){let i=t.slice(0,-r.length),n=this.tryConjugationNormalization(i);if(n&&n.stem!==i)return J(n.stem,n.confidence*.95,{removedSuffixes:[r,...n.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}}return null}tryConjugationNormalization(t){for(let e of Al)if(t.endsWith(e.ending)){let r=t.slice(0,-e.ending.length);if(r.length<2)continue;let i=r+e.stem;return J(i,e.confidence,{removedSuffixes:[e.ending],conjugationType:e.type})}return null}},xl=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Sl=class{constructor(t=xl){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}},Dl="()[]{},:;",Bl=class{constructor(t=Dl){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 n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function zi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Kr(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Kr(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Kr(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var Tl=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?zi(t,e)!==null:false}extract(t,e){let r=zi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Fl=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},Rl=["http://","https://","//","./","../","/"];function Ol(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function Pl(t,e){let r=t.slice(e),i=Rl.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=Ol(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var Nl=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=Pl(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Ll=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 Ml(){return [new Nl,new Fl,new Ll,new Tl]}function _l(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:Il,isIdentifierChar:jl}=_l(/[a-zA-Z\u00e0\u00e2\u00e6\u00e7\u00e9\u00e8\u00ea\u00eb\u00ef\u00ee\u00f4\u00f9\u00fb\u00fc\u00ff\u0153\u00c0\u00c2\u00c6\u00c7\u00c9\u00c8\u00ca\u00cb\u00cf\u00ce\u00d4\u00d9\u00db\u00dc\u0178\u0152]/),$l=new Set(["\xE0","a","de","du","des","dans","sur","sous","avec","sans","par","pour","entre","avant","apr\xE8s","apres","depuis","vers","chez","contre","au","aux"]),Vl=class{constructor(){this.name="french-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Il(t[e])}extract(t,e){if(!this.context)throw new Error("FrenchKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&jl(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=$l.has(n),o=this.context.lookupKeyword(n),s=o&&o.normalized!==o.native?o.normalized:void 0,u,l,c;if(!o&&this.context.normalizer){let d=this.context.normalizer.normalize(i);if(d.stem!==i&&d.confidence>=.7){let m=this.context.lookupKeyword(d.stem);m&&(u=m.normalized,l=d.stem,c=d.confidence);}}return {value:i,length:r-e,metadata:{normalized:s||u,stem:l,stemConfidence:c,isPreposition:a}}}};function Wl(){return [new Vl]}var ql=[{native:"vrai",normalized:"true"},{native:"faux",normalized:"false"},{native:"nul",normalized:"null"},{native:"ind\xE9fini",normalized:"undefined"},{native:"indefini",normalized:"undefined"},{native:"premier",normalized:"first"},{native:"premi\xE8re",normalized:"first"},{native:"premiere",normalized:"first"},{native:"dernier",normalized:"last"},{native:"derni\xE8re",normalized:"last"},{native:"derniere",normalized:"last"},{native:"suivant",normalized:"next"},{native:"pr\xE9c\xE9dent",normalized:"previous"},{native:"precedent",normalized:"previous"},{native:"proche",normalized:"closest"},{native:"parent",normalized:"parent"},{native:"clic",normalized:"click"},{native:"click",normalized:"click"},{native:"entr\xE9e",normalized:"input"},{native:"entree",normalized:"input"},{native:"changement",normalized:"change"},{native:"soumission",normalized:"submit"},{native:"touche bas",normalized:"keydown"},{native:"touche haut",normalized:"keyup"},{native:"souris dessus",normalized:"mouseover"},{native:"souris dehors",normalized:"mouseout"},{native:"focus",normalized:"focus"},{native:"flou",normalized:"blur"},{native:"chargement",normalized:"load"},{native:"d\xE9filement",normalized:"scroll"},{native:"defilement",normalized:"scroll"},{native:"je",normalized:"me"},{native:"mon",normalized:"my"},{native:"ma",normalized:"my"},{native:"mes",normalized:"my"},{native:"\xE7a",normalized:"it"},{native:"ca",normalized:"it"},{native:"resultat",normalized:"result"},{native:"evenement",normalized:"event"},{native:"seconde",normalized:"s"},{native:"secondes",normalized:"s"},{native:"milliseconde",normalized:"ms"},{native:"millisecondes",normalized:"ms"},{native:"minute",normalized:"m"},{native:"minutes",normalized:"m"},{native:"heure",normalized:"h"},{native:"heures",normalized:"h"},{native:"prefixer",normalized:"prepend"},{native:"creer",normalized:"make"},{native:"definir",normalized:"set"},{native:"etablir",normalized:"set"},{native:"incrementer",normalized:"increment"},{native:"decrementer",normalized:"decrement"},{native:"declencher",normalized:"trigger"},{native:"defocaliser",normalized:"blur"},{native:"recuperer",normalized:"fetch"},{native:"repeter",normalized:"repeat"},{native:"arreter",normalized:"halt"},{native:"defaut",normalized:"default"},{native:"jusqua",normalized:"until"},{native:"apres",normalized:"after"},{native:"journaliser",normalized:"log"},{native:"transmuter",normalized:"morph"},{native:"tant que",normalized:"while"},{native:"inclusif",normalized:"inclusive"},{native:"exclusif",normalized:"exclusive"},{native:"caract\xE8res",normalized:"characters"},{native:"al\xE9atoire",normalized:"random"}],Kl=class extends ze{constructor(){super(),this.language="fr",this.direction="ltr",this.initializeKeywordsFromProfile(ki,ql),this.normalizer=new wi,this.registerExtractors(Ml()),this.registerExtractor(new Ee),this.registerExtractor(new ge),this.registerExtractors(Wl()),this.registerExtractor(new Sl),this.registerExtractor(new Bl);}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('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},Hl=new Kl;be("fr",Hl,ki);var Ci={code:"de",name:"German",nativeName:"Deutsch",regions:["western","priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:false},references:{me:"ich",it:"es",you:"du",result:"Ergebnis",event:"Ereignis",target:"Ziel",body:"K\xF6rper",document:"dokument",window:"fenster",detail:"detail"},possessive:{marker:"",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"mein",it:"sein",you:"dein"},keywords:{mein:"me",meine:"me",meinen:"me",dein:"you",deine:"you",deinen:"you",sein:"it",seine:"it",seinen:"it"}},roleMarkers:{destination:{primary:"auf",alternatives:["zu","in"],position:"before"},source:{primary:"von",alternatives:["aus"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"mit",position:"before"}},keywords:{toggle:{primary:"umschalten",alternatives:["wechseln"],normalized:"toggle"},add:{primary:"hinzuf\xFCgen",normalized:"add"},remove:{primary:"entfernen",alternatives:["l\xF6schen"],normalized:"remove"},put:{primary:"setzen",alternatives:["stellen","platzieren"],normalized:"put"},append:{primary:"anh\xE4ngen",normalized:"append"},prepend:{primary:"voranstellen",normalized:"prepend"},take:{primary:"nehmen",normalized:"take"},make:{primary:"machen",alternatives:["erstellen","erzeugen"],normalized:"make"},clone:{primary:"klonen",alternatives:["duplizieren"],normalized:"clone"},swap:{primary:"austauschen",alternatives:["tauschen","vertauschen"],normalized:"swap"},morph:{primary:"verwandeln",alternatives:["transformieren"],normalized:"morph"},set:{primary:"festlegen",alternatives:["definieren"],normalized:"set"},get:{primary:"holen",alternatives:["bekommen","erhalten"],normalized:"get"},increment:{primary:"erh\xF6hen",normalized:"increment"},decrement:{primary:"verringern",alternatives:["vermindern"],normalized:"decrement"},log:{primary:"protokollieren",alternatives:["ausgeben"],normalized:"log"},show:{primary:"zeigen",alternatives:["anzeigen"],normalized:"show"},hide:{primary:"verbergen",alternatives:["verstecken"],normalized:"hide"},transition:{primary:"\xFCbergang",alternatives:["animieren"],normalized:"transition"},on:{primary:"bei",alternatives:["auf"],normalized:"on"},trigger:{primary:"ausl\xF6sen",normalized:"trigger"},send:{primary:"senden",alternatives:["schicken"],normalized:"send"},focus:{primary:"Fokus",alternatives:["Fokuserhalt","fokussieren"],normalized:"focus"},blur:{primary:"Fokusverlust",alternatives:["verlassen","defokussieren","entfokussieren"],normalized:"blur"},empty:{primary:"leeren",alternatives:["leer"],normalized:"empty"},open:{primary:"\xF6ffnen",alternatives:["oeffnen"],normalized:"open"},close:{primary:"schlie\xDFen",alternatives:["schliessen"],normalized:"close"},select:{primary:"markieren",normalized:"select"},clear:{primary:"bereinigen",normalized:"clear"},reset:{primary:"zur\xFCcksetzen",alternatives:["zuruecksetzen"],normalized:"reset"},breakpoint:{primary:"haltepunkt",normalized:"breakpoint"},go:{primary:"gehen",alternatives:["navigieren"],normalized:"go"},scroll:{primary:"scrollen",normalized:"scroll"},push:{primary:"dr\xFCcken",alternatives:["push"],normalized:"push"},replace:{primary:"ersetzen",normalized:"replace"},process:{primary:"verarbeiten",normalized:"process"},wait:{primary:"warten",normalized:"wait"},fetch:{primary:"abrufen",alternatives:["laden"],normalized:"fetch"},settle:{primary:"stabilisieren",normalized:"settle"},if:{primary:"falls",alternatives:["sofern"],normalized:"if"},unless:{primary:"wennnicht",normalized:"unless"},when:{primary:"wenn",normalized:"when"},changes:{primary:"\xE4ndert",normalized:"changes"},where:{primary:"wo",normalized:"where"},else:{primary:"sonst",alternatives:["ansonsten"],normalized:"else"},repeat:{primary:"wiederholen",normalized:"repeat"},for:{primary:"f\xFCr",normalized:"for"},while:{primary:"solange",alternatives:["w\xE4hrend"],normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"fortfahren",alternatives:["weiter"],normalized:"continue"},halt:{primary:"anhalten",alternatives:["stoppen"],normalized:"halt"},throw:{primary:"werfen",normalized:"throw"},call:{primary:"aufrufen",normalized:"call"},return:{primary:"zur\xFCckgeben",normalized:"return"},then:{primary:"dann",alternatives:["danach","anschlie\xDFend"],normalized:"then"},and:{primary:"und",alternatives:["sowie","auch"],normalized:"and"},is:{primary:"ist",normalized:"is"},matches:{primary:"passt",normalized:"matches"},exists:{primary:"existiert",normalized:"exists"},no:{primary:"kein",normalized:"no"},end:{primary:"ende",alternatives:["fertig"],normalized:"end"},js:{primary:"js",alternatives:["javascript"],normalized:"js"},async:{primary:"asynchron",normalized:"async"},tell:{primary:"sagen",normalized:"tell"},default:{primary:"standard",normalized:"default"},init:{primary:"Initialisierung",alternatives:["initialisieren"],normalized:"init"},behavior:{primary:"verhalten",normalized:"behavior"},install:{primary:"installieren",normalized:"install"},measure:{primary:"messen",normalized:"measure"},beep:{primary:"piepton",normalized:"beep"},break:{primary:"unterbrechen",normalized:"break"},copy:{primary:"kopieren",normalized:"copy"},exit:{primary:"beenden",normalized:"exit"},pick:{primary:"ausw\xE4hlen",normalized:"pick"},render:{primary:"rendern",normalized:"render"},into:{primary:"hinein",normalized:"into"},before:{primary:"vor",normalized:"before"},after:{primary:"nach",normalized:"after"},click:{primary:"Klick",alternatives:["Klicken"],normalized:"click"},hover:{primary:"Hover",alternatives:["Schweben"],normalized:"hover"},submit:{primary:"Absenden",alternatives:["Senden"],normalized:"submit"},input:{primary:"Eingabe",normalized:"input"},change:{primary:"\xC4nderung",alternatives:["\xC4ndern"],normalized:"change"},resize:{primary:"Gr\xF6\xDFen\xE4nderung",alternatives:["gr\xF6\xDFen\xE4nderung","gr\xF6ssen\xE4nderung","Gr\xF6\xDFe \xE4ndern","gr\xF6\xDFe\xE4ndern"],normalized:"resize"},until:{primary:"bis",normalized:"until"},event:{primary:"Ereignis",alternatives:["Event"],normalized:"event"},from:{primary:"von",alternatives:["aus"],normalized:"from"},connect:{primary:"verbinden",alternatives:["Verbindung"],normalized:"connect"},stream:{primary:"stream",alternatives:["Strom"],normalized:"stream"},live:{primary:"direkt",alternatives:["live","echtzeit"],normalized:"live"},socket:{primary:"socket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"binden",alternatives:["verknuepfen","bind"],normalized:"bind"},intercept:{primary:"abfangen",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"arbeiter",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["ereignisquelle"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"bei",alternatives:["auf"],normalized:"on"},sourceMarker:{primary:"von",alternatives:["aus"],position:"before"},conditionalKeyword:{primary:"wenn",alternatives:["falls"]},eventMarker:{primary:"bei",alternatives:["beim"],position:"before"},temporalMarkers:["wenn","bei"]}},Ul=["an","auf","aus","ein","mit","vor","zu","ab","bei","nach","weg","um","her","hin"];function Gl(t){let e=t.toLowerCase();return !!(e.endsWith("en")||e.endsWith("eln")||e.endsWith("ern")||e.startsWith("ge")&&e.endsWith("t")||e.startsWith("ge")&&e.endsWith("en")||/[\u00e4\u00f6\u00fc\u00df]/i.test(t))}var Yl=[{ending:"end",stem:"en",confidence:.88,type:"gerund"},{ending:"e",stem:"en",confidence:.75,type:"present"},{ending:"st",stem:"en",confidence:.8,type:"present"},{ending:"t",stem:"en",confidence:.78,type:"present"},{ending:"en",stem:"en",confidence:.85,type:"dictionary"},{ending:"test",stem:"en",confidence:.85,type:"past"},{ending:"ten",stem:"en",confidence:.82,type:"past"},{ending:"tet",stem:"en",confidence:.85,type:"past"},{ending:"te",stem:"en",confidence:.82,type:"past"},{ending:"test",stem:"en",confidence:.8,type:"subjunctive"},{ending:"ten",stem:"en",confidence:.78,type:"subjunctive"},{ending:"tet",stem:"en",confidence:.8,type:"subjunctive"},{ending:"te",stem:"en",confidence:.78,type:"subjunctive"},{ending:"e",stem:"en",confidence:.72,type:"imperative"},{ending:"t",stem:"en",confidence:.72,type:"imperative"},{ending:"en",stem:"en",confidence:.75,type:"imperative"}],Zl=[{ending:"le",stem:"eln",confidence:.82,type:"present"},{ending:"elst",stem:"eln",confidence:.85,type:"present"},{ending:"elt",stem:"eln",confidence:.85,type:"present"},{ending:"eln",stem:"eln",confidence:.88,type:"dictionary"},{ending:"re",stem:"ern",confidence:.82,type:"present"},{ending:"erst",stem:"ern",confidence:.85,type:"present"},{ending:"ert",stem:"ern",confidence:.85,type:"present"},{ending:"ern",stem:"ern",confidence:.88,type:"dictionary"}],Xl=[...Yl,...Zl].sort((t,e)=>e.ending.length-t.ending.length),Ai=class{constructor(){this.language="de";}isNormalizable(t){return t.length<3?false:Gl(t)}normalize(t){let e=t.toLowerCase();if(e.endsWith("en")&&e.length>=4)return se(t);if((e.endsWith("eln")||e.endsWith("ern"))&&e.length>=5)return se(t);let r=this.tryParticipleNormalization(e);if(r)return r;let i=this.tryConjugationNormalization(e);return i||se(t)}tryParticipleNormalization(t){for(let e of Ul)if(t.startsWith(e+"ge")){let r=t.slice(e.length),i=this.trySimpleParticipleNormalization(r);if(i){let n={removedPrefixes:["ge"],conjugationType:"participle"};return i.metadata?.removedSuffixes&&(n.removedSuffixes=i.metadata.removedSuffixes),J(e+i.stem,i.confidence*.95,n)}}return this.trySimpleParticipleNormalization(t)}trySimpleParticipleNormalization(t){if(!t.startsWith("ge"))return null;let e=t.slice(2);if(e.endsWith("t")&&e.length>=3){let r=e.slice(0,-1);return J(r+"en",.85,{removedPrefixes:["ge"],removedSuffixes:["t"],conjugationType:"participle"})}return e.endsWith("en")&&e.length>=4?J(e,.82,{removedPrefixes:["ge"],conjugationType:"participle"}):null}tryConjugationNormalization(t){for(let e of Xl)if(t.endsWith(e.ending)){let r=t.slice(0,-e.ending.length);if(r.length<2)continue;let i=r+e.stem;return J(i,e.confidence,{removedSuffixes:[e.ending],conjugationType:e.type})}return null}},Jl=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Ql=class{constructor(t=Jl){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}},ec="()[]{},:;",rc=class{constructor(t=ec){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 Hr(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function bi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Hr(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Hr(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Hr(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var tc=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}},ic=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},nc=["http://","https://","//","./","../","/"];function ac(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function oc(t,e){let r=t.slice(e),i=nc.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=ac(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var sc=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=oc(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},uc=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 lc(){return [new sc,new ic,new uc,new tc]}function cc(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:dc,isIdentifierChar:mc}=cc(/[a-zA-Z\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df]/),pc=new Set(["an","auf","aus","bei","durch","f\xFCr","fur","gegen","in","mit","nach","ohne","seit","\xFCber","uber","um","unter","von","vor","zu","zwischen","bis","gegen\xFCber","gegenuber","w\xE4hrend","wahrend","wegen","trotz","statt","innerhalb","au\xDFerhalb","ausserhalb"]),fc=class{constructor(){this.name="german-keyword";}setContext(t){this.context=t;}canExtract(t,e){return dc(t[e])}extract(t,e){if(!this.context)throw new Error("GermanKeywordExtractor: context not set");return this.extractGermanWord(t,e)}extractGermanWord(t,e){if(!this.context)return null;let r=e,i="";for(;r<t.length&&mc(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=pc.has(n),o=this.context.lookupKeyword(i),s=o&&o.normalized!==o.native?o.normalized:void 0,u;if(!o&&this.context.normalizer){let l=this.context.normalizer.normalize(i);if(l.stem!==i&&l.confidence>=.7){let c=this.context.lookupKeyword(l.stem);c&&(u=c.normalized);}}return {value:i,length:r-e,metadata:{normalized:s||u,isPreposition:a}}}};function yc(){return [new fc]}var hc=[{native:"wahr",normalized:"true"},{native:"falsch",normalized:"false"},{native:"null",normalized:"null"},{native:"undefiniert",normalized:"undefined"},{native:"erste",normalized:"first"},{native:"erster",normalized:"first"},{native:"erstes",normalized:"first"},{native:"letzte",normalized:"last"},{native:"letzter",normalized:"last"},{native:"letztes",normalized:"last"},{native:"n\xE4chste",normalized:"next"},{native:"nachste",normalized:"next"},{native:"n\xE4chstgelegene",normalized:"closest"},{native:"nachstgelegene",normalized:"closest"},{native:"vorherige",normalized:"previous"},{native:"eltern",normalized:"parent"},{native:"klick",normalized:"click"},{native:"click",normalized:"click"},{native:"eingabe",normalized:"input"},{native:"\xE4nderung",normalized:"change"},{native:"anderung",normalized:"change"},{native:"absenden",normalized:"submit"},{native:"taste unten",normalized:"keydown"},{native:"taste oben",normalized:"keyup"},{native:"maus dr\xFCber",normalized:"mouseover"},{native:"maus druber",normalized:"mouseover"},{native:"maus weg",normalized:"mouseout"},{native:"fokus",normalized:"focus"},{native:"unsch\xE4rfe",normalized:"blur"},{native:"unscharfe",normalized:"blur"},{native:"scrollen",normalized:"scroll"},{native:"meine",normalized:"my"},{native:"meinen",normalized:"my"},{native:"ergebnis",normalized:"result"},{native:"ziel",normalized:"target"},{native:"sekunde",normalized:"s"},{native:"sekunden",normalized:"s"},{native:"millisekunde",normalized:"ms"},{native:"millisekunden",normalized:"ms"},{native:"minute",normalized:"m"},{native:"minuten",normalized:"m"},{native:"stunde",normalized:"h"},{native:"stunden",normalized:"h"},{native:"hinzufugen",normalized:"add"},{native:"hinzufgen",normalized:"add"},{native:"loschen",normalized:"remove"},{native:"anhangen",normalized:"append"},{native:"erhohen",normalized:"increment"},{native:"ubergang",normalized:"transition"},{native:"auslosen",normalized:"trigger"},{native:"zuruckgeben",normalized:"return"},{native:"anschliessend",normalized:"then"},{native:"erh\xF6he",normalized:"increment"},{native:"erhohe",normalized:"increment"},{native:"verringere",normalized:"decrement"},{native:"inklusiv",normalized:"inclusive"},{native:"exklusiv",normalized:"exclusive"},{native:"Zeichen",normalized:"characters"},{native:"zuf\xE4llig",normalized:"random"}],vc=class extends ze{constructor(){super(),this.language="de",this.direction="ltr",this.initializeKeywordsFromProfile(Ci,hc),this.normalizer=new Ai,this.registerExtractors(lc()),this.registerExtractor(new Ee),this.registerExtractor(new ge),this.registerExtractors(yc()),this.registerExtractor(new Ql),this.registerExtractor(new rc);}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('"')||t.startsWith("'")||/^\d/.test(t)?"literal":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},Ec=new vc;be("de",Ec,Ci);function fr(t){let e=t.getAttribute("data-lang");if(e)return pr(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return pr(r);let i=t.closest?.("[lang]")?.getAttribute("lang");if(i)return pr(i);let n=typeof document<"u"?document.documentElement?.lang:null;return n&&n!=="en"?pr(n):null}function pr(t){return t.split("-")[0].toLowerCase()}var xi={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 yr(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):rr(r));let i=t.roles.get("source");if(i&&e.push("from",rr(i)),t.body&&t.body.length>0){let n=t.body.map(yr);e.push(n.join(" "));}return e.join(" ")}function wc(t){let e=t.chainType==="async"?"async":t.chainType,r=t.statements.map(yr),i=r[0]??"";for(let n=1;n<r.length;n++){let a=t.statements[n-1],o=t.statements[n],s=a.kind==="command"&&gc.has(a.action),u=a.kind==="command"&&a.action==="bind"&&o.kind==="command"&&o.action==="bind";a.kind==="command"&&zc.has(a.action)&&(i+=" end"),i+=(s||u?" ":` ${e} `)+r[n];}return i}function bc(t){let e=xi[t.action];if(e){let i=[t.action];for(let[n,a]of e){let o=t.roles.get(n);o&&((n==="destination"||n==="source")&&o.type==="reference"&&o.value==="me"||(a&&i.push(a),i.push(rr(o))));}return i.join(" ")}let r=[t.action];for(let[,i]of t.roles)r.push(rr(i));return r.join(" ")}function rr(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=rr(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 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 Dc(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 Si(t){function e(n,a,o){try{return t.isLanguageRegistered(a)?t.translateSingle(n,a,o):null}catch{return null}}function r(n,a,o){try{let s=o(n,a);return s!==n?s:null}catch{return null}}function i(n,a,o){if(o.strategy==="semantic"||o.strategy==="auto"){let s=xc(o.confidenceThreshold,a),u=e(n,a,s);if(u!==null)return u}if((o.strategy==="auto"||o.strategy==="i18n")&&o.i18nToEnglish){let s=r(n,a,o.i18nToEnglish);if(s!==null)return s}return null}return function(a,o,s={}){if(o==="en")return a;let u={...Ac,...s},l=i(a,o,u);if(l!==null)return l;let c=Dc(a);if(c){let d=i(c.commands,o,u);if(d!==null)return c.prefix+d}return a}}var Ur=Si({isLanguageRegistered:Nt,translateSingle(t,e,r){let i=ti(t,e);return i.confidence<r||!i.node?null:yr(i.node)}});var Gr=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 Di(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(a=>`[${a}]`),'script[type="text/hyperscript"]'].join(", "),n=a=>{if(Gr.has(a))return;if(a instanceof HTMLScriptElement&&a.type==="text/hyperscript"){let l=a.textContent??"";if(!l)return;let c=e(l,a);Gr.add(a),c!=null&&c!==l&&(a.textContent=c);return}let o=Tc(a,r);if(!o)return;let s=a.getAttribute(o);if(!s)return;let u=e(s,a);Gr.add(a),u!=null&&u!==s&&a.setAttribute(o,u);};t.addBeforeProcessHook(a=>{!a||typeof a.querySelectorAll!="function"||(typeof a.matches=="function"&&a.matches(i)&&n(a),a.querySelectorAll(i).forEach(n));});}function Ti(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 Bi=new Set;function Fi(t,e,r){Bi.has(t)||(Bi.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;Di(i,(n,a)=>{let o=Fc(a,t);if(!o||o==="en")return n;let s=Ur(n,o,t);if(s!==n){if(t.validateWithHost!==false&&!Ti(i,s))return t.debug?console.log(`[hyperscript-i18n] ${o}: host rejected "${s}" \u2014 keeping "${n}"`):Fi(o,n,s),n;t.debug&&console.log(`[hyperscript-i18n] ${o}: "${n}" \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=fr(t);return r||(e.defaultLanguage??null)}function Ri(t,e,r={}){return e==="en"?t:Ur(t,e,r)}Pt(t=>ci(t));function Oi(){typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(Yr());}var E0=["es","pt","fr","de"];Oi();
5
- exports.plugin=Yr;exports.preprocess=Ri;exports.resolveLanguage=fr;exports.supportedLanguages=E0;return exports;})({});
1
+ var HyperscriptI18n=(function(exports){'use strict';function xe(t,e){return e?{type:"literal",value:t,dataType:e}:{type:"literal",value:t}}function Or(t,e){return e?{type:"selector",value:t,selectorKind:e}:{type:"selector",value:t}}function yr(t){return {type:"reference",value:t}}function Rr(t,e){return {type:"property-path",object:t,property:e}}var Ht=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function nt(t,e=Ht){return e.has(t)}var ba=class{constructor(t){this.namespace=t,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let t=process.env.DEBUG||"";return t==="*"||t.includes("framework:*")||t.includes(`framework:${this.namespace}`)}return false}log(t,e,...r){if(!this.enabled)return;let i=`[framework:${this.namespace}]`,n=new Date().toISOString();switch(t){case "debug":console.debug(`${n} ${i} DEBUG:`,e,...r);break;case "info":console.info(`${n} ${i} INFO:`,e,...r);break;case "warn":console.warn(`${n} ${i} WARN:`,e,...r);break;case "error":console.error(`${n} ${i} ERROR:`,e,...r);break}}debug(t,...e){this.log("debug",t,...e);}info(t,...e){this.log("info",t,...e);}warn(t,...e){this.log("warn",t,...e);}error(t,...e){this.log("error",t,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function Ca(t){return new ba(t)}function rr(t,e){return !e||e.length===0||e.includes(t)||e.includes("expression")?true:t==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function Aa(t,e){return t?.possessive?.keywords?.[e]}var hr=class tr{constructor(){this.logger=Ca("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,i){let n=e.mark(),a=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let u=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)u.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",u),this.logger.debug("Profile code:",i?.code);}this.currentProfile=i,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(r.template.tokens,null,2));let o=this.matchTokenSequence(e,r.template.tokens,a);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(a.entries()).map(([u,l])=>[u,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(n),null;let s=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-n.position,confidence:s}}matchBest(e,r,i){let n=[];for(let o of r){let s=e.mark(),u=this.matchPattern(e,o,i);u&&n.push(u),e.reset(s);}if(n.length===0)return null;n.sort((o,s)=>{let u=s.pattern.priority-o.pattern.priority;if(u!==0)return u;let l=s.confidence-o.confidence;return Math.abs(l)>.001?l:s.consumedTokens-o.consumedTokens});let a=n[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,i,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let s=null,u=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let d=e.peek();if(this.logger.debug(" >> Current input token:",d?JSON.stringify({type:d.type,value:d.value,kind:d.kind}):"EOF"),c.type==="role"&&c.greedy){let v=this.collectStopMarkers(r,l+1);if(n)for(let E of n)v.add(E);let h=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||this.isStopMarker(E,v))break;h.push(E.value),e.advance();}if(h.length>0){i.set(c.role,{type:"expression",raw:h.join(" ")}),s=null,u=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let v=this.collectStopMarkers(r,l+1);if(n)for(let E of n)v.add(E);if(this.matchGroupToken(e,c,i,v)){s=null,u=null;continue}if(this.isOptional(c))continue;return false}let m=c.type==="role"&&c.optional===true,p=m?e.mark():null;if(c.type==="role"&&!m){let v=l+1<r.length?r[l+1]:null;if(v?.type==="literal"){let h=e.peek();if(h&&this.getMatchType(h,v.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(c))continue;if(s&&u){this.logger.debug(" >> BACKTRACKING: undoing optional role",u),e.reset(s),i.delete(u),s=null,u=null;let E=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",E),E)continue}return false}}}let y=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Match result:",y),y){m?(s=p,u=c.role):(s=null,u=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(s&&u){this.logger.debug(" >> BACKTRACKING: undoing optional role",u),e.reset(s),i.delete(u),s=null,u=null;let v=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",v),v)continue}return false}}return true}matchPatternToken(e,r,i){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,i);case "group":return this.matchGroupToken(e,r,i);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",i?JSON.stringify({type:i.type,value:i.value,kind:i.kind}):"null"),!i)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let n=this.getMatchType(i,r.value);if(this.logger.debug(" >>> matchType for",i.value,"vs",r.value,":",n),n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(i,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,i){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",r.role),this.logger.debug(" >>> matchRoleToken: expected types",r.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",r.optional),this.skipNoiseWords(e);let n=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null"),!n)return r.optional||false;let a=this.tryMatchPossessiveExpression(e);if(a)return r.expectedTypes&&r.expectedTypes.length>0&&!rr(a.type,r.expectedTypes)?r.optional||false:(i.set(r.role,a),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!rr(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&&!rr(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&&!rr(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&&!rr(l.type,r.expectedTypes)?r.optional||false:(i.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null");let c=this.tokenToSemanticValue(n);return this.logger.debug(" >>> tokenToSemanticValue returned:",c?JSON.stringify(c):"null"),c?(this.logger.debug(" >>> Validating type:",c.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!rr(c.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),i.set(r.role,c),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=r.normalized||r.value,n=this.safeToLowerCase(i),a=Aa(this.currentProfile,n);if(!a)return null;let o=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(o),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let u=s.value;s.kind==="selector"&&u.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u)&&(u=u.substring(1));let l=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),Rr(yr(a),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(i),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<tr.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}s.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=`${r.value}.${a.value}`,s=1;for(;!e.isAtEnd()&&s<tr.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<tr.MAX_METHOD_ARGS;){let m=e.peek();if(!m)break;if(m.kind==="punctuation"&&m.value===")"){if(c===0){e.advance();break}c--;}if(m.kind==="punctuation"&&m.value==="("&&c++,m.kind==="punctuation"&&m.value===","){e.advance();continue}l.push(m.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="punctuation"||n.value!=="'s")return e.reset(i),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"&&a.kind!=="identifier"?(e.reset(i),null):(e.advance(),Rr(Or(r.value),a.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(i),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return Rr(Or(r.value),o)}matchGroupToken(e,r,i,n){let a=e.mark(),o=new Set(i.keys());if(this.matchTokenSequence(e,r.tokens,i,n))return true;e.reset(a);for(let l of i.keys())o.has(l)||i.delete(l);if(!r.optional)return false;let u=this.getGroupLeadingMarker(r);if(u)for(let l=1;l<=tr.MAX_MARKER_SCAN;l++){let c=e.peek(l);if(!c)break;if((c.normalized||c.value).toLowerCase()===u){this.logger.debug(" >> MARKER SCAN: found",u,"at offset",l,"- skipping intervening tokens");for(let p=0;p<l;p++)e.advance();if(this.matchTokenSequence(e,r.tokens,i,n))return true;e.reset(a);for(let p of i.keys())o.has(p)||i.delete(p);break}}return true}getGroupLeadingMarker(e){let r=e.tokens[0];return r?.type==="literal"?r.value.toLowerCase():null}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===r.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,r){let i=new Set;for(let n=r;n<e.length;n++){let a=e[n];if(a.type==="literal"){if(i.add(a.value.toLowerCase()),a.alternatives)for(let o of a.alternatives)i.add(o.toLowerCase());break}if(a.type==="group"){for(let o of a.tokens)if(o.type==="literal"){if(i.add(o.value.toLowerCase()),o.alternatives)for(let s of o.alternatives)i.add(s.toLowerCase());break}if(!a.optional)break}}return i}isStopMarker(e,r){return r.size===0?false:!!(r.has(e.value.toLowerCase())||e.normalized&&r.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return Or(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return xe(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return yr(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return xe(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let n=e.slice(1,-1);return xe(n,"string")}if(e==="true")return xe(true,"boolean");if(e==="false")return xe(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?xe(e,"duration"):xe(n,"number")}let i=parseFloat(e);return isNaN(i)?xe(e,"string"):xe(i,"number")}applyExtractionRules(e,r){for(let[i,n]of Object.entries(e.extraction))r.has(i)||(n.value!==void 0?r.set(i,{type:"literal",value:n.value}):n.default&&r.set(i,n.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let i=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")n+=1,r.has(l.role)&&(i+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let d=a(c.role),m=.8;n+=m,r.has(c.role)?i+=m:d&&(i+=m*.6);}}let o=n>0?i/n:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let s=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+s);let u=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+u)),o}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let r=e.template.tokens[0];if(!r||r.type!=="literal")return 0;let i=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(i.has(r.value))return .15;if(r.alternatives){for(let n of r.alternatives)if(i.has(n))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let i=0,n={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[a,o]of r.entries()){let s=n[a];if(!s||s.length===0)continue;let u="metadata"in o?o.metadata:void 0;if(u&&typeof u.prepositionValue=="string"){let l=u.prepositionValue;s.includes(l)?i+=.1:i-=.1;}}return Math.max(-0.1,Math.min(.1,i))}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=this.safeToLowerCase(r.value);if(tr.ENGLISH_NOISE_WORDS.has(i)){let n=e.mark();e.advance();let a=e.peek();if(a&&a.kind==="selector")return;e.reset(n);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(i=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return i?r:void 0}};hr.MAX_MARKER_SCAN=3;hr.MAX_PROPERTY_DEPTH=10;hr.MAX_METHOD_ARGS=20;hr.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var xa=hr;new xa;var _e=class{constructor(){this.name="string-literal";}canExtract(t,e){let r=t[e];return r==="'"&&e>0&&/[\p{L}\p{M}\p{N}_)\]]/u.test(t[e-1])?false:r==='"'||r==="'"||r==="`"||r==="\u201C"||r==="\u2018"}extract(t,e){let r=t[e];if(r==="\u201C"){let a=1;for(;e+a<t.length;){if(t[e+a]==="\u201D")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}if(r==="\u2018"){let a=1;for(;e+a<t.length;){if(t[e+a]==="\u2019")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}let i=1,n=false;for(;e+i<t.length;){let a=t[e+i];if(n){n=false,i++;continue}if(a==="\\"){n=true,i++;continue}if(a===r)return i++,{value:t.substring(e,e+i),length:i};i++;}return null}},Ie=class{constructor(){this.name="number";}canExtract(t,e){return /\d/.test(t[e])}extract(t,e){let r=0,i=false;for(;e+r<t.length;){let o=t[e+r];if(/\d/.test(o))r++;else if(o==="."&&!i)i=true,r++;else break}if(r===0)return null;let n=t.substring(e,e+r),a=e+r;if(a<t.length){let o=t.slice(a),s=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of s)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:n+"ms",length:r+2,metadata:{hasTimeUnit:true}};let u=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of u)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:n+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:n,length:r}}};function Sa(t){return "setContext"in t&&typeof t.setContext=="function"}function Da(t){let e={language:t.language,direction:t.direction,lookupKeyword:t.lookupKeyword.bind(t),isKeyword:t.isKeyword.bind(t),isKeywordStart:t.isKeywordStart.bind(t),...t.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:t.isKeywordStartAtBoundary.bind(t)}:{}};return t.normalizer?{...e,normalizer:t.normalizer}:e}var de=class{constructor(t,e){this.pos=0,this.tokens=t,this.language=e;}peek(t=0){let e=this.pos+t;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(t){this.pos=t.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(t){let e=[];for(;!this.isAtEnd()&&t(this.peek());)e.push(this.advance());return e}skipWhile(t){for(;!this.isAtEnd()&&t(this.peek());)this.advance();}};function ee(t,e){return {start:t,end:e}}function re(t,e,r,i){if(typeof t=="object"){let{value:a,kind:o,position:s,normalized:u,stem:l,stemConfidence:c,metadata:d}=t;return {value:a,kind:o,position:s,...u!==void 0&&{normalized:u},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...d!==void 0&&{metadata:d}}}let n=t;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof i=="string")return {value:n,kind:e,position:r,normalized:i};if(i){let{normalized:a,stem:o,stemConfidence:s,metadata:u}=i;return {value:n,kind:e,position:r,...a!==void 0&&{normalized:a},...o!==void 0&&{stem:o},...s!==void 0&&{stemConfidence:s},...u!==void 0&&{metadata:u}}}return {value:n,kind:e,position:r}}function He(t){return /\s/.test(t)}function Ba(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function Ta(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function Ke(t){return /\d/.test(t)}function Lr(t){return t.replace(/[\u064b-\u0652\u0670]/g,"")}function Fa(t){return /[a-zA-Z]/.test(t)}function fe(t){return /[a-zA-Z0-9_-]/.test(t)}function Oa(t,e){if(e>=t.length)return null;let r=t[e];if(!Ba(r))return null;let i=e,n="";if(r==="#"||r==="."){for(n+=t[i++];i<t.length&&fe(t[i]);)n+=t[i++];if(n.length<=1)return null;if(i<t.length&&t[i]==="."&&r==="#"){let o=i+1;for(;o<t.length&&fe(t[o]);)o++;if(o<t.length&&t[o]==="(")return n}}else if(r==="["){let a=1,o=false,s=null,u=false;for(n+=t[i++];i<t.length&&a>0;){let l=t[i];n+=l,u?u=false:l==="\\"?u=true:o?l===s&&(o=false,s=null):l==='"'||l==="'"||l==="`"?(o=true,s=l):l==="["?a++:l==="]"&&a--,i++;}if(a!==0)return null}else if(r==="@"){for(n+=t[i++];i<t.length&&fe(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="*"){for(n+=t[i++];i<t.length&&fe(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="<"){if(n+=t[i++],i>=t.length||!Fa(t[i]))return null;for(;i<t.length&&fe(t[i]);)n+=t[i++];for(;i<t.length;){let a=t[i];if(a==="."){if(n+=t[i++],i>=t.length||!fe(t[i]))return null;for(;i<t.length&&fe(t[i]);)n+=t[i++];}else if(a==="#"){if(n+=t[i++],i>=t.length||!fe(t[i]))return null;for(;i<t.length&&fe(t[i]);)n+=t[i++];}else if(a==="["){let o=1,s=false,u=null,l=false;for(n+=t[i++];i<t.length&&o>0;){let c=t[i];n+=c,l?l=false:c==="\\"?l=true:s?c===u&&(s=false,u=null):c==='"'||c==="'"||c==="`"?(s=true,u=c):c==="["?o++:c==="]"&&o--,i++;}if(o!==0)return null}else break}for(;i<t.length&&He(t[i]);)n+=t[i++];if(i<t.length&&t[i]==="/")for(n+=t[i++];i<t.length&&He(t[i]);)n+=t[i++];if(i>=t.length||t[i]!==">")return null;n+=t[i++];}return n||null}function Ra(t,e){if(e>=t.length||t[e]!=="'"||e+1>=t.length||t[e+1].toLowerCase()!=="s")return false;if(e+2>=t.length)return true;let i=t[e+2];return He(i)||i==="*"||!fe(i)}function Pa(t,e){if(e>=t.length)return null;let r=t[e];if(!Ta(r)||r==="'"&&Ra(t,e))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!n)return null;let a=e+1,o=r,s=false;for(;a<t.length;){let u=t[a];if(o+=u,s)s=false;else if(u==="\\")s=true;else if(u===n)return o;a++;}return o}function La(t,e){if(e>=t.length)return false;let r=t[e],i=t[e+1]||"",n=t[e+2]||"";if(r==="/"&&i!=="/"&&/[a-zA-Z0-9._-]/.test(i)||r==="/"&&i==="/"&&/[a-zA-Z]/.test(n)||r==="."&&(i==="/"||i==="."&&n==="/"))return true;let a=t.slice(e,e+8).toLowerCase();return !!(a.startsWith("http://")||a.startsWith("https://"))}function Na(t,e){if(!La(t,e))return null;let r=e,i="",n=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<t.length;){let a=t[r];if(a==="#"){if(i.length>0&&/[a-zA-Z0-9/.]$/.test(i))for(i+=a,r++;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)i+=t[r++];break}if(n.test(a))i+=a,r++;else break}return i.length<2?null:i}function Ma(t,e){if(e>=t.length)return null;let r=t[e];if(!Ke(r)&&r!=="-"&&r!=="+")return null;let i=e,n="";if((t[i]==="-"||t[i]==="+")&&(n+=t[i++]),i>=t.length||!Ke(t[i]))return null;for(;i<t.length&&Ke(t[i]);)n+=t[i++];if(i<t.length&&t[i]===".")for(n+=t[i++];i<t.length&&Ke(t[i]);)n+=t[i++];return i<t.length&&(t.slice(i,i+2)==="ms"?n+="ms":(t[i]==="s"||t[i]==="m"||t[i]==="h")&&(n+=t[i])),n}var _a=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(_a);var Ia=new Set(["patient","destination","source","style","event","eventMarker","agent","goal","manner","into","from","to","with","at","of","as","by","in","on","over","under","between","through","without"]);function $a(t){return t.includes("-")&&/^[\p{L}\p{N}_]+(-[\p{L}\p{N}_]+)+$/u.test(t)}var ja=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],Nr=class Pr{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){Sa(e)&&e.setContext(Da(this)),this.extractors.push(e);}registerExtractors(e){for(let r of e)this.registerExtractor(r);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let r=[],i=0;for(;i<e.length;){for(;i<e.length&&He(e[i]);)i++;if(i>=e.length)break;let n=this.tryMultiWordKeyword(e,i);if(n){r.push(n),i=n.position.end;continue}let a=false;for(let o of this.extractors)if(o.canExtract(e,i)){let s=o.extract(e,i);if(s){let u=s.metadata?.normalized,l=s.metadata?.stem,c=s.metadata?.stemConfidence,d={};if(s.metadata)for(let[p,f]of Object.entries(s.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(d[p]=f);let m={};u&&(m.normalized=u),l&&(m.stem=l),c!==void 0&&(m.stemConfidence=c),Object.keys(d).length>0&&(m.metadata=d),r.push(re(s.value,this.classifyToken(s.value),ee(i,i+s.length),Object.keys(m).length>0?m:void 0)),i+=s.length,a=true;break}}if(!a){let o=e[i],s=this.classifyUnknownChar(o);r.push(re(o,s,ee(i,i+1))),i++;}}return new de(this.mergeColonQualifiedNames(r),this.language)}mergeColonQualifiedNames(e){let r=[];for(let i of e){let n=r[r.length-1];if(n&&Pr.ASCII_WORD.test(n.value)&&Pr.COLON_QUALIFIER.test(i.value)&&n.position.end===i.position.start){let a=n.value+i.value;r[r.length-1]=re(a,this.classifyToken(a),ee(n.position.start,i.position.end));continue}r.push(i);}return r}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,i){if(e[r]!==".")return false;let n=i[i.length-1],a=n&&n.position.end<r;if(n&&!a&&(n.kind==="identifier"||n.kind==="keyword"||n.kind==="selector"))return i.push(re(".","operator",ee(r,r+1))),true;let u=r+1;for(;u<e.length&&fe(e[u]);)u++;return u<e.length&&e[u]==="("?(i.push(re(".","operator",ee(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let i=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[n,a]of Object.entries(e.keywords))if(i.set(a.primary,{native:a.primary,normalized:a.normalized||n}),a.alternatives)for(let o of a.alternatives)i.set(o,{native:o,normalized:a.normalized||n});}if(e.references){for(let[n,a]of Object.entries(e.references))i.set(a,{native:a,normalized:n});for(let n of Object.keys(e.references))i.has(n)||i.set(n,{native:n,normalized:n});}if(e.roleMarkers){for(let[n,a]of Object.entries(e.roleMarkers))if(a.primary&&i.set(a.primary,{native:a.primary,normalized:n}),a.alternatives)for(let o of a.alternatives)i.set(o,{native:o,normalized:n});}if(e.possessive?.keywords)for(let[n,a]of Object.entries(e.possessive.keywords))i.set(n,{native:n,normalized:a});for(let n of ja)i.has(n)||i.set(n,{native:n,normalized:n});for(let n of r)i.set(n.native,n);this.profileKeywords=Array.from(i.values()).sort((n,a)=>a.native.length-n.native.length),this.multiWordKeywords=this.profileKeywords.filter(n=>(n.native.includes(" ")||$a(n.native))&&!Ia.has(n.normalized)),this.profileKeywordMap=new Map;for(let n of this.profileKeywords){this.profileKeywordMap.set(n.native.toLowerCase(),n);let a=this.removeDiacritics(n.native);a!==n.native&&!this.profileKeywordMap.has(a.toLowerCase())&&this.profileKeywordMap.set(a.toLowerCase(),n);}}removeDiacritics(e){return Lr(e)}tryProfileKeyword(e,r){for(let i of this.profileKeywords)if(e.slice(r).startsWith(i.native))return re(i.native,"keyword",ee(r,r+i.native.length),i.normalized);return null}tryMultiWordKeyword(e,r,i=n=>/[\p{L}\p{N}_]/u.test(n)){if(this.multiWordKeywords.length===0)return null;let n=e.slice(r);for(let a of this.multiWordKeywords){if(!n.startsWith(a.native))continue;let o=e[r+a.native.length];if(!(o!==void 0&&i(o)))return re(a.native,"keyword",ee(r,r+a.native.length),a.normalized)}return null}isKeywordStart(e,r){let i=e.slice(r);return this.profileKeywords.some(n=>i.startsWith(n.native))}isKeywordStartAtBoundary(e,r,i=n=>/[\p{L}\p{N}_]/u.test(n)){let n=e.slice(r);return this.profileKeywords.some(a=>{if(!n.startsWith(a.native))return false;let o=e[r+a.native.length];return o===void 0||!i(o)})}lookupKeyword(e){let r=this.profileKeywordMap.get(e.toLowerCase());if(r)return r;let i=this.removeDiacritics(e);if(i!==e)return this.profileKeywordMap.get(i.toLowerCase())}isKeyword(e){return this.lookupKeyword(e)!==void 0}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let r=this.normalizer.normalize(e);return r.stem!==e&&r.confidence>=.7?r:null}tryMorphKeywordMatch(e,r,i){let n=this.tryNormalize(e);if(!n)return null;let a=this.lookupKeyword(n.stem);if(!a)return null;let o={normalized:a.normalized,stem:n.stem,stemConfidence:n.confidence};return re(e,"keyword",ee(r,i),o)}trySelector(e,r){let i=Oa(e,r);return i?re(i,"selector",ee(r,r+i.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let i=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!i)return null;let n=i[0].replace(/(\s|\.)$/,""),a=n.slice(1).split("(")[0],o=i[1];return {...re(n,"event-modifier",ee(r,r+n.length)),metadata:{modifierName:a,value:o?a==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let i=Pa(e,r);return i?re(i,"literal",ee(r,r+i.length)):null}tryNumber(e,r){let i=Ma(e,r);return i?re(i,"literal",ee(r,r+i.length)):null}tryMatchTimeUnit(e,r,i,n=false){let a=r;if(n)for(;a<e.length&&He(e[a]);)a++;let o=e.slice(a);for(let s of i){let u=o.slice(0,s.length);if(s.caseInsensitive?u.toLowerCase()===s.pattern.toLowerCase():u===s.pattern){if(s.notFollowedBy&&(o[s.length]||"")===s.notFollowedBy)continue;if(s.checkBoundary){let c=o[s.length]||"";if(fe(c))continue}return {suffix:s.suffix,endPos:a+s.length}}}return null}parseBaseNumber(e,r,i=true){let n=r,a="";if(i&&(e[n]==="-"||e[n]==="+")&&(a+=e[n++]),n>=e.length||!Ke(e[n]))return null;for(;n<e.length&&Ke(e[n]);)a+=e[n++];if(n<e.length&&e[n]===".")for(a+=e[n++];n<e.length&&Ke(e[n]);)a+=e[n++];return !a||a==="-"||a==="+"?null:{number:a,endPos:n}}tryNumberWithTimeUnits(e,r,i,n={}){let{allowSign:a=true,skipWhitespace:o=false}=n,s=this.parseBaseNumber(e,r,a);if(!s)return null;let{number:u,endPos:l}=s,c=[...i,...Pr.STANDARD_TIME_UNITS],d=this.tryMatchTimeUnit(e,l,c,o);return d&&(u+=d.suffix,l=d.endPos),re(u,"literal",ee(r,l))}tryUrl(e,r){let i=Na(e,r);return i?re(i,"url",ee(r,r+i.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!fe(e[r+1]))return null;let i=r+1;for(;i<e.length&&fe(e[i]);)i++;let n=e.slice(r,i);return re(n,"identifier",ee(r,i))}tryOperator(e,r){let i=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(i))return re(i,"operator",ee(r,r+2));let n=e[r];return ["<",">","!","+","-","*","/","="].includes(n)?re(n,"operator",ee(r,r+1)):["(",")","{","}",",",";",":"].includes(n)?re(n,"punctuation",ee(r,r+1)):null}tryMultiCharParticle(e,r,i){for(let n of i)if(e.slice(r,r+n.length)===n)return re(n,"particle",ee(r,r+n.length));return null}};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 $e=Nr;function be(t){return {stem:t,confidence:1}}function oe(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}var Zt=class{constructor(t){this.language=t.language,this.config={minWordLength:3,minStemLength:2,...t};}normalize(t){let e=t.toLowerCase();if(this.isAlreadyNormalized(e))return be(t);if(this.config.reflexiveSuffixes){let r=this.tryReflexiveNormalization(e);if(r)return r}if(this.config.endings){let r=this.tryConjugationEndings(e);if(r)return r}if(this.config.suffixRules){let r=this.trySuffixRules(e);if(r)return r}if(this.config.prefixRules){let r=this.tryPrefixRules(e);if(r)return r}return be(t)}isAlreadyNormalized(t){return this.config.infinitiveEndings?this.config.infinitiveEndings.some(e=>t.endsWith(e)):false}tryReflexiveNormalization(t){let e=this.config.reflexiveSuffixes;if(!e)return null;for(let r of e){if(!t.endsWith(r))continue;let i=t.slice(0,-r.length);if(this.isAlreadyNormalized(i))return oe(i,.88,{removedSuffixes:[r],conjugationType:"reflexive"});let n=this.tryConjugationEndings(i)||this.trySuffixRules(i);if(n&&n.stem!==i)return oe(n.stem,n.confidence*.95,{removedSuffixes:[r,...n.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationEndings(t){let e=this.config.endings;if(!e)return null;let r=this.config.minStemLength??2;for(let i of e){if(!t.endsWith(i.ending))continue;let n=t.slice(0,-i.ending.length);if(n.length<r)continue;let a=n+i.stem;return oe(a,i.confidence,{removedSuffixes:[i.ending],conjugationType:i.type})}return null}trySuffixRules(t){let e=this.config.suffixRules;if(!e)return null;let r=this.config.minStemLength??2;for(let i of e){if(!t.endsWith(i.pattern))continue;let n=t.slice(0,-i.pattern.length),a=i.minStemLength??r;if(n.length<a)continue;let o=n+(i.replacement||"");return oe(o,i.confidence,{removedSuffixes:[i.pattern],...i.conjugationType&&{conjugationType:i.conjugationType}})}return null}tryPrefixRules(t){let e=this.config.prefixRules;if(!e)return null;for(let r of e){if(!t.startsWith(r.pattern))continue;let i=t.slice(r.pattern.length),n=r.minRemaining??this.config.minStemLength??2;if(!(i.length<n))return oe(i,1-r.confidencePenalty,{removedPrefixes:[r.pattern]})}return null}};var Va=Object.defineProperty,Wa=Object.getOwnPropertyNames,Li=(t,e)=>function(){return t&&(e=(0, t[Wa(t)[0]])(t=0)),e},qa=(t,e)=>{for(var r in e)Va(t,r,{get:e[r],enumerable:true});};function Yt(t,e){return t.replace(/\{(\w+)\}/g,(r,i)=>String(e[i]??`{${i}}`))}function Ee(t,e,r={},i){let n=Ni[t],a=Yt(n,r),o=Mi[t],s=o?Yt(o,r):void 0;return {code:t,message:a,severity:e,...i&&{role:i},...s&&{suggestion:s}}}var P,Ni,Mi,Ka=Li({"src/generators/schema-error-codes.ts"(){P={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},Ni={[P.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[P.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[P.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[P.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[P.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[P.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[P.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[P.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[P.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[P.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[P.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[P.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[P.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[P.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[P.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[P.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[P.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Mi={[P.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[P.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[P.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[P.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[P.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[P.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[P.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[P.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[P.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[P.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[P.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[P.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[P.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[P.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),_i={};qa(_i,{SchemaErrorCodes:()=>P,formatValidationResults:()=>Ja,getValidationStats:()=>Qa,validateAllKeywordCollisions:()=>to,validateAllSchemas:()=>Xa,validateCommandSchema:()=>Ii,validateKeywordCollisions:()=>$i,validateRoleValues:()=>eo});function Ha(t,e){return {action:t,items:e}}function Ii(t){let e=[];for(let i of t.roles)i.expectedTypes.includes("literal")&&i.expectedTypes.includes("selector")&&(i.role==="patient"&&mt.has(t.action)?e.push(Ee(P.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:i.role,command:t.action},i.role)):e.push(Ee(P.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:i.role},i.role))),i.expectedTypes.length>3&&!mt.has(t.action)&&e.push(Ee(P.TOO_MANY_EXPECTED_TYPES,"warning",{role:i.role,count:i.expectedTypes.length},i.role));for(let i of t.roles)i.selectorKinds&&i.selectorKinds.length>0&&(i.expectedTypes.includes("selector")||e.push(Ee(P.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:i.role},i.role)));switch(t.action){case "transition":Ua(t,e);break;case "on":Ga(t,e);break;case "if":case "unless":Za(t,e);break;case "repeat":case "for":case "while":Ya(t,e);break}return t.roles.filter(i=>i.required).length===0&&(ji.has(t.action)?e.push(Ee(P.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(Ee(P.NO_REQUIRED_ROLES,"warning",{}))),Ha(t.action,e)}function Ua(t,e){let r=t.roles.find(n=>n.role==="patient"),i=t.roles.find(n=>n.role==="goal");r&&!i&&e.push(Ee(P.TRANSITION_MISSING_GOAL,"error",{}));}function Ga(t,e){let r=t.roles.find(i=>i.role==="event");r||e.push(Ee(P.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(Ee(P.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Za(t,e){let r=t.roles.find(i=>i.role==="condition");r||e.push(Ee(P.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(Ee(P.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Ya(t,e){t.action==="for"?t.roles.find(i=>i.role==="source")||e.push(Ee(P.FOR_LOOP_MISSING_SOURCE,"warning",{})):t.action==="while"&&(t.roles.find(i=>i.role==="condition")||e.push(Ee(P.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Xa(t,e={}){let r=new Map,{includeNotes:i=false}=e;for(let[n,a]of Object.entries(t)){let o=Ii(a),s=o.items.some(l=>l.severity==="warning"||l.severity==="error"),u=i&&o.items.some(l=>l.severity==="note");(s||u)&&r.set(n,o);}return r}function Ja(t,e={}){let r=[],{showNotes:i=false,showCodes:n=true}=e;for(let[a,o]of t){let s=o.items.filter(c=>c.severity==="error"),u=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(s.length>0){r.push(` \u274C ${a}:`);for(let c of s){let d=n?` [${c.code}]`:"";r.push(` ERROR${d}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(u.length>0){r.push(` \u26A0\uFE0F ${a}:`);for(let c of u){let d=n?` [${c.code}]`:"";r.push(` ${d?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(i&&l.length>0){r.push(` \u2139\uFE0F ${a}:`);for(let c of l){let d=n?` [${c.code}]`:"";r.push(` ${d?`${c.code}: `:""}${c.message}`);}}}return r.join(`
2
+ `)}function Qa(t){let e=0,r=0,i=0,n={};for(let a of t.values())for(let o of a.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&i++,n[o.code]=(n[o.code]||0)+1;return {totalCommands:t.size,errors:e,warnings:r,notes:i,byCode:n}}function eo(t,e){let r=[];for(let i of e){let n=t.roles.find(a=>a.role===i.role);n&&(n.expectedTypes.length>0&&!n.expectedTypes.includes(i.type)&&(n.expectedTypes.includes("expression")||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects type [${n.expectedTypes.join(", ")}], got '${i.type}'`,code:P.VALUE_TYPE_MISMATCH})),i.type==="selector"&&i.selectorKind&&n.selectorKinds&&n.selectorKinds.length>0&&(n.selectorKinds.includes(i.selectorKind)||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects selector kind [${n.selectorKinds.join(", ")}], got '${i.selectorKind}'`,code:P.SELECTOR_KIND_MISMATCH})));}return r}function ro(t){if(t.length!==2)return false;let[e,r]=[...t].sort();return Vi.some(([i,n])=>i===e&&n===r)}function $i(t){let e=[];if(!t.keywords)return {language:t.code,collisions:e};let r=new Map;for(let[n,a]of Object.entries(t.keywords)){if(!a||!a.primary)continue;let o=r.get(a.primary)||[];if(o.push({command:n,isPrimary:true}),r.set(a.primary,o),a.alternatives)for(let s of a.alternatives){let u=r.get(s)||[];u.push({command:n,isPrimary:false}),r.set(s,u);}}for(let[n,a]of r){let o=[...new Set(a.map(l=>l.command))];if(o.length<=1||ro(o))continue;let s=a.filter(l=>l.isPrimary).length,u;s>=2?u="primary-primary":s===1?u="primary-alternative":u="alternative-alternative",e.push({keyword:n,commands:o.sort(),type:u});}let i={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((n,a)=>i[n.type]-i[a.type]),{language:t.code,collisions:e}}function to(t){let e=[];for(let[,r]of Object.entries(t)){let i=$i(r);i.collisions.length>0&&e.push(i);}return e.sort((r,i)=>r.language.localeCompare(i.language))}var mt,ji,Vi,io=Li({"src/generators/schema-validator.ts"(){Ka(),mt=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),ji=new Set(["compound","else","halt","continue","init","settle","focus","blur","show","hide","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint","live","eventsource","socket","worker","intercept"]),Vi=[["change","changes"]];}});var wt=["is not really equal to","is really equal to","is greater than or equal to","is less than or equal to","is not equal to","is equal to","is greater than","is less than","is not really","is really","is not equal","is equal","is not in","is in","is not","is","am not in","am in","am","does not match","do not match","does not contain","does not contains","do not contain","does not include","does not precede","does not follow","precedes","follows","really equals","equals","matches","match","contains","contain","includes","include","has","have","in"],kt=["is not empty","is empty","does not exist"],bt=["is not an","is not a","is an","is a"],no=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),ao=new Set(["and","or","not","no"]),oo=new Set(["true","false","null","undefined"]),so=new Set(wt.map(t=>t.slice(t.lastIndexOf(" ")+1))),uo=new Set(["next","previous","closest","first","last"]),lo=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function Wi(t){let e=[],r=0,i=1,n=1;function a(){if(e.length===0)return true;let f=e[e.length-1];return f.type==="IDENTIFIER"&&so.has(f.value.toLowerCase())||f.type==="IDENTIFIER"&&uo.has(f.value.toLowerCase())||f.type==="IDENTIFIER"&&f.value.toLowerCase()==="of"?true:["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(f.type)}function o(f=0){return t[r+f]??""}function s(){let f=t[r];return r++,f===`
3
+ `?(i++,n=1):n++,f}function u(){for(;r<t.length&&/\s/.test(t[r]);)s();}function l(f){let y="";for(;r<t.length&&f(t[r]);)y+=s();return y}function c(f){let y=f;for(s();r<t.length&&t[r]!==f;)t[r]==="\\"&&r+1<t.length&&(y+=s()),y+=s();return r<t.length&&(y+=s()),y}function d(){let f="`";for(s();r<t.length&&t[r]!=="`";)t[r]==="\\"&&r+1<t.length&&(f+=s()),f+=s();return r<t.length&&(f+=s()),f}function m(){let f="<";for(s();r<t.length&&(f+=s(),!f.endsWith("/>")););return f}function p(f,y,v){return {type:f,value:y,start:v,end:r,line:i,column:n-y.length}}for(;r<t.length&&(u(),!(r>=t.length));){let f=r,y=o();if(y==="'"&&o(1)==="s"&&!/\w/.test(o(2))){s(),s(),e.push(p("POSSESSIVE","'s",f));continue}if(y==='"'||y==="'"){let v=c(y);e.push(p("STRING",v,f));continue}if(y==="`"){let v=d();e.push(p("TEMPLATE_LITERAL",v,f));continue}if(y==="<"&&/[a-zA-Z.#\[]/.test(o(1))){let v=m();e.push(p("QUERY_SELECTOR",v,f));continue}if(y==="#"&&a()){s();let v=l(h=>/[\w-]/.test(h));e.push(p("ID_SELECTOR","#"+v,f));continue}if(y==="."&&/[a-zA-Z_-]/.test(o(1))&&a()){s();let v=l(h=>/[\w-]/.test(h));e.push(p("CLASS_SELECTOR","."+v,f));continue}if(y==="@"&&/[a-zA-Z_]/.test(o(1))){s();let v=l(h=>/[\w-]/.test(h));e.push(p("ATTRIBUTE_REF","@"+v,f));continue}if(y==="["&&a()&&o(1)==="@"){let h="";for(h+=s();r<t.length&&t[r]!=="]";)t[r]==='"'||t[r]==="'"?h+=c(t[r]):h+=s();r<t.length&&(h+=s()),e.push(p("ATTRIBUTE_SELECTOR",h,f));continue}if(y==="["){s(),e.push(p("LBRACKET","[",f));continue}if(y==="]"){s(),e.push(p("RBRACKET","]",f));continue}if(/\d/.test(y)){let v=l(z=>/[\d.]/.test(z)),h=r,E=l(z=>/[a-zA-Z]/.test(z));lo.has(E)?e.push(p("TIME_EXPRESSION",v+E,f)):(r=h,e.push(p("NUMBER",v,f)));continue}if(y==="("){s(),e.push(p("LPAREN","(",f));continue}if(y===")"){s(),e.push(p("RPAREN",")",f));continue}if(y==="{"){s(),e.push(p("LBRACE","{",f));continue}if(y==="}"){s(),e.push(p("RBRACE","}",f));continue}if(y===","){s(),e.push(p("COMMA",",",f));continue}if(y===":"){s(),e.push(p("COLON",":",f));continue}if(y==="."){s(),e.push(p("DOT",".",f));continue}if(y==="|"){s(),e.push(p("PIPE","|",f));continue}if(y==="+"||y==="-"||y==="*"||y==="/"||y==="%"){s(),e.push(p("OPERATOR",y,f));continue}if(y==="="||y==="!"||y==="<"||y===">"){let v=s();o()==="="&&(v+=s()),(v==="=="||v==="!=")&&o()==="="&&(v+=s()),e.push(p("COMPARISON",v,f));continue}if(/[a-zA-Z_$]/.test(y)){let v=l(E=>/[\w$]/.test(E)),h=v.toLowerCase();no.has(h)?e.push(p("CONTEXT_VAR",v,f)):ao.has(h)?e.push(p("LOGICAL",v,f)):oo.has(h)?e.push(p("BOOLEAN",v,f)):e.push(p("IDENTIFIER",v,f));continue}s();}return e.push(p("EOF","",r)),e}var co=new Set(["my","its","your"]),mo={my:"me",its:"it",your:"you"},po=new Set(["is","matches","match","contains","in","exists","does"]),fo=new Set(["next","previous","closest","first","last"]),yo=[...kt,...bt,...wt].map(t=>[t,t.split(" ")]),ho=class{constructor(){this.tokens=[],this.current=0;}parse(t){try{return this.tokens=Wi(t),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(e){return {success:false,error:e instanceof Error?e.message:"Parse error"}}}peek(){return this.tokens[this.current]??{type:"EOF",value:"",start:0,end:0}}peekAt(t){return this.tokens[this.current+t]??{type:"EOF",value:"",start:0,end:0}}previous(){return this.tokens[this.current-1]??{type:"EOF",value:"",start:0,end:0}}isAtEnd(){return this.peek().type==="EOF"}advance(){return this.isAtEnd()||this.current++,this.previous()}check(t){return this.peek().type===t}checkValue(t){return this.peek().value.toLowerCase()===t.toLowerCase()}match(...t){for(let e of t)if(this.check(e))return this.advance(),true;return false}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.checkValue("or");){let e=this.advance().value,r=this.parseAnd();t=this.createBinaryExpression(e,t,r);}return t}parseAnd(){let t=this.parseEquality();for(;this.checkValue("and");){let e=this.advance().value,r=this.parseEquality();t=this.createBinaryExpression(e,t,r);}return t}parseEquality(){let t=this.parseComparison();for(;;){if(this.match("COMPARISON")){let r=this.previous().value;t=this.createBinaryExpression(r,t,this.parseComparison());continue}let e=this.matchComparisonPhrase();if(e===void 0)break;if(kt.includes(e))t=this.createPostfixUnary(e,t);else if(bt.includes(e))t=this.parseTypeCheck(t,e.startsWith("is not"));else {let r=e==="match"?"matches":e;t=this.createBinaryExpression(r,t,this.parseComparison());}}return t}matchComparisonPhrase(){for(let[t,e]of yo)if(e.every((r,i)=>this.peekAt(i).value.toLowerCase()===r)){for(let r=0;r<e.length;r++)this.advance();return t}}parseTypeCheck(t,e){let r=this.advance();if(r.type==="EOF")throw new Error(`Expected a type name after 'is ${e?"not ":""}a'`);let i=true;return this.peek().value==="!"&&(this.advance(),i=false),{type:"typeCheckExpression",value:t,typeName:r.value,nullOk:i,negated:e,start:t.start,end:this.previous().end}}parseComparison(){let t=this.parseAddition();for(;this.check("COMPARISON");){let e=this.advance().value,r=this.parseAddition();t=this.createBinaryExpression(e,t,r);}return t}parseAddition(){let t=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let e=this.advance().value,r=this.parseMultiplication();t=this.createBinaryExpression(e,t,r);}return t}parseMultiplication(){let t=this.parseConversion();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%"||this.checkValue("mod");){let e=this.advance().value.toLowerCase(),r=this.parseConversion();t=this.createBinaryExpression(e,t,r);}return t}parseConversion(){let t=this.parseUnary();for(;this.checkValue("as")&&this.conversionTypeAt(1)!==void 0;)for(this.advance(),t=this.createAsExpression(t,this.parseConversionType());this.check("PIPE")&&this.conversionTypeAt(1)!==void 0;)this.advance(),t=this.createAsExpression(t,this.parseConversionType());return t}conversionTypeAt(t){let e=this.peekAt(t).value.toLowerCase(),r=e==="a"||e==="an"?t+1:t;return this.peekAt(r).type==="IDENTIFIER"?r:void 0}parseConversionType(){let t=this.conversionTypeAt(0)??0;for(let n=0;n<t;n++)this.advance();let e=this.advance(),r=this.peekAt(1).type;if(!this.check("COLON")||r!=="NUMBER"&&r!=="IDENTIFIER")return e;this.advance();let i=this.advance();return {...e,value:`${e.value}:${i.value}`,end:i.end}}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let t=this.advance().value,e=this.parseUnary();return this.createUnaryExpression(t,e)}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance();t=this.createMemberExpression(t,this.createIdentifier(e.value,e),false);}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance();t=this.createPossessiveExpression(t,this.createIdentifier(e.value,e));}else break;else if(this.match("LPAREN")){let e=this.parseArguments();t=this.createCallExpression(t,e);}else if(this.match("LBRACKET")){let e=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");t=this.createMemberExpression(t,e,true);}else if(t.type==="identifier"&&co.has(t.name)&&this.check("IDENTIFIER")&&!po.has(this.peek().value.toLowerCase())){let e=this.advance(),r=t,i={...r,name:mo[r.name]??r.name};t=this.createMemberExpression(i,this.createIdentifier(e.value,e),false);}else if(this.checkValue("exists")&&this.peekAt(1).type!=="LPAREN")this.advance(),t=this.createPostfixUnary("exists",t);else break;return t}parsePrimary(){let t=this.peek();if(this.checkValue("the")&&(this.peekAt(1).type==="IDENTIFIER"||this.peekAt(1).type==="CONTEXT_VAR")&&this.peekAt(2).value.toLowerCase()==="of")return this.advance(),this.parsePropertyOf(this.advance(),t,false);if(this.match("NUMBER"))return this.createLiteral(parseFloat(t.value),"number",t);if(this.match("STRING")){let e=t.value.slice(1,-1);return this.createLiteral(e,"string",t)}if(this.match("BOOLEAN")){let e=t.value==="true"?true:t.value==="false"?false:t.value==="null"?null:void 0,r={true:"boolean",false:"boolean",null:"null",undefined:"undefined"};return this.createLiteral(e,r[t.value]??"string",t)}if(this.match("TEMPLATE_LITERAL")){let e=t.value;return {type:"templateLiteral",value:e.length>=2&&e.startsWith("`")&&e.endsWith("`")?e.slice(1,-1):e,start:t.start,end:t.end,line:t.line,column:t.column}}if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(t);if(this.match("ID_SELECTOR"))return this.createSelector(t.value,"id",t);if(this.match("CLASS_SELECTOR"))return this.createSelector(t.value,"class",t);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(t.value,"attribute",t);if(this.match("ATTRIBUTE_REF")){let e={type:"attributeAccess",attributeName:t.value.slice(1),start:t.start,end:t.end};return this.checkValue("of")?(this.advance(),this.createBinaryExpression("of",e,this.parseConversion())):e}if(this.match("QUERY_SELECTOR")){let e=t.value.slice(1,-2);return this.createSelector(e,"query",t)}if(this.match("CONTEXT_VAR"))return this.createIdentifier(t.value,t);if(this.match("IDENTIFIER")){if(fo.has(t.value.toLowerCase())&&(this.check("CLASS_SELECTOR")||this.check("ID_SELECTOR")||this.check("QUERY_SELECTOR"))){let e=this.advance(),r=e.type==="QUERY_SELECTOR"?e.value.slice(1,-2):e.value,i=e.type==="CLASS_SELECTOR"?"class":e.type==="ID_SELECTOR"?"id":"query";return {type:"callExpression",callee:this.createIdentifier(t.value,t),arguments:[this.createSelector(r,i,e)],start:t.start,end:e.end}}return this.checkValue("of")?this.parsePropertyOf(t,t):this.createIdentifier(t.value,t)}if(this.match("LPAREN")){let e=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return e}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${t.value}`)}parsePropertyOf(t,e,r=true){this.advance();let i=r?this.parseConversion():this.parseUnary();return {type:"propertyOfExpression",property:this.createIdentifier(t.value,t),target:i,start:e.start,end:this.previous().end}}parseArguments(){let t=[];if(!this.check("RPAREN"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return t}parseArrayLiteral(){let t=[],e=this.previous().start;if(!this.check("RBRACKET"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return {type:"arrayLiteral",elements:t,start:e,end:this.previous().end}}parseObjectLiteral(){let t=[],e=this.previous().start;if(!this.check("RBRACE"))do{let r;if(this.check("STRING"))r=this.advance().value.slice(1,-1);else if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR"))r=this.advance().value;else throw new Error("Expected property name");if(!this.match("COLON"))throw new Error("Expected : after property name");let i=this.parseExpression();t.push({key:r,value:i});}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return {type:"objectLiteral",properties:t.map(r=>({type:"objectProperty",key:{type:"identifier",name:r.key},value:r.value})),start:e,end:this.previous().end}}parseTimeExpression(t){let e=t.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!e)throw new Error(`Invalid time expression: ${t.value}`);let r=parseFloat(e[1]),i=e[2].toLowerCase();return {type:"timeExpression",value:r,unit:i,raw:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createLiteral(t,e,r){return {type:"literal",value:t,dataType:e,raw:r.value,start:r.start,end:r.end,line:r.line,column:r.column}}createSelector(t,e,r){return {type:"selector",value:t,selector:t,selectorType:e,start:r.start,end:r.end,line:r.line,column:r.column}}createIdentifier(t,e){return {type:"identifier",name:t,start:e.start,end:e.end,line:e.line,column:e.column}}createMemberExpression(t,e,r){return {type:"memberExpression",object:t,property:e,computed:r,start:t.start,end:this.previous().end}}createPossessiveExpression(t,e){return {type:"possessiveExpression",object:t,property:e,start:t.start,end:this.previous().end}}createBinaryExpression(t,e,r){return {type:"binaryExpression",operator:t,left:e,right:r,start:e.start,end:r.end}}createAsExpression(t,e){return {type:"asExpression",expression:t,targetType:this.createIdentifier(e.value,e),start:t.start,end:e.end}}createUnaryExpression(t,e){return {type:"unaryExpression",operator:t,operand:e,prefix:true,start:this.previous().start,end:e.end}}createPostfixUnary(t,e){return {type:"unaryExpression",operator:t,operand:e,prefix:false,start:e.start,end:this.previous().end}}createCallExpression(t,e){return {type:"callExpression",callee:t,arguments:e,start:t.start,end:this.previous().end}}};function vo(t){return new ho().parse(t)}function Ye(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 Je(t,e){return At(t,e,"source")}function Ct(t,e){return At(t,e,"destination")}function Eo(t,e){return At(t,e,"patient")}function At(t,e,r){if(!e||!t.roles.some(a=>a.role===r))return [];let i=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},n={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[n,i]:[i,n]}]}var te=["selector","reference","expression"],go={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination",for:"duration"}},argSkipTokens:["on"],roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2,markerOptional:{zh:true}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}},{role:"duration",description:"How long the class stays on before reverting (`toggle .a for 2s`)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3,valueShape:"time",markerOverride:{en:"for",ja:"\u9593",ko:"\uB3D9\uC548"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},zo={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector","literal"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",es:"a",ar:"\u0625\u0644\u0649",zh:"\u5230",fr:"\xE0",de:"zu",pt:"a",he:"\u05D0\u05DC",id:"ke",it:"a",sw:"kwa"},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","dans"],de:["auf","in"],pt:["em","para"],he:["\u05E2\u05DC","\u05D1","\u05DC"],id:["pada","di"],it:["in","su"],sw:["kwenye"]}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},wo={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source"}},targetRole:"source",argSkipTokens:["from"],roles:[{role:"patient",description:"The class/attribute to remove, or the element to remove",required:true,expectedTypes:te,svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},xt={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"into",ar:"\u0641\u064A",zh:"\u5230",fr:"dans",de:"in",he:"\u05D1",id:"ke",sw:"kwa"},markerVariants:{en:["before","after"]},markerLegacy:{ar:["\u0639\u0644\u0649","\u0625\u0644\u0649","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","\xE0"],de:["auf","zu"],he:["\u05E2\u05DC","\u05D0\u05DC","\u05DC"],id:["pada","di"],sw:["kwenye"]},methodCarrier:"method"}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},ko={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient",on:"scope"}},argSkipTokens:["to"],roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",th:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B",zh:"\u628A"},markerOptional:{zh:true}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","selector","expression","reference","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",th:"\u0E43\u0E19",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902",zh:"\u5230"},markerVariants:{tr:["e","a","ye","ya"],zh:["\u4E3A","\u70BA","\u6210"]}},{role:"scope",description:"The element(s) the attribute/property is set on (defaults to me)",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3,markerOverride:{en:"on",es:"on",pt:"on",fr:"on",de:"on",it:"on",id:"on",ms:"on",sw:"on",tl:"on",zh:"on",vi:"on",ru:"on",uk:"on",pl:"on",th:"on",he:"on",ar:"on",ja:"on",ko:"on",tr:"on",hi:"on",bn:"on",qu:"on"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},bo={action:"bind",description:"Reactively bind a variable to an element or property value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to bind",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",it:"",id:"",ms:"",vi:"",ru:"",uk:"",pl:"",th:"",zh:"",he:"",ar:"",sw:"",tl:"",ja:"\u3092",ko:"\uB97C",tr:"i",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"source",description:"The element or property to bind to",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"zu",it:"in",id:"ke",ms:"ke",vi:"v\xE0o",ru:"\u0432",uk:"\u0432",pl:"do",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",zh:"\u5230",he:"\u05DC",sw:"kwa",th:"\u0E43\u0E19",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"}}],errorCodes:["MISSING_TARGET","MISSING_VALUE","INVALID_SYNTAX"],recoveryHints:{MISSING_TARGET:"Add a variable to bind: bind $name to #input",MISSING_VALUE:'Add "to <element>" to specify the binding source',INVALID_SYNTAX:"Use syntax: bind <variable> to <element>"}},Co={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ao={action:"when",description:"Reactive observer: re-run the body when a watched expression changes",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,structuralOnly:true,roles:[{role:"condition",description:"The watched expression (`or`-separated expressions watch each)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1}]},xo={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},So={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Do={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Bo={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},To={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:["style","duration"]}},roles:[{role:"patient",description:"The element to show",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"The hide/show strategy (`with opacity`, `with *opacity`)",required:false,expectedTypes:["expression","selector"],svoPosition:2,sovPosition:2}]},Fo={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:["style","duration"]}},roles:[{role:"patient",description:"The element to hide",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"The hide/show strategy (`with opacity`, `with *opacity`)",required:false,expectedTypes:["expression","selector"],svoPosition:2,sovPosition:2}]},Oo={action:"on",description:"Handle an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{from:"source"}},hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],widenTypeVariants:[{role:"event",types:["literal","expression"],idSuffix:"expr-event",excludeLanguages:["ko"]}]},Ro={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{on:"destination"}},argSkipTokens:["on"],roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2,markerVariants:{hi:["\u0915\u094B"],qu:["ta"],bn:["\u0995\u09C7"]},markerOverride:{bn:"\u0995\u09C7",hi:"\u0915\u094B"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Po={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Lo={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",ast:{args:["source"],modifiers:{with:["style","method"],as:"responseType",body:"patient"},isBlocking:true},roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"style",description:"Request options object (method, headers, body, credentials\u2026)",required:false,expectedTypes:["expression"],valueShape:"object",svoPosition:2,sovPosition:2},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:3,sovPosition:3,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:5,sovPosition:5}]},No={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal","selector","expression","reference","property-path"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},Mo={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal","selector","expression","reference","property-path"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},_o={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Io={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},$o={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:1}]},jo={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",ast:{args:[["source","patient"]]},roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",he:"\u05D0\u05EA",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},Vo={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source",for:"recipient"}},argSkipTokens:["from"],roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to all current holders)",required:false,expectedTypes:te,svoPosition:2,sovPosition:1},{role:"recipient",description:"The element the class moves ONTO (`take .active from .tab for me`)",required:false,expectedTypes:["reference"],svoPosition:3,sovPosition:3,valueShape:"reference",markerOverride:{en:"for"}}]},Wo={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},qo={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",ast:{args:[],modifiers:{the:"patient"}},argSkipTokens:["the"],roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Ko={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",ast:{args:[["destination","patient"]],isBlocking:true},roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ho={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression","property-path"],svoPosition:1,sovPosition:1}]},Uo={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{to:"destination",detail:"patient"}},roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"man",sw:"kwa"}}]},Go={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Zo={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Yo={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Xo={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",ast:{args:[["quantity","patient"]]},hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},Jo={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{in:"source"}},hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in",es:"en",fr:"en",de:"in",it:"in",pt:"dentro",id:"dalam",ms:"dalam",pl:"w",ru:"\u0432",uk:"\u0443",sw:"ndani",th:"\u0E43\u0E19",vi:"trong",ar:"\u0641\u064A",tl:"sa_loob",he:"in",zh:"\u5728"}}]},Qo={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},es={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",ast:{},roles:[]},Ur={en:"url",es:"url",pt:"url",fr:"url",de:"url",it:"url",ja:"url",ko:"url",zh:"url",ar:"url",he:"url",hi:"url",bn:"url",tr:"url",ru:"url",uk:"url",pl:"url",id:"url",vi:"url",th:"url",ms:"url",tl:"url",sw:"url",qu:"url"},rs=Object.fromEntries(Object.keys(Ur).map(t=>[t,"in new"])),ts={action:"go",description:"Navigate to a URL, or scroll to an element",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to, or the element to scroll to",required:true,expectedTypes:["literal",...te],svoPosition:1,sovPosition:1,markerOverride:{en:"to",es:"a",ar:"\u0625\u0644\u0649",fr:"\xE0",de:"zu",pt:"para",he:"\u05D0\u05DC",hi:"\u092A\u0930",id:"ke",it:"a",ru:"\u043D\u0430",sw:"kwa",uk:"\u043D\u0430"},renderOverride:{en:"",zh:"",vi:"",th:""},markerOptional:{en:true,zh:true,vi:true,th:true},markerVariants:{zh:["\u628A"]},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],fr:["sur","dans"],de:["auf","in"],pt:["em","a"],he:["\u05E2\u05DC","\u05D1","\u05DC","\u05D0\u05EA"],hi:["\u092E\u0947\u0902"],id:["pada","di"],it:["in","su"],ru:["\u0432","\u043A"],sw:["kwenye"],uk:["\u0432","\u0434\u043E"]}},{role:"manner",description:"Open the URL in a new window (`in new window`)",required:false,expectedTypes:["reference","literal","expression"],valueShape:"keyword",svoPosition:2,sovPosition:2,markerOverride:rs}],rolePrefixLiteralVariants:[{role:"destination",literal:Ur,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},is={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"goal",over:"duration",on:"destination"}},omitRoleVariants:["goal"],roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal","expression","selector"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"zu",he:"\u05E2\u05DC",it:"in",ja:"\u306B",ko:"\uC5D0",ms:"ke",pl:"do",ru:"\u0432",th:"\u0E43\u0E19",tr:"e",uk:"\u0432",vi:"v\xE0o",zh:"\u5230",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},ns={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",ast:{args:[["source","patient"]],modifiers:{into:"destination"}},roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},as={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","patient"]]},roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},os={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","patient"]]},roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ss={action:"empty",description:"Remove all children from an element (sets innerHTML to empty)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to empty (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},us={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{as:"style"}},roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}}]},ls={action:"close",description:"Close a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to close (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},cs={action:"select",description:"Select the contents of a text field or DOM element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element whose contents to select (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ds={action:"clear",description:"Clear a variable, local, or input element",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The variable or element to clear (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ms={action:"reset",description:"Reset a <form> element to its default values",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The form element to reset (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ps={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},fs={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],markerOptional:{he:true,zh:true},svoPosition:1,sovPosition:1}]},ys={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference","property-path"],svoPosition:1,sovPosition:1}]},hs={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},vs={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",ast:{args:[["destination","patient"]]},hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:te,svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},Es={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient"}},roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta",ja:"\u3092",ko:"\uB97C",tr:"i",hi:"\u0915\u094B",de:"",es:"",fr:"",it:"",pt:"",pl:"",ru:"",uk:"",vi:"",id:"",ms:"",th:"",zh:"\u628A",he:"\u05D0\u05EA"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",ja:"\u306B",ko:"\uC5D0",tr:"e",hi:"\u092E\u0947\u0902",de:"zu",es:"a",fr:"\xE0",it:"in",pt:"para",pl:"do",ru:"\u0432",uk:"\u0432",vi:"v\xE0o",id:"ke",ms:"ke",th:"\u0E43\u0E19",zh:"\u5230",he:"\u05E2\u05DC"}}]},gs={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",ast:{},hasBody:true,roles:[]},zs={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},ws={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination"}},roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},ks={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{of:["destination","source"]}},roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},bs={en:"using view",es:"using view",pt:"using view",fr:"using view",de:"using view",it:"using view",ja:"using view",ko:"using view",zh:"using view",ar:"using view",he:"using view",hi:"using view",bn:"using view",tr:"using view",ru:"using view",uk:"using view",pl:"using view",id:"using view",vi:"using view",th:"using view",ms:"using view",tl:"using view",sw:"using view",qu:"using view"},St={role:"manner",description:"Run the swap inside a `document.startViewTransition()` (`using view transition`)",required:false,expectedTypes:["literal","expression"],valueShape:"keyword",markerOverride:bs},Cs={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",ast:{args:["method","destination","patient"],modifiers:{viewTransition:"manner"}},roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:te,svoPosition:2,sovPosition:1,markerOverride:{en:"of",es:"",fr:"",pt:"",it:"",de:"",pl:"",ru:"",uk:"",id:"",ms:"",sw:"",th:"",vi:"",he:"\u05D0\u05EA",zh:"\u628A",tl:""}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with",es:"con",fr:"avec",pt:"com",it:"con",de:"mit",pl:"z",ru:"\u0441",uk:"\u0437",id:"dengan",ms:"dengan",sw:"na",th:"\u0E14\u0E49\u0E27\u0E22",vi:"v\u1EDBi",he:"\u05E2\u05DD",zh:"\u7528",hi:"\u0938\u0947",bn:"\u09A6\u09BF\u09AF\u09BC\u09C7",tr:"ile",qu:"wan",ar:"\u0628\u0640",tl:"nang"}},{...St,svoPosition:4,sovPosition:4}]},As={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",ast:{args:[["source","destination"]],modifiers:{on:"patient",viewTransition:"manner"}},roles:[{role:"patient",description:"The element to morph",required:true,expectedTypes:te,svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"destination",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}},{...St,svoPosition:3,sovPosition:3}]},xs={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}]},Ss={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Ds={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:1}]},Bs={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Ts={action:"pick",description:"Select item(s), character(s), a range, first/last/random N, or regex matches from a root",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The range/count/index/regex argument to pick",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The root to pick from (with "of"/"from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Fs={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",ast:{args:["destination"]},argSkipTokens:["of","the","top","bottom","middle","center","nearest","left","right","smoothly","instantly"],roles:[{role:"destination",description:"The element to scroll to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},Os={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},Rs={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:Ur}]},Ps={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:Ur}]},Ls={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{viewTransition:"manner"}},roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Os},{...St,svoPosition:2,sovPosition:2}]},Ns={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression"],valueShape:"object",svoPosition:2,sovPosition:1}]},ue={toggle:go,add:zo,remove:wo,put:xt,set:ko,show:To,hide:Fo,on:Oo,trigger:Ro,wait:Po,fetch:Lo,increment:No,decrement:Mo,append:_o,prepend:Io,log:$o,get:jo,take:Vo,make:Wo,halt:qo,settle:Ko,throw:Ho,send:Uo,if:Go,unless:Zo,else:Yo,repeat:Xo,for:Jo,while:Qo,continue:es,go:ts,scroll:Fs,push:Rs,replace:Ps,process:Ls,transition:is,clone:ns,focus:as,blur:os,empty:ss,open:us,close:ls,select:cs,clear:ds,reset:ms,breakpoint:ps,call:fs,return:ys,js:hs,tell:vs,default:Es,init:gs,behavior:zs,install:ws,measure:ks,swap:Cs,morph:As,beep:xs,break:Ss,copy:Ds,exit:Bs,pick:Ts,render:Ns,bind:bo,live:Co,when:Ao,eventsource:xo,socket:So,worker:Do,intercept:Bo,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function se(t){return ue[t]}function Ms(){return Object.values(ue).filter(t=>t.structuralOnly!==true&&(t.roles.length>0||t.bareKeyword===true))}typeof process<"u"&&process.env.LOKASCRIPT_SCHEMA_VALIDATION==="1"&&Promise.resolve().then(()=>(io(),_i)).then(({validateAllSchemas:t,formatValidationResults:e})=>{let r=t(ue);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
4
+ These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(t=>{console.debug("Schema validation skipped:",t);});var qi=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document","true","false","null","undefined","empty"]),Ge=new Map,Le=new Map,gr=new Map,pt=null;function Ki(t,e){let r={...t};for(let i of Object.keys(e)){let n=e[i],a=t[i];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?r[i]=Ki(a,n):r[i]=n);}return r}function _s(t,e){return Ki(t,e)}function Dt(t){if(!t.extends)return t;let e=Le.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=Dt(e);return _s(r,t)}function qe(t,e,r){Ge.set(t,e),Le.set(t,r),gr.delete(t);}function Hi(t){pt=t;}var Xt=new Map;function sr(t){return t.split("-")[0]}function ur(t){return t.includes("-")}function Is(t){let e=Ge.get(t);if(!e&&ur(t)){let r=sr(t);e=Ge.get(r);}if(!e){let r=Array.from(Ge.keys()).join(", ");throw new Error(`Language '${t}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${t}';`)}return e}function $s(t){let e=Le.get(t);if(!e&&ur(t)){let r=sr(t);e=Le.get(r);}if(!e){let r=Array.from(Le.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 Dt(e)}function O(t){let e=Le.get(t);return !e&&ur(t)&&(e=Le.get(sr(t))),e?Dt(e):void 0}function js(){return Array.from(Ge.keys())}function Ui(t){if(Ge.has(t)&&Le.has(t))return true;if(ur(t)){let e=sr(t);return Ge.has(e)&&Le.has(e)}return false}function Vs(t,e){let i=Is(e).tokenize(t);return e==="en"?i:qs(i,e)}var Gi=()=>false;function Ws(t){Gi=t;}function qs(t,e){let r=t.tokens,i=[],n=false;for(let a=0;a<r.length;a++){let o=r[a],s=r[a-1],u=a+2;for(;u<r.length&&r[u]?.value!==")"&&r[u-1].position.end===r[u].position.start;)u++;let l=r.slice(a+1,u),c=l.map(p=>p.value).join(""),d=l[0],m=l[l.length-1];if(o.value==="("&&d&&m&&r[u]?.value===")"&&/^[\p{L}_$][\p{L}\p{M}\p{N}_$]*$/u.test(c)&&!(d.kind!=="particle"&&qi.has((d.normalized??d.value).toLowerCase()))&&Gi(c,e)&&o.position.end===d.position.start&&m.position.end===r[u].position.start&&!(s&&s.position.end===o.position.start&&/[\p{L}\p{N}_)\]]$/u.test(s.value))){i.push({value:`(${c})`,kind:"identifier",position:{...o.position,end:r[u].position.end}}),a=u,n=true;continue}i.push(o);}return n?new de(i,e):t}function pe(t){let e=gr.get(t);if(!e&&ur(t)&&(e=gr.get(sr(t))),e)return e;let r=Xt.get(t);if(!r&&ur(t)&&(r=Xt.get(sr(t))),r)return gr.set(t,r),r;if(!pt)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let i=$s(t),n=pt(i);return gr.set(t,n),n}var Zi={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function Oe(t){let e="complex";return t.startsWith("#")&&!t.includes(" ")?e="id":t.startsWith(".")&&!t.includes(" ")?e="class":t.startsWith("[")&&t.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(t)&&(e="element"),{type:"selector",value:t,selectorKind:e}}function Y(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}function Yi(t){if(t==="true")return Y(true,"boolean");if(t==="false")return Y(false,"boolean");if(t==="null")return {type:"expression",raw:"null"}}function Fe(t){return nt(t)}function Ae(t){return {type:"reference",value:t}}function Xi(t,e){return e?{...t,position:e}:t}function Re(t,e,r){return r?{type:"property-path",object:t,property:e,access:r}:{type:"property-path",object:t,property:e}}function me(t,e,r){let i={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...i,metadata:r}:i}function vr(t,e,r,i,n,a){let o=new Map;o.set("event",t);let s={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(s.eventModifiers=r),i!==void 0&&(s.metadata=i),n!==void 0&&n.length>0&&(s.parameterNames=n),s}function hu(t,e,r,i,n){let a={kind:"behavior",action:"behavior",roles:new Map,name:t,parameters:e,eventHandlers:r};return i!==void 0&&i.length>0&&(a.initBlock=i),n!==void 0&&(a.metadata=n),a}function vu(t,e,r,i){let n={kind:"def",action:"def",roles:new Map,name:t,parameters:e,body:r};return i!==void 0&&(n.metadata=i),n}function ft(t,e,r,i,n){let a={kind:"feature",action:t,roles:n??new Map,body:e};return r!==void 0&&(a.name=r),i!==void 0&&(a.metadata=i),a}function ir(t,e="then",r){let i={kind:"compound",action:"compound",roles:new Map,statements:t,chainType:e};return r!==void 0&&(i.metadata=r),i}function Eu(t,e,r,i){let n=new Map;n.set("condition",t);let a={kind:"conditional",action:"if",roles:n,thenBranch:e};return r!==void 0&&(a.elseBranch=r),i!==void 0&&(a.metadata=i),a}function gu(t,e,r,i,n){let a={kind:"loop",action:t,loopVariant:e,roles:new Map(Object.entries(r)),body:i};return n?.loopVariable&&(a.loopVariable=n.loopVariable),n?.indexVariable&&(a.indexVariable=n.indexVariable),n?.metadata&&(a.metadata=n.metadata),a}function Mr(t,e){return !e||e.length===0||e.includes(t)||e.includes("expression")?true:t==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):t==="expression"?e.some(r=>["selector","reference","expression"].includes(r)):false}function zu(t,e){let r=t.markerOverride?.[e.code],i=e.roleMarkers[t.role];if(r!==void 0){let n=wu(t,e.code,r);return {primary:r,...n&&{alternatives:n},position:i?.position??"before",isOverride:true}}if(i&&i.primary){let n={primary:i.primary,position:i.position,isOverride:false};return i.alternatives&&(n.alternatives=i.alternatives),n}return null}function wu(t,e,r){let i=t.markerLegacy?.[e];if(!i?.length)return;let n=[...new Set(i)].filter(a=>a&&a!==r);return n.length?n:void 0}function Ne(t,e,r){let i=t.markerLegacy?.[e]??[],n=t.methodCarrier?[]:t.markerVariants?.[e]??[],a=[...new Set([...i,...n])].filter(o=>o&&o!==r);return a.length?a:void 0}var xr=new Set(["destination","source","patient","object","event","eventmarker","manner","instrument","style"]);function Se(t,e){let r=t.possessive?.keywords?.[e];if(r)return r;let i=t.possessive?.specialForms;if(i){for(let[n,a]of Object.entries(i))if(a===e)return n}}function at(t){return Zi.possessive?.specialForms?.[t]??`${t}'s`}var Gr=new Set(["+","-","*","/","%","<",">","<=",">=","==","!=","===","!=="]),Ji=new Set(["<",">","<=",">=","==","!=","===","!=="]),je=new Set([...Gr,"mod"]),ku=/^[<>=!+\-*/%]+$/,Qi={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};function bu(t){return Qi[t]}function Zr(t,e){return Qi[e]?.has(t.toLowerCase())??false}var en={ar:["\u0645\u0631\u0627\u062A","\u0645\u0631\u0629"],bn:["\u09AC\u09BE\u09B0"],de:["mal","Mal"],es:["veces","vez"],fr:["fois"],he:["\u05E4\u05E2\u05DE\u05D9\u05DD","\u05E4\u05E2\u05DD"],hi:["\u092C\u093E\u0930"],id:["kali"],it:["volte","volta"],ja:["\u56DE","\u5EA6"],ko:["\uBC88","\uD68C"],ms:["kali"],pl:["razy","raz"],pt:["vezes","vez"],qu:["kuti"],ru:["\u0440\u0430\u0437","\u0440\u0430\u0437\u0430"],sw:["mara"],th:["\u0E04\u0E23\u0E31\u0E49\u0E07"],tl:["beses"],tr:["kez","kere","defa"],uk:["\u0440\u0430\u0437\u0456\u0432","\u0440\u0430\u0437\u0438","\u0440\u0430\u0437"],vi:["l\u1EA7n"],zh:["\u6B21","\u904D"]},Bt={ar:{\u0642\u064A\u0645\u0629:"value"},bn:{\u0985\u0995\u09CD\u09B7\u09AE:"disabled",\u0986\u0987\u09A1\u09BF:"id","\u099A\u09C7\u0995 \u0995\u09B0\u09BE":"checked",\u09A6\u09C8\u09B0\u09CD\u0998\u09CD\u09AF:"length",\u09AE\u09BE\u09A8:"value"},de:{wert:"value"},es:{valor:"value"},fr:{valeur:"value"},hi:{\u0905\u0915\u094D\u0937\u092E:"disabled",\u091A\u0947\u0915:"checked",\u091B\u093F\u092A\u093E:"hidden",\u092E\u093E\u0928:"value"},id:{nilai:"value"},it:{valore:"value"},ja:{\u5024:"value"},ko:{\uAC12:"value"},ms:{dilumpuhkan:"disabled",ditanda:"checked",nilai:"value",panjang:"length"},pl:{warto\u015B\u0107:"value"},pt:{valor:"value"},qu:{chanin:"value"},ru:{\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435:"value",\u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u043E:"disabled",\u043E\u0442\u043C\u0435\u0447\u0435\u043D\u043E:"checked",\u0441\u043A\u0440\u044B\u0442\u043E:"hidden"},sw:{thamani:"value"},th:{\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27:"length",\u0E04\u0E48\u0E32:"value",\u0E1B\u0E34\u0E14\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19:"disabled",\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E41\u0E25\u0E49\u0E27:"checked",\u0E44\u0E2D\u0E14\u0E35:"id"},tl:{haba:"length",halaga:"value",hindi_pinagana:"disabled",naka_tsek:"checked"},tr:{de\u011Fer:"value"},uk:{\u0432\u0438\u043C\u043A\u043D\u0435\u043D\u043E:"disabled",\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F:"value",\u043F\u043E\u0437\u043D\u0430\u0447\u0435\u043D\u043E:"checked",\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u043D\u043E:"hidden"},vi:{\u1EA9n:"hidden","\u0111\u01B0\u1EE3c ch\u1ECDn":"checked","gi\xE1 tr\u1ECB":"value","v\xF4 hi\u1EC7u":"disabled"},zh:{\u503C:"value"}},Cu={ar:{\u0623\u0648:"or",\u0643\u0640:"as",\u0644\u064A\u0633:"not",\u0648:"and",\u064A\u062D\u062A\u0648\u064A:"contains",\u064A\u0633\u0627\u0648\u064A:"equals",\u064A\u0634\u0645\u0644:"includes"},bn:{\u0985\u09A5\u09AC\u09BE:"or",\u098F\u09AC\u0982:"and",\u09A8\u09BE:"not",\u09B9\u09BF\u09B8\u09BE\u09AC\u09C7:"as"},de:{als:"as",beinhaltet:"includes",enth\u00E4lt:"contains",gleicht:"equals",nicht:"not",oder:"or",und:"and"},es:{como:"as",contiene:"contains",iguala:"equals",incluye:"includes",no:"not",o:"or",y:"and"},fr:{comme:"as",contient:"contains",\u00E9gale:"equals",et:"and",inclut:"includes",non:"not",ou:"or"},he:{\u05D5\u05D2\u05DD:"and"},hi:{\u0914\u0930:"and",\u0915\u0947_\u0930\u0942\u092A_\u092E\u0947\u0902:"as",\u0928\u0939\u0940\u0902:"not",\u092C\u0930\u093E\u092C\u0930:"equals",\u092E\u0947\u0902_\u0939\u0948:"includes",\u092F\u093E:"or",\u0936\u093E\u092E\u093F\u0932:"contains"},id:{atau:"or",berisi:"contains",bukan:"not",dan:"and",sama:"equals",sebagai:"as",termasuk:"includes"},it:{come:"as",contiene:"contains",e:"and",include:"includes",non:"not",o:"or",uguale:"equals"},ja:{\u305D\u3057\u3066:"and",\u3067\u306F\u306A\u3044:"not",\u3068\u3057\u3066:"as",\u307E\u305F\u306F:"or",\u542B\u3080:"contains",\u542B\u3081\u308B:"includes",\u7B49\u3057\u3044:"equals"},ko:{\uAC19\uB2E4:"equals",\uADF8\uB9AC\uACE0:"and",\uB610\uB294:"or",\uB85C:"as",\uC544\uB2C8:"not",\uD3EC\uD568:"contains",\uD3EC\uD568\uD558\uB2E4:"includes"},ms:{atau:"or",bukan:"not",dan:"and",mengandungi:"contains",sama:"equals",sebagai:"as",termasuk:"includes"},pl:{i:"and",jako:"as",lub:"or",nie:"not",obejmuje:"includes","r\xF3wna si\u0119":"equals",zawiera:"contains"},pt:{como:"as",cont\u00E9m:"contains",e:"and",igual:"equals",inclui:"includes",n\u00E3o:"not",ou:"or"},qu:{churasqa:"includes",hina:"as",hinallataq:"and",kikin:"equals",ukupi_kan:"contains",utaq:"or"},ru:{\u0432\u043A\u043B\u044E\u0447\u0430\u0435\u0442:"includes",\u0438:"and",\u0438\u043B\u0438:"or",\u043A\u0430\u043A:"as",\u043D\u0435:"not",\u0440\u0430\u0432\u043D\u043E:"equals",\u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442:"contains"},sw:{au:"or",ina:"contains",kuwa:"as",pamoja:"includes",sawa:"equals",si:"not"},th:{\u0E44\u0E21\u0E48:"not",\u0E41\u0E25\u0E30:"and",\u0E2B\u0E23\u0E37\u0E2D:"or"},tl:{at:"and",bilang:"as",hindi:"not",katumbas:"equals",naglalaman:"contains",o:"or"},tr:{de\u011Fil:"not",e\u015Fittir:"equals",i\u00E7erir:"contains",olarak:"as",ve:"and",veya:"or"},uk:{\u0430\u0431\u043E:"or",\u0432\u043A\u043B\u044E\u0447\u0430\u0454:"includes",\u0434\u043E\u0440\u0456\u0432\u043D\u044E\u0454:"equals",\u0456:"and",\u043C\u0456\u0441\u0442\u0438\u0442\u044C:"contains",\u043D\u0435:"not",\u044F\u043A:"as"},vi:{b\u1EB1ng:"equals",ch\u1EE9a:"contains",ho\u1EB7c:"or",kh\u00F4ng:"not",nh\u01B0:"as",v\u00E0:"and"},zh:{\u4F5C\u4E3A:"as",\u5305\u542B:"contains",\u5305\u62EC:"includes",\u548C:"and",\u6216:"or",\u7B49\u4E8E:"equals",\u975E:"not"}},rn={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 We(t,e){let r=e.value.toLowerCase(),i=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||i==="of"||i==="source")return true;let n=t?.code?rn[t.code]:void 0;return !!n&&n.has(r)}var Au={destination:"in",source:"from"},tn={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"])},nn=new Set(["in","into","at","within","inside"]);function xu(t,e){let r=e.value.toLowerCase();if((t?.code?tn[t.code]:void 0)?.has(r))return "in";let n=e.normalized??e.value,a=n.toLowerCase();return nn.has(a)?"in":Au[a]??n}function Su(t,e){return e.value.toLowerCase()==="in"||(t?.code?tn[t.code]:void 0)?.has(e.value.toLowerCase())?true:nn.has((e.normalized??e.value).toLowerCase())}var Du=new Set(["me","it","you","body","document","target","result"]);function Bu(t,e){let r=t[e];if(!r)return null;if(r.kind==="selector")return /^[*@]/.test(r.value)?null:{kind:"selector",parts:[{text:r.value,token:r}],consumed:1};let i=(r.normalized??r.value).toLowerCase();if(Du.has(i))return {kind:"reference",parts:[{text:i,token:r}],consumed:1};let n=t[e+1];return i==="closest"&&n?.kind==="selector"&&!/^[*@]/.test(n.value)?{kind:"closest",parts:[{text:"closest",token:r},{text:n.value,token:n}],consumed:2}:null}function an(t,e,r,i){let n=t[e];if(!n||!Su(r,n))return null;let a=Bu(t,e+1);if(!a)return null;let o=t[e+1+a.consumed];return i?.(n)===true&&i(o)!==true?null:{marker:n,scope:a}}var ot=new Set(["first","last","next","previous","random","closest"]),Tu={bn:{\u09B6\u09C7\u09B7:"last"}},mr=new Set(Object.keys(ue).map(t=>t.toLowerCase()));function br(t,e,r,i){let n=t[e];if(!n)return null;let a=(n.normalized??n.value).toLowerCase(),o=t[e+1],s=r?.code&&o?.kind==="selector"&&o.value.startsWith("<")?Tu[r.code]?.[n.value.toLowerCase()]:void 0;if(!ot.has(a)&&!ot.has(n.value.toLowerCase())&&s===void 0)return null;let u=[{text:s??n.normalized??n.value,token:n}],l=e+1,c=t[l];if(!c||c.kind!=="selector"||Ji.has(c.value))return null;u.push({text:c.value,token:c}),l++;let d=0;for(;d++<8;){let f=t[l];if(f&&f.kind==="selector"&&f.value.startsWith("."))u.push({text:f.value,token:f}),l++;else break}let m=t[l],p=t[l+1];if(m&&p&&p.kind==="selector"&&!/^[*@]/.test(p.value)&&(m.kind==="keyword"||m.kind==="particle"||m.kind==="identifier")&&!ot.has((m.normalized??m.value).toLowerCase())&&!mr.has((m.normalized??m.value).toLowerCase())&&!(i?.(m)===true&&i(t[l+2])!==true))u.push({text:xu(r,m),token:m}),u.push({text:p.value,token:p}),l+=2;else {let f=an(t,l,r,i);f&&f.scope.kind!=="selector"&&(u.push({text:"in",token:f.marker},...f.scope.parts),l+=1+f.scope.consumed);}return {parts:u,consumed:l-e}}function Ze(t,e){let r=Cu[t];return r?r[e.toLowerCase()]??e:e}function he(t,e){let r=Bt[t];return r?r[e.toLowerCase()]??e:e}function ei(t,e){return Bt[t]?.[e.toLowerCase()]!==void 0}function Fu(t,e){let r=[e.value,e.normalized].filter(Boolean);for(let i of r){let n=Se(t,i)??Se(t,i.toLowerCase());if(n)return n}}function on(t){return t.kind==="literal"||t.kind==="operator"||t.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(t.value)}function Ou(t,e){let r=t?.references;if(!r)return false;let i=Object.values(r).filter(a=>typeof a=="string").map(a=>a.toLowerCase());return [e.value,e.normalized].filter(Boolean).some(a=>i.includes(a.toLowerCase()))}function ar(t,e){return on(t)?he(e,t.value)!==t.value?true:t.kind==="identifier":false}var Ru=new Set(["true","false","null","undefined","me","my","it","its","you","your","result","event","target","body","detail","document","window"]);function sn(t){return t.kind==="literal"||t.kind==="selector"||t.kind==="reference"?true:t.kind==="identifier"?Lu.test(t.value):t.kind==="keyword"&&Ru.has((t.normalized??t.value).toLowerCase())}function ri(t){return !!t&&(t.value===")"||t.value==="]"||sn(t))}function yt(t){if(!t)return false;if(/^[([-]$/.test(t.value)||sn(t))return true;let e=(t.normalized??"").toLowerCase();return t.kind==="keyword"&&(e==="not"||e==="no")}var Pu=/^\.[\p{L}_-][\p{L}\p{N}_-]*$/u,Lu=/^(?:[:$]?[\p{L}_][\p{L}\p{M}\p{N}_]*|\([\p{L}_$][\p{L}\p{M}\p{N}_$]*\))$/u,U={beforeClassRef:"has"},Nu={ar:{\u0647\u0648:{beforePredicate:"is",afterOperand:"is"},\u0641\u0627\u0631\u063A:{afterCopula:"empty"}},hi:{\u0939\u0948:{beforePredicate:"is",beforeClassRef:"has",afterOperand:"is"},\u0916\u093E\u0932\u0940:{afterCopula:"empty"}},id:{kosong:{afterCopula:"empty"},punya:U},th:{\u0E40\u0E1B\u0E47\u0E19:{beforeTypeName:"as",beforePredicate:"is",afterOperand:"is"},\u0E27\u0E48\u0E32\u0E07:{afterCopula:"empty"},\u0E21\u0E35:U},ja:{\u7A7A:{afterCopula:"empty"},\u3042\u308B:U},sw:{tupu:{afterCopula:"empty",otherwise:"null"},na:{betweenOperands:"and"},ana:U,nina:U},zh:{\u6CA1\u6709:{beforeBareIdentifier:"no",beforeSelector:"no"},\u6709:U},tl:{walang:{beforeBareIdentifier:"no",beforeSelector:"no"},may:{afterSubject:"exists",beforeClassRef:"has"}},bn:{\u0986\u099B\u09C7:{afterSubject:"exists",beforeClassRef:"has"},\u0986\u099B\u09BF:U},qu:{mana:{beforeOperand:"not"},chusaq:{afterCopula:"empty"},kachkan:U,kachkani:U},tr:{var:{afterSubject:"exists",beforeClassRef:"has"},bo\u015F:{afterCopula:"empty"}},de:{hat:U,habe:U},es:{tiene:U,tengo:U},fr:{a:U,ai:U},it:{ha:U,ho:U},ko:{\uC788\uB2E4:U},ms:{ada:U},pl:{ma:U,mam:U},pt:{tem:U,tenho:U},ru:{\u0438\u043C\u0435\u0435\u0442:U,\u0438\u043C\u0435\u044E:U},uk:{\u043C\u0430\u0454:U,\u043C\u0430\u044E:U},vi:{c\u00F3:U}},Mu=new Set(["text","json","html","response","blob","arraybuffer"]),_u=new Set(["empty","null","undefined","true","false"]),un=new Set(["Number","Int","Float","String","Boolean","Date","Array","Object","JSON","json","JSONString","FormData","FormEncoded","HTML","Fragment","Values","Values:Form","Values:JSON","Set","Map","Keys","Entries","Reversed","Unique","Flat"]);function Cr(t){return un.has(t)||/^Fixed(?::\d+)?$/.test(t)||/^[A-Z][A-Za-z0-9_]*(?::[A-Za-z0-9_]+)?$/.test(t)}function ln(t,e,r,i,n,a){let o=ht(t,e);if(!o)return;if(o.beforeTypeName&&i?.kind==="identifier"&&a?.value!=="("&&(un.has(i.value)||Mu.has(i.value.toLowerCase())))return o.beforeTypeName;if(o.beforePredicate&&i&&(i.kind==="literal"||i.kind==="keyword"&&_u.has((i.normalized??"").toLowerCase())))return o.beforePredicate;if(o.afterCopula&&n!==void 0&&["is","not","does","do"].includes(n.toLowerCase()))return o.afterCopula;if(o.beforeBareIdentifier&&i?.kind==="identifier"&&/^[A-Za-z_]\w*$/.test(i.value))return o.beforeBareIdentifier;let s=!!i&&Ar(i,t)&&Pe({prev:e,beforePrev:r,next:a},t);if(o.beforeOperand&&(yt(i)||s))return o.beforeOperand;if(o.beforeSelector&&i?.kind==="selector")return o.beforeSelector;if(o.beforeClassRef&&i&&Pu.test(i.value))return o.beforeClassRef;if(o.afterSubject&&(r?.kind==="selector"||r?.kind==="reference"))return o.afterSubject;let u=!!r&&Ar(r,t)&&n===r.value;return o.betweenOperands&&(ri(r)||u)&&yt(i)?o.betweenOperands:o.afterOperand&&(ri(r)||r?.value==="}")?o.afterOperand:o.otherwise}function ht(t,e){let r=Nu[t];return r?.[e.value]??r?.[e.value.toLowerCase()]}function Iu(t,e,r,i){return ln(t,e,r,i,void 0,void 0)}function $u(t){return ku.test(t)||t==="("||t==="["||t===","}function ju(t){return Gr.has(t)&&t!=="-"||t===")"||t==="]"||t===","}var Vu=new Set(["is","am","contains","contain","matches","match","has","have","includes","include","exists","exist","mod"]);function cn(t,e,r,i){let n=e.kind==="keyword"?(e.normalized??"").toLowerCase():Ze(t,e.value).toLowerCase();if(n!=="and"&&n!=="or")return false;if(r===void 0||r!==void 0&&$u(r.value))return true;if(i===void 0)return false;if(ju(i.value))return true;let a=i.kind==="keyword"?(i.normalized??i.value).toLowerCase():Ze(t,i.value).toLowerCase();return Vu.has(a)}var Wu=new Set(["include","contain","match","exist"]);function dn(t){let e=t?.toLowerCase();return e==="is"||e==="not"}function mn(t,e,r){let i=e[r],n=e[r-1];return !i||!n||i.value.toLowerCase()!=="in"?false:dn(lr(t,n,e[r-2],i,void 0))}function lr(t,e,r,i,n,a){if(n?.toLowerCase()==="equal"&&e.value.toLowerCase()==="to")return "to";if(dn(n)&&e.value.toLowerCase()==="in")return "in";if(n?.toLowerCase()==="not"&&Wu.has(e.value.toLowerCase()))return e.value.toLowerCase();let o=ln(t,e,r,i,n,a);if(o!==void 0)return o;if(cn(t,e,r,i))return e.value;let s=Ze(t,e.value);if(s!==e.value)return s;if(e.kind!=="keyword")return e.value;let u=(e.normalized??e.value).toLowerCase();return u!=="event"&&xr.has(u)||Ar(e,t)&&Pe({prev:r,next:i,afterNext:a},t)?e.value:e.normalized??e.value}function pn(t,e,r,i){let n=t[e],a=t[e+1];if(!n||!a||!on(n)||!We(r,a)||!ar(n,i))return;if(t[e+2]?.kind==="selector")return e+2;let o=e;for(;t[o]!==void 0&&t[o+1]!==void 0&&We(r,t[o+1])&&ar(t[o],i);)o+=2;return o>e+2&&t[o]?.kind==="selector"?o:void 0}var qu=new Set(["if","unless","while","until","for","when","where","is","not","no","and","or","as"]);function Ku(t){let e=(t.normalized??t.value).toLowerCase();return e==="event"||Fe(e)?false:qu.has(e)||xr.has(e)}function Ar(t,e){return t.kind!=="keyword"?false:(t.normalized??t.value).toLowerCase()==="end"||Zr(t.value,e)}function ve(t,e){return {prev:t[e-1],beforePrev:t[e-2],third:t[e-3],next:t[e+1],afterNext:t[e+2]}}var Hu=new Set(["and","or","is","times"]),Uu=new Set(["if","unless","while","until","is","and","or","in"]),Gu=t=>Object.prototype.hasOwnProperty.call(ue,t);function st(t){if(t.kind!=="keyword"&&!(t.normalized&&t.normalized!==t.value))return;let e=(t.normalized??t.value).toLowerCase();return Gu(e)?e:void 0}var ti=new WeakMap;function ii(t,e,r=false){let i;try{i=pe(t);}catch{return new Set}let n=ti.get(i);n||(n=new Map,ti.set(i,n));let a=r?`${e} before a role pair`:e,o=n.get(a);if(!o){o=new Set;for(let s of i){if(s.command!==e)continue;let[u,l,c,d]=s.template.tokens;if(!(u?.type!=="literal"||l?.type!=="literal")&&!(r&&(c?.type!=="role"||d?.type!=="role")))for(let m of [l.value,...l.alternatives??[]])o.add(m.toLowerCase());}n.set(a,o);}return o}var ni=new WeakMap;function Zu(t){let e;try{e=pe(t);}catch{return new Set}let r=ni.get(e);if(!r){let i=new Set(Object.values(O(t)?.roleMarkers??{}).flatMap(a=>a?[a.primary,...a.alternatives??[]]:[]).map(a=>a.toLowerCase())),n=new Set;for(let a of e){if(a.command!=="repeat")continue;let o=a.template.tokens;o.forEach((s,u)=>{if(!(s.type!=="literal"||o[u+1]?.type!=="role"))for(let l of [s.value,...s.alternatives??[]])i.has(l.toLowerCase())||n.add(l.toLowerCase());});}r=n,ni.set(e,r);}return r}function ai(t){return t.kind==="particle"?true:t.kind==="keyword"&&xr.has((t.normalized??"").toLowerCase())}function oi(t,e){return t.kind==="keyword"&&t.normalized?t.normalized.toLowerCase():Ze(e,t.value).toLowerCase()}function Pe(t,e){let{prev:r,beforePrev:i,next:n,afterNext:a}=t;if(n){if(je.has(n.value)||Hu.has((n.normalized??n.value).toLowerCase())||n.value==="'"&&a?.value.toLowerCase()==="s")return true;let f=ht(e,n)?.betweenOperands;if((f==="and"||f==="or")&&yt(a))return true}let o=O(e),s=!!o&&o.markingStrategy!=="preposition";if(s&&n?.kind==="particle"&&a?.kind!=="particle")return true;if(!r)return false;if(Gr.has(r.value))return true;let u=oi(r,e);if(u==="not"||u==="no"||ht(e,r)?.beforeOperand==="not")return true;let l=o?.wordOrder!=="SOV",c=t.third?st(t.third):void 0;if(c&&i&&ii(e,c,true).has(i.value.toLowerCase()))return true;let d=i&&l?st(i):void 0;if(d&&!ii(e,d).has(r.value.toLowerCase())||i&&!s&&ai(i))return false;if(Uu.has(u))return true;let m=!!i&&oi(i,e)!=="repeat"&&!!en[e]?.includes(r.value);if(Zu(e).has(r.value.toLowerCase())&&(l||u!=="repeat")&&!m)return true;let p=l?st(r):void 0;return p&&ue[p].roles.some(f=>f.required)?true:!s&&ai(r)}function fn(t){if(t.kind==="keyword")return Ku(t)?"structure":mr.has((t.normalized??t.value).toLowerCase())?"verb":void 0}function Be(t,e){let r=e?.code??"en",[i]=t;if(t.length===1&&i&&(fn(i)||Ar(i,r)))return i.value;let n="",a,o,s=(u,l)=>{if(o=u,a===void 0){n=u,a=l;return}let d=a.position?.end!==void 0&&l.position?.start!==void 0&&a.position.end===l.position.start&&(u.startsWith(".")||u.startsWith("!"));n+=(d?"":" ")+u,a=l;};for(let u=0;u<t.length;u++){let l=t[u],c=e?Fu(e,l):void 0,d=t[u+1];if(l.value===":"&&a!==void 0&&o!==void 0&&d!==void 0&&a.position?.end===l.position?.start&&l.position?.end===d.position?.start&&Cr(`${o}:${d.value}`)){n+=`:${d.value}`,o=`${o}:${d.value}`,a=d,u+=1;continue}if(l.value==="'"&&a!==void 0&&d?.value==="s"&&l.position?.end!==void 0&&d.position?.start===l.position.end){n+="'s",a=d;let h=t[u+2];h&&he(r,h.value)!==h.value?(s(he(r,h.value),h),u+=2):u+=1;continue}let m=e?.possessive,p=t[u+2];if(m?.markerPosition==="between"&&m.marker&&l.kind==="selector"&&d?.value===m.marker&&p!==void 0&&ar(p,r)){s(`${l.value}'s`,l),s(he(r,p.value),p),u+=2;continue}if(d?.value.toLowerCase()==="of"&&he(r,l.value)!==l.value&&ar(l,r)){s(he(r,l.value),l);continue}if(c!==void 0&&d){let h=e?.possessive?.connectors,E=!!h?.length&&h.some(g=>{let A=g.toLowerCase();return A===d.value.toLowerCase()||A===(d.normalized??"").toLowerCase()}),z=E?u+2:u+1,k=t[z];if(k&&ar(k,r)){s(at(c),l),s(he(r,k.value),k),u=z;continue}if(E&&k&&/^\.[a-zA-Z_]\w*$/.test(k.value)&&d.position?.end!==void 0&&k.position?.start!==void 0&&d.position.end===k.position.start){s(at(c),l),s(he(r,k.value.slice(1)),k),u=z;continue}if(!E&&/^\.[a-zA-Z_]\w*$/.test(d.value)&&l.position?.end!==void 0&&d.position?.start!==void 0&&l.position.end===d.position.start&&!Ou(e,l)){s(at(c),l),s(he(r,d.value.slice(1)),d),u+=1;continue}}let f=t[u+2],y=pn(t,u,e,r);if(y!==void 0){for(let h=u;h<y;h+=2)s(he(r,t[h].value),t[h]),s("of",t[h+1]);s(t[y].value,t[y]),u=y;continue}if(l.kind==="selector"&&d&&f&&We(e,d)&&ar(f,r)&&he(r,f.value)!==f.value){s(he(r,f.value),f),s("of",d),s(l.value,l),u+=2;continue}let v=br(t,u,e);if(v){for(let h of v.parts)s(h.text,h.token);u+=v.consumed-1;continue}s(lr(r,l,t[u-1],d,o,t[u+2]),l);}return n.trim()}function Yu(t){if(!t)return true;if(t.kind!=="keyword")return false;let e=(t.normalized??t.value).toLowerCase();return e==="then"||e==="end"||e==="else"}function yn(t){return !!t&&je.has(t.value)}var Xu=class{constructor(t,e,r,i,n){this.patternToken=e,this.afterLiteral=r,this.nextPatternToken=i,this.wouldMatch=n;let a=t.position();this.token=t.tokens[a],this.prev=t.tokens[a-1],this.next=t.tokens[a+1],this.place=ve(t.tokens,a);}get lastSlot(){return this.nextPatternToken===void 0}get tokenIsMarker(){return this.tokenIsMarkerMemo??(this.tokenIsMarkerMemo=this.wouldMatch(this.nextPatternToken,this.token)),this.tokenIsMarkerMemo}get beforeRole(){return this.nextPatternToken?.type==="role"}get nextIsMarker(){return this.nextIsMarkerMemo??(this.nextIsMarkerMemo=this.next!==void 0&&this.wouldMatch(this.nextPatternToken,this.next)),this.nextIsMarkerMemo}get clauseEndsAfter(){return Yu(this.next)}};function Ju(t){let e=t.token.value.toLowerCase();if(e!=="a"&&e!=="an")return false;let r=t.next;return r!==void 0&&(Gr.has(r.value)||t.nextIsMarker)}function Tt(t){return t.kind==="keyword"&&mr.has((t.normalized??t.value).toLowerCase())}function Qu(t,e){let r=t.token;if(r.kind!=="keyword")return false;let i=(r.normalized??r.value).toLowerCase();return i==="then"?true:(i==="end"&&t.next?.kind!=="selector"||Zr(r.value,e))&&!Pe(t.place,e)}function el(t,e){return Ar(t.token,e)&&Pe(t.place,e)}function hn(t){return t.afterLiteral&&(t.clauseEndsAfter||t.nextIsMarker)}function rl(t,e){let r=t.patternToken.role;return r!=="quantity"&&!(r==="event"&&e==="repeat")?false:Tt(t.token)&&!hn(t)&&!t.nextIsMarker}function tl(t){let e=t.patternToken;return !e.optional||e.role==="event"||e.role==="action"||e.valueShape==="keyword"||!Tt(t.token)?false:(t.lastSlot||t.tokenIsMarker)&&!hn(t)}function il(t,e,r,i){let n=t.type==="group"&&t.optional?t.tokens.every(o=>o.type==="role")?t.tokens[0]:void 0:t;if(!n||n.type!=="role"||!n.optional||n.role==="event"||n.role==="action"||n.valueShape==="keyword"||!e||e.kind!=="keyword"||r===void 0)return false;let a=i(r,e);return Tt(e)?!a:a}function nl(t){return mr.has((t.normalized??t.value).toLowerCase())}function al(t,e){return t?.kind==="particle"&&!!e&&["selector","literal","identifier"].includes(e.kind)&&!yn(e)}function ol(t){if(t.token.kind!=="particle")return false;let e=t.next;return e!==void 0&&t.nextIsMarker&&(e.kind==="particle"||t.prev?.kind==="particle")||t.afterLiteral&&t.beforeRole||t.clauseEndsAfter}function sl(t,e){let r=t.patternToken;if(r.role==="event"||r.role==="action"||r.valueShape==="keyword")return false;let i=r.expectedTypes;if(i?.length&&!i.some(a=>a==="expression"||a==="reference"))return false;let n=fn(t.token);return n==="structure"?true:n!=="verb"||(t.token.normalized??t.token.value).toLowerCase()==="empty"?false:!e?.hasBody&&!e?.roles.some(a=>a.role==="event")}function ul(t){let e=(t.normalized||t.value).toLowerCase();if(e==="empty")return Yi("null");if(e==="a"||e==="an")return {type:"expression",raw:t.value}}function ll(t,e,r){return t.kind==="particle"&&(e||yn(r))}function vn(t,e){let r=t[e];return r?.kind==="particle"&&t[e-1]?.value.toLowerCase()==="of"&&/^[\p{L}_$][\p{L}\p{M}\p{N}_$]*$/u.test(r.value)}var si=new Set(["is","am","are","be","was","were","not","no"]),cl=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948","\u0928\u0939\u0940\u0902","mana"]),En=new Set(["empty","null","undefined"]);function dl(t,e,r,i){let n=(t.normalized??t.value).toLowerCase(),a=t.value.toLowerCase(),o=(e.normalized??e.value).toLowerCase();return (si.has(n)||si.has(Ze(i,a))||cl.has(a)&&En.has(o))&&!r}var ml=new Set(["'s","a","am","an","and","as","closest","contain","contains","do","does","empty","equal","equals","exist","exists","false","first","greater","has","have","in","include","includes","is","it","its","last","less","match","matches","me","mod","my","next","no","not","null","of","or","previous","really","some","than","the","true","undefined","you","your","result","target","body","detail"]),pl=new Set(["am","and","as","contain","contains","do","does","empty","equal","equals","exist","exists","greater","has","have","in","include","includes","is","less","match","matches","mod","no","not","of","or","really","some","than"]),ui=/\s+as\s+([A-Za-z]\w*)!?\s*$/;function gn(t){let e=t;for(let n=ui.exec(e);n;n=ui.exec(e)){if(!Cr(n[1]??""))return false;e=e.slice(0,n.index);}let r=e.replace(/"[^"]*"|'[^']*'/g,"");if(/["']/.test(r.replace(/'s\b/g,""))||/[^\x00-\x7F]/.test(r))return false;let i=vo(e);return !i.success||i.consumed===void 0||i.consumed!==Wi(e).length-1?false:fl(i.node).every(Cr)}function fl(t){let e=[],r=i=>{if(Array.isArray(i)){i.forEach(r);return}if(!i||typeof i!="object")return;let n=i;n.type==="asExpression"&&e.push(String(n.targetType?.name??"")),Object.values(i).forEach(r);};return r(t),e}function zr(t,e){return t?.position?.end!==void 0&&e?.position?.start!==void 0&&t.position.end===e.position.start}var yl=new Set(["is","not","really","am","or"]);function zn(t,e,r){let i=n=>{let a=t[n];return a?lr(r,a,t[n-1],t[n+1],void 0).toLowerCase():""};return i(e)==="to"&&i(e-1)==="equal"&&yl.has(i(e-2))}function hl(t){return t.value==="a"}var vl=new Set(["event","window","document"]);function El(t,e,r){let i=t[e],n=t[e-1];return !i||!n||!We(r,n)?false:vl.has((i.normalized??i.value).toLowerCase())}function gl(t,e){if(t.kind==="conjunction")return true;if(t.kind==="keyword"){let r=(t.normalized??t.value).toLowerCase();if(r==="then"||r==="end"||r==="else"||Zr(t.value,e.profile?.code??""))return true}return e.owes(t)}function li(t,e,r){let i=r.profile?.code??"en";if(mn(i,t,e)||vn(t,e)||zn(t,e,i)||hl(t[e]))return false;let n=t[e];return gl(n,r)||r.commandMarkers.has(n.value.toLowerCase())}function zl(t,e,r){let i=t[e],n=t[e-1],a=r.profile?.code??"en";if(i.kind==="literal"||i.value==="'"&&t[e+1]?.value==="s"||i.value==="s"&&n?.value==="'")return true;if(i.kind==="selector"){if(!i.value.startsWith(".")||!n||zr(n,i)||je.has(n.value)||/^[([,]$/.test(n.value)||We(r.profile,n))return true;let s=lr(a,n,t[e-2],i,void 0).toLowerCase();return pl.has(s)}if(je.has(i.value)||/^[()[\],.!<>=+\-*/%]+$/.test(i.value)||We(r.profile,i)||cn(a,i,n,t[e+1])||mn(a,t,e)||vn(t,e)||El(t,e,r.profile)||zn(t,e,a))return true;let o=lr(a,i,n,t[e+1],void 0).toLowerCase();return o==="as"&&r.hasResponseType?false:ml.has(o)?true:i.kind==="identifier"&&/^(?:[\p{L}_$][\p{L}\p{M}\p{N}_$]*('s)?|\([\p{L}_$][\p{L}\p{M}\p{N}_$]*\))$/u.test(i.value)}function wl(t,e,r){if(!t[e]||li(t,e,r))return [];let i=e;for(;i<t.length&&!li(t,i,r)&&zl(t,i,r);)i++;let n=[];for(let a=i;a>e;a--)n.push(a);return n}function kl(t,e,r){let i=[],n=e;for(;;){let a=t[n];if(!a)break;if(a.value==="'"&&t[n+1]?.value==="s"&&t[n+2])n+=3;else if(/.'s$/.test(t[n-1]?.value??""))n+=1;else if(We(r,a)&&t[n+1])n+=2;else break;i.push(n);}return i.reverse()}function bl(t,e,r,i){for(let n of r){let a=Be(t.slice(e,n),i);if(gn(a))return {end:n,raw:a}}}[...xt.roles.find(t=>t.role==="destination")?.expectedTypes??[]];[...xt.roles.find(t=>t.role==="patient")?.expectedTypes??[]];var wn=[{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 ut(t,e,r,i){let n=wn.find(o=>o.lang===t);if(!n)return false;let a=(o,s)=>(o??"").toLowerCase()===s.toLowerCase();return a(e,n.end)&&a(r,n.at)&&a(i,n.of)}function Cl(t,e){let r=wn.find(n=>n.lang===t);if(!r)return false;let i=e.toLowerCase();return i===r.at.toLowerCase()||i===r.of.toLowerCase()||i===r.end.toLowerCase()}var kn=96,Al=/^[A-Za-z_][\w-]*$/,xl=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function bn(t,e){let r=t.peek(e);return !!r&&r.kind==="identifier"&&xl.test(r.value)}function Cn(t,e){let r=t.peek(e);if(!r||r.kind!=="identifier"&&r.kind!=="keyword"||!Al.test(r.value))return false;let i=t.peek(e+1),n=t.peek(e+2);return !!i&&i.value===":"&&!!n}function ci(t,e=0){return bn(t,e)||Cn(t,e)}function Sl(t){let e=t.peek();if(!e||e.value!=="{"&&e.value!=="(")return null;let r="",i=-1,n=0,a=0;for(;!t.isAtEnd()&&a++<kn;){let o=t.advance();if(!o)break;if(i>=0&&o.position.start>i&&(r+=" ".repeat(o.position.start-i)),r+=o.value,i=o.position.end,o.value==="{"||o.value==="(")n++;else if((o.value==="}"||o.value===")")&&(n--,n===0))return r}return null}function di(t){let e=t.peek();return e?e.value==="{"||e.value==="("?Sl(t):e.value===","||e.value===":"?null:(t.advance(),e.value):null}function wr(t,e){let r=t.mark(),i=[];if(e!==void 0){let a=t.peek();if(!a||a.value!==":"||!t.peek(1))return null;t.advance();let o=di(t);if(o===null)return t.reset(r),null;i.push(`${e}:${o}`);}else if(!ci(t))return null;let n=0;for(;n++<kn;){let a=t.peek();if(!a)break;if(a.value===","){if(i.length===0||!ci(t,1))break;t.advance();continue}if(bn(t,0)){i.push(t.advance().value);continue}if(!Cn(t,0))break;let o=t.advance().value;t.advance();let s=di(t);if(s===null)return t.reset(r),null;i.push(`${o}:${s}`);}return i.length===0?(t.reset(r),null):`{${i.join(", ")}}`}function Vr(t){switch(t.kind){case "selector":return Oe(t.value);case "literal":return Dl(t.value);case "keyword":{let r=ul(t);if(r)return r;let i=(t.normalized||t.value).toLowerCase();return Fe(i)?Ae(i):Yi(i)??Y(t.normalized||t.value)}case "identifier":if(t.value.startsWith("@"))return Oe(t.value);if(t.value.startsWith(":")||t.value.startsWith("$"))return Ae(t.value);let e=t.value.toLowerCase();return Fe(e)?Ae(e):{type:"expression",raw:t.value};case "url":{let r=Y(t.value,"string");return t.value.includes("${")?{...r,interpolates:true}:r}default:return null}}function Dl(t){if(t.startsWith('"')||t.startsWith("'")||t.startsWith("`")||t.startsWith("\u300C")){let i=t.slice(1,-1);return Y(i,"string")}if(t==="true")return Y(true,"boolean");if(t==="false")return Y(false,"boolean");let e=t.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let i=parseFloat(e[1]);return e[2]?Y(t,"duration"):Y(i,"number")}let r=parseFloat(t);return isNaN(r)?Y(t,"string"):Y(r,"number")}var _r=.8,Bl=.6,Tl=.15,Fl=.5,mi=.15,pi=.1,fi=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]),Ol={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]},Rl=class{calculate(t){return this.calculateWithBreakdown(t).final}calculateWithBreakdown(t){let e=this.scoreRoleCoverage(t),r=this.scoreStemPenalty(t),i=this.scoreLanguageBoost(t),n=this.scoreLanguageAdjustment(t),a=e;return a=Math.max(Fl,a+r),a=Math.min(1,a+i),a=Math.max(0,Math.min(1,a+n)),{roleCoverage:e,stemPenalty:r,languageBoost:i,languageAdjustment:n,final:a}}scoreRoleCoverage(t){let{pattern:e,captured:r}=t,i=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0,o=e.command==="on"?e.extraction?.action?.value:void 0,s=ue[o??e.command]?.roles,u=l=>s?.find(c=>c.role===l)?.valueShape!==void 0;for(let l of e.template.tokens)if(l.type==="role")r.has(l.role)?(n+=1,i+=1):u(l.role)||(n+=1);else if(l.type==="group")for(let c of l.tokens)c.type==="role"&&(r.has(c.role)?(n+=_r,i+=_r):u(c.role)||(n+=_r,a(c.role)&&(i+=_r*Bl)));return n>0?i/n:1}scoreStemPenalty(t){let{stemMatchCount:e,totalKeywordMatches:r}=t;return e<=0||r<=0?0:-(e/r)*Tl}scoreLanguageBoost(t){let{pattern:e}=t;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:fi.has(r.value)||r.alternatives?.some(i=>fi.has(i))?mi:0}scoreLanguageAdjustment(t){let{pattern:e,captured:r}=t;if(e.language!=="ar")return 0;let i=0;for(let[n,a]of r.entries()){let o=Ol[n];if(!o||o.length===0)continue;let s="metadata"in a?a.metadata:void 0;s&&typeof s.prepositionValue=="string"&&(o.includes(s.prepositionValue)?i+=.1:i-=.1);}return Math.max(-pi,Math.min(pi,i))}},Pl=new Rl,Ll=new Set(Object.values(ue).filter(t=>t.bareKeyword===true).map(t=>t.action));function Nl(t){return t.startsWith("*")||t.startsWith("@")}var ie=class ${constructor(e){this.patternRest=[],this.slotAfterLiteral=false,this.wouldMatch=(r,i)=>this.patternTokenWouldMatch(r,i),this.matchCache=new Map,this.roleStarts=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Pl;}matchPattern(e,r){let i=e.mark(),n=new Map;if(this.currentProfile=O(r.language),this.currentPatternCommand=r.command,this.currentRoleCommand=r.extraction?.action?.value??r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,this.roleStarts=new Map,this.eventSource=void 0,this.patternRest=[],!this.matchTokenSequence(e,r.template.tokens,n))return e.reset(i),null;let o=this.confidenceModel.calculate({pattern:r,captured:n,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-i.position,confidence:o,roleStarts:this.roleStarts,...this.eventSource?{eventSource:this.eventSource}:{}}}matchBest(e,r){this.matchCache.clear();let i=[],n=e.position();for(let o of r){let s=e.mark(),u=`${n}:${o.id}`,l;this.matchCache.has(u)?l=this.matchCache.get(u):(l=this.matchPattern(e,o),this.matchCache.set(u,l)),l&&i.push(l),e.reset(s);}if(i.length===0)return null;i.sort((o,s)=>{let u=s.pattern.priority-o.pattern.priority;return u!==0?u:s.confidence-o.confidence});let a=i[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,i,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let s=0;for(let u=0;u<r.length;u++){let l=r[u];if(s>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,i,l),il(l,e.peek(),r[u+1]??n,this.wouldMatch)){let m=e.mark(),p=new Map(i);if(this.matchTokenSequence(e,r.slice(u+1),p,n)&&this.atClauseEnd(e)){i.clear();for(let[f,y]of p)i.set(f,y);return true}e.reset(m);}let c=this.patternRest;this.patternRest=[...r.slice(u+1),...c],this.slotAfterLiteral=l.type==="role"&&r[u-1]?.type==="literal";let d=this.matchPatternToken(e,l,i,r[u+1]??n);if(this.patternRest=c,s=l.type==="role"&&l.role==="event"?2:Math.max(0,s-1),!d){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,i){if(r.has("source")||this.eventSource)return;let n=e.peek(),a=e.peek(1);if(!n||!a||this.patternTokenWouldMatch(i,n))return;let o=this.currentProfile?.roleMarkers?.source,s=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let c=l.value.toLowerCase();return o.primary?.toLowerCase()===c?true:!!o.alternatives?.some(d=>d.toLowerCase()===c)},u=o?.position;if(u!=="after"&&s(n)){let l=this.sourceNounValue(a);if(!l)return;e.advance(),e.advance(),this.eventSource=l;return}if(u==="after"&&s(a)){let l=this.sourceNounValue(n);if(!l)return;e.advance(),e.advance(),this.eventSource=l;}}sourceNounValue(e){if(e.kind==="selector")return this.tokenToSemanticValue(e)??void 0;if(e.kind!=="keyword"&&e.kind!=="identifier")return;let r=(e.normalized??e.value).toLowerCase();if(r!=="me"){if(Fe(r))return {type:"reference",value:r};if(e.kind==="identifier"&&/^[A-Za-z_$][\w$]*$/.test(e.value))return {type:"expression",raw:e.value}}}matchPatternToken(e,r,i,n){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":{let a=e.position(),o=this.matchRoleToken(e,r,i,n);return o&&i.has(r.role)&&this.roleStarts.set(r.role,a),o}case "group":return this.matchGroupToken(e,r,i,n);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(!i)return false;let n=this.getMatchType(i,r.value);if(n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(i,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let a of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(a.includes(o)&&this.tryMatchShatteredCompound(e,a,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let i=e.mark(),n=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;n.push(o.value),e.advance();let s=e.peek();if(!s||s.value!=="-")break;e.advance(),n.push("-");}if(n.length<3||n[n.length-1]==="-")return e.reset(i),null;let a=n.join("").toLowerCase();for(let[o,s]of Object.entries(r.keywords))if(s.primary.toLowerCase()===a||s.alternatives?.some(u=>u.toLowerCase()===a))return Y(o);return e.reset(i),null}tryMatchShatteredCompound(e,r,i){let n=r.split(i);if(n.length<2||n.some(o=>o.length===0))return false;let a=e.mark();for(let o=0;o<n.length;o++){if(o>0){let u=e.peek();if(!u||u.value!==i)return e.reset(a),false;e.advance();}let s=e.peek();if(!s||s.kind!=="identifier"&&s.kind!=="keyword"&&s.kind!=="particle"||s.value.toLowerCase()!==n[o].toLowerCase())return e.reset(a),false;e.advance();}return true}matchRoleToken(e,r,i,n){let a=e.position(),o=i.get(r.role);return this.matchRoleTokenCore(e,r,i,n)?(this.absorbTrailingConversion(e,r,i,n,a),this.absorbTrailingConditionOperand(e,r,i,n,a),this.absorbExpressionTail(e,r,i,n,a),this.stampCaptureSpan(e,r.role,i,a,o),true):false}absorbExpressionTail(e,r,i,n,a){if(r.role==="event"||r.role==="action"||this.isClassNameSlot(r)||!i.has(r.role)||e.position()<=a)return;let o=r.expectedTypes;if(o&&o.length>0&&!o.includes("expression"))return;let s=$.boundedByMarker(n)?wl(e.tokens,e.position(),this.extentContext()):kl(e.tokens,e.position(),this.currentProfile),u=bl(e.tokens,a,s,this.currentProfile);if(u){for(;e.position()<u.end;)e.advance();i.set(r.role,{type:"expression",raw:u.raw,value:u.raw});}}extentContext(){let e=this.restLiterals();return {profile:this.currentProfile,owes:r=>e.some(i=>this.patternTokenWouldMatch(i,r)),commandMarkers:this.commandMarkers(),hasResponseType:!!this.currentSchema()?.roles.some(r=>r.role==="responseType")}}isClassNameSlot(e){return e.role==="patient"&&["add","remove","toggle","take"].includes(this.currentRoleCommand??"")}isObjectValueSlot(e){let r=this.currentRoleCommand;return e.role==="source"?r==="get":e.role==="patient"&&(r==="put"||r==="set")}static boundedByMarker(e){return !e||e.type==="literal"?true:e.type==="group"?e.tokens[0]?.type==="literal":false}restLiterals(){let e=[],r=i=>{for(let n of i)n.type==="literal"?e.push(n):n.type==="group"&&r(n.tokens);};return r(this.patternRest),e}currentSchema(){let e=this.currentRoleCommand;if(!(!e||!(e in ue)))return ue[e]}commandMarkers(){let e=this.currentSchema(),r=this.currentProfile,i=new Set;if(!e||!r)return i;for(let n of e.roles){let a=n.markerOverride?.[r.code];if(a){i.add(a.toLowerCase());continue}let o=r.roleMarkers[n.role];if(o){i.add(o.primary.toLowerCase());for(let s of o.alternatives??[])i.add(s.toLowerCase());}}return i.delete(""),i}stampCaptureSpan(e,r,i,n,a){let o=i.get(r);if(!o||o===a||o.position||e.position()<=n)return;let s=e.tokens[n],u=e.tokens[e.position()-1];!s||!u||i.set(r,Xi(o,{start:s.position.start,end:u.position.end}));}absorbTrailingConditionOperand(e,r,i,n,a){if(r.role!=="condition"||!i.has("condition")||e.position()<=a)return;let o=this.currentPatternCommand==="repeat";if(!o&&(n!==void 0||this.currentPatternCommand!=="on"))return;let s=$.CONDITION_OPERATOR_WORDS,u=m=>{let p=(m.normalized??"").toLowerCase(),f=m.value.toLowerCase();if(s.has(p)||s.has(f))return true;let y=$.LOOP_CONDITION_OPERATORS;return o&&(y.has(f)||y.has(p))},l=m=>!!m&&(m.kind==="selector"||m.kind==="identifier"||m.kind==="literal")&&!u(m)&&!mr.has((m.normalized??m.value).toLowerCase())&&!this.patternTokenWouldMatch(n,m),c=false;for(;;){let m=e.peek();if(!m||!u(m)||this.patternTokenWouldMatch(n,m))break;e.advance(),c=true;let p=e.peek();if(l(p)){e.advance();for(let f=e.peek();!(!f||!/^\.[a-zA-Z_]\w*$/.test(f.value)||f.position.start!==p.position.end);f=e.peek())e.advance(),p=f;}if(!o)break}if(!c)return;let d=Be(e.tokens.slice(a,e.position()),this.currentProfile);i.set("condition",{type:"expression",raw:d,value:d});}conversionRunLength(e){let r=e.peek();if(!r||(r.normalized??r.value).toLowerCase()!=="as"&&r.value.toLowerCase()!=="as")return 0;let n=this.conversionTypeLength(e,1);if(n===0)return 0;for(n+=1;;){if(e.peek(n)?.value!=="|")return n;let a=this.conversionTypeLength(e,n+1);if(a===0)return n;n+=1+a;}}conversionTypeLength(e,r){let i=e.peek(r)?.value.toLowerCase(),n=i==="a"||i==="an"?r+1:r,a=e.peek(n);if(!a)return 0;let o=e.peek(n+1),s=e.peek(n+2);return o?.value===":"&&s&&zr(a,o)&&zr(o,s)&&Cr(`${a.value}:${s.value}`)?n-r+3:Cr(a.value)?n-r+1:0}absorbTrailingConversion(e,r,i,n,a){if(r.role==="event"||r.role==="action"||!i.has(r.role)||e.position()<=a)return;let o=this.conversionRunLength(e);if(o===0||this.patternTokenWouldMatch(n,e.peek()))return;for(let u=0;u<o;u++)e.advance();let s=Be(e.tokens.slice(a,e.position()),this.currentProfile);i.set(r.role,{type:"expression",raw:s,value:s});}matchRoleTokenCore(e,r,i,n){this.skipNoiseWords(e,r,n);let a=e.peek();if(!a)return r.optional||false;let o=this.slotAt(e,r,n);if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let g=this.tryFoldHyphenActionKeyword(e);if(g)return i.set(r.role,g),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!$.tokenLooksLikeEvent(a))return r.optional||false;let g=(a.normalized??a.value).toLowerCase();if($.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||$.VISIBILITY_STRATEGIES.has(g)||this.currentProfile&&(Se(this.currentProfile,a.value)??Se(this.currentProfile,g))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let g=(a.normalized??a.value).toLowerCase();if($.STRUCTURAL_NEVER_EVENT.has(g))return r.optional||false}if(Qu(o,this.currentProfile?.code??"")||rl(o,this.currentPatternCommand))return r.optional||false;if(r.role==="duration"){let g=(a.normalized??a.value).toLowerCase();if($.POSITIONAL_OR_SCOPE_KEYWORDS.has(g))return r.optional||false}if(tl(o))return true;if(this.roleAcceptsPropertyPath(r)){let g=this.tryMatchPositionalPossessiveExpression(e,n);if(g)return i.set(r.role,g),true}let s=this.tryMatchPositionalExpression(e,n);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!Mr(s.type,r.expectedTypes)?r.optional||false:(i.set(r.role,s),true);let u=this.tryMatchCaretScopeExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Mr(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);let l=this.tryMatchParenReceiverCall(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,l),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let g=this.tryMatchBeepPrefixExpression(e);if(g)return i.set(r.role,g),true;let A=this.tryMatchHyphenatedWord(e);if(A)return i.set(r.role,A),true;let b=this.isWrittenTarget(r)?null:this.tryMatchOperatorRunExpression(e);if(b)return i.set(r.role,b),true}if(this.currentPatternCommand==="pick"&&r.role==="patient"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let g=this.tryMatchPickRangeExpression(e);if(g)return i.set(r.role,g),true}if(this.roleAcceptsPropertyPath(r)){let g=this.tryMatchOfPossessiveExpression(e,n);if(g)return i.set(r.role,g),true;let A=this.tryMatchPostNominalPossessiveExpression(e);if(A)return i.set(r.role,A),true}let c=this.tryMatchPossessiveExpression(e);if(c)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(c.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,c),true);let d=this.tryMatchMethodCallExpression(e);if(d)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(d.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,d),true);let p=r.role==="event"&&this.currentPatternCommand==="on"||$.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")||this.isWrittenTarget(r)?null:this.tryMatchBareCallExpression(e);if(p)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(p.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,p),true);let f=this.tryMatchPossessiveSelectorExpression(e);if(f)return r.expectedTypes&&r.expectedTypes.length>0&&!Mr(f.type,r.expectedTypes)?r.optional||false:(i.set(r.role,f),true);let y=r.role!=="condition",v=this.tryMatchPropertyAccessExpression(e,y);if(v)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(v.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,v),true);let h=this.tryMatchSelectorPropertyExpression(e);if(h)return r.expectedTypes&&r.expectedTypes.length>0&&!Mr(h.type,r.expectedTypes)?r.optional||false:(i.set(r.role,h),true);if(a.value==="("&&r.role!=="event"&&r.role!=="action"&&(!r.expectedTypes?.length||r.expectedTypes.some(g=>g==="expression"||g==="selector"||g==="reference"))){let g=this.tryMatchParenGroupExpression(e);if(g)return i.set(r.role,g),true}if(a.kind==="identifier"&&a.value==="{"){let g=r.expectedTypes,b=g?.length===1&&g[0]==="expression"||this.isObjectValueSlot(r)?this.tryMatchBraceRunExpression(e):!g?.length||g.includes("literal")?this.tryMatchBraceRunLiteral(e):null;if(b)return i.set(r.role,b),true}if(r.role==="style"&&r.expectedTypes?.length===1&&r.expectedTypes[0]==="expression"){let g=wr(e);if(g)return i.set(r.role,{type:"expression",raw:g}),true}if(ol(o)||sl(o,this.currentSchema())||el(o,this.currentProfile?.code??""))return i.set(r.role,{type:"expression",raw:a.value}),e.advance(),true;let E=this.tokenToSemanticValue(a);if(!E)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(E.type)){let g=E.type==="selector"&&String(E.value).startsWith("@"),A=r.expectedTypes.some(b=>b==="expression"||b==="reference");if(!(g&&A))return r.optional||false}r.valueShape==="keyword"&&E.type==="expression"?i.set(r.role,Y(String(E.raw??""))):i.set(r.role,E),e.advance();let z=this.isClassNameSlot(r);if(E.type==="selector"&&(E.value.startsWith("<")||E.value.startsWith(".")&&!z)&&r.role!=="event"){let g=an(e.tokens,e.position(),this.currentProfile,A=>A===void 0?false:this.patternTokenWouldMatch(n,A));if(g){let[A,b]=g.scope.parts,x=g.scope.kind==="reference"?Ae(A.text):g.scope.kind==="closest"?{type:"expression",raw:`closest ${b.text}`}:this.tokenToSemanticValue(A.token);for(let D=0;D<1+g.scope.consumed;D++)e.advance();i.set(r.role,{...E,scope:x});}}if(r.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&g.position.start===a.position.end&&"value"in E&&(i.set(r.role,Y(`${String(E.value)}${g.value}`)),e.advance());let A=e.peek();if(A&&(A.kind==="particle"||A.kind==="keyword")&&(A.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(n,A)){let b=e.peek(1),x=b?this.sourceNounValue(b):void 0;x&&!this.eventSource&&(e.advance(),e.advance(),this.eventSource=x);}}return true}atClauseEnd(e){let r=e.peek();if(!r||r.kind==="conjunction")return true;if(r.kind!=="keyword")return false;let i=(r.normalized??r.value).toLowerCase();return i==="then"||i==="end"?true:Zr(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=br(e.tokens,e.position(),this.currentProfile,n=>n===void 0?false:this.patternTokenWouldMatch(r,n));if(!i)return null;for(let n=0;n<i.consumed;n++)e.advance();return {type:"expression",raw:i.parts.map(n=>n.text).join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let i=e.peek(1),n=e.peek(2),a=(i?.normalized??"").toLowerCase(),o=!!i&&(i.value.toLowerCase()==="on"||a==="destination"||a==="on");return !i||!n||n.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${n.value}`})}isOfPossessiveMarker(e){return We(this.currentProfile,e)}logicalConnectiveOf(e){let r=e.peek();if(!r)return;let i=this.currentProfile?.code??"en",n=u=>u==="and"||u==="or"||u==="not",a=Ze(i,r.value).toLowerCase();if(n(a))return a;if(this.commandMarkers().has(r.value.toLowerCase()))return;let o=e.position(),s=Iu(i,r,e.tokens[o-1],e.tokens[o+1]);return s&&n(s)?s:void 0}tryConsumeRunPhrase(e){let r=this.currentProfile?.code??"en",i=e.tokens,n=e.position(),a=[],o;for(let s=0;s<6&&n+s<i.length;s++){let u=i[n+s],l=lr(r,u,i[n+s-1],i[n+s+1],o).toLowerCase();a.push(l),o=l;}for(let[s,u]of $.RUN_PHRASES)if(s.every((l,c)=>a[c]===l)){for(let l=0;l<s.length;l++)e.advance();return u}}slotAt(e,r,i){return new Xu(e,r,this.slotAfterLiteral,i,this.wouldMatch)}static isBareWordToken(e){return !!e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.value)}tryMatchBeepPrefixExpression(e){let r=e.peek(),i=e.peek(1);if(!r||!i||i.value!=="!"||(r.normalized??r.value).toLowerCase()!=="beep"||!(r.position?.end!==void 0&&i.position?.start!==void 0&&r.position.end===i.position.start))return null;let a=e.mark(),o=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(a),null;for(;;){let u=e.peek();if(!u||!je.has(u.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e,true)){e.reset(l);break}}let s=Be(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:s,value:s}}tryMatchHyphenatedWord(e){let r=e.peek();if(!$.isBareWordToken(r))return null;let i=1,n=[r.value];for(;;){let a=e.peek(i),o=e.peek(i+1);if(!a||a.value!=="-"||!$.isBareWordToken(o)||!zr(e.peek(i-1),a)||!zr(a,o))break;n.push(o.value),i+=2;}if(n.length<2)return null;for(let a=0;a<i;a++)e.advance();return Y(n.join("-"),"string")}tryMatchOperatorRunExpression(e){let r=e.mark(),i=e.position(),n=e.peek(),a=!!n&&(this.logicalConnectiveOf(e)==="not"||n.value==="-");if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let o=1;for(;;){let u=e.peek();if(!u)break;let l=this.logicalConnectiveOf(e),c=(l==="and"||l==="or")&&this.currentRoleCommand!=="wait",d=e.mark();if(c||je.has(u.value))e.advance();else {let m=this.tryConsumeRunPhrase(e);if(m===void 0)break;if(m==="none"){o++;continue}}if(!this.tryConsumeRunOperand(e,true,c)){e.reset(d);break}o++;}if(o<2&&!a)return e.reset(r),null;let s=Be(e.tokens.slice(i,e.position()),this.currentProfile);return {type:"expression",raw:s,value:s}}static rangeSeparatorFor(e){let[r]=$.PICK_RANGE_SEPARATORS_BY_LANG[e]??[];return r}isPickRangeSeparator(e){let r=(e.normalized??e.value).toLowerCase();if($.PICK_RANGE_SEPARATORS.has(r))return true;let i=this.currentProfile?.code;return i?$.PICK_RANGE_SEPARATORS_BY_LANG[i]?.has(e.value.toLowerCase())??false:false}tryMatchPickRangeExpression(e){let r=e.mark(),i=e.position();if(!this.tryConsumePickRangeOperand(e))return e.reset(r),null;let n=e.peek();if(!n||!this.isPickRangeSeparator(n)||(e.advance(),!this.tryConsumePickRangeOperand(e)))return e.reset(r),null;let a=e.peek();a&&$.PICK_RANGE_MODES.has((a.normalized??a.value).toLowerCase())&&e.advance();let o=e.tokens.slice(i,e.position()),[s,,u,l]=o,c=m=>m.kind==="keyword"?m.normalized??m.value:m.value,d=`${c(s)} to ${c(u)}`;return l&&(d+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:d,value:d}}tryConsumePickRangeOperand(e){let r=e.peek();if(!r)return false;let i=(r.normalized??r.value).toLowerCase();if(this.isPickRangeSeparator(r))return false;let n=i==="start"||i==="end";return r.kind==="literal"||r.kind==="identifier"||r.kind==="keyword"&&n?(e.advance(),true):false}tryConsumeRunOperand(e,r=false,i=false){let n=e.peek();if(!n)return false;if(this.logicalConnectiveOf(e)==="not"){let o=e.mark();return e.advance(),al(e.peek()??void 0,e.peek(1)??void 0)?(e.reset(o),false):this.tryConsumeRunOperand(e,true,i)?true:(e.reset(o),false)}if(n.value==="-"){let o=e.mark();return e.advance(),this.tryConsumeRunOperand(e,true,i)?true:(e.reset(o),false)}if(i&&nl(n))return false;if(ll(n,r,e.peek(1)??void 0))return e.advance(),true;if(n.value==="("){let o=e.mark(),s=0;for(;!e.isAtEnd();){let u=e.advance();if(u.value==="(")s++;else if(u.value===")"&&(s--,s===0))return true}return e.reset(o),false}if(this.tryMatchPossessiveExpression(e))return true;if(n.value.toLowerCase()==="the"){let o=e.mark();if(e.advance(),this.tryConsumeRunOperand(e,r,i))return true;e.reset(o);}if(this.tryMatchOfPossessiveExpression(e)||this.tryMatchPossessiveSelectorExpression(e)||this.tryMatchPropertyAccessExpression(e,true)||this.tryMatchSelectorPropertyExpression(e))return true;let a=(n.normalized??"").toLowerCase();return (n.kind==="literal"||n.kind==="identifier"||n.kind==="selector"||n.kind==="keyword")&&!je.has(n.value)&&!["then","else"].includes(a)&&(a!=="end"||this.endWordIsValueAt(e))&&n.value!==")"?(e.advance(),true):false}endWordIsValueAt(e){return Pe(ve(e.tokens,e.position()),this.currentProfile?.code??"")}isPossessorToken(e){if(!this.currentProfile)return false;for(let r of [e.value,e.normalized].filter(Boolean))if(Se(this.currentProfile,r)??Se(this.currentProfile,r.toLowerCase()))return true;return false}isBareWordPropertyHead(e){return e.kind!=="identifier"||/^[$:@#.*]/.test(e.value)||this.isStructuralKeyword(e.value)||e.normalized&&this.isStructuralKeyword(e.normalized)||e.normalized&&this.isRoleMarkerConcept(e.normalized)?false:!this.isPossessorToken(e)}toEnglishProperty(e){return this.currentProfile?he(this.currentProfile.code,e):e}roleAcceptsPropertyPath(e){if(e.type!=="role")return false;if(e.expectedTypes)return e.expectedTypes.includes("property-path");let r=this.currentRoleCommand;return r?ue[r]?.roles.find(a=>a.role===e.role)?.expectedTypes?.includes("property-path")??false:false}tryMatchOfPossessiveExpression(e,r){let i=e.peek();if(!i||!(i.kind==="selector"?/^[*@]/.test(i.value):this.isBareWordPropertyHead(i)))return null;let a=e.position(),o=e.mark();e.advance();let s=e.peek();if(!s||!this.isOfPossessiveMarker(s))return e.reset(o),null;e.advance(),e.peek()?.value.toLowerCase()==="the"&&e.advance();let u=br(e.tokens,e.position(),this.currentProfile,c=>c===void 0?false:this.patternTokenWouldMatch(r,c));if(u){for(let c=0;c<u.consumed;c++)e.advance();return Re({type:"expression",raw:u.parts.map(c=>c.text).join(" ")},this.toEnglishProperty(i.value),"possessive")}let l=e.peek();if(!l||l.kind!=="selector"||Nl(l.value)){if(e.reset(o),this.patternTokenWouldMatch(r,s))return null;let c=this.currentProfile?.code??"en",d=pn(e.tokens,a,this.currentProfile,c);if(d===void 0)return null;for(;e.position()<=d;)e.advance();let m=Be(e.tokens.slice(a,d+1),this.currentProfile);return {type:"expression",raw:m,value:m}}return e.advance(),Re(Oe(l.value),this.toEnglishProperty(i.value),"possessive")}tryMatchPositionalPossessiveExpression(e,r){let i=this.currentProfile,n=i?.possessive?.marker;if(!i||!n||i.possessive?.markerPosition!=="between"||i.code==="th")return null;let a=br(e.tokens,e.position(),i,l=>l===void 0?false:this.patternTokenWouldMatch(r,l));if(!a)return null;let o=e.peek(a.consumed),s=e.peek(a.consumed+1);if(!o||o.value!==n)return null;let u=!!s&&(this.isBareWordPropertyHead(s)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="keyword"&&ei(i.code,s.value));if(!s||!u)return null;for(let l=0;l<a.consumed+2;l++)e.advance();return Re({type:"expression",raw:a.parts.map(l=>l.text).join(" ")},this.toEnglishProperty(s.value),"possessive")}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=[r.value,r.normalized].filter(Boolean),n;for(let u of i)if(n=Se(this.currentProfile,u)??Se(this.currentProfile,u.toLowerCase()),n)break;if(!n)return null;let a=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let u=e.peek();if(u){let l=u.value.toLowerCase(),c=(u.normalized??"").toLowerCase();o.some(d=>d.toLowerCase()===l||d.toLowerCase()===c)&&e.advance();}}let s=e.peek();if(!s||Cl(this.currentProfile.code,s.value))return e.reset(a),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)&&!(s.normalized&&this.isStructuralKeyword(s.normalized))&&!(s.normalized&&this.isRoleMarkerConcept(s.normalized))&&!(s.normalized&&$.COMMAND_ACTION_KEYWORDS.has(s.normalized.toLowerCase()))||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let u=s.value;s.kind==="selector"&&u.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u)&&(u=u.substring(1)),u=this.toEnglishProperty(u);let l=u;for(;;){let d=e.peek();if(d?.kind==="selector"&&d.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(d.value)){l+=d.value,e.advance();continue}if(d?.value==="?"){let m=e.peek(1);if(m?.kind==="selector"&&m.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(m.value)){l+=`?${m.value}`,e.advance(),e.advance();continue}}break}let c=e.peek();if(c&&c.value.startsWith("(")){let d="",m=0,p=0;for(;!e.isAtEnd()&&p++<$.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;d+=f.value,e.advance();for(let y of f.value)y==="("?m++:y===")"&&m--;if(m<=0)break}l+=d;}return Re(Ae(n),l,"possessive")}return e.reset(a),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=e.peek();if(!r)return null;let i=r.kind==="selector"&&r.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(r.value);if(!(r.kind==="identifier"&&!this.isStructuralKeyword(r.value)&&!(r.normalized&&this.isStructuralKeyword(r.normalized))&&!(r.normalized&&this.isRoleMarkerConcept(r.normalized))||r.kind==="selector"&&(r.value.startsWith("*")||r.value.startsWith("@"))||i)||this.isPossessorToken(r))return null;let a=e.mark(),o=r.value;i&&(o=o.substring(1)),e.advance(),o=this.toEnglishProperty(o);let s=o;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)s+=e.peek().value,e.advance();let u=e.peek();if(!u)return e.reset(a),null;let l;for(let d of [u.value,u.normalized].filter(Boolean))if(l=Se(this.currentProfile,d)??Se(this.currentProfile,d.toLowerCase()),l)break;if(!l)return e.reset(a),null;let c=e.mark();return this.tryMatchPossessiveExpression(e)?(e.reset(a),null):(e.reset(c),e.advance(),Re(Ae(l),s,"possessive"))}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}isRoleMarkerConcept(e){return xr.has(e.toLowerCase())}static tokenLooksLikeEvent(e){if(e.kind==="selector"||e.kind==="url"||e.kind==="literal")return false;let r=e.value;if(/[/#@*]/.test(r)||r.startsWith('"')||r.startsWith("'")||r.startsWith("`"))return false;let i=e.normalized?.toLowerCase();return !(i&&Ll.has(i)||i==="me"||i==="it"||i==="you")}tryMatchBraceRunLiteral(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let i=e.mark();e.advance();let n=["{"],a=1,o=0;for(;!e.isAtEnd()&&o++<$.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(s.value==="{")a++;else if(s.value==="}"&&(a--,a===0))return n.push("}"),Y(n.join(" "));n.push(s.value);}return e.reset(i),null}tryMatchBraceRunExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let i=e.mark(),n="",a=-1,o=0,s=0;for(;!e.isAtEnd()&&s++<$.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(a>=0&&u.position.start>a&&(n+=" ".repeat(u.position.start-a)),n+=u.value,a=u.position.end,u.value==="{")o++;else if(u.value==="}"&&(o--,o===0))return {type:"expression",raw:n}}return e.reset(i),null}tryMatchBareCallExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(r.value))return null;let i=e.peek(1);if(!i||i.value!=="(")return null;let n=e.mark();e.advance();let a=e.advance(),o="",s=a.position?.end,u=false,l=0;for(;!e.isAtEnd()&&l++<$.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),u=true;break}let d=s!==void 0&&c.position?.start===s;o+=(o===""||d?"":" ")+c.value,s=c.position?.end,e.advance();}return u?{type:"expression",raw:`${r.value}(${o})`}:(e.reset(n),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(i),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<$.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}s.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${s.join(", ")})`}}tryMatchParenReceiverCall(e){if(e.peek()?.value!=="(")return null;let r=e.mark(),i=[];e.advance();let n=1;for(;!e.isAtEnd()&&i.length<=$.MAX_METHOD_ARGS*4;){let c=e.peek();if(e.advance(),c.value==="(")n++;else if(c.value===")"&&--n===0)break;i.push(c);}let a=e.tokens[e.position()-1],o=e.peek();if(n!==0||i.length===0||!o||o.kind!=="selector"||!/^\.[A-Za-z_$][\w$]*$/.test(o.value)||!$.abuts(a,o))return e.reset(r),null;e.advance();let s=e.peek();if(s?.value!=="("||!$.abuts(o,s))return e.reset(r),null;let u=this.consumeCallParens(e);return u===null?(e.reset(r),null):{type:"expression",raw:`(${Be(i,this.currentProfile)})${o.value}${u}`}}tryMatchParenGroupExpression(e){if(e.peek()?.value!=="(")return null;let r=e.mark();e.advance();let i=[],n=1;for(;!e.isAtEnd();){let l=e.peek();if(e.advance(),l.value==="(")n++;else if(l.value===")"&&--n===0)break;i.push(l);}let a=e.tokens[e.position()-1],o=e.peek(),s=!!o&&(o.value==="'"||je.has(o.value)||$.abuts(a,o)&&(o.value.startsWith(".")||o.value==="("));if(n!==0||i.length===0||s)return e.reset(r),null;let u=`(${Be(i,this.currentProfile)})`;return {type:"expression",raw:u,value:u}}static abuts(e,r){return !!e&&!!r&&e.position.end===r.position.start}consumeCallParens(e){let r=e.mark(),i=[],n=0;for(;!e.isAtEnd();){let a=e.peek();if(!a)break;if(i.push(a.value),e.advance(),a.value==="(")n++;else if(a.value===")"&&--n===0)return i.join("")}return e.reset(r),null}tryMatchPropertyAccessExpression(e,r=true){let i=e.peek();if(!i||i.kind!=="identifier"&&i.kind!=="keyword")return null;let n=e.mark();e.advance();let a=i.value.toLowerCase(),o=e.peek();if((i.kind==="identifier"||$.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)&&o.position.start===i.position.end){let p=i.value,f=[],y=0;for(;y<$.MAX_PROPERTY_DEPTH;){let E=e.peek();if(E&&E.kind==="selector"&&/^\.[a-zA-Z_]/.test(E.value))p+=`.${E.value.slice(1)}`,f.push(E.value.slice(1)),e.advance(),y++;else break}let v=e.peek(),h=!!v&&v.value.startsWith("(");return r&&!h&&f.length>0&&Fe(a)?Re(Ae(a),f.join("."),"dot"):(h&&(p+=this.consumeCallParens(e)??""),{type:"expression",raw:p})}let s=e.peek();if(!s||s.kind!=="operator"||s.value!==".")return e.reset(n),null;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")return e.reset(n),null;e.advance();let l=`${i.value}.${u.value}`,c=1;for(;!e.isAtEnd()&&c<$.MAX_PROPERTY_DEPTH;){let p=e.peek();if(!p||p.kind!=="operator"||p.value!==".")break;e.advance();let f=e.peek();if(!f||f.kind!=="identifier")break;e.advance(),l+=`.${f.value}`,c++;}let d=e.peek();if(d&&d.kind==="punctuation"&&d.value==="("){e.advance();let p=[],f=0;for(;!e.isAtEnd()&&p.length<$.MAX_METHOD_ARGS;){let v=e.peek();if(!v)break;if(v.kind==="punctuation"&&v.value===")"){if(f===0){e.advance();break}f--;}if(v.kind==="punctuation"&&v.value==="("&&f++,v.kind==="punctuation"&&v.value===","){e.advance();continue}p.push(v.value),e.advance();}return {type:"expression",raw:`${l}(${p.join(", ")})`}}let m=i.value.toLowerCase();if(r&&Fe(m)){let p=l.split(".").slice(1).join(".");return Re(Ae(m),p,"dot")}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek(),a=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!n&&n.kind==="punctuation"&&n.value==="'s",s=!!n&&n.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",u=(()=>{if(!this.currentPatternCommand||(n?.normalized??"").toLowerCase()!=="source")return false;let f=ue[this.currentPatternCommand];return !!f&&f.roles.some(y=>y.role==="source")})(),l=!!n&&!!a&&a!=="'s"&&n.value===a&&(n.kind==="particle"||n.kind==="punctuation"||n.kind==="identifier")&&!u;if(!o&&!l&&!s)return e.reset(i),null;e.advance(),s&&e.advance();let c=e.peek();if(!c)return e.reset(i),null;let d=c.kind==="selector"&&c.value.startsWith("*"),m=c.kind==="keyword"&&!!this.currentProfile&&ei(this.currentProfile.code,c.value);return c.kind==="identifier"||d||m||(o||s)&&(c.kind==="selector"||c.kind==="keyword")?(e.advance(),Re(Oe(r.value),this.toEnglishProperty(c.value),"possessive")):(e.reset(i),null)}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(i),null;e.advance();let a=[n.value.slice(1)],o=n;for(let u=e.peek();u&&u.kind==="selector"&&/^\.[a-zA-Z_]/.test(u.value)&&a.length<$.MAX_PROPERTY_DEPTH;u=e.peek())a.push(u.value.slice(1)),o=u,e.advance();let s=e.peek();if(s?.value==="("&&$.abuts(o,s)){let u=this.consumeCallParens(e);if(u!==null)return {type:"expression",raw:`${r.value}.${a.join(".")}${u}`}}return Re(Oe(r.value),a.join("."),"dot")}matchGroupToken(e,r,i,n){let a=e.mark(),o=new Map(i),s=this.matchTokenSequence(e,r.tokens,i,n);if(s){let u=[];for(let l of r.tokens)if(l.type==="group"&&l.renderRequired)for(let c of l.tokens)c.type==="literal"&&u.push(c.value,...c.alternatives??[]);u.length>0&&[...i.keys()].some(c=>!o.has(c))&&(e.tokens.slice(a.position,e.position()).some(m=>u.some(p=>this.getMatchType(m,p)!=="none"))||(s=false));}if(!s){e.reset(a);for(let u of i.keys())o.has(u)||i.delete(u);for(let[u,l]of o)i.get(u)!==l&&i.set(u,l);return r.optional||false}return true}getMatchType(e,r){if(e.value===r)return "exact";if(e.normalized===r)return "normalized";if(e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7)return "stem";if(e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase())return "case-insensitive";if(e.kind==="keyword"){let i=Lr(e.value).toLowerCase();if(i&&i===Lr(r).toLowerCase())return "case-insensitive"}return "none"}isWrittenTarget(e){return $.WRITTEN_ROLE[this.currentRoleCommand??""]===e.role}tokenToSemanticValue(e){return Vr(e)}applyExtractionRules(e,r){for(let[i,n]of Object.entries(e.extraction)){let a=r.get(i);if(a){if(n.transform){let o=a.type==="literal"?String(a.value):String(a.raw??"");r.set(i,n.transform(o));}}else n.value!==void 0?r.set(i,{type:"literal",value:n.value}):n.default&&r.set(i,{...n.default,implicit:true});}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e,r,i){let n=e.peek();if(!n)return;let a=n.value.toLowerCase();if($.ENGLISH_NOISE_WORDS.has(a)){if(Ju(this.slotAt(e,r,i)))return;let o=e.mark();e.advance();let s=e.peek();if(s&&(s.kind==="selector"||s.kind==="identifier"))return;let u=e.peek(1);if(s&&s.kind==="keyword"&&u&&u.kind==="selector"&&/^\.[a-zA-Z_]/.test(u.value))return;let l=s?(s.normalized??s.value).toLowerCase():"";if(s&&$.POSITIONAL_OR_SCOPE_KEYWORDS.has(l))return;let c=e.peek(1),d=c?(c.normalized??c.value).toLowerCase():"",m=this.currentProfile?.wordOrder!=="SOV"&&$.COMMAND_ACTION_KEYWORDS.has(d),p=!c||c.kind==="particle"||$.CLAUSE_BOUNDARY_KEYWORDS.has(d)||m;if(s&&s.kind==="keyword"&&this.currentProfile?.code!=="en"&&Fe(l)&&p||s&&s.kind==="keyword"&&this.currentProfile?.code==="en"&&Fe(l))return;e.reset(o);}a==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(i=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return i?r:void 0}};ie.CONDITION_OPERATOR_WORDS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);ie.LOOP_CONDITION_OPERATORS=new Set([...Ji,"and","or"]);ie.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);ie.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then","while"]);ie.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);ie.COMMAND_ACTION_KEYWORDS=mr;ie.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);ie.RUN_PHRASES=[...kt.map(t=>[t.split(" "),"none"]),...bt.map(t=>[t.split(" "),"type"]),...wt.filter(t=>!/^(in|am|has|have)$|^am /.test(t)).map(t=>[t.split(" "),"operand"]),[["exists"],"none"]];ie.PICK_RANGE_SEPARATORS=new Set(["to"]);ie.PICK_RANGE_SEPARATORS_BY_LANG={ar:new Set(["\u0625\u0644\u0649"]),bn:new Set(["\u09A5\u09C7\u0995\u09C7"]),de:new Set(["zu","bis"]),es:new Set(["a"]),fr:new Set(["\xE0"]),he:new Set(["\u05E2\u05DC","\u05E2\u05D3"]),hi:new Set(["\u0938\u0947"]),id:new Set(["ke"]),it:new Set(["in","a"]),ja:new Set(["\u304B\u3089"]),ko:new Set(["\uBD80\uD130"]),ms:new Set(["ke"]),pl:new Set(["do"]),pt:new Set(["para","a"]),qu:new Set(["kama"]),ru:new Set(["\u0432","\u0434\u043E"]),sw:new Set(["kwa","hadi"]),th:new Set(["\u0E43\u0E19","\u0E16\u0E36\u0E07"]),tl:new Set(["sa"]),tr:new Set(["ile"]),uk:new Set(["\u0432","\u0434\u043E"]),vi:new Set(["v\xE0o","\u0111\u1EBFn"]),zh:new Set(["\u5230"])};ie.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);ie.VISIBILITY_STRATEGIES=new Set(["display","visibility","opacity","twdisplay","twvisibility","twopacity"]);ie.MAX_BRACE_RUN_TOKENS=64;ie.MAX_PROPERTY_DEPTH=10;ie.MAX_METHOD_ARGS=20;ie.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);ie.WRITTEN_ROLE={increment:"patient",decrement:"patient",set:"destination"};ie.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var An=ie,Ce=new An;function Z(t,e){return Vs(t,e)}function xn(){return js()}var qr={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"])},Ml=new Set(Object.values(qr).flatMap(t=>[...t]));function Wr(t,e){let r=(t.normalized??t.value).toLowerCase();if(r==="or")return true;let i=e===void 0?Ml:qr[e];return i?i.has(t.value)||i.has(r):false}var Sn=["if","unless","repeat","for","while"],Yr=/^[A-Z][A-Za-z0-9_]*$/;function Q(t,e){let r=new Set([e]),n=O(t)?.keywords?.[e];if(n){n.primary&&r.add(n.primary.toLowerCase());for(let a of n.alternatives??[])r.add(a.toLowerCase());}return r}function V(t,e){return e.has(t.value.toLowerCase())?true:t.normalized?e.has(t.normalized.toLowerCase()):false}var _l=new Set(Sn);function Sr(t){return {byAction:Sn.map(e=>[e,Q(t,e)]),elseForms:Q(t,"else"),inForms:Q(t,"in")}}function yi(t,e){if(!t)return;let r=t.normalized?.toLowerCase();return r?_l.has(r)?r:void 0:e.byAction.find(([,i])=>V(t,i))?.[0]}function Dr(t,e,r){let i=t[e],n=yi(i,r);if(!n||n==="while")return false;let a=t[e-1];if(n==="for"){if(yi(a,r)==="repeat")return false;if(i.value.toLowerCase()==="for"){let o=t[e+2];return !!o&&(V(o,r.inForms)||o.normalized==="in")}}return !(n==="if"&&a&&V(a,r.elseForms))}var hi=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Il=new Set(["destination","source","style","patient","on","from","to"]);function or(t){if(!t||t.kind==="selector")return false;let e=(t.normalized??t.value).toLowerCase(),r=t.value.toLowerCase();return !(hi.has(e)||hi.has(r)||Il.has(e))}var $l=t=>Object.prototype.hasOwnProperty.call(ue,t);function Dn(t){return t.flatMap(e=>e.type==="literal"?[e.value,...e.alternatives??[]].map(r=>r.toLowerCase()):e.type==="group"?Dn(e.tokens):[])}var jl=new Set(["toggle","trigger"]);function Bn(t){return t.flatMap((e,r)=>{if(e.type==="group")return Bn(e.tokens);if(e.type!=="literal")return [];let i=t[r+1];return [{words:[e.value,...e.alternatives??[]].map(n=>n.toLowerCase()),role:i?.type==="role"?i.role:void 0}]})}function Vl(t,e,r,i){return t.some((n,a)=>{if(!n.words.includes(e)||!n.role||!i.has(n.role))return false;let o=0;for(let s of r){let u=t.findIndex((l,c)=>c>=o&&c<a&&l.words.includes(s));if(u<0)return false;o=u+1;}return true})}function Wl(t,e,r,i,n){let a=t[r].value.toLowerCase();for(let o=r-1;o>e;o--){let s=t[o];if(n(s)||s.value.toLowerCase()===a)return false;let u=(s.normalized??s.value).toLowerCase();if(!$l(u))continue;let l=pe(i).filter(d=>d.command===u);if(jl.has(u))return l.some(d=>Dn(d.template.tokens).includes(a));let c=new Set((ue[u]?.roles??[]).filter(d=>d.required).map(d=>d.role));return l.some(d=>{let m=Bn(d.template.tokens),p=new Set(m.flatMap(y=>y.words)),f=t.slice(o+1,r).map(y=>y.value.toLowerCase()).filter(y=>p.has(y));return Vl(m,a,f,c)})}return false}var vi=new Set(["ja","ko"]);function Ve(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 Tn(t,e){let r=[],i=e.position.end,n=t.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(n){i=e.position.end+n[0].length;for(let a of n[1].split(/[,\u060c\u3001]/)){let o=a.trim();o&&r.push(o);}}return {parameters:r,headerEnd:i}}function Br(t,e,r){let i=e+1;if(i>=t.length)return -1;let n=Ve(O(r)?.roleMarkers?.patient);return n.size>0&&V(t[i],n)&&i++,i<t.length?i:-1}var Fn=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function ql(t){let e=1;if(t[1]?.value==="("){let r=0,i=1;for(;i<t.length;i++)if(t[i].value==="(")r++;else if(t[i].value===")"&&--r===0)break;if(i>=t.length)return -1;e=i+1;}return e+1}function Kl(t,e,r){let i=O(r);if(i?.wordOrder!=="SOV"||!Fn.test(t[0].value)||e!==ql(t))return false;let n=Ve(i.roleMarkers?.patient);return n.size===0?false:V(t[e-1],n)}function Hl(t,e,r){if(!O(e))return null;let i=Q(e,"behavior"),n=Q(e,"def"),a=t.toLowerCase(),o=[...i].some(d=>a.includes(d)),s=/\bdef\b/.test(a)||[...n].some(d=>d!=="def"&&a.includes(d));if(!o&&!s)return null;let u=Z(t,e).tokens;if(u.length<2)return null;if(V(u[0],i))return Ei(t,e,u,r,0);let l=u.findIndex((d,m)=>m>0&&V(d,i));if(l>0&&Yr.test(u[0].value))return Ei(t,e,u,r,l);if(V(u[0],n))return gi(t,e,u,r,0);let c=u.findIndex((d,m)=>m>0&&V(d,n));return c>0&&Kl(u,c,e)?gi(t,e,u,r,c):null}function Ul(t,e,r){let i=O(e);if(!i)return null;let n=i.wordOrder!=="SOV",a=vi.has(e)?Ve(i.roleMarkers?.event):new Set,o=vi.has(e)?Ve(i.keywords?.on):new Set,s=a.size>0&&o.size>0,u=s?Ve(i.roleMarkers?.source):new Set,l=Q(e,"end"),c=Q(e,"on"),d=Q(e,"then"),m=t.toLowerCase(),p=[...l].some(x=>m.includes(x)),f=(n||s)&&(()=>{let x=0;for(let D of c)if(D){for(let w=m.indexOf(D);w>=0;w=m.indexOf(D,w+D.length))if(++x>=2)return true}return false})();if(!p&&!f)return null;let y=Z(t,e).tokens;if(y.length<2)return null;let v=Sr(e),h=x=>Dr(y,x,v),E=x=>V(x,l),z=[],k=0,g=0;for(let x=0;x<y.length;x++){let D=y[x];if(E(D)){if(k>0){k--;continue}let w=t.slice(y[g].position.start,D.position.start).trim();w&&z.push(w),g=x+1;}else if(h(x))k++;else if(n&&k===0&&x>g&&V(D,c)&&or(y[x+1])&&!(y[x+2]&&V(y[x+2],d))&&!Wl(y,g,x,e,w=>E(w)||V(w,d))){let w=t.slice(y[g].position.start,D.position.start).trim();w&&z.push(w),g=x;}else if(s&&k===0&&x-1>g&&V(D,a)&&y[x+1]!==void 0&&V(y[x+1],o)){let w=y[x-1],C=y.slice(g,x-1);if(!(C.length===2&&V(C[1],u))){let R=t.slice(y[g].position.start,w.position.start).trim();R&&z.push(R),g=x-1;}}}if(g<y.length){let x=t.slice(y[g].position.start).trim();x&&z.push(x);}if(z.length<2)return null;let A=[],b=[];for(let x of z){let D;try{D=r.statement(x,e);}catch{return null}if(!D||D.kind!=="event-handler")return null;let w=D;if(A.push(w),!w.body||w.body.length===0)return null;b.push(w.metadata?.confidence??.75);}return ir(A,"then",{sourceLanguage:e,confidence:cr(b),sourceText:t})}function cr(t){return t.length>0?t.reduce((e,r)=>e+r,0)/t.length:0}function Xr(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 Ei(t,e,r,i,n){let a=n>0,o=a?0:Br(r,n,e);if(o<0)return null;let s=r[o],u=s.value;if(!Yr.test(u))return null;let{parameters:l,headerEnd:c}=Tn(t,s),d=a?n+1:r.findIndex(C=>C.position.start>=c);d<=o&&(d=o+1);let m=Q(e,"init"),p=Q(e,"end"),f=Sr(e),y=C=>Dr(r,C,f),v=C=>V(C,p),h=O(e)?.wordOrder!=="SOV",E=h?Gl(e):new Set,z=C=>{let S=t.slice(r[D].position.end,r[C].position.start).trim();if(S)try{let R=Xr(i.body(S,e));g.push(...R),A.push(cr(R.map(_=>_.metadata?.confidence??.75)));}catch{A.push(0);}},k=[],g=[],A=[],b=false,x=0,D=d;for(let C=d;C<r.length;C++){let S=r[C];if(v(S)){if(x>0){x--;continue}if(C===D){b=true;break}if(V(r[D],m))z(C);else {let R=t.slice(r[D].position.start,S.position.start).trim();try{let _=i.statement(R,e);if(_&&_.kind==="event-handler"){let F=_;k.push(F);let T=!F.body||F.body.length===0;A.push(T?.2:F.metadata?.confidence??.75);}else A.push(0);}catch{A.push(0);}}D=C+1;}else y(C)?x++:h&&x===0&&C>D&&V(r[D],m)&&E.has(S.value.toLowerCase())&&(r[C+1]?.kind==="identifier"||r[C+1]?.kind==="keyword")&&or(r[C+1])&&(z(C),D=C);}if(k.length===0&&g.length===0)return null;let w=(b?1:.8)*cr(A);return hu(u,l,k,g.length>0?g:void 0,{sourceLanguage:e,confidence:w,sourceText:t})}function Gl(t){let e=new Set;for(let r of pe(t))if(!(r.command!=="on"||/-event-/i.test(r.id)))for(let i of r.template.tokens){if(i.type==="role"&&i.role==="event")break;if(i.type==="literal")for(let n of [i.value,...i.alternatives??[]])e.add(n.toLowerCase());}return e}function gi(t,e,r,i,n){let a=n>0,o=a?0:Br(r,n,e);if(o<0)return null;let s=r[o],u=s.value;if(!Fn.test(u))return null;let{parameters:l,headerEnd:c}=Tn(t,s),d=a?n+1:r.findIndex(b=>b.position.start>=c);d<=o&&(d=o+1);let m=Q(e,"end"),p=Sr(e),f=b=>Dr(r,b,p),y=b=>V(b,m),v=0,h=-1;for(let b=d;b<r.length;b++)if(y(r[b])){if(v===0){h=b;break}v--;}else f(b)&&v++;let E=r[d]?.position.start??c,z=h>=0?r[h].position.start:t.length,k=t.slice(E,z).trim();if(!k)return null;let g;try{g=Xr(i.body(k,e));}catch{return null}if(g.length===0)return null;let A=cr(g.map(b=>b.metadata?.confidence??.75));return h<0&&(A*=.8),vu(u,l,g,{sourceLanguage:e,confidence:A,sourceText:t})}var vt=["live","eventsource","socket","worker","intercept"],Zl=new Set(["intercept"]),Ft=new Set(["eventsource","socket","worker"]),Yl=new Set(["eventsource","socket"]),Xl=new Set(["worker"]),Jl=6,Ql=2;function ec(t,e){for(let i of vt)if(V(t[0],Q(e,i)))return {action:i,keywordIdx:0};if(O(e)?.wordOrder!=="SOV")return null;let r=Math.min(t.length,Jl);for(let i=1;i<r;i++)for(let n of vt)if(n!=="live"&&V(t[i],Q(e,n))&&!(Ft.has(n)&&!Yr.test(t[0].value))&&!(n==="intercept"&&i>Ql))return {action:n,keywordIdx:i};return null}function rc(t,e,r){let i=Ve(O(r)?.roleMarkers?.source);return i.size===0||e+1>=t.length?0:V(t[e],i)||V(t[e+1],i)?2:0}function On(t){let e=Q(t,"on");e.add("when");let r=O(t)?.eventHandler;if(r?.keyword){e.add(r.keyword.primary.toLowerCase());for(let i of r.keyword.alternatives??[])e.add(i.toLowerCase());}for(let i of r?.temporalMarkers??[])e.add(i.toLowerCase());return e}function tc(t,e,r){let i=O(r)?.eventHandler,n=[i?.eventMarker?.primary,...i?.eventMarker?.alternatives??[],...i?.temporalMarkers??[]].filter(o=>!!o&&/\s/.test(o)),a=1;for(let o of n){let s=o.toLowerCase().split(/\s+/),u=e-s.length+1;u<0||s.every((l,c)=>t[u+c]?.value.toLowerCase()===l)&&(a=Math.max(a,s.length));}return a}function ic(t,e,r,i,n){if(t==="live")return r+1;if(r>0){let l=r+1;return t==="eventsource"&&(l+=rc(e,l,i)),l}let a=Br(e,r,i);if(a<0)return -1;if(t==="worker")return a+1;let o=On(i),s=Ve(O(i)?.roleMarkers?.event),u=n>=0?n:e.length;for(let l=a+1;l<u;l++){if(!V(e[l],o))continue;if(or(e[l+1]))return l;if(l>a+2&&s.size>0&&V(e[l-1],s)&&or(e[l-2]))return l-2;let c=tc(e,l,i);if(c>1&&l-c>a&&or(e[l-c]))return l-c;if(l>a+1&&or(e[l-1]))return l-1}return u}function nc(t,e,r,i){if(!Ft.has(t))return;let n=r>0?0:Br(e,r,i);if(!(n<0))return e[n].value}function ac(t,e,r){if(!O(e))return null;let i=t.toLowerCase(),n=false;for(let u of [...vt,"changes"]){for(let l of Q(e,u))if(l&&i.includes(l)){n=true;break}if(n)break}if(!n)return null;let a=Z(t,e).tokens;if(a.length<2)return null;let o=cc(a,e);if(o>=0)return mc(t,e,a,r,o);let s=ec(a,e);return s?oc(t,e,a,r,s.action,s.keywordIdx):null}function oc(t,e,r,i,n,a){let o=Q(e,"end"),s=Sr(e),u=g=>Dr(r,g,s),l=g=>V(g,o),c=nc(n,r,a,e);if(Ft.has(n)&&(!c||!Yr.test(c)))return null;let d=g=>({sourceLanguage:e,confidence:g,sourceText:t}),m=Et(r,a+1,l,u);if(Zl.has(n))return m>=0&&m!==r.length-1?null:ft(n,[],c,d(m>=0?1:.8));let p=ic(n,r,a,e,m);if(p<0||p>r.length)return null;let f=[],y=[],v=false,h=Xl.has(n);if(h||Yl.has(n)){let g=h?"def":"event-handler",A=0,b=p;for(let x=p;x<r.length;x++){let D=r[x];if(l(D)){if(A>0){A--;continue}if(v=true,x===b)break;let w=h?D.position.end:D.position.start,C=t.slice(r[b].position.start,w).trim();try{let S=i.statement(C,e);if(S&&S.kind===g){let R=S;f.push(R);let _=!R.body||R.body.length===0;y.push(_?.2:R.metadata?.confidence??.75);}else y.push(0);}catch{y.push(0);}b=x+1;}else u(x)&&A++;}}else {let g=Et(r,p,l,u);v=g>=0;let A=g>=0?r[g].position.start:t.length,b=t.slice(r[p].position.start,A).trim();if(!b)return null;try{f.push(...Xr(i.body(b,e)));}catch{return null}if(f.length===0)return null;y.push(...f.map(x=>x.metadata?.confidence??.75));}if(f.length===0&&!v)return null;let E=v?1:.8,z=y.length>0?E*cr(y):E,k=sc(n,t,r,a,p,e);return ft(n,f,c,d(z),k?new Map([["source",k]]):void 0)}function sc(t,e,r,i,n,a){if(t!=="eventsource"&&t!=="socket"||i!==0)return;let o=Br(r,i,a);if(o<0)return;let s=o+1,u=Math.min(n,r.length)-1;if(t==="eventsource"){let c=Ve(O(a)?.roleMarkers?.source),d=m=>!!m&&(V(m,c)||(m.normalized??"").toLowerCase()==="source");d(r[s])?s++:d(r[u])&&u--;}if(s>u)return;let l=e.slice(r[s].position.start,r[u].position.end).trim();return l?{type:"expression",raw:l}:void 0}var uc=new Set([...Object.keys(ue),"then","else"]);function lc(t){let e=Q(t,"when");for(let r of On(t))e.add(r);return e}function cc(t,e){if(t.length<3||!V(t[0],lc(e)))return -1;let r=Q(e,"changes"),i=Q(e,"end");for(let n=2;n<t.length;n++){let a=t[n];if(a.kind==="literal")continue;if(V(a,r))return n;if(V(a,i))return -1;let o=(a.normalized??a.value).toLowerCase();if(a.kind==="keyword"&&uc.has(o))return -1}return -1}function dc(t,e,r){if(r==="en"){let n=e[0],a=e[e.length-1];return {type:"expression",raw:t.slice(n.position.start,a.position.end).trim()}}let i=e.map(n=>Wr(n,r)?{...n,kind:"keyword",normalized:"or"}:n);return {type:"expression",raw:Be(i,O(r))}}function mc(t,e,r,i,n){let a=Q(e,"end"),o=Sr(e),s=E=>Dr(r,E,o),u=E=>V(E,a),l=n+1;if(l>=r.length)return null;let c=Et(r,l,u,s),d=c>=0;if(d&&c!==r.length-1)return null;let m=d?r[c].position.start:t.length,p=t.slice(r[l].position.start,m).trim();if(!p)return null;let f;try{f=Xr(i.body(p,e));}catch{return null}if(f.length===0)return null;let y=dc(t,r.slice(1,n),e),h=(d?1:.8)*cr(f.map(E=>E.metadata?.confidence??.75));return ft("when",f,void 0,{sourceLanguage:e,confidence:h,sourceText:t},new Map([["condition",y]]))}function Et(t,e,r,i){let n=0;for(let a=e;a<t.length;a++)if(r(t[a])){if(n===0)return a;n--;}else i(a)&&n++;return -1}var Te={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll",\uB9C8\uC6B0\uC2A4\uC5D4\uD130:"mouseenter",\uB9C8\uC6B0\uC2A4\uB9AC\uBE0C:"mouseleave",\uB9C8\uC6B0\uC2A4\uBB34\uBE0C:"mousemove",\uD0A4\uD504\uB808\uC2A4:"keypress",\uD130\uCE58\uC885\uB8CC:"touchend",\uD130\uCE58\uCDE8\uC18C:"touchcancel"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll",\u307C\u304B\u3057:"blur"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll",\u062A\u0631\u0643\u064A\u0632:"focus","\u0645\u0641\u062A\u0627\u062D \u0623\u0633\u0641\u0644":"keydown","\u0645\u0641\u062A\u0627\u062D \u0623\u0639\u0644\u0649":"keyup","\u0641\u0623\u0631\u0629 \u0641\u0648\u0642":"mouseover","\u062A\u063A\u064A\u064A\u0631 \u062D\u062C\u0645":"resize"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll",cambiar:"change",enfocar:"focus",desenfocar:"blur",cargar:"load",desplazar:"scroll",dobleclic:"dblclick",rat\u00F3nentrar:"mouseenter",rat\u00F3nsalir:"mouseleave",rat\u00F3nmover:"mousemove",teclapresar:"keypress",descargar:"unload",toqueempezar:"touchstart",toqueterminar:"touchend",toquemover:"touchmove",toquecancelar:"touchcancel"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll",bulan\u0131k:"blur",farebas:"mousedown",fareb\u0131rak:"mouseup",kayd\u0131r:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll",duploClique:"dblclick",mouseEntrar:"mouseenter",mouseSair:"mouseleave",mouseMover:"mousemove",teclaPressionar:"keypress",descarregar:"unload",toqueIn\u00EDcio:"touchstart",toqueFim:"touchend",toqueMover:"touchmove",toqueCancelar:"touchcancel"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll",\u6309\u952E\u6309\u4E0B:"keydown",\u9F20\u6807\u79FB\u52A8:"mousemove",\u5378\u8F7D:"unload",\u8C03\u6574\u5927\u5C0F:"resize",\u89E6\u6478\u5F00\u59CB:"touchstart",\u89E6\u6478\u79FB\u52A8:"touchmove"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll",flou:"blur",doubleclic:"dblclick",sourisentrer:"mouseenter",sourissortir:"mouseleave",sourisbouger:"mousemove",touchepress\u00E9e:"keypress",d\u00E9charger:"unload",touchercommencer:"touchstart",toucherfin:"touchend",toucherbouger:"touchmove",toucherannuler:"touchcancel"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll","taste unten":"keydown","taste oben":"keyup","maus dr\xFCber":"mouseover","maus weg":"mouseout",doppelklick:"dblclick",mauseintreten:"mouseenter",mausverlassen:"mouseleave",mausbewegen:"mousemove",tastedr\u00FCcken:"keypress",entladen:"unload",ber\u00FChrungstart:"touchstart",ber\u00FChrungend:"touchend",ber\u00FChrungbewegen:"touchmove",ber\u00FChrungabbrechen:"touchcancel"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll",tekan_tombol:"keydown",keyup:"keyup",arahkan:"mouseover",tinggalkan:"mouseout",bongkar:"unload"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",kambiay:"change",apachiy:"submit",kachay:"submit",apaykachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll",bonyeza:"click",ingizo:"input",kitufe_shuka:"keydown",kitufe_juu:"keyup",panya_nje:"mouseout",wasilisha:"submit","sogeza juu":"mouseover",shuka:"unload"},vi:{"\u0111\u1ED5i k\xEDch th\u01B0\u1EDBc":"resize"}};function Rn(t,e){let r=Te[e];return r&&r[t]?r[t]:t.toLowerCase()}function pc(t,e){let r=Te[e];return r?Object.keys(r).filter(i=>r[i]===t):[]}var fc=Object.fromEntries(Object.entries(Te).map(([t,e])=>{let r={};for(let[i,n]of Object.entries(e))n in r||(r[n]=i);return [t,r]})),yc={ar:new Set(["mouseover"]),bn:new Set(["resize"]),de:new Set(["keydown","keyup","load","mouseout","mouseover"]),fr:new Set(["blur"]),id:new Set(["input","keyup","mouseout","mouseover"]),ja:new Set(["keypress","mousedown","mouseup","resize"]),qu:new Set(["change","focus","load","resize","submit"]),sw:new Set(["change","click","input","keydown","keyup","mouseout","mouseover","submit"]),tr:new Set(["keydown","keyup","load","mousedown","mouseout","mouseover","mouseup","resize","scroll"]),zh:new Set(["focus","keyup","mouseout","mouseover"])};function Pn(t,e){return yc[e]?.has(t)?t:fc[e]?.[t]??t}var hc=new Set(["the","to","on","with","into","from","at"]),zi=/^[A-Za-z_$][\w$]*$/,vc=64;function wi(t){let e="";for(let r=0;r<t.length;r++){let i=t[r],n=t[r-1];n&&i.position.start>n.position.end&&(e+=" "),e+=i.value;}return e}function Ec(t,e){let r=0;for(let i=e;i<t.length&&i-e<=vc;i++){let n=t[i].value;if(n==="(")r++;else if(n===")"&&(r--,r===0))return i+1}return -1}function ki(t,e){return e.position.start===t.position.end}function gc(t,e,r,i){let n=t[e];if(!n||n.kind!=="identifier"&&n.kind!=="keyword"||!zi.test(n.value)||i(n))return null;let a=e+1,o=n.value;for(;t[a]?.kind==="selector"&&/^\.[A-Za-z_$][\w$]*$/.test(t[a].value)&&ki(t[a-1],t[a]);)o+=t[a].value,a++;let s=a>e+1,u=t[a];if(!u||u.value!=="("||!ki(t[a-1],u))return null;let l=Ec(t,a);if(l<0)return null;let c=o+wi(t.slice(a,l));if(s)return {text:`call ${c}`,consumed:l-e};let d=l,p=t[d]?.value.toLowerCase(),f=null;if(p==="me")f="me",d++;else if(p!==void 0&&hc.has(p)){d++,t[d]?.value.toLowerCase()==="the"&&d++;let y=t[d];if(!y)return null;let v=br(t,d,r);if(v)f=`(${wi(t.slice(d,d+v.consumed))})`,d+=v.consumed;else if(y.kind==="selector"&&y.value.startsWith("#")&&!/[.[:\s]/.test(y.value.slice(1)))f=y.value,d++;else if(y.kind==="selector"&&/^[.<]/.test(y.value))f=`(${y.value})`,d++;else if((y.kind==="keyword"||y.kind==="identifier")&&zi.test(y.value)&&(Fe(y.value.toLowerCase())||y.kind==="identifier"))f=y.value,d++;else return null}return {text:f?`call ${f}.${c}`:`call ${c}`,consumed:d-e}}var zc={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},wc=[["\u043E\u0434\u0438\u043D","_","\u0440\u0430\u0437"],["\u043E\u0434\u0438\u043D_\u0440\u0430\u0437"],["\u043E\u0434\u043D\u0430\u0436\u0434\u044B"],["m\u1ED9t","l\u1EA7n"],["once"]],kc=/^(\d+)(ms|s|m)?$/,bc=new Set(["selector","literal","url","event-modifier"]);function Cc(t){let e=t.match(kc);if(!e)return null;let r=parseInt(e[1],10),i=e[2]||"ms";return i==="s"?r*=1e3:i==="m"&&(r*=6e4),r}function Ac(t){for(let e=1;e<t.length;e++){let r=t[e];if(bc.has(r.kind))continue;let i=r.value.toLowerCase(),n=zc[i];if(n){let a=0;for(let o=e+1;o<t.length;o++){let s=t[o],u=Cc(s.value);if(u!==null)return {modifiers:{[n]:u},start:r.position.start,end:s.position.end};if(s.kind==="selector"||s.kind==="literal"||s.kind==="url"||++a>2)break}continue}for(let a of wc){if(a[0]!==i||e+a.length>t.length)continue;let o=true;for(let s=1;s<a.length;s++)if(t[e+s].value.toLowerCase()!==a[s]){o=false;break}if(o)return {modifiers:{once:true},start:r.position.start,end:t[e+a.length-1].position.end}}}return null}function xc(t,e){try{let r=Z(t,e),i=pe(e);if(i.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let n=[...i].sort((l,c)=>c.priority-l.priority),a=n.filter(l=>l.command==="on"),o=Ce.matchBest(r,a);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let s=n.filter(l=>l.command!=="on"),u=Ce.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 Ln(t,e){try{let i=ad(t,e);if(i)return {node:i,confidence:i.metadata?.confidence??.8,error:void 0,tokensConsumed:Z(t,e).tokens.length}}catch{}let r=xc(t,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}new Set(Object.values(Bt).flatMap(t=>Object.values(t)));var Wc=new Set(["a","an","the"]),Ai=new Map;function qc(t){let e=Ai.get(t);return e||(e=new Set(Object.values(ue).flatMap(r=>r.roles.flatMap(i=>[i.markerOverride?.[t],...i.markerVariants?.[t]??[]].filter(n=>typeof n=="string"&&n.length>0)))),Ai.set(t,e)),e}function Kc(t,e){let r=Z(t,e).tokens,i=r[0];if(r.length!==1||!i)return {collision:"structure",word:"words"};let n=i.normalized!==t?i.normalized:void 0;if(i.kind==="keyword"&&qi.has(n??""))return {collision:"pronoun",word:"pronoun",sense:n};if(i.kind==="identifier"&&!n){if(qc(e).has(t))return {collision:"structure",word:"marker"};let a=Ze(e,t);return a!==t?{collision:"structure",word:"connective",sense:a}:Wc.has(t.toLowerCase())?{collision:"structure",word:"article"}:null}return i.kind==="particle"?{collision:"structure",word:"marker"}:{collision:"structure",word:"keyword",sense:n}}function Hc(t,e){let r=`${e}\0${t}`,i=xi.get(r);return i===void 0&&(i=Kc(t,e)?.collision??null,xi.set(r,i)),i}var xi=new Map;Ws((t,e)=>Hc(t,e)==="structure");var Ue=new Set(["if","unless","while","repeat","for"]),Nn=new Set(["repeat","for"]),nr={kind:"loop-close"};function Ot(t){return t===nr}function zt(t){if(Ot(t)||t.kind!=="command"||!Nn.has(t.action))return false;let e=t.body;return !(Array.isArray(e)&&e.length>0)}function Uc(t){switch(t.type){case "expression":return t.raw;case "literal":return String(t.value);case "reference":return t.value;default:return}}function Ir(t,e){for(let r=e-1;r>=0;r--)if(t[r].kind!=="particle")return t[r]}function ct(t){return t.kind!=="keyword"&&t.kind!=="identifier"?false:(t.normalized??t.value).toLowerCase()==="repeat"}function $r(t){let e=0;for(let r of t)zt(r)?e++:Ot(r)&&e>0&&e--;return e}var dt=new Set(["then","end","else","if","unless","while","for","repeat","and"]),Gc=new Set(["first","last","next","previous","random","closest"]),Zc=new Set(["me","my","i","it","its","you","your","result"]),Si=new Set(["top","middle","bottom","left","center","right","nearest"]),Yc=new Set(["smoothly","instantly"]);function Xc(t,e){if(!e)return false;let r=e.value.toLowerCase();switch(t.type){case "selector":return t.value.toLowerCase()===r;case "reference":return t.value===(e.normalized??e.value).toLowerCase()||t.value===r;case "expression":return t.raw.toLowerCase().split(/\s+/)[0]===r;default:return String("value"in t?t.value:"").toLowerCase()===r}}var Er=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function Jc(t){let e=(t.normalized??t.value).toLowerCase();return e==="document"||e==="window"||e==="me"||e==="body"?Ae(e):t.kind==="selector"?Oe(t.value):{type:"expression",raw:t.value}}var Di=new Map;function Bi(t){let e=Di.get(t);return e||(e=new Set(pe(t).map(r=>r.command).filter(r=>r!=="on")),Di.set(t,e)),e}var De=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"]),Ti=class extends Error{constructor(t,e,r,i){super(t),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=i;}};function G(t,e,r){return {message:t,severity:e,source:"semantic-parser",...r&&{code:r}}}function q(t,e){return e.length===0?t:{...t,diagnostics:e}}var Hr=120;function Qc(t,e,r){let i=e.tokens.length;if(t.consumedTokens>=i)return null;let n=e.tokens[t.consumedTokens],a=e.tokens[i-1];if(!n||!a)return null;let o=r.slice(n.position.start,a.position.end);if(!o.trim())return null;let s=o.length>Hr?`${o.slice(0,Hr)}\u2026`:o,u=i-t.consumedTokens;return `pattern ${t.pattern.id} left ${u} token(s) unconsumed: "${s}"`}var Fi=/^repeat-.*-(times|for-in|while-head|until-head|until-condition-head)$/,ed=new Set(["forever","times","for","while","until","until-event"]),rd=new Set(["to","from","into","onto","with","as","at","of","in","on","by","and","or","then","end","else","the","a","an","async"]);function jr(t){let e=[],r=new Set((t.diagnostics??[]).map(n=>`${n.code}|${n.message}`)),i=n=>{if(!n||typeof n!="object")return;if(n!==t)for(let o of n.diagnostics??[]){if(o.code!=="unconsumed-input")continue;let s=`${o.code}|${o.message}`;r.has(s)||(r.add(s),e.push(o));}let a=n;for(let o of Mn){let s=a[o];if(Array.isArray(s))for(let u of s)i(u);}};return i(t),e.length===0?t:q(t,[...t.diagnostics??[],...e])}function td(t){if(t.length>=2){let e=t[0];if((e==='"'||e==="'")&&t.endsWith(e))return t.slice(1,-1)}return t}var Mn=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function _n(t,e,r){if(!t||typeof t!="object")return t;if(t.action&&t.roles instanceof Map){let n=se(t.action),a=n?.primaryRole;if(n&&a&&a!=="patient"&&!n.roles.some(o=>o.role==="patient")&&t.roles.has("patient")&&!t.roles.has(a)){let o=t.roles,s=o.get("patient");s!==void 0&&(o.delete("patient"),o.set(a,s));}if(t.action==="tell"){let o=t.roles,s=o.get("patient"),u=o.get("destination");s&&(s.type==="selector"||s.type==="reference")&&(!u||u.type==="literal")&&(o.delete("patient"),o.set("destination",s));}if(t.action==="transition"){let o=t.roles,s=o.get("goal");s&&s.type==="literal"&&s.dataType==="duration"&&!o.has("duration")&&(o.delete("goal"),o.set("duration",s));}if(t.action==="fetch"){let o=t.roles,s=o.get("patient"),u=o.get("source");s&&u&&(s.type==="literal"||s.type==="expression")&&u.type==="expression"&&!o.has("style")&&(o.delete("patient"),o.set("style",u),o.set("source",s));}if(t.action==="transition"){let o=t.roles,s=o.get("destination");s&&s.type==="literal"&&!o.has("goal")&&(o.delete("destination"),o.set("goal",s));let u=o.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(u.value)&&o.set("patient",{type:"expression",raw:u.value});}if(t.action==="morph"){let o=t.roles,s=o.get("patient");s&&s.type==="literal"&&typeof s.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(s.value)&&o.set("patient",{type:"expression",raw:s.value});}if(t.action==="wait"){let o=t.roles;if(!o.has("event")){let s=o.get("duration"),u=s?.type==="expression"?s.raw:s?.type==="literal"?s.value:void 0,l=typeof u=="string"&&r?Rn(u,r):"";typeof u=="string"&&De.has(u.toLowerCase())?(o.delete("duration"),o.set("event",{type:"literal",value:u,dataType:"string"})):De.has(l)&&(o.delete("duration"),o.set("event",{type:"literal",value:l,dataType:"string"}));}}if(t.kind==="command"&&t.action!=="on"){let o=t.roles,s=o.get("event");if(s&&s.type==="expression"){let u=s.raw;typeof u=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(u)&&o.set("event",{type:"literal",value:u,dataType:"string"});}}if(e?.size){let o=t.roles;for(let s of ["destination","source"]){let u=o.get(s);u&&u.type==="literal"&&typeof u.value=="string"&&e.has(u.value)&&o.set(s,{type:"expression",raw:u.value});}}}let i=t;for(let n of Mn){let a=i[n];if(Array.isArray(a))for(let o of a)_n(o,e,r);}return t}var ge=class B{constructor(){this.parseDepth=0,this.coverageFrames=[],this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++,this.coverageFrames.push([]);try{let i=_n(this.parseInternal(e,r),this.boundIdentifiers,r),n=this.coverageFrames[this.coverageFrames.length-1];if(n.length>0&&(i=q(i,[...i.diagnostics??[],...n])),this.parseDepth===1&&(i=jr(i),i.kind==="event-handler")){let a={node:i,input:e},o=a.node.eventModifiers;if(o&&(o.once||o.debounce!==void 0||o.throttle!==void 0))for(let u=0;u<4;u++){let l=this.reclaimDanglingFromTail(a.node,a.input,r)??this.reclaimEventCompoundTail(a.node,a.input,r)??this.reclaimResponseTypeTail(a.node,a.input,r)??this.reclaimCapturedDestinationTail(a.node,a.input,r);if(!l)break;a=l;}let s=this.reclaimEventCompoundTail(a.node,a.input,r);s&&(a=s),i=a.node;}return i}finally{this.coverageFrames.pop(),this.parseDepth--;}}coverageMark(){let e=this.coverageFrames[this.coverageFrames.length-1];return e?e.length:0}coverageRollback(e){let r=this.coverageFrames[this.coverageFrames.length-1];r&&r.length>e&&(r.length=e);}static getCoverageMarkerSurfaces(e){let r=B.coverageMarkerSurfaces.get(e);if(!r){r=new Set;let i=O(e)?.roleMarkers;if(i){for(let n of Object.values(i))if(n){if(n.primary)for(let a of n.primary.toLowerCase().split(/\s+/))r.add(a);for(let a of n.alternatives??[])for(let o of a.toLowerCase().split(/\s+/))r.add(o);}}for(let n of B.LEAKED_RENDER_MARKERS[e]??[])r.add(n.toLowerCase());B.coverageMarkerSurfaces.set(e,r);}return r}isCoverageResidueToken(e,r){if(e.kind==="particle"||e.kind==="conjunction"||e.metadata?.closesTrackedBlock||this.isThenKeyword(e.value,r)||this.isEndKeyword(e.value,r)||this.isElseKeyword(e.value,r))return true;let i=(e.normalized??e.value).toLowerCase();return rd.has(i)?true:B.getCoverageMarkerSurfaces(r).has(e.value.toLowerCase())}recordDroppedTokens(e,r,i){if(e.length===0)return;let n=this.coverageFrames[this.coverageFrames.length-1];if(!n||!e.some(s=>!this.isCoverageResidueToken(s,r)))return;let a=e.map(s=>s.value).join(" ").trim();if(!a)return;let o=a.length>Hr?`${a.slice(0,Hr)}\u2026`:a;n.push(G(`${i} left ${e.length} token(s) unconsumed: "${o}"`,"warning","unconsumed-input"));}registerBoundIdentifiers(e){let r=e.action==="repeat"||e.action==="for"?"patient":e.action==="set"?"destination":null;if(!r)return;let i=e.roles.get(r);i?.type==="expression"&&typeof i.raw=="string"&&/^[A-Za-z_]\w*$/.test(i.raw)&&this.boundIdentifiers.add(i.raw);}parseInternal(e,r){let i=Hl(e,r,{statement:(w,C)=>this.parse(w,C),body:(w,C)=>this.parseStatements(w,C)});if(i)return i;let n=ac(e,r,{statement:(w,C)=>this.parse(w,C),body:(w,C)=>this.parseStatements(w,C)});if(n)return n;let a=Ul(e,r,{statement:(w,C)=>this.parse(w,C),body:(w,C)=>this.parseStatements(w,C)});if(a)return a;let{modifiers:o,remainingInput:s}=this.extractStandaloneModifiers(e,r),u=s||e,c=this.stripAsyncModifier(u,r).remainingInput??u,m=this.stripDoNotThrowModifier(c,r).remainingInput??c,p=[],f=Z(m,r);this.positionSource=m;{let w=f.mark(),C=this.consumeJsBlock(f,r);if(C&&f.isAtEnd())return q(C,p);f.reset(w);}let y=pe(r);if(y.length===0)throw new Ti(`No patterns available for language: ${r}`,r,m,[G(`No patterns registered for language '${r}'`,"error","no-patterns")]);let v=[...y].sort((w,C)=>C.priority-w.priority);{let w=f.tokens;if(O(r)?.wordOrder==="VSO"&&w.length>=4&&w[0]?.normalized==="source"){let C=w.findIndex(S=>S.normalized==="on");if(C>=2&&C+1<w.length){let S=m.slice(w[0].position.start,w[C].position.start).trim(),R=w[C+1].position.end,_=m.slice(w[C].position.start,R)+" "+S+m.slice(R);if(_!==m)try{let F=this.parse(_,r);if(F&&F.kind==="event-handler"){let T=o?this.applyModifiers(F,o):F;return q(T,p)}}catch{}}}}{let w=f.tokens,C=w[0]?.normalized==="if";for(let S=0;C&&S+3<w.length;S++){let R=(w[S+3]?.normalized??w[S+3]?.value??"").toLowerCase();if(w[S]?.normalized==="source"&&w[S+2]?.normalized==="on"&&B.KNOWN_EVENTS.has(R)){let _=(m.slice(0,w[S].position.start).trimEnd()+" "+m.slice(w[S+1].position.end).trimStart()).trim();if(_&&_!==m)try{let F=this.parse(_,r);if(F&&F.kind==="event-handler"){let T=o?this.applyModifiers(F,o):F;return q(T,p)}}catch{}break}}}{let w=this.tryDoNotThrow(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=this.tryTellTo(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=this.tryScrollModifiers(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=this.tryLoopIndex(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=this.tryWaitAlternatives(f.tokens,m,r);if(w){let C=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return q(C,p)}}{let w=f.tokens,C=Bi(r);for(let S=0;S+1<w.length;S++){let R=w[S];if(this.isBodyCommandWord(R,C))break;if(w[S+1].value!=="(")continue;let _=(R.normalized??R.value).toLowerCase();if(!(B.KNOWN_EVENTS.has(_)||De.has(_))&&R.kind!=="identifier")continue;let T=this.matchEventParamPhrase(w,S+1);if(T.len===0)continue;let N=w[S+T.len],K=(m.slice(0,w[S+1].position.start).trimEnd()+" "+m.slice(N.position.end).trimStart()).trim();try{let M=this.parse(K,r);if(M?.kind==="event-handler"){let I=this.reclaimEventCompoundTail(jr(M),K,r);I&&(M=I.node);}let j=M?.roles.get("event"),ye=(j?.type==="expression"?j.raw:j&&"value"in j?String(j.value):void 0)?.toLowerCase(),H=m.slice(0,w[S+1].position.start).trimEnd().toLowerCase(),L=ye===R.value.toLowerCase()||ye===_||ye!==void 0&&pc(ye,r).some(I=>H.endsWith(I.toLowerCase()));if(M?.kind==="event-handler"&&L){M.parameterNames=T.names;let I=o?this.applyModifiers(M,o):M;return q(I,p)}}catch{}}}{let w=f.tokens,C=Bi(r);for(let S=1;S<w.length-1;S++){let R=w[S];if(this.isBodyCommandWord(R,C))break;if(!Wr(R,r))continue;let _=w[S+1],F=(_.normalized??_.value).toLowerCase();if(!B.KNOWN_EVENTS.has(F))break;let T=S+1,N=w[S+2];N&&N.kind==="selector"&&N.value.startsWith("[")&&(T=S+2);let K=w[S].position.start,M=w[T].position.end,j=(m.slice(0,K).trimEnd()+" "+m.slice(M).trimStart()).trim();if(j&&j!==m)try{let ne=this.parse(j,r);if(ne&&ne.kind==="event-handler"){ne.additionalEvents=[{type:"literal",value:T>S+1?F+N.value:F}];let ye=o?this.applyModifiers(ne,o):ne;return q(ye,p)}}catch{}break}}{let w=Ac(f.tokens);if(w){let C=(m.slice(0,w.start).trimEnd()+" "+m.slice(w.end).trimStart()).trim();if(C&&C!==m)try{let S=this.parse(C,r);if(S&&S.kind==="event-handler"){let R=this.applyModifiers(S,{...o??{},...w.modifiers});return q(R,p)}}catch{}}}let h=v.filter(w=>w.command==="on"),E=f.mark(),z=Ce.matchBest(f,h);if(z){p.push(G(`event pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match"));let w=false;if(/^event-[a-z]+-bare$/.test(z.pattern.id)){let C=z.captured.get("event"),S=(C?.raw??C?.value??"").toString().toLowerCase(),R=Te[r],_=B.KNOWN_EVENTS.has(S)||!!R&&Object.keys(R).some(F=>F.toLowerCase()===S);if(S&&!_){let F=this.trySOVEventExtraction(m,r,v);if(F){p.push(G(`bare-event mis-anchor on "${S}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let T=o?this.applyModifiers(F,o):F;return q(T,p)}if(C?.type==="reference"||C?.type==="expression"){f.reset(E);let T=v.filter(K=>K.command!=="on"),N=Ce.matchBest(f,T);f.reset(E),N&&N.pattern.command!=="on"?(w=true,p.push(G(`bare-event mis-anchor on reference "${S}" rejected; command ${N.pattern.command} preferred`,"info","stage-bare-event-guard"))):Ce.matchBest(f,h);}}}if(!w){let C=this.buildEventHandler(z,f,r),S=o?this.applyModifiers(C,o):C;return q(S,p)}}p.push(G(`event patterns: ${h.length} tried, no match`,"info","stage-event"));let k=this.tryTrailingEventExtraction(m,r,v);if(k){p.push(G("trailing event extraction succeeded","info","stage-trailing-event"));let w=o?this.applyModifiers(k,o):k;return q(w,p)}let g=v.filter(w=>w.command!=="on"),A=this.tryParseUnlessGuard(f,g,r);if(A&&A.length>0){let w=A.length===1?A[0]:ir(A,"then",{sourceLanguage:r,confidence:1});return q(w,p)}let b=Ce.matchBest(f,g);if(b){if(Ue.has(b.pattern.command)){let C=this.trySOVEventExtraction(m,r,v);if(C){p.push(G(`SOV event extraction preferred over bare ${b.pattern.command} command`,"info","stage-sov-loop"));let R=o?this.applyModifiers(C,o):C;return q(R,p)}let S=this.tryMidStreamEventExtraction(m,r,v);if(S){p.push(G(`mid-stream event extraction preferred over bare ${b.pattern.command} command`,"info","stage-midstream-loop"));let R=o?this.applyModifiers(S,o):S;return q(R,p)}}else if(B.KNOWN_EVENTS.has(b.pattern.command)&&this.hasSOVEventMarkerHead(m,r)){let C=this.trySOVEventExtraction(m,r,v);if(C){p.push(G(`SOV event extraction preferred over command-homonym event ${b.pattern.command}`,"info","stage-sov-homonym"));let S=o?this.applyModifiers(C,o):C;return q(S,p)}}else if(O(r)?.wordOrder==="VSO"){let C=this.tryMidStreamEventExtraction(m,r,v);if(C){p.push(G(`mid-stream event extraction preferred over bare ${b.pattern.command} command`,"info","stage-midstream-cmd"));let S=o?this.applyModifiers(C,o):C;return q(S,p)}}if(b.consumedTokens<f.tokens.length&&O(r)?.wordOrder==="SOV"){let C=this.trySOVEventExtraction(m,r,v);if(C){p.push(G(`SOV event extraction preferred over partial ${b.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let S=o?this.applyModifiers(C,o):C;return q(S,p)}}if(b.consumedTokens<f.tokens.length&&Nn.has(b.pattern.command)){let C=this.tryTopLevelLoop(f,g,r);if(C)return p.push(G(`top-level loop: ${C.kind}`,"info","stage-top-level-loop")),q(C,p)}if(b.consumedTokens<f.tokens.length&&!Ue.has(b.pattern.command)){let C=this.tryTopLevelCommandSequence(f,g,r);if(C)return p.push(G(`top-level command sequence: ${C.statements.length} commands`,"info","stage-top-level-sequence")),q(C,p)}if(b.consumedTokens<f.tokens.length&&(b.pattern.command==="if"||b.pattern.command==="unless")){let C=this.tryCompoundCommandParsing(f,g,r);if(C)return p.push(G("conditional with a trailing body","info","stage-compound")),q(C,p)}p.push(G(`command pattern matched: ${b.pattern.id} (confidence: ${b.confidence.toFixed(2)})`,"info","pattern-match"));let w=Qc(b,f,m);return w&&p.push(G(w,"warning","unconsumed-input")),q(this.buildCommand(b,r),p)}if(p.push(G(`command patterns: ${g.length} tried, no match`,"info","stage-command")),!m.includes(`
5
+ `)&&O(r)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(m,r,v);if(w){p.push(G("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let C=o?this.applyModifiers(w,o):w;return q(C,p)}}let x=this.trySOVEventExtraction(m,r,v);if(x){p.push(G("SOV event extraction succeeded","info","stage-sov"));let w=o?this.applyModifiers(x,o):x;return q(w,p)}p.push(G("SOV event extraction: no event keyword found","info","stage-sov"));let D=this.tryCompoundCommandParsing(f,g,r);if(D)return p.push(G("compound command parsing succeeded","info","stage-compound")),q(D,p);if(p.push(G("compound parsing: no then-keywords or no command matches","info","stage-compound")),r==="en"){let w=Z(m,r),C=this.tryParsePseudoCommand(w,g,r);if(C&&w.isAtEnd())return p.push(G("pseudo-command parsed as call","info","stage-pseudo")),q(C,p)}throw p.push(G(`all parse stages exhausted for "${m}"`,"error","parse-failed")),new Ti(`Could not parse input in ${r}: ${m}`,r,m,p)}tryParsePseudoCommand(e,r,i){if(i!=="en")return null;let n=gc(e.tokens,e.position(),O(i),s=>!!se((s.normalized??s.value).toLowerCase()));if(!n)return null;let a=Z(n.text,i),o=Ce.matchBest(a,r.filter(s=>s.command==="call"));if(!o||!a.isAtEnd())return null;for(let s=0;s<n.consumed;s++)e.advance();return this.buildCommand(o,i)}parseStatements(e,r){let i=Z(e,r),n=pe(r).filter(a=>a.command!=="on").sort((a,o)=>o.priority-a.priority);this.coverageFrames.push([]);try{let a=this.parseBodyWithClauses(i,n,r),o=this.coverageFrames[this.coverageFrames.length-1];if(o.length>0&&a.length>0){let s=a[a.length-1];a[a.length-1]=q(s,[...s.diagnostics??[],...o]);}return a}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return xn()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let i={};for(let[a,o]of e.captured)i[a]=o;let n=me(e.pattern.command,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(n),n}buildEventHandler(e,r,i){if(!e)throw new Error("No match to build event handler from");let n=e.captured.get("event");if(!n)throw new Error("Event handler pattern matched but no event captured");{let z=n.type==="expression"?n.raw:n.type==="literal"?n.value:void 0;if(typeof z=="string"&&/^[^\s()[\]{}:]+$/.test(z)){let k=Te[i]?.[z];k?n={type:"literal",value:k,dataType:"string"}:n.type==="expression"&&B.KNOWN_EVENTS.has(z.toLowerCase())&&(n={type:"literal",value:z.toLowerCase(),dataType:"string"});}}let a=Ce.extractEventModifiers(r),o=z=>!(z.type==="reference"&&z.value==="me")&&z.implicit!==true,s=e.captured.get("source"),u=e.pattern.command==="on"&&/^(on|event)-/.test(e.pattern.id),l=false;s&&(e.pattern.id.endsWith("source")||u)&&o(s)&&(a={...a??{},from:s},l=true);let c;if(e.eventSource&&!l){let z=e.captured.get("action"),k=z?.type==="literal"?se(String(z.value)):void 0;O(i)?.roleMarkers?.source?.position==="after"&&k?.roles.some(A=>A.role==="source")&&!e.captured.has("source")?c=e.eventSource:o(e.eventSource)&&(a={...a??{},from:e.eventSource});}let d=e.captured.get("event")?.position,m=r.tokens[r.position()-1],f=d!==void 0&&m!==void 0&&m.position.end>d.end?[]:this.extractOrConjunctionEvents(r,i),y=n;f.length>0&&n.type==="literal"&&(y={type:"literal",value:[String(n.value),...f.map(k=>String("value"in k?k.value:""))].join(" or ")});let v,h=e.captured.get("action");if(h&&h.type==="literal"&&h.value==="if"){let z=r.tokens,k=-1;for(let g=r.position()-1;g>=0;g--){let A=z[g],b=(A.normalized??A.value).toLowerCase();if(this.isIfKeyword(b,i)){k=g;break}}for(;k>0;){let g=z[k-1];if(!this.isIfKeyword((g.normalized??g.value).toLowerCase(),i))break;k--;}if(k>=0){let g=pe(i).filter(C=>C.command!=="on").sort((C,S)=>S.priority-C.priority),A=z.slice(k);if(e.pattern.id.endsWith("vso-verb-first")&&y.type==="literal"){let C=String(y.value??"").split("[")[0].trim().toLowerCase(),S=A.findIndex((R,_)=>{if(_===0||C==="")return false;let F=(R.normalized??R.value).toLowerCase(),T=A[_-1];return F===C&&T.kind==="keyword"&&(T.normalized??"").toLowerCase()==="on"});if(S>0){let R=A[S+1],_=R&&R.kind==="selector"&&R.value.startsWith("[")?1:0;A=[...A.slice(0,S-1),...A.slice(S+1+_)];}}let b=new de(A,i),x=this.coverageMark(),D=this.parseBodyWithClauses(b,g,i);if(D.some(C=>C.kind==="conditional")||D.length===1&&D[0]?.kind==="compound"&&D[0].statements.some(C=>C.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return vr(y,D,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(x);}}if(h&&h.type==="literal"&&String(h.value)!=="js"&&se(String(h.value))!==void 0){let z=h.value,k={};for(let[T,N]of e.captured)if(T!=="event"&&T!=="action"&&T!=="continues"){if(T==="source"&&l)continue;k[T]=N;}if(c&&(k.source=c),z==="repeat"){let T=r.peek(),N=M=>(M.normalized??M.value).toLowerCase();if(T&&T.kind==="keyword"&&N(T)==="forever")k.loopType={type:"literal",value:"forever"},delete k.patient,r.advance();else if(T&&T.kind==="keyword"&&N(T)==="event"){r.advance();let M=r.peek();if(M)for(k.event={type:"literal",value:N(M)},k.loopType={type:"literal",value:"until-event"},delete k.patient;!r.isAtEnd();){let j=r.peek();if(!j||j.kind==="conjunction"||j.kind==="keyword"&&(this.isThenKeyword(j.value,i)||this.isEndKeyword(j.value,i)))break;r.advance();}}let K=k.patient;K&&K.type==="reference"&&K.value==="me"&&delete k.patient;}let g=me(z,k,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence});this.registerBoundIdentifiers(g);let A=[];if(!Ue.has(z)||z==="repeat"||z==="while"){let T=e.pattern.id.includes("verb-first"),N=r.tokens,K=r.position(),M=L=>{let I=N[L];if(I.kind==="conjunction")return true;if(I.kind!=="keyword")return false;let X=ve(N,L);return this.isThenAt(I,X,i)||this.isEndKeyword(I.value,i)&&!Pe(X,i)},j=z==="repeat"||z==="while",ne=L=>M(L)||j&&this.isBlockEndToken(N[L],ve(N,L),i),ye=new Set;{let L=O(i)?.keywords?.[z];L?.primary&&ye.add(L.primary.toLowerCase());for(let I of L?.alternatives??[])ye.add(I.toLowerCase());}let H=-1;for(let L=K-1;L>=0;L--){let I=N[L];if(M(L))break;if((I.normalized??I.value).toLowerCase()===z||ye.has(I.value.toLowerCase())){H=L;break}}if(H>=0){let L=K,I=0;for(;L<N.length;){let ae=N[L],we=Ir(N,L);if(j&&this.isIfKeyword((ae.normalized??ae.value).toLowerCase(),i)&&!(we&&this.isElseKeyword(we.value,i)))I++;else if(I>0)this.isBlockEndToken(ae,ve(N,L),i)&&I--;else if(ne(L))break;L++;}let X=N.slice(H,L),ze=X;if(T){let ae=String(n.value??"").toLowerCase(),we=X.findIndex(le=>(le.normalized??le.value).toLowerCase()===ae);if(we<0)ze=null;else {let le=X[we-1],ce=le&&le.kind==="keyword"&&le.normalized?.toLowerCase()==="on"?we-1:we;ze=[...X.slice(0,ce),...X.slice(we+1)];}}if(ze&&ze.length>1){let ae=pe(i).filter(W=>W.command!=="on").sort((W,J)=>J.priority-W.priority),we=this.coverageMark(),le=this.parseClause(ze,ae,i),ce=le[0],Qe=W=>W!==null&&typeof W=="object"&&typeof W.type=="string"?W.type:typeof W,er=se(z),rt=er?.primaryRole,Vt=W=>W==="patient"&&rt&&rt!=="patient"&&!er?.roles.some(J=>J.role==="patient")?rt:W,va=(W,J)=>{if(!Ue.has(z)||!er)return false;let Me=er.roles.find(fr=>fr.role===Vt(W));return Me?Me.expectedTypes.length>0&&!Me.expectedTypes.includes(Qe(J)):true},tt=(W,J)=>W==="patient"&&!!er&&!er.roles.some(Me=>Me.role==="patient")&&Qe(J)==="literal"&&xr.has(String(J.value??"").toLowerCase()),it=W=>W!==null&&typeof W=="object"&&W.implicit===true,Ea=!!ce&&ce.kind==="command"&&Object.entries(k).every(([W,J])=>{if(it(J)||va(W,J)||tt(W,J))return true;let Me=ce.roles.get(Vt(W));if(Me!==void 0&&Qe(Me)===Qe(J))return true;if(W==="patient"&&z==="pick"&&Qe(J)==="literal"){let fr=ce.roles.get("method"),qt=Qe(fr),Kt=qt==="literal"?String(fr.value):qt==="expression"?String(fr.raw):void 0;return Kt!==void 0&&Kt===String(J.value)}return false}),Wt=ce?.metadata?.patternId??"",ga=!Ue.has(z)||Fi.test(Wt),za=Fi.test(Wt);if((le.length===1||za&&le.length>1)&&ce&&ce.kind==="command"&&(ce.action===z||z==="while"&&ce.action==="repeat"&&/-while-head$/.test(ce.metadata?.patternId??""))&&Ea&&ga&&(ce.roles.size>Object.entries(k).filter(([W,J])=>!tt(W,J)).length||[...ce.roles.values()].filter(W=>!it(W)).length>Object.entries(k).filter(([W,J])=>!tt(W,J)&&!it(J)).length))for(g=ce,A=le.slice(1);r.position()<L;)r.advance();else this.coverageRollback(we);}}}if(!Ue.has(z)){let T=g;if(se(z)?.roles.some(H=>H.role==="quantity"&&!H.required)&&!T.roles.has("quantity")){let H=r.peek();H&&/^-?\d+(\.\d+)?$/.test(H.value)&&(g=me(z,{...Object.fromEntries(T.roles),quantity:{type:"literal",value:parseFloat(H.value),dataType:"number"}},T.metadata),r.advance());}let K=g;if(se(z)?.roles.some(H=>H.role==="duration"&&!H.required)&&!K.roles.has("duration")){let H=/^\d+(\.\d+)?(ms|s)$/i,L=r.peek(),I=false;if(L&&L.kind==="particle"){let X=r.peek(1);X&&H.test(X.value)&&(I=true,L=X);}L&&H.test(L.value)&&(g=me(z,{...Object.fromEntries(K.roles),duration:{type:"literal",value:L.value,dataType:"string"}},K.metadata),I&&r.advance(),r.advance(),this.consumeForPostposition(r,i));}let j=g,ne=se(z);if(ne?.roles.find(H=>H.role==="responseType"&&!H.required)&&!j.roles.has("responseType")){let H=ae=>typeof ae=="string"&&B.RESPONSE_TYPE_WORDS.has(ae.toLowerCase()),L=(ae,we)=>{let le=Object.fromEntries(j.roles);we&&delete le.destination,le.responseType={type:"expression",raw:ae},g=me(z,le,j.metadata);},I=j.roles.get("destination"),X=ne?.roles.find(ae=>ae.role==="destination"),ze=I?.raw??I?.value;if(I&&X&&!X.expectedTypes.includes(I.type)&&H(ze))L(ze,true);else {let ae=r.peek();ae&&H(ae.value)&&(L(ae.value,false),r.advance());}}if(z==="wait"){let H=g;if(!H.roles.has("event")){let L=r.peek();if(L&&De.has(L.value.toLowerCase())){let I=Object.fromEntries(H.roles),X=I.duration;X&&X.type!=="literal"&&X.type!=="expression"&&delete I.duration;let ze=I.patient;ze&&ze.type==="reference"&&ze.value==="me"&&delete I.patient,I.event={type:"literal",value:L.value,dataType:"string"},g=me(z,I,H.metadata),r.advance(),this.consumeForPostposition(r,i);}}}this.tryAttachTrailingRole(r,g,i),this.tryAttachTrailingStyle(r,g,i),this.tryAttachTrailingExpressionRole(r,g,i),this.tryAttachNewWindow(r,g);}let b=e.captured.get("continues"),x=b?.type==="literal"&&b.value==="then",D=r.peek(),w=!!D&&this.isThenKeyword(D.value,i),S=Ue.has(z)&&!!D&&!this.isEndKeyword(D.value,i),R=!!D&&!this.isEndKeyword(D.value,i),_=[g,...A],F=!!D&&this.isEndKeyword(D.value,i)&&$r(_)>0&&r.peek(1)!==null;if(F&&(r.advance(),_.push(nr)),x||w||S||R||F){let T=pe(i).filter(M=>M.command!=="on").sort((M,j)=>j.priority-M.priority),N=pe(i).filter(M=>M.id.startsWith("grammar-")&&M.id.includes("-continuation")).sort((M,j)=>j.priority-M.priority),K=this.parseBodyWithGrammarPatterns(r,T,N,i,_);v=this.foldLoopBlocks([..._,...K]);}else v=this.foldLoopBlocks(_),r.isAtEnd()||this.recordDroppedTokens(r.tokens.slice(r.position()),i,"handler body tail");}else {let z=pe(i).filter(g=>g.command!=="on").sort((g,A)=>A.priority-g.priority),k=h?e.roleStarts?.get("action"):void 0;if(k!==void 0&&k<r.position()){let g=new de(r.tokens.slice(k),i);for(v=this.parseBodyWithClauses(g,z,i);!r.isAtEnd();)r.advance();}else v=this.parseBodyWithClauses(r,z,i);}let E=v.length>1?[ir(v,"then",{sourceLanguage:i})]:v;return vr(y,E,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,i){let n=[],a=[],o=0,s=[],u=(c=0)=>{let d=$r(n);o=d+c,s.length=0;for(let m=0;m<d;m++)s.push("loop");for(let m=0;m<c;m++)s.push("while");};for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(a.length===0){let z=this.consumeJsBlock(e,i)??this.consumeVerbFinalJsBlock(e,i);if(z){n.push(z);continue}let k=this.tryParseConditionalBlock(e,r,i);if(k){n.push(k);continue}let g=this.tryParseUnlessGuard(e,r,i);if(g){n.push(...g);continue}}let d=c.kind==="conjunction"||c.kind==="keyword"&&this.isThenAt(c,ve(e.tokens,e.position()),i),m=a[a.length-1],p=e.peek(1),f=m?.value.toLowerCase()==="at"&&p?.value.toLowerCase()==="of"||ut(i,c.value,m?.value,p?.value),y=c.kind==="keyword"&&this.isEndKeyword(c.value,i)&&!f&&!Pe(ve(e.tokens,e.position()),i);if((y||!f&&this.isBlockEndToken(c,ve(e.tokens,e.position()),i))&&s.every(z=>z==="loop")&&this.closeLoopAtEnd(e,a,n,r,i)){a.length=0,u();continue}if(y&&o>0){o--,s.pop(),a.push({...c,metadata:{...c.metadata,closesTrackedBlock:true}}),e.advance();continue}if(d&&s.includes("if")){a.push(c),e.advance();continue}if(d){if(a.length>0){let z=this.parseClause(a,r,i);n.push(...z),a.length=0,u(z.filter(k=>{let g=k;return g.action==="while"&&(!Array.isArray(g.body)||g.body.length===0)}).length);}e.advance();continue}if(y){e.advance();let z=[];for(;!e.isAtEnd();){let k=e.peek();if(!k||k.kind==="conjunction"||k.kind==="keyword"&&(this.isThenKeyword(k.value,i)||this.isEndKeyword(k.value,i)))break;z.push(k),e.advance();}if(z.length>0){let k=this.coverageMark(),g=a.length>0?this.parseClause(a,r,i):[];g.length===0&&a.length>0?(this.coverageRollback(k),n.push(...this.parseClause([...a,...z],r,i))):(n.push(...g),n.push(...this.parseClause(z,r,i)));}else if(a.length>0){let k=this.parseClause(a,r,i);n.push(...k);}a.length=0;break}let h=(c.normalized??c.value).toLowerCase(),E=ct(c);if(c.kind==="keyword"||E){let z=this.isIfKeyword(h,i),k=Ir(a,a.length);(h==="for"||h==="while")&&k&&ct(k)||z&&k&&this.isElseKeyword(k.value,i)||(E&&s[s.length-1]==="while"?s[s.length-1]="loop":(z||this.isUnlessKeyword(h,i)||h==="while"||h==="for"||E)&&(o++,s.push(z?"if":E||h==="for"?"loop":h==="while"?"while":"other")));}a.push(c),e.advance();}if(a.length>0){let c=this.parseClause(a,r,i);n.push(...c);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),i,"body stream tail"),this.foldFrontedWhileIntoRepeat(n,i);for(let c=n.length-1;c>=0;c--){let d=n[c];d.kind==="command"&&d.action==="for"&&(!(d.roles instanceof Map)||d.roles.size===0)&&(!Array.isArray(d.body)||d.body.length===0)&&n.splice(c,1);}let l=this.foldLoopBlocks(n);return l.length>1?[ir(l,"then",{sourceLanguage:i})]:l}closeLoopAtEnd(e,r,i,n,a){let o=$r(i);if(r.length===0)return o===0?false:(i.push(nr),e.advance(),true);let s=this.coverageMark(),u=this.parseClause([...r],n,a);return u.length===0||o+u.filter(zt).length===0?(this.coverageRollback(s),false):(i.push(...u,nr),e.advance(),true)}foldLoopBlocks(e){let r=[],i=[],n=o=>{(i.length>0?i[i.length-1].body:r).push(o);},a=o=>{let s=i.pop();s&&n(this.buildLoopNode(s.head,s.body,o));};for(let o of e)Ot(o)?a(true):zt(o)?i.push({head:o,body:[]}):n(o);for(;i.length>0;)a(false);return r}buildLoopNode(e,r,i=false){if(r.length===0&&!i)return e;let n=e.roles.get("loopType");if(n?.type==="literal"&&typeof n.value=="number"){let d=new Map(e.roles);return d.set("quantity",n),d.set("loopType",{type:"literal",value:"times"}),this.buildLoopNode({...e,roles:d},r,i)}let a=n?.type==="literal"?String(n.value):void 0,o=e.action==="for"||a==="for"?"for":a==="times"||a==="while"||a==="forever"?a:a==="until"||a==="until-event"?"until":e.roles.has("quantity")?"times":"forever",s=o==="for"?e.roles.get("patient"):void 0,u=s?Uc(s):void 0,l=new Map(e.roles),c=l.get("quantity");return (o==="while"||o==="until")&&c&&!l.has("condition")&&(l.set("condition",c),l.delete("quantity")),gu(e.action==="for"?"for":"repeat",o,Object.fromEntries(l),r,{...u?{loopVariable:u}:{},...e.metadata?{metadata:e.metadata}:{}})}tryTopLevelLoop(e,r,i){let n=this.coverageMark(),a;try{let s=new de(e.tokens,i);a=this.parseBodyWithClauses(s,r,i);}catch{return this.coverageRollback(n),null}let[o]=a;if(a.length===1&&o.kind==="loop")return o;if(a.length===1&&o.kind==="compound"){let s=o;if(s.statements[0]?.kind==="loop"){let u=s.statements.map(l=>l.metadata?.confidence??.75);return ir(s.statements,s.chainType,{sourceLanguage:i,confidence:u.reduce((l,c)=>l+c,0)/u.length})}}return this.coverageRollback(n),null}tryTopLevelCommandSequence(e,r,i){let n=this.coverageMark(),a;try{let l=new de(e.tokens,i);a=this.parseBodyWithClauses(l,r,i);}catch{return this.coverageRollback(n),null}if(a.length!==1||a[0].kind!=="compound")return this.coverageRollback(n),null;let o=a[0];if(o.statements.length<2)return this.coverageRollback(n),null;let s=o.statements.map(l=>l.metadata?.confidence??.75),u=s.reduce((l,c)=>l+c,0)/s.length;return ir(o.statements,o.chainType,{sourceLanguage:i,confidence:u})}foldFrontedWhileIntoRepeat(e,r){for(let i=0;i+1<e.length;i++){let n=e[i],a=e[i+1];if(n.kind!=="command"||n.action!=="while"||a.kind!=="command"||a.action!=="repeat")continue;let o=n.roles.get("condition");if(!o||a.roles.has("condition")||Array.isArray(n.body)||Array.isArray(a.body))continue;let s=new Map(a.roles);s.set("condition",o),s.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(i,2,{...a,roles:s,metadata:{...a.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(a.metadata?.confidence??0,n.metadata?.confidence??0)}});}}takeRepeatCount(e,r,i){if(O(i)?.wordOrder==="SOV"){let o=B.countBeforeVerb(r,i);if(o<0)return;let s=r[o];return r.length=o,s}let n=e.mark();e.peek()?.kind==="particle"&&e.advance();let a=e.peek();if(a&&B.countsBefore(a,e.peek(1),i))return e.advance(),e.advance(),a;if(!B.isCountToken(a)){e.reset(n);return}return e.advance(),e.peek()?.kind==="identifier"&&e.advance(),a}static isCountToken(e){let r=e?.kind==="literal"?Vr(e):null;return r?.type==="literal"&&typeof r.value=="number"}static countsBefore(e,r,i){return !e||!r||!en[i]?.includes(r.value)?false:e.kind==="identifier"||B.isCountToken(e)}static countBeforeVerb(e,r){let i=B.isCountToken,n=e.length;return e[n-1]?.kind==="particle"&&n--,B.countsBefore(e[n-2],e[n-1],r)?n-2:(e[n-1]?.kind==="identifier"&&i(e[n-2])&&n--,i(e[n-1])?n-1:-1)}loopHeadReadsBody(e,r,i){if(O(i)?.wordOrder!=="SOV")return false;if(B.countBeforeVerb(r,i)>=0)return true;let n=e.captured.get("loopType");return n?.type==="literal"&&typeof n.value!="number"&&!ed.has(String(n.value))}bareRepeatHead(e,r){let i=e?Vr(e):null;return me("repeat",e&&i?{loopType:Y("times"),quantity:Xi(i,{start:e.position.start,end:e.position.end})}:{},{sourceLanguage:r,confidence:.6})}parseClause(e,r,i){if(e.length===0)return [];let n=null,a=e,o=e[e.length-1];if(o&&e.length>=2){let h=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(h,i)&&(n="unless",a=e.slice(0,-1));}let s=null;if(n&&a.length>=3){let h=O(i),E=h?B.buildVerbLookup(h):null;if(E)for(let z=1;z<a.length-1;z++){let k=a[z],g=E.get(k.value.toLowerCase())??(k.normalized?E.get(k.normalized.toLowerCase()):void 0);if(g&&!B.CONDITION_OPERATORS.has(g)){s=a.slice(0,z),a=a.slice(z);break}}}let u=new de(a,i),l=[],c=this.coverageMark(),d=0,m=[],p=s,f=()=>{if(m.length===0)return;let h=m.slice();if(m.length=0,n&&l.length===0&&p===null){p=h;return}let E=h[0];if(!(E&&(E.kind==="identifier"||E.kind==="selector"||E.kind==="literal"||E.kind==="reference"))){this.recordDroppedTokens(h,i,"body clause");return}let k=false;for(let g of this.parseSOVClauseByVerbAnchoring(h,i)){let A=g.action,b=g.roles;A&&se(A)&&b instanceof Map&&b.size>0&&(l.push(g),k=true);}k||this.recordDroppedTokens(h,i,"body clause");};for(;!u.isAtEnd();){let h=u.peek(),E=!!h&&h.normalized?.toLowerCase()==="repeat",z=u.mark(),k=Ce.matchBest(u,r);if(E&&k&&(k.pattern.command!=="repeat"||this.loopHeadReadsBody(k,m,i))){u.reset(z),u.advance();let g=this.takeRepeatCount(u,m,i);f(),l.push(this.bareRepeatHead(g,i)),d++;continue}if(!k&&h&&this.isIfKeyword((h.normalized??h.value).toLowerCase(),i)){let g=this.tryParseConditionalBlock(u,r,i);if(g){f(),l.push(g),d++;continue}}if(k&&k.pattern.command==="if"){let g=u.mark(),A=m.length;for(u.reset(z);!u.isAtEnd();){let x=u.peek();if(!x||this.isIfKeyword((x.normalized??x.value).toLowerCase(),i))break;m.push(x),u.advance();}let b=this.tryParseConditionalBlock(u,r,i);if(b){f(),l.push(b),d++;continue}m.length=A,u.reset(g);}if(k){f();let g=this.buildCommand(k,i);l.push(g),d++,this.tryAttachTrailingRole(u,g,i),this.tryAttachTrailingStyle(u,g,i),this.tryAttachTrailingExpressionRole(u,g,i),this.tryAttachTrailingDuration(u,g);}else {let g=m.length===0?this.tryParsePseudoCommand(u,r,i):null;if(g){f(),l.push(g),d++;continue}let A=u.peek(),b=A?.kind==="identifier"&&A.value.toLowerCase()==="repeat";if(A&&(A.normalized?.toLowerCase()==="repeat"||b)){let x=u.mark();u.advance();let D=this.takeRepeatCount(u,m,i);if(D||!b){f(),l.push(this.bareRepeatHead(D,i)),d++;continue}u.reset(x);}A&&m.push(A),u.advance();}}f();let y=l;if(d===0){let h=this.parseSOVClauseByVerbAnchoring(a,i);h.length>0&&(this.coverageRollback(c),y=h);}let v=p;return n&&y.length>0&&v&&v.length>0?[me(n,{condition:{type:"expression",raw:this.joinTokenText(v,i)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85}),...y]:n&&v&&v.length>0&&y.length===0?[me(n,{condition:{type:"expression",raw:this.joinTokenText(v,i)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85})]:y}tryAttachTrailingDuration(e,r){let i=r.roles;if(i.has("duration")||!se(r.action)?.roles.some(o=>o.role==="duration"&&!o.required))return;let a=e.peek();!a||!/^\d+(?:\.\d+)?(?:ms|s|m|h)$/.test(a.value)||(i.set("duration",Y(a.value,"duration")),e.advance());}tryAttachNewWindow(e,r){let i=r.roles;if(r.action!=="go"||i.has("manner"))return;let[n,a,o]=[e.peek(),e.peek(1),e.peek(2)];if(!(n?.value.toLowerCase()!=="in"||a?.value.toLowerCase()!=="new")&&!(!o||(o.normalized??o.value).toLowerCase()!=="window")){i.set("manner",Ae("window"));for(let s=0;s<3;s++)e.advance();}}tryAttachTrailingRole(e,r,i){let n=se(r.action);if(!n)return;let a=O(i);if(!a)return;let o=r.roles,s=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let d=(l.normalized??l.value).toLowerCase();return dt.has(d)?false:d==="body"||d==="it"||d==="you"||d==="result"||d==="document"||d==="window"||this.boundIdentifiers.has(l.value)?true:c?false:l.kind==="identifier"||l.kind==="reference"},u=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:c}of u){if(!n.roles.some(v=>v.role===l))continue;let d=a.roleMarkers?.[l];if(!d)continue;let m=o.get(l);if(m&&!(m.type==="reference"&&m.value==="me"))continue;let p=v=>{if(!v||v.kind!=="particle"&&v.kind!=="keyword")return false;let h=v.value.toLowerCase();return d.primary?.toLowerCase()===h?true:c?false:(v.normalized??"").toLowerCase()===l?true:!!d.alternatives?.some(E=>E.toLowerCase()===h)},f=e.peek(),y=e.peek(1);if(!f||!y)return;if(c&&d.position==="after"){let v=e.peek(2),h=(f.normalized??f.value).toLowerCase();if(Gc.has(h)&&y.kind==="selector"&&p(v)){o.set(l,{type:"expression",raw:`${h} ${y.value}`}),e.advance(),e.advance(),e.advance();return}}if(d.position==="after"){if(s(f,c)&&p(y)){let v=this.tokenToSemanticValue(f);e.advance(),e.advance(),v&&o.set(l,v);return}if(c&&s(f,c)){let v=e.peek(2),h=e.peek(3);if((y.normalized??y.value).toLowerCase()==="in"&&v&&!p(v)&&p(h)){let E=this.tokenToSemanticValue(f);e.advance(),e.advance(),e.advance(),e.advance(),E&&o.set(l,E);return}}}else if(p(f)&&s(y,c)){e.advance();let v=this.tokenToSemanticValue(e.advance());v&&o.set(l,v);return}}}tryAttachTrailingStyle(e,r,i){if(r.action!=="fetch"&&r.action!=="render")return;let n=r.roles;if(!se(r.action)?.roles.some(h=>h.role==="style"))return;let o=n.get("style");if(o){if(o.type==="expression"&&typeof o.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(o.raw)&&e.peek()?.value===":"){let h=wr(e,o.raw);h&&n.set("style",{type:"expression",raw:h});}this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(r.action==="fetch"){let h=n.get("patient"),E=n.get("source");if(h&&E&&(h.type==="literal"||h.type==="expression")&&E.type==="expression"&&typeof E.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(E.raw)&&e.peek()?.value===":"){let z=wr(e,E.raw);z&&(n.set("source",{type:"expression",raw:z}),this.tryAttachResponseTypeAfterStyle(e,r,i));return}}let u=O(i)?.roleMarkers?.style;if(!u)return;if(u.position==="before"){let h=new Set([u.primary,...u.alternatives??[]].map(g=>g.toLowerCase())),E=e.peek();if(!E||!h.has(E.value.toLowerCase()))return;let z=e.mark();e.advance();let k=wr(e);if(!k){e.reset(z);return}n.set("style",{type:"expression",raw:k}),this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(u.position!=="after")return;let l=new Set([u.primary,...u.alternatives??[]].map(h=>h.toLowerCase())),c=h=>h.kind==="conjunction"||h.kind==="keyword"&&(this.isThenKeyword(h.value,i)||this.isEndKeyword(h.value,i)),d=24,m=-1,p=0;for(let h=0;h<d;h++){let E=e.peek(h);if(!E||c(E))break;if(E.value==="("||E.value==="{"?p++:(E.value===")"||E.value==="}")&&(p=Math.max(0,p-1)),p===0&&(E.kind==="particle"||E.kind==="keyword")&&l.has(E.value.toLowerCase())){m=h;break}}if(m<=0)return;let f=[];for(let h=0;h<m;h++){let E=e.peek(h);E&&f.push(E);}if(f.length===1&&B.RESPONSE_TYPE_WORDS.has(f[0].value.toLowerCase()))return;let y=new de(f,i),v=wr(y);n.set("style",{type:"expression",raw:v&&y.isAtEnd()?v:this.joinTokenText(f,i)});for(let h=0;h<=m;h++)e.advance();this.tryAttachResponseTypeAfterStyle(e,r,i);}tryAttachResponseTypeAfterStyle(e,r,i){let n=r.roles;if(n.has("responseType")||!se(r.action)?.roles.some(c=>c.role==="responseType"&&!c.required))return;let o=c=>!!c&&B.RESPONSE_TYPE_WORDS.has(c.toLowerCase()),s=e.peek();if(!s)return;let u=c=>{n.set("responseType",{type:"expression",raw:c});};if(B.AS_MARKERS_BEFORE[i]?.some(c=>s.value.toLowerCase()===c)){let c=e.peek(1);c&&o(c.value)&&(e.advance(),e.advance(),u(c.value));return}if(o(s.value)){e.advance(),u(s.value);for(let c of B.AS_MARKERS_AFTER[i]??[])if(c.every((d,m)=>e.peek(m)?.value.toLowerCase()===d)){for(let d=0;d<c.length;d++)e.advance();break}}}tryAttachTrailingExpressionRole(e,r,i){let n=r.action,a=n==="js"?{role:"patient",terminator:"boundary"}:n==="go"||n==="scroll"?{role:"destination",terminator:"destination-marker"}:null;if(!a)return;let o=r.roles,s=o.get(a.role);if(n==="go"&&s&&s.type==="expression"&&String(s.raw).toLowerCase()==="url"){let h=e.peek();if(h&&!dt.has((h.normalized??h.value).toLowerCase())){let z=this.tokenToSemanticValue(h);if(z.type==="literal"||z.type==="selector"){o.set(a.role,z),o.set("method",{type:"literal",value:"url"}),e.advance();return}}let E=o.get("patient");if(E&&(E.type==="literal"||E.type==="selector")){o.set(a.role,E),o.set("method",{type:"literal",value:"url"}),o.delete("patient");return}}if(n==="go"&&s&&s.type==="expression"){let h=/^url\s+(\S+)$/i.exec(String(s.raw??""));if(h){let E=h[1].replace(/^["']|["']$/g,"");o.set(a.role,{type:"literal",value:E,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(n==="go"&&!s){let h=o.get("patient");if(h&&h.type==="expression"&&String(h.raw).toLowerCase()==="url"){let E=e.peek();if(E&&!dt.has((E.normalized??E.value).toLowerCase())){let z=this.tokenToSemanticValue(E);if(z.type==="literal"||z.type==="selector"){o.set(a.role,z),o.set("method",{type:"literal",value:"url"}),o.delete("patient"),e.advance();return}}}}if(s&&!(s.type==="reference"&&s.value==="me"))return;let u=O(i);if(!u)return;let l=null;if(a.terminator==="destination-marker"){let h=u.roleMarkers?.destination;if(!h||h.position!=="after")return;l=h.primary.toLowerCase();}let c=h=>h.kind==="conjunction"||h.kind==="keyword"&&(this.isThenKeyword(h.value,i)||this.isEndKeyword(h.value,i)),d=24,m=[],p=0,f=false;for(let h=0;h<d;h++){let E=e.peek(h);if(!E||c(E))break;if(E.value==="("||E.value==="{"?p++:(E.value===")"||E.value==="}")&&(p=Math.max(0,p-1)),l!==null&&p===0&&(E.kind==="particle"||E.kind==="keyword")&&E.value.toLowerCase()===l){f=true;break}m.push(E);}if(m.length===0||l!==null&&!f)return;let y=m.length+(f?1:0);if(n==="go"&&m.length===2&&m[0].value.toLowerCase()==="url"){let h=this.tokenToSemanticValue(m[1]);if(h.type==="literal"||h.type==="selector"){o.set(a.role,h),o.set("method",{type:"literal",value:"url"});let E=o.get("patient");E&&E.type==="reference"&&E.value==="me"&&!se(n)?.roles.some(z=>z.role==="patient")&&o.delete("patient");for(let z=0;z<y;z++)e.advance();return}}let v=m;if(n==="js"){let h=u.keywords?.js,E=k=>[h?.primary,...h?.alternatives??[]].some(g=>!!g&&g.length>k.value.length&&g.includes(k.value)),z=0;for(;z<v.length&&E(v[z]);)z++;if(v=v.slice(z),v.length===0)return}if(o.set(a.role,{type:"expression",raw:this.joinTokenText(v,i)}),a.role!=="patient"){let h=o.get("patient");h&&h.type==="reference"&&h.value==="me"&&!se(n)?.roles.some(E=>E.role==="patient")&&o.delete("patient");}for(let h=0;h<y;h++)e.advance();}static buildVerbLookup(e){let r=new Map;for(let[i,n]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(i)&&(r.set(n.primary.toLowerCase(),i),n.alternatives))for(let a of n.alternatives)r.set(a.toLowerCase(),i);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[i,n]of Object.entries(e.roleMarkers)){if(!n)continue;if((i!=="event"||!r.has(n.primary))&&r.set(n.primary,i),n.alternatives)for(let o of n.alternatives)r.has(o)||r.set(o,i);}return r}parseSOVClauseByVerbAnchoring(e,r){let i=O(r);if(!i||i.wordOrder!=="SOV")return [];let n=B.buildVerbLookup(i),a=B.buildMarkerToRoleLookup(i),o=[],s=0;for(;s<e.length;){let u=-1,l="";for(let f=s;f<e.length;f++){let y=e[f];if(a.has(y.value))continue;let v=n.get(y.value.toLowerCase()),h=y.normalized?n.get(y.normalized.toLowerCase()):void 0,E=v||h;if(E){u=f,l=E;break}}if(u===-1)break;let c=e.slice(s,u),d=e.length;for(let f=u+1;f<e.length;f++){let y=e[f];if(y.kind==="conjunction"||this.isThenKeyword(y.value,r)){d=f;break}if(f>u+1&&!a.has(y.value)&&(n.get(y.value.toLowerCase())||(y.normalized?n.get(y.normalized.toLowerCase()):void 0))){d=f;break}}let m=e.slice(u+1,d),p=this.extractRolesFromMarkedTokens(c,m,a,l,r);if(o.push(me(l,p,{sourceLanguage:r,confidence:.7})),s=d,s<e.length){let f=e[s];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&s++;}}return o}extractRolesFromMarkedTokens(e,r,i,n,a){let o={},s=(l,c)=>{let d=this.isEndKeyword(l.value,a),m=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !d&&!m?false:l.metadata?.closesTrackedBlock===true||d?true:!(c&&c.kind==="selector")},u=l=>{let c=[];for(let d=0;d<l.length;d++){let m=l[d];if(s(m,l[d+1]))continue;let p=i.get(m.value);if(p&&m.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c,a);if(f){let y=this.mapRoleForCommand(p,n,o);y&&(o[y]=f);}c=[];}else c.push(m);}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!o.duration&&se(n)?.roles.some(m=>m.role==="duration"))o.duration={type:"literal",value:c[0].value,dataType:"string"};else {let m=this.tokensToSemanticValue(c,a);m&&(o.patient?o.destination||(o.destination=m):o.patient=m);}};return u(e),u(r),o}mapRoleForCommand(e,r,i){return r==="set"&&(e==="patient"?e="destination":e==="destination"&&(e="patient")),i[e]?e==="patient"&&!i.destination?"destination":e==="destination"&&!i.patient?"patient":e==="source"&&!i.source?"source":null:e}tokensToSemanticValue(e,r){if(e.length===0)return null;let i=e.filter(s=>s.kind!=="whitespace");if(i.length===0)return null;if(i.length>=2&&(i[0].kind==="selector"||/^[#.@*<]/.test(i[0].value))){let s=i.findIndex((u,l)=>l>0&&(u.normalized??u.value).toLowerCase()==="in");s>0&&(i=i.slice(0,s));}if(i.length===1)return this.tokenToSemanticValue(i[0]);let n=this.joinTokenText(i,r);if(gn(n))return {type:"expression",raw:n};let a=i.map(s=>s.value).join(""),o=i[0];return o.kind==="selector"||o.value.startsWith("#")||o.value.startsWith(".")||o.value.startsWith("@")||o.value.startsWith("*")?Oe(a):o.kind==="literal"||o.value.startsWith('"')||o.value.startsWith("'")?Y(td(a),"string"):o.kind==="reference"?Ae(a):Y(n)}tokenToSemanticValue(e){return Vr(e)??Y(e.value)}parseBodyWithGrammarPatterns(e,r,i,n,a=[]){let o=[],s=()=>$r([...a,...o]),u=[],l=false,c=()=>{if(!l&&u.length>0){let p=this.parseSOVClauseByVerbAnchoring(u,n);o.push(...p),p.length===0&&this.recordDroppedTokens(u,n,"fused body walk");}else u.length>0&&this.recordDroppedTokens(u,n,"fused body walk");u=[],l=false;},d=0,m=()=>o.filter(p=>{let f=p;return f.action==="while"&&(!Array.isArray(f.body)||f.body.length===0)}).length-d;for(;!e.isAtEnd();){let p=e.peek();if(p&&this.isThenKeyword(p.value,n)){c(),e.advance();continue}if(p&&s()>0&&!this.isEndKeyword(p.value,n)&&this.isBlockEndToken(p,ve(e.tokens,e.position()),n)&&!ut(n,p.value,e.peek(-1)?.value,e.peek(1)?.value)){c(),o.push(nr),e.advance();continue}if(p&&this.isEndKeyword(p.value,n)){let y=e.peek(-1),v=e.peek(1);if(!ut(n,p.value,y?.value,v?.value)){if(c(),s()>0){o.push(nr),e.advance();continue}if(m()>0){d++,e.advance();continue}e.advance();break}}if(p&&!l&&this.isIfKeyword((p.normalized??p.value).toLowerCase(),n)){c();let y=this.tryParseConditionalBlock(e,r,n);if(y){o.push(y),l=true;continue}}let f=false;if(i.length>0){let y=Ce.matchBest(e,i);if(y){let v=y.pattern.command,h={};for(let[k,g]of y.captured)k!=="event"&&k!=="action"&&k!=="continues"&&(h[k]=g);let E=me(v,h,{sourceLanguage:n,patternId:y.pattern.id});o.push(E),f=true,l=true;let z=y.captured.get("continues");if(z&&z.type==="literal"&&z.value==="then")continue}}if(!f){let y=e.mark(),v=Ce.matchBest(e,r);if(v){if(v.pattern.command==="if"){let E=e.mark();for(e.reset(y);!e.isAtEnd();){let k=e.peek();if(!k||this.isIfKeyword((k.normalized??k.value).toLowerCase(),n))break;e.advance();}let z=this.tryParseConditionalBlock(e,r,n);if(z){c(),o.push(z),l=true;continue}e.reset(E);}let h=this.buildCommand(v,n);o.push(h),this.tryAttachTrailingRole(e,h,n),f=true,l=true;}}f||(p&&u.push(p),e.advance());}c(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),n,"fused body walk");for(let p=o.length-1;p>=0;p--){let f=o[p];f.kind==="command"&&f.action==="for"&&(!(f.roles instanceof Map)||f.roles.size===0)&&(!Array.isArray(f.body)||f.body.length===0)&&o.splice(p,1);}return o}tryCompoundCommandParsing(e,r,i){let n=e.tokens,a=n.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,i)),o=n.some(c=>this.isElseKeyword(c.value,i));if(!a&&!o)return null;let s=new de(n,i),u=this.coverageMark(),l=this.parseBodyWithClauses(s,r,i);return l.length===0?(this.coverageRollback(u),null):l[0]}static isEnEventKeyword(e){if(typeof e!="string")return false;let r=e.toLowerCase(),i=B.enEventKeywordCache.get(r);if(i!==void 0)return i;let n=false;try{let a=Z(r,"en").tokens;n=a.length===1&&a[0]?.kind==="keyword";}catch{n=false;}return B.enEventKeywordCache.set(r,n),n}matchEventMarkerPhrase(e,r,i){let n=B.SOV_EVENT_MARKER_PHRASES[i];if(!n)return 0;for(let a of n)if(a.every((o,s)=>e[r+s]?.value===o))return a.length;return 0}hasSOVEventMarkerHead(e,r){let i=B.SOV_EVENT_MARKERS[r];if(i===void 0)return false;let{tokens:n}=Z(e,r),a=Te[r],o=new Set;if(a)for(let s of Object.keys(a))o.add(s.toLowerCase());for(let s=0;s<n.length;s++){let u=n[s],l=u.value.toLowerCase(),c=u.normalized?.toLowerCase();if(!(!!c&&(B.KNOWN_EVENTS.has(c)||De.has(c))||B.KNOWN_EVENTS.has(l)||De.has(l)||o.has(l)))continue;let m=this.matchEventParamPhrase(n,s+1).len,p=n[s+1+m];if(p&&(p.kind==="particle"||p.kind==="keyword")&&i.has(p.value)||this.matchEventMarkerPhrase(n,s+1+m,r)>0)return true}return false}tryScrollModifiers(e,r,i){let n=p=>p?.value.toLowerCase()??"",a=-1,o=-1;for(let p=0;p<e.length&&a<0;p++){let f=n(e[p])==="the"?p+1:p;Si.has(n(e[f]))&&(Si.has(n(e[f+1]))&&f++,!(n(e[f+1])!=="of"||!e[f+2])&&(a=p,o=f+1));}let s=a<0?e.findIndex(p=>Yc.has(n(p))):-1;if(a<0&&s<0)return null;let u=a>=0?a:s,l=a>=0?o:s,c=r.slice(0,e[u].position.start).trimEnd(),d=r.slice(e[l].position.end).trimStart(),m=c?c.length+1:0;try{let p=this.parse(c?`${c} ${d}`:d,i),f=[],y=E=>{if(!E)return;E.kind==="command"&&(E.action==="go"||E.action==="scroll")&&f.push(E);let z=E;for(let k of Er){let g=z[k];Array.isArray(g)&&g.forEach(A=>y(A));}};y(p??void 0);let v=E=>E.roles.get("destination")?.position?.start??-1,h=E=>f.filter(z=>v(z)>=0&&v(z)<=E).reduce((z,k)=>!z||v(k)>v(z)?k:z,void 0);if(!p)return null;if(a>=0){let E=h(m),z=E?.roles.get("destination"),k=e[o+1];if(!E||!z||!Xc(z,k))return null;let g=e.slice(a,o).map(A=>A.value.toLowerCase());E.scrollPosition=g.join(" ");}else {let E=h(e[s].position.start-1);if(!E)return null;E.scrollBehavior=n(e[s]);}return p}catch{return null}}tryDoNotThrow(e,r,i){let n=u=>u?.value.toLowerCase(),a=e.findIndex((u,l)=>n(u)==="do"&&n(e[l+1])==="not"&&n(e[l+2])==="throw");if(a<0)return null;let o=e[a].position.start,s=(r.slice(0,e[a].position.start).trimEnd()+" "+r.slice(e[a+2].position.end).trimStart()).trim();try{let u=this.parse(s,i),l=[],c=p=>{if(!p)return;p.kind==="command"&&p.action==="fetch"&&l.push(p);let f=p;for(let y of Er){let v=f[y];Array.isArray(v)&&v.forEach(h=>c(h));}};c(u??void 0);let d=p=>p.roles.get("source")?.position?.start??-1,m=l.filter(p=>d(p)>=0&&d(p)<o).reduce((p,f)=>!p||d(f)>d(p)?f:p,void 0);return !u||!m?null:(m.doNotThrow=!0,u)}catch{return null}}tryTellTo(e,r,i){let n=u=>(u.normalized??u.value).toLowerCase()==="tell",a=e.findIndex(n);if(a<0)return null;let o=O(i)?.roleMarkers?.destination,s=new Set([o?.primary,...o?.alternatives??[]].filter(u=>!!u));for(let u=a+1;u<e.length;u++){if(e[u].value.toLowerCase()!=="to")continue;let l=e[u].position.start,c=(r.slice(0,l).trimEnd()+" "+r.slice(e[u].position.end).trimStart()).trim();try{let d=this.parse(c,i);if(!d)continue;let m=[],p=E=>{if(!E)return;E.kind==="command"&&m.push(E);let z=E;for(let k of Er){let g=z[k];Array.isArray(g)&&g.forEach(A=>p(A));}};p(d);let f=E=>E.roles.get("destination")?.position?.start??-1,y=m.filter(E=>E.action==="tell"&&f(E)>=0&&f(E)<l).reduce((E,z)=>!E||f(z)>f(E)?z:E,void 0);if(!y)continue;let v=y.roles.get("destination")?.position?.end??-1;if(v<0||!e.filter(E=>E.position.start>=v&&E.position.start<l).every(E=>n(E)||s.has(E.value)))continue;return d}catch{continue}}return null}tryLoopIndex(e,r,i){let n=l=>l?.value.toLowerCase(),a=new Set;for(let l of pe(i))if(!(l.command!=="repeat"&&l.command!=="for")){for(let c of l.template.tokens)if(c.type==="literal")for(let d of [c.value,...c.alternatives??[]])a.add(d.toLowerCase());}let o=l=>a.has(l.value.toLowerCase()),s=O(i)?.roleMarkers?.style?.primary?.toLowerCase(),u=l=>n(l)==="with"||!!s&&n(l)===s;for(let l=0;l+1<e.length;l++){let c=u(e[l])&&n(e[l+1])==="index",d=n(e[l])==="index";if(!c&&!d)continue;let m=e[l].position.start,p=(r.slice(0,m).trimEnd()+" "+r.slice(e[l+1].position.end).trimStart()).trim();try{let f=this.parse(p,i);if(!f)continue;let y=[],v=b=>{if(!b)return;b.kind==="loop"&&y.push(b);let x=b;for(let D of Er){let w=x[D];Array.isArray(w)&&w.forEach(C=>v(C));}};v(f);let h=b=>Math.max(-1,...[...b.roles.values()].map(x=>x.position?.end??-1).filter(x=>x<=m)),E=y.filter(b=>h(b)>=0).reduce((b,x)=>!b||h(x)>h(b)?x:b,void 0);if(!E)continue;let z=e.filter(b=>b.position.start>=h(E)&&b.position.start<m),k=E.roles.get("quantity"),g=k?.type==="literal"&&typeof k.value=="number"?k.position?.end:void 0,A=g===void 0?void 0:e.find(b=>b.position.start>=g);if(!z.every(b=>b===A||o(b)))continue;return E.indexVariable=c?"index":e[l+1].value,f}catch{continue}}return null}tryWaitAlternatives(e,r,i){let n=v=>!!v&&(v.normalized??v.value).toLowerCase()==="wait";if(!e.some(v=>n(v)))return null;let a=v=>(v.normalized??v.value).toLowerCase(),o=v=>{if(!v)return;let h=z=>B.KNOWN_EVENTS.has(z)||De.has(z);if(h(a(v)))return a(v);let E=Rn(v.value,i);return h(E)?E:void 0},s=v=>o(v)!==void 0,u=v=>!!v&&/^\d+(?:\.\d+)?(?:ms|s)$/.test(v.value),l=O(i)?.roleMarkers?.source,c=new Set([l?.primary,...l?.alternatives??[]].filter(Boolean).map(v=>v.toLowerCase())),d=v=>!!v&&((v.normalized??"")==="source"||c.has(v.value.toLowerCase())),m=l?.position!=="after",p=O(i)?.wordOrder==="SOV",f=(v,h)=>p?n(e[h])||e[h]?.kind==="particle"&&n(e[h+1]):n(e[v-1])||n(e[v-2]),y=v=>{let h=Pn(o(e[v]),i).split(/\s+/);return h.length<2||e[v].value!==h[0]?1:h.every((E,z)=>z===0||e[v+z]?.value===E)?h.length:1};for(let v=0;v<e.length;v++){if(!s(e[v]))continue;let h=[],E=v+y(v),z=this.matchEventParamPhrase(e,E);h.push(z.names.length>0?{event:o(e[v]),params:z.names}:{event:o(e[v])});let k=E+z.len;for(;Wr(e[k]??{value:""},i);){let F=e[k+1];if(s(F)){let T=k+1+y(k+1),N=this.matchEventParamPhrase(e,T);h.push(N.names.length>0?{event:o(F),params:N.names}:{event:o(F)}),k=T+N.len;}else if(u(F))h.push({duration:F.value}),k+=2;else break}let g=k,A,b;if(m&&d(e[k])&&e[k+1]?(A=[k,k+1],b=e[k+1]):!m&&e[k]&&d(e[k+1])&&(A=[k,k+1],b=e[k]),!(h.length>1||z.names.length>0||!!A))continue;let D=A?A[1]+1:g;if(!f(v,D))continue;let w=[];g>E&&w.push([e[E-1].position.end,e[g-1].position.end]),A&&w.push([e[A[0]].position.start,e[A[1]].position.end]),w.sort((F,T)=>F[0]-T[0]);let C="",S=0;for(let[F,T]of w)C+=r.slice(S,F)+" ",S=T;C=(C+r.slice(S)).replace(/\s+/g," ").trim();let R=h[0],_=0;for(let F=0;F<v;F++)o(e[F])===R.event&&f(F,F+1)&&_++;try{let F=this.parse(C,i),T=[],N=M=>{if(!M)return;let j=M.roles?.get("event"),ne=j?.type==="expression"?j.raw:j&&"value"in j?String(j.value):void 0;M.kind==="command"&&M.action==="wait"&&ne?.toLowerCase()===R.event&&T.push(M);let ye=M;for(let H of Er){let L=ye[H];Array.isArray(L)&&L.forEach(I=>N(I));}};N(F??void 0);let K=T[_];if(!F||!K)continue;return K.waitAlternatives=h,b&&(K.waitSource=Jc(b)),F}catch{}}return null}isBodyCommandWord(e,r){let i=(e.normalized??e.value).toLowerCase();return e.kind==="keyword"&&r.has(i)&&!B.KNOWN_EVENTS.has(i)&&!De.has(i)}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let i=[];for(let n=r+1;n<e.length;n++){let a=e[n].value;if(a===")")return e[r-1]?.position?.end!==e[r]?.position?.start&&e[n+1]?.kind==="particle"?{len:0,names:[]}:{len:n-r+1,names:i};if(a===",")continue;let o=e[n].kind;if(o!=="identifier"&&o!=="keyword"||!/^[A-Za-z_$][\w$]*$/.test(a))break;let s=(e[n].normalized??a).toLowerCase();if(o==="keyword"&&Zc.has(s))break;i.push(a);}return {len:0,names:[]}}isStrippableSourceRef(e,r){if(!e)return false;let i=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(i==="me"||i==="i"||i==="it"))return true;let n=e.value.toLowerCase();return r.has(n)||!!i&&r.has(i)}tryTrailingEventExtraction(e,r,i){let n=Z(e,r).tokens;if(n.length<3)return null;let a=Te[r],o=new Set;if(a)for(let k of Object.keys(a))o.add(k.toLowerCase());let s=n.length-2,u=n[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))return null;let c=n[n.length-1],d=c.value.toLowerCase(),m=c.normalized?.toLowerCase();if(!(!!m&&B.KNOWN_EVENTS.has(m)||B.KNOWN_EVENTS.has(d)||o.has(d)))return null;let f=m&&B.KNOWN_EVENTS.has(m)?m:a?.[d]??d,y=n.slice(0,s);if(y.length===0)return null;let v=i.filter(k=>k.command!=="on"),h=new de(y,r),E=this.coverageMark(),z=this.parseBodyWithClauses(h,v,r);return z.length===0?(this.coverageRollback(E),null):vr({type:"literal",value:f},z,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,i){let n=Z(e,r).tokens;if(n.length<3)return null;let a=Te[r],o=new Set;if(a)for(let s of Object.keys(a))o.add(s.toLowerCase());for(let s=0;s<n.length-1;s++){let u=n[s];if(!(u.kind==="keyword"&&u.normalized?.toLowerCase()==="on"))continue;let c=n[s+1],d=c.value.toLowerCase(),m=c.normalized?.toLowerCase();if(!(!!m&&B.KNOWN_EVENTS.has(m)||B.KNOWN_EVENTS.has(d)||o.has(d)))continue;let f=m&&B.KNOWN_EVENTS.has(m)?m:a?.[d]??d,y=n.filter((k,g)=>g!==s&&g!==s+1);if(y.length===0)return null;let v=i.filter(k=>k.command!=="on"),h=new de(y,r),E=this.coverageMark(),z=this.parseBodyWithClauses(h,v,r);return z.length===0?(this.coverageRollback(E),null):vr({type:"literal",value:f},z,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,i){let n=B.SOV_EVENT_MARKERS[r];if(!n)return null;let o=Z(e,r).tokens,s=Te[r],u=new Set;if(s)for(let A of Object.keys(s))u.add(A.toLowerCase());let l=B.SOV_SOURCE_MARKERS[r],c=-1,d="",m="",p=1,f=[];for(let A=0;A<o.length;A++){let b=o[A],x=b.value.toLowerCase(),D=x,w="",C=x.indexOf("[");C>0&&(D=x.slice(0,C),w=b.value.slice(C));let S=b.normalized?.toLowerCase(),R=S&&(B.KNOWN_EVENTS.has(S)||De.has(S)),_=u.has(x)||u.has(D),F=B.KNOWN_EVENTS.has(D)||De.has(D);if(R||_||F){let T=o[A-1];if(T&&(T.normalized??T.value).toLowerCase()==="event")continue;let N;R?N=S:_?N=s?.[x]??s?.[D]??D:N=D;let K=this.matchEventParamPhrase(o,A+1);if(n.size>0){let M=1+K.len,j=o[A+M];j&&j.kind==="selector"&&j.value.startsWith("[")&&(M+=1);let ne=o[A+M];if(ne&&(ne.kind==="particle"||ne.kind==="keyword")&&n.has(ne.value)){c=A,d=N,m=w||(M===K.len+2?o[A+M-1].value:""),p=M+1,f=K.names;break}}else {c=A,d=N,m=w,p=1+K.len+this.matchEventMarkerPhrase(o,A+1+K.len,r),f=K.names;break}}}if(c===-1){let A=new Set(i.filter(b=>b.command!=="on").map(b=>b.command));for(let b=0;b<o.length;b++){let x=o[b];if(x.kind==="identifier"&&!x.value.startsWith("`"))if(n.size>0){let D=1,w=o[b+1];w&&w.kind==="selector"&&w.value.startsWith("[")&&(D=2);let C=o[b+D];if(C&&(C.kind==="particle"||C.kind==="keyword")&&n.has(C.value)){c=b,d=x.value,m=D===2?o[b+1].value:"",p=D+1;break}}else {let D=this.matchEventMarkerPhrase(o,b+1,r);if(D>0){c=b,d=x.value,m="",p=1+D;break}let w=o[b+1];if(w&&w.kind==="keyword"&&w.normalized!=null&&A.has(w.normalized)){c=b,d=x.value,m="",p=1;break}}}}if(c===-1)return null;let y=new Set;for(let A=c;A<c+p;A++)y.add(A);if(l){let A=c+p;if(A<o.length){let b=o[A];if((b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value))y.add(A);else if(this.isStrippableSourceRef(b,l.windowTokens)){let x=o[A+1];x&&(x.kind==="particle"||x.kind==="keyword")&&l.markers.has(x.value)&&(y.add(A),y.add(A+1));}}if(c>=2){let b=o[c-1];(b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(y.add(c-2),y.add(c-1));}for(let b=0;b<c;b++){let x=o[b],D=x.value.toLowerCase(),w=x.normalized?.toLowerCase();if(l.windowTokens.has(D)||w&&l.windowTokens.has(w)){y.add(b);break}}}let v=o.filter((A,b)=>!y.has(b));if(v.length===0)return null;let h=i.filter(A=>A.command!=="on"),E=new de(v,r),z=this.coverageMark(),k=this.parseBodyWithClauses(E,h,r);if(k.length===0)return this.coverageRollback(z),null;let g={sourceLanguage:r,confidence:.75};return m&&(g.keyFilter=m),vr(B.isEnEventKeyword(d)?{type:"literal",value:d}:{type:"expression",raw:d},k,void 0,g,f)}profileKeywordMatches(e,r,i){let n=O(e)?.keywords?.[r];return n?n.primary?.toLowerCase()===i?true:!!n.alternatives?.some(a=>a.toLowerCase()===i):false}consumeForPostposition(e,r){let i=e.peek();if(!i)return;let n=(i.normalized??"").toLowerCase(),a=O(r)?.keywords?.for;(n==="for"||i.value===a?.primary||(a?.alternatives??[]).includes(i.value))&&e.advance();}isThenAt(e,r,i){return this.isThenKeyword(e.value,i)?!(this.isEndKeyword(e.value,i)&&Pe(r,i)):false}isThenKeyword(e,r){let i=e.toLowerCase(),a={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[r];return a?a.has(i):i==="then"||this.profileKeywordMatches(r,"then",i)}isElseKeyword(e,r){let i=e.toLowerCase();return i==="else"?true:this.profileKeywordMatches(r,"else",i)}isEndKeyword(e,r){let i=e.toLowerCase(),n=bu(r);return n?i==="end"||n.has(i):i==="end"||this.profileKeywordMatches(r,"end",i)}isJsKeyword(e){let r=(e.normalized??e.value).toLowerCase();return r==="js"||this.profileKeywordMatches("en","js",r)}isPatientMarker(e,r){let i=O(r)?.roleMarkers?.patient;if(!i?.primary)return false;let n=e.value.toLowerCase();return i.primary.toLowerCase()===n?true:!!i.alternatives?.some(a=>a.toLowerCase()===n)}isJsBlockTerminator(e,r){return this.isEndKeyword(e,r)||this.profileKeywordMatches(r,"end",e.toLowerCase())}consumeVerbFinalJsBlock(e,r){let i=e.mark(),n=0,a=-1;for(;;){let c=e.peek(n);if(!c||this.isThenKeyword(c.value,r)||this.isJsBlockTerminator(c.value,r))break;if(this.isJsKeyword(c)){let d=e.peek(n+1),m=!!d&&c.position?.end!==void 0&&c.position.end===d.position?.start&&this.profileKeywordMatches(r,"js",`${c.value}${d.value}`.toLowerCase()),p=e.peek(n+(m?2:1));if(n>0&&p&&this.isJsBlockTerminator(p.value,r)){a=n;break}}n++;}if(a<=0)return null;let o=[];for(let c=0;c<a;c++){let d=e.peek(c);d&&o.push(d);}let s=o[o.length-1];if(s&&this.isPatientMarker(s,r)&&o.pop(),o.length===0)return e.reset(i),null;let u=this.rawJsBody(o);for(let c=0;c<a;c++)e.advance();e.advance();let l=e.peek();return l&&!this.isJsBlockTerminator(l.value,r)&&e.advance(),e.advance(),me("js",{patient:{type:"expression",raw:u||"()"}},{sourceLanguage:r,patternId:`js-opaque-final-${r}`,confidence:1})}consumeJsBlock(e,r){let i=e.peek();if(!i||!this.isJsKeyword(i))return null;let n=e.mark(),a=[];e.advance();let o=e.peek();o&&i.position?.end!==void 0&&i.position.end===o.position?.start&&this.profileKeywordMatches(r,"js",`${i.value}${o.value}`.toLowerCase())&&e.advance();let s=e.peek();s&&this.isPatientMarker(s,r)&&e.advance();let u=false;for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(e.advance(),this.isJsBlockTerminator(c.value,r)){u=true;break}a.push(c);}if(!u)return e.reset(n),null;let l=this.rawJsBody(a);return me("js",{patient:{type:"expression",raw:l||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}rawJsBody(e){if(e.length===0)return "";let r=e[0].position?.start,i=e[e.length-1].position?.end,n=this.positionSource;if(n!==void 0&&r!==void 0&&i!==void 0){let o=n.slice(r,i),s=u=>u.replace(/\s+/g,"");if(s(o)===s(e.map(u=>u.value).join("")))return o.trim()}let a="";for(let o=0;o<e.length;o++){let s=e[o-1],u=s?.position?.end!==void 0&&e[o].position?.start===s.position.end;o>0&&!u&&(a+=" "),a+=e[o].value;}return a.trim()}isIfKeyword(e,r){let i=e.toLowerCase();return i==="if"?true:this.profileKeywordMatches(r,"if",i)}isUnlessKeyword(e,r){let i=e.toLowerCase();return i==="unless"?true:this.profileKeywordMatches(r,"unless",i)}tryParseUnlessGuard(e,r,i){let n=e.peek();if(!n||!this.isUnlessKeyword((n.normalized??n.value).toLowerCase(),i))return null;let a=e.mark(),o=this.tryParseConditionalBlock(e,r,i,true);if(!o||o.kind!=="conditional")return e.reset(a),null;let s=o;if(s.elseBranch&&s.elseBranch.length>0)return e.reset(a),null;let u=s.roles.get("condition");return u?[me("unless",{condition:u},{sourceLanguage:i,patternId:`unless-${i}-guard`,confidence:1}),...s.thenBranch]:(e.reset(a),null)}isBlockEndToken(e,r,i){let n=r.next;return (this.isEndKeyword(e.value,i)||e.kind==="keyword"&&(e.normalized??"").toLowerCase()==="end"&&!(n&&n.kind==="selector"))&&!Pe(r,i)}opensNestedBlock(e,r,i){let n=(e.normalized??e.value).toLowerCase();return this.isIfKeyword(n,i)?!(r&&this.isElseKeyword(r.value,i)):this.isUnlessKeyword(n,i)?true:n==="repeat"?e.kind==="keyword"||e.kind==="identifier":n!=="for"||e.kind!=="keyword"?false:!(r&&ct(r))}tryParseConditionalBlock(e,r,i,n=false){let a=e.peek();if(!a)return null;let o=(a.normalized??a.value).toLowerCase();if(!this.isIfKeyword(o,i)&&!(n&&this.isUnlessKeyword(o,i)))return null;let s=e.mark(),u=this.coverageMark();e.advance();let l=e.tokens,c=e.position(),d=[],m=0;for(;!e.isAtEnd();){let w=e.peek();if(!w)break;if(d.length>0&&this.opensNestedBlock(w,Ir(d,d.length),i)){m++,d.push(w),e.advance();continue}if(this.isBlockEndToken(w,ve(e.tokens,e.position()),i)){if(m===0){e.advance();break}m--,d.push(w),e.advance();continue}d.push(w),e.advance();}if(d.length===0)return e.reset(s),this.coverageRollback(u),null;let p=O(i),f=p?.wordOrder==="SOV"?B.buildVerbLookup(p):null,y=0,v=0,h=[];for(;y<d.length;y++){let w=d[y],C=(w.normalized??w.value).toLowerCase();if(y>0&&(this.isIfKeyword(C,i)||this.isUnlessKeyword(C,i))?v++:this.isBlockEndToken(w,ve(l,c+y),i)&&v--,v===0&&this.isThenAt(w,ve(l,c+y),i)){y++;break}if(v===0&&h.length>0){let S=(w.normalized??w.value).toLowerCase(),R=dl(d[y-1],w,h.length===1,i),_=f!==null&&f.has(w.value.toLowerCase())&&!En.has(S),F=/^\.[a-zA-Z_]\w*$/.test(w.value)&&d[y-1].position?.end!==void 0&&w.position?.start!==void 0&&d[y-1].position.end===w.position.start;if(!B.CONDITION_OPERATORS.has(S)&&!F&&(!R||_)&&(this.tokensBeginCommand(d.slice(y),r,i)||this.sovCommandStartsAt(d.slice(y),f)))break}h.push(w);}if(h.length===0)return e.reset(s),this.coverageRollback(u),null;let z=[],k=[],g=false,A=0;for(;y<d.length;y++){let w=d[y];if(this.opensNestedBlock(w,Ir(d,y),i)?A++:this.isBlockEndToken(w,ve(l,c+y),i)&&A--,A===0&&!g&&this.isElseKeyword(w.value,i)){g=true;continue}(g?k:z).push(w);}let b={type:"expression",raw:this.joinTokenText(h,i)},x=this.parseBranch(z,r,i),D=k.length>0?this.parseBranch(k,r,i):void 0;return x.length===0&&(!D||D.length===0)?(e.reset(s),this.coverageRollback(u),null):Eu(b,x,D,{sourceLanguage:i,patternId:`conditional-${i}-folded`,confidence:1})}joinTokenText(e,r){return Be(e,O(r))}tokensBeginCommand(e,r,i){if(e.length===0)return false;let n=new de(e,i);return Ce.matchBest(n,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let i=s=>r.has(s.value.toLowerCase())||!!s.normalized&&r.has(s.normalized.toLowerCase()),n=s=>s.kind==="identifier"||s.kind==="selector"||s.kind==="literal"||s.kind==="reference",a=0,o=0;for(;a+1<e.length;){let s=e[a],u=e[a+1];if(!n(s)||u.kind!=="particle")break;o+=1,a+=2;let l=e[a];if(o>=1&&l&&i(l))return true}return false}parseBranch(e,r,i){if(e.length===0)return [];let n=new de(e,i),a=this.parseBodyWithClauses(n,r,i);return a.length===1&&a[0]?.kind==="compound"?a[0].statements:a}extractStandaloneModifiers(e,r){let n=Z(e,r).tokens;if(n.length===0)return {modifiers:null,remainingInput:null};let o=n[0].value.toLowerCase(),s=y=>n[y]?.value.toLowerCase(),u=y=>!!n[y]&&n[y].kind!=="selector";if(o==="on"&&s(1)==="first"&&n.length>2)return {modifiers:{once:true,onceAsFirst:true},remainingInput:e.slice(0,n[1].position.start)+e.slice(n[2].position.start)};if(o==="first"&&u(1))return {modifiers:{once:true,onceAsFirst:true},remainingInput:e.slice(n[1].position.start)};let l=B.STANDALONE_MODIFIERS[o];if(!l)return {modifiers:null,remainingInput:null};let c={},d=1;if(l==="once")c.once=true;else {let y=1;if(y<n.length){let v=n[y],h=n[y+1],E=v.kind==="identifier"&&h?.kind==="literal"&&/^\d+(ms|s|m)?$/.test(h.value);(v.kind==="keyword"||v.kind==="particle"||E)&&(y++,d++);}if(y<n.length){let v=n[y];if(v.kind==="literal"){let h=v.value.match(/^(\d+)(ms|s|m)?$/);if(h){let E=parseInt(h[1],10),z=h[2]||"ms";z==="s"?E*=1e3:z==="m"&&(E*=6e4),c[l]=E,d=y+1;}}}c[l]||(c[l]=l==="debounce"?300:100);}let m=n.slice(d);if(m.length===0)return {modifiers:null,remainingInput:null};let p=m[0].position.start,f=e.slice(p);return {modifiers:c,remainingInput:f}}stripAsyncModifier(e,r){let i=O(r)?.keywords?.async,n=new Set(["async"]);i?.primary&&n.add(i.primary.toLowerCase()),i?.alternatives?.forEach(l=>n.add(l.toLowerCase()));let a=Z(e,r).tokens,o=a.findIndex(l=>n.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let s=a[o],u=(e.slice(0,s.position.start)+e.slice(s.position.end)).replace(/\s{2,}/g," ").trim();return u.length===0?{remainingInput:null}:{remainingInput:u}}stripDoNotThrowModifier(e,r){let i=Z(e,r).tokens;for(let n=0;n<i.length-1;n++){if(i[n].value.toLowerCase()!=="do")continue;let a=-1;for(let l=n+1;l<=n+5&&l<i.length;l++){let c=i[l];if(c.normalized?.toLowerCase()==="throw"){a=l;break}let d=c.kind;if(d==="selector"||d==="literal"||d==="reference"||d==="conjunction")break}if(a===-1)continue;let o=i[n].position.start,s=i[a].position.end,u=(e.slice(0,o)+e.slice(s)).replace(/\s{2,}/g," ").trim();return u.length===0?{remainingInput:null}:{remainingInput:u}}return {remainingInput:null}}static droppedTokenCount(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").reduce((r,i)=>r+(parseInt(/left (\d+) token/.exec(i.message)?.[1]??"0",10)||0),0)}static unconsumedSpans(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").map(r=>/unconsumed: "(.*)"$/.exec(r.message)?.[1]).filter(r=>!!r).map(r=>r.replace(/\s+/g," ").trim())}static withoutSpanDiagnostics(e,r){return {...e,diagnostics:(e.diagnostics??[]).filter(i=>{if(i.code!=="unconsumed-input")return true;let n=/unconsumed: "(.*)"$/.exec(i.message)?.[1];return !n||n.replace(/\s+/g," ").trim()!==r})}}static sourceNounValue(e){if(e.kind==="selector")return Oe(e.value);let r=(e.normalized??e.value).toLowerCase();return Fe(r)?{type:"reference",value:r}:{type:"literal",value:e.value,dataType:"string"}}reclaimDanglingFromTail(e,r,i){let n=B.droppedTokenCount,a=B.unconsumedSpans(e);if(a.length===0)return null;let o=n(e),s=O(i)?.roleMarkers?.source,u=new Set;s?.primary&&u.add(s.primary),s?.alternatives?.forEach(c=>u.add(c));let l=Z(r,i).tokens;for(let c=0;c<l.length;c++){let d=l[c];if(d.normalized!=="source"&&!u.has(d.value))continue;let m=s?.position==="after"?c-1:c+1,p=l[m];if(!p||p.kind!=="identifier"&&p.kind!=="keyword")continue;let f=Math.min(d.position.start,p.position.start),y=Math.max(d.position.end,p.position.end),v=r.slice(f,y).replace(/\s+/g," ").trim();if(!a.some(E=>E===v||E.includes(v)))continue;let h=(r.slice(0,f).trimEnd()+" "+r.slice(y).trimStart()).trim();if(!(!h||h===r))try{let E=this.parse(h,i);if(!E||E.kind!=="event-handler")continue;let z=jr(E);if(n(z)<o)return {node:{...z,eventModifiers:{...z.eventModifiers,from:B.sourceNounValue(p)}},input:h}}catch{}}return null}reclaimEventCompoundTail(e,r,i){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=Te[i];if(!a)return null;let o=e.roles,s=o.get("event"),u=s?.type==="literal"&&typeof s.value=="string"?s.value:null;if(!u)return null;let l=d=>d.replace(/\s+/g," ").trim(),c=Z(r,i).tokens;for(let d of n)for(let m=1;m<c.length;m++)for(let p=m;p<c.length;p++){let f=l(r.slice(c[m].position.start,c[p].position.end));if(f.length>d.length)break;if(f!==d)continue;let y=c[m-1];if((a[y.value]??y.normalized)!==u)break;let h=l(r.slice(y.position.start,c[p].position.end)),E=a[h];if(!E)break;return o.set("event",{type:"literal",value:E,dataType:"string"}),{node:B.withoutSpanDiagnostics(e,d),input:r}}return null}reclaimResponseTypeTail(e,r,i){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=B.AS_MARKERS_BEFORE[i];if(!a)return null;let o=l=>l.replace(/\s+/g," ").trim(),s=B.droppedTokenCount(e),u=Z(r,i).tokens;for(let l=0;l+1<u.length;l++){let c=u[l],d=u[l+1];if(!a.some(f=>c.value.toLowerCase()===f)||!B.RESPONSE_TYPE_WORDS.has(d.value.toLowerCase()))continue;let m=o(r.slice(c.position.start,d.position.end));if(!n.includes(m))continue;let p=(r.slice(0,c.position.start).trimEnd()+" "+r.slice(d.position.end).trimStart()).trim();if(!(!p||p===r))try{let f=this.parse(p,i);if(!f||f.kind!=="event-handler")continue;let y=jr(f);if(B.droppedTokenCount(y)>=s)continue;let v=B.findResponseTypeTarget(y);if(!v)continue;return v.roles.set("responseType",{type:"expression",raw:d.value}),{node:y,input:p}}catch{}}return null}static findResponseTypeTarget(e){let r=null,i=n=>{if(!n||typeof n!="object"||r)return;if(n.kind==="command"){let o=n;if(se(o.action)?.roles.some(u=>u.role==="responseType"&&!u.required)&&!o.roles.has("responseType")){r=o;return}}let a=n;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let s=a[o];Array.isArray(s)&&s.forEach(u=>i(u));}};return i(e),r}reclaimCapturedDestinationTail(e,r,i){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=O(i)?.roleMarkers?.destination,o=new Set;if(a?.primary&&o.add(a.primary),a?.alternatives?.forEach(l=>o.add(l)),o.size===0)return null;let s=l=>l.replace(/\s+/g," ").trim(),u=Z(r,i).tokens;for(let l=0;l+1<u.length;l++){let c=u[l],d=u[l+1],m=o.has(c.value)&&d.normalized==="me",p=c.normalized==="me"&&o.has(d.value);if(!m&&!p)continue;let f=s(r.slice(c.position.start,d.position.end));if(!n.includes(f))continue;let y=false,v=h=>{if(!h||typeof h!="object"||y)return;if(h.kind==="command"){let z=h.roles.get("destination");if(z?.type==="reference"&&z.value==="me"){y=true;return}}let E=h;for(let z of ["body","statements","thenBranch","elseBranch","commands"]){let k=E[z];Array.isArray(k)&&k.forEach(g=>v(g));}};if(v(e),!!y)return {node:B.withoutSpanDiagnostics(e,f),input:r}}return null}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let i=[];for(;;){let n=e.mark(),a=e.peek();if(!a)break;if(!Wr(a,r)){e.reset(n);break}e.advance();let o=e.peek();if(!o){e.reset(n);break}let s=o.normalized||o.value;e.advance(),i.push({type:"literal",value:s});}return i}};ge.coverageMarkerSurfaces=new Map;ge.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};ge.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"]};ge.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};ge.enEventKeywordCache=new Map;ge.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);ge.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);ge.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"])};ge.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};ge.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"])}};ge.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);ge.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};var id=ge,nd=new id;function ad(t,e){return nd.parse(t,e)}function In(t,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...t].sort((i,n)=>{let a=i[r]??99,o=n[r]??99;return a-o})}function dr(t,e){let r,i;if(t.markerOverride&&t.markerOverride[e.code]!==void 0)r=t.markerOverride[e.code],i=r?Ne(t,e.code,r):void 0;else {let n=e.roleMarkers[t.role];if(n){r=n.primary;let a=Ne(t,e.code,r)??[],o=[...new Set([...n.alternatives??[],...a])].filter(s=>s!==r);i=o.length?o:void 0;}}return {marker:r,alternatives:i}}function Tr(t,e,r){r.roles.find(n=>n.role==="scope"&&!n.required)&&(t.push({type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}),e.scope={fromRole:"scope"});}function Rt(t,e,r,i){jn(t,e,r,i,"manner",{requireMarker:true});}function $n(t,e,r,i){jn(t,e,r,i,"recipient",{requireMarker:false});}function jn(t,e,r,i,n,a){let o=r.roles.find(u=>u.role===n&&!u.required);if(!o)return;let s=o.markerOverride?.[i];a.requireMarker&&!s||(t.push({type:"group",optional:true,tokens:[...(s?s.split(/\s+/):[]).map(u=>({type:"literal",value:u})),{type:"role",role:n,optional:true,expectedTypes:o.expectedTypes,...o.valueShape!==void 0?{valueShape:o.valueShape}:{}}]}),e[n]={fromRole:n});}function Vn(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 Wn(t,e,r){let i=t.roles.find(c=>c.role===r);if(!i||r==="patient")return [{type:"role",role:r,optional:false}];let{marker:n,alternatives:a}=dr(i,e),o={type:"role",role:r,optional:false,...i.valueShape!==void 0?{valueShape:i.valueShape}:{}};if(!n)return [o];let s=n.split(/\s+/).filter(Boolean),u={type:"group",optional:true,tokens:s.map(c=>({type:"literal",value:c,...s.length===1&&a?.length?{alternatives:a}:{}}))};return (e.roleMarkers[r]?.position??"before")==="after"?[o,u]:[u,o]}function qn(t,e,r,i,n){for(let a of r.roles)a.required||n.has(a.role)||e[a.role]||!(a.markerOverride?.[i.code]??i.roleMarkers[a.role]?.primary)&&a.valueShape===void 0||(t.push({type:"group",optional:true,tokens:Un(a,i)}),e[a.role]=a.default?{fromRole:a.role,default:a.default}:{fromRole:a.role});}function od(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let f=i.primary.split(/\s+/);if(f.length>1)for(let y of f)a.push({type:"literal",value:y});else {let y=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(y);}}let o=Vn(t),s=e.roleMarkers.destination,u=t.roles.some(f=>f.role==="destination");s&&u&&o!=="destination"&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]});let l=e.roleMarkers.source,c=t.roles.some(f=>f.role==="source");l&&c&&o!=="source"&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"source",optional:true},l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary}]}),a.push(...Wn(t,e,o));let d=e.roleMarkers.patient;if(d&&o==="patient"){let f=d.alternatives?{type:"literal",value:d.primary,alternatives:d.alternatives}:{type:"literal",value:d.primary};a.push(f);}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(m),o!=="source"&&a.push(...Je(t,e.roleMarkers.source)),o!=="destination"&&a.push(...Ct(t,e.roleMarkers.destination));let p={action:{value:t.action},event:{fromRole:"event"},[o]:{fromRole:o},...o==="destination"?{}:Ye(t),...o==="source"?{}:Xe(t)};return qn(a,p,t,e,new Set(["event",o,"destination","source"])),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`{event} ${i.primary} {destination?} {${o}} ${d?.primary||""} ${r.primary}`,tokens:a},extraction:p}}function sd(t,e,r,i,n){let a=[],o=t.action==="swap",s=o?"destination":"patient";a.push({type:"role",role:s,optional:false});let u=e.roleMarkers.patient;if(u){let m=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(m);}if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let p of m)a.push({type:"literal",value:p});else {let p=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(p);}}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(l),a.push(...Je(t,e.roleMarkers.source));let c=e.roleMarkers.destination;if(o&&c){let m=t.roles.find(p=>p.role==="patient")?.markerOverride?.[e.code];if(m&&m!==c.primary){let p=c.alternatives??[];p.includes(m)||(c={...c,alternatives:[...p,m]});}}a.push(...o?Eo(t,c):Ct(t,c));let d={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...o?{}:Ye(t),...Xe(t)};return $n(a,d,t,e.code),Rt(a,d,t,e.code),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`{patient} ${u?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:d}}function ud(t,e,r,i,n){let a=t.roles.find(d=>d.role==="source");if(!a)return null;let{marker:o,alternatives:s}=dr(a,e),u=e.roleMarkers.patient;if(!o||o===i.primary||o===u?.primary)return null;let l=[];l.push({type:"role",role:"patient",optional:false}),u&&l.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}),l.push({type:"role",role:"source",optional:false,...a.expectedTypes?{expectedTypes:a.expectedTypes}:{},...a.valueShape!==void 0?{valueShape:a.valueShape}:{}});for(let d of o.split(/\s+/))l.push(s&&o.split(/\s+/).length===1?{type:"literal",value:d,alternatives:s}:{type:"literal",value:d});if(l.push({type:"role",role:"event",optional:false}),i.position==="after"){let d=i.primary.split(/\s+/);if(d.length>1)for(let m of d)l.push({type:"literal",value:m});else l.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}l.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary});let c={action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},source:{fromRole:"source"}};return $n(l,c,t,e.code),Rt(l,c,t,e.code),{id:`${t.action}-event-${e.code}-sov-source-fronted`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{patient} ${u?.primary||""} {source} ${o} {event} ${i.primary} ${r.primary}`,tokens:l},extraction:c}}function ld(t,e,r,i,n){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}let s=e.roleMarkers.destination;if(s&&(a.push({type:"role",role:"destination",optional:false}),a.push(s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary})),a.push({type:"role",role:"event",optional:false}),i.position==="after"){let l=i.primary.split(/\s+/);if(l.length>1)for(let c of l)a.push({type:"literal",value:c});else {let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(u),{id:`${t.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${s?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function cd(t,e,r,i,n){let a=[];a.push({type:"role",role:"event",optional:false});let o=i.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&a.push({type:"literal",value:o[0],alternatives:o.slice(1)});let s=e.roleMarkers.destination;s&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let c=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(l),a.push(...Je(t,e.roleMarkers.source)),a.push(...Ct(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(n.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ye(t),...Xe(t)}}}function dd(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let s=i.primary.split(/\s+/);if(s.length>1)for(let u of s)a.push({type:"literal",value:u});else {let u=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(u);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(o),{id:`${t.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function md(t,e,r,i){let n=e.eventHandler?.temporalMarkers;if(!n||n.length===0)return null;let a=[];a.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),a.push({type:"literal",value:n[0],alternatives:n.slice(1)}),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let u=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(u);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),{id:`${t.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(i.basePriority??100)+49,template:{format:`{event} ${n[0]} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function pd(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let d=i.primary.split(/\s+/);if(d.length>1)for(let m of d)a.push({type:"literal",value:m});else {let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(m);}}let s=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.sovPosition??999,f=m.sovPosition??999;return p-f});for(let d of s){a.push({type:"role",role:d.role,optional:false});let{marker:m,alternatives:p}=dr(d,e);if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u);let l=s.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(d=>[d.role,{fromRole:d.role}]))};return Tr(a,c,t),{id:`${t.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`{event} ${i.primary} ${l} ${r.primary}`,tokens:a},extraction:c}}function fd(t,e,r,i,n){let a=[],s=[...t.roles.filter(c=>c.required)].sort((c,d)=>{let m=c.sovPosition??999,p=d.sovPosition??999;return m-p});for(let c of s){a.push({type:"role",role:c.role,optional:false});let{marker:d,alternatives:m}=dr(c,e);d&&a.push(m?{type:"literal",value:d,alternatives:m}:{type:"literal",value:d});}if(a.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),a.push({type:"role",role:"event",optional:false}),i.position==="after"){let c=i.primary.split(/\s+/);if(c.length>1)for(let d of c)a.push({type:"literal",value:d});else a.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}let u=s.map(c=>`{${c.role}}`).join(" "),l={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))};return Tr(a,l,t),{id:`${t.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`${u} ${r.primary} {event} ${i.primary}`,tokens:a},extraction:l}}function yd(t,e,r,i,n){let a=[],s=[...t.roles.filter(v=>v.required)].sort((v,h)=>{let E=v.sovPosition??999,z=h.sovPosition??999;return E-z}),u=s[0];a.push({type:"role",role:u.role,optional:false});let{marker:l,alternatives:c}=dr(u,e);if(l){let v=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};a.push(v);}if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let v=i.primary.split(/\s+/);if(v.length>1)for(let h of v)a.push({type:"literal",value:h});else {let h=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(h);}}let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(d);let m=s[1];a.push({type:"role",role:m.role,optional:false});let{marker:p,alternatives:f}=dr(m,e);if(p){let v=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};a.push(v);}let y={action:{value:t.action},event:{fromRole:"event"},[u.role]:{fromRole:u.role},[m.role]:{fromRole:m.role}};return Tr(a,y,t),{id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{${u.role}} {event} ${i.primary} ${r.primary} {${m.role}}`,tokens:a},extraction:y}}function Kn(t,e,r){let i=Ne(t,e.code,r.primary)??[],n=[...new Set([...r.alternatives??[],...i])].filter(a=>a!==r.primary);return n.length?n:void 0}function Oi(t,e,r,i,n){let a=[];if(i.position==="before"){let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=Vn(t);a.push(...Wn(t,e,s));let u=e.roleMarkers.destination,l=t.roles.some(d=>d.role==="destination");u&&l&&s!=="destination"&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),s!=="source"&&a.push(...Je(t,e.roleMarkers.source));let c={action:{value:t.action},event:{fromRole:"event"},[s]:{fromRole:s},...s==="destination"?{}:Ye(t),...s==="source"?{}:Xe(t)};return qn(a,c,t,e,new Set(["event",s,"destination","source"])),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`${i.primary} {event} ${r.primary} {${s}} ${u?.primary||""} {destination?}`,tokens:a},extraction:c}}function hd(t,e,r,i,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=t.action==="swap";a.push({type:"role",role:s?"destination":"patient",optional:false});let u=s?void 0:e.roleMarkers.destination;if(u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...Je(t,e.roleMarkers.source)),i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}if(a.push({type:"role",role:"event",optional:false}),s){let c=t.roles.find(d=>d.role==="patient")?.markerOverride?.[e.code];c&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:c},{type:"role",role:"patient",optional:false}]});}let l={action:{value:t.action},event:{fromRole:"event"},[s?"destination":"patient"]:{fromRole:s?"destination":"patient"},...s?{}:Ye(t),...Xe(t)};return Rt(a,l,t,e.code),{id:`${t.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${i.primary} {event}`,tokens:a},extraction:l}}function vd(t,e,r,i,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.svoPosition??999,f=m.svoPosition??999;return p-f});for(let d of u){let m,p;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)m=d.markerOverride[e.code],p=m?Ne(d,e.code,m):void 0;else {let f=e.roleMarkers[d.role];f&&(m=f.primary,p=Kn(d,e,f));}if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}a.push({type:"role",role:d.role,optional:false});}if(i.position==="before"){let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let l=u.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(d=>[d.role,{fromRole:d.role}]))};return Tr(a,c,t),{id:`${t.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${r.primary} ${l} ${i.primary} {event}`,tokens:a},extraction:c}}function Ri(t,e,r,i,n){let a=[];if(i.position==="before"){let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.svoPosition??999,f=m.svoPosition??999;return p-f});for(let d of u){let m,p;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)m=d.markerOverride[e.code],p=m?Ne(d,e.code,m):void 0;else {let f=e.roleMarkers[d.role];f&&(m=f.primary,p=Kn(d,e,f));}if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}a.push({type:"role",role:d.role,optional:false});}let l=u.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(d=>[d.role,{fromRole:d.role}]))};return Tr(a,c,t),{id:`${t.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`${i.primary} {event} ${r.primary} ${l}`,tokens:a},extraction:c}}function Ed(t,e,r,i,n){let a=[],o=e.eventHandler?.negationMarker;if(i.position==="before"){let l=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}a.push({type:"role",role:"event",optional:false});let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(s),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...Je(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${i.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ye(t),...Xe(t)}}}function gd(t,e,r,i){let n=[];n.push({type:"literal",value:"and",alternatives:["then"]}),n.push({type:"role",role:"event",optional:false});let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(a),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&n.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),n.push(...Je(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ye(t),...Xe(t)}}}var pr={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function kr(t,e,r=pr){let i=`${t.action}-${e.code}-generated`,n=r.basePriority??100,a=e.keywords[t.action];if(!a)throw new Error(`No keyword translation for '${t.action}' in ${e.code}`);let o=bd(t,e,a),s=Pt(t,e),u=Sd(t,e,a);return {id:i,language:e.code,command:t.action,priority:n,template:{format:u,tokens:o},extraction:s}}function zd(t,e,r=pr){if(t.roles.filter(s=>!s.required).length===0)return null;let n=t.roles.filter(s=>s.required),a={...t,roles:n};return {...kr(a,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:Pt(t,e)}}function Pi(t,e,r=pr){if(e.wordOrder!=="SOV")return null;let i=t.roles.filter(s=>s.required);if(i.length!==1)return null;let n=e.keywords[t.action];if(!n)return null;let a=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary},o=i.flatMap(s=>{let u=s.valuePrefixLiteral?.[e.code],l={type:"role",role:s.role,optional:false,expectedTypes:s.expectedTypes};return u?[{type:"literal",value:u},l]:[l]});return {id:`${t.action}-${e.code}-generated-verb-first`,language:e.code,command:t.action,priority:(r.basePriority??100)-20,template:{format:`${n.primary} <${i[0].role}>`,tokens:[a,...o]},extraction:Pt(t,e)}}function wd(t,e,r=pr){let i=[];if(i.push(kr(t,e,r)),r.generateSimpleVariants){let n=zd(t,e,r);n&&i.push(n);}for(let n of t.omitRoleVariants??[]){let a={...t,roles:t.roles.filter(s=>s.role!==n)},o=kr(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-no-${n}`,priority:(r.basePriority??100)-8});}for(let n of t.widenTypeVariants??[]){if(n.excludeLanguages?.includes(e.code))continue;let a={...t,roles:t.roles.map(s=>s.role===n.role?{...s,expectedTypes:[...n.types]}:s)},o=kr(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)-(n.priorityDelta??15)});}if(r.generateVerbFirstVariants!==false){let n=Pi(t,e,r);n&&i.push(n);}for(let n of t.rolePrefixLiteralVariants??[]){let a=n.literal[e.code];if(!a)continue;let{rolePrefixLiteralVariants:o,...s}=t,u={...s,roles:t.roles.map(m=>m.role===n.role?{...m,valuePrefixLiteral:{[e.code]:a}}:m)},l=n.priorityDelta??5,c=n.methodCarrier?{[n.methodCarrier]:{value:a}}:{},d=kr(u,e,r);if(i.push({...d,id:`${t.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)+l,extraction:{...d.extraction,...c}}),r.generateVerbFirstVariants!==false){let m=Pi(u,e,r);m&&i.push({...m,id:`${t.action}-${e.code}-generated-verb-first-${n.idSuffix}`,priority:(r.basePriority??100)-20+l,extraction:{...m.extraction,...c}});}}return i}function Hn(t,e=pr){let r=[],i=Ms();for(let n of i){if(!t.keywords[n.action])continue;let a=wd(n,t,e);if(r.push(...a),t.eventHandler?.eventMarker){let o=kd(n,t,e);r.push(...o);}}return r}function kd(t,e,r=pr){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let i=[],n=e.eventHandler.eventMarker,a=e.keywords[t.action];if(!a)return [];if(t.roles.length===0)return [];if(t.action==="js")return [];let s=t.roles.filter(u=>u.required).length===2;if(e.wordOrder==="SOV")if(s)i.push(pd(t,e,a,n,r)),i.push(yd(t,e,a,n,r)),i.push(fd(t,e,a,n,r));else {i.push(od(t,e,a,n,r)),i.push(sd(t,e,a,n,r));let u=ud(t,e,a,n,r);u&&i.push(u);let l=e.roleMarkers.destination;l&&l.primary!==n.primary&&i.push(ld(t,e,a,n,r));let c=n.primary.split(/\s+/),d=n.alternatives?.some(p=>!p.includes(" ")&&p.length>1);c.length>1&&d&&i.push(cd(t,e,a,n,r)),i.push(dd(t,e,a,n,r));let m=md(t,e,a,r);m&&i.push(m);}else e.wordOrder==="VSO"?s?(i.push(Ri(t,e,a,n,r)),i.push(vd(t,e,a,n,r))):(i.push(Oi(t,e,a,n,r)),i.push(hd(t,e,a,n,r)),e.eventHandler?.negationMarker&&i.push(Ed(t,e,a,n,r)),e.tokenization?.prefixes&&i.push(gd(t,e,a,r))):s?i.push(Ri(t,e,a,n,r)):i.push(Oi(t,e,a,n,r));return i}function bd(t,e,r){let i=[],n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=Ad(t,e);switch(e.wordOrder){case "SVO":i.push(n),i.push(...a);break;case "SOV":i.push(...a),i.push(n);break;case "VSO":i.push(n),i.push(...a);break;default:i.push(n),i.push(...a);}return Cd(i)}function Cd(t){let e=[];for(let r of t){let i=e[e.length-1];if(i&&i.type==="literal"&&r.type==="literal"&&i.value===r.value){let n=[...i.alternatives??[],...r.alternatives??[]];n.length&&(e[e.length-1]={...i,alternatives:[...new Set(n)]});continue}e.push(r);}return e}function Ad(t,e){let r=[],i=In(t.roles,e.wordOrder);for(let n of i){let a=Un(n,e);n.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function Un(t,e){let r=[],i=t.markerOverride?.[e.code],n=e.roleMarkers[t.role],a=t.renderOverride?.[e.code]==="",o={type:"role",role:t.role,optional:!t.required,expectedTypes:t.expectedTypes,...t.valueShape!==void 0?{valueShape:t.valueShape}:{}},s=t.valuePrefixLiteral?.[e.code],u=()=>{s&&r.push({type:"literal",value:s}),r.push(o);};if(i!==void 0){let l=i?i.split(/\s+/).filter(Boolean):[],c=i!==void 0&&i===t.markerOverride?.en,d=n?.position??(e.wordOrder==="SOV"&&!c?"after":"before"),m=t.markerOptional?.[e.code]===true,p=f=>{let y=l.length===1?Ne(t,e.code,f)??[]:[],v={type:"literal",value:f,...y.length?{alternatives:y}:{},...a?{renderSuppress:true}:{}};r.push(m?{type:"group",optional:true,tokens:[v]}:v);};if(d==="before"){for(let f of l)p(f);u();}else {u();for(let f of l)p(f);}}else if(n){let l=()=>{let d=[...new Set([...n.alternatives??[],...Ne(t,e.code,n.primary)??[]])].filter(m=>m!==n.primary);return {type:"literal",value:n.primary,...d.length?{alternatives:d}:{},...a?{renderSuppress:true}:{}}},c=d=>{if(!e.markersOptional&&!t.markerOptional?.[e.code]){r.push(d);return}r.push({type:"group",optional:true,...e.markersOptional&&!t.markerOptional?.[e.code]?{renderRequired:true}:{},tokens:[d]});};n.position==="before"?(n.primary&&c(l()),u()):(u(),c(l()));}else u();return r}function xd(t,e){let r={};for(let i of t.roles){let n=i.markerOverride?.[e.code],a=e.roleMarkers[i.role];if(i.valuePrefixLiteral?.[e.code])r[i.role]={marker:i.valuePrefixLiteral[e.code]};else if(n!==void 0)if(!n)r[i.role]={};else {let s=!/\s/.test(n.trim())?Ne(i,e.code,n)??[]:[];r[i.role]=s.length?{marker:n,markerAlternatives:s}:{marker:n};}else if(a&&a.primary){let o=[...new Set([...a.alternatives??[],...Ne(i,e.code,a.primary)??[]])].filter(s=>s!==a.primary);r[i.role]=o.length?{marker:a.primary,markerAlternatives:o}:{marker:a.primary};}else r[i.role]={};}return r}function Pt(t,e){let r=xd(t,e),i={};for(let n of t.roles){let a=r[n.role]||{};!n.required&&n.default?i[n.role]={...a,default:n.default}:i[n.role]=a;}return i}function Sd(t,e,r){let i=[],a=In(t.roles,e.wordOrder).map(o=>{let s=zu(o,e),u="";return s&&s.primary?s.position==="before"?u=`${s.primary} {${o.role}}`:u=`{${o.role}} ${s.primary}`:u=`{${o.role}}`,o.required?u:`[${u}]`});switch(e.wordOrder){case "SVO":case "VSO":i.push(r.primary,...a);break;case "SOV":i.push(...a,r.primary);break;default:i.push(r.primary,...a);}return i.join(" ")}var Dd=class{constructor(t={}){this.cache=new Map,this.config={maxSize:t.maxSize??1e3,ttlMs:t.ttlMs??0,enabled:t.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(t,e){return `${e}:${t}`}isExpired(t){return this.config.ttlMs===0?false:Date.now()-t.createdAt>this.config.ttlMs}evictLRU(){let t=this.cache.keys().next().value;t!==void 0&&(this.cache.delete(t),this.stats.evictions++);}get(t,e){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(t,e),i=this.cache.get(r);if(!i){this.stats.misses++;return}if(this.isExpired(i)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),i.lastAccessed=Date.now(),this.cache.set(r,i),this.stats.hits++,i.result}set(t,e,r){if(!this.config.enabled||r!==null&&typeof r=="object"&&"confidence"in r&&r.confidence===0)return;let i=this.makeKey(t,e),n=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(i,{result:r,createdAt:n,lastAccessed:n});}has(t,e){if(!this.config.enabled)return false;let r=this.makeKey(t,e),i=this.cache.get(r);return i?this.isExpired(i)?(this.cache.delete(r),this.stats.expirations++,false):true:false}delete(t,e){let r=this.makeKey(t,e);return this.cache.delete(r)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let t=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:t>0?this.stats.hits/t:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(t){if(t.maxSize!==void 0)for(this.config.maxSize=t.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();t.ttlMs!==void 0&&(this.config.ttlMs=t.ttlMs),t.enabled!==void 0&&(this.config.enabled=t.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}};new Dd;function Bd(t){return /[\u00e1\u00e9\u00ed\u00f3\u00fa\u00fc\u00f1\u00c1\u00c9\u00cd\u00d3\u00da\u00dc\u00d1]/.test(t)}var Td=[{ending:"ando",stem:"ar",confidence:.88,type:"gerund"},{ending:"ado",stem:"ar",confidence:.88,type:"participle"},{ending:"ada",stem:"ar",confidence:.88,type:"participle"},{ending:"ados",stem:"ar",confidence:.88,type:"participle"},{ending:"adas",stem:"ar",confidence:.88,type:"participle"},{ending:"o",stem:"ar",confidence:.75,type:"present"},{ending:"as",stem:"ar",confidence:.82,type:"present"},{ending:"a",stem:"ar",confidence:.75,type:"present"},{ending:"amos",stem:"ar",confidence:.85,type:"present"},{ending:"\xE1is",stem:"ar",confidence:.85,type:"present"},{ending:"ais",stem:"ar",confidence:.82,type:"present"},{ending:"an",stem:"ar",confidence:.8,type:"present"},{ending:"\xE9",stem:"ar",confidence:.85,type:"past"},{ending:"aste",stem:"ar",confidence:.88,type:"past"},{ending:"\xF3",stem:"ar",confidence:.82,type:"past"},{ending:"amos",stem:"ar",confidence:.85,type:"past"},{ending:"asteis",stem:"ar",confidence:.88,type:"past"},{ending:"aron",stem:"ar",confidence:.88,type:"past"},{ending:"aba",stem:"ar",confidence:.88,type:"past"},{ending:"abas",stem:"ar",confidence:.88,type:"past"},{ending:"\xE1bamos",stem:"ar",confidence:.88,type:"past"},{ending:"abamos",stem:"ar",confidence:.85,type:"past"},{ending:"abais",stem:"ar",confidence:.88,type:"past"},{ending:"aban",stem:"ar",confidence:.88,type:"past"},{ending:"e",stem:"ar",confidence:.72,type:"subjunctive"},{ending:"es",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"emos",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"\xE9is",stem:"ar",confidence:.85,type:"subjunctive"},{ending:"eis",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"en",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"a",stem:"ar",confidence:.75,type:"imperative"},{ending:"ad",stem:"ar",confidence:.85,type:"imperative"},{ending:"ar",stem:"ar",confidence:.92,type:"dictionary"}],Fd=[{ending:"iendo",stem:"er",confidence:.88,type:"gerund"},{ending:"ido",stem:"er",confidence:.85,type:"participle"},{ending:"ida",stem:"er",confidence:.85,type:"participle"},{ending:"idos",stem:"er",confidence:.85,type:"participle"},{ending:"idas",stem:"er",confidence:.85,type:"participle"},{ending:"o",stem:"er",confidence:.72,type:"present"},{ending:"es",stem:"er",confidence:.78,type:"present"},{ending:"e",stem:"er",confidence:.72,type:"present"},{ending:"emos",stem:"er",confidence:.85,type:"present"},{ending:"\xE9is",stem:"er",confidence:.85,type:"present"},{ending:"eis",stem:"er",confidence:.82,type:"present"},{ending:"en",stem:"er",confidence:.78,type:"present"},{ending:"\xED",stem:"er",confidence:.85,type:"past"},{ending:"iste",stem:"er",confidence:.88,type:"past"},{ending:"i\xF3",stem:"er",confidence:.85,type:"past"},{ending:"io",stem:"er",confidence:.82,type:"past"},{ending:"imos",stem:"er",confidence:.85,type:"past"},{ending:"isteis",stem:"er",confidence:.88,type:"past"},{ending:"ieron",stem:"er",confidence:.88,type:"past"},{ending:"\xEDa",stem:"er",confidence:.88,type:"past"},{ending:"ia",stem:"er",confidence:.85,type:"past"},{ending:"\xEDas",stem:"er",confidence:.88,type:"past"},{ending:"ias",stem:"er",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"er",confidence:.88,type:"past"},{ending:"iamos",stem:"er",confidence:.85,type:"past"},{ending:"\xEDais",stem:"er",confidence:.88,type:"past"},{ending:"iais",stem:"er",confidence:.85,type:"past"},{ending:"\xEDan",stem:"er",confidence:.88,type:"past"},{ending:"ian",stem:"er",confidence:.85,type:"past"},{ending:"er",stem:"er",confidence:.92,type:"dictionary"}],Od=[{ending:"iendo",stem:"ir",confidence:.88,type:"gerund"},{ending:"ido",stem:"ir",confidence:.85,type:"participle"},{ending:"ida",stem:"ir",confidence:.85,type:"participle"},{ending:"idos",stem:"ir",confidence:.85,type:"participle"},{ending:"idas",stem:"ir",confidence:.85,type:"participle"},{ending:"o",stem:"ir",confidence:.72,type:"present"},{ending:"es",stem:"ir",confidence:.78,type:"present"},{ending:"e",stem:"ir",confidence:.72,type:"present"},{ending:"imos",stem:"ir",confidence:.85,type:"present"},{ending:"\xEDs",stem:"ir",confidence:.85,type:"present"},{ending:"is",stem:"ir",confidence:.82,type:"present"},{ending:"en",stem:"ir",confidence:.78,type:"present"},{ending:"\xED",stem:"ir",confidence:.85,type:"past"},{ending:"iste",stem:"ir",confidence:.88,type:"past"},{ending:"i\xF3",stem:"ir",confidence:.85,type:"past"},{ending:"io",stem:"ir",confidence:.82,type:"past"},{ending:"imos",stem:"ir",confidence:.85,type:"past"},{ending:"isteis",stem:"ir",confidence:.88,type:"past"},{ending:"ieron",stem:"ir",confidence:.88,type:"past"},{ending:"\xEDa",stem:"ir",confidence:.88,type:"past"},{ending:"ia",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDas",stem:"ir",confidence:.88,type:"past"},{ending:"ias",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"ir",confidence:.88,type:"past"},{ending:"iamos",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDais",stem:"ir",confidence:.88,type:"past"},{ending:"iais",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDan",stem:"ir",confidence:.88,type:"past"},{ending:"ian",stem:"ir",confidence:.85,type:"past"},{ending:"ir",stem:"ir",confidence:.92,type:"dictionary"}],Rd=[...Td,...Fd,...Od].sort((t,e)=>e.ending.length-t.ending.length),Yn=class extends Zt{constructor(){super({language:"es",minWordLength:3,minStemLength:2,endings:Rd,reflexiveSuffixes:["se","me","te","nos","os"],infinitiveEndings:["ar","er","ir"]});}isNormalizable(t){if(t.length<3)return false;let e=t.toLowerCase();if(e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir")||e.endsWith("ando")||e.endsWith("iendo")||e.endsWith("ado")||e.endsWith("ido")||e.endsWith("arse")||e.endsWith("erse")||e.endsWith("irse"))return true;for(let r of t)if(Bd(r))return true;return false}};new Yn;var Xn={code:"es",name:"Spanish",nativeName:"Espa\xF1ol",regions:["western","priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:true},references:{me:"yo",it:"ello",you:"t\xFA",result:"resultado",event:"evento",target:"objetivo",body:"cuerpo",document:"documento",window:"ventana",detail:"detalle"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"mi",it:"su",you:"tu"},keywords:{mi:"me",tu:"you",su:"it"}},roleMarkers:{destination:{primary:"en",alternatives:["sobre","a","hacia"],position:"before"},source:{primary:"de",alternatives:["desde"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"con",position:"before"}},keywords:{toggle:{primary:"alternar",alternatives:["conmutar","toggle"],normalized:"toggle"},add:{primary:"agregar",alternatives:["a\xF1adir"],normalized:"add"},remove:{primary:"quitar",alternatives:["eliminar","remover","sacar","borrar"],normalized:"remove"},put:{primary:"poner",alternatives:["colocar","pon"],normalized:"put"},append:{primary:"anexar",normalized:"append"},prepend:{primary:"anteponer",normalized:"prepend"},take:{primary:"tomar",normalized:"take"},make:{primary:"hacer",alternatives:["crear"],normalized:"make"},clone:{primary:"clonar",alternatives:["duplicar"],normalized:"clone"},swap:{primary:"intercambiar",alternatives:["permutar"],normalized:"swap"},morph:{primary:"transformar",alternatives:["convertir"],normalized:"morph"},set:{primary:"establecer",alternatives:["fijar","definir","establece"],normalized:"set"},get:{primary:"obtener",alternatives:["conseguir","obt\xE9n"],normalized:"get"},increment:{primary:"incrementar",alternatives:["aumentar"],normalized:"increment"},decrement:{primary:"decrementar",alternatives:["disminuir"],normalized:"decrement"},log:{primary:"registrar",alternatives:["imprimir"],normalized:"log"},show:{primary:"mostrar",alternatives:["ense\xF1ar","muestra"],normalized:"show"},hide:{primary:"ocultar",alternatives:["esconder"],normalized:"hide"},transition:{primary:"transici\xF3n",alternatives:["animar"],normalized:"transition"},on:{primary:"en",alternatives:["al"],normalized:"on"},trigger:{primary:"disparar",alternatives:["activar"],normalized:"trigger"},send:{primary:"enviar",alternatives:["env\xEDa"],normalized:"send"},focus:{primary:"enfoque",alternatives:["enfocar"],normalized:"focus"},blur:{primary:"p\xE9rdida de foco",alternatives:["perdida de foco","desenfoque","desenfocar"],normalized:"blur"},open:{primary:"abrir",normalized:"open"},close:{primary:"cerrar",normalized:"close"},select:{primary:"seleccionar",normalized:"select"},clear:{primary:"limpiar",normalized:"clear"},reset:{primary:"reiniciar",alternatives:["restablecer"],normalized:"reset"},breakpoint:{primary:"punto-interrupci\xF3n",alternatives:["punto-interrupcion"],normalized:"breakpoint"},click:{primary:"clic",alternatives:["hacer clic","click"],normalized:"click"},resize:{primary:"cambio de tama\xF1o",alternatives:["cambio de tamano","redimensionar"],normalized:"resize"},hover:{primary:"sobrevolar",alternatives:["pasar por encima"],normalized:"hover"},submit:{primary:"env\xEDo",alternatives:["envio","someter"],normalized:"submit"},input:{primary:"entrada",alternatives:["introducir"],normalized:"input"},change:{primary:"cambio",alternatives:["cambiar"],normalized:"change"},load:{primary:"carga",alternatives:["cargar"],normalized:"load"},scroll:{primary:"desplazamiento",alternatives:["desplazar"],normalized:"scroll"},keydown:{primary:"tecla pulsada",alternatives:["tecla presionada","tecla abajo"],normalized:"keydown"},keyup:{primary:"tecla soltada",alternatives:["tecla liberada","tecla arriba"],normalized:"keyup"},mouseover:{primary:"rat\xF3n encima",alternatives:["raton encima","mouse encima"],normalized:"mouseover"},mouseout:{primary:"rat\xF3n fuera",alternatives:["raton fuera","mouse fuera"],normalized:"mouseout"},mousedown:{primary:"rat\xF3n pulsado",alternatives:["raton pulsado","mouse presionado","rat\xF3n abajo","raton abajo","rat\xF3nabajo"],normalized:"mousedown"},mouseup:{primary:"rat\xF3n soltado",alternatives:["raton soltado","mouse soltado","rat\xF3n arriba","raton arriba","rat\xF3narriba"],normalized:"mouseup"},go:{primary:"ir",alternatives:["navegar","ve"],normalized:"go"},push:{primary:"empujar",alternatives:["push"],normalized:"push"},replace:{primary:"reemplazar",alternatives:["sustituir"],normalized:"replace"},process:{primary:"procesar",normalized:"process"},wait:{primary:"esperar",normalized:"wait"},fetch:{primary:"buscar",alternatives:["recuperar"],normalized:"fetch"},settle:{primary:"estabilizar",normalized:"settle"},if:{primary:"si",normalized:"if"},unless:{primary:"menos",alternatives:["a menos que","salvo"],normalized:"unless"},when:{primary:"cuando",normalized:"when"},changes:{primary:"cambia",normalized:"changes"},where:{primary:"donde",normalized:"where"},else:{primary:"sino",alternatives:["de lo contrario"],normalized:"else"},repeat:{primary:"repetir",normalized:"repeat"},for:{primary:"para",normalized:"for"},while:{primary:"mientras",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"continuar",normalized:"continue"},halt:{primary:"detener",alternatives:["parar"],normalized:"halt"},throw:{primary:"lanzar",alternatives:["arrojar"],normalized:"throw"},call:{primary:"llamar",normalized:"call"},return:{primary:"retornar",alternatives:["devolver"],normalized:"return"},then:{primary:"entonces",alternatives:["luego"],normalized:"then"},and:{primary:"y",alternatives:["adem\xE1s","tambi\xE9n"],normalized:"and"},or:{primary:"o",normalized:"or"},not:{primary:"no",normalized:"not"},is:{primary:"es",normalized:"is"},exists:{primary:"existe",normalized:"exists"},empty:{primary:"vac\xEDo",alternatives:["vacio"],normalized:"empty"},matches:{primary:"coincide",normalized:"matches"},no:{primary:"ning\xFAn",normalized:"no"},end:{primary:"fin",alternatives:["final","terminar"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"as\xEDncrono",alternatives:["asincrono"],normalized:"async"},tell:{primary:"decir",normalized:"tell"},default:{primary:"predeterminar",alternatives:["por defecto"],normalized:"default"},init:{primary:"inicio",alternatives:["inicializaci\xF3n","iniciar","inicializar"],normalized:"init"},behavior:{primary:"comportamiento",normalized:"behavior"},install:{primary:"instalar",normalized:"install"},measure:{primary:"medir",normalized:"measure"},beep:{primary:"pitido",normalized:"beep"},break:{primary:"romper",normalized:"break"},copy:{primary:"copiar",normalized:"copy"},exit:{primary:"salir",normalized:"exit"},pick:{primary:"escoger",normalized:"pick"},render:{primary:"renderizar",normalized:"render"},first:{primary:"primero",alternatives:["primera"],normalized:"first"},last:{primary:"\xFAltimo",alternatives:["ultima"],normalized:"last"},next:{primary:"siguiente",normalized:"next"},previous:{primary:"anterior",normalized:"previous"},closest:{primary:"cercano",normalized:"closest"},parent:{primary:"padre",normalized:"parent"},into:{primary:"dentro",alternatives:["adentro","dentro de"],normalized:"into"},before:{primary:"antes",alternatives:["antes de"],normalized:"before"},after:{primary:"despu\xE9s",alternatives:["despues","despu\xE9s de","despues de"],normalized:"after"},out:{primary:"fuera",alternatives:["fuera de"],normalized:"out"},until:{primary:"hasta",alternatives:["hasta que"],normalized:"until"},event:{primary:"evento",normalized:"event"},from:{primary:"de",alternatives:["desde"],normalized:"from"},connect:{primary:"conectar",alternatives:["conectarse"],normalized:"connect"},stream:{primary:"transmitir",alternatives:["flujo"],normalized:"stream"},live:{primary:"en-vivo",alternatives:["vivo","directo"],normalized:"live"},socket:{primary:"socket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"vincular",alternatives:["enlazar","bind"],normalized:"bind"},intercept:{primary:"interceptar",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"trabajador",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["fuente-de-eventos"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"al",alternatives:["cuando","en"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["desde"],position:"before"},eventMarker:{primary:"al",alternatives:["cuando","en"],position:"before"},temporalMarkers:["cuando","al"]}},Pd=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Ld=class{constructor(t=Pd){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}},Nd="()[]{},:;",Md=class{constructor(t=Nd){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Lt(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function Gn(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Lt(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Lt(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Lt(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var _d=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Gn(t,e)!==null:false}extract(t,e){let r=Gn(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Id=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},$d=["http://","https://","//","./","../","/"];function jd(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function Vd(t,e){let r=t.slice(e),i=$d.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=jd(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var Wd=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=Vd(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},qd=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 Kd(){return [new Wd,new Id,new qd,new _d]}function Hd(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:Zn,isIdentifierChar:Ud}=Hd(/[a-zA-Z\u00e1\u00e9\u00ed\u00f3\u00fa\u00fc\u00f1\u00c1\u00c9\u00cd\u00d3\u00da\u00dc\u00d1]/),Gd=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),Zd=class{constructor(){this.name="spanish-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Zn(t[e])}extract(t,e){if(!this.context)throw new Error("SpanishKeywordExtractor: context not set");let r=this.tryMultiWordPhrase(t,e);return r||this.extractSpanishWord(t,e)}tryMultiWordPhrase(t,e){if(!this.context)return null;let r=["de lo contrario","de lo normal","por defecto","de nuevo","de otra manera"];for(let i of r)if(t.slice(e,e+i.length).toLowerCase()===i.toLowerCase()){let a=e+i.length;if(a>=t.length||He(t[a])||!Zn(t[a])){let o=this.context.lookupKeyword(i);return {value:t.slice(e,a),length:i.length,metadata:{normalized:o?.normalized,multiWord:true}}}}return null}extractSpanishWord(t,e){if(!this.context)return null;let r=e,i="";for(;r<t.length&&Ud(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=Gd.has(n),o=this.context.lookupKeyword(i),s=o&&o.normalized!==o.native?o.normalized:void 0,u,l,c;if(!o&&this.context.normalizer){let d=this.context.normalizer.normalize(i);if(d.stem!==i&&d.confidence>=.7){let m=this.context.lookupKeyword(d.stem);m&&(u=m.normalized,l=d.stem,c=d.confidence);}}return {value:i,length:r-e,metadata:{normalized:s||u,stem:l,stemConfidence:c,isPreposition:a}}}};function Yd(){return [new Zd]}var Xd=new Set(["en","a","de","desde","hasta","con","sin","por","para","sobre","entre","antes","despu\xE9s","despues","dentro","fuera","al","del"]),Jd=[{native:"verdadero",normalized:"true"},{native:"falso",normalized:"false"},{native:"nulo",normalized:"null"},{native:"indefinido",normalized:"undefined"},{native:"segundo",normalized:"s"},{native:"segundos",normalized:"s"},{native:"milisegundo",normalized:"ms"},{native:"milisegundos",normalized:"ms"},{native:"minuto",normalized:"m"},{native:"minutos",normalized:"m"},{native:"hora",normalized:"h"},{native:"horas",normalized:"h"},{native:"m\xED",normalized:"me"},{native:"destino",normalized:"target"},{native:"inclusivo",normalized:"inclusive"},{native:"exclusivo",normalized:"exclusive"},{native:"caracteres",normalized:"characters"},{native:"aleatorio",normalized:"random"}],Qd=class extends $e{constructor(){super(),this.language="es",this.direction="ltr",this.initializeKeywordsFromProfile(Xn,Jd),this.setNormalizer(new Yn),this.registerExtractors(Kd()),this.registerExtractor(new _e),this.registerExtractor(new Ie),this.registerExtractors(Yd()),this.registerExtractor(new Ld),this.registerExtractor(new Md);}classifyToken(t){let e=t.toLowerCase();return Xd.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"}},em=new Qd;qe("es",em,Xn);var ea={code:"pt",name:"Portuguese",nativeName:"Portugu\xEAs",regions:["western","priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,verb:{position:"start",subjectDrop:true},references:{me:"eu",it:"ele",you:"voc\xEA",result:"resultado",event:"evento",target:"alvo",body:"corpo",document:"documento",window:"janela",detail:"detalhe"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"meu",it:"seu",you:"teu"},keywords:{meu:"me",minha:"me",teu:"you",tua:"you",seu:"it",sua:"it"}},roleMarkers:{destination:{primary:"em",alternatives:["para","a"],position:"before"},source:{primary:"de",alternatives:["desde"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"com",position:"before"}},keywords:{toggle:{primary:"alternar",alternatives:[],normalized:"toggle"},add:{primary:"adicionar",alternatives:["acrescentar"],normalized:"add"},remove:{primary:"remover",alternatives:["eliminar","apagar","remova"],normalized:"remove"},put:{primary:"colocar",alternatives:["p\xF4r","por","coloque"],normalized:"put"},append:{primary:"anexar",normalized:"append"},prepend:{primary:"preceder",normalized:"prepend"},take:{primary:"pegar",alternatives:["pegue"],normalized:"take"},make:{primary:"fazer",alternatives:["criar"],normalized:"make"},clone:{primary:"clonar",alternatives:[],normalized:"clone"},swap:{primary:"trocar",alternatives:["substituir"],normalized:"swap"},morph:{primary:"transformar",alternatives:["converter"],normalized:"morph"},set:{primary:"definir",alternatives:["configurar","defina"],normalized:"set"},get:{primary:"obter",alternatives:["obtenha"],normalized:"get"},increment:{primary:"incrementar",alternatives:["aumentar"],normalized:"increment"},decrement:{primary:"decrementar",alternatives:["diminuir"],normalized:"decrement"},log:{primary:"registrar",alternatives:["imprimir"],normalized:"log"},show:{primary:"mostrar",alternatives:["exibir"],normalized:"show"},hide:{primary:"ocultar",alternatives:["esconder","esconda"],normalized:"hide"},transition:{primary:"transi\xE7\xE3o",alternatives:["animar"],normalized:"transition"},on:{primary:"em",alternatives:["ao"],normalized:"on"},trigger:{primary:"disparar",alternatives:["ativar"],normalized:"trigger"},send:{primary:"enviar",normalized:"send"},focus:{primary:"foco",alternatives:["focar"],normalized:"focus"},blur:{primary:"perda de foco",alternatives:["desfocar"],normalized:"blur"},empty:{primary:"esvaziar",alternatives:["vazio"],normalized:"empty"},open:{primary:"abrir",normalized:"open"},close:{primary:"fechar",normalized:"close"},select:{primary:"selecionar",normalized:"select"},clear:{primary:"limpar",normalized:"clear"},reset:{primary:"redefinir",alternatives:["resetar"],normalized:"reset"},breakpoint:{primary:"ponto-interrup\xE7\xE3o",alternatives:["ponto-interrupcao"],normalized:"breakpoint"},go:{primary:"ir",alternatives:["navegar","v\xE1"],normalized:"go"},scroll:{primary:"rolagem",alternatives:["rolar","deslocamento","scroll"],normalized:"scroll"},push:{primary:"empurrar",alternatives:["push"],normalized:"push"},replace:{primary:"repor",alternatives:["recolocar"],normalized:"replace"},process:{primary:"processar",normalized:"process"},wait:{primary:"esperar",alternatives:["aguardar"],normalized:"wait"},fetch:{primary:"buscar",alternatives:["busque"],normalized:"fetch"},settle:{primary:"estabilizar",normalized:"settle"},if:{primary:"se",normalized:"if"},unless:{primary:"salvo",alternatives:["a_menos"],normalized:"unless"},when:{primary:"quando",normalized:"when"},changes:{primary:"muda",normalized:"changes"},where:{primary:"onde",normalized:"where"},else:{primary:"sen\xE3o",normalized:"else"},repeat:{primary:"repetir",normalized:"repeat"},for:{primary:"para",normalized:"for"},while:{primary:"enquanto",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"continuar",normalized:"continue"},halt:{primary:"parar",normalized:"halt"},throw:{primary:"lan\xE7ar",normalized:"throw"},call:{primary:"chamar",normalized:"call"},return:{primary:"retornar",alternatives:["devolver"],normalized:"return"},then:{primary:"ent\xE3o",alternatives:["logo"],normalized:"then"},and:{primary:"e",alternatives:["tamb\xE9m","al\xE9m disso"],normalized:"and"},matches:{primary:"corresponde",normalized:"matches"},exists:{primary:"existe",normalized:"exists"},is:{primary:"\xE9",normalized:"is"},no:{primary:"nenhum",normalized:"no"},end:{primary:"fim",alternatives:["final","t\xE9rmino"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"ass\xEDncrono",normalized:"async"},tell:{primary:"dizer",normalized:"tell"},default:{primary:"padr\xE3o",normalized:"default"},init:{primary:"inicializa\xE7\xE3o",alternatives:["iniciar","inicializar"],normalized:"init"},behavior:{primary:"comportamento",normalized:"behavior"},install:{primary:"instalar",normalized:"install"},measure:{primary:"medir",normalized:"measure"},beep:{primary:"apitar",normalized:"beep"},break:{primary:"interromper",normalized:"break"},copy:{primary:"copiar",normalized:"copy"},exit:{primary:"sair",normalized:"exit"},pick:{primary:"escolher",normalized:"pick"},render:{primary:"renderizar",normalized:"render"},into:{primary:"dentro",alternatives:["dentro de"],normalized:"into"},before:{primary:"antes",normalized:"before"},after:{primary:"depois",normalized:"after"},click:{primary:"clique",alternatives:["clicar"],normalized:"click"},resize:{primary:"redimensionamento",alternatives:["redimensionar"],normalized:"resize"},hover:{primary:"sobrevoar",alternatives:["passar"],normalized:"hover"},submit:{primary:"envio",alternatives:["submeter","submiss\xE3o"],normalized:"submit"},input:{primary:"entrada",alternatives:["inser\xE7\xE3o"],normalized:"input"},change:{primary:"altera\xE7\xE3o",alternatives:["mudan\xE7a"],normalized:"change"},mousedown:{primary:"mouse pressionado",alternatives:["rato pressionado","mouse baixo","mouseBaixo"],normalized:"mousedown"},mouseup:{primary:"mouse solto",alternatives:["mouse liberado","rato libertado","mouse cima","mouseCima"],normalized:"mouseup"},until:{primary:"at\xE9",normalized:"until"},event:{primary:"evento",normalized:"event"},from:{primary:"de",alternatives:["desde"],normalized:"from"},connect:{primary:"conectar",alternatives:["conex\xE3o"],normalized:"connect"},stream:{primary:"transmitir",alternatives:["fluxo"],normalized:"stream"},live:{primary:"ao-vivo",alternatives:["vivo","direto"],normalized:"live"},socket:{primary:"soquete",alternatives:["websocket"],normalized:"socket"},bind:{primary:"vincular",alternatives:["ligar","bind"],normalized:"bind"},intercept:{primary:"interceptar",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"trabalhador",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["fonte-de-eventos"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"em",alternatives:["ao"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["desde"],position:"before"},conditionalKeyword:{primary:"quando",alternatives:["se"]},eventMarker:{primary:"ao",alternatives:["no","em"],position:"before"},temporalMarkers:["quando","ao"]}};function rm(t){return /[\u00e1\u00e0\u00e2\u00e3\u00e9\u00ea\u00ed\u00f3\u00f4\u00f5\u00fa\u00fc\u00e7\u00c1\u00c0\u00c2\u00c3\u00c9\u00ca\u00cd\u00d3\u00d4\u00d5\u00da\u00dc\u00c7]/.test(t)}function tm(t){let e=t.toLowerCase();if(e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir")||e.endsWith("ando")||e.endsWith("endo")||e.endsWith("indo")||e.endsWith("ado")||e.endsWith("ido")||e.endsWith("ar-se")||e.endsWith("er-se")||e.endsWith("ir-se"))return true;for(let r of t)if(rm(r))return true;return false}var Jn=["-se","-me","-te","-nos","-vos"],im=[{ending:"ando",stem:"ar",confidence:.88,type:"gerund"},{ending:"ado",stem:"ar",confidence:.88,type:"participle"},{ending:"ada",stem:"ar",confidence:.88,type:"participle"},{ending:"ados",stem:"ar",confidence:.88,type:"participle"},{ending:"adas",stem:"ar",confidence:.88,type:"participle"},{ending:"o",stem:"ar",confidence:.75,type:"present"},{ending:"as",stem:"ar",confidence:.82,type:"present"},{ending:"a",stem:"ar",confidence:.75,type:"present"},{ending:"amos",stem:"ar",confidence:.85,type:"present"},{ending:"ais",stem:"ar",confidence:.85,type:"present"},{ending:"am",stem:"ar",confidence:.8,type:"present"},{ending:"ei",stem:"ar",confidence:.88,type:"past"},{ending:"aste",stem:"ar",confidence:.88,type:"past"},{ending:"ou",stem:"ar",confidence:.88,type:"past"},{ending:"\xE1mos",stem:"ar",confidence:.88,type:"past"},{ending:"amos",stem:"ar",confidence:.85,type:"past"},{ending:"astes",stem:"ar",confidence:.88,type:"past"},{ending:"aram",stem:"ar",confidence:.88,type:"past"},{ending:"ava",stem:"ar",confidence:.88,type:"past"},{ending:"avas",stem:"ar",confidence:.88,type:"past"},{ending:"\xE1vamos",stem:"ar",confidence:.88,type:"past"},{ending:"avamos",stem:"ar",confidence:.85,type:"past"},{ending:"\xE1veis",stem:"ar",confidence:.88,type:"past"},{ending:"aveis",stem:"ar",confidence:.85,type:"past"},{ending:"avam",stem:"ar",confidence:.88,type:"past"},{ending:"e",stem:"ar",confidence:.72,type:"subjunctive"},{ending:"es",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"emos",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"eis",stem:"ar",confidence:.82,type:"subjunctive"},{ending:"em",stem:"ar",confidence:.78,type:"subjunctive"},{ending:"a",stem:"ar",confidence:.75,type:"imperative"},{ending:"ai",stem:"ar",confidence:.85,type:"imperative"},{ending:"ar",stem:"ar",confidence:.92,type:"dictionary"}],nm=[{ending:"endo",stem:"er",confidence:.88,type:"gerund"},{ending:"ido",stem:"er",confidence:.85,type:"participle"},{ending:"ida",stem:"er",confidence:.85,type:"participle"},{ending:"idos",stem:"er",confidence:.85,type:"participle"},{ending:"idas",stem:"er",confidence:.85,type:"participle"},{ending:"o",stem:"er",confidence:.72,type:"present"},{ending:"es",stem:"er",confidence:.78,type:"present"},{ending:"e",stem:"er",confidence:.72,type:"present"},{ending:"emos",stem:"er",confidence:.85,type:"present"},{ending:"eis",stem:"er",confidence:.82,type:"present"},{ending:"em",stem:"er",confidence:.78,type:"present"},{ending:"i",stem:"er",confidence:.85,type:"past"},{ending:"este",stem:"er",confidence:.88,type:"past"},{ending:"eu",stem:"er",confidence:.88,type:"past"},{ending:"emos",stem:"er",confidence:.85,type:"past"},{ending:"estes",stem:"er",confidence:.88,type:"past"},{ending:"eram",stem:"er",confidence:.88,type:"past"},{ending:"ia",stem:"er",confidence:.85,type:"past"},{ending:"ias",stem:"er",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"er",confidence:.88,type:"past"},{ending:"iamos",stem:"er",confidence:.85,type:"past"},{ending:"\xEDeis",stem:"er",confidence:.88,type:"past"},{ending:"ieis",stem:"er",confidence:.85,type:"past"},{ending:"iam",stem:"er",confidence:.85,type:"past"},{ending:"er",stem:"er",confidence:.92,type:"dictionary"}],am=[{ending:"indo",stem:"ir",confidence:.88,type:"gerund"},{ending:"ido",stem:"ir",confidence:.85,type:"participle"},{ending:"ida",stem:"ir",confidence:.85,type:"participle"},{ending:"idos",stem:"ir",confidence:.85,type:"participle"},{ending:"idas",stem:"ir",confidence:.85,type:"participle"},{ending:"o",stem:"ir",confidence:.72,type:"present"},{ending:"es",stem:"ir",confidence:.78,type:"present"},{ending:"e",stem:"ir",confidence:.72,type:"present"},{ending:"imos",stem:"ir",confidence:.85,type:"present"},{ending:"is",stem:"ir",confidence:.82,type:"present"},{ending:"em",stem:"ir",confidence:.78,type:"present"},{ending:"i",stem:"ir",confidence:.85,type:"past"},{ending:"iste",stem:"ir",confidence:.88,type:"past"},{ending:"iu",stem:"ir",confidence:.88,type:"past"},{ending:"imos",stem:"ir",confidence:.85,type:"past"},{ending:"istes",stem:"ir",confidence:.88,type:"past"},{ending:"iram",stem:"ir",confidence:.88,type:"past"},{ending:"ia",stem:"ir",confidence:.85,type:"past"},{ending:"ias",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDamos",stem:"ir",confidence:.88,type:"past"},{ending:"iamos",stem:"ir",confidence:.85,type:"past"},{ending:"\xEDeis",stem:"ir",confidence:.88,type:"past"},{ending:"ieis",stem:"ir",confidence:.85,type:"past"},{ending:"iam",stem:"ir",confidence:.85,type:"past"},{ending:"ir",stem:"ir",confidence:.92,type:"dictionary"}],om=[...im,...nm,...am].sort((t,e)=>e.ending.length-t.ending.length),ra=class{constructor(){this.language="pt";}isNormalizable(t){return t.length<3?false:tm(t)}normalize(t){let e=t.toLowerCase();if((e.endsWith("ar")||e.endsWith("er")||e.endsWith("ir"))&&!Jn.some(n=>e.endsWith(n)))return be(t);let r=this.tryReflexiveNormalization(e);if(r)return r;let i=this.tryConjugationNormalization(e);return i||be(t)}tryReflexiveNormalization(t){for(let e of Jn)if(t.endsWith(e)){let r=t.slice(0,-e.length);if(r.endsWith("ar")||r.endsWith("er")||r.endsWith("ir"))return oe(r,.88,{removedSuffixes:[e],conjugationType:"reflexive"});let i=this.tryConjugationNormalization(r);if(i&&i.stem!==r)return oe(i.stem,i.confidence*.95,{removedSuffixes:[e,...i.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}tryConjugationNormalization(t){for(let e of om)if(t.endsWith(e.ending)){let r=t.slice(0,-e.ending.length);if(r.length<2)continue;let i=r+e.stem;return oe(i,e.confidence,{removedSuffixes:[e.ending],conjugationType:e.type})}return null}},sm=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],um=class{constructor(t=sm){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}},lm="()[]{},:;",cm=class{constructor(t=lm){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Nt(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function Qn(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Nt(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Nt(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Nt(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var dm=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Qn(t,e)!==null:false}extract(t,e){let r=Qn(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},mm=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},pm=["http://","https://","//","./","../","/"];function fm(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function ym(t,e){let r=t.slice(e),i=pm.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=fm(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var hm=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=ym(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},vm=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 Em(){return [new hm,new mm,new vm,new dm]}function gm(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:zm,isIdentifierChar:wm}=gm(/[a-zA-Z\u00e1\u00e2\u00e3\u00e9\u00ea\u00ed\u00f3\u00f4\u00f5\u00fa\u00e7\u00c1\u00c2\u00c3\u00c9\u00ca\u00cd\u00d3\u00d4\u00d5\u00da\u00c7]/),km=new Set(["em","a","de","para","com","sem","por","sobre","entre","antes","depois","dentro","fora","ao","do","da","no","na"]),bm=class{constructor(){this.name="portuguese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return zm(t[e])}extract(t,e){if(!this.context)throw new Error("PortugueseKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&wm(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=km.has(n),o=this.context.lookupKeyword(n),s=o&&o.normalized!==o.native?o.normalized:void 0,u,l,c;if(!o&&this.context.normalizer){let d=this.context.normalizer.normalize(i);if(d.stem!==i&&d.confidence>=.7){let m=this.context.lookupKeyword(d.stem);m&&(u=m.normalized,l=d.stem,c=d.confidence);}}return {value:i,length:r-e,metadata:{normalized:s||u,stem:l,stemConfidence:c,isPreposition:a}}}};function Cm(){return [new bm]}var Am=new Set(["em","a","de","desde","at\xE9","ate","com","sem","por","para","sobre","entre","antes","depois","dentro","fora","ao","do","no","na"]),xm=[{native:"verdadeiro",normalized:"true"},{native:"falso",normalized:"false"},{native:"nulo",normalized:"null"},{native:"indefinido",normalized:"undefined"},{native:"primeiro",normalized:"first"},{native:"primeira",normalized:"first"},{native:"\xFAltimo",normalized:"last"},{native:"ultima",normalized:"last"},{native:"pr\xF3ximo",normalized:"next"},{native:"proximo",normalized:"next"},{native:"anterior",normalized:"previous"},{native:"maispr\xF3ximo",normalized:"closest"},{native:"maisproximo",normalized:"closest"},{native:"pai",normalized:"parent"},{native:"clique",normalized:"click"},{native:"click",normalized:"click"},{native:"entrada",normalized:"input"},{native:"mudan\xE7a",normalized:"change"},{native:"mudanca",normalized:"change"},{native:"envio",normalized:"submit"},{native:"tecla baixo",normalized:"keydown"},{native:"tecla cima",normalized:"keyup"},{native:"mouse sobre",normalized:"mouseover"},{native:"mouse fora",normalized:"mouseout"},{native:"foco",normalized:"focus"},{native:"desfoque",normalized:"blur"},{native:"carregar",normalized:"load"},{native:"rolagem",normalized:"scroll"},{native:"meu",normalized:"my"},{native:"minha",normalized:"my"},{native:"isso",normalized:"it"},{native:"segundo",normalized:"s"},{native:"segundos",normalized:"s"},{native:"milissegundo",normalized:"ms"},{native:"milissegundos",normalized:"ms"},{native:"minuto",normalized:"m"},{native:"minutos",normalized:"m"},{native:"hora",normalized:"h"},{native:"horas",normalized:"h"},{native:"senao",normalized:"else"},{native:"transicao",normalized:"transition"},{native:"ate",normalized:"until"},{native:"entao",normalized:"then"},{native:"lancar",normalized:"throw"},{native:"assincrono",normalized:"async"},{native:"padrao",normalized:"default"},{native:"at\xE9 que",normalized:"until"},{native:"dentro de",normalized:"into"},{native:"inclusivo",normalized:"inclusive"},{native:"exclusivo",normalized:"exclusive"},{native:"caracteres",normalized:"characters"},{native:"aleat\xF3rio",normalized:"random"}],Sm=class extends $e{constructor(){super(),this.language="pt",this.direction="ltr",this.initializeKeywordsFromProfile(ea,xm),this.setNormalizer(new ra),this.registerExtractors(Em()),this.registerExtractor(new _e),this.registerExtractor(new Ie),this.registerExtractors(Cm()),this.registerExtractor(new um),this.registerExtractor(new cm);}classifyToken(t){let e=t.toLowerCase();return Am.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":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},Dm=new Sm;qe("pt",Dm,ea);var ia={code:"fr",name:"French",nativeName:"Fran\xE7ais",regions:["western","priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:false},references:{me:"moi",it:"il",you:"toi",result:"r\xE9sultat",event:"\xE9v\xE9nement",target:"cible",body:"corps",document:"document",window:"fen\xEAtre",detail:"d\xE9tail"},possessive:{marker:"de",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"ma",it:"sa",you:"ta"},keywords:{mon:"me",ma:"me",mes:"me",ton:"you",ta:"you",tes:"you",son:"it",sa:"it",ses:"it"}},roleMarkers:{destination:{primary:"sur",alternatives:["\xE0","dans"],position:"before"},source:{primary:"de",alternatives:["depuis"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"avec",position:"before"}},keywords:{toggle:{primary:"basculer",alternatives:["alterner"],normalized:"toggle"},add:{primary:"ajouter",normalized:"add"},remove:{primary:"supprimer",alternatives:["enlever","retirer","retire"],normalized:"remove"},put:{primary:"mettre",alternatives:["placer","mets"],normalized:"put"},append:{primary:"annexer",normalized:"append"},prepend:{primary:"pr\xE9fixer",normalized:"prepend"},take:{primary:"prendre",normalized:"take"},make:{primary:"faire",alternatives:["cr\xE9er"],normalized:"make"},clone:{primary:"cloner",alternatives:["dupliquer"],normalized:"clone"},swap:{primary:"\xE9changer",alternatives:["permuter"],normalized:"swap"},morph:{primary:"transformer",alternatives:["m\xE9tamorphoser"],normalized:"morph"},set:{primary:"d\xE9finir",alternatives:["\xE9tablir"],normalized:"set"},get:{primary:"obtenir",alternatives:["obtiens"],normalized:"get"},increment:{primary:"incr\xE9menter",alternatives:["augmenter"],normalized:"increment"},decrement:{primary:"d\xE9cr\xE9menter",alternatives:["diminuer"],normalized:"decrement"},log:{primary:"enregistrer",alternatives:["journaliser"],normalized:"log"},show:{primary:"montrer",alternatives:["afficher","montre"],normalized:"show"},hide:{primary:"cacher",alternatives:["masquer"],normalized:"hide"},transition:{primary:"transition",alternatives:["animer"],normalized:"transition"},on:{primary:"sur",alternatives:["lors"],normalized:"on"},trigger:{primary:"d\xE9clencher",normalized:"trigger"},send:{primary:"envoyer",alternatives:["envoie"],normalized:"send"},focus:{primary:"focaliser",alternatives:["concentrer"],normalized:"focus"},blur:{primary:"perte de focus",alternatives:["d\xE9focaliser"],normalized:"blur"},empty:{primary:"vider",alternatives:["vide"],normalized:"empty"},open:{primary:"ouvrir",normalized:"open"},close:{primary:"fermer",normalized:"close"},select:{primary:"s\xE9lectionner",alternatives:["selectionner"],normalized:"select"},clear:{primary:"effacer",normalized:"clear"},reset:{primary:"r\xE9initialiser",alternatives:["reinitialiser"],normalized:"reset"},breakpoint:{primary:"point-arr\xEAt",alternatives:["point-arret"],normalized:"breakpoint"},go:{primary:"aller",alternatives:["naviguer","va"],normalized:"go"},scroll:{primary:"d\xE9filement",alternatives:["defilement","d\xE9filer","faire-d\xE9filer"],normalized:"scroll"},push:{primary:"pousser",normalized:"push"},replace:{primary:"remplacer",normalized:"replace"},process:{primary:"traiter",normalized:"process"},wait:{primary:"attendre",normalized:"wait"},fetch:{primary:"chercher",alternatives:["r\xE9cup\xE9rer","r\xE9cup\xE8re"],normalized:"fetch"},settle:{primary:"stabiliser",normalized:"settle"},if:{primary:"si",normalized:"if"},unless:{primary:"saufsi",normalized:"unless"},when:{primary:"quand",normalized:"when"},changes:{primary:"change",normalized:"changes"},where:{primary:"o\xF9",normalized:"where"},else:{primary:"sinon",normalized:"else"},repeat:{primary:"r\xE9p\xE9ter",normalized:"repeat"},for:{primary:"pour",normalized:"for"},while:{primary:"pendant",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"continuer",normalized:"continue"},halt:{primary:"arr\xEAter",alternatives:["stopper"],normalized:"halt"},throw:{primary:"lancer",normalized:"throw"},call:{primary:"appeler",normalized:"call"},return:{primary:"retourner",alternatives:["renvoyer"],normalized:"return"},then:{primary:"puis",alternatives:["ensuite","alors"],normalized:"then"},and:{primary:"et",alternatives:["aussi","\xE9galement"],normalized:"and"},matches:{primary:"correspond",normalized:"matches"},exists:{primary:"existe",normalized:"exists"},is:{primary:"est",normalized:"is"},no:{primary:"aucun",normalized:"no"},end:{primary:"fin",alternatives:["terminer","finir"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"asynchrone",normalized:"async"},tell:{primary:"dire",normalized:"tell"},default:{primary:"d\xE9faut",normalized:"default"},init:{primary:"initialiser",normalized:"init"},behavior:{primary:"comportement",normalized:"behavior"},install:{primary:"installer",normalized:"install"},measure:{primary:"mesurer",normalized:"measure"},beep:{primary:"bip",normalized:"beep"},break:{primary:"interrompre",normalized:"break"},copy:{primary:"copier",normalized:"copy"},exit:{primary:"sortir",normalized:"exit"},pick:{primary:"choisir",normalized:"pick"},render:{primary:"rendu",normalized:"render"},into:{primary:"dans",normalized:"into"},before:{primary:"avant",normalized:"before"},after:{primary:"apr\xE8s",normalized:"after"},click:{primary:"clic",alternatives:["clique"],normalized:"click"},resize:{primary:"redimensionnement",alternatives:["redimensionner"],normalized:"resize"},hover:{primary:"survol",alternatives:["survoler"],normalized:"hover"},submit:{primary:"soumission",alternatives:["soumettre"],normalized:"submit"},input:{primary:"saisie",alternatives:["entr\xE9e"],normalized:"input"},change:{primary:"changement",alternatives:["modifier","changer"],normalized:"change"},load:{primary:"charger",alternatives:["chargement"],normalized:"load"},until:{primary:"jusqu'\xE0",alternatives:["jusque"],normalized:"until"},event:{primary:"\xE9v\xE9nement",normalized:"event"},from:{primary:"de",alternatives:["depuis"],normalized:"from"},connect:{primary:"connecter",alternatives:["connexion"],normalized:"connect"},stream:{primary:"flux",alternatives:["streaming"],normalized:"stream"},live:{primary:"en-direct",alternatives:["direct","vif"],normalized:"live"},socket:{primary:"socket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"lier",alternatives:["relier","bind"],normalized:"bind"},intercept:{primary:"intercepter",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"travailleur",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["source-d-evenements"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"sur",alternatives:["lors"],normalized:"on"},sourceMarker:{primary:"de",alternatives:["depuis"],position:"before"},conditionalKeyword:{primary:"quand",alternatives:["lorsque"]},eventMarker:{primary:"au",alternatives:["lors du","lors de","sur"],position:"before"},temporalMarkers:["quand","lorsque"]}};function Bm(t){let e=t.toLowerCase();return !!(e.endsWith("er")||e.endsWith("ir")||e.endsWith("re")||e.endsWith("ant")||e.endsWith("\xE9")||e.endsWith("i")||e.endsWith("u")||/[\u00e0\u00e2\u00e4\u00e9\u00e8\u00ea\u00eb\u00ef\u00ee\u00f4\u00f9\u00fb\u00fc\u00ff\u00e7\u0153\u00e6]/i.test(t))}var Tm=["toi","vous","nous"],Fm=[{ending:"ant",stem:"er",confidence:.88,type:"gerund"},{ending:"\xE9",stem:"er",confidence:.88,type:"participle"},{ending:"\xE9e",stem:"er",confidence:.88,type:"participle"},{ending:"\xE9s",stem:"er",confidence:.88,type:"participle"},{ending:"\xE9es",stem:"er",confidence:.88,type:"participle"},{ending:"e",stem:"er",confidence:.75,type:"present"},{ending:"es",stem:"er",confidence:.78,type:"present"},{ending:"ons",stem:"er",confidence:.85,type:"present"},{ending:"ez",stem:"er",confidence:.85,type:"present"},{ending:"ent",stem:"er",confidence:.82,type:"present"},{ending:"ais",stem:"er",confidence:.82,type:"past"},{ending:"ait",stem:"er",confidence:.82,type:"past"},{ending:"ions",stem:"er",confidence:.85,type:"past"},{ending:"iez",stem:"er",confidence:.85,type:"past"},{ending:"aient",stem:"er",confidence:.85,type:"past"},{ending:"ai",stem:"er",confidence:.8,type:"past"},{ending:"as",stem:"er",confidence:.78,type:"past"},{ending:"a",stem:"er",confidence:.75,type:"past"},{ending:"\xE2mes",stem:"er",confidence:.88,type:"past"},{ending:"\xE2tes",stem:"er",confidence:.88,type:"past"},{ending:"\xE8rent",stem:"er",confidence:.88,type:"past"},{ending:"erai",stem:"er",confidence:.85,type:"future"},{ending:"eras",stem:"er",confidence:.85,type:"future"},{ending:"era",stem:"er",confidence:.82,type:"future"},{ending:"erons",stem:"er",confidence:.88,type:"future"},{ending:"erez",stem:"er",confidence:.88,type:"future"},{ending:"eront",stem:"er",confidence:.88,type:"future"},{ending:"erais",stem:"er",confidence:.85,type:"conditional"},{ending:"erait",stem:"er",confidence:.85,type:"conditional"},{ending:"erions",stem:"er",confidence:.88,type:"conditional"},{ending:"eriez",stem:"er",confidence:.88,type:"conditional"},{ending:"eraient",stem:"er",confidence:.88,type:"conditional"},{ending:"ions",stem:"er",confidence:.8,type:"subjunctive"},{ending:"iez",stem:"er",confidence:.8,type:"subjunctive"},{ending:"ons",stem:"er",confidence:.82,type:"imperative"},{ending:"ez",stem:"er",confidence:.82,type:"imperative"},{ending:"er",stem:"er",confidence:.92,type:"dictionary"}],Om=[{ending:"issant",stem:"ir",confidence:.88,type:"gerund"},{ending:"i",stem:"ir",confidence:.8,type:"participle"},{ending:"ie",stem:"ir",confidence:.82,type:"participle"},{ending:"is",stem:"ir",confidence:.78,type:"participle"},{ending:"ies",stem:"ir",confidence:.82,type:"participle"},{ending:"is",stem:"ir",confidence:.78,type:"present"},{ending:"it",stem:"ir",confidence:.78,type:"present"},{ending:"issons",stem:"ir",confidence:.88,type:"present"},{ending:"issez",stem:"ir",confidence:.88,type:"present"},{ending:"issent",stem:"ir",confidence:.88,type:"present"},{ending:"issais",stem:"ir",confidence:.85,type:"past"},{ending:"issait",stem:"ir",confidence:.85,type:"past"},{ending:"issions",stem:"ir",confidence:.88,type:"past"},{ending:"issiez",stem:"ir",confidence:.88,type:"past"},{ending:"issaient",stem:"ir",confidence:.88,type:"past"},{ending:"irai",stem:"ir",confidence:.85,type:"future"},{ending:"iras",stem:"ir",confidence:.85,type:"future"},{ending:"ira",stem:"ir",confidence:.82,type:"future"},{ending:"irons",stem:"ir",confidence:.88,type:"future"},{ending:"irez",stem:"ir",confidence:.88,type:"future"},{ending:"iront",stem:"ir",confidence:.88,type:"future"},{ending:"ir",stem:"ir",confidence:.9,type:"dictionary"}],Rm=[{ending:"ant",stem:"re",confidence:.82,type:"gerund"},{ending:"u",stem:"re",confidence:.8,type:"participle"},{ending:"ue",stem:"re",confidence:.82,type:"participle"},{ending:"us",stem:"re",confidence:.82,type:"participle"},{ending:"ues",stem:"re",confidence:.82,type:"participle"},{ending:"s",stem:"re",confidence:.72,type:"present"},{ending:"d",stem:"re",confidence:.75,type:"present"},{ending:"ons",stem:"re",confidence:.82,type:"present"},{ending:"ez",stem:"re",confidence:.82,type:"present"},{ending:"ent",stem:"re",confidence:.8,type:"present"},{ending:"re",stem:"re",confidence:.9,type:"dictionary"}],Pm=[...Fm,...Om,...Rm].sort((t,e)=>e.ending.length-t.ending.length),na=class{constructor(){this.language="fr";}isNormalizable(t){return t.length<3?false:Bm(t)}normalize(t){let e=t.toLowerCase();if((e.endsWith("er")||e.endsWith("ir")||e.endsWith("re"))&&e.length>=4)return be(t);let r=this.tryReflexiveNormalization(e);if(r)return r;let i=this.tryConjugationNormalization(e);return i||be(t)}tryReflexiveNormalization(t){for(let e of Tm){let r="-"+e;if(t.endsWith(r)){let i=t.slice(0,-r.length),n=this.tryConjugationNormalization(i);if(n&&n.stem!==i)return oe(n.stem,n.confidence*.95,{removedSuffixes:[r,...n.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}}return null}tryConjugationNormalization(t){for(let e of Pm)if(t.endsWith(e.ending)){let r=t.slice(0,-e.ending.length);if(r.length<2)continue;let i=r+e.stem;return oe(i,e.confidence,{removedSuffixes:[e.ending],conjugationType:e.type})}return null}},Lm=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Nm=class{constructor(t=Lm){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}},Mm="()[]{},:;",_m=class{constructor(t=Mm){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 Mt(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function ta(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Mt(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Mt(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Mt(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var Im=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?ta(t,e)!==null:false}extract(t,e){let r=ta(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},$m=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},jm=["http://","https://","//","./","../","/"];function Vm(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function Wm(t,e){let r=t.slice(e),i=jm.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=Vm(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var qm=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=Wm(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Km=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 Hm(){return [new qm,new $m,new Km,new Im]}function Um(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:Gm,isIdentifierChar:Zm}=Um(/[a-zA-Z\u00e0\u00e2\u00e6\u00e7\u00e9\u00e8\u00ea\u00eb\u00ef\u00ee\u00f4\u00f9\u00fb\u00fc\u00ff\u0153\u00c0\u00c2\u00c6\u00c7\u00c9\u00c8\u00ca\u00cb\u00cf\u00ce\u00d4\u00d9\u00db\u00dc\u0178\u0152]/),Ym=new Set(["\xE0","a","de","du","des","dans","sur","sous","avec","sans","par","pour","entre","avant","apr\xE8s","apres","depuis","vers","chez","contre","au","aux"]),Xm=class{constructor(){this.name="french-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Gm(t[e])}extract(t,e){if(!this.context)throw new Error("FrenchKeywordExtractor: context not set");let r=e,i="";for(;r<t.length&&Zm(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=Ym.has(n),o=this.context.lookupKeyword(n),s=o&&o.normalized!==o.native?o.normalized:void 0,u,l,c;if(!o&&this.context.normalizer){let d=this.context.normalizer.normalize(i);if(d.stem!==i&&d.confidence>=.7){let m=this.context.lookupKeyword(d.stem);m&&(u=m.normalized,l=d.stem,c=d.confidence);}}return {value:i,length:r-e,metadata:{normalized:s||u,stem:l,stemConfidence:c,isPreposition:a}}}};function Jm(){return [new Xm]}var Qm=[{native:"vrai",normalized:"true"},{native:"faux",normalized:"false"},{native:"nul",normalized:"null"},{native:"ind\xE9fini",normalized:"undefined"},{native:"indefini",normalized:"undefined"},{native:"premier",normalized:"first"},{native:"premi\xE8re",normalized:"first"},{native:"premiere",normalized:"first"},{native:"dernier",normalized:"last"},{native:"derni\xE8re",normalized:"last"},{native:"derniere",normalized:"last"},{native:"suivant",normalized:"next"},{native:"pr\xE9c\xE9dent",normalized:"previous"},{native:"precedent",normalized:"previous"},{native:"proche",normalized:"closest"},{native:"parent",normalized:"parent"},{native:"clic",normalized:"click"},{native:"click",normalized:"click"},{native:"entr\xE9e",normalized:"input"},{native:"entree",normalized:"input"},{native:"changement",normalized:"change"},{native:"soumission",normalized:"submit"},{native:"touche bas",normalized:"keydown"},{native:"touche haut",normalized:"keyup"},{native:"souris dessus",normalized:"mouseover"},{native:"souris dehors",normalized:"mouseout"},{native:"focus",normalized:"focus"},{native:"flou",normalized:"blur"},{native:"chargement",normalized:"load"},{native:"d\xE9filement",normalized:"scroll"},{native:"defilement",normalized:"scroll"},{native:"je",normalized:"me"},{native:"mon",normalized:"my"},{native:"ma",normalized:"my"},{native:"mes",normalized:"my"},{native:"\xE7a",normalized:"it"},{native:"ca",normalized:"it"},{native:"resultat",normalized:"result"},{native:"evenement",normalized:"event"},{native:"seconde",normalized:"s"},{native:"secondes",normalized:"s"},{native:"milliseconde",normalized:"ms"},{native:"millisecondes",normalized:"ms"},{native:"minute",normalized:"m"},{native:"minutes",normalized:"m"},{native:"heure",normalized:"h"},{native:"heures",normalized:"h"},{native:"prefixer",normalized:"prepend"},{native:"creer",normalized:"make"},{native:"definir",normalized:"set"},{native:"etablir",normalized:"set"},{native:"incrementer",normalized:"increment"},{native:"decrementer",normalized:"decrement"},{native:"declencher",normalized:"trigger"},{native:"defocaliser",normalized:"blur"},{native:"recuperer",normalized:"fetch"},{native:"repeter",normalized:"repeat"},{native:"arreter",normalized:"halt"},{native:"defaut",normalized:"default"},{native:"jusqua",normalized:"until"},{native:"apres",normalized:"after"},{native:"journaliser",normalized:"log"},{native:"transmuter",normalized:"morph"},{native:"tant que",normalized:"while"},{native:"inclusif",normalized:"inclusive"},{native:"exclusif",normalized:"exclusive"},{native:"caract\xE8res",normalized:"characters"},{native:"al\xE9atoire",normalized:"random"}],ep=class extends $e{constructor(){super(),this.language="fr",this.direction="ltr",this.initializeKeywordsFromProfile(ia,Qm),this.normalizer=new na,this.registerExtractors(Hm()),this.registerExtractor(new _e),this.registerExtractor(new Ie),this.registerExtractors(Jm()),this.registerExtractor(new Nm),this.registerExtractor(new _m);}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('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},rp=new ep;qe("fr",rp,ia);var oa={code:"de",name:"German",nativeName:"Deutsch",regions:["western","priority"],direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:false},references:{me:"ich",it:"es",you:"du",result:"Ergebnis",event:"Ereignis",target:"Ziel",body:"K\xF6rper",document:"dokument",window:"fenster",detail:"detail"},possessive:{marker:"",markerPosition:"before-property",usePossessiveAdjectives:true,specialForms:{me:"mein",it:"sein",you:"dein"},keywords:{mein:"me",meine:"me",meinen:"me",dein:"you",deine:"you",deinen:"you",sein:"it",seine:"it",seinen:"it"}},roleMarkers:{destination:{primary:"auf",alternatives:["zu","in"],position:"before"},source:{primary:"von",alternatives:["aus"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"mit",position:"before"}},keywords:{toggle:{primary:"umschalten",alternatives:["wechseln"],normalized:"toggle"},add:{primary:"hinzuf\xFCgen",normalized:"add"},remove:{primary:"entfernen",alternatives:["l\xF6schen"],normalized:"remove"},put:{primary:"setzen",alternatives:["stellen","platzieren"],normalized:"put"},append:{primary:"anh\xE4ngen",normalized:"append"},prepend:{primary:"voranstellen",normalized:"prepend"},take:{primary:"nehmen",normalized:"take"},make:{primary:"machen",alternatives:["erstellen","erzeugen"],normalized:"make"},clone:{primary:"klonen",alternatives:["duplizieren"],normalized:"clone"},swap:{primary:"austauschen",alternatives:["tauschen","vertauschen"],normalized:"swap"},morph:{primary:"verwandeln",alternatives:["transformieren"],normalized:"morph"},set:{primary:"festlegen",alternatives:["definieren"],normalized:"set"},get:{primary:"holen",alternatives:["bekommen","erhalten"],normalized:"get"},increment:{primary:"erh\xF6hen",normalized:"increment"},decrement:{primary:"verringern",alternatives:["vermindern"],normalized:"decrement"},log:{primary:"protokollieren",alternatives:["ausgeben"],normalized:"log"},show:{primary:"zeigen",alternatives:["anzeigen"],normalized:"show"},hide:{primary:"verbergen",alternatives:["verstecken"],normalized:"hide"},transition:{primary:"\xFCbergang",alternatives:["animieren"],normalized:"transition"},on:{primary:"bei",alternatives:["auf"],normalized:"on"},trigger:{primary:"ausl\xF6sen",normalized:"trigger"},send:{primary:"senden",alternatives:["schicken"],normalized:"send"},focus:{primary:"Fokus",alternatives:["Fokuserhalt","fokussieren"],normalized:"focus"},blur:{primary:"Fokusverlust",alternatives:["verlassen","defokussieren","entfokussieren"],normalized:"blur"},empty:{primary:"leeren",alternatives:["leer"],normalized:"empty"},open:{primary:"\xF6ffnen",alternatives:["oeffnen"],normalized:"open"},close:{primary:"schlie\xDFen",alternatives:["schliessen"],normalized:"close"},select:{primary:"markieren",normalized:"select"},clear:{primary:"bereinigen",normalized:"clear"},reset:{primary:"zur\xFCcksetzen",alternatives:["zuruecksetzen"],normalized:"reset"},breakpoint:{primary:"haltepunkt",normalized:"breakpoint"},go:{primary:"gehen",alternatives:["navigieren"],normalized:"go"},scroll:{primary:"scrollen",normalized:"scroll"},push:{primary:"dr\xFCcken",alternatives:["push"],normalized:"push"},replace:{primary:"ersetzen",normalized:"replace"},process:{primary:"verarbeiten",normalized:"process"},wait:{primary:"warten",normalized:"wait"},fetch:{primary:"abrufen",alternatives:["laden"],normalized:"fetch"},settle:{primary:"stabilisieren",normalized:"settle"},if:{primary:"falls",alternatives:["sofern"],normalized:"if"},unless:{primary:"wennnicht",normalized:"unless"},when:{primary:"wenn",normalized:"when"},changes:{primary:"\xE4ndert",normalized:"changes"},where:{primary:"wo",normalized:"where"},else:{primary:"sonst",alternatives:["ansonsten"],normalized:"else"},repeat:{primary:"wiederholen",normalized:"repeat"},for:{primary:"f\xFCr",normalized:"for"},while:{primary:"solange",alternatives:["w\xE4hrend"],normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"fortfahren",alternatives:["weiter"],normalized:"continue"},halt:{primary:"anhalten",alternatives:["stoppen"],normalized:"halt"},throw:{primary:"werfen",normalized:"throw"},call:{primary:"aufrufen",normalized:"call"},return:{primary:"zur\xFCckgeben",normalized:"return"},then:{primary:"dann",alternatives:["danach","anschlie\xDFend"],normalized:"then"},and:{primary:"und",alternatives:["sowie","auch"],normalized:"and"},is:{primary:"ist",normalized:"is"},matches:{primary:"passt",normalized:"matches"},exists:{primary:"existiert",normalized:"exists"},no:{primary:"kein",normalized:"no"},end:{primary:"ende",alternatives:["fertig"],normalized:"end"},js:{primary:"js",alternatives:["javascript"],normalized:"js"},async:{primary:"asynchron",normalized:"async"},tell:{primary:"sagen",normalized:"tell"},default:{primary:"standard",normalized:"default"},init:{primary:"Initialisierung",alternatives:["initialisieren"],normalized:"init"},behavior:{primary:"verhalten",normalized:"behavior"},install:{primary:"installieren",normalized:"install"},measure:{primary:"messen",normalized:"measure"},beep:{primary:"piepton",normalized:"beep"},break:{primary:"unterbrechen",normalized:"break"},copy:{primary:"kopieren",normalized:"copy"},exit:{primary:"beenden",normalized:"exit"},pick:{primary:"ausw\xE4hlen",normalized:"pick"},render:{primary:"rendern",normalized:"render"},into:{primary:"hinein",normalized:"into"},before:{primary:"vor",normalized:"before"},after:{primary:"nach",normalized:"after"},click:{primary:"Klick",alternatives:["Klicken"],normalized:"click"},hover:{primary:"Hover",alternatives:["Schweben"],normalized:"hover"},submit:{primary:"Absenden",alternatives:["Senden"],normalized:"submit"},input:{primary:"Eingabe",normalized:"input"},change:{primary:"\xC4nderung",alternatives:["\xC4ndern"],normalized:"change"},resize:{primary:"Gr\xF6\xDFen\xE4nderung",alternatives:["gr\xF6\xDFen\xE4nderung","gr\xF6ssen\xE4nderung","Gr\xF6\xDFe \xE4ndern","gr\xF6\xDFe\xE4ndern"],normalized:"resize"},until:{primary:"bis",normalized:"until"},event:{primary:"Ereignis",alternatives:["Event"],normalized:"event"},from:{primary:"von",alternatives:["aus"],normalized:"from"},connect:{primary:"verbinden",alternatives:["Verbindung"],normalized:"connect"},stream:{primary:"stream",alternatives:["Strom"],normalized:"stream"},live:{primary:"direkt",alternatives:["live","echtzeit"],normalized:"live"},socket:{primary:"socket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"binden",alternatives:["verknuepfen","bind"],normalized:"bind"},intercept:{primary:"abfangen",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"arbeiter",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["ereignisquelle"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"bei",alternatives:["auf"],normalized:"on"},sourceMarker:{primary:"von",alternatives:["aus"],position:"before"},conditionalKeyword:{primary:"wenn",alternatives:["falls"]},eventMarker:{primary:"bei",alternatives:["beim"],position:"before"},temporalMarkers:["wenn","bei"]}},tp=["an","auf","aus","ein","mit","vor","zu","ab","bei","nach","weg","um","her","hin"];function ip(t){let e=t.toLowerCase();return !!(e.endsWith("en")||e.endsWith("eln")||e.endsWith("ern")||e.startsWith("ge")&&e.endsWith("t")||e.startsWith("ge")&&e.endsWith("en")||/[\u00e4\u00f6\u00fc\u00df]/i.test(t))}var np=[{ending:"end",stem:"en",confidence:.88,type:"gerund"},{ending:"e",stem:"en",confidence:.75,type:"present"},{ending:"st",stem:"en",confidence:.8,type:"present"},{ending:"t",stem:"en",confidence:.78,type:"present"},{ending:"en",stem:"en",confidence:.85,type:"dictionary"},{ending:"test",stem:"en",confidence:.85,type:"past"},{ending:"ten",stem:"en",confidence:.82,type:"past"},{ending:"tet",stem:"en",confidence:.85,type:"past"},{ending:"te",stem:"en",confidence:.82,type:"past"},{ending:"test",stem:"en",confidence:.8,type:"subjunctive"},{ending:"ten",stem:"en",confidence:.78,type:"subjunctive"},{ending:"tet",stem:"en",confidence:.8,type:"subjunctive"},{ending:"te",stem:"en",confidence:.78,type:"subjunctive"},{ending:"e",stem:"en",confidence:.72,type:"imperative"},{ending:"t",stem:"en",confidence:.72,type:"imperative"},{ending:"en",stem:"en",confidence:.75,type:"imperative"}],ap=[{ending:"le",stem:"eln",confidence:.82,type:"present"},{ending:"elst",stem:"eln",confidence:.85,type:"present"},{ending:"elt",stem:"eln",confidence:.85,type:"present"},{ending:"eln",stem:"eln",confidence:.88,type:"dictionary"},{ending:"re",stem:"ern",confidence:.82,type:"present"},{ending:"erst",stem:"ern",confidence:.85,type:"present"},{ending:"ert",stem:"ern",confidence:.85,type:"present"},{ending:"ern",stem:"ern",confidence:.88,type:"dictionary"}],op=[...np,...ap].sort((t,e)=>e.ending.length-t.ending.length),sa=class{constructor(){this.language="de";}isNormalizable(t){return t.length<3?false:ip(t)}normalize(t){let e=t.toLowerCase();if(e.endsWith("en")&&e.length>=4)return be(t);if((e.endsWith("eln")||e.endsWith("ern"))&&e.length>=5)return be(t);let r=this.tryParticipleNormalization(e);if(r)return r;let i=this.tryConjugationNormalization(e);return i||be(t)}tryParticipleNormalization(t){for(let e of tp)if(t.startsWith(e+"ge")){let r=t.slice(e.length),i=this.trySimpleParticipleNormalization(r);if(i){let n={removedPrefixes:["ge"],conjugationType:"participle"};return i.metadata?.removedSuffixes&&(n.removedSuffixes=i.metadata.removedSuffixes),oe(e+i.stem,i.confidence*.95,n)}}return this.trySimpleParticipleNormalization(t)}trySimpleParticipleNormalization(t){if(!t.startsWith("ge"))return null;let e=t.slice(2);if(e.endsWith("t")&&e.length>=3){let r=e.slice(0,-1);return oe(r+"en",.85,{removedPrefixes:["ge"],removedSuffixes:["t"],conjugationType:"participle"})}return e.endsWith("en")&&e.length>=4?oe(e,.82,{removedPrefixes:["ge"],conjugationType:"participle"}):null}tryConjugationNormalization(t){for(let e of op)if(t.endsWith(e.ending)){let r=t.slice(0,-e.ending.length);if(r.length<2)continue;let i=r+e.stem;return oe(i,e.confidence,{removedSuffixes:[e.ending],conjugationType:e.type})}return null}},sp=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],up=class{constructor(t=sp){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}},lp="()[]{},:;",cp=class{constructor(t=lp){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function _t(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function aa(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=_t(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=_t(t,e+n[0].length);return t.slice(e,a)}if(r==="@"){let i=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="*"){let i=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=_t(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var dp=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?aa(t,e)!==null:false}extract(t,e){let r=aa(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},mp=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},pp=["http://","https://","//","./","../","/"];function fp(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function yp(t,e){let r=t.slice(e),i=pp.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=fp(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var hp=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=yp(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},vp=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 Ep(){return [new hp,new mp,new vp,new dp]}function gp(t){return {isLetter:i=>t.test(i),isIdentifierChar:i=>/[0-9]/.test(i)||t.test(i)}}var{isLetter:zp,isIdentifierChar:wp}=gp(/[a-zA-Z\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df]/),kp=new Set(["an","auf","aus","bei","durch","f\xFCr","fur","gegen","in","mit","nach","ohne","seit","\xFCber","uber","um","unter","von","vor","zu","zwischen","bis","gegen\xFCber","gegenuber","w\xE4hrend","wahrend","wegen","trotz","statt","innerhalb","au\xDFerhalb","ausserhalb"]),bp=class{constructor(){this.name="german-keyword";}setContext(t){this.context=t;}canExtract(t,e){return zp(t[e])}extract(t,e){if(!this.context)throw new Error("GermanKeywordExtractor: context not set");return this.extractGermanWord(t,e)}extractGermanWord(t,e){if(!this.context)return null;let r=e,i="";for(;r<t.length&&wp(t[r]);)i+=t[r++];if(!i)return null;let n=i.toLowerCase(),a=kp.has(n),o=this.context.lookupKeyword(i),s=o&&o.normalized!==o.native?o.normalized:void 0,u;if(!o&&this.context.normalizer){let l=this.context.normalizer.normalize(i);if(l.stem!==i&&l.confidence>=.7){let c=this.context.lookupKeyword(l.stem);c&&(u=c.normalized);}}return {value:i,length:r-e,metadata:{normalized:s||u,isPreposition:a}}}};function Cp(){return [new bp]}var Ap=[{native:"wahr",normalized:"true"},{native:"falsch",normalized:"false"},{native:"null",normalized:"null"},{native:"undefiniert",normalized:"undefined"},{native:"erste",normalized:"first"},{native:"erster",normalized:"first"},{native:"erstes",normalized:"first"},{native:"letzte",normalized:"last"},{native:"letzter",normalized:"last"},{native:"letztes",normalized:"last"},{native:"n\xE4chste",normalized:"next"},{native:"nachste",normalized:"next"},{native:"n\xE4chstgelegene",normalized:"closest"},{native:"nachstgelegene",normalized:"closest"},{native:"vorherige",normalized:"previous"},{native:"eltern",normalized:"parent"},{native:"klick",normalized:"click"},{native:"click",normalized:"click"},{native:"eingabe",normalized:"input"},{native:"\xE4nderung",normalized:"change"},{native:"anderung",normalized:"change"},{native:"absenden",normalized:"submit"},{native:"taste unten",normalized:"keydown"},{native:"taste oben",normalized:"keyup"},{native:"maus dr\xFCber",normalized:"mouseover"},{native:"maus druber",normalized:"mouseover"},{native:"maus weg",normalized:"mouseout"},{native:"fokus",normalized:"focus"},{native:"unsch\xE4rfe",normalized:"blur"},{native:"unscharfe",normalized:"blur"},{native:"scrollen",normalized:"scroll"},{native:"meine",normalized:"my"},{native:"meinen",normalized:"my"},{native:"ergebnis",normalized:"result"},{native:"ziel",normalized:"target"},{native:"sekunde",normalized:"s"},{native:"sekunden",normalized:"s"},{native:"millisekunde",normalized:"ms"},{native:"millisekunden",normalized:"ms"},{native:"minute",normalized:"m"},{native:"minuten",normalized:"m"},{native:"stunde",normalized:"h"},{native:"stunden",normalized:"h"},{native:"hinzufugen",normalized:"add"},{native:"hinzufgen",normalized:"add"},{native:"loschen",normalized:"remove"},{native:"anhangen",normalized:"append"},{native:"erhohen",normalized:"increment"},{native:"ubergang",normalized:"transition"},{native:"auslosen",normalized:"trigger"},{native:"zuruckgeben",normalized:"return"},{native:"anschliessend",normalized:"then"},{native:"erh\xF6he",normalized:"increment"},{native:"erhohe",normalized:"increment"},{native:"verringere",normalized:"decrement"},{native:"inklusiv",normalized:"inclusive"},{native:"exklusiv",normalized:"exclusive"},{native:"Zeichen",normalized:"characters"},{native:"zuf\xE4llig",normalized:"random"}],xp=class extends $e{constructor(){super(),this.language="de",this.direction="ltr",this.initializeKeywordsFromProfile(oa,Ap),this.normalizer=new sa,this.registerExtractors(Ep()),this.registerExtractor(new _e),this.registerExtractor(new Ie),this.registerExtractors(Cp()),this.registerExtractor(new up),this.registerExtractor(new cp);}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('"')||t.startsWith("'")||/^\d/.test(t)?"literal":t.startsWith("/")||t.startsWith("./")||t.startsWith("http")?"url":"identifier"}},Sp=new xp;qe("de",Sp,oa);function Qr(t){let e=t.getAttribute("data-lang");if(e)return Jr(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return Jr(r);let i=t.closest?.("[lang]")?.getAttribute("lang");if(i)return Jr(i);let n=typeof document<"u"?document.documentElement?.lang:null;return n&&n!=="en"?Jr(n):null}function Jr(t){return t.split("-")[0].toLowerCase()}var ua={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],beep:[["patient",""]],behavior:[["patient",""]],bind:[["destination",""],["source","to"]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],eventsource:[],exit:[],fetch:[["source",""],["style","with"],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""],["manner","in new"]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],intercept:[],js:[["patient",""]],live:[],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["patient",""],["destination","to"],["manner","using view"]],on:[["event",""],["source","from"]],open:[["patient",""],["style","as"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"],["manner","using view"]],push:[["patient","url"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],replace:[["patient","url"]],reset:[["patient",""]],return:[["patient",""]],scroll:[["destination","to"]],select:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"],["scope","on"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],socket:[],swap:[["method",""],["destination","of"],["patient","with"],["manner","using view"]],take:[["patient",""],["source","from"],["recipient","for"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"],["duration","for"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],when:[["condition",""]],while:[["condition",""]],worker:[]};var Dp=new Set(["repeat","for","while","tell"]),Bp=new Set(["js"]);function et(t){switch(t.kind){case "event-handler":return Fp(t);case "compound":return la(t);case "loop":return Tp(t);default:return Op(t)}}function Tp(t){let e={kind:"command",action:t.action,roles:t.roles};return la({statements:[e,...t.body],chainType:"then"})}function Fp(t){let e=["on"],r=t.roles.get("event");r&&e.push(r.type==="literal"?String(r.value):Fr(r));let i=t.roles.get("source");if(i&&e.push("from",Fr(i)),t.body&&t.body.length>0){let n=t.body.map(et);e.push(n.join(" "));}return e.join(" ")}function la(t){let e=t.chainType==="async"?"async":t.chainType,r=t.statements.map(et),i=r[0]??"";for(let n=1;n<r.length;n++){let a=t.statements[n-1],o=t.statements[n],s=a.kind==="command"&&Dp.has(a.action),u=a.kind==="command"&&a.action==="bind"&&o.kind==="command"&&o.action==="bind";a.kind==="command"&&Bp.has(a.action)&&(i+=" end"),i+=(s||u?" ":` ${e} `)+r[n];}return i}function Op(t){let e=ua[t.action];if(e){let i=[t.action];for(let[n,a]of e){let o=t.roles.get(n);o&&((n==="destination"||n==="source")&&o.type==="reference"&&o.value==="me"||(a&&i.push(a),i.push(Fr(o))));}return i.join(" ")}let r=[t.action];for(let[,i]of t.roles)r.push(Fr(i));return r.join(" ")}function Fr(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 Rp(t);case "expression":return t.raw;case "flag":return t.enabled?`+${t.name}`:`~${t.name}`}}function Rp(t){let e=Fr(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 Pp={confidenceThreshold:.5,strategy:"semantic"};function Lp(t,e){return typeof t=="number"?t:t[e]??t["*"]??.5}var Np=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Mp(t){let e=t.match(Np);if(!e)return null;let r=e[1],i=t.slice(r.length);return i?{prefix:r,commands:i}:null}function ca(t){function e(n,a,o){try{return t.isLanguageRegistered(a)?t.translateSingle(n,a,o):null}catch{return null}}function r(n,a,o){try{let s=o(n,a);return s!==n?s:null}catch{return null}}function i(n,a,o){if(o.strategy==="semantic"||o.strategy==="auto"){let s=Lp(o.confidenceThreshold,a),u=e(n,a,s);if(u!==null)return u}if((o.strategy==="auto"||o.strategy==="i18n")&&o.i18nToEnglish){let s=r(n,a,o.i18nToEnglish);if(s!==null)return s}return null}return function(a,o,s={}){if(o==="en")return a;let u={...Pp,...s},l=i(a,o,u);if(l!==null)return l;let c=Mp(a);if(c){let d=i(c.commands,o,u);if(d!==null)return c.prefix+d}return a}}var It=ca({isLanguageRegistered:Ui,translateSingle(t,e,r){let i=Ln(t,e);return i.confidence<r||!i.node?null:et(i.node)}});var $t=new WeakSet;function _p(t){return (t.config?.attributes??"_, script, data-script").split(",").map(r=>r.trim()).filter(Boolean)}function Ip(t,e){for(let r of e)if(t.hasAttribute(r))return r;return null}function da(t,e){if(typeof t.addSourceTransform=="function"){t.addSourceTransform(e);return}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=_p(t),i=[...r.map(a=>`[${a}]`),'script[type="text/hyperscript"]'].join(", "),n=a=>{if($t.has(a))return;if(a instanceof HTMLScriptElement&&a.type==="text/hyperscript"){let l=a.textContent??"";if(!l)return;let c=e(l,a);$t.add(a),c!=null&&c!==l&&(a.textContent=c);return}let o=Ip(a,r);if(!o)return;let s=a.getAttribute(o);if(!s)return;let u=e(s,a);$t.add(a),u!=null&&u!==s&&a.setAttribute(o,u);};t.addBeforeProcessHook(a=>{!a||typeof a.querySelectorAll!="function"||(typeof a.matches=="function"&&a.matches(i)&&n(a),a.querySelectorAll(i).forEach(n));});}var $p=new Set(["me","my","i","it","its","you","your"]);function jp(t){for(let e of t?.features??[])for(let r of e.events??[])if(typeof r.on=="string"&&$p.has(r.on.toLowerCase()))return r.on}function pa(t,e){if(typeof t.parse!="function")return true;try{let r=t.parse(e);return r?.errors&&r.errors.length>0?!1:jp(r)===void 0}catch{return false}}var ma=new Set;function fa(t,e,r){ma.has(t)||(ma.add(t),console.warn(`[hyperscript-i18n] Translation for lang="${t}" rendered hyperscript the host parser rejects (or reads as a handler for an event named like me/it/you) \u2014 falling back to the original text. Source: "${e.length>60?e.slice(0,60)+"\u2026":e}" \u2192 "${r.length>60?r.slice(0,60)+"\u2026":r}". Further elements in this language stay quiet \u2014 enable { debug: true } for per-element detail.`));}function jt(t={}){return function(r){let i=r;da(i,(n,a)=>{let o=Vp(a,t);if(!o||o==="en")return n;let s=It(n,o,t);if(s!==n){if(t.validateWithHost!==false&&!pa(i,s))return t.debug?console.log(`[hyperscript-i18n] ${o}: host rejected "${s}" \u2014 keeping "${n}"`):fa(o,n,s),n;t.debug&&console.log(`[hyperscript-i18n] ${o}: "${n}" \u2192 "${s}"`);}return s});}}function Vp(t,e){if(e.languageAttribute){let i=t.getAttribute(e.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let r=Qr(t);return r||(e.defaultLanguage??null)}function ya(t,e,r={}){return e==="en"?t:It(t,e,r)}Hi(t=>Hn(t));function ha(){typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(jt());}var Py=["es","pt","fr","de"];ha();
6
+ exports.plugin=jt;exports.preprocess=ya;exports.resolveLanguage=Qr;exports.supportedLanguages=Py;return exports;})({});