@hyperscript-tools/multilingual 2.7.2 → 2.9.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 (32) hide show
  1. package/CHANGELOG.md +393 -0
  2. package/dist/hyperscript-i18n-ar.global.js +5 -5
  3. package/dist/hyperscript-i18n-bn.global.js +5 -5
  4. package/dist/hyperscript-i18n-de.global.js +5 -5
  5. package/dist/hyperscript-i18n-east-asian.global.js +5 -5
  6. package/dist/hyperscript-i18n-en.global.js +7 -7
  7. package/dist/hyperscript-i18n-es.global.js +5 -5
  8. package/dist/hyperscript-i18n-fr.global.js +5 -5
  9. package/dist/hyperscript-i18n-he.global.js +5 -5
  10. package/dist/hyperscript-i18n-hi.global.js +5 -5
  11. package/dist/hyperscript-i18n-id.global.js +5 -5
  12. package/dist/hyperscript-i18n-it.global.js +5 -5
  13. package/dist/hyperscript-i18n-ja.global.js +5 -5
  14. package/dist/hyperscript-i18n-ko.global.js +5 -5
  15. package/dist/hyperscript-i18n-ms.global.js +5 -5
  16. package/dist/hyperscript-i18n-pl.global.js +5 -5
  17. package/dist/hyperscript-i18n-pt.global.js +5 -5
  18. package/dist/hyperscript-i18n-qu.global.js +5 -5
  19. package/dist/hyperscript-i18n-ru.global.js +5 -5
  20. package/dist/hyperscript-i18n-slavic.global.js +5 -5
  21. package/dist/hyperscript-i18n-south-asian.global.js +5 -5
  22. package/dist/hyperscript-i18n-southeast-asian.global.js +5 -5
  23. package/dist/hyperscript-i18n-sw.global.js +5 -5
  24. package/dist/hyperscript-i18n-th.global.js +5 -5
  25. package/dist/hyperscript-i18n-tl.global.js +5 -5
  26. package/dist/hyperscript-i18n-tr.global.js +5 -5
  27. package/dist/hyperscript-i18n-uk.global.js +5 -5
  28. package/dist/hyperscript-i18n-vi.global.js +5 -5
  29. package/dist/hyperscript-i18n-western.global.js +5 -5
  30. package/dist/hyperscript-i18n-zh.global.js +5 -5
  31. package/dist/hyperscript-i18n.global.js +28 -27
  32. package/package.json +4 -3
@@ -1,5 +1,5 @@
1
- var HyperscriptI18n=(function(exports){'use strict';function re(t,e){return e?{type:"literal",value:t,dataType:e}:{type:"literal",value:t}}function $e(t,e){return e?{type:"selector",value:t,selectorKind:e}:{type:"selector",value:t}}function Le(t){return {type:"reference",value:t}}function qe(t,e){return {type:"property-path",object:t,property:e}}var fr=new Set(["me","you","it","result","event","target","body"]);function Xe(t,e=fr){return e.has(t)}var wt=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 At(t){return new wt(t)}function ke(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 Dt(t,e){return t?.possessive?.keywords?.[e]}var _e=class be{constructor(){this.logger=At("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,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 s=[];for(let l=0;l<10;l++){let m=e.peek(l);if(m)s.push({type:m.type,value:m.value,kind:m.kind});else break}this.logger.debug("Input tokens (first 10):",s),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(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(n),null;let u=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-n.position,confidence:u}}matchBest(e,r,i){let n=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,i);s&&n.push(s),e.reset(u);}if(n.length===0)return null;n.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let 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 u=null,s=null;for(let l=0;l<r.length;l++){let m=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(m,null,2));let c=e.peek();if(this.logger.debug(" >> Current input token:",c?JSON.stringify({type:c.type,value:c.value,kind:c.kind}):"EOF"),m.type==="role"&&m.greedy){let h=this.collectStopMarkers(r,l+1);if(n)for(let k of n)h.add(k);let g=[];for(;!e.isAtEnd();){let k=e.peek();if(!k||this.isStopMarker(k,h))break;g.push(k.value),e.advance();}if(g.length>0){i.set(m.role,{type:"expression",raw:g.join(" ")}),u=null,s=null;continue}else {if(m.optional)continue;return false}}if(m.type==="group"){let h=this.collectStopMarkers(r,l+1);if(n)for(let k of n)h.add(k);if(this.matchGroupToken(e,m,i,h)){u=null,s=null;continue}if(this.isOptional(m))continue;return false}let p=m.type==="role"&&m.optional===true,d=p?e.mark():null;if(m.type==="role"&&!p){let h=l+1<r.length?r[l+1]:null;if(h?.type==="literal"){let g=e.peek();if(g&&this.getMatchType(g,h.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(m))continue;if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),i.delete(s),u=null,s=null;let k=this.matchPatternToken(e,m,i);if(this.logger.debug(" >> Backtrack retry result:",k),k)continue}return false}}}let y=this.matchPatternToken(e,m,i);if(this.logger.debug(" >> Match result:",y),y){p?(u=d,s=m.role):(u=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(m)){if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),i.delete(s),u=null,s=null;let h=this.matchPatternToken(e,m,i);if(this.logger.debug(" >> Backtrack retry result:",h),h)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&&!ke(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&&!ke(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(s.type,r.expectedTypes)?r.optional||false:(i.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(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 m=this.tokenToSemanticValue(n);return this.logger.debug(" >>> tokenToSemanticValue returned:",m?JSON.stringify(m):"null"),m?(this.logger.debug(" >>> Validating type:",m.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!ke(m.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,m),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=Dt(this.currentProfile,n);if(!a)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let m=e.peek();return m?.kind==="literal"&&m.value.startsWith("(")&&(l+=m.value,e.advance()),qe(Le(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 u=[];for(;!e.isAtEnd()&&u.length<be.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.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}`,u=1;for(;!e.isAtEnd()&&u<be.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let m=e.peek();if(!m||m.kind!=="identifier")break;e.advance(),o+=`.${m.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],m=0;for(;!e.isAtEnd()&&l.length<be.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(m===0){e.advance();break}m--;}if(p.kind==="punctuation"&&p.value==="("&&m++,p.kind==="punctuation"&&p.value===","){e.advance();continue}l.push(p.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(),qe($e(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 qe($e(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 s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=be.MAX_MARKER_SCAN;l++){let m=e.peek(l);if(!m)break;if((m.normalized||m.value).toLowerCase()===s){this.logger.debug(" >> MARKER SCAN: found",s,"at offset",l,"- skipping intervening tokens");for(let d=0;d<l;d++)e.advance();if(this.matchTokenSequence(e,r.tokens,i,n))return true;e.reset(a);for(let d of i.keys())o.has(d)||i.delete(d);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 u of o.alternatives)i.add(u.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 $e(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return re(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Le(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return re(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 re(n,"string")}if(e==="true")return re(true,"boolean");if(e==="false")return re(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?re(e,"duration"):re(n,"number")}let i=parseFloat(e);return isNaN(i)?re(e,"string"):re(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 m of l.tokens)if(m.type==="role"){let c=a(m.role),p=.8;n+=p,r.has(m.role)?i+=p:c&&(i+=p*.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 u=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+u);let s=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+s)),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 u=n[a];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?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(be.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}};_e.MAX_MARKER_SCAN=3;_e.MAX_PROPERTY_DEPTH=10;_e.MAX_METHOD_ARGS=20;_e.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Bt=_e;new Bt;var we=class{constructor(){this.name="string-literal";}canExtract(t,e){let r=t[e];return 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}},Ae=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),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value: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 s=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of s)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 St(t){return "setContext"in t&&typeof t.setContext=="function"}function xt(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 te=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 I(t,e){return {start:t,end:e}}function j(t,e,r,i){if(typeof t=="object"){let{value:a,kind:o,position:u,normalized:s,stem:l,stemConfidence:m,metadata:c}=t;return {value:a,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...m!==void 0&&{stemConfidence:m},...c!==void 0&&{metadata:c}}}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:u,metadata:s}=i;return {value:n,kind:e,position:r,...a!==void 0&&{normalized:a},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:n,kind:e,position:r}}function Ne(t){return /\s/.test(t)}function Tt(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function Ft(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function de(t){return /\d/.test(t)}function Ot(t){return /[a-zA-Z]/.test(t)}function W(t){return /[a-zA-Z0-9_-]/.test(t)}function Rt(t,e){if(e>=t.length)return null;let r=t[e];if(!Tt(r))return null;let i=e,n="";if(r==="#"||r==="."){for(n+=t[i++];i<t.length&&W(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&&W(t[o]);)o++;if(o<t.length&&t[o]==="(")return n}}else if(r==="["){let a=1,o=false,u=null,s=false;for(n+=t[i++];i<t.length&&a>0;){let l=t[i];n+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?a++:l==="]"&&a--,i++;}if(a!==0)return null}else if(r==="@"){for(n+=t[i++];i<t.length&&W(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="*"){for(n+=t[i++];i<t.length&&W(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="<"){if(n+=t[i++],i>=t.length||!Ot(t[i]))return null;for(;i<t.length&&W(t[i]);)n+=t[i++];for(;i<t.length;){let a=t[i];if(a==="."){if(n+=t[i++],i>=t.length||!W(t[i]))return null;for(;i<t.length&&W(t[i]);)n+=t[i++];}else if(a==="#"){if(n+=t[i++],i>=t.length||!W(t[i]))return null;for(;i<t.length&&W(t[i]);)n+=t[i++];}else if(a==="["){let o=1,u=false,s=null,l=false;for(n+=t[i++];i<t.length&&o>0;){let m=t[i];n+=m,l?l=false:m==="\\"?l=true:u?m===s&&(u=false,s=null):m==='"'||m==="'"||m==="`"?(u=true,s=m):m==="["?o++:m==="]"&&o--,i++;}if(o!==0)return null}else break}for(;i<t.length&&Ne(t[i]);)n+=t[i++];if(i<t.length&&t[i]==="/")for(n+=t[i++];i<t.length&&Ne(t[i]);)n+=t[i++];if(i>=t.length||t[i]!==">")return null;n+=t[i++];}return n||null}function Pt(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 Ne(i)||i==="*"||!W(i)}function Lt(t,e){if(e>=t.length)return null;let r=t[e];if(!Ft(r)||r==="'"&&Pt(t,e))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!n)return null;let a=e+1,o=r,u=false;for(;a<t.length;){let s=t[a];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===n)return o;a++;}return o}function Nt(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 _t(t,e){if(!Nt(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 Mt(t,e){if(e>=t.length)return null;let r=t[e];if(!de(r)&&r!=="-"&&r!=="+")return null;let i=e,n="";if((t[i]==="-"||t[i]==="+")&&(n+=t[i++]),i>=t.length||!de(t[i]))return null;for(;i<t.length&&de(t[i]);)n+=t[i++];if(i<t.length&&t[i]===".")for(n+=t[i++];i<t.length&&de(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 It=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(It);var jt=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"]),Vt=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],vr=class Er{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){St(e)&&e.setContext(xt(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&&Ne(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 u=o.extract(e,i);if(u){let s=u.metadata?.normalized,l=u.metadata?.stem,m=u.metadata?.stemConfidence,c={};if(u.metadata)for(let[d,f]of Object.entries(u.metadata))d!=="normalized"&&d!=="stem"&&d!=="stemConfidence"&&(c[d]=f);let p={};s&&(p.normalized=s),l&&(p.stem=l),m!==void 0&&(p.stemConfidence=m),Object.keys(c).length>0&&(p.metadata=c),r.push(j(u.value,this.classifyToken(u.value),I(i,i+u.length),Object.keys(p).length>0?p:void 0)),i+=u.length,a=true;break}}if(!a){let o=e[i],u=this.classifyUnknownChar(o);r.push(j(o,u,I(i,i+1))),i++;}}return new te(r,this.language)}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(j(".","operator",I(r,r+1))),true;let s=r+1;for(;s<e.length&&W(e[s]);)s++;return s<e.length&&e[s]==="("?(i.push(j(".","operator",I(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 Vt)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(" ")&&!jt.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 e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,r){for(let i of this.profileKeywords)if(e.slice(r).startsWith(i.native))return j(i.native,"keyword",I(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 j(a.native,"keyword",I(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){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let r=this.normalizer.normalize(e);return r.stem!==e&&r.confidence>=.7?r:null}tryMorphKeywordMatch(e,r,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 j(e,"keyword",I(r,i),o)}trySelector(e,r){let i=Rt(e,r);return i?j(i,"selector",I(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 {...j(n,"event-modifier",I(r,r+n.length)),metadata:{modifierName:a,value:o?a==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let i=Lt(e,r);return i?j(i,"literal",I(r,r+i.length)):null}tryNumber(e,r){let i=Mt(e,r);return i?j(i,"literal",I(r,r+i.length)):null}tryMatchTimeUnit(e,r,i,n=false){let a=r;if(n)for(;a<e.length&&Ne(e[a]);)a++;let o=e.slice(a);for(let u of i){let s=o.slice(0,u.length);if(u.caseInsensitive?s.toLowerCase()===u.pattern.toLowerCase():s===u.pattern){if(u.notFollowedBy&&(o[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let m=o[u.length]||"";if(W(m))continue}return {suffix:u.suffix,endPos:a+u.length}}}return null}parseBaseNumber(e,r,i=true){let n=r,a="";if(i&&(e[n]==="-"||e[n]==="+")&&(a+=e[n++]),n>=e.length||!de(e[n]))return null;for(;n<e.length&&de(e[n]);)a+=e[n++];if(n<e.length&&e[n]===".")for(a+=e[n++];n<e.length&&de(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,u=this.parseBaseNumber(e,r,a);if(!u)return null;let{number:s,endPos:l}=u,m=[...i,...Er.STANDARD_TIME_UNITS],c=this.tryMatchTimeUnit(e,l,m,o);return c&&(s+=c.suffix,l=c.endPos),j(s,"literal",I(r,l))}tryUrl(e,r){let i=_t(e,r);return i?j(i,"url",I(r,r+i.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!W(e[r+1]))return null;let i=r+1;for(;i<e.length&&W(e[i]);)i++;let n=e.slice(r,i);return j(n,"identifier",I(r,i))}tryOperator(e,r){let i=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(i))return j(i,"operator",I(r,r+2));let n=e[r];return ["<",">","!","+","-","*","/","="].includes(n)?j(n,"operator",I(r,r+1)):["(",")","{","}",",",";",":"].includes(n)?j(n,"punctuation",I(r,r+1)):null}tryMultiCharParticle(e,r,i){for(let n of i)if(e.slice(r,r+n.length)===n)return j(n,"particle",I(r,r+n.length));return null}};vr.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var De=vr;function We(t){return {stem:t,confidence:1}}function se(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}var $t=Object.defineProperty,qt=Object.getOwnPropertyNames,Or=(t,e)=>function(){return t&&(e=(0, t[qt(t)[0]])(t=0)),e},Wt=(t,e)=>{for(var r in e)$t(t,r,{get:e[r],enumerable:true});};function gr(t,e){return t.replace(/\{(\w+)\}/g,(r,i)=>String(e[i]??`{${i}}`))}function G(t,e,r={},i){let n=Rr[t],a=gr(n,r),o=Pr[t],u=o?gr(o,r):void 0;return {code:t,message:a,severity:e,...i&&{role:i},...u&&{suggestion:u}}}var S,Rr,Pr,Kt=Or({"src/generators/schema-error-codes.ts"(){S={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"},Rr={[S.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[S.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[S.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[S.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[S.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[S.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.",[S.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.",[S.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[S.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[S.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[S.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[S.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[S.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[S.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[S.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[S.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[S.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Pr={[S.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[S.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[S.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[S.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[S.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[S.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[S.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[S.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[S.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[S.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[S.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[S.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[S.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[S.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),Lr={};Wt(Lr,{SchemaErrorCodes:()=>S,formatValidationResults:()=>Xt,getValidationStats:()=>Qt,validateAllKeywordCollisions:()=>ri,validateAllSchemas:()=>Jt,validateCommandSchema:()=>Nr,validateKeywordCollisions:()=>_r,validateRoleValues:()=>ei});function Ut(t,e){return {action:t,items:e}}function Nr(t){let e=[];for(let i of t.roles)i.expectedTypes.includes("literal")&&i.expectedTypes.includes("selector")&&(i.role==="patient"&&er.has(t.action)?e.push(G(S.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:i.role,command:t.action},i.role)):e.push(G(S.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:i.role},i.role))),i.expectedTypes.length>3&&!er.has(t.action)&&e.push(G(S.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(G(S.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:i.role},i.role)));switch(t.action){case "transition":Ht(t,e);break;case "on":Gt(t,e);break;case "if":case "unless":Yt(t,e);break;case "repeat":case "for":case "while":Zt(t,e);break}return t.roles.filter(i=>i.required).length===0&&(Mr.has(t.action)?e.push(G(S.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(G(S.NO_REQUIRED_ROLES,"warning",{}))),Ut(t.action,e)}function Ht(t,e){let r=t.roles.find(n=>n.role==="patient"),i=t.roles.find(n=>n.role==="goal");r&&!i&&e.push(G(S.TRANSITION_MISSING_GOAL,"error",{}));}function Gt(t,e){let r=t.roles.find(i=>i.role==="event");r||e.push(G(S.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(G(S.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Yt(t,e){let r=t.roles.find(i=>i.role==="condition");r||e.push(G(S.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(G(S.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Zt(t,e){t.action==="for"?t.roles.find(i=>i.role==="source")||e.push(G(S.FOR_LOOP_MISSING_SOURCE,"warning",{})):t.action==="while"&&(t.roles.find(i=>i.role==="condition")||e.push(G(S.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Jt(t,e={}){let r=new Map,{includeNotes:i=false}=e;for(let[n,a]of Object.entries(t)){let o=Nr(a),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=i&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(n,o);}return r}function Xt(t,e={}){let r=[],{showNotes:i=false,showCodes:n=true}=e;for(let[a,o]of t){let u=o.items.filter(m=>m.severity==="error"),s=o.items.filter(m=>m.severity==="warning"),l=o.items.filter(m=>m.severity==="note");if(u.length>0){r.push(` \u274C ${a}:`);for(let m of u){let c=n?` [${m.code}]`:"";r.push(` ERROR${c}: ${m.message}`),m.suggestion&&r.push(` \u{1F4A1} Suggestion: ${m.suggestion}`);}}if(s.length>0){r.push(` \u26A0\uFE0F ${a}:`);for(let m of s){let c=n?` [${m.code}]`:"";r.push(` ${c?`${m.code}: `:""}${m.message}`),m.suggestion&&r.push(` \u{1F4A1} ${m.suggestion}`);}}if(i&&l.length>0){r.push(` \u2139\uFE0F ${a}:`);for(let m of l){let c=n?` [${m.code}]`:"";r.push(` ${c?`${m.code}: `:""}${m.message}`);}}}return r.join(`
2
- `)}function Qt(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 ei(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:S.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:S.SELECTOR_KIND_MISMATCH})));}return r}function _r(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 u of a.alternatives){let s=r.get(u)||[];s.push({command:n,isPrimary:false}),r.set(u,s);}}for(let[n,a]of r){let o=[...new Set(a.map(l=>l.command))];if(o.length<=1)continue;let u=a.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:n,commands:o.sort(),type:s});}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 ri(t){let e=[];for(let[,r]of Object.entries(t)){let i=_r(r);i.collisions.length>0&&e.push(i);}return e.sort((r,i)=>r.language.localeCompare(i.language))}var er,Mr,ti=Or({"src/generators/schema-validator.ts"(){Kt(),er=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Mr=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint"]);}});var he=new Map,oe=new Map,Ie=new Map,rr=null;function Ir(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]=Ir(a,n):r[i]=n);}return r}function ii(t,e){return Ir(t,e)}function ar(t){if(!t.extends)return t;let e=oe.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=ar(e);return ii(r,t)}function Re(t,e,r){he.set(t,e),oe.set(t,r),Ie.delete(t);}function jr(t){rr=t;}var zr=new Map;function Fe(t){return t.split("-")[0]}function Oe(t){return t.includes("-")}function ni(t){let e=he.get(t);if(!e&&Oe(t)){let r=Fe(t);e=he.get(r);}if(!e){let r=Array.from(he.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 ai(t){let e=oe.get(t);if(!e&&Oe(t)){let r=Fe(t);e=oe.get(r);}if(!e){let r=Array.from(oe.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 ar(e)}function N(t){let e=oe.get(t);return !e&&Oe(t)&&(e=oe.get(Fe(t))),e?ar(e):void 0}function oi(){return Array.from(he.keys())}function Vr(t){if(he.has(t)&&oe.has(t))return true;if(Oe(t)){let e=Fe(t);return he.has(e)&&oe.has(e)}return false}function ui(t,e){return ni(e).tokenize(t)}function ae(t){let e=Ie.get(t);if(!e&&Oe(t)&&(e=Ie.get(Fe(t))),e)return e;let r=zr.get(t);if(!r&&Oe(t)&&(r=zr.get(Fe(t))),r)return Ie.set(t,r),r;if(!rr)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let i=ai(t),n=rr(i);return Ie.set(t,n),n}function ye(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 M(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}function Be(t){return Xe(t)}function ie(t){return {type:"reference",value:t}}function fe(t,e){return {type:"property-path",object:t,property:e}}function Z(t,e,r){let i={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...i,metadata:r}:i}function Me(t,e,r,i,n,a){let o=new Map;o.set("event",t);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),i!==void 0&&(u.metadata=i),n!==void 0&&n.length>0&&(u.parameterNames=n),u}function Ri(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 Pi(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 tr(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 Li(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 Ke(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 Ee(t){let e=t.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function ge(t){let e=t.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function ze(t,e){return $r(t,e,"source")}function or(t,e){return $r(t,e,"destination")}function $r(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 Ni={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}}],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)"}},_i={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector","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"}}],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"}},Mi={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",targetRole:"source",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"}},Ii={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"},markerVariants:{en:["before","after"]},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"}},ji={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{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",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"},markerVariants:{tr:["e","a","ye","ya"]}},{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>"}},Vi={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"],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>"}},$i={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},qi={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Wi={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ki={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ui={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Hi={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Gi={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Yi={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Zi={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Ji={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}]},Xi={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"as"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},Qi={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},en={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},rn={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},tn={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},nn={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},an={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",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}]},on={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},un={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},sn={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},ln={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},cn={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},mn={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","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"}}]},pn={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},dn={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},fn={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},yn={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},hn={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference","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"}}]},vn={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},En={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},gn={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""},markerOptional:{en:true},markerVariants:{he:["\u05D0\u05EA"],zh:["\u628A"]}}]},zn={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",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}]},Cn={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},kn={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},bn={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},wn={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}]},An={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"as"}}]},Dn={action:"close",description:"Close a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to close (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Bn={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}]},Sn={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}]},xn={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}]},Tn={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Fn={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],markerOptional:{he:true,zh:true},svoPosition:1,sovPosition:1}]},On={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},Rn={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Pn={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Ln={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},Nn={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["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"}}]},_n={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Mn={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},In={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},jn={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Vn={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of",es:"",fr:"",pt:"",it:"",de:"",pl:"",ru:"",uk:"",id:"",ms:"",sw:"",th:"",vi:"",he:"\u05D0\u05EA",zh:"\u628A"}},{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"}}]},$n={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",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"}}]},qn={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}]},Wn={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Kn={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}]},Un={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Hn={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Gn={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"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"}}]},qr={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"},Yn={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"},Zn={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:qr}]},Jn={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:qr}]},Xn={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Yn}]},Qn={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},ve={toggle:Ni,add:_i,remove:Mi,put:Ii,set:ji,show:Hi,hide:Gi,on:Yi,trigger:Zi,wait:Ji,fetch:Xi,increment:Qi,decrement:en,append:rn,prepend:tn,log:nn,get:an,take:on,make:un,halt:sn,settle:ln,throw:cn,send:mn,if:pn,unless:dn,else:fn,repeat:yn,for:hn,while:vn,continue:En,go:gn,scroll:Gn,push:Zn,replace:Jn,process:Xn,transition:zn,clone:Cn,focus:kn,blur:bn,empty:wn,open:An,close:Dn,select:Bn,clear:Sn,reset:xn,breakpoint:Tn,call:Fn,return:On,js:Rn,async:Pn,tell:Ln,default:Nn,init:_n,behavior:Mn,install:In,measure:jn,swap:Vn,morph:$n,beep:qn,break:Wn,copy:Kn,exit:Un,pick:Hn,render:Qn,bind:Vi,live:$i,eventsource:qi,socket:Wi,worker:Ki,intercept:Ui,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function ce(t){return ve[t]}function ea(){return Object.values(ve).filter(t=>t.roles.length>0||t.bareKeyword===true)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(ti(),Lr)).then(({validateAllSchemas:t,formatValidationResults:e})=>{let r=t(ve);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
3
- These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(t=>{console.debug("Schema validation skipped:",t);});function le(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}}var Wr=[{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 Cr(t,e,r,i){let n=Wr.find(o=>o.lang===t);if(!n)return false;let a=(o,u)=>(o??"").toLowerCase()===u.toLowerCase();return a(e,n.end)&&a(r,n.at)&&a(i,n.of)}function ra(t,e){let r=Wr.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 Qe=.8,ta=.6,ia=.15,na=.5,kr=.15,br=.1,wr=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"]),aa={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"]},oa=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(na,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=o=>e.extraction?.[o]?.default!==void 0;for(let o of e.template.tokens)if(o.type==="role")n+=1,r.has(o.role)&&(i+=1);else if(o.type==="group")for(let u of o.tokens)u.type==="role"&&(n+=Qe,r.has(u.role)?i+=Qe:a(u.role)&&(i+=Qe*ta));return n>0?i/n:1}scoreStemPenalty(t){let{stemMatchCount:e,totalKeywordMatches:r}=t;return e<=0||r<=0?0:-(e/r)*ia}scoreLanguageBoost(t){let{pattern:e}=t;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:wr.has(r.value)||r.alternatives?.some(i=>wr.has(i))?kr: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=aa[n];if(!o||o.length===0)continue;let u="metadata"in a?a.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?i+=.1:i-=.1);}return Math.max(-br,Math.min(br,i))}},ua=new oa,sa=new Set(Object.values(ve).filter(t=>t.bareKeyword===true).map(t=>t.action)),U=class P{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??ua;}matchPattern(e,r){let i=e.mark(),n=new Map;if(this.currentProfile=N(r.language),this.currentPatternCommand=r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,!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}}matchBest(e,r){this.matchCache.clear();let i=[],n=e.position();for(let o of r){let u=e.mark(),s=`${n}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&i.push(l),e.reset(u);}if(i.length===0)return null;i.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.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 u=0;for(let s=0;s<r.length;s++){let l=r[s];u>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,i,l);let m=this.matchPatternToken(e,l,i,r[s+1]??n);if(u=l.type==="role"&&l.role==="event"?2:Math.max(0,u-1),!m){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,u=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let m=l.value.toLowerCase();return o.primary?.toLowerCase()===m?true:!!o.alternatives?.some(c=>c.toLowerCase()===m)},s=o?.position;if(s!=="after"&&u(n)&&a.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(s==="after"&&n.kind==="selector"&&u(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":return this.matchRoleToken(e,r,i,n);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 u=e.peek();if(!u||u.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,u]of Object.entries(r.keywords))if(u.primary.toLowerCase()===a||u.alternatives?.some(s=>s.toLowerCase()===a))return M(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 s=e.peek();if(!s||s.value!==i)return e.reset(a),false;e.advance();}let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword"&&u.kind!=="particle"||u.value.toLowerCase()!==n[o].toLowerCase())return e.reset(a),false;e.advance();}return true}matchRoleToken(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 g=this.tryFoldHyphenActionKeyword(e);if(g)return i.set(r.role,g),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!P.tokenLooksLikeEvent(a))return r.optional||false;let g=(a.normalized??a.value).toLowerCase();if(P.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||this.currentProfile&&(le(this.currentProfile,a.value)??le(this.currentProfile,g))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let g=(a.normalized??a.value).toLowerCase();if(P.STRUCTURAL_NEVER_EVENT.has(g))return r.optional||false}if(r.role==="duration"){let g=(a.normalized??a.value).toLowerCase();if(P.POSITIONAL_OR_SCOPE_KEYWORDS.has(g))return r.optional||false}if(r.optional&&n===void 0&&r.role!=="event"&&r.role!=="action"&&a.kind==="keyword"&&(a.normalized??a.value).toLowerCase()in ve)return true;let o=this.tryMatchPositionalExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Ke(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let u=this.tryMatchCaretScopeExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Ke(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let g=this.tryMatchOperatorRunExpression(e);if(g)return i.set(r.role,g),true}if(r.expectedTypes?.includes("property-path")){let g=this.tryMatchOfPossessiveExpression(e);if(g)return i.set(r.role,g),true;let k=this.tryMatchPostNominalPossessiveExpression(e);if(k)return i.set(r.role,k),true}let s=this.tryMatchPossessiveExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(s.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,s),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 c=r.role==="event"&&this.currentPatternCommand==="on"||P.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(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 p=this.tryMatchPossessiveSelectorExpression(e);if(p)return r.expectedTypes&&r.expectedTypes.length>0&&!Ke(p.type,r.expectedTypes)?r.optional||false:(i.set(r.role,p),true);let d=r.role!=="condition",f=this.tryMatchPropertyAccessExpression(e,d);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 y=this.tryMatchSelectorPropertyExpression(e);if(y)return r.expectedTypes&&r.expectedTypes.length>0&&!Ke(y.type,r.expectedTypes)?r.optional||false:(i.set(r.role,y),true);if(a.kind==="identifier"&&a.value==="{"&&(!r.expectedTypes?.length||r.expectedTypes.includes("literal"))){let g=this.tryMatchBraceRunLiteral(e);if(g)return i.set(r.role,g),true}let h=this.tokenToSemanticValue(a);if(!h)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(h.type)){let g=h.type==="selector"&&String(h.value).startsWith("@"),k=r.expectedTypes.some(w=>w==="expression"||w==="reference");if(!(g&&k))return r.optional||false}if(i.set(r.role,h),e.advance(),r.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&"value"in h&&(i.set(r.role,M(`${String(h.value)}${g.value}`)),e.advance());let k=e.peek();if(k&&(k.kind==="particle"||k.kind==="keyword")&&(k.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(n,k)){let w=e.peek(1);if(w&&(w.kind==="selector"||w.kind==="identifier")){e.advance();let A=this.tokenToSemanticValue(e.advance());A&&!i.has("source")&&i.set("source",A);}}}return true}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){let r=e.peek();if(!r)return null;let i=(r.normalized??r.value).toLowerCase();if(!P.POSITIONAL_KEYWORDS.has(i)&&!P.POSITIONAL_KEYWORDS.has(r.value.toLowerCase()))return null;let n=e.mark(),a=[r.normalized??r.value];e.advance();let o=e.peek();if(!o||o.kind!=="selector")return e.reset(n),null;a.push(o.value),e.advance();let u=0;for(;u++<8;){let m=e.peek();if(m&&m.kind==="selector"&&m.value.startsWith("."))a.push(m.value),e.advance();else break}let s=e.peek(),l=e.peek(1);return s&&l&&l.kind==="selector"&&(s.kind==="keyword"||s.kind==="particle"||s.kind==="identifier")&&!P.POSITIONAL_KEYWORDS.has((s.normalized??s.value).toLowerCase())&&!P.COMMAND_ACTION_KEYWORDS.has((s.normalized??s.value).toLowerCase())&&(a.push(s.normalized??s.value,l.value),e.advance(),e.advance()),{type:"expression",raw:a.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){let r=e.value.toLowerCase(),i=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||i==="of"||i==="source")return true;let n=this.currentProfile?.code?P.OF_POSSESSIVE_MARKERS[this.currentProfile.code]:void 0;return !!n&&n.has(r)}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||!P.RUN_OPERATORS.has(o.value))break;let u=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(u);break}n++;}if(n<2)return e.reset(r),null;let a=e.tokens.slice(i,e.position()).map(o=>o.value).join(" ");return {type:"expression",raw:a,value:a}}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")&&!P.RUN_OPERATORS.has(r.value)&&r.value!==")"?(e.advance(),true):false}tryMatchOfPossessiveExpression(e){let r=e.peek();if(!r||r.kind!=="selector")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"?(e.reset(i),null):(e.advance(),fe(ye(a.value),r.value))}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=[r.value,r.normalized].filter(Boolean),n;for(let s of i)if(n=le(this.currentProfile,s)??le(this.currentProfile,s.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 s=e.peek();if(s){let l=s.value.toLowerCase(),m=(s.normalized??"").toLowerCase();o.some(c=>c.toLowerCase()===l||c.toLowerCase()===m)&&e.advance();}}let u=e.peek();if(!u||ra(this.currentProfile.code,u.value))return e.reset(a),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)&&!(u.normalized&&this.isStructuralKeyword(u.normalized))&&!(u.normalized&&this.isRoleMarkerConcept(u.normalized))||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let m=e.peek();if(m&&m.value.startsWith("(")){let c="",p=0,d=0;for(;!e.isAtEnd()&&d++<P.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;c+=f.value,e.advance();for(let y of f.value)y==="("?p++:y===")"&&p--;if(p<=0)break}l+=c;}return fe(ie(n),l)}return e.reset(a),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=c=>{for(let p of [c.value,c.normalized].filter(Boolean))if(le(this.currentProfile,p)??le(this.currentProfile,p.toLowerCase()))return true;return false},i=e.peek();if(!i)return null;let n=i.kind==="selector"&&i.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(i.value);if(!(i.kind==="identifier"&&!this.isStructuralKeyword(i.value)&&!(i.normalized&&this.isStructuralKeyword(i.normalized))&&!(i.normalized&&this.isRoleMarkerConcept(i.normalized))||i.kind==="selector"&&(i.value.startsWith("*")||i.value.startsWith("@"))||n)||r(i))return null;let o=e.mark(),u=i.value;n&&(u=u.substring(1)),e.advance();let s=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)s+=e.peek().value,e.advance();let l=e.peek();if(!l)return e.reset(o),null;let m;for(let c of [l.value,l.normalized].filter(Boolean))if(m=le(this.currentProfile,c)??le(this.currentProfile,c.toLowerCase()),m)break;return m?(e.advance(),fe(ie(m),s)):(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())}isRoleMarkerConcept(e){return new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]).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&&sa.has(i))}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++<P.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(u.value==="{")a++;else if(u.value==="}"&&(a--,a===0))return n.push("}"),M(n.join(" "));n.push(u.value);}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(),e.advance();let a=[],o=false,u=0;for(;!e.isAtEnd()&&u++<P.MAX_METHOD_ARGS+2;){let s=e.peek();if(!s)break;if(s.value===")"){e.advance(),o=true;break}if(s.value===","){e.advance();continue}a.push(s.value),e.advance();}return o?{type:"expression",raw:`${r.value}(${a.join(", ")})`}:(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 u=[];for(;!e.isAtEnd()&&u.length<P.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.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"||P.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let d=i.value,f=[],y=0;for(;y<P.MAX_PROPERTY_DEPTH;){let k=e.peek();if(k&&k.kind==="selector"&&/^\.[a-zA-Z_]/.test(k.value))d+=`.${k.value.slice(1)}`,f.push(k.value.slice(1)),e.advance(),y++;else break}let h=e.peek(),g=!!h&&h.value.startsWith("(");if(r&&!g&&f.length>0&&Be(a))return fe(ie(a),f.join("."));if(g){let k=e.mark(),w=[],A=0,z=false;for(;!e.isAtEnd();){let E=e.peek();if(!E)break;if(E.value==="(")A++;else if(E.value===")"){if(w.push(E.value),e.advance(),A--,A===0&&(z=true),z)break;continue}w.push(E.value),e.advance();}z?d+=w.join(""):e.reset(k);}return {type:"expression",raw:d}}let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="identifier")return e.reset(n),null;e.advance();let l=`${i.value}.${s.value}`,m=1;for(;!e.isAtEnd()&&m<P.MAX_PROPERTY_DEPTH;){let d=e.peek();if(!d||d.kind!=="operator"||d.value!==".")break;e.advance();let f=e.peek();if(!f||f.kind!=="identifier")break;e.advance(),l+=`.${f.value}`,m++;}let c=e.peek();if(c&&c.kind==="punctuation"&&c.value==="("){e.advance();let d=[],f=0;for(;!e.isAtEnd()&&d.length<P.MAX_METHOD_ARGS;){let h=e.peek();if(!h)break;if(h.kind==="punctuation"&&h.value===")"){if(f===0){e.advance();break}f--;}if(h.kind==="punctuation"&&h.value==="("&&f++,h.kind==="punctuation"&&h.value===","){e.advance();continue}d.push(h.value),e.advance();}return {type:"expression",raw:`${l}(${d.join(", ")})`}}let p=i.value.toLowerCase();if(r&&Be(p)){let d=l.split(".").slice(1).join(".");return fe(ie(p),d)}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",u=!!n&&n.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(n?.normalized??"").toLowerCase()!=="source")return false;let p=ve[this.currentPatternCommand];return !!p&&p.roles.some(d=>d.role==="source")})(),l=!!n&&!!a&&a!=="'s"&&n.value===a&&(n.kind==="particle"||n.kind==="punctuation")&&!s;if(!o&&!l&&!u)return e.reset(i),null;e.advance(),u&&e.advance();let m=e.peek();return !m||!(m.kind==="identifier"||(o||u)&&(m.kind==="selector"||m.kind==="keyword"))?(e.reset(i),null):(e.advance(),fe(ye(r.value),m.value))}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 fe(ye(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)){e.reset(a);for(let s of i.keys())o.has(s)||i.delete(s);return r.optional||false}return true}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return ye(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Be(r)?ie(r):M(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return ye(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return ie(e.value);let i=e.value.toLowerCase();return Be(i)?ie(i):{type:"expression",raw:e.value};case "url":return M(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 M(n,"string")}if(e==="true")return M(true,"boolean");if(e==="false")return M(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?M(e,"duration"):M(n,"number")}let i=parseFloat(e);return isNaN(i)?M(e,"string"):M(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}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=r.value.toLowerCase();if(P.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 u=a?(a.normalized??a.value).toLowerCase():"";if(a&&P.POSITIONAL_OR_SCOPE_KEYWORDS.has(u))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",m=this.currentProfile?.wordOrder!=="SOV"&&P.COMMAND_ACTION_KEYWORDS.has(l),c=!s||s.kind==="particle"||P.CLAUSE_BOUNDARY_KEYWORDS.has(l)||m;if(a&&a.kind==="keyword"&&this.currentProfile?.code!=="en"&&Be(u)&&c||a&&a.kind==="keyword"&&this.currentProfile?.code==="en"&&Be(u))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}};U.POSITIONAL_KEYWORDS=new Set(["first","last","next","previous","random","closest"]);U.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);U.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then"]);U.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);U.COMMAND_ACTION_KEYWORDS=new Set(Object.keys(ve).map(t=>t.toLowerCase()));U.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);U.OF_POSSESSIVE_MARKERS={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"]),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"])};U.RUN_OPERATORS=new Set(["+","-","*","/"]);U.MAX_BRACE_RUN_TOKENS=64;U.MAX_PROPERTY_DEPTH=10;U.MAX_METHOD_ARGS=20;U.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);U.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var la=U,Q=new la;function H(t,e){return ui(t,e)}function Kr(){return oi()}var Ge=["if","unless","repeat","for","while"];function ne(t,e){let r=new Set([e]),n=N(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 J(t,e){return e.has(t.value.toLowerCase())?true:t.normalized?e.has(t.normalized.toLowerCase()):false}var ca=new Set(Ge);function ur(t,e){let r=t.normalized?.toLowerCase();return r?ca.has(r):e.some(i=>J(t,i))}var Ar=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),ma=new Set(["destination","source","style","patient","on","from","to"]);function pa(t){if(!t||t.kind==="selector")return false;let e=(t.normalized??t.value).toLowerCase(),r=t.value.toLowerCase();return !(Ar.has(e)||Ar.has(r)||ma.has(e))}var Dr=new Set(["ja","ko"]);function ir(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 Ur(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(/[,،、]/)){let o=a.trim();o&&r.push(o);}}return {parameters:r,headerEnd:i}}function Hr(t,e,r){let i=e+1;if(i>=t.length)return -1;let n=ir(N(r)?.roleMarkers?.patient);return n.size>0&&J(t[i],n)&&i++,i<t.length?i:-1}function da(t,e,r){if(!N(e))return null;let i=ne(e,"behavior"),n=ne(e,"def"),a=t.toLowerCase(),o=[...i].some(m=>a.includes(m)),u=/\bdef\b/.test(a)||[...n].some(m=>m!=="def"&&a.includes(m));if(!o&&!u)return null;let s=H(t,e).tokens;if(s.length<2)return null;if(J(s[0],i))return Br(t,e,s,r,0);let l=s.findIndex((m,c)=>c>0&&J(m,i));return l>0&&/^[A-Z][A-Za-z0-9_]*$/.test(s[0].value)?Br(t,e,s,r,l):J(s[0],n)?ya(t,e,s,r):null}function fa(t,e,r){let i=N(e);if(!i)return null;let n=i.wordOrder!=="SOV",a=Dr.has(e)?ir(i.roleMarkers?.event):new Set,o=Dr.has(e)?ir(i.keywords?.on):new Set,u=a.size>0&&o.size>0,s=ne(e,"end"),l=ne(e,"on"),m=t.toLowerCase(),c=[...s].some(E=>m.includes(E)),p=(n||u)&&(()=>{let E=0;for(let b of l)if(b){for(let v=m.indexOf(b);v>=0;v=m.indexOf(b,v+b.length))if(++E>=2)return true}return false})();if(!c&&!p)return null;let d=H(t,e).tokens;if(d.length<2)return null;let f=Ge.map(E=>ne(e,E)),y=E=>ur(E,f),h=E=>J(E,s),g=[],k=0,w=0;for(let E=0;E<d.length;E++){let b=d[E];if(h(b)){if(k>0){k--;continue}let v=t.slice(d[w].position.start,b.position.start).trim();v&&g.push(v),w=E+1;}else if(y(b))k++;else if(n&&k===0&&E>w&&J(b,l)&&pa(d[E+1])){let v=t.slice(d[w].position.start,b.position.start).trim();v&&g.push(v),w=E;}else if(u&&k===0&&E-1>w&&J(b,a)&&d[E+1]!==void 0&&J(d[E+1],o)){let v=d[E-1],C=t.slice(d[w].position.start,v.position.start).trim();C&&g.push(C),w=E-1;}}if(w<d.length){let E=t.slice(d[w].position.start).trim();E&&g.push(E);}if(g.length<2)return null;let A=[],z=[];for(let E of g){let b;try{b=r.statement(E,e);}catch{return null}if(!b||b.kind!=="event-handler")return null;let v=b;A.push(v);let C=!v.body||v.body.length===0;z.push(C?.2:v.metadata?.confidence??.75);}return tr(A,"then",{sourceLanguage:e,confidence:Ue(z),sourceText:t})}function Ue(t){return t.length>0?t.reduce((e,r)=>e+r,0)/t.length:0}function Gr(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 Br(t,e,r,i,n){let a=n>0,o=a?0:Hr(r,n,e);if(o<0)return null;let u=r[o],s=u.value;if(!/^[A-Z][A-Za-z0-9_]*$/.test(s))return null;let{parameters:l,headerEnd:m}=Ur(t,u),c=a?n+1:r.findIndex(v=>v.position.start>=m);c<=o&&(c=o+1);let p=ne(e,"init"),d=ne(e,"end"),f=Ge.map(v=>ne(e,v)),y=v=>ur(v,f),h=v=>J(v,d),g=[],k=[],w=[],A=false,z=0,E=c;for(let v=c;v<r.length;v++){let C=r[v];if(h(C)){if(z>0){z--;continue}if(v===E){A=true;break}if(J(r[E],p)){let B=t.slice(r[E].position.end,C.position.start).trim();if(B)try{let D=Gr(i.body(B,e));k.push(...D),w.push(Ue(D.map(O=>O.metadata?.confidence??.75)));}catch{w.push(0);}}else {let B=t.slice(r[E].position.start,C.position.start).trim();try{let D=i.statement(B,e);if(D&&D.kind==="event-handler"){let O=D;g.push(O);let x=!O.body||O.body.length===0;w.push(x?.2:O.metadata?.confidence??.75);}else w.push(0);}catch{w.push(0);}}E=v+1;}else y(C)&&z++;}if(g.length===0&&k.length===0)return null;let b=(A?1:.8)*Ue(w);return Ri(s,l,g,k.length>0?k:void 0,{sourceLanguage:e,confidence:b,sourceText:t})}function ya(t,e,r,i){let n=Hr(r,0,e);if(n<0)return null;let a=r[n],o=a.value;if(!/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/.test(o))return null;let{parameters:u,headerEnd:s}=Ur(t,a),l=r.findIndex(z=>z.position.start>=s);l<=n&&(l=n+1);let m=ne(e,"end"),c=Ge.map(z=>ne(e,z)),p=z=>ur(z,c),d=z=>J(z,m),f=0,y=-1;for(let z=l;z<r.length;z++)if(d(r[z])){if(f===0){y=z;break}f--;}else p(r[z])&&f++;let h=r[l]?.position.start??s,g=y>=0?r[y].position.start:t.length,k=t.slice(h,g).trim();if(!k)return null;let w;try{w=Gr(i.body(k,e));}catch{return null}if(w.length===0)return null;let A=Ue(w.map(z=>z.metadata?.confidence??.75));return y<0&&(A*=.8),Pi(o,u,w,{sourceLanguage:e,confidence:A,sourceText:t})}var xe={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};Object.fromEntries(Object.entries(xe).map(([t,e])=>{let r={};for(let[i,n]of Object.entries(e))n in r||(r[n]=i);return [t,r]}));var Se=new Set(["if","unless","while","repeat","for"]),za=new Set(["then","end","else","if","unless","while","for","repeat","and"]),Ca=new Set(["first","last","next","previous","random","closest"]),Te=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"]),Sr=class extends Error{constructor(t,e,r,i){super(t),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=i;}};function _(t,e,r){return {message:t,severity:e,source:"semantic-parser",...r&&{code:r}}}function K(t,e){return e.length===0?t:{...t,diagnostics:e}}function xr(t){if(t.length>=2){let e=t[0];if((e==='"'||e==="'")&&t.endsWith(e))return t.slice(1,-1)}return t}var ka=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function Yr(t,e){if(!t||typeof t!="object")return t;if(t.action&&t.roles instanceof Map){let i=ce(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"),u=a.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!u||u.type==="literal")&&(a.delete("patient"),a.set("destination",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 u=a.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(u.value)&&a.set("patient",{type:"expression",raw:u.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"),u=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof u=="string"&&Te.has(u.toLowerCase())&&(a.delete("duration"),a.set("event",{type:"literal",value:u,dataType:"string"}));}}if(t.kind==="command"&&t.action!=="on"){let a=t.roles,o=a.get("event");if(o&&o.type==="expression"){let u=o.raw;typeof u=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(u)&&a.set("event",{type:"literal",value:u,dataType:"string"});}}if(e?.size){let a=t.roles;for(let o of ["destination","source"]){let u=a.get(o);u&&u.type==="literal"&&typeof u.value=="string"&&e.has(u.value)&&a.set(o,{type:"expression",raw:u.value});}}}let r=t;for(let i of ka){let n=r[i];if(Array.isArray(n))for(let a of n)Yr(a,e);}return t}var X=class F{constructor(){this.parseDepth=0,this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++;try{return Yr(this.parseInternal(e,r),this.boundIdentifiers)}finally{this.parseDepth--;}}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=da(e,r,{statement:(v,C)=>this.parse(v,C),body:(v,C)=>this.parseStatements(v,C)});if(i)return i;let n=fa(e,r,{statement:(v,C)=>this.parse(v,C),body:(v,C)=>this.parseStatements(v,C)});if(n)return n;let{modifiers:a,remainingInput:o}=this.extractStandaloneModifiers(e,r),u=o||e,l=this.stripAsyncModifier(u,r).remainingInput??u,c=this.stripDoNotThrowModifier(l,r).remainingInput??l,p=[],d=H(c,r),f=ae(r);if(f.length===0)throw new Sr(`No patterns available for language: ${r}`,r,c,[_(`No patterns registered for language '${r}'`,"error","no-patterns")]);let y=[...f].sort((v,C)=>C.priority-v.priority);{let v=d.tokens;if(N(r)?.wordOrder==="VSO"&&v.length>=4&&v[0]?.normalized==="source"){let C=v.findIndex(B=>B.normalized==="on");if(C>=2&&C+1<v.length){let B=c.slice(v[0].position.start,v[C].position.start).trim(),D=v[C+1].position.end,O=c.slice(v[C].position.start,D)+" "+B+c.slice(D);if(O!==c)try{let x=this.parse(O,r);if(x&&x.kind==="event-handler"){let T=a?this.applyModifiers(x,a):x;return K(T,p)}}catch{}}}}{let v=d.tokens;for(let C=1;C<v.length-1;C++){let B=v[C],D=B.value,O=(B.normalized??B.value).toLowerCase();if(!(O==="or"||F.OR_KEYWORDS.has(D)||F.OR_KEYWORDS.has(O)))continue;let T=v[C+1],L=(T.normalized??T.value).toLowerCase();if(!F.KNOWN_EVENTS.has(L))break;let R=C+1,$=v[C+2];$&&$.kind==="selector"&&$.value.startsWith("[")&&(R=C+2);let q=v[C].position.start,me=v[R].position.end,ee=(c.slice(0,q).trimEnd()+" "+c.slice(me).trimStart()).trim();if(ee&&ee!==c)try{let pe=this.parse(ee,r);if(pe&&pe.kind==="event-handler"){pe.additionalEvents=[{type:"literal",value:L}];let Je=a?this.applyModifiers(pe,a):pe;return K(Je,p)}}catch{}break}}let h=y.filter(v=>v.command==="on"),g=d.mark(),k=Q.matchBest(d,h);if(k){p.push(_(`event pattern matched: ${k.pattern.id} (confidence: ${k.confidence.toFixed(2)})`,"info","pattern-match"));let v=false;if(/^event-[a-z]+-bare$/.test(k.pattern.id)){let C=k.captured.get("event"),B=(C?.raw??C?.value??"").toString().toLowerCase(),D=xe[r],O=F.KNOWN_EVENTS.has(B)||!!D&&Object.keys(D).some(x=>x.toLowerCase()===B);if(B&&!O){let x=this.trySOVEventExtraction(c,r,y);if(x){p.push(_(`bare-event mis-anchor on "${B}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let T=a?this.applyModifiers(x,a):x;return K(T,p)}if(C?.type==="reference"||C?.type==="expression"){d.reset(g);let T=y.filter(R=>R.command!=="on"),L=Q.matchBest(d,T);d.reset(g),L&&L.pattern.command!=="on"?(v=true,p.push(_(`bare-event mis-anchor on reference "${B}" rejected; command ${L.pattern.command} preferred`,"info","stage-bare-event-guard"))):Q.matchBest(d,h);}}}if(!v){let C=this.buildEventHandler(k,d,r),B=a?this.applyModifiers(C,a):C;return K(B,p)}}p.push(_(`event patterns: ${h.length} tried, no match`,"info","stage-event"));let w=this.tryTrailingEventExtraction(c,r,y);if(w){p.push(_("trailing event extraction succeeded","info","stage-trailing-event"));let v=a?this.applyModifiers(w,a):w;return K(v,p)}let A=y.filter(v=>v.command!=="on"),z=Q.matchBest(d,A);if(z){if(Se.has(z.pattern.command)){let v=this.trySOVEventExtraction(c,r,y);if(v){p.push(_(`SOV event extraction preferred over bare ${z.pattern.command} command`,"info","stage-sov-loop"));let B=a?this.applyModifiers(v,a):v;return K(B,p)}let C=this.tryMidStreamEventExtraction(c,r,y);if(C){p.push(_(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-loop"));let B=a?this.applyModifiers(C,a):C;return K(B,p)}}else if(F.KNOWN_EVENTS.has(z.pattern.command)&&this.hasSOVEventMarkerHead(c,r)){let v=this.trySOVEventExtraction(c,r,y);if(v){p.push(_(`SOV event extraction preferred over command-homonym event ${z.pattern.command}`,"info","stage-sov-homonym"));let C=a?this.applyModifiers(v,a):v;return K(C,p)}}else if(N(r)?.wordOrder==="VSO"){let v=this.tryMidStreamEventExtraction(c,r,y);if(v){p.push(_(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-cmd"));let C=a?this.applyModifiers(v,a):v;return K(C,p)}}if(z.consumedTokens<d.tokens.length&&N(r)?.wordOrder==="SOV"){let v=this.trySOVEventExtraction(c,r,y);if(v){p.push(_(`SOV event extraction preferred over partial ${z.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let C=a?this.applyModifiers(v,a):v;return K(C,p)}}return p.push(_(`command pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match")),K(this.buildCommand(z,r),p)}if(p.push(_(`command patterns: ${A.length} tried, no match`,"info","stage-command")),!c.includes(`
4
- `)&&N(r)?.wordOrder==="VSO"){let v=this.tryMidStreamEventExtraction(c,r,y);if(v){p.push(_("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let C=a?this.applyModifiers(v,a):v;return K(C,p)}}let E=this.trySOVEventExtraction(c,r,y);if(E){p.push(_("SOV event extraction succeeded","info","stage-sov"));let v=a?this.applyModifiers(E,a):E;return K(v,p)}p.push(_("SOV event extraction: no event keyword found","info","stage-sov"));let b=this.tryCompoundCommandParsing(d,A,r);if(b)return p.push(_("compound command parsing succeeded","info","stage-compound")),K(b,p);throw p.push(_("compound parsing: no then-keywords or no command matches","info","stage-compound")),p.push(_(`all parse stages exhausted for "${c}"`,"error","parse-failed")),new Sr(`Could not parse input in ${r}: ${c}`,r,c,p)}parseStatements(e,r){let i=H(e,r),n=ae(r).filter(a=>a.command!=="on").sort((a,o)=>o.priority-a.priority);return this.parseBodyWithClauses(i,n,r)}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Kr()}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=Z(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 a=Q.extractEventModifiers(r),o=this.extractOrConjunctionEvents(r,i),u=n;o.length>0&&n.type==="literal"&&(u={type:"literal",value:[String(n.value),...o.map(c=>String("value"in c?c.value:""))].join(" or ")});let s,l=e.captured.get("action");if(l&&l.type==="literal"&&l.value==="if"){let m=r.tokens,c=-1;for(let p=r.position()-1;p>=0;p--){let d=m[p],f=(d.normalized??d.value).toLowerCase();if(this.isIfKeyword(f,i)){c=p;break}}if(c>=0){let p=ae(i).filter(h=>h.command!=="on").sort((h,g)=>g.priority-h.priority),d=new te(m.slice(c),i),f=this.parseBodyWithClauses(d,p,i);if(f.some(h=>h.kind==="conditional")||f.length===1&&f[0]?.kind==="compound"&&f[0].statements.some(h=>h.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return Me(u,f,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}}}if(l&&l.type==="literal"){let m=l.value,c={};for(let[A,z]of e.captured)A!=="event"&&A!=="action"&&A!=="continues"&&(c[A]=z);if(m==="repeat"){let A=r.peek(),z=b=>(b.normalized??b.value).toLowerCase();if(A&&A.kind==="keyword"&&z(A)==="forever")c.loopType={type:"literal",value:"forever"},delete c.patient,r.advance();else if(A&&A.kind==="keyword"&&z(A)==="event"){r.advance();let b=r.peek();if(b)for(c.event={type:"literal",value:z(b)},c.loopType={type:"literal",value:"until-event"},delete c.patient;!r.isAtEnd();){let v=r.peek();if(!v||v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,i)||this.isEndKeyword(v.value,i)))break;r.advance();}}let E=c.patient;E&&E.type==="reference"&&E.value==="me"&&delete c.patient;}let p=Z(m,c,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(p),!Se.has(m)||m==="repeat"){let A=e.pattern.id.includes("verb-first"),z=r.tokens,E=r.position(),b=C=>C.kind==="conjunction"||C.kind==="keyword"&&(this.isThenKeyword(C.value,i)||this.isEndKeyword(C.value,i)),v=-1;for(let C=E-1;C>=0;C--){let B=z[C];if(b(B))break;if((B.normalized??B.value).toLowerCase()===m){v=C;break}}if(v>=0){let C=E;for(;C<z.length&&!b(z[C]);)C++;let B=z.slice(v,C),D=B;if(A){let O=String(n.value??"").toLowerCase(),x=B.findIndex(T=>(T.normalized??T.value).toLowerCase()===O);if(x<0)D=null;else {let T=B[x-1],L=T&&T.kind==="keyword"&&T.normalized?.toLowerCase()==="on"?x-1:x;D=[...B.slice(0,L),...B.slice(x+1)];}}if(D&&D.length>1){let O=ae(i).filter(V=>V.command!=="on").sort((V,ue)=>ue.priority-V.priority),x=this.parseClause(D,O,i),T=x[0],L=V=>V!==null&&typeof V=="object"&&typeof V.type=="string"?V.type:typeof V,R=ce(m),$=R?.primaryRole,q=V=>V==="patient"&&$&&$!=="patient"&&!R?.roles.some(ue=>ue.role==="patient")?$:V,me=(V,ue)=>{if(!Se.has(m)||!R)return false;let Ce=R.roles.find(kt=>kt.role===q(V));return Ce?Ce.expectedTypes.length>0&&!Ce.expectedTypes.includes(L(ue)):true},ee=!!T&&T.kind==="command"&&Object.entries(c).every(([V,ue])=>{if(me(V,ue))return true;let Ce=T.roles.get(q(V));return Ce!==void 0&&L(Ce)===L(ue)}),pe=T?.metadata?.patternId??"",Je=!Se.has(m)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(pe);if(x.length===1&&T&&T.kind==="command"&&T.action===m&&ee&&Je&&T.roles.size>Object.keys(c).length)for(p=T;r.position()<C;)r.advance();}}}if(!Se.has(m)){let A=p;if(ce(m)?.roles.some(D=>D.role==="quantity"&&!D.required)&&!A.roles.has("quantity")){let D=r.peek();D&&/^-?\d+(\.\d+)?$/.test(D.value)&&(p=Z(m,{...Object.fromEntries(A.roles),quantity:{type:"literal",value:parseFloat(D.value),dataType:"number"}},A.metadata),r.advance());}let E=p;if(ce(m)?.roles.some(D=>D.role==="duration"&&!D.required)&&!E.roles.has("duration")){let D=r.peek();D&&/^\d+(\.\d+)?(ms|s)$/i.test(D.value)&&(p=Z(m,{...Object.fromEntries(E.roles),duration:{type:"literal",value:D.value,dataType:"string"}},E.metadata),r.advance(),this.consumeForPostposition(r,i));}let v=p,C=ce(m);if(C?.roles.find(D=>D.role==="responseType"&&!D.required)&&!v.roles.has("responseType")){let D=R=>typeof R=="string"&&F.RESPONSE_TYPE_WORDS.has(R.toLowerCase()),O=(R,$)=>{let q=Object.fromEntries(v.roles);$&&delete q.destination,q.responseType={type:"expression",raw:R},p=Z(m,q,v.metadata);},x=v.roles.get("destination"),T=C?.roles.find(R=>R.role==="destination"),L=x?.raw??x?.value;if(x&&T&&!T.expectedTypes.includes(x.type)&&D(L))O(L,true);else {let R=r.peek();R&&D(R.value)&&(O(R.value,false),r.advance());}}if(m==="wait"){let D=p;if(!D.roles.has("event")){let O=r.peek();if(O&&Te.has(O.value.toLowerCase())){let x=Object.fromEntries(D.roles),T=x.duration;T&&T.type!=="literal"&&T.type!=="expression"&&delete x.duration;let L=x.patient;L&&L.type==="reference"&&L.value==="me"&&delete x.patient,x.event={type:"literal",value:O.value,dataType:"string"},p=Z(m,x,D.metadata),r.advance(),this.consumeForPostposition(r,i);}}}}let d=e.captured.get("continues"),f=d?.type==="literal"&&d.value==="then",y=r.peek(),h=!!y&&this.isThenKeyword(y.value,i),k=Se.has(m)&&!!y&&!this.isEndKeyword(y.value,i),w=!!y&&!this.isEndKeyword(y.value,i);if(f||h||k||w){let A=ae(i).filter(b=>b.command!=="on").sort((b,v)=>v.priority-b.priority),z=ae(i).filter(b=>b.id.startsWith("grammar-")&&b.id.includes("-continuation")).sort((b,v)=>v.priority-b.priority),E=this.parseBodyWithGrammarPatterns(r,A,z,i);E.length>0?s=[p,...E]:s=[p];}else s=[p];}else {let m=ae(i).filter(c=>c.command!=="on").sort((c,p)=>p.priority-c.priority);s=this.parseBodyWithClauses(r,m,i);}return Me(u,s,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,i){let n=[],a=[],o=0,u=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(a.length===0){let f=this.consumeJsBlock(e,i);if(f){n.push(f);continue}let y=this.tryParseConditionalBlock(e,r,i);if(y){n.push(y);continue}}let l=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,i),m=a[a.length-1],c=e.peek(1),p=m?.value.toLowerCase()==="at"&&c?.value.toLowerCase()==="of"||Cr(i,s.value,m?.value,c?.value),d=s.kind==="keyword"&&this.isEndKeyword(s.value,i)&&!p;if(d&&o>0){o--,u.pop(),a.push(s),e.advance();continue}if(l&&u.includes("if")){a.push(s),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(y=>{let h=y;return (h.action==="for"||h.action==="repeat"||h.action==="while")&&(!Array.isArray(h.body)||h.body.length===0)}).length,u.length=0;for(let y=0;y<o;y++)u.push("other");}e.advance();continue}if(d){e.advance();let f=[];for(;!e.isAtEnd();){let y=e.peek();if(!y||y.kind==="conjunction"||y.kind==="keyword"&&(this.isThenKeyword(y.value,i)||this.isEndKeyword(y.value,i)))break;f.push(y),e.advance();}if(f.length>0){let y=a.length>0?this.parseClause(a,r,i):[];y.length===0&&a.length>0?n.push(...this.parseClause([...a,...f],r,i)):(n.push(...y),n.push(...this.parseClause(f,r,i)));}else if(a.length>0){let y=this.parseClause(a,r,i);n.push(...y);}a.length=0;break}if(s.kind==="keyword"){let f=(s.normalized??s.value).toLowerCase();(this.isIfKeyword(f,i)||this.isUnlessKeyword(f,i)||f==="while"||f==="for"||f==="repeat")&&(o++,u.push(this.isIfKeyword(f,i)?"if":"other"));}a.push(s),e.advance();}if(a.length>0){let s=this.parseClause(a,r,i);n.push(...s);}this.foldFrontedWhileIntoRepeat(n,i);for(let s=n.length-1;s>=0;s--){let l=n[s];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&n.splice(s,1);}return n.length>1?[tr(n,"then",{sourceLanguage:i})]:n}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 u=new Map(a.roles);u.set("condition",o),u.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(i,2,{...a,roles:u,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 h=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(h,i)&&(n="unless",a=e.slice(0,-1));}let u=null;if(n&&a.length>=3){let h=N(i),g=h?F.buildVerbLookup(h):null;if(g)for(let k=1;k<a.length-1;k++){let w=a[k],A=g.get(w.value.toLowerCase())??(w.normalized?g.get(w.normalized.toLowerCase()):void 0);if(A&&!F.CONDITION_OPERATORS.has(A)){u=a.slice(0,k),a=a.slice(k);break}}}let s=new te(a,i),l=[],m=0,c=[],p=u,d=()=>{if(c.length===0)return;let h=c.slice();if(c.length=0,n&&l.length===0&&p===null){p=h;return}let g=h[0];if(g&&(g.kind==="identifier"||g.kind==="selector"||g.kind==="literal"||g.kind==="reference"))for(let w of this.parseSOVClauseByVerbAnchoring(h,i)){let A=w.action,z=w.roles;A&&ce(A)&&z instanceof Map&&z.size>0&&l.push(w);}};for(;!s.isAtEnd();){let h=s.peek(),g=!!h&&h.normalized?.toLowerCase()==="repeat",k=s.mark(),w=Q.matchBest(s,r);if(g&&w&&w.pattern.command!=="repeat"){s.reset(k),d(),l.push(Z("repeat",{},{sourceLanguage:i,confidence:.6})),m++,s.advance();continue}if(w&&w.pattern.command==="if"){let A=s.mark(),z=c.length;for(s.reset(k);!s.isAtEnd();){let b=s.peek();if(!b||this.isIfKeyword((b.normalized??b.value).toLowerCase(),i))break;c.push(b),s.advance();}let E=this.tryParseConditionalBlock(s,r,i);if(E){d(),l.push(E),m++;continue}c.length=z,s.reset(A);}if(w){d();let A=this.buildCommand(w,i);l.push(A),m++,this.tryAttachTrailingRole(s,A,i);}else {let A=s.peek();A&&A.normalized?.toLowerCase()==="repeat"?(d(),l.push(Z("repeat",{},{sourceLanguage:i,confidence:.6})),m++):A&&c.push(A),s.advance();}}d();let f=l;if(m===0){let h=this.parseSOVClauseByVerbAnchoring(a,i);h.length>0&&(f=h);}let y=p;return n&&f.length>0&&y&&y.length>0?[Z(n,{condition:{type:"expression",raw:this.joinTokenText(y)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85}),...f]:f}tryAttachTrailingRole(e,r,i){let n=ce(r.action);if(!n)return;let a=N(i);if(!a)return;let o=r.roles,u=(l,m)=>{if(!l)return false;if(l.kind==="selector")return true;let c=(l.normalized??l.value).toLowerCase();return za.has(c)?false:c==="body"||c==="it"||c==="you"||c==="result"||c==="document"||c==="window"||this.boundIdentifiers.has(l.value)?true:m?false:l.kind==="identifier"||l.kind==="reference"},s=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:m}of s){if(!n.roles.some(h=>h.role===l))continue;let c=a.roleMarkers?.[l];if(!c)continue;let p=o.get(l);if(p&&!(p.type==="reference"&&p.value==="me"))continue;let d=h=>{if(!h||h.kind!=="particle"&&h.kind!=="keyword")return false;let g=h.value.toLowerCase();return c.primary?.toLowerCase()===g?true:m?false:(h.normalized??"").toLowerCase()===l?true:!!c.alternatives?.some(k=>k.toLowerCase()===g)},f=e.peek(),y=e.peek(1);if(!f||!y)return;if(m&&c.position==="after"){let h=e.peek(2),g=(f.normalized??f.value).toLowerCase();if(Ca.has(g)&&y.kind==="selector"&&d(h)){o.set(l,{type:"expression",raw:`${g} ${y.value}`}),e.advance(),e.advance(),e.advance();return}}if(c.position==="after"){if(u(f,m)&&d(y)){let h=this.tokenToSemanticValue(f);e.advance(),e.advance(),h&&o.set(l,h);return}}else if(d(f)&&u(y,m)){e.advance();let h=this.tokenToSemanticValue(e.advance());h&&o.set(l,h);return}}}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=N(r);if(!i||i.wordOrder!=="SOV")return [];let n=F.buildVerbLookup(i),a=F.buildMarkerToRoleLookup(i),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let f=u;f<e.length;f++){let y=e[f];if(a.has(y.value))continue;let h=n.get(y.value.toLowerCase()),g=y.normalized?n.get(y.normalized.toLowerCase()):void 0,k=h||g;if(k){s=f,l=k;break}}if(s===-1)break;let m=e.slice(u,s),c=e.length;for(let f=s+1;f<e.length;f++){let y=e[f];if(y.kind==="conjunction"||this.isThenKeyword(y.value,r)){c=f;break}if(f>s+1&&!a.has(y.value)&&(n.get(y.value.toLowerCase())||(y.normalized?n.get(y.normalized.toLowerCase()):void 0))){c=f;break}}let p=e.slice(s+1,c),d=this.extractRolesFromMarkedTokens(m,p,a,l,r);if(o.push(Z(l,d,{sourceLanguage:r,confidence:.7})),u=c,u<e.length){let f=e[u];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&u++;}}return o}extractRolesFromMarkedTokens(e,r,i,n,a){let o={},u=s=>{let l=[];for(let m of s){let c=i.get(m.value);if(c&&m.kind==="particle"&&l.length>0){let p=this.tokensToSemanticValue(l);if(p){let d=this.mapRoleForCommand(c,n,o);d&&(o[d]=p);}l=[];}else l.push(m);}if(l.length>0)if(l.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(l[0].value)&&!o.duration&&ce(n)?.roles.some(c=>c.role==="duration"))o.duration={type:"literal",value:l[0].value,dataType:"string"};else {let c=this.tokensToSemanticValue(l);c&&(o.patient?o.destination||(o.destination=c):o.patient=c);}};return u(e),u(r),o}mapRoleForCommand(e,r,i){return i[e]?e==="patient"&&!i.destination?"destination":e==="destination"&&!i.patient?"patient":e==="source"&&!i.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let r=e.filter(a=>a.kind!=="whitespace");if(r.length===0)return null;if(r.length===1)return this.tokenToSemanticValue(r[0]);let i=r.map(a=>a.value).join(""),n=r[0];return n.kind==="selector"||n.value.startsWith("#")||n.value.startsWith(".")||n.value.startsWith("@")||n.value.startsWith("*")?ye(i):n.kind==="literal"||n.value.startsWith('"')||n.value.startsWith("'")?M(xr(i),"string"):n.kind==="reference"?ie(i):M(i)}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return ye(r);if(r.startsWith('"')||r.startsWith("'"))return M(xr(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return M(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return M(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return M(false);let i=e.normalized?.toLowerCase();return i==="me"||i==="it"||i==="you"||i==="result"||i==="body"?ie(i):e.kind==="reference"?ie(e.normalized||"me"):M(r)}parseBodyWithGrammarPatterns(e,r,i,n){let a=[],o=[],u=false,s=()=>{!u&&o.length>0&&a.push(...this.parseSOVClauseByVerbAnchoring(o,n)),o=[],u=false;},l=0,m=()=>{let c=0;for(let p of a){let d=p;(d.action==="for"||d.action==="repeat"||d.action==="while")&&(!Array.isArray(d.body)||d.body.length===0)&&c++;}return c-l};for(;!e.isAtEnd();){let c=e.peek();if(c&&this.isThenKeyword(c.value,n)){s(),e.advance();continue}if(c&&this.isEndKeyword(c.value,n)){let d=e.peek(-1),f=e.peek(1);if(!Cr(n,c.value,d?.value,f?.value)){if(s(),m()>0){l++,e.advance();continue}e.advance();break}}if(c&&!u&&this.isIfKeyword((c.normalized??c.value).toLowerCase(),n)){s();let d=this.tryParseConditionalBlock(e,r,n);if(d){a.push(d),u=true;continue}}let p=false;if(i.length>0){let d=Q.matchBest(e,i);if(d){let f=d.pattern.command,y={};for(let[k,w]of d.captured)k!=="event"&&k!=="action"&&k!=="continues"&&(y[k]=w);let h=Z(f,y,{sourceLanguage:n,patternId:d.pattern.id});a.push(h),p=true,u=true;let g=d.captured.get("continues");if(g&&g.type==="literal"&&g.value==="then")continue}}if(!p){let d=e.mark(),f=Q.matchBest(e,r);if(f){if(f.pattern.command==="if"){let h=e.mark();for(e.reset(d);!e.isAtEnd();){let k=e.peek();if(!k||this.isIfKeyword((k.normalized??k.value).toLowerCase(),n))break;e.advance();}let g=this.tryParseConditionalBlock(e,r,n);if(g){s(),a.push(g),u=true;continue}e.reset(h);}let y=this.buildCommand(f,n);a.push(y),this.tryAttachTrailingRole(e,y,n),p=true,u=true;}}p||(c&&o.push(c),e.advance());}s();for(let c=a.length-1;c>=0;c--){let p=a[c];p.kind==="command"&&p.action==="for"&&(!(p.roles instanceof Map)||p.roles.size===0)&&(!Array.isArray(p.body)||p.body.length===0)&&a.splice(c,1);}return a}tryCompoundCommandParsing(e,r,i){let n=e.tokens,a=n.some(l=>l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,i)),o=n.some(l=>this.isElseKeyword(l.value,i));if(!a&&!o)return null;let u=new te(n,i),s=this.parseBodyWithClauses(u,r,i);return s.length===0?null:s.length===1?s[0]:tr(s,"then",{sourceLanguage:i,confidence:.65})}matchEventMarkerPhrase(e,r,i){let n=F.SOV_EVENT_MARKER_PHRASES[i];if(!n)return 0;for(let a of n)if(a.every((o,u)=>e[r+u]?.value===o))return a.length;return 0}hasSOVEventMarkerHead(e,r){let i=F.SOV_EVENT_MARKERS[r];if(i===void 0)return false;let{tokens:n}=H(e,r),a=xe[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length;u++){let s=n[u],l=s.value.toLowerCase(),m=s.normalized?.toLowerCase();if(!(!!m&&(F.KNOWN_EVENTS.has(m)||Te.has(m))||F.KNOWN_EVENTS.has(l)||Te.has(l)||o.has(l)))continue;let p=this.matchEventParamPhrase(n,u+1).len,d=n[u+1+p];if(d&&(d.kind==="particle"||d.kind==="keyword")&&i.has(d.value)||this.matchEventMarkerPhrase(n,u+1+p,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=H(e,r).tokens;if(n.length<3)return null;let a=xe[r],o=new Set;if(a)for(let w of Object.keys(a))o.add(w.toLowerCase());let u=n.length-2,s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))return null;let m=n[n.length-1],c=m.value.toLowerCase(),p=m.normalized?.toLowerCase();if(!(!!p&&F.KNOWN_EVENTS.has(p)||F.KNOWN_EVENTS.has(c)||o.has(c)))return null;let f=p&&F.KNOWN_EVENTS.has(p)?p:a?.[c]??c,y=n.slice(0,u);if(y.length===0)return null;let h=i.filter(w=>w.command!=="on"),g=new te(y,r),k=this.parseBodyWithClauses(g,h,r);return k.length===0?null:Me({type:"literal",value:f},k,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,i){let n=H(e,r).tokens;if(n.length<3)return null;let a=xe[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length-1;u++){let s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let m=n[u+1],c=m.value.toLowerCase(),p=m.normalized?.toLowerCase();if(!(!!p&&F.KNOWN_EVENTS.has(p)||F.KNOWN_EVENTS.has(c)||o.has(c)))continue;let f=p&&F.KNOWN_EVENTS.has(p)?p:a?.[c]??c,y=n.filter((w,A)=>A!==u&&A!==u+1);if(y.length===0)return null;let h=i.filter(w=>w.command!=="on"),g=new te(y,r),k=this.parseBodyWithClauses(g,h,r);return k.length===0?null:Me({type:"literal",value:f},k,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,i){let n=F.SOV_EVENT_MARKERS[r];if(!n)return null;let o=H(e,r).tokens,u=xe[r],s=new Set;if(u)for(let z of Object.keys(u))s.add(z.toLowerCase());let l=F.SOV_SOURCE_MARKERS[r],m=-1,c="",p="",d=1,f=[];for(let z=0;z<o.length;z++){let E=o[z],b=E.value.toLowerCase(),v=b,C="",B=b.indexOf("[");B>0&&(v=b.slice(0,B),C=E.value.slice(B));let D=E.normalized?.toLowerCase(),O=D&&(F.KNOWN_EVENTS.has(D)||Te.has(D)),x=s.has(b)||s.has(v),T=F.KNOWN_EVENTS.has(v)||Te.has(v);if(O||x||T){let L=o[z-1];if(L&&(L.normalized??L.value).toLowerCase()==="event")continue;let R;O?R=D:x?R=u?.[b]??u?.[v]??v:R=v;let $=this.matchEventParamPhrase(o,z+1);if(n.size>0){let q=1+$.len,me=o[z+q];me&&me.kind==="selector"&&me.value.startsWith("[")&&(q+=1);let ee=o[z+q];if(ee&&(ee.kind==="particle"||ee.kind==="keyword")&&n.has(ee.value)){m=z,c=R,p=C||(q===$.len+2?o[z+q-1].value:""),d=q+1,f=$.names;break}}else {m=z,c=R,p=C,d=1+$.len+this.matchEventMarkerPhrase(o,z+1+$.len,r),f=$.names;break}}}if(m===-1){let z=new Set(i.filter(E=>E.command!=="on").map(E=>E.command));for(let E=0;E<o.length;E++){let b=o[E];if(b.kind==="identifier")if(n.size>0){let v=1,C=o[E+1];C&&C.kind==="selector"&&C.value.startsWith("[")&&(v=2);let B=o[E+v];if(B&&(B.kind==="particle"||B.kind==="keyword")&&n.has(B.value)){m=E,c=b.value,p=v===2?o[E+1].value:"",d=v+1;break}}else {let v=this.matchEventMarkerPhrase(o,E+1,r);if(v>0){m=E,c=b.value,p="",d=1+v;break}let C=o[E+1];if(C&&C.kind==="keyword"&&C.normalized!=null&&z.has(C.normalized)){m=E,c=b.value,p="",d=1;break}}}}if(m===-1)return null;let y=new Set;for(let z=m;z<m+d;z++)y.add(z);if(l){let z=m+d;if(z<o.length){let E=o[z];if((E.kind==="particle"||E.kind==="keyword")&&l.markers.has(E.value))y.add(z);else if(this.isStrippableSourceRef(E,l.windowTokens)){let b=o[z+1];b&&(b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value)&&(y.add(z),y.add(z+1));}}if(m>=2){let E=o[m-1];(E.kind==="particle"||E.kind==="keyword")&&l.markers.has(E.value)&&this.isStrippableSourceRef(o[m-2],l.windowTokens)&&(y.add(m-2),y.add(m-1));}for(let E=0;E<m;E++){let b=o[E],v=b.value.toLowerCase(),C=b.normalized?.toLowerCase();if(l.windowTokens.has(v)||C&&l.windowTokens.has(C)){y.add(E);break}}}let h=o.filter((z,E)=>!y.has(E));if(h.length===0)return null;let g=i.filter(z=>z.command!=="on"),k=new te(h,r),w=this.parseBodyWithClauses(k,g,r);if(w.length===0)return null;let A={sourceLanguage:r,confidence:.75};return p&&(A.keyFilter=p),Me({type:"literal",value:c},w,void 0,A,f)}profileKeywordMatches(e,r,i){let n=N(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=N(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(),a={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"])}[r];return a?i==="end"||a.has(i):i==="end"||this.profileKeywordMatches(r,"end",i)}isJsKeyword(e){let r=(e.normalized??e.value).toLowerCase();return r==="js"||this.profileKeywordMatches("en","js",r)}consumeJsBlock(e,r){let i=e.peek();if(!i||!this.isJsKeyword(i))return null;let n=e.mark(),a=[];e.advance();let o=false;for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(e.advance(),this.isEndKeyword(s.value,r)){o=true;break}a.push(s);}if(!o)return e.reset(n),null;let u=a.map(s=>s.value).join(" ").trim();return Z("js",{patient:{type:"expression",raw:u||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}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)}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){let n=e.peek();if(!n)return null;let a=(n.normalized??n.value).toLowerCase();if(!this.isIfKeyword(a,i))return null;let o=e.mark();e.advance();let u=[],s=0;for(;!e.isAtEnd();){let E=e.peek();if(!E)break;let b=(E.normalized??E.value).toLowerCase();if(this.isIfKeyword(b,i)||this.isUnlessKeyword(b,i)){s++,u.push(E),e.advance();continue}if(this.isBlockEndToken(E,e.peek(1)??void 0,i)){if(s===0){e.advance();break}s--,u.push(E),e.advance();continue}u.push(E),e.advance();}if(u.length===0)return e.reset(o),null;let l=N(i),m=l?.wordOrder==="SOV"?F.buildVerbLookup(l):null,c=0,p=0,d=[];for(;c<u.length;c++){let E=u[c],b=(E.normalized??E.value).toLowerCase();if(this.isIfKeyword(b,i)||this.isUnlessKeyword(b,i)?p++:this.isBlockEndToken(E,u[c+1],i)&&p--,p===0&&this.isThenKeyword(E.value,i)){c++;break}if(p===0&&d.length>0){let v=(u[c-1].normalized??u[c-1].value).toLowerCase(),C=u[c-1].value.toLowerCase(),B=(E.normalized??E.value).toLowerCase(),D=F.CONDITION_COPULAS.has(v)||F.CONDITION_COPULAS_SURFACE.has(C)&&F.CONDITION_PREDICATES.has(B),O=m!==null&&m.has(E.value.toLowerCase())&&!F.CONDITION_PREDICATES.has(B);if(!F.CONDITION_OPERATORS.has(B)&&(!D||O)&&(this.tokensBeginCommand(u.slice(c),r,i)||this.sovCommandStartsAt(u.slice(c),m)))break}d.push(E);}if(d.length===0)return e.reset(o),null;let y=[],h=[],g=false,k=0;for(;c<u.length;c++){let E=u[c],b=(E.normalized??E.value).toLowerCase();if(this.isIfKeyword(b,i)||this.isUnlessKeyword(b,i)?k++:this.isBlockEndToken(E,u[c+1],i)&&k--,k===0&&!g&&this.isElseKeyword(E.value,i)){g=true;continue}(g?h:y).push(E);}let w={type:"expression",raw:this.joinTokenText(d)},A=this.parseBranch(y,r,i),z=h.length>0?this.parseBranch(h,r,i):void 0;return A.length===0&&(!z||z.length===0)?(e.reset(o),null):Li(w,A,z,{sourceLanguage:i,patternId:`conditional-${i}-folded`,confidence:1})}joinTokenText(e){return e.map(r=>r.kind==="keyword"?r.normalized??r.value:r.value).join(" ").trim()}tokensBeginCommand(e,r,i){if(e.length===0)return false;let n=new te(e,i);return Q.matchBest(n,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let i=u=>r.has(u.value.toLowerCase())||!!u.normalized&&r.has(u.normalized.toLowerCase()),n=u=>u.kind==="identifier"||u.kind==="selector"||u.kind==="literal"||u.kind==="reference",a=0,o=0;for(;a+1<e.length;){let u=e[a],s=e[a+1];if(!n(u)||s.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 te(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=H(e,r).tokens;if(n.length===0)return {modifiers:null,remainingInput:null};let o=n[0].value.toLowerCase(),u=F.STANDALONE_MODIFIERS[o];if(!u)return {modifiers:null,remainingInput:null};let s={},l=1;if(u==="once")s.once=true;else {let d=1;if(d<n.length){let f=n[d];(f.kind==="keyword"||f.kind==="particle")&&(d++,l++);}if(d<n.length){let f=n[d];if(f.kind==="literal"){let y=f.value.match(/^(\d+)(ms|s|m)?$/);if(y){let h=parseInt(y[1],10),g=y[2]||"ms";g==="s"?h*=1e3:g==="m"&&(h*=6e4),s[u]=h,l=d+1;}}}s[u]||(s[u]=u==="debounce"?300:100);}let m=n.slice(l);if(m.length===0)return {modifiers:null,remainingInput:null};let c=m[0].position.start,p=e.slice(c);return {modifiers:s,remainingInput:p}}stripAsyncModifier(e,r){let i=N(r)?.keywords?.async,n=new Set(["async"]);i?.primary&&n.add(i.primary.toLowerCase()),i?.alternatives?.forEach(l=>n.add(l.toLowerCase()));let a=H(e,r).tokens,o=a.findIndex(l=>n.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let u=a[o],s=(e.slice(0,u.position.start)+e.slice(u.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let i=H(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 m=i[l];if(m.normalized?.toLowerCase()==="throw"){a=l;break}let c=m.kind;if(c==="selector"||c==="literal"||c==="reference"||c==="conjunction")break}if(a===-1)continue;let o=i[n].position.start,u=i[a].position.end,s=(e.slice(0,o)+e.slice(u)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}return {remainingInput:null}}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;let o=(a.normalized||a.value).toLowerCase();if(!F.OR_KEYWORDS.has(o)){e.reset(n);break}e.advance();let u=e.peek();if(!u){e.reset(n);break}let s=(u.normalized||u.value).toLowerCase();e.advance(),i.push({type:"literal",value:s});}return i}};X.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);X.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);X.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"])};X.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};X.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"])}};X.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);X.CONDITION_COPULAS_SURFACE=new Set(["est","\u0435\u0441\u0442\u044C","\u0454","\xE9","ay","\u0647\u0648","adalah","\u0E40\u0E1B\u0E47\u0E19","\u09B9\u09AF\u09BC","\u0939\u0948","dir","kanqa"]);X.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);X.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);X.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};X.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o","\u092F\u093E","\u0985\u09A5\u09AC\u09BE"]);var ba=X,wa=new ba;function Aa(t,e){return wa.parse(t,e)}function Da(t,e){try{let r=H(t,e),i=ae(e);if(i.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let n=[...i].sort((l,m)=>m.priority-l.priority),a=n.filter(l=>l.command==="on"),o=Q.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 u=n.filter(l=>l.command!=="on"),s=Q.matchBest(r,u);return s?{confidence:s.confidence,parseSuccess:!0,patternId:s.pattern.id,action:s.pattern.command,tokensConsumed:s.consumedTokens}:{confidence:0,parseSuccess:!1,error:`Could not match any patterns for: ${t}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function Zr(t,e){try{let i=Aa(t,e);if(i)return {node:i,confidence:i.metadata?.confidence??.8,error:void 0,tokensConsumed:H(t,e).tokens.length}}catch{}let r=Da(t,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function Jr(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 Ba(t,e){let r=t.markerOverride?.[e.code],i=e.roleMarkers[t.role];if(r!==void 0)return {primary:r,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 He(t,e){let r,i;if(t.markerOverride&&t.markerOverride[e.code]!==void 0)r=t.markerOverride[e.code];else {let a=e.roleMarkers[t.role];a&&(r=a.primary,i=a.alternatives?[...a.alternatives]:void 0);}let n=t.markerVariants?.[e.code];if(n&&n.length>0){let a=i?[...i]:[];for(let o of n)o!==r&&!a.includes(o)&&a.push(o);i=a;}return {marker:r,alternatives:i}}function je(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 Sa(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let l=i.primary.split(/\s+/);if(l.length>1)for(let m of l)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 o=e.roleMarkers.destination;o&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary}]}),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let l=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(l);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),a.push(...ze(t,e.roleMarkers.source)),a.push(...or(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`{event} ${i.primary} {destination?} {patient} ${u?.primary||""} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(t),...ge(t)}}}function xa(t,e,r,i,n){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(s);}if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let s=i.primary.split(/\s+/);if(s.length>1)for(let l of s)a.push({type:"literal",value:l});else {let l=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(l);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(u),a.push(...ze(t,e.roleMarkers.source)),a.push(...or(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`{patient} ${o?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(t),...ge(t)}}}function Ta(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 u=e.roleMarkers.destination;if(u&&(a.push({type:"role",role:"destination",optional:false}),a.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),a.push({type:"role",role:"event",optional:false}),i.position==="after"){let l=i.primary.split(/\s+/);if(l.length>1)for(let m of l)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=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-patient-first-dest`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function Fa(t,e,r,i,n){let a=[];a.push({type:"role",role:"event",optional:false});let o=i.alternatives?.filter(m=>!m.includes(" ")&&m.length>1)||[];o.length>0&&a.push({type:"literal",value:o[0],alternatives:o.slice(1)});let u=e.roleMarkers.destination;u&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let m=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};a.push(m);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(l),a.push(...ze(t,e.roleMarkers.source)),a.push(...or(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"},...Ee(t),...ge(t)}}}function Oa(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let u=i.primary.split(/\s+/);if(u.length>1)for(let s of u)a.push({type:"literal",value:s});else {let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(s);}}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 Ra(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 s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(s);}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-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 Pa(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let c=i.primary.split(/\s+/);if(c.length>1)for(let p of c)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 u=[...t.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.sovPosition??999,f=p.sovPosition??999;return d-f});for(let c of u){a.push({type:"role",role:c.role,optional:false});let{marker:p,alternatives:d}=He(c,e);if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};a.push(f);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(s);let l=u.map(c=>`{${c.role}}`).join(" "),m={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))};return je(a,m,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:m}}function La(t,e,r,i,n){let a=[],u=[...t.roles.filter(m=>m.required)].sort((m,c)=>{let p=m.sovPosition??999,d=c.sovPosition??999;return p-d});for(let m of u){a.push({type:"role",role:m.role,optional:false});let{marker:c,alternatives:p}=He(m,e);c&&a.push(p?{type:"literal",value:c,alternatives:p}:{type:"literal",value:c});}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 m=i.primary.split(/\s+/);if(m.length>1)for(let c of m)a.push({type:"literal",value:c});else a.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}let s=u.map(m=>`{${m.role}}`).join(" "),l={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return je(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:`${s} ${r.primary} {event} ${i.primary}`,tokens:a},extraction:l}}function Na(t,e,r,i,n){let a=[],u=[...t.roles.filter(h=>h.required)].sort((h,g)=>{let k=h.sovPosition??999,w=g.sovPosition??999;return k-w}),s=u[0];a.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:m}=He(s,e);if(l){let h=m?{type:"literal",value:l,alternatives:m}:{type:"literal",value:l};a.push(h);}if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let h=i.primary.split(/\s+/);if(h.length>1)for(let g of h)a.push({type:"literal",value:g});else {let g=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(g);}}let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(c);let p=u[1];a.push({type:"role",role:p.role,optional:false});let{marker:d,alternatives:f}=He(p,e);if(d){let h=f?{type:"literal",value:d,alternatives:f}:{type:"literal",value:d};a.push(h);}let y={action:{value:t.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[p.role]:{fromRole:p.role}};return je(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:`{${s.role}} {event} ${i.primary} ${r.primary} {${p.role}}`,tokens:a},extraction:y}}function Tr(t,e,r,i,n){let a=[];if(i.position==="before"){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(s);}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),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...ze(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`${i.primary} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(t),...ge(t)}}}function _a(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),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;if(u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...ze(t,e.roleMarkers.source)),i.position==="before"){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(s);}return a.push({type:"role",role:"event",optional:false}),{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:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(t),...ge(t)}}}function Ma(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.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.svoPosition??999,f=p.svoPosition??999;return d-f});for(let c of s){let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};a.push(f);}a.push({type:"role",role:c.role,optional:false});}if(i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}a.push({type:"role",role:"event",optional:false});let l=s.map(c=>`{${c.role}}`).join(" "),m={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))};return je(a,m,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:m}}function Fr(t,e,r,i,n){let a=[];if(i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}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=[...t.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.svoPosition??999,f=p.svoPosition??999;return d-f});for(let c of s){let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};a.push(f);}a.push({type:"role",role:c.role,optional:false});}let l=s.map(c=>`{${c.role}}`).join(" "),m={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))};return je(a,m,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:m}}function Ia(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 u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),a.push(...ze(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${i.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(t),...ge(t)}}}function ja(t,e,r,i){let n=[];n.push({type:"literal",value:"and",alternatives:["then"]}),n.push({type:"role",role:"event",optional:false});let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(a),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&n.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),n.push(...ze(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(t),...ge(t)}}}var Pe={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function nr(t,e,r=Pe){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=Ka(t,e,a),u=sr(t,e),s=Za(t,e,a);return {id:i,language:e.code,command:t.action,priority:n,template:{format:s,tokens:o},extraction:u}}function Va(t,e,r=Pe){if(t.roles.filter(u=>!u.required).length===0)return null;let n=t.roles.filter(u=>u.required),a={...t,roles:n};return {...nr(a,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:sr(t,e)}}function $a(t,e,r=Pe){if(e.wordOrder!=="SOV")return null;let i=t.roles.filter(u=>u.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.map(u=>({type:"role",role:u.role,optional:false,expectedTypes:u.expectedTypes}));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:sr(t,e)}}function qa(t,e,r=Pe){let i=[];if(i.push(nr(t,e,r)),r.generateSimpleVariants){let n=Va(t,e,r);n&&i.push(n);}for(let n of t.omitRoleVariants??[]){let a={...t,roles:t.roles.filter(u=>u.role!==n)},o=nr(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-no-${n}`,priority:(r.basePriority??100)-8});}if(r.generateVerbFirstVariants!==false){let n=$a(t,e,r);n&&i.push(n);}return i}function Xr(t,e=Pe){let r=[],i=ea();for(let n of i){if(!t.keywords[n.action])continue;let a=qa(n,t,e);if(r.push(...a),t.eventHandler?.eventMarker){let o=Wa(n,t,e);r.push(...o);}}return r}function Wa(t,e,r=Pe){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 [];let u=t.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)i.push(Pa(t,e,a,n,r)),i.push(Na(t,e,a,n,r)),i.push(La(t,e,a,n,r));else {i.push(Sa(t,e,a,n,r)),i.push(xa(t,e,a,n,r));let s=e.roleMarkers.destination;s&&s.primary!==n.primary&&i.push(Ta(t,e,a,n,r));let l=n.primary.split(/\s+/),m=n.alternatives?.some(p=>!p.includes(" ")&&p.length>1);l.length>1&&m&&i.push(Fa(t,e,a,n,r)),i.push(Oa(t,e,a,n,r));let c=Ra(t,e,a,r);c&&i.push(c);}else e.wordOrder==="VSO"?u?(i.push(Fr(t,e,a,n,r)),i.push(Ma(t,e,a,n,r))):(i.push(Tr(t,e,a,n,r)),i.push(_a(t,e,a,n,r)),e.eventHandler?.negationMarker&&i.push(Ia(t,e,a,n,r)),e.tokenization?.prefixes&&i.push(ja(t,e,a,r))):u?i.push(Fr(t,e,a,n,r)):i.push(Tr(t,e,a,n,r));return i}function Ka(t,e,r){let i=[],n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=Ha(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 Ua(i)}function Ua(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 Ha(t,e){let r=[],i=Jr(t.roles,e.wordOrder);for(let n of i){let a=Ga(n,e);n.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function Ga(t,e){let r=[],i=t.markerOverride?.[e.code],n=e.roleMarkers[t.role],a={type:"role",role:t.role,optional:!t.required,expectedTypes:t.expectedTypes};if(i!==void 0){let o=i?i.split(/\s+/).filter(Boolean):[],u=n?.position??"before",s=t.markerOptional?.[e.code]===true,l=m=>{let c={type:"literal",value:m};r.push(s?{type:"group",optional:true,tokens:[c]}:c);};if(u==="before"){for(let m of o)l(m);r.push(a);}else {r.push(a);for(let m of o)l(m);}}else if(n){let o=t.markerVariants?.[e.code]??[],u=()=>{let l=[...new Set([...n.alternatives??[],...o])].filter(m=>m!==n.primary);return l.length?{type:"literal",value:n.primary,alternatives:l}:{type:"literal",value:n.primary}},s=l=>{r.push(e.markersOptional||t.markerOptional?.[e.code]?{type:"group",optional:true,tokens:[l]}:l);};n.position==="before"?(n.primary&&s(u()),r.push(a)):(r.push(a),s(u()));}else r.push(a);return r}function Ya(t,e){let r={};for(let i of t.roles){let n=i.markerOverride?.[e.code],a=e.roleMarkers[i.role];if(n!==void 0)r[i.role]=n?{marker:n}:{};else if(a&&a.primary){let o=i.markerVariants?.[e.code]??[],u=[...new Set([...a.alternatives??[],...o])].filter(s=>s!==a.primary);r[i.role]=u.length?{marker:a.primary,markerAlternatives:u}:{marker:a.primary};}else r[i.role]={};}return r}function sr(t,e){let r=Ya(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 Za(t,e,r){let i=[],a=Jr(t.roles,e.wordOrder).map(o=>{let u=Ba(o,e),s="";return u&&u.primary?u.position==="before"?s=`${u.primary} {${o.role}}`:s=`{${o.role}} ${u.primary}`:s=`{${o.role}}`,o.required?s:`[${s}]`});switch(e.wordOrder){case "SVO":case "VSO":i.push(r.primary,...a);break;case "SOV":i.push(...a,r.primary);break;default:i.push(r.primary,...a);}return i.join(" ")}var Ja=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 Ja;var Xa=[{pattern:"\u3057\u305F\u3089",confidence:.88,conjugationType:"conditional-tara",minStemLength:2},{pattern:"\u3059\u308B\u3068",confidence:.88,conjugationType:"conditional-to",minStemLength:2},{pattern:"\u3059\u308C\u3070",confidence:.85,conjugationType:"conditional-ba",minStemLength:2},{pattern:"\u305F\u3089",confidence:.85,conjugationType:"conditional-tara",minStemLength:2},{pattern:"\u308C\u3070",confidence:.82,conjugationType:"conditional-ba",minStemLength:2},{pattern:"\u3066\u3044\u307E\u3057\u305F",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\u3066\u3044\u307E\u3059",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304F\u3060\u3055\u3044",confidence:.85,conjugationType:"request",minStemLength:2},{pattern:"\u3067\u304F\u3060\u3055\u3044",confidence:.85,conjugationType:"request",minStemLength:2},{pattern:"\u3066\u3044\u308B",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304A\u304F",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u307F\u308B",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u3042\u308B",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304F\u308C",confidence:.8,conjugationType:"casual-request",minStemLength:2},{pattern:"\u3067\u304F\u308C",confidence:.8,conjugationType:"casual-request",minStemLength:2},{pattern:"\u3061\u3083\u3063\u305F",confidence:.82,conjugationType:"contracted-past",minStemLength:2},{pattern:"\u3058\u3083\u3063\u305F",confidence:.82,conjugationType:"contracted-past",minStemLength:2},{pattern:"\u3061\u3083\u3046",confidence:.82,conjugationType:"contracted",minStemLength:2},{pattern:"\u3058\u3083\u3046",confidence:.82,conjugationType:"contracted",minStemLength:2},{pattern:"\u307E\u3057\u305F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"\u307E\u305B\u3093",confidence:.85,conjugationType:"negative",minStemLength:2},{pattern:"\u307E\u3059",confidence:.85,conjugationType:"polite",minStemLength:2},{pattern:"\u3066",confidence:.85,conjugationType:"te-form",minStemLength:2},{pattern:"\u305F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"\u306A\u3044",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"\u306A\u304B\u3063\u305F",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\u3089\u308C\u308B",confidence:.8,conjugationType:"potential",minStemLength:2},{pattern:"\u308C\u308B",confidence:.78,conjugationType:"potential",minStemLength:2},{pattern:"\u3089\u308C\u305F",confidence:.8,conjugationType:"passive",minStemLength:2},{pattern:"\u3055\u305B\u308B",confidence:.8,conjugationType:"causative",minStemLength:2},{pattern:"\u305B\u308B",confidence:.78,conjugationType:"causative",minStemLength:2},{pattern:"\u3088\u3046",confidence:.8,conjugationType:"volitional",minStemLength:2},{pattern:"\u308B",confidence:.75,conjugationType:"dictionary",minStemLength:3}],Qa=[{pattern:"\u3057\u305F\u3089",confidence:.88,conjugationType:"conditional-tara"},{pattern:"\u3059\u308B\u3068",confidence:.88,conjugationType:"conditional-to"},{pattern:"\u3059\u308C\u3070",confidence:.85,conjugationType:"conditional-ba"},{pattern:"\u3057\u3066\u3044\u307E\u3059",confidence:.85,conjugationType:"progressive"},{pattern:"\u3057\u3066\u3044\u308B",confidence:.85,conjugationType:"progressive"},{pattern:"\u3057\u307E\u3057\u305F",confidence:.85,conjugationType:"past"},{pattern:"\u3057\u307E\u3059",confidence:.85,conjugationType:"polite"},{pattern:"\u3057\u306A\u3044",confidence:.82,conjugationType:"negative"},{pattern:"\u3057\u3066",confidence:.85,conjugationType:"te-form"},{pattern:"\u3057\u305F",confidence:.85,conjugationType:"past"},{pattern:"\u3059\u308B",confidence:.88,conjugationType:"dictionary"}];function it(t){let e=t.charCodeAt(0);return e>=12352&&e<=12447}function eo(t){let e=t.charCodeAt(0);return e>=12448&&e<=12543}function ro(t){let e=t.charCodeAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903}function to(t){for(let e of t)if(it(e)||eo(e)||ro(e))return true;return false}var nt=class{constructor(){this.language="ja";}isNormalizable(t){if(!to(t)||t.length<2)return false;let e=t[t.length-1];return it(e)}normalize(t){let e=this.normalizeCompound(t);if(e)return e;let r=this.trySuruNormalization(t);if(r)return r;for(let i of Xa)if(t.endsWith(i.pattern)){let n=t.slice(0,-i.pattern.length),a=i.minStemLength??2;if(n.length<a)continue;let o={removedSuffixes:[i.pattern]};return i.conjugationType&&(o.conjugationType=i.conjugationType),se(n,i.confidence,o)}return We(t)}trySuruNormalization(t){for(let e of Qa)if(t.endsWith(e.pattern)){let r=t.slice(0,-e.pattern.length);if(r.length<1)continue;return se(r,e.confidence,{removedSuffixes:[e.pattern],conjugationType:e.conjugationType,originalForm:"suru-verb"})}return null}normalizeCompound(t){let e=[{pattern:"\u3066\u3044\u306A\u304B\u3063\u305F",suffixes:["\u3066","\u3044","\u306A\u304B\u3063\u305F"],confidence:.8,minStemLength:2},{pattern:"\u3067\u3044\u306A\u304B\u3063\u305F",suffixes:["\u3067","\u3044","\u306A\u304B\u3063\u305F"],confidence:.8,minStemLength:2},{pattern:"\u3066\u3044\u306A\u3044",suffixes:["\u3066","\u3044","\u306A\u3044"],confidence:.82,minStemLength:2},{pattern:"\u3067\u3044\u306A\u3044",suffixes:["\u3067","\u3044","\u306A\u3044"],confidence:.82,minStemLength:2},{pattern:"\u3066\u3044\u305F",suffixes:["\u3066","\u3044","\u305F"],confidence:.85,minStemLength:2},{pattern:"\u3067\u3044\u305F",suffixes:["\u3067","\u3044","\u305F"],confidence:.85,minStemLength:2}];for(let{pattern:r,suffixes:i,confidence:n,minStemLength:a}of e)if(t.endsWith(r)){let o=t.slice(0,-r.length);if(o.length<a)continue;return se(o,n,{removedSuffixes:i,conjugationType:"compound"})}return null}},at={code:"ja",name:"Japanese",nativeName:"\u65E5\u672C\u8A9E",regions:["east-asian","priority"],direction:"ltr",script:"cjk",wordOrder:"SOV",markingStrategy:"particle",usesSpaces:false,defaultVerbForm:"base",verb:{position:"end",suffixes:["\u308B","\u3066","\u305F","\u307E\u3059","\u306A\u3044"],subjectDrop:true},references:{me:"\u81EA\u5206",it:"\u305D\u308C",you:"\u3042\u306A\u305F",result:"\u7D50\u679C",event:"\u30A4\u30D9\u30F3\u30C8",target:"\u30BF\u30FC\u30B2\u30C3\u30C8",body:"\u30DC\u30C7\u30A3"},possessive:{marker:"\u306E",markerPosition:"between",keywords:{\u79C1\u306E:"me",\u3042\u306A\u305F\u306E:"you",\u305D\u306E:"it"}},roleMarkers:{patient:{primary:"\u3092",position:"after"},destination:{primary:"\u306B",alternatives:["\u3078","\u3067","\u306E"],position:"after"},source:{primary:"\u304B\u3089",position:"after"},style:{primary:"\u3067",position:"after"},event:{primary:"\u3092",position:"after"}},keywords:{toggle:{primary:"\u5207\u308A\u66FF\u3048",alternatives:["\u5207\u308A\u66FF\u3048\u308B","\u30C8\u30B0\u30EB","\u30C8\u30B0\u30EB\u3059\u308B"],normalized:"toggle"},add:{primary:"\u8FFD\u52A0",alternatives:["\u8FFD\u52A0\u3059\u308B","\u52A0\u3048\u308B"],normalized:"add"},remove:{primary:"\u524A\u9664",alternatives:["\u524A\u9664\u3059\u308B","\u53D6\u308A\u9664\u304F"],normalized:"remove"},put:{primary:"\u7F6E\u304F",alternatives:["\u5165\u308C\u308B"],normalized:"put"},append:{primary:"\u672B\u5C3E\u8FFD\u52A0",alternatives:["\u672B\u5C3E\u306B\u8FFD\u52A0","\u30A2\u30DA\u30F3\u30C9"],normalized:"append"},prepend:{primary:"\u5148\u982D\u8FFD\u52A0",alternatives:["\u5148\u982D\u306B\u8FFD\u52A0","\u30D7\u30EA\u30DA\u30F3\u30C9"],normalized:"prepend"},take:{primary:"\u53D6\u308B",normalized:"take"},make:{primary:"\u4F5C\u308B",alternatives:["\u4F5C\u6210"],normalized:"make"},clone:{primary:"\u8907\u88FD",alternatives:["\u30AF\u30ED\u30FC\u30F3"],normalized:"clone"},swap:{primary:"\u4EA4\u63DB",alternatives:["\u30B9\u30EF\u30C3\u30D7","\u5165\u308C\u66FF\u3048"],normalized:"swap"},morph:{primary:"\u5909\u5F62",alternatives:["\u30E2\u30FC\u30D5","\u5909\u63DB"],normalized:"morph"},set:{primary:"\u8A2D\u5B9A",alternatives:["\u8A2D\u5B9A\u3059\u308B"],normalized:"set"},get:{primary:"\u53D6\u5F97",alternatives:["\u53D6\u5F97\u3059\u308B","\u30B2\u30C3\u30C8"],normalized:"get"},increment:{primary:"\u5897\u52A0",alternatives:["\u5897\u3084\u3059","\u30A4\u30F3\u30AF\u30EA\u30E1\u30F3\u30C8"],normalized:"increment"},decrement:{primary:"\u6E1B\u5C11",alternatives:["\u6E1B\u3089\u3059","\u30C7\u30AF\u30EA\u30E1\u30F3\u30C8"],normalized:"decrement"},log:{primary:"\u8A18\u9332",alternatives:["\u30ED\u30B0","\u51FA\u529B"],normalized:"log"},show:{primary:"\u8868\u793A",alternatives:["\u8868\u793A\u3059\u308B","\u898B\u305B\u308B"],normalized:"show"},hide:{primary:"\u96A0\u3059",alternatives:["\u975E\u8868\u793A","\u975E\u8868\u793A\u306B\u3059\u308B"],normalized:"hide"},transition:{primary:"\u9077\u79FB",alternatives:["\u30C8\u30E9\u30F3\u30B8\u30B7\u30E7\u30F3","\u30A2\u30CB\u30E1\u30FC\u30B7\u30E7\u30F3"],normalized:"transition"},on:{primary:"\u3067",alternatives:["\u6642"],normalized:"on"},trigger:{primary:"\u5F15\u304D\u91D1",alternatives:["\u767A\u706B","\u30C8\u30EA\u30AC\u30FC"],normalized:"trigger"},send:{primary:"\u9001\u308B",alternatives:["\u9001\u4FE1"],normalized:"send"},focus:{primary:"\u30D5\u30A9\u30FC\u30AB\u30B9",alternatives:["\u96C6\u4E2D"],normalized:"focus"},blur:{primary:"\u307C\u304B\u3057",alternatives:["\u30D5\u30A9\u30FC\u30AB\u30B9\u89E3\u9664","\u30D6\u30E9\u30FC"],normalized:"blur"},empty:{primary:"\u7A7A\u306B",alternatives:["\u7A7A\u306B\u3059\u308B"],normalized:"empty"},open:{primary:"\u958B\u304F",alternatives:["\u30AA\u30FC\u30D7\u30F3"],normalized:"open"},close:{primary:"\u9589\u3058\u308B",alternatives:["\u30AF\u30ED\u30FC\u30BA"],normalized:"close"},select:{primary:"\u9078\u3076",alternatives:["\u30BB\u30EC\u30AF\u30C8"],normalized:"select"},clear:{primary:"\u30AF\u30EA\u30A2",alternatives:["\u6D88\u53BB"],normalized:"clear"},reset:{primary:"\u30EA\u30BB\u30C3\u30C8",alternatives:["\u518D\u8A2D\u5B9A"],normalized:"reset"},breakpoint:{primary:"\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8",normalized:"breakpoint"},go:{primary:"\u79FB\u52D5",alternatives:["\u884C\u304F","\u30CA\u30D3\u30B2\u30FC\u30C8"],normalized:"go"},scroll:{primary:"\u30B9\u30AF\u30ED\u30FC\u30EB",normalized:"scroll"},push:{primary:"\u30D7\u30C3\u30B7\u30E5",normalized:"push"},replace:{primary:"\u7F6E\u63DB",alternatives:["\u7F6E\u304D\u63DB\u3048"],normalized:"replace"},process:{primary:"\u51E6\u7406",normalized:"process"},wait:{primary:"\u5F85\u3064",alternatives:["\u5F85\u6A5F"],normalized:"wait"},fetch:{primary:"\u30D5\u30A7\u30C3\u30C1",normalized:"fetch"},settle:{primary:"\u5B89\u5B9A",alternatives:["\u843D\u3061\u7740\u304F"],normalized:"settle"},if:{primary:"\u3082\u3057",normalized:"if"},when:{primary:"\u3068\u304D",alternatives:["\u3068\u304D\u306B"],normalized:"when"},where:{primary:"\u3069\u3053",normalized:"where"},else:{primary:"\u305D\u3046\u3067\u306A\u3051\u308C\u3070",alternatives:["\u305D\u308C\u4EE5\u5916"],normalized:"else"},unless:{primary:"\u306A\u3044\u9650\u308A",normalized:"unless"},repeat:{primary:"\u7E70\u308A\u8FD4\u3057",alternatives:["\u7E70\u308A\u8FD4\u3059","\u30EA\u30D4\u30FC\u30C8"],normalized:"repeat"},for:{primary:"\u305F\u3081\u306B",alternatives:["\u5404"],normalized:"for"},while:{primary:"\u306E\u9593",alternatives:["\u9593"],normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"\u7D9A\u3051\u308B",alternatives:["\u7D99\u7D9A"],normalized:"continue"},halt:{primary:"\u505C\u6B62",alternatives:["\u6B62\u3081\u308B","\u30CF\u30EB\u30C8"],normalized:"halt"},throw:{primary:"\u6295\u3052\u308B",alternatives:["\u30B9\u30ED\u30FC"],normalized:"throw"},call:{primary:"\u547C\u3073\u51FA\u3057",alternatives:["\u30B3\u30FC\u30EB","\u547C\u3076"],normalized:"call"},return:{primary:"\u623B\u308B",alternatives:["\u8FD4\u3059","\u30EA\u30BF\u30FC\u30F3"],normalized:"return"},then:{primary:"\u305D\u308C\u304B\u3089",alternatives:["\u6B21\u306B","\u306A\u3089\u3070","\u306A\u3089"],normalized:"then"},and:{primary:"\u307E\u305F",alternatives:["\u3068","\u305D\u3057\u3066"],normalized:"and"},end:{primary:"\u7D42\u308F\u308A",alternatives:["\u304A\u308F\u308A"],normalized:"end"},js:{primary:"JS\u5B9F\u884C",alternatives:["js"],normalized:"js"},async:{primary:"\u975E\u540C\u671F",alternatives:["\u30A2\u30B7\u30F3\u30AF"],normalized:"async"},tell:{primary:"\u4F1D\u3048\u308B",alternatives:["\u30C6\u30EB"],normalized:"tell"},default:{primary:"\u65E2\u5B9A",alternatives:["\u30C7\u30D5\u30A9\u30EB\u30C8"],normalized:"default"},init:{primary:"\u521D\u671F\u5316",alternatives:["\u30A4\u30CB\u30C3\u30C8"],normalized:"init"},behavior:{primary:"\u632F\u308B\u821E\u3044",alternatives:["\u30D3\u30D8\u30A4\u30D3\u30A2"],normalized:"behavior"},install:{primary:"\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB",alternatives:["\u5C0E\u5165"],normalized:"install"},measure:{primary:"\u6E2C\u5B9A",alternatives:["\u8A08\u6E2C","\u30E1\u30B8\u30E3\u30FC"],normalized:"measure"},beep:{primary:"\u30D3\u30FC\u30D7",normalized:"beep"},break:{primary:"\u4E2D\u65AD",normalized:"break"},copy:{primary:"\u30B3\u30D4\u30FC",normalized:"copy"},exit:{primary:"\u9000\u51FA",normalized:"exit"},pick:{primary:"\u9078\u629E",normalized:"pick"},render:{primary:"\u63CF\u753B",normalized:"render"},into:{primary:"\u3078",alternatives:["\u306B"],normalized:"into"},before:{primary:"\u524D\u306B",alternatives:["\u524D"],normalized:"before"},after:{primary:"\u5F8C\u306B",alternatives:["\u5F8C"],normalized:"after"},until:{primary:"\u307E\u3067",alternatives:["\u8FC4"],normalized:"until"},event:{primary:"\u30A4\u30D9\u30F3\u30C8",alternatives:["\u4E8B\u8C61"],normalized:"event"},from:{primary:"\u304B\u3089",normalized:"from"},connect:{primary:"\u63A5\u7D9A",alternatives:["\u63A5\u7D9A\u3059\u308B"],normalized:"connect"},stream:{primary:"\u30B9\u30C8\u30EA\u30FC\u30E0",alternatives:["\u914D\u4FE1"],normalized:"stream"},live:{primary:"\u30E9\u30A4\u30D6",alternatives:["\u5B9F\u6642\u9593"],normalized:"live"},socket:{primary:"\u30BD\u30B1\u30C3\u30C8",alternatives:["websocket"],normalized:"socket"},bind:{primary:"\u30D0\u30A4\u30F3\u30C9",alternatives:["\u7D50\u3073\u3064\u3051\u308B","bind"],normalized:"bind"},intercept:{primary:"\u30A4\u30F3\u30BF\u30FC\u30BB\u30D7\u30C8",alternatives:["\u508D\u53D7","intercept"],normalized:"intercept"},worker:{primary:"\u30EF\u30FC\u30AB\u30FC",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u30A4\u30D9\u30F3\u30C8\u30BD\u30FC\u30B9"],normalized:"eventsource"}},tokenization:{particles:["\u3092","\u306B","\u3067","\u304B\u3089","\u306E","\u304C","\u306F","\u3082","\u3078","\u3068"],boundaryStrategy:"particle"},eventHandler:{eventMarker:{primary:"\u3067",position:"after"},temporalMarkers:["\u6642","\u3068\u304D"]}},io=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],no=class{constructor(t=io){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}},ao="()[]{},:;",oo=class{constructor(t=ao){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=t[e];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$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return n?n[0]:null}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))return t.slice(e,n+1);n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return i?i[0]:null}return null}var uo=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Qr(t,e)!==null:false}extract(t,e){let r=Qr(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},so=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}}}};function lo(t,e){let r=t.slice(e);if(r.startsWith("http://")||r.startsWith("https://")){let i=r.match(/^https?:\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("//")){let i=r.match(/^\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("./")||r.startsWith("../")){let i=r.match(/^\.\.?\/[^\s]*/);return i?i[0]:null}if(r.startsWith("/")){let i=r.match(/^\/[^\s]*/);return i?i[0]:null}return null}var co=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=lo(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},mo=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 po(t){let e=t.charCodeAt(0);return e>=12352&&e<=12447}function fo(t){let e=t.charCodeAt(0);return e>=12448&&e<=12543}function yo(t){let e=t.charCodeAt(0);return e>=19968&&e<=40879||e>=13312&&e<=19903}function et(t){return po(t)||fo(t)||yo(t)}var ho=class{constructor(){this.name="japanese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return et(t[e])}extract(t,e){if(!this.context)throw new Error("JapaneseKeywordExtractor: context not set");let r=e;this.context.isKeywordStart(t,e);let i="",n=e;for(;n<t.length&&et(t[n]);)i+=t[n],n++;let a=i,o=i.length;for(let m=i.length;m>0;m--){let c=i.substring(0,m);if(this.context.lookupKeyword(c)){a=c,o=m;break}}if(i=a,n=e+o,!i)return null;let u=this.context.lookupKeyword(i),s=u&&u.normalized!==u.native?u.normalized:void 0,l;if(!u&&this.context.normalizer){let m=this.context.normalizer.normalize(i);if(m.stem!==i&&m.confidence>=.7){let c=this.context.lookupKeyword(m.stem);c&&(l=c.normalized);}}return {value:i,length:n-r,metadata:{normalized:s||l}}}},rt=new Map([["\u3092",{role:"patient",confidence:.95}],["\u306B",{role:"destination",confidence:.85}],["\u304C",{role:"subject",confidence:.9}],["\u306E",{role:"possessive",confidence:.9}],["\u3068",{role:"conjunction",confidence:.8}],["\u3067",{role:"instrument",confidence:.85}],["\u3078",{role:"direction",confidence:.85}],["\u3084",{role:"listing",confidence:.8}],["\u304B",{role:"question",confidence:.85}],["\u3082",{role:"also",confidence:.85}],["\u306F",{role:"topic",confidence:.9}]]),tt=new Map([["\u304B\u3089",{role:"source",confidence:.95}],["\u307E\u3067",{role:"until",confidence:.95}],["\u3088\u308A",{role:"comparison",confidence:.9}],["\u3068\u3057\u3066",{role:"as",confidence:.9}],["\u306B\u3064\u3044\u3066",{role:"about",confidence:.9}],["\u306B\u3088\u3063\u3066",{role:"by-means",confidence:.9}],["\u306B\u3066",{role:"at-location",confidence:.85}]]),vo=class{constructor(){this.name="japanese-particle";}setContext(t){this._context=t;}longerKeywordStartsHere(t,e){if(!this._context)return false;for(let r=4;r>=2;r--){let i=t.slice(e,e+r);if(i.length===r&&this._context.isKeyword(i))return true}return false}canExtract(t,e){let r=t[e];if(rt.has(r)&&!this.longerKeywordStartsHere(t,e))return true;for(let[i]of tt)if(t.startsWith(i,e))return true;return false}extract(t,e){for(let[n,a]of tt)if(t.startsWith(n,e))return {value:n,length:n.length,metadata:{role:a.role,confidence:a.confidence,variant:n}};let r=t[e];if(this.longerKeywordStartsHere(t,e))return null;let i=rt.get(r);return i?{value:r,length:1,metadata:{role:i.role,confidence:i.confidence,variant:r}}:null}};function Eo(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function go(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var zo=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return Eo(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",n=e;for(;n<t.length&&go(t[n]);)i+=t[n],n++;if(!i)return null;let a=this.context.lookupKeyword(i),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:n-r,metadata:{normalized:o}}}};function Co(){return [new co,new so,new mo,new uo]}var ko=new Set(["\u3092","\u306B","\u3067","\u304B\u3089","\u307E\u3067","\u3078","\u3068","\u306E","\u304C","\u306F","\u3082","\u3088\u308A"]),bo=[{native:"\u771F",normalized:"true"},{native:"\u507D",normalized:"false"},{native:"\u30CC\u30EB",normalized:"null"},{native:"\u672A\u5B9A\u7FA9",normalized:"undefined"},{native:"\u6700\u521D",normalized:"first"},{native:"\u6700\u5F8C",normalized:"last"},{native:"\u6B21",normalized:"next"},{native:"\u524D",normalized:"previous"},{native:"\u6700\u3082\u8FD1\u3044",normalized:"closest"},{native:"\u89AA",normalized:"parent"},{native:"\u30AF\u30EA\u30C3\u30AF",normalized:"click"},{native:"\u5909\u66F4",normalized:"change"},{native:"\u9001\u4FE1",normalized:"submit"},{native:"\u5165\u529B",normalized:"input"},{native:"\u30ED\u30FC\u30C9",normalized:"load"},{native:"\u8AAD\u307F\u8FBC\u307F",normalized:"load"},{native:"\u30B9\u30AF\u30ED\u30FC\u30EB",normalized:"scroll"},{native:"\u30AD\u30FC\u30C0\u30A6\u30F3",normalized:"keydown"},{native:"\u30AD\u30FC\u30A2\u30C3\u30D7",normalized:"keyup"},{native:"\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC",normalized:"mouseover"},{native:"\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8",normalized:"mouseout"},{native:"\u30DE\u30A6\u30B9\u62BC\u4E0B",normalized:"mousedown"},{native:"\u30DE\u30A6\u30B9\u89E3\u653E",normalized:"mouseup"},{native:"\u307E\u305F\u306F",normalized:"or"},{native:"\u79C1",normalized:"me"},{native:"\u3057\u305F\u3089",normalized:"on"},{native:"\u3059\u308B\u3068",normalized:"on"},{native:"\u6642\u306B",normalized:"on"},{native:"\u79D2",normalized:"s"},{native:"\u30DF\u30EA\u79D2",normalized:"ms"},{native:"\u5206",normalized:"m"},{native:"\u6642\u9593",normalized:"h"}],wo=class extends De{constructor(){super(),this.language="ja",this.direction="ltr",this.initializeKeywordsFromProfile(at,bo),this.normalizer=new nt,this.registerExtractors(Co()),this.registerExtractor(new we),this.registerExtractor(new Ae),this.registerExtractor(new zo),this.registerExtractor(new vo),this.registerExtractor(new ho),this.registerExtractor(new no),this.registerExtractor(new oo);}classifyToken(t){return ko.has(t)?"particle":this.isKeyword(t)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(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("'")||t.startsWith("\u300C")||/^\d/.test(t)?"literal":"identifier"}},Ao=new wo;Re("ja",Ao,at);function Do(t){let e=t.charCodeAt(0);return e>=44032&&e<=55203}function Bo(t){for(let e of t)if(Do(e))return true;return false}var So=[{pattern:"\uD558\uC2DC\uB2C8\uAE4C",confidence:.85,conjugationType:"honorific-causal",minStemLength:1},{pattern:"\uD558\uC2E4\uB54C",confidence:.88,conjugationType:"honorific-temporal",minStemLength:1},{pattern:"\uD558\uC2E4 \uB54C",confidence:.88,conjugationType:"honorific-temporal",minStemLength:1},{pattern:"\uD558\uC2DC\uBA74",confidence:.88,conjugationType:"honorific-conditional",minStemLength:1},{pattern:"\uC73C\uC2DC\uBA74",confidence:.85,conjugationType:"honorific-conditional",minStemLength:2},{pattern:"\uC2DC\uBA74",confidence:.82,conjugationType:"honorific-conditional",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uD558\uACE0 \uB098\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uD558\uACE0\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uACE0\uB098\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uACE0 \uB098\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uACE0\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uAE30\uC804\uC5D0",confidence:.85,conjugationType:"sequential-before",minStemLength:1},{pattern:"\uD558\uAE30 \uC804\uC5D0",confidence:.85,conjugationType:"sequential-before",minStemLength:1},{pattern:"\uAE30\uC804\uC5D0",confidence:.82,conjugationType:"sequential-before",minStemLength:2},{pattern:"\uAE30 \uC804\uC5D0",confidence:.82,conjugationType:"sequential-before",minStemLength:2},{pattern:"\uD558\uC790\uB9C8\uC790",confidence:.88,conjugationType:"immediate",minStemLength:1},{pattern:"\uC790\uB9C8\uC790",confidence:.85,conjugationType:"immediate",minStemLength:2},{pattern:"\uD574\uC57C\uD574\uC694",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uD574\uC57C\uD574",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uD574\uC57C\uD558\uB2E4",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uC5B4\uC57C\uD574\uC694",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC5B4\uC57C\uD574",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC544\uC57C\uD574\uC694",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC544\uC57C\uD574",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uD558\uB2C8\uAE4C",confidence:.85,conjugationType:"causal-nikka",minStemLength:1},{pattern:"\uD560\uB54C",confidence:.88,conjugationType:"temporal-ttae",minStemLength:1},{pattern:"\uD560 \uB54C",confidence:.88,conjugationType:"temporal-ttae",minStemLength:1},{pattern:"\uC744\uB54C",confidence:.85,conjugationType:"temporal-ttae",minStemLength:2},{pattern:"\uC744 \uB54C",confidence:.85,conjugationType:"temporal-ttae",minStemLength:2},{pattern:"\uD558\uBA74",confidence:.88,conjugationType:"conditional-myeon",minStemLength:1},{pattern:"\uC73C\uBA74",confidence:.85,conjugationType:"conditional-myeon",minStemLength:2},{pattern:"\uB2C8\uAE4C",confidence:.82,conjugationType:"causal-nikka",minStemLength:2},{pattern:"\uBA74",confidence:.8,conjugationType:"conditional-myeon",minStemLength:2},{pattern:"\uD558\uC600\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD588\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD569\uB2C8\uB2E4",confidence:.85,conjugationType:"polite",minStemLength:1},{pattern:"\uC2B5\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uB429\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:1},{pattern:"\u3142\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uD558\uC138\uC694",confidence:.85,conjugationType:"honorific",minStemLength:1},{pattern:"\uD558\uC2ED\uC2DC\uC624",confidence:.85,conjugationType:"honorific",minStemLength:1},{pattern:"\uC138\uC694",confidence:.82,conjugationType:"honorific",minStemLength:2},{pattern:"\uC2ED\uC2DC\uC624",confidence:.82,conjugationType:"honorific",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5B4\uC694",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uD558\uACE0\uC788\uC5B4",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uD588\uC5B4\uC694",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD574\uC694",confidence:.85,conjugationType:"polite",minStemLength:1},{pattern:"\uC5B4\uC694",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uC544\uC694",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uD588\uC5B4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD574",confidence:.8,conjugationType:"present",minStemLength:1},{pattern:"\uC5C8\uC5B4",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\uC558\uC5B4",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uB2E4",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uACE0\uC788\uB2E4",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uACE0\uC788\uC5B4",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uD558\uB2E4",confidence:.88,conjugationType:"dictionary",minStemLength:1},{pattern:"\uD558\uC9C0\uC54A\uB2E4",confidence:.82,conjugationType:"negative",minStemLength:1},{pattern:"\uC548\uD558\uB2E4",confidence:.82,conjugationType:"negative",minStemLength:1},{pattern:"\uC9C0\uC54A\uB2E4",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"\uD574\uB77C",confidence:.82,conjugationType:"imperative",minStemLength:1},{pattern:"\uD558\uB77C",confidence:.82,conjugationType:"imperative",minStemLength:1},{pattern:"\uB2E4",confidence:.75,conjugationType:"dictionary",minStemLength:2}],xo=[{pattern:"\uD558\uC2DC\uB2C8\uAE4C",confidence:.88,conjugationType:"honorific-causal"},{pattern:"\uD558\uC2E4\uB54C",confidence:.88,conjugationType:"honorific-temporal"},{pattern:"\uD558\uC2E4 \uB54C",confidence:.88,conjugationType:"honorific-temporal"},{pattern:"\uD558\uC2DC\uBA74",confidence:.88,conjugationType:"honorific-conditional"},{pattern:"\uD558\uC168\uC5B4\uC694",confidence:.85,conjugationType:"honorific-past"},{pattern:"\uD558\uC168\uC5B4",confidence:.85,conjugationType:"honorific-past"},{pattern:"\uD558\uC2ED\uB2C8\uB2E4",confidence:.85,conjugationType:"honorific-polite"},{pattern:"\uD558\uACE0\uB098\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uACE0 \uB098\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uACE0\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uAE30\uC804\uC5D0",confidence:.88,conjugationType:"sequential-before"},{pattern:"\uD558\uAE30 \uC804\uC5D0",confidence:.88,conjugationType:"sequential-before"},{pattern:"\uD558\uC790\uB9C8\uC790",confidence:.88,conjugationType:"immediate"},{pattern:"\uD574\uC57C\uD574\uC694",confidence:.88,conjugationType:"obligation"},{pattern:"\uD574\uC57C\uD574",confidence:.88,conjugationType:"obligation"},{pattern:"\uD574\uC57C\uD558\uB2E4",confidence:.88,conjugationType:"obligation"},{pattern:"\uD558\uB2C8\uAE4C",confidence:.88,conjugationType:"causal-nikka"},{pattern:"\uD560\uB54C",confidence:.88,conjugationType:"temporal-ttae"},{pattern:"\uD560 \uB54C",confidence:.88,conjugationType:"temporal-ttae"},{pattern:"\uD558\uBA74",confidence:.88,conjugationType:"conditional-myeon"},{pattern:"\uD558\uC600\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past"},{pattern:"\uD588\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past"},{pattern:"\uD569\uB2C8\uB2E4",confidence:.85,conjugationType:"polite"},{pattern:"\uD558\uC2ED\uC2DC\uC624",confidence:.85,conjugationType:"honorific"},{pattern:"\uD558\uC138\uC694",confidence:.85,conjugationType:"honorific"},{pattern:"\uD588\uC5B4\uC694",confidence:.85,conjugationType:"past"},{pattern:"\uD574\uC694",confidence:.85,conjugationType:"polite"},{pattern:"\uD588\uC5B4",confidence:.85,conjugationType:"past"},{pattern:"\uD574",confidence:.8,conjugationType:"present"},{pattern:"\uD558\uACE0\uC788\uC5B4\uC694",confidence:.82,conjugationType:"progressive"},{pattern:"\uD558\uACE0\uC788\uC5B4",confidence:.82,conjugationType:"progressive"},{pattern:"\uD558\uACE0\uC788\uB2E4",confidence:.82,conjugationType:"progressive"},{pattern:"\uD574\uC11C",confidence:.82,conjugationType:"connective"},{pattern:"\uD558\uACE0",confidence:.8,conjugationType:"connective"},{pattern:"\uD558\uC9C0\uC54A\uC544\uC694",confidence:.82,conjugationType:"negative"},{pattern:"\uD558\uC9C0\uC54A\uB2E4",confidence:.82,conjugationType:"negative"},{pattern:"\uC548\uD574\uC694",confidence:.82,conjugationType:"negative"},{pattern:"\uC548\uD574",confidence:.82,conjugationType:"negative"},{pattern:"\uD574\uB77C",confidence:.82,conjugationType:"imperative"},{pattern:"\uD558\uB77C",confidence:.82,conjugationType:"imperative"},{pattern:"\uD558\uB2E4",confidence:.88,conjugationType:"dictionary"}],ct=class{constructor(){this.language="ko";}isNormalizable(t){return !(!Bo(t)||t.length<2)}normalize(t){let e=this.normalizeCompound(t);if(e)return e;let r=this.tryHadaNormalization(t);if(r)return r;for(let i of So)if(t.endsWith(i.pattern)){let n=t.slice(0,-i.pattern.length),a=i.minStemLength??2;if(n.length<a)continue;let o={removedSuffixes:[i.pattern]};return i.conjugationType&&(o.conjugationType=i.conjugationType),se(n,i.confidence,o)}return We(t)}tryHadaNormalization(t){for(let e of xo)if(t.endsWith(e.pattern)){let r=t.slice(0,-e.pattern.length);if(r.length<1)continue;return se(r,e.confidence,{removedSuffixes:[e.pattern],conjugationType:e.conjugationType,originalForm:"hada-verb"})}return null}normalizeCompound(t){let e=[{pattern:"\uD558\uACE0\uB098\uC11C\uC600\uC5B4",suffixes:["\uD558\uACE0\uB098\uC11C","\uC600\uC5B4"],confidence:.78,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C\uC600\uB2E4",suffixes:["\uD558\uACE0\uB098\uC11C","\uC600\uB2E4"],confidence:.78,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C",suffixes:["\uD558\uACE0","\uB098\uC11C"],confidence:.85,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uC5B4",suffixes:["\uD574\uC57C","\uD588\uC5B4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uB2E4",suffixes:["\uD574\uC57C","\uD588\uB2E4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uC2B5\uB2C8\uB2E4",suffixes:["\uD574\uC57C","\uD588\uC2B5\uB2C8\uB2E4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD558\uC2DC\uBA74\uC11C",suffixes:["\uD558\uC2DC","\uBA74\uC11C"],confidence:.82,conjugationType:"connective",minStemLength:2},{pattern:"\uD558\uC2DC\uBA70",suffixes:["\uD558\uC2DC","\uBA70"],confidence:.82,conjugationType:"connective",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5C8\uC5B4",suffixes:["\uD558\uACE0","\uC788\uC5C8\uC5B4"],confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5C8\uB2E4",suffixes:["\uD558\uACE0","\uC788\uC5C8\uB2E4"],confidence:.8,conjugationType:"progressive",minStemLength:2}];for(let{pattern:r,suffixes:i,confidence:n,conjugationType:a,minStemLength:o}of e)if(t.endsWith(r)){let u=t.slice(0,-r.length);if(u.length<o)continue;return se(u,n,{removedSuffixes:i,conjugationType:a})}return null}},mt={code:"ko",name:"Korean",nativeName:"\uD55C\uAD6D\uC5B4",regions:["east-asian","priority"],direction:"ltr",script:"hangul",wordOrder:"SOV",markingStrategy:"particle",usesSpaces:true,verb:{position:"end",suffixes:["\uB2E4","\uC694","\uB2C8\uB2E4","\uC138\uC694"],subjectDrop:true},references:{me:"\uB098",it:"\uADF8\uAC83",you:"\uB108",result:"\uACB0\uACFC",event:"\uC774\uBCA4\uD2B8",target:"\uB300\uC0C1",body:"\uBC14\uB514"},possessive:{marker:"\uC758",markerPosition:"between",specialForms:{me:"\uB0B4",it:"\uADF8\uAC83\uC758",you:"\uB124"},keywords:{\uB0B4:"me",\uB124:"you",\uADF8\uC758:"it"}},roleMarkers:{patient:{primary:"\uC744",alternatives:["\uB97C"],position:"after"},destination:{primary:"\uC5D0",alternatives:["\uC73C\uB85C","\uB85C","\uC758"],position:"after"},source:{primary:"\uC5D0\uC11C",alternatives:["\uBD80\uD130"],position:"after"},style:{primary:"\uB85C",alternatives:["\uC73C\uB85C"],position:"after"},event:{primary:"\uC744",alternatives:["\uB97C"],position:"after"}},keywords:{toggle:{primary:"\uD1A0\uAE00",normalized:"toggle"},add:{primary:"\uCD94\uAC00",normalized:"add"},remove:{primary:"\uC81C\uAC70",alternatives:["\uC0AD\uC81C"],normalized:"remove"},put:{primary:"\uB123\uB2E4",alternatives:["\uB123\uAE30","\uB193\uAE30"],normalized:"put"},append:{primary:"\uB367\uBD99\uC774\uB2E4",alternatives:["\uB05D\uC5D0\uCD94\uAC00"],normalized:"append"},prepend:{primary:"\uC55E\uC5D0\uCD94\uAC00",alternatives:["\uC120\uB450\uCD94\uAC00"],normalized:"prepend"},take:{primary:"\uAC00\uC838\uC624\uB2E4",normalized:"take"},make:{primary:"\uB9CC\uB4E4\uB2E4",normalized:"make"},clone:{primary:"\uBCF5\uC81C",normalized:"clone"},swap:{primary:"\uAD50\uD658",alternatives:["\uBC14\uAFB8\uB2E4"],normalized:"swap"},morph:{primary:"\uBCC0\uD615",alternatives:["\uBCC0\uD658"],normalized:"morph"},set:{primary:"\uC124\uC815",normalized:"set"},get:{primary:"\uC5BB\uB2E4",normalized:"get"},increment:{primary:"\uC99D\uAC00",normalized:"increment"},decrement:{primary:"\uAC10\uC18C",normalized:"decrement"},log:{primary:"\uB85C\uADF8",normalized:"log"},show:{primary:"\uBCF4\uC774\uB2E4",alternatives:["\uD45C\uC2DC","\uBCF4\uC774\uAE30"],normalized:"show"},hide:{primary:"\uC228\uAE30\uB2E4",alternatives:["\uC228\uAE30\uAE30"],normalized:"hide"},transition:{primary:"\uD2B8\uB79C\uC9C0\uC158",alternatives:["\uC804\uD658"],normalized:"transition"},on:{primary:"\uC5D0",alternatives:["\uC2DC","\uD560 \uB54C"],normalized:"on"},trigger:{primary:"\uD2B8\uB9AC\uAC70",normalized:"trigger"},send:{primary:"\uBCF4\uB0B4\uB2E4",normalized:"send"},focus:{primary:"\uD3EC\uCEE4\uC2A4",normalized:"focus"},blur:{primary:"\uBE14\uB7EC",normalized:"blur"},empty:{primary:"\uBE44\uC6B0\uAE30",normalized:"empty"},open:{primary:"\uC5F4\uAE30",normalized:"open"},close:{primary:"\uB2EB\uAE30",normalized:"close"},select:{primary:"\uACE0\uB974\uAE30",normalized:"select"},clear:{primary:"\uC9C0\uC6B0\uAE30",normalized:"clear"},reset:{primary:"\uC7AC\uC124\uC815",normalized:"reset"},breakpoint:{primary:"\uC911\uB2E8\uC810",normalized:"breakpoint"},click:{primary:"\uD074\uB9AD",normalized:"click"},hover:{primary:"\uD638\uBC84",normalized:"hover"},submit:{primary:"\uC81C\uCD9C",normalized:"submit"},input:{primary:"\uC785\uB825",normalized:"input"},change:{primary:"\uBCC0\uACBD",normalized:"change"},go:{primary:"\uC774\uB3D9",normalized:"go"},scroll:{primary:"\uC2A4\uD06C\uB864",normalized:"scroll"},push:{primary:"\uD478\uC2DC",normalized:"push"},replace:{primary:"\uAD50\uCCB4",alternatives:["\uBC14\uAFB8\uAE30"],normalized:"replace"},process:{primary:"\uCC98\uB9AC",normalized:"process"},wait:{primary:"\uB300\uAE30",normalized:"wait"},fetch:{primary:"\uD328\uCE58",alternatives:["\uAC00\uC838\uC624\uAE30"],normalized:"fetch"},settle:{primary:"\uC548\uC815",normalized:"settle"},if:{primary:"\uB9CC\uC57D",normalized:"if"},when:{primary:"\uB54C",normalized:"when"},where:{primary:"\uC5B4\uB514",normalized:"where"},else:{primary:"\uC544\uB2C8\uBA74",normalized:"else"},unless:{primary:"\uC544\uB2C8\uB77C\uBA74",normalized:"unless"},repeat:{primary:"\uBC18\uBCF5",normalized:"repeat"},for:{primary:"\uAC01\uAC01",normalized:"for"},while:{primary:"\uB3D9\uC548",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"\uACC4\uC18D",normalized:"continue"},halt:{primary:"\uC815\uC9C0",normalized:"halt"},throw:{primary:"\uB358\uC9C0\uB2E4",normalized:"throw"},call:{primary:"\uD638\uCD9C",normalized:"call"},return:{primary:"\uBC18\uD658",normalized:"return"},then:{primary:"\uADF8\uB2E4\uC74C",alternatives:["\uADF8\uB7F0\uD6C4"],normalized:"then"},and:{primary:"\uADF8\uB9AC\uACE0",alternatives:["\uB610\uD55C","\uBC0F"],normalized:"and"},matches:{primary:"\uC77C\uCE58",normalized:"matches"},end:{primary:"\uB05D",alternatives:["\uB9C8\uCE68"],normalized:"end"},js:{primary:"JS\uC2E4\uD589",alternatives:["js"],normalized:"js"},async:{primary:"\uBE44\uB3D9\uAE30",normalized:"async"},tell:{primary:"\uB9D0\uD558\uB2E4",normalized:"tell"},default:{primary:"\uAE30\uBCF8\uAC12",normalized:"default"},init:{primary:"\uCD08\uAE30\uD654",normalized:"init"},behavior:{primary:"\uB3D9\uC791",normalized:"behavior"},install:{primary:"\uC124\uCE58",normalized:"install"},measure:{primary:"\uCE21\uC815",normalized:"measure"},beep:{primary:"\uBE44\uD504",normalized:"beep"},break:{primary:"\uC911\uB2E8",normalized:"break"},copy:{primary:"\uBCF5\uC0AC",normalized:"copy"},exit:{primary:"\uB098\uAC00\uAE30",normalized:"exit"},pick:{primary:"\uC120\uD0DD",normalized:"pick"},render:{primary:"\uB80C\uB354\uB9C1",normalized:"render"},into:{primary:"\uC73C\uB85C",normalized:"into"},before:{primary:"\uC804\uC5D0",normalized:"before"},after:{primary:"\uD6C4\uC5D0",normalized:"after"},until:{primary:"\uAE4C\uC9C0",normalized:"until"},event:{primary:"\uC774\uBCA4\uD2B8",normalized:"event"},from:{primary:"\uC5D0\uC11C",normalized:"from"},connect:{primary:"\uC5F0\uACB0",alternatives:["\uC811\uC18D"],normalized:"connect"},stream:{primary:"\uC2A4\uD2B8\uB9BC",alternatives:["\uC2A4\uD2B8\uB9AC\uBC0D"],normalized:"stream"},live:{primary:"\uC2E4\uC2DC\uAC04",alternatives:["\uB77C\uC774\uBE0C"],normalized:"live"},socket:{primary:"\uC18C\uCF13",alternatives:["websocket"],normalized:"socket"},bind:{primary:"\uBC14\uC778\uB4DC",alternatives:["bind"],normalized:"bind"},intercept:{primary:"\uAC00\uB85C\uCC44\uAE30",alternatives:["\uC778\uD130\uC149\uD2B8","intercept"],normalized:"intercept"},worker:{primary:"\uC6CC\uCEE4",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\uC774\uBCA4\uD2B8\uC18C\uC2A4"],normalized:"eventsource"}},tokenization:{particles:["\uC744","\uB97C","\uC774","\uAC00","\uC740","\uB294","\uC5D0","\uC5D0\uC11C","\uC73C\uB85C","\uB85C","\uC640","\uACFC","\uB3C4"],boundaryStrategy:"space"},eventHandler:{eventMarker:{primary:"\uD560 \uB54C",alternatives:["\uD560\uB54C","\uB54C","\uC5D0"],position:"after"},temporalMarkers:["\uD560 \uB54C","\uD560\uB54C","\uB54C"]}},To=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Fo=class{constructor(t=To){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}},Oo="()[]{},:;",Ro=class{constructor(t=Oo){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 ot(t,e){let r=t[e];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$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return n?n[0]:null}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))return t.slice(e,n+1);n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return i?i[0]:null}return null}var Po=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?ot(t,e)!==null:false}extract(t,e){let r=ot(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Lo=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}}}};function No(t,e){let r=t.slice(e);if(r.startsWith("http://")||r.startsWith("https://")){let i=r.match(/^https?:\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("//")){let i=r.match(/^\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("./")||r.startsWith("../")){let i=r.match(/^\.\.?\/[^\s]*/);return i?i[0]:null}if(r.startsWith("/")){let i=r.match(/^\/[^\s]*/);return i?i[0]:null}return null}var _o=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=No(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Mo=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 Io(t){let e=t.charCodeAt(0);return e>=44032&&e<=55203}function jo(t){let e=t.charCodeAt(0);return e>=4352&&e<=4607||e>=12592&&e<=12687}function lr(t){return Io(t)||jo(t)}var Vo=["\uD560\uB54C","\uD558\uBA74","\uD558\uB2C8\uAE4C","\uD560 \uB54C"],$o=class{constructor(){this.name="korean-keyword";}setContext(t){this.context=t;}canExtract(t,e){return lr(t[e])}extract(t,e){if(!this.context)throw new Error("KoreanKeywordExtractor: context not set");let r=e,i=6;for(let c=Math.min(i,t.length-r);c>=2;c--){let p=t.slice(r,r+c),d=true;for(let y=0;y<p.length;y++)if(!lr(p[y])){d=false;break}if(!d)continue;let f=this.context.lookupKeyword(p);if(f)return {value:p,length:c,metadata:{normalized:f.normalized!==f.native?f.normalized:void 0}};if(this.context.normalizer){let y=this.context.normalizer.normalize(p);if(y.stem!==p&&y.confidence>=.7){let h=this.context.lookupKeyword(y.stem);if(h)return {value:p,length:c,metadata:{normalized:h.normalized,stem:y.stem,stemConfidence:y.confidence}}}}}let n="",a=e;for(;a<t.length&&lr(t[a])&&!(n.length>0&&this.context.isKeywordStart(t,a));)n+=t[a],a++;if(!n)return null;for(let c of Vo)if(n.endsWith(c)&&n.length>c.length){let p=n.slice(0,-c.length),d=this.context.lookupKeyword(p);if(d)return {value:p,length:p.length,metadata:{normalized:d.normalized,hasSuffix:true,suffix:c,stem:p}}}let o=this.context.lookupKeyword(n),u=o&&o.normalized!==o.native?o.normalized:void 0;n.includes("\uD1A0\uAE00")&&(console.log(`[KO DEBUG] word="${n}"`),console.log(`[KO DEBUG] keywordEntry=${o?"FOUND":"NOT FOUND"}`),console.log(`[KO DEBUG] normalizer=${this.context.normalizer?"EXISTS":"MISSING"}`));let s,l,m;if(!o&&this.context.normalizer){let c=this.context.normalizer.normalize(n);if(c.stem!==n&&c.confidence>=.7){let p=this.context.lookupKeyword(c.stem);p&&(s=p.normalized,l=c.stem,m=c.confidence,n.includes("\uD1A0\uAE00")&&console.log(`[KO DEBUG] word="${n}", stem="${c.stem}", normalized="${s}"`));}}return {value:n,length:a-r,metadata:{normalized:u||s,stem:l,stemConfidence:m}}}},ut=new Map([["\uC774",{role:"agent",confidence:.85,variant:"consonant",description:"subject marker (after consonant)"}],["\uAC00",{role:"agent",confidence:.85,variant:"vowel",description:"subject marker (after vowel)"}],["\uC744",{role:"patient",confidence:.95,variant:"consonant",description:"object marker (after consonant)"}],["\uB97C",{role:"patient",confidence:.95,variant:"vowel",description:"object marker (after vowel)"}],["\uC740",{role:"agent",confidence:.75,variant:"consonant",description:"topic marker (after consonant)"}],["\uB294",{role:"agent",confidence:.75,variant:"vowel",description:"topic marker (after vowel)"}],["\uC5D0",{role:"destination",confidence:.85,description:"at/to marker"}],["\uB85C",{role:"destination",confidence:.85,variant:"vowel",description:"to/by means (after vowel or \u3139)"}],["\uC640",{role:"style",confidence:.7,variant:"vowel",description:"and/with (after vowel)"}],["\uACFC",{role:"style",confidence:.7,variant:"consonant",description:"and/with (after consonant)"}],["\uC758",{role:"patient",confidence:.6,description:"possessive marker"}],["\uB3C4",{role:"patient",confidence:.65,description:"also/too marker"}],["\uB9CC",{role:"patient",confidence:.65,description:"only marker"}]]),st=new Map([["\uC5D0\uC11C",{role:"source",confidence:.8,description:"at/from marker (action location)"}],["\uC73C\uB85C",{role:"destination",confidence:.85,variant:"consonant",description:"to/by means (after consonant)"}],["\uBD80\uD130",{role:"source",confidence:.9,description:"from/since marker"}],["\uAE4C\uC9C0",{role:"destination",confidence:.75,description:"until/to marker"}],["\uCC98\uB7FC",{role:"manner",confidence:.8,description:"like/as marker"}],["\uBCF4\uB2E4",{role:"source",confidence:.75,description:"than marker"}]]);function lt(t){if(!t)return false;let e=t.codePointAt(0);return e>=44032&&e<=55203}var qo=class{constructor(){this.name="korean-particle";}setContext(t){this._context=t,this._context;}canExtract(t,e){let r=t[e];if(ut.has(r)&&!lt(t[e+1]))return true;for(let[i]of st)if(t.startsWith(i,e))return true;return false}extract(t,e){for(let[n,a]of st)if(t.startsWith(n,e))return {value:n,length:n.length,metadata:{particleRole:a.role,particleConfidence:a.confidence,particleVariant:a.variant}};let r=t[e],i=ut.get(r);return i&&!lt(t[e+1])?{value:r,length:1,metadata:{particleRole:i.role,particleConfidence:i.confidence,particleVariant:i.variant}}:null}};function Wo(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Ko(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var Uo=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return Wo(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",n=e;for(;n<t.length&&Ko(t[n]);)i+=t[n],n++;if(!i)return null;let a=this.context.lookupKeyword(i),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:n-r,metadata:{normalized:o}}}};function Ho(){return [new _o,new Lo,new Mo,new Po]}var Go=new Set(["\uC774","\uAC00","\uC744","\uB97C","\uC740","\uB294","\uC5D0","\uC5D0\uC11C","\uB85C","\uC73C\uB85C","\uC640","\uACFC","\uC758","\uB3C4","\uB9CC","\uBD80\uD130","\uAE4C\uC9C0","\uCC98\uB7FC","\uBCF4\uB2E4"]),Yo=[{native:"\uCC38",normalized:"true"},{native:"\uAC70\uC9D3",normalized:"false"},{native:"\uB110",normalized:"null"},{native:"\uBBF8\uC815\uC758",normalized:"undefined"},{native:"\uCCAB\uBC88\uC9F8",normalized:"first"},{native:"\uB9C8\uC9C0\uB9C9",normalized:"last"},{native:"\uB2E4\uC74C",normalized:"next"},{native:"\uC774\uC804",normalized:"previous"},{native:"\uAC00\uC7A5\uAC00\uAE4C\uC6B4",normalized:"closest"},{native:"\uBD80\uBAA8",normalized:"parent"},{native:"\uD074\uB9AD",normalized:"click"},{native:"\uB354\uBE14\uD074\uB9AD",normalized:"dblclick"},{native:"\uBCC0\uACBD",normalized:"change"},{native:"\uC81C\uCD9C",normalized:"submit"},{native:"\uC785\uB825",normalized:"input"},{native:"\uB85C\uB4DC",normalized:"load"},{native:"\uC2A4\uD06C\uB864",normalized:"scroll"},{native:"\uD0A4\uB2E4\uC6B4",normalized:"keydown"},{native:"\uD0A4\uC5C5",normalized:"keyup"},{native:"\uB9C8\uC6B0\uC2A4\uC624\uBC84",normalized:"mouseover"},{native:"\uB9C8\uC6B0\uC2A4\uC544\uC6C3",normalized:"mouseout"},{native:"\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4",normalized:"mousedown"},{native:"\uB9C8\uC6B0\uC2A4\uC5C5",normalized:"mouseup"},{native:"\uB0B4",normalized:"my"},{native:"\uADF8\uAC83\uC758",normalized:"its"},{native:"\uADF8\uB2E4\uC74C",normalized:"then"},{native:"\uADF8\uB7F0\uD6C4",normalized:"then"},{native:"\uADF8\uB7EC\uBA74",normalized:"then"},{native:"\uADF8\uB9AC\uACE0",normalized:"and"},{native:"\uB610\uB294",normalized:"or"},{native:"\uC544\uB2C8",normalized:"not"},{native:"\uC774\uB2E4",normalized:"is"},{native:"\uCD08",normalized:"s"},{native:"\uBC00\uB9AC\uCD08",normalized:"ms"},{native:"\uBD84",normalized:"m"},{native:"\uC2DC\uAC04",normalized:"h"}],Zo=class extends De{constructor(){super(),this.language="ko",this.direction="ltr",this.initializeKeywordsFromProfile(mt,Yo),this.normalizer=new ct,this.registerExtractors(Ho()),this.registerExtractor(new we),this.registerExtractor(new Ae),this.registerExtractor(new Uo),this.registerExtractor(new qo),this.registerExtractor(new $o),this.registerExtractor(new Fo),this.registerExtractor(new Ro);}classifyToken(t){return Go.has(t)?"particle":this.isKeyword(t)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(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":"identifier"}},Jo=new Zo;Re("ko",Jo,mt);var yt={code:"zh",name:"Chinese",nativeName:"\u4E2D\u6587",regions:["east-asian","priority"],direction:"ltr",script:"cjk",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:false,verb:{position:"second",subjectDrop:true},references:{me:"\u6211",it:"\u5B83",you:"\u4F60",result:"\u7ED3\u679C",event:"\u4E8B\u4EF6",target:"\u76EE\u6807",body:"\u4E3B\u4F53"},possessive:{marker:"\u7684",markerPosition:"between",keywords:{\u6211\u7684:"me",\u4F60\u7684:"you",\u5B83\u7684:"it",\u4ED6\u7684:"it",\u5979\u7684:"it"}},roleMarkers:{destination:{primary:"\u5728",alternatives:["\u5230","\u4E8E"],position:"before"},source:{primary:"\u4ECE",alternatives:["\u7531"],position:"before"},patient:{primary:"\u628A",position:"before"},style:{primary:"\u7528",alternatives:["\u4EE5"],position:"before"}},keywords:{toggle:{primary:"\u5207\u6362",normalized:"toggle"},add:{primary:"\u6DFB\u52A0",alternatives:["\u52A0"],normalized:"add"},remove:{primary:"\u79FB\u9664",alternatives:["\u5220\u9664","\u53BB\u6389"],normalized:"remove"},put:{primary:"\u653E\u7F6E",alternatives:["\u653E","\u653E\u5165"],normalized:"put"},append:{primary:"\u8FFD\u52A0",alternatives:["\u9644\u52A0"],normalized:"append"},prepend:{primary:"\u524D\u7F6E",alternatives:["\u9884\u7F6E"],normalized:"prepend"},take:{primary:"\u62FF\u53D6",normalized:"take"},make:{primary:"\u5236\u4F5C",normalized:"make"},clone:{primary:"\u514B\u9686",normalized:"clone"},swap:{primary:"\u4EA4\u6362",normalized:"swap"},morph:{primary:"\u53D8\u5F62",alternatives:["\u8F6C\u6362"],normalized:"morph"},set:{primary:"\u8BBE\u7F6E",alternatives:["\u8BBE\u5B9A"],normalized:"set"},get:{primary:"\u83B7\u53D6",alternatives:["\u83B7\u5F97","\u53D6\u5F97"],normalized:"get"},increment:{primary:"\u589E\u52A0",normalized:"increment"},decrement:{primary:"\u51CF\u5C11",normalized:"decrement"},log:{primary:"\u65E5\u5FD7",normalized:"log"},show:{primary:"\u663E\u793A",alternatives:["\u5C55\u793A"],normalized:"show"},hide:{primary:"\u9690\u85CF",normalized:"hide"},transition:{primary:"\u8FC7\u6E21",normalized:"transition"},on:{primary:"\u5F53",alternatives:["\u5728...\u65F6"],normalized:"on"},trigger:{primary:"\u89E6\u53D1",normalized:"trigger"},send:{primary:"\u53D1\u9001",normalized:"send"},focus:{primary:"\u805A\u7126",normalized:"focus"},blur:{primary:"\u5931\u7126",normalized:"blur"},empty:{primary:"\u6E05\u7A7A",alternatives:["\u7A7A\u7684"],normalized:"empty"},open:{primary:"\u6253\u5F00",normalized:"open"},close:{primary:"\u5173\u95ED",normalized:"close"},select:{primary:"\u9009\u62E9",normalized:"select"},clear:{primary:"\u6E05\u9664",normalized:"clear"},reset:{primary:"\u91CD\u7F6E",normalized:"reset"},breakpoint:{primary:"\u65AD\u70B9",normalized:"breakpoint"},click:{primary:"\u70B9\u51FB",normalized:"click"},hover:{primary:"\u60AC\u505C",alternatives:["\u60AC\u6D6E"],normalized:"hover"},submit:{primary:"\u63D0\u4EA4",normalized:"submit"},input:{primary:"\u8F93\u5165",normalized:"input"},change:{primary:"\u6539\u53D8",alternatives:["\u53D8\u5316"],normalized:"change"},go:{primary:"\u524D\u5F80",normalized:"go"},scroll:{primary:"\u6EDA\u52A8",normalized:"scroll"},push:{primary:"\u63A8\u9001",normalized:"push"},replace:{primary:"\u66FF\u6362",normalized:"replace"},process:{primary:"\u5904\u7406",normalized:"process"},wait:{primary:"\u7B49\u5F85",normalized:"wait"},fetch:{primary:"\u6293\u53D6",normalized:"fetch"},settle:{primary:"\u7A33\u5B9A",normalized:"settle"},if:{primary:"\u5982\u679C",normalized:"if"},unless:{primary:"\u9664\u975E",normalized:"unless"},when:{primary:"\u4F55\u65F6",normalized:"when"},where:{primary:"\u54EA\u91CC",normalized:"where"},else:{primary:"\u5426\u5219",normalized:"else"},matches:{primary:"\u5339\u914D",normalized:"matches"},repeat:{primary:"\u91CD\u590D",normalized:"repeat"},for:{primary:"\u4E3A",normalized:"for"},while:{primary:"\u6301\u7EED",normalized:"while"},continue:{primary:"\u7EE7\u7EED",normalized:"continue"},halt:{primary:"\u505C\u6B62",normalized:"halt"},throw:{primary:"\u629B\u51FA",normalized:"throw"},call:{primary:"\u8C03\u7528",normalized:"call"},return:{primary:"\u8FD4\u56DE",normalized:"return"},then:{primary:"\u7136\u540E",alternatives:["\u63A5\u7740","\u90A3\u4E48"],normalized:"then"},and:{primary:"\u5E76\u4E14",alternatives:["\u548C","\u800C\u4E14"],normalized:"and"},end:{primary:"\u7ED3\u675F",alternatives:["\u7EC8\u6B62","\u5B8C"],normalized:"end"},js:{primary:"JS\u6267\u884C",alternatives:["js"],normalized:"js"},async:{primary:"\u5F02\u6B65",normalized:"async"},tell:{primary:"\u544A\u8BC9",normalized:"tell"},default:{primary:"\u9ED8\u8BA4",normalized:"default"},init:{primary:"\u521D\u59CB\u5316",normalized:"init"},behavior:{primary:"\u884C\u4E3A",normalized:"behavior"},install:{primary:"\u5B89\u88C5",normalized:"install"},measure:{primary:"\u6D4B\u91CF",normalized:"measure"},beep:{primary:"\u8702\u9E23",normalized:"beep"},break:{primary:"\u4E2D\u65AD",normalized:"break"},copy:{primary:"\u590D\u5236",normalized:"copy"},exit:{primary:"\u9000\u51FA",normalized:"exit"},pick:{primary:"\u9009\u53D6",normalized:"pick"},render:{primary:"\u6E32\u67D3",normalized:"render"},into:{primary:"\u8FDB\u5165",normalized:"into"},before:{primary:"\u4E4B\u524D",normalized:"before"},after:{primary:"\u4E4B\u540E",normalized:"after"},until:{primary:"\u76F4\u5230",normalized:"until"},event:{primary:"\u4E8B\u4EF6",normalized:"event"},from:{primary:"\u4ECE",normalized:"from"},connect:{primary:"\u8FDE\u63A5",alternatives:["\u8FDE\u63A5\u5668"],normalized:"connect"},stream:{primary:"\u6D41",alternatives:["\u6D41\u5F0F\u4F20\u8F93"],normalized:"stream"},live:{primary:"\u5B9E\u65F6",alternatives:["\u76F4\u64AD"],normalized:"live"},socket:{primary:"\u5957\u63A5\u5B57",alternatives:["websocket","socket"],normalized:"socket"},bind:{primary:"\u7ED1\u5B9A",alternatives:["bind"],normalized:"bind"},intercept:{primary:"\u62E6\u622A",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"\u5DE5\u4F5C\u7EBF\u7A0B",alternatives:["\u5DE5\u4F5C\u8005","worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u4E8B\u4EF6\u6E90"],normalized:"eventsource"}},tokenization:{boundaryStrategy:"character"},eventHandler:{keyword:{primary:"\u5F53",alternatives:["\u5728...\u65F6"],normalized:"on"},sourceMarker:{primary:"\u4ECE",position:"before"},eventMarker:{primary:"\u5F53",alternatives:["\u5728"],position:"before"},temporalMarkers:["\u5F53","\u5728...\u65F6"]}},Xo=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Qo=class{constructor(t=Xo){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}},eu="()[]{},:;",ru=class{constructor(t=eu){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function pt(t,e){let r=t[e];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$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return n?n[0]:null}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))return t.slice(e,n+1);n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return i?i[0]:null}return null}var tu=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?pt(t,e)!==null:false}extract(t,e){let r=pt(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},iu=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}}}};function nu(t,e){let r=t.slice(e);if(r.startsWith("http://")||r.startsWith("https://")){let i=r.match(/^https?:\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("//")){let i=r.match(/^\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("./")||r.startsWith("../")){let i=r.match(/^\.\.?\/[^\s]*/);return i?i[0]:null}if(r.startsWith("/")){let i=r.match(/^\/[^\s]*/);return i?i[0]:null}return null}var au=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=nu(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},ou=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 cr(t){let e=t.charCodeAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=63744&&e<=64255||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=183984&&e<=191471||e>=194560&&e<=195103}var uu=class{constructor(){this.name="chinese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return cr(t[e])}extract(t,e){if(!this.context)throw new Error("ChineseKeywordExtractor: context not set");let r=e,i=null;if(this.context.isKeywordStart(t,e))for(let o=10;o>=1;o--){let u=t.slice(e,e+o);if([...u].every(s=>cr(s))){let s=this.context.lookupKeyword(u);if(s){i={word:u,entry:s};break}}}if(i)return {value:i.word,length:i.word.length,metadata:{normalized:i.entry.normalized}};let n="",a=e;for(;a<t.length&&cr(t[a])&&(n+=t[a],a++,!(a<t.length&&this.context.isKeywordStart(t,a))););return n?{value:n,length:a-r,metadata:{}}:null}},dt=new Map([["\u628A",{role:"patient",confidence:.95,description:"ba-construction object marker"}],["\u5728",{role:"location",confidence:.85,description:"at/in/on location marker"}],["\u4ECE",{role:"source",confidence:.9,description:"from marker"}],["\u5230",{role:"destination",confidence:.9,description:"to/until marker"}],["\u5411",{role:"destination",confidence:.85,description:"towards marker"}],["\u7ED9",{role:"destination",confidence:.85,description:"to/for recipient marker"}],["\u5BF9",{role:"destination",confidence:.8,description:"to/towards marker"}],["\u7528",{role:"instrument",confidence:.85,description:"with/using marker"}],["\u88AB",{role:"agent",confidence:.8,description:"by (passive) marker"}],["\u8BA9",{role:"agent",confidence:.75,description:"let/make causative marker"}],["\u7684",{role:"possessive",confidence:.9,description:"possessive/attributive marker"}],["\u5730",{role:"manner",confidence:.85,description:"adverbial marker"}],["\u5F97",{role:"manner",confidence:.8,description:"complement marker"}],["\u4E86",{role:"aspect",confidence:.7,description:"completion aspect marker"}],["\u7740",{role:"aspect",confidence:.7,description:"progressive aspect marker"}],["\u8FC7",{role:"aspect",confidence:.7,description:"experiential aspect marker"}],["\u5417",{role:"mood",confidence:.75,description:"question particle"}],["\u5462",{role:"mood",confidence:.7,description:"question/emphasis particle"}],["\u5427",{role:"mood",confidence:.7,description:"suggestion particle"}]]),ft=new Map([["\u7136\u540E",{role:"sequence",confidence:.9,description:"then/afterwards"}],["\u63A5\u7740",{role:"sequence",confidence:.85,description:"next/following"}],["\u5E76\u4E14",{role:"conjunction",confidence:.85,description:"and/moreover"}],["\u6216\u8005",{role:"conjunction",confidence:.85,description:"or"}],["\u5982\u679C",{role:"condition",confidence:.9,description:"if"}],["\u90A3\u4E48",{role:"consequence",confidence:.85,description:"then"}],["\u5426\u5219",{role:"alternative",confidence:.85,description:"otherwise"}]]),su=class{constructor(){this.name="chinese-particle";}setContext(t){this._context=t;}longerKeywordAt(t,e,r){let i=this._context;if(!i)return false;let n=Math.min(10,t.length-e);for(let a=n;a>r;a--)if(i.lookupKeyword(t.slice(e,e+a)))return true;return false}canExtract(t,e){let r=t[e];if(dt.has(r)&&!this.longerKeywordAt(t,e,1))return true;for(let[i]of ft)if(t.startsWith(i,e)&&!this.longerKeywordAt(t,e,i.length))return true;return false}extract(t,e){for(let[n,a]of ft)if(t.startsWith(n,e)&&!this.longerKeywordAt(t,e,n.length))return {value:n,length:n.length,metadata:{particleRole:a.role,particleConfidence:a.confidence,particleDescription:a.description}};let r=t[e],i=dt.get(r);return i&&!this.longerKeywordAt(t,e,1)?{value:r,length:1,metadata:{particleRole:i.role,particleConfidence:i.confidence,particleDescription:i.description}}:null}};function lu(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function cu(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var mu=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return lu(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",n=e;for(;n<t.length&&cu(t[n]);)i+=t[n],n++;if(!i)return null;let a=this.context.lookupKeyword(i),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:n-r,metadata:{normalized:o}}}};function pu(){return [new au,new iu,new ou,new tu]}var du=new Set(["\u628A","\u5728","\u4ECE","\u5230","\u5411","\u7ED9","\u5BF9","\u7528","\u88AB","\u8BA9","\u7684","\u5730","\u5F97","\u4E86","\u7740","\u8FC7","\u5417","\u5462","\u5427"]),fu=[{native:"\u771F",normalized:"true"},{native:"\u5047",normalized:"false"},{native:"\u7A7A",normalized:"null"},{native:"\u672A\u5B9A\u4E49",normalized:"undefined"},{native:"\u7B2C\u4E00\u4E2A",normalized:"first"},{native:"\u9996\u4E2A",normalized:"first"},{native:"\u6700\u540E\u4E00\u4E2A",normalized:"last"},{native:"\u672B\u4E2A",normalized:"last"},{native:"\u4E0B\u4E00\u4E2A",normalized:"next"},{native:"\u4E0A\u4E00\u4E2A",normalized:"previous"},{native:"\u6700\u8FD1\u7684",normalized:"closest"},{native:"\u7236\u7EA7",normalized:"parent"},{native:"\u70B9\u51FB",normalized:"click"},{native:"\u53CC\u51FB",normalized:"dblclick"},{native:"\u8F93\u5165",normalized:"input"},{native:"\u53D8\u66F4",normalized:"change"},{native:"\u6539\u53D8",normalized:"change"},{native:"\u63D0\u4EA4",normalized:"submit"},{native:"\u6309\u952E",normalized:"keydown"},{native:"\u91CA\u653E\u952E",normalized:"keyup"},{native:"\u9F20\u6807\u79FB\u5165",normalized:"mouseover"},{native:"\u9F20\u6807\u79FB\u51FA",normalized:"mouseout"},{native:"\u83B7\u5F97\u7126\u70B9",normalized:"focus"},{native:"\u5931\u53BB\u7126\u70B9",normalized:"blur"},{native:"\u52A0\u8F7D",normalized:"load"},{native:"\u6EDA\u52A8",normalized:"scroll"},{native:"\u6211\u7684",normalized:"my"},{native:"\u5B83\u7684",normalized:"its"},{native:"\u79D2",normalized:"s"},{native:"\u6BEB\u79D2",normalized:"ms"},{native:"\u5206\u949F",normalized:"m"},{native:"\u5C0F\u65F6",normalized:"h"},{native:"\u548C",normalized:"and"},{native:"\u6216\u8005",normalized:"or"},{native:"\u6216",normalized:"or"},{native:"\u4E0D",normalized:"not"},{native:"\u975E",normalized:"not"},{native:"\u662F",normalized:"is"},{native:"\u82E5",normalized:"if"},{native:"\u4E0D\u7136",normalized:"else"},{native:"\u5FAA\u73AF",normalized:"repeat"},{native:"\u904D\u5386",normalized:"for"},{native:"\u6BCF\u4E2A",normalized:"for"},{native:"\u4E3A\u6BCF",normalized:"for"},{native:"\u4E2D\u6B62",normalized:"halt"},{native:"\u629B",normalized:"throw"},{native:"\u547C\u53EB",normalized:"call"},{native:"\u56DE",normalized:"return"},{native:"\u811A\u672C",normalized:"js"},{native:"\u901A\u77E5",normalized:"tell"},{native:"\u7F3A\u7701",normalized:"default"},{native:"\u521D\u59CB",normalized:"init"},{native:"\u52A8\u4F5C",normalized:"behavior"},{native:"\u6FC0\u53D1",normalized:"trigger"},{native:"\u5BF9\u7126",normalized:"focus"},{native:"\u6A21\u7CCA",normalized:"blur"},{native:"\u8DF3\u8F6C",normalized:"go"},{native:"\u5BFC\u822A",normalized:"go"},{native:"\u6293\u53D6",normalized:"fetch"},{native:"\u83B7\u53D6\u6570\u636E",normalized:"fetch"},{native:"\u5B89\u5B9A",normalized:"settle"},{native:"\u62FF\u53D6",normalized:"take"},{native:"\u53D6",normalized:"take"},{native:"\u521B\u5EFA",normalized:"make"},{native:"\u514B\u9686",normalized:"clone"},{native:"\u8BB0\u5F55",normalized:"log"},{native:"\u6253\u5370",normalized:"log"},{native:"\u52A8\u753B",normalized:"transition"},{native:"\u5230\u91CC\u9762",normalized:"into"},{native:"\u91CC",normalized:"into"},{native:"\u524D",normalized:"before"},{native:"\u540E",normalized:"after"},{native:"\u90A3\u4E48",normalized:"then"},{native:"\u5B8C",normalized:"end"}],yu=class extends De{constructor(){super(),this.language="zh",this.direction="ltr",this.initializeKeywordsFromProfile(yt,fu),this.registerExtractors(pu()),this.registerExtractor(new we),this.registerExtractor(new Ae),this.registerExtractor(new mu),this.registerExtractor(new su),this.registerExtractor(new uu),this.registerExtractor(new Qo),this.registerExtractor(new ru);}classifyToken(t){return du.has(t)?"particle":this.isKeyword(t)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(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("'")||t.startsWith("\u201C")||t.startsWith("\u2018")||/^\d/.test(t)?"literal":"identifier"}},hu=new yu;Re("zh",hu,yt);function Ye(t){let e=t.getAttribute("data-lang");if(e)return mr(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return mr(r);let i=typeof document<"u"?document.documentElement?.lang:null;return i&&i!=="en"?mr(i):null}function mr(t){return t.split("-")[0].toLowerCase()}var ht={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],bind:[["destination",""],["source","to"]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],eventsource:[],exit:[],fetch:[["source",""],["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"]],on:[["event",""],["source","from"]],open:[["style","as"],["patient",""]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"]],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"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],while:[["condition",""]],worker:[]};function Ze(t){switch(t.kind){case "event-handler":return vu(t);case "compound":return Eu(t);default:return gu(t)}}function vu(t){let e=["on"],r=t.roles.get("event");r&&e.push(Ve(r));let i=t.roles.get("source");if(i&&e.push("from",Ve(i)),t.body&&t.body.length>0){let n=t.body.map(Ze);e.push(n.join(" then "));}return e.join(" ")}function Eu(t){let e=t.chainType==="async"?"async":t.chainType;return t.statements.map(Ze).join(` ${e} `)}function gu(t){let e=ht[t.action];if(e){let i=[t.action];for(let[n,a]of e){let o=t.roles.get(n);o&&(n==="destination"&&o.type==="reference"&&o.value==="me"||(a&&i.push(a),i.push(Ve(o))));}return i.join(" ")}let r=[t.action];for(let[,i]of t.roles)r.push(Ve(i));return r.join(" ")}function Ve(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 zu(t);case "expression":return t.raw;case "flag":return t.enabled?`+${t.name}`:`~${t.name}`}}function zu(t){let e=Ve(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 Et=.5,Cu={confidenceThreshold:Et,strategy:"semantic",fallbackToOriginal:true};function ku(t,e){return typeof t=="number"?t:t[e]??t["*"]??Et}function pr(t,e,r={}){let i={...Cu,...r},n=vt(t,e,i);if(n!==null)return n;let a=wu(t);if(a){let o=vt(a.commands,e,i);if(o!==null)return a.prefix+o}return t}function vt(t,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let i=ku(r.confidenceThreshold,e),n=gt(t,e,i);if(n!==null)return n}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let i=Au(t,e,r.i18nToEnglish);if(i!==null)return i}return null}var bu=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function wu(t){let e=t.match(bu);if(!e)return null;let r=e[1],i=t.slice(r.length);return i?{prefix:r,commands:i}:null}function gt(t,e,r){try{let i=Bu(t,e);if(i.length>1)return Su(i,e,r);if(!Vr(e))return null;let n=Zr(t,e);return n.confidence<r||!n.node?null:Ze(n.node)}catch{return null}}function Au(t,e,r){try{let i=r(t,e);return i!==t?i:null}catch{return null}}function Du(t){let e=["then"],r=N(t);if(r?.keywords?.then){let i=r.keywords.then;if(i.primary&&i.primary!=="then"&&e.push(i.primary),i.alternatives)for(let n of i.alternatives)e.includes(n)||e.push(n);}return e}function Bu(t,e){let i=Du(e).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),n=new RegExp(`\\s+(?:${i.join("|")})\\s+`,"i"),a=t.split(`
5
- `).map(u=>u.trim()).filter(u=>u.length>0),o=[];for(let u of a){let s=u.split(n);o.push(...s);}return o}function Su(t,e,r){let i=[];for(let n of t){let a=gt(n.trim(),e,r);if(a===null)return null;i.push(a);}return i.join(" then ")}function dr(t={}){return function(r){let{internals:i}=r,n=i.runtime,a=n.getScript.bind(n);n.getScript=function(o){let u=a(o);if(!u)return null;let s=xu(o,t);if(!s||s==="en")return u;let l=pr(u,s,t);return t.debug&&l!==u&&console.log(`[hyperscript-i18n] ${s}: "${u}" \u2192 "${l}"`),l};}}function xu(t,e){if(e.languageAttribute){let i=t.getAttribute(e.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let r=Ye(t);return r||(e.defaultLanguage??null)}function zt(t,e,r={}){return e==="en"?t:pr(t,e,r)}jr(t=>Xr(t));function Ct(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(dr()),Tu());}function Tu(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let r=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(r).forEach(i=>{let n=e.getInternalData(i);n.initialized&&(n.initialized=false);}),e.processNode(document.body);}var _l=["ja","ko","zh"];Ct();exports.plugin=dr;exports.preprocess=zt;exports.resolveLanguage=Ye;exports.supportedLanguages=_l;return exports;})({});
1
+ var HyperscriptI18n=(function(exports){'use strict';function ue(t,e){return e?{type:"literal",value:t,dataType:e}:{type:"literal",value:t}}function Ze(t,e){return e?{type:"selector",value:t,selectorKind:e}:{type:"selector",value:t}}function Ie(t){return {type:"reference",value:t}}function Xe(t,e){return {type:"property-path",object:t,property:e}}var _r=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function dr(t,e=_r){return e.has(t)}var ci=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 mi(t){return new ci(t)}function De(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 di(t,e){return t?.possessive?.keywords?.[e]}var $e=class Be{constructor(){this.logger=mi("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 s=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)s.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",s),this.logger.debug("Profile code:",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(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(n),null;let u=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-n.position,confidence:u}}matchBest(e,r,i){let n=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,i);s&&n.push(s),e.reset(u);}if(n.length===0)return null;n.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let 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 u=null,s=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let m=e.peek();if(this.logger.debug(" >> Current input token:",m?JSON.stringify({type:m.type,value:m.value,kind:m.kind}):"EOF"),c.type==="role"&&c.greedy){let v=this.collectStopMarkers(r,l+1);if(n)for(let h of n)v.add(h);let f=[];for(;!e.isAtEnd();){let h=e.peek();if(!h||this.isStopMarker(h,v))break;f.push(h.value),e.advance();}if(f.length>0){i.set(c.role,{type:"expression",raw:f.join(" ")}),u=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let v=this.collectStopMarkers(r,l+1);if(n)for(let h of n)v.add(h);if(this.matchGroupToken(e,c,i,v)){u=null,s=null;continue}if(this.isOptional(c))continue;return false}let d=c.type==="role"&&c.optional===true,p=d?e.mark():null;if(c.type==="role"&&!d){let v=l+1<r.length?r[l+1]:null;if(v?.type==="literal"){let f=e.peek();if(f&&this.getMatchType(f,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(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),i.delete(s),u=null,s=null;let h=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}}let E=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Match result:",E),E){d?(u=p,s=c.role):(u=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),i.delete(s),u=null,s=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&&!De(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&&!De(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!De(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!De(s.type,r.expectedTypes)?r.optional||false:(i.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!De(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&&!De(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=di(this.currentProfile,n);if(!a)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),Xe(Ie(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 u=[];for(;!e.isAtEnd()&&u.length<Be.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.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}`,u=1;for(;!e.isAtEnd()&&u<Be.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<Be.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(c===0){e.advance();break}c--;}if(d.kind==="punctuation"&&d.value==="("&&c++,d.kind==="punctuation"&&d.value===","){e.advance();continue}l.push(d.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let 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(),Xe(Ze(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 Xe(Ze(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 s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=Be.MAX_MARKER_SCAN;l++){let c=e.peek(l);if(!c)break;if((c.normalized||c.value).toLowerCase()===s){this.logger.debug(" >> MARKER SCAN: found",s,"at offset",l,"- skipping intervening tokens");for(let 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 u of o.alternatives)i.add(u.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 Ze(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return ue(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Ie(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return ue(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 ue(n,"string")}if(e==="true")return ue(true,"boolean");if(e==="false")return ue(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?ue(e,"duration"):ue(n,"number")}let i=parseFloat(e);return isNaN(i)?ue(e,"string"):ue(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 m=a(c.role),d=.8;n+=d,r.has(c.role)?i+=d:m&&(i+=d*.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 u=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+u);let s=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+s)),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 u=n[a];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?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(Be.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}};$e.MAX_MARKER_SCAN=3;$e.MAX_PROPERTY_DEPTH=10;$e.MAX_METHOD_ARGS=20;$e.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var pi=$e;new pi;var Se=class{constructor(){this.name="string-literal";}canExtract(t,e){let r=t[e];return 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}},xe=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),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value: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 s=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of s)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 fi(t){return "setContext"in t&&typeof t.setContext=="function"}function yi(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 re=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 $(t,e){return {start:t,end:e}}function V(t,e,r,i){if(typeof t=="object"){let{value:a,kind:o,position:u,normalized:s,stem:l,stemConfidence:c,metadata:m}=t;return {value:a,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...m!==void 0&&{metadata:m}}}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:u,metadata:s}=i;return {value:n,kind:e,position:r,...a!==void 0&&{normalized:a},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:n,kind:e,position:r}}function je(t){return /\s/.test(t)}function hi(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function vi(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function he(t){return /\d/.test(t)}function Qe(t){return t.replace(/[ً-ْٰ]/g,"")}function Ei(t){return /[a-zA-Z]/.test(t)}function X(t){return /[a-zA-Z0-9_-]/.test(t)}function gi(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&&X(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&&X(t[o]);)o++;if(o<t.length&&t[o]==="(")return n}}else if(r==="["){let a=1,o=false,u=null,s=false;for(n+=t[i++];i<t.length&&a>0;){let l=t[i];n+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?a++:l==="]"&&a--,i++;}if(a!==0)return null}else if(r==="@"){for(n+=t[i++];i<t.length&&X(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="*"){for(n+=t[i++];i<t.length&&X(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="<"){if(n+=t[i++],i>=t.length||!Ei(t[i]))return null;for(;i<t.length&&X(t[i]);)n+=t[i++];for(;i<t.length;){let a=t[i];if(a==="."){if(n+=t[i++],i>=t.length||!X(t[i]))return null;for(;i<t.length&&X(t[i]);)n+=t[i++];}else if(a==="#"){if(n+=t[i++],i>=t.length||!X(t[i]))return null;for(;i<t.length&&X(t[i]);)n+=t[i++];}else if(a==="["){let o=1,u=false,s=null,l=false;for(n+=t[i++];i<t.length&&o>0;){let c=t[i];n+=c,l?l=false:c==="\\"?l=true:u?c===s&&(u=false,s=null):c==='"'||c==="'"||c==="`"?(u=true,s=c):c==="["?o++:c==="]"&&o--,i++;}if(o!==0)return null}else break}for(;i<t.length&&je(t[i]);)n+=t[i++];if(i<t.length&&t[i]==="/")for(n+=t[i++];i<t.length&&je(t[i]);)n+=t[i++];if(i>=t.length||t[i]!==">")return null;n+=t[i++];}return n||null}function Ci(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 je(i)||i==="*"||!X(i)}function zi(t,e){if(e>=t.length)return null;let r=t[e];if(!vi(r)||r==="'"&&Ci(t,e))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!n)return null;let a=e+1,o=r,u=false;for(;a<t.length;){let s=t[a];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===n)return o;a++;}return o}function ki(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 wi(t,e){if(!ki(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 bi(t,e){if(e>=t.length)return null;let r=t[e];if(!he(r)&&r!=="-"&&r!=="+")return null;let i=e,n="";if((t[i]==="-"||t[i]==="+")&&(n+=t[i++]),i>=t.length||!he(t[i]))return null;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++];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 Ai=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Ai);var Di=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"]),Bi=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],er=class Je{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){fi(e)&&e.setContext(yi(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&&je(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 u=o.extract(e,i);if(u){let s=u.metadata?.normalized,l=u.metadata?.stem,c=u.metadata?.stemConfidence,m={};if(u.metadata)for(let[p,y]of Object.entries(u.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(m[p]=y);let d={};s&&(d.normalized=s),l&&(d.stem=l),c!==void 0&&(d.stemConfidence=c),Object.keys(m).length>0&&(d.metadata=m),r.push(V(u.value,this.classifyToken(u.value),$(i,i+u.length),Object.keys(d).length>0?d:void 0)),i+=u.length,a=true;break}}if(!a){let o=e[i],u=this.classifyUnknownChar(o);r.push(V(o,u,$(i,i+1))),i++;}}return new re(this.mergeColonQualifiedNames(r),this.language)}mergeColonQualifiedNames(e){let r=[];for(let i of e){let n=r[r.length-1];if(n&&Je.ASCII_WORD.test(n.value)&&Je.COLON_QUALIFIER.test(i.value)&&n.position.end===i.position.start){let a=n.value+i.value;r[r.length-1]=V(a,this.classifyToken(a),$(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(V(".","operator",$(r,r+1))),true;let s=r+1;for(;s<e.length&&X(e[s]);)s++;return s<e.length&&e[s]==="("?(i.push(V(".","operator",$(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 Bi)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(" ")&&!Di.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 Qe(e)}tryProfileKeyword(e,r){for(let i of this.profileKeywords)if(e.slice(r).startsWith(i.native))return V(i.native,"keyword",$(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 V(a.native,"keyword",$(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 V(e,"keyword",$(r,i),o)}trySelector(e,r){let i=gi(e,r);return i?V(i,"selector",$(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 {...V(n,"event-modifier",$(r,r+n.length)),metadata:{modifierName:a,value:o?a==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let i=zi(e,r);return i?V(i,"literal",$(r,r+i.length)):null}tryNumber(e,r){let i=bi(e,r);return i?V(i,"literal",$(r,r+i.length)):null}tryMatchTimeUnit(e,r,i,n=false){let a=r;if(n)for(;a<e.length&&je(e[a]);)a++;let o=e.slice(a);for(let u of i){let s=o.slice(0,u.length);if(u.caseInsensitive?s.toLowerCase()===u.pattern.toLowerCase():s===u.pattern){if(u.notFollowedBy&&(o[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let c=o[u.length]||"";if(X(c))continue}return {suffix:u.suffix,endPos:a+u.length}}}return null}parseBaseNumber(e,r,i=true){let n=r,a="";if(i&&(e[n]==="-"||e[n]==="+")&&(a+=e[n++]),n>=e.length||!he(e[n]))return null;for(;n<e.length&&he(e[n]);)a+=e[n++];if(n<e.length&&e[n]===".")for(a+=e[n++];n<e.length&&he(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,u=this.parseBaseNumber(e,r,a);if(!u)return null;let{number:s,endPos:l}=u,c=[...i,...Je.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,o);return m&&(s+=m.suffix,l=m.endPos),V(s,"literal",$(r,l))}tryUrl(e,r){let i=wi(e,r);return i?V(i,"url",$(r,r+i.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!X(e[r+1]))return null;let i=r+1;for(;i<e.length&&X(e[i]);)i++;let n=e.slice(r,i);return V(n,"identifier",$(r,i))}tryOperator(e,r){let i=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(i))return V(i,"operator",$(r,r+2));let n=e[r];return ["<",">","!","+","-","*","/","="].includes(n)?V(n,"operator",$(r,r+1)):["(",")","{","}",",",";",":"].includes(n)?V(n,"punctuation",$(r,r+1)):null}tryMultiCharParticle(e,r,i){for(let n of i)if(e.slice(r,r+n.length)===n)return V(n,"particle",$(r,r+n.length));return null}};er.ASCII_WORD=/^[A-Za-z_][A-Za-z0-9_]*$/;er.COLON_QUALIFIER=/^:[A-Za-z_][A-Za-z0-9_]*$/;er.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 Te=er;function rr(t){return {stem:t,confidence:1}}function pe(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}var Si=Object.defineProperty,xi=Object.getOwnPropertyNames,ut=(t,e)=>function(){return t&&(e=(0, t[xi(t)[0]])(t=0)),e},Ti=(t,e)=>{for(var r in e)Si(t,r,{get:e[r],enumerable:true});};function jr(t,e){return t.replace(/\{(\w+)\}/g,(r,i)=>String(e[i]??`{${i}}`))}function Q(t,e,r={},i){let n=st[t],a=jr(n,r),o=lt[t],u=o?jr(o,r):void 0;return {code:t,message:a,severity:e,...i&&{role:i},...u&&{suggestion:u}}}var T,st,lt,Fi=ut({"src/generators/schema-error-codes.ts"(){T={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},st={[T.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[T.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[T.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[T.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[T.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[T.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.",[T.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.",[T.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[T.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[T.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[T.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[T.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[T.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[T.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[T.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[T.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[T.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},lt={[T.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[T.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[T.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[T.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[T.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[T.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[T.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[T.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[T.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[T.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[T.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[T.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[T.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[T.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),ct={};Ti(ct,{SchemaErrorCodes:()=>T,formatValidationResults:()=>Mi,getValidationStats:()=>Ii,validateAllKeywordCollisions:()=>$i,validateAllSchemas:()=>_i,validateCommandSchema:()=>mt,validateKeywordCollisions:()=>dt,validateRoleValues:()=>ji});function Ri(t,e){return {action:t,items:e}}function mt(t){let e=[];for(let i of t.roles)i.expectedTypes.includes("literal")&&i.expectedTypes.includes("selector")&&(i.role==="patient"&&Er.has(t.action)?e.push(Q(T.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:i.role,command:t.action},i.role)):e.push(Q(T.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:i.role},i.role))),i.expectedTypes.length>3&&!Er.has(t.action)&&e.push(Q(T.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(Q(T.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:i.role},i.role)));switch(t.action){case "transition":Oi(t,e);break;case "on":Li(t,e);break;case "if":case "unless":Pi(t,e);break;case "repeat":case "for":case "while":Ni(t,e);break}return t.roles.filter(i=>i.required).length===0&&(pt.has(t.action)?e.push(Q(T.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(Q(T.NO_REQUIRED_ROLES,"warning",{}))),Ri(t.action,e)}function Oi(t,e){let r=t.roles.find(n=>n.role==="patient"),i=t.roles.find(n=>n.role==="goal");r&&!i&&e.push(Q(T.TRANSITION_MISSING_GOAL,"error",{}));}function Li(t,e){let r=t.roles.find(i=>i.role==="event");r||e.push(Q(T.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(Q(T.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Pi(t,e){let r=t.roles.find(i=>i.role==="condition");r||e.push(Q(T.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(Q(T.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Ni(t,e){t.action==="for"?t.roles.find(i=>i.role==="source")||e.push(Q(T.FOR_LOOP_MISSING_SOURCE,"warning",{})):t.action==="while"&&(t.roles.find(i=>i.role==="condition")||e.push(Q(T.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function _i(t,e={}){let r=new Map,{includeNotes:i=false}=e;for(let[n,a]of Object.entries(t)){let o=mt(a),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=i&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(n,o);}return r}function Mi(t,e={}){let r=[],{showNotes:i=false,showCodes:n=true}=e;for(let[a,o]of t){let u=o.items.filter(c=>c.severity==="error"),s=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(u.length>0){r.push(` \u274C ${a}:`);for(let c of u){let m=n?` [${c.code}]`:"";r.push(` ERROR${m}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(s.length>0){r.push(` \u26A0\uFE0F ${a}:`);for(let c of s){let m=n?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(i&&l.length>0){r.push(` \u2139\uFE0F ${a}:`);for(let c of l){let m=n?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`);}}}return r.join(`
2
+ `)}function Ii(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 ji(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:T.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:T.SELECTOR_KIND_MISMATCH})));}return r}function dt(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 u of a.alternatives){let s=r.get(u)||[];s.push({command:n,isPrimary:false}),r.set(u,s);}}for(let[n,a]of r){let o=[...new Set(a.map(l=>l.command))];if(o.length<=1)continue;let u=a.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:n,commands:o.sort(),type:s});}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 $i(t){let e=[];for(let[,r]of Object.entries(t)){let i=dt(r);i.collisions.length>0&&e.push(i);}return e.sort((r,i)=>r.language.localeCompare(i.language))}var Er,pt,Vi=ut({"src/generators/schema-validator.ts"(){Fi(),Er=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),pt=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint","live","eventsource","socket","worker","intercept"]);}});var Ce=new Map,ce=new Map,qe=new Map,gr=null;function ft(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]=ft(a,n):r[i]=n);}return r}function qi(t,e){return ft(t,e)}function wr(t){if(!t.extends)return t;let e=ce.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=wr(e);return qi(r,t)}function Ne(t,e,r){Ce.set(t,e),ce.set(t,r),qe.delete(t);}function yt(t){gr=t;}var $r=new Map;function Le(t){return t.split("-")[0]}function Pe(t){return t.includes("-")}function Wi(t){let e=Ce.get(t);if(!e&&Pe(t)){let r=Le(t);e=Ce.get(r);}if(!e){let r=Array.from(Ce.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 Ki(t){let e=ce.get(t);if(!e&&Pe(t)){let r=Le(t);e=ce.get(r);}if(!e){let r=Array.from(ce.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 wr(e)}function L(t){let e=ce.get(t);return !e&&Pe(t)&&(e=ce.get(Le(t))),e?wr(e):void 0}function Ui(){return Array.from(Ce.keys())}function ht(t){if(Ce.has(t)&&ce.has(t))return true;if(Pe(t)){let e=Le(t);return Ce.has(e)&&ce.has(e)}return false}function Hi(t,e){return Wi(e).tokenize(t)}function le(t){let e=qe.get(t);if(!e&&Pe(t)&&(e=qe.get(Le(t))),e)return e;let r=$r.get(t);if(!r&&Pe(t)&&(r=$r.get(Le(t))),r)return qe.set(t,r),r;if(!gr)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let i=Ki(t),n=gr(i);return qe.set(t,n),n}var vt={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function ge(t){let e="complex";return t.startsWith("#")&&!t.includes(" ")?e="id":t.startsWith(".")&&!t.includes(" ")?e="class":t.startsWith("[")&&t.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(t)&&(e="element"),{type:"selector",value:t,selectorKind:e}}function q(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}function Fe(t){return dr(t)}function ne(t){return {type:"reference",value:t}}function ve(t,e){return {type:"property-path",object:t,property:e}}function te(t,e,r){let i={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...i,metadata:r}:i}function Ve(t,e,r,i,n,a){let o=new Map;o.set("event",t);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),i!==void 0&&(u.metadata=i),n!==void 0&&n.length>0&&(u.parameterNames=n),u}function gn(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 Cn(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 Vr(t,e,r,i){let n={kind:"feature",action:t,roles:new Map,body:e};return r!==void 0&&(n.name=r),i!==void 0&&(n.metadata=i),n}function Cr(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 zn(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 tr(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 ke(t){let e=t.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function we(t){let e=t.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function be(t,e){return Et(t,e,"source")}function br(t,e){return Et(t,e,"destination")}function Et(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 kn={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}}],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)"}},wn={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector","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"}},bn={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",targetRole:"source",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"}},An={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"}},Dn={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{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",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"},markerVariants:{tr:["e","a","ye","ya"]}},{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>"}},Bn={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>"}},Sn={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},xn={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Tn={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Fn={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Rn={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},On={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Ln={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Pn={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Nn={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2,markerVariants:{hi:["\u0915\u094B"],qu:["ta"],bn:["\u0995\u09C7"]}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},_n={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}]},Mn={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"style",description:"Request options object (method, headers, body, credentials\u2026)",required:false,expectedTypes:["expression"],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"}},{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}]},In={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},jn={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},$n={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Vn={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},qn={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Wn={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",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}]},Kn={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Un={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},Hn={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Gn={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Yn={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Zn={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","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"}}]},Xn={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Jn={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Qn={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},ea={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},ra={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference","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"}}]},ta={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},ia={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Ar={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"},na={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:Ar,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},aa={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",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}]},oa={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},ua={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},sa={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},la={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}]},ca={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"as"}}]},ma={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}]},da={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}]},pa={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}]},fa={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}]},ya={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},ha={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],markerOptional:{he:true,zh:true},svoPosition:1,sovPosition:1}]},va={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},Ea={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},ga={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Ca={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},za={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["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"}}]},ka={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},wa={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},ba={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Aa={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Da={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of",es:"",fr:"",pt:"",it:"",de:"",pl:"",ru:"",uk:"",id:"",ms:"",sw:"",th:"",vi:"",he:"\u05D0\u05EA",zh:"\u628A"}},{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"}}]},Ba={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",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"}}]},Sa={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}]},xa={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Ta={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}]},Fa={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Ra={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}]},Oa={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"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"},Pa={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:Ar}]},Na={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:Ar}]},_a={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",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}]},Ma={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},ze={toggle:kn,add:wn,remove:bn,put:An,set:Dn,show:On,hide:Ln,on:Pn,trigger:Nn,wait:_n,fetch:Mn,increment:In,decrement:jn,append:$n,prepend:Vn,log:qn,get:Wn,take:Kn,make:Un,halt:Hn,settle:Gn,throw:Yn,send:Zn,if:Xn,unless:Jn,else:Qn,repeat:ea,for:ra,while:ta,continue:ia,go:na,scroll:Oa,push:Pa,replace:Na,process:_a,transition:aa,clone:oa,focus:ua,blur:sa,empty:la,open:ca,close:ma,select:da,clear:pa,reset:fa,breakpoint:ya,call:ha,return:va,js:Ea,async:ga,tell:Ca,default:za,init:ka,behavior:wa,install:ba,measure:Aa,swap:Da,morph:Ba,beep:Sa,break:xa,copy:Ta,exit:Fa,pick:Ra,render:Ma,bind:Bn,live:Sn,eventsource:xn,socket:Tn,worker:Fn,intercept:Rn,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function J(t){return ze[t]}function Ia(){return Object.values(ze).filter(t=>t.roles.length>0||t.bareKeyword===true)}typeof process<"u"&&process.env.LOKASCRIPT_SCHEMA_VALIDATION==="1"&&Promise.resolve().then(()=>(Vi(),ct)).then(({validateAllSchemas:t,formatValidationResults:e})=>{let r=t(ze);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
3
+ These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(t=>{console.debug("Schema validation skipped:",t);});function 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 pr(t){return vt.possessive?.specialForms?.[t]??`${t}'s`}var ja={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"}},$a={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"}},Va={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"])};function gt(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?Va[t.code]:void 0;return !!n&&n.has(r)}var qa={destination:"in",source:"from"},Wa={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"])},Ka=new Set(["in","into","at","within","inside"]);function Ua(t,e){let r=e.value.toLowerCase();if((t?.code?Wa[t.code]:void 0)?.has(r))return "in";let n=e.normalized??e.value,a=n.toLowerCase();return Ka.has(a)?"in":qa[a]??n}var fr=new Set(["first","last","next","previous","random","closest"]),Ha={bn:{\u09B6\u09C7\u09B7:"last"}},Ct=new Set(Object.keys(ze).map(t=>t.toLowerCase()));function zt(t,e,r){let i=t[e];if(!i)return null;let n=(i.normalized??i.value).toLowerCase(),a=t[e+1],o=r?.code&&a?.kind==="selector"&&a.value.startsWith("<")?Ha[r.code]?.[i.value.toLowerCase()]:void 0;if(!fr.has(n)&&!fr.has(i.value.toLowerCase())&&o===void 0)return null;let u=[{text:o??i.normalized??i.value,token:i}],s=e+1,l=t[s];if(!l||l.kind!=="selector")return null;u.push({text:l.value,token:l}),s++;let c=0;for(;c++<8;){let p=t[s];if(p&&p.kind==="selector"&&p.value.startsWith("."))u.push({text:p.value,token:p}),s++;else break}let m=t[s],d=t[s+1];return m&&d&&d.kind==="selector"&&(m.kind==="keyword"||m.kind==="particle"||m.kind==="identifier")&&!fr.has((m.normalized??m.value).toLowerCase())&&!Ct.has((m.normalized??m.value).toLowerCase())&&(u.push({text:Ua(r,m),token:m}),u.push({text:d.value,token:d}),s+=2),{parts:u,consumed:s-e}}function Ga(t,e){let r=$a[t];return r?r[e.toLowerCase()]??e:e}function Oe(t,e){let r=ja[t];return r?r[e.toLowerCase()]??e:e}function Ya(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 kt(t){return t.kind==="literal"||t.kind==="operator"||t.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(t.value)}function Za(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 Xa(t,e){return kt(t)?Oe(e,t.value)!==t.value?true:t.kind==="identifier":false}var Ja={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"}}},Qa=new Set(["empty","null","undefined","true","false"]),eo=new Set(["Number","Int","Float","String","Date","Array","Object","JSON","json","FormData","HTML","Fragment","Values"]);function ro(t,e,r,i){let n=Ja[t],a=n?.[e.value]??n?.[e.value.toLowerCase()];if(a){if(a.beforeTypeName&&i?.kind==="identifier"&&eo.has(i.value))return a.beforeTypeName;if(a.beforePredicate&&i&&(i.kind==="literal"||i.kind==="keyword"&&Qa.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 zr(t,e){let r=e?.code??"en",i="",n,a=(u,s)=>{if(n===void 0){i=u,n=s;return}let c=n.position?.end!==void 0&&s.position?.start!==void 0&&n.position.end===s.position.start&&(u.startsWith(".")||u.startsWith("!"));i+=(c?"":" ")+u,n=s;},o=u=>u.kind==="keyword"?u.normalized??u.value:u.value;for(let u=0;u<t.length;u++){let s=t[u],l=e?Ya(e,s):void 0,c=t[u+1];if(l!==void 0&&c){let E=e?.possessive?.connectors,v=!!E?.length&&E.some(z=>{let D=z.toLowerCase();return D===c.value.toLowerCase()||D===(c.normalized??"").toLowerCase()}),f=v?u+2:u+1,h=t[f];if(h&&Xa(h,r)){a(pr(l),s),a(Oe(r,h.value),h),u=f;continue}if(v&&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(pr(l),s),a(Oe(r,h.value.slice(1)),h),u=f;continue}if(!v&&/^\.[a-zA-Z_]\w*$/.test(c.value)&&s.position?.end!==void 0&&c.position?.start!==void 0&&s.position.end===c.position.start&&!Za(e,s)){a(pr(l),s),a(Oe(r,c.value.slice(1)),c),u+=1;continue}}let m=t[u+2];if(c&&m&&m.kind==="selector"&&gt(e,c)&&kt(s)){a(Oe(r,s.value),s),a("of",c),a(m.value,m),u+=2;continue}let d=zt(t,u,e);if(d){for(let E of d.parts)a(E.text,E.token);u+=d.consumed-1;continue}let p=ro(r,s,t[u-1],c);if(p!==void 0){a(p,s);continue}let y=Ga(r,s.value);if(y!==s.value){a(y,s);continue}a(o(s),s);}return i.trim()}var wt=[{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 qr(t,e,r,i){let n=wt.find(o=>o.lang===t);if(!n)return false;let a=(o,u)=>(o??"").toLowerCase()===u.toLowerCase();return a(e,n.end)&&a(r,n.at)&&a(i,n.of)}function to(t,e){let r=wt.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 bt={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};function io(t){return bt[t]}function no(t,e){return bt[e]?.has(t.toLowerCase())??false}var At=96,ao=/^[A-Za-z_][\w-]*$/,oo=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function Dt(t,e){let r=t.peek(e);return !!r&&r.kind==="identifier"&&oo.test(r.value)}function Bt(t,e){let r=t.peek(e);if(!r||r.kind!=="identifier"&&r.kind!=="keyword"||!ao.test(r.value))return false;let i=t.peek(e+1),n=t.peek(e+2);return !!i&&i.value===":"&&!!n}function Wr(t,e=0){return Dt(t,e)||Bt(t,e)}function uo(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++<At;){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 Kr(t){let e=t.peek();return e?e.value==="{"||e.value==="("?uo(t):e.value===","||e.value===":"?null:(t.advance(),e.value):null}function We(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=Kr(t);if(o===null)return t.reset(r),null;i.push(`${e}:${o}`);}else if(!Wr(t))return null;let n=0;for(;n++<At;){let a=t.peek();if(!a)break;if(a.value===","){if(i.length===0||!Wr(t,1))break;t.advance();continue}if(Dt(t,0)){i.push(t.advance().value);continue}if(!Bt(t,0))break;let o=t.advance().value;t.advance();let u=Kr(t);if(u===null)return t.reset(r),null;i.push(`${o}:${u}`);}return i.length===0?(t.reset(r),null):`{${i.join(", ")}}`}var yr=.8,so=.6,lo=.15,co=.5,Ur=.15,Hr=.1,Gr=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"]),mo={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"]},po=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(co,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=o=>e.extraction?.[o]?.default!==void 0;for(let o of e.template.tokens)if(o.type==="role")n+=1,r.has(o.role)&&(i+=1);else if(o.type==="group")for(let u of o.tokens)u.type==="role"&&(n+=yr,r.has(u.role)?i+=yr:a(u.role)&&(i+=yr*so));return n>0?i/n:1}scoreStemPenalty(t){let{stemMatchCount:e,totalKeywordMatches:r}=t;return e<=0||r<=0?0:-(e/r)*lo}scoreLanguageBoost(t){let{pattern:e}=t;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:Gr.has(r.value)||r.alternatives?.some(i=>Gr.has(i))?Ur: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=mo[n];if(!o||o.length===0)continue;let u="metadata"in a?a.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?i+=.1:i-=.1);}return Math.max(-Hr,Math.min(Hr,i))}},fo=new po,yo=new Set(Object.values(ze).filter(t=>t.bareKeyword===true).map(t=>t.action)),Z=class _{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??fo;}matchPattern(e,r){let i=e.mark(),n=new Map;if(this.currentProfile=L(r.language),this.currentPatternCommand=r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,!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}}matchBest(e,r){this.matchCache.clear();let i=[],n=e.position();for(let o of r){let u=e.mark(),s=`${n}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&i.push(l),e.reset(u);}if(i.length===0)return null;i.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.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 u=0;for(let s=0;s<r.length;s++){let l=r[s];u>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,i,l);let c=this.matchPatternToken(e,l,i,r[s+1]??n);if(u=l.type==="role"&&l.role==="event"?2:Math.max(0,u-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,u=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let c=l.value.toLowerCase();return o.primary?.toLowerCase()===c?true:!!o.alternatives?.some(m=>m.toLowerCase()===c)},s=o?.position;if(s!=="after"&&u(n)&&a.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(s==="after"&&n.kind==="selector"&&u(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":return this.matchRoleToken(e,r,i,n);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 u=e.peek();if(!u||u.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,u]of Object.entries(r.keywords))if(u.primary.toLowerCase()===a||u.alternatives?.some(s=>s.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 s=e.peek();if(!s||s.value!==i)return e.reset(a),false;e.advance();}let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword"&&u.kind!=="particle"||u.value.toLowerCase()!==n[o].toLowerCase())return e.reset(a),false;e.advance();}return true}matchRoleToken(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 f=this.tryFoldHyphenActionKeyword(e);if(f)return i.set(r.role,f),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!_.tokenLooksLikeEvent(a))return r.optional||false;let f=(a.normalized??a.value).toLowerCase();if(_.POSITIONAL_OR_SCOPE_KEYWORDS.has(f)||this.currentProfile&&(se(this.currentProfile,a.value)??se(this.currentProfile,f))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let f=(a.normalized??a.value).toLowerCase();if(_.STRUCTURAL_NEVER_EVENT.has(f))return r.optional||false}if(a.kind==="keyword"){let f=(a.normalized??a.value).toLowerCase();if(f==="then"||f==="end"&&e.peek(1)?.kind!=="selector"||no(a.value,this.currentProfile?.code??""))return r.optional||false}if(r.role==="duration"){let f=(a.normalized??a.value).toLowerCase();if(_.POSITIONAL_OR_SCOPE_KEYWORDS.has(f))return r.optional||false}if(r.optional&&n===void 0&&r.role!=="event"&&r.role!=="action"&&a.kind==="keyword"&&(a.normalized??a.value).toLowerCase()in ze)return true;let o=this.tryMatchPositionalExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!tr(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let u=this.tryMatchCaretScopeExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!tr(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let f=this.tryMatchBeepPrefixExpression(e);if(f)return i.set(r.role,f),true;let h=this.tryMatchOperatorRunExpression(e);if(h)return i.set(r.role,h),true}if(this.currentPatternCommand==="pick"&&r.role==="patient"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let f=this.tryMatchPickRangeExpression(e);if(f)return i.set(r.role,f),true}if(r.expectedTypes?.includes("property-path")){let f=this.tryMatchOfPossessiveExpression(e);if(f)return i.set(r.role,f),true;let h=this.tryMatchPostNominalPossessiveExpression(e);if(h)return i.set(r.role,h),true}let s=this.tryMatchPossessiveExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(s.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,s),true);let l=this.tryMatchMethodCallExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(l.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,l),true);let m=r.role==="event"&&this.currentPatternCommand==="on"||_.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(m)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(m.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,m),true);let d=this.tryMatchPossessiveSelectorExpression(e);if(d)return r.expectedTypes&&r.expectedTypes.length>0&&!tr(d.type,r.expectedTypes)?r.optional||false:(i.set(r.role,d),true);let p=r.role!=="condition",y=this.tryMatchPropertyAccessExpression(e,p);if(y)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(y.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,y),true);let E=this.tryMatchSelectorPropertyExpression(e);if(E)return r.expectedTypes&&r.expectedTypes.length>0&&!tr(E.type,r.expectedTypes)?r.optional||false:(i.set(r.role,E),true);if(a.kind==="identifier"&&a.value==="{"){let f=r.expectedTypes,z=f?.length===1&&f[0]==="expression"?this.tryMatchBraceRunExpression(e):!f?.length||f.includes("literal")?this.tryMatchBraceRunLiteral(e):null;if(z)return i.set(r.role,z),true}if(r.role==="style"&&r.expectedTypes?.length===1&&r.expectedTypes[0]==="expression"){let f=We(e);if(f)return i.set(r.role,{type:"expression",raw:f}),true}let v=this.tokenToSemanticValue(a);if(!v)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(v.type)){let f=v.type==="selector"&&String(v.value).startsWith("@"),h=r.expectedTypes.some(z=>z==="expression"||z==="reference");if(!(f&&h))return r.optional||false}if(i.set(r.role,v),e.advance(),r.role==="event"){let f=e.peek();f&&f.kind==="selector"&&f.value.startsWith("[")&&"value"in v&&(i.set(r.role,q(`${String(v.value)}${f.value}`)),e.advance());let h=e.peek();if(h&&(h.kind==="particle"||h.kind==="keyword")&&(h.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(n,h)){let z=e.peek(1);if(z&&(z.kind==="selector"||z.kind==="identifier")){e.advance();let D=this.tokenToSemanticValue(e.advance());D&&!i.has("source")&&i.set("source",D);}}}return true}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){let r=zt(e.tokens,e.position(),this.currentProfile);if(!r)return null;for(let i=0;i<r.consumed;i++)e.advance();return {type:"expression",raw:r.parts.map(i=>i.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 gt(this.currentProfile,e)}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 s=e.peek();if(!s||!_.RUN_OPERATORS.has(s.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(l);break}}let u=zr(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:u,value:u}}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||!_.RUN_OPERATORS.has(o.value))break;let u=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(u);break}n++;}if(n<2)return e.reset(r),null;let a=zr(e.tokens.slice(i,e.position()),this.currentProfile);return {type:"expression",raw:a,value:a}}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()),[u,,s,l]=o,c=d=>d.kind==="keyword"?d.normalized??d.value:d.value,m=`${c(u)} to ${c(s)}`;return l&&(m+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:m,value:m}}tryConsumePickRangeOperand(e){let r=e.peek();if(!r)return false;let i=(r.normalized??r.value).toLowerCase();if(this.isPickRangeSeparator(r))return false;let 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")&&!_.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(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?Oe(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"?(e.reset(i),null):(e.advance(),ve(ge(a.value),this.toEnglishProperty(r.value)))}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=[r.value,r.normalized].filter(Boolean),n;for(let s of i)if(n=se(this.currentProfile,s)??se(this.currentProfile,s.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 s=e.peek();if(s){let l=s.value.toLowerCase(),c=(s.normalized??"").toLowerCase();o.some(m=>m.toLowerCase()===l||m.toLowerCase()===c)&&e.advance();}}let u=e.peek();if(!u||to(this.currentProfile.code,u.value))return e.reset(a),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)&&!(u.normalized&&this.isStructuralKeyword(u.normalized))&&!(u.normalized&&this.isRoleMarkerConcept(u.normalized))&&!(u.normalized&&_.COMMAND_ACTION_KEYWORDS.has(u.normalized.toLowerCase()))||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1)),s=this.toEnglishProperty(s);let l=s;for(;;){let m=e.peek();if(m?.kind==="selector"&&m.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(m.value)){l+=m.value,e.advance();continue}if(m?.value==="?"){let d=e.peek(1);if(d?.kind==="selector"&&d.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(d.value)){l+=`?${d.value}`,e.advance(),e.advance();continue}}break}let c=e.peek();if(c&&c.value.startsWith("(")){let m="",d=0,p=0;for(;!e.isAtEnd()&&p++<_.MAX_METHOD_ARGS+2;){let y=e.peek();if(!y)break;m+=y.value,e.advance();for(let E of y.value)E==="("?d++:E===")"&&d--;if(d<=0)break}l+=m;}return ve(ne(n),l)}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 u=o;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)u+=e.peek().value,e.advance();let s=e.peek();if(!s)return e.reset(a),null;let l;for(let c of [s.value,s.normalized].filter(Boolean))if(l=se(this.currentProfile,c)??se(this.currentProfile,c.toLowerCase()),l)break;return l?(e.advance(),ve(ne(l),u)):(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 new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]).has(e.toLowerCase())}static tokenLooksLikeEvent(e){if(e.kind==="selector"||e.kind==="url"||e.kind==="literal")return false;let r=e.value;if(/[/#@*]/.test(r)||r.startsWith('"')||r.startsWith("'")||r.startsWith("`"))return false;let i=e.normalized?.toLowerCase();return !(i&&yo.has(i))}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 u=e.advance();if(!u)break;if(u.value==="{")a++;else if(u.value==="}"&&(a--,a===0))return n.push("}"),q(n.join(" "));n.push(u.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,u=0;for(;!e.isAtEnd()&&u++<_.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(a>=0&&s.position.start>a&&(n+=" ".repeat(s.position.start-a)),n+=s.value,a=s.position.end,s.value==="{")o++;else if(s.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="",u=a.position?.end,s=false,l=0;for(;!e.isAtEnd()&&l++<_.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),s=true;break}let m=u!==void 0&&c.position?.start===u;o+=(o===""||m?"":" ")+c.value,u=c.position?.end,e.advance();}return s?{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 u=[];for(;!e.isAtEnd()&&u.length<_.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.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"||_.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let p=i.value,y=[],E=0;for(;E<_.MAX_PROPERTY_DEPTH;){let h=e.peek();if(h&&h.kind==="selector"&&/^\.[a-zA-Z_]/.test(h.value))p+=`.${h.value.slice(1)}`,y.push(h.value.slice(1)),e.advance(),E++;else break}let v=e.peek(),f=!!v&&v.value.startsWith("(");if(r&&!f&&y.length>0&&Fe(a))return ve(ne(a),y.join("."));if(f){let h=e.mark(),z=[],D=0,A=false;for(;!e.isAtEnd();){let C=e.peek();if(!C)break;if(C.value==="(")D++;else if(C.value===")"){if(z.push(C.value),e.advance(),D--,D===0&&(A=true),A)break;continue}z.push(C.value),e.advance();}A?p+=z.join(""):e.reset(h);}return {type:"expression",raw:p}}let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="identifier")return e.reset(n),null;e.advance();let l=`${i.value}.${s.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 y=e.peek();if(!y||y.kind!=="identifier")break;e.advance(),l+=`.${y.value}`,c++;}let m=e.peek();if(m&&m.kind==="punctuation"&&m.value==="("){e.advance();let p=[],y=0;for(;!e.isAtEnd()&&p.length<_.MAX_METHOD_ARGS;){let v=e.peek();if(!v)break;if(v.kind==="punctuation"&&v.value===")"){if(y===0){e.advance();break}y--;}if(v.kind==="punctuation"&&v.value==="("&&y++,v.kind==="punctuation"&&v.value===","){e.advance();continue}p.push(v.value),e.advance();}return {type:"expression",raw:`${l}(${p.join(", ")})`}}let d=i.value.toLowerCase();if(r&&Fe(d)){let p=l.split(".").slice(1).join(".");return ve(ne(d),p)}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",u=!!n&&n.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(n?.normalized??"").toLowerCase()!=="source")return false;let d=ze[this.currentPatternCommand];return !!d&&d.roles.some(p=>p.role==="source")})(),l=!!n&&!!a&&a!=="'s"&&n.value===a&&(n.kind==="particle"||n.kind==="punctuation")&&!s;if(!o&&!l&&!u)return e.reset(i),null;e.advance(),u&&e.advance();let c=e.peek();return !c||!(c.kind==="identifier"||(o||u)&&(c.kind==="selector"||c.kind==="keyword"))?(e.reset(i),null):(e.advance(),ve(ge(r.value),this.toEnglishProperty(c.value)))}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 ve(ge(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)){e.reset(a);for(let s of i.keys())o.has(s)||i.delete(s);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=Qe(e.value).toLowerCase();if(i&&i===Qe(r).toLowerCase())return "case-insensitive"}return "none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return ge(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Fe(r)?ne(r):q(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return ge(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return ne(e.value);let i=e.value.toLowerCase();return Fe(i)?ne(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);}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=r.value.toLowerCase();if(_.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 u=a?(a.normalized??a.value).toLowerCase():"";if(a&&_.POSITIONAL_OR_SCOPE_KEYWORDS.has(u))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&_.COMMAND_ACTION_KEYWORDS.has(l),m=!s||s.kind==="particle"||_.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(a&&a.kind==="keyword"&&this.currentProfile?.code!=="en"&&Fe(u)&&m||a&&a.kind==="keyword"&&this.currentProfile?.code==="en"&&Fe(u))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}};Z.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);Z.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then"]);Z.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);Z.COMMAND_ACTION_KEYWORDS=Ct;Z.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);Z.RUN_OPERATORS=new Set(["+","-","*","/"]);Z.PICK_RANGE_SEPARATORS=new Set(["to"]);Z.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"])};Z.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);Z.MAX_BRACE_RUN_TOKENS=64;Z.MAX_PROPERTY_DEPTH=10;Z.MAX_METHOD_ARGS=20;Z.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);Z.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var ho=Z,ie=new ho;function K(t,e){return Hi(t,e)}function St(){return Ui()}var He=["if","unless","repeat","for","while"],or=/^[A-Z][A-Za-z0-9_]*$/;function G(t,e){let r=new Set([e]),n=L(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 j(t,e){return e.has(t.value.toLowerCase())?true:t.normalized?e.has(t.normalized.toLowerCase()):false}var vo=new Set(He);function ur(t,e){let r=t.normalized?.toLowerCase();return r?vo.has(r):e.some(i=>j(t,i))}var Yr=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Eo=new Set(["destination","source","style","patient","on","from","to"]);function xt(t){if(!t||t.kind==="selector")return false;let e=(t.normalized??t.value).toLowerCase(),r=t.value.toLowerCase();return !(Yr.has(e)||Yr.has(r)||Eo.has(e))}var Zr=new Set(["ja","ko"]);function Ke(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 Tt(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(/[,،、]/)){let o=a.trim();o&&r.push(o);}}return {parameters:r,headerEnd:i}}function sr(t,e,r){let i=e+1;if(i>=t.length)return -1;let n=Ke(L(r)?.roleMarkers?.patient);return n.size>0&&j(t[i],n)&&i++,i<t.length?i:-1}var Ft=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function go(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 Co(t,e,r){let i=L(r);if(i?.wordOrder!=="SOV"||!Ft.test(t[0].value)||e!==go(t))return false;let n=Ke(i.roleMarkers?.patient);return n.size===0?false:j(t[e-1],n)}function zo(t,e,r){if(!L(e))return null;let i=G(e,"behavior"),n=G(e,"def"),a=t.toLowerCase(),o=[...i].some(m=>a.includes(m)),u=/\bdef\b/.test(a)||[...n].some(m=>m!=="def"&&a.includes(m));if(!o&&!u)return null;let s=K(t,e).tokens;if(s.length<2)return null;if(j(s[0],i))return Xr(t,e,s,r,0);let l=s.findIndex((m,d)=>d>0&&j(m,i));if(l>0&&or.test(s[0].value))return Xr(t,e,s,r,l);if(j(s[0],n))return Jr(t,e,s,r,0);let c=s.findIndex((m,d)=>d>0&&j(m,n));return c>0&&Co(s,c,e)?Jr(t,e,s,r,c):null}function ko(t,e,r){let i=L(e);if(!i)return null;let n=i.wordOrder!=="SOV",a=Zr.has(e)?Ke(i.roleMarkers?.event):new Set,o=Zr.has(e)?Ke(i.keywords?.on):new Set,u=a.size>0&&o.size>0,s=G(e,"end"),l=G(e,"on"),c=t.toLowerCase(),m=[...s].some(C=>c.includes(C)),d=(n||u)&&(()=>{let C=0;for(let g of l)if(g){for(let b=c.indexOf(g);b>=0;b=c.indexOf(g,b+g.length))if(++C>=2)return true}return false})();if(!m&&!d)return null;let p=K(t,e).tokens;if(p.length<2)return null;let y=He.map(C=>G(e,C)),E=C=>ur(C,y),v=C=>j(C,s),f=[],h=0,z=0;for(let C=0;C<p.length;C++){let g=p[C];if(v(g)){if(h>0){h--;continue}let b=t.slice(p[z].position.start,g.position.start).trim();b&&f.push(b),z=C+1;}else if(E(g))h++;else if(n&&h===0&&C>z&&j(g,l)&&xt(p[C+1])){let b=t.slice(p[z].position.start,g.position.start).trim();b&&f.push(b),z=C;}else if(u&&h===0&&C-1>z&&j(g,a)&&p[C+1]!==void 0&&j(p[C+1],o)){let b=p[C-1],k=t.slice(p[z].position.start,b.position.start).trim();k&&f.push(k),z=C-1;}}if(z<p.length){let C=t.slice(p[z].position.start).trim();C&&f.push(C);}if(f.length<2)return null;let D=[],A=[];for(let C of f){let g;try{g=r.statement(C,e);}catch{return null}if(!g||g.kind!=="event-handler")return null;let b=g;D.push(b);let k=!b.body||b.body.length===0;A.push(k?.2:b.metadata?.confidence??.75);}return Cr(D,"then",{sourceLanguage:e,confidence:Ue(A),sourceText:t})}function Ue(t){return t.length>0?t.reduce((e,r)=>e+r,0)/t.length:0}function Dr(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 Xr(t,e,r,i,n){let a=n>0,o=a?0:sr(r,n,e);if(o<0)return null;let u=r[o],s=u.value;if(!or.test(s))return null;let{parameters:l,headerEnd:c}=Tt(t,u),m=a?n+1:r.findIndex(b=>b.position.start>=c);m<=o&&(m=o+1);let d=G(e,"init"),p=G(e,"end"),y=He.map(b=>G(e,b)),E=b=>ur(b,y),v=b=>j(b,p),f=[],h=[],z=[],D=false,A=0,C=m;for(let b=m;b<r.length;b++){let k=r[b];if(v(k)){if(A>0){A--;continue}if(b===C){D=true;break}if(j(r[C],d)){let w=t.slice(r[C].position.end,k.position.start).trim();if(w)try{let B=Dr(i.body(w,e));h.push(...B),z.push(Ue(B.map(S=>S.metadata?.confidence??.75)));}catch{z.push(0);}}else {let w=t.slice(r[C].position.start,k.position.start).trim();try{let B=i.statement(w,e);if(B&&B.kind==="event-handler"){let S=B;f.push(S);let R=!S.body||S.body.length===0;z.push(R?.2:S.metadata?.confidence??.75);}else z.push(0);}catch{z.push(0);}}C=b+1;}else E(k)&&A++;}if(f.length===0&&h.length===0)return null;let g=(D?1:.8)*Ue(z);return gn(s,l,f,h.length>0?h:void 0,{sourceLanguage:e,confidence:g,sourceText:t})}function Jr(t,e,r,i,n){let a=n>0,o=a?0:sr(r,n,e);if(o<0)return null;let u=r[o],s=u.value;if(!Ft.test(s))return null;let{parameters:l,headerEnd:c}=Tt(t,u),m=a?n+1:r.findIndex(g=>g.position.start>=c);m<=o&&(m=o+1);let d=G(e,"end"),p=He.map(g=>G(e,g)),y=g=>ur(g,p),E=g=>j(g,d),v=0,f=-1;for(let g=m;g<r.length;g++)if(E(r[g])){if(v===0){f=g;break}v--;}else y(r[g])&&v++;let h=r[m]?.position.start??c,z=f>=0?r[f].position.start:t.length,D=t.slice(h,z).trim();if(!D)return null;let A;try{A=Dr(i.body(D,e));}catch{return null}if(A.length===0)return null;let C=Ue(A.map(g=>g.metadata?.confidence??.75));return f<0&&(C*=.8),Cn(s,l,A,{sourceLanguage:e,confidence:C,sourceText:t})}var kr=["live","eventsource","socket","worker","intercept"],wo=new Set(["intercept"]),Br=new Set(["eventsource","socket","worker"]),bo=new Set(["eventsource","socket"]),Ao=new Set(["worker"]),Do=6,Bo=2;function So(t,e){for(let i of kr)if(j(t[0],G(e,i)))return {action:i,keywordIdx:0};if(L(e)?.wordOrder!=="SOV")return null;let r=Math.min(t.length,Do);for(let i=1;i<r;i++)for(let n of kr)if(n!=="live"&&j(t[i],G(e,n))&&!(Br.has(n)&&!or.test(t[0].value))&&!(n==="intercept"&&i>Bo))return {action:n,keywordIdx:i};return null}function xo(t,e,r){let i=Ke(L(r)?.roleMarkers?.source);return i.size===0||e+1>=t.length?0:j(t[e],i)||j(t[e+1],i)?2:0}function To(t,e,r,i,n){if(t==="live")return r+1;if(r>0){let s=r+1;return t==="eventsource"&&(s+=xo(e,s,i)),s}let a=sr(e,r,i);if(a<0)return -1;if(t==="worker")return a+1;let o=G(i,"on"),u=n>=0?n:e.length;for(let s=a+1;s<u;s++)if(j(e[s],o)&&xt(e[s+1]))return s;return u}function Fo(t,e,r,i){if(!Br.has(t))return;let n=r>0?0:sr(e,r,i);if(!(n<0))return e[n].value}function Ro(t,e,r){if(!L(e))return null;let i=t.toLowerCase(),n=false;for(let u of kr){for(let s of G(e,u))if(s&&i.includes(s)){n=true;break}if(n)break}if(!n)return null;let a=K(t,e).tokens;if(a.length<2)return null;let o=So(a,e);return o?Oo(t,e,a,r,o.action,o.keywordIdx):null}function Oo(t,e,r,i,n,a){let o=G(e,"end"),u=He.map(D=>G(e,D)),s=D=>ur(D,u),l=D=>j(D,o),c=Fo(n,r,a,e);if(Br.has(n)&&(!c||!or.test(c)))return null;let m=D=>({sourceLanguage:e,confidence:D,sourceText:t}),d=Qr(r,a+1,l,s);if(wo.has(n))return d>=0&&d!==r.length-1?null:Vr(n,[],c,m(d>=0?1:.8));let p=To(n,r,a,e,d);if(p<0||p>r.length)return null;let y=[],E=[],v=false,f=Ao.has(n);if(f||bo.has(n)){let D=f?"def":"event-handler",A=0,C=p;for(let g=p;g<r.length;g++){let b=r[g];if(l(b)){if(A>0){A--;continue}if(v=true,g===C)break;let k=f?b.position.end:b.position.start,w=t.slice(r[C].position.start,k).trim();try{let B=i.statement(w,e);if(B&&B.kind===D){let S=B;y.push(S);let R=!S.body||S.body.length===0;E.push(R?.2:S.metadata?.confidence??.75);}else E.push(0);}catch{E.push(0);}C=g+1;}else s(b)&&A++;}}else {let D=Qr(r,p,l,s);v=D>=0;let A=D>=0?r[D].position.start:t.length,C=t.slice(r[p].position.start,A).trim();if(!C)return null;try{y.push(...Dr(i.body(C,e)));}catch{return null}if(y.length===0)return null;E.push(...y.map(g=>g.metadata?.confidence??.75));}if(y.length===0&&!v)return null;let h=v?1:.8,z=E.length>0?h*Ue(E):h;return Vr(n,y,c,m(z))}function Qr(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 fe={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll",\uB9C8\uC6B0\uC2A4\uC5D4\uD130:"mouseenter",\uB9C8\uC6B0\uC2A4\uB9AC\uBE0C:"mouseleave",\uB9C8\uC6B0\uC2A4\uBB34\uBE0C:"mousemove",\uD0A4\uD504\uB808\uC2A4:"keypress",\uD130\uCE58\uC885\uB8CC:"touchend",\uD130\uCE58\uCDE8\uC18C:"touchcancel"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll",\u307C\u304B\u3057:"blur"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll",\u062A\u0631\u0643\u064A\u0632:"focus","\u0645\u0641\u062A\u0627\u062D \u0623\u0633\u0641\u0644":"keydown","\u0645\u0641\u062A\u0627\u062D \u0623\u0639\u0644\u0649":"keyup","\u0641\u0623\u0631\u0629 \u0641\u0648\u0642":"mouseover","\u062A\u063A\u064A\u064A\u0631 \u062D\u062C\u0645":"resize"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll",cambiar:"change",enfocar:"focus",desenfocar:"blur",cargar:"load",desplazar:"scroll",dobleclic:"dblclick",rat\u00F3nentrar:"mouseenter",rat\u00F3nsalir:"mouseleave",rat\u00F3nmover:"mousemove",teclapresar:"keypress",descargar:"unload",toqueempezar:"touchstart",toqueterminar:"touchend",toquemover:"touchmove",toquecancelar:"touchcancel"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll",bulan\u0131k:"blur",farebas:"mousedown",fareb\u0131rak:"mouseup",kayd\u0131r:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll",duploClique:"dblclick",mouseEntrar:"mouseenter",mouseSair:"mouseleave",mouseMover:"mousemove",teclaPressionar:"keypress",descarregar:"unload",toqueIn\u00EDcio:"touchstart",toqueFim:"touchend",toqueMover:"touchmove",toqueCancelar:"touchcancel"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll",\u6309\u952E\u6309\u4E0B:"keydown",\u9F20\u6807\u79FB\u52A8:"mousemove",\u5378\u8F7D:"unload",\u8C03\u6574\u5927\u5C0F:"resize",\u89E6\u6478\u5F00\u59CB:"touchstart",\u89E6\u6478\u79FB\u52A8:"touchmove"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll",flou:"blur",doubleclic:"dblclick",sourisentrer:"mouseenter",sourissortir:"mouseleave",sourisbouger:"mousemove",touchepress\u00E9e:"keypress",d\u00E9charger:"unload",touchercommencer:"touchstart",toucherfin:"touchend",toucherbouger:"touchmove",toucherannuler:"touchcancel"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll","taste unten":"keydown","taste oben":"keyup","maus dr\xFCber":"mouseover","maus weg":"mouseout",doppelklick:"dblclick",mauseintreten:"mouseenter",mausverlassen:"mouseleave",mausbewegen:"mousemove",tastedr\u00FCcken:"keypress",entladen:"unload",ber\u00FChrungstart:"touchstart",ber\u00FChrungend:"touchend",ber\u00FChrungbewegen:"touchmove",ber\u00FChrungabbrechen:"touchcancel"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll",tekan_tombol:"keydown",keyup:"keyup",arahkan:"mouseover",tinggalkan:"mouseout",bongkar:"unload"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",kambiay:"change",apachiy:"submit",kachay:"submit",apaykachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll",bonyeza:"click",ingizo:"input",kitufe_shuka:"keydown",kitufe_juu:"keyup",panya_nje:"mouseout",wasilisha:"submit","sogeza juu":"mouseover",shuka:"unload"},vi:{"\u0111\u1ED5i k\xEDch th\u01B0\u1EDBc":"resize"}};Object.fromEntries(Object.entries(fe).map(([t,e])=>{let r={};for(let[i,n]of Object.entries(e))n in r||(r[n]=i);return [t,r]}));var _o={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},Mo=[["\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"]],Io=/^(\d+)(ms|s|m)?$/,jo=new Set(["selector","literal","url","event-modifier"]);function $o(t){let e=t.match(Io);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 Vo(t){for(let e=1;e<t.length;e++){let r=t[e];if(jo.has(r.kind))continue;let i=r.value.toLowerCase(),n=_o[i];if(n){let a=0;for(let o=e+1;o<t.length;o++){let u=t[o],s=$o(u.value);if(s!==null)return {modifiers:{[n]:s},start:r.position.start,end:u.position.end};if(u.kind==="selector"||u.kind==="literal"||u.kind==="url"||++a>2)break}continue}for(let a of Mo){if(a[0]!==i||e+a.length>t.length)continue;let o=true;for(let u=1;u<a.length;u++)if(t[e+u].value.toLowerCase()!==a[u]){o=false;break}if(o)return {modifiers:{once:true},start:r.position.start,end:t[e+a.length-1].position.end}}}return null}var Ee=new Set(["if","unless","while","repeat","for"]),hr=new Set(["then","end","else","if","unless","while","for","repeat","and"]),Wo=new Set(["first","last","next","previous","random","closest"]),Re=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),tt=class extends Error{constructor(t,e,r,i){super(t),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=i;}};function M(t,e,r){return {message:t,severity:e,source:"semantic-parser",...r&&{code:r}}}function I(t,e){return e.length===0?t:{...t,diagnostics:e}}var nr=120;function Ko(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 u=o.length>nr?`${o.slice(0,nr)}\u2026`:o,s=i-t.consumedTokens;return `pattern ${t.pattern.id} left ${s} token(s) unconsumed: "${u}"`}var Uo=new Set(["to","from","into","onto","with","as","at","of","in","on","by","and","or","then","end","else","the","a","an","async"]);function vr(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 u=`${o.code}|${o.message}`;r.has(u)||(r.add(u),e.push(o));}let a=n;for(let o of Rt){let u=a[o];if(Array.isArray(u))for(let s of u)i(s);}};return i(t),e.length===0?t:I(t,[...t.diagnostics??[],...e])}function it(t){if(t.length>=2){let e=t[0];if((e==='"'||e==="'")&&t.endsWith(e))return t.slice(1,-1)}return t}var Rt=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function Ot(t,e){if(!t||typeof t!="object")return t;if(t.action&&t.roles instanceof Map){let i=J(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"),u=a.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!u||u.type==="literal")&&(a.delete("patient"),a.set("destination",o));}if(t.action==="fetch"){let a=t.roles,o=a.get("patient"),u=a.get("source");o&&u&&(o.type==="literal"||o.type==="expression")&&u.type==="expression"&&!a.has("style")&&(a.delete("patient"),a.set("style",u),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 u=a.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(u.value)&&a.set("patient",{type:"expression",raw:u.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"),u=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof u=="string"&&Re.has(u.toLowerCase())&&(a.delete("duration"),a.set("event",{type:"literal",value:u,dataType:"string"}));}}if(t.kind==="command"&&t.action!=="on"){let a=t.roles,o=a.get("event");if(o&&o.type==="expression"){let u=o.raw;typeof u=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(u)&&a.set("event",{type:"literal",value:u,dataType:"string"});}}if(e?.size){let a=t.roles;for(let o of ["destination","source"]){let u=a.get(o);u&&u.type==="literal"&&typeof u.value=="string"&&e.has(u.value)&&a.set(o,{type:"expression",raw:u.value});}}}let r=t;for(let i of Rt){let n=r[i];if(Array.isArray(n))for(let a of n)Ot(a,e);}return t}var Y=class x{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=Ot(this.parseInternal(e,r),this.boundIdentifiers),n=this.coverageFrames[this.coverageFrames.length-1];if(n.length>0&&(i=I(i,[...i.diagnostics??[],...n])),this.parseDepth===1&&(i=vr(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 s=0;s<4;s++){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 u=this.reclaimEventCompoundTail(a.node,a.input,r);u&&(a=u),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=x.coverageMarkerSurfaces.get(e);if(!r){r=new Set;let i=L(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 x.LEAKED_RENDER_MARKERS[e]??[])r.add(n.toLowerCase());x.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 Uo.has(i)?true:x.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(u=>!this.isCoverageResidueToken(u,r)))return;let a=e.map(u=>u.value).join(" ").trim();if(!a)return;let o=a.length>nr?`${a.slice(0,nr)}\u2026`:a;n.push(M(`${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=zo(e,r,{statement:(k,w)=>this.parse(k,w),body:(k,w)=>this.parseStatements(k,w)});if(i)return i;let n=Ro(e,r,{statement:(k,w)=>this.parse(k,w),body:(k,w)=>this.parseStatements(k,w)});if(n)return n;let a=ko(e,r,{statement:(k,w)=>this.parse(k,w),body:(k,w)=>this.parseStatements(k,w)});if(a)return a;let{modifiers:o,remainingInput:u}=this.extractStandaloneModifiers(e,r),s=u||e,c=this.stripAsyncModifier(s,r).remainingInput??s,d=this.stripDoNotThrowModifier(c,r).remainingInput??c,p=[],y=K(d,r),E=le(r);if(E.length===0)throw new tt(`No patterns available for language: ${r}`,r,d,[M(`No patterns registered for language '${r}'`,"error","no-patterns")]);let v=[...E].sort((k,w)=>w.priority-k.priority);{let k=y.tokens;if(L(r)?.wordOrder==="VSO"&&k.length>=4&&k[0]?.normalized==="source"){let w=k.findIndex(B=>B.normalized==="on");if(w>=2&&w+1<k.length){let B=d.slice(k[0].position.start,k[w].position.start).trim(),S=k[w+1].position.end,R=d.slice(k[w].position.start,S)+" "+B+d.slice(S);if(R!==d)try{let F=this.parse(R,r);if(F&&F.kind==="event-handler"){let O=o?this.applyModifiers(F,o):F;return I(O,p)}}catch{}}}}{let k=y.tokens,w=k[0]?.normalized==="if";for(let B=0;w&&B+3<k.length;B++){let S=(k[B+3]?.normalized??k[B+3]?.value??"").toLowerCase();if(k[B]?.normalized==="source"&&k[B+2]?.normalized==="on"&&x.KNOWN_EVENTS.has(S)){let R=(d.slice(0,k[B].position.start).trimEnd()+" "+d.slice(k[B+1].position.end).trimStart()).trim();if(R&&R!==d)try{let F=this.parse(R,r);if(F&&F.kind==="event-handler"){let O=o?this.applyModifiers(F,o):F;return I(O,p)}}catch{}break}}}{let k=y.tokens;for(let w=1;w<k.length-1;w++){let B=k[w],S=B.value,R=(B.normalized??B.value).toLowerCase();if(!(R==="or"||x.OR_KEYWORDS.has(S)||x.OR_KEYWORDS.has(R)))continue;let O=k[w+1],P=(O.normalized??O.value).toLowerCase();if(!x.KNOWN_EVENTS.has(P))break;let N=w+1,U=k[w+2];U&&U.kind==="selector"&&U.value.startsWith("[")&&(N=w+2);let H=k[w].position.start,de=k[N].position.end,ae=(d.slice(0,H).trimEnd()+" "+d.slice(de).trimStart()).trim();if(ae&&ae!==d)try{let ye=this.parse(ae,r);if(ye&&ye.kind==="event-handler"){ye.additionalEvents=[{type:"literal",value:P}];let mr=o?this.applyModifiers(ye,o):ye;return I(mr,p)}}catch{}break}}{let k=Vo(y.tokens);if(k){let w=(d.slice(0,k.start).trimEnd()+" "+d.slice(k.end).trimStart()).trim();if(w&&w!==d)try{let B=this.parse(w,r);if(B&&B.kind==="event-handler"){let S=this.applyModifiers(B,{...o??{},...k.modifiers});return I(S,p)}}catch{}}}let f=v.filter(k=>k.command==="on"),h=y.mark(),z=ie.matchBest(y,f);if(z){p.push(M(`event pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match"));let k=false;if(/^event-[a-z]+-bare$/.test(z.pattern.id)){let w=z.captured.get("event"),B=(w?.raw??w?.value??"").toString().toLowerCase(),S=fe[r],R=x.KNOWN_EVENTS.has(B)||!!S&&Object.keys(S).some(F=>F.toLowerCase()===B);if(B&&!R){let F=this.trySOVEventExtraction(d,r,v);if(F){p.push(M(`bare-event mis-anchor on "${B}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let O=o?this.applyModifiers(F,o):F;return I(O,p)}if(w?.type==="reference"||w?.type==="expression"){y.reset(h);let O=v.filter(N=>N.command!=="on"),P=ie.matchBest(y,O);y.reset(h),P&&P.pattern.command!=="on"?(k=true,p.push(M(`bare-event mis-anchor on reference "${B}" rejected; command ${P.pattern.command} preferred`,"info","stage-bare-event-guard"))):ie.matchBest(y,f);}}}if(!k){let w=this.buildEventHandler(z,y,r),B=o?this.applyModifiers(w,o):w;return I(B,p)}}p.push(M(`event patterns: ${f.length} tried, no match`,"info","stage-event"));let D=this.tryTrailingEventExtraction(d,r,v);if(D){p.push(M("trailing event extraction succeeded","info","stage-trailing-event"));let k=o?this.applyModifiers(D,o):D;return I(k,p)}let A=v.filter(k=>k.command!=="on"),C=ie.matchBest(y,A);if(C){if(Ee.has(C.pattern.command)){let w=this.trySOVEventExtraction(d,r,v);if(w){p.push(M(`SOV event extraction preferred over bare ${C.pattern.command} command`,"info","stage-sov-loop"));let S=o?this.applyModifiers(w,o):w;return I(S,p)}let B=this.tryMidStreamEventExtraction(d,r,v);if(B){p.push(M(`mid-stream event extraction preferred over bare ${C.pattern.command} command`,"info","stage-midstream-loop"));let S=o?this.applyModifiers(B,o):B;return I(S,p)}}else if(x.KNOWN_EVENTS.has(C.pattern.command)&&this.hasSOVEventMarkerHead(d,r)){let w=this.trySOVEventExtraction(d,r,v);if(w){p.push(M(`SOV event extraction preferred over command-homonym event ${C.pattern.command}`,"info","stage-sov-homonym"));let B=o?this.applyModifiers(w,o):w;return I(B,p)}}else if(L(r)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(d,r,v);if(w){p.push(M(`mid-stream event extraction preferred over bare ${C.pattern.command} command`,"info","stage-midstream-cmd"));let B=o?this.applyModifiers(w,o):w;return I(B,p)}}if(C.consumedTokens<y.tokens.length&&L(r)?.wordOrder==="SOV"){let w=this.trySOVEventExtraction(d,r,v);if(w){p.push(M(`SOV event extraction preferred over partial ${C.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let B=o?this.applyModifiers(w,o):w;return I(B,p)}}if(C.consumedTokens<y.tokens.length&&!Ee.has(C.pattern.command)){let w=this.tryTopLevelCommandSequence(y,A,r);if(w)return p.push(M(`top-level command sequence: ${w.statements.length} commands`,"info","stage-top-level-sequence")),I(w,p)}p.push(M(`command pattern matched: ${C.pattern.id} (confidence: ${C.confidence.toFixed(2)})`,"info","pattern-match"));let k=Ko(C,y,d);return k&&p.push(M(k,"warning","unconsumed-input")),I(this.buildCommand(C,r),p)}if(p.push(M(`command patterns: ${A.length} tried, no match`,"info","stage-command")),!d.includes(`
4
+ `)&&L(r)?.wordOrder==="VSO"){let k=this.tryMidStreamEventExtraction(d,r,v);if(k){p.push(M("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let w=o?this.applyModifiers(k,o):k;return I(w,p)}}let g=this.trySOVEventExtraction(d,r,v);if(g){p.push(M("SOV event extraction succeeded","info","stage-sov"));let k=o?this.applyModifiers(g,o):g;return I(k,p)}p.push(M("SOV event extraction: no event keyword found","info","stage-sov"));let b=this.tryCompoundCommandParsing(y,A,r);if(b)return p.push(M("compound command parsing succeeded","info","stage-compound")),I(b,p);throw p.push(M("compound parsing: no then-keywords or no command matches","info","stage-compound")),p.push(M(`all parse stages exhausted for "${d}"`,"error","parse-failed")),new tt(`Could not parse input in ${r}: ${d}`,r,d,p)}parseStatements(e,r){let i=K(e,r),n=le(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 u=a[a.length-1];a[a.length-1]=I(u,[...u.diagnostics??[],...o]);}return a}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return St()}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=te(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 d=fe[i]?.[m];d?n={type:"literal",value:d,dataType:"string"}:n.type==="expression"&&x.KNOWN_EVENTS.has(m.toLowerCase())&&(n={type:"literal",value:m.toLowerCase(),dataType:"string"});}}let a=ie.extractEventModifiers(r),o=e.captured.get("source");o&&e.pattern.id.includes("source")&&!(o.type==="reference"&&o.value==="me")&&(a={...a??{},from:o});let u=this.extractOrConjunctionEvents(r,i),s=n;u.length>0&&n.type==="literal"&&(s={type:"literal",value:[String(n.value),...u.map(d=>String("value"in d?d.value:""))].join(" or ")});let l,c=e.captured.get("action");if(c&&c.type==="literal"&&c.value==="if"){let m=r.tokens,d=-1;for(let p=r.position()-1;p>=0;p--){let y=m[p],E=(y.normalized??y.value).toLowerCase();if(this.isIfKeyword(E,i)){d=p;break}}if(d>=0){let p=le(i).filter(z=>z.command!=="on").sort((z,D)=>D.priority-z.priority),y=m.slice(d);if(e.pattern.id.endsWith("vso-verb-first")&&s.type==="literal"){let z=String(s.value??"").split("[")[0].trim().toLowerCase(),D=y.findIndex((A,C)=>{if(C===0||z==="")return false;let g=(A.normalized??A.value).toLowerCase(),b=y[C-1];return g===z&&b.kind==="keyword"&&(b.normalized??"").toLowerCase()==="on"});if(D>0){let A=y[D+1],C=A&&A.kind==="selector"&&A.value.startsWith("[")?1:0;y=[...y.slice(0,D-1),...y.slice(D+1+C)];}}let E=new re(y,i),v=this.coverageMark(),f=this.parseBodyWithClauses(E,p,i);if(f.some(z=>z.kind==="conditional")||f.length===1&&f[0]?.kind==="compound"&&f[0].statements.some(z=>z.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return Ve(s,f,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(v);}}if(c&&c.type==="literal"){let m=c.value,d={};for(let[A,C]of e.captured)A!=="event"&&A!=="action"&&A!=="continues"&&(d[A]=C);if(m==="repeat"){let A=r.peek(),C=b=>(b.normalized??b.value).toLowerCase();if(A&&A.kind==="keyword"&&C(A)==="forever")d.loopType={type:"literal",value:"forever"},delete d.patient,r.advance();else if(A&&A.kind==="keyword"&&C(A)==="event"){r.advance();let b=r.peek();if(b)for(d.event={type:"literal",value:C(b)},d.loopType={type:"literal",value:"until-event"},delete d.patient;!r.isAtEnd();){let k=r.peek();if(!k||k.kind==="conjunction"||k.kind==="keyword"&&(this.isThenKeyword(k.value,i)||this.isEndKeyword(k.value,i)))break;r.advance();}}let g=d.patient;g&&g.type==="reference"&&g.value==="me"&&delete d.patient;}let p=te(m,d,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(p),!Ee.has(m)||m==="repeat"){let A=e.pattern.id.includes("verb-first"),C=r.tokens,g=r.position(),b=w=>w.kind==="conjunction"||w.kind==="keyword"&&(this.isThenKeyword(w.value,i)||this.isEndKeyword(w.value,i)),k=-1;for(let w=g-1;w>=0;w--){let B=C[w];if(b(B))break;if((B.normalized??B.value).toLowerCase()===m){k=w;break}}if(k>=0){let w=g;for(;w<C.length&&!b(C[w]);)w++;let B=C.slice(k,w),S=B;if(A){let R=String(n.value??"").toLowerCase(),F=B.findIndex(O=>(O.normalized??O.value).toLowerCase()===R);if(F<0)S=null;else {let O=B[F-1],P=O&&O.kind==="keyword"&&O.normalized?.toLowerCase()==="on"?F-1:F;S=[...B.slice(0,P),...B.slice(F+1)];}}if(S&&S.length>1){let R=le(i).filter(W=>W.command!=="on").sort((W,oe)=>oe.priority-W.priority),F=this.coverageMark(),O=this.parseClause(S,R,i),P=O[0],N=W=>W!==null&&typeof W=="object"&&typeof W.type=="string"?W.type:typeof W,U=J(m),H=U?.primaryRole,de=W=>W==="patient"&&H&&H!=="patient"&&!U?.roles.some(oe=>oe.role==="patient")?H:W,ae=(W,oe)=>{if(!Ee.has(m)||!U)return false;let Ae=U.roles.find(Me=>Me.role===de(W));return Ae?Ae.expectedTypes.length>0&&!Ae.expectedTypes.includes(N(oe)):true},ye=!!P&&P.kind==="command"&&Object.entries(d).every(([W,oe])=>{if(ae(W,oe))return true;let Ae=P.roles.get(de(W));if(Ae!==void 0&&N(Ae)===N(oe))return true;if(W==="patient"&&m==="pick"&&N(oe)==="literal"){let Me=P.roles.get("method");return Me!==void 0&&N(Me)==="literal"&&String(Me.value)===String(oe.value)}return false}),mr=P?.metadata?.patternId??"",ui=!Ee.has(m)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(mr);if(O.length===1&&P&&P.kind==="command"&&P.action===m&&ye&&ui&&P.roles.size>Object.keys(d).length)for(p=P;r.position()<w;)r.advance();else this.coverageRollback(F);}}}if(!Ee.has(m)){let A=p;if(J(m)?.roles.some(S=>S.role==="quantity"&&!S.required)&&!A.roles.has("quantity")){let S=r.peek();S&&/^-?\d+(\.\d+)?$/.test(S.value)&&(p=te(m,{...Object.fromEntries(A.roles),quantity:{type:"literal",value:parseFloat(S.value),dataType:"number"}},A.metadata),r.advance());}let g=p;if(J(m)?.roles.some(S=>S.role==="duration"&&!S.required)&&!g.roles.has("duration")){let S=/^\d+(\.\d+)?(ms|s)$/i,R=r.peek(),F=false;if(R&&R.kind==="particle"){let O=r.peek(1);O&&S.test(O.value)&&(F=true,R=O);}R&&S.test(R.value)&&(p=te(m,{...Object.fromEntries(g.roles),duration:{type:"literal",value:R.value,dataType:"string"}},g.metadata),F&&r.advance(),r.advance(),this.consumeForPostposition(r,i));}let k=p,w=J(m);if(w?.roles.find(S=>S.role==="responseType"&&!S.required)&&!k.roles.has("responseType")){let S=N=>typeof N=="string"&&x.RESPONSE_TYPE_WORDS.has(N.toLowerCase()),R=(N,U)=>{let H=Object.fromEntries(k.roles);U&&delete H.destination,H.responseType={type:"expression",raw:N},p=te(m,H,k.metadata);},F=k.roles.get("destination"),O=w?.roles.find(N=>N.role==="destination"),P=F?.raw??F?.value;if(F&&O&&!O.expectedTypes.includes(F.type)&&S(P))R(P,true);else {let N=r.peek();N&&S(N.value)&&(R(N.value,false),r.advance());}}if(m==="wait"){let S=p;if(!S.roles.has("event")){let R=r.peek();if(R&&Re.has(R.value.toLowerCase())){let F=Object.fromEntries(S.roles),O=F.duration;O&&O.type!=="literal"&&O.type!=="expression"&&delete F.duration;let P=F.patient;P&&P.type==="reference"&&P.value==="me"&&delete F.patient,F.event={type:"literal",value:R.value,dataType:"string"},p=te(m,F,S.metadata),r.advance(),this.consumeForPostposition(r,i);}}}this.tryAttachTrailingRole(r,p,i),this.tryAttachTrailingStyle(r,p,i),this.tryAttachTrailingExpressionRole(r,p,i);}let y=e.captured.get("continues"),E=y?.type==="literal"&&y.value==="then",v=r.peek(),f=!!v&&this.isThenKeyword(v.value,i),z=Ee.has(m)&&!!v&&!this.isEndKeyword(v.value,i),D=!!v&&!this.isEndKeyword(v.value,i);if(E||f||z||D){let A=le(i).filter(b=>b.command!=="on").sort((b,k)=>k.priority-b.priority),C=le(i).filter(b=>b.id.startsWith("grammar-")&&b.id.includes("-continuation")).sort((b,k)=>k.priority-b.priority),g=this.parseBodyWithGrammarPatterns(r,A,C,i);g.length>0?l=[p,...g]:l=[p];}else l=[p],r.isAtEnd()||this.recordDroppedTokens(r.tokens.slice(r.position()),i,"handler body tail");}else {let m=le(i).filter(d=>d.command!=="on").sort((d,p)=>p.priority-d.priority);l=this.parseBodyWithClauses(r,m,i);}return Ve(s,l,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,i){let n=[],a=[],o=0,u=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(a.length===0){let y=this.consumeJsBlock(e,i);if(y){n.push(y);continue}let E=this.tryParseConditionalBlock(e,r,i);if(E){n.push(E);continue}}let l=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,i),c=a[a.length-1],m=e.peek(1),d=c?.value.toLowerCase()==="at"&&m?.value.toLowerCase()==="of"||qr(i,s.value,c?.value,m?.value),p=s.kind==="keyword"&&this.isEndKeyword(s.value,i)&&!d;if(p&&o>0){o--,u.pop(),a.push({...s,metadata:{...s.metadata,closesTrackedBlock:true}}),e.advance();continue}if(l&&u.includes("if")){a.push(s),e.advance();continue}if(l){if(a.length>0){let y=this.parseClause(a,r,i);n.push(...y),a.length=0,o=y.filter(E=>{let v=E;return (v.action==="for"||v.action==="repeat"||v.action==="while")&&(!Array.isArray(v.body)||v.body.length===0)}).length,u.length=0;for(let E=0;E<o;E++)u.push("other");}e.advance();continue}if(p){e.advance();let y=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||E.kind==="conjunction"||E.kind==="keyword"&&(this.isThenKeyword(E.value,i)||this.isEndKeyword(E.value,i)))break;y.push(E),e.advance();}if(y.length>0){let E=this.coverageMark(),v=a.length>0?this.parseClause(a,r,i):[];v.length===0&&a.length>0?(this.coverageRollback(E),n.push(...this.parseClause([...a,...y],r,i))):(n.push(...v),n.push(...this.parseClause(y,r,i)));}else if(a.length>0){let E=this.parseClause(a,r,i);n.push(...E);}a.length=0;break}if(s.kind==="keyword"){let y=(s.normalized??s.value).toLowerCase();(this.isIfKeyword(y,i)||this.isUnlessKeyword(y,i)||y==="while"||y==="for"||y==="repeat")&&(o++,u.push(this.isIfKeyword(y,i)?"if":"other"));}a.push(s),e.advance();}if(a.length>0){let s=this.parseClause(a,r,i);n.push(...s);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),i,"body stream tail"),this.foldFrontedWhileIntoRepeat(n,i);for(let s=n.length-1;s>=0;s--){let l=n[s];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&n.splice(s,1);}return n.length>1?[Cr(n,"then",{sourceLanguage:i})]:n}tryTopLevelCommandSequence(e,r,i){let n=this.coverageMark(),a;try{let l=new re(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 u=o.statements.map(l=>l.metadata?.confidence??.75),s=u.reduce((l,c)=>l+c,0)/u.length;return Cr(o.statements,o.chainType,{sourceLanguage:i,confidence:s})}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 u=new Map(a.roles);u.set("condition",o),u.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(i,2,{...a,roles:u,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 f=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(f,i)&&(n="unless",a=e.slice(0,-1));}let u=null;if(n&&a.length>=3){let f=L(i),h=f?x.buildVerbLookup(f):null;if(h)for(let z=1;z<a.length-1;z++){let D=a[z],A=h.get(D.value.toLowerCase())??(D.normalized?h.get(D.normalized.toLowerCase()):void 0);if(A&&!x.CONDITION_OPERATORS.has(A)){u=a.slice(0,z),a=a.slice(z);break}}}let s=new re(a,i),l=[],c=this.coverageMark(),m=0,d=[],p=u,y=()=>{if(d.length===0)return;let f=d.slice();if(d.length=0,n&&l.length===0&&p===null){p=f;return}let h=f[0];if(!(h&&(h.kind==="identifier"||h.kind==="selector"||h.kind==="literal"||h.kind==="reference"))){this.recordDroppedTokens(f,i,"body clause");return}let D=false;for(let A of this.parseSOVClauseByVerbAnchoring(f,i)){let C=A.action,g=A.roles;C&&J(C)&&g instanceof Map&&g.size>0&&(l.push(A),D=true);}D||this.recordDroppedTokens(f,i,"body clause");};for(;!s.isAtEnd();){let f=s.peek(),h=!!f&&f.normalized?.toLowerCase()==="repeat",z=s.mark(),D=ie.matchBest(s,r);if(h&&D&&D.pattern.command!=="repeat"){s.reset(z),y(),l.push(te("repeat",{},{sourceLanguage:i,confidence:.6})),m++,s.advance();continue}if(D&&D.pattern.command==="if"){let A=s.mark(),C=d.length;for(s.reset(z);!s.isAtEnd();){let b=s.peek();if(!b||this.isIfKeyword((b.normalized??b.value).toLowerCase(),i))break;d.push(b),s.advance();}let g=this.tryParseConditionalBlock(s,r,i);if(g){y(),l.push(g),m++;continue}d.length=C,s.reset(A);}if(D){y();let A=this.buildCommand(D,i);l.push(A),m++,this.tryAttachTrailingRole(s,A,i),this.tryAttachTrailingStyle(s,A,i),this.tryAttachTrailingExpressionRole(s,A,i);}else {let A=s.peek();A&&A.normalized?.toLowerCase()==="repeat"?(y(),l.push(te("repeat",{},{sourceLanguage:i,confidence:.6})),m++):A&&d.push(A),s.advance();}}y();let E=l;if(m===0){let f=this.parseSOVClauseByVerbAnchoring(a,i);f.length>0&&(this.coverageRollback(c),E=f);}let v=p;return n&&E.length>0&&v&&v.length>0?[te(n,{condition:{type:"expression",raw:this.joinTokenText(v,i)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85}),...E]:(n&&v&&v.length>0&&E.length===0&&this.recordDroppedTokens(v,i,"body clause"),E)}tryAttachTrailingRole(e,r,i){let n=J(r.action);if(!n)return;let a=L(i);if(!a)return;let o=r.roles,u=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let m=(l.normalized??l.value).toLowerCase();return hr.has(m)?false:m==="body"||m==="it"||m==="you"||m==="result"||m==="document"||m==="window"||this.boundIdentifiers.has(l.value)?true:c?false:l.kind==="identifier"||l.kind==="reference"},s=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:c}of s){if(!n.roles.some(v=>v.role===l))continue;let m=a.roleMarkers?.[l];if(!m)continue;let d=o.get(l);if(d&&!(d.type==="reference"&&d.value==="me"))continue;let p=v=>{if(!v||v.kind!=="particle"&&v.kind!=="keyword")return false;let f=v.value.toLowerCase();return m.primary?.toLowerCase()===f?true:c?false:(v.normalized??"").toLowerCase()===l?true:!!m.alternatives?.some(h=>h.toLowerCase()===f)},y=e.peek(),E=e.peek(1);if(!y||!E)return;if(c&&m.position==="after"){let v=e.peek(2),f=(y.normalized??y.value).toLowerCase();if(Wo.has(f)&&E.kind==="selector"&&p(v)){o.set(l,{type:"expression",raw:`${f} ${E.value}`}),e.advance(),e.advance(),e.advance();return}}if(m.position==="after"){if(u(y,c)&&p(E)){let v=this.tokenToSemanticValue(y);e.advance(),e.advance(),v&&o.set(l,v);return}if(c&&u(y,c)){let v=e.peek(2),f=e.peek(3);if((E.normalized??E.value).toLowerCase()==="in"&&v&&!p(v)&&p(f)){let h=this.tokenToSemanticValue(y);e.advance(),e.advance(),e.advance(),e.advance(),h&&o.set(l,h);return}}}else if(p(y)&&u(E,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(!J(r.action)?.roles.some(f=>f.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 f=We(e,o.raw);f&&(n.set("style",{type:"expression",raw:f}),this.tryAttachResponseTypeAfterStyle(e,r,i));}return}if(r.action==="fetch"){let f=n.get("patient"),h=n.get("source");if(f&&h&&(f.type==="literal"||f.type==="expression")&&h.type==="expression"&&typeof h.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(h.raw)&&e.peek()?.value===":"){let z=We(e,h.raw);z&&(n.set("source",{type:"expression",raw:z}),this.tryAttachResponseTypeAfterStyle(e,r,i));return}}let s=L(i)?.roleMarkers?.style;if(!s)return;if(s.position==="before"){let f=new Set([s.primary,...s.alternatives??[]].map(A=>A.toLowerCase())),h=e.peek();if(!h||!f.has(h.value.toLowerCase()))return;let z=e.mark();e.advance();let D=We(e);if(!D){e.reset(z);return}n.set("style",{type:"expression",raw:D}),this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(s.position!=="after")return;let l=new Set([s.primary,...s.alternatives??[]].map(f=>f.toLowerCase())),c=f=>f.kind==="conjunction"||f.kind==="keyword"&&(this.isThenKeyword(f.value,i)||this.isEndKeyword(f.value,i)),m=24,d=-1,p=0;for(let f=0;f<m;f++){let h=e.peek(f);if(!h||c(h))break;if(h.value==="("||h.value==="{"?p++:(h.value===")"||h.value==="}")&&(p=Math.max(0,p-1)),p===0&&(h.kind==="particle"||h.kind==="keyword")&&l.has(h.value.toLowerCase())){d=f;break}}if(d<=0)return;let y=[];for(let f=0;f<d;f++){let h=e.peek(f);h&&y.push(h);}if(y.length===1&&x.RESPONSE_TYPE_WORDS.has(y[0].value.toLowerCase()))return;let E=new re(y,i),v=We(E);n.set("style",{type:"expression",raw:v&&E.isAtEnd()?v:this.joinTokenText(y,i)});for(let f=0;f<=d;f++)e.advance();this.tryAttachResponseTypeAfterStyle(e,r,i);}tryAttachResponseTypeAfterStyle(e,r,i){let n=r.roles;if(n.has("responseType")||!J(r.action)?.roles.some(c=>c.role==="responseType"&&!c.required))return;let o=c=>!!c&&x.RESPONSE_TYPE_WORDS.has(c.toLowerCase()),u=e.peek();if(!u)return;let s=c=>{n.set("responseType",{type:"expression",raw:c});};if(x.AS_MARKERS_BEFORE[i]?.some(c=>u.value.toLowerCase()===c)){let c=e.peek(1);c&&o(c.value)&&(e.advance(),e.advance(),s(c.value));return}if(o(u.value)){e.advance(),s(u.value);for(let c of x.AS_MARKERS_AFTER[i]??[])if(c.every((m,d)=>e.peek(d)?.value.toLowerCase()===m)){for(let m=0;m<c.length;m++)e.advance();break}}}tryAttachTrailingExpressionRole(e,r,i){let 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,u=o.get(a.role);if(n==="go"&&u&&u.type==="expression"&&String(u.raw).toLowerCase()==="url"){let f=e.peek();if(f&&!hr.has((f.normalized??f.value).toLowerCase())){let z=this.tokenToSemanticValue(f);if(z.type==="literal"||z.type==="selector"){o.set(a.role,z),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"&&u&&u.type==="expression"){let f=/^url\s+(\S+)$/i.exec(String(u.raw??""));if(f){let h=f[1].replace(/^["']|["']$/g,"");o.set(a.role,{type:"literal",value:h,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(n==="go"&&!u){let f=o.get("patient");if(f&&f.type==="expression"&&String(f.raw).toLowerCase()==="url"){let h=e.peek();if(h&&!hr.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"}),o.delete("patient"),e.advance();return}}}}if(u&&!(u.type==="reference"&&u.value==="me"))return;let s=L(i);if(!s)return;let l=null;if(a.terminator==="destination-marker"){let f=s.roleMarkers?.destination;if(!f||f.position!=="after")return;l=f.primary.toLowerCase();}let c=f=>f.kind==="conjunction"||f.kind==="keyword"&&(this.isThenKeyword(f.value,i)||this.isEndKeyword(f.value,i)),m=24,d=[],p=0,y=false;for(let f=0;f<m;f++){let h=e.peek(f);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){y=true;break}d.push(h);}if(d.length===0||l!==null&&!y)return;let E=d.length+(y?1:0);if(n==="go"&&d.length===2&&d[0].value.toLowerCase()==="url"){let f=this.tokenToSemanticValue(d[1]);if(f.type==="literal"||f.type==="selector"){o.set(a.role,f),o.set("method",{type:"literal",value:"url"});let h=o.get("patient");h&&h.type==="reference"&&h.value==="me"&&!J(n)?.roles.some(z=>z.role==="patient")&&o.delete("patient");for(let z=0;z<E;z++)e.advance();return}}let v=d;if(n==="js"){let f=s.keywords?.js,h=D=>[f?.primary,...f?.alternatives??[]].some(A=>!!A&&A.length>D.value.length&&A.includes(D.value)),z=0;for(;z<v.length&&h(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 f=o.get("patient");f&&f.type==="reference"&&f.value==="me"&&!J(n)?.roles.some(h=>h.role==="patient")&&o.delete("patient");}for(let f=0;f<E;f++)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=L(r);if(!i||i.wordOrder!=="SOV")return [];let n=x.buildVerbLookup(i),a=x.buildMarkerToRoleLookup(i),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let y=u;y<e.length;y++){let E=e[y];if(a.has(E.value))continue;let v=n.get(E.value.toLowerCase()),f=E.normalized?n.get(E.normalized.toLowerCase()):void 0,h=v||f;if(h){s=y,l=h;break}}if(s===-1)break;let c=e.slice(u,s),m=e.length;for(let y=s+1;y<e.length;y++){let E=e[y];if(E.kind==="conjunction"||this.isThenKeyword(E.value,r)){m=y;break}if(y>s+1&&!a.has(E.value)&&(n.get(E.value.toLowerCase())||(E.normalized?n.get(E.normalized.toLowerCase()):void 0))){m=y;break}}let d=e.slice(s+1,m),p=this.extractRolesFromMarkedTokens(c,d,a,l,r);if(o.push(te(l,p,{sourceLanguage:r,confidence:.7})),u=m,u<e.length){let y=e[u];(y.kind==="conjunction"||this.isThenKeyword(y.value,r))&&u++;}}return o}extractRolesFromMarkedTokens(e,r,i,n,a){let o={},u=(l,c)=>{let m=this.isEndKeyword(l.value,a),d=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !m&&!d?false:l.metadata?.closesTrackedBlock===true||m?true:!(c&&c.kind==="selector")},s=l=>{let c=[];for(let m=0;m<l.length;m++){let d=l[m];if(u(d,l[m+1]))continue;let p=i.get(d.value);if(p&&d.kind==="particle"&&c.length>0){let y=this.tokensToSemanticValue(c,a);if(y){let E=this.mapRoleForCommand(p,n,o);E&&(o[E]=y);}c=[];}else c.push(d);}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!o.duration&&J(n)?.roles.some(d=>d.role==="duration"))o.duration={type:"literal",value:c[0].value,dataType:"string"};else {let d=this.tokensToSemanticValue(c,a);d&&(o.patient?o.destination||(o.destination=d):o.patient=d);}};return s(e),s(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((u,s)=>s>0&&(u.normalized??u.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("*")?ge(n):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?q(it(n),"string"):a.kind==="reference"?ne(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 ge(r);if(r.startsWith('"')||r.startsWith("'"))return q(it(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 ne(r);let i=e.normalized?.toLowerCase();return i==="me"||i==="it"||i==="you"||i==="result"||i==="body"?ne(i):e.kind==="reference"?ne(e.normalized||"me"):q(r)}parseBodyWithGrammarPatterns(e,r,i,n){let a=[],o=[],u=false,s=()=>{if(!u&&o.length>0){let m=this.parseSOVClauseByVerbAnchoring(o,n);a.push(...m),m.length===0&&this.recordDroppedTokens(o,n,"fused body walk");}else o.length>0&&this.recordDroppedTokens(o,n,"fused body walk");o=[],u=false;},l=0,c=()=>{let m=0;for(let d of a){let p=d;(p.action==="for"||p.action==="repeat"||p.action==="while")&&(!Array.isArray(p.body)||p.body.length===0)&&m++;}return m-l};for(;!e.isAtEnd();){let m=e.peek();if(m&&this.isThenKeyword(m.value,n)){s(),e.advance();continue}if(m&&this.isEndKeyword(m.value,n)){let p=e.peek(-1),y=e.peek(1);if(!qr(n,m.value,p?.value,y?.value)){if(s(),c()>0){l++,e.advance();continue}e.advance();break}}if(m&&!u&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),n)){s();let p=this.tryParseConditionalBlock(e,r,n);if(p){a.push(p),u=true;continue}}let d=false;if(i.length>0){let p=ie.matchBest(e,i);if(p){let y=p.pattern.command,E={};for(let[h,z]of p.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(E[h]=z);let v=te(y,E,{sourceLanguage:n,patternId:p.pattern.id});a.push(v),d=true,u=true;let f=p.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then")continue}}if(!d){let p=e.mark(),y=ie.matchBest(e,r);if(y){if(y.pattern.command==="if"){let v=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 f=this.tryParseConditionalBlock(e,r,n);if(f){s(),a.push(f),u=true;continue}e.reset(v);}let E=this.buildCommand(y,n);a.push(E),this.tryAttachTrailingRole(e,E,n),d=true,u=true;}}d||(m&&o.push(m),e.advance());}s(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),n,"fused body walk");for(let m=a.length-1;m>=0;m--){let d=a[m];d.kind==="command"&&d.action==="for"&&(!(d.roles instanceof Map)||d.roles.size===0)&&(!Array.isArray(d.body)||d.body.length===0)&&a.splice(m,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 u=new re(n,i),s=this.coverageMark(),l=this.parseBodyWithClauses(u,r,i);return l.length===0?(this.coverageRollback(s),null):l[0]}matchEventMarkerPhrase(e,r,i){let n=x.SOV_EVENT_MARKER_PHRASES[i];if(!n)return 0;for(let a of n)if(a.every((o,u)=>e[r+u]?.value===o))return a.length;return 0}hasSOVEventMarkerHead(e,r){let i=x.SOV_EVENT_MARKERS[r];if(i===void 0)return false;let{tokens:n}=K(e,r),a=fe[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length;u++){let s=n[u],l=s.value.toLowerCase(),c=s.normalized?.toLowerCase();if(!(!!c&&(x.KNOWN_EVENTS.has(c)||Re.has(c))||x.KNOWN_EVENTS.has(l)||Re.has(l)||o.has(l)))continue;let d=this.matchEventParamPhrase(n,u+1).len,p=n[u+1+d];if(p&&(p.kind==="particle"||p.kind==="keyword")&&i.has(p.value)||this.matchEventMarkerPhrase(n,u+1+d,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=K(e,r).tokens;if(n.length<3)return null;let a=fe[r],o=new Set;if(a)for(let D of Object.keys(a))o.add(D.toLowerCase());let u=n.length-2,s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))return null;let c=n[n.length-1],m=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&x.KNOWN_EVENTS.has(d)||x.KNOWN_EVENTS.has(m)||o.has(m)))return null;let y=d&&x.KNOWN_EVENTS.has(d)?d:a?.[m]??m,E=n.slice(0,u);if(E.length===0)return null;let v=i.filter(D=>D.command!=="on"),f=new re(E,r),h=this.coverageMark(),z=this.parseBodyWithClauses(f,v,r);return z.length===0?(this.coverageRollback(h),null):Ve({type:"literal",value:y},z,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,i){let n=K(e,r).tokens;if(n.length<3)return null;let a=fe[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length-1;u++){let s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let c=n[u+1],m=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&x.KNOWN_EVENTS.has(d)||x.KNOWN_EVENTS.has(m)||o.has(m)))continue;let y=d&&x.KNOWN_EVENTS.has(d)?d:a?.[m]??m,E=n.filter((D,A)=>A!==u&&A!==u+1);if(E.length===0)return null;let v=i.filter(D=>D.command!=="on"),f=new re(E,r),h=this.coverageMark(),z=this.parseBodyWithClauses(f,v,r);return z.length===0?(this.coverageRollback(h),null):Ve({type:"literal",value:y},z,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,i){let n=x.SOV_EVENT_MARKERS[r];if(!n)return null;let o=K(e,r).tokens,u=fe[r],s=new Set;if(u)for(let C of Object.keys(u))s.add(C.toLowerCase());let l=x.SOV_SOURCE_MARKERS[r],c=-1,m="",d="",p=1,y=[];for(let C=0;C<o.length;C++){let g=o[C],b=g.value.toLowerCase(),k=b,w="",B=b.indexOf("[");B>0&&(k=b.slice(0,B),w=g.value.slice(B));let S=g.normalized?.toLowerCase(),R=S&&(x.KNOWN_EVENTS.has(S)||Re.has(S)),F=s.has(b)||s.has(k),O=x.KNOWN_EVENTS.has(k)||Re.has(k);if(R||F||O){let P=o[C-1];if(P&&(P.normalized??P.value).toLowerCase()==="event")continue;let N;R?N=S:F?N=u?.[b]??u?.[k]??k:N=k;let U=this.matchEventParamPhrase(o,C+1);if(n.size>0){let H=1+U.len,de=o[C+H];de&&de.kind==="selector"&&de.value.startsWith("[")&&(H+=1);let ae=o[C+H];if(ae&&(ae.kind==="particle"||ae.kind==="keyword")&&n.has(ae.value)){c=C,m=N,d=w||(H===U.len+2?o[C+H-1].value:""),p=H+1,y=U.names;break}}else {c=C,m=N,d=w,p=1+U.len+this.matchEventMarkerPhrase(o,C+1+U.len,r),y=U.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 k=1,w=o[g+1];w&&w.kind==="selector"&&w.value.startsWith("[")&&(k=2);let B=o[g+k];if(B&&(B.kind==="particle"||B.kind==="keyword")&&n.has(B.value)){c=g,m=b.value,d=k===2?o[g+1].value:"",p=k+1;break}}else {let k=this.matchEventMarkerPhrase(o,g+1,r);if(k>0){c=g,m=b.value,d="",p=1+k;break}let w=o[g+1];if(w&&w.kind==="keyword"&&w.normalized!=null&&C.has(w.normalized)){c=g,m=b.value,d="",p=1;break}}}}if(c===-1)return null;let E=new Set;for(let C=c;C<c+p;C++)E.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))E.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)&&(E.add(C),E.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)&&(E.add(c-2),E.add(c-1));}for(let g=0;g<c;g++){let b=o[g],k=b.value.toLowerCase(),w=b.normalized?.toLowerCase();if(l.windowTokens.has(k)||w&&l.windowTokens.has(w)){E.add(g);break}}}let v=o.filter((C,g)=>!E.has(g));if(v.length===0)return null;let f=i.filter(C=>C.command!=="on"),h=new re(v,r),z=this.coverageMark(),D=this.parseBodyWithClauses(h,f,r);if(D.length===0)return this.coverageRollback(z),null;let A={sourceLanguage:r,confidence:.75};return d&&(A.keyFilter=d),Ve({type:"literal",value:m},D,void 0,A,y)}profileKeywordMatches(e,r,i){let n=L(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=L(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=io(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)}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 u=false;for(;!e.isAtEnd();){let l=e.peek();if(!l)break;if(e.advance(),this.isEndKeyword(l.value,r)){u=true;break}a.push(l);}if(!u)return e.reset(n),null;let s=a.map(l=>l.value).join(" ").trim();return te("js",{patient:{type:"expression",raw:s||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}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)}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){let n=e.peek();if(!n)return null;let a=(n.normalized??n.value).toLowerCase();if(!this.isIfKeyword(a,i))return null;let o=e.mark(),u=this.coverageMark();e.advance();let s=[],l=0;for(;!e.isAtEnd();){let g=e.peek();if(!g)break;let b=(g.normalized??g.value).toLowerCase();if(this.isIfKeyword(b,i)||this.isUnlessKeyword(b,i)){l++,s.push(g),e.advance();continue}if(this.isBlockEndToken(g,e.peek(1)??void 0,i)){if(l===0){e.advance();break}l--,s.push(g),e.advance();continue}s.push(g),e.advance();}if(s.length===0)return e.reset(o),this.coverageRollback(u),null;let c=L(i),m=c?.wordOrder==="SOV"?x.buildVerbLookup(c):null,d=0,p=0,y=[];for(;d<s.length;d++){let g=s[d],b=(g.normalized??g.value).toLowerCase();if(this.isIfKeyword(b,i)||this.isUnlessKeyword(b,i)?p++:this.isBlockEndToken(g,s[d+1],i)&&p--,p===0&&this.isThenKeyword(g.value,i)){d++;break}if(p===0&&y.length>0){let k=(s[d-1].normalized??s[d-1].value).toLowerCase(),w=s[d-1].value.toLowerCase(),B=(g.normalized??g.value).toLowerCase(),S=x.CONDITION_COPULAS.has(k)||x.CONDITION_COPULAS_SURFACE.has(w)&&x.CONDITION_PREDICATES.has(B),R=m!==null&&m.has(g.value.toLowerCase())&&!x.CONDITION_PREDICATES.has(B),F=/^\.[a-zA-Z_]\w*$/.test(g.value)&&s[d-1].position?.end!==void 0&&g.position?.start!==void 0&&s[d-1].position.end===g.position.start;if(!x.CONDITION_OPERATORS.has(B)&&!F&&(!S||R)&&(this.tokensBeginCommand(s.slice(d),r,i)||this.sovCommandStartsAt(s.slice(d),m)))break}y.push(g);}if(y.length===0)return e.reset(o),this.coverageRollback(u),null;let v=[],f=[],h=false,z=0;for(;d<s.length;d++){let g=s[d],b=(g.normalized??g.value).toLowerCase();if(this.isIfKeyword(b,i)||this.isUnlessKeyword(b,i)?z++:this.isBlockEndToken(g,s[d+1],i)&&z--,z===0&&!h&&this.isElseKeyword(g.value,i)){h=true;continue}(h?f:v).push(g);}let D={type:"expression",raw:this.joinTokenText(y,i)},A=this.parseBranch(v,r,i),C=f.length>0?this.parseBranch(f,r,i):void 0;return A.length===0&&(!C||C.length===0)?(e.reset(o),this.coverageRollback(u),null):zn(D,A,C,{sourceLanguage:i,patternId:`conditional-${i}-folded`,confidence:1})}joinTokenText(e,r){return zr(e,L(r))}tokensBeginCommand(e,r,i){if(e.length===0)return false;let n=new re(e,i);return ie.matchBest(n,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let i=u=>r.has(u.value.toLowerCase())||!!u.normalized&&r.has(u.normalized.toLowerCase()),n=u=>u.kind==="identifier"||u.kind==="selector"||u.kind==="literal"||u.kind==="reference",a=0,o=0;for(;a+1<e.length;){let u=e[a],s=e[a+1];if(!n(u)||s.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 re(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=K(e,r).tokens;if(n.length===0)return {modifiers:null,remainingInput:null};let o=n[0].value.toLowerCase(),u=x.STANDALONE_MODIFIERS[o];if(!u)return {modifiers:null,remainingInput:null};let s={},l=1;if(u==="once")s.once=true;else {let p=1;if(p<n.length){let y=n[p],E=n[p+1],v=y.kind==="identifier"&&E?.kind==="literal"&&/^\d+(ms|s|m)?$/.test(E.value);(y.kind==="keyword"||y.kind==="particle"||v)&&(p++,l++);}if(p<n.length){let y=n[p];if(y.kind==="literal"){let E=y.value.match(/^(\d+)(ms|s|m)?$/);if(E){let v=parseInt(E[1],10),f=E[2]||"ms";f==="s"?v*=1e3:f==="m"&&(v*=6e4),s[u]=v,l=p+1;}}}s[u]||(s[u]=u==="debounce"?300:100);}let c=n.slice(l);if(c.length===0)return {modifiers:null,remainingInput:null};let m=c[0].position.start,d=e.slice(m);return {modifiers:s,remainingInput:d}}stripAsyncModifier(e,r){let i=L(r)?.keywords?.async,n=new Set(["async"]);i?.primary&&n.add(i.primary.toLowerCase()),i?.alternatives?.forEach(l=>n.add(l.toLowerCase()));let a=K(e,r).tokens,o=a.findIndex(l=>n.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let u=a[o],s=(e.slice(0,u.position.start)+e.slice(u.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let i=K(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 m=c.kind;if(m==="selector"||m==="literal"||m==="reference"||m==="conjunction")break}if(a===-1)continue;let o=i[n].position.start,u=i[a].position.end,s=(e.slice(0,o)+e.slice(u)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}return {remainingInput:null}}static droppedTokenCount(e){return (e.diagnostics??[]).filter(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=x.droppedTokenCount,a=x.unconsumedSpans(e);if(a.length===0)return null;let o=n(e),u=L(i)?.roleMarkers?.source,s=new Set;u?.primary&&s.add(u.primary),u?.alternatives?.forEach(c=>s.add(c));let l=K(r,i).tokens;for(let c=0;c<l.length;c++){let m=l[c];if(m.normalized!=="source"&&!s.has(m.value))continue;let d=u?.position==="after"?c-1:c+1,p=l[d];if(!p||p.kind!=="identifier"&&p.kind!=="keyword")continue;let y=Math.min(m.position.start,p.position.start),E=Math.max(m.position.end,p.position.end),v=r.slice(y,E).replace(/\s+/g," ").trim();if(!a.some(h=>h===v||h.includes(v)))continue;let f=(r.slice(0,y).trimEnd()+" "+r.slice(E).trimStart()).trim();if(!(!f||f===r))try{let h=this.parse(f,i);if(!h||h.kind!=="event-handler")continue;let z=vr(h);if(n(z)<o)return {node:{...z,eventModifiers:{...z.eventModifiers,from:{type:"literal",value:p.value,dataType:"string"}}},input:f}}catch{}}return null}reclaimEventCompoundTail(e,r,i){let n=x.unconsumedSpans(e);if(n.length===0)return null;let a=fe[i];if(!a)return null;let o=e.roles,u=o.get("event"),s=u?.type==="literal"&&typeof u.value=="string"?u.value:null;if(!s)return null;let l=m=>m.replace(/\s+/g," ").trim(),c=K(r,i).tokens;for(let m of n)for(let d=1;d<c.length;d++)for(let p=d;p<c.length;p++){let y=l(r.slice(c[d].position.start,c[p].position.end));if(y.length>m.length)break;if(y!==m)continue;let E=c[d-1];if((a[E.value]??E.normalized)!==s)break;let f=l(r.slice(E.position.start,c[p].position.end)),h=a[f];if(!h)break;return o.set("event",{type:"literal",value:h,dataType:"string"}),{node:x.withoutSpanDiagnostics(e,m),input:r}}return null}reclaimResponseTypeTail(e,r,i){let n=x.unconsumedSpans(e);if(n.length===0)return null;let a=x.AS_MARKERS_BEFORE[i];if(!a)return null;let o=l=>l.replace(/\s+/g," ").trim(),u=x.droppedTokenCount(e),s=K(r,i).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],m=s[l+1];if(!a.some(y=>c.value.toLowerCase()===y)||!x.RESPONSE_TYPE_WORDS.has(m.value.toLowerCase()))continue;let d=o(r.slice(c.position.start,m.position.end));if(!n.includes(d))continue;let p=(r.slice(0,c.position.start).trimEnd()+" "+r.slice(m.position.end).trimStart()).trim();if(!(!p||p===r))try{let y=this.parse(p,i);if(!y||y.kind!=="event-handler")continue;let E=vr(y);if(x.droppedTokenCount(E)>=u)continue;let v=x.findResponseTypeTarget(E);if(!v)continue;return v.roles.set("responseType",{type:"expression",raw:m.value}),{node:E,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(J(o.action)?.roles.some(s=>s.role==="responseType"&&!s.required)&&!o.roles.has("responseType")){r=o;return}}let a=n;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let u=a[o];Array.isArray(u)&&u.forEach(s=>i(s));}};return i(e),r}reclaimCapturedDestinationTail(e,r,i){let n=x.unconsumedSpans(e);if(n.length===0)return null;let a=L(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 u=l=>l.replace(/\s+/g," ").trim(),s=K(r,i).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],m=s[l+1],d=o.has(c.value)&&m.normalized==="me",p=c.normalized==="me"&&o.has(m.value);if(!d&&!p)continue;let y=u(r.slice(c.position.start,m.position.end));if(!n.includes(y))continue;let E=false,v=f=>{if(!f||typeof f!="object"||E)return;if(f.kind==="command"){let z=f.roles.get("destination");if(z?.type==="reference"&&z.value==="me"){E=true;return}}let h=f;for(let z of ["body","statements","thenBranch","elseBranch","commands"]){let D=h[z];Array.isArray(D)&&D.forEach(A=>v(A));}};if(v(e),!!E)return {node:x.withoutSpanDiagnostics(e,y),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;let o=(a.normalized||a.value).toLowerCase();if(!x.OR_KEYWORDS.has(o)){e.reset(n);break}e.advance();let u=e.peek();if(!u){e.reset(n);break}let s=(u.normalized||u.value).toLowerCase();e.advance(),i.push({type:"literal",value:s});}return i}};Y.coverageMarkerSurfaces=new Map;Y.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};Y.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"]};Y.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};Y.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);Y.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);Y.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"])};Y.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};Y.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"])}};Y.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);Y.CONDITION_COPULAS_SURFACE=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948"]);Y.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);Y.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Y.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};Y.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o","\u092F\u093E","\u0985\u09A5\u09AC\u09BE"]);var Ho=Y,Go=new Ho;function Yo(t,e){return Go.parse(t,e)}function Zo(t,e){try{let r=K(t,e),i=le(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=ie.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 u=n.filter(l=>l.command!=="on"),s=ie.matchBest(r,u);return s?{confidence:s.confidence,parseSuccess:!0,patternId:s.pattern.id,action:s.pattern.command,tokensConsumed:s.consumedTokens}:{confidence:0,parseSuccess:!1,error:`Could not match any patterns for: ${t}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function Lt(t,e){try{let i=Yo(t,e);if(i)return {node:i,confidence:i.metadata?.confidence??.8,error:void 0,tokensConsumed:K(t,e).tokens.length}}catch{}let r=Zo(t,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function Pt(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 Xo(t,e){let r=t.markerOverride?.[e.code],i=e.roleMarkers[t.role];if(r!==void 0){let n=Jo(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 Jo(t,e,r){let i=t.markerLegacy?.[e];if(!i?.length)return;let n=[...new Set(i)].filter(a=>a&&a!==r);return n.length?n:void 0}function me(t,e,r){let i=t.markerLegacy?.[e]??[],n=t.methodCarrier?[]:t.markerVariants?.[e]??[],a=[...new Set([...i,...n])].filter(o=>o&&o!==r);return a.length?a:void 0}function ar(t,e){let r,i;if(t.markerOverride&&t.markerOverride[e.code]!==void 0)r=t.markerOverride[e.code],i=r?me(t,e.code,r):void 0;else {let n=e.roleMarkers[t.role];if(n){r=n.primary;let a=me(t,e.code,r)??[],o=[...new Set([...n.alternatives??[],...a])].filter(u=>u!==r);i=o.length?o:void 0;}}return {marker:r,alternatives:i}}function Ge(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 Qo(t,e,r,i,n){let a=[];if(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 o=e.roleMarkers.destination;o&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary}]}),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let l=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(l);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),a.push(...be(t,e.roleMarkers.source)),a.push(...br(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`{event} ${i.primary} {destination?} {patient} ${u?.primary||""} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(t),...we(t)}}}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);}if(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};a.push(u),a.push(...be(t,e.roleMarkers.source));let s=e.roleMarkers.destination;if(t.action==="swap"&&s){let l=t.roles.find(c=>c.role==="patient")?.markerOverride?.[e.code];if(l&&l!==s.primary){let c=s.alternatives??[];c.includes(l)||(s={...s,alternatives:[...c,l]});}}return a.push(...br(t,s)),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`{patient} ${o?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(t),...we(t)}}}function ru(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 u=e.roleMarkers.destination;if(u&&(a.push({type:"role",role:"destination",optional:false}),a.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.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 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-patient-first-dest`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function tu(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 u=e.roleMarkers.destination;u&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};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(...be(t,e.roleMarkers.source)),a.push(...br(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"},...ke(t),...we(t)}}}function iu(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let u=i.primary.split(/\s+/);if(u.length>1)for(let s of u)a.push({type:"literal",value:s});else {let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(s);}}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 nu(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 s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(s);}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-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 au(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let d of m)a.push({type:"literal",value:d});else {let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}}let u=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.sovPosition??999,y=d.sovPosition??999;return p-y});for(let m of u){a.push({type:"role",role:m.role,optional:false});let{marker:d,alternatives:p}=ar(m,e);if(d){let y=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};a.push(y);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(s);let l=u.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Ge(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 ou(t,e,r,i,n){let a=[],u=[...t.roles.filter(c=>c.required)].sort((c,m)=>{let d=c.sovPosition??999,p=m.sovPosition??999;return d-p});for(let c of u){a.push({type:"role",role:c.role,optional:false});let{marker:m,alternatives:d}=ar(c,e);m&&a.push(d?{type:"literal",value:m,alternatives:d}:{type:"literal",value:m});}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 m of c)a.push({type:"literal",value:m});else a.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}let s=u.map(c=>`{${c.role}}`).join(" "),l={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))};return Ge(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:`${s} ${r.primary} {event} ${i.primary}`,tokens:a},extraction:l}}function uu(t,e,r,i,n){let a=[],u=[...t.roles.filter(v=>v.required)].sort((v,f)=>{let h=v.sovPosition??999,z=f.sovPosition??999;return h-z}),s=u[0];a.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:c}=ar(s,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 f of v)a.push({type:"literal",value:f});else {let f=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(f);}}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(m);let d=u[1];a.push({type:"role",role:d.role,optional:false});let{marker:p,alternatives:y}=ar(d,e);if(p){let v=y?{type:"literal",value:p,alternatives:y}:{type:"literal",value:p};a.push(v);}let E={action:{value:t.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[d.role]:{fromRole:d.role}};return Ge(a,E,t),{id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{${s.role}} {event} ${i.primary} ${r.primary} {${d.role}}`,tokens:a},extraction:E}}function Nt(t,e,r){let i=me(t,e.code,r.primary)??[],n=[...new Set([...r.alternatives??[],...i])].filter(a=>a!==r.primary);return n.length?n:void 0}function nt(t,e,r,i,n){let a=[];if(i.position==="before"){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(s);}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),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(...be(t,e.roleMarkers.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} {patient} ${u?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(t),...we(t)}}}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),a.push({type:"role",role:"patient",optional:false});let u=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(...be(t,e.roleMarkers.source)),i.position==="before"){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(s);}if(a.push({type:"role",role:"event",optional:false}),t.action==="swap"){let s=t.roles.find(l=>l.role==="patient")?.markerOverride?.[e.code];s&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:s},{type:"role",role:"destination",optional:false}]});}return {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:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(t),...we(t)}}}function lu(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.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.svoPosition??999,y=d.svoPosition??999;return p-y});for(let m of s){let d,p;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)d=m.markerOverride[e.code],p=d?me(m,e.code,d):void 0;else {let y=e.roleMarkers[m.role];y&&(d=y.primary,p=Nt(m,e,y));}if(d){let y=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};a.push(y);}a.push({type:"role",role:m.role,optional:false});}if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(m);}a.push({type:"role",role:"event",optional:false});let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Ge(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 at(t,e,r,i,n){let a=[];if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(m);}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=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.svoPosition??999,y=d.svoPosition??999;return p-y});for(let m of s){let d,p;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)d=m.markerOverride[e.code],p=d?me(m,e.code,d):void 0;else {let y=e.roleMarkers[m.role];y&&(d=y.primary,p=Nt(m,e,y));}if(d){let y=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};a.push(y);}a.push({type:"role",role:m.role,optional:false});}let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Ge(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 cu(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 u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),a.push(...be(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} ${s?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(t),...we(t)}}}function mu(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(...be(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"},...ke(t),...we(t)}}}var _e={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function ir(t,e,r=_e){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=yu(t,e,a),u=Sr(t,e),s=Cu(t,e,a);return {id:i,language:e.code,command:t.action,priority:n,template:{format:s,tokens:o},extraction:u}}function du(t,e,r=_e){if(t.roles.filter(u=>!u.required).length===0)return null;let n=t.roles.filter(u=>u.required),a={...t,roles:n};return {...ir(a,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:Sr(t,e)}}function ot(t,e,r=_e){if(e.wordOrder!=="SOV")return null;let i=t.roles.filter(u=>u.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(u=>{let s=u.valuePrefixLiteral?.[e.code],l={type:"role",role:u.role,optional:false,expectedTypes:u.expectedTypes};return s?[{type:"literal",value:s},l]:[l]});return {id:`${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:Sr(t,e)}}function pu(t,e,r=_e){let i=[];if(i.push(ir(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(u=>u.role!==n)},o=ir(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-no-${n}`,priority:(r.basePriority??100)-8});}if(r.generateVerbFirstVariants!==false){let n=ot(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,...u}=t,s={...u,roles:t.roles.map(d=>d.role===n.role?{...d,valuePrefixLiteral:{[e.code]:a}}:d)},l=n.priorityDelta??5,c=n.methodCarrier?{[n.methodCarrier]:{value:a}}:{},m=ir(s,e,r);if(i.push({...m,id:`${t.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)+l,extraction:{...m.extraction,...c}}),r.generateVerbFirstVariants!==false){let d=ot(s,e,r);d&&i.push({...d,id:`${t.action}-${e.code}-generated-verb-first-${n.idSuffix}`,priority:(r.basePriority??100)-20+l,extraction:{...d.extraction,...c}});}}return i}function _t(t,e=_e){let r=[],i=Ia();for(let n of i){if(!t.keywords[n.action])continue;let a=pu(n,t,e);if(r.push(...a),t.eventHandler?.eventMarker){let o=fu(n,t,e);r.push(...o);}}return r}function fu(t,e,r=_e){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 [];let u=t.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)i.push(au(t,e,a,n,r)),i.push(uu(t,e,a,n,r)),i.push(ou(t,e,a,n,r));else {i.push(Qo(t,e,a,n,r)),i.push(eu(t,e,a,n,r));let s=e.roleMarkers.destination;s&&s.primary!==n.primary&&i.push(ru(t,e,a,n,r));let l=n.primary.split(/\s+/),c=n.alternatives?.some(d=>!d.includes(" ")&&d.length>1);l.length>1&&c&&i.push(tu(t,e,a,n,r)),i.push(iu(t,e,a,n,r));let m=nu(t,e,a,r);m&&i.push(m);}else e.wordOrder==="VSO"?u?(i.push(at(t,e,a,n,r)),i.push(lu(t,e,a,n,r))):(i.push(nt(t,e,a,n,r)),i.push(su(t,e,a,n,r)),e.eventHandler?.negationMarker&&i.push(cu(t,e,a,n,r)),e.tokenization?.prefixes&&i.push(mu(t,e,a,r))):u?i.push(at(t,e,a,n,r)):i.push(nt(t,e,a,n,r));return i}function yu(t,e,r){let i=[],n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=vu(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 hu(i)}function hu(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 vu(t,e){let r=[],i=Pt(t.roles,e.wordOrder);for(let n of i){let a=Eu(n,e);n.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function Eu(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},u=t.valuePrefixLiteral?.[e.code],s=()=>{u&&r.push({type:"literal",value:u}),r.push(o);};if(i!==void 0){let l=i?i.split(/\s+/).filter(Boolean):[],c=n?.position??"before",m=t.markerOptional?.[e.code]===true,d=p=>{let y=l.length===1?me(t,e.code,p)??[]:[],E={type:"literal",value:p,...y.length?{alternatives:y}:{},...a?{renderSuppress:true}:{}};r.push(m?{type:"group",optional:true,tokens:[E]}:E);};if(c==="before"){for(let p of l)d(p);s();}else {s();for(let p of l)d(p);}}else if(n){let l=()=>{let m=[...new Set([...n.alternatives??[],...me(t,e.code,n.primary)??[]])].filter(d=>d!==n.primary);return {type:"literal",value:n.primary,...m.length?{alternatives:m}:{},...a?{renderSuppress:true}:{}}},c=m=>{r.push(e.markersOptional||t.markerOptional?.[e.code]?{type:"group",optional:true,tokens:[m]}:m);};n.position==="before"?(n.primary&&c(l()),s()):(s(),c(l()));}else s();return r}function gu(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 u=!/\s/.test(n.trim())?me(i,e.code,n)??[]:[];r[i.role]=u.length?{marker:n,markerAlternatives:u}:{marker:n};}else if(a&&a.primary){let o=[...new Set([...a.alternatives??[],...me(i,e.code,a.primary)??[]])].filter(u=>u!==a.primary);r[i.role]=o.length?{marker:a.primary,markerAlternatives:o}:{marker:a.primary};}else r[i.role]={};}return r}function Sr(t,e){let r=gu(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 Cu(t,e,r){let i=[],a=Pt(t.roles,e.wordOrder).map(o=>{let u=Xo(o,e),s="";return u&&u.primary?u.position==="before"?s=`${u.primary} {${o.role}}`:s=`{${o.role}} ${u.primary}`:s=`{${o.role}}`,o.required?s:`[${s}]`});switch(e.wordOrder){case "SVO":case "VSO":i.push(r.primary,...a);break;case "SOV":i.push(...a,r.primary);break;default:i.push(r.primary,...a);}return i.join(" ")}var zu=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 zu;var ku=[{pattern:"\u3057\u305F\u3089",confidence:.88,conjugationType:"conditional-tara",minStemLength:2},{pattern:"\u3059\u308B\u3068",confidence:.88,conjugationType:"conditional-to",minStemLength:2},{pattern:"\u3059\u308C\u3070",confidence:.85,conjugationType:"conditional-ba",minStemLength:2},{pattern:"\u305F\u3089",confidence:.85,conjugationType:"conditional-tara",minStemLength:2},{pattern:"\u308C\u3070",confidence:.82,conjugationType:"conditional-ba",minStemLength:2},{pattern:"\u3066\u3044\u307E\u3057\u305F",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\u3066\u3044\u307E\u3059",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304F\u3060\u3055\u3044",confidence:.85,conjugationType:"request",minStemLength:2},{pattern:"\u3067\u304F\u3060\u3055\u3044",confidence:.85,conjugationType:"request",minStemLength:2},{pattern:"\u3066\u3044\u308B",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304A\u304F",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u307F\u308B",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u3042\u308B",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304F\u308C",confidence:.8,conjugationType:"casual-request",minStemLength:2},{pattern:"\u3067\u304F\u308C",confidence:.8,conjugationType:"casual-request",minStemLength:2},{pattern:"\u3061\u3083\u3063\u305F",confidence:.82,conjugationType:"contracted-past",minStemLength:2},{pattern:"\u3058\u3083\u3063\u305F",confidence:.82,conjugationType:"contracted-past",minStemLength:2},{pattern:"\u3061\u3083\u3046",confidence:.82,conjugationType:"contracted",minStemLength:2},{pattern:"\u3058\u3083\u3046",confidence:.82,conjugationType:"contracted",minStemLength:2},{pattern:"\u307E\u3057\u305F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"\u307E\u305B\u3093",confidence:.85,conjugationType:"negative",minStemLength:2},{pattern:"\u307E\u3059",confidence:.85,conjugationType:"polite",minStemLength:2},{pattern:"\u3066",confidence:.85,conjugationType:"te-form",minStemLength:2},{pattern:"\u305F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"\u306A\u3044",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"\u306A\u304B\u3063\u305F",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\u3089\u308C\u308B",confidence:.8,conjugationType:"potential",minStemLength:2},{pattern:"\u308C\u308B",confidence:.78,conjugationType:"potential",minStemLength:2},{pattern:"\u3089\u308C\u305F",confidence:.8,conjugationType:"passive",minStemLength:2},{pattern:"\u3055\u305B\u308B",confidence:.8,conjugationType:"causative",minStemLength:2},{pattern:"\u305B\u308B",confidence:.78,conjugationType:"causative",minStemLength:2},{pattern:"\u3088\u3046",confidence:.8,conjugationType:"volitional",minStemLength:2},{pattern:"\u308B",confidence:.75,conjugationType:"dictionary",minStemLength:3}],wu=[{pattern:"\u3057\u305F\u3089",confidence:.88,conjugationType:"conditional-tara"},{pattern:"\u3059\u308B\u3068",confidence:.88,conjugationType:"conditional-to"},{pattern:"\u3059\u308C\u3070",confidence:.85,conjugationType:"conditional-ba"},{pattern:"\u3057\u3066\u3044\u307E\u3059",confidence:.85,conjugationType:"progressive"},{pattern:"\u3057\u3066\u3044\u308B",confidence:.85,conjugationType:"progressive"},{pattern:"\u3057\u307E\u3057\u305F",confidence:.85,conjugationType:"past"},{pattern:"\u3057\u307E\u3059",confidence:.85,conjugationType:"polite"},{pattern:"\u3057\u306A\u3044",confidence:.82,conjugationType:"negative"},{pattern:"\u3057\u3066",confidence:.85,conjugationType:"te-form"},{pattern:"\u3057\u305F",confidence:.85,conjugationType:"past"},{pattern:"\u3059\u308B",confidence:.88,conjugationType:"dictionary"}];function Vt(t){let e=t.charCodeAt(0);return e>=12352&&e<=12447}function bu(t){let e=t.charCodeAt(0);return e>=12448&&e<=12543}function Au(t){let e=t.charCodeAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903}function Du(t){for(let e of t)if(Vt(e)||bu(e)||Au(e))return true;return false}var qt=class{constructor(){this.language="ja";}isNormalizable(t){if(!Du(t)||t.length<2)return false;let e=t[t.length-1];return Vt(e)}normalize(t){let e=this.normalizeCompound(t);if(e)return e;let r=this.trySuruNormalization(t);if(r)return r;for(let i of ku)if(t.endsWith(i.pattern)){let n=t.slice(0,-i.pattern.length),a=i.minStemLength??2;if(n.length<a)continue;let o={removedSuffixes:[i.pattern]};return i.conjugationType&&(o.conjugationType=i.conjugationType),pe(n,i.confidence,o)}return rr(t)}trySuruNormalization(t){for(let e of wu)if(t.endsWith(e.pattern)){let r=t.slice(0,-e.pattern.length);if(r.length<1)continue;return pe(r,e.confidence,{removedSuffixes:[e.pattern],conjugationType:e.conjugationType,originalForm:"suru-verb"})}return null}normalizeCompound(t){let e=[{pattern:"\u3066\u3044\u306A\u304B\u3063\u305F",suffixes:["\u3066","\u3044","\u306A\u304B\u3063\u305F"],confidence:.8,minStemLength:2},{pattern:"\u3067\u3044\u306A\u304B\u3063\u305F",suffixes:["\u3067","\u3044","\u306A\u304B\u3063\u305F"],confidence:.8,minStemLength:2},{pattern:"\u3066\u3044\u306A\u3044",suffixes:["\u3066","\u3044","\u306A\u3044"],confidence:.82,minStemLength:2},{pattern:"\u3067\u3044\u306A\u3044",suffixes:["\u3067","\u3044","\u306A\u3044"],confidence:.82,minStemLength:2},{pattern:"\u3066\u3044\u305F",suffixes:["\u3066","\u3044","\u305F"],confidence:.85,minStemLength:2},{pattern:"\u3067\u3044\u305F",suffixes:["\u3067","\u3044","\u305F"],confidence:.85,minStemLength:2}];for(let{pattern:r,suffixes:i,confidence:n,minStemLength:a}of e)if(t.endsWith(r)){let o=t.slice(0,-r.length);if(o.length<a)continue;return pe(o,n,{removedSuffixes:i,conjugationType:"compound"})}return null}},Wt={code:"ja",name:"Japanese",nativeName:"\u65E5\u672C\u8A9E",regions:["east-asian","priority"],direction:"ltr",script:"cjk",wordOrder:"SOV",markingStrategy:"particle",usesSpaces:false,defaultVerbForm:"base",verb:{position:"end",suffixes:["\u308B","\u3066","\u305F","\u307E\u3059","\u306A\u3044"],subjectDrop:true},references:{me:"\u81EA\u5206",it:"\u305D\u308C",you:"\u3042\u306A\u305F",result:"\u7D50\u679C",event:"\u30A4\u30D9\u30F3\u30C8",target:"\u30BF\u30FC\u30B2\u30C3\u30C8",body:"\u30DC\u30C7\u30A3",document:"\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8",window:"\u30A6\u30A3\u30F3\u30C9\u30A6",detail:"\u8A73\u7D30"},possessive:{marker:"\u306E",markerPosition:"between",keywords:{\u79C1\u306E:"me",\u3042\u306A\u305F\u306E:"you",\u305D\u306E:"it"}},roleMarkers:{patient:{primary:"\u3092",position:"after"},destination:{primary:"\u306B",alternatives:["\u3078","\u3067","\u306E"],position:"after"},source:{primary:"\u304B\u3089",position:"after"},style:{primary:"\u3067",position:"after"},event:{primary:"\u3092",position:"after"}},keywords:{toggle:{primary:"\u5207\u308A\u66FF\u3048",alternatives:["\u5207\u308A\u66FF\u3048\u308B","\u30C8\u30B0\u30EB","\u30C8\u30B0\u30EB\u3059\u308B"],normalized:"toggle"},add:{primary:"\u8FFD\u52A0",alternatives:["\u8FFD\u52A0\u3059\u308B","\u52A0\u3048\u308B"],normalized:"add"},remove:{primary:"\u524A\u9664",alternatives:["\u524A\u9664\u3059\u308B","\u53D6\u308A\u9664\u304F"],normalized:"remove"},put:{primary:"\u7F6E\u304F",alternatives:["\u5165\u308C\u308B"],normalized:"put"},append:{primary:"\u672B\u5C3E\u8FFD\u52A0",alternatives:["\u672B\u5C3E\u306B\u8FFD\u52A0","\u30A2\u30DA\u30F3\u30C9"],normalized:"append"},prepend:{primary:"\u5148\u982D\u8FFD\u52A0",alternatives:["\u5148\u982D\u306B\u8FFD\u52A0","\u30D7\u30EA\u30DA\u30F3\u30C9"],normalized:"prepend"},take:{primary:"\u53D6\u308B",normalized:"take"},make:{primary:"\u4F5C\u308B",alternatives:["\u4F5C\u6210"],normalized:"make"},clone:{primary:"\u8907\u88FD",alternatives:["\u30AF\u30ED\u30FC\u30F3"],normalized:"clone"},swap:{primary:"\u4EA4\u63DB",alternatives:["\u30B9\u30EF\u30C3\u30D7","\u5165\u308C\u66FF\u3048"],normalized:"swap"},morph:{primary:"\u5909\u5F62",alternatives:["\u30E2\u30FC\u30D5","\u5909\u63DB"],normalized:"morph"},set:{primary:"\u8A2D\u5B9A",alternatives:["\u8A2D\u5B9A\u3059\u308B"],normalized:"set"},get:{primary:"\u53D6\u5F97",alternatives:["\u53D6\u5F97\u3059\u308B","\u30B2\u30C3\u30C8"],normalized:"get"},increment:{primary:"\u5897\u52A0",alternatives:["\u5897\u3084\u3059","\u30A4\u30F3\u30AF\u30EA\u30E1\u30F3\u30C8"],normalized:"increment"},decrement:{primary:"\u6E1B\u5C11",alternatives:["\u6E1B\u3089\u3059","\u30C7\u30AF\u30EA\u30E1\u30F3\u30C8"],normalized:"decrement"},log:{primary:"\u8A18\u9332",alternatives:["\u30ED\u30B0","\u51FA\u529B"],normalized:"log"},show:{primary:"\u8868\u793A",alternatives:["\u8868\u793A\u3059\u308B","\u898B\u305B\u308B"],normalized:"show"},hide:{primary:"\u96A0\u3059",alternatives:["\u975E\u8868\u793A","\u975E\u8868\u793A\u306B\u3059\u308B"],normalized:"hide"},transition:{primary:"\u9077\u79FB",alternatives:["\u30C8\u30E9\u30F3\u30B8\u30B7\u30E7\u30F3","\u30A2\u30CB\u30E1\u30FC\u30B7\u30E7\u30F3"],normalized:"transition"},on:{primary:"\u3067",alternatives:["\u6642"],normalized:"on"},trigger:{primary:"\u5F15\u304D\u91D1",alternatives:["\u767A\u706B","\u30C8\u30EA\u30AC\u30FC"],normalized:"trigger"},send:{primary:"\u9001\u308B",alternatives:["\u9001\u4FE1"],normalized:"send"},focus:{primary:"\u30D5\u30A9\u30FC\u30AB\u30B9",alternatives:["\u96C6\u4E2D"],normalized:"focus"},blur:{primary:"\u307C\u304B\u3057",alternatives:["\u30D5\u30A9\u30FC\u30AB\u30B9\u89E3\u9664","\u30D6\u30E9\u30FC"],normalized:"blur"},empty:{primary:"\u7A7A\u306B",alternatives:["\u7A7A\u306B\u3059\u308B"],normalized:"empty"},open:{primary:"\u958B\u304F",alternatives:["\u30AA\u30FC\u30D7\u30F3"],normalized:"open"},close:{primary:"\u9589\u3058\u308B",alternatives:["\u30AF\u30ED\u30FC\u30BA"],normalized:"close"},select:{primary:"\u9078\u3076",alternatives:["\u30BB\u30EC\u30AF\u30C8"],normalized:"select"},clear:{primary:"\u30AF\u30EA\u30A2",alternatives:["\u6D88\u53BB"],normalized:"clear"},reset:{primary:"\u30EA\u30BB\u30C3\u30C8",alternatives:["\u518D\u8A2D\u5B9A"],normalized:"reset"},breakpoint:{primary:"\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8",normalized:"breakpoint"},go:{primary:"\u79FB\u52D5",alternatives:["\u884C\u304F","\u30CA\u30D3\u30B2\u30FC\u30C8"],normalized:"go"},scroll:{primary:"\u30B9\u30AF\u30ED\u30FC\u30EB",normalized:"scroll"},push:{primary:"\u30D7\u30C3\u30B7\u30E5",normalized:"push"},replace:{primary:"\u7F6E\u63DB",alternatives:["\u7F6E\u304D\u63DB\u3048"],normalized:"replace"},process:{primary:"\u51E6\u7406",normalized:"process"},wait:{primary:"\u5F85\u3064",alternatives:["\u5F85\u6A5F"],normalized:"wait"},fetch:{primary:"\u30D5\u30A7\u30C3\u30C1",normalized:"fetch"},settle:{primary:"\u5B89\u5B9A",alternatives:["\u843D\u3061\u7740\u304F"],normalized:"settle"},if:{primary:"\u3082\u3057",normalized:"if"},when:{primary:"\u3068\u304D",alternatives:["\u3068\u304D\u306B"],normalized:"when"},where:{primary:"\u3069\u3053",normalized:"where"},else:{primary:"\u305D\u3046\u3067\u306A\u3051\u308C\u3070",alternatives:["\u305D\u308C\u4EE5\u5916"],normalized:"else"},unless:{primary:"\u306A\u3044\u9650\u308A",normalized:"unless"},repeat:{primary:"\u7E70\u308A\u8FD4\u3057",alternatives:["\u7E70\u308A\u8FD4\u3059","\u30EA\u30D4\u30FC\u30C8"],normalized:"repeat"},for:{primary:"\u305F\u3081\u306B",alternatives:["\u5404"],normalized:"for"},while:{primary:"\u306E\u9593",alternatives:["\u9593"],normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"\u7D9A\u3051\u308B",alternatives:["\u7D99\u7D9A"],normalized:"continue"},halt:{primary:"\u505C\u6B62",alternatives:["\u6B62\u3081\u308B","\u30CF\u30EB\u30C8"],normalized:"halt"},throw:{primary:"\u6295\u3052\u308B",alternatives:["\u30B9\u30ED\u30FC"],normalized:"throw"},call:{primary:"\u547C\u3073\u51FA\u3057",alternatives:["\u30B3\u30FC\u30EB","\u547C\u3076"],normalized:"call"},return:{primary:"\u623B\u308B",alternatives:["\u8FD4\u3059","\u30EA\u30BF\u30FC\u30F3"],normalized:"return"},then:{primary:"\u305D\u308C\u304B\u3089",alternatives:["\u6B21\u306B","\u306A\u3089\u3070","\u306A\u3089"],normalized:"then"},and:{primary:"\u307E\u305F",alternatives:["\u3068","\u305D\u3057\u3066"],normalized:"and"},matches:{primary:"\u4E00\u81F4\u3059\u308B",normalized:"matches"},exists:{primary:"\u5B58\u5728\u3059\u308B",normalized:"exists"},is:{primary:"\u3067\u3042\u308B",normalized:"is"},no:{primary:"\u306A\u3044",normalized:"no"},end:{primary:"\u7D42\u308F\u308A",alternatives:["\u304A\u308F\u308A"],normalized:"end"},js:{primary:"JS\u5B9F\u884C",alternatives:["js"],normalized:"js"},async:{primary:"\u975E\u540C\u671F",alternatives:["\u30A2\u30B7\u30F3\u30AF"],normalized:"async"},tell:{primary:"\u4F1D\u3048\u308B",alternatives:["\u30C6\u30EB"],normalized:"tell"},default:{primary:"\u65E2\u5B9A",alternatives:["\u30C7\u30D5\u30A9\u30EB\u30C8"],normalized:"default"},init:{primary:"\u521D\u671F\u5316",alternatives:["\u30A4\u30CB\u30C3\u30C8"],normalized:"init"},behavior:{primary:"\u632F\u308B\u821E\u3044",alternatives:["\u30D3\u30D8\u30A4\u30D3\u30A2"],normalized:"behavior"},install:{primary:"\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB",alternatives:["\u5C0E\u5165"],normalized:"install"},measure:{primary:"\u6E2C\u5B9A",alternatives:["\u8A08\u6E2C","\u30E1\u30B8\u30E3\u30FC"],normalized:"measure"},beep:{primary:"\u30D3\u30FC\u30D7",normalized:"beep"},break:{primary:"\u4E2D\u65AD",normalized:"break"},copy:{primary:"\u30B3\u30D4\u30FC",normalized:"copy"},exit:{primary:"\u9000\u51FA",normalized:"exit"},pick:{primary:"\u9078\u629E",normalized:"pick"},render:{primary:"\u63CF\u753B",normalized:"render"},into:{primary:"\u3078",alternatives:["\u306B"],normalized:"into"},before:{primary:"\u524D\u306B",alternatives:["\u524D"],normalized:"before"},after:{primary:"\u5F8C\u306B",alternatives:["\u5F8C"],normalized:"after"},until:{primary:"\u307E\u3067",alternatives:["\u8FC4"],normalized:"until"},event:{primary:"\u30A4\u30D9\u30F3\u30C8",alternatives:["\u4E8B\u8C61"],normalized:"event"},from:{primary:"\u304B\u3089",normalized:"from"},connect:{primary:"\u63A5\u7D9A",alternatives:["\u63A5\u7D9A\u3059\u308B"],normalized:"connect"},stream:{primary:"\u30B9\u30C8\u30EA\u30FC\u30E0",alternatives:["\u914D\u4FE1"],normalized:"stream"},live:{primary:"\u30E9\u30A4\u30D6",alternatives:["\u5B9F\u6642\u9593"],normalized:"live"},socket:{primary:"\u30BD\u30B1\u30C3\u30C8",alternatives:["websocket"],normalized:"socket"},bind:{primary:"\u30D0\u30A4\u30F3\u30C9",alternatives:["\u7D50\u3073\u3064\u3051\u308B","bind"],normalized:"bind"},intercept:{primary:"\u30A4\u30F3\u30BF\u30FC\u30BB\u30D7\u30C8",alternatives:["\u508D\u53D7","intercept"],normalized:"intercept"},worker:{primary:"\u30EF\u30FC\u30AB\u30FC",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u30A4\u30D9\u30F3\u30C8\u30BD\u30FC\u30B9"],normalized:"eventsource"}},tokenization:{particles:["\u3092","\u306B","\u3067","\u304B\u3089","\u306E","\u304C","\u306F","\u3082","\u3078","\u3068"],boundaryStrategy:"particle"},eventHandler:{eventMarker:{primary:"\u3067",position:"after"},temporalMarkers:["\u6642","\u3068\u304D"]}},Bu=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Su=class{constructor(t=Bu){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}},xu="()[]{},:;",Tu=class{constructor(t=xu){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 xr(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 Mt(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=xr(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=xr(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=xr(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 Fu=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Mt(t,e)!==null:false}extract(t,e){let r=Mt(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Ru=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}}}},Ou=["http://","https://","//","./","../","/"];function Lu(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 Pu(t,e){let r=t.slice(e),i=Ou.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=Lu(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var Nu=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=Pu(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},_u=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 Mu(t){let e=t.charCodeAt(0);return e>=12352&&e<=12447}function Iu(t){let e=t.charCodeAt(0);return e>=12448&&e<=12543}function ju(t){let e=t.charCodeAt(0);return e>=19968&&e<=40879||e>=13312&&e<=19903}function It(t){return Mu(t)||Iu(t)||ju(t)}var $u=class{constructor(){this.name="japanese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return It(t[e])}extract(t,e){if(!this.context)throw new Error("JapaneseKeywordExtractor: context not set");let r=e;this.context.isKeywordStart(t,e);let i="",n=e;for(;n<t.length&&It(t[n]);)i+=t[n],n++;let a=i,o=i.length;for(let c=i.length;c>0;c--){let m=i.substring(0,c);if(this.context.lookupKeyword(m)){a=m,o=c;break}}if(i=a,n=e+o,!i)return null;let u=this.context.lookupKeyword(i),s=u&&u.normalized!==u.native?u.normalized:void 0,l;if(!u&&this.context.normalizer){let c=this.context.normalizer.normalize(i);if(c.stem!==i&&c.confidence>=.7){let m=this.context.lookupKeyword(c.stem);m&&(l=m.normalized);}}return {value:i,length:n-r,metadata:{normalized:s||l}}}},jt=new Map([["\u3092",{role:"patient",confidence:.95}],["\u306B",{role:"destination",confidence:.85}],["\u304C",{role:"subject",confidence:.9}],["\u306E",{role:"possessive",confidence:.9}],["\u3068",{role:"conjunction",confidence:.8}],["\u3067",{role:"instrument",confidence:.85}],["\u3078",{role:"direction",confidence:.85}],["\u3084",{role:"listing",confidence:.8}],["\u304B",{role:"question",confidence:.85}],["\u3082",{role:"also",confidence:.85}],["\u306F",{role:"topic",confidence:.9}]]),$t=new Map([["\u304B\u3089",{role:"source",confidence:.95}],["\u307E\u3067",{role:"until",confidence:.95}],["\u3088\u308A",{role:"comparison",confidence:.9}],["\u3068\u3057\u3066",{role:"as",confidence:.9}],["\u306B\u3064\u3044\u3066",{role:"about",confidence:.9}],["\u306B\u3088\u3063\u3066",{role:"by-means",confidence:.9}],["\u306B\u3066",{role:"at-location",confidence:.85}]]),Vu=class{constructor(){this.name="japanese-particle";}setContext(t){this._context=t;}longerKeywordStartsHere(t,e){if(!this._context)return false;for(let r=4;r>=2;r--){let i=t.slice(e,e+r);if(i.length===r&&this._context.isKeyword(i))return true}return false}canExtract(t,e){let r=t[e];if(jt.has(r)&&!this.longerKeywordStartsHere(t,e))return true;for(let[i]of $t)if(t.startsWith(i,e))return true;return false}extract(t,e){for(let[n,a]of $t)if(t.startsWith(n,e))return {value:n,length:n.length,metadata:{role:a.role,confidence:a.confidence,variant:n}};let r=t[e];if(this.longerKeywordStartsHere(t,e))return null;let i=jt.get(r);return i?{value:r,length:1,metadata:{role:i.role,confidence:i.confidence,variant:r}}:null}};function qu(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Wu(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var Ku=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return qu(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",n=e;for(;n<t.length&&Wu(t[n]);)i+=t[n],n++;if(!i)return null;let a=this.context.lookupKeyword(i),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:n-r,metadata:{normalized:o}}}};function Uu(){return [new Nu,new Ru,new _u,new Fu]}var Hu=new Set(["\u3092","\u306B","\u3067","\u304B\u3089","\u307E\u3067","\u3078","\u3068","\u306E","\u304C","\u306F","\u3082","\u3088\u308A"]),Gu=[{native:"\u771F",normalized:"true"},{native:"\u507D",normalized:"false"},{native:"\u30CC\u30EB",normalized:"null"},{native:"\u672A\u5B9A\u7FA9",normalized:"undefined"},{native:"\u6700\u521D",normalized:"first"},{native:"\u6700\u5F8C",normalized:"last"},{native:"\u6B21",normalized:"next"},{native:"\u524D",normalized:"previous"},{native:"\u6700\u3082\u8FD1\u3044",normalized:"closest"},{native:"\u89AA",normalized:"parent"},{native:"\u306E\u4E2D",normalized:"in"},{native:"\u30AF\u30EA\u30C3\u30AF",normalized:"click"},{native:"\u5909\u66F4",normalized:"change"},{native:"\u9001\u4FE1",normalized:"submit"},{native:"\u5165\u529B",normalized:"input"},{native:"\u30ED\u30FC\u30C9",normalized:"load"},{native:"\u8AAD\u307F\u8FBC\u307F",normalized:"load"},{native:"\u30B9\u30AF\u30ED\u30FC\u30EB",normalized:"scroll"},{native:"\u30AD\u30FC\u30C0\u30A6\u30F3",normalized:"keydown"},{native:"\u30AD\u30FC\u30A2\u30C3\u30D7",normalized:"keyup"},{native:"\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC",normalized:"mouseover"},{native:"\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8",normalized:"mouseout"},{native:"\u30DE\u30A6\u30B9\u62BC\u4E0B",normalized:"mousedown"},{native:"\u30DE\u30A6\u30B9\u89E3\u653E",normalized:"mouseup"},{native:"\u307E\u305F\u306F",normalized:"or"},{native:"\u79C1",normalized:"me"},{native:"\u5BFE\u8C61",normalized:"target"},{native:"\u3057\u305F\u3089",normalized:"on"},{native:"\u3059\u308B\u3068",normalized:"on"},{native:"\u6642\u306B",normalized:"on"},{native:"\u79D2",normalized:"s"},{native:"\u30DF\u30EA\u79D2",normalized:"ms"},{native:"\u5206",normalized:"m"},{native:"\u6642\u9593",normalized:"h"},{native:"\u542B\u3080",normalized:"inclusive"},{native:"\u9664\u304F",normalized:"exclusive"},{native:"\u6587\u5B57",normalized:"characters"},{native:"\u30E9\u30F3\u30C0\u30E0",normalized:"random"}],Yu=class extends Te{constructor(){super(),this.language="ja",this.direction="ltr",this.initializeKeywordsFromProfile(Wt,Gu),this.normalizer=new qt,this.registerExtractors(Uu()),this.registerExtractor(new Se),this.registerExtractor(new xe),this.registerExtractor(new Ku),this.registerExtractor(new Vu),this.registerExtractor(new $u),this.registerExtractor(new Su),this.registerExtractor(new Tu);}classifyToken(t){return Hu.has(t)?"particle":this.isKeyword(t)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(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("'")||t.startsWith("\u300C")||/^\d/.test(t)?"literal":"identifier"}},Zu=new Yu;Ne("ja",Zu,Wt);function Xu(t){let e=t.charCodeAt(0);return e>=44032&&e<=55203}function Ju(t){for(let e of t)if(Xu(e))return true;return false}var Qu=[{pattern:"\uD558\uC2DC\uB2C8\uAE4C",confidence:.85,conjugationType:"honorific-causal",minStemLength:1},{pattern:"\uD558\uC2E4\uB54C",confidence:.88,conjugationType:"honorific-temporal",minStemLength:1},{pattern:"\uD558\uC2E4 \uB54C",confidence:.88,conjugationType:"honorific-temporal",minStemLength:1},{pattern:"\uD558\uC2DC\uBA74",confidence:.88,conjugationType:"honorific-conditional",minStemLength:1},{pattern:"\uC73C\uC2DC\uBA74",confidence:.85,conjugationType:"honorific-conditional",minStemLength:2},{pattern:"\uC2DC\uBA74",confidence:.82,conjugationType:"honorific-conditional",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uD558\uACE0 \uB098\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uD558\uACE0\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uACE0\uB098\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uACE0 \uB098\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uACE0\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uAE30\uC804\uC5D0",confidence:.85,conjugationType:"sequential-before",minStemLength:1},{pattern:"\uD558\uAE30 \uC804\uC5D0",confidence:.85,conjugationType:"sequential-before",minStemLength:1},{pattern:"\uAE30\uC804\uC5D0",confidence:.82,conjugationType:"sequential-before",minStemLength:2},{pattern:"\uAE30 \uC804\uC5D0",confidence:.82,conjugationType:"sequential-before",minStemLength:2},{pattern:"\uD558\uC790\uB9C8\uC790",confidence:.88,conjugationType:"immediate",minStemLength:1},{pattern:"\uC790\uB9C8\uC790",confidence:.85,conjugationType:"immediate",minStemLength:2},{pattern:"\uD574\uC57C\uD574\uC694",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uD574\uC57C\uD574",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uD574\uC57C\uD558\uB2E4",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uC5B4\uC57C\uD574\uC694",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC5B4\uC57C\uD574",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC544\uC57C\uD574\uC694",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC544\uC57C\uD574",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uD558\uB2C8\uAE4C",confidence:.85,conjugationType:"causal-nikka",minStemLength:1},{pattern:"\uD560\uB54C",confidence:.88,conjugationType:"temporal-ttae",minStemLength:1},{pattern:"\uD560 \uB54C",confidence:.88,conjugationType:"temporal-ttae",minStemLength:1},{pattern:"\uC744\uB54C",confidence:.85,conjugationType:"temporal-ttae",minStemLength:2},{pattern:"\uC744 \uB54C",confidence:.85,conjugationType:"temporal-ttae",minStemLength:2},{pattern:"\uD558\uBA74",confidence:.88,conjugationType:"conditional-myeon",minStemLength:1},{pattern:"\uC73C\uBA74",confidence:.85,conjugationType:"conditional-myeon",minStemLength:2},{pattern:"\uB2C8\uAE4C",confidence:.82,conjugationType:"causal-nikka",minStemLength:2},{pattern:"\uBA74",confidence:.8,conjugationType:"conditional-myeon",minStemLength:2},{pattern:"\uD558\uC600\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD588\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD569\uB2C8\uB2E4",confidence:.85,conjugationType:"polite",minStemLength:1},{pattern:"\uC2B5\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uB429\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:1},{pattern:"\u3142\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uD558\uC138\uC694",confidence:.85,conjugationType:"honorific",minStemLength:1},{pattern:"\uD558\uC2ED\uC2DC\uC624",confidence:.85,conjugationType:"honorific",minStemLength:1},{pattern:"\uC138\uC694",confidence:.82,conjugationType:"honorific",minStemLength:2},{pattern:"\uC2ED\uC2DC\uC624",confidence:.82,conjugationType:"honorific",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5B4\uC694",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uD558\uACE0\uC788\uC5B4",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uD588\uC5B4\uC694",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD574\uC694",confidence:.85,conjugationType:"polite",minStemLength:1},{pattern:"\uC5B4\uC694",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uC544\uC694",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uD588\uC5B4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD574",confidence:.8,conjugationType:"present",minStemLength:1},{pattern:"\uC5C8\uC5B4",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\uC558\uC5B4",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uB2E4",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uACE0\uC788\uB2E4",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uACE0\uC788\uC5B4",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uD558\uB2E4",confidence:.88,conjugationType:"dictionary",minStemLength:1},{pattern:"\uD558\uC9C0\uC54A\uB2E4",confidence:.82,conjugationType:"negative",minStemLength:1},{pattern:"\uC548\uD558\uB2E4",confidence:.82,conjugationType:"negative",minStemLength:1},{pattern:"\uC9C0\uC54A\uB2E4",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"\uD574\uB77C",confidence:.82,conjugationType:"imperative",minStemLength:1},{pattern:"\uD558\uB77C",confidence:.82,conjugationType:"imperative",minStemLength:1},{pattern:"\uB2E4",confidence:.75,conjugationType:"dictionary",minStemLength:2}],es=[{pattern:"\uD558\uC2DC\uB2C8\uAE4C",confidence:.88,conjugationType:"honorific-causal"},{pattern:"\uD558\uC2E4\uB54C",confidence:.88,conjugationType:"honorific-temporal"},{pattern:"\uD558\uC2E4 \uB54C",confidence:.88,conjugationType:"honorific-temporal"},{pattern:"\uD558\uC2DC\uBA74",confidence:.88,conjugationType:"honorific-conditional"},{pattern:"\uD558\uC168\uC5B4\uC694",confidence:.85,conjugationType:"honorific-past"},{pattern:"\uD558\uC168\uC5B4",confidence:.85,conjugationType:"honorific-past"},{pattern:"\uD558\uC2ED\uB2C8\uB2E4",confidence:.85,conjugationType:"honorific-polite"},{pattern:"\uD558\uACE0\uB098\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uACE0 \uB098\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uACE0\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uAE30\uC804\uC5D0",confidence:.88,conjugationType:"sequential-before"},{pattern:"\uD558\uAE30 \uC804\uC5D0",confidence:.88,conjugationType:"sequential-before"},{pattern:"\uD558\uC790\uB9C8\uC790",confidence:.88,conjugationType:"immediate"},{pattern:"\uD574\uC57C\uD574\uC694",confidence:.88,conjugationType:"obligation"},{pattern:"\uD574\uC57C\uD574",confidence:.88,conjugationType:"obligation"},{pattern:"\uD574\uC57C\uD558\uB2E4",confidence:.88,conjugationType:"obligation"},{pattern:"\uD558\uB2C8\uAE4C",confidence:.88,conjugationType:"causal-nikka"},{pattern:"\uD560\uB54C",confidence:.88,conjugationType:"temporal-ttae"},{pattern:"\uD560 \uB54C",confidence:.88,conjugationType:"temporal-ttae"},{pattern:"\uD558\uBA74",confidence:.88,conjugationType:"conditional-myeon"},{pattern:"\uD558\uC600\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past"},{pattern:"\uD588\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past"},{pattern:"\uD569\uB2C8\uB2E4",confidence:.85,conjugationType:"polite"},{pattern:"\uD558\uC2ED\uC2DC\uC624",confidence:.85,conjugationType:"honorific"},{pattern:"\uD558\uC138\uC694",confidence:.85,conjugationType:"honorific"},{pattern:"\uD588\uC5B4\uC694",confidence:.85,conjugationType:"past"},{pattern:"\uD574\uC694",confidence:.85,conjugationType:"polite"},{pattern:"\uD588\uC5B4",confidence:.85,conjugationType:"past"},{pattern:"\uD574",confidence:.8,conjugationType:"present"},{pattern:"\uD558\uACE0\uC788\uC5B4\uC694",confidence:.82,conjugationType:"progressive"},{pattern:"\uD558\uACE0\uC788\uC5B4",confidence:.82,conjugationType:"progressive"},{pattern:"\uD558\uACE0\uC788\uB2E4",confidence:.82,conjugationType:"progressive"},{pattern:"\uD574\uC11C",confidence:.82,conjugationType:"connective"},{pattern:"\uD558\uACE0",confidence:.8,conjugationType:"connective"},{pattern:"\uD558\uC9C0\uC54A\uC544\uC694",confidence:.82,conjugationType:"negative"},{pattern:"\uD558\uC9C0\uC54A\uB2E4",confidence:.82,conjugationType:"negative"},{pattern:"\uC548\uD574\uC694",confidence:.82,conjugationType:"negative"},{pattern:"\uC548\uD574",confidence:.82,conjugationType:"negative"},{pattern:"\uD574\uB77C",confidence:.82,conjugationType:"imperative"},{pattern:"\uD558\uB77C",confidence:.82,conjugationType:"imperative"},{pattern:"\uD558\uB2E4",confidence:.88,conjugationType:"dictionary"}],Yt=class{constructor(){this.language="ko";}isNormalizable(t){return !(!Ju(t)||t.length<2)}normalize(t){let e=this.normalizeCompound(t);if(e)return e;let r=this.tryHadaNormalization(t);if(r)return r;for(let i of Qu)if(t.endsWith(i.pattern)){let n=t.slice(0,-i.pattern.length),a=i.minStemLength??2;if(n.length<a)continue;let o={removedSuffixes:[i.pattern]};return i.conjugationType&&(o.conjugationType=i.conjugationType),pe(n,i.confidence,o)}return rr(t)}tryHadaNormalization(t){for(let e of es)if(t.endsWith(e.pattern)){let r=t.slice(0,-e.pattern.length);if(r.length<1)continue;return pe(r,e.confidence,{removedSuffixes:[e.pattern],conjugationType:e.conjugationType,originalForm:"hada-verb"})}return null}normalizeCompound(t){let e=[{pattern:"\uD558\uACE0\uB098\uC11C\uC600\uC5B4",suffixes:["\uD558\uACE0\uB098\uC11C","\uC600\uC5B4"],confidence:.78,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C\uC600\uB2E4",suffixes:["\uD558\uACE0\uB098\uC11C","\uC600\uB2E4"],confidence:.78,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C",suffixes:["\uD558\uACE0","\uB098\uC11C"],confidence:.85,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uC5B4",suffixes:["\uD574\uC57C","\uD588\uC5B4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uB2E4",suffixes:["\uD574\uC57C","\uD588\uB2E4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uC2B5\uB2C8\uB2E4",suffixes:["\uD574\uC57C","\uD588\uC2B5\uB2C8\uB2E4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD558\uC2DC\uBA74\uC11C",suffixes:["\uD558\uC2DC","\uBA74\uC11C"],confidence:.82,conjugationType:"connective",minStemLength:2},{pattern:"\uD558\uC2DC\uBA70",suffixes:["\uD558\uC2DC","\uBA70"],confidence:.82,conjugationType:"connective",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5C8\uC5B4",suffixes:["\uD558\uACE0","\uC788\uC5C8\uC5B4"],confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5C8\uB2E4",suffixes:["\uD558\uACE0","\uC788\uC5C8\uB2E4"],confidence:.8,conjugationType:"progressive",minStemLength:2}];for(let{pattern:r,suffixes:i,confidence:n,conjugationType:a,minStemLength:o}of e)if(t.endsWith(r)){let u=t.slice(0,-r.length);if(u.length<o)continue;return pe(u,n,{removedSuffixes:i,conjugationType:a})}return null}},Zt={code:"ko",name:"Korean",nativeName:"\uD55C\uAD6D\uC5B4",regions:["east-asian","priority"],direction:"ltr",script:"hangul",wordOrder:"SOV",markingStrategy:"particle",usesSpaces:true,verb:{position:"end",suffixes:["\uB2E4","\uC694","\uB2C8\uB2E4","\uC138\uC694"],subjectDrop:true},references:{me:"\uB098",it:"\uADF8\uAC83",you:"\uB108",result:"\uACB0\uACFC",event:"\uC774\uBCA4\uD2B8",target:"\uB300\uC0C1",body:"\uBC14\uB514",document:"\uBB38\uC11C",window:"\uCC3D",detail:"\uC138\uBD80"},possessive:{marker:"\uC758",markerPosition:"between",specialForms:{me:"\uB0B4",it:"\uADF8\uAC83\uC758",you:"\uB124"},keywords:{\uB0B4:"me",\uB124:"you",\uADF8\uC758:"it"}},roleMarkers:{patient:{primary:"\uC744",alternatives:["\uB97C"],position:"after"},destination:{primary:"\uC5D0",alternatives:["\uC73C\uB85C","\uB85C","\uC758"],position:"after"},source:{primary:"\uC5D0\uC11C",alternatives:["\uBD80\uD130"],position:"after"},style:{primary:"\uB85C",alternatives:["\uC73C\uB85C"],position:"after"},event:{primary:"\uC744",alternatives:["\uB97C"],position:"after"}},keywords:{toggle:{primary:"\uD1A0\uAE00",normalized:"toggle"},add:{primary:"\uCD94\uAC00",normalized:"add"},remove:{primary:"\uC81C\uAC70",alternatives:["\uC0AD\uC81C"],normalized:"remove"},put:{primary:"\uB123\uB2E4",alternatives:["\uB123\uAE30","\uB193\uAE30","\uB123\uC73C\uC138\uC694"],normalized:"put"},append:{primary:"\uB367\uBD99\uC774\uB2E4",alternatives:["\uB05D\uC5D0\uCD94\uAC00"],normalized:"append"},prepend:{primary:"\uC55E\uC5D0\uCD94\uAC00",alternatives:["\uC120\uB450\uCD94\uAC00"],normalized:"prepend"},take:{primary:"\uAC00\uC838\uC624\uB2E4",alternatives:["\uAC00\uC838\uC624\uC138\uC694"],normalized:"take"},make:{primary:"\uB9CC\uB4E4\uB2E4",normalized:"make"},clone:{primary:"\uBCF5\uC81C",normalized:"clone"},swap:{primary:"\uAD50\uD658",alternatives:["\uBC14\uAFB8\uB2E4"],normalized:"swap"},morph:{primary:"\uBCC0\uD615",alternatives:["\uBCC0\uD658"],normalized:"morph"},set:{primary:"\uC124\uC815",normalized:"set"},get:{primary:"\uC5BB\uB2E4",alternatives:["\uC5BB\uC73C\uC138\uC694"],normalized:"get"},increment:{primary:"\uC99D\uAC00",normalized:"increment"},decrement:{primary:"\uAC10\uC18C",normalized:"decrement"},log:{primary:"\uB85C\uADF8",normalized:"log"},show:{primary:"\uBCF4\uC774\uB2E4",alternatives:["\uD45C\uC2DC","\uBCF4\uC774\uAE30","\uBCF4\uC774\uC138\uC694"],normalized:"show"},hide:{primary:"\uC228\uAE30\uB2E4",alternatives:["\uC228\uAE30\uAE30","\uC228\uAE30\uC138\uC694"],normalized:"hide"},transition:{primary:"\uD2B8\uB79C\uC9C0\uC158",alternatives:["\uC804\uD658"],normalized:"transition"},on:{primary:"\uC5D0",alternatives:["\uC2DC","\uD560 \uB54C"],normalized:"on"},trigger:{primary:"\uD2B8\uB9AC\uAC70",normalized:"trigger"},send:{primary:"\uBCF4\uB0B4\uB2E4",alternatives:["\uBCF4\uB0B4\uC138\uC694"],normalized:"send"},focus:{primary:"\uD3EC\uCEE4\uC2A4",normalized:"focus"},blur:{primary:"\uBE14\uB7EC",normalized:"blur"},empty:{primary:"\uBE44\uC6B0\uAE30",alternatives:["\uBE44\uC5B4\uC788\uB294"],normalized:"empty"},open:{primary:"\uC5F4\uAE30",normalized:"open"},close:{primary:"\uB2EB\uAE30",normalized:"close"},select:{primary:"\uACE0\uB974\uAE30",normalized:"select"},clear:{primary:"\uC9C0\uC6B0\uAE30",normalized:"clear"},reset:{primary:"\uC7AC\uC124\uC815",normalized:"reset"},breakpoint:{primary:"\uC911\uB2E8\uC810",normalized:"breakpoint"},click:{primary:"\uD074\uB9AD",normalized:"click"},hover:{primary:"\uD638\uBC84",normalized:"hover"},submit:{primary:"\uC81C\uCD9C",normalized:"submit"},input:{primary:"\uC785\uB825",normalized:"input"},change:{primary:"\uBCC0\uACBD",normalized:"change"},go:{primary:"\uC774\uB3D9",normalized:"go"},scroll:{primary:"\uC2A4\uD06C\uB864",normalized:"scroll"},push:{primary:"\uD478\uC2DC",normalized:"push"},replace:{primary:"\uAD50\uCCB4",alternatives:["\uBC14\uAFB8\uAE30"],normalized:"replace"},process:{primary:"\uCC98\uB9AC",normalized:"process"},wait:{primary:"\uB300\uAE30",normalized:"wait"},fetch:{primary:"\uD328\uCE58",alternatives:["\uAC00\uC838\uC624\uAE30"],normalized:"fetch"},settle:{primary:"\uC548\uC815",normalized:"settle"},if:{primary:"\uB9CC\uC57D",normalized:"if"},when:{primary:"\uB54C",normalized:"when"},where:{primary:"\uC5B4\uB514",normalized:"where"},else:{primary:"\uC544\uB2C8\uBA74",normalized:"else"},unless:{primary:"\uC544\uB2C8\uB77C\uBA74",normalized:"unless"},repeat:{primary:"\uBC18\uBCF5",normalized:"repeat"},for:{primary:"\uAC01\uAC01",normalized:"for"},while:{primary:"\uB3D9\uC548",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"\uACC4\uC18D",normalized:"continue"},halt:{primary:"\uC815\uC9C0",normalized:"halt"},throw:{primary:"\uB358\uC9C0\uB2E4",normalized:"throw"},call:{primary:"\uD638\uCD9C",normalized:"call"},return:{primary:"\uBC18\uD658",normalized:"return"},then:{primary:"\uADF8\uB2E4\uC74C",alternatives:["\uADF8\uB7F0\uD6C4"],normalized:"then"},and:{primary:"\uADF8\uB9AC\uACE0",alternatives:["\uB610\uD55C","\uBC0F"],normalized:"and"},matches:{primary:"\uC77C\uCE58",normalized:"matches"},exists:{primary:"\uC874\uC7AC",normalized:"exists"},no:{primary:"\uC5C6\uC74C",normalized:"no"},end:{primary:"\uB05D",alternatives:["\uB9C8\uCE68"],normalized:"end"},js:{primary:"JS\uC2E4\uD589",alternatives:["js"],normalized:"js"},async:{primary:"\uBE44\uB3D9\uAE30",normalized:"async"},tell:{primary:"\uB9D0\uD558\uB2E4",normalized:"tell"},default:{primary:"\uAE30\uBCF8\uAC12",normalized:"default"},init:{primary:"\uCD08\uAE30\uD654",normalized:"init"},behavior:{primary:"\uB3D9\uC791",normalized:"behavior"},install:{primary:"\uC124\uCE58",normalized:"install"},measure:{primary:"\uCE21\uC815",normalized:"measure"},beep:{primary:"\uBE44\uD504",normalized:"beep"},break:{primary:"\uC911\uB2E8",normalized:"break"},copy:{primary:"\uBCF5\uC0AC",normalized:"copy"},exit:{primary:"\uB098\uAC00\uAE30",normalized:"exit"},pick:{primary:"\uC120\uD0DD",normalized:"pick"},render:{primary:"\uB80C\uB354\uB9C1",normalized:"render"},into:{primary:"\uC73C\uB85C",normalized:"into"},before:{primary:"\uC804\uC5D0",normalized:"before"},after:{primary:"\uD6C4\uC5D0",normalized:"after"},until:{primary:"\uAE4C\uC9C0",normalized:"until"},event:{primary:"\uC774\uBCA4\uD2B8",normalized:"event"},from:{primary:"\uC5D0\uC11C",normalized:"from"},connect:{primary:"\uC5F0\uACB0",alternatives:["\uC811\uC18D"],normalized:"connect"},stream:{primary:"\uC2A4\uD2B8\uB9BC",alternatives:["\uC2A4\uD2B8\uB9AC\uBC0D"],normalized:"stream"},live:{primary:"\uC2E4\uC2DC\uAC04",alternatives:["\uB77C\uC774\uBE0C"],normalized:"live"},socket:{primary:"\uC18C\uCF13",alternatives:["websocket"],normalized:"socket"},bind:{primary:"\uBC14\uC778\uB4DC",alternatives:["bind"],normalized:"bind"},intercept:{primary:"\uAC00\uB85C\uCC44\uAE30",alternatives:["\uC778\uD130\uC149\uD2B8","intercept"],normalized:"intercept"},worker:{primary:"\uC6CC\uCEE4",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\uC774\uBCA4\uD2B8\uC18C\uC2A4"],normalized:"eventsource"}},tokenization:{particles:["\uC744","\uB97C","\uC774","\uAC00","\uC740","\uB294","\uC5D0","\uC5D0\uC11C","\uC73C\uB85C","\uB85C","\uC640","\uACFC","\uB3C4"],boundaryStrategy:"space"},eventHandler:{eventMarker:{primary:"\uD560 \uB54C",alternatives:["\uD560\uB54C","\uB54C","\uC5D0"],position:"after"},temporalMarkers:["\uD560 \uB54C","\uD560\uB54C","\uB54C"]}},rs=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],ts=class{constructor(t=rs){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}},is="()[]{},:;",ns=class{constructor(t=is){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 Tr(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 Kt(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Tr(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=Tr(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=Tr(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 as=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Kt(t,e)!==null:false}extract(t,e){let r=Kt(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},os=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}}}},us=["http://","https://","//","./","../","/"];function ss(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 ls(t,e){let r=t.slice(e),i=us.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=ss(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var cs=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=ls(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},ms=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 ds(t){let e=t.charCodeAt(0);return e>=44032&&e<=55203}function ps(t){let e=t.charCodeAt(0);return e>=4352&&e<=4607||e>=12592&&e<=12687}function Fr(t){return ds(t)||ps(t)}var fs=["\uD560\uB54C","\uD558\uBA74","\uD558\uB2C8\uAE4C","\uD560 \uB54C"],ys=class{constructor(){this.name="korean-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Fr(t[e])}extract(t,e){if(!this.context)throw new Error("KoreanKeywordExtractor: context not set");let r=e,i=6;for(let m=Math.min(i,t.length-r);m>=2;m--){let d=t.slice(r,r+m),p=true;for(let E=0;E<d.length;E++)if(!Fr(d[E])){p=false;break}if(!p)continue;let y=this.context.lookupKeyword(d);if(y)return {value:d,length:m,metadata:{normalized:y.normalized!==y.native?y.normalized:void 0}};if(this.context.normalizer){let E=this.context.normalizer.normalize(d);if(E.stem!==d&&E.confidence>=.7){let v=this.context.lookupKeyword(E.stem);if(v)return {value:d,length:m,metadata:{normalized:v.normalized,stem:E.stem,stemConfidence:E.confidence}}}}}let n="",a=e;for(;a<t.length&&Fr(t[a])&&!(n.length>0&&this.context.isKeywordStart(t,a));)n+=t[a],a++;if(!n)return null;for(let m of fs)if(n.endsWith(m)&&n.length>m.length){let d=n.slice(0,-m.length),p=this.context.lookupKeyword(d);if(p)return {value:d,length:d.length,metadata:{normalized:p.normalized,hasSuffix:true,suffix:m,stem:d}}}let o=this.context.lookupKeyword(n),u=o&&o.normalized!==o.native?o.normalized:void 0;n.includes("\uD1A0\uAE00")&&(console.log(`[KO DEBUG] word="${n}"`),console.log(`[KO DEBUG] keywordEntry=${o?"FOUND":"NOT FOUND"}`),console.log(`[KO DEBUG] normalizer=${this.context.normalizer?"EXISTS":"MISSING"}`));let s,l,c;if(!o&&this.context.normalizer){let m=this.context.normalizer.normalize(n);if(m.stem!==n&&m.confidence>=.7){let d=this.context.lookupKeyword(m.stem);d&&(s=d.normalized,l=m.stem,c=m.confidence,n.includes("\uD1A0\uAE00")&&console.log(`[KO DEBUG] word="${n}", stem="${m.stem}", normalized="${s}"`));}}return {value:n,length:a-r,metadata:{normalized:u||s,stem:l,stemConfidence:c}}}},Ut=new Map([["\uC774",{role:"agent",confidence:.85,variant:"consonant",description:"subject marker (after consonant)"}],["\uAC00",{role:"agent",confidence:.85,variant:"vowel",description:"subject marker (after vowel)"}],["\uC744",{role:"patient",confidence:.95,variant:"consonant",description:"object marker (after consonant)"}],["\uB97C",{role:"patient",confidence:.95,variant:"vowel",description:"object marker (after vowel)"}],["\uC740",{role:"agent",confidence:.75,variant:"consonant",description:"topic marker (after consonant)"}],["\uB294",{role:"agent",confidence:.75,variant:"vowel",description:"topic marker (after vowel)"}],["\uC5D0",{role:"destination",confidence:.85,description:"at/to marker"}],["\uB85C",{role:"destination",confidence:.85,variant:"vowel",description:"to/by means (after vowel or \u3139)"}],["\uC640",{role:"style",confidence:.7,variant:"vowel",description:"and/with (after vowel)"}],["\uACFC",{role:"style",confidence:.7,variant:"consonant",description:"and/with (after consonant)"}],["\uC758",{role:"patient",confidence:.6,description:"possessive marker"}],["\uB3C4",{role:"patient",confidence:.65,description:"also/too marker"}],["\uB9CC",{role:"patient",confidence:.65,description:"only marker"}]]),Ht=new Map([["\uC5D0\uC11C",{role:"source",confidence:.8,description:"at/from marker (action location)"}],["\uC73C\uB85C",{role:"destination",confidence:.85,variant:"consonant",description:"to/by means (after consonant)"}],["\uBD80\uD130",{role:"source",confidence:.9,description:"from/since marker"}],["\uAE4C\uC9C0",{role:"destination",confidence:.75,description:"until/to marker"}],["\uCC98\uB7FC",{role:"manner",confidence:.8,description:"like/as marker"}],["\uBCF4\uB2E4",{role:"source",confidence:.75,description:"than marker"}]]);function Gt(t){if(!t)return false;let e=t.codePointAt(0);return e>=44032&&e<=55203}var hs=class{constructor(){this.name="korean-particle";}setContext(t){this._context=t,this._context;}canExtract(t,e){let r=t[e];if(Ut.has(r)&&!Gt(t[e+1]))return true;for(let[i]of Ht)if(t.startsWith(i,e))return true;return false}extract(t,e){for(let[n,a]of Ht)if(t.startsWith(n,e))return {value:n,length:n.length,metadata:{particleRole:a.role,particleConfidence:a.confidence,particleVariant:a.variant}};let r=t[e],i=Ut.get(r);return i&&!Gt(t[e+1])?{value:r,length:1,metadata:{particleRole:i.role,particleConfidence:i.confidence,particleVariant:i.variant}}:null}};function vs(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Es(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var gs=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return vs(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",n=e;for(;n<t.length&&Es(t[n]);)i+=t[n],n++;if(!i)return null;let a=this.context.lookupKeyword(i),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:n-r,metadata:{normalized:o}}}};function Cs(){return [new cs,new os,new ms,new as]}var zs=new Set(["\uC774","\uAC00","\uC744","\uB97C","\uC740","\uB294","\uC5D0","\uC5D0\uC11C","\uB85C","\uC73C\uB85C","\uC640","\uACFC","\uC758","\uB3C4","\uB9CC","\uBD80\uD130","\uAE4C\uC9C0","\uCC98\uB7FC","\uBCF4\uB2E4"]),ks=[{native:"\uCC38",normalized:"true"},{native:"\uAC70\uC9D3",normalized:"false"},{native:"\uB110",normalized:"null"},{native:"\uBBF8\uC815\uC758",normalized:"undefined"},{native:"\uC815\uC758\uC548\uB428",normalized:"undefined"},{native:"\uCCAB\uBC88\uC9F8",normalized:"first"},{native:"\uB9C8\uC9C0\uB9C9",normalized:"last"},{native:"\uB2E4\uC74C",normalized:"next"},{native:"\uC774\uC804",normalized:"previous"},{native:"\uAC00\uC7A5\uAC00\uAE4C\uC6B4",normalized:"closest"},{native:"\uBD80\uBAA8",normalized:"parent"},{native:"\uC548\uC5D0",normalized:"in"},{native:"\uD074\uB9AD",normalized:"click"},{native:"\uB354\uBE14\uD074\uB9AD",normalized:"dblclick"},{native:"\uBCC0\uACBD",normalized:"change"},{native:"\uC81C\uCD9C",normalized:"submit"},{native:"\uC785\uB825",normalized:"input"},{native:"\uB85C\uB4DC",normalized:"load"},{native:"\uC2A4\uD06C\uB864",normalized:"scroll"},{native:"\uD0A4\uB2E4\uC6B4",normalized:"keydown"},{native:"\uD0A4\uC5C5",normalized:"keyup"},{native:"\uB9C8\uC6B0\uC2A4\uC624\uBC84",normalized:"mouseover"},{native:"\uB9C8\uC6B0\uC2A4\uC544\uC6C3",normalized:"mouseout"},{native:"\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4",normalized:"mousedown"},{native:"\uB9C8\uC6B0\uC2A4\uC5C5",normalized:"mouseup"},{native:"\uB0B4",normalized:"my"},{native:"\uADF8\uAC83\uC758",normalized:"its"},{native:"\uADF8\uB2E4\uC74C",normalized:"then"},{native:"\uADF8\uB7F0\uD6C4",normalized:"then"},{native:"\uADF8\uB7EC\uBA74",normalized:"then"},{native:"\uADF8\uB9AC\uACE0",normalized:"and"},{native:"\uB610\uB294",normalized:"or"},{native:"\uC544\uB2C8",normalized:"not"},{native:"\uC774\uB2E4",normalized:"is"},{native:"\uCD08",normalized:"s"},{native:"\uBC00\uB9AC\uCD08",normalized:"ms"},{native:"\uBD84",normalized:"m"},{native:"\uC2DC\uAC04",normalized:"h"},{native:"\uD3EC\uD568",normalized:"inclusive"},{native:"\uC81C\uC678",normalized:"exclusive"},{native:"\uBB38\uC790",normalized:"characters"},{native:"\uBB34\uC791\uC704",normalized:"random"}],ws=class extends Te{constructor(){super(),this.language="ko",this.direction="ltr",this.initializeKeywordsFromProfile(Zt,ks),this.normalizer=new Yt,this.registerExtractors(Cs()),this.registerExtractor(new Se),this.registerExtractor(new xe),this.registerExtractor(new gs),this.registerExtractor(new hs),this.registerExtractor(new ys),this.registerExtractor(new ts),this.registerExtractor(new ns);}classifyToken(t){return zs.has(t)?"particle":this.isKeyword(t)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(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":"identifier"}},bs=new ws;Ne("ko",bs,Zt);var ei={code:"zh",name:"Chinese",nativeName:"\u4E2D\u6587",regions:["east-asian","priority"],direction:"ltr",script:"cjk",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:false,verb:{position:"second",subjectDrop:true},references:{me:"\u6211",it:"\u5B83",you:"\u4F60",result:"\u7ED3\u679C",event:"\u4E8B\u4EF6",target:"\u76EE\u6807",body:"\u4E3B\u4F53",document:"\u6587\u6863",window:"\u7A97\u53E3",detail:"\u8BE6\u60C5"},possessive:{marker:"\u7684",markerPosition:"between",keywords:{\u6211\u7684:"me",\u4F60\u7684:"you",\u5B83\u7684:"it",\u4ED6\u7684:"it",\u5979\u7684:"it"}},roleMarkers:{destination:{primary:"\u5728",alternatives:["\u5230","\u4E8E"],position:"before"},source:{primary:"\u4ECE",alternatives:["\u7531"],position:"before"},patient:{primary:"\u628A",position:"before"},style:{primary:"\u7528",alternatives:["\u4EE5"],position:"before"}},keywords:{toggle:{primary:"\u5207\u6362",normalized:"toggle"},add:{primary:"\u6DFB\u52A0",alternatives:["\u52A0"],normalized:"add"},remove:{primary:"\u79FB\u9664",alternatives:["\u5220\u9664","\u53BB\u6389"],normalized:"remove"},put:{primary:"\u653E\u7F6E",alternatives:["\u653E","\u653E\u5165"],normalized:"put"},append:{primary:"\u8FFD\u52A0",alternatives:["\u9644\u52A0"],normalized:"append"},prepend:{primary:"\u524D\u7F6E",alternatives:["\u9884\u7F6E"],normalized:"prepend"},take:{primary:"\u62FF\u53D6",normalized:"take"},make:{primary:"\u5236\u4F5C",normalized:"make"},clone:{primary:"\u514B\u9686",normalized:"clone"},swap:{primary:"\u4EA4\u6362",normalized:"swap"},morph:{primary:"\u53D8\u5F62",alternatives:["\u8F6C\u6362"],normalized:"morph"},set:{primary:"\u8BBE\u7F6E",alternatives:["\u8BBE\u5B9A"],normalized:"set"},get:{primary:"\u83B7\u53D6",alternatives:["\u83B7\u5F97","\u53D6\u5F97"],normalized:"get"},increment:{primary:"\u589E\u52A0",normalized:"increment"},decrement:{primary:"\u51CF\u5C11",normalized:"decrement"},log:{primary:"\u65E5\u5FD7",normalized:"log"},show:{primary:"\u663E\u793A",alternatives:["\u5C55\u793A"],normalized:"show"},hide:{primary:"\u9690\u85CF",normalized:"hide"},transition:{primary:"\u8FC7\u6E21",normalized:"transition"},on:{primary:"\u5F53",alternatives:["\u5728...\u65F6"],normalized:"on"},trigger:{primary:"\u89E6\u53D1",normalized:"trigger"},send:{primary:"\u53D1\u9001",normalized:"send"},focus:{primary:"\u805A\u7126",normalized:"focus"},blur:{primary:"\u5931\u7126",normalized:"blur"},empty:{primary:"\u6E05\u7A7A",alternatives:["\u7A7A\u7684"],normalized:"empty"},open:{primary:"\u6253\u5F00",normalized:"open"},close:{primary:"\u5173\u95ED",normalized:"close"},select:{primary:"\u9009\u62E9",normalized:"select"},clear:{primary:"\u6E05\u9664",normalized:"clear"},reset:{primary:"\u91CD\u7F6E",normalized:"reset"},breakpoint:{primary:"\u65AD\u70B9",normalized:"breakpoint"},click:{primary:"\u70B9\u51FB",normalized:"click"},hover:{primary:"\u60AC\u505C",alternatives:["\u60AC\u6D6E"],normalized:"hover"},submit:{primary:"\u63D0\u4EA4",normalized:"submit"},input:{primary:"\u8F93\u5165",normalized:"input"},change:{primary:"\u6539\u53D8",alternatives:["\u53D8\u5316"],normalized:"change"},go:{primary:"\u524D\u5F80",normalized:"go"},scroll:{primary:"\u6EDA\u52A8",normalized:"scroll"},push:{primary:"\u63A8\u9001",normalized:"push"},replace:{primary:"\u66FF\u6362",normalized:"replace"},process:{primary:"\u5904\u7406",normalized:"process"},wait:{primary:"\u7B49\u5F85",normalized:"wait"},fetch:{primary:"\u6293\u53D6",normalized:"fetch"},settle:{primary:"\u7A33\u5B9A",normalized:"settle"},if:{primary:"\u5982\u679C",normalized:"if"},unless:{primary:"\u9664\u975E",normalized:"unless"},when:{primary:"\u4F55\u65F6",normalized:"when"},where:{primary:"\u54EA\u91CC",normalized:"where"},else:{primary:"\u5426\u5219",normalized:"else"},matches:{primary:"\u5339\u914D",normalized:"matches"},repeat:{primary:"\u91CD\u590D",normalized:"repeat"},for:{primary:"\u4E3A",normalized:"for"},while:{primary:"\u6301\u7EED",normalized:"while"},continue:{primary:"\u7EE7\u7EED",normalized:"continue"},halt:{primary:"\u505C\u6B62",normalized:"halt"},throw:{primary:"\u629B\u51FA",normalized:"throw"},call:{primary:"\u8C03\u7528",normalized:"call"},return:{primary:"\u8FD4\u56DE",normalized:"return"},then:{primary:"\u7136\u540E",alternatives:["\u63A5\u7740","\u90A3\u4E48"],normalized:"then"},and:{primary:"\u5E76\u4E14",alternatives:["\u548C","\u800C\u4E14"],normalized:"and"},exists:{primary:"\u5B58\u5728",normalized:"exists"},end:{primary:"\u7ED3\u675F",alternatives:["\u7EC8\u6B62","\u5B8C"],normalized:"end"},js:{primary:"JS\u6267\u884C",alternatives:["js"],normalized:"js"},async:{primary:"\u5F02\u6B65",normalized:"async"},tell:{primary:"\u544A\u8BC9",normalized:"tell"},default:{primary:"\u9ED8\u8BA4",normalized:"default"},init:{primary:"\u521D\u59CB\u5316",normalized:"init"},behavior:{primary:"\u884C\u4E3A",normalized:"behavior"},install:{primary:"\u5B89\u88C5",normalized:"install"},measure:{primary:"\u6D4B\u91CF",normalized:"measure"},beep:{primary:"\u8702\u9E23",normalized:"beep"},break:{primary:"\u4E2D\u65AD",normalized:"break"},copy:{primary:"\u590D\u5236",normalized:"copy"},exit:{primary:"\u9000\u51FA",normalized:"exit"},pick:{primary:"\u9009\u53D6",normalized:"pick"},render:{primary:"\u6E32\u67D3",normalized:"render"},into:{primary:"\u8FDB\u5165",normalized:"into"},before:{primary:"\u4E4B\u524D",normalized:"before"},after:{primary:"\u4E4B\u540E",normalized:"after"},until:{primary:"\u76F4\u5230",normalized:"until"},event:{primary:"\u4E8B\u4EF6",normalized:"event"},from:{primary:"\u4ECE",normalized:"from"},connect:{primary:"\u8FDE\u63A5",alternatives:["\u8FDE\u63A5\u5668"],normalized:"connect"},stream:{primary:"\u6D41",alternatives:["\u6D41\u5F0F\u4F20\u8F93"],normalized:"stream"},live:{primary:"\u5B9E\u65F6",alternatives:["\u76F4\u64AD"],normalized:"live"},socket:{primary:"\u5957\u63A5\u5B57",alternatives:["websocket","socket"],normalized:"socket"},bind:{primary:"\u7ED1\u5B9A",alternatives:["bind"],normalized:"bind"},intercept:{primary:"\u62E6\u622A",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"\u5DE5\u4F5C\u7EBF\u7A0B",alternatives:["\u5DE5\u4F5C\u8005","worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u4E8B\u4EF6\u6E90"],normalized:"eventsource"}},tokenization:{boundaryStrategy:"character"},eventHandler:{keyword:{primary:"\u5F53",alternatives:["\u5728...\u65F6"],normalized:"on"},sourceMarker:{primary:"\u4ECE",position:"before"},eventMarker:{primary:"\u5F53",alternatives:["\u5728"],position:"before"},temporalMarkers:["\u5F53","\u5728...\u65F6"]}},As=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Ds=class{constructor(t=As){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}},Bs="()[]{},:;",Ss=class{constructor(t=Bs){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 Rr(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 Xt(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Rr(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=Rr(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=Rr(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 xs=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Xt(t,e)!==null:false}extract(t,e){let r=Xt(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Ts=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}}}},Fs=["http://","https://","//","./","../","/"];function Rs(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 Os(t,e){let r=t.slice(e),i=Fs.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=Rs(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var Ls=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=Os(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Ps=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 Or(t){let e=t.charCodeAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=63744&&e<=64255||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=183984&&e<=191471||e>=194560&&e<=195103}var Ns=class{constructor(){this.name="chinese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Or(t[e])}extract(t,e){if(!this.context)throw new Error("ChineseKeywordExtractor: context not set");let r=e,i=null;if(this.context.isKeywordStart(t,e))for(let o=10;o>=1;o--){let u=t.slice(e,e+o);if([...u].every(s=>Or(s))){let s=this.context.lookupKeyword(u);if(s){i={word:u,entry:s};break}}}if(i)return {value:i.word,length:i.word.length,metadata:{normalized:i.entry.normalized}};let n="",a=e;for(;a<t.length&&Or(t[a])&&(n+=t[a],a++,!(a<t.length&&this.context.isKeywordStart(t,a))););return n?{value:n,length:a-r,metadata:{}}:null}},Jt=new Map([["\u628A",{role:"patient",confidence:.95,description:"ba-construction object marker"}],["\u5728",{role:"location",confidence:.85,description:"at/in/on location marker"}],["\u4ECE",{role:"source",confidence:.9,description:"from marker"}],["\u5230",{role:"destination",confidence:.9,description:"to/until marker"}],["\u5411",{role:"destination",confidence:.85,description:"towards marker"}],["\u7ED9",{role:"destination",confidence:.85,description:"to/for recipient marker"}],["\u5BF9",{role:"destination",confidence:.8,description:"to/towards marker"}],["\u7528",{role:"instrument",confidence:.85,description:"with/using marker"}],["\u88AB",{role:"agent",confidence:.8,description:"by (passive) marker"}],["\u8BA9",{role:"agent",confidence:.75,description:"let/make causative marker"}],["\u7684",{role:"possessive",confidence:.9,description:"possessive/attributive marker"}],["\u5730",{role:"manner",confidence:.85,description:"adverbial marker"}],["\u5F97",{role:"manner",confidence:.8,description:"complement marker"}],["\u4E86",{role:"aspect",confidence:.7,description:"completion aspect marker"}],["\u7740",{role:"aspect",confidence:.7,description:"progressive aspect marker"}],["\u8FC7",{role:"aspect",confidence:.7,description:"experiential aspect marker"}],["\u5417",{role:"mood",confidence:.75,description:"question particle"}],["\u5462",{role:"mood",confidence:.7,description:"question/emphasis particle"}],["\u5427",{role:"mood",confidence:.7,description:"suggestion particle"}]]),Qt=new Map([["\u7136\u540E",{role:"sequence",confidence:.9,description:"then/afterwards"}],["\u63A5\u7740",{role:"sequence",confidence:.85,description:"next/following"}],["\u5E76\u4E14",{role:"conjunction",confidence:.85,description:"and/moreover"}],["\u6216\u8005",{role:"conjunction",confidence:.85,description:"or"}],["\u5982\u679C",{role:"condition",confidence:.9,description:"if"}],["\u90A3\u4E48",{role:"consequence",confidence:.85,description:"then"}],["\u5426\u5219",{role:"alternative",confidence:.85,description:"otherwise"}]]),_s=class{constructor(){this.name="chinese-particle";}setContext(t){this._context=t;}longerKeywordAt(t,e,r){let i=this._context;if(!i)return false;let n=Math.min(10,t.length-e);for(let a=n;a>r;a--)if(i.lookupKeyword(t.slice(e,e+a)))return true;return false}canExtract(t,e){let r=t[e];if(Jt.has(r)&&!this.longerKeywordAt(t,e,1))return true;for(let[i]of Qt)if(t.startsWith(i,e)&&!this.longerKeywordAt(t,e,i.length))return true;return false}extract(t,e){for(let[n,a]of Qt)if(t.startsWith(n,e)&&!this.longerKeywordAt(t,e,n.length))return {value:n,length:n.length,metadata:{particleRole:a.role,particleConfidence:a.confidence,particleDescription:a.description}};let r=t[e],i=Jt.get(r);return i&&!this.longerKeywordAt(t,e,1)?{value:r,length:1,metadata:{particleRole:i.role,particleConfidence:i.confidence,particleDescription:i.description}}:null}};function Ms(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Is(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var js=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return Ms(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",n=e;for(;n<t.length&&Is(t[n]);)i+=t[n],n++;if(!i)return null;let a=this.context.lookupKeyword(i),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:n-r,metadata:{normalized:o}}}};function $s(){return [new Ls,new Ts,new Ps,new xs]}var Vs=new Set(["\u628A","\u5728","\u4ECE","\u5230","\u5411","\u7ED9","\u5BF9","\u7528","\u88AB","\u8BA9","\u7684","\u5730","\u5F97","\u4E86","\u7740","\u8FC7","\u5417","\u5462","\u5427"]),qs=[{native:"\u771F",normalized:"true"},{native:"\u5047",normalized:"false"},{native:"\u7A7A",normalized:"null"},{native:"\u672A\u5B9A\u4E49",normalized:"undefined"},{native:"\u7B2C\u4E00\u4E2A",normalized:"first"},{native:"\u9996\u4E2A",normalized:"first"},{native:"\u6700\u540E\u4E00\u4E2A",normalized:"last"},{native:"\u672B\u4E2A",normalized:"last"},{native:"\u4E0B\u4E00\u4E2A",normalized:"next"},{native:"\u4E0A\u4E00\u4E2A",normalized:"previous"},{native:"\u6700\u8FD1\u7684",normalized:"closest"},{native:"\u7236\u7EA7",normalized:"parent"},{native:"\u70B9\u51FB",normalized:"click"},{native:"\u53CC\u51FB",normalized:"dblclick"},{native:"\u8F93\u5165",normalized:"input"},{native:"\u53D8\u66F4",normalized:"change"},{native:"\u6539\u53D8",normalized:"change"},{native:"\u63D0\u4EA4",normalized:"submit"},{native:"\u6309\u952E",normalized:"keydown"},{native:"\u91CA\u653E\u952E",normalized:"keyup"},{native:"\u9F20\u6807\u79FB\u5165",normalized:"mouseover"},{native:"\u9F20\u6807\u79FB\u51FA",normalized:"mouseout"},{native:"\u83B7\u5F97\u7126\u70B9",normalized:"focus"},{native:"\u5931\u53BB\u7126\u70B9",normalized:"blur"},{native:"\u52A0\u8F7D",normalized:"load"},{native:"\u6EDA\u52A8",normalized:"scroll"},{native:"\u6211\u7684",normalized:"my"},{native:"\u5B83\u7684",normalized:"its"},{native:"\u79D2",normalized:"s"},{native:"\u6BEB\u79D2",normalized:"ms"},{native:"\u5206\u949F",normalized:"m"},{native:"\u5C0F\u65F6",normalized:"h"},{native:"\u548C",normalized:"and"},{native:"\u6216\u8005",normalized:"or"},{native:"\u6216",normalized:"or"},{native:"\u4E0D",normalized:"not"},{native:"\u975E",normalized:"not"},{native:"\u662F",normalized:"is"},{native:"\u82E5",normalized:"if"},{native:"\u4E0D\u7136",normalized:"else"},{native:"\u5FAA\u73AF",normalized:"repeat"},{native:"\u904D\u5386",normalized:"for"},{native:"\u6BCF\u4E2A",normalized:"for"},{native:"\u4E3A\u6BCF",normalized:"for"},{native:"\u4E2D\u6B62",normalized:"halt"},{native:"\u629B",normalized:"throw"},{native:"\u547C\u53EB",normalized:"call"},{native:"\u56DE",normalized:"return"},{native:"\u811A\u672C",normalized:"js"},{native:"\u901A\u77E5",normalized:"tell"},{native:"\u7F3A\u7701",normalized:"default"},{native:"\u521D\u59CB",normalized:"init"},{native:"\u52A8\u4F5C",normalized:"behavior"},{native:"\u6FC0\u53D1",normalized:"trigger"},{native:"\u5BF9\u7126",normalized:"focus"},{native:"\u6A21\u7CCA",normalized:"blur"},{native:"\u8DF3\u8F6C",normalized:"go"},{native:"\u5BFC\u822A",normalized:"go"},{native:"\u6293\u53D6",normalized:"fetch"},{native:"\u83B7\u53D6\u6570\u636E",normalized:"fetch"},{native:"\u5B89\u5B9A",normalized:"settle"},{native:"\u62FF\u53D6",normalized:"take"},{native:"\u53D6",normalized:"take"},{native:"\u521B\u5EFA",normalized:"make"},{native:"\u514B\u9686",normalized:"clone"},{native:"\u8BB0\u5F55",normalized:"log"},{native:"\u6253\u5370",normalized:"log"},{native:"\u52A8\u753B",normalized:"transition"},{native:"\u5230\u91CC\u9762",normalized:"into"},{native:"\u91CC",normalized:"into"},{native:"\u524D",normalized:"before"},{native:"\u540E",normalized:"after"},{native:"\u90A3\u4E48",normalized:"then"},{native:"\u5B8C",normalized:"end"},{native:"\u4F5C\u4E3A",normalized:"as"},{native:"\u5305\u542B",normalized:"inclusive"},{native:"\u6392\u9664",normalized:"exclusive"},{native:"\u5B57\u7B26",normalized:"characters"},{native:"\u968F\u673A",normalized:"random"}],Ws=class extends Te{constructor(){super(),this.language="zh",this.direction="ltr",this.initializeKeywordsFromProfile(ei,qs),this.registerExtractors($s()),this.registerExtractor(new Se),this.registerExtractor(new xe),this.registerExtractor(new js),this.registerExtractor(new _s),this.registerExtractor(new Ns),this.registerExtractor(new Ds),this.registerExtractor(new Ss);}classifyToken(t){return Vs.has(t)?"particle":this.isKeyword(t)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(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("'")||t.startsWith("\u201C")||t.startsWith("\u2018")||/^\d/.test(t)?"literal":"identifier"}},Ks=new Ws;Ne("zh",Ks,ei);function lr(t){let e=t.getAttribute("data-lang");if(e)return Lr(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return Lr(r);let i=typeof document<"u"?document.documentElement?.lang:null;return i&&i!=="en"?Lr(i):null}function Lr(t){return t.split("-")[0].toLowerCase()}var ri={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],bind:[["destination",""],["source","to"]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],eventsource:[],exit:[],fetch:[["source",""],["style","with"],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],intercept:[],js:[["patient",""]],live:[],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["patient",""],["destination","to"]],on:[["event",""],["source","from"]],open:[["style","as"],["patient",""]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"]],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"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],while:[["condition",""]],worker:[]};function cr(t){switch(t.kind){case "event-handler":return Us(t);case "compound":return Hs(t);default:return Gs(t)}}function Us(t){let e=["on"],r=t.roles.get("event");r&&e.push(Ye(r));let i=t.roles.get("source");if(i&&e.push("from",Ye(i)),t.body&&t.body.length>0){let n=t.body.map(cr);e.push(n.join(" then "));}return e.join(" ")}function Hs(t){let e=t.chainType==="async"?"async":t.chainType;return t.statements.map(cr).join(` ${e} `)}function Gs(t){let e=ri[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(Ye(o))));}return i.join(" ")}let r=[t.action];for(let[,i]of t.roles)r.push(Ye(i));return r.join(" ")}function Ye(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 Ys(t);case "expression":return t.raw;case "flag":return t.enabled?`+${t.name}`:`~${t.name}`}}function Ys(t){let e=Ye(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 ii=.5,Zs={confidenceThreshold:ii,strategy:"semantic",fallbackToOriginal:true};function Xs(t,e){return typeof t=="number"?t:t[e]??t["*"]??ii}function Pr(t,e,r={}){let i={...Zs,...r},n=ti(t,e,i);if(n!==null)return n;let a=Qs(t);if(a){let o=ti(a.commands,e,i);if(o!==null)return a.prefix+o}return t}function ti(t,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let i=Xs(r.confidenceThreshold,e),n=ni(t,e,i);if(n!==null)return n}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let i=el(t,e,r.i18nToEnglish);if(i!==null)return i}return null}var Js=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Qs(t){let e=t.match(Js);if(!e)return null;let r=e[1],i=t.slice(r.length);return i?{prefix:r,commands:i}:null}function ni(t,e,r){try{let i=tl(t,e);if(i.length>1)return il(i,e,r);if(!ht(e))return null;let n=Lt(t,e);return n.confidence<r||!n.node?null:cr(n.node)}catch{return null}}function el(t,e,r){try{let i=r(t,e);return i!==t?i:null}catch{return null}}function rl(t){let e=["then"],r=L(t);if(r?.keywords?.then){let i=r.keywords.then;if(i.primary&&i.primary!=="then"&&e.push(i.primary),i.alternatives)for(let n of i.alternatives)e.includes(n)||e.push(n);}return e}function tl(t,e){let i=rl(e).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),n=new RegExp(`\\s+(?:${i.join("|")})\\s+`,"i"),a=t.split(`
5
+ `).map(u=>u.trim()).filter(u=>u.length>0),o=[];for(let u of a){let s=u.split(n);o.push(...s);}return o}function il(t,e,r){let i=[];for(let n of t){let a=ni(n.trim(),e,r);if(a===null)return null;i.push(a);}return i.join(" then ")}function Nr(t={}){return function(r){let{internals:i}=r,n=i.runtime,a=n.getScript.bind(n);n.getScript=function(o){let u=a(o);if(!u)return null;let s=nl(o,t);if(!s||s==="en")return u;let l=Pr(u,s,t);return t.debug&&l!==u&&console.log(`[hyperscript-i18n] ${s}: "${u}" \u2192 "${l}"`),l};}}function nl(t,e){if(e.languageAttribute){let i=t.getAttribute(e.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let r=lr(t);return r||(e.defaultLanguage??null)}function ai(t,e,r={}){return e==="en"?t:Pr(t,e,r)}yt(t=>_t(t));function oi(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Nr()),al());}function al(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let r=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(r).forEach(i=>{let n=e.getInternalData(i);n.initialized&&(n.initialized=false);}),e.processNode(document.body);}var p0=["ja","ko","zh"];oi();exports.plugin=Nr;exports.preprocess=ai;exports.resolveLanguage=lr;exports.supportedLanguages=p0;return exports;})({});