@hyperscript-tools/multilingual 2.6.0 → 2.7.1

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.
@@ -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 Pe(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(Pe(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 Pe(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 Lt(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 Pt(t,e){if(e>=t.length)return null;let r=t[e];if(!Ft(r)||r==="'"&&Lt(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=Pt(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=Lr[t],u=o?gr(o,r):void 0;return {code:t,message:a,severity:e,...i&&{role:i},...u&&{suggestion:u}}}var S,Rr,Lr,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."},Lr={[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."};}}),Pr={};Wt(Pr,{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 Li(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 Pi(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}]},Ln={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Pn={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:Ln,tell:Pn,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(),Pr)).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 L{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(!L.tokenLooksLikeEvent(a))return r.optional||false;let g=(a.normalized??a.value).toLowerCase();if(L.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(L.STRUCTURAL_NEVER_EVENT.has(g))return r.optional||false}if(r.role==="duration"){let g=(a.normalized??a.value).toLowerCase();if(L.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"||L.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(!L.POSITIONAL_KEYWORDS.has(i)&&!L.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")&&!L.POSITIONAL_KEYWORDS.has((s.normalized??s.value).toLowerCase())&&!L.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?L.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||!L.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")&&!L.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++<L.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++<L.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++<L.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<L.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}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"||L.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let d=i.value,f=[],y=0;for(;y<L.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<L.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<L.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(L.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&&L.POSITIONAL_OR_SCOPE_KEYWORDS.has(u))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",m=this.currentProfile?.wordOrder!=="SOV"&&L.COMMAND_ACTION_KEYWORDS.has(l),c=!s||s.kind==="particle"||L.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),Li(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],P=(T.normalized??T.value).toLowerCase();if(!F.KNOWN_EVENTS.has(P))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:P}];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"),P=Q.matchBest(d,T);d.reset(g),P&&P.pattern.command!=="on"?(v=true,p.push(_(`bare-event mis-anchor on reference "${B}" rejected; command ${P.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],P=T&&T.kind==="keyword"&&T.normalized?.toLowerCase()==="on"?x-1:x;D=[...B.slice(0,P),...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],P=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(P(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&&P(Ce)===P(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"),P=x?.raw??x?.value;if(x&&T&&!T.expectedTypes.includes(x.type)&&D(P))O(P,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 P=x.patient;P&&P.type==="reference"&&P.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 P=o[z-1];if(P&&(P.normalized??P.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):Pi(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 La(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 Pa(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 Le={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function nr(t,e,r=Le){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=Le){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=Le){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=Le){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=Le){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=Le){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(La(t,e,a,n,r)),i.push(Na(t,e,a,n,r)),i.push(Pa(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 Lo=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}},Po=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 Po,new Mo,new Lo]}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(`
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
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;})({});