@lokascript/semantic 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ar.ar.global.js +2 -2
- package/dist/browser-core.core.global.js +2 -2
- package/dist/browser-de.de.global.js +2 -2
- package/dist/browser-east-asian.east-asian.global.js +2 -2
- package/dist/browser-en-tr.en-tr.global.js +2 -2
- package/dist/browser-en.en.global.js +2 -2
- package/dist/browser-es-en.es-en.global.js +2 -2
- package/dist/browser-es.es.global.js +2 -2
- package/dist/browser-fr.fr.global.js +2 -2
- package/dist/browser-id.id.global.js +2 -2
- package/dist/browser-ja.ja.global.js +2 -2
- package/dist/browser-ko.ko.global.js +2 -2
- package/dist/browser-lazy.lazy.global.js +2 -2
- package/dist/browser-priority.priority.global.js +2 -2
- package/dist/browser-pt.pt.global.js +2 -2
- package/dist/browser-qu.qu.global.js +2 -2
- package/dist/browser-sw.sw.global.js +2 -2
- package/dist/browser-tr.tr.global.js +2 -2
- package/dist/browser-western.western.global.js +2 -2
- package/dist/browser-zh.zh.global.js +2 -2
- package/dist/browser.global.js +2 -2
- package/dist/browser.global.js.map +1 -1
- package/dist/index.cjs +13042 -17462
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -5
- package/dist/index.d.ts +49 -5
- package/dist/index.js +14044 -18464
- package/dist/index.js.map +1 -1
- package/dist/languages/ar.d.ts +1 -1
- package/dist/languages/ar.js +31 -44
- package/dist/languages/ar.js.map +1 -1
- package/dist/languages/de.d.ts +1 -1
- package/dist/languages/de.js +14 -2
- package/dist/languages/de.js.map +1 -1
- package/dist/languages/en.d.ts +1 -1
- package/dist/languages/en.js +558 -12
- package/dist/languages/en.js.map +1 -1
- package/dist/languages/es.d.ts +1 -1
- package/dist/languages/es.js +16 -0
- package/dist/languages/es.js.map +1 -1
- package/dist/languages/fr.d.ts +1 -1
- package/dist/languages/fr.js +14 -2
- package/dist/languages/fr.js.map +1 -1
- package/dist/languages/id.d.ts +1 -1
- package/dist/languages/id.js +14 -2
- package/dist/languages/id.js.map +1 -1
- package/dist/languages/ja.d.ts +1 -1
- package/dist/languages/ja.js +18 -3
- package/dist/languages/ja.js.map +1 -1
- package/dist/languages/ko.d.ts +8 -1
- package/dist/languages/ko.js +75 -43
- package/dist/languages/ko.js.map +1 -1
- package/dist/languages/pt.d.ts +1 -1
- package/dist/languages/pt.js +17 -0
- package/dist/languages/pt.js.map +1 -1
- package/dist/languages/qu.d.ts +12 -1
- package/dist/languages/qu.js +77 -2
- package/dist/languages/qu.js.map +1 -1
- package/dist/languages/sw.d.ts +1 -1
- package/dist/languages/sw.js.map +1 -1
- package/dist/languages/tr.d.ts +9 -1
- package/dist/languages/tr.js +96 -72
- package/dist/languages/tr.js.map +1 -1
- package/dist/languages/zh.d.ts +1 -1
- package/dist/languages/zh.js +16 -0
- package/dist/languages/zh.js.map +1 -1
- package/dist/{types-C4dcj53L.d.ts → types-BY3Id07j.d.ts} +20 -5
- package/package.json +20 -29
- package/src/generators/command-schemas.ts +21 -10
- package/src/generators/event-handler-generator.ts +50 -44
- package/src/generators/language-profiles.ts +6 -0
- package/src/generators/pattern-generator.ts +883 -1
- package/src/generators/profiles/arabic.ts +19 -3
- package/src/generators/profiles/bengali.ts +12 -1
- package/src/generators/profiles/chinese.ts +15 -0
- package/src/generators/profiles/french.ts +12 -1
- package/src/generators/profiles/german.ts +12 -1
- package/src/generators/profiles/hebrew.ts +148 -0
- package/src/generators/profiles/hindi.ts +12 -1
- package/src/generators/profiles/index.ts +2 -0
- package/src/generators/profiles/indonesian.ts +12 -1
- package/src/generators/profiles/italian.ts +16 -0
- package/src/generators/profiles/japanese.ts +11 -2
- package/src/generators/profiles/korean.ts +15 -1
- package/src/generators/profiles/polish.ts +12 -0
- package/src/generators/profiles/portuguese.ts +16 -0
- package/src/generators/profiles/russian.ts +11 -0
- package/src/generators/profiles/spanish.ts +15 -0
- package/src/generators/profiles/spanishMexico.ts +176 -0
- package/src/generators/profiles/thai.ts +11 -0
- package/src/generators/profiles/turkish.ts +49 -7
- package/src/generators/profiles/types.ts +21 -5
- package/src/generators/profiles/ukrainian.ts +11 -0
- package/src/generators/profiles/vietnamese.ts +11 -0
- package/src/language-building-schema.ts +111 -0
- package/src/languages/_all.ts +5 -1
- package/src/languages/es-MX.ts +32 -0
- package/src/languages/he.ts +15 -0
- package/src/parser/pattern-matcher.ts +10 -1
- package/src/parser/semantic-parser.ts +3 -0
- package/src/patterns/add/ar.ts +3 -59
- package/src/patterns/add/index.ts +5 -1
- package/src/patterns/add/ja.ts +3 -81
- package/src/patterns/add/ko.ts +3 -62
- package/src/patterns/add/qu.ts +69 -0
- package/src/patterns/add/tr.ts +3 -59
- package/src/patterns/builders.ts +1 -0
- package/src/patterns/decrement/tr.ts +3 -36
- package/src/patterns/event-handler/ar.ts +3 -139
- package/src/patterns/event-handler/he.ts +15 -0
- package/src/patterns/event-handler/index.ts +5 -1
- package/src/patterns/event-handler/ja.ts +3 -106
- package/src/patterns/event-handler/ko.ts +3 -121
- package/src/patterns/event-handler/ms.ts +45 -20
- package/src/patterns/event-handler/tr.ts +3 -158
- package/src/patterns/get/ar.ts +3 -37
- package/src/patterns/get/ja.ts +3 -41
- package/src/patterns/get/ko.ts +3 -41
- package/src/patterns/grammar-transformed/ja.ts +3 -1701
- package/src/patterns/grammar-transformed/ko.ts +3 -1299
- package/src/patterns/grammar-transformed/tr.ts +3 -1055
- package/src/patterns/hide/ar.ts +3 -55
- package/src/patterns/hide/ja.ts +3 -57
- package/src/patterns/hide/ko.ts +3 -57
- package/src/patterns/hide/tr.ts +3 -53
- package/src/patterns/increment/tr.ts +3 -40
- package/src/patterns/put/ar.ts +3 -62
- package/src/patterns/put/ja.ts +3 -63
- package/src/patterns/put/ko.ts +3 -55
- package/src/patterns/put/tr.ts +3 -55
- package/src/patterns/remove/ar.ts +3 -59
- package/src/patterns/remove/index.ts +5 -1
- package/src/patterns/remove/ja.ts +3 -62
- package/src/patterns/remove/ko.ts +3 -66
- package/src/patterns/remove/qu.ts +69 -0
- package/src/patterns/remove/tr.ts +3 -66
- package/src/patterns/set/ar.ts +3 -72
- package/src/patterns/set/ja.ts +3 -74
- package/src/patterns/set/ko.ts +3 -73
- package/src/patterns/set/tr.ts +3 -95
- package/src/patterns/show/ar.ts +3 -55
- package/src/patterns/show/ja.ts +3 -57
- package/src/patterns/show/ko.ts +3 -61
- package/src/patterns/show/tr.ts +3 -53
- package/src/patterns/take/ar.ts +3 -39
- package/src/patterns/toggle/ar.ts +3 -49
- package/src/patterns/toggle/index.ts +5 -1
- package/src/patterns/toggle/ja.ts +3 -144
- package/src/patterns/toggle/ko.ts +3 -101
- package/src/patterns/toggle/qu.ts +90 -0
- package/src/patterns/toggle/tr.ts +3 -76
- package/src/registry.ts +179 -15
- package/src/tokenizers/arabic.ts +13 -46
- package/src/tokenizers/bengali.ts +2 -16
- package/src/tokenizers/he.ts +542 -0
- package/src/tokenizers/index.ts +1 -0
- package/src/tokenizers/japanese.ts +3 -1
- package/src/tokenizers/korean.ts +104 -48
- package/src/tokenizers/ms.ts +3 -0
- package/src/tokenizers/quechua.ts +101 -2
- package/src/tokenizers/turkish.ts +64 -69
- package/src/types.ts +13 -0
package/dist/languages/en.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/generators/schema-error-codes.ts","../../src/generators/schema-validator.ts","../../src/registry.ts","../../src/tokenizers/base.ts","../../src/generators/profiles/english.ts","../../src/tokenizers/english.ts","../../src/generators/command-schemas.ts","../../src/parser/utils/role-positioning.ts","../../src/parser/utils/marker-resolution.ts","../../src/generators/pattern-generator.ts","../../src/patterns/toggle/en.ts","../../src/patterns/put/en.ts","../../src/patterns/event-handler/en.ts","../../src/patterns/en.ts","../../src/languages/en.ts"],"sourcesContent":["/**\n * Schema Error Codes\n *\n * Provides machine-readable error codes for schema validation.\n * These codes enable LLMs and tooling to programmatically identify\n * and respond to specific validation issues.\n */\n\nimport type { SemanticRole } from '../types';\n\n/**\n * Severity levels for schema validation items.\n */\nexport type SchemaValidationSeverity = 'error' | 'warning' | 'note';\n\n/**\n * A structured validation item with machine-readable code.\n */\nexport interface SchemaValidationItem {\n /** Machine-readable error code */\n code: string;\n /** Human-readable message */\n message: string;\n /** Severity level */\n severity: SchemaValidationSeverity;\n /** Affected role, if applicable */\n role?: SemanticRole;\n /** Suggested fix */\n suggestion?: string;\n}\n\n/**\n * Schema error codes organized by category.\n */\nexport const SchemaErrorCodes = {\n // Type ambiguity issues\n AMBIGUOUS_TYPE_LITERAL_SELECTOR: 'SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR',\n TOO_MANY_EXPECTED_TYPES: 'SCHEMA_TOO_MANY_EXPECTED_TYPES',\n MULTI_TYPE_PATIENT_EXPECTED: 'SCHEMA_MULTI_TYPE_PATIENT_EXPECTED',\n\n // Role issues\n NO_REQUIRED_ROLES: 'SCHEMA_NO_REQUIRED_ROLES',\n NO_REQUIRED_ROLES_EXPECTED: 'SCHEMA_NO_REQUIRED_ROLES_EXPECTED',\n\n // Transition command\n TRANSITION_PATIENT_ACCEPTS_SELECTOR: 'SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR',\n TRANSITION_MISSING_GOAL: 'SCHEMA_TRANSITION_MISSING_GOAL',\n\n // Event handler command\n EVENT_HANDLER_MISSING_EVENT: 'SCHEMA_EVENT_HANDLER_MISSING_EVENT',\n EVENT_HANDLER_EVENT_NOT_REQUIRED: 'SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED',\n\n // Conditional commands\n CONDITIONAL_MISSING_CONDITION: 'SCHEMA_CONDITIONAL_MISSING_CONDITION',\n CONDITIONAL_CONDITION_NOT_REQUIRED: 'SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED',\n\n // Loop commands\n FOR_LOOP_MISSING_SOURCE: 'SCHEMA_FOR_LOOP_MISSING_SOURCE',\n WHILE_LOOP_MISSING_CONDITION: 'SCHEMA_WHILE_LOOP_MISSING_CONDITION',\n} as const;\n\nexport type SchemaErrorCode = (typeof SchemaErrorCodes)[keyof typeof SchemaErrorCodes];\n\n/**\n * Message templates for each error code.\n * Use {role}, {command}, {count} placeholders for dynamic values.\n */\nexport const SchemaErrorMessages: Record<SchemaErrorCode, string> = {\n // Type ambiguity\n [SchemaErrorCodes.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:\n \"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).\",\n [SchemaErrorCodes.TOO_MANY_EXPECTED_TYPES]:\n \"Role '{role}' accepts {count} different types. This may make type inference unreliable.\",\n [SchemaErrorCodes.MULTI_TYPE_PATIENT_EXPECTED]:\n \"Role '{role}' accepts multiple types (expected for {command} command).\",\n\n // Role issues\n [SchemaErrorCodes.NO_REQUIRED_ROLES]: 'Command has no required roles. Is this intentional?',\n [SchemaErrorCodes.NO_REQUIRED_ROLES_EXPECTED]:\n 'Command has no required roles (expected for {command}).',\n\n // Transition\n [SchemaErrorCodes.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:\n \"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.\",\n [SchemaErrorCodes.TRANSITION_MISSING_GOAL]:\n \"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.\",\n\n // Event handler\n [SchemaErrorCodes.EVENT_HANDLER_MISSING_EVENT]:\n \"Event handler command should have an 'event' role to specify which event to listen for.\",\n [SchemaErrorCodes.EVENT_HANDLER_EVENT_NOT_REQUIRED]:\n 'Event role should be required - every event handler needs an event to listen for.',\n\n // Conditionals\n [SchemaErrorCodes.CONDITIONAL_MISSING_CONDITION]:\n \"Conditional command should have a 'condition' role for the boolean expression.\",\n [SchemaErrorCodes.CONDITIONAL_CONDITION_NOT_REQUIRED]:\n 'Condition role should be required - conditionals need a condition to evaluate.',\n\n // Loops\n [SchemaErrorCodes.FOR_LOOP_MISSING_SOURCE]:\n \"For-loop should have a 'source' role for the collection to iterate over.\",\n [SchemaErrorCodes.WHILE_LOOP_MISSING_CONDITION]:\n \"While-loop should have a 'condition' role for the loop condition.\",\n};\n\n/**\n * Suggested fixes for each error code.\n */\nexport const SchemaErrorSuggestions: Partial<Record<SchemaErrorCode, string>> = {\n [SchemaErrorCodes.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:\n 'Consider being more specific about which type is expected, or use explicit type markers.',\n [SchemaErrorCodes.TOO_MANY_EXPECTED_TYPES]:\n 'Consider narrowing the accepted types to improve type inference reliability.',\n [SchemaErrorCodes.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:\n \"Remove 'selector' from expectedTypes and only accept 'literal'.\",\n [SchemaErrorCodes.TRANSITION_MISSING_GOAL]:\n \"Add a 'goal' role with expectedTypes ['literal', 'variable'].\",\n [SchemaErrorCodes.EVENT_HANDLER_MISSING_EVENT]:\n \"Add an 'event' role with expectedTypes ['literal'].\",\n [SchemaErrorCodes.EVENT_HANDLER_EVENT_NOT_REQUIRED]: \"Set required: true on the 'event' role.\",\n [SchemaErrorCodes.CONDITIONAL_MISSING_CONDITION]:\n \"Add a 'condition' role with expectedTypes ['expression'].\",\n [SchemaErrorCodes.CONDITIONAL_CONDITION_NOT_REQUIRED]:\n \"Set required: true on the 'condition' role.\",\n [SchemaErrorCodes.FOR_LOOP_MISSING_SOURCE]:\n \"Add a 'source' role for the collection to iterate over.\",\n [SchemaErrorCodes.WHILE_LOOP_MISSING_CONDITION]:\n \"Add a 'condition' role for the loop continuation condition.\",\n};\n\n/**\n * Interpolate placeholders in a message template.\n */\nfunction interpolate(template: string, params: Record<string, string | number>): string {\n return template.replace(/\\{(\\w+)\\}/g, (_, key) => String(params[key] ?? `{${key}}`));\n}\n\n/**\n * Create a schema validation item with proper interpolation.\n */\nexport function createSchemaValidationItem(\n code: SchemaErrorCode,\n severity: SchemaValidationSeverity,\n params: Record<string, string | number> = {},\n role?: SemanticRole\n): SchemaValidationItem {\n const messageTemplate = SchemaErrorMessages[code];\n const message = interpolate(messageTemplate, params);\n const suggestionTemplate = SchemaErrorSuggestions[code];\n const suggestion = suggestionTemplate ? interpolate(suggestionTemplate, params) : undefined;\n\n return {\n code,\n message,\n severity,\n ...(role && { role }),\n ...(suggestion && { suggestion }),\n };\n}\n","/**\n * Schema Validation\n *\n * Validates command schemas to catch design issues early:\n * - Ambiguous type combinations (e.g., both 'literal' and 'selector')\n * - Missing required roles for specific commands\n * - Schema inconsistencies\n *\n * This runs at build time in development to catch schema errors before they cause\n * runtime issues.\n */\n\nimport type { CommandSchema } from './command-schemas';\nimport type { ActionType } from '../types';\nimport {\n type SchemaValidationItem,\n type SchemaValidationSeverity,\n SchemaErrorCodes,\n createSchemaValidationItem,\n} from './schema-error-codes';\n\n// Re-export for convenience\nexport type { SchemaValidationItem, SchemaValidationSeverity };\nexport { SchemaErrorCodes };\n\n/**\n * Result from validating a single command schema.\n *\n * The `items` array contains all validation results with machine-readable codes.\n * For backward compatibility, `notes`, `warnings`, and `errors` getters are provided.\n */\nexport interface SchemaValidation {\n action: ActionType;\n /** All validation items with structured codes and severity */\n items: SchemaValidationItem[];\n}\n\n/**\n * Extended validation result with backward-compatible getters.\n */\nexport interface SchemaValidationResult extends SchemaValidation {\n /** @deprecated Use items.filter(i => i.severity === 'note') */\n readonly notes: string[];\n /** @deprecated Use items.filter(i => i.severity === 'warning') */\n readonly warnings: string[];\n /** @deprecated Use items.filter(i => i.severity === 'error') */\n readonly errors: string[];\n}\n\n/**\n * Create a SchemaValidationResult with backward-compatible getters.\n */\nfunction createValidationResult(\n action: ActionType,\n items: SchemaValidationItem[]\n): SchemaValidationResult {\n return {\n action,\n items,\n get notes() {\n return items.filter(i => i.severity === 'note').map(i => i.message);\n },\n get warnings() {\n return items.filter(i => i.severity === 'warning').map(i => i.message);\n },\n get errors() {\n return items.filter(i => i.severity === 'error').map(i => i.message);\n },\n };\n}\n\n// Commands where multi-type patient roles are intentional (not ambiguous)\nconst MULTI_TYPE_PATIENT_COMMANDS = new Set([\n 'put',\n 'append',\n 'prepend',\n 'log',\n 'throw',\n 'make',\n 'measure',\n 'return',\n 'swap',\n 'morph', // DOM manipulation commands that accept various content types\n]);\n\n// Commands that intentionally have no required roles\nconst NO_REQUIRED_ROLES_COMMANDS = new Set([\n 'compound',\n 'else',\n 'halt',\n 'continue',\n 'async',\n 'init',\n 'settle',\n 'focus',\n 'blur',\n 'return',\n 'js',\n 'measure', // Commands with optional-only roles\n]);\n\n/**\n * Validate a single command schema for potential issues.\n *\n * @param schema - The command schema to validate\n * @returns Validation result with structured items and backward-compatible getters\n */\nexport function validateCommandSchema(schema: CommandSchema): SchemaValidationResult {\n const items: SchemaValidationItem[] = [];\n\n // Check for ambiguous type combinations in roles\n for (const role of schema.roles) {\n // Check if a role accepts both 'literal' and 'selector'\n if (role.expectedTypes.includes('literal') && role.expectedTypes.includes('selector')) {\n if (role.role === 'patient' && MULTI_TYPE_PATIENT_COMMANDS.has(schema.action)) {\n // Known pattern - add as note, not warning\n items.push(\n createSchemaValidationItem(\n SchemaErrorCodes.MULTI_TYPE_PATIENT_EXPECTED,\n 'note',\n { role: role.role, command: schema.action },\n role.role\n )\n );\n } else {\n items.push(\n createSchemaValidationItem(\n SchemaErrorCodes.AMBIGUOUS_TYPE_LITERAL_SELECTOR,\n 'warning',\n { role: role.role },\n role.role\n )\n );\n }\n }\n\n // Warn if a role has too many expected types (> 3)\n if (role.expectedTypes.length > 3 && !MULTI_TYPE_PATIENT_COMMANDS.has(schema.action)) {\n items.push(\n createSchemaValidationItem(\n SchemaErrorCodes.TOO_MANY_EXPECTED_TYPES,\n 'warning',\n { role: role.role, count: role.expectedTypes.length },\n role.role\n )\n );\n }\n }\n\n // Command-specific validation rules\n switch (schema.action) {\n case 'transition':\n validateTransitionSchema(schema, items);\n break;\n\n case 'on':\n validateEventHandlerSchema(schema, items);\n break;\n\n case 'if':\n case 'unless':\n validateConditionalSchema(schema, items);\n break;\n\n case 'repeat':\n case 'for':\n case 'while':\n validateLoopSchema(schema, items);\n break;\n }\n\n // Check for schemas with no required roles\n const requiredRoles = schema.roles.filter(r => r.required);\n if (requiredRoles.length === 0) {\n if (NO_REQUIRED_ROLES_COMMANDS.has(schema.action)) {\n // Known pattern - add as note\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.NO_REQUIRED_ROLES_EXPECTED, 'note', {\n command: schema.action,\n })\n );\n } else {\n items.push(createSchemaValidationItem(SchemaErrorCodes.NO_REQUIRED_ROLES, 'warning', {}));\n }\n }\n\n return createValidationResult(schema.action, items);\n}\n\n/**\n * Validate the transition command schema.\n */\nfunction validateTransitionSchema(schema: CommandSchema, items: SchemaValidationItem[]): void {\n const patientRole = schema.roles.find(r => r.role === 'patient');\n const goalRole = schema.roles.find(r => r.role === 'goal');\n\n // Check that patient (property name) only accepts literals\n if (patientRole && patientRole.expectedTypes.includes('selector')) {\n items.push(\n createSchemaValidationItem(\n SchemaErrorCodes.TRANSITION_PATIENT_ACCEPTS_SELECTOR,\n 'warning',\n {},\n 'patient'\n )\n );\n }\n\n // Check that transition has a goal role for the target value\n if (patientRole && !goalRole) {\n items.push(createSchemaValidationItem(SchemaErrorCodes.TRANSITION_MISSING_GOAL, 'error', {}));\n }\n}\n\n/**\n * Validate event handler schemas (on command).\n */\nfunction validateEventHandlerSchema(schema: CommandSchema, items: SchemaValidationItem[]): void {\n const eventRole = schema.roles.find(r => r.role === 'event');\n\n if (!eventRole) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.EVENT_HANDLER_MISSING_EVENT, 'warning', {})\n );\n }\n\n if (eventRole && !eventRole.required) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.EVENT_HANDLER_EVENT_NOT_REQUIRED, 'warning', {})\n );\n }\n}\n\n/**\n * Validate conditional schemas (if/unless).\n */\nfunction validateConditionalSchema(schema: CommandSchema, items: SchemaValidationItem[]): void {\n const conditionRole = schema.roles.find(r => r.role === 'condition');\n\n if (!conditionRole) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.CONDITIONAL_MISSING_CONDITION, 'warning', {})\n );\n }\n\n if (conditionRole && !conditionRole.required) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.CONDITIONAL_CONDITION_NOT_REQUIRED, 'warning', {})\n );\n }\n}\n\n/**\n * Validate loop schemas (repeat, for, while).\n */\nfunction validateLoopSchema(schema: CommandSchema, items: SchemaValidationItem[]): void {\n // Different loop types have different requirements\n if (schema.action === 'for') {\n const sourceRole = schema.roles.find(r => r.role === 'source');\n if (!sourceRole) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.FOR_LOOP_MISSING_SOURCE, 'warning', {})\n );\n }\n } else if (schema.action === 'while') {\n const conditionRole = schema.roles.find(r => r.role === 'condition');\n if (!conditionRole) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.WHILE_LOOP_MISSING_CONDITION, 'warning', {})\n );\n }\n }\n}\n\n/**\n * Validate all command schemas in the registry.\n *\n * @param schemas - Map of action names to command schemas\n * @param options - Validation options\n * @returns Map of action names to validation results (only includes schemas with issues)\n */\nexport function validateAllSchemas(\n schemas: Record<string, CommandSchema>,\n options: { includeNotes?: boolean } = {}\n): Map<string, SchemaValidationResult> {\n const results = new Map<string, SchemaValidationResult>();\n const { includeNotes = false } = options;\n\n for (const [action, schema] of Object.entries(schemas)) {\n const validation = validateCommandSchema(schema);\n\n // Include in results if there are warnings/errors (or notes if requested)\n const hasWarningsOrErrors = validation.items.some(\n i => i.severity === 'warning' || i.severity === 'error'\n );\n const hasNotes = includeNotes && validation.items.some(i => i.severity === 'note');\n\n if (hasWarningsOrErrors || hasNotes) {\n results.set(action, validation);\n }\n }\n\n return results;\n}\n\n/**\n * Format validation results for console output.\n *\n * @param validations - Map of validation results\n * @param options - Formatting options\n * @returns Formatted string for console output\n */\nexport function formatValidationResults(\n validations: Map<string, SchemaValidationResult>,\n options: { showNotes?: boolean; showCodes?: boolean } = {}\n): string {\n const lines: string[] = [];\n const { showNotes = false, showCodes = true } = options;\n\n for (const [action, result] of validations) {\n const errors = result.items.filter(i => i.severity === 'error');\n const warnings = result.items.filter(i => i.severity === 'warning');\n const notes = result.items.filter(i => i.severity === 'note');\n\n if (errors.length > 0) {\n lines.push(` ❌ ${action}:`);\n for (const item of errors) {\n const codeStr = showCodes ? ` [${item.code}]` : '';\n lines.push(` ERROR${codeStr}: ${item.message}`);\n if (item.suggestion) {\n lines.push(` 💡 Suggestion: ${item.suggestion}`);\n }\n }\n }\n\n if (warnings.length > 0) {\n lines.push(` ⚠️ ${action}:`);\n for (const item of warnings) {\n const codeStr = showCodes ? ` [${item.code}]` : '';\n lines.push(` ${codeStr ? `${item.code}: ` : ''}${item.message}`);\n if (item.suggestion) {\n lines.push(` 💡 ${item.suggestion}`);\n }\n }\n }\n\n if (showNotes && notes.length > 0) {\n lines.push(` ℹ️ ${action}:`);\n for (const item of notes) {\n const codeStr = showCodes ? ` [${item.code}]` : '';\n lines.push(` ${codeStr ? `${item.code}: ` : ''}${item.message}`);\n }\n }\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Get validation statistics.\n */\nexport function getValidationStats(validations: Map<string, SchemaValidationResult>): {\n totalCommands: number;\n errors: number;\n warnings: number;\n notes: number;\n byCode: Record<string, number>;\n} {\n let errors = 0;\n let warnings = 0;\n let notes = 0;\n const byCode: Record<string, number> = {};\n\n for (const result of validations.values()) {\n for (const item of result.items) {\n if (item.severity === 'error') errors++;\n else if (item.severity === 'warning') warnings++;\n else if (item.severity === 'note') notes++;\n\n byCode[item.code] = (byCode[item.code] || 0) + 1;\n }\n }\n\n return {\n totalCommands: validations.size,\n errors,\n warnings,\n notes,\n byCode,\n };\n}\n","/**\n * Language Registry\n *\n * Central registration point for language support in the semantic parser.\n * Languages self-register when their modules are imported, enabling\n * tree-shaking for minimal bundles.\n *\n * @example\n * ```typescript\n * // Import only the languages you need\n * import '@lokascript/semantic/languages/en';\n * import '@lokascript/semantic/languages/es';\n *\n * // Now parse works for registered languages\n * import { parse } from '@lokascript/semantic';\n * parse('toggle .active', 'en'); // Works\n * parse('alternar .activo', 'es'); // Works\n * parse('切り替え .active', 'ja'); // Error: Language not registered\n * ```\n */\n\nimport type { LanguageTokenizer, LanguagePattern, TokenStream } from './types';\n\n// Re-export profile types from generators for convenience\nexport type {\n LanguageProfile,\n WordOrder,\n MarkingStrategy,\n RoleMarker,\n VerbConfig,\n PossessiveConfig,\n KeywordTranslation,\n TokenizationConfig,\n} from './generators/language-profiles';\n\nimport type { LanguageProfile } from './generators/language-profiles';\n\n// =============================================================================\n// External Pattern Source Interface\n// =============================================================================\n\n/**\n * Interface for external pattern sources (e.g., @lokascript/patterns-reference database).\n * External sources can provide additional patterns at runtime.\n */\nexport interface ExternalPatternsSource {\n /** Unique identifier for the source */\n id: string;\n /** Human-readable name */\n name: string;\n /** Get patterns for a specific language */\n getPatternsForLanguage(language: string): Promise<ExternalPatternEntry[]>;\n /** Get patterns for a specific command */\n getPatternsForCommand(command: string, language?: string): Promise<ExternalPatternEntry[]>;\n /** Check if source has patterns for a language */\n hasPatterns(language: string): Promise<boolean>;\n /** Get all supported languages */\n getSupportedLanguages(): Promise<string[]>;\n}\n\n/**\n * Pattern entry from external source.\n */\nexport interface ExternalPatternEntry {\n id: string;\n code: string;\n command: string | null;\n language: string;\n confidence: number;\n verified: boolean;\n title?: string;\n category?: string;\n}\n\n// =============================================================================\n// Registry State\n// =============================================================================\n\nconst tokenizers = new Map<string, LanguageTokenizer>();\nconst profiles = new Map<string, LanguageProfile>();\nconst patternCache = new Map<string, LanguagePattern[]>();\n\n// External pattern sources (e.g., @lokascript/patterns-reference database)\nconst externalSources = new Map<string, ExternalPatternsSource>();\n\n// Pattern generator function - set by patterns module to avoid circular deps\nlet patternGenerator: ((profile: LanguageProfile) => LanguagePattern[]) | null = null;\n\n// =============================================================================\n// Registration Functions\n// =============================================================================\n\n/**\n * Register a language with its tokenizer and profile.\n * Called automatically by language modules when imported.\n */\nexport function registerLanguage(\n code: string,\n tokenizer: LanguageTokenizer,\n profile: LanguageProfile\n): void {\n tokenizers.set(code, tokenizer);\n profiles.set(code, profile);\n // Clear pattern cache for this language if it was previously cached\n patternCache.delete(code);\n}\n\n/**\n * Register only a tokenizer (for backwards compatibility).\n */\nexport function registerTokenizer(tokenizer: LanguageTokenizer): void {\n tokenizers.set(tokenizer.language, tokenizer);\n}\n\n/**\n * Register only a profile (for backwards compatibility).\n */\nexport function registerProfile(profile: LanguageProfile): void {\n profiles.set(profile.code, profile);\n patternCache.delete(profile.code);\n}\n\n/**\n * Set the pattern generator function.\n * Called by patterns module to inject the generator without circular deps.\n */\nexport function setPatternGenerator(\n generator: (profile: LanguageProfile) => LanguagePattern[]\n): void {\n patternGenerator = generator;\n}\n\n// Direct pattern registration map (for tree-shaking)\nconst registeredPatterns = new Map<string, LanguagePattern[]>();\n\n/**\n * Register patterns directly for a language.\n * This enables tree-shaking by allowing each language module to register\n * only its own patterns.\n */\nexport function registerPatterns(code: string, patterns: LanguagePattern[]): void {\n registeredPatterns.set(code, patterns);\n // Clear cached patterns if any\n patternCache.delete(code);\n}\n\n/**\n * Check if patterns are directly registered for a language.\n */\nexport function hasRegisteredPatterns(code: string): boolean {\n return registeredPatterns.has(code);\n}\n\n/**\n * Get directly registered patterns for a language.\n */\nexport function getRegisteredPatterns(code: string): LanguagePattern[] | undefined {\n return registeredPatterns.get(code);\n}\n\n// =============================================================================\n// External Pattern Sources\n// =============================================================================\n\n/**\n * Register an external pattern source.\n * External sources (like @lokascript/patterns-reference) can provide\n * additional patterns at runtime.\n *\n * @example\n * ```typescript\n * import { registerPatternsSource } from '@lokascript/semantic';\n * import { createPatternsProvider } from '@lokascript/patterns-reference';\n *\n * const provider = createPatternsProvider();\n * registerPatternsSource(provider);\n * ```\n */\nexport function registerPatternsSource(source: ExternalPatternsSource): void {\n externalSources.set(source.id, source);\n}\n\n/**\n * Unregister an external pattern source.\n */\nexport function unregisterPatternsSource(sourceId: string): boolean {\n return externalSources.delete(sourceId);\n}\n\n/**\n * Get a registered external pattern source.\n */\nexport function getPatternsSource(sourceId: string): ExternalPatternsSource | undefined {\n return externalSources.get(sourceId);\n}\n\n/**\n * Get all registered external pattern sources.\n */\nexport function getAllPatternsSources(): ExternalPatternsSource[] {\n return Array.from(externalSources.values());\n}\n\n/**\n * Check if any external pattern sources are registered.\n */\nexport function hasExternalSources(): boolean {\n return externalSources.size > 0;\n}\n\n/**\n * Query patterns from all external sources for a language.\n * Returns patterns sorted by confidence.\n */\nexport async function queryExternalPatterns(language: string): Promise<ExternalPatternEntry[]> {\n if (externalSources.size === 0) {\n return [];\n }\n\n const allPatterns: ExternalPatternEntry[] = [];\n\n for (const source of externalSources.values()) {\n try {\n const patterns = await source.getPatternsForLanguage(language);\n allPatterns.push(...patterns);\n } catch (error) {\n console.warn(\n `[Registry] Failed to query patterns from ${source.name}:`,\n error instanceof Error ? error.message : String(error)\n );\n }\n }\n\n // Sort by confidence (highest first)\n return allPatterns.sort((a, b) => b.confidence - a.confidence);\n}\n\n/**\n * Query patterns from all external sources for a command.\n */\nexport async function queryExternalPatternsForCommand(\n command: string,\n language?: string\n): Promise<ExternalPatternEntry[]> {\n if (externalSources.size === 0) {\n return [];\n }\n\n const allPatterns: ExternalPatternEntry[] = [];\n\n for (const source of externalSources.values()) {\n try {\n const patterns = await source.getPatternsForCommand(command, language);\n allPatterns.push(...patterns);\n } catch (error) {\n console.warn(\n `[Registry] Failed to query patterns from ${source.name}:`,\n error instanceof Error ? error.message : String(error)\n );\n }\n }\n\n return allPatterns.sort((a, b) => b.confidence - a.confidence);\n}\n\n// =============================================================================\n// Query Functions\n// =============================================================================\n\n/**\n * Get a tokenizer for the specified language.\n * @throws Error if language is not registered\n */\nexport function getTokenizer(code: string): LanguageTokenizer {\n const tokenizer = tokenizers.get(code);\n if (!tokenizer) {\n const registered = Array.from(tokenizers.keys()).join(', ');\n throw new Error(\n `Language '${code}' is not registered. ` +\n `Registered languages: ${registered || 'none'}. ` +\n `Import the language module first: import '@lokascript/semantic/languages/${code}';`\n );\n }\n return tokenizer;\n}\n\n/**\n * Get a profile for the specified language.\n * @throws Error if language is not registered\n */\nexport function getProfile(code: string): LanguageProfile {\n const profile = profiles.get(code);\n if (!profile) {\n const registered = Array.from(profiles.keys()).join(', ');\n throw new Error(\n `Language profile '${code}' is not registered. ` +\n `Registered languages: ${registered || 'none'}. ` +\n `Import the language module first: import '@lokascript/semantic/languages/${code}';`\n );\n }\n return profile;\n}\n\n/**\n * Try to get a tokenizer, returning undefined if not registered.\n */\nexport function tryGetTokenizer(code: string): LanguageTokenizer | undefined {\n return tokenizers.get(code);\n}\n\n/**\n * Try to get a profile, returning undefined if not registered.\n */\nexport function tryGetProfile(code: string): LanguageProfile | undefined {\n return profiles.get(code);\n}\n\n/**\n * Get all registered language codes.\n */\nexport function getRegisteredLanguages(): string[] {\n return Array.from(tokenizers.keys());\n}\n\n/**\n * Check if a language is registered.\n */\nexport function isLanguageRegistered(code: string): boolean {\n return tokenizers.has(code) && profiles.has(code);\n}\n\n/**\n * Check if a language is supported (alias for isLanguageRegistered).\n * For backwards compatibility with tokenizers API.\n */\nexport function isLanguageSupported(code: string): boolean {\n return tokenizers.has(code);\n}\n\n// =============================================================================\n// Tokenization\n// =============================================================================\n\n/**\n * Tokenize input in the specified language.\n * @throws Error if language is not registered\n */\nexport function tokenize(input: string, language: string): TokenStream {\n const tokenizer = getTokenizer(language);\n return tokenizer.tokenize(input);\n}\n\n// =============================================================================\n// Pattern Access (Lazy Generation)\n// =============================================================================\n\n/**\n * Get patterns for a specific language.\n * First checks for directly registered patterns (for tree-shaking),\n * then falls back to pattern generator.\n * @throws Error if language is not registered\n */\nexport function getPatternsForLanguage(code: string): LanguagePattern[] {\n // Check cache first\n const cached = patternCache.get(code);\n if (cached) {\n return cached;\n }\n\n // Check for directly registered patterns (tree-shakeable path)\n const registered = registeredPatterns.get(code);\n if (registered) {\n patternCache.set(code, registered);\n return registered;\n }\n\n // Fall back to pattern generator\n if (!patternGenerator) {\n throw new Error(\n `No patterns registered for language '${code}'. ` +\n 'Either import the language module or set a pattern generator.'\n );\n }\n\n // Get profile (throws if not registered)\n const profile = getProfile(code);\n const patterns = patternGenerator(profile);\n patternCache.set(code, patterns);\n return patterns;\n}\n\n/**\n * Get patterns for a specific language and command.\n */\nexport function getPatternsForLanguageAndCommand(\n language: string,\n command: string\n): LanguagePattern[] {\n return getPatternsForLanguage(language)\n .filter(p => p.command === command)\n .sort((a, b) => b.priority - a.priority);\n}\n\n/**\n * Clear the pattern cache for a language (useful for testing).\n */\nexport function clearPatternCache(code?: string): void {\n if (code) {\n patternCache.delete(code);\n } else {\n patternCache.clear();\n }\n}\n\n// =============================================================================\n// Backwards Compatibility\n// =============================================================================\n\n/**\n * Get all profiles as a record (for backwards compatibility).\n * Note: Only returns registered profiles.\n */\nexport function getAllProfiles(): Record<string, LanguageProfile> {\n const result: Record<string, LanguageProfile> = {};\n for (const [code, profile] of profiles) {\n result[code] = profile;\n }\n return result;\n}\n\n/**\n * Get all tokenizers as a record (for backwards compatibility).\n * Note: Only returns registered tokenizers.\n */\nexport function getAllTokenizers(): Record<string, LanguageTokenizer> {\n const result: Record<string, LanguageTokenizer> = {};\n for (const [code, tokenizer] of tokenizers) {\n result[code] = tokenizer;\n }\n return result;\n}\n","/**\n * Base Tokenizer\n *\n * Provides the TokenStream implementation and shared tokenization utilities.\n * Language-specific tokenizers extend these base utilities.\n */\n\nimport type {\n LanguageToken,\n TokenKind,\n TokenStream,\n StreamMark,\n SourcePosition,\n LanguageTokenizer,\n} from '../types';\nimport type { MorphologicalNormalizer, NormalizationResult } from './morphology/types';\n\n// =============================================================================\n// Time Unit Configuration\n// =============================================================================\n\n/**\n * Configuration for a native language time unit pattern.\n * Used by tryNumberWithTimeUnits() to match language-specific time units.\n */\nexport interface TimeUnitMapping {\n /** The pattern to match (e.g., 'segundos', 'ミリ秒') */\n readonly pattern: string;\n /** The standard suffix to use (ms, s, m, h) */\n readonly suffix: string;\n /** Length of the pattern (for optimization) */\n readonly length: number;\n /** Whether to check for word boundary after the pattern */\n readonly checkBoundary?: boolean;\n /** Character that cannot follow the pattern (e.g., 's' for 'm' to avoid 'ms') */\n readonly notFollowedBy?: string;\n /** Whether to do case-insensitive matching */\n readonly caseInsensitive?: boolean;\n}\n\n// =============================================================================\n// Token Stream Implementation\n// =============================================================================\n\n/**\n * Concrete implementation of TokenStream.\n */\nexport class TokenStreamImpl implements TokenStream {\n readonly tokens: readonly LanguageToken[];\n readonly language: string;\n private pos: number = 0;\n\n constructor(tokens: LanguageToken[], language: string) {\n this.tokens = tokens;\n this.language = language;\n }\n\n peek(offset: number = 0): LanguageToken | null {\n const index = this.pos + offset;\n if (index < 0 || index >= this.tokens.length) {\n return null;\n }\n return this.tokens[index];\n }\n\n advance(): LanguageToken {\n if (this.isAtEnd()) {\n throw new Error('Unexpected end of token stream');\n }\n return this.tokens[this.pos++];\n }\n\n isAtEnd(): boolean {\n return this.pos >= this.tokens.length;\n }\n\n mark(): StreamMark {\n return { position: this.pos };\n }\n\n reset(mark: StreamMark): void {\n this.pos = mark.position;\n }\n\n position(): number {\n return this.pos;\n }\n\n /**\n * Get remaining tokens as an array.\n */\n remaining(): LanguageToken[] {\n return this.tokens.slice(this.pos);\n }\n\n /**\n * Consume tokens while predicate is true.\n */\n takeWhile(predicate: (token: LanguageToken) => boolean): LanguageToken[] {\n const result: LanguageToken[] = [];\n while (!this.isAtEnd() && predicate(this.peek()!)) {\n result.push(this.advance());\n }\n return result;\n }\n\n /**\n * Skip tokens while predicate is true.\n */\n skipWhile(predicate: (token: LanguageToken) => boolean): void {\n while (!this.isAtEnd() && predicate(this.peek()!)) {\n this.advance();\n }\n }\n}\n\n// =============================================================================\n// Shared Tokenization Utilities\n// =============================================================================\n\n/**\n * Create a source position from start and end offsets.\n */\nexport function createPosition(start: number, end: number): SourcePosition {\n return { start, end };\n}\n\n/**\n * Options for creating a token with optional morphological data.\n */\nexport interface CreateTokenOptions {\n /** Explicitly normalized form from keyword map */\n normalized?: string;\n /** Morphologically normalized stem */\n stem?: string;\n /** Confidence in the stem (0.0-1.0) */\n stemConfidence?: number;\n}\n\n/**\n * Create a language token.\n */\nexport function createToken(\n value: string,\n kind: TokenKind,\n position: SourcePosition,\n normalizedOrOptions?: string | CreateTokenOptions\n): LanguageToken {\n // Handle legacy string argument for backward compatibility\n if (typeof normalizedOrOptions === 'string') {\n return { value, kind, position, normalized: normalizedOrOptions };\n }\n\n // Handle options object\n if (normalizedOrOptions) {\n const { normalized, stem, stemConfidence } = normalizedOrOptions;\n const token: LanguageToken = { value, kind, position };\n\n // Build token with only defined properties\n if (normalized !== undefined) {\n (token as any).normalized = normalized;\n }\n if (stem !== undefined) {\n (token as any).stem = stem;\n if (stemConfidence !== undefined) {\n (token as any).stemConfidence = stemConfidence;\n }\n }\n\n return token;\n }\n\n return { value, kind, position };\n}\n\n/**\n * Check if a character is whitespace.\n */\nexport function isWhitespace(char: string): boolean {\n return /\\s/.test(char);\n}\n\n/**\n * Check if a string starts with a CSS selector prefix.\n * Includes JSX-style element selectors: <form />, <div>\n */\nexport function isSelectorStart(char: string): boolean {\n return (\n char === '#' || char === '.' || char === '[' || char === '@' || char === '*' || char === '<'\n );\n}\n\n/**\n * Check if a character is a quote (string delimiter).\n */\nexport function isQuote(char: string): boolean {\n return char === '\"' || char === \"'\" || char === '`' || char === '「' || char === '」';\n}\n\n/**\n * Check if a character is a digit.\n */\nexport function isDigit(char: string): boolean {\n return /\\d/.test(char);\n}\n\n/**\n * Check if a character is an ASCII letter.\n */\nexport function isAsciiLetter(char: string): boolean {\n return /[a-zA-Z]/.test(char);\n}\n\n/**\n * Check if a character is part of an ASCII identifier.\n */\nexport function isAsciiIdentifierChar(char: string): boolean {\n return /[a-zA-Z0-9_-]/.test(char);\n}\n\n// =============================================================================\n// Unicode Range Classification\n// =============================================================================\n\n/**\n * Unicode range tuple: [start, end] (inclusive).\n */\nexport type UnicodeRange = readonly [number, number];\n\n/**\n * Create a character classifier for Unicode ranges.\n * Returns a function that checks if a character's code point falls within any of the ranges.\n *\n * @example\n * // Japanese Hiragana\n * const isHiragana = createUnicodeRangeClassifier([[0x3040, 0x309f]]);\n *\n * // Korean (Hangul syllables + Jamo)\n * const isKorean = createUnicodeRangeClassifier([\n * [0xac00, 0xd7a3], // Hangul syllables\n * [0x1100, 0x11ff], // Hangul Jamo\n * [0x3130, 0x318f], // Hangul Compatibility Jamo\n * ]);\n */\nexport function createUnicodeRangeClassifier(\n ranges: readonly UnicodeRange[]\n): (char: string) => boolean {\n return (char: string): boolean => {\n const code = char.charCodeAt(0);\n return ranges.some(([start, end]) => code >= start && code <= end);\n };\n}\n\n/**\n * Combine multiple character classifiers into one.\n * Returns true if any of the classifiers return true.\n *\n * @example\n * const isJapanese = combineClassifiers(isHiragana, isKatakana, isKanji);\n */\nexport function combineClassifiers(\n ...classifiers: Array<(char: string) => boolean>\n): (char: string) => boolean {\n return (char: string): boolean => classifiers.some(fn => fn(char));\n}\n\n/**\n * Character classifiers for a Latin-based language.\n */\nexport interface LatinCharClassifiers {\n /** Check if character is a letter in this language (including accented chars). */\n isLetter: (char: string) => boolean;\n /** Check if character is part of an identifier (letter, digit, underscore, hyphen). */\n isIdentifierChar: (char: string) => boolean;\n}\n\n/**\n * Create character classifiers for a Latin-based language.\n * Returns isLetter and isIdentifierChar functions based on the provided regex.\n *\n * @example\n * // Spanish letters\n * const { isLetter, isIdentifierChar } = createLatinCharClassifiers(/[a-zA-ZáéíóúüñÁÉÍÓÚÜÑ]/);\n *\n * // German letters\n * const { isLetter, isIdentifierChar } = createLatinCharClassifiers(/[a-zA-ZäöüÄÖÜß]/);\n */\nexport function createLatinCharClassifiers(letterPattern: RegExp): LatinCharClassifiers {\n const isLetter = (char: string): boolean => letterPattern.test(char);\n const isIdentifierChar = (char: string): boolean => isLetter(char) || /[0-9_-]/.test(char);\n return { isLetter, isIdentifierChar };\n}\n\n// =============================================================================\n// CSS Selector Tokenization\n// =============================================================================\n\n/**\n * Extract a CSS selector from the input string starting at pos.\n * CSS selectors are universal across languages.\n *\n * Supported formats:\n * - #id\n * - .class\n * - [attribute]\n * - [attribute=value]\n * - @attribute (shorthand)\n * - *property (CSS property shorthand)\n * - Complex selectors with combinators (limited)\n *\n * Method call handling:\n * - #dialog.showModal() → stops after #dialog (method call, not compound selector)\n * - #box.active → compound selector (no parens)\n */\nexport function extractCssSelector(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const char = input[startPos];\n if (!isSelectorStart(char)) return null;\n\n let pos = startPos;\n let selector = '';\n\n // Handle different selector types\n if (char === '#' || char === '.') {\n // ID or class selector: #id, .class\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n // Must have at least one character after prefix\n if (selector.length <= 1) return null;\n\n // Check for method call pattern: #id.method() or .class.method()\n // If we see .identifier followed by (, don't consume it - it's a method call\n if (pos < input.length && input[pos] === '.' && char === '#') {\n // Look ahead to see if this is a method call\n const methodStart = pos + 1;\n let methodEnd = methodStart;\n while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {\n methodEnd++;\n }\n // If followed by (, it's a method call - stop here\n if (methodEnd < input.length && input[methodEnd] === '(') {\n return selector;\n }\n }\n } else if (char === '[') {\n // Attribute selector: [attr] or [attr=value] or [attr=\"value\"]\n // Need to track quote state to avoid counting brackets inside quotes\n let depth = 1;\n let inQuote = false;\n let quoteChar: string | null = null;\n let escaped = false;\n\n selector += input[pos++]; // [\n\n while (pos < input.length && depth > 0) {\n const c = input[pos];\n selector += c;\n\n if (escaped) {\n // Skip escaped character\n escaped = false;\n } else if (c === '\\\\') {\n // Next character is escaped\n escaped = true;\n } else if (inQuote) {\n // Inside a quoted string\n if (c === quoteChar) {\n inQuote = false;\n quoteChar = null;\n }\n } else {\n // Not inside a quoted string\n if (c === '\"' || c === \"'\" || c === '`') {\n inQuote = true;\n quoteChar = c;\n } else if (c === '[') {\n depth++;\n } else if (c === ']') {\n depth--;\n }\n }\n pos++;\n }\n if (depth !== 0) return null;\n } else if (char === '@') {\n // Attribute shorthand: @disabled\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n if (selector.length <= 1) return null;\n } else if (char === '*') {\n // CSS property shorthand: *display\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n if (selector.length <= 1) return null;\n } else if (char === '<') {\n // HTML literal selector with optional modifiers and attributes:\n // - <div>\n // - <div.class>\n // - <div#id>\n // - <div.class#id>\n // - <button[disabled]/>\n // - <div.card/>\n // - <div.class#id[attr=\"value\"]/>\n selector += input[pos++]; // <\n\n // Must be followed by an identifier (tag name)\n if (pos >= input.length || !isAsciiLetter(input[pos])) return null;\n\n // Extract tag name\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n\n // Process modifiers and attributes\n // Can have multiple .class, one #id, and multiple [attr] in any order\n while (pos < input.length) {\n const modChar = input[pos];\n\n if (modChar === '.') {\n // Class modifier\n selector += input[pos++]; // .\n if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {\n return null; // Invalid - class name required after .\n }\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n } else if (modChar === '#') {\n // ID modifier\n selector += input[pos++]; // #\n if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {\n return null; // Invalid - ID required after #\n }\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n } else if (modChar === '[') {\n // Attribute modifier: [disabled] or [type=\"button\"]\n // Need to track quote state to avoid counting brackets inside quotes\n let depth = 1;\n let inQuote = false;\n let quoteChar: string | null = null;\n let escaped = false;\n\n selector += input[pos++]; // [\n\n while (pos < input.length && depth > 0) {\n const c = input[pos];\n selector += c;\n\n if (escaped) {\n escaped = false;\n } else if (c === '\\\\') {\n escaped = true;\n } else if (inQuote) {\n if (c === quoteChar) {\n inQuote = false;\n quoteChar = null;\n }\n } else {\n if (c === '\"' || c === \"'\" || c === '`') {\n inQuote = true;\n quoteChar = c;\n } else if (c === '[') {\n depth++;\n } else if (c === ']') {\n depth--;\n }\n }\n pos++;\n }\n if (depth !== 0) return null; // Unclosed bracket\n } else {\n // No more modifiers\n break;\n }\n }\n\n // Skip whitespace before optional self-closing /\n while (pos < input.length && isWhitespace(input[pos])) {\n selector += input[pos++];\n }\n\n // Optional self-closing /\n if (pos < input.length && input[pos] === '/') {\n selector += input[pos++];\n // Skip whitespace after /\n while (pos < input.length && isWhitespace(input[pos])) {\n selector += input[pos++];\n }\n }\n\n // Must end with >\n if (pos >= input.length || input[pos] !== '>') return null;\n selector += input[pos++]; // >\n }\n\n return selector || null;\n}\n\n// =============================================================================\n// String Literal Tokenization\n// =============================================================================\n\n/**\n * Check if a single quote at pos is a possessive marker ('s).\n * Returns true if this looks like possessive, not a string start.\n *\n * Examples:\n * - #element's *opacity → possessive (returns true)\n * - 'hello' → string (returns false)\n * - it's value → possessive (returns true)\n */\nexport function isPossessiveMarker(input: string, pos: number): boolean {\n if (pos >= input.length || input[pos] !== \"'\") return false;\n\n // Check if followed by 's' or 'S'\n if (pos + 1 >= input.length) return false;\n const nextChar = input[pos + 1].toLowerCase();\n if (nextChar !== 's') return false;\n\n // After 's, should be end, whitespace, or special char (not alphanumeric)\n if (pos + 2 >= input.length) return true; // end of input\n const afterS = input[pos + 2];\n return isWhitespace(afterS) || afterS === '*' || !isAsciiIdentifierChar(afterS);\n}\n\n/**\n * Extract a string literal from the input starting at pos.\n * Handles both ASCII quotes and Unicode quotes.\n *\n * Note: Single quotes that look like possessive markers ('s) are skipped.\n */\nexport function extractStringLiteral(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const openQuote = input[startPos];\n if (!isQuote(openQuote)) return null;\n\n // Check for possessive marker - don't treat as string\n if (openQuote === \"'\" && isPossessiveMarker(input, startPos)) {\n return null;\n }\n\n // Map opening quotes to closing quotes\n const closeQuoteMap: Record<string, string> = {\n '\"': '\"',\n \"'\": \"'\",\n '`': '`',\n '「': '」',\n };\n\n const closeQuote = closeQuoteMap[openQuote];\n if (!closeQuote) return null;\n\n let pos = startPos + 1;\n let literal = openQuote;\n let escaped = false;\n\n while (pos < input.length) {\n const char = input[pos];\n literal += char;\n\n if (escaped) {\n escaped = false;\n } else if (char === '\\\\') {\n escaped = true;\n } else if (char === closeQuote) {\n // Found closing quote\n return literal;\n }\n pos++;\n }\n\n // Unclosed string - return what we have\n return literal;\n}\n\n// =============================================================================\n// URL Tokenization\n// =============================================================================\n\n/**\n * Check if the input at position starts a URL.\n * Detects: /path, ./path, ../path, //domain.com, http://, https://\n */\nexport function isUrlStart(input: string, pos: number): boolean {\n if (pos >= input.length) return false;\n\n const char = input[pos];\n const next = input[pos + 1] || '';\n const third = input[pos + 2] || '';\n\n // Absolute path: /something (but not just /)\n // Must be followed by alphanumeric or path char, not another / (that's protocol-relative)\n if (char === '/' && next !== '/' && /[a-zA-Z0-9._-]/.test(next)) {\n return true;\n }\n\n // Protocol-relative: //domain.com\n if (char === '/' && next === '/' && /[a-zA-Z]/.test(third)) {\n return true;\n }\n\n // Relative path: ./ or ../\n if (char === '.' && (next === '/' || (next === '.' && third === '/'))) {\n return true;\n }\n\n // Full URL: http:// or https://\n const slice = input.slice(pos, pos + 8).toLowerCase();\n if (slice.startsWith('http://') || slice.startsWith('https://')) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Extract a URL from the input starting at pos.\n * Handles paths, query strings, and fragments.\n *\n * Fragment (#) handling:\n * - /page#section → includes fragment as part of URL\n * - #id alone → not a URL (CSS selector)\n */\nexport function extractUrl(input: string, startPos: number): string | null {\n if (!isUrlStart(input, startPos)) return null;\n\n let pos = startPos;\n let url = '';\n\n // Core URL characters (RFC 3986 unreserved + sub-delims + path/query chars)\n // Includes: letters, digits, and - . _ ~ : / ? # [ ] @ ! $ & ' ( ) * + , ; = %\n const urlChars = /[a-zA-Z0-9/:._\\-?&=%@+~!$'()*,;[\\]]/;\n\n while (pos < input.length) {\n const char = input[pos];\n\n // Special handling for #\n if (char === '#') {\n // Only include # if we have path content before it (it's a fragment)\n // If # appears at URL start or after certain chars, stop (might be CSS selector)\n if (url.length > 0 && /[a-zA-Z0-9/.]$/.test(url)) {\n // Include fragment\n url += char;\n pos++;\n // Consume fragment identifier (letters, digits, underscore, hyphen)\n while (pos < input.length && /[a-zA-Z0-9_-]/.test(input[pos])) {\n url += input[pos++];\n }\n }\n // Stop either way - fragment consumed or # is separate token\n break;\n }\n\n if (urlChars.test(char)) {\n url += char;\n pos++;\n } else {\n break;\n }\n }\n\n // Minimum length validation\n if (url.length < 2) return null;\n\n return url;\n}\n\n// =============================================================================\n// Number Tokenization\n// =============================================================================\n\n/**\n * Extract a number from the input starting at pos.\n * Handles integers and decimals.\n */\nexport function extractNumber(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const char = input[startPos];\n if (!isDigit(char) && char !== '-' && char !== '+') return null;\n\n let pos = startPos;\n let number = '';\n\n // Optional sign\n if (input[pos] === '-' || input[pos] === '+') {\n number += input[pos++];\n }\n\n // Must have at least one digit\n if (pos >= input.length || !isDigit(input[pos])) {\n return null;\n }\n\n // Integer part\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n\n // Optional decimal part\n if (pos < input.length && input[pos] === '.') {\n number += input[pos++];\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n }\n\n // Optional duration suffix (s, ms, m, h)\n if (pos < input.length) {\n const suffix = input.slice(pos, pos + 2);\n if (suffix === 'ms') {\n number += 'ms';\n } else if (input[pos] === 's' || input[pos] === 'm' || input[pos] === 'h') {\n number += input[pos];\n }\n }\n\n return number;\n}\n\n// =============================================================================\n// Base Tokenizer Class\n// =============================================================================\n\n/**\n * Keyword entry for tokenizer - maps native word to normalized English form.\n */\nexport interface KeywordEntry {\n readonly native: string;\n readonly normalized: string;\n}\n\n/**\n * Profile interface for keyword derivation.\n * Matches the structure of LanguageProfile but only includes fields needed for tokenization.\n */\nexport interface TokenizerProfile {\n readonly keywords?: Record<\n string,\n { primary: string; alternatives?: string[]; normalized?: string }\n >;\n readonly references?: Record<string, string>;\n readonly roleMarkers?: Record<\n string,\n { primary: string; alternatives?: string[]; position?: string }\n >;\n}\n\n/**\n * Abstract base class for language-specific tokenizers.\n * Provides common functionality for CSS selectors, strings, and numbers.\n */\nexport abstract class BaseTokenizer implements LanguageTokenizer {\n abstract readonly language: string;\n abstract readonly direction: 'ltr' | 'rtl';\n\n /** Optional morphological normalizer for this language */\n protected normalizer?: MorphologicalNormalizer;\n\n /** Keywords derived from profile, sorted longest-first for greedy matching */\n protected profileKeywords: KeywordEntry[] = [];\n\n /** Map for O(1) keyword lookups by lowercase native word */\n protected profileKeywordMap: Map<string, KeywordEntry> = new Map();\n\n abstract tokenize(input: string): TokenStream;\n abstract classifyToken(token: string): TokenKind;\n\n /**\n * Initialize keyword mappings from a language profile.\n * Builds a list of native→english mappings from:\n * - profile.keywords (primary + alternatives)\n * - profile.references (me, it, you, etc.)\n * - profile.roleMarkers (into, from, with, etc.)\n *\n * Results are sorted longest-first for greedy matching (important for non-space languages).\n * Extras take precedence over profile entries when there are duplicates.\n *\n * @param profile - Language profile containing keyword translations\n * @param extras - Additional keyword entries to include (literals, positional, events)\n */\n protected initializeKeywordsFromProfile(\n profile: TokenizerProfile,\n extras: KeywordEntry[] = []\n ): void {\n // Use a Map to deduplicate, with extras taking precedence\n const keywordMap = new Map<string, KeywordEntry>();\n\n // Extract from keywords (command translations)\n if (profile.keywords) {\n for (const [normalized, translation] of Object.entries(profile.keywords)) {\n // Primary translation\n keywordMap.set(translation.primary, {\n native: translation.primary,\n normalized: translation.normalized || normalized,\n });\n\n // Alternative forms\n if (translation.alternatives) {\n for (const alt of translation.alternatives) {\n keywordMap.set(alt, {\n native: alt,\n normalized: translation.normalized || normalized,\n });\n }\n }\n }\n }\n\n // Extract from references (me, it, you, etc.)\n if (profile.references) {\n for (const [normalized, native] of Object.entries(profile.references)) {\n keywordMap.set(native, { native, normalized });\n }\n }\n\n // Extract from roleMarkers (into, from, with, etc.)\n if (profile.roleMarkers) {\n for (const [role, marker] of Object.entries(profile.roleMarkers)) {\n if (marker.primary) {\n keywordMap.set(marker.primary, { native: marker.primary, normalized: role });\n }\n if (marker.alternatives) {\n for (const alt of marker.alternatives) {\n keywordMap.set(alt, { native: alt, normalized: role });\n }\n }\n }\n }\n\n // Add extra entries (literals, positional, events) - these OVERRIDE profile entries\n for (const extra of extras) {\n keywordMap.set(extra.native, extra);\n }\n\n // Convert to array and sort longest-first for greedy matching\n this.profileKeywords = Array.from(keywordMap.values()).sort(\n (a, b) => b.native.length - a.native.length\n );\n\n // Build Map for O(1) lookups (case-insensitive + diacritic-insensitive)\n // This allows matching both 'بدّل' (with shadda) and 'بدل' (without) to the same entry\n this.profileKeywordMap = new Map();\n for (const keyword of this.profileKeywords) {\n // Add original form (with diacritics if present)\n this.profileKeywordMap.set(keyword.native.toLowerCase(), keyword);\n\n // Add diacritic-normalized form (for Arabic, Turkish, etc.)\n const normalized = this.removeDiacritics(keyword.native);\n if (normalized !== keyword.native && !this.profileKeywordMap.has(normalized.toLowerCase())) {\n this.profileKeywordMap.set(normalized.toLowerCase(), keyword);\n }\n }\n }\n\n /**\n * Remove diacritical marks from a word for normalization.\n * Primarily for Arabic (shadda, fatha, kasra, damma, sukun, etc.)\n * but could be extended for other languages.\n *\n * @param word - Word to normalize\n * @returns Word without diacritics\n */\n protected removeDiacritics(word: string): string {\n // Arabic diacritics: U+064B-U+0652 (fatha, kasra, damma, sukun, shadda, etc.)\n // U+0670 (superscript alif)\n return word.replace(/[\\u064B-\\u0652\\u0670]/g, '');\n }\n\n /**\n * Try to match a keyword from profile at the current position.\n * Uses longest-first greedy matching (important for non-space languages).\n *\n * @param input - Input string\n * @param pos - Current position\n * @returns Token if matched, null otherwise\n */\n protected tryProfileKeyword(input: string, pos: number): LanguageToken | null {\n for (const entry of this.profileKeywords) {\n if (input.slice(pos).startsWith(entry.native)) {\n return createToken(\n entry.native,\n 'keyword',\n createPosition(pos, pos + entry.native.length),\n entry.normalized\n );\n }\n }\n return null;\n }\n\n /**\n * Check if the remaining input starts with any known keyword.\n * Useful for non-space languages to detect word boundaries.\n *\n * @param input - Input string\n * @param pos - Current position\n * @returns true if a keyword starts at this position\n */\n protected isKeywordStart(input: string, pos: number): boolean {\n const remaining = input.slice(pos);\n return this.profileKeywords.some(entry => remaining.startsWith(entry.native));\n }\n\n /**\n * Look up a keyword by native word (case-insensitive).\n * O(1) lookup using the keyword map.\n *\n * @param native - Native word to look up\n * @returns KeywordEntry if found, undefined otherwise\n */\n protected lookupKeyword(native: string): KeywordEntry | undefined {\n return this.profileKeywordMap.get(native.toLowerCase());\n }\n\n /**\n * Check if a word is a known keyword (case-insensitive).\n * O(1) lookup using the keyword map.\n *\n * @param native - Native word to check\n * @returns true if the word is a keyword\n */\n protected isKeyword(native: string): boolean {\n return this.profileKeywordMap.has(native.toLowerCase());\n }\n\n /**\n * Set the morphological normalizer for this tokenizer.\n */\n setNormalizer(normalizer: MorphologicalNormalizer): void {\n this.normalizer = normalizer;\n }\n\n /**\n * Try to normalize a word using the morphological normalizer.\n * Returns null if no normalizer is set or normalization fails.\n *\n * Note: We don't check isNormalizable() here because the individual tokenizers\n * historically called normalize() directly without that check. The normalize()\n * method itself handles returning noChange() for words that can't be normalized.\n */\n protected tryNormalize(word: string): NormalizationResult | null {\n if (!this.normalizer) return null;\n\n const result = this.normalizer.normalize(word);\n\n // Only return if actually normalized (stem differs from input)\n if (result.stem !== word && result.confidence >= 0.7) {\n return result;\n }\n\n return null;\n }\n\n /**\n * Try morphological normalization and keyword lookup.\n *\n * If the word can be normalized to a stem that matches a known keyword,\n * returns a keyword token with morphological metadata (stem, stemConfidence).\n *\n * This is the common pattern for handling conjugated verbs across languages:\n * 1. Normalize the word (e.g., \"toggled\" → \"toggle\")\n * 2. Look up the stem in the keyword map\n * 3. Create a token with both the original form and stem metadata\n *\n * @param word - The word to normalize and look up\n * @param startPos - Start position for the token\n * @param endPos - End position for the token\n * @returns Token if stem matches a keyword, null otherwise\n */\n protected tryMorphKeywordMatch(\n word: string,\n startPos: number,\n endPos: number\n ): LanguageToken | null {\n const result = this.tryNormalize(word);\n if (!result) return null;\n\n // Check if the stem is a known keyword\n const stemEntry = this.lookupKeyword(result.stem);\n if (!stemEntry) return null;\n\n const tokenOptions: CreateTokenOptions = {\n normalized: stemEntry.normalized,\n stem: result.stem,\n stemConfidence: result.confidence,\n };\n return createToken(word, 'keyword', createPosition(startPos, endPos), tokenOptions);\n }\n\n /**\n * Try to extract a CSS selector at the current position.\n */\n protected trySelector(input: string, pos: number): LanguageToken | null {\n const selector = extractCssSelector(input, pos);\n if (selector) {\n return createToken(selector, 'selector', createPosition(pos, pos + selector.length));\n }\n return null;\n }\n\n /**\n * Try to extract an event modifier at the current position.\n * Event modifiers are .once, .debounce(N), .throttle(N), .queue(strategy)\n */\n protected tryEventModifier(input: string, pos: number): LanguageToken | null {\n // Must start with a dot\n if (input[pos] !== '.') {\n return null;\n }\n\n // Match pattern: .(once|debounce|throttle|queue) followed by optional (value)\n const match = input\n .slice(pos)\n .match(/^\\.(?:once|debounce|throttle|queue)(?:\\(([^)]+)\\))?(?:\\s|$|\\.)/);\n if (!match) {\n return null;\n }\n\n const fullMatch = match[0].replace(/(\\s|\\.)$/, ''); // Remove trailing space or dot\n const modifierName = fullMatch.slice(1).split('(')[0]; // Extract modifier name\n const value = match[1]; // Extract value from parentheses if present\n\n // Create token with metadata\n const token = createToken(\n fullMatch,\n 'event-modifier',\n createPosition(pos, pos + fullMatch.length)\n );\n\n // Add metadata for the modifier\n return {\n ...token,\n metadata: {\n modifierName,\n value: value ? (modifierName === 'queue' ? value : parseInt(value, 10)) : undefined,\n },\n };\n }\n\n /**\n * Try to extract a string literal at the current position.\n */\n protected tryString(input: string, pos: number): LanguageToken | null {\n const literal = extractStringLiteral(input, pos);\n if (literal) {\n return createToken(literal, 'literal', createPosition(pos, pos + literal.length));\n }\n return null;\n }\n\n /**\n * Try to extract a number at the current position.\n */\n protected tryNumber(input: string, pos: number): LanguageToken | null {\n const number = extractNumber(input, pos);\n if (number) {\n return createToken(number, 'literal', createPosition(pos, pos + number.length));\n }\n return null;\n }\n\n /**\n * Configuration for native language time units.\n * Maps patterns to their standard suffix (ms, s, m, h).\n */\n protected static readonly STANDARD_TIME_UNITS: readonly TimeUnitMapping[] = [\n { pattern: 'ms', suffix: 'ms', length: 2 },\n { pattern: 's', suffix: 's', length: 1, checkBoundary: true },\n { pattern: 'm', suffix: 'm', length: 1, checkBoundary: true, notFollowedBy: 's' },\n { pattern: 'h', suffix: 'h', length: 1, checkBoundary: true },\n ];\n\n /**\n * Try to match a time unit from a list of patterns.\n *\n * @param input - Input string\n * @param pos - Position after the number\n * @param timeUnits - Array of time unit mappings (native pattern → standard suffix)\n * @param skipWhitespace - Whether to skip whitespace before time unit (default: false)\n * @returns Object with matched suffix and new position, or null if no match\n */\n protected tryMatchTimeUnit(\n input: string,\n pos: number,\n timeUnits: readonly TimeUnitMapping[],\n skipWhitespace = false\n ): { suffix: string; endPos: number } | null {\n let unitPos = pos;\n\n // Optionally skip whitespace before time unit\n if (skipWhitespace) {\n while (unitPos < input.length && isWhitespace(input[unitPos])) {\n unitPos++;\n }\n }\n\n const remaining = input.slice(unitPos);\n\n // Check each time unit pattern\n for (const unit of timeUnits) {\n const candidate = remaining.slice(0, unit.length);\n const matches = unit.caseInsensitive\n ? candidate.toLowerCase() === unit.pattern.toLowerCase()\n : candidate === unit.pattern;\n\n if (matches) {\n // Check notFollowedBy constraint (e.g., 'm' should not match 'ms')\n if (unit.notFollowedBy) {\n const nextChar = remaining[unit.length] || '';\n if (nextChar === unit.notFollowedBy) continue;\n }\n\n // Check word boundary if required\n if (unit.checkBoundary) {\n const nextChar = remaining[unit.length] || '';\n if (isAsciiIdentifierChar(nextChar)) continue;\n }\n\n return { suffix: unit.suffix, endPos: unitPos + unit.length };\n }\n }\n\n return null;\n }\n\n /**\n * Parse a base number (sign, integer, decimal) without time units.\n * Returns the number string and end position.\n *\n * @param input - Input string\n * @param startPos - Start position\n * @param allowSign - Whether to allow +/- sign (default: true)\n * @returns Object with number string and end position, or null\n */\n protected parseBaseNumber(\n input: string,\n startPos: number,\n allowSign = true\n ): { number: string; endPos: number } | null {\n let pos = startPos;\n let number = '';\n\n // Optional sign\n if (allowSign && (input[pos] === '-' || input[pos] === '+')) {\n number += input[pos++];\n }\n\n // Must have at least one digit\n if (pos >= input.length || !isDigit(input[pos])) {\n return null;\n }\n\n // Integer part\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n\n // Optional decimal\n if (pos < input.length && input[pos] === '.') {\n number += input[pos++];\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n }\n\n if (!number || number === '-' || number === '+') return null;\n\n return { number, endPos: pos };\n }\n\n /**\n * Try to extract a number with native language time units.\n *\n * This is a template method that handles the common pattern:\n * 1. Parse the base number (sign, integer, decimal)\n * 2. Try to match native language time units\n * 3. Fall back to standard time units (ms, s, m, h)\n *\n * @param input - Input string\n * @param pos - Start position\n * @param nativeTimeUnits - Language-specific time unit mappings\n * @param options - Configuration options\n * @returns Token if number found, null otherwise\n */\n protected tryNumberWithTimeUnits(\n input: string,\n pos: number,\n nativeTimeUnits: readonly TimeUnitMapping[],\n options: { allowSign?: boolean; skipWhitespace?: boolean } = {}\n ): LanguageToken | null {\n const { allowSign = true, skipWhitespace = false } = options;\n\n // Parse base number\n const baseResult = this.parseBaseNumber(input, pos, allowSign);\n if (!baseResult) return null;\n\n let { number, endPos } = baseResult;\n\n // Try native time units first, then standard\n const allUnits = [...nativeTimeUnits, ...BaseTokenizer.STANDARD_TIME_UNITS];\n const timeMatch = this.tryMatchTimeUnit(input, endPos, allUnits, skipWhitespace);\n\n if (timeMatch) {\n number += timeMatch.suffix;\n endPos = timeMatch.endPos;\n }\n\n return createToken(number, 'literal', createPosition(pos, endPos));\n }\n\n /**\n * Try to extract a URL at the current position.\n * Handles /path, ./path, ../path, //domain.com, http://, https://\n */\n protected tryUrl(input: string, pos: number): LanguageToken | null {\n const url = extractUrl(input, pos);\n if (url) {\n return createToken(url, 'url', createPosition(pos, pos + url.length));\n }\n return null;\n }\n\n /**\n * Try to extract a variable reference (:varname) at the current position.\n * In hyperscript, :x refers to a local variable named x.\n */\n protected tryVariableRef(input: string, pos: number): LanguageToken | null {\n if (input[pos] !== ':') return null;\n if (pos + 1 >= input.length) return null;\n if (!isAsciiIdentifierChar(input[pos + 1])) return null;\n\n let endPos = pos + 1;\n while (endPos < input.length && isAsciiIdentifierChar(input[endPos])) {\n endPos++;\n }\n\n const varRef = input.slice(pos, endPos);\n return createToken(varRef, 'identifier', createPosition(pos, endPos));\n }\n\n /**\n * Try to extract an operator or punctuation token at the current position.\n * Handles two-character operators (==, !=, etc.) and single-character operators.\n */\n protected tryOperator(input: string, pos: number): LanguageToken | null {\n // Two-character operators\n const twoChar = input.slice(pos, pos + 2);\n if (['==', '!=', '<=', '>=', '&&', '||', '->'].includes(twoChar)) {\n return createToken(twoChar, 'operator', createPosition(pos, pos + 2));\n }\n\n // Single-character operators\n const oneChar = input[pos];\n if (['<', '>', '!', '+', '-', '*', '/', '='].includes(oneChar)) {\n return createToken(oneChar, 'operator', createPosition(pos, pos + 1));\n }\n\n // Punctuation\n if (['(', ')', '{', '}', ',', ';', ':'].includes(oneChar)) {\n return createToken(oneChar, 'punctuation', createPosition(pos, pos + 1));\n }\n\n return null;\n }\n\n /**\n * Try to match a multi-character particle from a list.\n *\n * Used by languages like Japanese, Korean, and Chinese that have\n * multi-character particles (e.g., Japanese から, まで, より).\n *\n * @param input - Input string\n * @param pos - Current position\n * @param particles - Array of multi-character particles to match\n * @returns Token if matched, null otherwise\n */\n protected tryMultiCharParticle(\n input: string,\n pos: number,\n particles: readonly string[]\n ): LanguageToken | null {\n for (const particle of particles) {\n if (input.slice(pos, pos + particle.length) === particle) {\n return createToken(particle, 'particle', createPosition(pos, pos + particle.length));\n }\n }\n return null;\n }\n}\n","/**\n * English Language Profile\n *\n * SVO word order, prepositions, space-separated.\n */\n\nimport type { LanguageProfile } from './types';\n\nexport const englishProfile: LanguageProfile = {\n code: 'en',\n name: 'English',\n nativeName: 'English',\n direction: 'ltr',\n wordOrder: 'SVO',\n markingStrategy: 'preposition',\n usesSpaces: true,\n // English infinitive and imperative are identical (\"toggle\", \"save\", \"open\")\n defaultVerbForm: 'base',\n verb: {\n position: 'start',\n subjectDrop: false,\n },\n references: {\n me: 'me',\n it: 'it',\n you: 'you',\n result: 'result',\n event: 'event',\n target: 'target',\n body: 'body',\n },\n possessive: {\n marker: \"'s\",\n markerPosition: 'after-object',\n specialForms: {\n me: 'my',\n it: 'its',\n you: 'your',\n },\n keywords: {\n my: 'me',\n your: 'you',\n its: 'it',\n },\n },\n roleMarkers: {\n destination: { primary: 'on', alternatives: ['to', 'from'], position: 'before' },\n source: { primary: 'from', position: 'before' },\n patient: { primary: '', position: 'before' },\n style: { primary: 'with', alternatives: ['by', 'using'], position: 'before' },\n responseType: { primary: 'as', position: 'before' },\n method: { primary: 'via', alternatives: ['using'], position: 'before' },\n },\n keywords: {\n toggle: { primary: 'toggle' },\n add: { primary: 'add' },\n remove: { primary: 'remove' },\n put: { primary: 'put' },\n append: { primary: 'append' },\n prepend: { primary: 'prepend' },\n take: { primary: 'take' },\n make: { primary: 'make' },\n clone: { primary: 'clone' },\n swap: { primary: 'swap' },\n morph: { primary: 'morph' },\n set: { primary: 'set' },\n get: { primary: 'get' },\n increment: { primary: 'increment' },\n decrement: { primary: 'decrement' },\n log: { primary: 'log' },\n show: { primary: 'show' },\n hide: { primary: 'hide' },\n transition: { primary: 'transition' },\n on: { primary: 'on' },\n trigger: { primary: 'trigger' },\n send: { primary: 'send' },\n focus: { primary: 'focus' },\n blur: { primary: 'blur' },\n go: { primary: 'go' },\n wait: { primary: 'wait' },\n fetch: { primary: 'fetch' },\n settle: { primary: 'settle' },\n if: { primary: 'if' },\n when: { primary: 'when', normalized: 'when' },\n where: { primary: 'where', normalized: 'where' },\n else: { primary: 'else' },\n repeat: { primary: 'repeat' },\n for: { primary: 'for' },\n while: { primary: 'while' },\n continue: { primary: 'continue' },\n halt: { primary: 'halt' },\n throw: { primary: 'throw' },\n call: { primary: 'call' },\n return: { primary: 'return' },\n then: { primary: 'then' },\n and: { primary: 'and' },\n end: { primary: 'end' },\n js: { primary: 'js' },\n async: { primary: 'async' },\n tell: { primary: 'tell' },\n default: { primary: 'default' },\n init: { primary: 'init' },\n behavior: { primary: 'behavior' },\n install: { primary: 'install' },\n measure: { primary: 'measure' },\n into: { primary: 'into' },\n before: { primary: 'before' },\n after: { primary: 'after' },\n until: { primary: 'until' },\n event: { primary: 'event' },\n from: { primary: 'from' },\n },\n};\n","/**\n * English Tokenizer\n *\n * Tokenizes English hyperscript input.\n * English uses space-separated words with prepositions.\n */\n\nimport type { LanguageToken, TokenKind, TokenStream } from '../types';\nimport {\n BaseTokenizer,\n TokenStreamImpl,\n createToken,\n createPosition,\n isWhitespace,\n isAsciiIdentifierChar,\n isSelectorStart,\n isQuote,\n isDigit,\n isUrlStart,\n isPossessiveMarker,\n type KeywordEntry,\n} from './base';\nimport { englishProfile } from '../generators/profiles/english';\n\n// =============================================================================\n// English Extras (keywords not in profile)\n// =============================================================================\n\n/**\n * Extra keywords not covered by the profile:\n * - Literals (true, false, null, undefined)\n * - Event names\n * - Positional words\n * - Prepositions/modifiers\n * - Articles\n * - Synonyms with normalized forms\n * - Swap strategies\n * - British spelling aliases\n */\nconst ENGLISH_EXTRAS: KeywordEntry[] = [\n // Values/Literals\n { native: 'true', normalized: 'true' },\n { native: 'false', normalized: 'false' },\n { native: 'null', normalized: 'null' },\n { native: 'undefined', normalized: 'undefined' },\n\n // Positional\n { native: 'first', normalized: 'first' },\n { native: 'last', normalized: 'last' },\n { native: 'next', normalized: 'next' },\n { native: 'previous', normalized: 'previous' },\n { native: 'closest', normalized: 'closest' },\n\n // Events\n { native: 'click', normalized: 'click' },\n { native: 'dblclick', normalized: 'dblclick' },\n { native: 'mousedown', normalized: 'mousedown' },\n { native: 'mouseup', normalized: 'mouseup' },\n { native: 'mouseover', normalized: 'mouseover' },\n { native: 'mouseout', normalized: 'mouseout' },\n { native: 'mouseenter', normalized: 'mouseenter' },\n { native: 'mouseleave', normalized: 'mouseleave' },\n { native: 'mousemove', normalized: 'mousemove' },\n { native: 'keydown', normalized: 'keydown' },\n { native: 'keyup', normalized: 'keyup' },\n { native: 'keypress', normalized: 'keypress' },\n { native: 'input', normalized: 'input' },\n { native: 'change', normalized: 'change' },\n { native: 'submit', normalized: 'submit' },\n { native: 'reset', normalized: 'reset' },\n { native: 'load', normalized: 'load' },\n { native: 'unload', normalized: 'unload' },\n { native: 'scroll', normalized: 'scroll' },\n { native: 'resize', normalized: 'resize' },\n { native: 'dragstart', normalized: 'dragstart' },\n { native: 'drag', normalized: 'drag' },\n { native: 'dragend', normalized: 'dragend' },\n { native: 'dragenter', normalized: 'dragenter' },\n { native: 'dragleave', normalized: 'dragleave' },\n { native: 'dragover', normalized: 'dragover' },\n { native: 'drop', normalized: 'drop' },\n { native: 'touchstart', normalized: 'touchstart' },\n { native: 'touchmove', normalized: 'touchmove' },\n { native: 'touchend', normalized: 'touchend' },\n { native: 'touchcancel', normalized: 'touchcancel' },\n\n // Prepositions/modifiers not in profile\n { native: 'in', normalized: 'in' },\n { native: 'to', normalized: 'to' },\n { native: 'at', normalized: 'at' },\n { native: 'by', normalized: 'by' },\n { native: 'with', normalized: 'with' },\n { native: 'without', normalized: 'without' },\n { native: 'of', normalized: 'of' },\n { native: 'as', normalized: 'as' },\n\n // Event handling keywords\n { native: 'every', normalized: 'every' },\n { native: 'upon', normalized: 'upon' },\n\n // Control flow helpers not in profile\n { native: 'unless', normalized: 'unless' },\n { native: 'forever', normalized: 'forever' },\n { native: 'times', normalized: 'times' },\n\n // Logical\n { native: 'and', normalized: 'and' },\n { native: 'or', normalized: 'or' },\n { native: 'not', normalized: 'not' },\n { native: 'is', normalized: 'is' },\n { native: 'exists', normalized: 'exists' },\n { native: 'empty', normalized: 'empty' },\n\n // References not in profile\n { native: 'my', normalized: 'my' },\n { native: 'your', normalized: 'your' },\n { native: 'its', normalized: 'its' },\n { native: 'the', normalized: 'the' },\n { native: 'a', normalized: 'a' },\n { native: 'an', normalized: 'an' },\n\n // Swap strategies\n { native: 'delete', normalized: 'delete' },\n { native: 'innerHTML', normalized: 'innerHTML' },\n { native: 'outerHTML', normalized: 'outerHTML' },\n { native: 'beforebegin', normalized: 'beforebegin' },\n { native: 'afterend', normalized: 'afterend' },\n { native: 'beforeend', normalized: 'beforeend' },\n { native: 'afterbegin', normalized: 'afterbegin' },\n\n // Command synonyms with normalized forms\n { native: 'flip', normalized: 'toggle' },\n { native: 'switch', normalized: 'toggle' },\n { native: 'increase', normalized: 'increment' },\n { native: 'decrease', normalized: 'decrement' },\n { native: 'display', normalized: 'show' },\n { native: 'reveal', normalized: 'show' },\n { native: 'conceal', normalized: 'hide' },\n\n // British spelling aliases\n { native: 'colour', normalized: 'color' },\n { native: 'grey', normalized: 'gray' },\n { native: 'centre', normalized: 'center' },\n { native: 'behaviour', normalized: 'behavior' },\n { native: 'initialise', normalized: 'initialize' },\n { native: 'favourite', normalized: 'favorite' },\n];\n\n// =============================================================================\n// English Tokenizer Implementation\n// =============================================================================\n\nexport class EnglishTokenizer extends BaseTokenizer {\n readonly language = 'en';\n readonly direction = 'ltr' as const;\n\n constructor() {\n super();\n // Initialize keywords from profile + extras (single source of truth)\n this.initializeKeywordsFromProfile(englishProfile, ENGLISH_EXTRAS);\n }\n\n tokenize(input: string): TokenStream {\n const tokens: LanguageToken[] = [];\n let pos = 0;\n\n while (pos < input.length) {\n // Skip whitespace\n if (isWhitespace(input[pos])) {\n pos++;\n continue;\n }\n\n // Try CSS selector first (highest priority)\n // But check if this is a property access or method call first\n if (isSelectorStart(input[pos])) {\n // Check for event modifier first (.once, .debounce(), etc.)\n const modifierToken = this.tryEventModifier(input, pos);\n if (modifierToken) {\n tokens.push(modifierToken);\n pos = modifierToken.position.end;\n continue;\n }\n\n // Check for property access pattern: identifier.identifier or identifier.method()\n // When the previous token is an identifier or keyword AND there's no whitespace,\n // treat . as property accessor. With whitespace (e.g., \"add .active\"), it's a selector.\n if (input[pos] === '.') {\n const lastToken = tokens[tokens.length - 1];\n // Property access requires NO whitespace between tokens (e.g., \"obj.prop\")\n // CSS selectors have whitespace (e.g., \"add .active\")\n const hasWhitespaceBefore = lastToken && lastToken.position.end < pos;\n const isPropertyAccess =\n lastToken &&\n !hasWhitespaceBefore &&\n (lastToken.kind === 'identifier' ||\n lastToken.kind === 'keyword' ||\n lastToken.kind === 'selector');\n\n if (isPropertyAccess) {\n // Tokenize . as property accessor\n tokens.push(createToken('.', 'operator', createPosition(pos, pos + 1)));\n pos++;\n continue;\n }\n\n // Check for method call pattern at start: .identifier(\n const methodStart = pos + 1;\n let methodEnd = methodStart;\n while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {\n methodEnd++;\n }\n // If followed by (, this is a method call, not a class selector\n if (methodEnd < input.length && input[methodEnd] === '(') {\n // Tokenize . as property accessor\n tokens.push(createToken('.', 'operator', createPosition(pos, pos + 1)));\n pos++;\n continue;\n }\n }\n\n const selectorToken = this.trySelector(input, pos);\n if (selectorToken) {\n tokens.push(selectorToken);\n pos = selectorToken.position.end;\n continue;\n }\n }\n\n // Try string literal (but not possessive markers)\n if (isQuote(input[pos])) {\n // Check for possessive 's marker first\n if (input[pos] === \"'\" && isPossessiveMarker(input, pos)) {\n // Tokenize 's as a possessive marker\n tokens.push(createToken(\"'s\", 'punctuation', createPosition(pos, pos + 2)));\n pos += 2;\n continue;\n }\n const stringToken = this.tryString(input, pos);\n if (stringToken) {\n tokens.push(stringToken);\n pos = stringToken.position.end;\n continue;\n }\n }\n\n // Try URL (/path, ./path, http://, etc.)\n if (isUrlStart(input, pos)) {\n const urlToken = this.tryUrl(input, pos);\n if (urlToken) {\n tokens.push(urlToken);\n pos = urlToken.position.end;\n continue;\n }\n }\n\n // Try number\n if (\n isDigit(input[pos]) ||\n (input[pos] === '-' && pos + 1 < input.length && isDigit(input[pos + 1]))\n ) {\n const numberToken = this.tryNumber(input, pos);\n if (numberToken) {\n tokens.push(numberToken);\n pos = numberToken.position.end;\n continue;\n }\n }\n\n // Try variable reference (:varname)\n const varToken = this.tryVariableRef(input, pos);\n if (varToken) {\n tokens.push(varToken);\n pos = varToken.position.end;\n continue;\n }\n\n // Try word (identifier or keyword)\n if (isAsciiIdentifierChar(input[pos])) {\n const wordToken = this.extractWord(input, pos);\n if (wordToken) {\n tokens.push(wordToken);\n pos = wordToken.position.end;\n continue;\n }\n }\n\n // Try operator\n const operatorToken = this.tryOperator(input, pos);\n if (operatorToken) {\n tokens.push(operatorToken);\n pos = operatorToken.position.end;\n continue;\n }\n\n // Skip unknown character\n pos++;\n }\n\n return new TokenStreamImpl(tokens, 'en');\n }\n\n classifyToken(token: string): TokenKind {\n // O(1) Map lookup instead of O(n) array search\n if (this.isKeyword(token)) return 'keyword';\n if (token.startsWith('#') || token.startsWith('.') || token.startsWith('[')) return 'selector';\n if (token.startsWith('\"') || token.startsWith(\"'\")) return 'literal';\n if (/^\\d/.test(token)) return 'literal';\n if (['==', '!=', '<=', '>=', '<', '>', '&&', '||', '!'].includes(token)) return 'operator';\n if (token.startsWith('/') || token.startsWith('./') || token.startsWith('http')) return 'url';\n\n return 'identifier';\n }\n\n /**\n * Extract a word (identifier or keyword) from the input.\n * Handles namespaced event names like \"draggable:start\".\n */\n private extractWord(input: string, startPos: number): LanguageToken | null {\n let pos = startPos;\n let word = '';\n\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n word += input[pos++];\n }\n\n if (!word) return null;\n\n // Check for namespaced event name pattern: word:word (e.g., draggable:start)\n // This is different from variable references (:varname) which start with colon\n if (pos < input.length && input[pos] === ':') {\n const colonPos = pos;\n pos++; // consume colon\n let namespace = '';\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n namespace += input[pos++];\n }\n // Only treat as namespaced event if there's text after the colon\n if (namespace) {\n word = word + ':' + namespace;\n } else {\n // No text after colon, revert to just the word\n pos = colonPos;\n }\n }\n\n const kind = this.classifyToken(word);\n\n // O(1) Map lookup for normalized form (for synonyms like flip→toggle)\n const keywordEntry = this.lookupKeyword(word);\n const normalized =\n keywordEntry && keywordEntry.normalized !== keywordEntry.native\n ? keywordEntry.normalized\n : undefined;\n\n // Check for natural class syntax: \"{identifier} class\" → \".{identifier}\"\n // This allows \"toggle the active class\" to work like \"toggle the .active\"\n if (kind === 'identifier') {\n const classConversion = this.tryConvertToClassSelector(input, pos, word);\n if (classConversion) {\n return classConversion.token;\n }\n }\n\n return createToken(\n word,\n kind,\n createPosition(startPos, pos),\n normalized // Will be undefined if not a synonym, which is fine\n );\n }\n\n /**\n * Try to convert an identifier followed by \"class\" to a class selector.\n * E.g., \"active class\" → \".active\"\n *\n * This enables natural English syntax like:\n * - \"toggle the active class\" → \"toggle .active\"\n * - \"add the visible class\" → \"add .visible\"\n */\n private tryConvertToClassSelector(\n input: string,\n pos: number,\n word: string\n ): { token: LanguageToken; endPos: number } | null {\n let checkPos = pos;\n\n // Skip whitespace\n while (checkPos < input.length && /\\s/.test(input[checkPos])) {\n checkPos++;\n }\n\n // Check if next word is \"class\"\n if (input.slice(checkPos, checkPos + 5).toLowerCase() === 'class') {\n // Make sure \"class\" is a complete word (not \"className\" etc.)\n const afterClass = checkPos + 5;\n if (afterClass >= input.length || !isAsciiIdentifierChar(input[afterClass])) {\n // Convert to class selector\n const selectorValue = '.' + word;\n // Note: we DON'T consume \"class\" here - let the noise word handling in\n // pattern-matcher skip it. This keeps the token stream cleaner.\n return {\n token: createToken(selectorValue, 'selector', createPosition(pos - word.length, pos)),\n endPos: pos,\n };\n }\n }\n\n return null;\n }\n}\n\n/**\n * Singleton instance.\n */\nexport const englishTokenizer = new EnglishTokenizer();\n","/**\n * Command Schemas\n *\n * Defines the semantic structure of each hyperscript command.\n * Used by the pattern generator to create language-specific patterns.\n */\n\nimport type { SemanticRole, ActionType, SemanticValue } from '../types';\n\n// =============================================================================\n// Command Schema Types\n// =============================================================================\n\n/**\n * A role specification in a command schema.\n */\nexport interface RoleSpec {\n /** The semantic role */\n readonly role: SemanticRole;\n /** Description of what this role represents */\n readonly description: string;\n /** Whether this role is required */\n readonly required: boolean;\n /** Expected value types */\n readonly expectedTypes: Array<'selector' | 'literal' | 'reference' | 'expression'>;\n /** Default value if not provided */\n readonly default?: SemanticValue;\n /** Position hint for SVO languages (higher = earlier) */\n readonly svoPosition?: number;\n /** Position hint for SOV languages (higher = earlier) */\n readonly sovPosition?: number;\n /**\n * Override the default role marker for this command.\n * Maps language code to the marker to use (e.g., { en: 'to', es: 'a' }).\n * If not specified, uses the language profile's default roleMarker.\n */\n readonly markerOverride?: Record<string, string>;\n}\n\n/**\n * A precondition that must be met before command execution.\n * Used for runtime error documentation.\n */\nexport interface CommandPrecondition {\n /** Human-readable condition description */\n readonly condition: string;\n /** Error code thrown when precondition fails */\n readonly errorCode: string;\n /** Error message template */\n readonly message: string;\n}\n\n/**\n * A command schema defines the semantic structure of a command.\n */\nexport interface CommandSchema {\n /** The action type (command name) */\n readonly action: ActionType;\n /** Human-readable description */\n readonly description: string;\n /** Roles this command accepts */\n readonly roles: RoleSpec[];\n /** The primary role (what the command acts on) */\n readonly primaryRole: SemanticRole;\n /** Category for grouping */\n readonly category: CommandCategory;\n /** Whether this command typically has a body (like event handlers) */\n readonly hasBody?: boolean;\n /** Notes about special handling */\n readonly notes?: string;\n\n // Runtime error documentation (optional for backward compatibility)\n\n /** Possible runtime error codes this command can throw */\n readonly errorCodes?: readonly string[];\n /** Preconditions that must be met before execution */\n readonly preconditions?: readonly CommandPrecondition[];\n /** Recovery hints mapping error code to suggestion */\n readonly recoveryHints?: Readonly<Record<string, string>>;\n}\n\n/**\n * Command categories for organization.\n */\nexport type CommandCategory =\n | 'dom-class' // Class/attribute manipulation\n | 'dom-content' // Content manipulation\n | 'dom-visibility' // Show/hide\n | 'variable' // Variable operations\n | 'event' // Event handling\n | 'async' // Async operations\n | 'navigation' // URL/navigation\n | 'control-flow'; // Control flow\n\n// =============================================================================\n// Command Schema Definitions\n// =============================================================================\n\n/**\n * Toggle command: adds class/attribute if absent, removes if present.\n *\n * Patterns:\n * - EN: toggle .active on #button\n * - JA: #button の .active を 切り替え\n * - AR: بدّل .active على #button\n */\nexport const toggleSchema: CommandSchema = {\n action: 'toggle',\n description: 'Toggle a class or attribute on/off',\n category: 'dom-class',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The class or attribute to toggle',\n required: true,\n expectedTypes: ['selector'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n // Runtime error documentation\n errorCodes: ['MISSING_ARGUMENT', 'NO_VALID_CLASS_NAMES', 'INVALID_CSS_PROPERTY'],\n preconditions: [\n {\n condition: 'Command has at least one argument',\n errorCode: 'MISSING_ARGUMENT',\n message: 'toggle command requires an argument',\n },\n {\n condition: 'Class names are valid CSS identifiers',\n errorCode: 'NO_VALID_CLASS_NAMES',\n message: 'toggle command: no valid class names found',\n },\n ],\n recoveryHints: {\n MISSING_ARGUMENT: 'Add a class selector (.classname) or attribute to toggle',\n NO_VALID_CLASS_NAMES: 'Ensure class names start with a dot (.) and are valid CSS identifiers',\n INVALID_CSS_PROPERTY: 'Check CSS property name syntax (use kebab-case)',\n },\n};\n\n/**\n * Add command: adds a class or attribute.\n */\nexport const addSchema: CommandSchema = {\n action: 'add',\n description: 'Add a class or attribute to an element',\n category: 'dom-class',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The class or attribute to add',\n required: true,\n expectedTypes: ['selector'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n // Runtime error documentation\n errorCodes: ['MISSING_ARGUMENT', 'NO_VALID_CLASS_NAMES', 'PROPERTY_REQUIRES_VALUE'],\n preconditions: [\n {\n condition: 'Command has at least one argument',\n errorCode: 'MISSING_ARGUMENT',\n message: 'add command requires an argument',\n },\n ],\n recoveryHints: {\n MISSING_ARGUMENT: 'Add a class selector (.classname) or attribute to add',\n NO_VALID_CLASS_NAMES: 'Ensure class names start with a dot (.) and are valid CSS identifiers',\n PROPERTY_REQUIRES_VALUE: 'When adding a property (*prop), provide a value argument',\n },\n};\n\n/**\n * Remove command: removes a class or attribute.\n */\nexport const removeSchema: CommandSchema = {\n action: 'remove',\n description: 'Remove a class or attribute from an element',\n category: 'dom-class',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The class or attribute to remove',\n required: true,\n expectedTypes: ['selector'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'The element to remove from (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n // Runtime error documentation\n errorCodes: ['MISSING_ARGUMENT', 'NO_VALID_CLASS_NAMES'],\n preconditions: [\n {\n condition: 'Command has at least one argument',\n errorCode: 'MISSING_ARGUMENT',\n message: 'remove command requires an argument',\n },\n ],\n recoveryHints: {\n MISSING_ARGUMENT: 'Add a class selector (.classname) or attribute to remove',\n NO_VALID_CLASS_NAMES: 'Ensure class names start with a dot (.) and are valid CSS identifiers',\n },\n};\n\n/**\n * Put command: puts content into a target.\n *\n * Patterns:\n * - EN: put \"hello\" into #output\n * - JA: #output に \"hello\" を 置く\n * - AR: ضع \"hello\" في #output\n */\nexport const putSchema: CommandSchema = {\n action: 'put',\n description: 'Put content into a target element or variable',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The content to put',\n required: true,\n expectedTypes: ['literal', 'selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'Where to put the content',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n // Runtime error documentation\n errorCodes: [\n 'MISSING_ARGUMENTS',\n 'MISSING_CONTENT',\n 'MISSING_POSITION',\n 'INVALID_POSITION',\n 'NO_TARGET',\n 'NO_ELEMENTS',\n ],\n preconditions: [\n {\n condition: 'Command has content and position arguments',\n errorCode: 'MISSING_ARGUMENTS',\n message: 'put requires arguments',\n },\n {\n condition: 'Content to put is specified',\n errorCode: 'MISSING_CONTENT',\n message: 'put requires content',\n },\n {\n condition: 'Position keyword is specified (into, before, after, etc.)',\n errorCode: 'MISSING_POSITION',\n message: 'put requires position keyword',\n },\n ],\n recoveryHints: {\n MISSING_ARGUMENTS: 'Use syntax: put <content> into/before/after <target>',\n MISSING_CONTENT: 'Add content to put (string, element, or expression)',\n MISSING_POSITION: 'Add position keyword: into, before, after, at start of, at end of',\n INVALID_POSITION: 'Valid positions: into, before, after, at start of, at end of',\n NO_TARGET: 'Ensure target element exists or use \"me\" reference',\n NO_ELEMENTS: 'Check that the selector matches existing elements',\n },\n};\n\n/**\n * Set command: sets a property or variable.\n *\n * Patterns:\n * - EN: set :count to 10\n * - ES: establecer :count a 10\n * - JA: :count を 10 に 設定\n * - KO: :x 에 5 을 설정 (uses default markers)\n * - TR: :x e 5 i ayarla (uses default markers)\n *\n * Note: Only override markers for SVO languages where patient has no default marker.\n * SOV languages (Korean, Japanese, Turkish) already have correct object markers.\n */\nexport const setSchema: CommandSchema = {\n action: 'set',\n description: 'Set a property or variable to a value',\n category: 'variable',\n primaryRole: 'destination',\n roles: [\n {\n role: 'destination',\n description: 'The property or variable to set',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 1,\n sovPosition: 1,\n // Override destination marker for English (remove 'on', use no marker)\n // Other languages keep their default destination markers\n markerOverride: {\n en: '', // No marker before destination in English: \"set :x to 5\"\n },\n },\n {\n role: 'patient',\n description: 'The value to set',\n required: true,\n expectedTypes: ['literal', 'expression', 'reference'],\n svoPosition: 2,\n sovPosition: 2,\n // Override patient marker for SVO languages with their native prepositions\n // SOV languages (Korean, Japanese, Turkish) use their default object markers\n markerOverride: {\n en: 'to', // \"set :x to 5\"\n es: 'a', // \"establecer x a 10\"\n pt: 'para', // \"definir x para 10\"\n fr: 'à', // \"définir x à 10\"\n de: 'auf', // \"setze x auf 10\"\n id: 'ke', // \"atur x ke 10\"\n },\n },\n ],\n // Runtime error documentation\n errorCodes: ['MISSING_TARGET', 'INVALID_TARGET', 'MISSING_VALUE', 'INVALID_SYNTAX'],\n preconditions: [\n {\n condition: 'Command has a target variable or property',\n errorCode: 'MISSING_TARGET',\n message: 'set command requires a target',\n },\n {\n condition: 'Target is a valid variable or property reference',\n errorCode: 'INVALID_TARGET',\n message: 'set command target must be a string or object literal',\n },\n {\n condition: 'Value is specified with \"to\" keyword',\n errorCode: 'MISSING_VALUE',\n message: 'set command requires a value (use \"to\" keyword)',\n },\n ],\n recoveryHints: {\n MISSING_TARGET: 'Add a target: set :variable to value OR set element.property to value',\n INVALID_TARGET:\n 'Use local variable (:name), element property (el.prop), or \"the X of Y\" syntax',\n MISSING_VALUE: 'Add \"to <value>\" to specify what to set',\n INVALID_SYNTAX: 'Use syntax: set <target> to <value>',\n },\n};\n\n/**\n * Show command: makes an element visible.\n */\nexport const showSchema: CommandSchema = {\n action: 'show',\n description: 'Make an element visible',\n category: 'dom-visibility',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to show',\n required: true, // Changed from false - patient is primary role\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'style',\n description: 'Animation style (fade, slide, etc.)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Hide command: makes an element invisible.\n */\nexport const hideSchema: CommandSchema = {\n action: 'hide',\n description: 'Make an element invisible',\n category: 'dom-visibility',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to hide',\n required: true, // Changed from false - patient is primary role\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'style',\n description: 'Animation style (fade, slide, etc.)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * On command: event handler.\n */\nexport const onSchema: CommandSchema = {\n action: 'on',\n description: 'Handle an event',\n category: 'event',\n primaryRole: 'event',\n hasBody: true,\n roles: [\n {\n role: 'event',\n description: 'The event to handle',\n required: true,\n expectedTypes: ['literal'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'The element to listen on (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Trigger command: dispatches an event.\n * Supports namespaced events like \"draggable:start\".\n */\nexport const triggerSchema: CommandSchema = {\n action: 'trigger',\n description: 'Trigger/dispatch an event',\n category: 'event',\n primaryRole: 'event',\n roles: [\n {\n role: 'event',\n description: 'The event to trigger (supports namespaced events like draggable:start)',\n required: true,\n expectedTypes: ['literal', 'expression'], // expression for custom/namespaced event names\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Wait command: pauses execution.\n */\nexport const waitSchema: CommandSchema = {\n action: 'wait',\n description: 'Wait for a duration or event',\n category: 'async',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'Duration or event to wait for',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Fetch command: makes HTTP request.\n */\nexport const fetchSchema: CommandSchema = {\n action: 'fetch',\n description: 'Fetch data from a URL',\n category: 'async',\n primaryRole: 'source',\n roles: [\n {\n role: 'source',\n description: 'The URL to fetch from',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'responseType',\n description: 'Response format (json, text, html, blob, etc.)',\n required: false,\n expectedTypes: ['literal', 'expression'], // json/text/html are identifiers → expression type\n svoPosition: 2,\n sovPosition: 2,\n },\n {\n role: 'method',\n description: 'HTTP method (GET, POST, etc.)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 3,\n sovPosition: 3,\n },\n {\n role: 'destination',\n description: 'Where to store the result',\n required: false,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 4,\n sovPosition: 4,\n },\n ],\n};\n\n/**\n * Increment command: increases a numeric value.\n */\nexport const incrementSchema: CommandSchema = {\n action: 'increment',\n description: 'Increment a numeric value',\n category: 'variable',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The value to increment',\n required: true,\n expectedTypes: ['selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'quantity',\n description: 'Amount to increment by (defaults to 1)',\n required: false,\n expectedTypes: ['literal'],\n default: { type: 'literal', value: 1, dataType: 'number' },\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Decrement command: decreases a numeric value.\n */\nexport const decrementSchema: CommandSchema = {\n action: 'decrement',\n description: 'Decrement a numeric value',\n category: 'variable',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The value to decrement',\n required: true,\n expectedTypes: ['selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'quantity',\n description: 'Amount to decrement by (defaults to 1)',\n required: false,\n expectedTypes: ['literal'],\n default: { type: 'literal', value: 1, dataType: 'number' },\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Append command: appends content to an element.\n */\nexport const appendSchema: CommandSchema = {\n action: 'append',\n description: 'Append content to an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The content to append',\n required: true,\n expectedTypes: ['literal', 'selector', 'expression'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The element to append to',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Prepend command: prepends content to an element.\n */\nexport const prependSchema: CommandSchema = {\n action: 'prepend',\n description: 'Prepend content to an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The content to prepend',\n required: true,\n expectedTypes: ['literal', 'selector', 'expression'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The element to prepend to',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n// =============================================================================\n// Batch 1 - Simple Commands\n// =============================================================================\n\n/**\n * Log command: logs a value to console.\n */\nexport const logSchema: CommandSchema = {\n action: 'log',\n description: 'Log a value to the console',\n category: 'variable',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The value to log',\n required: true,\n expectedTypes: ['literal', 'selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Get command: retrieves a value.\n */\nexport const getCommandSchema: CommandSchema = {\n action: 'get',\n description: 'Get a value from a source',\n category: 'variable',\n primaryRole: 'source',\n roles: [\n {\n role: 'source',\n description: 'The source to get from',\n required: true,\n expectedTypes: ['selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 2,\n // No marker before source for simple GET pattern: \"get #element\" not \"get from #element\"\n markerOverride: {\n en: '',\n es: '',\n pt: '',\n fr: '',\n de: '',\n ja: '',\n zh: '',\n ko: '',\n ar: '',\n tr: '',\n id: '',\n },\n },\n {\n role: 'destination',\n description: 'Where to store the result (optional)',\n required: false,\n expectedTypes: ['reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Take command: takes/removes content from a source.\n */\nexport const takeSchema: CommandSchema = {\n action: 'take',\n description: 'Take content from a source element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The class or element to take',\n required: true,\n expectedTypes: ['selector'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'The element to take from (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Make command: creates a new element.\n */\nexport const makeSchema: CommandSchema = {\n action: 'make',\n description: 'Create a new element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element type or selector to create',\n required: true,\n expectedTypes: ['literal', 'selector'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Halt command: stops execution or event propagation.\n * Supports: halt, halt the event, halt default, halt the bubbling\n */\nexport const haltSchema: CommandSchema = {\n action: 'halt',\n description: 'Halt/stop execution or event propagation',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'What to halt (event, default, bubbling, etc.)',\n required: false, // Plain \"halt\" is valid\n expectedTypes: ['literal', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Settle command: waits for animations to complete.\n */\nexport const settleSchema: CommandSchema = {\n action: 'settle',\n description: 'Wait for animations/transitions to settle',\n category: 'async',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to settle (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Throw command: throws an error/exception.\n */\nexport const throwSchema: CommandSchema = {\n action: 'throw',\n description: 'Throw an error',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The error message or object to throw',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Send command: sends/dispatches an event.\n */\nexport const sendSchema: CommandSchema = {\n action: 'send',\n description: 'Send an event to an element',\n category: 'event',\n primaryRole: 'event',\n roles: [\n {\n role: 'event',\n description: 'The event to send',\n required: true,\n expectedTypes: ['literal', 'expression'], // identifiers tokenize as expression\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n // send uses \"to\" not \"on\" for destination: send foo to #target\n markerOverride: {\n en: 'to',\n ja: 'に',\n ar: 'إلى',\n es: 'a',\n ko: '에게',\n zh: '到',\n tr: '-e',\n pt: 'para',\n fr: 'à',\n de: 'an',\n id: 'ke',\n qu: '-man',\n sw: 'kwa',\n },\n },\n ],\n};\n\n// =============================================================================\n// Batch 2 - Control Flow Commands\n// =============================================================================\n\n/**\n * If command: conditional execution.\n */\nexport const ifSchema: CommandSchema = {\n action: 'if',\n description: 'Conditional execution',\n category: 'control-flow',\n primaryRole: 'condition',\n hasBody: true,\n roles: [\n {\n role: 'condition',\n description: 'The condition to evaluate',\n required: true,\n expectedTypes: ['expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Unless command: negated conditional execution.\n * Executes body when condition is false.\n */\nexport const unlessSchema: CommandSchema = {\n action: 'unless',\n description: 'Negated conditional execution (executes when condition is false)',\n category: 'control-flow',\n primaryRole: 'condition',\n hasBody: true,\n roles: [\n {\n role: 'condition',\n description: 'The condition to evaluate (body executes when false)',\n required: true,\n expectedTypes: ['expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Else command: alternative branch.\n */\nexport const elseSchema: CommandSchema = {\n action: 'else',\n description: 'Else branch of conditional',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [], // No roles - follows an if\n};\n\n/**\n * Repeat command: loop execution.\n */\nexport const repeatSchema: CommandSchema = {\n action: 'repeat',\n description: 'Repeat a block of commands',\n category: 'control-flow',\n primaryRole: 'loopType',\n hasBody: true,\n roles: [\n {\n role: 'loopType',\n description: 'Loop variant: forever, times, for, while, until, until-event',\n required: true,\n expectedTypes: ['literal'],\n svoPosition: 0,\n sovPosition: 0,\n },\n {\n role: 'quantity',\n description: 'Number of times to repeat',\n required: false,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'event',\n description: 'Event to wait for (terminates loop)',\n required: false,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 2,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'Element to listen for event on',\n required: false,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 3,\n sovPosition: 3,\n },\n ],\n notes:\n 'Can also use \"repeat forever\", \"repeat until condition\", or \"repeat until event X from Y\"',\n};\n\n/**\n * For command: iteration over collection.\n */\nexport const forSchema: CommandSchema = {\n action: 'for',\n description: 'Iterate over a collection',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [\n {\n role: 'patient',\n description: 'The iteration variable',\n required: true,\n expectedTypes: ['reference'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'The collection to iterate over',\n required: true,\n expectedTypes: ['selector', 'reference', 'expression'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * While command: conditional loop.\n */\nexport const whileSchema: CommandSchema = {\n action: 'while',\n description: 'Loop while condition is true',\n category: 'control-flow',\n primaryRole: 'condition',\n hasBody: true,\n roles: [\n {\n role: 'condition',\n description: 'The condition to check',\n required: true,\n expectedTypes: ['expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Continue command: skip to next iteration.\n */\nexport const continueSchema: CommandSchema = {\n action: 'continue',\n description: 'Continue to next loop iteration',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [], // No roles\n};\n\n// =============================================================================\n// Batch 3 - DOM & Navigation Commands\n// =============================================================================\n\n/**\n * Go command: navigates to a URL.\n */\nexport const goSchema: CommandSchema = {\n action: 'go',\n description: 'Navigate to a URL',\n category: 'navigation',\n primaryRole: 'destination',\n roles: [\n {\n role: 'destination',\n description: 'The URL to navigate to',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Transition command: animates element changes.\n */\nexport const transitionSchema: CommandSchema = {\n action: 'transition',\n description: 'Transition an element with animation',\n category: 'dom-visibility',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The property to transition (opacity, *background-color, etc.)',\n required: true,\n expectedTypes: ['literal'], // Only literal - CSS properties are strings, not selectors\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'goal',\n description: 'The target value to transition to',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 2,\n sovPosition: 3,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 3,\n sovPosition: 1,\n },\n {\n role: 'duration',\n description: 'Transition duration (over 500ms, for 2 seconds)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 4,\n sovPosition: 4,\n },\n {\n role: 'style',\n description: 'Easing function (ease-in, linear, etc.)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 5,\n sovPosition: 5,\n },\n ],\n};\n\n/**\n * Clone command: clones an element.\n */\nexport const cloneSchema: CommandSchema = {\n action: 'clone',\n description: 'Clone an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to clone',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'Where to put the clone',\n required: false,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Focus command: focuses an element.\n */\nexport const focusSchema: CommandSchema = {\n action: 'focus',\n description: 'Focus an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to focus (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Blur command: removes focus from an element.\n */\nexport const blurSchema: CommandSchema = {\n action: 'blur',\n description: 'Remove focus from an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to blur (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n// =============================================================================\n// Batch 4 - Advanced Commands\n// =============================================================================\n\n/**\n * Call command: calls a function.\n */\nexport const callSchema: CommandSchema = {\n action: 'call',\n description: 'Call a function',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The function to call',\n required: true,\n expectedTypes: ['expression', 'reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Return command: returns a value.\n */\nexport const returnSchema: CommandSchema = {\n action: 'return',\n description: 'Return a value from a function',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The value to return',\n required: false,\n expectedTypes: ['literal', 'expression', 'reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * JS command: executes raw JavaScript.\n */\nexport const jsSchema: CommandSchema = {\n action: 'js',\n description: 'Execute raw JavaScript code',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [\n {\n role: 'patient',\n description: 'The JavaScript code to execute',\n required: false,\n expectedTypes: ['expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Async command: runs commands asynchronously.\n */\nexport const asyncSchema: CommandSchema = {\n action: 'async',\n description: 'Execute commands asynchronously',\n category: 'async',\n primaryRole: 'patient',\n hasBody: true,\n roles: [],\n};\n\n/**\n * Tell command: sends commands to another element.\n */\nexport const tellSchema: CommandSchema = {\n action: 'tell',\n description: 'Execute commands in context of another element',\n category: 'control-flow',\n primaryRole: 'destination',\n hasBody: true,\n roles: [\n {\n role: 'destination',\n description: 'The element to tell',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Default command: sets default values.\n */\nexport const defaultSchema: CommandSchema = {\n action: 'default',\n description: 'Set a default value for a variable',\n category: 'variable',\n primaryRole: 'destination',\n roles: [\n {\n role: 'destination',\n description: 'The variable to set default for',\n required: true,\n expectedTypes: ['reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'patient',\n description: 'The default value',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Init command: initialization block.\n */\nexport const initSchema: CommandSchema = {\n action: 'init',\n description: 'Initialization block that runs once',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [],\n};\n\n/**\n * Behavior command: defines reusable behavior.\n * Patterns:\n * - EN: behavior Draggable\n * - EN: behavior Draggable(dragHandle)\n */\nexport const behaviorSchema: CommandSchema = {\n action: 'behavior',\n description: 'Define a reusable behavior',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [\n {\n role: 'patient',\n description: 'The behavior name (PascalCase identifier)',\n required: true,\n expectedTypes: ['literal', 'reference', 'expression'], // expression for PascalCase identifiers\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Install command: installs a behavior on an element.\n * Patterns:\n * - EN: install Draggable\n * - EN: install Draggable(dragHandle: .titlebar)\n * - EN: install Draggable on #element\n */\nexport const installSchema: CommandSchema = {\n action: 'install',\n description: 'Install a behavior on an element',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The behavior name to install',\n required: true,\n expectedTypes: ['literal', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'Element to install on (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Measure command: measures element dimensions or position.\n * Patterns:\n * - EN: measure x\n * - EN: measure width\n * - EN: measure width of #element\n */\nexport const measureSchema: CommandSchema = {\n action: 'measure',\n description: 'Measure element dimensions (x, y, width, height, etc.)',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'Property to measure (x, y, width, height, top, left, etc.)',\n required: false, // Plain \"measure\" is valid, defaults to bounds\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'source',\n description: 'Element to measure (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n// =============================================================================\n// Batch 5 - DOM Content Manipulation\n// =============================================================================\n\n/**\n * Swap command: swaps DOM content using various strategies.\n *\n * Patterns:\n * - EN: swap innerHTML of #target\n * - EN: swap delete #target\n * - EN: swap beforebegin #target with <html>\n */\nexport const swapSchema: CommandSchema = {\n action: 'swap',\n description: 'Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)',\n category: 'dom-content',\n primaryRole: 'destination',\n roles: [\n {\n role: 'method',\n description: 'The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 1,\n sovPosition: 3,\n },\n {\n role: 'destination',\n description: 'The element to swap content in/for',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n {\n role: 'patient',\n description: 'The content to swap in (optional for delete)',\n required: false,\n expectedTypes: ['literal', 'expression', 'selector'],\n svoPosition: 3,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Morph command: morphs one element into another using DOM diffing.\n *\n * Patterns:\n * - EN: morph #target to <html>\n * - EN: morph me into #template\n */\nexport const morphSchema: CommandSchema = {\n action: 'morph',\n description: 'Morph an element into another using DOM diffing',\n category: 'dom-content',\n primaryRole: 'destination',\n roles: [\n {\n role: 'destination',\n description: 'The element to morph',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'patient',\n description: 'The target content/element to morph into',\n required: true,\n expectedTypes: ['literal', 'expression', 'selector'],\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n// =============================================================================\n// Schema Registry\n// =============================================================================\n\n/**\n * All available command schemas.\n */\nexport const commandSchemas: Record<ActionType, CommandSchema> = {\n // Original schemas\n toggle: toggleSchema,\n add: addSchema,\n remove: removeSchema,\n put: putSchema,\n set: setSchema,\n show: showSchema,\n hide: hideSchema,\n on: onSchema,\n trigger: triggerSchema,\n wait: waitSchema,\n fetch: fetchSchema,\n increment: incrementSchema,\n decrement: decrementSchema,\n append: appendSchema,\n prepend: prependSchema,\n // Batch 1 - Simple Commands\n log: logSchema,\n get: getCommandSchema,\n take: takeSchema,\n make: makeSchema,\n halt: haltSchema,\n settle: settleSchema,\n throw: throwSchema,\n send: sendSchema,\n // Batch 2 - Control Flow\n if: ifSchema,\n unless: unlessSchema,\n else: elseSchema,\n repeat: repeatSchema,\n for: forSchema,\n while: whileSchema,\n continue: continueSchema,\n // Batch 3 - DOM & Navigation\n go: goSchema,\n transition: transitionSchema,\n clone: cloneSchema,\n focus: focusSchema,\n blur: blurSchema,\n // Batch 4 - Advanced\n call: callSchema,\n return: returnSchema,\n js: jsSchema,\n async: asyncSchema,\n tell: tellSchema,\n default: defaultSchema,\n init: initSchema,\n behavior: behaviorSchema,\n install: installSchema,\n measure: measureSchema,\n // Batch 5 - DOM Content Manipulation\n swap: swapSchema,\n morph: morphSchema,\n // Meta commands (for compound structures)\n compound: {\n action: 'compound',\n description: 'A compound node representing chained statements',\n primaryRole: 'patient', // Compound nodes don't have a traditional primary role\n category: 'control-flow',\n hasBody: true,\n roles: [],\n },\n};\n\n/**\n * Get a command schema by action type.\n */\nexport function getSchema(action: ActionType): CommandSchema | undefined {\n return commandSchemas[action];\n}\n\n/**\n * Get all schemas for a category.\n */\nexport function getSchemasByCategory(category: CommandCategory): CommandSchema[] {\n return Object.values(commandSchemas).filter(s => s.category === category);\n}\n\n/**\n * Get all fully-defined schemas (with roles).\n */\nexport function getDefinedSchemas(): CommandSchema[] {\n return Object.values(commandSchemas).filter(s => s.roles.length > 0);\n}\n\n// =============================================================================\n// Schema Validation (Development Only)\n// =============================================================================\n\n// Run schema validation at module load time in development builds\n// This is tree-shaken out in production builds\nif (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') {\n // Dynamic import to avoid bundling in production\n import('./schema-validator')\n .then(({ validateAllSchemas, formatValidationResults }) => {\n const validations = validateAllSchemas(commandSchemas);\n\n if (validations.size > 0) {\n console.warn('[SCHEMA VALIDATION] Found issues in command schemas:');\n console.warn(formatValidationResults(validations));\n console.warn('\\nThese warnings help identify potential schema design issues.');\n console.warn('Fix them to improve type inference and avoid runtime bugs.');\n }\n })\n .catch(err => {\n // Silently ignore if schema validator is not available\n console.debug('Schema validation skipped:', err);\n });\n}\n","/**\n * Role Positioning Utility\n *\n * Shared utilities for sorting and positioning semantic roles based on word order.\n * Used by pattern-generator and pattern-matcher to ensure consistent behavior.\n */\n\nimport type { SemanticRole } from '../../types';\nimport type { WordOrder } from '../../generators/profiles/types';\n\n/**\n * Priority order for semantic roles used in pattern matching.\n * Lower number = higher priority (comes first in pattern).\n * Only includes roles commonly used in patterns.\n */\nexport const ROLE_PRIORITY: Partial<Record<SemanticRole, number>> = {\n patient: 1,\n destination: 2,\n source: 3,\n style: 4,\n manner: 5,\n goal: 6,\n};\n\n/**\n * Get the priority of a semantic role.\n * Returns 99 for unknown/unlisted roles.\n */\nexport function getRolePriority(role: SemanticRole): number {\n return ROLE_PRIORITY[role] ?? 99;\n}\n\n/**\n * Sort semantic roles by their priority.\n * Patient comes first, then destination, source, etc.\n */\nexport function sortRolesByPriority(roles: SemanticRole[]): SemanticRole[] {\n return [...roles].sort((a, b) => getRolePriority(a) - getRolePriority(b));\n}\n\n// Re-export for convenience\nexport type { WordOrder };\n\n/**\n * Minimum interface for roles that can be sorted by position.\n */\nexport interface RoleWithPosition {\n role: SemanticRole;\n sovPosition?: number;\n svoPosition?: number;\n}\n\n/**\n * Sort roles by their position for a given word order.\n *\n * @param roles Array of role specs with position info\n * @param wordOrder The word order to use (SVO, SOV, VSO)\n * @returns Sorted array of roles\n */\nexport function sortRolesByWordOrder<T extends RoleWithPosition>(\n roles: readonly T[],\n wordOrder: WordOrder\n): T[] {\n const sortKey = wordOrder === 'SOV' ? 'sovPosition' : 'svoPosition';\n return [...roles].sort((a, b) => {\n const aPos = a[sortKey] ?? 99;\n const bPos = b[sortKey] ?? 99;\n return aPos - bPos;\n });\n}\n","/**\n * Marker Resolution Utility\n *\n * Shared utilities for resolving role markers from language profiles.\n * Used by pattern-generator to build tokens and extraction rules.\n */\n\nimport type { SemanticRole } from '../../types';\nimport type { LanguageProfile, RoleMarker } from '../../generators/language-profiles';\n\n/**\n * Minimum interface for role specs that can have marker resolution.\n * Compatible with the RoleSpec type from command-schemas.\n */\nexport interface RoleSpecWithMarker {\n role: SemanticRole;\n markerOverride?: Record<string, string | undefined>;\n}\n\n/**\n * Resolved marker information for a role.\n */\nexport interface ResolvedMarker {\n /** Primary marker string (may be empty string for no marker) */\n primary: string;\n /** Alternative markers */\n alternatives?: string[];\n /** Position relative to role value */\n position: 'before' | 'after';\n /** Whether this is an override marker */\n isOverride: boolean;\n}\n\n/**\n * Resolve the marker for a role in a specific language.\n *\n * Checks for command-specific marker overrides first,\n * then falls back to the default marker from the language profile.\n *\n * @param roleSpec Role specification with optional override\n * @param profile Language profile with role markers\n * @returns Resolved marker info, or null if no marker\n */\nexport function resolveMarkerForRole(\n roleSpec: RoleSpecWithMarker,\n profile: LanguageProfile\n): ResolvedMarker | null {\n // Check for command-specific marker override first\n const overrideMarker = roleSpec.markerOverride?.[profile.code];\n const defaultMarker = profile.roleMarkers[roleSpec.role];\n\n if (overrideMarker !== undefined) {\n // Use override marker (can be empty string to suppress default marker)\n return {\n primary: overrideMarker,\n position: defaultMarker?.position ?? 'before',\n isOverride: true,\n };\n }\n\n if (defaultMarker && defaultMarker.primary) {\n const result: ResolvedMarker = {\n primary: defaultMarker.primary,\n position: defaultMarker.position,\n isOverride: false,\n };\n if (defaultMarker.alternatives) {\n result.alternatives = defaultMarker.alternatives;\n }\n return result;\n }\n\n return null;\n}\n\n/**\n * Get all markers (primary + alternatives) for a role.\n *\n * @param roleSpec Role specification\n * @param profile Language profile\n * @returns Array of marker strings, or empty array if no markers\n */\nexport function getAllMarkersForRole(\n roleSpec: RoleSpecWithMarker,\n profile: LanguageProfile\n): string[] {\n const resolved = resolveMarkerForRole(roleSpec, profile);\n if (!resolved || !resolved.primary) {\n return [];\n }\n\n const markers = [resolved.primary];\n if (resolved.alternatives) {\n markers.push(...resolved.alternatives);\n }\n return markers;\n}\n\n/**\n * Get the default role marker from a language profile.\n *\n * @param profile Language profile\n * @param role Semantic role\n * @returns Role marker or undefined\n */\nexport function getDefaultRoleMarker(\n profile: LanguageProfile,\n role: SemanticRole\n): RoleMarker | undefined {\n return profile.roleMarkers[role];\n}\n","/**\n * Pattern Generator\n *\n * Generates LanguagePattern objects from CommandSchema + LanguageProfile.\n * This solves the pattern explosion problem by deriving patterns from\n * high-level definitions rather than hand-writing each one.\n */\n\nimport type { LanguagePattern, PatternToken, ExtractionRule } from '../types';\nimport type { LanguageProfile } from './language-profiles';\nimport type { CommandSchema, RoleSpec } from './command-schemas';\nimport { getDefinedSchemas } from './command-schemas';\n\n// Import shared utilities\nimport { sortRolesByWordOrder } from '../parser/utils/role-positioning';\nimport { resolveMarkerForRole } from '../parser/utils/marker-resolution';\n\n// Note: languageProfiles is no longer imported here.\n// Pattern generation for specific languages uses the registry instead.\n\n// Import registry functions - this is safe because:\n// 1. Registry doesn't import pattern-generator\n// 2. The circular path is: pattern-generator -> registry -> pattern-generator\n// But registry only uses setPatternGenerator which is exported, not module-level code\nimport {\n getRegisteredLanguages as registryGetLanguages,\n tryGetProfile as registryTryGetProfile,\n} from '../registry';\n\nfunction getAllRegisteredProfiles(): LanguageProfile[] {\n const languages = registryGetLanguages();\n return languages\n .map((lang: string) => registryTryGetProfile(lang))\n .filter((p): p is LanguageProfile => p !== undefined);\n}\n\n// =============================================================================\n// Pattern Generator\n// =============================================================================\n\n/**\n * Configuration for pattern generation.\n */\nexport interface GeneratorConfig {\n /** Base priority for generated patterns (higher = checked first) */\n basePriority?: number;\n /** Whether to generate simple patterns (without optional roles) */\n generateSimpleVariants?: boolean;\n /** Whether to generate alternative keyword patterns */\n generateAlternatives?: boolean;\n}\n\nconst defaultConfig: GeneratorConfig = {\n basePriority: 100,\n generateSimpleVariants: true,\n generateAlternatives: true,\n};\n\n/**\n * Generate a pattern for a command in a specific language.\n */\nexport function generatePattern(\n schema: CommandSchema,\n profile: LanguageProfile,\n config: GeneratorConfig = defaultConfig\n): LanguagePattern {\n const id = `${schema.action}-${profile.code}-generated`;\n const priority = config.basePriority ?? 100;\n\n // Get keyword translation\n const keyword = profile.keywords[schema.action];\n if (!keyword) {\n throw new Error(`No keyword translation for '${schema.action}' in ${profile.code}`);\n }\n\n // Build tokens based on word order\n const tokens = buildTokens(schema, profile, keyword);\n\n // Build extraction rules with defaults for optional roles\n // This ensures defaults are applied even when optional groups don't match\n const extraction = buildExtractionRulesWithDefaults(schema, profile);\n\n // Build template format string (for documentation)\n const format = buildFormatString(schema, profile, keyword);\n\n return {\n id,\n language: profile.code,\n command: schema.action,\n priority,\n template: {\n format,\n tokens,\n },\n extraction,\n };\n}\n\n/**\n * Generate a simple variant pattern (without optional roles).\n */\nexport function generateSimplePattern(\n schema: CommandSchema,\n profile: LanguageProfile,\n config: GeneratorConfig = defaultConfig\n): LanguagePattern | null {\n // Only generate simple variant if there are optional roles\n const optionalRoles = schema.roles.filter(r => !r.required);\n if (optionalRoles.length === 0) {\n return null;\n }\n\n const requiredRoles = schema.roles.filter(r => r.required);\n const simpleSchema: CommandSchema = {\n ...schema,\n roles: requiredRoles,\n };\n\n const pattern = generatePattern(simpleSchema, profile, config);\n\n // Adjust for simple variant\n return {\n ...pattern,\n id: `${schema.action}-${profile.code}-simple`,\n priority: (config.basePriority ?? 100) - 5, // Lower priority than full pattern (was -10)\n extraction: buildExtractionRulesWithDefaults(schema, profile),\n };\n}\n\n/**\n * Generate all pattern variants for a command in a language.\n */\nexport function generatePatternVariants(\n schema: CommandSchema,\n profile: LanguageProfile,\n config: GeneratorConfig = defaultConfig\n): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n\n // Main pattern\n patterns.push(generatePattern(schema, profile, config));\n\n // Simple variant (without optional roles)\n if (config.generateSimpleVariants) {\n const simple = generateSimplePattern(schema, profile, config);\n if (simple) {\n patterns.push(simple);\n }\n }\n\n return patterns;\n}\n\n/**\n * Generate patterns for all commands in a specific language.\n */\nexport function generatePatternsForLanguage(\n profile: LanguageProfile,\n config: GeneratorConfig = defaultConfig\n): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n const schemas = getDefinedSchemas();\n\n for (const schema of schemas) {\n // Skip if no keyword translation exists\n if (!profile.keywords[schema.action]) {\n continue;\n }\n\n const variants = generatePatternVariants(schema, profile, config);\n patterns.push(...variants);\n }\n\n return patterns;\n}\n\n/**\n * Generate patterns for a command across specified profiles.\n *\n * @param schema Command schema to generate patterns for\n * @param profiles Array of language profiles to generate patterns for (defaults to all registered)\n * @param config Generator configuration\n */\nexport function generatePatternsForCommand(\n schema: CommandSchema,\n profiles?: LanguageProfile[],\n config: GeneratorConfig = defaultConfig\n): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n\n // If no profiles provided, use all registered profiles\n const profilesToUse = profiles ?? getAllRegisteredProfiles();\n\n for (const profile of profilesToUse) {\n // Skip if no keyword translation exists\n if (!profile.keywords[schema.action]) {\n continue;\n }\n\n const variants = generatePatternVariants(schema, profile, config);\n patterns.push(...variants);\n }\n\n return patterns;\n}\n\n/**\n * Generate all patterns for all commands across specified profiles.\n *\n * @param profiles Array of language profiles to generate patterns for (defaults to all registered)\n * @param config Generator configuration\n */\nexport function generateAllPatterns(\n profiles?: LanguageProfile[],\n config: GeneratorConfig = defaultConfig\n): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n\n // If no profiles provided, use all registered profiles\n const profilesToUse = profiles ?? getAllRegisteredProfiles();\n\n for (const profile of profilesToUse) {\n const langPatterns = generatePatternsForLanguage(profile, config);\n patterns.push(...langPatterns);\n }\n\n return patterns;\n}\n\n// =============================================================================\n// Token Building\n// =============================================================================\n\n/**\n * Build pattern tokens based on word order.\n */\nfunction buildTokens(\n schema: CommandSchema,\n profile: LanguageProfile,\n keyword: { primary: string; alternatives?: string[] }\n): PatternToken[] {\n const tokens: PatternToken[] = [];\n\n // Get verb token\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n\n // Get role tokens sorted by position\n const roleTokens = buildRoleTokens(schema, profile);\n\n // Arrange based on word order\n switch (profile.wordOrder) {\n case 'SVO':\n // Verb first, then roles in order\n tokens.push(verbToken);\n tokens.push(...roleTokens);\n break;\n\n case 'SOV':\n // Roles first (reversed for SOV), then verb\n tokens.push(...roleTokens);\n tokens.push(verbToken);\n break;\n\n case 'VSO':\n // Verb first, then subject, then object\n tokens.push(verbToken);\n tokens.push(...roleTokens);\n break;\n\n default:\n // Default to SVO\n tokens.push(verbToken);\n tokens.push(...roleTokens);\n }\n\n return tokens;\n}\n\n/**\n * Build tokens for roles.\n */\nfunction buildRoleTokens(schema: CommandSchema, profile: LanguageProfile): PatternToken[] {\n const tokens: PatternToken[] = [];\n\n // Sort roles by position using shared utility\n const sortedRoles = sortRolesByWordOrder(schema.roles, profile.wordOrder);\n\n for (const roleSpec of sortedRoles) {\n const roleToken = buildRoleToken(roleSpec, profile);\n\n if (!roleSpec.required) {\n // Wrap optional roles in a group\n tokens.push({\n type: 'group',\n optional: true,\n tokens: roleToken,\n });\n } else {\n tokens.push(...roleToken);\n }\n }\n\n return tokens;\n}\n\n/**\n * Build token(s) for a single role.\n */\nfunction buildRoleToken(roleSpec: RoleSpec, profile: LanguageProfile): PatternToken[] {\n const tokens: PatternToken[] = [];\n\n // Check for command-specific marker override first\n const overrideMarker = roleSpec.markerOverride?.[profile.code];\n const defaultMarker = profile.roleMarkers[roleSpec.role];\n\n // Role value token\n const roleValueToken: PatternToken = {\n type: 'role',\n role: roleSpec.role,\n optional: !roleSpec.required,\n expectedTypes: roleSpec.expectedTypes as any,\n };\n\n // Use override marker if available, otherwise use default\n if (overrideMarker !== undefined) {\n // Command-specific marker override\n const position = defaultMarker?.position ?? 'before';\n if (position === 'before') {\n if (overrideMarker) {\n tokens.push({ type: 'literal', value: overrideMarker });\n }\n tokens.push(roleValueToken);\n } else {\n tokens.push(roleValueToken);\n if (overrideMarker) {\n tokens.push({ type: 'literal', value: overrideMarker });\n }\n }\n } else if (defaultMarker) {\n if (defaultMarker.position === 'before') {\n // Preposition: \"on #button\"\n if (defaultMarker.primary) {\n const markerToken: PatternToken = defaultMarker.alternatives\n ? {\n type: 'literal',\n value: defaultMarker.primary,\n alternatives: defaultMarker.alternatives,\n }\n : { type: 'literal', value: defaultMarker.primary };\n tokens.push(markerToken);\n }\n tokens.push(roleValueToken);\n } else {\n // Postposition/particle: \"#button に\"\n tokens.push(roleValueToken);\n const markerToken: PatternToken = defaultMarker.alternatives\n ? {\n type: 'literal',\n value: defaultMarker.primary,\n alternatives: defaultMarker.alternatives,\n }\n : { type: 'literal', value: defaultMarker.primary };\n tokens.push(markerToken);\n }\n } else {\n // No marker, just the role value\n tokens.push(roleValueToken);\n }\n\n return tokens;\n}\n\n// =============================================================================\n// Extraction Rules Building\n// =============================================================================\n\n/**\n * Build extraction rules for a pattern.\n */\nfunction buildExtractionRules(\n schema: CommandSchema,\n profile: LanguageProfile\n): Record<string, ExtractionRule> {\n const rules: Record<string, ExtractionRule> = {};\n\n for (const roleSpec of schema.roles) {\n // Check for command-specific marker override first\n const overrideMarker = roleSpec.markerOverride?.[profile.code];\n const defaultMarker = profile.roleMarkers[roleSpec.role];\n\n if (overrideMarker !== undefined) {\n // Use the override marker\n rules[roleSpec.role] = overrideMarker ? { marker: overrideMarker } : {};\n } else if (defaultMarker && defaultMarker.primary) {\n rules[roleSpec.role] = defaultMarker.alternatives\n ? { marker: defaultMarker.primary, markerAlternatives: defaultMarker.alternatives }\n : { marker: defaultMarker.primary };\n } else {\n rules[roleSpec.role] = {};\n }\n }\n\n return rules;\n}\n\n/**\n * Build extraction rules with defaults for optional roles.\n */\nfunction buildExtractionRulesWithDefaults(\n schema: CommandSchema,\n profile: LanguageProfile\n): Record<string, ExtractionRule> {\n const baseRules = buildExtractionRules(schema, profile);\n const rules: Record<string, ExtractionRule> = {};\n\n // Copy base rules and add defaults for optional roles\n for (const roleSpec of schema.roles) {\n const baseRule = baseRules[roleSpec.role] || {};\n\n if (!roleSpec.required && roleSpec.default) {\n rules[roleSpec.role] = { ...baseRule, default: roleSpec.default };\n } else {\n rules[roleSpec.role] = baseRule;\n }\n }\n\n return rules;\n}\n\n// =============================================================================\n// Format String Building\n// =============================================================================\n\n/**\n * Build a human-readable format string for documentation.\n */\nfunction buildFormatString(\n schema: CommandSchema,\n profile: LanguageProfile,\n keyword: { primary: string }\n): string {\n const parts: string[] = [];\n\n // Sort roles by position using shared utility\n const sortedRoles = sortRolesByWordOrder(schema.roles, profile.wordOrder);\n\n // Build role parts\n const roleParts = sortedRoles.map(roleSpec => {\n // Use shared marker resolution utility\n const resolved = resolveMarkerForRole(roleSpec, profile);\n let part = '';\n\n if (resolved && resolved.primary) {\n // Has a marker\n if (resolved.position === 'before') {\n part = `${resolved.primary} {${roleSpec.role}}`;\n } else {\n part = `{${roleSpec.role}} ${resolved.primary}`;\n }\n } else {\n // No marker\n part = `{${roleSpec.role}}`;\n }\n\n return roleSpec.required ? part : `[${part}]`;\n });\n\n // Arrange based on word order\n switch (profile.wordOrder) {\n case 'SVO':\n case 'VSO':\n parts.push(keyword.primary, ...roleParts);\n break;\n case 'SOV':\n parts.push(...roleParts, keyword.primary);\n break;\n default:\n parts.push(keyword.primary, ...roleParts);\n }\n\n return parts.join(' ');\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Get a summary of what patterns can be generated.\n * Note: This requires the registry to have languages registered.\n */\nexport function getGeneratorSummary(): {\n languages: string[];\n commands: string[];\n totalPatterns: number;\n} {\n const languages = registryGetLanguages();\n const commands = getDefinedSchemas().map(s => s.action);\n\n // Estimate total patterns (2 variants per command per language)\n let totalPatterns = 0;\n for (const lang of languages) {\n const profile = registryTryGetProfile(lang);\n if (profile) {\n for (const schema of getDefinedSchemas()) {\n if (profile.keywords[schema.action]) {\n totalPatterns += 2; // Full + simple variant\n }\n }\n }\n }\n\n return { languages, commands, totalPatterns };\n}\n\n/**\n * Validate that all required keywords exist for a language.\n */\nexport function validateLanguageKeywords(\n profile: LanguageProfile,\n schemas: CommandSchema[] = getDefinedSchemas()\n): { missing: string[]; available: string[] } {\n const missing: string[] = [];\n const available: string[] = [];\n\n for (const schema of schemas) {\n if (profile.keywords[schema.action]) {\n available.push(schema.action);\n } else {\n missing.push(schema.action);\n }\n }\n\n return { missing, available };\n}\n","/**\n * English Toggle Patterns\n *\n * Tree-shakeable: Only included when English is imported.\n */\n\nimport type { LanguagePattern } from '../../types';\n\n/**\n * Get English toggle patterns.\n */\nexport function getTogglePatternsEn(): LanguagePattern[] {\n return [\n {\n id: 'toggle-en-full',\n language: 'en',\n command: 'toggle',\n priority: 100,\n template: {\n format: 'toggle {patient} on {target}',\n tokens: [\n { type: 'literal', value: 'toggle' },\n { type: 'role', role: 'patient' },\n {\n type: 'group',\n optional: true,\n tokens: [\n { type: 'literal', value: 'on', alternatives: ['from'] },\n { type: 'role', role: 'destination' },\n ],\n },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: {\n marker: 'on',\n markerAlternatives: ['from'],\n default: { type: 'reference', value: 'me' },\n },\n },\n },\n {\n id: 'toggle-en-simple',\n language: 'en',\n command: 'toggle',\n priority: 90,\n template: {\n format: 'toggle {patient}',\n tokens: [\n { type: 'literal', value: 'toggle' },\n { type: 'role', role: 'patient' },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: { default: { type: 'reference', value: 'me' } },\n },\n },\n ];\n}\n","/**\n * English Put Patterns\n *\n * Tree-shakeable: Only included when English is imported.\n */\n\nimport type { LanguagePattern } from '../../types';\n\n/**\n * Get English put patterns.\n */\nexport function getPutPatternsEn(): LanguagePattern[] {\n return [\n {\n id: 'put-en-into',\n language: 'en',\n command: 'put',\n priority: 100,\n template: {\n format: 'put {patient} into {destination}',\n tokens: [\n { type: 'literal', value: 'put' },\n { type: 'role', role: 'patient' },\n { type: 'literal', value: 'into', alternatives: ['in', 'to'] },\n { type: 'role', role: 'destination' },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: { marker: 'into', markerAlternatives: ['in', 'to'] },\n },\n },\n {\n id: 'put-en-before',\n language: 'en',\n command: 'put',\n priority: 95,\n template: {\n format: 'put {patient} before {destination}',\n tokens: [\n { type: 'literal', value: 'put' },\n { type: 'role', role: 'patient' },\n { type: 'literal', value: 'before' },\n { type: 'role', role: 'destination' },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: { marker: 'before' },\n manner: { default: { type: 'literal', value: 'before' } },\n },\n },\n {\n id: 'put-en-after',\n language: 'en',\n command: 'put',\n priority: 95,\n template: {\n format: 'put {patient} after {destination}',\n tokens: [\n { type: 'literal', value: 'put' },\n { type: 'role', role: 'patient' },\n { type: 'literal', value: 'after' },\n { type: 'role', role: 'destination' },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: { marker: 'after' },\n manner: { default: { type: 'literal', value: 'after' } },\n },\n },\n ];\n}\n","/**\n * English Event Handler Patterns\n *\n * Tree-shakeable: Only included when English is imported.\n */\n\nimport type { LanguagePattern } from '../../types';\n\n/**\n * Get English event handler patterns.\n */\nexport function getEventHandlerPatternsEn(): LanguagePattern[] {\n return [\n {\n id: 'event-en-when-source',\n language: 'en',\n command: 'on',\n priority: 115,\n template: {\n format: 'when {event} from {source} {body}',\n tokens: [\n { type: 'literal', value: 'when' },\n { type: 'role', role: 'event' },\n { type: 'literal', value: 'from' },\n { type: 'role', role: 'source' },\n ],\n },\n extraction: {\n event: { position: 1 },\n source: { marker: 'from' },\n },\n },\n {\n id: 'event-en-when',\n language: 'en',\n command: 'on',\n priority: 105,\n template: {\n format: 'when {event} {body}',\n tokens: [\n { type: 'literal', value: 'when' },\n { type: 'role', role: 'event' },\n ],\n },\n extraction: {\n event: { position: 1 },\n },\n },\n {\n id: 'event-en-source',\n language: 'en',\n command: 'on',\n priority: 110,\n template: {\n format: 'on {event} from {source} {body}',\n tokens: [\n { type: 'literal', value: 'on' },\n { type: 'role', role: 'event' },\n { type: 'literal', value: 'from' },\n { type: 'role', role: 'source' },\n ],\n },\n extraction: {\n event: { position: 1 },\n source: { marker: 'from' },\n },\n },\n {\n id: 'event-en-standard',\n language: 'en',\n command: 'on',\n priority: 100,\n template: {\n format: 'on {event} {body}',\n tokens: [\n { type: 'literal', value: 'on' },\n { type: 'role', role: 'event' },\n ],\n },\n extraction: {\n event: { position: 1 },\n },\n },\n {\n id: 'event-en-upon',\n language: 'en',\n command: 'on',\n priority: 98,\n template: {\n format: 'upon {event} {body}',\n tokens: [\n { type: 'literal', value: 'upon' },\n { type: 'role', role: 'event' },\n ],\n },\n extraction: {\n event: { position: 1 },\n },\n },\n {\n id: 'event-en-if',\n language: 'en',\n command: 'on',\n priority: 95,\n template: {\n format: 'if {event} {body}',\n tokens: [\n { type: 'literal', value: 'if' },\n { type: 'role', role: 'event' },\n ],\n },\n extraction: {\n event: { position: 1 },\n },\n },\n ];\n}\n","/**\n * English Patterns Module\n *\n * Builds all patterns for English language.\n * This module is imported by languages/en.ts and only includes English patterns.\n */\n\nimport type { LanguagePattern } from '../types';\nimport { englishProfile } from '../generators/profiles/english';\nimport { generatePatternsForLanguage } from '../generators/pattern-generator';\n\n// Import directly from per-language files for tree-shaking\nimport { getTogglePatternsEn } from './toggle/en';\nimport { getPutPatternsEn } from './put/en';\nimport { getEventHandlerPatternsEn } from './event-handler/en';\n\n// =============================================================================\n// Hand-crafted English-only patterns\n// =============================================================================\n\n/**\n * English: \"fetch /url as json\" with response type.\n */\nconst fetchWithResponseTypeEnglish: LanguagePattern = {\n id: 'fetch-en-with-response-type',\n language: 'en',\n command: 'fetch',\n priority: 90,\n template: {\n format: 'fetch {source} as {responseType}',\n tokens: [\n { type: 'literal', value: 'fetch' },\n { type: 'role', role: 'source', expectedTypes: ['literal', 'expression'] },\n { type: 'literal', value: 'as' },\n { type: 'role', role: 'responseType', expectedTypes: ['literal', 'expression'] },\n ],\n },\n extraction: {\n source: { position: 1 },\n responseType: { marker: 'as' },\n },\n};\n\n/**\n * English: \"fetch /url\" without \"from\" preposition.\n */\nconst fetchSimpleEnglish: LanguagePattern = {\n id: 'fetch-en-simple',\n language: 'en',\n command: 'fetch',\n priority: 80,\n template: {\n format: 'fetch {source}',\n tokens: [\n { type: 'literal', value: 'fetch' },\n { type: 'role', role: 'source' },\n ],\n },\n extraction: {\n source: { position: 1 },\n },\n};\n\n/**\n * English: \"swap <strategy> <target>\" without prepositions.\n */\nconst swapSimpleEnglish: LanguagePattern = {\n id: 'swap-en-handcrafted',\n language: 'en',\n command: 'swap',\n priority: 110,\n template: {\n format: 'swap {method} {destination}',\n tokens: [\n { type: 'literal', value: 'swap' },\n { type: 'role', role: 'method' },\n { type: 'role', role: 'destination' },\n ],\n },\n extraction: {\n method: { position: 1 },\n destination: { position: 2 },\n },\n};\n\n/**\n * English: \"repeat until event pointerup from document\"\n */\nconst repeatUntilEventFromEnglish: LanguagePattern = {\n id: 'repeat-en-until-event-from',\n language: 'en',\n command: 'repeat',\n priority: 120,\n template: {\n format: 'repeat until event {event} from {source}',\n tokens: [\n { type: 'literal', value: 'repeat' },\n { type: 'literal', value: 'until' },\n { type: 'literal', value: 'event' },\n { type: 'role', role: 'event', expectedTypes: ['literal', 'expression'] },\n { type: 'literal', value: 'from' },\n { type: 'role', role: 'source', expectedTypes: ['selector', 'reference', 'expression'] },\n ],\n },\n extraction: {\n event: { marker: 'event' },\n source: { marker: 'from' },\n loopType: { default: { type: 'literal', value: 'until-event' } },\n },\n};\n\n/**\n * English: \"repeat until event pointerup\"\n */\nconst repeatUntilEventEnglish: LanguagePattern = {\n id: 'repeat-en-until-event',\n language: 'en',\n command: 'repeat',\n priority: 110,\n template: {\n format: 'repeat until event {event}',\n tokens: [\n { type: 'literal', value: 'repeat' },\n { type: 'literal', value: 'until' },\n { type: 'literal', value: 'event' },\n { type: 'role', role: 'event', expectedTypes: ['literal', 'expression'] },\n ],\n },\n extraction: {\n event: { marker: 'event' },\n loopType: { default: { type: 'literal', value: 'until-event' } },\n },\n};\n\n/**\n * English: \"set {target} to {value}\" with possessive syntax support\n */\nconst setPossessiveEnglish: LanguagePattern = {\n id: 'set-en-possessive',\n language: 'en',\n command: 'set',\n priority: 100,\n template: {\n format: 'set {destination} to {patient}',\n tokens: [\n { type: 'literal', value: 'set' },\n {\n type: 'role',\n role: 'destination',\n expectedTypes: ['property-path', 'selector', 'reference', 'expression'],\n },\n { type: 'literal', value: 'to' },\n { type: 'role', role: 'patient', expectedTypes: ['literal', 'expression', 'reference'] },\n ],\n },\n extraction: {\n destination: { position: 1 },\n patient: { marker: 'to' },\n },\n};\n\n/**\n * English: \"for {variable} in {collection}\"\n */\nconst forEnglish: LanguagePattern = {\n id: 'for-en-basic',\n language: 'en',\n command: 'for',\n priority: 100,\n template: {\n format: 'for {patient} in {source}',\n tokens: [\n { type: 'literal', value: 'for' },\n { type: 'role', role: 'patient', expectedTypes: ['expression', 'reference'] },\n { type: 'literal', value: 'in' },\n { type: 'role', role: 'source', expectedTypes: ['selector', 'expression', 'reference'] },\n ],\n },\n extraction: {\n patient: { position: 1 },\n source: { marker: 'in' },\n loopType: { default: { type: 'literal', value: 'for' } },\n },\n};\n\n/**\n * English: \"if {condition}\"\n */\nconst ifEnglish: LanguagePattern = {\n id: 'if-en-basic',\n language: 'en',\n command: 'if',\n priority: 100,\n template: {\n format: 'if {condition}',\n tokens: [\n { type: 'literal', value: 'if' },\n { type: 'role', role: 'condition', expectedTypes: ['expression', 'reference', 'selector'] },\n ],\n },\n extraction: {\n condition: { position: 1 },\n },\n};\n\n/**\n * English: \"unless {condition}\"\n */\nconst unlessEnglish: LanguagePattern = {\n id: 'unless-en-basic',\n language: 'en',\n command: 'unless',\n priority: 100,\n template: {\n format: 'unless {condition}',\n tokens: [\n { type: 'literal', value: 'unless' },\n { type: 'role', role: 'condition', expectedTypes: ['expression', 'reference', 'selector'] },\n ],\n },\n extraction: {\n condition: { position: 1 },\n },\n};\n\n/**\n * English: \"in 2s toggle .active\" - Natural temporal delay\n */\nconst temporalInEnglish: LanguagePattern = {\n id: 'temporal-en-in',\n language: 'en',\n command: 'wait',\n priority: 95,\n template: {\n format: 'in {duration}',\n tokens: [\n { type: 'literal', value: 'in' },\n { type: 'role', role: 'duration', expectedTypes: ['literal', 'expression'] },\n ],\n },\n extraction: {\n duration: { position: 1 },\n },\n};\n\n/**\n * English: \"after 2s show #tooltip\" - Natural temporal delay\n */\nconst temporalAfterEnglish: LanguagePattern = {\n id: 'temporal-en-after',\n language: 'en',\n command: 'wait',\n priority: 95,\n template: {\n format: 'after {duration}',\n tokens: [\n { type: 'literal', value: 'after' },\n { type: 'role', role: 'duration', expectedTypes: ['literal', 'expression'] },\n ],\n },\n extraction: {\n duration: { position: 1 },\n },\n};\n\n// =============================================================================\n// Build All English Patterns\n// =============================================================================\n\n/**\n * Build all English patterns.\n * Called once when the English language module is imported.\n */\nexport function buildEnglishPatterns(): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n\n // 1. Hand-crafted patterns\n patterns.push(...getTogglePatternsEn());\n patterns.push(...getPutPatternsEn());\n patterns.push(...getEventHandlerPatternsEn());\n\n // 2. English-only hand-crafted patterns\n patterns.push(\n fetchWithResponseTypeEnglish,\n fetchSimpleEnglish,\n swapSimpleEnglish,\n repeatUntilEventFromEnglish,\n repeatUntilEventEnglish,\n setPossessiveEnglish,\n forEnglish,\n ifEnglish,\n unlessEnglish,\n temporalInEnglish,\n temporalAfterEnglish\n );\n\n // 3. Generated patterns for English\n const generatedPatterns = generatePatternsForLanguage(englishProfile);\n patterns.push(...generatedPatterns);\n\n return patterns;\n}\n","/**\n * English Language Module\n *\n * Self-registering module for English language support.\n * Importing this module registers English tokenizer, profile, and patterns.\n *\n * This module enables tree-shaking by directly importing only English-specific\n * code, avoiding the patterns/index.ts barrel which pulls in all languages.\n *\n * @example\n * ```typescript\n * import '@lokascript/semantic/languages/en';\n * ```\n */\n\nimport { registerLanguage, registerPatterns } from '../registry';\nimport { englishTokenizer } from '../tokenizers/english';\nimport { englishProfile } from '../generators/profiles/english';\nimport { buildEnglishPatterns } from '../patterns/en';\n\n// Re-export for direct access\nexport { englishTokenizer } from '../tokenizers/english';\nexport { englishProfile } from '../generators/profiles/english';\n\n// Auto-register when this module is imported\nregisterLanguage('en', englishTokenizer, englishProfile);\n\n// Register English patterns directly (enables tree-shaking)\nregisterPatterns('en', buildEngl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uBAAwC;AAAA,EAC5C,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,MACN,EAAE,MAAM,WAAW,OAAO,QAAQ;AAAA,MAClC,EAAE,MAAM,QAAQ,MAAM,YAAY,eAAe,CAAC,WAAW,YAAY,EAAE;AAAA,IAC7E;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,UAAU,EAAE,UAAU,EAAE;AAAA,EAC1B;AACF;AAUO,SAAS,uBAA0C;AACxD,QAAM,WAA8B,CAAC;AAGrC,WAAS,KAAK,GAAG,oBAAoB,CAAC;AACtC,WAAS,KAAK,GAAG,iBAAiB,CAAC;AACnC,WAAS,KAAK,GAAG,0BAA0B,CAAC;AAG5C,WAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,QAAM,oBAAoB,4BAA4B,cAAc;AACpE,WAAS,KAAK,GAAG,iBAAiB;AAElC,SAAO;AACT;;;ACpRA,iBAAiB,MAAM,kBAAkB,cAAc;AAGvD,iBAAiB,MAAM,qBAAqB,CAAC;","names":["validateAllSchemas","formatValidationResults"]}
|
|
1
|
+
{"version":3,"sources":["../../src/generators/schema-error-codes.ts","../../src/generators/schema-validator.ts","../../src/registry.ts","../../src/tokenizers/base.ts","../../src/generators/profiles/english.ts","../../src/tokenizers/english.ts","../../src/generators/command-schemas.ts","../../src/parser/utils/role-positioning.ts","../../src/parser/utils/marker-resolution.ts","../../src/generators/pattern-generator.ts","../../src/patterns/toggle/en.ts","../../src/patterns/put/en.ts","../../src/patterns/event-handler/en.ts","../../src/patterns/en.ts","../../src/languages/en.ts"],"sourcesContent":["/**\n * Schema Error Codes\n *\n * Provides machine-readable error codes for schema validation.\n * These codes enable LLMs and tooling to programmatically identify\n * and respond to specific validation issues.\n */\n\nimport type { SemanticRole } from '../types';\n\n/**\n * Severity levels for schema validation items.\n */\nexport type SchemaValidationSeverity = 'error' | 'warning' | 'note';\n\n/**\n * A structured validation item with machine-readable code.\n */\nexport interface SchemaValidationItem {\n /** Machine-readable error code */\n code: string;\n /** Human-readable message */\n message: string;\n /** Severity level */\n severity: SchemaValidationSeverity;\n /** Affected role, if applicable */\n role?: SemanticRole;\n /** Suggested fix */\n suggestion?: string;\n}\n\n/**\n * Schema error codes organized by category.\n */\nexport const SchemaErrorCodes = {\n // Type ambiguity issues\n AMBIGUOUS_TYPE_LITERAL_SELECTOR: 'SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR',\n TOO_MANY_EXPECTED_TYPES: 'SCHEMA_TOO_MANY_EXPECTED_TYPES',\n MULTI_TYPE_PATIENT_EXPECTED: 'SCHEMA_MULTI_TYPE_PATIENT_EXPECTED',\n\n // Role issues\n NO_REQUIRED_ROLES: 'SCHEMA_NO_REQUIRED_ROLES',\n NO_REQUIRED_ROLES_EXPECTED: 'SCHEMA_NO_REQUIRED_ROLES_EXPECTED',\n\n // Transition command\n TRANSITION_PATIENT_ACCEPTS_SELECTOR: 'SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR',\n TRANSITION_MISSING_GOAL: 'SCHEMA_TRANSITION_MISSING_GOAL',\n\n // Event handler command\n EVENT_HANDLER_MISSING_EVENT: 'SCHEMA_EVENT_HANDLER_MISSING_EVENT',\n EVENT_HANDLER_EVENT_NOT_REQUIRED: 'SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED',\n\n // Conditional commands\n CONDITIONAL_MISSING_CONDITION: 'SCHEMA_CONDITIONAL_MISSING_CONDITION',\n CONDITIONAL_CONDITION_NOT_REQUIRED: 'SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED',\n\n // Loop commands\n FOR_LOOP_MISSING_SOURCE: 'SCHEMA_FOR_LOOP_MISSING_SOURCE',\n WHILE_LOOP_MISSING_CONDITION: 'SCHEMA_WHILE_LOOP_MISSING_CONDITION',\n} as const;\n\nexport type SchemaErrorCode = (typeof SchemaErrorCodes)[keyof typeof SchemaErrorCodes];\n\n/**\n * Message templates for each error code.\n * Use {role}, {command}, {count} placeholders for dynamic values.\n */\nexport const SchemaErrorMessages: Record<SchemaErrorCode, string> = {\n // Type ambiguity\n [SchemaErrorCodes.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:\n \"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).\",\n [SchemaErrorCodes.TOO_MANY_EXPECTED_TYPES]:\n \"Role '{role}' accepts {count} different types. This may make type inference unreliable.\",\n [SchemaErrorCodes.MULTI_TYPE_PATIENT_EXPECTED]:\n \"Role '{role}' accepts multiple types (expected for {command} command).\",\n\n // Role issues\n [SchemaErrorCodes.NO_REQUIRED_ROLES]: 'Command has no required roles. Is this intentional?',\n [SchemaErrorCodes.NO_REQUIRED_ROLES_EXPECTED]:\n 'Command has no required roles (expected for {command}).',\n\n // Transition\n [SchemaErrorCodes.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:\n \"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.\",\n [SchemaErrorCodes.TRANSITION_MISSING_GOAL]:\n \"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.\",\n\n // Event handler\n [SchemaErrorCodes.EVENT_HANDLER_MISSING_EVENT]:\n \"Event handler command should have an 'event' role to specify which event to listen for.\",\n [SchemaErrorCodes.EVENT_HANDLER_EVENT_NOT_REQUIRED]:\n 'Event role should be required - every event handler needs an event to listen for.',\n\n // Conditionals\n [SchemaErrorCodes.CONDITIONAL_MISSING_CONDITION]:\n \"Conditional command should have a 'condition' role for the boolean expression.\",\n [SchemaErrorCodes.CONDITIONAL_CONDITION_NOT_REQUIRED]:\n 'Condition role should be required - conditionals need a condition to evaluate.',\n\n // Loops\n [SchemaErrorCodes.FOR_LOOP_MISSING_SOURCE]:\n \"For-loop should have a 'source' role for the collection to iterate over.\",\n [SchemaErrorCodes.WHILE_LOOP_MISSING_CONDITION]:\n \"While-loop should have a 'condition' role for the loop condition.\",\n};\n\n/**\n * Suggested fixes for each error code.\n */\nexport const SchemaErrorSuggestions: Partial<Record<SchemaErrorCode, string>> = {\n [SchemaErrorCodes.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:\n 'Consider being more specific about which type is expected, or use explicit type markers.',\n [SchemaErrorCodes.TOO_MANY_EXPECTED_TYPES]:\n 'Consider narrowing the accepted types to improve type inference reliability.',\n [SchemaErrorCodes.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:\n \"Remove 'selector' from expectedTypes and only accept 'literal'.\",\n [SchemaErrorCodes.TRANSITION_MISSING_GOAL]:\n \"Add a 'goal' role with expectedTypes ['literal', 'variable'].\",\n [SchemaErrorCodes.EVENT_HANDLER_MISSING_EVENT]:\n \"Add an 'event' role with expectedTypes ['literal'].\",\n [SchemaErrorCodes.EVENT_HANDLER_EVENT_NOT_REQUIRED]: \"Set required: true on the 'event' role.\",\n [SchemaErrorCodes.CONDITIONAL_MISSING_CONDITION]:\n \"Add a 'condition' role with expectedTypes ['expression'].\",\n [SchemaErrorCodes.CONDITIONAL_CONDITION_NOT_REQUIRED]:\n \"Set required: true on the 'condition' role.\",\n [SchemaErrorCodes.FOR_LOOP_MISSING_SOURCE]:\n \"Add a 'source' role for the collection to iterate over.\",\n [SchemaErrorCodes.WHILE_LOOP_MISSING_CONDITION]:\n \"Add a 'condition' role for the loop continuation condition.\",\n};\n\n/**\n * Interpolate placeholders in a message template.\n */\nfunction interpolate(template: string, params: Record<string, string | number>): string {\n return template.replace(/\\{(\\w+)\\}/g, (_, key) => String(params[key] ?? `{${key}}`));\n}\n\n/**\n * Create a schema validation item with proper interpolation.\n */\nexport function createSchemaValidationItem(\n code: SchemaErrorCode,\n severity: SchemaValidationSeverity,\n params: Record<string, string | number> = {},\n role?: SemanticRole\n): SchemaValidationItem {\n const messageTemplate = SchemaErrorMessages[code];\n const message = interpolate(messageTemplate, params);\n const suggestionTemplate = SchemaErrorSuggestions[code];\n const suggestion = suggestionTemplate ? interpolate(suggestionTemplate, params) : undefined;\n\n return {\n code,\n message,\n severity,\n ...(role && { role }),\n ...(suggestion && { suggestion }),\n };\n}\n","/**\n * Schema Validation\n *\n * Validates command schemas to catch design issues early:\n * - Ambiguous type combinations (e.g., both 'literal' and 'selector')\n * - Missing required roles for specific commands\n * - Schema inconsistencies\n *\n * This runs at build time in development to catch schema errors before they cause\n * runtime issues.\n */\n\nimport type { CommandSchema } from './command-schemas';\nimport type { ActionType } from '../types';\nimport {\n type SchemaValidationItem,\n type SchemaValidationSeverity,\n SchemaErrorCodes,\n createSchemaValidationItem,\n} from './schema-error-codes';\n\n// Re-export for convenience\nexport type { SchemaValidationItem, SchemaValidationSeverity };\nexport { SchemaErrorCodes };\n\n/**\n * Result from validating a single command schema.\n *\n * The `items` array contains all validation results with machine-readable codes.\n * For backward compatibility, `notes`, `warnings`, and `errors` getters are provided.\n */\nexport interface SchemaValidation {\n action: ActionType;\n /** All validation items with structured codes and severity */\n items: SchemaValidationItem[];\n}\n\n/**\n * Extended validation result with backward-compatible getters.\n */\nexport interface SchemaValidationResult extends SchemaValidation {\n /** @deprecated Use items.filter(i => i.severity === 'note') */\n readonly notes: string[];\n /** @deprecated Use items.filter(i => i.severity === 'warning') */\n readonly warnings: string[];\n /** @deprecated Use items.filter(i => i.severity === 'error') */\n readonly errors: string[];\n}\n\n/**\n * Create a SchemaValidationResult with backward-compatible getters.\n */\nfunction createValidationResult(\n action: ActionType,\n items: SchemaValidationItem[]\n): SchemaValidationResult {\n return {\n action,\n items,\n get notes() {\n return items.filter(i => i.severity === 'note').map(i => i.message);\n },\n get warnings() {\n return items.filter(i => i.severity === 'warning').map(i => i.message);\n },\n get errors() {\n return items.filter(i => i.severity === 'error').map(i => i.message);\n },\n };\n}\n\n// Commands where multi-type patient roles are intentional (not ambiguous)\nconst MULTI_TYPE_PATIENT_COMMANDS = new Set([\n 'put',\n 'append',\n 'prepend',\n 'log',\n 'throw',\n 'make',\n 'measure',\n 'return',\n 'swap',\n 'morph', // DOM manipulation commands that accept various content types\n]);\n\n// Commands that intentionally have no required roles\nconst NO_REQUIRED_ROLES_COMMANDS = new Set([\n 'compound',\n 'else',\n 'halt',\n 'continue',\n 'async',\n 'init',\n 'settle',\n 'focus',\n 'blur',\n 'return',\n 'js',\n 'measure', // Commands with optional-only roles\n]);\n\n/**\n * Validate a single command schema for potential issues.\n *\n * @param schema - The command schema to validate\n * @returns Validation result with structured items and backward-compatible getters\n */\nexport function validateCommandSchema(schema: CommandSchema): SchemaValidationResult {\n const items: SchemaValidationItem[] = [];\n\n // Check for ambiguous type combinations in roles\n for (const role of schema.roles) {\n // Check if a role accepts both 'literal' and 'selector'\n if (role.expectedTypes.includes('literal') && role.expectedTypes.includes('selector')) {\n if (role.role === 'patient' && MULTI_TYPE_PATIENT_COMMANDS.has(schema.action)) {\n // Known pattern - add as note, not warning\n items.push(\n createSchemaValidationItem(\n SchemaErrorCodes.MULTI_TYPE_PATIENT_EXPECTED,\n 'note',\n { role: role.role, command: schema.action },\n role.role\n )\n );\n } else {\n items.push(\n createSchemaValidationItem(\n SchemaErrorCodes.AMBIGUOUS_TYPE_LITERAL_SELECTOR,\n 'warning',\n { role: role.role },\n role.role\n )\n );\n }\n }\n\n // Warn if a role has too many expected types (> 3)\n if (role.expectedTypes.length > 3 && !MULTI_TYPE_PATIENT_COMMANDS.has(schema.action)) {\n items.push(\n createSchemaValidationItem(\n SchemaErrorCodes.TOO_MANY_EXPECTED_TYPES,\n 'warning',\n { role: role.role, count: role.expectedTypes.length },\n role.role\n )\n );\n }\n }\n\n // Command-specific validation rules\n switch (schema.action) {\n case 'transition':\n validateTransitionSchema(schema, items);\n break;\n\n case 'on':\n validateEventHandlerSchema(schema, items);\n break;\n\n case 'if':\n case 'unless':\n validateConditionalSchema(schema, items);\n break;\n\n case 'repeat':\n case 'for':\n case 'while':\n validateLoopSchema(schema, items);\n break;\n }\n\n // Check for schemas with no required roles\n const requiredRoles = schema.roles.filter(r => r.required);\n if (requiredRoles.length === 0) {\n if (NO_REQUIRED_ROLES_COMMANDS.has(schema.action)) {\n // Known pattern - add as note\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.NO_REQUIRED_ROLES_EXPECTED, 'note', {\n command: schema.action,\n })\n );\n } else {\n items.push(createSchemaValidationItem(SchemaErrorCodes.NO_REQUIRED_ROLES, 'warning', {}));\n }\n }\n\n return createValidationResult(schema.action, items);\n}\n\n/**\n * Validate the transition command schema.\n */\nfunction validateTransitionSchema(schema: CommandSchema, items: SchemaValidationItem[]): void {\n const patientRole = schema.roles.find(r => r.role === 'patient');\n const goalRole = schema.roles.find(r => r.role === 'goal');\n\n // Check that patient (property name) only accepts literals\n if (patientRole && patientRole.expectedTypes.includes('selector')) {\n items.push(\n createSchemaValidationItem(\n SchemaErrorCodes.TRANSITION_PATIENT_ACCEPTS_SELECTOR,\n 'warning',\n {},\n 'patient'\n )\n );\n }\n\n // Check that transition has a goal role for the target value\n if (patientRole && !goalRole) {\n items.push(createSchemaValidationItem(SchemaErrorCodes.TRANSITION_MISSING_GOAL, 'error', {}));\n }\n}\n\n/**\n * Validate event handler schemas (on command).\n */\nfunction validateEventHandlerSchema(schema: CommandSchema, items: SchemaValidationItem[]): void {\n const eventRole = schema.roles.find(r => r.role === 'event');\n\n if (!eventRole) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.EVENT_HANDLER_MISSING_EVENT, 'warning', {})\n );\n }\n\n if (eventRole && !eventRole.required) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.EVENT_HANDLER_EVENT_NOT_REQUIRED, 'warning', {})\n );\n }\n}\n\n/**\n * Validate conditional schemas (if/unless).\n */\nfunction validateConditionalSchema(schema: CommandSchema, items: SchemaValidationItem[]): void {\n const conditionRole = schema.roles.find(r => r.role === 'condition');\n\n if (!conditionRole) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.CONDITIONAL_MISSING_CONDITION, 'warning', {})\n );\n }\n\n if (conditionRole && !conditionRole.required) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.CONDITIONAL_CONDITION_NOT_REQUIRED, 'warning', {})\n );\n }\n}\n\n/**\n * Validate loop schemas (repeat, for, while).\n */\nfunction validateLoopSchema(schema: CommandSchema, items: SchemaValidationItem[]): void {\n // Different loop types have different requirements\n if (schema.action === 'for') {\n const sourceRole = schema.roles.find(r => r.role === 'source');\n if (!sourceRole) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.FOR_LOOP_MISSING_SOURCE, 'warning', {})\n );\n }\n } else if (schema.action === 'while') {\n const conditionRole = schema.roles.find(r => r.role === 'condition');\n if (!conditionRole) {\n items.push(\n createSchemaValidationItem(SchemaErrorCodes.WHILE_LOOP_MISSING_CONDITION, 'warning', {})\n );\n }\n }\n}\n\n/**\n * Validate all command schemas in the registry.\n *\n * @param schemas - Map of action names to command schemas\n * @param options - Validation options\n * @returns Map of action names to validation results (only includes schemas with issues)\n */\nexport function validateAllSchemas(\n schemas: Record<string, CommandSchema>,\n options: { includeNotes?: boolean } = {}\n): Map<string, SchemaValidationResult> {\n const results = new Map<string, SchemaValidationResult>();\n const { includeNotes = false } = options;\n\n for (const [action, schema] of Object.entries(schemas)) {\n const validation = validateCommandSchema(schema);\n\n // Include in results if there are warnings/errors (or notes if requested)\n const hasWarningsOrErrors = validation.items.some(\n i => i.severity === 'warning' || i.severity === 'error'\n );\n const hasNotes = includeNotes && validation.items.some(i => i.severity === 'note');\n\n if (hasWarningsOrErrors || hasNotes) {\n results.set(action, validation);\n }\n }\n\n return results;\n}\n\n/**\n * Format validation results for console output.\n *\n * @param validations - Map of validation results\n * @param options - Formatting options\n * @returns Formatted string for console output\n */\nexport function formatValidationResults(\n validations: Map<string, SchemaValidationResult>,\n options: { showNotes?: boolean; showCodes?: boolean } = {}\n): string {\n const lines: string[] = [];\n const { showNotes = false, showCodes = true } = options;\n\n for (const [action, result] of validations) {\n const errors = result.items.filter(i => i.severity === 'error');\n const warnings = result.items.filter(i => i.severity === 'warning');\n const notes = result.items.filter(i => i.severity === 'note');\n\n if (errors.length > 0) {\n lines.push(` ❌ ${action}:`);\n for (const item of errors) {\n const codeStr = showCodes ? ` [${item.code}]` : '';\n lines.push(` ERROR${codeStr}: ${item.message}`);\n if (item.suggestion) {\n lines.push(` 💡 Suggestion: ${item.suggestion}`);\n }\n }\n }\n\n if (warnings.length > 0) {\n lines.push(` ⚠️ ${action}:`);\n for (const item of warnings) {\n const codeStr = showCodes ? ` [${item.code}]` : '';\n lines.push(` ${codeStr ? `${item.code}: ` : ''}${item.message}`);\n if (item.suggestion) {\n lines.push(` 💡 ${item.suggestion}`);\n }\n }\n }\n\n if (showNotes && notes.length > 0) {\n lines.push(` ℹ️ ${action}:`);\n for (const item of notes) {\n const codeStr = showCodes ? ` [${item.code}]` : '';\n lines.push(` ${codeStr ? `${item.code}: ` : ''}${item.message}`);\n }\n }\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Get validation statistics.\n */\nexport function getValidationStats(validations: Map<string, SchemaValidationResult>): {\n totalCommands: number;\n errors: number;\n warnings: number;\n notes: number;\n byCode: Record<string, number>;\n} {\n let errors = 0;\n let warnings = 0;\n let notes = 0;\n const byCode: Record<string, number> = {};\n\n for (const result of validations.values()) {\n for (const item of result.items) {\n if (item.severity === 'error') errors++;\n else if (item.severity === 'warning') warnings++;\n else if (item.severity === 'note') notes++;\n\n byCode[item.code] = (byCode[item.code] || 0) + 1;\n }\n }\n\n return {\n totalCommands: validations.size,\n errors,\n warnings,\n notes,\n byCode,\n };\n}\n","/**\n * Language Registry\n *\n * Central registration point for language support in the semantic parser.\n * Languages self-register when their modules are imported, enabling\n * tree-shaking for minimal bundles.\n *\n * @example\n * ```typescript\n * // Import only the languages you need\n * import '@lokascript/semantic/languages/en';\n * import '@lokascript/semantic/languages/es';\n *\n * // Now parse works for registered languages\n * import { parse } from '@lokascript/semantic';\n * parse('toggle .active', 'en'); // Works\n * parse('alternar .activo', 'es'); // Works\n * parse('切り替え .active', 'ja'); // Error: Language not registered\n * ```\n */\n\nimport type { LanguageTokenizer, LanguagePattern, TokenStream } from './types';\n\n// Re-export profile types from generators for convenience\nexport type {\n LanguageProfile,\n WordOrder,\n MarkingStrategy,\n RoleMarker,\n VerbConfig,\n PossessiveConfig,\n KeywordTranslation,\n TokenizationConfig,\n} from './generators/language-profiles';\n\nimport type { LanguageProfile } from './generators/language-profiles';\n\n// =============================================================================\n// External Pattern Source Interface\n// =============================================================================\n\n/**\n * Interface for external pattern sources (e.g., @lokascript/patterns-reference database).\n * External sources can provide additional patterns at runtime.\n */\nexport interface ExternalPatternsSource {\n /** Unique identifier for the source */\n id: string;\n /** Human-readable name */\n name: string;\n /** Get patterns for a specific language */\n getPatternsForLanguage(language: string): Promise<ExternalPatternEntry[]>;\n /** Get patterns for a specific command */\n getPatternsForCommand(command: string, language?: string): Promise<ExternalPatternEntry[]>;\n /** Check if source has patterns for a language */\n hasPatterns(language: string): Promise<boolean>;\n /** Get all supported languages */\n getSupportedLanguages(): Promise<string[]>;\n}\n\n/**\n * Pattern entry from external source.\n */\nexport interface ExternalPatternEntry {\n id: string;\n code: string;\n command: string | null;\n language: string;\n confidence: number;\n verified: boolean;\n title?: string;\n category?: string;\n}\n\n// =============================================================================\n// Registry State\n// =============================================================================\n\nconst tokenizers = new Map<string, LanguageTokenizer>();\nconst profiles = new Map<string, LanguageProfile>();\nconst patternCache = new Map<string, LanguagePattern[]>();\n\n// External pattern sources (e.g., @lokascript/patterns-reference database)\nconst externalSources = new Map<string, ExternalPatternsSource>();\n\n// Pattern generator function - set by patterns module to avoid circular deps\nlet patternGenerator: ((profile: LanguageProfile) => LanguagePattern[]) | null = null;\n\n// =============================================================================\n// Profile Inheritance\n// =============================================================================\n\n/**\n * Deep merge two objects, with variant values overriding base values.\n * Arrays are replaced, not merged.\n */\nfunction deepMerge<T extends object>(base: T, variant: Partial<T>): T {\n const result = { ...base } as T;\n\n for (const key of Object.keys(variant) as (keyof T)[]) {\n const variantValue = variant[key];\n const baseValue = base[key];\n\n if (variantValue === undefined) {\n continue;\n }\n\n // If both are objects (but not arrays), merge recursively\n if (\n typeof variantValue === 'object' &&\n variantValue !== null &&\n !Array.isArray(variantValue) &&\n typeof baseValue === 'object' &&\n baseValue !== null &&\n !Array.isArray(baseValue)\n ) {\n result[key] = deepMerge(\n baseValue as object,\n variantValue as Partial<typeof baseValue>\n ) as T[keyof T];\n } else {\n // Replace value (including arrays)\n result[key] = variantValue as T[keyof T];\n }\n }\n\n return result;\n}\n\n/**\n * Merge a variant profile with its base profile.\n * The variant's fields override the base, with deep merging for nested objects.\n *\n * @example\n * ```typescript\n * const esMX = mergeProfiles(spanishProfile, {\n * code: 'es-MX',\n * name: 'Spanish (Mexico)',\n * keywords: {\n * toggle: { primary: 'alternar', alternatives: ['dale', 'cambiar'] },\n * },\n * });\n * ```\n */\nexport function mergeProfiles(\n base: LanguageProfile,\n variant: Partial<LanguageProfile>\n): LanguageProfile {\n return deepMerge(base, variant);\n}\n\n/**\n * Resolve a profile, applying inheritance if the profile has an `extends` field.\n * Returns the merged profile with base language properties inherited.\n */\nexport function resolveProfile(profile: LanguageProfile): LanguageProfile {\n if (!profile.extends) {\n return profile;\n }\n\n const baseProfile = profiles.get(profile.extends);\n if (!baseProfile) {\n console.warn(\n `[Registry] Profile '${profile.code}' extends '${profile.extends}' but base is not registered. ` +\n `Make sure to import the base language before the variant.`\n );\n return profile;\n }\n\n // Recursively resolve base profile (in case it also extends something)\n const resolvedBase = resolveProfile(baseProfile);\n\n // Merge, with variant overriding base\n return mergeProfiles(resolvedBase, profile);\n}\n\n// =============================================================================\n// Registration Functions\n// =============================================================================\n\n/**\n * Register a language with its tokenizer and profile.\n * Called automatically by language modules when imported.\n * If the profile has an `extends` field, it will inherit from the base profile.\n */\nexport function registerLanguage(\n code: string,\n tokenizer: LanguageTokenizer,\n profile: LanguageProfile\n): void {\n tokenizers.set(code, tokenizer);\n // Store the original profile (inheritance is resolved at query time)\n profiles.set(code, profile);\n // Clear pattern cache for this language if it was previously cached\n patternCache.delete(code);\n}\n\n/**\n * Register only a tokenizer (for backwards compatibility).\n */\nexport function registerTokenizer(tokenizer: LanguageTokenizer): void {\n tokenizers.set(tokenizer.language, tokenizer);\n}\n\n/**\n * Register only a profile (for backwards compatibility).\n */\nexport function registerProfile(profile: LanguageProfile): void {\n profiles.set(profile.code, profile);\n patternCache.delete(profile.code);\n}\n\n/**\n * Set the pattern generator function.\n * Called by patterns module to inject the generator without circular deps.\n */\nexport function setPatternGenerator(\n generator: (profile: LanguageProfile) => LanguagePattern[]\n): void {\n patternGenerator = generator;\n}\n\n// Direct pattern registration map (for tree-shaking)\nconst registeredPatterns = new Map<string, LanguagePattern[]>();\n\n/**\n * Register patterns directly for a language.\n * This enables tree-shaking by allowing each language module to register\n * only its own patterns.\n */\nexport function registerPatterns(code: string, patterns: LanguagePattern[]): void {\n registeredPatterns.set(code, patterns);\n // Clear cached patterns if any\n patternCache.delete(code);\n}\n\n/**\n * Check if patterns are directly registered for a language.\n */\nexport function hasRegisteredPatterns(code: string): boolean {\n return registeredPatterns.has(code);\n}\n\n/**\n * Get directly registered patterns for a language.\n */\nexport function getRegisteredPatterns(code: string): LanguagePattern[] | undefined {\n return registeredPatterns.get(code);\n}\n\n// =============================================================================\n// External Pattern Sources\n// =============================================================================\n\n/**\n * Register an external pattern source.\n * External sources (like @lokascript/patterns-reference) can provide\n * additional patterns at runtime.\n *\n * @example\n * ```typescript\n * import { registerPatternsSource } from '@lokascript/semantic';\n * import { createPatternsProvider } from '@lokascript/patterns-reference';\n *\n * const provider = createPatternsProvider();\n * registerPatternsSource(provider);\n * ```\n */\nexport function registerPatternsSource(source: ExternalPatternsSource): void {\n externalSources.set(source.id, source);\n}\n\n/**\n * Unregister an external pattern source.\n */\nexport function unregisterPatternsSource(sourceId: string): boolean {\n return externalSources.delete(sourceId);\n}\n\n/**\n * Get a registered external pattern source.\n */\nexport function getPatternsSource(sourceId: string): ExternalPatternsSource | undefined {\n return externalSources.get(sourceId);\n}\n\n/**\n * Get all registered external pattern sources.\n */\nexport function getAllPatternsSources(): ExternalPatternsSource[] {\n return Array.from(externalSources.values());\n}\n\n/**\n * Check if any external pattern sources are registered.\n */\nexport function hasExternalSources(): boolean {\n return externalSources.size > 0;\n}\n\n/**\n * Query patterns from all external sources for a language.\n * Returns patterns sorted by confidence.\n */\nexport async function queryExternalPatterns(language: string): Promise<ExternalPatternEntry[]> {\n if (externalSources.size === 0) {\n return [];\n }\n\n const allPatterns: ExternalPatternEntry[] = [];\n\n for (const source of externalSources.values()) {\n try {\n const patterns = await source.getPatternsForLanguage(language);\n allPatterns.push(...patterns);\n } catch (error) {\n console.warn(\n `[Registry] Failed to query patterns from ${source.name}:`,\n error instanceof Error ? error.message : String(error)\n );\n }\n }\n\n // Sort by confidence (highest first)\n return allPatterns.sort((a, b) => b.confidence - a.confidence);\n}\n\n/**\n * Query patterns from all external sources for a command.\n */\nexport async function queryExternalPatternsForCommand(\n command: string,\n language?: string\n): Promise<ExternalPatternEntry[]> {\n if (externalSources.size === 0) {\n return [];\n }\n\n const allPatterns: ExternalPatternEntry[] = [];\n\n for (const source of externalSources.values()) {\n try {\n const patterns = await source.getPatternsForCommand(command, language);\n allPatterns.push(...patterns);\n } catch (error) {\n console.warn(\n `[Registry] Failed to query patterns from ${source.name}:`,\n error instanceof Error ? error.message : String(error)\n );\n }\n }\n\n return allPatterns.sort((a, b) => b.confidence - a.confidence);\n}\n\n// =============================================================================\n// Language Code Utilities\n// =============================================================================\n\n/**\n * Extract the base language code from a BCP 47 tag.\n * Examples: 'es-MX' → 'es', 'pt-BR' → 'pt', 'en' → 'en'\n */\nexport function getBaseLanguageCode(code: string): string {\n return code.split('-')[0];\n}\n\n/**\n * Check if a code is a language variant (has region subtag).\n * Examples: 'es-MX' → true, 'pt' → false\n */\nexport function isLanguageVariant(code: string): boolean {\n return code.includes('-');\n}\n\n// =============================================================================\n// Query Functions\n// =============================================================================\n\n/**\n * Get a tokenizer for the specified language.\n * Supports fallback: if 'es-MX' is not registered, falls back to 'es'.\n * @throws Error if neither the variant nor base language is registered\n */\nexport function getTokenizer(code: string): LanguageTokenizer {\n // Try exact match first\n let tokenizer = tokenizers.get(code);\n\n // Fallback: es-MX → es\n if (!tokenizer && isLanguageVariant(code)) {\n const baseCode = getBaseLanguageCode(code);\n tokenizer = tokenizers.get(baseCode);\n }\n\n if (!tokenizer) {\n const registered = Array.from(tokenizers.keys()).join(', ');\n throw new Error(\n `Language '${code}' is not registered. ` +\n `Registered languages: ${registered || 'none'}. ` +\n `Import the language module first: import '@lokascript/semantic/languages/${code}';`\n );\n }\n return tokenizer;\n}\n\n/**\n * Get a profile for the specified language.\n * Supports fallback: if 'es-MX' is not registered, falls back to 'es'.\n * @throws Error if neither the variant nor base language is registered\n */\nexport function getProfile(code: string): LanguageProfile {\n // Try exact match first\n let profile = profiles.get(code);\n\n // Fallback: es-MX → es\n if (!profile && isLanguageVariant(code)) {\n const baseCode = getBaseLanguageCode(code);\n profile = profiles.get(baseCode);\n }\n\n if (!profile) {\n const registered = Array.from(profiles.keys()).join(', ');\n throw new Error(\n `Language profile '${code}' is not registered. ` +\n `Registered languages: ${registered || 'none'}. ` +\n `Import the language module first: import '@lokascript/semantic/languages/${code}';`\n );\n }\n\n // Resolve inheritance if profile extends another\n return resolveProfile(profile);\n}\n\n/**\n * Try to get a tokenizer, returning undefined if not registered.\n * Supports fallback: if 'es-MX' is not registered, falls back to 'es'.\n */\nexport function tryGetTokenizer(code: string): LanguageTokenizer | undefined {\n let tokenizer = tokenizers.get(code);\n if (!tokenizer && isLanguageVariant(code)) {\n tokenizer = tokenizers.get(getBaseLanguageCode(code));\n }\n return tokenizer;\n}\n\n/**\n * Try to get a profile, returning undefined if not registered.\n * Supports fallback: if 'es-MX' is not registered, falls back to 'es'.\n */\nexport function tryGetProfile(code: string): LanguageProfile | undefined {\n let profile = profiles.get(code);\n if (!profile && isLanguageVariant(code)) {\n profile = profiles.get(getBaseLanguageCode(code));\n }\n // Resolve inheritance if profile extends another\n return profile ? resolveProfile(profile) : undefined;\n}\n\n/**\n * Get all registered language codes.\n */\nexport function getRegisteredLanguages(): string[] {\n return Array.from(tokenizers.keys());\n}\n\n/**\n * Check if a language is registered (exact match or base language fallback).\n */\nexport function isLanguageRegistered(code: string): boolean {\n if (tokenizers.has(code) && profiles.has(code)) {\n return true;\n }\n // Check fallback for variants\n if (isLanguageVariant(code)) {\n const baseCode = getBaseLanguageCode(code);\n return tokenizers.has(baseCode) && profiles.has(baseCode);\n }\n return false;\n}\n\n/**\n * Check if a language is supported (exact match or base language fallback).\n * For backwards compatibility with tokenizers API.\n */\nexport function isLanguageSupported(code: string): boolean {\n if (tokenizers.has(code)) {\n return true;\n }\n // Check fallback for variants\n if (isLanguageVariant(code)) {\n return tokenizers.has(getBaseLanguageCode(code));\n }\n return false;\n}\n\n// =============================================================================\n// Tokenization\n// =============================================================================\n\n/**\n * Tokenize input in the specified language.\n * @throws Error if language is not registered\n */\nexport function tokenize(input: string, language: string): TokenStream {\n const tokenizer = getTokenizer(language);\n return tokenizer.tokenize(input);\n}\n\n// =============================================================================\n// Pattern Access (Lazy Generation)\n// =============================================================================\n\n/**\n * Get patterns for a specific language.\n * First checks for directly registered patterns (for tree-shaking),\n * then falls back to pattern generator.\n * Supports fallback: if 'es-MX' is not registered, falls back to 'es'.\n * @throws Error if language is not registered\n */\nexport function getPatternsForLanguage(code: string): LanguagePattern[] {\n // Check cache first (try exact, then base language)\n let cached = patternCache.get(code);\n if (!cached && isLanguageVariant(code)) {\n cached = patternCache.get(getBaseLanguageCode(code));\n }\n if (cached) {\n return cached;\n }\n\n // Check for directly registered patterns (tree-shakeable path)\n // Try exact match, then base language fallback\n let registered = registeredPatterns.get(code);\n if (!registered && isLanguageVariant(code)) {\n registered = registeredPatterns.get(getBaseLanguageCode(code));\n }\n if (registered) {\n patternCache.set(code, registered);\n return registered;\n }\n\n // Fall back to pattern generator\n if (!patternGenerator) {\n throw new Error(\n `No patterns registered for language '${code}'. ` +\n 'Either import the language module or set a pattern generator.'\n );\n }\n\n // Get profile (throws if not registered) - has built-in fallback\n const profile = getProfile(code);\n const patterns = patternGenerator(profile);\n patternCache.set(code, patterns);\n return patterns;\n}\n\n/**\n * Get patterns for a specific language and command.\n */\nexport function getPatternsForLanguageAndCommand(\n language: string,\n command: string\n): LanguagePattern[] {\n return getPatternsForLanguage(language)\n .filter(p => p.command === command)\n .sort((a, b) => b.priority - a.priority);\n}\n\n/**\n * Clear the pattern cache for a language (useful for testing).\n */\nexport function clearPatternCache(code?: string): void {\n if (code) {\n patternCache.delete(code);\n } else {\n patternCache.clear();\n }\n}\n\n// =============================================================================\n// Backwards Compatibility\n// =============================================================================\n\n/**\n * Get all profiles as a record (for backwards compatibility).\n * Note: Only returns registered profiles.\n */\nexport function getAllProfiles(): Record<string, LanguageProfile> {\n const result: Record<string, LanguageProfile> = {};\n for (const [code, profile] of profiles) {\n result[code] = profile;\n }\n return result;\n}\n\n/**\n * Get all tokenizers as a record (for backwards compatibility).\n * Note: Only returns registered tokenizers.\n */\nexport function getAllTokenizers(): Record<string, LanguageTokenizer> {\n const result: Record<string, LanguageTokenizer> = {};\n for (const [code, tokenizer] of tokenizers) {\n result[code] = tokenizer;\n }\n return result;\n}\n","/**\n * Base Tokenizer\n *\n * Provides the TokenStream implementation and shared tokenization utilities.\n * Language-specific tokenizers extend these base utilities.\n */\n\nimport type {\n LanguageToken,\n TokenKind,\n TokenStream,\n StreamMark,\n SourcePosition,\n LanguageTokenizer,\n} from '../types';\nimport type { MorphologicalNormalizer, NormalizationResult } from './morphology/types';\n\n// =============================================================================\n// Time Unit Configuration\n// =============================================================================\n\n/**\n * Configuration for a native language time unit pattern.\n * Used by tryNumberWithTimeUnits() to match language-specific time units.\n */\nexport interface TimeUnitMapping {\n /** The pattern to match (e.g., 'segundos', 'ミリ秒') */\n readonly pattern: string;\n /** The standard suffix to use (ms, s, m, h) */\n readonly suffix: string;\n /** Length of the pattern (for optimization) */\n readonly length: number;\n /** Whether to check for word boundary after the pattern */\n readonly checkBoundary?: boolean;\n /** Character that cannot follow the pattern (e.g., 's' for 'm' to avoid 'ms') */\n readonly notFollowedBy?: string;\n /** Whether to do case-insensitive matching */\n readonly caseInsensitive?: boolean;\n}\n\n// =============================================================================\n// Token Stream Implementation\n// =============================================================================\n\n/**\n * Concrete implementation of TokenStream.\n */\nexport class TokenStreamImpl implements TokenStream {\n readonly tokens: readonly LanguageToken[];\n readonly language: string;\n private pos: number = 0;\n\n constructor(tokens: LanguageToken[], language: string) {\n this.tokens = tokens;\n this.language = language;\n }\n\n peek(offset: number = 0): LanguageToken | null {\n const index = this.pos + offset;\n if (index < 0 || index >= this.tokens.length) {\n return null;\n }\n return this.tokens[index];\n }\n\n advance(): LanguageToken {\n if (this.isAtEnd()) {\n throw new Error('Unexpected end of token stream');\n }\n return this.tokens[this.pos++];\n }\n\n isAtEnd(): boolean {\n return this.pos >= this.tokens.length;\n }\n\n mark(): StreamMark {\n return { position: this.pos };\n }\n\n reset(mark: StreamMark): void {\n this.pos = mark.position;\n }\n\n position(): number {\n return this.pos;\n }\n\n /**\n * Get remaining tokens as an array.\n */\n remaining(): LanguageToken[] {\n return this.tokens.slice(this.pos);\n }\n\n /**\n * Consume tokens while predicate is true.\n */\n takeWhile(predicate: (token: LanguageToken) => boolean): LanguageToken[] {\n const result: LanguageToken[] = [];\n while (!this.isAtEnd() && predicate(this.peek()!)) {\n result.push(this.advance());\n }\n return result;\n }\n\n /**\n * Skip tokens while predicate is true.\n */\n skipWhile(predicate: (token: LanguageToken) => boolean): void {\n while (!this.isAtEnd() && predicate(this.peek()!)) {\n this.advance();\n }\n }\n}\n\n// =============================================================================\n// Shared Tokenization Utilities\n// =============================================================================\n\n/**\n * Create a source position from start and end offsets.\n */\nexport function createPosition(start: number, end: number): SourcePosition {\n return { start, end };\n}\n\n/**\n * Options for creating a token with optional morphological data.\n */\nexport interface CreateTokenOptions {\n /** Explicitly normalized form from keyword map */\n normalized?: string;\n /** Morphologically normalized stem */\n stem?: string;\n /** Confidence in the stem (0.0-1.0) */\n stemConfidence?: number;\n}\n\n/**\n * Create a language token.\n */\nexport function createToken(\n value: string,\n kind: TokenKind,\n position: SourcePosition,\n normalizedOrOptions?: string | CreateTokenOptions\n): LanguageToken {\n // Handle legacy string argument for backward compatibility\n if (typeof normalizedOrOptions === 'string') {\n return { value, kind, position, normalized: normalizedOrOptions };\n }\n\n // Handle options object\n if (normalizedOrOptions) {\n const { normalized, stem, stemConfidence } = normalizedOrOptions;\n const token: LanguageToken = { value, kind, position };\n\n // Build token with only defined properties\n if (normalized !== undefined) {\n (token as any).normalized = normalized;\n }\n if (stem !== undefined) {\n (token as any).stem = stem;\n if (stemConfidence !== undefined) {\n (token as any).stemConfidence = stemConfidence;\n }\n }\n\n return token;\n }\n\n return { value, kind, position };\n}\n\n/**\n * Check if a character is whitespace.\n */\nexport function isWhitespace(char: string): boolean {\n return /\\s/.test(char);\n}\n\n/**\n * Check if a string starts with a CSS selector prefix.\n * Includes JSX-style element selectors: <form />, <div>\n */\nexport function isSelectorStart(char: string): boolean {\n return (\n char === '#' || char === '.' || char === '[' || char === '@' || char === '*' || char === '<'\n );\n}\n\n/**\n * Check if a character is a quote (string delimiter).\n */\nexport function isQuote(char: string): boolean {\n return char === '\"' || char === \"'\" || char === '`' || char === '「' || char === '」';\n}\n\n/**\n * Check if a character is a digit.\n */\nexport function isDigit(char: string): boolean {\n return /\\d/.test(char);\n}\n\n/**\n * Check if a character is an ASCII letter.\n */\nexport function isAsciiLetter(char: string): boolean {\n return /[a-zA-Z]/.test(char);\n}\n\n/**\n * Check if a character is part of an ASCII identifier.\n */\nexport function isAsciiIdentifierChar(char: string): boolean {\n return /[a-zA-Z0-9_-]/.test(char);\n}\n\n// =============================================================================\n// Unicode Range Classification\n// =============================================================================\n\n/**\n * Unicode range tuple: [start, end] (inclusive).\n */\nexport type UnicodeRange = readonly [number, number];\n\n/**\n * Create a character classifier for Unicode ranges.\n * Returns a function that checks if a character's code point falls within any of the ranges.\n *\n * @example\n * // Japanese Hiragana\n * const isHiragana = createUnicodeRangeClassifier([[0x3040, 0x309f]]);\n *\n * // Korean (Hangul syllables + Jamo)\n * const isKorean = createUnicodeRangeClassifier([\n * [0xac00, 0xd7a3], // Hangul syllables\n * [0x1100, 0x11ff], // Hangul Jamo\n * [0x3130, 0x318f], // Hangul Compatibility Jamo\n * ]);\n */\nexport function createUnicodeRangeClassifier(\n ranges: readonly UnicodeRange[]\n): (char: string) => boolean {\n return (char: string): boolean => {\n const code = char.charCodeAt(0);\n return ranges.some(([start, end]) => code >= start && code <= end);\n };\n}\n\n/**\n * Combine multiple character classifiers into one.\n * Returns true if any of the classifiers return true.\n *\n * @example\n * const isJapanese = combineClassifiers(isHiragana, isKatakana, isKanji);\n */\nexport function combineClassifiers(\n ...classifiers: Array<(char: string) => boolean>\n): (char: string) => boolean {\n return (char: string): boolean => classifiers.some(fn => fn(char));\n}\n\n/**\n * Character classifiers for a Latin-based language.\n */\nexport interface LatinCharClassifiers {\n /** Check if character is a letter in this language (including accented chars). */\n isLetter: (char: string) => boolean;\n /** Check if character is part of an identifier (letter, digit, underscore, hyphen). */\n isIdentifierChar: (char: string) => boolean;\n}\n\n/**\n * Create character classifiers for a Latin-based language.\n * Returns isLetter and isIdentifierChar functions based on the provided regex.\n *\n * @example\n * // Spanish letters\n * const { isLetter, isIdentifierChar } = createLatinCharClassifiers(/[a-zA-ZáéíóúüñÁÉÍÓÚÜÑ]/);\n *\n * // German letters\n * const { isLetter, isIdentifierChar } = createLatinCharClassifiers(/[a-zA-ZäöüÄÖÜß]/);\n */\nexport function createLatinCharClassifiers(letterPattern: RegExp): LatinCharClassifiers {\n const isLetter = (char: string): boolean => letterPattern.test(char);\n const isIdentifierChar = (char: string): boolean => isLetter(char) || /[0-9_-]/.test(char);\n return { isLetter, isIdentifierChar };\n}\n\n// =============================================================================\n// CSS Selector Tokenization\n// =============================================================================\n\n/**\n * Extract a CSS selector from the input string starting at pos.\n * CSS selectors are universal across languages.\n *\n * Supported formats:\n * - #id\n * - .class\n * - [attribute]\n * - [attribute=value]\n * - @attribute (shorthand)\n * - *property (CSS property shorthand)\n * - Complex selectors with combinators (limited)\n *\n * Method call handling:\n * - #dialog.showModal() → stops after #dialog (method call, not compound selector)\n * - #box.active → compound selector (no parens)\n */\nexport function extractCssSelector(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const char = input[startPos];\n if (!isSelectorStart(char)) return null;\n\n let pos = startPos;\n let selector = '';\n\n // Handle different selector types\n if (char === '#' || char === '.') {\n // ID or class selector: #id, .class\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n // Must have at least one character after prefix\n if (selector.length <= 1) return null;\n\n // Check for method call pattern: #id.method() or .class.method()\n // If we see .identifier followed by (, don't consume it - it's a method call\n if (pos < input.length && input[pos] === '.' && char === '#') {\n // Look ahead to see if this is a method call\n const methodStart = pos + 1;\n let methodEnd = methodStart;\n while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {\n methodEnd++;\n }\n // If followed by (, it's a method call - stop here\n if (methodEnd < input.length && input[methodEnd] === '(') {\n return selector;\n }\n }\n } else if (char === '[') {\n // Attribute selector: [attr] or [attr=value] or [attr=\"value\"]\n // Need to track quote state to avoid counting brackets inside quotes\n let depth = 1;\n let inQuote = false;\n let quoteChar: string | null = null;\n let escaped = false;\n\n selector += input[pos++]; // [\n\n while (pos < input.length && depth > 0) {\n const c = input[pos];\n selector += c;\n\n if (escaped) {\n // Skip escaped character\n escaped = false;\n } else if (c === '\\\\') {\n // Next character is escaped\n escaped = true;\n } else if (inQuote) {\n // Inside a quoted string\n if (c === quoteChar) {\n inQuote = false;\n quoteChar = null;\n }\n } else {\n // Not inside a quoted string\n if (c === '\"' || c === \"'\" || c === '`') {\n inQuote = true;\n quoteChar = c;\n } else if (c === '[') {\n depth++;\n } else if (c === ']') {\n depth--;\n }\n }\n pos++;\n }\n if (depth !== 0) return null;\n } else if (char === '@') {\n // Attribute shorthand: @disabled\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n if (selector.length <= 1) return null;\n } else if (char === '*') {\n // CSS property shorthand: *display\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n if (selector.length <= 1) return null;\n } else if (char === '<') {\n // HTML literal selector with optional modifiers and attributes:\n // - <div>\n // - <div.class>\n // - <div#id>\n // - <div.class#id>\n // - <button[disabled]/>\n // - <div.card/>\n // - <div.class#id[attr=\"value\"]/>\n selector += input[pos++]; // <\n\n // Must be followed by an identifier (tag name)\n if (pos >= input.length || !isAsciiLetter(input[pos])) return null;\n\n // Extract tag name\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n\n // Process modifiers and attributes\n // Can have multiple .class, one #id, and multiple [attr] in any order\n while (pos < input.length) {\n const modChar = input[pos];\n\n if (modChar === '.') {\n // Class modifier\n selector += input[pos++]; // .\n if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {\n return null; // Invalid - class name required after .\n }\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n } else if (modChar === '#') {\n // ID modifier\n selector += input[pos++]; // #\n if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {\n return null; // Invalid - ID required after #\n }\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n } else if (modChar === '[') {\n // Attribute modifier: [disabled] or [type=\"button\"]\n // Need to track quote state to avoid counting brackets inside quotes\n let depth = 1;\n let inQuote = false;\n let quoteChar: string | null = null;\n let escaped = false;\n\n selector += input[pos++]; // [\n\n while (pos < input.length && depth > 0) {\n const c = input[pos];\n selector += c;\n\n if (escaped) {\n escaped = false;\n } else if (c === '\\\\') {\n escaped = true;\n } else if (inQuote) {\n if (c === quoteChar) {\n inQuote = false;\n quoteChar = null;\n }\n } else {\n if (c === '\"' || c === \"'\" || c === '`') {\n inQuote = true;\n quoteChar = c;\n } else if (c === '[') {\n depth++;\n } else if (c === ']') {\n depth--;\n }\n }\n pos++;\n }\n if (depth !== 0) return null; // Unclosed bracket\n } else {\n // No more modifiers\n break;\n }\n }\n\n // Skip whitespace before optional self-closing /\n while (pos < input.length && isWhitespace(input[pos])) {\n selector += input[pos++];\n }\n\n // Optional self-closing /\n if (pos < input.length && input[pos] === '/') {\n selector += input[pos++];\n // Skip whitespace after /\n while (pos < input.length && isWhitespace(input[pos])) {\n selector += input[pos++];\n }\n }\n\n // Must end with >\n if (pos >= input.length || input[pos] !== '>') return null;\n selector += input[pos++]; // >\n }\n\n return selector || null;\n}\n\n// =============================================================================\n// String Literal Tokenization\n// =============================================================================\n\n/**\n * Check if a single quote at pos is a possessive marker ('s).\n * Returns true if this looks like possessive, not a string start.\n *\n * Examples:\n * - #element's *opacity → possessive (returns true)\n * - 'hello' → string (returns false)\n * - it's value → possessive (returns true)\n */\nexport function isPossessiveMarker(input: string, pos: number): boolean {\n if (pos >= input.length || input[pos] !== \"'\") return false;\n\n // Check if followed by 's' or 'S'\n if (pos + 1 >= input.length) return false;\n const nextChar = input[pos + 1].toLowerCase();\n if (nextChar !== 's') return false;\n\n // After 's, should be end, whitespace, or special char (not alphanumeric)\n if (pos + 2 >= input.length) return true; // end of input\n const afterS = input[pos + 2];\n return isWhitespace(afterS) || afterS === '*' || !isAsciiIdentifierChar(afterS);\n}\n\n/**\n * Extract a string literal from the input starting at pos.\n * Handles both ASCII quotes and Unicode quotes.\n *\n * Note: Single quotes that look like possessive markers ('s) are skipped.\n */\nexport function extractStringLiteral(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const openQuote = input[startPos];\n if (!isQuote(openQuote)) return null;\n\n // Check for possessive marker - don't treat as string\n if (openQuote === \"'\" && isPossessiveMarker(input, startPos)) {\n return null;\n }\n\n // Map opening quotes to closing quotes\n const closeQuoteMap: Record<string, string> = {\n '\"': '\"',\n \"'\": \"'\",\n '`': '`',\n '「': '」',\n };\n\n const closeQuote = closeQuoteMap[openQuote];\n if (!closeQuote) return null;\n\n let pos = startPos + 1;\n let literal = openQuote;\n let escaped = false;\n\n while (pos < input.length) {\n const char = input[pos];\n literal += char;\n\n if (escaped) {\n escaped = false;\n } else if (char === '\\\\') {\n escaped = true;\n } else if (char === closeQuote) {\n // Found closing quote\n return literal;\n }\n pos++;\n }\n\n // Unclosed string - return what we have\n return literal;\n}\n\n// =============================================================================\n// URL Tokenization\n// =============================================================================\n\n/**\n * Check if the input at position starts a URL.\n * Detects: /path, ./path, ../path, //domain.com, http://, https://\n */\nexport function isUrlStart(input: string, pos: number): boolean {\n if (pos >= input.length) return false;\n\n const char = input[pos];\n const next = input[pos + 1] || '';\n const third = input[pos + 2] || '';\n\n // Absolute path: /something (but not just /)\n // Must be followed by alphanumeric or path char, not another / (that's protocol-relative)\n if (char === '/' && next !== '/' && /[a-zA-Z0-9._-]/.test(next)) {\n return true;\n }\n\n // Protocol-relative: //domain.com\n if (char === '/' && next === '/' && /[a-zA-Z]/.test(third)) {\n return true;\n }\n\n // Relative path: ./ or ../\n if (char === '.' && (next === '/' || (next === '.' && third === '/'))) {\n return true;\n }\n\n // Full URL: http:// or https://\n const slice = input.slice(pos, pos + 8).toLowerCase();\n if (slice.startsWith('http://') || slice.startsWith('https://')) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Extract a URL from the input starting at pos.\n * Handles paths, query strings, and fragments.\n *\n * Fragment (#) handling:\n * - /page#section → includes fragment as part of URL\n * - #id alone → not a URL (CSS selector)\n */\nexport function extractUrl(input: string, startPos: number): string | null {\n if (!isUrlStart(input, startPos)) return null;\n\n let pos = startPos;\n let url = '';\n\n // Core URL characters (RFC 3986 unreserved + sub-delims + path/query chars)\n // Includes: letters, digits, and - . _ ~ : / ? # [ ] @ ! $ & ' ( ) * + , ; = %\n const urlChars = /[a-zA-Z0-9/:._\\-?&=%@+~!$'()*,;[\\]]/;\n\n while (pos < input.length) {\n const char = input[pos];\n\n // Special handling for #\n if (char === '#') {\n // Only include # if we have path content before it (it's a fragment)\n // If # appears at URL start or after certain chars, stop (might be CSS selector)\n if (url.length > 0 && /[a-zA-Z0-9/.]$/.test(url)) {\n // Include fragment\n url += char;\n pos++;\n // Consume fragment identifier (letters, digits, underscore, hyphen)\n while (pos < input.length && /[a-zA-Z0-9_-]/.test(input[pos])) {\n url += input[pos++];\n }\n }\n // Stop either way - fragment consumed or # is separate token\n break;\n }\n\n if (urlChars.test(char)) {\n url += char;\n pos++;\n } else {\n break;\n }\n }\n\n // Minimum length validation\n if (url.length < 2) return null;\n\n return url;\n}\n\n// =============================================================================\n// Number Tokenization\n// =============================================================================\n\n/**\n * Extract a number from the input starting at pos.\n * Handles integers and decimals.\n */\nexport function extractNumber(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const char = input[startPos];\n if (!isDigit(char) && char !== '-' && char !== '+') return null;\n\n let pos = startPos;\n let number = '';\n\n // Optional sign\n if (input[pos] === '-' || input[pos] === '+') {\n number += input[pos++];\n }\n\n // Must have at least one digit\n if (pos >= input.length || !isDigit(input[pos])) {\n return null;\n }\n\n // Integer part\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n\n // Optional decimal part\n if (pos < input.length && input[pos] === '.') {\n number += input[pos++];\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n }\n\n // Optional duration suffix (s, ms, m, h)\n if (pos < input.length) {\n const suffix = input.slice(pos, pos + 2);\n if (suffix === 'ms') {\n number += 'ms';\n } else if (input[pos] === 's' || input[pos] === 'm' || input[pos] === 'h') {\n number += input[pos];\n }\n }\n\n return number;\n}\n\n// =============================================================================\n// Base Tokenizer Class\n// =============================================================================\n\n/**\n * Keyword entry for tokenizer - maps native word to normalized English form.\n */\nexport interface KeywordEntry {\n readonly native: string;\n readonly normalized: string;\n}\n\n/**\n * Profile interface for keyword derivation.\n * Matches the structure of LanguageProfile but only includes fields needed for tokenization.\n */\nexport interface TokenizerProfile {\n readonly keywords?: Record<\n string,\n { primary: string; alternatives?: string[]; normalized?: string }\n >;\n readonly references?: Record<string, string>;\n readonly roleMarkers?: Record<\n string,\n { primary: string; alternatives?: string[]; position?: string }\n >;\n}\n\n/**\n * Abstract base class for language-specific tokenizers.\n * Provides common functionality for CSS selectors, strings, and numbers.\n */\nexport abstract class BaseTokenizer implements LanguageTokenizer {\n abstract readonly language: string;\n abstract readonly direction: 'ltr' | 'rtl';\n\n /** Optional morphological normalizer for this language */\n protected normalizer?: MorphologicalNormalizer;\n\n /** Keywords derived from profile, sorted longest-first for greedy matching */\n protected profileKeywords: KeywordEntry[] = [];\n\n /** Map for O(1) keyword lookups by lowercase native word */\n protected profileKeywordMap: Map<string, KeywordEntry> = new Map();\n\n abstract tokenize(input: string): TokenStream;\n abstract classifyToken(token: string): TokenKind;\n\n /**\n * Initialize keyword mappings from a language profile.\n * Builds a list of native→english mappings from:\n * - profile.keywords (primary + alternatives)\n * - profile.references (me, it, you, etc.)\n * - profile.roleMarkers (into, from, with, etc.)\n *\n * Results are sorted longest-first for greedy matching (important for non-space languages).\n * Extras take precedence over profile entries when there are duplicates.\n *\n * @param profile - Language profile containing keyword translations\n * @param extras - Additional keyword entries to include (literals, positional, events)\n */\n protected initializeKeywordsFromProfile(\n profile: TokenizerProfile,\n extras: KeywordEntry[] = []\n ): void {\n // Use a Map to deduplicate, with extras taking precedence\n const keywordMap = new Map<string, KeywordEntry>();\n\n // Extract from keywords (command translations)\n if (profile.keywords) {\n for (const [normalized, translation] of Object.entries(profile.keywords)) {\n // Primary translation\n keywordMap.set(translation.primary, {\n native: translation.primary,\n normalized: translation.normalized || normalized,\n });\n\n // Alternative forms\n if (translation.alternatives) {\n for (const alt of translation.alternatives) {\n keywordMap.set(alt, {\n native: alt,\n normalized: translation.normalized || normalized,\n });\n }\n }\n }\n }\n\n // Extract from references (me, it, you, etc.)\n if (profile.references) {\n for (const [normalized, native] of Object.entries(profile.references)) {\n keywordMap.set(native, { native, normalized });\n }\n }\n\n // Extract from roleMarkers (into, from, with, etc.)\n if (profile.roleMarkers) {\n for (const [role, marker] of Object.entries(profile.roleMarkers)) {\n if (marker.primary) {\n keywordMap.set(marker.primary, { native: marker.primary, normalized: role });\n }\n if (marker.alternatives) {\n for (const alt of marker.alternatives) {\n keywordMap.set(alt, { native: alt, normalized: role });\n }\n }\n }\n }\n\n // Add extra entries (literals, positional, events) - these OVERRIDE profile entries\n for (const extra of extras) {\n keywordMap.set(extra.native, extra);\n }\n\n // Convert to array and sort longest-first for greedy matching\n this.profileKeywords = Array.from(keywordMap.values()).sort(\n (a, b) => b.native.length - a.native.length\n );\n\n // Build Map for O(1) lookups (case-insensitive + diacritic-insensitive)\n // This allows matching both 'بدّل' (with shadda) and 'بدل' (without) to the same entry\n this.profileKeywordMap = new Map();\n for (const keyword of this.profileKeywords) {\n // Add original form (with diacritics if present)\n this.profileKeywordMap.set(keyword.native.toLowerCase(), keyword);\n\n // Add diacritic-normalized form (for Arabic, Turkish, etc.)\n const normalized = this.removeDiacritics(keyword.native);\n if (normalized !== keyword.native && !this.profileKeywordMap.has(normalized.toLowerCase())) {\n this.profileKeywordMap.set(normalized.toLowerCase(), keyword);\n }\n }\n }\n\n /**\n * Remove diacritical marks from a word for normalization.\n * Primarily for Arabic (shadda, fatha, kasra, damma, sukun, etc.)\n * but could be extended for other languages.\n *\n * @param word - Word to normalize\n * @returns Word without diacritics\n */\n protected removeDiacritics(word: string): string {\n // Arabic diacritics: U+064B-U+0652 (fatha, kasra, damma, sukun, shadda, etc.)\n // U+0670 (superscript alif)\n return word.replace(/[\\u064B-\\u0652\\u0670]/g, '');\n }\n\n /**\n * Try to match a keyword from profile at the current position.\n * Uses longest-first greedy matching (important for non-space languages).\n *\n * @param input - Input string\n * @param pos - Current position\n * @returns Token if matched, null otherwise\n */\n protected tryProfileKeyword(input: string, pos: number): LanguageToken | null {\n for (const entry of this.profileKeywords) {\n if (input.slice(pos).startsWith(entry.native)) {\n return createToken(\n entry.native,\n 'keyword',\n createPosition(pos, pos + entry.native.length),\n entry.normalized\n );\n }\n }\n return null;\n }\n\n /**\n * Check if the remaining input starts with any known keyword.\n * Useful for non-space languages to detect word boundaries.\n *\n * @param input - Input string\n * @param pos - Current position\n * @returns true if a keyword starts at this position\n */\n protected isKeywordStart(input: string, pos: number): boolean {\n const remaining = input.slice(pos);\n return this.profileKeywords.some(entry => remaining.startsWith(entry.native));\n }\n\n /**\n * Look up a keyword by native word (case-insensitive).\n * O(1) lookup using the keyword map.\n *\n * @param native - Native word to look up\n * @returns KeywordEntry if found, undefined otherwise\n */\n protected lookupKeyword(native: string): KeywordEntry | undefined {\n return this.profileKeywordMap.get(native.toLowerCase());\n }\n\n /**\n * Check if a word is a known keyword (case-insensitive).\n * O(1) lookup using the keyword map.\n *\n * @param native - Native word to check\n * @returns true if the word is a keyword\n */\n protected isKeyword(native: string): boolean {\n return this.profileKeywordMap.has(native.toLowerCase());\n }\n\n /**\n * Set the morphological normalizer for this tokenizer.\n */\n setNormalizer(normalizer: MorphologicalNormalizer): void {\n this.normalizer = normalizer;\n }\n\n /**\n * Try to normalize a word using the morphological normalizer.\n * Returns null if no normalizer is set or normalization fails.\n *\n * Note: We don't check isNormalizable() here because the individual tokenizers\n * historically called normalize() directly without that check. The normalize()\n * method itself handles returning noChange() for words that can't be normalized.\n */\n protected tryNormalize(word: string): NormalizationResult | null {\n if (!this.normalizer) return null;\n\n const result = this.normalizer.normalize(word);\n\n // Only return if actually normalized (stem differs from input)\n if (result.stem !== word && result.confidence >= 0.7) {\n return result;\n }\n\n return null;\n }\n\n /**\n * Try morphological normalization and keyword lookup.\n *\n * If the word can be normalized to a stem that matches a known keyword,\n * returns a keyword token with morphological metadata (stem, stemConfidence).\n *\n * This is the common pattern for handling conjugated verbs across languages:\n * 1. Normalize the word (e.g., \"toggled\" → \"toggle\")\n * 2. Look up the stem in the keyword map\n * 3. Create a token with both the original form and stem metadata\n *\n * @param word - The word to normalize and look up\n * @param startPos - Start position for the token\n * @param endPos - End position for the token\n * @returns Token if stem matches a keyword, null otherwise\n */\n protected tryMorphKeywordMatch(\n word: string,\n startPos: number,\n endPos: number\n ): LanguageToken | null {\n const result = this.tryNormalize(word);\n if (!result) return null;\n\n // Check if the stem is a known keyword\n const stemEntry = this.lookupKeyword(result.stem);\n if (!stemEntry) return null;\n\n const tokenOptions: CreateTokenOptions = {\n normalized: stemEntry.normalized,\n stem: result.stem,\n stemConfidence: result.confidence,\n };\n return createToken(word, 'keyword', createPosition(startPos, endPos), tokenOptions);\n }\n\n /**\n * Try to extract a CSS selector at the current position.\n */\n protected trySelector(input: string, pos: number): LanguageToken | null {\n const selector = extractCssSelector(input, pos);\n if (selector) {\n return createToken(selector, 'selector', createPosition(pos, pos + selector.length));\n }\n return null;\n }\n\n /**\n * Try to extract an event modifier at the current position.\n * Event modifiers are .once, .debounce(N), .throttle(N), .queue(strategy)\n */\n protected tryEventModifier(input: string, pos: number): LanguageToken | null {\n // Must start with a dot\n if (input[pos] !== '.') {\n return null;\n }\n\n // Match pattern: .(once|debounce|throttle|queue) followed by optional (value)\n const match = input\n .slice(pos)\n .match(/^\\.(?:once|debounce|throttle|queue)(?:\\(([^)]+)\\))?(?:\\s|$|\\.)/);\n if (!match) {\n return null;\n }\n\n const fullMatch = match[0].replace(/(\\s|\\.)$/, ''); // Remove trailing space or dot\n const modifierName = fullMatch.slice(1).split('(')[0]; // Extract modifier name\n const value = match[1]; // Extract value from parentheses if present\n\n // Create token with metadata\n const token = createToken(\n fullMatch,\n 'event-modifier',\n createPosition(pos, pos + fullMatch.length)\n );\n\n // Add metadata for the modifier\n return {\n ...token,\n metadata: {\n modifierName,\n value: value ? (modifierName === 'queue' ? value : parseInt(value, 10)) : undefined,\n },\n };\n }\n\n /**\n * Try to extract a string literal at the current position.\n */\n protected tryString(input: string, pos: number): LanguageToken | null {\n const literal = extractStringLiteral(input, pos);\n if (literal) {\n return createToken(literal, 'literal', createPosition(pos, pos + literal.length));\n }\n return null;\n }\n\n /**\n * Try to extract a number at the current position.\n */\n protected tryNumber(input: string, pos: number): LanguageToken | null {\n const number = extractNumber(input, pos);\n if (number) {\n return createToken(number, 'literal', createPosition(pos, pos + number.length));\n }\n return null;\n }\n\n /**\n * Configuration for native language time units.\n * Maps patterns to their standard suffix (ms, s, m, h).\n */\n protected static readonly STANDARD_TIME_UNITS: readonly TimeUnitMapping[] = [\n { pattern: 'ms', suffix: 'ms', length: 2 },\n { pattern: 's', suffix: 's', length: 1, checkBoundary: true },\n { pattern: 'm', suffix: 'm', length: 1, checkBoundary: true, notFollowedBy: 's' },\n { pattern: 'h', suffix: 'h', length: 1, checkBoundary: true },\n ];\n\n /**\n * Try to match a time unit from a list of patterns.\n *\n * @param input - Input string\n * @param pos - Position after the number\n * @param timeUnits - Array of time unit mappings (native pattern → standard suffix)\n * @param skipWhitespace - Whether to skip whitespace before time unit (default: false)\n * @returns Object with matched suffix and new position, or null if no match\n */\n protected tryMatchTimeUnit(\n input: string,\n pos: number,\n timeUnits: readonly TimeUnitMapping[],\n skipWhitespace = false\n ): { suffix: string; endPos: number } | null {\n let unitPos = pos;\n\n // Optionally skip whitespace before time unit\n if (skipWhitespace) {\n while (unitPos < input.length && isWhitespace(input[unitPos])) {\n unitPos++;\n }\n }\n\n const remaining = input.slice(unitPos);\n\n // Check each time unit pattern\n for (const unit of timeUnits) {\n const candidate = remaining.slice(0, unit.length);\n const matches = unit.caseInsensitive\n ? candidate.toLowerCase() === unit.pattern.toLowerCase()\n : candidate === unit.pattern;\n\n if (matches) {\n // Check notFollowedBy constraint (e.g., 'm' should not match 'ms')\n if (unit.notFollowedBy) {\n const nextChar = remaining[unit.length] || '';\n if (nextChar === unit.notFollowedBy) continue;\n }\n\n // Check word boundary if required\n if (unit.checkBoundary) {\n const nextChar = remaining[unit.length] || '';\n if (isAsciiIdentifierChar(nextChar)) continue;\n }\n\n return { suffix: unit.suffix, endPos: unitPos + unit.length };\n }\n }\n\n return null;\n }\n\n /**\n * Parse a base number (sign, integer, decimal) without time units.\n * Returns the number string and end position.\n *\n * @param input - Input string\n * @param startPos - Start position\n * @param allowSign - Whether to allow +/- sign (default: true)\n * @returns Object with number string and end position, or null\n */\n protected parseBaseNumber(\n input: string,\n startPos: number,\n allowSign = true\n ): { number: string; endPos: number } | null {\n let pos = startPos;\n let number = '';\n\n // Optional sign\n if (allowSign && (input[pos] === '-' || input[pos] === '+')) {\n number += input[pos++];\n }\n\n // Must have at least one digit\n if (pos >= input.length || !isDigit(input[pos])) {\n return null;\n }\n\n // Integer part\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n\n // Optional decimal\n if (pos < input.length && input[pos] === '.') {\n number += input[pos++];\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n }\n\n if (!number || number === '-' || number === '+') return null;\n\n return { number, endPos: pos };\n }\n\n /**\n * Try to extract a number with native language time units.\n *\n * This is a template method that handles the common pattern:\n * 1. Parse the base number (sign, integer, decimal)\n * 2. Try to match native language time units\n * 3. Fall back to standard time units (ms, s, m, h)\n *\n * @param input - Input string\n * @param pos - Start position\n * @param nativeTimeUnits - Language-specific time unit mappings\n * @param options - Configuration options\n * @returns Token if number found, null otherwise\n */\n protected tryNumberWithTimeUnits(\n input: string,\n pos: number,\n nativeTimeUnits: readonly TimeUnitMapping[],\n options: { allowSign?: boolean; skipWhitespace?: boolean } = {}\n ): LanguageToken | null {\n const { allowSign = true, skipWhitespace = false } = options;\n\n // Parse base number\n const baseResult = this.parseBaseNumber(input, pos, allowSign);\n if (!baseResult) return null;\n\n let { number, endPos } = baseResult;\n\n // Try native time units first, then standard\n const allUnits = [...nativeTimeUnits, ...BaseTokenizer.STANDARD_TIME_UNITS];\n const timeMatch = this.tryMatchTimeUnit(input, endPos, allUnits, skipWhitespace);\n\n if (timeMatch) {\n number += timeMatch.suffix;\n endPos = timeMatch.endPos;\n }\n\n return createToken(number, 'literal', createPosition(pos, endPos));\n }\n\n /**\n * Try to extract a URL at the current position.\n * Handles /path, ./path, ../path, //domain.com, http://, https://\n */\n protected tryUrl(input: string, pos: number): LanguageToken | null {\n const url = extractUrl(input, pos);\n if (url) {\n return createToken(url, 'url', createPosition(pos, pos + url.length));\n }\n return null;\n }\n\n /**\n * Try to extract a variable reference (:varname) at the current position.\n * In hyperscript, :x refers to a local variable named x.\n */\n protected tryVariableRef(input: string, pos: number): LanguageToken | null {\n if (input[pos] !== ':') return null;\n if (pos + 1 >= input.length) return null;\n if (!isAsciiIdentifierChar(input[pos + 1])) return null;\n\n let endPos = pos + 1;\n while (endPos < input.length && isAsciiIdentifierChar(input[endPos])) {\n endPos++;\n }\n\n const varRef = input.slice(pos, endPos);\n return createToken(varRef, 'identifier', createPosition(pos, endPos));\n }\n\n /**\n * Try to extract an operator or punctuation token at the current position.\n * Handles two-character operators (==, !=, etc.) and single-character operators.\n */\n protected tryOperator(input: string, pos: number): LanguageToken | null {\n // Two-character operators\n const twoChar = input.slice(pos, pos + 2);\n if (['==', '!=', '<=', '>=', '&&', '||', '->'].includes(twoChar)) {\n return createToken(twoChar, 'operator', createPosition(pos, pos + 2));\n }\n\n // Single-character operators\n const oneChar = input[pos];\n if (['<', '>', '!', '+', '-', '*', '/', '='].includes(oneChar)) {\n return createToken(oneChar, 'operator', createPosition(pos, pos + 1));\n }\n\n // Punctuation\n if (['(', ')', '{', '}', ',', ';', ':'].includes(oneChar)) {\n return createToken(oneChar, 'punctuation', createPosition(pos, pos + 1));\n }\n\n return null;\n }\n\n /**\n * Try to match a multi-character particle from a list.\n *\n * Used by languages like Japanese, Korean, and Chinese that have\n * multi-character particles (e.g., Japanese から, まで, より).\n *\n * @param input - Input string\n * @param pos - Current position\n * @param particles - Array of multi-character particles to match\n * @returns Token if matched, null otherwise\n */\n protected tryMultiCharParticle(\n input: string,\n pos: number,\n particles: readonly string[]\n ): LanguageToken | null {\n for (const particle of particles) {\n if (input.slice(pos, pos + particle.length) === particle) {\n return createToken(particle, 'particle', createPosition(pos, pos + particle.length));\n }\n }\n return null;\n }\n}\n","/**\n * English Language Profile\n *\n * SVO word order, prepositions, space-separated.\n */\n\nimport type { LanguageProfile } from './types';\n\nexport const englishProfile: LanguageProfile = {\n code: 'en',\n name: 'English',\n nativeName: 'English',\n direction: 'ltr',\n wordOrder: 'SVO',\n markingStrategy: 'preposition',\n usesSpaces: true,\n // English infinitive and imperative are identical (\"toggle\", \"save\", \"open\")\n defaultVerbForm: 'base',\n verb: {\n position: 'start',\n subjectDrop: false,\n },\n references: {\n me: 'me',\n it: 'it',\n you: 'you',\n result: 'result',\n event: 'event',\n target: 'target',\n body: 'body',\n },\n possessive: {\n marker: \"'s\",\n markerPosition: 'after-object',\n specialForms: {\n me: 'my',\n it: 'its',\n you: 'your',\n },\n keywords: {\n my: 'me',\n your: 'you',\n its: 'it',\n },\n },\n roleMarkers: {\n destination: { primary: 'on', alternatives: ['to', 'from'], position: 'before' },\n source: { primary: 'from', position: 'before' },\n patient: { primary: '', position: 'before' },\n style: { primary: 'with', alternatives: ['by', 'using'], position: 'before' },\n responseType: { primary: 'as', position: 'before' },\n method: { primary: 'via', alternatives: ['using'], position: 'before' },\n },\n keywords: {\n toggle: { primary: 'toggle' },\n add: { primary: 'add' },\n remove: { primary: 'remove' },\n put: { primary: 'put' },\n append: { primary: 'append' },\n prepend: { primary: 'prepend' },\n take: { primary: 'take' },\n make: { primary: 'make' },\n clone: { primary: 'clone' },\n swap: { primary: 'swap' },\n morph: { primary: 'morph' },\n set: { primary: 'set' },\n get: { primary: 'get' },\n increment: { primary: 'increment' },\n decrement: { primary: 'decrement' },\n log: { primary: 'log' },\n show: { primary: 'show' },\n hide: { primary: 'hide' },\n transition: { primary: 'transition' },\n on: { primary: 'on' },\n trigger: { primary: 'trigger' },\n send: { primary: 'send' },\n focus: { primary: 'focus' },\n blur: { primary: 'blur' },\n go: { primary: 'go' },\n wait: { primary: 'wait' },\n fetch: { primary: 'fetch' },\n settle: { primary: 'settle' },\n if: { primary: 'if' },\n when: { primary: 'when', normalized: 'when' },\n where: { primary: 'where', normalized: 'where' },\n else: { primary: 'else' },\n repeat: { primary: 'repeat' },\n for: { primary: 'for' },\n while: { primary: 'while' },\n continue: { primary: 'continue' },\n halt: { primary: 'halt' },\n throw: { primary: 'throw' },\n call: { primary: 'call' },\n return: { primary: 'return' },\n then: { primary: 'then' },\n and: { primary: 'and' },\n end: { primary: 'end' },\n js: { primary: 'js' },\n async: { primary: 'async' },\n tell: { primary: 'tell' },\n default: { primary: 'default' },\n init: { primary: 'init' },\n behavior: { primary: 'behavior' },\n install: { primary: 'install' },\n measure: { primary: 'measure' },\n into: { primary: 'into' },\n before: { primary: 'before' },\n after: { primary: 'after' },\n until: { primary: 'until' },\n event: { primary: 'event' },\n from: { primary: 'from' },\n },\n};\n","/**\n * English Tokenizer\n *\n * Tokenizes English hyperscript input.\n * English uses space-separated words with prepositions.\n */\n\nimport type { LanguageToken, TokenKind, TokenStream } from '../types';\nimport {\n BaseTokenizer,\n TokenStreamImpl,\n createToken,\n createPosition,\n isWhitespace,\n isAsciiIdentifierChar,\n isSelectorStart,\n isQuote,\n isDigit,\n isUrlStart,\n isPossessiveMarker,\n type KeywordEntry,\n} from './base';\nimport { englishProfile } from '../generators/profiles/english';\n\n// =============================================================================\n// English Extras (keywords not in profile)\n// =============================================================================\n\n/**\n * Extra keywords not covered by the profile:\n * - Literals (true, false, null, undefined)\n * - Event names\n * - Positional words\n * - Prepositions/modifiers\n * - Articles\n * - Synonyms with normalized forms\n * - Swap strategies\n * - British spelling aliases\n */\nconst ENGLISH_EXTRAS: KeywordEntry[] = [\n // Values/Literals\n { native: 'true', normalized: 'true' },\n { native: 'false', normalized: 'false' },\n { native: 'null', normalized: 'null' },\n { native: 'undefined', normalized: 'undefined' },\n\n // Positional\n { native: 'first', normalized: 'first' },\n { native: 'last', normalized: 'last' },\n { native: 'next', normalized: 'next' },\n { native: 'previous', normalized: 'previous' },\n { native: 'closest', normalized: 'closest' },\n\n // Events\n { native: 'click', normalized: 'click' },\n { native: 'dblclick', normalized: 'dblclick' },\n { native: 'mousedown', normalized: 'mousedown' },\n { native: 'mouseup', normalized: 'mouseup' },\n { native: 'mouseover', normalized: 'mouseover' },\n { native: 'mouseout', normalized: 'mouseout' },\n { native: 'mouseenter', normalized: 'mouseenter' },\n { native: 'mouseleave', normalized: 'mouseleave' },\n { native: 'mousemove', normalized: 'mousemove' },\n { native: 'keydown', normalized: 'keydown' },\n { native: 'keyup', normalized: 'keyup' },\n { native: 'keypress', normalized: 'keypress' },\n { native: 'input', normalized: 'input' },\n { native: 'change', normalized: 'change' },\n { native: 'submit', normalized: 'submit' },\n { native: 'reset', normalized: 'reset' },\n { native: 'load', normalized: 'load' },\n { native: 'unload', normalized: 'unload' },\n { native: 'scroll', normalized: 'scroll' },\n { native: 'resize', normalized: 'resize' },\n { native: 'dragstart', normalized: 'dragstart' },\n { native: 'drag', normalized: 'drag' },\n { native: 'dragend', normalized: 'dragend' },\n { native: 'dragenter', normalized: 'dragenter' },\n { native: 'dragleave', normalized: 'dragleave' },\n { native: 'dragover', normalized: 'dragover' },\n { native: 'drop', normalized: 'drop' },\n { native: 'touchstart', normalized: 'touchstart' },\n { native: 'touchmove', normalized: 'touchmove' },\n { native: 'touchend', normalized: 'touchend' },\n { native: 'touchcancel', normalized: 'touchcancel' },\n\n // Prepositions/modifiers not in profile\n { native: 'in', normalized: 'in' },\n { native: 'to', normalized: 'to' },\n { native: 'at', normalized: 'at' },\n { native: 'by', normalized: 'by' },\n { native: 'with', normalized: 'with' },\n { native: 'without', normalized: 'without' },\n { native: 'of', normalized: 'of' },\n { native: 'as', normalized: 'as' },\n\n // Event handling keywords\n { native: 'every', normalized: 'every' },\n { native: 'upon', normalized: 'upon' },\n\n // Control flow helpers not in profile\n { native: 'unless', normalized: 'unless' },\n { native: 'forever', normalized: 'forever' },\n { native: 'times', normalized: 'times' },\n\n // Logical\n { native: 'and', normalized: 'and' },\n { native: 'or', normalized: 'or' },\n { native: 'not', normalized: 'not' },\n { native: 'is', normalized: 'is' },\n { native: 'exists', normalized: 'exists' },\n { native: 'empty', normalized: 'empty' },\n\n // References not in profile\n { native: 'my', normalized: 'my' },\n { native: 'your', normalized: 'your' },\n { native: 'its', normalized: 'its' },\n { native: 'the', normalized: 'the' },\n { native: 'a', normalized: 'a' },\n { native: 'an', normalized: 'an' },\n\n // Swap strategies\n { native: 'delete', normalized: 'delete' },\n { native: 'innerHTML', normalized: 'innerHTML' },\n { native: 'outerHTML', normalized: 'outerHTML' },\n { native: 'beforebegin', normalized: 'beforebegin' },\n { native: 'afterend', normalized: 'afterend' },\n { native: 'beforeend', normalized: 'beforeend' },\n { native: 'afterbegin', normalized: 'afterbegin' },\n\n // Command synonyms with normalized forms\n { native: 'flip', normalized: 'toggle' },\n { native: 'switch', normalized: 'toggle' },\n { native: 'increase', normalized: 'increment' },\n { native: 'decrease', normalized: 'decrement' },\n { native: 'display', normalized: 'show' },\n { native: 'reveal', normalized: 'show' },\n { native: 'conceal', normalized: 'hide' },\n\n // British spelling aliases\n { native: 'colour', normalized: 'color' },\n { native: 'grey', normalized: 'gray' },\n { native: 'centre', normalized: 'center' },\n { native: 'behaviour', normalized: 'behavior' },\n { native: 'initialise', normalized: 'initialize' },\n { native: 'favourite', normalized: 'favorite' },\n];\n\n// =============================================================================\n// English Tokenizer Implementation\n// =============================================================================\n\nexport class EnglishTokenizer extends BaseTokenizer {\n readonly language = 'en';\n readonly direction = 'ltr' as const;\n\n constructor() {\n super();\n // Initialize keywords from profile + extras (single source of truth)\n this.initializeKeywordsFromProfile(englishProfile, ENGLISH_EXTRAS);\n }\n\n tokenize(input: string): TokenStream {\n const tokens: LanguageToken[] = [];\n let pos = 0;\n\n while (pos < input.length) {\n // Skip whitespace\n if (isWhitespace(input[pos])) {\n pos++;\n continue;\n }\n\n // Try CSS selector first (highest priority)\n // But check if this is a property access or method call first\n if (isSelectorStart(input[pos])) {\n // Check for event modifier first (.once, .debounce(), etc.)\n const modifierToken = this.tryEventModifier(input, pos);\n if (modifierToken) {\n tokens.push(modifierToken);\n pos = modifierToken.position.end;\n continue;\n }\n\n // Check for property access pattern: identifier.identifier or identifier.method()\n // When the previous token is an identifier or keyword AND there's no whitespace,\n // treat . as property accessor. With whitespace (e.g., \"add .active\"), it's a selector.\n if (input[pos] === '.') {\n const lastToken = tokens[tokens.length - 1];\n // Property access requires NO whitespace between tokens (e.g., \"obj.prop\")\n // CSS selectors have whitespace (e.g., \"add .active\")\n const hasWhitespaceBefore = lastToken && lastToken.position.end < pos;\n const isPropertyAccess =\n lastToken &&\n !hasWhitespaceBefore &&\n (lastToken.kind === 'identifier' ||\n lastToken.kind === 'keyword' ||\n lastToken.kind === 'selector');\n\n if (isPropertyAccess) {\n // Tokenize . as property accessor\n tokens.push(createToken('.', 'operator', createPosition(pos, pos + 1)));\n pos++;\n continue;\n }\n\n // Check for method call pattern at start: .identifier(\n const methodStart = pos + 1;\n let methodEnd = methodStart;\n while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {\n methodEnd++;\n }\n // If followed by (, this is a method call, not a class selector\n if (methodEnd < input.length && input[methodEnd] === '(') {\n // Tokenize . as property accessor\n tokens.push(createToken('.', 'operator', createPosition(pos, pos + 1)));\n pos++;\n continue;\n }\n }\n\n const selectorToken = this.trySelector(input, pos);\n if (selectorToken) {\n tokens.push(selectorToken);\n pos = selectorToken.position.end;\n continue;\n }\n }\n\n // Try string literal (but not possessive markers)\n if (isQuote(input[pos])) {\n // Check for possessive 's marker first\n if (input[pos] === \"'\" && isPossessiveMarker(input, pos)) {\n // Tokenize 's as a possessive marker\n tokens.push(createToken(\"'s\", 'punctuation', createPosition(pos, pos + 2)));\n pos += 2;\n continue;\n }\n const stringToken = this.tryString(input, pos);\n if (stringToken) {\n tokens.push(stringToken);\n pos = stringToken.position.end;\n continue;\n }\n }\n\n // Try URL (/path, ./path, http://, etc.)\n if (isUrlStart(input, pos)) {\n const urlToken = this.tryUrl(input, pos);\n if (urlToken) {\n tokens.push(urlToken);\n pos = urlToken.position.end;\n continue;\n }\n }\n\n // Try number\n if (\n isDigit(input[pos]) ||\n (input[pos] === '-' && pos + 1 < input.length && isDigit(input[pos + 1]))\n ) {\n const numberToken = this.tryNumber(input, pos);\n if (numberToken) {\n tokens.push(numberToken);\n pos = numberToken.position.end;\n continue;\n }\n }\n\n // Try variable reference (:varname)\n const varToken = this.tryVariableRef(input, pos);\n if (varToken) {\n tokens.push(varToken);\n pos = varToken.position.end;\n continue;\n }\n\n // Try word (identifier or keyword)\n if (isAsciiIdentifierChar(input[pos])) {\n const wordToken = this.extractWord(input, pos);\n if (wordToken) {\n tokens.push(wordToken);\n pos = wordToken.position.end;\n continue;\n }\n }\n\n // Try operator\n const operatorToken = this.tryOperator(input, pos);\n if (operatorToken) {\n tokens.push(operatorToken);\n pos = operatorToken.position.end;\n continue;\n }\n\n // Skip unknown character\n pos++;\n }\n\n return new TokenStreamImpl(tokens, 'en');\n }\n\n classifyToken(token: string): TokenKind {\n // O(1) Map lookup instead of O(n) array search\n if (this.isKeyword(token)) return 'keyword';\n if (token.startsWith('#') || token.startsWith('.') || token.startsWith('[')) return 'selector';\n if (token.startsWith('\"') || token.startsWith(\"'\")) return 'literal';\n if (/^\\d/.test(token)) return 'literal';\n if (['==', '!=', '<=', '>=', '<', '>', '&&', '||', '!'].includes(token)) return 'operator';\n if (token.startsWith('/') || token.startsWith('./') || token.startsWith('http')) return 'url';\n\n return 'identifier';\n }\n\n /**\n * Extract a word (identifier or keyword) from the input.\n * Handles namespaced event names like \"draggable:start\".\n */\n private extractWord(input: string, startPos: number): LanguageToken | null {\n let pos = startPos;\n let word = '';\n\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n word += input[pos++];\n }\n\n if (!word) return null;\n\n // Check for namespaced event name pattern: word:word (e.g., draggable:start)\n // This is different from variable references (:varname) which start with colon\n if (pos < input.length && input[pos] === ':') {\n const colonPos = pos;\n pos++; // consume colon\n let namespace = '';\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n namespace += input[pos++];\n }\n // Only treat as namespaced event if there's text after the colon\n if (namespace) {\n word = word + ':' + namespace;\n } else {\n // No text after colon, revert to just the word\n pos = colonPos;\n }\n }\n\n const kind = this.classifyToken(word);\n\n // O(1) Map lookup for normalized form (for synonyms like flip→toggle)\n const keywordEntry = this.lookupKeyword(word);\n const normalized =\n keywordEntry && keywordEntry.normalized !== keywordEntry.native\n ? keywordEntry.normalized\n : undefined;\n\n // Check for natural class syntax: \"{identifier} class\" → \".{identifier}\"\n // This allows \"toggle the active class\" to work like \"toggle the .active\"\n if (kind === 'identifier') {\n const classConversion = this.tryConvertToClassSelector(input, pos, word);\n if (classConversion) {\n return classConversion.token;\n }\n }\n\n return createToken(\n word,\n kind,\n createPosition(startPos, pos),\n normalized // Will be undefined if not a synonym, which is fine\n );\n }\n\n /**\n * Try to convert an identifier followed by \"class\" to a class selector.\n * E.g., \"active class\" → \".active\"\n *\n * This enables natural English syntax like:\n * - \"toggle the active class\" → \"toggle .active\"\n * - \"add the visible class\" → \"add .visible\"\n */\n private tryConvertToClassSelector(\n input: string,\n pos: number,\n word: string\n ): { token: LanguageToken; endPos: number } | null {\n let checkPos = pos;\n\n // Skip whitespace\n while (checkPos < input.length && /\\s/.test(input[checkPos])) {\n checkPos++;\n }\n\n // Check if next word is \"class\"\n if (input.slice(checkPos, checkPos + 5).toLowerCase() === 'class') {\n // Make sure \"class\" is a complete word (not \"className\" etc.)\n const afterClass = checkPos + 5;\n if (afterClass >= input.length || !isAsciiIdentifierChar(input[afterClass])) {\n // Convert to class selector\n const selectorValue = '.' + word;\n // Note: we DON'T consume \"class\" here - let the noise word handling in\n // pattern-matcher skip it. This keeps the token stream cleaner.\n return {\n token: createToken(selectorValue, 'selector', createPosition(pos - word.length, pos)),\n endPos: pos,\n };\n }\n }\n\n return null;\n }\n}\n\n/**\n * Singleton instance.\n */\nexport const englishTokenizer = new EnglishTokenizer();\n","/**\n * Command Schemas\n *\n * Defines the semantic structure of each hyperscript command.\n * Used by the pattern generator to create language-specific patterns.\n */\n\nimport type { SemanticRole, ActionType, SemanticValue } from '../types';\n\n// =============================================================================\n// Command Schema Types\n// =============================================================================\n\n/**\n * A role specification in a command schema.\n */\nexport interface RoleSpec {\n /** The semantic role */\n readonly role: SemanticRole;\n /** Description of what this role represents */\n readonly description: string;\n /** Whether this role is required */\n readonly required: boolean;\n /** Expected value types */\n readonly expectedTypes: Array<'selector' | 'literal' | 'reference' | 'expression'>;\n /** Default value if not provided */\n readonly default?: SemanticValue;\n /** Position hint for SVO languages (higher = earlier) */\n readonly svoPosition?: number;\n /** Position hint for SOV languages (higher = earlier) */\n readonly sovPosition?: number;\n /**\n * Override the default role marker for this command.\n * Maps language code to the marker to use (e.g., { en: 'to', es: 'a' }).\n * If not specified, uses the language profile's default roleMarker.\n */\n readonly markerOverride?: Record<string, string>;\n}\n\n/**\n * A precondition that must be met before command execution.\n * Used for runtime error documentation.\n */\nexport interface CommandPrecondition {\n /** Human-readable condition description */\n readonly condition: string;\n /** Error code thrown when precondition fails */\n readonly errorCode: string;\n /** Error message template */\n readonly message: string;\n}\n\n/**\n * A command schema defines the semantic structure of a command.\n */\nexport interface CommandSchema {\n /** The action type (command name) */\n readonly action: ActionType;\n /** Human-readable description */\n readonly description: string;\n /** Roles this command accepts */\n readonly roles: RoleSpec[];\n /** The primary role (what the command acts on) */\n readonly primaryRole: SemanticRole;\n /** Category for grouping */\n readonly category: CommandCategory;\n /** Whether this command typically has a body (like event handlers) */\n readonly hasBody?: boolean;\n /** Notes about special handling */\n readonly notes?: string;\n\n // Runtime error documentation (optional for backward compatibility)\n\n /** Possible runtime error codes this command can throw */\n readonly errorCodes?: readonly string[];\n /** Preconditions that must be met before execution */\n readonly preconditions?: readonly CommandPrecondition[];\n /** Recovery hints mapping error code to suggestion */\n readonly recoveryHints?: Readonly<Record<string, string>>;\n}\n\n/**\n * Command categories for organization.\n */\nexport type CommandCategory =\n | 'dom-class' // Class/attribute manipulation\n | 'dom-content' // Content manipulation\n | 'dom-visibility' // Show/hide\n | 'variable' // Variable operations\n | 'event' // Event handling\n | 'async' // Async operations\n | 'navigation' // URL/navigation\n | 'control-flow'; // Control flow\n\n// =============================================================================\n// Command Schema Definitions\n// =============================================================================\n\n/**\n * Toggle command: adds class/attribute if absent, removes if present.\n *\n * Patterns:\n * - EN: toggle .active on #button\n * - JA: #button の .active を 切り替え\n * - AR: بدّل .active على #button\n */\nexport const toggleSchema: CommandSchema = {\n action: 'toggle',\n description: 'Toggle a class or attribute on/off',\n category: 'dom-class',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The class or attribute to toggle',\n required: true,\n expectedTypes: ['selector'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n // Runtime error documentation\n errorCodes: ['MISSING_ARGUMENT', 'NO_VALID_CLASS_NAMES', 'INVALID_CSS_PROPERTY'],\n preconditions: [\n {\n condition: 'Command has at least one argument',\n errorCode: 'MISSING_ARGUMENT',\n message: 'toggle command requires an argument',\n },\n {\n condition: 'Class names are valid CSS identifiers',\n errorCode: 'NO_VALID_CLASS_NAMES',\n message: 'toggle command: no valid class names found',\n },\n ],\n recoveryHints: {\n MISSING_ARGUMENT: 'Add a class selector (.classname) or attribute to toggle',\n NO_VALID_CLASS_NAMES: 'Ensure class names start with a dot (.) and are valid CSS identifiers',\n INVALID_CSS_PROPERTY: 'Check CSS property name syntax (use kebab-case)',\n },\n};\n\n/**\n * Add command: adds a class or attribute.\n */\nexport const addSchema: CommandSchema = {\n action: 'add',\n description: 'Add a class or attribute to an element',\n category: 'dom-class',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The class or attribute to add',\n required: true,\n expectedTypes: ['selector'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n // Runtime error documentation\n errorCodes: ['MISSING_ARGUMENT', 'NO_VALID_CLASS_NAMES', 'PROPERTY_REQUIRES_VALUE'],\n preconditions: [\n {\n condition: 'Command has at least one argument',\n errorCode: 'MISSING_ARGUMENT',\n message: 'add command requires an argument',\n },\n ],\n recoveryHints: {\n MISSING_ARGUMENT: 'Add a class selector (.classname) or attribute to add',\n NO_VALID_CLASS_NAMES: 'Ensure class names start with a dot (.) and are valid CSS identifiers',\n PROPERTY_REQUIRES_VALUE: 'When adding a property (*prop), provide a value argument',\n },\n};\n\n/**\n * Remove command: removes a class or attribute.\n */\nexport const removeSchema: CommandSchema = {\n action: 'remove',\n description: 'Remove a class or attribute from an element',\n category: 'dom-class',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The class or attribute to remove',\n required: true,\n expectedTypes: ['selector'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'The element to remove from (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n // Runtime error documentation\n errorCodes: ['MISSING_ARGUMENT', 'NO_VALID_CLASS_NAMES'],\n preconditions: [\n {\n condition: 'Command has at least one argument',\n errorCode: 'MISSING_ARGUMENT',\n message: 'remove command requires an argument',\n },\n ],\n recoveryHints: {\n MISSING_ARGUMENT: 'Add a class selector (.classname) or attribute to remove',\n NO_VALID_CLASS_NAMES: 'Ensure class names start with a dot (.) and are valid CSS identifiers',\n },\n};\n\n/**\n * Put command: puts content into a target.\n *\n * Patterns:\n * - EN: put \"hello\" into #output\n * - JA: #output に \"hello\" を 置く\n * - AR: ضع \"hello\" في #output\n */\nexport const putSchema: CommandSchema = {\n action: 'put',\n description: 'Put content into a target element or variable',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The content to put',\n required: true,\n expectedTypes: ['literal', 'selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1, // SOV: patient comes first (を marker)\n },\n {\n role: 'destination',\n description: 'Where to put the content',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 2, // SOV: destination comes second (に/에/a marker)\n },\n ],\n // Runtime error documentation\n errorCodes: [\n 'MISSING_ARGUMENTS',\n 'MISSING_CONTENT',\n 'MISSING_POSITION',\n 'INVALID_POSITION',\n 'NO_TARGET',\n 'NO_ELEMENTS',\n ],\n preconditions: [\n {\n condition: 'Command has content and position arguments',\n errorCode: 'MISSING_ARGUMENTS',\n message: 'put requires arguments',\n },\n {\n condition: 'Content to put is specified',\n errorCode: 'MISSING_CONTENT',\n message: 'put requires content',\n },\n {\n condition: 'Position keyword is specified (into, before, after, etc.)',\n errorCode: 'MISSING_POSITION',\n message: 'put requires position keyword',\n },\n ],\n recoveryHints: {\n MISSING_ARGUMENTS: 'Use syntax: put <content> into/before/after <target>',\n MISSING_CONTENT: 'Add content to put (string, element, or expression)',\n MISSING_POSITION: 'Add position keyword: into, before, after, at start of, at end of',\n INVALID_POSITION: 'Valid positions: into, before, after, at start of, at end of',\n NO_TARGET: 'Ensure target element exists or use \"me\" reference',\n NO_ELEMENTS: 'Check that the selector matches existing elements',\n },\n};\n\n/**\n * Set command: sets a property or variable.\n *\n * Patterns:\n * - EN: set :count to 10\n * - ES: establecer :count a 10\n * - JA: :count を 10 に 設定\n * - KO: :x 에 5 을 설정 (uses default markers)\n * - TR: :x e 5 i ayarla (uses default markers)\n *\n * Note: Only override markers for SVO languages where patient has no default marker.\n * SOV languages (Korean, Japanese, Turkish) already have correct object markers.\n */\nexport const setSchema: CommandSchema = {\n action: 'set',\n description: 'Set a property or variable to a value',\n category: 'variable',\n primaryRole: 'destination',\n roles: [\n {\n role: 'destination',\n description: 'The property or variable to set',\n required: true,\n expectedTypes: ['selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n // Override destination marker for English (remove 'on', use no marker)\n // SOV languages swap markers: variable gets patient marker (を/를/i)\n // Arabic (VSO): no marker before variable\n markerOverride: {\n en: '', // No marker before destination in English: \"set :x to 5\"\n ja: 'を', // \"x を 10 に 設定\" - variable gets object marker\n ko: '를', // \"x 를 10 으로 설정\" - variable gets object marker\n tr: 'i', // \"x i 10 e ayarla\" - variable gets accusative marker\n ar: '', // \"عيّن x إلى 10\" - no marker before variable\n },\n },\n {\n role: 'patient',\n description: 'The value to set',\n required: true,\n expectedTypes: ['literal', 'expression', 'reference'],\n svoPosition: 2,\n sovPosition: 2,\n // Override patient marker for SVO languages with their native prepositions\n // SOV languages swap markers: value gets destination marker (に/으로/e)\n // Arabic (VSO): إلى preposition before value\n markerOverride: {\n en: 'to', // \"set :x to 5\"\n es: 'a', // \"establecer x a 10\"\n pt: 'para', // \"definir x para 10\"\n fr: 'à', // \"définir x à 10\"\n de: 'auf', // \"setze x auf 10\"\n id: 'ke', // \"atur x ke 10\"\n ja: 'に', // \"x を 10 に 設定\" - value gets destination marker\n ko: '으로', // \"x 를 10 으로 설정\" - value gets manner/instrument marker\n tr: 'e', // \"x i 10 e ayarla\" - value gets dative marker\n ar: 'إلى', // \"عيّن x إلى 10\" - value gets preposition \"to\"\n },\n },\n ],\n // Runtime error documentation\n errorCodes: ['MISSING_TARGET', 'INVALID_TARGET', 'MISSING_VALUE', 'INVALID_SYNTAX'],\n preconditions: [\n {\n condition: 'Command has a target variable or property',\n errorCode: 'MISSING_TARGET',\n message: 'set command requires a target',\n },\n {\n condition: 'Target is a valid variable or property reference',\n errorCode: 'INVALID_TARGET',\n message: 'set command target must be a string or object literal',\n },\n {\n condition: 'Value is specified with \"to\" keyword',\n errorCode: 'MISSING_VALUE',\n message: 'set command requires a value (use \"to\" keyword)',\n },\n ],\n recoveryHints: {\n MISSING_TARGET: 'Add a target: set :variable to value OR set element.property to value',\n INVALID_TARGET:\n 'Use local variable (:name), element property (el.prop), or \"the X of Y\" syntax',\n MISSING_VALUE: 'Add \"to <value>\" to specify what to set',\n INVALID_SYNTAX: 'Use syntax: set <target> to <value>',\n },\n};\n\n/**\n * Show command: makes an element visible.\n */\nexport const showSchema: CommandSchema = {\n action: 'show',\n description: 'Make an element visible',\n category: 'dom-visibility',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to show',\n required: true, // Changed from false - patient is primary role\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'style',\n description: 'Animation style (fade, slide, etc.)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Hide command: makes an element invisible.\n */\nexport const hideSchema: CommandSchema = {\n action: 'hide',\n description: 'Make an element invisible',\n category: 'dom-visibility',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to hide',\n required: true, // Changed from false - patient is primary role\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'style',\n description: 'Animation style (fade, slide, etc.)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * On command: event handler.\n */\nexport const onSchema: CommandSchema = {\n action: 'on',\n description: 'Handle an event',\n category: 'event',\n primaryRole: 'event',\n hasBody: true,\n roles: [\n {\n role: 'event',\n description: 'The event to handle',\n required: true,\n expectedTypes: ['literal'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'The element to listen on (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Trigger command: dispatches an event.\n * Supports namespaced events like \"draggable:start\".\n */\nexport const triggerSchema: CommandSchema = {\n action: 'trigger',\n description: 'Trigger/dispatch an event',\n category: 'event',\n primaryRole: 'event',\n roles: [\n {\n role: 'event',\n description: 'The event to trigger (supports namespaced events like draggable:start)',\n required: true,\n expectedTypes: ['literal', 'expression'], // expression for custom/namespaced event names\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Wait command: pauses execution.\n */\nexport const waitSchema: CommandSchema = {\n action: 'wait',\n description: 'Wait for a duration or event',\n category: 'async',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'Duration or event to wait for',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Fetch command: makes HTTP request.\n */\nexport const fetchSchema: CommandSchema = {\n action: 'fetch',\n description: 'Fetch data from a URL',\n category: 'async',\n primaryRole: 'source',\n roles: [\n {\n role: 'source',\n description: 'The URL to fetch from',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'responseType',\n description: 'Response format (json, text, html, blob, etc.)',\n required: false,\n expectedTypes: ['literal', 'expression'], // json/text/html are identifiers → expression type\n svoPosition: 2,\n sovPosition: 2,\n },\n {\n role: 'method',\n description: 'HTTP method (GET, POST, etc.)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 3,\n sovPosition: 3,\n },\n {\n role: 'destination',\n description: 'Where to store the result',\n required: false,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 4,\n sovPosition: 4,\n },\n ],\n};\n\n/**\n * Increment command: increases a numeric value.\n */\nexport const incrementSchema: CommandSchema = {\n action: 'increment',\n description: 'Increment a numeric value',\n category: 'variable',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The value to increment',\n required: true,\n expectedTypes: ['selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'quantity',\n description: 'Amount to increment by (defaults to 1)',\n required: false,\n expectedTypes: ['literal'],\n default: { type: 'literal', value: 1, dataType: 'number' },\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Decrement command: decreases a numeric value.\n */\nexport const decrementSchema: CommandSchema = {\n action: 'decrement',\n description: 'Decrement a numeric value',\n category: 'variable',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The value to decrement',\n required: true,\n expectedTypes: ['selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'quantity',\n description: 'Amount to decrement by (defaults to 1)',\n required: false,\n expectedTypes: ['literal'],\n default: { type: 'literal', value: 1, dataType: 'number' },\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Append command: appends content to an element.\n */\nexport const appendSchema: CommandSchema = {\n action: 'append',\n description: 'Append content to an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The content to append',\n required: true,\n expectedTypes: ['literal', 'selector', 'expression'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The element to append to',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Prepend command: prepends content to an element.\n */\nexport const prependSchema: CommandSchema = {\n action: 'prepend',\n description: 'Prepend content to an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The content to prepend',\n required: true,\n expectedTypes: ['literal', 'selector', 'expression'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The element to prepend to',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n// =============================================================================\n// Batch 1 - Simple Commands\n// =============================================================================\n\n/**\n * Log command: logs a value to console.\n */\nexport const logSchema: CommandSchema = {\n action: 'log',\n description: 'Log a value to the console',\n category: 'variable',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The value to log',\n required: true,\n expectedTypes: ['literal', 'selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Get command: retrieves a value.\n */\nexport const getCommandSchema: CommandSchema = {\n action: 'get',\n description: 'Get a value from a source',\n category: 'variable',\n primaryRole: 'source',\n roles: [\n {\n role: 'source',\n description: 'The source to get from',\n required: true,\n expectedTypes: ['selector', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 2,\n // Marker overrides for GET pattern\n // SOV languages use object markers, SVO languages have no marker\n markerOverride: {\n en: '',\n es: '',\n pt: '',\n fr: '',\n de: '',\n ja: 'を', // Japanese object marker: #element を 取得\n zh: '',\n ko: '를', // Korean object marker: #element 를 가져오기\n ar: 'على', // Arabic preposition: احصل على #element\n tr: 'i', // Turkish accusative: #element i al\n id: '',\n },\n },\n {\n role: 'destination',\n description: 'Where to store the result (optional)',\n required: false,\n expectedTypes: ['reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Take command: takes/removes content from a source.\n */\nexport const takeSchema: CommandSchema = {\n action: 'take',\n description: 'Take content from a source element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The class or element to take',\n required: true,\n expectedTypes: ['selector'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'The element to take from (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Make command: creates a new element.\n */\nexport const makeSchema: CommandSchema = {\n action: 'make',\n description: 'Create a new element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element type or selector to create',\n required: true,\n expectedTypes: ['literal', 'selector'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Halt command: stops execution or event propagation.\n * Supports: halt, halt the event, halt default, halt the bubbling\n */\nexport const haltSchema: CommandSchema = {\n action: 'halt',\n description: 'Halt/stop execution or event propagation',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'What to halt (event, default, bubbling, etc.)',\n required: false, // Plain \"halt\" is valid\n expectedTypes: ['literal', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Settle command: waits for animations to complete.\n */\nexport const settleSchema: CommandSchema = {\n action: 'settle',\n description: 'Wait for animations/transitions to settle',\n category: 'async',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to settle (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Throw command: throws an error/exception.\n */\nexport const throwSchema: CommandSchema = {\n action: 'throw',\n description: 'Throw an error',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The error message or object to throw',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Send command: sends/dispatches an event.\n */\nexport const sendSchema: CommandSchema = {\n action: 'send',\n description: 'Send an event to an element',\n category: 'event',\n primaryRole: 'event',\n roles: [\n {\n role: 'event',\n description: 'The event to send',\n required: true,\n expectedTypes: ['literal', 'expression'], // identifiers tokenize as expression\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n // send uses \"to\" not \"on\" for destination: send foo to #target\n markerOverride: {\n en: 'to',\n ja: 'に',\n ar: 'إلى',\n es: 'a',\n ko: '에게',\n zh: '到',\n tr: '-e',\n pt: 'para',\n fr: 'à',\n de: 'an',\n id: 'ke',\n qu: '-man',\n sw: 'kwa',\n },\n },\n ],\n};\n\n// =============================================================================\n// Batch 2 - Control Flow Commands\n// =============================================================================\n\n/**\n * If command: conditional execution.\n */\nexport const ifSchema: CommandSchema = {\n action: 'if',\n description: 'Conditional execution',\n category: 'control-flow',\n primaryRole: 'condition',\n hasBody: true,\n roles: [\n {\n role: 'condition',\n description: 'The condition to evaluate',\n required: true,\n expectedTypes: ['expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Unless command: negated conditional execution.\n * Executes body when condition is false.\n */\nexport const unlessSchema: CommandSchema = {\n action: 'unless',\n description: 'Negated conditional execution (executes when condition is false)',\n category: 'control-flow',\n primaryRole: 'condition',\n hasBody: true,\n roles: [\n {\n role: 'condition',\n description: 'The condition to evaluate (body executes when false)',\n required: true,\n expectedTypes: ['expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Else command: alternative branch.\n */\nexport const elseSchema: CommandSchema = {\n action: 'else',\n description: 'Else branch of conditional',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [], // No roles - follows an if\n};\n\n/**\n * Repeat command: loop execution.\n */\nexport const repeatSchema: CommandSchema = {\n action: 'repeat',\n description: 'Repeat a block of commands',\n category: 'control-flow',\n primaryRole: 'loopType',\n hasBody: true,\n roles: [\n {\n role: 'loopType',\n description: 'Loop variant: forever, times, for, while, until, until-event',\n required: true,\n expectedTypes: ['literal'],\n svoPosition: 0,\n sovPosition: 0,\n },\n {\n role: 'quantity',\n description: 'Number of times to repeat',\n required: false,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'event',\n description: 'Event to wait for (terminates loop)',\n required: false,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 2,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'Element to listen for event on',\n required: false,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 3,\n sovPosition: 3,\n },\n ],\n notes:\n 'Can also use \"repeat forever\", \"repeat until condition\", or \"repeat until event X from Y\"',\n};\n\n/**\n * For command: iteration over collection.\n */\nexport const forSchema: CommandSchema = {\n action: 'for',\n description: 'Iterate over a collection',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [\n {\n role: 'patient',\n description: 'The iteration variable',\n required: true,\n expectedTypes: ['reference'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'source',\n description: 'The collection to iterate over',\n required: true,\n expectedTypes: ['selector', 'reference', 'expression'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * While command: conditional loop.\n */\nexport const whileSchema: CommandSchema = {\n action: 'while',\n description: 'Loop while condition is true',\n category: 'control-flow',\n primaryRole: 'condition',\n hasBody: true,\n roles: [\n {\n role: 'condition',\n description: 'The condition to check',\n required: true,\n expectedTypes: ['expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Continue command: skip to next iteration.\n */\nexport const continueSchema: CommandSchema = {\n action: 'continue',\n description: 'Continue to next loop iteration',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [], // No roles\n};\n\n// =============================================================================\n// Batch 3 - DOM & Navigation Commands\n// =============================================================================\n\n/**\n * Go command: navigates to a URL.\n */\nexport const goSchema: CommandSchema = {\n action: 'go',\n description: 'Navigate to a URL',\n category: 'navigation',\n primaryRole: 'destination',\n roles: [\n {\n role: 'destination',\n description: 'The URL to navigate to',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Transition command: animates element changes.\n */\nexport const transitionSchema: CommandSchema = {\n action: 'transition',\n description: 'Transition an element with animation',\n category: 'dom-visibility',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The property to transition (opacity, *background-color, etc.)',\n required: true,\n expectedTypes: ['literal'], // Only literal - CSS properties are strings, not selectors\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'goal',\n description: 'The target value to transition to',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 2,\n sovPosition: 3,\n },\n {\n role: 'destination',\n description: 'The target element (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 3,\n sovPosition: 1,\n },\n {\n role: 'duration',\n description: 'Transition duration (over 500ms, for 2 seconds)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 4,\n sovPosition: 4,\n },\n {\n role: 'style',\n description: 'Easing function (ease-in, linear, etc.)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 5,\n sovPosition: 5,\n },\n ],\n};\n\n/**\n * Clone command: clones an element.\n */\nexport const cloneSchema: CommandSchema = {\n action: 'clone',\n description: 'Clone an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to clone',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'Where to put the clone',\n required: false,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Focus command: focuses an element.\n */\nexport const focusSchema: CommandSchema = {\n action: 'focus',\n description: 'Focus an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to focus (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Blur command: removes focus from an element.\n */\nexport const blurSchema: CommandSchema = {\n action: 'blur',\n description: 'Remove focus from an element',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The element to blur (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n// =============================================================================\n// Batch 4 - Advanced Commands\n// =============================================================================\n\n/**\n * Call command: calls a function.\n */\nexport const callSchema: CommandSchema = {\n action: 'call',\n description: 'Call a function',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The function to call',\n required: true,\n expectedTypes: ['expression', 'reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Return command: returns a value.\n */\nexport const returnSchema: CommandSchema = {\n action: 'return',\n description: 'Return a value from a function',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The value to return',\n required: false,\n expectedTypes: ['literal', 'expression', 'reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * JS command: executes raw JavaScript.\n */\nexport const jsSchema: CommandSchema = {\n action: 'js',\n description: 'Execute raw JavaScript code',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [\n {\n role: 'patient',\n description: 'The JavaScript code to execute',\n required: false,\n expectedTypes: ['expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Async command: runs commands asynchronously.\n */\nexport const asyncSchema: CommandSchema = {\n action: 'async',\n description: 'Execute commands asynchronously',\n category: 'async',\n primaryRole: 'patient',\n hasBody: true,\n roles: [],\n};\n\n/**\n * Tell command: sends commands to another element.\n */\nexport const tellSchema: CommandSchema = {\n action: 'tell',\n description: 'Execute commands in context of another element',\n category: 'control-flow',\n primaryRole: 'destination',\n hasBody: true,\n roles: [\n {\n role: 'destination',\n description: 'The element to tell',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Default command: sets default values.\n */\nexport const defaultSchema: CommandSchema = {\n action: 'default',\n description: 'Set a default value for a variable',\n category: 'variable',\n primaryRole: 'destination',\n roles: [\n {\n role: 'destination',\n description: 'The variable to set default for',\n required: true,\n expectedTypes: ['reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'patient',\n description: 'The default value',\n required: true,\n expectedTypes: ['literal', 'expression'],\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Init command: initialization block.\n */\nexport const initSchema: CommandSchema = {\n action: 'init',\n description: 'Initialization block that runs once',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [],\n};\n\n/**\n * Behavior command: defines reusable behavior.\n * Patterns:\n * - EN: behavior Draggable\n * - EN: behavior Draggable(dragHandle)\n */\nexport const behaviorSchema: CommandSchema = {\n action: 'behavior',\n description: 'Define a reusable behavior',\n category: 'control-flow',\n primaryRole: 'patient',\n hasBody: true,\n roles: [\n {\n role: 'patient',\n description: 'The behavior name (PascalCase identifier)',\n required: true,\n expectedTypes: ['literal', 'reference', 'expression'], // expression for PascalCase identifiers\n svoPosition: 1,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Install command: installs a behavior on an element.\n * Patterns:\n * - EN: install Draggable\n * - EN: install Draggable(dragHandle: .titlebar)\n * - EN: install Draggable on #element\n */\nexport const installSchema: CommandSchema = {\n action: 'install',\n description: 'Install a behavior on an element',\n category: 'control-flow',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'The behavior name to install',\n required: true,\n expectedTypes: ['literal', 'reference', 'expression'],\n svoPosition: 1,\n sovPosition: 2,\n },\n {\n role: 'destination',\n description: 'Element to install on (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 1,\n },\n ],\n};\n\n/**\n * Measure command: measures element dimensions or position.\n * Patterns:\n * - EN: measure x\n * - EN: measure width\n * - EN: measure width of #element\n */\nexport const measureSchema: CommandSchema = {\n action: 'measure',\n description: 'Measure element dimensions (x, y, width, height, etc.)',\n category: 'dom-content',\n primaryRole: 'patient',\n roles: [\n {\n role: 'patient',\n description: 'Property to measure (x, y, width, height, top, left, etc.)',\n required: false, // Plain \"measure\" is valid, defaults to bounds\n expectedTypes: ['literal', 'expression'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'source',\n description: 'Element to measure (defaults to me)',\n required: false,\n expectedTypes: ['selector', 'reference'],\n default: { type: 'reference', value: 'me' },\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n// =============================================================================\n// Batch 5 - DOM Content Manipulation\n// =============================================================================\n\n/**\n * Swap command: swaps DOM content using various strategies.\n *\n * Patterns:\n * - EN: swap innerHTML of #target\n * - EN: swap delete #target\n * - EN: swap beforebegin #target with <html>\n */\nexport const swapSchema: CommandSchema = {\n action: 'swap',\n description: 'Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)',\n category: 'dom-content',\n primaryRole: 'destination',\n roles: [\n {\n role: 'method',\n description: 'The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)',\n required: false,\n expectedTypes: ['literal'],\n svoPosition: 1,\n sovPosition: 3,\n },\n {\n role: 'destination',\n description: 'The element to swap content in/for',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 2,\n sovPosition: 1,\n },\n {\n role: 'patient',\n description: 'The content to swap in (optional for delete)',\n required: false,\n expectedTypes: ['literal', 'expression', 'selector'],\n svoPosition: 3,\n sovPosition: 2,\n },\n ],\n};\n\n/**\n * Morph command: morphs one element into another using DOM diffing.\n *\n * Patterns:\n * - EN: morph #target to <html>\n * - EN: morph me into #template\n */\nexport const morphSchema: CommandSchema = {\n action: 'morph',\n description: 'Morph an element into another using DOM diffing',\n category: 'dom-content',\n primaryRole: 'destination',\n roles: [\n {\n role: 'destination',\n description: 'The element to morph',\n required: true,\n expectedTypes: ['selector', 'reference'],\n svoPosition: 1,\n sovPosition: 1,\n },\n {\n role: 'patient',\n description: 'The target content/element to morph into',\n required: true,\n expectedTypes: ['literal', 'expression', 'selector'],\n svoPosition: 2,\n sovPosition: 2,\n },\n ],\n};\n\n// =============================================================================\n// Schema Registry\n// =============================================================================\n\n/**\n * All available command schemas.\n */\nexport const commandSchemas: Record<ActionType, CommandSchema> = {\n // Original schemas\n toggle: toggleSchema,\n add: addSchema,\n remove: removeSchema,\n put: putSchema,\n set: setSchema,\n show: showSchema,\n hide: hideSchema,\n on: onSchema,\n trigger: triggerSchema,\n wait: waitSchema,\n fetch: fetchSchema,\n increment: incrementSchema,\n decrement: decrementSchema,\n append: appendSchema,\n prepend: prependSchema,\n // Batch 1 - Simple Commands\n log: logSchema,\n get: getCommandSchema,\n take: takeSchema,\n make: makeSchema,\n halt: haltSchema,\n settle: settleSchema,\n throw: throwSchema,\n send: sendSchema,\n // Batch 2 - Control Flow\n if: ifSchema,\n unless: unlessSchema,\n else: elseSchema,\n repeat: repeatSchema,\n for: forSchema,\n while: whileSchema,\n continue: continueSchema,\n // Batch 3 - DOM & Navigation\n go: goSchema,\n transition: transitionSchema,\n clone: cloneSchema,\n focus: focusSchema,\n blur: blurSchema,\n // Batch 4 - Advanced\n call: callSchema,\n return: returnSchema,\n js: jsSchema,\n async: asyncSchema,\n tell: tellSchema,\n default: defaultSchema,\n init: initSchema,\n behavior: behaviorSchema,\n install: installSchema,\n measure: measureSchema,\n // Batch 5 - DOM Content Manipulation\n swap: swapSchema,\n morph: morphSchema,\n // Meta commands (for compound structures)\n compound: {\n action: 'compound',\n description: 'A compound node representing chained statements',\n primaryRole: 'patient', // Compound nodes don't have a traditional primary role\n category: 'control-flow',\n hasBody: true,\n roles: [],\n },\n};\n\n/**\n * Get a command schema by action type.\n */\nexport function getSchema(action: ActionType): CommandSchema | undefined {\n return commandSchemas[action];\n}\n\n/**\n * Get all schemas for a category.\n */\nexport function getSchemasByCategory(category: CommandCategory): CommandSchema[] {\n return Object.values(commandSchemas).filter(s => s.category === category);\n}\n\n/**\n * Get all fully-defined schemas (with roles).\n */\nexport function getDefinedSchemas(): CommandSchema[] {\n return Object.values(commandSchemas).filter(s => s.roles.length > 0);\n}\n\n// =============================================================================\n// Schema Validation (Development Only)\n// =============================================================================\n\n// Run schema validation at module load time in development builds\n// This is tree-shaken out in production builds\nif (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') {\n // Dynamic import to avoid bundling in production\n import('./schema-validator')\n .then(({ validateAllSchemas, formatValidationResults }) => {\n const validations = validateAllSchemas(commandSchemas);\n\n if (validations.size > 0) {\n console.warn('[SCHEMA VALIDATION] Found issues in command schemas:');\n console.warn(formatValidationResults(validations));\n console.warn('\\nThese warnings help identify potential schema design issues.');\n console.warn('Fix them to improve type inference and avoid runtime bugs.');\n }\n })\n .catch(err => {\n // Silently ignore if schema validator is not available\n console.debug('Schema validation skipped:', err);\n });\n}\n","/**\n * Role Positioning Utility\n *\n * Shared utilities for sorting and positioning semantic roles based on word order.\n * Used by pattern-generator and pattern-matcher to ensure consistent behavior.\n */\n\nimport type { SemanticRole } from '../../types';\nimport type { WordOrder } from '../../generators/profiles/types';\n\n/**\n * Priority order for semantic roles used in pattern matching.\n * Lower number = higher priority (comes first in pattern).\n * Only includes roles commonly used in patterns.\n */\nexport const ROLE_PRIORITY: Partial<Record<SemanticRole, number>> = {\n patient: 1,\n destination: 2,\n source: 3,\n style: 4,\n manner: 5,\n goal: 6,\n};\n\n/**\n * Get the priority of a semantic role.\n * Returns 99 for unknown/unlisted roles.\n */\nexport function getRolePriority(role: SemanticRole): number {\n return ROLE_PRIORITY[role] ?? 99;\n}\n\n/**\n * Sort semantic roles by their priority.\n * Patient comes first, then destination, source, etc.\n */\nexport function sortRolesByPriority(roles: SemanticRole[]): SemanticRole[] {\n return [...roles].sort((a, b) => getRolePriority(a) - getRolePriority(b));\n}\n\n// Re-export for convenience\nexport type { WordOrder };\n\n/**\n * Minimum interface for roles that can be sorted by position.\n */\nexport interface RoleWithPosition {\n role: SemanticRole;\n sovPosition?: number;\n svoPosition?: number;\n}\n\n/**\n * Sort roles by their position for a given word order.\n *\n * @param roles Array of role specs with position info\n * @param wordOrder The word order to use (SVO, SOV, VSO)\n * @returns Sorted array of roles\n */\nexport function sortRolesByWordOrder<T extends RoleWithPosition>(\n roles: readonly T[],\n wordOrder: WordOrder\n): T[] {\n const sortKey = wordOrder === 'SOV' ? 'sovPosition' : 'svoPosition';\n return [...roles].sort((a, b) => {\n const aPos = a[sortKey] ?? 99;\n const bPos = b[sortKey] ?? 99;\n return aPos - bPos;\n });\n}\n","/**\n * Marker Resolution Utility\n *\n * Shared utilities for resolving role markers from language profiles.\n * Used by pattern-generator to build tokens and extraction rules.\n */\n\nimport type { SemanticRole } from '../../types';\nimport type { LanguageProfile, RoleMarker } from '../../generators/language-profiles';\n\n/**\n * Minimum interface for role specs that can have marker resolution.\n * Compatible with the RoleSpec type from command-schemas.\n */\nexport interface RoleSpecWithMarker {\n role: SemanticRole;\n markerOverride?: Record<string, string | undefined>;\n}\n\n/**\n * Resolved marker information for a role.\n */\nexport interface ResolvedMarker {\n /** Primary marker string (may be empty string for no marker) */\n primary: string;\n /** Alternative markers */\n alternatives?: string[];\n /** Position relative to role value */\n position: 'before' | 'after';\n /** Whether this is an override marker */\n isOverride: boolean;\n}\n\n/**\n * Resolve the marker for a role in a specific language.\n *\n * Checks for command-specific marker overrides first,\n * then falls back to the default marker from the language profile.\n *\n * @param roleSpec Role specification with optional override\n * @param profile Language profile with role markers\n * @returns Resolved marker info, or null if no marker\n */\nexport function resolveMarkerForRole(\n roleSpec: RoleSpecWithMarker,\n profile: LanguageProfile\n): ResolvedMarker | null {\n // Check for command-specific marker override first\n const overrideMarker = roleSpec.markerOverride?.[profile.code];\n const defaultMarker = profile.roleMarkers[roleSpec.role];\n\n if (overrideMarker !== undefined) {\n // Use override marker (can be empty string to suppress default marker)\n return {\n primary: overrideMarker,\n position: defaultMarker?.position ?? 'before',\n isOverride: true,\n };\n }\n\n if (defaultMarker && defaultMarker.primary) {\n const result: ResolvedMarker = {\n primary: defaultMarker.primary,\n position: defaultMarker.position,\n isOverride: false,\n };\n if (defaultMarker.alternatives) {\n result.alternatives = defaultMarker.alternatives;\n }\n return result;\n }\n\n return null;\n}\n\n/**\n * Get all markers (primary + alternatives) for a role.\n *\n * @param roleSpec Role specification\n * @param profile Language profile\n * @returns Array of marker strings, or empty array if no markers\n */\nexport function getAllMarkersForRole(\n roleSpec: RoleSpecWithMarker,\n profile: LanguageProfile\n): string[] {\n const resolved = resolveMarkerForRole(roleSpec, profile);\n if (!resolved || !resolved.primary) {\n return [];\n }\n\n const markers = [resolved.primary];\n if (resolved.alternatives) {\n markers.push(...resolved.alternatives);\n }\n return markers;\n}\n\n/**\n * Get the default role marker from a language profile.\n *\n * @param profile Language profile\n * @param role Semantic role\n * @returns Role marker or undefined\n */\nexport function getDefaultRoleMarker(\n profile: LanguageProfile,\n role: SemanticRole\n): RoleMarker | undefined {\n return profile.roleMarkers[role];\n}\n","/**\n * Pattern Generator\n *\n * Generates LanguagePattern objects from CommandSchema + LanguageProfile.\n * This solves the pattern explosion problem by deriving patterns from\n * high-level definitions rather than hand-writing each one.\n */\n\nimport type { LanguagePattern, PatternToken, ExtractionRule } from '../types';\nimport type { LanguageProfile, KeywordTranslation, RoleMarker } from './language-profiles';\nimport type { CommandSchema, RoleSpec } from './command-schemas';\nimport { getDefinedSchemas } from './command-schemas';\n\n// Import shared utilities\nimport { sortRolesByWordOrder } from '../parser/utils/role-positioning';\nimport { resolveMarkerForRole } from '../parser/utils/marker-resolution';\n\n// Note: languageProfiles is no longer imported here.\n// Pattern generation for specific languages uses the registry instead.\n\n// Import registry functions - this is safe because:\n// 1. Registry doesn't import pattern-generator\n// 2. The circular path is: pattern-generator -> registry -> pattern-generator\n// But registry only uses setPatternGenerator which is exported, not module-level code\nimport {\n getRegisteredLanguages as registryGetLanguages,\n tryGetProfile as registryTryGetProfile,\n} from '../registry';\n\nfunction getAllRegisteredProfiles(): LanguageProfile[] {\n const languages = registryGetLanguages();\n return languages\n .map((lang: string) => registryTryGetProfile(lang))\n .filter((p): p is LanguageProfile => p !== undefined);\n}\n\n// =============================================================================\n// Pattern Generator\n// =============================================================================\n\n/**\n * Configuration for pattern generation.\n */\nexport interface GeneratorConfig {\n /** Base priority for generated patterns (higher = checked first) */\n basePriority?: number;\n /** Whether to generate simple patterns (without optional roles) */\n generateSimpleVariants?: boolean;\n /** Whether to generate alternative keyword patterns */\n generateAlternatives?: boolean;\n}\n\nconst defaultConfig: GeneratorConfig = {\n basePriority: 100,\n generateSimpleVariants: true,\n generateAlternatives: true,\n};\n\n/**\n * Generate a pattern for a command in a specific language.\n */\nexport function generatePattern(\n schema: CommandSchema,\n profile: LanguageProfile,\n config: GeneratorConfig = defaultConfig\n): LanguagePattern {\n const id = `${schema.action}-${profile.code}-generated`;\n const priority = config.basePriority ?? 100;\n\n // Get keyword translation\n const keyword = profile.keywords[schema.action];\n if (!keyword) {\n throw new Error(`No keyword translation for '${schema.action}' in ${profile.code}`);\n }\n\n // Build tokens based on word order\n const tokens = buildTokens(schema, profile, keyword);\n\n // Build extraction rules with defaults for optional roles\n // This ensures defaults are applied even when optional groups don't match\n const extraction = buildExtractionRulesWithDefaults(schema, profile);\n\n // Build template format string (for documentation)\n const format = buildFormatString(schema, profile, keyword);\n\n return {\n id,\n language: profile.code,\n command: schema.action,\n priority,\n template: {\n format,\n tokens,\n },\n extraction,\n };\n}\n\n/**\n * Generate a simple variant pattern (without optional roles).\n */\nexport function generateSimplePattern(\n schema: CommandSchema,\n profile: LanguageProfile,\n config: GeneratorConfig = defaultConfig\n): LanguagePattern | null {\n // Only generate simple variant if there are optional roles\n const optionalRoles = schema.roles.filter(r => !r.required);\n if (optionalRoles.length === 0) {\n return null;\n }\n\n const requiredRoles = schema.roles.filter(r => r.required);\n const simpleSchema: CommandSchema = {\n ...schema,\n roles: requiredRoles,\n };\n\n const pattern = generatePattern(simpleSchema, profile, config);\n\n // Adjust for simple variant\n return {\n ...pattern,\n id: `${schema.action}-${profile.code}-simple`,\n priority: (config.basePriority ?? 100) - 5, // Lower priority than full pattern (was -10)\n extraction: buildExtractionRulesWithDefaults(schema, profile),\n };\n}\n\n/**\n * Generate all pattern variants for a command in a language.\n */\nexport function generatePatternVariants(\n schema: CommandSchema,\n profile: LanguageProfile,\n config: GeneratorConfig = defaultConfig\n): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n\n // Main pattern\n patterns.push(generatePattern(schema, profile, config));\n\n // Simple variant (without optional roles)\n if (config.generateSimpleVariants) {\n const simple = generateSimplePattern(schema, profile, config);\n if (simple) {\n patterns.push(simple);\n }\n }\n\n return patterns;\n}\n\n/**\n * Generate patterns for all commands in a specific language.\n */\nexport function generatePatternsForLanguage(\n profile: LanguageProfile,\n config: GeneratorConfig = defaultConfig\n): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n const schemas = getDefinedSchemas();\n\n for (const schema of schemas) {\n // Skip if no keyword translation exists\n if (!profile.keywords[schema.action]) {\n continue;\n }\n\n // Generate simple command patterns\n const variants = generatePatternVariants(schema, profile, config);\n patterns.push(...variants);\n\n // Generate event handler patterns (on [event] [command] [patient])\n // Only generate for languages with eventHandler configuration\n if (profile.eventHandler?.eventMarker) {\n const eventHandlerPatterns = generateEventHandlerPatterns(schema, profile, config);\n patterns.push(...eventHandlerPatterns);\n }\n }\n\n return patterns;\n}\n\n/**\n * Generate patterns for a command across specified profiles.\n *\n * @param schema Command schema to generate patterns for\n * @param profiles Array of language profiles to generate patterns for (defaults to all registered)\n * @param config Generator configuration\n */\nexport function generatePatternsForCommand(\n schema: CommandSchema,\n profiles?: LanguageProfile[],\n config: GeneratorConfig = defaultConfig\n): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n\n // If no profiles provided, use all registered profiles\n const profilesToUse = profiles ?? getAllRegisteredProfiles();\n\n for (const profile of profilesToUse) {\n // Skip if no keyword translation exists\n if (!profile.keywords[schema.action]) {\n continue;\n }\n\n const variants = generatePatternVariants(schema, profile, config);\n patterns.push(...variants);\n }\n\n return patterns;\n}\n\n/**\n * Generate all patterns for all commands across specified profiles.\n *\n * @param profiles Array of language profiles to generate patterns for (defaults to all registered)\n * @param config Generator configuration\n */\nexport function generateAllPatterns(\n profiles?: LanguageProfile[],\n config: GeneratorConfig = defaultConfig\n): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n\n // If no profiles provided, use all registered profiles\n const profilesToUse = profiles ?? getAllRegisteredProfiles();\n\n for (const profile of profilesToUse) {\n const langPatterns = generatePatternsForLanguage(profile, config);\n patterns.push(...langPatterns);\n }\n\n return patterns;\n}\n\n/**\n * Generate event handler patterns for a command in a specific language.\n *\n * Creates patterns that wrap commands with event handlers (e.g., \"on click toggle .active\").\n * Automatically handles SOV, SVO, and VSO word orders based on language profile.\n *\n * @param commandSchema - The command to wrap (toggle, add, remove, etc.)\n * @param profile - Language profile with eventHandler configuration\n * @param config - Generator configuration\n * @returns Array of event handler patterns (empty if profile lacks eventHandler config)\n */\nexport function generateEventHandlerPatterns(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n config: GeneratorConfig = defaultConfig\n): LanguagePattern[] {\n // Only generate if profile has eventHandler configuration\n if (!profile.eventHandler || !profile.eventHandler.eventMarker) {\n return [];\n }\n\n const patterns: LanguagePattern[] = [];\n const eventMarker = profile.eventHandler.eventMarker;\n const keyword = profile.keywords[commandSchema.action];\n\n if (!keyword) {\n return []; // No translation for this command\n }\n\n // Check if this is a two-role command (like put, set)\n const requiredRoles = commandSchema.roles.filter(r => r.required);\n const hasTwoRequiredRoles = requiredRoles.length === 2;\n\n // Generate pattern based on word order\n if (profile.wordOrder === 'SOV') {\n if (hasTwoRequiredRoles) {\n // Two-role SOV pattern for put/set commands\n // Japanese put: 入力 で \"test\" を #output に 入れる\n // Korean set: 변경 할 때 x 를 10 으로 설정\n patterns.push(\n generateSOVTwoRoleEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config)\n );\n } else {\n // SOV: [event] [eventMarker] [destination? destMarker?] [patient] [patientMarker] [verb]\n // Japanese: クリック で #button の .active を 切り替え\n // Korean: 클릭 할 때 #button 의 .active 를 토글\n // Turkish: tıklama da #button ın .active i değiştir\n patterns.push(\n generateSOVEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config)\n );\n\n // For multi-word event markers with no-space alternatives (Korean compact forms),\n // also generate a pattern that accepts the compact form\n // Example: 클릭할때 .active를토글 (할때 as single token)\n const markerWords = eventMarker.primary.split(/\\s+/);\n const hasNoSpaceAlternative = eventMarker.alternatives?.some(\n alt => !alt.includes(' ') && alt.length > 1\n );\n if (markerWords.length > 1 && hasNoSpaceAlternative) {\n patterns.push(\n generateSOVCompactEventHandlerPattern(\n commandSchema,\n profile,\n keyword,\n eventMarker,\n config\n )\n );\n }\n\n // Add simple pattern (no patient required, defaults to 'me')\n // Supports: クリック で 増加 (click on increment)\n patterns.push(\n generateSOVSimpleEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config)\n );\n\n // Add temporal pattern if temporalMarkers defined\n // Supports: クリック の 時 .active を 切り替え (click's time toggle .active)\n const temporalPattern = generateSOVTemporalEventHandlerPattern(\n commandSchema,\n profile,\n keyword,\n config\n );\n if (temporalPattern) {\n patterns.push(temporalPattern);\n }\n }\n } else if (profile.wordOrder === 'VSO') {\n if (hasTwoRequiredRoles) {\n // Two-role VSO pattern for put/set commands\n // Arabic put: عند الإدخال ضع \"test\" في #output\n patterns.push(\n generateVSOTwoRoleEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config)\n );\n } else {\n // VSO: [eventMarker] [event] [verb] [patient] [على destination?]\n // Arabic: عند النقر بدّل .active على #button\n patterns.push(\n generateVSOEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config)\n );\n\n // Add negated event pattern variant for languages with negation markers\n // Pattern: [eventMarker] [negation] [event] [verb] [patient]\n // Example: عند عدم التركيز أخف #tooltip = \"on blur hide #tooltip\"\n if (profile.eventHandler?.negationMarker) {\n patterns.push(\n generateVSONegatedEventHandlerPattern(\n commandSchema,\n profile,\n keyword,\n eventMarker,\n config\n )\n );\n }\n\n // Add proclitic-prefixed pattern variant for Arabic\n // Pattern: [proclitic]? [event] [verb] [patient]\n // Example: والنقر بدّل .active (and click toggle .active)\n if (profile.tokenization?.prefixes) {\n patterns.push(\n generateVSOProcliticEventHandlerPattern(commandSchema, profile, keyword, config)\n );\n }\n }\n } else {\n // SVO: Use VSO pattern structure for event handlers\n if (hasTwoRequiredRoles) {\n patterns.push(\n generateVSOTwoRoleEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config)\n );\n } else {\n patterns.push(\n generateVSOEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config)\n );\n }\n }\n\n return patterns;\n}\n\n/**\n * Generate SOV event handler pattern (Japanese, Korean, Turkish).\n */\nfunction generateSOVEventHandlerPattern(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n keyword: KeywordTranslation,\n eventMarker: RoleMarker,\n config: GeneratorConfig\n): LanguagePattern {\n const tokens: PatternToken[] = [];\n\n // Event role\n tokens.push({ type: 'role', role: 'event', optional: false });\n\n // Event marker (after event in SOV)\n // Handle multi-word markers like Korean \"할 때\" by splitting into separate tokens\n if (eventMarker.position === 'after') {\n const markerWords = eventMarker.primary.split(/\\s+/);\n if (markerWords.length > 1) {\n // Multi-word marker: create a token for each word\n for (const word of markerWords) {\n tokens.push({ type: 'literal', value: word });\n }\n } else {\n // Single-word marker: include alternatives\n const markerToken: PatternToken = eventMarker.alternatives\n ? { type: 'literal', value: eventMarker.primary, alternatives: eventMarker.alternatives }\n : { type: 'literal', value: eventMarker.primary };\n tokens.push(markerToken);\n }\n }\n\n // Optional destination with its marker\n const destMarker = profile.roleMarkers.destination;\n if (destMarker) {\n tokens.push({\n type: 'group',\n optional: true,\n tokens: [\n { type: 'role', role: 'destination', optional: true },\n destMarker.alternatives\n ? { type: 'literal', value: destMarker.primary, alternatives: destMarker.alternatives }\n : { type: 'literal', value: destMarker.primary },\n ],\n });\n }\n\n // Patient role\n tokens.push({ type: 'role', role: 'patient', optional: false });\n\n // Patient marker (postposition/particle after patient)\n const patientMarker = profile.roleMarkers.patient;\n if (patientMarker) {\n const patMarkerToken: PatternToken = patientMarker.alternatives\n ? { type: 'literal', value: patientMarker.primary, alternatives: patientMarker.alternatives }\n : { type: 'literal', value: patientMarker.primary };\n tokens.push(patMarkerToken);\n }\n\n // Command verb at end (SOV)\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n tokens.push(verbToken);\n\n return {\n id: `${commandSchema.action}-event-${profile.code}-sov`,\n language: profile.code,\n command: 'on', // This is an event handler pattern\n priority: (config.basePriority ?? 100) + 50, // Higher priority than simple commands\n template: {\n format: `{event} ${eventMarker.primary} {destination?} {patient} ${patientMarker?.primary || ''} ${keyword.primary}`,\n tokens,\n },\n extraction: {\n action: { value: commandSchema.action }, // Extract the wrapped command\n event: { fromRole: 'event' },\n patient: { fromRole: 'patient' },\n destination: { fromRole: 'destination', default: { type: 'reference', value: 'me' } },\n },\n };\n}\n\n/**\n * Generate SOV compact event handler pattern for languages with no-space forms.\n *\n * This handles Korean compact forms where the event marker is attached directly\n * to the event word without a space:\n * - 클릭할때 .active를토글 (click+when toggle .active)\n *\n * The pattern uses a single token for the no-space marker alternatives.\n */\nfunction generateSOVCompactEventHandlerPattern(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n keyword: KeywordTranslation,\n eventMarker: RoleMarker,\n config: GeneratorConfig\n): LanguagePattern {\n const tokens: PatternToken[] = [];\n\n // Event role\n tokens.push({ type: 'role', role: 'event', optional: false });\n\n // Event marker as single token (using no-space alternatives)\n // Filter alternatives to only include no-space versions\n const noSpaceAlternatives =\n eventMarker.alternatives?.filter(alt => !alt.includes(' ') && alt.length > 1) || [];\n\n if (noSpaceAlternatives.length > 0) {\n tokens.push({\n type: 'literal',\n value: noSpaceAlternatives[0],\n alternatives: noSpaceAlternatives.slice(1),\n });\n }\n\n // Optional destination with its marker\n const destMarker = profile.roleMarkers.destination;\n if (destMarker) {\n tokens.push({\n type: 'group',\n optional: true,\n tokens: [\n { type: 'role', role: 'destination', optional: true },\n destMarker.alternatives\n ? { type: 'literal', value: destMarker.primary, alternatives: destMarker.alternatives }\n : { type: 'literal', value: destMarker.primary },\n ],\n });\n }\n\n // Patient role\n tokens.push({ type: 'role', role: 'patient', optional: false });\n\n // Patient marker (postposition/particle after patient)\n const patientMarker = profile.roleMarkers.patient;\n if (patientMarker) {\n const patMarkerToken: PatternToken = patientMarker.alternatives\n ? { type: 'literal', value: patientMarker.primary, alternatives: patientMarker.alternatives }\n : { type: 'literal', value: patientMarker.primary };\n tokens.push(patMarkerToken);\n }\n\n // Command verb at end (SOV)\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n tokens.push(verbToken);\n\n return {\n id: `${commandSchema.action}-event-${profile.code}-sov-compact`,\n language: profile.code,\n command: 'on', // This is an event handler pattern\n priority: (config.basePriority ?? 100) + 52, // Slightly higher priority for compact forms\n template: {\n format: `{event}${noSpaceAlternatives[0] || ''} {patient} ${keyword.primary}`,\n tokens,\n },\n extraction: {\n action: { value: commandSchema.action }, // Extract the wrapped command\n event: { fromRole: 'event' },\n patient: { fromRole: 'patient' },\n destination: { fromRole: 'destination', default: { type: 'reference', value: 'me' } },\n },\n };\n}\n\n/**\n * Generate SOV simple event handler pattern (patient optional, defaults to 'me').\n *\n * Supports patterns like:\n * - Japanese: クリック で 増加 (click on increment)\n * - Korean: 클릭 할 때 증가 (click when increment)\n * - Turkish: tıklama da artır (click on increment)\n *\n * The patient is not explicitly specified - it defaults to 'me' (current element).\n */\nfunction generateSOVSimpleEventHandlerPattern(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n keyword: KeywordTranslation,\n eventMarker: RoleMarker,\n config: GeneratorConfig\n): LanguagePattern {\n const tokens: PatternToken[] = [];\n\n // Event role\n tokens.push({ type: 'role', role: 'event', optional: false });\n\n // Event marker (after event in SOV)\n if (eventMarker.position === 'after') {\n const markerWords = eventMarker.primary.split(/\\s+/);\n if (markerWords.length > 1) {\n // Multi-word marker: create a token for each word\n for (const word of markerWords) {\n tokens.push({ type: 'literal', value: word });\n }\n } else {\n const markerToken: PatternToken = eventMarker.alternatives\n ? { type: 'literal', value: eventMarker.primary, alternatives: eventMarker.alternatives }\n : { type: 'literal', value: eventMarker.primary };\n tokens.push(markerToken);\n }\n }\n\n // Command verb at end (SOV) - no patient required\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n tokens.push(verbToken);\n\n return {\n id: `${commandSchema.action}-event-${profile.code}-sov-simple`,\n language: profile.code,\n command: 'on',\n priority: (config.basePriority ?? 100) + 48, // Lower than full pattern (50) but higher than base\n template: {\n format: `{event} ${eventMarker.primary} ${keyword.primary}`,\n tokens,\n },\n extraction: {\n action: { value: commandSchema.action },\n event: { fromRole: 'event' },\n patient: { default: { type: 'reference', value: 'me' } }, // Default to 'me'\n },\n };\n}\n\n/**\n * Generate SOV temporal event handler pattern.\n *\n * Supports patterns with temporal markers like:\n * - Japanese: クリック 時 .active を 切り替え (click time toggle .active)\n * - Japanese: クリック の 時 .active を 切り替え (click's time toggle .active)\n *\n * Uses profile.eventHandler.temporalMarkers for language-specific temporal words.\n */\nfunction generateSOVTemporalEventHandlerPattern(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n keyword: KeywordTranslation,\n config: GeneratorConfig\n): LanguagePattern | null {\n const temporalMarkers = profile.eventHandler?.temporalMarkers;\n if (!temporalMarkers || temporalMarkers.length === 0) return null;\n\n const tokens: PatternToken[] = [];\n\n // Event role\n tokens.push({ type: 'role', role: 'event', optional: false });\n\n // Optional possessive marker (の in Japanese)\n if (profile.possessive?.marker) {\n tokens.push({\n type: 'group',\n optional: true,\n tokens: [{ type: 'literal', value: profile.possessive.marker }],\n });\n }\n\n // Temporal marker (時, とき in Japanese)\n tokens.push({\n type: 'literal',\n value: temporalMarkers[0],\n alternatives: temporalMarkers.slice(1),\n });\n\n // Patient role\n tokens.push({ type: 'role', role: 'patient', optional: false });\n\n // Patient marker\n const patientMarker = profile.roleMarkers.patient;\n if (patientMarker?.primary) {\n const patMarkerToken: PatternToken = patientMarker.alternatives\n ? { type: 'literal', value: patientMarker.primary, alternatives: patientMarker.alternatives }\n : { type: 'literal', value: patientMarker.primary };\n tokens.push(patMarkerToken);\n }\n\n // Command verb at end\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n tokens.push(verbToken);\n\n return {\n id: `${commandSchema.action}-event-${profile.code}-sov-temporal`,\n language: profile.code,\n command: 'on',\n priority: (config.basePriority ?? 100) + 49, // Between simple and full pattern\n template: {\n format: `{event} ${temporalMarkers[0]} {patient} ${keyword.primary}`,\n tokens,\n },\n extraction: {\n action: { value: commandSchema.action },\n event: { fromRole: 'event' },\n patient: { fromRole: 'patient' },\n },\n };\n}\n\n/**\n * Generate VSO event handler pattern (Arabic).\n */\nfunction generateVSOEventHandlerPattern(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n keyword: KeywordTranslation,\n eventMarker: RoleMarker,\n config: GeneratorConfig\n): LanguagePattern {\n const tokens: PatternToken[] = [];\n\n // Event marker (before event in VSO)\n if (eventMarker.position === 'before') {\n const markerToken: PatternToken = eventMarker.alternatives\n ? { type: 'literal', value: eventMarker.primary, alternatives: eventMarker.alternatives }\n : { type: 'literal', value: eventMarker.primary };\n tokens.push(markerToken);\n }\n\n // Event role\n tokens.push({ type: 'role', role: 'event', optional: false });\n\n // Command verb (verb comes early in VSO)\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n tokens.push(verbToken);\n\n // Patient role\n tokens.push({ type: 'role', role: 'patient', optional: false });\n\n // Optional destination with preposition\n const destMarker = profile.roleMarkers.destination;\n if (destMarker) {\n tokens.push({\n type: 'group',\n optional: true,\n tokens: [\n destMarker.alternatives\n ? { type: 'literal', value: destMarker.primary, alternatives: destMarker.alternatives }\n : { type: 'literal', value: destMarker.primary },\n { type: 'role', role: 'destination', optional: true },\n ],\n });\n }\n\n return {\n id: `${commandSchema.action}-event-${profile.code}-vso`,\n language: profile.code,\n command: 'on', // This is an event handler pattern\n priority: (config.basePriority ?? 100) + 50, // Higher priority than simple commands\n template: {\n format: `${eventMarker.primary} {event} ${keyword.primary} {patient} ${destMarker?.primary || ''} {destination?}`,\n tokens,\n },\n extraction: {\n action: { value: commandSchema.action }, // Extract the wrapped command\n event: { fromRole: 'event' },\n patient: { fromRole: 'patient' },\n destination: { fromRole: 'destination', default: { type: 'reference', value: 'me' } },\n },\n };\n}\n\n/**\n * Generate SOV two-role event handler pattern (for put/set commands).\n *\n * Patterns:\n * - Japanese put: 入力 で \"test\" を #output に 入れる\n * [event] [eventMarker] [patient] [patientMarker] [destination] [destMarker] [verb]\n * - Korean set: 변경 할 때 x 를 10 으로 설정\n * [event] [eventMarker] [role1] [role1Marker] [role2] [role2Marker] [verb]\n * - Turkish put: giriş de \"test\" i #output a koy\n * [event] [eventMarker] [patient] [patientMarker] [destination] [destMarker] [verb]\n */\nfunction generateSOVTwoRoleEventHandlerPattern(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n keyword: KeywordTranslation,\n eventMarker: RoleMarker,\n config: GeneratorConfig\n): LanguagePattern {\n const tokens: PatternToken[] = [];\n\n // Event role\n tokens.push({ type: 'role', role: 'event', optional: false });\n\n // Event marker (after event in SOV)\n // Handle multi-word markers like Korean \"할 때\" by splitting into separate tokens\n if (eventMarker.position === 'after') {\n const markerWords = eventMarker.primary.split(/\\s+/);\n if (markerWords.length > 1) {\n // Multi-word marker: create a token for each word\n for (const word of markerWords) {\n tokens.push({ type: 'literal', value: word });\n }\n } else {\n // Single-word marker: include alternatives\n const markerToken: PatternToken = eventMarker.alternatives\n ? { type: 'literal', value: eventMarker.primary, alternatives: eventMarker.alternatives }\n : { type: 'literal', value: eventMarker.primary };\n tokens.push(markerToken);\n }\n }\n\n // Get the two required roles from the schema\n const requiredRoles = commandSchema.roles.filter(r => r.required);\n\n // Sort by SOV position (lower number = earlier in sentence)\n const sortedRoles = [...requiredRoles].sort((a, b) => {\n const aPos = a.sovPosition ?? 999;\n const bPos = b.sovPosition ?? 999;\n return aPos - bPos;\n });\n\n // Add each role with its marker\n for (const roleSpec of sortedRoles) {\n // Add the role\n tokens.push({ type: 'role', role: roleSpec.role, optional: false });\n\n // Get marker for this role - check for override first\n let marker: string | undefined;\n let markerAlternatives: string[] | undefined;\n\n if (roleSpec.markerOverride && roleSpec.markerOverride[profile.code]) {\n // Use the override marker\n marker = roleSpec.markerOverride[profile.code];\n } else {\n // Use default role marker from profile\n const roleMarker = profile.roleMarkers[roleSpec.role];\n if (roleMarker) {\n marker = roleMarker.primary;\n markerAlternatives = roleMarker.alternatives;\n }\n }\n\n // Add the marker token\n if (marker) {\n const markerToken: PatternToken = markerAlternatives\n ? { type: 'literal', value: marker, alternatives: markerAlternatives }\n : { type: 'literal', value: marker };\n tokens.push(markerToken);\n }\n }\n\n // Command verb at end (SOV)\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n tokens.push(verbToken);\n\n // Build format string\n const roleNames = sortedRoles.map(r => `{${r.role}}`).join(' ');\n\n return {\n id: `${commandSchema.action}-event-${profile.code}-sov-2role`,\n language: profile.code,\n command: 'on', // This is an event handler pattern\n priority: (config.basePriority ?? 100) + 55, // Higher priority than single-role patterns\n template: {\n format: `{event} ${eventMarker.primary} ${roleNames} ${keyword.primary}`,\n tokens,\n },\n extraction: {\n action: { value: commandSchema.action }, // Extract the wrapped command\n event: { fromRole: 'event' },\n patient: { fromRole: 'patient' },\n destination: { fromRole: 'destination' },\n },\n };\n}\n\n/**\n * Generate VSO two-role event handler pattern (for put/set commands).\n *\n * Patterns:\n * - Arabic put: عند الإدخال ضع \"test\" في #output\n * [eventMarker] [event] [verb] [patient] [destPrep] [destination]\n * - Arabic set: عند التغيير عيّن x إلى 10\n * [eventMarker] [event] [verb] [destination] [patientPrep] [patient]\n */\nfunction generateVSOTwoRoleEventHandlerPattern(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n keyword: KeywordTranslation,\n eventMarker: RoleMarker,\n config: GeneratorConfig\n): LanguagePattern {\n const tokens: PatternToken[] = [];\n\n // Event marker (before event in VSO)\n if (eventMarker.position === 'before') {\n const markerToken: PatternToken = eventMarker.alternatives\n ? { type: 'literal', value: eventMarker.primary, alternatives: eventMarker.alternatives }\n : { type: 'literal', value: eventMarker.primary };\n tokens.push(markerToken);\n }\n\n // Event role\n tokens.push({ type: 'role', role: 'event', optional: false });\n\n // Command verb (verb comes early in VSO)\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n tokens.push(verbToken);\n\n // Get the two required roles from the schema\n const requiredRoles = commandSchema.roles.filter(r => r.required);\n\n // Sort by SVO position for VSO (role order is similar)\n const sortedRoles = [...requiredRoles].sort((a, b) => {\n const aPos = a.svoPosition ?? 999;\n const bPos = b.svoPosition ?? 999;\n return aPos - bPos;\n });\n\n // Add each role with its preposition/marker\n for (const roleSpec of sortedRoles) {\n // Get marker for this role - check for override first\n let marker: string | undefined;\n let markerAlternatives: string[] | undefined;\n\n if (roleSpec.markerOverride && roleSpec.markerOverride[profile.code]) {\n // Use the override marker\n marker = roleSpec.markerOverride[profile.code];\n } else {\n // Use default role marker from profile\n const roleMarker = profile.roleMarkers[roleSpec.role];\n if (roleMarker) {\n marker = roleMarker.primary;\n markerAlternatives = roleMarker.alternatives;\n }\n }\n\n // In VSO, prepositions come BEFORE the noun (prepositional languages)\n if (marker) {\n const markerToken: PatternToken = markerAlternatives\n ? { type: 'literal', value: marker, alternatives: markerAlternatives }\n : { type: 'literal', value: marker };\n tokens.push(markerToken);\n }\n\n // Add the role\n tokens.push({ type: 'role', role: roleSpec.role, optional: false });\n }\n\n // Build format string\n const roleNames = sortedRoles.map(r => `{${r.role}}`).join(' ');\n\n return {\n id: `${commandSchema.action}-event-${profile.code}-vso-2role`,\n language: profile.code,\n command: 'on', // This is an event handler pattern\n priority: (config.basePriority ?? 100) + 55, // Higher priority than single-role patterns\n template: {\n format: `${eventMarker.primary} {event} ${keyword.primary} ${roleNames}`,\n tokens,\n },\n extraction: {\n action: { value: commandSchema.action }, // Extract the wrapped command\n event: { fromRole: 'event' },\n patient: { fromRole: 'patient' },\n destination: { fromRole: 'destination' },\n },\n };\n}\n\n/**\n * Generate VSO negated event handler pattern.\n *\n * Patterns:\n * - Arabic: عند عدم التركيز أخف #tooltip\n * [eventMarker] [negation] [event] [verb] [patient]\n *\n * Used for events expressed as negation + opposite action:\n * - عدم التركيز = \"not focusing\" = blur\n */\nfunction generateVSONegatedEventHandlerPattern(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n keyword: KeywordTranslation,\n eventMarker: RoleMarker,\n config: GeneratorConfig\n): LanguagePattern {\n const tokens: PatternToken[] = [];\n const negationMarker = profile.eventHandler?.negationMarker;\n\n // Event marker (before event in VSO)\n if (eventMarker.position === 'before') {\n const markerToken: PatternToken = eventMarker.alternatives\n ? { type: 'literal', value: eventMarker.primary, alternatives: eventMarker.alternatives }\n : { type: 'literal', value: eventMarker.primary };\n tokens.push(markerToken);\n }\n\n // Negation marker (e.g., عدم = \"not/lack of\")\n if (negationMarker) {\n const negToken: PatternToken = negationMarker.alternatives\n ? {\n type: 'literal',\n value: negationMarker.primary,\n alternatives: negationMarker.alternatives,\n }\n : { type: 'literal', value: negationMarker.primary };\n tokens.push(negToken);\n }\n\n // Event role (the action being negated, e.g., التركيز = \"the focusing\")\n tokens.push({ type: 'role', role: 'event', optional: false });\n\n // Command verb (verb comes early in VSO)\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n tokens.push(verbToken);\n\n // Patient role\n tokens.push({ type: 'role', role: 'patient', optional: false });\n\n // Optional destination with preposition\n const destMarker = profile.roleMarkers.destination;\n if (destMarker) {\n tokens.push({\n type: 'group',\n optional: true,\n tokens: [\n destMarker.alternatives\n ? { type: 'literal', value: destMarker.primary, alternatives: destMarker.alternatives }\n : { type: 'literal', value: destMarker.primary },\n { type: 'role', role: 'destination', optional: true },\n ],\n });\n }\n\n return {\n id: `${commandSchema.action}-event-${profile.code}-vso-negated`,\n language: profile.code,\n command: 'on', // This is an event handler pattern\n priority: (config.basePriority ?? 100) + 48, // Slightly lower priority than standard patterns\n template: {\n format: `${eventMarker.primary} ${negationMarker?.primary || ''} {event} ${keyword.primary} {patient} ${destMarker?.primary || ''} {destination?}`,\n tokens,\n },\n extraction: {\n action: { value: commandSchema.action }, // Extract the wrapped command\n event: { fromRole: 'event' },\n patient: { fromRole: 'patient' },\n destination: { fromRole: 'destination', default: { type: 'reference', value: 'me' } },\n },\n };\n}\n\n/**\n * Generate VSO proclitic event handler pattern (for Arabic chained events).\n *\n * Patterns:\n * - Arabic: والنقر بدّل .active\n * [proclitic] [event] [verb] [patient]\n * - Arabic: فالتحويم أضف .highlight\n * [proclitic] [event] [verb] [patient]\n *\n * These patterns have a conjunction proclitic (و = and, ف = then) attached to\n * the event, without the عند event marker. Used for chained/consequent events.\n */\nfunction generateVSOProcliticEventHandlerPattern(\n commandSchema: CommandSchema,\n profile: LanguageProfile,\n keyword: KeywordTranslation,\n config: GeneratorConfig\n): LanguagePattern {\n const tokens: PatternToken[] = [];\n\n // Required conjunction token (و = and, ف = then)\n // The conjunction must be present for this pattern - it distinguishes chained events from regular commands\n // Use normalized values since proclitics are tokenized as conjunction tokens\n tokens.push({\n type: 'literal',\n value: 'and', // Matches normalized 'and' (Arabic: و)\n alternatives: ['then'], // Also matches normalized 'then' (Arabic: ف)\n });\n\n // Event role (the event name, e.g., النقر = the click)\n tokens.push({ type: 'role', role: 'event', optional: false });\n\n // Command verb (verb comes early in VSO)\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n tokens.push(verbToken);\n\n // Patient role\n tokens.push({ type: 'role', role: 'patient', optional: false });\n\n // Optional destination with preposition\n const destMarker = profile.roleMarkers.destination;\n if (destMarker) {\n tokens.push({\n type: 'group',\n optional: true,\n tokens: [\n destMarker.alternatives\n ? { type: 'literal', value: destMarker.primary, alternatives: destMarker.alternatives }\n : { type: 'literal', value: destMarker.primary },\n { type: 'role', role: 'destination', optional: true },\n ],\n });\n }\n\n return {\n id: `${commandSchema.action}-event-${profile.code}-vso-proclitic`,\n language: profile.code,\n command: 'on', // This is an event handler pattern\n priority: (config.basePriority ?? 100) + 45, // Lower priority than standard patterns\n template: {\n format: `[proclitic?] {event} ${keyword.primary} {patient} ${destMarker?.primary || ''} {destination?}`,\n tokens,\n },\n extraction: {\n action: { value: commandSchema.action }, // Extract the wrapped command\n event: { fromRole: 'event' },\n patient: { fromRole: 'patient' },\n destination: { fromRole: 'destination', default: { type: 'reference', value: 'me' } },\n },\n };\n}\n\n// =============================================================================\n// Token Building\n// =============================================================================\n\n/**\n * Build pattern tokens based on word order.\n */\nfunction buildTokens(\n schema: CommandSchema,\n profile: LanguageProfile,\n keyword: { primary: string; alternatives?: string[] }\n): PatternToken[] {\n const tokens: PatternToken[] = [];\n\n // Get verb token\n const verbToken: PatternToken = keyword.alternatives\n ? { type: 'literal', value: keyword.primary, alternatives: keyword.alternatives }\n : { type: 'literal', value: keyword.primary };\n\n // Get role tokens sorted by position\n const roleTokens = buildRoleTokens(schema, profile);\n\n // Arrange based on word order\n switch (profile.wordOrder) {\n case 'SVO':\n // Verb first, then roles in order\n tokens.push(verbToken);\n tokens.push(...roleTokens);\n break;\n\n case 'SOV':\n // Roles first (reversed for SOV), then verb\n tokens.push(...roleTokens);\n tokens.push(verbToken);\n break;\n\n case 'VSO':\n // Verb first, then subject, then object\n tokens.push(verbToken);\n tokens.push(...roleTokens);\n break;\n\n default:\n // Default to SVO\n tokens.push(verbToken);\n tokens.push(...roleTokens);\n }\n\n return tokens;\n}\n\n/**\n * Build tokens for roles.\n */\nfunction buildRoleTokens(schema: CommandSchema, profile: LanguageProfile): PatternToken[] {\n const tokens: PatternToken[] = [];\n\n // Sort roles by position using shared utility\n const sortedRoles = sortRolesByWordOrder(schema.roles, profile.wordOrder);\n\n for (const roleSpec of sortedRoles) {\n const roleToken = buildRoleToken(roleSpec, profile);\n\n if (!roleSpec.required) {\n // Wrap optional roles in a group\n tokens.push({\n type: 'group',\n optional: true,\n tokens: roleToken,\n });\n } else {\n tokens.push(...roleToken);\n }\n }\n\n return tokens;\n}\n\n/**\n * Build token(s) for a single role.\n */\nfunction buildRoleToken(roleSpec: RoleSpec, profile: LanguageProfile): PatternToken[] {\n const tokens: PatternToken[] = [];\n\n // Check for command-specific marker override first\n const overrideMarker = roleSpec.markerOverride?.[profile.code];\n const defaultMarker = profile.roleMarkers[roleSpec.role];\n\n // Role value token\n const roleValueToken: PatternToken = {\n type: 'role',\n role: roleSpec.role,\n optional: !roleSpec.required,\n expectedTypes: roleSpec.expectedTypes as any,\n };\n\n // Use override marker if available, otherwise use default\n if (overrideMarker !== undefined) {\n // Command-specific marker override\n const position = defaultMarker?.position ?? 'before';\n if (position === 'before') {\n if (overrideMarker) {\n tokens.push({ type: 'literal', value: overrideMarker });\n }\n tokens.push(roleValueToken);\n } else {\n tokens.push(roleValueToken);\n if (overrideMarker) {\n tokens.push({ type: 'literal', value: overrideMarker });\n }\n }\n } else if (defaultMarker) {\n if (defaultMarker.position === 'before') {\n // Preposition: \"on #button\"\n if (defaultMarker.primary) {\n const markerToken: PatternToken = defaultMarker.alternatives\n ? {\n type: 'literal',\n value: defaultMarker.primary,\n alternatives: defaultMarker.alternatives,\n }\n : { type: 'literal', value: defaultMarker.primary };\n tokens.push(markerToken);\n }\n tokens.push(roleValueToken);\n } else {\n // Postposition/particle: \"#button に\"\n tokens.push(roleValueToken);\n const markerToken: PatternToken = defaultMarker.alternatives\n ? {\n type: 'literal',\n value: defaultMarker.primary,\n alternatives: defaultMarker.alternatives,\n }\n : { type: 'literal', value: defaultMarker.primary };\n tokens.push(markerToken);\n }\n } else {\n // No marker, just the role value\n tokens.push(roleValueToken);\n }\n\n return tokens;\n}\n\n// =============================================================================\n// Extraction Rules Building\n// =============================================================================\n\n/**\n * Build extraction rules for a pattern.\n */\nfunction buildExtractionRules(\n schema: CommandSchema,\n profile: LanguageProfile\n): Record<string, ExtractionRule> {\n const rules: Record<string, ExtractionRule> = {};\n\n for (const roleSpec of schema.roles) {\n // Check for command-specific marker override first\n const overrideMarker = roleSpec.markerOverride?.[profile.code];\n const defaultMarker = profile.roleMarkers[roleSpec.role];\n\n if (overrideMarker !== undefined) {\n // Use the override marker\n rules[roleSpec.role] = overrideMarker ? { marker: overrideMarker } : {};\n } else if (defaultMarker && defaultMarker.primary) {\n rules[roleSpec.role] = defaultMarker.alternatives\n ? { marker: defaultMarker.primary, markerAlternatives: defaultMarker.alternatives }\n : { marker: defaultMarker.primary };\n } else {\n rules[roleSpec.role] = {};\n }\n }\n\n return rules;\n}\n\n/**\n * Build extraction rules with defaults for optional roles.\n */\nfunction buildExtractionRulesWithDefaults(\n schema: CommandSchema,\n profile: LanguageProfile\n): Record<string, ExtractionRule> {\n const baseRules = buildExtractionRules(schema, profile);\n const rules: Record<string, ExtractionRule> = {};\n\n // Copy base rules and add defaults for optional roles\n for (const roleSpec of schema.roles) {\n const baseRule = baseRules[roleSpec.role] || {};\n\n if (!roleSpec.required && roleSpec.default) {\n rules[roleSpec.role] = { ...baseRule, default: roleSpec.default };\n } else {\n rules[roleSpec.role] = baseRule;\n }\n }\n\n return rules;\n}\n\n// =============================================================================\n// Format String Building\n// =============================================================================\n\n/**\n * Build a human-readable format string for documentation.\n */\nfunction buildFormatString(\n schema: CommandSchema,\n profile: LanguageProfile,\n keyword: { primary: string }\n): string {\n const parts: string[] = [];\n\n // Sort roles by position using shared utility\n const sortedRoles = sortRolesByWordOrder(schema.roles, profile.wordOrder);\n\n // Build role parts\n const roleParts = sortedRoles.map(roleSpec => {\n // Use shared marker resolution utility\n const resolved = resolveMarkerForRole(roleSpec, profile);\n let part = '';\n\n if (resolved && resolved.primary) {\n // Has a marker\n if (resolved.position === 'before') {\n part = `${resolved.primary} {${roleSpec.role}}`;\n } else {\n part = `{${roleSpec.role}} ${resolved.primary}`;\n }\n } else {\n // No marker\n part = `{${roleSpec.role}}`;\n }\n\n return roleSpec.required ? part : `[${part}]`;\n });\n\n // Arrange based on word order\n switch (profile.wordOrder) {\n case 'SVO':\n case 'VSO':\n parts.push(keyword.primary, ...roleParts);\n break;\n case 'SOV':\n parts.push(...roleParts, keyword.primary);\n break;\n default:\n parts.push(keyword.primary, ...roleParts);\n }\n\n return parts.join(' ');\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Get a summary of what patterns can be generated.\n * Note: This requires the registry to have languages registered.\n */\nexport function getGeneratorSummary(): {\n languages: string[];\n commands: string[];\n totalPatterns: number;\n} {\n const languages = registryGetLanguages();\n const commands = getDefinedSchemas().map(s => s.action);\n\n // Estimate total patterns (2 variants per command per language)\n let totalPatterns = 0;\n for (const lang of languages) {\n const profile = registryTryGetProfile(lang);\n if (profile) {\n for (const schema of getDefinedSchemas()) {\n if (profile.keywords[schema.action]) {\n totalPatterns += 2; // Full + simple variant\n }\n }\n }\n }\n\n return { languages, commands, totalPatterns };\n}\n\n/**\n * Validate that all required keywords exist for a language.\n */\nexport function validateLanguageKeywords(\n profile: LanguageProfile,\n schemas: CommandSchema[] = getDefinedSchemas()\n): { missing: string[]; available: string[] } {\n const missing: string[] = [];\n const available: string[] = [];\n\n for (const schema of schemas) {\n if (profile.keywords[schema.action]) {\n available.push(schema.action);\n } else {\n missing.push(schema.action);\n }\n }\n\n return { missing, available };\n}\n","/**\n * English Toggle Patterns\n *\n * Tree-shakeable: Only included when English is imported.\n */\n\nimport type { LanguagePattern } from '../../types';\n\n/**\n * Get English toggle patterns.\n */\nexport function getTogglePatternsEn(): LanguagePattern[] {\n return [\n {\n id: 'toggle-en-full',\n language: 'en',\n command: 'toggle',\n priority: 100,\n template: {\n format: 'toggle {patient} on {target}',\n tokens: [\n { type: 'literal', value: 'toggle' },\n { type: 'role', role: 'patient' },\n {\n type: 'group',\n optional: true,\n tokens: [\n { type: 'literal', value: 'on', alternatives: ['from'] },\n { type: 'role', role: 'destination' },\n ],\n },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: {\n marker: 'on',\n markerAlternatives: ['from'],\n default: { type: 'reference', value: 'me' },\n },\n },\n },\n {\n id: 'toggle-en-simple',\n language: 'en',\n command: 'toggle',\n priority: 90,\n template: {\n format: 'toggle {patient}',\n tokens: [\n { type: 'literal', value: 'toggle' },\n { type: 'role', role: 'patient' },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: { default: { type: 'reference', value: 'me' } },\n },\n },\n ];\n}\n","/**\n * English Put Patterns\n *\n * Tree-shakeable: Only included when English is imported.\n */\n\nimport type { LanguagePattern } from '../../types';\n\n/**\n * Get English put patterns.\n */\nexport function getPutPatternsEn(): LanguagePattern[] {\n return [\n {\n id: 'put-en-into',\n language: 'en',\n command: 'put',\n priority: 100,\n template: {\n format: 'put {patient} into {destination}',\n tokens: [\n { type: 'literal', value: 'put' },\n { type: 'role', role: 'patient' },\n { type: 'literal', value: 'into', alternatives: ['in', 'to'] },\n { type: 'role', role: 'destination' },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: { marker: 'into', markerAlternatives: ['in', 'to'] },\n },\n },\n {\n id: 'put-en-before',\n language: 'en',\n command: 'put',\n priority: 95,\n template: {\n format: 'put {patient} before {destination}',\n tokens: [\n { type: 'literal', value: 'put' },\n { type: 'role', role: 'patient' },\n { type: 'literal', value: 'before' },\n { type: 'role', role: 'destination' },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: { marker: 'before' },\n manner: { default: { type: 'literal', value: 'before' } },\n },\n },\n {\n id: 'put-en-after',\n language: 'en',\n command: 'put',\n priority: 95,\n template: {\n format: 'put {patient} after {destination}',\n tokens: [\n { type: 'literal', value: 'put' },\n { type: 'role', role: 'patient' },\n { type: 'literal', value: 'after' },\n { type: 'role', role: 'destination' },\n ],\n },\n extraction: {\n patient: { position: 1 },\n destination: { marker: 'after' },\n manner: { default: { type: 'literal', value: 'after' } },\n },\n },\n ];\n}\n","/**\n * English Event Handler Patterns\n *\n * Tree-shakeable: Only included when English is imported.\n */\n\nimport type { LanguagePattern } from '../../types';\n\n/**\n * Get English event handler patterns.\n */\nexport function getEventHandlerPatternsEn(): LanguagePattern[] {\n return [\n {\n id: 'event-en-when-source',\n language: 'en',\n command: 'on',\n priority: 115,\n template: {\n format: 'when {event} from {source} {body}',\n tokens: [\n { type: 'literal', value: 'when' },\n { type: 'role', role: 'event' },\n { type: 'literal', value: 'from' },\n { type: 'role', role: 'source' },\n ],\n },\n extraction: {\n event: { position: 1 },\n source: { marker: 'from' },\n },\n },\n {\n id: 'event-en-when',\n language: 'en',\n command: 'on',\n priority: 105,\n template: {\n format: 'when {event} {body}',\n tokens: [\n { type: 'literal', value: 'when' },\n { type: 'role', role: 'event' },\n ],\n },\n extraction: {\n event: { position: 1 },\n },\n },\n {\n id: 'event-en-source',\n language: 'en',\n command: 'on',\n priority: 110,\n template: {\n format: 'on {event} from {source} {body}',\n tokens: [\n { type: 'literal', value: 'on' },\n { type: 'role', role: 'event' },\n { type: 'literal', value: 'from' },\n { type: 'role', role: 'source' },\n ],\n },\n extraction: {\n event: { position: 1 },\n source: { marker: 'from' },\n },\n },\n {\n id: 'event-en-standard',\n language: 'en',\n command: 'on',\n priority: 100,\n template: {\n format: 'on {event} {body}',\n tokens: [\n { type: 'literal', value: 'on' },\n { type: 'role', role: 'event' },\n ],\n },\n extraction: {\n event: { position: 1 },\n },\n },\n {\n id: 'event-en-upon',\n language: 'en',\n command: 'on',\n priority: 98,\n template: {\n format: 'upon {event} {body}',\n tokens: [\n { type: 'literal', value: 'upon' },\n { type: 'role', role: 'event' },\n ],\n },\n extraction: {\n event: { position: 1 },\n },\n },\n {\n id: 'event-en-if',\n language: 'en',\n command: 'on',\n priority: 95,\n template: {\n format: 'if {event} {body}',\n tokens: [\n { type: 'literal', value: 'if' },\n { type: 'role', role: 'event' },\n ],\n },\n extraction: {\n event: { position: 1 },\n },\n },\n ];\n}\n","/**\n * English Patterns Module\n *\n * Builds all patterns for English language.\n * This module is imported by languages/en.ts and only includes English patterns.\n */\n\nimport type { LanguagePattern } from '../types';\nimport { englishProfile } from '../generators/profiles/english';\nimport { generatePatternsForLanguage } from '../generators/pattern-generator';\n\n// Import directly from per-language files for tree-shaking\nimport { getTogglePatternsEn } from './toggle/en';\nimport { getPutPatternsEn } from './put/en';\nimport { getEventHandlerPatternsEn } from './event-handler/en';\n\n// =============================================================================\n// Hand-crafted English-only patterns\n// =============================================================================\n\n/**\n * English: \"fetch /url as json\" with response type.\n */\nconst fetchWithResponseTypeEnglish: LanguagePattern = {\n id: 'fetch-en-with-response-type',\n language: 'en',\n command: 'fetch',\n priority: 90,\n template: {\n format: 'fetch {source} as {responseType}',\n tokens: [\n { type: 'literal', value: 'fetch' },\n { type: 'role', role: 'source', expectedTypes: ['literal', 'expression'] },\n { type: 'literal', value: 'as' },\n { type: 'role', role: 'responseType', expectedTypes: ['literal', 'expression'] },\n ],\n },\n extraction: {\n source: { position: 1 },\n responseType: { marker: 'as' },\n },\n};\n\n/**\n * English: \"fetch /url\" without \"from\" preposition.\n */\nconst fetchSimpleEnglish: LanguagePattern = {\n id: 'fetch-en-simple',\n language: 'en',\n command: 'fetch',\n priority: 80,\n template: {\n format: 'fetch {source}',\n tokens: [\n { type: 'literal', value: 'fetch' },\n { type: 'role', role: 'source' },\n ],\n },\n extraction: {\n source: { position: 1 },\n },\n};\n\n/**\n * English: \"swap <strategy> <target>\" without prepositions.\n */\nconst swapSimpleEnglish: LanguagePattern = {\n id: 'swap-en-handcrafted',\n language: 'en',\n command: 'swap',\n priority: 110,\n template: {\n format: 'swap {method} {destination}',\n tokens: [\n { type: 'literal', value: 'swap' },\n { type: 'role', role: 'method' },\n { type: 'role', role: 'destination' },\n ],\n },\n extraction: {\n method: { position: 1 },\n destination: { position: 2 },\n },\n};\n\n/**\n * English: \"repeat until event pointerup from document\"\n */\nconst repeatUntilEventFromEnglish: LanguagePattern = {\n id: 'repeat-en-until-event-from',\n language: 'en',\n command: 'repeat',\n priority: 120,\n template: {\n format: 'repeat until event {event} from {source}',\n tokens: [\n { type: 'literal', value: 'repeat' },\n { type: 'literal', value: 'until' },\n { type: 'literal', value: 'event' },\n { type: 'role', role: 'event', expectedTypes: ['literal', 'expression'] },\n { type: 'literal', value: 'from' },\n { type: 'role', role: 'source', expectedTypes: ['selector', 'reference', 'expression'] },\n ],\n },\n extraction: {\n event: { marker: 'event' },\n source: { marker: 'from' },\n loopType: { default: { type: 'literal', value: 'until-event' } },\n },\n};\n\n/**\n * English: \"repeat until event pointerup\"\n */\nconst repeatUntilEventEnglish: LanguagePattern = {\n id: 'repeat-en-until-event',\n language: 'en',\n command: 'repeat',\n priority: 110,\n template: {\n format: 'repeat until event {event}',\n tokens: [\n { type: 'literal', value: 'repeat' },\n { type: 'literal', value: 'until' },\n { type: 'literal', value: 'event' },\n { type: 'role', role: 'event', expectedTypes: ['literal', 'expression'] },\n ],\n },\n extraction: {\n event: { marker: 'event' },\n loopType: { default: { type: 'literal', value: 'until-event' } },\n },\n};\n\n/**\n * English: \"set {target} to {value}\" with possessive syntax support\n */\nconst setPossessiveEnglish: LanguagePattern = {\n id: 'set-en-possessive',\n language: 'en',\n command: 'set',\n priority: 100,\n template: {\n format: 'set {destination} to {patient}',\n tokens: [\n { type: 'literal', value: 'set' },\n {\n type: 'role',\n role: 'destination',\n expectedTypes: ['property-path', 'selector', 'reference', 'expression'],\n },\n { type: 'literal', value: 'to' },\n { type: 'role', role: 'patient', expectedTypes: ['literal', 'expression', 'reference'] },\n ],\n },\n extraction: {\n destination: { position: 1 },\n patient: { marker: 'to' },\n },\n};\n\n/**\n * English: \"for {variable} in {collection}\"\n */\nconst forEnglish: LanguagePattern = {\n id: 'for-en-basic',\n language: 'en',\n command: 'for',\n priority: 100,\n template: {\n format: 'for {patient} in {source}',\n tokens: [\n { type: 'literal', value: 'for' },\n { type: 'role', role: 'patient', expectedTypes: ['expression', 'reference'] },\n { type: 'literal', value: 'in' },\n { type: 'role', role: 'source', expectedTypes: ['selector', 'expression', 'reference'] },\n ],\n },\n extraction: {\n patient: { position: 1 },\n source: { marker: 'in' },\n loopType: { default: { type: 'literal', value: 'for' } },\n },\n};\n\n/**\n * English: \"if {condition}\"\n */\nconst ifEnglish: LanguagePattern = {\n id: 'if-en-basic',\n language: 'en',\n command: 'if',\n priority: 100,\n template: {\n format: 'if {condition}',\n tokens: [\n { type: 'literal', value: 'if' },\n { type: 'role', role: 'condition', expectedTypes: ['expression', 'reference', 'selector'] },\n ],\n },\n extraction: {\n condition: { position: 1 },\n },\n};\n\n/**\n * English: \"unless {condition}\"\n */\nconst unlessEnglish: LanguagePattern = {\n id: 'unless-en-basic',\n language: 'en',\n command: 'unless',\n priority: 100,\n template: {\n format: 'unless {condition}',\n tokens: [\n { type: 'literal', value: 'unless' },\n { type: 'role', role: 'condition', expectedTypes: ['expression', 'reference', 'selector'] },\n ],\n },\n extraction: {\n condition: { position: 1 },\n },\n};\n\n/**\n * English: \"in 2s toggle .active\" - Natural temporal delay\n */\nconst temporalInEnglish: LanguagePattern = {\n id: 'temporal-en-in',\n language: 'en',\n command: 'wait',\n priority: 95,\n template: {\n format: 'in {duration}',\n tokens: [\n { type: 'literal', value: 'in' },\n { type: 'role', role: 'duration', expectedTypes: ['literal', 'expression'] },\n ],\n },\n extraction: {\n duration: { position: 1 },\n },\n};\n\n/**\n * English: \"after 2s show #tooltip\" - Natural temporal delay\n */\nconst temporalAfterEnglish: LanguagePattern = {\n id: 'temporal-en-after',\n language: 'en',\n command: 'wait',\n priority: 95,\n template: {\n format: 'after {duration}',\n tokens: [\n { type: 'literal', value: 'after' },\n { type: 'role', role: 'duration', expectedTypes: ['literal', 'expression'] },\n ],\n },\n extraction: {\n duration: { position: 1 },\n },\n};\n\n// =============================================================================\n// Build All English Patterns\n// =============================================================================\n\n/**\n * Build all English patterns.\n * Called once when the English language module is imported.\n */\nexport function buildEnglishPatterns(): LanguagePattern[] {\n const patterns: LanguagePattern[] = [];\n\n // 1. Hand-crafted patterns\n patterns.push(...getTogglePatternsEn());\n patterns.push(...getPutPatternsEn());\n patterns.push(...getEventHandlerPatternsEn());\n\n // 2. English-only hand-crafted patterns\n patterns.push(\n fetchWithResponseTypeEnglish,\n fetchSimpleEnglish,\n swapSimpleEnglish,\n repeatUntilEventFromEnglish,\n repeatUntilEventEnglish,\n setPossessiveEnglish,\n forEnglish,\n ifEnglish,\n unlessEnglish,\n temporalInEnglish,\n temporalAfterEnglish\n );\n\n // 3. Generated patterns for English\n const generatedPatterns = generatePatternsForLanguage(englishProfile);\n patterns.push(...generatedPatterns);\n\n return patterns;\n}\n","/**\n * English Language Module\n *\n * Self-registering module for English language support.\n * Importing this module registers English tokenizer, profile, and patterns.\n *\n * This module enables tree-shaking by directly importing only English-specific\n * code, avoiding the patterns/index.ts barrel which pulls in all languages.\n *\n * @example\n * ```typescript\n * import '@lokascript/semantic/languages/en';\n * ```\n */\n\nimport { registerLanguage, registerPatterns } from '../registry';\nimport { englishTokenizer } from '../tokenizers/english';\nimport { englishProfile } from '../generators/profiles/english';\nimport { buildEnglishPatterns } from '../patterns/en';\n\n// Re-export for direct access\nexport { englishTokenizer } from '../tokenizers/english';\nexport { englishProfile } from '../generators/profiles/english';\n\n// Auto-register when this module is imported\nregisterLanguage('en', englishTokenizer, englishProfile);\n\n// Register English patterns directly (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