@hyperscript-tools/multilingual 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hyperscript-i18n-ar.global.js +5 -4
- package/dist/hyperscript-i18n-bn.global.js +5 -4
- package/dist/hyperscript-i18n-de.global.js +5 -4
- package/dist/hyperscript-i18n-east-asian.global.js +5 -4
- package/dist/hyperscript-i18n-en.global.js +7 -6
- package/dist/hyperscript-i18n-es.global.js +5 -4
- package/dist/hyperscript-i18n-fr.global.js +5 -4
- package/dist/hyperscript-i18n-he.global.js +5 -4
- package/dist/hyperscript-i18n-hi.global.js +5 -4
- package/dist/hyperscript-i18n-id.global.js +5 -4
- package/dist/hyperscript-i18n-it.global.js +5 -4
- package/dist/hyperscript-i18n-ja.global.js +5 -4
- package/dist/hyperscript-i18n-ko.global.js +5 -4
- package/dist/hyperscript-i18n-ms.global.js +5 -4
- package/dist/hyperscript-i18n-pl.global.js +5 -4
- package/dist/hyperscript-i18n-pt.global.js +5 -4
- package/dist/hyperscript-i18n-qu.global.js +5 -4
- package/dist/hyperscript-i18n-ru.global.js +5 -4
- package/dist/hyperscript-i18n-slavic.global.js +5 -4
- package/dist/hyperscript-i18n-south-asian.global.js +5 -4
- package/dist/hyperscript-i18n-southeast-asian.global.js +5 -4
- package/dist/hyperscript-i18n-sw.global.js +5 -4
- package/dist/hyperscript-i18n-th.global.js +5 -4
- package/dist/hyperscript-i18n-tl.global.js +5 -4
- package/dist/hyperscript-i18n-tr.global.js +5 -4
- package/dist/hyperscript-i18n-uk.global.js +5 -4
- package/dist/hyperscript-i18n-vi.global.js +5 -4
- package/dist/hyperscript-i18n-western.global.js +5 -4
- package/dist/hyperscript-i18n-zh.global.js +5 -4
- package/dist/hyperscript-i18n.global.js +34 -30
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var HyperscriptI18n=(function(exports){'use strict';function x(a,e){return e?{type:"literal",value:a,dataType:e}:{type:"literal",value:a}}function ne(a,e){return e?{type:"selector",value:a,selectorKind:e}:{type:"selector",value:a}}function H(a){return {type:"reference",value:a}}function oe(a,e){return {type:"property-path",object:a,property:e}}var xe=new Set(["me","you","it","result","event","target","body"]);function fe(a,e=xe){return e.has(a)}var wr=class{constructor(a){this.namespace=a,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let a=process.env.DEBUG||"";return a==="*"||a.includes("framework:*")||a.includes(`framework:${this.namespace}`)}return false}log(a,e,...r){if(!this.enabled)return;let t=`[framework:${this.namespace}]`,i=new Date().toISOString();switch(a){case "debug":console.debug(`${i} ${t} DEBUG:`,e,...r);break;case "info":console.info(`${i} ${t} INFO:`,e,...r);break;case "warn":console.warn(`${i} ${t} WARN:`,e,...r);break;case "error":console.error(`${i} ${t} ERROR:`,e,...r);break}}debug(a,...e){this.log("debug",a,...e);}info(a,...e){this.log("info",a,...e);}warn(a,...e){this.log("warn",a,...e);}error(a,...e){this.log("error",a,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function Cr(a){return new wr(a)}function j(a,e){return !e||e.length===0||e.includes(a)||e.includes("expression")?true:a==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function Ar(a,e){return a?.possessive?.keywords?.[e]}var Y=class q{constructor(){this.logger=Cr("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,t){let i=e.mark(),n=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let s=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)s.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",s),this.logger.debug("Profile code:",t?.code);}this.currentProfile=t,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(r.template.tokens,null,2));let o=this.matchTokenSequence(e,r.template.tokens,n);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(n.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(i),null;let u=this.calculateConfidence(r,n);return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-i.position,confidence:u}}matchBest(e,r,t){let i=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,t);s&&i.push(s),e.reset(u);}if(i.length===0)return null;i.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let n=i[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t,i){let n=r[0],o=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=null,s=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let m=e.peek();if(this.logger.debug(" >> Current input token:",m?JSON.stringify({type:m.type,value:m.value,kind:m.kind}):"EOF"),c.type==="role"&&c.greedy){let h=this.collectStopMarkers(r,l+1);if(i)for(let z of i)h.add(z);let g=[];for(;!e.isAtEnd();){let z=e.peek();if(!z||this.isStopMarker(z,h))break;g.push(z.value),e.advance();}if(g.length>0){t.set(c.role,{type:"expression",raw:g.join(" ")}),u=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let h=this.collectStopMarkers(r,l+1);if(i)for(let z of i)h.add(z);if(this.matchGroupToken(e,c,t,h)){u=null,s=null;continue}if(this.isOptional(c))continue;return false}let p=c.type==="role"&&c.optional===true,d=p?e.mark():null;if(c.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(c))continue;if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let z=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",z),z)continue}return false}}}let v=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Match result:",v),v){p?(u=d,s=c.role):(u=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let h=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}return true}matchPatternToken(e,r,t){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t);case "group":return this.matchGroupToken(e,r,t);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",t?JSON.stringify({type:t.type,value:t.value,kind:t.kind}):"null"),!t)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let i=this.getMatchType(t,r.value);if(this.logger.debug(" >>> matchType for",t.value,"vs",r.value,":",i),i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let o=this.getMatchType(t,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,t){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 i=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null"),!i)return r.optional||false;let n=this.tryMatchPossessiveExpression(e);if(n)return r.expectedTypes&&r.expectedTypes.length>0&&!j(n.type,r.expectedTypes)?r.optional||false:(t.set(r.role,n),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!j(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!j(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!j(s.type,r.expectedTypes)?r.optional||false:(t.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!j(l.type,r.expectedTypes)?r.optional||false:(t.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null");let c=this.tokenToSemanticValue(i);return this.logger.debug(" >>> tokenToSemanticValue returned:",c?JSON.stringify(c):"null"),c?(this.logger.debug(" >>> Validating type:",c.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!j(c.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),t.set(r.role,c),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=r.normalized||r.value,i=this.safeToLowerCase(t),n=Ar(this.currentProfile,i);if(!n)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),oe(H(n),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<q.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}.${n.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let t=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=`${r.value}.${n.value}`,u=1;for(;!e.isAtEnd()&&u<q.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<q.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(c===0){e.advance();break}c--;}if(p.kind==="punctuation"&&p.value==="("&&c++,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 t=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(t),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(t),null):(e.advance(),oe(ne(r.value),n.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(t),null;let n=e.peek(1);n&&n.kind,e.advance();let o=i.value.slice(1);return oe(ne(r.value),o)}matchGroupToken(e,r,t,i){let n=e.mark(),o=new Set(t.keys());if(this.matchTokenSequence(e,r.tokens,t,i))return true;e.reset(n);for(let l of t.keys())o.has(l)||t.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=q.MAX_MARKER_SCAN;l++){let c=e.peek(l);if(!c)break;if((c.normalized||c.value).toLowerCase()===s){this.logger.debug(" >> MARKER SCAN: found",s,"at offset",l,"- skipping intervening tokens");for(let d=0;d<l;d++)e.advance();if(this.matchTokenSequence(e,r.tokens,t,i))return true;e.reset(n);for(let d of t.keys())o.has(d)||t.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 t=new Set;for(let i=r;i<e.length;i++){let n=e[i];if(n.type==="literal"){if(t.add(n.value.toLowerCase()),n.alternatives)for(let o of n.alternatives)t.add(o.toLowerCase());break}if(n.type==="group"){for(let o of n.tokens)if(o.type==="literal"){if(t.add(o.value.toLowerCase()),o.alternatives)for(let u of o.alternatives)t.add(u.toLowerCase());break}if(!n.optional)break}}return t}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 ne(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return x(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return H(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return x(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return x(i,"string")}if(e==="true")return x(true,"boolean");if(e==="false")return x(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let i=parseFloat(r[1]);return r[2]?x(e,"duration"):x(i,"number")}let t=parseFloat(e);return isNaN(t)?x(e,"string"):x(t,"number")}applyExtractionRules(e,r){for(let[t,i]of Object.entries(e.extraction))r.has(t)||(i.value!==void 0?r.set(t,{type:"literal",value:i.value}):i.default&&r.set(t,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let t=0,i=0,n=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")i+=1,r.has(l.role)&&(t+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let m=n(c.role),p=.8;i+=p,r.has(c.role)?t+=p:m&&(t+=p*.6);}}let o=i>0?t/i:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let u=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+u);let s=this.arabicPrepositionDisambiguation(e,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 t=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(t.has(r.value))return .15;if(r.alternatives){for(let i of r.alternatives)if(t.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let t=0,i={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[n,o]of r.entries()){let u=i[n];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?t+=.1:t-=.1;}}return Math.max(-0.1,Math.min(.1,t))}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=this.safeToLowerCase(r.value);if(q.ENGLISH_NOISE_WORDS.has(t)){let i=e.mark();e.advance();let n=e.peek();if(n&&n.kind==="selector")return;e.reset(i);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let n=i.metadata;if(!n)break;switch(t=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return t?r:void 0}};Y.MAX_MARKER_SCAN=3;Y.MAX_PROPERTY_DEPTH=10;Y.MAX_METHOD_ARGS=20;Y.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Dr=Y;new Dr;var Fe=class{constructor(){this.name="number";}canExtract(a,e){return /\d/.test(a[e])}extract(a,e){let r=0,t=false;for(;e+r<a.length;){let o=a[e+r];if(/\d/.test(o))r++;else if(o==="."&&!t)t=true,r++;else break}if(r===0)return null;let i=a.substring(e,e+r),n=e+r;if(n<a.length){let o=a.slice(n),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value:i+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:i+"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:i+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:i+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:i,length:r}}};function Sr(a){return "setContext"in a&&typeof a.setContext=="function"}function xr(a){let e={language:a.language,direction:a.direction,lookupKeyword:a.lookupKeyword.bind(a),isKeyword:a.isKeyword.bind(a),isKeywordStart:a.isKeywordStart.bind(a)};return a.normalizer?{...e,normalizer:a.normalizer}:e}var Q=class{constructor(a,e){this.pos=0,this.tokens=a,this.language=e;}peek(a=0){let e=this.pos+a;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(a){this.pos=a.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(a){let e=[];for(;!this.isAtEnd()&&a(this.peek());)e.push(this.advance());return e}skipWhile(a){for(;!this.isAtEnd()&&a(this.peek());)this.advance();}};function k(a,e){return {start:a,end:e}}function b(a,e,r,t){if(typeof a=="object"){let{value:n,kind:o,position:u,normalized:s,stem:l,stemConfidence:c,metadata:m}=a;return {value:n,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...m!==void 0&&{metadata:m}}}let i=a;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof t=="string")return {value:i,kind:e,position:r,normalized:t};if(t){let{normalized:n,stem:o,stemConfidence:u,metadata:s}=t;return {value:i,kind:e,position:r,...n!==void 0&&{normalized:n},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:i,kind:e,position:r}}function G(a){return /\s/.test(a)}function Br(a){return a==="#"||a==="."||a==="["||a==="@"||a==="*"||a==="<"}function Tr(a){return a==='"'||a==="'"||a==="`"||a==="\u300C"||a==="\u300D"}function O(a){return /\d/.test(a)}function Fr(a){return /[a-zA-Z]/.test(a)}function A(a){return /[a-zA-Z0-9_-]/.test(a)}function Pr(a,e){if(e>=a.length)return null;let r=a[e];if(!Br(r))return null;let t=e,i="";if(r==="#"||r==="."){for(i+=a[t++];t<a.length&&A(a[t]);)i+=a[t++];if(i.length<=1)return null;if(t<a.length&&a[t]==="."&&r==="#"){let o=t+1;for(;o<a.length&&A(a[o]);)o++;if(o<a.length&&a[o]==="(")return i}}else if(r==="["){let n=1,o=false,u=null,s=false;for(i+=a[t++];t<a.length&&n>0;){let l=a[t];i+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?n++:l==="]"&&n--,t++;}if(n!==0)return null}else if(r==="@"){for(i+=a[t++];t<a.length&&A(a[t]);)i+=a[t++];if(i.length<=1)return null}else if(r==="*"){for(i+=a[t++];t<a.length&&A(a[t]);)i+=a[t++];if(i.length<=1)return null}else if(r==="<"){if(i+=a[t++],t>=a.length||!Fr(a[t]))return null;for(;t<a.length&&A(a[t]);)i+=a[t++];for(;t<a.length;){let n=a[t];if(n==="."){if(i+=a[t++],t>=a.length||!A(a[t]))return null;for(;t<a.length&&A(a[t]);)i+=a[t++];}else if(n==="#"){if(i+=a[t++],t>=a.length||!A(a[t]))return null;for(;t<a.length&&A(a[t]);)i+=a[t++];}else if(n==="["){let o=1,u=false,s=null,l=false;for(i+=a[t++];t<a.length&&o>0;){let c=a[t];i+=c,l?l=false:c==="\\"?l=true:u?c===s&&(u=false,s=null):c==='"'||c==="'"||c==="`"?(u=true,s=c):c==="["?o++:c==="]"&&o--,t++;}if(o!==0)return null}else break}for(;t<a.length&&G(a[t]);)i+=a[t++];if(t<a.length&&a[t]==="/")for(i+=a[t++];t<a.length&&G(a[t]);)i+=a[t++];if(t>=a.length||a[t]!==">")return null;i+=a[t++];}return i||null}function Rr(a,e){if(e>=a.length||a[e]!=="'"||e+1>=a.length||a[e+1].toLowerCase()!=="s")return false;if(e+2>=a.length)return true;let t=a[e+2];return G(t)||t==="*"||!A(t)}function _r(a,e){if(e>=a.length)return null;let r=a[e];if(!Tr(r)||r==="'"&&Rr(a,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!i)return null;let n=e+1,o=r,u=false;for(;n<a.length;){let s=a[n];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===i)return o;n++;}return o}function Or(a,e){if(e>=a.length)return false;let r=a[e],t=a[e+1]||"",i=a[e+2]||"";if(r==="/"&&t!=="/"&&/[a-zA-Z0-9._-]/.test(t)||r==="/"&&t==="/"&&/[a-zA-Z]/.test(i)||r==="."&&(t==="/"||t==="."&&i==="/"))return true;let n=a.slice(e,e+8).toLowerCase();return !!(n.startsWith("http://")||n.startsWith("https://"))}function Nr(a,e){if(!Or(a,e))return null;let r=e,t="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<a.length;){let n=a[r];if(n==="#"){if(t.length>0&&/[a-zA-Z0-9/.]$/.test(t))for(t+=n,r++;r<a.length&&/[a-zA-Z0-9_-]/.test(a[r]);)t+=a[r++];break}if(i.test(n))t+=n,r++;else break}return t.length<2?null:t}function Mr(a,e){if(e>=a.length)return null;let r=a[e];if(!O(r)&&r!=="-"&&r!=="+")return null;let t=e,i="";if((a[t]==="-"||a[t]==="+")&&(i+=a[t++]),t>=a.length||!O(a[t]))return null;for(;t<a.length&&O(a[t]);)i+=a[t++];if(t<a.length&&a[t]===".")for(i+=a[t++];t<a.length&&O(a[t]);)i+=a[t++];return t<a.length&&(a.slice(t,t+2)==="ms"?i+="ms":(a[t]==="s"||a[t]==="m"||a[t]==="h")&&(i+=a[t])),i}var Lr=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Lr);var Pe=class Re{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map,this.extractors=[];}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){Sr(e)&&e.setContext(xr(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=[],t=0;for(;t<e.length;){for(;t<e.length&&G(e[t]);)t++;if(t>=e.length)break;let i=false;for(let n of this.extractors)if(n.canExtract(e,t)){let o=n.extract(e,t);if(o){let u=o.metadata?.normalized,s=o.metadata?.stem,l=o.metadata?.stemConfidence,c={};if(o.metadata)for(let[p,d]of Object.entries(o.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(c[p]=d);let m={};u&&(m.normalized=u),s&&(m.stem=s),l!==void 0&&(m.stemConfidence=l),Object.keys(c).length>0&&(m.metadata=c),r.push(b(o.value,this.classifyToken(o.value),k(t,t+o.length),Object.keys(m).length>0?m:void 0)),t+=o.length,i=true;break}}if(!i){let n=e[t],o=this.classifyUnknownChar(n);r.push(b(n,o,k(t,t+1))),t++;}}return new Q(r,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,t){if(e[r]!==".")return false;let i=t[t.length-1],n=i&&i.position.end<r;if(i&&!n&&(i.kind==="identifier"||i.kind==="keyword"||i.kind==="selector"))return t.push(b(".","operator",k(r,r+1))),true;let s=r+1;for(;s<e.length&&A(e[s]);)s++;return s<e.length&&e[s]==="("?(t.push(b(".","operator",k(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let t=new Map;if(e.keywords){for(let[i,n]of Object.entries(e.keywords))if(t.set(n.primary,{native:n.primary,normalized:n.normalized||i}),n.alternatives)for(let o of n.alternatives)t.set(o,{native:o,normalized:n.normalized||i});}if(e.references){for(let[i,n]of Object.entries(e.references))t.set(n,{native:n,normalized:i});for(let i of Object.keys(e.references))t.has(i)||t.set(i,{native:i,normalized:i});}if(e.roleMarkers){for(let[i,n]of Object.entries(e.roleMarkers))if(n.primary&&t.set(n.primary,{native:n.primary,normalized:i}),n.alternatives)for(let o of n.alternatives)t.set(o,{native:o,normalized:i});}if(e.possessive?.keywords)for(let[i,n]of Object.entries(e.possessive.keywords))t.set(i,{native:i,normalized:n});for(let i of r)t.set(i.native,i);this.profileKeywords=Array.from(t.values()).sort((i,n)=>n.native.length-i.native.length),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let n=this.removeDiacritics(i.native);n!==i.native&&!this.profileKeywordMap.has(n.toLowerCase())&&this.profileKeywordMap.set(n.toLowerCase(),i);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,r){for(let t of this.profileKeywords)if(e.slice(r).startsWith(t.native))return b(t.native,"keyword",k(r,r+t.native.length),t.normalized);return null}isKeywordStart(e,r){let t=e.slice(r);return this.profileKeywords.some(i=>t.startsWith(i.native))}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,t){let i=this.tryNormalize(e);if(!i)return null;let n=this.lookupKeyword(i.stem);if(!n)return null;let o={normalized:n.normalized,stem:i.stem,stemConfidence:i.confidence};return b(e,"keyword",k(r,t),o)}trySelector(e,r){let t=Pr(e,r);return t?b(t,"selector",k(r,r+t.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let t=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!t)return null;let i=t[0].replace(/(\s|\.)$/,""),n=i.slice(1).split("(")[0],o=t[1];return {...b(i,"event-modifier",k(r,r+i.length)),metadata:{modifierName:n,value:o?n==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let t=_r(e,r);return t?b(t,"literal",k(r,r+t.length)):null}tryNumber(e,r){let t=Mr(e,r);return t?b(t,"literal",k(r,r+t.length)):null}tryMatchTimeUnit(e,r,t,i=false){let n=r;if(i)for(;n<e.length&&G(e[n]);)n++;let o=e.slice(n);for(let u of t){let s=o.slice(0,u.length);if(u.caseInsensitive?s.toLowerCase()===u.pattern.toLowerCase():s===u.pattern){if(u.notFollowedBy&&(o[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let c=o[u.length]||"";if(A(c))continue}return {suffix:u.suffix,endPos:n+u.length}}}return null}parseBaseNumber(e,r,t=true){let i=r,n="";if(t&&(e[i]==="-"||e[i]==="+")&&(n+=e[i++]),i>=e.length||!O(e[i]))return null;for(;i<e.length&&O(e[i]);)n+=e[i++];if(i<e.length&&e[i]===".")for(n+=e[i++];i<e.length&&O(e[i]);)n+=e[i++];return !n||n==="-"||n==="+"?null:{number:n,endPos:i}}tryNumberWithTimeUnits(e,r,t,i={}){let{allowSign:n=true,skipWhitespace:o=false}=i,u=this.parseBaseNumber(e,r,n);if(!u)return null;let{number:s,endPos:l}=u,c=[...t,...Re.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,o);return m&&(s+=m.suffix,l=m.endPos),b(s,"literal",k(r,l))}tryUrl(e,r){let t=Nr(e,r);return t?b(t,"url",k(r,r+t.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!A(e[r+1]))return null;let t=r+1;for(;t<e.length&&A(e[t]);)t++;let i=e.slice(r,t);return b(i,"identifier",k(r,t))}tryOperator(e,r){let t=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(t))return b(t,"operator",k(r,r+2));let i=e[r];return ["<",">","!","+","-","*","/","="].includes(i)?b(i,"operator",k(r,r+1)):["(",")","{","}",",",";",":"].includes(i)?b(i,"punctuation",k(r,r+1)):null}tryMultiCharParticle(e,r,t){for(let i of t)if(e.slice(r,r+i.length)===i)return b(i,"particle",k(r,r+i.length));return null}};Pe.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var _e=Pe;function Oe(a){return {stem:a,confidence:1}}function Ne(a,e,r){return r?{stem:a,confidence:e,metadata:r}:{stem:a,confidence:e}}var Ir=Object.defineProperty,jr=Object.getOwnPropertyNames,Ye=(a,e)=>function(){return a&&(e=(0, a[jr(a)[0]])(a=0)),e},qr=(a,e)=>{for(var r in e)Ir(a,r,{get:e[r],enumerable:true});};function Me(a,e){return a.replace(/\{(\w+)\}/g,(r,t)=>String(e[t]??`{${t}}`))}function D(a,e,r={},t){let i=Qe[a],n=Me(i,r),o=Je[a],u=o?Me(o,r):void 0;return {code:a,message:n,severity:e,...t&&{role:t},...u&&{suggestion:u}}}var f,Qe,Je,$r=Ye({"src/generators/schema-error-codes.ts"(){f={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},Qe={[f.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[f.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[f.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[f.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[f.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[f.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[f.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[f.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[f.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[f.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[f.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[f.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[f.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[f.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[f.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[f.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[f.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Je={[f.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[f.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[f.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[f.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[f.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[f.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[f.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[f.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[f.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[f.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[f.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[f.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[f.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[f.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),Xe={};qr(Xe,{SchemaErrorCodes:()=>f,formatValidationResults:()=>Yr,getValidationStats:()=>Qr,validateAllKeywordCollisions:()=>Xr,validateAllSchemas:()=>Gr,validateCommandSchema:()=>Ze,validateKeywordCollisions:()=>er,validateRoleValues:()=>Jr});function Vr(a,e){return {action:a,items:e}}function Ze(a){let e=[];for(let t of a.roles)t.expectedTypes.includes("literal")&&t.expectedTypes.includes("selector")&&(t.role==="patient"&&ge.has(a.action)?e.push(D(f.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:t.role,command:a.action},t.role)):e.push(D(f.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:t.role},t.role))),t.expectedTypes.length>3&&!ge.has(a.action)&&e.push(D(f.TOO_MANY_EXPECTED_TYPES,"warning",{role:t.role,count:t.expectedTypes.length},t.role));for(let t of a.roles)t.selectorKinds&&t.selectorKinds.length>0&&(t.expectedTypes.includes("selector")||e.push(D(f.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:t.role},t.role)));switch(a.action){case "transition":Wr(a,e);break;case "on":Kr(a,e);break;case "if":case "unless":Ur(a,e);break;case "repeat":case "for":case "while":Hr(a,e);break}return a.roles.filter(t=>t.required).length===0&&(rr.has(a.action)?e.push(D(f.NO_REQUIRED_ROLES_EXPECTED,"note",{command:a.action})):e.push(D(f.NO_REQUIRED_ROLES,"warning",{}))),Vr(a.action,e)}function Wr(a,e){let r=a.roles.find(i=>i.role==="patient"),t=a.roles.find(i=>i.role==="goal");r&&r.expectedTypes.includes("selector")&&e.push(D(f.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),r&&!t&&e.push(D(f.TRANSITION_MISSING_GOAL,"error",{}));}function Kr(a,e){let r=a.roles.find(t=>t.role==="event");r||e.push(D(f.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(D(f.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Ur(a,e){let r=a.roles.find(t=>t.role==="condition");r||e.push(D(f.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(D(f.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Hr(a,e){a.action==="for"?a.roles.find(t=>t.role==="source")||e.push(D(f.FOR_LOOP_MISSING_SOURCE,"warning",{})):a.action==="while"&&(a.roles.find(t=>t.role==="condition")||e.push(D(f.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Gr(a,e={}){let r=new Map,{includeNotes:t=false}=e;for(let[i,n]of Object.entries(a)){let o=Ze(n),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=t&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(i,o);}return r}function Yr(a,e={}){let r=[],{showNotes:t=false,showCodes:i=true}=e;for(let[n,o]of a){let u=o.items.filter(c=>c.severity==="error"),s=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(u.length>0){r.push(` \u274C ${n}:`);for(let c of u){let m=i?` [${c.code}]`:"";r.push(` ERROR${m}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(s.length>0){r.push(` \u26A0\uFE0F ${n}:`);for(let c of s){let m=i?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(t&&l.length>0){r.push(` \u2139\uFE0F ${n}:`);for(let c of l){let m=i?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`);}}}return r.join(`
|
|
2
|
-
`)}function Qr(a){let e=0,r=0,t=0,i={};for(let n of a.values())for(let o of n.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&t++,i[o.code]=(i[o.code]||0)+1;return {totalCommands:a.size,errors:e,warnings:r,notes:t,byCode:i}}function Jr(a,e){let r=[];for(let t of e){let i=a.roles.find(n=>n.role===t.role);i&&(i.expectedTypes.length>0&&!i.expectedTypes.includes(t.type)&&(i.expectedTypes.includes("expression")||r.push({level:"error",role:t.role,message:`${a.action}.${t.role} expects type [${i.expectedTypes.join(", ")}], got '${t.type}'`,code:f.VALUE_TYPE_MISMATCH})),t.type==="selector"&&t.selectorKind&&i.selectorKinds&&i.selectorKinds.length>0&&(i.selectorKinds.includes(t.selectorKind)||r.push({level:"error",role:t.role,message:`${a.action}.${t.role} expects selector kind [${i.selectorKinds.join(", ")}], got '${t.selectorKind}'`,code:f.SELECTOR_KIND_MISMATCH})));}return r}function er(a){let e=[];if(!a.keywords)return {language:a.code,collisions:e};let r=new Map;for(let[i,n]of Object.entries(a.keywords)){if(!n||!n.primary)continue;let o=r.get(n.primary)||[];if(o.push({command:i,isPrimary:true}),r.set(n.primary,o),n.alternatives)for(let u of n.alternatives){let s=r.get(u)||[];s.push({command:i,isPrimary:false}),r.set(u,s);}}for(let[i,n]of r){let o=[...new Set(n.map(l=>l.command))];if(o.length<=1)continue;let u=n.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:i,commands:o.sort(),type:s});}let t={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((i,n)=>t[i.type]-t[n.type]),{language:a.code,collisions:e}}function Xr(a){let e=[];for(let[,r]of Object.entries(a)){let t=er(r);t.collisions.length>0&&e.push(t);}return e.sort((r,t)=>r.language.localeCompare(t.language))}var ge,rr,Zr=Ye({"src/generators/schema-validator.ts"(){$r(),ge=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),rr=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 M=new Map,F=new Map,J=new Map,Ee=null;function tr(a,e){let r={...a};for(let t of Object.keys(e)){let i=e[t],n=a[t];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof n=="object"&&n!==null&&!Array.isArray(n)?r[t]=tr(n,i):r[t]=i);}return r}function et(a,e){return tr(a,e)}function ze(a){if(!a.extends)return a;let e=F.get(a.extends);if(!e)return console.warn(`[Registry] Profile '${a.code}' extends '${a.extends}' but base is not registered. Make sure to import the base language before the variant.`),a;let r=ze(e);return et(r,a)}function ar(a,e,r){M.set(a,e),F.set(a,r),J.delete(a);}function ir(a){Ee=a;}var Le=new Map;function V(a){return a.split("-")[0]}function W(a){return a.includes("-")}function rt(a){let e=M.get(a);if(!e&&W(a)){let r=V(a);e=M.get(r);}if(!e){let r=Array.from(M.keys()).join(", ");throw new Error(`Language '${a}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${a}';`)}return e}function tt(a){let e=F.get(a);if(!e&&W(a)){let r=V(a);e=F.get(r);}if(!e){let r=Array.from(F.keys()).join(", ");throw new Error(`Language profile '${a}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${a}';`)}return ze(e)}function L(a){let e=F.get(a);return !e&&W(a)&&(e=F.get(V(a))),e?ze(e):void 0}function at(){return Array.from(M.keys())}function nr(a){if(M.has(a)&&F.has(a))return true;if(W(a)){let e=V(a);return M.has(e)&&F.has(e)}return false}function it(a,e){return rt(e).tokenize(a)}function $(a){let e=J.get(a);if(!e&&W(a)&&(e=J.get(V(a))),e)return e;let r=Le.get(a);if(!r&&W(a)&&(r=Le.get(V(a))),r)return J.set(a,r),r;if(!Ee)throw new Error(`No patterns registered for language '${a}'. Either import the language module or set a pattern generator.`);let t=tt(a),i=Ee(t);return J.set(a,i),i}function Z(a){let e="complex";return a.startsWith("#")&&!a.includes(" ")?e="id":a.startsWith(".")&&!a.includes(" ")?e="class":a.startsWith("[")&&a.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(a)&&(e="element"),{type:"selector",value:a,selectorKind:e}}function w(a,e){let r={type:"literal",value:a};return e!==void 0?{type:"literal",value:a,dataType:e}:r}function Ie(a){return fe(a)}function N(a){return {type:"reference",value:a}}function he(a,e){return {type:"property-path",object:a,property:e}}function ue(a,e,r){let t={kind:"command",action:a,roles:new Map(Object.entries(e))};return r!==void 0?{...t,metadata:r}:t}function je(a,e,r,t,i,n){let o=new Map;o.set("event",a);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),t!==void 0&&(u.metadata=t),u}function qe(a,e="then",r){let t={kind:"compound",action:"compound",roles:new Map,statements:a,chainType:e};return r!==void 0&&(t.metadata=r),t}function $e(a,e){return !e||e.length===0||e.includes(a)||e.includes("expression")?true:a==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function Tt(a,e){return a.possessive?.keywords?.[e]}var ve=.8,Ft=.6,Pt=.15,Rt=.5,Ve=.15,We=.1,Ke=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"]),_t={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"]},Ot=class{calculate(a){return this.calculateWithBreakdown(a).final}calculateWithBreakdown(a){let e=this.scoreRoleCoverage(a),r=this.scoreStemPenalty(a),t=this.scoreLanguageBoost(a),i=this.scoreLanguageAdjustment(a),n=e;return n=Math.max(Rt,n+r),n=Math.min(1,n+t),n=Math.max(0,Math.min(1,n+i)),{roleCoverage:e,stemPenalty:r,languageBoost:t,languageAdjustment:i,final:n}}scoreRoleCoverage(a){let{pattern:e,captured:r}=a,t=0,i=0,n=o=>e.extraction?.[o]?.default!==void 0;for(let o of e.template.tokens)if(o.type==="role")i+=1,r.has(o.role)&&(t+=1);else if(o.type==="group")for(let u of o.tokens)u.type==="role"&&(i+=ve,r.has(u.role)?t+=ve:n(u.role)&&(t+=ve*Ft));return i>0?t/i:1}scoreStemPenalty(a){let{stemMatchCount:e,totalKeywordMatches:r}=a;return e<=0||r<=0?0:-(e/r)*Pt}scoreLanguageBoost(a){let{pattern:e}=a;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:Ke.has(r.value)||r.alternatives?.some(t=>Ke.has(t))?Ve:0}scoreLanguageAdjustment(a){let{pattern:e,captured:r}=a;if(e.language!=="ar")return 0;let t=0;for(let[i,n]of r.entries()){let o=_t[i];if(!o||o.length===0)continue;let u="metadata"in n?n.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?t+=.1:t-=.1);}return Math.max(-We,Math.min(We,t))}},Nt=new Ot,le=class X{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Nt;}matchPattern(e,r){let t=e.mark(),i=new Map;if(this.currentProfile=L(r.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,r.template.tokens,i))return e.reset(t),null;let o=this.confidenceModel.calculate({pattern:r,captured:i,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,i),{pattern:r,captured:i,consumedTokens:e.position()-t.position,confidence:o}}matchBest(e,r){this.matchCache.clear();let t=[],i=e.position();for(let o of r){let u=e.mark(),s=`${i}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&t.push(l),e.reset(u);}if(t.length===0)return null;t.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.confidence-o.confidence});let n=t[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t){let i=r[0],n=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!n)for(;e.peek()?.kind==="conjunction";)e.advance();for(let o of r)if(!this.matchPatternToken(e,o,t)){if(this.isOptional(o))continue;return false}return true}matchPatternToken(e,r,t){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t);case "group":return this.matchGroupToken(e,r,t);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(!t)return false;let i=this.getMatchType(t,r.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let o=this.getMatchType(t,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,t){this.skipNoiseWords(e);let i=e.peek();if(!i)return r.optional||false;let n=this.tryMatchPossessiveExpression(e);if(n)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(n.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,n),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(o.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!$e(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(s.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!$e(l.type,r.expectedTypes)?r.optional||false:(t.set(r.role,l),true);let c=this.tokenToSemanticValue(i);return !c||r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(c.type)?r.optional||false:(t.set(r.role,c),e.advance(),true)}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=(r.normalized||r.value).toLowerCase(),i=Tt(this.currentProfile,t);if(!i)return null;let n=e.mark();e.advance();let o=e.peek();if(!o)return e.reset(n),null;if(o.kind==="identifier"||o.kind==="keyword"&&!this.isStructuralKeyword(o.value)||o.kind==="selector"&&o.value.startsWith("*")||o.kind==="selector"&&o.value.startsWith("@")||o.kind==="selector"&&o.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(o.value)){e.advance();let u=o.value;o.kind==="selector"&&u.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u)&&(u=u.substring(1));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();return l?.kind==="literal"&&l.value.startsWith("(")&&(s+=l.value,e.advance()),he(N(i),s)}return e.reset(n),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<X.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}.${n.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let t=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=`${r.value}.${n.value}`,u=1;for(;!e.isAtEnd()&&u<X.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<X.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(c===0){e.advance();break}c--;}if(p.kind==="punctuation"&&p.value==="("&&c++,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 t=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(t),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(t),null):(e.advance(),he(Z(r.value),n.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(t),null;let n=e.peek(1);n&&n.kind,e.advance();let o=i.value.slice(1);return he(Z(r.value),o)}matchGroupToken(e,r,t){let i=e.mark(),n=new Set(t.keys());if(!this.matchTokenSequence(e,r.tokens,t)){e.reset(i);for(let u of t.keys())n.has(u)||t.delete(u);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 Z(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Ie(r)?N(r):w(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return N(e.value);let t=e.value.toLowerCase();return Ie(t)?N(t):{type:"expression",raw:e.value};case "url":return w(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return w(i,"string")}if(e==="true")return w(true,"boolean");if(e==="false")return w(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let i=parseFloat(r[1]);return r[2]?w(e,"duration"):w(i,"number")}let t=parseFloat(e);return isNaN(t)?w(e,"string"):w(t,"number")}applyExtractionRules(e,r){for(let[t,i]of Object.entries(e.extraction))r.has(t)||(i.value!==void 0?r.set(t,{type:"literal",value:i.value}):i.default&&r.set(t,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=r.value.toLowerCase();if(X.ENGLISH_NOISE_WORDS.has(t)){let i=e.mark();e.advance();let n=e.peek();if(n&&(n.kind==="selector"||n.kind==="identifier"))return;e.reset(i);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let n=i.metadata;if(!n)break;switch(t=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return t?r:void 0}};le.MAX_PROPERTY_DEPTH=10;le.MAX_METHOD_ARGS=20;le.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Mt=le,_=new Mt;function ee(a,e){return it(a,e)}function or(){return at()}var Lt={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",boyut_de\u011Fi\u015Ftir:"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"}};var jt={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}],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)"}},qt={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"],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,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"}},$t={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",targetRole:"source",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],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"}},Vt={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"}},Wt={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"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{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:"\uC73C\uB85C",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man"}}],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>"}},Kt={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}]},Ut={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}]},Ht={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}]},Gt={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}]},Yt={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}]},Qt={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}]},Jt={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"}}]},Xt={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"}}]},Zt={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"}}]},ea={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"}}]},ra={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}]},ta={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:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},aa={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}]},ia={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}]},na={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}]},oa={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}]},ua={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}]},sa={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"],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"}}]},la={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},ca={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"],svoPosition:1,sovPosition:1}]},ma={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},pa={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"'},da={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"],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"}}]},ya={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}]},fa={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},ha={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:""}}]},va={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal"],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:"kwenye",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"auf",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",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}]},ga={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"}}]},Ea={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}]},za={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}]},ka={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}]},ba={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"}}]},wa={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}]},Ca={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}]},Aa={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}]},Da={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}]},Sa={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[]},xa={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},Ba={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}]},Ta={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}]},Fa={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Pa={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:""}}]},Ra={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:["reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta"}},{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:"kwenye",bn:"\u09A4\u09C7",qu:"man"}}]},_a={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Oa={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}]},Na={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}]},Ma={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"}}]},La={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"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with"}}]},Ia={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"destination",roles:[{role:"destination",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"patient",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},ja={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}]},qa={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},$a={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}]},Va={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},Wa={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}]},Ka={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"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},ur={en:"url",es:"url",pt:"url",fr:"url",de:"url",it:"url",ja:"url",ko:"url",zh:"url",ar:"url",he:"url",hi:"url",bn:"url",tr:"url",ru:"url",uk:"url",pl:"url",id:"url",vi:"url",th:"url",ms:"url",tl:"url",sw:"url",qu:"url"},Ua={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"},Ha={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:ur}]},Ga={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:ur}]},Ya={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:Ua}]},Qa={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}]},sr={toggle:jt,add:qt,remove:$t,put:Vt,set:Wt,show:Kt,hide:Ut,on:Ht,trigger:Gt,wait:Yt,fetch:Qt,increment:Jt,decrement:Xt,append:Zt,prepend:ea,log:ra,get:ta,take:aa,make:ia,halt:na,settle:oa,throw:ua,send:sa,if:la,unless:ca,else:ma,repeat:pa,for:da,while:ya,continue:fa,go:ha,scroll:Ka,push:Ha,replace:Ga,process:Ya,transition:va,clone:ga,focus:Ea,blur:za,empty:ka,open:ba,close:wa,select:Ca,clear:Aa,reset:Da,breakpoint:Sa,call:xa,return:Ba,js:Ta,async:Fa,tell:Pa,default:Ra,init:_a,behavior:Oa,install:Na,measure:Ma,swap:La,morph:Ia,beep:ja,break:qa,copy:$a,exit:Va,pick:Wa,render:Qa,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function Ja(){return Object.values(sr).filter(a=>a.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Zr(),Xe)).then(({validateAllSchemas:a,formatValidationResults:e})=>{let r=a(sr);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(a=>{console.debug("Schema validation skipped:",a);});var Ue=class extends Error{constructor(a,e,r,t){super(a),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=t;}};function B(a,e,r){return {message:a,severity:e,source:"semantic-parser",...r&&{code:r}}}function se(a,e){return e.length===0?a:{...a,diagnostics:e}}var K=class T{parse(e,r){let{modifiers:t,remainingInput:i}=this.extractStandaloneModifiers(e,r),n=i||e,o=[],u=ee(n,r),s=$(r);if(s.length===0)throw new Ue(`No patterns available for language: ${r}`,r,n,[B(`No patterns registered for language '${r}'`,"error","no-patterns")]);let l=[...s].sort((h,g)=>g.priority-h.priority),c=l.filter(h=>h.command==="on"),m=_.matchBest(u,c);if(m){o.push(B(`event pattern matched: ${m.pattern.id} (confidence: ${m.confidence.toFixed(2)})`,"info","pattern-match"));let h=this.buildEventHandler(m,u,r),g=t?this.applyModifiers(h,t):h;return se(g,o)}o.push(B(`event patterns: ${c.length} tried, no match`,"info","stage-event"));let p=l.filter(h=>h.command!=="on"),d=_.matchBest(u,p);if(d)return o.push(B(`command pattern matched: ${d.pattern.id} (confidence: ${d.confidence.toFixed(2)})`,"info","pattern-match")),se(this.buildCommand(d,r),o);o.push(B(`command patterns: ${p.length} tried, no match`,"info","stage-command"));let y=this.trySOVEventExtraction(n,r,l);if(y){o.push(B("SOV event extraction succeeded","info","stage-sov"));let h=t?this.applyModifiers(y,t):y;return se(h,o)}o.push(B("SOV event extraction: no event keyword found","info","stage-sov"));let v=this.tryCompoundCommandParsing(u,p,r);if(v)return o.push(B("compound command parsing succeeded","info","stage-compound")),se(v,o);throw o.push(B("compound parsing: no then-keywords or no command matches","info","stage-compound")),o.push(B(`all parse stages exhausted for "${n}"`,"error","parse-failed")),new Ue(`Could not parse input in ${r}: ${n}`,r,n,o)}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return or()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let t={};for(let[i,n]of e.captured)t[i]=n;return ue(e.pattern.command,t,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,r,t){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");let n=_.extractEventModifiers(r),o=this.extractOrConjunctionEvents(r,t),u=i;o.length>0&&i.type==="literal"&&(u={type:"literal",value:[String(i.value),...o.map(m=>String("value"in m?m.value:""))].join(" or ")});let s,l=e.captured.get("action");if(l&&l.type==="literal"){let c=l.value,m={};for(let[y,v]of e.captured)y!=="event"&&y!=="action"&&y!=="continues"&&(m[y]=v);let p=ue(c,m,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence}),d=e.captured.get("continues");if(d&&d.type==="literal"&&d.value==="then"){let y=$(t).filter(g=>g.command!=="on").sort((g,z)=>z.priority-g.priority),v=$(t).filter(g=>g.id.startsWith("grammar-")&&g.id.includes("-continuation")).sort((g,z)=>z.priority-g.priority),h=this.parseBodyWithGrammarPatterns(r,y,v,t);h.length>0?s=[p,...h]:s=[p];}else s=[p];}else {let c=$(t).filter(m=>m.command!=="on").sort((m,p)=>p.priority-m.priority);s=this.parseBodyWithClauses(r,c,t);}return je(u,s,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,t){let i=[],n=[];for(;!e.isAtEnd();){let o=e.peek();if(!o)break;let u=o.kind==="conjunction"||o.kind==="keyword"&&this.isThenKeyword(o.value,t),s=o.kind==="keyword"&&this.isEndKeyword(o.value,t);if(u){if(n.length>0){let l=this.parseClause(n,r,t);i.push(...l),n.length=0;}e.advance();continue}if(s){if(n.length>0){let l=this.parseClause(n,r,t);i.push(...l);}e.advance();break}n.push(o),e.advance();}if(n.length>0){let o=this.parseClause(n,r,t);i.push(...o);}return i.length>1?[qe(i,"then",{sourceLanguage:t})]:i}parseClause(e,r,t){if(e.length===0)return [];let i=new Q(e,t),n=[];for(;!i.isAtEnd();){let o=_.matchBest(i,r);o?n.push(this.buildCommand(o,t)):i.advance();}if(n.length===0){let o=this.parseSOVClauseByVerbAnchoring(e,t);if(o.length>0)return o}return n}static buildVerbLookup(e){let r=new Map;for(let[t,i]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(t)&&(r.set(i.primary.toLowerCase(),t),i.alternatives))for(let n of i.alternatives)r.set(n.toLowerCase(),t);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[t,i]of Object.entries(e.roleMarkers))if(i&&(r.set(i.primary,t),i.alternatives))for(let n of i.alternatives)r.has(n)||r.set(n,t);return r}parseSOVClauseByVerbAnchoring(e,r){let t=L(r);if(!t||t.wordOrder!=="SOV")return [];let i=T.buildVerbLookup(t),n=T.buildMarkerToRoleLookup(t),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let y=u;y<e.length;y++){let v=e[y],h=i.get(v.value.toLowerCase()),g=v.normalized?i.get(v.normalized.toLowerCase()):void 0,z=h||g;if(z){s=y,l=z;break}}if(s===-1)break;let c=e.slice(u,s),m=e.length;for(let y=s+1;y<e.length;y++){let v=e[y];if(v.kind==="conjunction"||this.isThenKeyword(v.value,r)){m=y;break}if(y>s+1&&(i.get(v.value.toLowerCase())||(v.normalized?i.get(v.normalized.toLowerCase()):void 0))){m=y;break}}let p=e.slice(s+1,m),d=this.extractRolesFromMarkedTokens(c,p,n,l,r);if(o.push(ue(l,d,{sourceLanguage:r,confidence:.7})),u=m,u<e.length){let y=e[u];(y.kind==="conjunction"||this.isThenKeyword(y.value,r))&&u++;}}return o}extractRolesFromMarkedTokens(e,r,t,i,n){let o={},u=s=>{let l=[];for(let c of s){let m=t.get(c.value);if(m&&c.kind==="particle"&&l.length>0){let p=this.tokensToSemanticValue(l);if(p){let d=this.mapRoleForCommand(m,i,o);d&&(o[d]=p);}l=[];}else l.push(c);}if(l.length>0){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,t){return t[e]?e==="patient"&&!t.destination?"destination":e==="destination"&&!t.patient?"patient":e==="source"&&!t.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let r=e.filter(n=>n.kind!=="whitespace");if(r.length===0)return null;if(r.length===1)return this.tokenToSemanticValue(r[0]);let t=r.map(n=>n.value).join(""),i=r[0];return i.kind==="selector"||i.value.startsWith("#")||i.value.startsWith(".")||i.value.startsWith("@")||i.value.startsWith("*")?Z(t):i.kind==="literal"||i.value.startsWith('"')||i.value.startsWith("'")?w(t):i.kind==="reference"?N(t):w(t)}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return Z(r);if(r.startsWith('"')||r.startsWith("'"))return w(r);if(/^-?\d+(\.\d+)?$/.test(r))return w(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return w(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return w(false);let t=e.normalized?.toLowerCase();return t==="me"||t==="it"||t==="you"||t==="result"||t==="body"?N(t):e.kind==="reference"?N(e.normalized||"me"):w(r)}parseBodyWithGrammarPatterns(e,r,t,i){let n=[];for(;!e.isAtEnd();){let o=e.peek();if(o&&this.isThenKeyword(o.value,i)){e.advance();continue}if(o&&this.isEndKeyword(o.value,i)){e.advance();break}let u=false;if(t.length>0){let s=_.matchBest(e,t);if(s){let l=s.pattern.command,c={};for(let[d,y]of s.captured)d!=="event"&&d!=="action"&&d!=="continues"&&(c[d]=y);let m=ue(l,c,{sourceLanguage:i,patternId:s.pattern.id});n.push(m),u=true;let p=s.captured.get("continues");if(p&&p.type==="literal"&&p.value==="then")continue}}if(!u){let s=_.matchBest(e,r);s&&(n.push(this.buildCommand(s,i)),u=true);}u||e.advance();}return n}tryCompoundCommandParsing(e,r,t){let i=e.tokens;if(!i.some(s=>s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,t)))return null;let o=new Q(i,t),u=this.parseBodyWithClauses(o,r,t);return u.length===0?null:u.length===1?u[0]:qe(u,"then",{sourceLanguage:t,confidence:.65})}trySOVEventExtraction(e,r,t){let i=T.SOV_EVENT_MARKERS[r];if(!i)return null;let o=ee(e,r).tokens,u=Lt[r],s=new Set;if(u)for(let E of Object.keys(u))s.add(E.toLowerCase());let l=T.SOV_SOURCE_MARKERS[r],c=-1,m="",p="",d=1;for(let E=0;E<o.length;E++){let C=o[E],P=C.value.toLowerCase(),R=P,I="",pe=P.indexOf("[");pe>0&&(R=P.slice(0,pe),I=C.value.slice(pe));let de=C.normalized?.toLowerCase(),De=de&&T.KNOWN_EVENTS.has(de),Se=s.has(P)||s.has(R),kr=T.KNOWN_EVENTS.has(R);if(De||Se||kr){let U;if(De?U=de:Se?U=u?.[P]??u?.[R]??R:U=R,i.size>0){let ae=1,ye=o[E+1];ye&&ye.kind==="selector"&&ye.value.startsWith("[")&&(ae=2);let ie=o[E+ae];if(ie&&(ie.kind==="particle"||ie.kind==="keyword")&&i.has(ie.value)){c=E,m=U,p=I||(ae===2?o[E+1].value:""),d=ae+1;break}}else {c=E,m=U,p=I,d=1;break}}}if(c===-1)return null;let y=new Set;for(let E=c;E<c+d;E++)y.add(E);if(l){let E=c+d;if(E<o.length){let C=o[E];(C.kind==="particle"||C.kind==="keyword")&&l.markers.has(C.value)&&y.add(E);}for(let C=0;C<c;C++){let P=o[C],R=P.value.toLowerCase(),I=P.normalized?.toLowerCase();if(l.windowTokens.has(R)||I&&l.windowTokens.has(I)){y.add(C);break}}}let v=o.filter((E,C)=>!y.has(C));if(v.length===0)return null;let h=t.filter(E=>E.command!=="on"),g=new Q(v,r),z=this.parseBodyWithClauses(g,h,r);if(z.length===0)return null;let Ae={sourceLanguage:r,confidence:.75};return p&&(Ae.keyFilter=p),je({type:"literal",value:m},z,void 0,Ae)}isThenKeyword(e,r){let t={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","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),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","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (t[r]||t.en).has(e.toLowerCase())}isEndKeyword(e,r){let t={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\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","beenden","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"])};return (t[r]||t.en).has(e.toLowerCase())}extractStandaloneModifiers(e,r){let i=ee(e,r).tokens;if(i.length===0)return {modifiers:null,remainingInput:null};let o=i[0].value.toLowerCase(),u=T.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<i.length){let y=i[d];(y.kind==="keyword"||y.kind==="particle")&&(d++,l++);}if(d<i.length){let y=i[d];if(y.kind==="literal"){let v=y.value.match(/^(\d+)(ms|s|m)?$/);if(v){let h=parseInt(v[1],10),g=v[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 c=i.slice(l);if(c.length===0)return {modifiers:null,remainingInput:null};let m=c[0].position.start,p=e.slice(m);return {modifiers:s,remainingInput:p}}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let t=[];for(;;){let i=e.mark(),n=e.peek();if(!n)break;let o=(n.normalized||n.value).toLowerCase();if(!T.OR_KEYWORDS.has(o)){e.reset(i);break}e.advance();let u=e.peek();if(!u){e.reset(i);break}let s=(u.normalized||u.value).toLowerCase();e.advance(),t.push({type:"literal",value:s});}return t}};K.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);K.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"])};K.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"])}};K.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};K.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"]);var Xa=K,Za=new Xa;function ei(a,e){return Za.parse(a,e)}function ri(a,e){try{let r=ee(a,e),t=$(e);if(t.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let i=[...t].sort((l,c)=>c.priority-l.priority),n=i.filter(l=>l.command==="on"),o=_.matchBest(r,n);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let u=i.filter(l=>l.command!=="on"),s=_.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: ${a}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function lr(a,e){try{let t=ei(a,e);if(t)return {node:t,confidence:t.metadata?.confidence??.8,error:void 0,tokensConsumed:ee(a,e).tokens.length}}catch{}let r=ri(a,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function cr(a,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...a].sort((t,i)=>{let n=t[r]??99,o=i[r]??99;return n-o})}function ti(a,e){let r=a.markerOverride?.[e.code],t=e.roleMarkers[a.role];if(r!==void 0)return {primary:r,position:t?.position??"before",isOverride:true};if(t&&t.primary){let i={primary:t.primary,position:t.position,isOverride:false};return t.alternatives&&(i.alternatives=t.alternatives),i}return null}function ai(a,e,r,t,i){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let c of l)n.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}}let o=e.roleMarkers.destination;o&&n.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}]}),n.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};n.push(l);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),{id:`${a.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`{event} ${t.primary} {destination?} {patient} ${u?.primary||""} ${r.primary}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ii(a,e,r,t,i){let n=[];n.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};n.push(s);}if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let s=t.primary.split(/\s+/);if(s.length>1)for(let l of s)n.push({type:"literal",value:l});else {let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),{id:`${a.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`{patient} ${o?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ni(a,e,r,t,i){let n=[];n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(l);}let u=e.roleMarkers.destination;if(u&&(n.push({type:"role",role:"destination",optional:false}),n.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),n.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let c of l)n.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),{id:`${a.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function oi(a,e,r,t,i){let n=[];n.push({type:"role",role:"event",optional:false});let o=t.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&n.push({type:"literal",value:o[0],alternatives:o.slice(1)});let u=e.roleMarkers.destination;u&&n.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),n.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};n.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(l),{id:`${a.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(i.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ui(a,e,r,t,i){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let u=t.primary.split(/\s+/);if(u.length>1)for(let s of u)n.push({type:"literal",value:s});else {let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(o),{id:`${a.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function si(a,e,r,t){let i=e.eventHandler?.temporalMarkers;if(!i||i.length===0)return null;let n=[];n.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&n.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),n.push({type:"literal",value:i[0],alternatives:i.slice(1)}),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(s);}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),{id:`${a.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(t.basePriority??100)+49,template:{format:`{event} ${i[0]} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function li(a,e,r,t,i){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let c=t.primary.split(/\s+/);if(c.length>1)for(let m of c)n.push({type:"literal",value:m});else {let m=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(m);}}let u=[...a.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.sovPosition??999,d=m.sovPosition??999;return p-d});for(let c of u){n.push({type:"role",role:c.role,optional:false});let m,p;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)m=c.markerOverride[e.code];else {let d=e.roleMarkers[c.role];d&&(m=d.primary,p=d.alternatives);}if(m){let d=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};n.push(d);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(s);let l=u.map(c=>`{${c.role}}`).join(" ");return {id:`${a.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`{event} ${t.primary} ${l} ${r.primary}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))}}}function ci(a,e,r,t,i){let n=[],u=[...a.roles.filter(y=>y.required)].sort((y,v)=>{let h=y.sovPosition??999,g=v.sovPosition??999;return h-g}),s=u[0];n.push({type:"role",role:s.role,optional:false});let l;if(s.markerOverride&&s.markerOverride[e.code]!==void 0)l=s.markerOverride[e.code];else {let y=e.roleMarkers[s.role];y&&(l=y.primary);}if(l&&n.push({type:"literal",value:l}),n.push({type:"role",role:"event",optional:false}),t.position==="after"){let y=t.primary.split(/\s+/);if(y.length>1)for(let v of y)n.push({type:"literal",value:v});else {let v=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(v);}}let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(c);let m=u[1];n.push({type:"role",role:m.role,optional:false});let p,d;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)p=m.markerOverride[e.code];else {let y=e.roleMarkers[m.role];y&&(p=y.primary,d=y.alternatives);}if(p){let y=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};n.push(y);}return {id:`${a.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{${s.role}} {event} ${t.primary} ${r.primary} {${m.role}}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[m.role]:{fromRole:m.role}}}}function He(a,e,r,t,i){let n=[];if(t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),{id:`${a.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`${t.primary} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function mi(a,e,r,t,i){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;if(u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}return n.push({type:"role",role:"event",optional:false}),{id:`${a.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${t.primary} {event}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function pi(a,e,r,t,i){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=[...a.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.svoPosition??999,d=m.svoPosition??999;return p-d});for(let c of s){let m,p;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)m=c.markerOverride[e.code];else {let d=e.roleMarkers[c.role];d&&(m=d.primary,p=d.alternatives);}if(m){let d=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};n.push(d);}n.push({type:"role",role:c.role,optional:false});}if(t.position==="before"){let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}n.push({type:"role",role:"event",optional:false});let l=s.map(c=>`{${c.role}}`).join(" ");return {id:`${a.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${r.primary} ${l} ${t.primary} {event}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))}}}function Ge(a,e,r,t,i){let n=[];if(t.position==="before"){let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=[...a.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.svoPosition??999,d=m.svoPosition??999;return p-d});for(let c of s){let m,p;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)m=c.markerOverride[e.code];else {let d=e.roleMarkers[c.role];d&&(m=d.primary,p=d.alternatives);}if(m){let d=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};n.push(d);}n.push({type:"role",role:c.role,optional:false});}let l=s.map(c=>`{${c.role}}`).join(" ");return {id:`${a.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`${t.primary} {event} ${r.primary} ${l}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))}}}function di(a,e,r,t,i){let n=[],o=e.eventHandler?.negationMarker;if(t.position==="before"){let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(l);}n.push({type:"role",role:"event",optional:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u),n.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&n.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${a.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${t.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function yi(a,e,r,t){let i=[];i.push({type:"literal",value:"and",alternatives:["then"]}),i.push({type:"role",role:"event",optional:false});let n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(n),i.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&i.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),{id:`${a.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(t.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:a.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var re={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function mr(a,e,r=re){let t=`${a.action}-${e.code}-generated`,i=r.basePriority??100,n=e.keywords[a.action];if(!n)throw new Error(`No keyword translation for '${a.action}' in ${e.code}`);let o=gi(a,e,n),u=dr(a,e),s=bi(a,e,n);return {id:t,language:e.code,command:a.action,priority:i,template:{format:s,tokens:o},extraction:u}}function fi(a,e,r=re){if(a.roles.filter(u=>!u.required).length===0)return null;let i=a.roles.filter(u=>u.required),n={...a,roles:i};return {...mr(n,e,r),id:`${a.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:dr(a,e)}}function hi(a,e,r=re){let t=[];if(t.push(mr(a,e,r)),r.generateSimpleVariants){let i=fi(a,e,r);i&&t.push(i);}return t}function pr(a,e=re){let r=[],t=Ja();for(let i of t){if(!a.keywords[i.action])continue;let n=hi(i,a,e);if(r.push(...n),a.eventHandler?.eventMarker){let o=vi(i,a,e);r.push(...o);}}return r}function vi(a,e,r=re){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let t=[],i=e.eventHandler.eventMarker,n=e.keywords[a.action];if(!n)return [];let u=a.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)t.push(li(a,e,n,i,r)),t.push(ci(a,e,n,i,r));else {t.push(ai(a,e,n,i,r)),t.push(ii(a,e,n,i,r));let s=e.roleMarkers.destination;s&&s.primary!==i.primary&&t.push(ni(a,e,n,i,r));let l=i.primary.split(/\s+/),c=i.alternatives?.some(p=>!p.includes(" ")&&p.length>1);l.length>1&&c&&t.push(oi(a,e,n,i,r)),t.push(ui(a,e,n,i,r));let m=si(a,e,n,r);m&&t.push(m);}else e.wordOrder==="VSO"?u?(t.push(Ge(a,e,n,i,r)),t.push(pi(a,e,n,i,r))):(t.push(He(a,e,n,i,r)),t.push(mi(a,e,n,i,r)),e.eventHandler?.negationMarker&&t.push(di(a,e,n,i,r)),e.tokenization?.prefixes&&t.push(yi(a,e,n,r))):u?t.push(Ge(a,e,n,i,r)):t.push(He(a,e,n,i,r));return t}function gi(a,e,r){let t=[],i=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},n=Ei(a,e);switch(e.wordOrder){case "SVO":t.push(i),t.push(...n);break;case "SOV":t.push(...n),t.push(i);break;case "VSO":t.push(i),t.push(...n);break;default:t.push(i),t.push(...n);}return t}function Ei(a,e){let r=[],t=cr(a.roles,e.wordOrder);for(let i of t){let n=zi(i,e);i.required?r.push(...n):r.push({type:"group",optional:true,tokens:n});}return r}function zi(a,e){let r=[],t=a.markerOverride?.[e.code],i=e.roleMarkers[a.role],n={type:"role",role:a.role,optional:!a.required,expectedTypes:a.expectedTypes};if(t!==void 0){let o=t?t.split(/\s+/).filter(Boolean):[];if((i?.position??"before")==="before"){for(let s of o)r.push({type:"literal",value:s});r.push(n);}else {r.push(n);for(let s of o)r.push({type:"literal",value:s});}}else if(i)if(i.position==="before"){if(i.primary){let o=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};r.push(o);}r.push(n);}else {r.push(n);let o=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};r.push(o);}else r.push(n);return r}function ki(a,e){let r={};for(let t of a.roles){let i=t.markerOverride?.[e.code],n=e.roleMarkers[t.role];i!==void 0?r[t.role]=i?{marker:i}:{}:n&&n.primary?r[t.role]=n.alternatives?{marker:n.primary,markerAlternatives:n.alternatives}:{marker:n.primary}:r[t.role]={};}return r}function dr(a,e){let r=ki(a,e),t={};for(let i of a.roles){let n=r[i.role]||{};!i.required&&i.default?t[i.role]={...n,default:i.default}:t[i.role]=n;}return t}function bi(a,e,r){let t=[],n=cr(a.roles,e.wordOrder).map(o=>{let u=ti(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":t.push(r.primary,...n);break;case "SOV":t.push(...n,r.primary);break;default:t.push(r.primary,...n);}return t.join(" ")}var wi=class{constructor(a={}){this.cache=new Map,this.config={maxSize:a.maxSize??1e3,ttlMs:a.ttlMs??0,enabled:a.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(a,e){return `${e}:${a}`}isExpired(a){return this.config.ttlMs===0?false:Date.now()-a.createdAt>this.config.ttlMs}evictLRU(){let a=this.cache.keys().next().value;a!==void 0&&(this.cache.delete(a),this.stats.evictions++);}get(a,e){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(a,e),t=this.cache.get(r);if(!t){this.stats.misses++;return}if(this.isExpired(t)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),t.lastAccessed=Date.now(),this.cache.set(r,t),this.stats.hits++,t.result}set(a,e,r){if(!this.config.enabled||r!==null&&typeof r=="object"&&"confidence"in r&&r.confidence===0)return;let t=this.makeKey(a,e),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(t,{result:r,createdAt:i,lastAccessed:i});}has(a,e){if(!this.config.enabled)return false;let r=this.makeKey(a,e),t=this.cache.get(r);return t?this.isExpired(t)?(this.cache.delete(r),this.stats.expirations++,false):true:false}delete(a,e){let r=this.makeKey(a,e);return this.cache.delete(r)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let a=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:a>0?this.stats.hits/a:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(a){if(a.maxSize!==void 0)for(this.config.maxSize=a.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();a.ttlMs!==void 0&&(this.config.ttlMs=a.ttlMs),a.enabled!==void 0&&(this.config.enabled=a.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}};new wi;var yr={code:"qu",name:"Quechua",nativeName:"Runasimi",direction:"ltr",script:"latin",wordOrder:"SOV",markingStrategy:"postposition",usesSpaces:true,verb:{position:"end",subjectDrop:true},references:{me:"\xF1uqa",it:"pay",you:"qam",result:"rurasqa",event:"ruwakuq",target:"\xF1awpaqman",body:"ukhu"},possessive:{marker:"-pa",markerPosition:"after-object",keywords:{\u00F1uqapa:"me",\u00F1uqaypa:"me",qampa:"you",paypa:"it"}},roleMarkers:{patient:{primary:"ta",position:"after"},destination:{primary:"man",alternatives:["pa"],position:"after"},source:{primary:"manta",position:"after"},style:{primary:"wan",position:"after"},event:{primary:"pi",position:"after"}},keywords:{toggle:{primary:"t'ikray",alternatives:["tikray"],normalized:"toggle"},add:{primary:"yapay",alternatives:["yapaykuy"],normalized:"add"},remove:{primary:"qichuy",alternatives:["hurquy","anchuchiy"],normalized:"remove"},put:{primary:"churay",alternatives:["tiyachiy"],normalized:"put"},append:{primary:"qatichiy",alternatives:["qhipaman_yapay"],normalized:"append"},prepend:{primary:"\xF1awpachiy",normalized:"prepend"},take:{primary:"hapiy",normalized:"take"},make:{primary:"ruray",alternatives:["kamay"],normalized:"make"},clone:{primary:"kikinchay",alternatives:[],normalized:"clone"},swap:{primary:"t'inkuy",alternatives:["rantikunakuy","rantin_tikray"],normalized:"swap"},morph:{primary:"tukunay",alternatives:[],normalized:"morph"},set:{primary:"churanay",alternatives:["kamaykuy"],normalized:"set"},get:{primary:"taripay",normalized:"get"},increment:{primary:"yapachiy",normalized:"increment"},decrement:{primary:"pisiyachiy",normalized:"decrement"},log:{primary:"qillqakuy",alternatives:["willakuy"],normalized:"log"},show:{primary:"rikuchiy",alternatives:["qawachiy"],normalized:"show"},hide:{primary:"pakay",alternatives:["pakakuy"],normalized:"hide"},transition:{primary:"pasay",alternatives:[],normalized:"transition"},on:{primary:"chaypim",alternatives:["kaypi"],normalized:"on"},trigger:{primary:"kuyuchiy",alternatives:["kichay"],normalized:"trigger"},send:{primary:"kachay",alternatives:["apachiy"],normalized:"send"},focus:{primary:"qhawachiy",alternatives:["qhaway"],normalized:"focus"},blur:{primary:"paqariy",alternatives:["mana qhawachiy"],normalized:"blur"},empty:{primary:"ch'usaq",normalized:"empty"},open:{primary:"paskay",normalized:"open"},close:{primary:"wichqay",normalized:"close"},select:{primary:"marcay",normalized:"select"},clear:{primary:"pichay",normalized:"clear"},reset:{primary:"musuqchay",normalized:"reset"},breakpoint:{primary:"sayachinay",normalized:"breakpoint"},go:{primary:"riy",alternatives:["puriy"],normalized:"go"},scroll:{primary:"kunray",alternatives:[],normalized:"scroll"},push:{primary:"tanqay",normalized:"push"},replace:{primary:"tikray_url",alternatives:[],normalized:"replace"},process:{primary:"rurariy",normalized:"process"},wait:{primary:"suyay",normalized:"wait"},fetch:{primary:"apamuy",alternatives:["taripakaramuy"],normalized:"fetch"},settle:{primary:"tiyakuy",normalized:"settle"},if:{primary:"sichus",normalized:"if"},when:{primary:"maykama",normalized:"when"},where:{primary:"maypi",normalized:"where"},else:{primary:"manachus",alternatives:["hukniraq"],normalized:"else"},repeat:{primary:"kutipay",alternatives:["muyu"],normalized:"repeat"},for:{primary:"sapankaq",normalized:"for"},while:{primary:"kaykamaqa",normalized:"while"},continue:{primary:"qatipay",normalized:"continue"},halt:{primary:"sayay",alternatives:[],normalized:"halt"},throw:{primary:"chanqay",normalized:"throw"},call:{primary:"waqyay",alternatives:["qayay"],normalized:"call"},return:{primary:"kutichiy",alternatives:["kutimuy"],normalized:"return"},then:{primary:"chaymantataq",alternatives:["hinaspa","chaymanta"],normalized:"then"},and:{primary:"hinallataq",alternatives:["ima","chaymantawan"],normalized:"and"},end:{primary:"tukukuy",alternatives:["tukuy","puchukay"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"mana waqtalla",normalized:"async"},tell:{primary:"niy",alternatives:[],normalized:"tell"},default:{primary:"qallariy",normalized:"default"},init:{primary:"qallarichiy",normalized:"init"},behavior:{primary:"ruwana",normalized:"behavior"},install:{primary:"tarpuy",normalized:"install"},measure:{primary:"tupuy",normalized:"measure"},beep:{primary:"waqay",normalized:"beep"},break:{primary:"p'akiy",normalized:"break"},copy:{primary:"qillqay",normalized:"copy"},exit:{primary:"lluqsiy",normalized:"exit"},pick:{primary:"akllay",normalized:"pick"},render:{primary:"rikurichiy",normalized:"render"},into:{primary:"ukuman",normalized:"into"},before:{primary:"\xF1awpaq",normalized:"before"},after:{primary:"qhipa",normalized:"after"},until:{primary:"kama",alternatives:["-kama"],normalized:"until"},event:{primary:"ruwakuq",alternatives:["imayna"],normalized:"event"},from:{primary:"manta",alternatives:["-manta"],normalized:"from"},click:{primary:"\xF1itiy",normalized:"click"},load:{primary:"apakuy",normalized:"load"},submit:{primary:"apaykachay",normalized:"submit"},hover:{primary:"hawachiy",normalized:"hover"},input:{primary:"yaykuchiy",normalized:"input"},change:{primary:"kambiay",normalized:"change"},connect:{primary:"tinkiy",alternatives:["watay","hukllachay"],normalized:"connect"},stream:{primary:"phawachiy",alternatives:["sururichiy","ch'uquchiy"],normalized:"stream"},live:{primary:"kawsachkaq",alternatives:["kunan-pacha","kawsay"],normalized:"live"},socket:{primary:"tinkina",alternatives:["t'oqo","tinkiy-tinkina"],normalized:"socket"}},eventHandler:{keyword:{primary:"pi",alternatives:["kaqtin"]},sourceMarker:{primary:"manta",position:"after"},eventMarker:{primary:"pi",alternatives:["kaqtin","kaqpi"],position:"after"}}};function Ci(a){let e=a.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:a==="\xF1"||a==="\xD1"||a==="'"||a==="'"}function Ai(a){for(let e of a)if(Ci(e))return true;return false}var Di=[{pattern:"shankichik",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"shaniku",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"shanki",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"shani",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"shanchik",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"shanku",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"shan",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"rqankichik",confidence:.8,conjugationType:"past",minStemLength:2},{pattern:"rqaniku",confidence:.8,conjugationType:"past",minStemLength:2},{pattern:"rqanki",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"rqani",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"rqanchik",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"rqanku",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"rqan",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"nqankichik",confidence:.8,conjugationType:"future",minStemLength:2},{pattern:"nqaniku",confidence:.8,conjugationType:"future",minStemLength:2},{pattern:"nqanki",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"nqani",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"nqanchik",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"nqanku",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"nqa",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"chikuy",confidence:.8,conjugationType:"compound",minStemLength:2},{pattern:"chiku",confidence:.82,conjugationType:"compound",minStemLength:2},{pattern:"chiy",confidence:.85,conjugationType:"causative",minStemLength:2,replacement:"y"},{pattern:"chiq",confidence:.85,conjugationType:"causative",minStemLength:2,replacement:"y"},{pattern:"chi",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"kuy",confidence:.82,conjugationType:"reflexive",minStemLength:2},{pattern:"rqa",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"rqan",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"sha",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"na",confidence:.85,conjugationType:"obligation",minStemLength:2},{pattern:"manmi",confidence:.8,conjugationType:"potential",minStemLength:2},{pattern:"man",confidence:.8,conjugationType:"potential",minStemLength:2},{pattern:"nkichik",confidence:.8,conjugationType:"present",minStemLength:2},{pattern:"niku",confidence:.8,conjugationType:"present",minStemLength:2},{pattern:"nki",confidence:.82,conjugationType:"present",minStemLength:2},{pattern:"nchik",confidence:.82,conjugationType:"present",minStemLength:2},{pattern:"nku",confidence:.82,conjugationType:"present",minStemLength:2},{pattern:"ni",confidence:.85,conjugationType:"present",minStemLength:2},{pattern:"ku",confidence:.82,conjugationType:"reflexive",minStemLength:2},{pattern:"ychik",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"y",confidence:.9,conjugationType:"dictionary",minStemLength:2},{pattern:"sqa",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"ska",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"kama",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"manta",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"man",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"wan",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"pi",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"ta",confidence:.7,conjugationType:"dictionary",minStemLength:2}],Si=class{constructor(){this.language="qu";}isNormalizable(a){return !(!Ai(a)||a.length<3||!/[aiu]/.test(a.toLowerCase()))}normalize(a){let e=a.toLowerCase();for(let r of Di)if(e.endsWith(r.pattern)){let t=e.slice(0,-r.pattern.length);r.replacement&&!t.endsWith(r.replacement)&&(t=t+r.replacement);let i=r.minStemLength??2;if(t.length<i||!this.isValidStem(t))continue;let n={removedSuffixes:[r.pattern]};return r.conjugationType&&(n.conjugationType=r.conjugationType),Ne(t,r.confidence,n)}return Oe(a)}isValidStem(a){return !(a.length<2||!/[aeiou]/.test(a)||new Set(["ta","man","pi","wan","pa","kama","hina"]).has(a))}},xi=new Si,Bi=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Ti=class{constructor(a=Bi){this.name="operator",this.operators=[...a].sort((e,r)=>r.length-e.length);}canExtract(a,e){return this.operators.some(r=>a.startsWith(r,e))}extract(a,e){for(let r of this.operators)if(a.startsWith(r,e))return {value:r,length:r.length};return null}},Fi="()[]{},:;",Pi=class{constructor(a=Fi){this.punctuation=a,this.name="punctuation";}canExtract(a,e){return this.punctuation.includes(a[e])}extract(a,e){let r=a[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Ri(a,e){let r=a[e];if(r==="#"){let t=a.slice(e).match(/^#[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="."){let t=a.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="["){let t=0,i=e;for(;i<a.length;){if(a[i]==="["&&t++,a[i]==="]"&&(t--,t===0))return a.slice(e,i+1);i++;}return null}if(r==="<"){let t=a.slice(e).match(/^<[\w-]+(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return t?t[0]:null}return null}var _i=class{constructor(){this.name="css-selector";}canExtract(a,e){let r=a[e];return r==="#"||r==="."||r==="["||r==="<"}extract(a,e){let r=Ri(a,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Oi=class{constructor(){this.name="event-modifier";}canExtract(a,e){if(a[e]!==".")return false;let r=a.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(a,e){let r=a.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let t=r[0],i=t.slice(1).split("(")[0],n=r[1];return {value:t,length:t.length,metadata:{modifierName:i,value:n?i==="queue"?n:parseInt(n,10):void 0}}}};function Ni(a,e){let r=a.slice(e);if(r.startsWith("http://")||r.startsWith("https://")){let t=r.match(/^https?:\/\/[^\s]*/);return t?t[0]:null}if(r.startsWith("//")){let t=r.match(/^\/\/[^\s]*/);return t?t[0]:null}if(r.startsWith("./")||r.startsWith("../")){let t=r.match(/^\.\.?\/[^\s]*/);return t?t[0]:null}if(r.startsWith("/")){let t=r.match(/^\/[^\s]*/);return t?t[0]:null}return null}var Mi=class{constructor(){this.name="url";}canExtract(a,e){let r=a.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(a,e){let r=Ni(a,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Li=class{constructor(){this.name="variable-ref";}canExtract(a,e){return a[e]===":"&&e+1<a.length&&/[a-zA-Z_]/.test(a[e+1])}extract(a,e){if(!this.canExtract(a,e))return null;let r=1;for(;e+r<a.length&&/[a-zA-Z0-9_]/.test(a[e+r]);)r++;return {value:a.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function ke(a){let e=a.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:a==="\xF1"||a==="\xD1"||a==="'"||a==="\u2019"}var Ii=new Set(["-ta","-man","-manta","-pi","-wan","-paq","-kama","-rayku","-hina","ta","man","manta","pi","wan","paq","kama","hina","pa"]),ji=new Set(["kama","hina","rayku","paq"]),qi=class{constructor(){this.name="quechua-keyword";}setContext(a){this.context=a;}canExtract(a,e){return ke(a[e])}extract(a,e){if(!this.context)throw new Error("QuechuaKeywordExtractor: context not set");let r=e,t=12;for(let l=Math.min(t,a.length-r);l>=2;l--){let c=a.slice(r,r+l),m=true;for(let d=0;d<c.length;d++)if(!ke(c[d])){m=false;break}if(!m)continue;let p=this.context.lookupKeyword(c);if(p)return {value:c,length:l,metadata:{normalized:p.normalized!==p.native?p.normalized:void 0}};if(this.context.normalizer){let d=this.context.normalizer.normalize(c);if(d.stem!==c&&d.confidence>=.7){let y=this.context.lookupKeyword(d.stem);if(y)return {value:c,length:l,metadata:{normalized:y.normalized}}}}}let i="",n=e;for(;n<a.length&&ke(a[n])&&!(i.length>0&&this.context.isKeywordStart(a,n));)i+=a[n],n++;if(!i)return null;if(Ii.has(i.toLowerCase()))return {value:i,length:n-r,metadata:{suffixValue:i.toLowerCase()}};if(ji.has(i.toLowerCase()))return {value:i,length:n-r,metadata:{postpositionValue:i.toLowerCase()}};let o=this.context.lookupKeyword(i),u=o&&o.normalized!==o.native?o.normalized:void 0,s;if(!o&&this.context.normalizer){let l=this.context.normalizer.normalize(i);if(l.stem!==i&&l.confidence>=.7){let c=this.context.lookupKeyword(l.stem);c&&(s=c.normalized);}}return {value:i,length:n-r,metadata:{normalized:u||s}}}};function $i(){return new qi}function Vi(){return [new Mi,new Oi,new Li,new _i]}var Wi=class{constructor(){this.name="quechua-string-literal";}canExtract(a,e){return a[e]==='"'}extract(a,e){let r=a[e],t=r,i=e+1;for(;i<a.length;){let n=a[i];if(n===r)return t+=n,{value:t,length:t.length};n==="\\"&&i+1<a.length?(t+=n+a[i+1],i+=2):(t+=n,i++);}return null}},Ki=new Set(["-ta","-man","-manta","-pi","-wan","-paq","-kama","-rayku","-hina","ta","man","manta","pi","wan","paq","kama","hina","pa"]),Ui=[{native:"ar\xED",normalized:"true"},{native:"ari",normalized:"true"},{native:"manan",normalized:"false"},{native:"mana",normalized:"false"},{native:"ch'usaq",normalized:"null"},{native:"chusaq",normalized:"null"},{native:"mana riqsisqa",normalized:"undefined"},{native:"\xF1awpaq",normalized:"first"},{native:"nawpaq",normalized:"first"},{native:"qhipa",normalized:"last"},{native:"hamuq",normalized:"next"},{native:"\xF1awpaq kaq",normalized:"previous"},{native:"\xF1awpaq_kaq",normalized:"previous"},{native:"aswan qayllaqa",normalized:"closest"},{native:"tayta",normalized:"parent"},{native:"llikllay",normalized:"click"},{native:"\xF1itiy",normalized:"click"},{native:"click",normalized:"click"},{native:"yaykuy",normalized:"input"},{native:"llave uray",normalized:"keydown"},{native:"llave hawa",normalized:"keyup"},{native:"mausiri yayku",normalized:"mouseover"},{native:"mausiri lluqsi",normalized:"mouseout"},{native:"qhaway",normalized:"focus"},{native:"mana qhaway",normalized:"blur"},{native:"kargay",normalized:"load"},{native:"muyuy",normalized:"scroll"},{native:"\xF1uqa",normalized:"me"},{native:"nuqa",normalized:"me"},{native:"\xF1uqap",normalized:"my"},{native:"nuqap",normalized:"my"},{native:"chay",normalized:"it"},{native:"chaymi",normalized:"it"},{native:"lluqsiy",normalized:"result"},{native:"ruway",normalized:"event"},{native:"maypi",normalized:"target"},{native:"sikundu",normalized:"s"},{native:"segundu",normalized:"s"},{native:"waranqa sikundu",normalized:"ms"},{native:"minutu",normalized:"m"},{native:"ura",normalized:"h"},{native:"hora",normalized:"h"},{native:"chaypim",normalized:"on"},{native:"kaypi",normalized:"on"},{native:"chayqa",normalized:"then"},{native:"chaymanta",normalized:"then"},{native:"chaymantataq",normalized:"then"},{native:"hinaspa",normalized:"then"},{native:"tukukuy",normalized:"end"},{native:"puchukay",normalized:"end"},{native:"kaykama",normalized:"until"},{native:"yapay",normalized:"add"},{native:"t'ikray",normalized:"toggle"},{native:"tikray",normalized:"toggle"},{native:"qhawachiy",normalized:"focus"},{native:"mana qhawachiy",normalized:"blur"},{native:"-manta",normalized:"from"}],Hi=class extends _e{constructor(){super(),this.language="qu",this.direction="ltr",this.initializeKeywordsFromProfile(yr,Ui),this.setNormalizer(xi),this.registerExtractors(Vi()),this.registerExtractor(new Wi),this.registerExtractor(new Fe),this.registerExtractor($i()),this.registerExtractor(new Ti),this.registerExtractor(new Pi);}classifyToken(a){let e=a.toLowerCase();return Ki.has(e)?"particle":this.isKeyword(e)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(a)?"event-modifier":a.startsWith("#")||a.startsWith(".")||a.startsWith("[")||a.startsWith("*")||a.startsWith("<")?"selector":a.startsWith('"')||/^\d/.test(a)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(a)?"operator":"identifier"}},Gi=new Hi;ar("qu",Gi,yr);function ce(a){let e=a.getAttribute("data-lang");if(e)return be(e);let r=a.getAttribute("data-hyperscript-lang")??a.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return be(r);let t=typeof document<"u"?document.documentElement?.lang:null;return t&&t!=="en"?be(t):null}function be(a){return a.split("-")[0].toLowerCase()}var fr={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],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",""]],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"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","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"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],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",""]]};function me(a){switch(a.kind){case "event-handler":return Yi(a);case "compound":return Qi(a);default:return Ji(a)}}function Yi(a){let e=["on"],r=a.roles.get("event");r&&e.push(te(r));let t=a.roles.get("source");if(t&&e.push("from",te(t)),a.body&&a.body.length>0){let i=a.body.map(me);e.push(i.join(" then "));}return e.join(" ")}function Qi(a){let e=a.chainType==="async"?"async":a.chainType;return a.statements.map(me).join(` ${e} `)}function Ji(a){let e=fr[a.action];if(e){let t=[a.action];for(let[i,n]of e){let o=a.roles.get(i);o&&(i==="destination"&&o.type==="reference"&&o.value==="me"||(n&&t.push(n),t.push(te(o))));}return t.join(" ")}let r=[a.action];for(let[,t]of a.roles)r.push(te(t));return r.join(" ")}function te(a){switch(a.type){case "literal":return typeof a.value=="string"&&a.dataType==="string"?`"${a.value}"`:String(a.value);case "selector":return a.value;case "reference":return a.value;case "property-path":return Xi(a);case "expression":return a.raw;case "flag":return a.enabled?`+${a.name}`:`~${a.name}`}}function Xi(a){let e=te(a.object),r=a.property;if(a.object.type==="reference")switch(a.object.value){case "me":return `my ${r}`;case "it":return `its ${r}`;case "you":return `your ${r}`}return `${e}'s ${r}`}var vr=.5,Zi={confidenceThreshold:vr,strategy:"semantic",fallbackToOriginal:true};function en(a,e){return typeof a=="number"?a:a[e]??a["*"]??vr}function we(a,e,r={}){let t={...Zi,...r},i=hr(a,e,t);if(i!==null)return i;let n=tn(a);if(n){let o=hr(n.commands,e,t);if(o!==null)return n.prefix+o}return a}function hr(a,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let t=en(r.confidenceThreshold,e),i=gr(a,e,t);if(i!==null)return i}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let t=an(a,e,r.i18nToEnglish);if(t!==null)return t}return null}var rn=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function tn(a){let e=a.match(rn);if(!e)return null;let r=e[1],t=a.slice(r.length);return t?{prefix:r,commands:t}:null}function gr(a,e,r){try{let t=on(a,e);if(t.length>1)return un(t,e,r);if(!nr(e))return null;let i=lr(a,e);return i.confidence<r||!i.node?null:me(i.node)}catch{return null}}function an(a,e,r){try{let t=r(a,e);return t!==a?t:null}catch{return null}}function nn(a){let e=["then"],r=L(a);if(r?.keywords?.then){let t=r.keywords.then;if(t.primary&&t.primary!=="then"&&e.push(t.primary),t.alternatives)for(let i of t.alternatives)e.includes(i)||e.push(i);}return e}function on(a,e){let t=nn(e).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\s+(?:${t.join("|")})\\s+`,"i"),n=a.split(`
|
|
4
|
-
`).map(u=>u.trim()).filter(u=>u.length>0),o=[];for(let u of n){let s=u.split(i);o.push(...s);}return o}function un(a,e,r){let t=[];for(let i of a){let n=gr(i.trim(),e,r);if(n===null)return null;t.push(n);}return t.join(" then ")}function Ce(a={}){return function(r){let{internals:t}=r,i=t.runtime,n=i.getScript.bind(i);i.getScript=function(o){let u=n(o);if(!u)return null;let s=sn(o,a);if(!s||s==="en")return u;let l=we(u,s,a);return a.debug&&l!==u&&console.log(`[hyperscript-i18n] ${s}: "${u}" \u2192 "${l}"`),l};}}function sn(a,e){if(e.languageAttribute){let t=a.getAttribute(e.languageAttribute);if(t)return t.split("-")[0].toLowerCase()}let r=ce(a);return r||(e.defaultLanguage??null)}function Er(a,e,r={}){return e==="en"?a:we(a,e,r)}ir(a=>pr(a));function zr(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Ce()),ln());}function ln(){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(t=>{let i=e.getInternalData(t);i.initialized&&(i.initialized=false);}),e.processNode(document.body);}var Ro=["qu"];zr();exports.plugin=Ce;exports.preprocess=Er;exports.resolveLanguage=ce;exports.supportedLanguages=Ro;return exports;})({});
|
|
1
|
+
var HyperscriptI18n=(function(exports){'use strict';function re(i,e){return e?{type:"literal",value:i,dataType:e}:{type:"literal",value:i}}function _e(i,e){return e?{type:"selector",value:i,selectorKind:e}:{type:"selector",value:i}}function Te(i){return {type:"reference",value:i}}function Ie(i,e){return {type:"property-path",object:i,property:e}}var sr=new Set(["me","you","it","result","event","target","body"]);function He(i,e=sr){return e.has(i)}var lt=class{constructor(i){this.namespace=i,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let i=process.env.DEBUG||"";return i==="*"||i.includes("framework:*")||i.includes(`framework:${this.namespace}`)}return false}log(i,e,...r){if(!this.enabled)return;let t=`[framework:${this.namespace}]`,a=new Date().toISOString();switch(i){case "debug":console.debug(`${a} ${t} DEBUG:`,e,...r);break;case "info":console.info(`${a} ${t} INFO:`,e,...r);break;case "warn":console.warn(`${a} ${t} WARN:`,e,...r);break;case "error":console.error(`${a} ${t} ERROR:`,e,...r);break}}debug(i,...e){this.log("debug",i,...e);}info(i,...e){this.log("info",i,...e);}warn(i,...e){this.log("warn",i,...e);}error(i,...e){this.log("error",i,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function ct(i){return new lt(i)}function ke(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function mt(i,e){return i?.possessive?.keywords?.[e]}var Oe=class be{constructor(){this.logger=ct("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,t){let a=e.mark(),n=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let s=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)s.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",s),this.logger.debug("Profile code:",t?.code);}this.currentProfile=t,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(r.template.tokens,null,2));let o=this.matchTokenSequence(e,r.template.tokens,n);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(n.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(a),null;let u=this.calculateConfidence(r,n);return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-a.position,confidence:u}}matchBest(e,r,t){let a=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,t);s&&a.push(s),e.reset(u);}if(a.length===0)return null;a.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let n=a[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t,a){let n=r[0],o=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=null,s=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let m=e.peek();if(this.logger.debug(" >> Current input token:",m?JSON.stringify({type:m.type,value:m.value,kind:m.kind}):"EOF"),c.type==="role"&&c.greedy){let f=this.collectStopMarkers(r,l+1);if(a)for(let b of a)f.add(b);let g=[];for(;!e.isAtEnd();){let b=e.peek();if(!b||this.isStopMarker(b,f))break;g.push(b.value),e.advance();}if(g.length>0){t.set(c.role,{type:"expression",raw:g.join(" ")}),u=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let f=this.collectStopMarkers(r,l+1);if(a)for(let b of a)f.add(b);if(this.matchGroupToken(e,c,t,f)){u=null,s=null;continue}if(this.isOptional(c))continue;return false}let p=c.type==="role"&&c.optional===true,d=p?e.mark():null;if(c.type==="role"&&!p){let f=l+1<r.length?r[l+1]:null;if(f?.type==="literal"){let g=e.peek();if(g&&this.getMatchType(g,f.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(c))continue;if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let b=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",b),b)continue}return false}}}let v=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Match result:",v),v){p?(u=d,s=c.role):(u=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let f=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",f),f)continue}return false}}return true}matchPatternToken(e,r,t){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t);case "group":return this.matchGroupToken(e,r,t);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",t?JSON.stringify({type:t.type,value:t.value,kind:t.kind}):"null"),!t)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let a=this.getMatchType(t,r.value);if(this.logger.debug(" >>> matchType for",t.value,"vs",r.value,":",a),a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let o=this.getMatchType(t,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,t){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",r.role),this.logger.debug(" >>> matchRoleToken: expected types",r.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",r.optional),this.skipNoiseWords(e);let a=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",a?JSON.stringify({value:a.value,kind:a.kind}):"null"),!a)return r.optional||false;let n=this.tryMatchPossessiveExpression(e);if(n)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(n.type,r.expectedTypes)?r.optional||false:(t.set(r.role,n),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(o.type,r.expectedTypes)?r.optional||false:(t.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:(t.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:(t.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:(t.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",a?JSON.stringify({value:a.value,kind:a.kind}):"null");let c=this.tokenToSemanticValue(a);return this.logger.debug(" >>> tokenToSemanticValue returned:",c?JSON.stringify(c):"null"),c?(this.logger.debug(" >>> Validating type:",c.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!ke(c.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),t.set(r.role,c),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=r.normalized||r.value,a=this.safeToLowerCase(t),n=mt(this.currentProfile,a);if(!n)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),Ie(Te(n),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),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}.${n.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=`${r.value}.${n.value}`,u=1;for(;!e.isAtEnd()&&u<be.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<be.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(c===0){e.advance();break}c--;}if(p.kind==="punctuation"&&p.value==="("&&c++,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 t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="'s")return e.reset(t),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(t),null):(e.advance(),Ie(_e(r.value),n.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(t),null;let n=e.peek(1);n&&n.kind,e.advance();let o=a.value.slice(1);return Ie(_e(r.value),o)}matchGroupToken(e,r,t,a){let n=e.mark(),o=new Set(t.keys());if(this.matchTokenSequence(e,r.tokens,t,a))return true;e.reset(n);for(let l of t.keys())o.has(l)||t.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=be.MAX_MARKER_SCAN;l++){let c=e.peek(l);if(!c)break;if((c.normalized||c.value).toLowerCase()===s){this.logger.debug(" >> MARKER SCAN: found",s,"at offset",l,"- skipping intervening tokens");for(let d=0;d<l;d++)e.advance();if(this.matchTokenSequence(e,r.tokens,t,a))return true;e.reset(n);for(let d of t.keys())o.has(d)||t.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 t=new Set;for(let a=r;a<e.length;a++){let n=e[a];if(n.type==="literal"){if(t.add(n.value.toLowerCase()),n.alternatives)for(let o of n.alternatives)t.add(o.toLowerCase());break}if(n.type==="group"){for(let o of n.tokens)if(o.type==="literal"){if(t.add(o.value.toLowerCase()),o.alternatives)for(let u of o.alternatives)t.add(u.toLowerCase());break}if(!n.optional)break}}return t}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 Te(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 a=e.slice(1,-1);return re(a,"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 a=parseFloat(r[1]);return r[2]?re(e,"duration"):re(a,"number")}let t=parseFloat(e);return isNaN(t)?re(e,"string"):re(t,"number")}applyExtractionRules(e,r){for(let[t,a]of Object.entries(e.extraction))r.has(t)||(a.value!==void 0?r.set(t,{type:"literal",value:a.value}):a.default&&r.set(t,a.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let t=0,a=0,n=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")a+=1,r.has(l.role)&&(t+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let m=n(c.role),p=.8;a+=p,r.has(c.role)?t+=p:m&&(t+=p*.6);}}let o=a>0?t/a: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 t=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(t.has(r.value))return .15;if(r.alternatives){for(let a of r.alternatives)if(t.has(a))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let t=0,a={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[n,o]of r.entries()){let u=a[n];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?t+=.1:t-=.1;}}return Math.max(-0.1,Math.min(.1,t))}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=this.safeToLowerCase(r.value);if(be.ENGLISH_NOISE_WORDS.has(t)){let a=e.mark();e.advance();let n=e.peek();if(n&&n.kind==="selector")return;e.reset(a);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(t=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return t?r:void 0}};Oe.MAX_MARKER_SCAN=3;Oe.MAX_PROPERTY_DEPTH=10;Oe.MAX_METHOD_ARGS=20;Oe.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var pt=Oe;new pt;var mr=class{constructor(){this.name="number";}canExtract(i,e){return /\d/.test(i[e])}extract(i,e){let r=0,t=false;for(;e+r<i.length;){let o=i[e+r];if(/\d/.test(o))r++;else if(o==="."&&!t)t=true,r++;else break}if(r===0)return null;let a=i.substring(e,e+r),n=e+r;if(n<i.length){let o=i.slice(n),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value:a+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:a+"ms",length:r+2,metadata:{hasTimeUnit:true}};let s=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of s)if(o.startsWith(l.pattern))return {value:a+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:a+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:a,length:r}}};function dt(i){return "setContext"in i&&typeof i.setContext=="function"}function yt(i){let e={language:i.language,direction:i.direction,lookupKeyword:i.lookupKeyword.bind(i),isKeyword:i.isKeyword.bind(i),isKeywordStart:i.isKeywordStart.bind(i),...i.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:i.isKeywordStartAtBoundary.bind(i)}:{}};return i.normalizer?{...e,normalizer:i.normalizer}:e}var te=class{constructor(i,e){this.pos=0,this.tokens=i,this.language=e;}peek(i=0){let e=this.pos+i;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(i){this.pos=i.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(i){let e=[];for(;!this.isAtEnd()&&i(this.peek());)e.push(this.advance());return e}skipWhile(i){for(;!this.isAtEnd()&&i(this.peek());)this.advance();}};function I(i,e){return {start:i,end:e}}function j(i,e,r,t){if(typeof i=="object"){let{value:n,kind:o,position:u,normalized:s,stem:l,stemConfidence:c,metadata:m}=i;return {value:n,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...m!==void 0&&{metadata:m}}}let a=i;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof t=="string")return {value:a,kind:e,position:r,normalized:t};if(t){let{normalized:n,stem:o,stemConfidence:u,metadata:s}=t;return {value:a,kind:e,position:r,...n!==void 0&&{normalized:n},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:a,kind:e,position:r}}function Fe(i){return /\s/.test(i)}function ft(i){return i==="#"||i==="."||i==="["||i==="@"||i==="*"||i==="<"}function ht(i){return i==='"'||i==="'"||i==="`"||i==="\u300C"||i==="\u300D"}function pe(i){return /\d/.test(i)}function vt(i){return /[a-zA-Z]/.test(i)}function W(i){return /[a-zA-Z0-9_-]/.test(i)}function Et(i,e){if(e>=i.length)return null;let r=i[e];if(!ft(r))return null;let t=e,a="";if(r==="#"||r==="."){for(a+=i[t++];t<i.length&&W(i[t]);)a+=i[t++];if(a.length<=1)return null;if(t<i.length&&i[t]==="."&&r==="#"){let o=t+1;for(;o<i.length&&W(i[o]);)o++;if(o<i.length&&i[o]==="(")return a}}else if(r==="["){let n=1,o=false,u=null,s=false;for(a+=i[t++];t<i.length&&n>0;){let l=i[t];a+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?n++:l==="]"&&n--,t++;}if(n!==0)return null}else if(r==="@"){for(a+=i[t++];t<i.length&&W(i[t]);)a+=i[t++];if(a.length<=1)return null}else if(r==="*"){for(a+=i[t++];t<i.length&&W(i[t]);)a+=i[t++];if(a.length<=1)return null}else if(r==="<"){if(a+=i[t++],t>=i.length||!vt(i[t]))return null;for(;t<i.length&&W(i[t]);)a+=i[t++];for(;t<i.length;){let n=i[t];if(n==="."){if(a+=i[t++],t>=i.length||!W(i[t]))return null;for(;t<i.length&&W(i[t]);)a+=i[t++];}else if(n==="#"){if(a+=i[t++],t>=i.length||!W(i[t]))return null;for(;t<i.length&&W(i[t]);)a+=i[t++];}else if(n==="["){let o=1,u=false,s=null,l=false;for(a+=i[t++];t<i.length&&o>0;){let c=i[t];a+=c,l?l=false:c==="\\"?l=true:u?c===s&&(u=false,s=null):c==='"'||c==="'"||c==="`"?(u=true,s=c):c==="["?o++:c==="]"&&o--,t++;}if(o!==0)return null}else break}for(;t<i.length&&Fe(i[t]);)a+=i[t++];if(t<i.length&&i[t]==="/")for(a+=i[t++];t<i.length&&Fe(i[t]);)a+=i[t++];if(t>=i.length||i[t]!==">")return null;a+=i[t++];}return a||null}function gt(i,e){if(e>=i.length||i[e]!=="'"||e+1>=i.length||i[e+1].toLowerCase()!=="s")return false;if(e+2>=i.length)return true;let t=i[e+2];return Fe(t)||t==="*"||!W(t)}function zt(i,e){if(e>=i.length)return null;let r=i[e];if(!ht(r)||r==="'"&>(i,e))return null;let a={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!a)return null;let n=e+1,o=r,u=false;for(;n<i.length;){let s=i[n];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===a)return o;n++;}return o}function kt(i,e){if(e>=i.length)return false;let r=i[e],t=i[e+1]||"",a=i[e+2]||"";if(r==="/"&&t!=="/"&&/[a-zA-Z0-9._-]/.test(t)||r==="/"&&t==="/"&&/[a-zA-Z]/.test(a)||r==="."&&(t==="/"||t==="."&&a==="/"))return true;let n=i.slice(e,e+8).toLowerCase();return !!(n.startsWith("http://")||n.startsWith("https://"))}function bt(i,e){if(!kt(i,e))return null;let r=e,t="",a=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<i.length;){let n=i[r];if(n==="#"){if(t.length>0&&/[a-zA-Z0-9/.]$/.test(t))for(t+=n,r++;r<i.length&&/[a-zA-Z0-9_-]/.test(i[r]);)t+=i[r++];break}if(a.test(n))t+=n,r++;else break}return t.length<2?null:t}function wt(i,e){if(e>=i.length)return null;let r=i[e];if(!pe(r)&&r!=="-"&&r!=="+")return null;let t=e,a="";if((i[t]==="-"||i[t]==="+")&&(a+=i[t++]),t>=i.length||!pe(i[t]))return null;for(;t<i.length&&pe(i[t]);)a+=i[t++];if(t<i.length&&i[t]===".")for(a+=i[t++];t<i.length&&pe(i[t]);)a+=i[t++];return t<i.length&&(i.slice(t,t+2)==="ms"?a+="ms":(i[t]==="s"||i[t]==="m"||i[t]==="h")&&(a+=i[t])),a}var Ct=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Ct);var At=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"]),Dt=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],pr=class dr{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){dt(e)&&e.setContext(yt(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=[],t=0;for(;t<e.length;){for(;t<e.length&&Fe(e[t]);)t++;if(t>=e.length)break;let a=this.tryMultiWordKeyword(e,t);if(a){r.push(a),t=a.position.end;continue}let n=false;for(let o of this.extractors)if(o.canExtract(e,t)){let u=o.extract(e,t);if(u){let s=u.metadata?.normalized,l=u.metadata?.stem,c=u.metadata?.stemConfidence,m={};if(u.metadata)for(let[d,y]of Object.entries(u.metadata))d!=="normalized"&&d!=="stem"&&d!=="stemConfidence"&&(m[d]=y);let p={};s&&(p.normalized=s),l&&(p.stem=l),c!==void 0&&(p.stemConfidence=c),Object.keys(m).length>0&&(p.metadata=m),r.push(j(u.value,this.classifyToken(u.value),I(t,t+u.length),Object.keys(p).length>0?p:void 0)),t+=u.length,n=true;break}}if(!n){let o=e[t],u=this.classifyUnknownChar(o);r.push(j(o,u,I(t,t+1))),t++;}}return new te(r,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,t){if(e[r]!==".")return false;let a=t[t.length-1],n=a&&a.position.end<r;if(a&&!n&&(a.kind==="identifier"||a.kind==="keyword"||a.kind==="selector"))return t.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]==="("?(t.push(j(".","operator",I(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let t=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[a,n]of Object.entries(e.keywords))if(t.set(n.primary,{native:n.primary,normalized:n.normalized||a}),n.alternatives)for(let o of n.alternatives)t.set(o,{native:o,normalized:n.normalized||a});}if(e.references){for(let[a,n]of Object.entries(e.references))t.set(n,{native:n,normalized:a});for(let a of Object.keys(e.references))t.has(a)||t.set(a,{native:a,normalized:a});}if(e.roleMarkers){for(let[a,n]of Object.entries(e.roleMarkers))if(n.primary&&t.set(n.primary,{native:n.primary,normalized:a}),n.alternatives)for(let o of n.alternatives)t.set(o,{native:o,normalized:a});}if(e.possessive?.keywords)for(let[a,n]of Object.entries(e.possessive.keywords))t.set(a,{native:a,normalized:n});for(let a of Dt)t.has(a)||t.set(a,{native:a,normalized:a});for(let a of r)t.set(a.native,a);this.profileKeywords=Array.from(t.values()).sort((a,n)=>n.native.length-a.native.length),this.multiWordKeywords=this.profileKeywords.filter(a=>a.native.includes(" ")&&!At.has(a.normalized)),this.profileKeywordMap=new Map;for(let a of this.profileKeywords){this.profileKeywordMap.set(a.native.toLowerCase(),a);let n=this.removeDiacritics(a.native);n!==a.native&&!this.profileKeywordMap.has(n.toLowerCase())&&this.profileKeywordMap.set(n.toLowerCase(),a);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,r){for(let t of this.profileKeywords)if(e.slice(r).startsWith(t.native))return j(t.native,"keyword",I(r,r+t.native.length),t.normalized);return null}tryMultiWordKeyword(e,r,t=a=>/[\p{L}\p{N}_]/u.test(a)){if(this.multiWordKeywords.length===0)return null;let a=e.slice(r);for(let n of this.multiWordKeywords){if(!a.startsWith(n.native))continue;let o=e[r+n.native.length];if(!(o!==void 0&&t(o)))return j(n.native,"keyword",I(r,r+n.native.length),n.normalized)}return null}isKeywordStart(e,r){let t=e.slice(r);return this.profileKeywords.some(a=>t.startsWith(a.native))}isKeywordStartAtBoundary(e,r,t=a=>/[\p{L}\p{N}_]/u.test(a)){let a=e.slice(r);return this.profileKeywords.some(n=>{if(!a.startsWith(n.native))return false;let o=e[r+n.native.length];return o===void 0||!t(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,t){let a=this.tryNormalize(e);if(!a)return null;let n=this.lookupKeyword(a.stem);if(!n)return null;let o={normalized:n.normalized,stem:a.stem,stemConfidence:a.confidence};return j(e,"keyword",I(r,t),o)}trySelector(e,r){let t=Et(e,r);return t?j(t,"selector",I(r,r+t.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let t=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!t)return null;let a=t[0].replace(/(\s|\.)$/,""),n=a.slice(1).split("(")[0],o=t[1];return {...j(a,"event-modifier",I(r,r+a.length)),metadata:{modifierName:n,value:o?n==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let t=zt(e,r);return t?j(t,"literal",I(r,r+t.length)):null}tryNumber(e,r){let t=wt(e,r);return t?j(t,"literal",I(r,r+t.length)):null}tryMatchTimeUnit(e,r,t,a=false){let n=r;if(a)for(;n<e.length&&Fe(e[n]);)n++;let o=e.slice(n);for(let u of t){let s=o.slice(0,u.length);if(u.caseInsensitive?s.toLowerCase()===u.pattern.toLowerCase():s===u.pattern){if(u.notFollowedBy&&(o[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let c=o[u.length]||"";if(W(c))continue}return {suffix:u.suffix,endPos:n+u.length}}}return null}parseBaseNumber(e,r,t=true){let a=r,n="";if(t&&(e[a]==="-"||e[a]==="+")&&(n+=e[a++]),a>=e.length||!pe(e[a]))return null;for(;a<e.length&&pe(e[a]);)n+=e[a++];if(a<e.length&&e[a]===".")for(n+=e[a++];a<e.length&&pe(e[a]);)n+=e[a++];return !n||n==="-"||n==="+"?null:{number:n,endPos:a}}tryNumberWithTimeUnits(e,r,t,a={}){let{allowSign:n=true,skipWhitespace:o=false}=a,u=this.parseBaseNumber(e,r,n);if(!u)return null;let{number:s,endPos:l}=u,c=[...t,...dr.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,o);return m&&(s+=m.suffix,l=m.endPos),j(s,"literal",I(r,l))}tryUrl(e,r){let t=bt(e,r);return t?j(t,"url",I(r,r+t.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!W(e[r+1]))return null;let t=r+1;for(;t<e.length&&W(e[t]);)t++;let a=e.slice(r,t);return j(a,"identifier",I(r,t))}tryOperator(e,r){let t=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(t))return j(t,"operator",I(r,r+2));let a=e[r];return ["<",">","!","+","-","*","/","="].includes(a)?j(a,"operator",I(r,r+1)):["(",")","{","}",",",";",":"].includes(a)?j(a,"punctuation",I(r,r+1)):null}tryMultiCharParticle(e,r,t){for(let a of t)if(e.slice(r,r+a.length)===a)return j(a,"particle",I(r,r+a.length));return null}};pr.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 yr=pr;function fr(i){return {stem:i,confidence:1}}function hr(i,e,r){return r?{stem:i,confidence:e,metadata:r}:{stem:i,confidence:e}}var St=Object.defineProperty,xt=Object.getOwnPropertyNames,Tr=(i,e)=>function(){return i&&(e=(0, i[xt(i)[0]])(i=0)),e},Bt=(i,e)=>{for(var r in e)St(i,r,{get:e[r],enumerable:true});};function vr(i,e){return i.replace(/\{(\w+)\}/g,(r,t)=>String(e[t]??`{${t}}`))}function G(i,e,r={},t){let a=Fr[i],n=vr(a,r),o=Or[i],u=o?vr(o,r):void 0;return {code:i,message:n,severity:e,...t&&{role:t},...u&&{suggestion:u}}}var x,Fr,Or,Tt=Tr({"src/generators/schema-error-codes.ts"(){x={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"},Fr={[x.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[x.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[x.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[x.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[x.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[x.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.",[x.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.",[x.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[x.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[x.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[x.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[x.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[x.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[x.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[x.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[x.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[x.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Or={[x.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[x.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[x.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[x.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[x.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[x.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[x.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[x.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[x.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[x.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[x.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[x.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[x.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[x.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),Rr={};Bt(Rr,{SchemaErrorCodes:()=>x,formatValidationResults:()=>Mt,getValidationStats:()=>_t,validateAllKeywordCollisions:()=>jt,validateAllSchemas:()=>Lt,validateCommandSchema:()=>Pr,validateKeywordCollisions:()=>Nr,validateRoleValues:()=>It});function Ft(i,e){return {action:i,items:e}}function Pr(i){let e=[];for(let t of i.roles)t.expectedTypes.includes("literal")&&t.expectedTypes.includes("selector")&&(t.role==="patient"&&Ye.has(i.action)?e.push(G(x.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:t.role,command:i.action},t.role)):e.push(G(x.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:t.role},t.role))),t.expectedTypes.length>3&&!Ye.has(i.action)&&e.push(G(x.TOO_MANY_EXPECTED_TYPES,"warning",{role:t.role,count:t.expectedTypes.length},t.role));for(let t of i.roles)t.selectorKinds&&t.selectorKinds.length>0&&(t.expectedTypes.includes("selector")||e.push(G(x.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:t.role},t.role)));switch(i.action){case "transition":Ot(i,e);break;case "on":Rt(i,e);break;case "if":case "unless":Pt(i,e);break;case "repeat":case "for":case "while":Nt(i,e);break}return i.roles.filter(t=>t.required).length===0&&(Lr.has(i.action)?e.push(G(x.NO_REQUIRED_ROLES_EXPECTED,"note",{command:i.action})):e.push(G(x.NO_REQUIRED_ROLES,"warning",{}))),Ft(i.action,e)}function Ot(i,e){let r=i.roles.find(a=>a.role==="patient"),t=i.roles.find(a=>a.role==="goal");r&&!t&&e.push(G(x.TRANSITION_MISSING_GOAL,"error",{}));}function Rt(i,e){let r=i.roles.find(t=>t.role==="event");r||e.push(G(x.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(G(x.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Pt(i,e){let r=i.roles.find(t=>t.role==="condition");r||e.push(G(x.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(G(x.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Nt(i,e){i.action==="for"?i.roles.find(t=>t.role==="source")||e.push(G(x.FOR_LOOP_MISSING_SOURCE,"warning",{})):i.action==="while"&&(i.roles.find(t=>t.role==="condition")||e.push(G(x.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Lt(i,e={}){let r=new Map,{includeNotes:t=false}=e;for(let[a,n]of Object.entries(i)){let o=Pr(n),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=t&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(a,o);}return r}function Mt(i,e={}){let r=[],{showNotes:t=false,showCodes:a=true}=e;for(let[n,o]of i){let u=o.items.filter(c=>c.severity==="error"),s=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(u.length>0){r.push(` \u274C ${n}:`);for(let c of u){let m=a?` [${c.code}]`:"";r.push(` ERROR${m}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(s.length>0){r.push(` \u26A0\uFE0F ${n}:`);for(let c of s){let m=a?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(t&&l.length>0){r.push(` \u2139\uFE0F ${n}:`);for(let c of l){let m=a?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`);}}}return r.join(`
|
|
2
|
+
`)}function _t(i){let e=0,r=0,t=0,a={};for(let n of i.values())for(let o of n.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&t++,a[o.code]=(a[o.code]||0)+1;return {totalCommands:i.size,errors:e,warnings:r,notes:t,byCode:a}}function It(i,e){let r=[];for(let t of e){let a=i.roles.find(n=>n.role===t.role);a&&(a.expectedTypes.length>0&&!a.expectedTypes.includes(t.type)&&(a.expectedTypes.includes("expression")||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects type [${a.expectedTypes.join(", ")}], got '${t.type}'`,code:x.VALUE_TYPE_MISMATCH})),t.type==="selector"&&t.selectorKind&&a.selectorKinds&&a.selectorKinds.length>0&&(a.selectorKinds.includes(t.selectorKind)||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects selector kind [${a.selectorKinds.join(", ")}], got '${t.selectorKind}'`,code:x.SELECTOR_KIND_MISMATCH})));}return r}function Nr(i){let e=[];if(!i.keywords)return {language:i.code,collisions:e};let r=new Map;for(let[a,n]of Object.entries(i.keywords)){if(!n||!n.primary)continue;let o=r.get(n.primary)||[];if(o.push({command:a,isPrimary:true}),r.set(n.primary,o),n.alternatives)for(let u of n.alternatives){let s=r.get(u)||[];s.push({command:a,isPrimary:false}),r.set(u,s);}}for(let[a,n]of r){let o=[...new Set(n.map(l=>l.command))];if(o.length<=1)continue;let u=n.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:a,commands:o.sort(),type:s});}let t={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((a,n)=>t[a.type]-t[n.type]),{language:i.code,collisions:e}}function jt(i){let e=[];for(let[,r]of Object.entries(i)){let t=Nr(r);t.collisions.length>0&&e.push(t);}return e.sort((r,t)=>r.language.localeCompare(t.language))}var Ye,Lr,qt=Tr({"src/generators/schema-validator.ts"(){Tt(),Ye=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Lr=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 fe=new Map,oe=new Map,Pe=new Map,Qe=null;function Mr(i,e){let r={...i};for(let t of Object.keys(e)){let a=e[t],n=i[t];a!==void 0&&(typeof a=="object"&&a!==null&&!Array.isArray(a)&&typeof n=="object"&&n!==null&&!Array.isArray(n)?r[t]=Mr(n,a):r[t]=a);}return r}function Vt(i,e){return Mr(i,e)}function er(i){if(!i.extends)return i;let e=oe.get(i.extends);if(!e)return console.warn(`[Registry] Profile '${i.code}' extends '${i.extends}' but base is not registered. Make sure to import the base language before the variant.`),i;let r=er(e);return Vt(r,i)}function _r(i,e,r){fe.set(i,e),oe.set(i,r),Pe.delete(i);}function Ir(i){Qe=i;}var Er=new Map;function Se(i){return i.split("-")[0]}function xe(i){return i.includes("-")}function $t(i){let e=fe.get(i);if(!e&&xe(i)){let r=Se(i);e=fe.get(r);}if(!e){let r=Array.from(fe.keys()).join(", ");throw new Error(`Language '${i}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return e}function Wt(i){let e=oe.get(i);if(!e&&xe(i)){let r=Se(i);e=oe.get(r);}if(!e){let r=Array.from(oe.keys()).join(", ");throw new Error(`Language profile '${i}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return er(e)}function L(i){let e=oe.get(i);return !e&&xe(i)&&(e=oe.get(Se(i))),e?er(e):void 0}function Kt(){return Array.from(fe.keys())}function jr(i){if(fe.has(i)&&oe.has(i))return true;if(xe(i)){let e=Se(i);return fe.has(e)&&oe.has(e)}return false}function Ut(i,e){return $t(e).tokenize(i)}function ne(i){let e=Pe.get(i);if(!e&&xe(i)&&(e=Pe.get(Se(i))),e)return e;let r=Er.get(i);if(!r&&xe(i)&&(r=Er.get(Se(i))),r)return Pe.set(i,r),r;if(!Qe)throw new Error(`No patterns registered for language '${i}'. Either import the language module or set a pattern generator.`);let t=Wt(i),a=Qe(t);return Pe.set(i,a),a}function ye(i){let e="complex";return i.startsWith("#")&&!i.includes(" ")?e="id":i.startsWith(".")&&!i.includes(" ")?e="class":i.startsWith("[")&&i.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(i)&&(e="element"),{type:"selector",value:i,selectorKind:e}}function _(i,e){let r={type:"literal",value:i};return e!==void 0?{type:"literal",value:i,dataType:e}:r}function we(i){return He(i)}function ie(i){return {type:"reference",value:i}}function de(i,e){return {type:"property-path",object:i,property:e}}function Q(i,e,r){let t={kind:"command",action:i,roles:new Map(Object.entries(e))};return r!==void 0?{...t,metadata:r}:t}function Re(i,e,r,t,a,n){let o=new Map;o.set("event",i);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),t!==void 0&&(u.metadata=t),a!==void 0&&a.length>0&&(u.parameterNames=a),u}function Ei(i,e,r,t,a){let n={kind:"behavior",action:"behavior",roles:new Map,name:i,parameters:e,eventHandlers:r};return t!==void 0&&t.length>0&&(n.initBlock=t),a!==void 0&&(n.metadata=a),n}function gi(i,e,r,t){let a={kind:"def",action:"def",roles:new Map,name:i,parameters:e,body:r};return t!==void 0&&(a.metadata=t),a}function Ze(i,e="then",r){let t={kind:"compound",action:"compound",roles:new Map,statements:i,chainType:e};return r!==void 0&&(t.metadata=r),t}function zi(i,e,r,t){let a=new Map;a.set("condition",i);let n={kind:"conditional",action:"if",roles:a,thenBranch:e};return r!==void 0&&(n.elseBranch=r),t!==void 0&&(n.metadata=t),n}function je(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):i==="expression"?e.some(r=>["selector","reference","expression"].includes(r)):false}function ve(i){let e=i.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function Ee(i){let e=i.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function ge(i,e){return qr(i,e,"source")}function rr(i,e){return qr(i,e,"destination")}function qr(i,e,r){if(!e||!i.roles.some(n=>n.role===r))return [];let t=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},a={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[a,t]:[t,a]}]}var ki={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)"}},bi={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"}},wi={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"}},Ci={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"}},Ai={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>"}},Di={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>"}},Si={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},xi={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Bi={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ti={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Fi={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Oi={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}]},Ri={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}]},Pi={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}]},Ni={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}]},Li={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}]},Mi={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}]},_i={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"}}]},Ii={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"}}]},ji={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"}}]},qi={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"}}]},Vi={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}]},$i={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}]},Wi={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}]},Ki={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}]},Ui={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}]},Hi={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}]},Gi={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}]},Yi={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"}}]},Qi={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}]},Zi={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}]},Xi={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Ji={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"'},ea={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"}}]},ra={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}]},ta={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},ia={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"]}}]},aa={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",omitRoleVariants:["goal"],roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal","expression","selector"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"zu",he:"\u05E2\u05DC",it:"in",ja:"\u306B",ko:"\uC5D0",ms:"ke",pl:"do",ru:"\u0432",th:"\u0E43\u0E19",tr:"e",uk:"\u0432",vi:"v\xE0o",zh:"\u5230",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},na={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"}}]},oa={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}]},ua={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}]},sa={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}]},la={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"}}]},ca={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}]},ma={action:"select",description:"Select the contents of a text field or DOM element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element whose contents to select (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},pa={action:"clear",description:"Clear a variable, local, or input element",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The variable or element to clear (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},da={action:"reset",description:"Reset a <form> element to its default values",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The form element to reset (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ya={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},fa={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}]},ha={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}]},va={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}]},Ea={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},ga={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},za={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta",ja:"\u3092",ko:"\uB97C",tr:"i",hi:"\u0915\u094B",de:"",es:"",fr:"",it:"",pt:"",pl:"",ru:"",uk:"",vi:"",id:"",ms:"",th:"",zh:"\u628A",he:"\u05D0\u05EA"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",ja:"\u306B",ko:"\uC5D0",tr:"e",hi:"\u092E\u0947\u0902",de:"zu",es:"a",fr:"\xE0",it:"in",pt:"para",pl:"do",ru:"\u0432",uk:"\u0432",vi:"v\xE0o",id:"ke",ms:"ke",th:"\u0E43\u0E19",zh:"\u5230",he:"\u05E2\u05DC"}}]},ka={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},ba={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}]},wa={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}]},Ca={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"}}]},Aa={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"}}]},Da={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"destination",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},Sa={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:false,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},xa={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Ba={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}]},Ta={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Fa={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}]},Oa={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",argSkipTokens:["of","the","top","bottom","middle","center","nearest","left","right","smoothly","instantly"],roles:[{role:"destination",description:"The element to scroll to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},Vr={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"},Ra={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},Pa={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:Vr}]},Na={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:Vr}]},La={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:Ra}]},Ma={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},he={toggle:ki,add:bi,remove:wi,put:Ci,set:Ai,show:Oi,hide:Ri,on:Pi,trigger:Ni,wait:Li,fetch:Mi,increment:_i,decrement:Ii,append:ji,prepend:qi,log:Vi,get:$i,take:Wi,make:Ki,halt:Ui,settle:Hi,throw:Gi,send:Yi,if:Qi,unless:Zi,else:Xi,repeat:Ji,for:ea,while:ra,continue:ta,go:ia,scroll:Oa,push:Pa,replace:Na,process:La,transition:aa,clone:na,focus:oa,blur:ua,empty:sa,open:la,close:ca,select:ma,clear:pa,reset:da,breakpoint:ya,call:fa,return:ha,js:va,async:Ea,tell:ga,default:za,init:ka,behavior:ba,install:wa,measure:Ca,swap:Aa,morph:Da,beep:Sa,break:xa,copy:Ba,exit:Ta,pick:Fa,render:Ma,bind:Di,live:Si,eventsource:xi,socket:Bi,worker:Ti,intercept:Fi,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function le(i){return he[i]}function _a(){return Object.values(he).filter(i=>i.roles.length>0||i.bareKeyword===true)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(qt(),Rr)).then(({validateAllSchemas:i,formatValidationResults:e})=>{let r=i(he);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(i=>{console.debug("Schema validation skipped:",i);});function se(i,e){let r=i.possessive?.keywords?.[e];if(r)return r;let t=i.possessive?.specialForms;if(t){for(let[a,n]of Object.entries(t))if(n===e)return a}}var $r=[{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 gr(i,e,r,t){let a=$r.find(o=>o.lang===i);if(!a)return false;let n=(o,u)=>(o??"").toLowerCase()===u.toLowerCase();return n(e,a.end)&&n(r,a.at)&&n(t,a.of)}function Ia(i,e){let r=$r.find(a=>a.lang===i);if(!r)return false;let t=e.toLowerCase();return t===r.at.toLowerCase()||t===r.of.toLowerCase()||t===r.end.toLowerCase()}var Ge=.8,ja=.6,qa=.15,Va=.5,zr=.15,kr=.1,br=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"]),$a={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]},Wa=class{calculate(i){return this.calculateWithBreakdown(i).final}calculateWithBreakdown(i){let e=this.scoreRoleCoverage(i),r=this.scoreStemPenalty(i),t=this.scoreLanguageBoost(i),a=this.scoreLanguageAdjustment(i),n=e;return n=Math.max(Va,n+r),n=Math.min(1,n+t),n=Math.max(0,Math.min(1,n+a)),{roleCoverage:e,stemPenalty:r,languageBoost:t,languageAdjustment:a,final:n}}scoreRoleCoverage(i){let{pattern:e,captured:r}=i,t=0,a=0,n=o=>e.extraction?.[o]?.default!==void 0;for(let o of e.template.tokens)if(o.type==="role")a+=1,r.has(o.role)&&(t+=1);else if(o.type==="group")for(let u of o.tokens)u.type==="role"&&(a+=Ge,r.has(u.role)?t+=Ge:n(u.role)&&(t+=Ge*ja));return a>0?t/a:1}scoreStemPenalty(i){let{stemMatchCount:e,totalKeywordMatches:r}=i;return e<=0||r<=0?0:-(e/r)*qa}scoreLanguageBoost(i){let{pattern:e}=i;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:br.has(r.value)||r.alternatives?.some(t=>br.has(t))?zr:0}scoreLanguageAdjustment(i){let{pattern:e,captured:r}=i;if(e.language!=="ar")return 0;let t=0;for(let[a,n]of r.entries()){let o=$a[a];if(!o||o.length===0)continue;let u="metadata"in n?n.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?t+=.1:t-=.1);}return Math.max(-kr,Math.min(kr,t))}},Ka=new Wa,Ua=new Set(Object.values(he).filter(i=>i.bareKeyword===true).map(i=>i.action)),U=class P{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Ka;}matchPattern(e,r){let t=e.mark(),a=new Map;if(this.currentProfile=L(r.language),this.currentPatternCommand=r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,r.template.tokens,a))return e.reset(t),null;let o=this.confidenceModel.calculate({pattern:r,captured:a,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-t.position,confidence:o}}matchBest(e,r){this.matchCache.clear();let t=[],a=e.position();for(let o of r){let u=e.mark(),s=`${a}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&t.push(l),e.reset(u);}if(t.length===0)return null;t.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.confidence-o.confidence});let n=t[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t,a){let n=r[0],o=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=0;for(let s=0;s<r.length;s++){let l=r[s];u>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,t,l);let c=this.matchPatternToken(e,l,t,r[s+1]??a);if(u=l.type==="role"&&l.role==="event"?2:Math.max(0,u-1),!c){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,t){if(r.has("source"))return;let a=e.peek(),n=e.peek(1);if(!a||!n||this.patternTokenWouldMatch(t,a))return;let o=this.currentProfile?.roleMarkers?.source,u=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let c=l.value.toLowerCase();return o.primary?.toLowerCase()===c?true:!!o.alternatives?.some(m=>m.toLowerCase()===c)},s=o?.position;if(s!=="after"&&u(a)&&n.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(s==="after"&&a.kind==="selector"&&u(n)){let l=this.tokenToSemanticValue(a);e.advance(),e.advance(),l&&r.set("source",l);}}matchPatternToken(e,r,t,a){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t,a);case "group":return this.matchGroupToken(e,r,t,a);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(!t)return false;let a=this.getMatchType(t,r.value);if(a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let o=this.getMatchType(t,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let n of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(n.includes(o)&&this.tryMatchShatteredCompound(e,n,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let t=e.mark(),a=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;a.push(o.value),e.advance();let u=e.peek();if(!u||u.value!=="-")break;e.advance(),a.push("-");}if(a.length<3||a[a.length-1]==="-")return e.reset(t),null;let n=a.join("").toLowerCase();for(let[o,u]of Object.entries(r.keywords))if(u.primary.toLowerCase()===n||u.alternatives?.some(s=>s.toLowerCase()===n))return _(o);return e.reset(t),null}tryMatchShatteredCompound(e,r,t){let a=r.split(t);if(a.length<2||a.some(o=>o.length===0))return false;let n=e.mark();for(let o=0;o<a.length;o++){if(o>0){let s=e.peek();if(!s||s.value!==t)return e.reset(n),false;e.advance();}let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword"&&u.kind!=="particle"||u.value.toLowerCase()!==a[o].toLowerCase())return e.reset(n),false;e.advance();}return true}matchRoleToken(e,r,t,a){this.skipNoiseWords(e);let n=e.peek();if(!n)return r.optional||false;if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let g=this.tryFoldHyphenActionKeyword(e);if(g)return t.set(r.role,g),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!P.tokenLooksLikeEvent(n))return r.optional||false;let g=(n.normalized??n.value).toLowerCase();if(P.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||this.currentProfile&&(se(this.currentProfile,n.value)??se(this.currentProfile,g))!==void 0||n.value.includes("?."))return r.optional||false}if(r.role==="event"){let g=(n.normalized??n.value).toLowerCase();if(P.STRUCTURAL_NEVER_EVENT.has(g))return r.optional||false}if(r.role==="duration"){let g=(n.normalized??n.value).toLowerCase();if(P.POSITIONAL_OR_SCOPE_KEYWORDS.has(g))return r.optional||false}if(r.optional&&a===void 0&&r.role!=="event"&&r.role!=="action"&&n.kind==="keyword"&&(n.normalized??n.value).toLowerCase()in he)return true;let o=this.tryMatchPositionalExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!je(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchCaretScopeExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!je(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let g=this.tryMatchOperatorRunExpression(e);if(g)return t.set(r.role,g),true}if(r.expectedTypes?.includes("property-path")){let g=this.tryMatchOfPossessiveExpression(e);if(g)return t.set(r.role,g),true;let b=this.tryMatchPostNominalPossessiveExpression(e);if(b)return t.set(r.role,b),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:(t.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:(t.set(r.role,l),true);let m=r.role==="event"&&this.currentPatternCommand==="on"||P.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(m)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(m.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,m),true);let p=this.tryMatchPossessiveSelectorExpression(e);if(p)return r.expectedTypes&&r.expectedTypes.length>0&&!je(p.type,r.expectedTypes)?r.optional||false:(t.set(r.role,p),true);let d=r.role!=="condition",y=this.tryMatchPropertyAccessExpression(e,d);if(y)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(y.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,y),true);let v=this.tryMatchSelectorPropertyExpression(e);if(v)return r.expectedTypes&&r.expectedTypes.length>0&&!je(v.type,r.expectedTypes)?r.optional||false:(t.set(r.role,v),true);if(n.kind==="identifier"&&n.value==="{"&&(!r.expectedTypes?.length||r.expectedTypes.includes("literal"))){let g=this.tryMatchBraceRunLiteral(e);if(g)return t.set(r.role,g),true}let f=this.tokenToSemanticValue(n);if(!f)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(f.type)){let g=f.type==="selector"&&String(f.value).startsWith("@"),b=r.expectedTypes.some(C=>C==="expression"||C==="reference");if(!(g&&b))return r.optional||false}if(t.set(r.role,f),e.advance(),r.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&"value"in f&&(t.set(r.role,_(`${String(f.value)}${g.value}`)),e.advance());let b=e.peek();if(b&&(b.kind==="particle"||b.kind==="keyword")&&(b.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(a,b)){let C=e.peek(1);if(C&&(C.kind==="selector"||C.kind==="identifier")){e.advance();let A=this.tokenToSemanticValue(e.advance());A&&!t.has("source")&&t.set("source",A);}}}return true}patternTokenWouldMatch(e,r){return e?e.type==="literal"?this.getMatchType(r,e.value)!=="none"?true:!!e.alternatives?.some(t=>this.getMatchType(r,t)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],r):false:false}tryMatchPositionalExpression(e){let r=e.peek();if(!r)return null;let t=(r.normalized??r.value).toLowerCase();if(!P.POSITIONAL_KEYWORDS.has(t)&&!P.POSITIONAL_KEYWORDS.has(r.value.toLowerCase()))return null;let a=e.mark(),n=[r.normalized??r.value];e.advance();let o=e.peek();if(!o||o.kind!=="selector")return e.reset(a),null;n.push(o.value),e.advance();let u=0;for(;u++<8;){let c=e.peek();if(c&&c.kind==="selector"&&c.value.startsWith("."))n.push(c.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())&&(n.push(s.normalized??s.value,l.value),e.advance(),e.advance()),{type:"expression",raw:n.join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let t=e.peek(1),a=e.peek(2),n=(t?.normalized??"").toLowerCase(),o=!!t&&(t.value.toLowerCase()==="on"||n==="destination"||n==="on");return !t||!a||a.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${a.value}`})}isOfPossessiveMarker(e){let r=e.value.toLowerCase(),t=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||t==="of"||t==="source")return true;let a=this.currentProfile?.code?P.OF_POSSESSIVE_MARKERS[this.currentProfile.code]:void 0;return !!a&&a.has(r)}tryMatchOperatorRunExpression(e){let r=e.mark(),t=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let a=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}a++;}if(a<2)return e.reset(r),null;let n=e.tokens.slice(t,e.position()).map(o=>o.value).join(" ");return {type:"expression",raw:n,value:n}}tryConsumeRunOperand(e){let r=e.peek();if(!r)return false;if(r.value==="("){let t=e.mark(),a=0;for(;!e.isAtEnd();){let n=e.advance();if(n.value==="(")a++;else if(n.value===")"&&(a--,a===0))return true}return e.reset(t),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 t=e.mark();e.advance();let a=e.peek();if(!a||!this.isOfPossessiveMarker(a))return e.reset(t),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"?(e.reset(t),null):(e.advance(),de(ye(n.value),r.value))}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=[r.value,r.normalized].filter(Boolean),a;for(let s of t)if(a=se(this.currentProfile,s)??se(this.currentProfile,s.toLowerCase()),a)break;if(!a)return null;let n=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let s=e.peek();if(s){let l=s.value.toLowerCase(),c=(s.normalized??"").toLowerCase();o.some(m=>m.toLowerCase()===l||m.toLowerCase()===c)&&e.advance();}}let u=e.peek();if(!u||Ia(this.currentProfile.code,u.value))return e.reset(n),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)&&!(u.normalized&&this.isStructuralKeyword(u.normalized))&&!(u.normalized&&this.isRoleMarkerConcept(u.normalized))||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();if(c&&c.value.startsWith("(")){let m="",p=0,d=0;for(;!e.isAtEnd()&&d++<P.MAX_METHOD_ARGS+2;){let y=e.peek();if(!y)break;m+=y.value,e.advance();for(let v of y.value)v==="("?p++:v===")"&&p--;if(p<=0)break}l+=m;}return de(ie(a),l)}return e.reset(n),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=m=>{for(let p of [m.value,m.normalized].filter(Boolean))if(se(this.currentProfile,p)??se(this.currentProfile,p.toLowerCase()))return true;return false},t=e.peek();if(!t)return null;let a=t.kind==="selector"&&t.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(t.value);if(!(t.kind==="identifier"&&!this.isStructuralKeyword(t.value)&&!(t.normalized&&this.isStructuralKeyword(t.normalized))&&!(t.normalized&&this.isRoleMarkerConcept(t.normalized))||t.kind==="selector"&&(t.value.startsWith("*")||t.value.startsWith("@"))||a)||r(t))return null;let o=e.mark(),u=t.value;a&&(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 c;for(let m of [l.value,l.normalized].filter(Boolean))if(c=se(this.currentProfile,m)??se(this.currentProfile,m.toLowerCase()),c)break;return c?(e.advance(),de(ie(c),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 t=e.normalized?.toLowerCase();return !(t&&Ua.has(t))}tryMatchBraceRunLiteral(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let t=e.mark();e.advance();let a=["{"],n=1,o=0;for(;!e.isAtEnd()&&o++<P.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(u.value==="{")n++;else if(u.value==="}"&&(n--,n===0))return a.push("}"),_(a.join(" "));a.push(u.value);}return e.reset(t),null}tryMatchBareCallExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(r.value))return null;let t=e.peek(1);if(!t||t.value!=="(")return null;let a=e.mark();e.advance(),e.advance();let n=[],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}n.push(s.value),e.advance();}return o?{type:"expression",raw:`${r.value}(${n.join(", ")})`}:(e.reset(a),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),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}.${n.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e,r=true){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let a=e.mark();e.advance();let n=t.value.toLowerCase(),o=e.peek();if((t.kind==="identifier"||P.PROPERTY_ACCESS_BASES.has(n))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let d=t.value,y=[],v=0;for(;v<P.MAX_PROPERTY_DEPTH;){let b=e.peek();if(b&&b.kind==="selector"&&/^\.[a-zA-Z_]/.test(b.value))d+=`.${b.value.slice(1)}`,y.push(b.value.slice(1)),e.advance(),v++;else break}let f=e.peek(),g=!!f&&f.value.startsWith("(");if(r&&!g&&y.length>0&&we(n))return de(ie(n),y.join("."));if(g){let b=e.mark(),C=[],A=0,z=false;for(;!e.isAtEnd();){let E=e.peek();if(!E)break;if(E.value==="(")A++;else if(E.value===")"){if(C.push(E.value),e.advance(),A--,A===0&&(z=true),z)break;continue}C.push(E.value),e.advance();}z?d+=C.join(""):e.reset(b);}return {type:"expression",raw:d}}let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")return e.reset(a),null;e.advance();let s=e.peek();if(!s||s.kind!=="identifier")return e.reset(a),null;e.advance();let l=`${t.value}.${s.value}`,c=1;for(;!e.isAtEnd()&&c<P.MAX_PROPERTY_DEPTH;){let d=e.peek();if(!d||d.kind!=="operator"||d.value!==".")break;e.advance();let y=e.peek();if(!y||y.kind!=="identifier")break;e.advance(),l+=`.${y.value}`,c++;}let m=e.peek();if(m&&m.kind==="punctuation"&&m.value==="("){e.advance();let d=[],y=0;for(;!e.isAtEnd()&&d.length<P.MAX_METHOD_ARGS;){let f=e.peek();if(!f)break;if(f.kind==="punctuation"&&f.value===")"){if(y===0){e.advance();break}y--;}if(f.kind==="punctuation"&&f.value==="("&&y++,f.kind==="punctuation"&&f.value===","){e.advance();continue}d.push(f.value),e.advance();}return {type:"expression",raw:`${l}(${d.join(", ")})`}}let p=t.value.toLowerCase();if(r&&we(p)){let d=l.split(".").slice(1).join(".");return de(ie(p),d)}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek(),n=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!a&&a.kind==="punctuation"&&a.value==="'s",u=!!a&&a.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(a?.normalized??"").toLowerCase()!=="source")return false;let p=he[this.currentPatternCommand];return !!p&&p.roles.some(d=>d.role==="source")})(),l=!!a&&!!n&&n!=="'s"&&a.value===n&&(a.kind==="particle"||a.kind==="punctuation")&&!s;if(!o&&!l&&!u)return e.reset(t),null;e.advance(),u&&e.advance();let c=e.peek();return !c||!(c.kind==="identifier"||(o||u)&&(c.kind==="selector"||c.kind==="keyword"))?(e.reset(t),null):(e.advance(),de(ye(r.value),c.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(t),null;let n=e.peek(1);n&&n.kind,e.advance();let o=a.value.slice(1);return de(ye(r.value),o)}matchGroupToken(e,r,t,a){let n=e.mark(),o=new Set(t.keys());if(!this.matchTokenSequence(e,r.tokens,t,a)){e.reset(n);for(let s of t.keys())o.has(s)||t.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 we(r)?ie(r):_(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 t=e.value.toLowerCase();return we(t)?ie(t):{type:"expression",raw:e.value};case "url":return _(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return _(a,"string")}if(e==="true")return _(true,"boolean");if(e==="false")return _(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?_(e,"duration"):_(a,"number")}let t=parseFloat(e);return isNaN(t)?_(e,"string"):_(t,"number")}applyExtractionRules(e,r){for(let[t,a]of Object.entries(e.extraction))r.has(t)||(a.value!==void 0?r.set(t,{type:"literal",value:a.value}):a.default&&r.set(t,a.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=r.value.toLowerCase();if(P.ENGLISH_NOISE_WORDS.has(t)){let a=e.mark();e.advance();let n=e.peek();if(n&&(n.kind==="selector"||n.kind==="identifier"))return;let o=e.peek(1);if(n&&n.kind==="keyword"&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value))return;let u=n?(n.normalized??n.value).toLowerCase():"";if(n&&P.POSITIONAL_OR_SCOPE_KEYWORDS.has(u))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&P.COMMAND_ACTION_KEYWORDS.has(l),m=!s||s.kind==="particle"||P.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(n&&n.kind==="keyword"&&this.currentProfile?.code!=="en"&&we(u)&&m||n&&n.kind==="keyword"&&this.currentProfile?.code==="en"&&we(u))return;e.reset(a);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(t=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return t?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(he).map(i=>i.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 Ha=U,J=new Ha;function H(i,e){return Ut(i,e)}function Wr(){return Kt()}var $e=["if","unless","repeat","for","while"];function ae(i,e){let r=new Set([e]),a=L(i)?.keywords?.[e];if(a){a.primary&&r.add(a.primary.toLowerCase());for(let n of a.alternatives??[])r.add(n.toLowerCase());}return r}function Z(i,e){return e.has(i.value.toLowerCase())?true:i.normalized?e.has(i.normalized.toLowerCase()):false}var Ga=new Set($e);function tr(i,e){let r=i.normalized?.toLowerCase();return r?Ga.has(r):e.some(t=>Z(i,t))}var wr=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Ya=new Set(["destination","source","style","patient","on","from","to"]);function Qa(i){if(!i||i.kind==="selector")return false;let e=(i.normalized??i.value).toLowerCase(),r=i.value.toLowerCase();return !(wr.has(e)||wr.has(r)||Ya.has(e))}var Cr=new Set(["ja","ko"]);function Xe(i){let e=new Set;i?.primary&&e.add(i.primary.toLowerCase());for(let r of i?.alternatives??[])e.add(r.toLowerCase());return e}function Kr(i,e){let r=[],t=e.position.end,a=i.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(a){t=e.position.end+a[0].length;for(let n of a[1].split(/[,،、]/)){let o=n.trim();o&&r.push(o);}}return {parameters:r,headerEnd:t}}function Ur(i,e,r){let t=e+1;if(t>=i.length)return -1;let a=Xe(L(r)?.roleMarkers?.patient);return a.size>0&&Z(i[t],a)&&t++,t<i.length?t:-1}function Za(i,e,r){if(!L(e))return null;let t=ae(e,"behavior"),a=ae(e,"def"),n=i.toLowerCase(),o=[...t].some(c=>n.includes(c)),u=/\bdef\b/.test(n)||[...a].some(c=>c!=="def"&&n.includes(c));if(!o&&!u)return null;let s=H(i,e).tokens;if(s.length<2)return null;if(Z(s[0],t))return Ar(i,e,s,r,0);let l=s.findIndex((c,m)=>m>0&&Z(c,t));return l>0&&/^[A-Z][A-Za-z0-9_]*$/.test(s[0].value)?Ar(i,e,s,r,l):Z(s[0],a)?Ja(i,e,s,r):null}function Xa(i,e,r){let t=L(e);if(!t)return null;let a=t.wordOrder!=="SOV",n=Cr.has(e)?Xe(t.roleMarkers?.event):new Set,o=Cr.has(e)?Xe(t.keywords?.on):new Set,u=n.size>0&&o.size>0,s=ae(e,"end"),l=ae(e,"on"),c=i.toLowerCase(),m=[...s].some(E=>c.includes(E)),p=(a||u)&&(()=>{let E=0;for(let w of l)if(w){for(let h=c.indexOf(w);h>=0;h=c.indexOf(w,h+w.length))if(++E>=2)return true}return false})();if(!m&&!p)return null;let d=H(i,e).tokens;if(d.length<2)return null;let y=$e.map(E=>ae(e,E)),v=E=>tr(E,y),f=E=>Z(E,s),g=[],b=0,C=0;for(let E=0;E<d.length;E++){let w=d[E];if(f(w)){if(b>0){b--;continue}let h=i.slice(d[C].position.start,w.position.start).trim();h&&g.push(h),C=E+1;}else if(v(w))b++;else if(a&&b===0&&E>C&&Z(w,l)&&Qa(d[E+1])){let h=i.slice(d[C].position.start,w.position.start).trim();h&&g.push(h),C=E;}else if(u&&b===0&&E-1>C&&Z(w,n)&&d[E+1]!==void 0&&Z(d[E+1],o)){let h=d[E-1],k=i.slice(d[C].position.start,h.position.start).trim();k&&g.push(k),C=E-1;}}if(C<d.length){let E=i.slice(d[C].position.start).trim();E&&g.push(E);}if(g.length<2)return null;let A=[],z=[];for(let E of g){let w;try{w=r.statement(E,e);}catch{return null}if(!w||w.kind!=="event-handler")return null;let h=w;A.push(h);let k=!h.body||h.body.length===0;z.push(k?.2:h.metadata?.confidence??.75);}return Ze(A,"then",{sourceLanguage:e,confidence:qe(z),sourceText:i})}function qe(i){return i.length>0?i.reduce((e,r)=>e+r,0)/i.length:0}function Hr(i){let e=[];for(let r of i){let t=r.statements;r.kind==="compound"&&Array.isArray(t)?e.push(...t):e.push(r);}return e}function Ar(i,e,r,t,a){let n=a>0,o=n?0:Ur(r,a,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:c}=Kr(i,u),m=n?a+1:r.findIndex(h=>h.position.start>=c);m<=o&&(m=o+1);let p=ae(e,"init"),d=ae(e,"end"),y=$e.map(h=>ae(e,h)),v=h=>tr(h,y),f=h=>Z(h,d),g=[],b=[],C=[],A=false,z=0,E=m;for(let h=m;h<r.length;h++){let k=r[h];if(f(k)){if(z>0){z--;continue}if(h===E){A=true;break}if(Z(r[E],p)){let S=i.slice(r[E].position.end,k.position.start).trim();if(S)try{let D=Hr(t.body(S,e));b.push(...D),C.push(qe(D.map(O=>O.metadata?.confidence??.75)));}catch{C.push(0);}}else {let S=i.slice(r[E].position.start,k.position.start).trim();try{let D=t.statement(S,e);if(D&&D.kind==="event-handler"){let O=D;g.push(O);let B=!O.body||O.body.length===0;C.push(B?.2:O.metadata?.confidence??.75);}else C.push(0);}catch{C.push(0);}}E=h+1;}else v(k)&&z++;}if(g.length===0&&b.length===0)return null;let w=(A?1:.8)*qe(C);return Ei(s,l,g,b.length>0?b:void 0,{sourceLanguage:e,confidence:w,sourceText:i})}function Ja(i,e,r,t){let a=Ur(r,0,e);if(a<0)return null;let n=r[a],o=n.value;if(!/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/.test(o))return null;let{parameters:u,headerEnd:s}=Kr(i,n),l=r.findIndex(z=>z.position.start>=s);l<=a&&(l=a+1);let c=ae(e,"end"),m=$e.map(z=>ae(e,z)),p=z=>tr(z,m),d=z=>Z(z,c),y=0,v=-1;for(let z=l;z<r.length;z++)if(d(r[z])){if(y===0){v=z;break}y--;}else p(r[z])&&y++;let f=r[l]?.position.start??s,g=v>=0?r[v].position.start:i.length,b=i.slice(f,g).trim();if(!b)return null;let C;try{C=Hr(t.body(b,e));}catch{return null}if(C.length===0)return null;let A=qe(C.map(z=>z.metadata?.confidence??.75));return v<0&&(A*=.8),gi(o,u,C,{sourceLanguage:e,confidence:A,sourceText:i})}var Ae={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(Ae).map(([i,e])=>{let r={};for(let[t,a]of Object.entries(e))a in r||(r[a]=t);return [i,r]}));var Ce=new Set(["if","unless","while","repeat","for"]),nn=new Set(["then","end","else","if","unless","while","for","repeat","and"]),on=new Set(["first","last","next","previous","random","closest"]),De=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),Dr=class extends Error{constructor(i,e,r,t){super(i),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=t;}};function M(i,e,r){return {message:i,severity:e,source:"semantic-parser",...r&&{code:r}}}function K(i,e){return e.length===0?i:{...i,diagnostics:e}}function Sr(i){if(i.length>=2){let e=i[0];if((e==='"'||e==="'")&&i.endsWith(e))return i.slice(1,-1)}return i}var un=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function Gr(i,e){if(!i||typeof i!="object")return i;if(i.action&&i.roles instanceof Map){let t=le(i.action),a=t?.primaryRole;if(t&&a&&a!=="patient"&&!t.roles.some(n=>n.role==="patient")&&i.roles.has("patient")&&!i.roles.has(a)){let n=i.roles,o=n.get("patient");o!==void 0&&(n.delete("patient"),n.set(a,o));}if(i.action==="tell"){let n=i.roles,o=n.get("patient"),u=n.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!u||u.type==="literal")&&(n.delete("patient"),n.set("destination",o));}if(i.action==="transition"){let n=i.roles,o=n.get("destination");o&&o.type==="literal"&&!n.has("goal")&&(n.delete("destination"),n.set("goal",o));let u=n.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(u.value)&&n.set("patient",{type:"expression",raw:u.value});}if(i.action==="morph"){let n=i.roles,o=n.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(o.value)&&n.set("patient",{type:"expression",raw:o.value});}if(i.action==="wait"){let n=i.roles;if(!n.has("event")){let o=n.get("duration"),u=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof u=="string"&&De.has(u.toLowerCase())&&(n.delete("duration"),n.set("event",{type:"literal",value:u,dataType:"string"}));}}if(i.kind==="command"&&i.action!=="on"){let n=i.roles,o=n.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)&&n.set("event",{type:"literal",value:u,dataType:"string"});}}if(e?.size){let n=i.roles;for(let o of ["destination","source"]){let u=n.get(o);u&&u.type==="literal"&&typeof u.value=="string"&&e.has(u.value)&&n.set(o,{type:"expression",raw:u.value});}}}let r=i;for(let t of un){let a=r[t];if(Array.isArray(a))for(let n of a)Gr(n,e);}return i}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 Gr(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 t=e.roles.get(r);t?.type==="expression"&&typeof t.raw=="string"&&/^[A-Za-z_]\w*$/.test(t.raw)&&this.boundIdentifiers.add(t.raw);}parseInternal(e,r){let t=Za(e,r,{statement:(h,k)=>this.parse(h,k),body:(h,k)=>this.parseStatements(h,k)});if(t)return t;let a=Xa(e,r,{statement:(h,k)=>this.parse(h,k),body:(h,k)=>this.parseStatements(h,k)});if(a)return a;let{modifiers:n,remainingInput:o}=this.extractStandaloneModifiers(e,r),u=o||e,l=this.stripAsyncModifier(u,r).remainingInput??u,m=this.stripDoNotThrowModifier(l,r).remainingInput??l,p=[],d=H(m,r),y=ne(r);if(y.length===0)throw new Dr(`No patterns available for language: ${r}`,r,m,[M(`No patterns registered for language '${r}'`,"error","no-patterns")]);let v=[...y].sort((h,k)=>k.priority-h.priority);{let h=d.tokens;if(L(r)?.wordOrder==="VSO"&&h.length>=4&&h[0]?.normalized==="source"){let k=h.findIndex(S=>S.normalized==="on");if(k>=2&&k+1<h.length){let S=m.slice(h[0].position.start,h[k].position.start).trim(),D=h[k+1].position.end,O=m.slice(h[k].position.start,D)+" "+S+m.slice(D);if(O!==m)try{let B=this.parse(O,r);if(B&&B.kind==="event-handler"){let T=n?this.applyModifiers(B,n):B;return K(T,p)}}catch{}}}}{let h=d.tokens;for(let k=1;k<h.length-1;k++){let S=h[k],D=S.value,O=(S.normalized??S.value).toLowerCase();if(!(O==="or"||F.OR_KEYWORDS.has(D)||F.OR_KEYWORDS.has(O)))continue;let T=h[k+1],N=(T.normalized??T.value).toLowerCase();if(!F.KNOWN_EVENTS.has(N))break;let R=k+1,V=h[k+2];V&&V.kind==="selector"&&V.value.startsWith("[")&&(R=k+2);let $=h[k].position.start,ce=h[R].position.end,ee=(m.slice(0,$).trimEnd()+" "+m.slice(ce).trimStart()).trim();if(ee&&ee!==m)try{let me=this.parse(ee,r);if(me&&me.kind==="event-handler"){me.additionalEvents=[{type:"literal",value:N}];let Ue=n?this.applyModifiers(me,n):me;return K(Ue,p)}}catch{}break}}let f=v.filter(h=>h.command==="on"),g=d.mark(),b=J.matchBest(d,f);if(b){p.push(M(`event pattern matched: ${b.pattern.id} (confidence: ${b.confidence.toFixed(2)})`,"info","pattern-match"));let h=false;if(/^event-[a-z]+-bare$/.test(b.pattern.id)){let k=b.captured.get("event"),S=(k?.raw??k?.value??"").toString().toLowerCase(),D=Ae[r],O=F.KNOWN_EVENTS.has(S)||!!D&&Object.keys(D).some(B=>B.toLowerCase()===S);if(S&&!O){let B=this.trySOVEventExtraction(m,r,v);if(B){p.push(M(`bare-event mis-anchor on "${S}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let T=n?this.applyModifiers(B,n):B;return K(T,p)}if(k?.type==="reference"||k?.type==="expression"){d.reset(g);let T=v.filter(R=>R.command!=="on"),N=J.matchBest(d,T);d.reset(g),N&&N.pattern.command!=="on"?(h=true,p.push(M(`bare-event mis-anchor on reference "${S}" rejected; command ${N.pattern.command} preferred`,"info","stage-bare-event-guard"))):J.matchBest(d,f);}}}if(!h){let k=this.buildEventHandler(b,d,r),S=n?this.applyModifiers(k,n):k;return K(S,p)}}p.push(M(`event patterns: ${f.length} tried, no match`,"info","stage-event"));let C=this.tryTrailingEventExtraction(m,r,v);if(C){p.push(M("trailing event extraction succeeded","info","stage-trailing-event"));let h=n?this.applyModifiers(C,n):C;return K(h,p)}let A=v.filter(h=>h.command!=="on"),z=J.matchBest(d,A);if(z){if(Ce.has(z.pattern.command)){let h=this.trySOVEventExtraction(m,r,v);if(h){p.push(M(`SOV event extraction preferred over bare ${z.pattern.command} command`,"info","stage-sov-loop"));let S=n?this.applyModifiers(h,n):h;return K(S,p)}let k=this.tryMidStreamEventExtraction(m,r,v);if(k){p.push(M(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-loop"));let S=n?this.applyModifiers(k,n):k;return K(S,p)}}else if(F.KNOWN_EVENTS.has(z.pattern.command)&&this.hasSOVEventMarkerHead(m,r)){let h=this.trySOVEventExtraction(m,r,v);if(h){p.push(M(`SOV event extraction preferred over command-homonym event ${z.pattern.command}`,"info","stage-sov-homonym"));let k=n?this.applyModifiers(h,n):h;return K(k,p)}}else if(L(r)?.wordOrder==="VSO"){let h=this.tryMidStreamEventExtraction(m,r,v);if(h){p.push(M(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-cmd"));let k=n?this.applyModifiers(h,n):h;return K(k,p)}}if(z.consumedTokens<d.tokens.length&&L(r)?.wordOrder==="SOV"){let h=this.trySOVEventExtraction(m,r,v);if(h){p.push(M(`SOV event extraction preferred over partial ${z.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let k=n?this.applyModifiers(h,n):h;return K(k,p)}}return p.push(M(`command pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match")),K(this.buildCommand(z,r),p)}if(p.push(M(`command patterns: ${A.length} tried, no match`,"info","stage-command")),!m.includes(`
|
|
4
|
+
`)&&L(r)?.wordOrder==="VSO"){let h=this.tryMidStreamEventExtraction(m,r,v);if(h){p.push(M("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let k=n?this.applyModifiers(h,n):h;return K(k,p)}}let E=this.trySOVEventExtraction(m,r,v);if(E){p.push(M("SOV event extraction succeeded","info","stage-sov"));let h=n?this.applyModifiers(E,n):E;return K(h,p)}p.push(M("SOV event extraction: no event keyword found","info","stage-sov"));let w=this.tryCompoundCommandParsing(d,A,r);if(w)return p.push(M("compound command parsing succeeded","info","stage-compound")),K(w,p);throw p.push(M("compound parsing: no then-keywords or no command matches","info","stage-compound")),p.push(M(`all parse stages exhausted for "${m}"`,"error","parse-failed")),new Dr(`Could not parse input in ${r}: ${m}`,r,m,p)}parseStatements(e,r){let t=H(e,r),a=ne(r).filter(n=>n.command!=="on").sort((n,o)=>o.priority-n.priority);return this.parseBodyWithClauses(t,a,r)}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Wr()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let t={};for(let[n,o]of e.captured)t[n]=o;let a=Q(e.pattern.command,t,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(a),a}buildEventHandler(e,r,t){if(!e)throw new Error("No match to build event handler from");let a=e.captured.get("event");if(!a)throw new Error("Event handler pattern matched but no event captured");let n=J.extractEventModifiers(r),o=this.extractOrConjunctionEvents(r,t),u=a;o.length>0&&a.type==="literal"&&(u={type:"literal",value:[String(a.value),...o.map(m=>String("value"in m?m.value:""))].join(" or ")});let s,l=e.captured.get("action");if(l&&l.type==="literal"&&l.value==="if"){let c=r.tokens,m=-1;for(let p=r.position()-1;p>=0;p--){let d=c[p],y=(d.normalized??d.value).toLowerCase();if(this.isIfKeyword(y,t)){m=p;break}}if(m>=0){let p=ne(t).filter(f=>f.command!=="on").sort((f,g)=>g.priority-f.priority),d=new te(c.slice(m),t),y=this.parseBodyWithClauses(d,p,t);if(y.some(f=>f.kind==="conditional")||y.length===1&&y[0]?.kind==="compound"&&y[0].statements.some(f=>f.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return Re(u,y,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}}}if(l&&l.type==="literal"){let c=l.value,m={};for(let[A,z]of e.captured)A!=="event"&&A!=="action"&&A!=="continues"&&(m[A]=z);if(c==="repeat"){let A=r.peek(),z=w=>(w.normalized??w.value).toLowerCase();if(A&&A.kind==="keyword"&&z(A)==="forever")m.loopType={type:"literal",value:"forever"},delete m.patient,r.advance();else if(A&&A.kind==="keyword"&&z(A)==="event"){r.advance();let w=r.peek();if(w)for(m.event={type:"literal",value:z(w)},m.loopType={type:"literal",value:"until-event"},delete m.patient;!r.isAtEnd();){let h=r.peek();if(!h||h.kind==="conjunction"||h.kind==="keyword"&&(this.isThenKeyword(h.value,t)||this.isEndKeyword(h.value,t)))break;r.advance();}}let E=m.patient;E&&E.type==="reference"&&E.value==="me"&&delete m.patient;}let p=Q(c,m,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(p),!Ce.has(c)||c==="repeat"){let A=e.pattern.id.includes("verb-first"),z=r.tokens,E=r.position(),w=k=>k.kind==="conjunction"||k.kind==="keyword"&&(this.isThenKeyword(k.value,t)||this.isEndKeyword(k.value,t)),h=-1;for(let k=E-1;k>=0;k--){let S=z[k];if(w(S))break;if((S.normalized??S.value).toLowerCase()===c){h=k;break}}if(h>=0){let k=E;for(;k<z.length&&!w(z[k]);)k++;let S=z.slice(h,k),D=S;if(A){let O=String(a.value??"").toLowerCase(),B=S.findIndex(T=>(T.normalized??T.value).toLowerCase()===O);if(B<0)D=null;else {let T=S[B-1],N=T&&T.kind==="keyword"&&T.normalized?.toLowerCase()==="on"?B-1:B;D=[...S.slice(0,N),...S.slice(B+1)];}}if(D&&D.length>1){let O=ne(t).filter(q=>q.command!=="on").sort((q,ue)=>ue.priority-q.priority),B=this.parseClause(D,O,t),T=B[0],N=q=>q!==null&&typeof q=="object"&&typeof q.type=="string"?q.type:typeof q,R=le(c),V=R?.primaryRole,$=q=>q==="patient"&&V&&V!=="patient"&&!R?.roles.some(ue=>ue.role==="patient")?V:q,ce=(q,ue)=>{if(!Ce.has(c)||!R)return false;let ze=R.roles.find(ut=>ut.role===$(q));return ze?ze.expectedTypes.length>0&&!ze.expectedTypes.includes(N(ue)):true},ee=!!T&&T.kind==="command"&&Object.entries(m).every(([q,ue])=>{if(ce(q,ue))return true;let ze=T.roles.get($(q));return ze!==void 0&&N(ze)===N(ue)}),me=T?.metadata?.patternId??"",Ue=!Ce.has(c)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(me);if(B.length===1&&T&&T.kind==="command"&&T.action===c&&ee&&Ue&&T.roles.size>Object.keys(m).length)for(p=T;r.position()<k;)r.advance();}}}if(!Ce.has(c)){let A=p;if(le(c)?.roles.some(D=>D.role==="quantity"&&!D.required)&&!A.roles.has("quantity")){let D=r.peek();D&&/^-?\d+(\.\d+)?$/.test(D.value)&&(p=Q(c,{...Object.fromEntries(A.roles),quantity:{type:"literal",value:parseFloat(D.value),dataType:"number"}},A.metadata),r.advance());}let E=p;if(le(c)?.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=Q(c,{...Object.fromEntries(E.roles),duration:{type:"literal",value:D.value,dataType:"string"}},E.metadata),r.advance(),this.consumeForPostposition(r,t));}let h=p,k=le(c);if(k?.roles.find(D=>D.role==="responseType"&&!D.required)&&!h.roles.has("responseType")){let D=R=>typeof R=="string"&&F.RESPONSE_TYPE_WORDS.has(R.toLowerCase()),O=(R,V)=>{let $=Object.fromEntries(h.roles);V&&delete $.destination,$.responseType={type:"expression",raw:R},p=Q(c,$,h.metadata);},B=h.roles.get("destination"),T=k?.roles.find(R=>R.role==="destination"),N=B?.raw??B?.value;if(B&&T&&!T.expectedTypes.includes(B.type)&&D(N))O(N,true);else {let R=r.peek();R&&D(R.value)&&(O(R.value,false),r.advance());}}if(c==="wait"){let D=p;if(!D.roles.has("event")){let O=r.peek();if(O&&De.has(O.value.toLowerCase())){let B=Object.fromEntries(D.roles),T=B.duration;T&&T.type!=="literal"&&T.type!=="expression"&&delete B.duration;let N=B.patient;N&&N.type==="reference"&&N.value==="me"&&delete B.patient,B.event={type:"literal",value:O.value,dataType:"string"},p=Q(c,B,D.metadata),r.advance(),this.consumeForPostposition(r,t);}}}}let d=e.captured.get("continues"),y=d?.type==="literal"&&d.value==="then",v=r.peek(),f=!!v&&this.isThenKeyword(v.value,t),b=Ce.has(c)&&!!v&&!this.isEndKeyword(v.value,t),C=!!v&&!this.isEndKeyword(v.value,t);if(y||f||b||C){let A=ne(t).filter(w=>w.command!=="on").sort((w,h)=>h.priority-w.priority),z=ne(t).filter(w=>w.id.startsWith("grammar-")&&w.id.includes("-continuation")).sort((w,h)=>h.priority-w.priority),E=this.parseBodyWithGrammarPatterns(r,A,z,t);E.length>0?s=[p,...E]:s=[p];}else s=[p];}else {let c=ne(t).filter(m=>m.command!=="on").sort((m,p)=>p.priority-m.priority);s=this.parseBodyWithClauses(r,c,t);}return Re(u,s,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,t){let a=[],n=[],o=0,u=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(n.length===0){let y=this.consumeJsBlock(e,t);if(y){a.push(y);continue}let v=this.tryParseConditionalBlock(e,r,t);if(v){a.push(v);continue}}let l=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,t),c=n[n.length-1],m=e.peek(1),p=c?.value.toLowerCase()==="at"&&m?.value.toLowerCase()==="of"||gr(t,s.value,c?.value,m?.value),d=s.kind==="keyword"&&this.isEndKeyword(s.value,t)&&!p;if(d&&o>0){o--,u.pop(),n.push(s),e.advance();continue}if(l&&u.includes("if")){n.push(s),e.advance();continue}if(l){if(n.length>0){let y=this.parseClause(n,r,t);a.push(...y),n.length=0,o=y.filter(v=>{let f=v;return (f.action==="for"||f.action==="repeat"||f.action==="while")&&(!Array.isArray(f.body)||f.body.length===0)}).length,u.length=0;for(let v=0;v<o;v++)u.push("other");}e.advance();continue}if(d){e.advance();let y=[];for(;!e.isAtEnd();){let v=e.peek();if(!v||v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,t)||this.isEndKeyword(v.value,t)))break;y.push(v),e.advance();}if(y.length>0){let v=n.length>0?this.parseClause(n,r,t):[];v.length===0&&n.length>0?a.push(...this.parseClause([...n,...y],r,t)):(a.push(...v),a.push(...this.parseClause(y,r,t)));}else if(n.length>0){let v=this.parseClause(n,r,t);a.push(...v);}n.length=0;break}if(s.kind==="keyword"){let y=(s.normalized??s.value).toLowerCase();(this.isIfKeyword(y,t)||this.isUnlessKeyword(y,t)||y==="while"||y==="for"||y==="repeat")&&(o++,u.push(this.isIfKeyword(y,t)?"if":"other"));}n.push(s),e.advance();}if(n.length>0){let s=this.parseClause(n,r,t);a.push(...s);}this.foldFrontedWhileIntoRepeat(a,t);for(let s=a.length-1;s>=0;s--){let l=a[s];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&a.splice(s,1);}return a.length>1?[Ze(a,"then",{sourceLanguage:t})]:a}foldFrontedWhileIntoRepeat(e,r){for(let t=0;t+1<e.length;t++){let a=e[t],n=e[t+1];if(a.kind!=="command"||a.action!=="while"||n.kind!=="command"||n.action!=="repeat")continue;let o=a.roles.get("condition");if(!o||n.roles.has("condition")||Array.isArray(a.body)||Array.isArray(n.body))continue;let u=new Map(n.roles);u.set("condition",o),u.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(t,2,{...n,roles:u,metadata:{...n.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(n.metadata?.confidence??0,a.metadata?.confidence??0)}});}}parseClause(e,r,t){if(e.length===0)return [];let a=null,n=e,o=e[e.length-1];if(o&&e.length>=2){let f=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(f,t)&&(a="unless",n=e.slice(0,-1));}let u=null;if(a&&n.length>=3){let f=L(t),g=f?F.buildVerbLookup(f):null;if(g)for(let b=1;b<n.length-1;b++){let C=n[b],A=g.get(C.value.toLowerCase())??(C.normalized?g.get(C.normalized.toLowerCase()):void 0);if(A&&!F.CONDITION_OPERATORS.has(A)){u=n.slice(0,b),n=n.slice(b);break}}}let s=new te(n,t),l=[],c=0,m=[],p=u,d=()=>{if(m.length===0)return;let f=m.slice();if(m.length=0,a&&l.length===0&&p===null){p=f;return}let g=f[0];if(g&&(g.kind==="identifier"||g.kind==="selector"||g.kind==="literal"||g.kind==="reference"))for(let C of this.parseSOVClauseByVerbAnchoring(f,t)){let A=C.action,z=C.roles;A&&le(A)&&z instanceof Map&&z.size>0&&l.push(C);}};for(;!s.isAtEnd();){let f=s.peek(),g=!!f&&f.normalized?.toLowerCase()==="repeat",b=s.mark(),C=J.matchBest(s,r);if(g&&C&&C.pattern.command!=="repeat"){s.reset(b),d(),l.push(Q("repeat",{},{sourceLanguage:t,confidence:.6})),c++,s.advance();continue}if(C&&C.pattern.command==="if"){let A=s.mark(),z=m.length;for(s.reset(b);!s.isAtEnd();){let w=s.peek();if(!w||this.isIfKeyword((w.normalized??w.value).toLowerCase(),t))break;m.push(w),s.advance();}let E=this.tryParseConditionalBlock(s,r,t);if(E){d(),l.push(E),c++;continue}m.length=z,s.reset(A);}if(C){d();let A=this.buildCommand(C,t);l.push(A),c++,this.tryAttachTrailingRole(s,A,t);}else {let A=s.peek();A&&A.normalized?.toLowerCase()==="repeat"?(d(),l.push(Q("repeat",{},{sourceLanguage:t,confidence:.6})),c++):A&&m.push(A),s.advance();}}d();let y=l;if(c===0){let f=this.parseSOVClauseByVerbAnchoring(n,t);f.length>0&&(y=f);}let v=p;return a&&y.length>0&&v&&v.length>0?[Q(a,{condition:{type:"expression",raw:this.joinTokenText(v)}},{sourceLanguage:t,patternId:`${a}-${t}-trailing-guard`,confidence:.85}),...y]:y}tryAttachTrailingRole(e,r,t){let a=le(r.action);if(!a)return;let n=L(t);if(!n)return;let o=r.roles,u=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let m=(l.normalized??l.value).toLowerCase();return nn.has(m)?false:m==="body"||m==="it"||m==="you"||m==="result"||m==="document"||m==="window"||this.boundIdentifiers.has(l.value)?true:c?false:l.kind==="identifier"||l.kind==="reference"},s=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:c}of s){if(!a.roles.some(f=>f.role===l))continue;let m=n.roleMarkers?.[l];if(!m)continue;let p=o.get(l);if(p&&!(p.type==="reference"&&p.value==="me"))continue;let d=f=>{if(!f||f.kind!=="particle"&&f.kind!=="keyword")return false;let g=f.value.toLowerCase();return m.primary?.toLowerCase()===g?true:c?false:(f.normalized??"").toLowerCase()===l?true:!!m.alternatives?.some(b=>b.toLowerCase()===g)},y=e.peek(),v=e.peek(1);if(!y||!v)return;if(c&&m.position==="after"){let f=e.peek(2),g=(y.normalized??y.value).toLowerCase();if(on.has(g)&&v.kind==="selector"&&d(f)){o.set(l,{type:"expression",raw:`${g} ${v.value}`}),e.advance(),e.advance(),e.advance();return}}if(m.position==="after"){if(u(y,c)&&d(v)){let f=this.tokenToSemanticValue(y);e.advance(),e.advance(),f&&o.set(l,f);return}}else if(d(y)&&u(v,c)){e.advance();let f=this.tokenToSemanticValue(e.advance());f&&o.set(l,f);return}}}static buildVerbLookup(e){let r=new Map;for(let[t,a]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(t)&&(r.set(a.primary.toLowerCase(),t),a.alternatives))for(let n of a.alternatives)r.set(n.toLowerCase(),t);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[t,a]of Object.entries(e.roleMarkers)){if(!a)continue;if((t!=="event"||!r.has(a.primary))&&r.set(a.primary,t),a.alternatives)for(let o of a.alternatives)r.has(o)||r.set(o,t);}return r}parseSOVClauseByVerbAnchoring(e,r){let t=L(r);if(!t||t.wordOrder!=="SOV")return [];let a=F.buildVerbLookup(t),n=F.buildMarkerToRoleLookup(t),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let y=u;y<e.length;y++){let v=e[y];if(n.has(v.value))continue;let f=a.get(v.value.toLowerCase()),g=v.normalized?a.get(v.normalized.toLowerCase()):void 0,b=f||g;if(b){s=y,l=b;break}}if(s===-1)break;let c=e.slice(u,s),m=e.length;for(let y=s+1;y<e.length;y++){let v=e[y];if(v.kind==="conjunction"||this.isThenKeyword(v.value,r)){m=y;break}if(y>s+1&&!n.has(v.value)&&(a.get(v.value.toLowerCase())||(v.normalized?a.get(v.normalized.toLowerCase()):void 0))){m=y;break}}let p=e.slice(s+1,m),d=this.extractRolesFromMarkedTokens(c,p,n,l,r);if(o.push(Q(l,d,{sourceLanguage:r,confidence:.7})),u=m,u<e.length){let y=e[u];(y.kind==="conjunction"||this.isThenKeyword(y.value,r))&&u++;}}return o}extractRolesFromMarkedTokens(e,r,t,a,n){let o={},u=s=>{let l=[];for(let c of s){let m=t.get(c.value);if(m&&c.kind==="particle"&&l.length>0){let p=this.tokensToSemanticValue(l);if(p){let d=this.mapRoleForCommand(m,a,o);d&&(o[d]=p);}l=[];}else l.push(c);}if(l.length>0)if(l.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(l[0].value)&&!o.duration&&le(a)?.roles.some(m=>m.role==="duration"))o.duration={type:"literal",value:l[0].value,dataType:"string"};else {let m=this.tokensToSemanticValue(l);m&&(o.patient?o.destination||(o.destination=m):o.patient=m);}};return u(e),u(r),o}mapRoleForCommand(e,r,t){return t[e]?e==="patient"&&!t.destination?"destination":e==="destination"&&!t.patient?"patient":e==="source"&&!t.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let r=e.filter(n=>n.kind!=="whitespace");if(r.length===0)return null;if(r.length===1)return this.tokenToSemanticValue(r[0]);let t=r.map(n=>n.value).join(""),a=r[0];return a.kind==="selector"||a.value.startsWith("#")||a.value.startsWith(".")||a.value.startsWith("@")||a.value.startsWith("*")?ye(t):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?_(Sr(t),"string"):a.kind==="reference"?ie(t):_(t)}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 _(Sr(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return _(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return _(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return _(false);let t=e.normalized?.toLowerCase();return t==="me"||t==="it"||t==="you"||t==="result"||t==="body"?ie(t):e.kind==="reference"?ie(e.normalized||"me"):_(r)}parseBodyWithGrammarPatterns(e,r,t,a){let n=[],o=[],u=false,s=()=>{!u&&o.length>0&&n.push(...this.parseSOVClauseByVerbAnchoring(o,a)),o=[],u=false;},l=0,c=()=>{let m=0;for(let p of n){let d=p;(d.action==="for"||d.action==="repeat"||d.action==="while")&&(!Array.isArray(d.body)||d.body.length===0)&&m++;}return m-l};for(;!e.isAtEnd();){let m=e.peek();if(m&&this.isThenKeyword(m.value,a)){s(),e.advance();continue}if(m&&this.isEndKeyword(m.value,a)){let d=e.peek(-1),y=e.peek(1);if(!gr(a,m.value,d?.value,y?.value)){if(s(),c()>0){l++,e.advance();continue}e.advance();break}}if(m&&!u&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),a)){s();let d=this.tryParseConditionalBlock(e,r,a);if(d){n.push(d),u=true;continue}}let p=false;if(t.length>0){let d=J.matchBest(e,t);if(d){let y=d.pattern.command,v={};for(let[b,C]of d.captured)b!=="event"&&b!=="action"&&b!=="continues"&&(v[b]=C);let f=Q(y,v,{sourceLanguage:a,patternId:d.pattern.id});n.push(f),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(),y=J.matchBest(e,r);if(y){if(y.pattern.command==="if"){let f=e.mark();for(e.reset(d);!e.isAtEnd();){let b=e.peek();if(!b||this.isIfKeyword((b.normalized??b.value).toLowerCase(),a))break;e.advance();}let g=this.tryParseConditionalBlock(e,r,a);if(g){s(),n.push(g),u=true;continue}e.reset(f);}let v=this.buildCommand(y,a);n.push(v),this.tryAttachTrailingRole(e,v,a),p=true,u=true;}}p||(m&&o.push(m),e.advance());}s();for(let m=n.length-1;m>=0;m--){let p=n[m];p.kind==="command"&&p.action==="for"&&(!(p.roles instanceof Map)||p.roles.size===0)&&(!Array.isArray(p.body)||p.body.length===0)&&n.splice(m,1);}return n}tryCompoundCommandParsing(e,r,t){let a=e.tokens,n=a.some(l=>l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,t)),o=a.some(l=>this.isElseKeyword(l.value,t));if(!n&&!o)return null;let u=new te(a,t),s=this.parseBodyWithClauses(u,r,t);return s.length===0?null:s.length===1?s[0]:Ze(s,"then",{sourceLanguage:t,confidence:.65})}matchEventMarkerPhrase(e,r,t){let a=F.SOV_EVENT_MARKER_PHRASES[t];if(!a)return 0;for(let n of a)if(n.every((o,u)=>e[r+u]?.value===o))return n.length;return 0}hasSOVEventMarkerHead(e,r){let t=F.SOV_EVENT_MARKERS[r];if(t===void 0)return false;let{tokens:a}=H(e,r),n=Ae[r],o=new Set;if(n)for(let u of Object.keys(n))o.add(u.toLowerCase());for(let u=0;u<a.length;u++){let s=a[u],l=s.value.toLowerCase(),c=s.normalized?.toLowerCase();if(!(!!c&&(F.KNOWN_EVENTS.has(c)||De.has(c))||F.KNOWN_EVENTS.has(l)||De.has(l)||o.has(l)))continue;let p=this.matchEventParamPhrase(a,u+1).len,d=a[u+1+p];if(d&&(d.kind==="particle"||d.kind==="keyword")&&t.has(d.value)||this.matchEventMarkerPhrase(a,u+1+p,r)>0)return true}return false}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let t=[];for(let a=r+1;a<e.length;a++){let n=e[a].value;if(n===")")return {len:a-r+1,names:t};if(n!==","){if(e[a].kind!=="identifier")break;t.push(n);}}return {len:0,names:[]}}isStrippableSourceRef(e,r){if(!e)return false;let t=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(t==="me"||t==="i"||t==="it"))return true;let a=e.value.toLowerCase();return r.has(a)||!!t&&r.has(t)}tryTrailingEventExtraction(e,r,t){let a=H(e,r).tokens;if(a.length<3)return null;let n=Ae[r],o=new Set;if(n)for(let C of Object.keys(n))o.add(C.toLowerCase());let u=a.length-2,s=a[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))return null;let c=a[a.length-1],m=c.value.toLowerCase(),p=c.normalized?.toLowerCase();if(!(!!p&&F.KNOWN_EVENTS.has(p)||F.KNOWN_EVENTS.has(m)||o.has(m)))return null;let y=p&&F.KNOWN_EVENTS.has(p)?p:n?.[m]??m,v=a.slice(0,u);if(v.length===0)return null;let f=t.filter(C=>C.command!=="on"),g=new te(v,r),b=this.parseBodyWithClauses(g,f,r);return b.length===0?null:Re({type:"literal",value:y},b,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,t){let a=H(e,r).tokens;if(a.length<3)return null;let n=Ae[r],o=new Set;if(n)for(let u of Object.keys(n))o.add(u.toLowerCase());for(let u=0;u<a.length-1;u++){let s=a[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let c=a[u+1],m=c.value.toLowerCase(),p=c.normalized?.toLowerCase();if(!(!!p&&F.KNOWN_EVENTS.has(p)||F.KNOWN_EVENTS.has(m)||o.has(m)))continue;let y=p&&F.KNOWN_EVENTS.has(p)?p:n?.[m]??m,v=a.filter((C,A)=>A!==u&&A!==u+1);if(v.length===0)return null;let f=t.filter(C=>C.command!=="on"),g=new te(v,r),b=this.parseBodyWithClauses(g,f,r);return b.length===0?null:Re({type:"literal",value:y},b,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,t){let a=F.SOV_EVENT_MARKERS[r];if(!a)return null;let o=H(e,r).tokens,u=Ae[r],s=new Set;if(u)for(let z of Object.keys(u))s.add(z.toLowerCase());let l=F.SOV_SOURCE_MARKERS[r],c=-1,m="",p="",d=1,y=[];for(let z=0;z<o.length;z++){let E=o[z],w=E.value.toLowerCase(),h=w,k="",S=w.indexOf("[");S>0&&(h=w.slice(0,S),k=E.value.slice(S));let D=E.normalized?.toLowerCase(),O=D&&(F.KNOWN_EVENTS.has(D)||De.has(D)),B=s.has(w)||s.has(h),T=F.KNOWN_EVENTS.has(h)||De.has(h);if(O||B||T){let N=o[z-1];if(N&&(N.normalized??N.value).toLowerCase()==="event")continue;let R;O?R=D:B?R=u?.[w]??u?.[h]??h:R=h;let V=this.matchEventParamPhrase(o,z+1);if(a.size>0){let $=1+V.len,ce=o[z+$];ce&&ce.kind==="selector"&&ce.value.startsWith("[")&&($+=1);let ee=o[z+$];if(ee&&(ee.kind==="particle"||ee.kind==="keyword")&&a.has(ee.value)){c=z,m=R,p=k||($===V.len+2?o[z+$-1].value:""),d=$+1,y=V.names;break}}else {c=z,m=R,p=k,d=1+V.len+this.matchEventMarkerPhrase(o,z+1+V.len,r),y=V.names;break}}}if(c===-1){let z=new Set(t.filter(E=>E.command!=="on").map(E=>E.command));for(let E=0;E<o.length;E++){let w=o[E];if(w.kind==="identifier")if(a.size>0){let h=1,k=o[E+1];k&&k.kind==="selector"&&k.value.startsWith("[")&&(h=2);let S=o[E+h];if(S&&(S.kind==="particle"||S.kind==="keyword")&&a.has(S.value)){c=E,m=w.value,p=h===2?o[E+1].value:"",d=h+1;break}}else {let h=this.matchEventMarkerPhrase(o,E+1,r);if(h>0){c=E,m=w.value,p="",d=1+h;break}let k=o[E+1];if(k&&k.kind==="keyword"&&k.normalized!=null&&z.has(k.normalized)){c=E,m=w.value,p="",d=1;break}}}}if(c===-1)return null;let v=new Set;for(let z=c;z<c+d;z++)v.add(z);if(l){let z=c+d;if(z<o.length){let E=o[z];if((E.kind==="particle"||E.kind==="keyword")&&l.markers.has(E.value))v.add(z);else if(this.isStrippableSourceRef(E,l.windowTokens)){let w=o[z+1];w&&(w.kind==="particle"||w.kind==="keyword")&&l.markers.has(w.value)&&(v.add(z),v.add(z+1));}}if(c>=2){let E=o[c-1];(E.kind==="particle"||E.kind==="keyword")&&l.markers.has(E.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(v.add(c-2),v.add(c-1));}for(let E=0;E<c;E++){let w=o[E],h=w.value.toLowerCase(),k=w.normalized?.toLowerCase();if(l.windowTokens.has(h)||k&&l.windowTokens.has(k)){v.add(E);break}}}let f=o.filter((z,E)=>!v.has(E));if(f.length===0)return null;let g=t.filter(z=>z.command!=="on"),b=new te(f,r),C=this.parseBodyWithClauses(b,g,r);if(C.length===0)return null;let A={sourceLanguage:r,confidence:.75};return p&&(A.keyFilter=p),Re({type:"literal",value:m},C,void 0,A,y)}profileKeywordMatches(e,r,t){let a=L(e)?.keywords?.[r];return a?a.primary?.toLowerCase()===t?true:!!a.alternatives?.some(n=>n.toLowerCase()===t):false}consumeForPostposition(e,r){let t=e.peek();if(!t)return;let a=(t.normalized??"").toLowerCase(),n=L(r)?.keywords?.for;(a==="for"||t.value===n?.primary||(n?.alternatives??[]).includes(t.value))&&e.advance();}isThenKeyword(e,r){let t=e.toLowerCase(),n={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[r];return n?n.has(t):t==="then"||this.profileKeywordMatches(r,"then",t)}isElseKeyword(e,r){let t=e.toLowerCase();return t==="else"?true:this.profileKeywordMatches(r,"else",t)}isEndKeyword(e,r){let t=e.toLowerCase(),n={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 n?t==="end"||n.has(t):t==="end"||this.profileKeywordMatches(r,"end",t)}isJsKeyword(e){let r=(e.normalized??e.value).toLowerCase();return r==="js"||this.profileKeywordMatches("en","js",r)}consumeJsBlock(e,r){let t=e.peek();if(!t||!this.isJsKeyword(t))return null;let a=e.mark(),n=[];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}n.push(s);}if(!o)return e.reset(a),null;let u=n.map(s=>s.value).join(" ").trim();return Q("js",{patient:{type:"expression",raw:u||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}isIfKeyword(e,r){let t=e.toLowerCase();return t==="if"?true:this.profileKeywordMatches(r,"if",t)}isUnlessKeyword(e,r){let t=e.toLowerCase();return t==="unless"?true:this.profileKeywordMatches(r,"unless",t)}isBlockEndToken(e,r,t){return this.isEndKeyword(e.value,t)?true:e.kind!=="keyword"||(e.normalized??"").toLowerCase()!=="end"?false:!(r&&r.kind==="selector")}tryParseConditionalBlock(e,r,t){let a=e.peek();if(!a)return null;let n=(a.normalized??a.value).toLowerCase();if(!this.isIfKeyword(n,t))return null;let o=e.mark();e.advance();let u=[],s=0;for(;!e.isAtEnd();){let E=e.peek();if(!E)break;let w=(E.normalized??E.value).toLowerCase();if(this.isIfKeyword(w,t)||this.isUnlessKeyword(w,t)){s++,u.push(E),e.advance();continue}if(this.isBlockEndToken(E,e.peek(1)??void 0,t)){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=L(t),c=l?.wordOrder==="SOV"?F.buildVerbLookup(l):null,m=0,p=0,d=[];for(;m<u.length;m++){let E=u[m],w=(E.normalized??E.value).toLowerCase();if(this.isIfKeyword(w,t)||this.isUnlessKeyword(w,t)?p++:this.isBlockEndToken(E,u[m+1],t)&&p--,p===0&&this.isThenKeyword(E.value,t)){m++;break}if(p===0&&d.length>0){let h=(u[m-1].normalized??u[m-1].value).toLowerCase(),k=u[m-1].value.toLowerCase(),S=(E.normalized??E.value).toLowerCase(),D=F.CONDITION_COPULAS.has(h)||F.CONDITION_COPULAS_SURFACE.has(k)&&F.CONDITION_PREDICATES.has(S),O=c!==null&&c.has(E.value.toLowerCase())&&!F.CONDITION_PREDICATES.has(S);if(!F.CONDITION_OPERATORS.has(S)&&(!D||O)&&(this.tokensBeginCommand(u.slice(m),r,t)||this.sovCommandStartsAt(u.slice(m),c)))break}d.push(E);}if(d.length===0)return e.reset(o),null;let v=[],f=[],g=false,b=0;for(;m<u.length;m++){let E=u[m],w=(E.normalized??E.value).toLowerCase();if(this.isIfKeyword(w,t)||this.isUnlessKeyword(w,t)?b++:this.isBlockEndToken(E,u[m+1],t)&&b--,b===0&&!g&&this.isElseKeyword(E.value,t)){g=true;continue}(g?f:v).push(E);}let C={type:"expression",raw:this.joinTokenText(d)},A=this.parseBranch(v,r,t),z=f.length>0?this.parseBranch(f,r,t):void 0;return A.length===0&&(!z||z.length===0)?(e.reset(o),null):zi(C,A,z,{sourceLanguage:t,patternId:`conditional-${t}-folded`,confidence:1})}joinTokenText(e){return e.map(r=>r.kind==="keyword"?r.normalized??r.value:r.value).join(" ").trim()}tokensBeginCommand(e,r,t){if(e.length===0)return false;let a=new te(e,t);return J.matchBest(a,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let t=u=>r.has(u.value.toLowerCase())||!!u.normalized&&r.has(u.normalized.toLowerCase()),a=u=>u.kind==="identifier"||u.kind==="selector"||u.kind==="literal"||u.kind==="reference",n=0,o=0;for(;n+1<e.length;){let u=e[n],s=e[n+1];if(!a(u)||s.kind!=="particle")break;o+=1,n+=2;let l=e[n];if(o>=1&&l&&t(l))return true}return false}parseBranch(e,r,t){if(e.length===0)return [];let a=new te(e,t),n=this.parseBodyWithClauses(a,r,t);return n.length===1&&n[0]?.kind==="compound"?n[0].statements:n}extractStandaloneModifiers(e,r){let a=H(e,r).tokens;if(a.length===0)return {modifiers:null,remainingInput:null};let o=a[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<a.length){let y=a[d];(y.kind==="keyword"||y.kind==="particle")&&(d++,l++);}if(d<a.length){let y=a[d];if(y.kind==="literal"){let v=y.value.match(/^(\d+)(ms|s|m)?$/);if(v){let f=parseInt(v[1],10),g=v[2]||"ms";g==="s"?f*=1e3:g==="m"&&(f*=6e4),s[u]=f,l=d+1;}}}s[u]||(s[u]=u==="debounce"?300:100);}let c=a.slice(l);if(c.length===0)return {modifiers:null,remainingInput:null};let m=c[0].position.start,p=e.slice(m);return {modifiers:s,remainingInput:p}}stripAsyncModifier(e,r){let t=L(r)?.keywords?.async,a=new Set(["async"]);t?.primary&&a.add(t.primary.toLowerCase()),t?.alternatives?.forEach(l=>a.add(l.toLowerCase()));let n=H(e,r).tokens,o=n.findIndex(l=>a.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let u=n[o],s=(e.slice(0,u.position.start)+e.slice(u.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let t=H(e,r).tokens;for(let a=0;a<t.length-1;a++){if(t[a].value.toLowerCase()!=="do")continue;let n=-1;for(let l=a+1;l<=a+5&&l<t.length;l++){let c=t[l];if(c.normalized?.toLowerCase()==="throw"){n=l;break}let m=c.kind;if(m==="selector"||m==="literal"||m==="reference"||m==="conjunction")break}if(n===-1)continue;let o=t[a].position.start,u=t[n].position.end,s=(e.slice(0,o)+e.slice(u)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}return {remainingInput:null}}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let t=[];for(;;){let a=e.mark(),n=e.peek();if(!n)break;let o=(n.normalized||n.value).toLowerCase();if(!F.OR_KEYWORDS.has(o)){e.reset(a);break}e.advance();let u=e.peek();if(!u){e.reset(a);break}let s=(u.normalized||u.value).toLowerCase();e.advance(),t.push({type:"literal",value:s});}return t}};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 sn=X,ln=new sn;function cn(i,e){return ln.parse(i,e)}function mn(i,e){try{let r=H(i,e),t=ne(e);if(t.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let a=[...t].sort((l,c)=>c.priority-l.priority),n=a.filter(l=>l.command==="on"),o=J.matchBest(r,n);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let u=a.filter(l=>l.command!=="on"),s=J.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: ${i}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function Yr(i,e){try{let t=cn(i,e);if(t)return {node:t,confidence:t.metadata?.confidence??.8,error:void 0,tokensConsumed:H(i,e).tokens.length}}catch{}let r=mn(i,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function Qr(i,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...i].sort((t,a)=>{let n=t[r]??99,o=a[r]??99;return n-o})}function pn(i,e){let r=i.markerOverride?.[e.code],t=e.roleMarkers[i.role];if(r!==void 0)return {primary:r,position:t?.position??"before",isOverride:true};if(t&&t.primary){let a={primary:t.primary,position:t.position,isOverride:false};return t.alternatives&&(a.alternatives=t.alternatives),a}return null}function Ve(i,e){let r,t;if(i.markerOverride&&i.markerOverride[e.code]!==void 0)r=i.markerOverride[e.code];else {let n=e.roleMarkers[i.role];n&&(r=n.primary,t=n.alternatives?[...n.alternatives]:void 0);}let a=i.markerVariants?.[e.code];if(a&&a.length>0){let n=t?[...t]:[];for(let o of a)o!==r&&!n.includes(o)&&n.push(o);t=n;}return {marker:r,alternatives:t}}function Ne(i,e,r){r.roles.find(a=>a.role==="scope"&&!a.required)&&(i.push({type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}),e.scope={fromRole:"scope"});}function dn(i,e,r,t,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let c of l)n.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}}let o=e.roleMarkers.destination;o&&n.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}]}),n.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};n.push(l);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),n.push(...ge(i,e.roleMarkers.source)),n.push(...rr(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`{event} ${t.primary} {destination?} {patient} ${u?.primary||""} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function yn(i,e,r,t,a){let n=[];n.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};n.push(s);}if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let s=t.primary.split(/\s+/);if(s.length>1)for(let l of s)n.push({type:"literal",value:l});else {let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),n.push(...ge(i,e.roleMarkers.source)),n.push(...rr(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`{patient} ${o?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function fn(i,e,r,t,a){let n=[];n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(l);}let u=e.roleMarkers.destination;if(u&&(n.push({type:"role",role:"destination",optional:false}),n.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),n.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let c of l)n.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),{id:`${i.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(a.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function hn(i,e,r,t,a){let n=[];n.push({type:"role",role:"event",optional:false});let o=t.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&n.push({type:"literal",value:o[0],alternatives:o.slice(1)});let u=e.roleMarkers.destination;u&&n.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),n.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};n.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(l),n.push(...ge(i,e.roleMarkers.source)),n.push(...rr(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(a.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function vn(i,e,r,t,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let u=t.primary.split(/\s+/);if(u.length>1)for(let s of u)n.push({type:"literal",value:s});else {let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(o),{id:`${i.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function En(i,e,r,t){let a=e.eventHandler?.temporalMarkers;if(!a||a.length===0)return null;let n=[];n.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&n.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),n.push({type:"literal",value:a[0],alternatives:a.slice(1)}),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(s);}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),{id:`${i.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(t.basePriority??100)+49,template:{format:`{event} ${a[0]} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function gn(i,e,r,t,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let m=t.primary.split(/\s+/);if(m.length>1)for(let p of m)n.push({type:"literal",value:p});else {let p=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(p);}}let u=[...i.roles.filter(m=>m.required)].sort((m,p)=>{let d=m.sovPosition??999,y=p.sovPosition??999;return d-y});for(let m of u){n.push({type:"role",role:m.role,optional:false});let{marker:p,alternatives:d}=Ve(m,e);if(p){let y=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};n.push(y);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(s);let l=u.map(m=>`{${m.role}}`).join(" "),c={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Ne(n,c,i),{id:`${i.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`{event} ${t.primary} ${l} ${r.primary}`,tokens:n},extraction:c}}function zn(i,e,r,t,a){let n=[],u=[...i.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.sovPosition??999,d=m.sovPosition??999;return p-d});for(let c of u){n.push({type:"role",role:c.role,optional:false});let{marker:m,alternatives:p}=Ve(c,e);m&&n.push(p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m});}if(n.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),n.push({type:"role",role:"event",optional:false}),t.position==="after"){let c=t.primary.split(/\s+/);if(c.length>1)for(let m of c)n.push({type:"literal",value:m});else n.push(t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary});}let s=u.map(c=>`{${c.role}}`).join(" "),l={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))};return Ne(n,l,i),{id:`${i.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(a.basePriority??100)+40,template:{format:`${s} ${r.primary} {event} ${t.primary}`,tokens:n},extraction:l}}function kn(i,e,r,t,a){let n=[],u=[...i.roles.filter(f=>f.required)].sort((f,g)=>{let b=f.sovPosition??999,C=g.sovPosition??999;return b-C}),s=u[0];n.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:c}=Ve(s,e);if(l){let f=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};n.push(f);}if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let f=t.primary.split(/\s+/);if(f.length>1)for(let g of f)n.push({type:"literal",value:g});else {let g=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(g);}}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(m);let p=u[1];n.push({type:"role",role:p.role,optional:false});let{marker:d,alternatives:y}=Ve(p,e);if(d){let f=y?{type:"literal",value:d,alternatives:y}:{type:"literal",value:d};n.push(f);}let v={action:{value:i.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[p.role]:{fromRole:p.role}};return Ne(n,v,i),{id:`${i.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{${s.role}} {event} ${t.primary} ${r.primary} {${p.role}}`,tokens:n},extraction:v}}function xr(i,e,r,t,a){let n=[];if(t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),n.push(...ge(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`${t.primary} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function bn(i,e,r,t,a){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;if(u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),n.push(...ge(i,e.roleMarkers.source)),t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}return n.push({type:"role",role:"event",optional:false}),{id:`${i.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${t.primary} {event}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function wn(i,e,r,t,a){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=[...i.roles.filter(m=>m.required)].sort((m,p)=>{let d=m.svoPosition??999,y=p.svoPosition??999;return d-y});for(let m of s){let p,d;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)p=m.markerOverride[e.code];else {let y=e.roleMarkers[m.role];y&&(p=y.primary,d=y.alternatives);}if(p){let y=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};n.push(y);}n.push({type:"role",role:m.role,optional:false});}if(t.position==="before"){let m=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(m);}n.push({type:"role",role:"event",optional:false});let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Ne(n,c,i),{id:`${i.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${r.primary} ${l} ${t.primary} {event}`,tokens:n},extraction:c}}function Br(i,e,r,t,a){let n=[];if(t.position==="before"){let m=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(m);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=[...i.roles.filter(m=>m.required)].sort((m,p)=>{let d=m.svoPosition??999,y=p.svoPosition??999;return d-y});for(let m of s){let p,d;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)p=m.markerOverride[e.code];else {let y=e.roleMarkers[m.role];y&&(p=y.primary,d=y.alternatives);}if(p){let y=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};n.push(y);}n.push({type:"role",role:m.role,optional:false});}let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Ne(n,c,i),{id:`${i.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`${t.primary} {event} ${r.primary} ${l}`,tokens:n},extraction:c}}function Cn(i,e,r,t,a){let n=[],o=e.eventHandler?.negationMarker;if(t.position==="before"){let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(l);}n.push({type:"role",role:"event",optional:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u),n.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&n.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),n.push(...ge(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${t.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function An(i,e,r,t){let a=[];a.push({type:"literal",value:"and",alternatives:["then"]}),a.push({type:"role",role:"event",optional:false});let n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(n),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&a.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),a.push(...ge(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(t.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}var Be={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Je(i,e,r=Be){let t=`${i.action}-${e.code}-generated`,a=r.basePriority??100,n=e.keywords[i.action];if(!n)throw new Error(`No keyword translation for '${i.action}' in ${e.code}`);let o=Tn(i,e,n),u=ir(i,e),s=Nn(i,e,n);return {id:t,language:e.code,command:i.action,priority:a,template:{format:s,tokens:o},extraction:u}}function Dn(i,e,r=Be){if(i.roles.filter(u=>!u.required).length===0)return null;let a=i.roles.filter(u=>u.required),n={...i,roles:a};return {...Je(n,e,r),id:`${i.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:ir(i,e)}}function Sn(i,e,r=Be){if(e.wordOrder!=="SOV")return null;let t=i.roles.filter(u=>u.required);if(t.length!==1)return null;let a=e.keywords[i.action];if(!a)return null;let n=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},o=t.map(u=>({type:"role",role:u.role,optional:false,expectedTypes:u.expectedTypes}));return {id:`${i.action}-${e.code}-generated-verb-first`,language:e.code,command:i.action,priority:(r.basePriority??100)-20,template:{format:`${a.primary} <${t[0].role}>`,tokens:[n,...o]},extraction:ir(i,e)}}function xn(i,e,r=Be){let t=[];if(t.push(Je(i,e,r)),r.generateSimpleVariants){let a=Dn(i,e,r);a&&t.push(a);}for(let a of i.omitRoleVariants??[]){let n={...i,roles:i.roles.filter(u=>u.role!==a)},o=Je(n,e,r);t.push({...o,id:`${i.action}-${e.code}-generated-no-${a}`,priority:(r.basePriority??100)-8});}if(r.generateVerbFirstVariants!==false){let a=Sn(i,e,r);a&&t.push(a);}return t}function Zr(i,e=Be){let r=[],t=_a();for(let a of t){if(!i.keywords[a.action])continue;let n=xn(a,i,e);if(r.push(...n),i.eventHandler?.eventMarker){let o=Bn(a,i,e);r.push(...o);}}return r}function Bn(i,e,r=Be){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let t=[],a=e.eventHandler.eventMarker,n=e.keywords[i.action];if(!n)return [];if(i.roles.length===0)return [];let u=i.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)t.push(gn(i,e,n,a,r)),t.push(kn(i,e,n,a,r)),t.push(zn(i,e,n,a,r));else {t.push(dn(i,e,n,a,r)),t.push(yn(i,e,n,a,r));let s=e.roleMarkers.destination;s&&s.primary!==a.primary&&t.push(fn(i,e,n,a,r));let l=a.primary.split(/\s+/),c=a.alternatives?.some(p=>!p.includes(" ")&&p.length>1);l.length>1&&c&&t.push(hn(i,e,n,a,r)),t.push(vn(i,e,n,a,r));let m=En(i,e,n,r);m&&t.push(m);}else e.wordOrder==="VSO"?u?(t.push(Br(i,e,n,a,r)),t.push(wn(i,e,n,a,r))):(t.push(xr(i,e,n,a,r)),t.push(bn(i,e,n,a,r)),e.eventHandler?.negationMarker&&t.push(Cn(i,e,n,a,r)),e.tokenization?.prefixes&&t.push(An(i,e,n,r))):u?t.push(Br(i,e,n,a,r)):t.push(xr(i,e,n,a,r));return t}function Tn(i,e,r){let t=[],a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},n=On(i,e);switch(e.wordOrder){case "SVO":t.push(a),t.push(...n);break;case "SOV":t.push(...n),t.push(a);break;case "VSO":t.push(a),t.push(...n);break;default:t.push(a),t.push(...n);}return Fn(t)}function Fn(i){let e=[];for(let r of i){let t=e[e.length-1];if(t&&t.type==="literal"&&r.type==="literal"&&t.value===r.value){let a=[...t.alternatives??[],...r.alternatives??[]];a.length&&(e[e.length-1]={...t,alternatives:[...new Set(a)]});continue}e.push(r);}return e}function On(i,e){let r=[],t=Qr(i.roles,e.wordOrder);for(let a of t){let n=Rn(a,e);a.required?r.push(...n):r.push({type:"group",optional:true,tokens:n});}return r}function Rn(i,e){let r=[],t=i.markerOverride?.[e.code],a=e.roleMarkers[i.role],n={type:"role",role:i.role,optional:!i.required,expectedTypes:i.expectedTypes};if(t!==void 0){let o=t?t.split(/\s+/).filter(Boolean):[],u=a?.position??"before",s=i.markerOptional?.[e.code]===true,l=c=>{let m={type:"literal",value:c};r.push(s?{type:"group",optional:true,tokens:[m]}:m);};if(u==="before"){for(let c of o)l(c);r.push(n);}else {r.push(n);for(let c of o)l(c);}}else if(a){let o=i.markerVariants?.[e.code]??[],u=()=>{let l=[...new Set([...a.alternatives??[],...o])].filter(c=>c!==a.primary);return l.length?{type:"literal",value:a.primary,alternatives:l}:{type:"literal",value:a.primary}},s=l=>{r.push(e.markersOptional||i.markerOptional?.[e.code]?{type:"group",optional:true,tokens:[l]}:l);};a.position==="before"?(a.primary&&s(u()),r.push(n)):(r.push(n),s(u()));}else r.push(n);return r}function Pn(i,e){let r={};for(let t of i.roles){let a=t.markerOverride?.[e.code],n=e.roleMarkers[t.role];if(a!==void 0)r[t.role]=a?{marker:a}:{};else if(n&&n.primary){let o=t.markerVariants?.[e.code]??[],u=[...new Set([...n.alternatives??[],...o])].filter(s=>s!==n.primary);r[t.role]=u.length?{marker:n.primary,markerAlternatives:u}:{marker:n.primary};}else r[t.role]={};}return r}function ir(i,e){let r=Pn(i,e),t={};for(let a of i.roles){let n=r[a.role]||{};!a.required&&a.default?t[a.role]={...n,default:a.default}:t[a.role]=n;}return t}function Nn(i,e,r){let t=[],n=Qr(i.roles,e.wordOrder).map(o=>{let u=pn(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":t.push(r.primary,...n);break;case "SOV":t.push(...n,r.primary);break;default:t.push(r.primary,...n);}return t.join(" ")}var Ln=class{constructor(i={}){this.cache=new Map,this.config={maxSize:i.maxSize??1e3,ttlMs:i.ttlMs??0,enabled:i.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(i,e){return `${e}:${i}`}isExpired(i){return this.config.ttlMs===0?false:Date.now()-i.createdAt>this.config.ttlMs}evictLRU(){let i=this.cache.keys().next().value;i!==void 0&&(this.cache.delete(i),this.stats.evictions++);}get(i,e){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(i,e),t=this.cache.get(r);if(!t){this.stats.misses++;return}if(this.isExpired(t)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),t.lastAccessed=Date.now(),this.cache.set(r,t),this.stats.hits++,t.result}set(i,e,r){if(!this.config.enabled||r!==null&&typeof r=="object"&&"confidence"in r&&r.confidence===0)return;let t=this.makeKey(i,e),a=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(t,{result:r,createdAt:a,lastAccessed:a});}has(i,e){if(!this.config.enabled)return false;let r=this.makeKey(i,e),t=this.cache.get(r);return t?this.isExpired(t)?(this.cache.delete(r),this.stats.expirations++,false):true:false}delete(i,e){let r=this.makeKey(i,e);return this.cache.delete(r)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let i=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:i>0?this.stats.hits/i:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(i){if(i.maxSize!==void 0)for(this.config.maxSize=i.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();i.ttlMs!==void 0&&(this.config.ttlMs=i.ttlMs),i.enabled!==void 0&&(this.config.enabled=i.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}};new Ln;var Jr={code:"qu",name:"Quechua",nativeName:"Runasimi",direction:"ltr",script:"latin",wordOrder:"SOV",markingStrategy:"postposition",usesSpaces:true,verb:{position:"end",subjectDrop:true},references:{me:"noqa",it:"chay",you:"qam",result:"rurasqa",event:"ruwakuq",target:"punta",body:"kurku"},possessive:{marker:"-pa",markerPosition:"after-object",keywords:{\u00F1uqapa:"me",\u00F1uqaypa:"me",noqaq:"me",qampa:"you",paypa:"it",chay:"it"},connectors:["paq","pa"]},roleMarkers:{patient:{primary:"ta",position:"after"},destination:{primary:"man",alternatives:["pa"],position:"after"},source:{primary:"manta",position:"after"},style:{primary:"wan",position:"after"},event:{primary:"pi",position:"after"}},keywords:{toggle:{primary:"t'ikray",alternatives:["tikray"],normalized:"toggle"},add:{primary:"yapay",alternatives:["yapaykuy"],normalized:"add"},remove:{primary:"qichuy",alternatives:["hurquy","anchuchiy"],normalized:"remove"},put:{primary:"churay",alternatives:["tiyachiy"],normalized:"put"},append:{primary:"qatichiy",alternatives:["qhipaman_yapay"],normalized:"append"},prepend:{primary:"\xF1awpachiy",normalized:"prepend"},take:{primary:"hapiy",normalized:"take"},make:{primary:"ruray",alternatives:["kamay"],normalized:"make"},clone:{primary:"kikinchay",alternatives:[],normalized:"clone"},swap:{primary:"t'inkuy",alternatives:["rantikunakuy","rantin_tikray"],normalized:"swap"},morph:{primary:"tukunay",alternatives:[],normalized:"morph"},set:{primary:"churanay",alternatives:["kamaykuy"],normalized:"set"},get:{primary:"taripay",normalized:"get"},increment:{primary:"yapachiy",normalized:"increment"},decrement:{primary:"pisiyachiy",normalized:"decrement"},log:{primary:"qillqakuy",alternatives:["willakuy"],normalized:"log"},show:{primary:"rikuchiy",alternatives:["qawachiy"],normalized:"show"},hide:{primary:"pakay",alternatives:["pakakuy"],normalized:"hide"},transition:{primary:"pasay",alternatives:[],normalized:"transition"},on:{primary:"chaypim",alternatives:["kaypi"],normalized:"on"},trigger:{primary:"kuyuchiy",alternatives:["kichay"],normalized:"trigger"},send:{primary:"kachay",alternatives:["apachiy"],normalized:"send"},focus:{primary:"qhawachiy",alternatives:["qhaway"],normalized:"focus"},blur:{primary:"paqariy",alternatives:["mana qhawachiy"],normalized:"blur"},empty:{primary:"ch'usaq",normalized:"empty"},open:{primary:"paskay",normalized:"open"},close:{primary:"wichqay",normalized:"close"},select:{primary:"marcay",normalized:"select"},clear:{primary:"pichay",normalized:"clear"},reset:{primary:"musuqchay",normalized:"reset"},breakpoint:{primary:"sayachinay",normalized:"breakpoint"},go:{primary:"riy",alternatives:["puriy"],normalized:"go"},scroll:{primary:"kunray",alternatives:[],normalized:"scroll"},push:{primary:"tanqay",normalized:"push"},replace:{primary:"tikray_url",alternatives:[],normalized:"replace"},process:{primary:"rurariy",normalized:"process"},wait:{primary:"suyay",normalized:"wait"},fetch:{primary:"apamuy",alternatives:["taripakaramuy"],normalized:"fetch"},settle:{primary:"tiyakuy",normalized:"settle"},if:{primary:"sichus",normalized:"if"},unless:{primary:"mana sichus",normalized:"unless"},when:{primary:"maykama",normalized:"when"},where:{primary:"maypi",normalized:"where"},else:{primary:"manachus",alternatives:["hukniraq"],normalized:"else"},repeat:{primary:"kutipay",alternatives:["muyu"],normalized:"repeat"},for:{primary:"sapankaq",normalized:"for"},while:{primary:"kaykamaqa",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"qatipay",normalized:"continue"},halt:{primary:"sayay",alternatives:[],normalized:"halt"},throw:{primary:"chanqay",normalized:"throw"},call:{primary:"waqyay",alternatives:["qayay"],normalized:"call"},return:{primary:"kutichiy",alternatives:["kutimuy"],normalized:"return"},then:{primary:"chaymantataq",alternatives:["hinaspa","chaymanta"],normalized:"then"},and:{primary:"hinallataq",alternatives:["ima","chaymantawan"],normalized:"and"},end:{primary:"tukukuy",alternatives:["tukuy","puchukay"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"mana waqtalla",normalized:"async"},tell:{primary:"niy",alternatives:[],normalized:"tell"},default:{primary:"\xF1awpaq_kaq",alternatives:["qallariy"],normalized:"default"},init:{primary:"qallarichiy",normalized:"init"},behavior:{primary:"ruwana",normalized:"behavior"},install:{primary:"tarpuy",normalized:"install"},measure:{primary:"tupuy",normalized:"measure"},beep:{primary:"waqay",normalized:"beep"},break:{primary:"p'akiy",normalized:"break"},copy:{primary:"qillqay",normalized:"copy"},exit:{primary:"lluqsiy",normalized:"exit"},pick:{primary:"akllay",normalized:"pick"},render:{primary:"rikurichiy",normalized:"render"},into:{primary:"ukuman",normalized:"into"},before:{primary:"\xF1awpaq",normalized:"before"},after:{primary:"qhipa",normalized:"after"},until:{primary:"kama",alternatives:["-kama"],normalized:"until"},event:{primary:"ruwakuq",alternatives:["imayna"],normalized:"event"},from:{primary:"manta",alternatives:["-manta"],normalized:"from"},click:{primary:"\xF1itiy",normalized:"click"},load:{primary:"apakuy",normalized:"load"},submit:{primary:"apaykachay",normalized:"submit"},hover:{primary:"hawachiy",normalized:"hover"},input:{primary:"yaykuchiy",normalized:"input"},change:{primary:"kambiay",normalized:"change"},connect:{primary:"tinkiy",alternatives:["watay","hukllachay"],normalized:"connect"},stream:{primary:"phawachiy",alternatives:["sururichiy","ch'uquchiy"],normalized:"stream"},live:{primary:"kawsachkaq",alternatives:["kunan-pacha","kawsay"],normalized:"live"},socket:{primary:"tinkina",alternatives:["t'oqo","tinkiy-tinkina"],normalized:"socket"},bind:{primary:"bind",alternatives:["watachiy"],normalized:"bind"},intercept:{primary:"hark'ay",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"llamk'aq",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["kawsay-pukyu"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"pi",alternatives:["kaqtin"]},sourceMarker:{primary:"manta",position:"after"},eventMarker:{primary:"pi",alternatives:["kaqtin","kaqpi"],position:"after"}}};function Mn(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:i==="\xF1"||i==="\xD1"||i==="'"||i==="'"}function _n(i){for(let e of i)if(Mn(e))return true;return false}var In=[{pattern:"shankichik",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"shaniku",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"shanki",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"shani",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"shanchik",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"shanku",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"shan",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"rqankichik",confidence:.8,conjugationType:"past",minStemLength:2},{pattern:"rqaniku",confidence:.8,conjugationType:"past",minStemLength:2},{pattern:"rqanki",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"rqani",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"rqanchik",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"rqanku",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"rqan",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"nqankichik",confidence:.8,conjugationType:"future",minStemLength:2},{pattern:"nqaniku",confidence:.8,conjugationType:"future",minStemLength:2},{pattern:"nqanki",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"nqani",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"nqanchik",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"nqanku",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"nqa",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"chikuy",confidence:.8,conjugationType:"compound",minStemLength:2},{pattern:"chiku",confidence:.82,conjugationType:"compound",minStemLength:2},{pattern:"chiy",confidence:.85,conjugationType:"causative",minStemLength:2,replacement:"y"},{pattern:"chiq",confidence:.85,conjugationType:"causative",minStemLength:2,replacement:"y"},{pattern:"chi",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"kuy",confidence:.82,conjugationType:"reflexive",minStemLength:2},{pattern:"rqa",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"rqan",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"sha",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"na",confidence:.85,conjugationType:"obligation",minStemLength:2},{pattern:"manmi",confidence:.8,conjugationType:"potential",minStemLength:2},{pattern:"man",confidence:.8,conjugationType:"potential",minStemLength:2},{pattern:"nkichik",confidence:.8,conjugationType:"present",minStemLength:2},{pattern:"niku",confidence:.8,conjugationType:"present",minStemLength:2},{pattern:"nki",confidence:.82,conjugationType:"present",minStemLength:2},{pattern:"nchik",confidence:.82,conjugationType:"present",minStemLength:2},{pattern:"nku",confidence:.82,conjugationType:"present",minStemLength:2},{pattern:"ni",confidence:.85,conjugationType:"present",minStemLength:2},{pattern:"ku",confidence:.82,conjugationType:"reflexive",minStemLength:2},{pattern:"ychik",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"y",confidence:.9,conjugationType:"dictionary",minStemLength:2},{pattern:"sqa",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"ska",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"kama",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"manta",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"man",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"wan",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"pi",confidence:.7,conjugationType:"dictionary",minStemLength:2},{pattern:"ta",confidence:.7,conjugationType:"dictionary",minStemLength:2}],jn=class{constructor(){this.language="qu";}isNormalizable(i){return !(!_n(i)||i.length<3||!/[aiu]/.test(i.toLowerCase()))}normalize(i){let e=i.toLowerCase();for(let r of In)if(e.endsWith(r.pattern)){let t=e.slice(0,-r.pattern.length);r.replacement&&!t.endsWith(r.replacement)&&(t=t+r.replacement);let a=r.minStemLength??2;if(t.length<a||!this.isValidStem(t))continue;let n={removedSuffixes:[r.pattern]};return r.conjugationType&&(n.conjugationType=r.conjugationType),hr(t,r.confidence,n)}return fr(i)}isValidStem(i){return !(i.length<2||!/[aeiou]/.test(i)||new Set(["ta","man","pi","wan","pa","kama","hina"]).has(i))}},qn=new jn,Vn=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],$n=class{constructor(i=Vn){this.name="operator",this.operators=[...i].sort((e,r)=>r.length-e.length);}canExtract(i,e){return this.operators.some(r=>i.startsWith(r,e))}extract(i,e){for(let r of this.operators)if(i.startsWith(r,e))return {value:r,length:r.length};return null}},Wn="()[]{},:;",Kn=class{constructor(i=Wn){this.punctuation=i,this.name="punctuation";}canExtract(i,e){return this.punctuation.includes(i[e])}extract(i,e){let r=i[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Xr(i,e){let r=i[e];if(r==="#"){let t=i.slice(e).match(/^#[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="."){let t=i.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(t)return t[0];let a=i.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return a?a[0]:null}if(r==="@"){let t=i.slice(e).match(/^@[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="*"){let t=i.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="["){let t=0,a=e;for(;a<i.length;){if(i[a]==="["&&t++,i[a]==="]"&&(t--,t===0))return i.slice(e,a+1);a++;}return null}if(r==="<"){let t=i.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return t?t[0]:null}return null}var Un=class{constructor(){this.name="css-selector";}canExtract(i,e){let r=i[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Xr(i,e)!==null:false}extract(i,e){let r=Xr(i,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Hn=class{constructor(){this.name="event-modifier";}canExtract(i,e){if(i[e]!==".")return false;let r=i.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(i,e){let r=i.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let t=r[0],a=t.slice(1).split("(")[0],n=r[1];return {value:t,length:t.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}};function Gn(i,e){let r=i.slice(e);if(r.startsWith("http://")||r.startsWith("https://")){let t=r.match(/^https?:\/\/[^\s]*/);return t?t[0]:null}if(r.startsWith("//")){let t=r.match(/^\/\/[^\s]*/);return t?t[0]:null}if(r.startsWith("./")||r.startsWith("../")){let t=r.match(/^\.\.?\/[^\s]*/);return t?t[0]:null}if(r.startsWith("/")){let t=r.match(/^\/[^\s]*/);return t?t[0]:null}return null}var Yn=class{constructor(){this.name="url";}canExtract(i,e){let r=i.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(i,e){let r=Gn(i,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Qn=class{constructor(){this.name="variable-ref";}canExtract(i,e){let r=i[e];return (r===":"||r==="$"||r==="^")&&e+1<i.length&&/[a-zA-Z_]/.test(i[e+1])}extract(i,e){if(!this.canExtract(i,e))return null;let r=1;for(;e+r<i.length&&/[a-zA-Z0-9_]/.test(i[e+r]);)r++;return {value:i.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function Le(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:i==="\xF1"||i==="\xD1"||i==="'"||i==="\u2019"}var ar=new Set(["-ta","-man","-manta","-pi","-wan","-paq","-kama","-rayku","-hina","ta","man","manta","pi","wan","paq","kama","hina","pa"]),et=new Set(["kama","hina","rayku","paq"]),Zn=new Set([...ar,...et].map(i=>i.startsWith("-")?i.slice(1):i));function Xn(i,e){let r=i.slice(e);for(let t of Zn){if(!r.startsWith(t))continue;let a=i[e+t.length];if(a===void 0||!Le(a))return true}return false}var Jn=class{constructor(){this.name="quechua-keyword";}setContext(i){this.context=i;}canExtract(i,e){return Le(i[e])?true:this.isHyphenatedSuffix(i,e)!==null}isHyphenatedSuffix(i,e){if(i[e]!=="-")return null;let r=i.slice(e).match(/^-([a-zñ'’]+)/i);return r&&ar.has(`-${r[1].toLowerCase()}`)?r[1]:null}extract(i,e){if(!this.context)throw new Error("QuechuaKeywordExtractor: context not set");let r=e,t=this.isHyphenatedSuffix(i,e);if(t!==null)return {value:t,length:t.length+1,metadata:{suffixValue:t.toLowerCase()}};let a=12;for(let c=Math.min(a,i.length-r);c>=2;c--){let m=i.slice(r,r+c),p=i[r+c];if(p!==void 0&&Le(p))continue;let d=true;for(let v=0;v<m.length;v++)if(!Le(m[v])){d=false;break}if(!d)continue;let y=this.context.lookupKeyword(m);if(y)return {value:m,length:c,metadata:{normalized:y.normalized!==y.native?y.normalized:void 0}};if(this.context.normalizer){let v=this.context.normalizer.normalize(m);if(v.stem!==m&&v.confidence>=.7){let f=this.context.lookupKeyword(v.stem);if(f)return {value:m,length:c,metadata:{normalized:f.normalized}}}}}let n="",o=e;for(;o<i.length&&Le(i[o])&&!(n.length>0&&Xn(i,o));)n+=i[o],o++;if(!n)return null;if(ar.has(n.toLowerCase()))return {value:n,length:o-r,metadata:{suffixValue:n.toLowerCase()}};if(et.has(n.toLowerCase()))return {value:n,length:o-r,metadata:{postpositionValue:n.toLowerCase()}};let u=this.context.lookupKeyword(n),s=u&&u.normalized!==u.native?u.normalized:void 0,l;if(!u&&this.context.normalizer){let c=this.context.normalizer.normalize(n);if(c.stem!==n&&c.confidence>=.7){let m=this.context.lookupKeyword(c.stem);m&&(l=m.normalized);}}return {value:n,length:o-r,metadata:{normalized:s||l}}}};function eo(){return new Jn}function ro(){return [new Yn,new Hn,new Qn,new Un]}var to=class{constructor(){this.name="quechua-string-literal";}canExtract(i,e){return i[e]==='"'||i[e]==="'"}extract(i,e){let r=i[e],t=r,a=e+1;for(;a<i.length;){let n=i[a];if(n===r)return t+=n,{value:t,length:t.length};n==="\\"&&a+1<i.length?(t+=n+i[a+1],a+=2):(t+=n,a++);}return null}},io=new Set(["-ta","-man","-manta","-pi","-wan","-paq","-kama","-rayku","-hina","ta","man","manta","pi","wan","paq","kama","hina","pa"]),ao=[{native:"cheqaq",normalized:"true"},{native:"ar\xED",normalized:"true"},{native:"ari",normalized:"true"},{native:"manan",normalized:"false"},{native:"mana",normalized:"false"},{native:"ch'usaq",normalized:"null"},{native:"chusaq",normalized:"null"},{native:"mana riqsisqa",normalized:"undefined"},{native:"\xF1awpaqpi",normalized:"before"},{native:"nawpaqpi",normalized:"before"},{native:"qhepapi",normalized:"after"},{native:"qhipapi",normalized:"after"},{native:"\xF1awpaq",normalized:"first"},{native:"nawpaq",normalized:"first"},{native:"qhipa",normalized:"last"},{native:"hamuq",normalized:"next"},{native:"qhipantin",normalized:"next"},{native:"\xF1awpaqnin",normalized:"previous"},{native:"\xF1awpaq kaq",normalized:"previous"},{native:"\xF1awpaq_kaq",normalized:"previous"},{native:"kaylla",normalized:"closest"},{native:"qaylla",normalized:"closest"},{native:"tayta",normalized:"parent"},{native:"llikllay",normalized:"click"},{native:"\xF1itiy",normalized:"click"},{native:"\xF1it'iy",normalized:"click"},{native:"click",normalized:"click"},{native:"yaykuy",normalized:"input"},{native:"llave uray",normalized:"keydown"},{native:"llave hawa",normalized:"keyup"},{native:"mausiri yayku",normalized:"mouseover"},{native:"mausiri lluqsi",normalized:"mouseout"},{native:"rat\xF1itiy",normalized:"mousedown"},{native:"rathuqariy",normalized:"mouseup"},{native:"qhaway",normalized:"focus"},{native:"mana qhaway",normalized:"blur"},{native:"kargay",normalized:"load"},{native:"muyuy",normalized:"scroll"},{native:"\xF1uqa",normalized:"me"},{native:"nuqa",normalized:"me"},{native:"\xF1uqap",normalized:"my"},{native:"nuqap",normalized:"my"},{native:"chay",normalized:"it"},{native:"chaymi",normalized:"it"},{native:"lluqsiy",normalized:"result"},{native:"ruway",normalized:"event"},{native:"maypi",normalized:"target"},{native:"sikundu",normalized:"s"},{native:"segundu",normalized:"s"},{native:"waranqa sikundu",normalized:"ms"},{native:"minutu",normalized:"m"},{native:"ura",normalized:"h"},{native:"hora",normalized:"h"},{native:"chaypim",normalized:"on"},{native:"kaypi",normalized:"on"},{native:"chayqa",normalized:"then"},{native:"chaymanta",normalized:"then"},{native:"chaymantataq",normalized:"then"},{native:"hinaspa",normalized:"then"},{native:"tukukuy",normalized:"end"},{native:"puchukay",normalized:"end"},{native:"kaykama",normalized:"until"},{native:"yapay",normalized:"add"},{native:"t'ikray",normalized:"toggle"},{native:"tikray",normalized:"toggle"},{native:"qhawachiy",normalized:"focus"},{native:"mana qhawachiy",normalized:"blur"},{native:"-manta",normalized:"from"}],no=class extends yr{constructor(){super(),this.language="qu",this.direction="ltr",this.initializeKeywordsFromProfile(Jr,ao),this.setNormalizer(qn),this.registerExtractors(ro()),this.registerExtractor(new to),this.registerExtractor(new mr),this.registerExtractor(eo()),this.registerExtractor(new $n),this.registerExtractor(new Kn);}classifyToken(i){let e=i.toLowerCase();return io.has(e)?"particle":this.isKeyword(e)?"keyword":i.startsWith("/")||i.startsWith("./")||i.startsWith("../")||i.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(i)?"event-modifier":i.startsWith("#")||i.startsWith(".")||i.startsWith("[")||i.startsWith("*")||i.startsWith("<")?"selector":i.startsWith('"')||/^\d/.test(i)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(i)?"operator":"identifier"}},oo=new no;_r("qu",oo,Jr);function We(i){let e=i.getAttribute("data-lang");if(e)return nr(e);let r=i.getAttribute("data-hyperscript-lang")??i.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return nr(r);let t=typeof document<"u"?document.documentElement?.lang:null;return t&&t!=="en"?nr(t):null}function nr(i){return i.split("-")[0].toLowerCase()}var rt={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 Ke(i){switch(i.kind){case "event-handler":return uo(i);case "compound":return so(i);default:return lo(i)}}function uo(i){let e=["on"],r=i.roles.get("event");r&&e.push(Me(r));let t=i.roles.get("source");if(t&&e.push("from",Me(t)),i.body&&i.body.length>0){let a=i.body.map(Ke);e.push(a.join(" then "));}return e.join(" ")}function so(i){let e=i.chainType==="async"?"async":i.chainType;return i.statements.map(Ke).join(` ${e} `)}function lo(i){let e=rt[i.action];if(e){let t=[i.action];for(let[a,n]of e){let o=i.roles.get(a);o&&(a==="destination"&&o.type==="reference"&&o.value==="me"||(n&&t.push(n),t.push(Me(o))));}return t.join(" ")}let r=[i.action];for(let[,t]of i.roles)r.push(Me(t));return r.join(" ")}function Me(i){switch(i.type){case "literal":return typeof i.value=="string"&&i.dataType==="string"?`"${i.value}"`:String(i.value);case "selector":return i.value;case "reference":return i.value;case "property-path":return co(i);case "expression":return i.raw;case "flag":return i.enabled?`+${i.name}`:`~${i.name}`}}function co(i){let e=Me(i.object),r=i.property;if(i.object.type==="reference")switch(i.object.value){case "me":return `my ${r}`;case "it":return `its ${r}`;case "you":return `your ${r}`}return `${e}'s ${r}`}var it=.5,mo={confidenceThreshold:it,strategy:"semantic",fallbackToOriginal:true};function po(i,e){return typeof i=="number"?i:i[e]??i["*"]??it}function or(i,e,r={}){let t={...mo,...r},a=tt(i,e,t);if(a!==null)return a;let n=fo(i);if(n){let o=tt(n.commands,e,t);if(o!==null)return n.prefix+o}return i}function tt(i,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let t=po(r.confidenceThreshold,e),a=at(i,e,t);if(a!==null)return a}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let t=ho(i,e,r.i18nToEnglish);if(t!==null)return t}return null}var yo=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function fo(i){let e=i.match(yo);if(!e)return null;let r=e[1],t=i.slice(r.length);return t?{prefix:r,commands:t}:null}function at(i,e,r){try{let t=Eo(i,e);if(t.length>1)return go(t,e,r);if(!jr(e))return null;let a=Yr(i,e);return a.confidence<r||!a.node?null:Ke(a.node)}catch{return null}}function ho(i,e,r){try{let t=r(i,e);return t!==i?t:null}catch{return null}}function vo(i){let e=["then"],r=L(i);if(r?.keywords?.then){let t=r.keywords.then;if(t.primary&&t.primary!=="then"&&e.push(t.primary),t.alternatives)for(let a of t.alternatives)e.includes(a)||e.push(a);}return e}function Eo(i,e){let t=vo(e).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),a=new RegExp(`\\s+(?:${t.join("|")})\\s+`,"i"),n=i.split(`
|
|
5
|
+
`).map(u=>u.trim()).filter(u=>u.length>0),o=[];for(let u of n){let s=u.split(a);o.push(...s);}return o}function go(i,e,r){let t=[];for(let a of i){let n=at(a.trim(),e,r);if(n===null)return null;t.push(n);}return t.join(" then ")}function ur(i={}){return function(r){let{internals:t}=r,a=t.runtime,n=a.getScript.bind(a);a.getScript=function(o){let u=n(o);if(!u)return null;let s=zo(o,i);if(!s||s==="en")return u;let l=or(u,s,i);return i.debug&&l!==u&&console.log(`[hyperscript-i18n] ${s}: "${u}" \u2192 "${l}"`),l};}}function zo(i,e){if(e.languageAttribute){let t=i.getAttribute(e.languageAttribute);if(t)return t.split("-")[0].toLowerCase()}let r=We(i);return r||(e.defaultLanguage??null)}function nt(i,e,r={}){return e==="en"?i:or(i,e,r)}Ir(i=>Zr(i));function ot(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(ur()),ko());}function ko(){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(t=>{let a=e.getInternalData(t);a.initialized&&(a.initialized=false);}),e.processNode(document.body);}var Wu=["qu"];ot();exports.plugin=ur;exports.preprocess=nt;exports.resolveLanguage=We;exports.supportedLanguages=Wu;return exports;})({});
|