@lokascript/compilation-service 2.0.0 → 2.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/index.cjs CHANGED
@@ -41,6 +41,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
41
41
  // ../core/dist/index.mjs
42
42
  var dist_exports = {};
43
43
  __export(dist_exports, {
44
+ DebugController: () => DebugController,
44
45
  Lexer: () => Lexer,
45
46
  Runtime: () => Runtime,
46
47
  RuntimeBase: () => RuntimeBase,
@@ -56,6 +57,7 @@ __export(dist_exports, {
56
57
  createBehaviorsFeature: () => createBehaviorsFeature,
57
58
  createChildContext: () => createChildContext,
58
59
  createContext: () => createContext,
60
+ createDebugController: () => createDebugController,
59
61
  createDef: () => createDef,
60
62
  createDefFeature: () => createDefFeature,
61
63
  createEventSource: () => createEventSource,
@@ -6843,6 +6845,65 @@ function createReference$1(value) {
6843
6845
  function createPropertyPath$1(object, property) {
6844
6846
  return { type: "property-path", object, property };
6845
6847
  }
6848
+ function createFlag(name, enabled = true) {
6849
+ return { type: "flag", name, enabled };
6850
+ }
6851
+ function createCommandNode$1(action, roles, metadata) {
6852
+ const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
6853
+ const node = {
6854
+ kind: "command",
6855
+ action,
6856
+ roles: rolesMap
6857
+ };
6858
+ if (metadata) {
6859
+ return { ...node, metadata };
6860
+ }
6861
+ return node;
6862
+ }
6863
+ function createEventHandlerNode(action, roles, body, metadata, eventModifiers) {
6864
+ const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
6865
+ const base = {
6866
+ kind: "event-handler",
6867
+ action,
6868
+ roles: rolesMap,
6869
+ body
6870
+ };
6871
+ return {
6872
+ ...base,
6873
+ ...eventModifiers,
6874
+ ...metadata && { metadata }
6875
+ };
6876
+ }
6877
+ function createConditionalNode$1(action, roles, thenBranch, elseBranch, metadata) {
6878
+ const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
6879
+ const base = {
6880
+ kind: "conditional",
6881
+ action,
6882
+ roles: rolesMap,
6883
+ thenBranch
6884
+ };
6885
+ return {
6886
+ ...base,
6887
+ ...elseBranch && { elseBranch },
6888
+ ...metadata && { metadata }
6889
+ };
6890
+ }
6891
+ function createLoopNode$1(action, roles, loopVariant, body, loopVariable, indexVariable, metadata) {
6892
+ const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
6893
+ const base = {
6894
+ kind: "loop",
6895
+ action,
6896
+ roles: rolesMap,
6897
+ loopVariant,
6898
+ body
6899
+ };
6900
+ return {
6901
+ ...base,
6902
+ ...loopVariable && { loopVariable },
6903
+ ...indexVariable && { indexVariable },
6904
+ ...metadata && { metadata }
6905
+ };
6906
+ }
6846
6907
  function createLogger(namespace) {
6847
6908
  return new DebugLogger(namespace);
6848
6909
  }
@@ -6880,6 +6941,341 @@ function createTokenizerContext(tokenizer) {
6880
6941
  }
6881
6942
  return ctx;
6882
6943
  }
6944
+ function isValidReference2(value, referenceSet = DEFAULT_REFERENCES) {
6945
+ return referenceSet.has(value);
6946
+ }
6947
+ function isNestedCommand(value) {
6948
+ const inner = value.slice(1, -1);
6949
+ let depth = 0;
6950
+ for (const ch of inner) {
6951
+ if (ch === "[") depth++;
6952
+ else if (ch === "]") depth--;
6953
+ else if (depth === 0 && (ch === " " || ch === ":")) return true;
6954
+ }
6955
+ return false;
6956
+ }
6957
+ function parseExplicit$1(input, options = {}) {
6958
+ const trimmed = input.trim();
6959
+ if (!trimmed.startsWith("[") || !trimmed.endsWith("]")) {
6960
+ throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");
6961
+ }
6962
+ const content = trimmed.slice(1, -1).trim();
6963
+ if (!content) {
6964
+ throw new Error("Empty explicit statement");
6965
+ }
6966
+ const tokens = tokenizeExplicit(content);
6967
+ if (tokens.length === 0) {
6968
+ throw new Error("No command specified in explicit statement");
6969
+ }
6970
+ const command2 = tokens[0].toLowerCase();
6971
+ const roles = /* @__PURE__ */ new Map();
6972
+ const refSet = options.referenceSet ?? DEFAULT_REFERENCES;
6973
+ const schema = options.schemaLookup?.getSchema(command2);
6974
+ const validRoleNames = schema ? new Set(schema.roles.map((r) => r.role)) : null;
6975
+ for (let i = 1; i < tokens.length; i++) {
6976
+ const token = tokens[i];
6977
+ if (token.startsWith("+") || token.startsWith("~")) {
6978
+ const enabled = token.startsWith("+");
6979
+ const flagName = token.slice(1);
6980
+ if (!flagName) {
6981
+ throw new Error(`Empty flag name: "${token}"`);
6982
+ }
6983
+ if (validRoleNames && !validRoleNames.has(flagName)) {
6984
+ const roleList = [...validRoleNames].join(", ");
6985
+ throw new Error(
6986
+ `Unknown flag "${flagName}" for command "${command2}". Valid roles: ${roleList}`
6987
+ );
6988
+ }
6989
+ roles.set(flagName, createFlag(flagName, enabled));
6990
+ continue;
6991
+ }
6992
+ const colonIndex = token.indexOf(":");
6993
+ if (colonIndex === -1) {
6994
+ throw new Error(`Invalid role format: "${token}". Expected role:value or +flag`);
6995
+ }
6996
+ const roleName = token.slice(0, colonIndex);
6997
+ if (validRoleNames && !STRUCTURAL_ROLES.has(roleName) && !validRoleNames.has(roleName)) {
6998
+ const roleList = [...validRoleNames].join(", ");
6999
+ throw new Error(
7000
+ `Unknown role "${roleName}" for command "${command2}". Valid roles: ${roleList}`
7001
+ );
7002
+ }
7003
+ const role = roleName;
7004
+ const valueStr = token.slice(colonIndex + 1);
7005
+ if (STRUCTURAL_ROLES.has(roleName) && valueStr.startsWith("[") && isNestedCommand(valueStr)) {
7006
+ const nestedEnd = findMatchingBracket(token, colonIndex + 1);
7007
+ const nestedSyntax = token.slice(colonIndex + 1, nestedEnd + 1);
7008
+ roles.set(role, { type: "expression", raw: nestedSyntax });
7009
+ continue;
7010
+ }
7011
+ const value = parseExplicitValue(valueStr, refSet);
7012
+ roles.set(role, value);
7013
+ }
7014
+ if (schema && command2 !== "on") {
7015
+ for (const roleSpec of schema.roles) {
7016
+ if (roleSpec.required && !roles.has(roleSpec.role) && !roleSpec.default) {
7017
+ throw new Error(
7018
+ `Missing required role "${roleSpec.role}" for command "${command2}": ${roleSpec.description}`
7019
+ );
7020
+ }
7021
+ }
7022
+ }
7023
+ switch (command2) {
7024
+ case "on": {
7025
+ const eventValue = roles.get("event");
7026
+ if (!eventValue) {
7027
+ throw new Error("Event handler requires event role: [on event:click ...]");
7028
+ }
7029
+ const body = extractStructuralBody(roles, "body", options);
7030
+ roles.delete("body");
7031
+ return createEventHandlerNode("on", roles, body, {
7032
+ sourceLanguage: "explicit"
7033
+ });
7034
+ }
7035
+ case "if": {
7036
+ const thenBranch = extractStructuralBody(roles, "then", options);
7037
+ const elseBranch = extractStructuralBody(roles, "else", options);
7038
+ roles.delete("then");
7039
+ roles.delete("else");
7040
+ return createConditionalNode$1(
7041
+ command2,
7042
+ roles,
7043
+ thenBranch,
7044
+ elseBranch.length > 0 ? elseBranch : void 0,
7045
+ {
7046
+ sourceLanguage: "explicit"
7047
+ }
7048
+ );
7049
+ }
7050
+ case "repeat": {
7051
+ const loopBody = extractStructuralBody(roles, "loop-body", options);
7052
+ const loopVariantValue = roles.get("loop-variant");
7053
+ const variableValue = roles.get("variable");
7054
+ const indexVariableValue = roles.get("index-variable");
7055
+ roles.delete("loop-body");
7056
+ roles.delete("loop-variant");
7057
+ roles.delete("variable");
7058
+ roles.delete("index-variable");
7059
+ let variant;
7060
+ if (loopVariantValue && loopVariantValue.type === "literal" && typeof loopVariantValue.value === "string") {
7061
+ variant = loopVariantValue.value;
7062
+ } else if (roles.has("quantity")) {
7063
+ variant = "times";
7064
+ } else if (roles.has("source")) {
7065
+ variant = "for";
7066
+ } else if (roles.has("condition")) {
7067
+ variant = "while";
7068
+ } else {
7069
+ variant = "forever";
7070
+ }
7071
+ const loopVariable = variableValue?.type === "literal" && typeof variableValue.value === "string" ? variableValue.value : variableValue?.type === "expression" ? variableValue.raw : void 0;
7072
+ const indexVariable = indexVariableValue?.type === "literal" && typeof indexVariableValue.value === "string" ? indexVariableValue.value : void 0;
7073
+ return createLoopNode$1(command2, roles, variant, loopBody, loopVariable, indexVariable, {
7074
+ sourceLanguage: "explicit"
7075
+ });
7076
+ }
7077
+ default:
7078
+ return createCommandNode$1(command2, roles, {
7079
+ sourceLanguage: "explicit"
7080
+ });
7081
+ }
7082
+ }
7083
+ function isExplicitSyntax(input) {
7084
+ const trimmed = input.trim();
7085
+ return trimmed.startsWith("[") && trimmed.endsWith("]");
7086
+ }
7087
+ function extractStructuralBody(roles, roleName, options) {
7088
+ const value = roles.get(roleName);
7089
+ if (!value) return [];
7090
+ if (value.type === "expression") {
7091
+ return [parseExplicit$1(value.raw, options)];
7092
+ }
7093
+ return [];
7094
+ }
7095
+ function inferSelectorKind(value) {
7096
+ if (!value) return void 0;
7097
+ if (value.startsWith("#")) return "id";
7098
+ if (value.startsWith(".")) return "class";
7099
+ if (value.startsWith("[")) return "attribute";
7100
+ if (value.startsWith("<") || value.startsWith("*")) return "element";
7101
+ if (/[>+~ ]/.test(value) && value.length > 1) return "complex";
7102
+ return void 0;
7103
+ }
7104
+ function tokenizeExplicit(content) {
7105
+ const tokens = [];
7106
+ let current = "";
7107
+ let inString = false;
7108
+ let stringChar = "";
7109
+ let bracketDepth = 0;
7110
+ for (let i = 0; i < content.length; i++) {
7111
+ const char = content[i];
7112
+ if (inString) {
7113
+ current += char;
7114
+ if (char === stringChar && content[i - 1] !== "\\") {
7115
+ inString = false;
7116
+ }
7117
+ continue;
7118
+ }
7119
+ if (char === '"' || char === "'") {
7120
+ inString = true;
7121
+ stringChar = char;
7122
+ current += char;
7123
+ continue;
7124
+ }
7125
+ if (char === "[") {
7126
+ bracketDepth++;
7127
+ current += char;
7128
+ continue;
7129
+ }
7130
+ if (char === "]") {
7131
+ bracketDepth--;
7132
+ current += char;
7133
+ continue;
7134
+ }
7135
+ if (char === " " && bracketDepth === 0) {
7136
+ if (current) {
7137
+ tokens.push(current);
7138
+ current = "";
7139
+ }
7140
+ continue;
7141
+ }
7142
+ current += char;
7143
+ }
7144
+ if (current) {
7145
+ tokens.push(current);
7146
+ }
7147
+ return tokens;
7148
+ }
7149
+ function parseExplicitValue(valueStr, referenceSet) {
7150
+ if (valueStr.startsWith("#") || valueStr.startsWith(".") || valueStr.startsWith("[") || valueStr.startsWith("@") || valueStr.startsWith("*")) {
7151
+ return createSelector$1(valueStr, inferSelectorKind(valueStr));
7152
+ }
7153
+ if (valueStr.startsWith('"') || valueStr.startsWith("'")) {
7154
+ const inner = valueStr.slice(1, -1);
7155
+ return createLiteral$1(inner, "string");
7156
+ }
7157
+ if (valueStr === "true") return createLiteral$1(true, "boolean");
7158
+ if (valueStr === "false") return createLiteral$1(false, "boolean");
7159
+ const lowerRef = valueStr.toLowerCase();
7160
+ if (isValidReference2(lowerRef, referenceSet)) {
7161
+ return createReference$1(lowerRef);
7162
+ }
7163
+ const numMatch = valueStr.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);
7164
+ if (numMatch) {
7165
+ const num = parseFloat(numMatch[1]);
7166
+ const suffix = numMatch[2];
7167
+ if (suffix) {
7168
+ return createLiteral$1(valueStr, "duration");
7169
+ }
7170
+ return createLiteral$1(num, "number");
7171
+ }
7172
+ return createLiteral$1(valueStr);
7173
+ }
7174
+ function findMatchingBracket(str, start) {
7175
+ let depth = 0;
7176
+ for (let i = start; i < str.length; i++) {
7177
+ if (str[i] === "[") depth++;
7178
+ else if (str[i] === "]") {
7179
+ depth--;
7180
+ if (depth === 0) return i;
7181
+ }
7182
+ }
7183
+ return str.length - 1;
7184
+ }
7185
+ function renderExplicit$1(node) {
7186
+ if (node.kind === "compound") {
7187
+ const compoundNode = node;
7188
+ const renderedStatements = compoundNode.statements.map((stmt) => renderExplicit$1(stmt));
7189
+ return renderedStatements.join(` ${compoundNode.chainType} `);
7190
+ }
7191
+ const parts = [node.action];
7192
+ for (const [role, value] of node.roles) {
7193
+ if (value.type === "flag") {
7194
+ parts.push(value.enabled ? `+${value.name}` : `~${value.name}`);
7195
+ } else {
7196
+ parts.push(`${role}:${valueToString(value)}`);
7197
+ }
7198
+ }
7199
+ if (node.kind === "event-handler") {
7200
+ const eventNode = node;
7201
+ if (eventNode.body && eventNode.body.length > 0) {
7202
+ const bodyParts = eventNode.body.map((n) => renderExplicit$1(n));
7203
+ parts.push(`body:${bodyParts.join(" ")}`);
7204
+ }
7205
+ }
7206
+ if (node.kind === "conditional") {
7207
+ const condNode = node;
7208
+ if (condNode.thenBranch && condNode.thenBranch.length > 0) {
7209
+ const thenParts = condNode.thenBranch.map((n) => renderExplicit$1(n));
7210
+ parts.push(`then:${thenParts.join(" ")}`);
7211
+ }
7212
+ if (condNode.elseBranch && condNode.elseBranch.length > 0) {
7213
+ const elseParts = condNode.elseBranch.map((n) => renderExplicit$1(n));
7214
+ parts.push(`else:${elseParts.join(" ")}`);
7215
+ }
7216
+ }
7217
+ if (node.kind === "loop") {
7218
+ const loopNode = node;
7219
+ if (loopNode.loopVariant) {
7220
+ parts.push(`loop-variant:${loopNode.loopVariant}`);
7221
+ }
7222
+ if (loopNode.loopVariable) {
7223
+ parts.push(`variable:${loopNode.loopVariable}`);
7224
+ }
7225
+ if (loopNode.indexVariable) {
7226
+ parts.push(`index-variable:${loopNode.indexVariable}`);
7227
+ }
7228
+ if (loopNode.body && loopNode.body.length > 0) {
7229
+ const bodyParts = loopNode.body.map((n) => renderExplicit$1(n));
7230
+ parts.push(`loop-body:${bodyParts.join(" ")}`);
7231
+ }
7232
+ }
7233
+ if (node.kind === "command") {
7234
+ const cmd = node;
7235
+ if (cmd.body && cmd.body.length > 0) {
7236
+ const bodyParts = cmd.body.map((n) => renderExplicit$1(n));
7237
+ parts.push(`body:${bodyParts.join(" ")}`);
7238
+ }
7239
+ if (cmd.catchBranch && cmd.catchBranch.length > 0) {
7240
+ const catchParts = cmd.catchBranch.map((n) => renderExplicit$1(n));
7241
+ parts.push(`catch:${catchParts.join(" ")}`);
7242
+ }
7243
+ if (cmd.finallyBranch && cmd.finallyBranch.length > 0) {
7244
+ const finallyParts = cmd.finallyBranch.map((n) => renderExplicit$1(n));
7245
+ parts.push(`finally:${finallyParts.join(" ")}`);
7246
+ }
7247
+ if (cmd.asyncVariant) {
7248
+ parts.push(`async-variant:${cmd.asyncVariant}`);
7249
+ }
7250
+ if (cmd.asyncBody && cmd.asyncBody.length > 0) {
7251
+ const asyncParts = cmd.asyncBody.map((n) => renderExplicit$1(n));
7252
+ parts.push(`async-body:${asyncParts.join(" ")}`);
7253
+ }
7254
+ }
7255
+ return `[${parts.join(" ")}]`;
7256
+ }
7257
+ function valueToString(value) {
7258
+ switch (value.type) {
7259
+ case "literal":
7260
+ if (typeof value.value === "string") {
7261
+ if (value.dataType === "string" || /\s/.test(value.value)) {
7262
+ return `"${value.value}"`;
7263
+ }
7264
+ return value.value;
7265
+ }
7266
+ return String(value.value);
7267
+ case "selector":
7268
+ return value.value;
7269
+ case "reference":
7270
+ return value.value;
7271
+ case "property-path":
7272
+ return `${valueToString(value.object)}'s ${value.property}`;
7273
+ case "expression":
7274
+ return value.raw;
7275
+ case "flag":
7276
+ return value.name;
7277
+ }
7278
+ }
6883
7279
  function createPosition(start, end) {
6884
7280
  return { start, end };
6885
7281
  }
@@ -7702,6 +8098,20 @@ function validateCommandSchema(schema) {
7702
8098
  );
7703
8099
  }
7704
8100
  }
8101
+ for (const role of schema.roles) {
8102
+ if (role.selectorKinds && role.selectorKinds.length > 0) {
8103
+ if (!role.expectedTypes.includes("selector")) {
8104
+ items.push(
8105
+ createSchemaValidationItem(
8106
+ SchemaErrorCodes.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,
8107
+ "warning",
8108
+ { role: role.role },
8109
+ role.role
8110
+ )
8111
+ );
8112
+ }
8113
+ }
8114
+ }
7705
8115
  switch (schema.action) {
7706
8116
  case "transition":
7707
8117
  validateTransitionSchema(schema, items);
@@ -7866,6 +8276,34 @@ function getValidationStats(validations) {
7866
8276
  byCode
7867
8277
  };
7868
8278
  }
8279
+ function validateRoleValues(schema, values) {
8280
+ const diagnostics = [];
8281
+ for (const value of values) {
8282
+ const roleSpec = schema.roles.find((r) => r.role === value.role);
8283
+ if (!roleSpec) continue;
8284
+ if (roleSpec.expectedTypes.length > 0 && !roleSpec.expectedTypes.includes(value.type)) {
8285
+ if (!roleSpec.expectedTypes.includes("expression")) {
8286
+ diagnostics.push({
8287
+ level: "error",
8288
+ role: value.role,
8289
+ message: `${schema.action}.${value.role} expects type [${roleSpec.expectedTypes.join(", ")}], got '${value.type}'`,
8290
+ code: SchemaErrorCodes.VALUE_TYPE_MISMATCH
8291
+ });
8292
+ }
8293
+ }
8294
+ if (value.type === "selector" && value.selectorKind && roleSpec.selectorKinds && roleSpec.selectorKinds.length > 0) {
8295
+ if (!roleSpec.selectorKinds.includes(value.selectorKind)) {
8296
+ diagnostics.push({
8297
+ level: "error",
8298
+ role: value.role,
8299
+ message: `${schema.action}.${value.role} expects selector kind [${roleSpec.selectorKinds.join(", ")}], got '${value.selectorKind}'`,
8300
+ code: SchemaErrorCodes.SELECTOR_KIND_MISMATCH
8301
+ });
8302
+ }
8303
+ }
8304
+ }
8305
+ return diagnostics;
8306
+ }
7869
8307
  function validateKeywordCollisions(profile) {
7870
8308
  const collisions = [];
7871
8309
  if (!profile.keywords) {
@@ -9534,7 +9972,7 @@ function createLiteral(value, dataType) {
9534
9972
  return result;
9535
9973
  }
9536
9974
  function isValidReference(value) {
9537
- return VALID_REFERENCES.has(value);
9975
+ return isValidReference2(value);
9538
9976
  }
9539
9977
  function createReference(value) {
9540
9978
  return { type: "reference", value };
@@ -9679,163 +10117,10 @@ function renderExplicit(node) {
9679
10117
  return semanticRenderer.renderExplicit(node);
9680
10118
  }
9681
10119
  function parseExplicit(input) {
9682
- const trimmed = input.trim();
9683
- if (!trimmed.startsWith("[") || !trimmed.endsWith("]")) {
9684
- throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");
9685
- }
9686
- const content = trimmed.slice(1, -1).trim();
9687
- if (!content) {
9688
- throw new Error("Empty explicit statement");
9689
- }
9690
- const tokens = tokenizeExplicit(content);
9691
- if (tokens.length === 0) {
9692
- throw new Error("No command specified in explicit statement");
9693
- }
9694
- const command2 = tokens[0].toLowerCase();
9695
- const roles = /* @__PURE__ */ new Map();
9696
- const schema = getSchema(command2);
9697
- const validRoleNames = schema ? new Set(schema.roles.map((r) => r.role)) : null;
9698
- for (let i = 1; i < tokens.length; i++) {
9699
- const token = tokens[i];
9700
- const colonIndex = token.indexOf(":");
9701
- if (colonIndex === -1) {
9702
- throw new Error(`Invalid role format: "${token}". Expected role:value`);
9703
- }
9704
- const roleName = token.slice(0, colonIndex);
9705
- if (validRoleNames && roleName !== "body" && !validRoleNames.has(roleName)) {
9706
- const roleList = [...validRoleNames].join(", ");
9707
- throw new Error(
9708
- `Unknown role "${roleName}" for command "${command2}". Valid roles: ${roleList}`
9709
- );
9710
- }
9711
- const role = roleName;
9712
- const valueStr = token.slice(colonIndex + 1);
9713
- if (role === "body" && valueStr.startsWith("[")) {
9714
- const nestedEnd = findMatchingBracket(token, colonIndex + 1);
9715
- const nestedSyntax = token.slice(colonIndex + 1, nestedEnd + 1);
9716
- roles.set(role, { type: "expression", raw: nestedSyntax });
9717
- continue;
9718
- }
9719
- const value = parseExplicitValue(valueStr);
9720
- roles.set(role, value);
9721
- }
9722
- if (schema && command2 !== "on") {
9723
- for (const roleSpec of schema.roles) {
9724
- if (roleSpec.required && !roles.has(roleSpec.role) && !roleSpec.default) {
9725
- throw new Error(
9726
- `Missing required role "${roleSpec.role}" for command "${command2}": ${roleSpec.description}`
9727
- );
9728
- }
9729
- }
9730
- }
9731
- if (command2 === "on") {
9732
- const eventValue = roles.get("event");
9733
- if (!eventValue) {
9734
- throw new Error("Event handler requires event role: [on event:click ...]");
9735
- }
9736
- const bodyValue = roles.get("body");
9737
- const body = [];
9738
- if (bodyValue && bodyValue.type === "expression") {
9739
- body.push(parseExplicit(bodyValue.raw));
9740
- }
9741
- roles.delete("body");
9742
- return createEventHandler(eventValue, body, void 0, {
9743
- sourceLanguage: "explicit"
9744
- });
9745
- }
9746
- const rolesObj = {};
9747
- for (const [role, value] of roles) {
9748
- rolesObj[role] = value;
9749
- }
9750
- return createCommandNode(command2, rolesObj, {
9751
- sourceLanguage: "explicit"
10120
+ return parseExplicit$1(input, {
10121
+ schemaLookup: hyperscriptSchemaLookup
9752
10122
  });
9753
10123
  }
9754
- function tokenizeExplicit(content) {
9755
- const tokens = [];
9756
- let current = "";
9757
- let inString = false;
9758
- let stringChar = "";
9759
- let bracketDepth = 0;
9760
- for (let i = 0; i < content.length; i++) {
9761
- const char = content[i];
9762
- if (inString) {
9763
- current += char;
9764
- if (char === stringChar && content[i - 1] !== "\\") {
9765
- inString = false;
9766
- }
9767
- continue;
9768
- }
9769
- if (char === '"' || char === "'") {
9770
- inString = true;
9771
- stringChar = char;
9772
- current += char;
9773
- continue;
9774
- }
9775
- if (char === "[") {
9776
- bracketDepth++;
9777
- current += char;
9778
- continue;
9779
- }
9780
- if (char === "]") {
9781
- bracketDepth--;
9782
- current += char;
9783
- continue;
9784
- }
9785
- if (char === " " && bracketDepth === 0) {
9786
- if (current) {
9787
- tokens.push(current);
9788
- current = "";
9789
- }
9790
- continue;
9791
- }
9792
- current += char;
9793
- }
9794
- if (current) {
9795
- tokens.push(current);
9796
- }
9797
- return tokens;
9798
- }
9799
- function parseExplicitValue(valueStr) {
9800
- if (valueStr.startsWith("#") || valueStr.startsWith(".") || valueStr.startsWith("[") || valueStr.startsWith("@") || valueStr.startsWith("*")) {
9801
- return createSelector(valueStr);
9802
- }
9803
- if (valueStr.startsWith('"') || valueStr.startsWith("'")) {
9804
- const inner = valueStr.slice(1, -1);
9805
- return createLiteral(inner, "string");
9806
- }
9807
- if (valueStr === "true") return createLiteral(true, "boolean");
9808
- if (valueStr === "false") return createLiteral(false, "boolean");
9809
- const lowerRef = valueStr.toLowerCase();
9810
- if (isValidReference(lowerRef)) {
9811
- return createReference(lowerRef);
9812
- }
9813
- const numMatch = valueStr.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);
9814
- if (numMatch) {
9815
- const num = parseFloat(numMatch[1]);
9816
- const suffix = numMatch[2];
9817
- if (suffix) {
9818
- return createLiteral(valueStr, "duration");
9819
- }
9820
- return createLiteral(num, "number");
9821
- }
9822
- return createLiteral(valueStr, "string");
9823
- }
9824
- function findMatchingBracket(str, start) {
9825
- let depth = 0;
9826
- for (let i = start; i < str.length; i++) {
9827
- if (str[i] === "[") depth++;
9828
- else if (str[i] === "]") {
9829
- depth--;
9830
- if (depth === 0) return i;
9831
- }
9832
- }
9833
- return str.length - 1;
9834
- }
9835
- function isExplicitSyntax(input) {
9836
- const trimmed = input.trim();
9837
- return trimmed.startsWith("[") && trimmed.endsWith("]");
9838
- }
9839
10124
  function parse(input, language) {
9840
10125
  return semanticParser.parse(input, language);
9841
10126
  }
@@ -17417,6 +17702,8 @@ function semanticValuesEqual(a, b) {
17417
17702
  return semanticValuesEqual(a.object, b.object) && a.property === b.property;
17418
17703
  case "expression":
17419
17704
  return a.raw === b.raw;
17705
+ case "flag":
17706
+ return a.name === b.name && a.enabled === b.enabled;
17420
17707
  default:
17421
17708
  return false;
17422
17709
  }
@@ -18195,6 +18482,8 @@ function convertValue(value, warnings) {
18195
18482
  return convertPropertyPath(value, warnings);
18196
18483
  case "expression":
18197
18484
  return convertExpression(value);
18485
+ case "flag":
18486
+ return { type: "literal", value: value.enabled };
18198
18487
  default:
18199
18488
  const _exhaustive = value;
18200
18489
  throw new Error(`Unknown semantic value type: ${_exhaustive.type}`);
@@ -18748,7 +19037,7 @@ function parseSemantic(code, language) {
18748
19037
  }
18749
19038
  function createHistorySwap(config2) {
18750
19039
  const { target, strategy = "morph", useViewTransition = false, fetchOptions = {}, transformUrl, onBeforeFetch, onAfterSwap, onError } = config2;
18751
- const resolveTarget2 = () => {
19040
+ const resolveTarget3 = () => {
18752
19041
  if (typeof target === "string") {
18753
19042
  const element = document.querySelector(target);
18754
19043
  return isHTMLElement(element) ? element : null;
@@ -18756,7 +19045,7 @@ function createHistorySwap(config2) {
18756
19045
  return isHTMLElement(target) ? target : null;
18757
19046
  };
18758
19047
  const handlePopstate = async (_event) => {
18759
- const targetElement = resolveTarget2();
19048
+ const targetElement = resolveTarget3();
18760
19049
  if (!targetElement) {
18761
19050
  console.warn(`HistorySwap: target "${target}" not found`);
18762
19051
  return;
@@ -18851,7 +19140,7 @@ function shouldHandleClick(event) {
18851
19140
  }
18852
19141
  function createBoosted(config2) {
18853
19142
  const { container, target, linkSelector = "a[href]", formSelector = "form", boostForms = false, strategy = "morph", pushUrl = true, useViewTransition = false, fetchOptions = {}, onBeforeFetch, onAfterSwap, onError } = config2;
18854
- const resolveTarget2 = () => {
19143
+ const resolveTarget3 = () => {
18855
19144
  if (!target) {
18856
19145
  return document.body;
18857
19146
  }
@@ -18862,7 +19151,7 @@ function createBoosted(config2) {
18862
19151
  return isHTMLElement(target) ? target : null;
18863
19152
  };
18864
19153
  const boost = async (url, method = "GET", body = null) => {
18865
- const targetElement = resolveTarget2();
19154
+ const targetElement = resolveTarget3();
18866
19155
  if (!targetElement) {
18867
19156
  console.warn(`Boosted: target "${target}" not found`);
18868
19157
  return;
@@ -19198,6 +19487,46 @@ function process$1(element) {
19198
19487
  console.error("Error processing hyperscript node:", error);
19199
19488
  }
19200
19489
  }
19490
+ function serializeValue(value) {
19491
+ if (value === null || value === void 0)
19492
+ return value;
19493
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
19494
+ return value;
19495
+ }
19496
+ if (value instanceof Element) {
19497
+ return describeElement(value);
19498
+ }
19499
+ if (Array.isArray(value)) {
19500
+ return `Array(${value.length})`;
19501
+ }
19502
+ if (value instanceof Map) {
19503
+ return `Map(${value.size})`;
19504
+ }
19505
+ if (value instanceof Set) {
19506
+ return `Set(${value.size})`;
19507
+ }
19508
+ if (typeof value === "function") {
19509
+ return `\u0192 ${value.name || "anonymous"}()`;
19510
+ }
19511
+ if (typeof value === "object") {
19512
+ const keys = Object.keys(value);
19513
+ if (keys.length <= 3) {
19514
+ return `{${keys.join(", ")}}`;
19515
+ }
19516
+ return `{${keys.slice(0, 3).join(", ")}, ...${keys.length - 3} more}`;
19517
+ }
19518
+ return String(value);
19519
+ }
19520
+ function describeElement(el) {
19521
+ let desc = `<${el.tagName.toLowerCase()}`;
19522
+ if (el.id)
19523
+ desc += `#${el.id}`;
19524
+ if (el.classList.length > 0) {
19525
+ desc += `.${Array.from(el.classList).join(".")}`;
19526
+ }
19527
+ desc += ">";
19528
+ return desc;
19529
+ }
19201
19530
  async function getOrCreateBridge() {
19202
19531
  if (!bridgeInstance) {
19203
19532
  const { SemanticGrammarBridge: SemanticGrammarBridge2 } = await Promise.resolve().then(function() {
@@ -19224,6 +19553,13 @@ function getDefaultParserOptions() {
19224
19553
  semanticConfidenceThreshold: config.confidenceThreshold
19225
19554
  };
19226
19555
  }
19556
+ function getDebugController() {
19557
+ if (!_debugController) {
19558
+ _debugController = new DebugController();
19559
+ getDefaultRuntime().registerHooks("__debugger", _debugController.hooks);
19560
+ }
19561
+ return _debugController;
19562
+ }
19227
19563
  function getDefaultRuntime() {
19228
19564
  if (!_defaultRuntime) {
19229
19565
  _defaultRuntime = new Runtime({
@@ -20278,6 +20614,9 @@ function flattenEventModifiers(modifiers) {
20278
20614
  flat.from = modifiers.from;
20279
20615
  return flat;
20280
20616
  }
20617
+ function createDebugController() {
20618
+ return new DebugController();
20619
+ }
20281
20620
  async function getSemanticModule() {
20282
20621
  if (!_semanticModule) {
20283
20622
  _semanticModule = await Promise.resolve().then(function() {
@@ -20286,7 +20625,7 @@ async function getSemanticModule() {
20286
20625
  }
20287
20626
  return _semanticModule;
20288
20627
  }
20289
- var KEYWORDS$2, COMMAND_TERMINATORS, COMMANDS, COMPOUND_COMMANDS, CONTROL_FLOW_COMMANDS, PUT_OPERATIONS, PUT_OPERATION_KEYWORDS, HYPERSCRIPT_KEYWORDS, CommandClassification, CSS_FUNCTIONS, CONTEXT_VARS$1, LOGICAL_OPERATORS$1, COMPARISON_OPERATORS, DOM_EVENTS, TOKENIZER_KEYWORDS, TokenKind, TokenType, KEYWORDS$1, MATHEMATICAL_OPERATORS, TIME_UNITS$1, isDebugEnabled$1, DEBUG, debug, debugEnabled, debugEventTarget, stats, DEFAULT_CONFIDENCE_THRESHOLD$1, SemanticIntegrationAdapter, MULTI_WORD_PATTERNS, DEFAULT_BOUNDARY_KEYWORDS, CommandNodeBuilder, SWAP_STRATEGY_KEYWORDS, Parser, HookRegistry, CleanupRegistry, sharedGlobals, EventSourceRegistry, ContextProviderRegistry, ExpressionTypeRegistry, expressionTypeRegistry, BOOLEAN_ATTRIBUTES, SPECIAL_DOM_PROPERTIES, BaseExpressionEvaluator, NUMBER_WORDS, isProduction, skipValidation, addDescribeToValidator, v, z, BaseExpressionImpl, MeExpression, YouExpression, ItExpression, CSSelectorInputSchema, CSSSelectorExpression, meExpression, youExpression, itExpression, itsExpression$1, resultExpression, querySelectorExpression, querySelectorAllExpression, idExpression, classExpression, closestExpression, parentExpression, windowExpression, documentExpression, elementWithSelectorExpression, styleRefExpression, possessiveStyleRefExpression, ofStyleRefExpression, referencesExpressions, LRUCache, HyperscriptCache, globalCache, PerformanceTracker, performanceTracker, cleanupInterval, BinaryLogicalInputSchema, UnaryLogicalInputSchema, AndExpression, OrExpression, NotExpression, ComparisonInputSchema, PatternMatchingInputSchema, equalsExpression, strictEqualsExpression, notEqualsExpression, strictNotEqualsExpression, lessThanExpression, lessThanOrEqualExpression, greaterThanExpression, greaterThanOrEqualExpression, andExpression, orExpression, notExpression, isEmptyExpression, noExpression, isNotEmptyExpression, existsExpression, doesNotExistExpression, containsExpression, doesNotContainExpression, startsWithExpression, endsWithExpression, matchesExpression, hasExpression, doesNotHaveExpression, logicalExpressions, enhancedConverters, AsExpressionInputSchema, AsExpression, IsExpressionInputSchema, IsExpression, defaultConversions, asExpression, isExpression, asyncExpression, conversionExpressions, evaluationToHyperScriptType, CollectionInputSchema, IndexInputSchema, RandomInputSchema, FirstExpression, LastExpression, AtExpression, RandomExpression, firstExpression, lastExpression, atExpression, nextExpression, previousExpression, nextWithinExpression, previousWithinExpression, positionalExpressions, UNSAFE_PROPS, possessiveExpression, myExpression, itsExpression, yourExpression, ofExpression, attributeExpression, attributeWithValueExpression, classReferenceExpression, idReferenceExpression, propertiesExpressions, StringLiteralInputSchema, NumberLiteralInputSchema, BooleanLiteralInputSchema, BinaryOperationInputSchema, StringLiteralExpression, NumberLiteralExpression, BooleanLiteralExpression, AdditionExpression, StringConcatenationExpression, MultiplicationExpression, specialExpressions, ExpressionEvaluator, ContextBridge, CommandAdapterV2, CommandRegistryV2, defaultRegistry, RegistryIntegration, eventRecursionDepth, RuntimeBase, COMMAND_NAME, COMMAND_CATEGORY, COMMAND_METADATA, KEYWORD_PREPOSITIONS, VisibilityCommandBase, HideCommand, createHideCommand, ShowCommand, createShowCommand, SMART_ELEMENT_TAGS, DOMModificationBase, AddCommand, createAddCommand, RemoveCommand, createRemoveCommand, PATTERN, BOOL_PROPS, ToggleCommand, createToggleCommand, PutCommand, createPutCommand, MakeCommand, createMakeCommand, SUPPORTS_MOVE_BEFORE, ELEMENT_NODE_TYPE, TEXT_NODE_TYPE, IS_PARENT_NODE_TYPE, Operation, candidateNodes, candidateElements, unmatchedNodes, unmatchedElements, whitespaceNodes, _idArrayMap, _idSetMap, _options, _Morph_instances, morphOneToMany_fn, morphOneToOne_fn, morphMatchingElements_fn, morphNonMatchingElements_fn, morphOtherNode_fn, visitAttributes_fn, visitTextArea_fn, replaceNode_fn, removeNode_fn, mapIdArraysForEach_fn, mapIdArrays_fn, mapIdSets_fn, Morph, morphlexMorph, morphlexMorphInner, morphlexEngine, currentEngine, morphAdapter, config$1, transitionQueue, isProcessingQueue, CRITICAL_LAYOUT_ELEMENTS, STRUCTURAL_SEMANTIC_ELEMENTS, WARNING_ELEMENTS, DEFAULT_VALIDATION_CONFIG, globalConfig, STYLES, SEVERITY_ICONS, SEVERITY_LABELS, STRATEGY_KEYWORDS, SwapCommand, MorphCommand, createSwapCommand, createMorphCommand, STRATEGY_MAP, ProcessPartialsCommand, createProcessPartialsCommand, WaitCommand, createWaitCommand, customResponseTypes, FetchCommand, createFetchCommand, SetCommand, createSetCommand, GetCommand, createGetCommand, NumericModifyCommand, createIncrementCommand, createDecrementCommand, LogCommand, createLogCommand, EventDispatchCommand, createTriggerCommand, createSendCommand, GoCommand, createGoCommand, KEYWORDS, HistoryCommand, createPushUrlCommand, createReplaceUrlCommand, ConditionalCommand, createConditionalCommand, createIfCommand, createUnlessCommand, RepeatCommand, createRepeatCommand, ControlFlowSignalBase, BreakCommand, createBreakCommand, ContinueCommand, createContinueCommand, HaltCommand, createHaltCommand, ReturnCommand, createReturnCommand, ExitCommand, createExitCommand, CallCommand, createCallCommand, AppendCommand, createAppendCommand, TransitionCommand, createTransitionCommand, MeasureCommand, createMeasureCommand, SettleCommand, createSettleCommand, JsCommand, createJsCommand, AsyncCommand, createAsyncCommand, DefaultCommand, createDefaultCommand, PseudoCommand, TellCommand, createTellCommand, CopyCommand, createCopyCommand, PickCommand, createPickCommand, ThrowCommand, createThrowCommand, BeepCommand, createBeepCommand, InstallCommand, TakeCommand, createTakeCommand, RenderCommand, Runtime, DebugLogger, _PatternMatcher$1, PatternMatcher$1, StringLiteralExtractor, NumberExtractor, IdentifierExtractor, TokenStreamImpl, DEFAULT_OPERATORS$1, _BaseTokenizer, BaseTokenizer, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __esm2, __export2, __copyProps2, __toCommonJS2, tokenizers, profiles, patternCache, patternGenerator, registeredPatterns, init_registry, init_token_utils, init_char_classifiers, init_base_tokenizer, init_base, init_types, COMBINED_PREFIXES, SINGLE_PREFIXES, VERB_PREFIXES, SUFFIXES, ArabicMorphologicalNormalizer, init_arabic_normalizer, arabic_exports, arabicProfile, init_arabic, DEFAULT_OPERATORS, OperatorExtractor, DEFAULT_PUNCTUATION, PunctuationExtractor, init_generic_extractors, CssSelectorExtractor, init_css_selector, EventModifierExtractor, init_event_modifier, UrlExtractor, init_url, VariableRefExtractor, init_variable_ref, JapaneseKeywordExtractor, init_japanese_keyword, SINGLE_CHAR_PARTICLES, MULTI_CHAR_PARTICLES, JapaneseParticleExtractor, init_japanese_particle, TEMPORAL_EVENT_SUFFIXES, KoreanKeywordExtractor, init_korean_keyword, SINGLE_CHAR_PARTICLES2, MULTI_CHAR_PARTICLES2, KoreanParticleExtractor, init_korean_particle, ChineseKeywordExtractor, init_chinese_keyword, SINGLE_CHAR_PARTICLES3, MULTI_CHAR_PARTICLES3, ChineseParticleExtractor, init_chinese_particle, isVietnameseLetter, isVietnameseIdentifierChar, PREPOSITIONS, VietnameseKeywordExtractor, init_vietnamese_keyword, isArabic2, PREPOSITIONS2, ArabicKeywordExtractor, init_arabic_keyword, isArabic3, PROCLITICS, ArabicProcliticExtractor, init_arabic_proclitic, isArabic4, TEMPORAL_MARKERS, ArabicTemporalExtractor, init_arabic_temporal, CyrillicKeywordExtractor, RUSSIAN_PREPOSITIONS, UKRAINIAN_PREPOSITIONS, init_cyrillic_keyword, HindiKeywordExtractor, init_hindi_keyword, SINGLE_POSTPOSITIONS, COMPOUND_POSTPOSITIONS, HindiParticleExtractor, init_hindi_particle, BengaliKeywordExtractor, init_bengali_keyword, SINGLE_POSTPOSITIONS2, BengaliParticleExtractor, init_bengali_particle, ThaiKeywordExtractor, init_thai_keyword, MalayKeywordExtractor, init_malay_keyword, PREPOSITIONS3, TagalogKeywordExtractor, init_tagalog_keyword, PREPOSITIONS4, isPolishLetter, isPolishIdentifierChar, PolishKeywordExtractor, init_polish_keyword, PREPOSITIONS5, isIndonesianLetter, isIndonesianIdentifierChar, IndonesianKeywordExtractor, init_indonesian_keyword, PREPOSITIONS6, isSwahiliLetter, isSwahiliIdentifierChar, SwahiliKeywordExtractor, init_swahili_keyword, POSTPOSITIONS, CASE_SUFFIXES, TurkishKeywordExtractor, init_turkish_keyword, SUFFIXES2, POSTPOSITIONS2, QuechuaKeywordExtractor, init_quechua_keyword, isHebrew, PREPOSITIONS7, CONJUNCTIONS, HebrewKeywordExtractor, init_hebrew_keyword, isHebrew2, PROCLITIC_PREFIXES, EVENT_MARKER_PREFIXES, EVENT_NAMES, HebrewProcliticExtractor, init_hebrew_proclitic, AsciiIdentifierExtractor, init_ascii_identifier, init_extractors, init_extractor_helpers, arabic_exports2, CONJUNCTIONS2, PREPOSITIONS8, ARABIC_EXTRAS, ArabicTokenizer, arabicTokenizer, init_arabic2, SUFFIX_RULES, BengaliMorphologicalNormalizer, bengaliMorphologicalNormalizer, init_bengali_normalizer, bengali_exports, bengaliProfile, init_bengali, bengali_exports2, SINGLE_POSTPOSITIONS3, BENGALI_EXTRAS, BengaliTokenizer, bengaliTokenizer, init_bengali2, german_exports, germanProfile, init_german, SEPARABLE_PREFIXES, VERB_ENDINGS, ELN_ERN_ENDINGS, ALL_ENDINGS, GermanMorphologicalNormalizer, init_german_normalizer, isGermanLetter, isGermanIdentifierChar, PREPOSITIONS9, GermanKeywordExtractor, init_german_keyword, german_exports2, GERMAN_EXTRAS, GermanTokenizer, germanTokenizer, init_german2, english_exports, englishProfile, init_english, EnglishKeywordExtractor, init_english_keyword, english_exports2, ENGLISH_EXTRAS, EnglishTokenizer, englishTokenizer, init_english2, SchemaErrorCodes, SchemaErrorMessages, SchemaErrorSuggestions, init_schema_error_codes, schema_validator_exports, MULTI_TYPE_PATIENT_COMMANDS, NO_REQUIRED_ROLES_COMMANDS, init_schema_validator, toggleSchema, addSchema, removeSchema, putSchema, setSchema, showSchema, hideSchema, onSchema, triggerSchema, waitSchema, fetchSchema, incrementSchema, decrementSchema, appendSchema, prependSchema, logSchema, getCommandSchema, takeSchema, makeSchema, haltSchema, settleSchema, throwSchema, sendSchema, ifSchema, unlessSchema, elseSchema, repeatSchema, forSchema, whileSchema, continueSchema, goSchema, transitionSchema, cloneSchema, focusSchema, blurSchema, callSchema, returnSchema, jsSchema, asyncSchema, tellSchema, defaultSchema, initSchema, behaviorSchema, installSchema, measureSchema, swapSchema, morphSchema, beepSchema, breakSchema, copySchema, exitSchema, pickSchema, renderSchema, commandSchemas, init_command_schemas, init_role_positioning, init_marker_resolution, init_event_handlers_sov, init_event_handlers_vso, defaultConfig, init_pattern_generator, init_en, init_en2, init_en3, en_exports, fetchWithResponseTypeEnglish, fetchSimpleEnglish, swapSimpleEnglish, repeatUntilEventFromEnglish, repeatUntilEventEnglish, setPossessiveEnglish, forEnglish, ifEnglish, unlessEnglish, temporalInEnglish, temporalAfterEnglish, init_en4, REFLEXIVE_SUFFIXES, AR_ENDINGS, ER_ENDINGS, IR_ENDINGS, ALL_ENDINGS2, SpanishMorphologicalNormalizer, init_spanish_normalizer, spanish_exports, spanishProfile, init_spanish, isSpanishLetter, isSpanishIdentifierChar, PREPOSITIONS10, SpanishKeywordExtractor, init_spanish_keyword, spanish_exports2, PREPOSITIONS11, SPANISH_EXTRAS, SpanishTokenizer, spanishTokenizer, init_spanish2, french_exports, frenchProfile, init_french, REFLEXIVE_SUFFIXES2, ER_ENDINGS2, IR_ENDINGS2, RE_ENDINGS, ALL_ENDINGS3, FrenchMorphologicalNormalizer, init_french_normalizer, isFrenchLetter, isFrenchIdentifierChar, PREPOSITIONS12, FrenchKeywordExtractor, init_french_keyword, french_exports2, FRENCH_EXTRAS, FrenchTokenizer, frenchTokenizer, init_french2, hebrewProfile, init_hebrew, PREPOSITIONS13, HEBREW_EXTRAS, HebrewTokenizer, hebrewTokenizer, init_he, SUFFIX_RULES2, HindiMorphologicalNormalizer, init_hindi_normalizer, hindi_exports, hindiProfile, init_hindi, hindi_exports2, SINGLE_POSTPOSITIONS4, HINDI_EXTRAS, HindiTokenizer, hindiTokenizer, init_hindi2, indonesian_exports, indonesianProfile, init_indonesian, indonesian_exports2, PREPOSITIONS14, INDONESIAN_EXTRAS, IndonesianTokenizer, indonesianTokenizer, init_indonesian2, REFLEXIVE_SUFFIXES3, ARE_ENDINGS, ERE_ENDINGS, IRE_ENDINGS, ALL_ENDINGS4, ItalianMorphologicalNormalizer, init_italian_normalizer, italian_exports, italianProfile, init_italian, RomanceKeywordExtractor, ITALIAN_PREPOSITIONS, init_romance_language_keyword, italian_exports2, PREPOSITIONS15, ITALIAN_EXTRAS, ItalianTokenizer, italianTokenizer, init_italian2, JAPANESE_SUFFIX_RULES, SURU_PATTERNS, JapaneseMorphologicalNormalizer, init_japanese_normalizer, japanese_exports, japaneseProfile, init_japanese, japanese_exports2, PARTICLES, JAPANESE_EXTRAS, JapaneseTokenizer, japaneseTokenizer, init_japanese2, KOREAN_SUFFIX_RULES, HADA_PATTERNS, KoreanMorphologicalNormalizer, init_korean_normalizer, korean_exports, koreanProfile, init_korean, korean_exports2, PARTICLES2, KOREAN_EXTRAS, KoreanTokenizer, koreanTokenizer, init_korean2, ms_exports, malayProfile, init_ms, ms_exports2, MALAY_EXTRAS, MalayTokenizer, malayTokenizer, init_ms2, polish_exports, polishProfile, init_polish, IMPERATIVE_TO_INFINITIVE, PolishMorphologicalNormalizer, init_polish_normalizer, polish_exports2, PREPOSITIONS16, POLISH_EXTRAS, PolishTokenizer, polishTokenizer, init_polish2, portuguese_exports, portugueseProfile, init_portuguese, REFLEXIVE_SUFFIXES4, AR_ENDINGS2, ER_ENDINGS3, IR_ENDINGS3, ALL_ENDINGS5, PortugueseMorphologicalNormalizer, init_portuguese_normalizer, isPortugueseLetter, isPortugueseIdentifierChar, PREPOSITIONS17, PortugueseKeywordExtractor, init_portuguese_keyword, portuguese_exports2, PREPOSITIONS18, PORTUGUESE_EXTRAS, PortugueseTokenizer, portugueseTokenizer, init_portuguese2, quechua_exports, quechuaProfile, init_quechua, QUECHUA_SUFFIX_RULES, QuechuaMorphologicalNormalizer, quechuaMorphologicalNormalizer, init_quechua_normalizer, quechua_exports2, QuechuaStringLiteralExtractor, SUFFIXES3, QUECHUA_EXTRAS, QuechuaTokenizer, quechuaTokenizer, init_quechua2, IMPERATIVE_TO_INFINITIVE2, RussianMorphologicalNormalizer, init_russian_normalizer, russian_exports, russianProfile, init_russian, russian_exports2, PREPOSITIONS19, RUSSIAN_EXTRAS, RussianTokenizer, russianTokenizer, init_russian2, swahili_exports, swahiliProfile, init_swahili, swahili_exports2, PREPOSITIONS20, SWAHILI_EXTRAS, SwahiliTokenizer, swahiliTokenizer, init_swahili2, thai_exports, thaiProfile, init_thai, thai_exports2, THAI_EXTRAS, ThaiTokenizer, thaiTokenizer, init_thai2, tl_exports, tagalogProfile, init_tl, COMBINED_PREFIXES2, SINGLE_PREFIXES2, INFIXES, SUFFIXES4, TagalogMorphologicalNormalizer, tagalogMorphologicalNormalizer, init_tagalog_normalizer, tl_exports2, TAGALOG_EXTRAS, TagalogTokenizer, tagalogTokenizer, init_tl2, TURKISH_SUFFIX_RULES, TurkishMorphologicalNormalizer, init_turkish_normalizer, turkish_exports, turkishProfile, init_turkish, turkish_exports2, POSTPOSITIONS3, CASE_SUFFIXES2, TURKISH_EXTRAS, TurkishTokenizer, turkishTokenizer, init_turkish2, IMPERATIVE_TO_INFINITIVE3, UkrainianMorphologicalNormalizer, init_ukrainian_normalizer, ukrainian_exports, ukrainianProfile, init_ukrainian, ukrainian_exports2, PREPOSITIONS21, UKRAINIAN_EXTRAS, UkrainianTokenizer, ukrainianTokenizer, init_ukrainian2, vietnamese_exports, vietnameseProfile, init_vietnamese, vietnamese_exports2, VIETNAMESE_EXTRAS, VietnameseTokenizer, vietnameseTokenizer, init_vietnamese2, chinese_exports, chineseProfile, init_chinese, chinese_exports2, PARTICLES3, CHINESE_EXTRAS, ChineseTokenizer, chineseTokenizer, init_chinese2, VALID_REFERENCES, init_types2, eventNameTranslations, init_shared, init_tokenizers, init_type_validation, init_possessive_keywords, _PatternMatcher2, PatternMatcher, patternMatcher, init_pattern_matcher, SemanticRendererImpl, semanticRenderer, init_renderer, init_parser, semantic_parser_exports, _SemanticParserImpl, SemanticParserImpl, semanticParser, init_semantic_parser, spanishMexicoProfile, fetchWithResponseTypeEnglish2, fetchSimpleEnglish2, fetchPatternsEn, swapSimpleEnglish2, swapPatternsEn, repeatUntilEventFromEnglish2, repeatUntilEventEnglish2, repeatPatternsEn, setPossessiveEnglish2, setPatternsEn, forEnglish2, ifEnglish2, unlessEnglish2, controlFlowPatternsEn, temporalInEnglish2, temporalAfterEnglish2, temporalPatternsEn, allEnglishOnlyPatterns, PATTERN_LOADERS, _generatedPatternsPerLanguage, handcraftedLanguages, patternCache2, _allPatterns, allPatterns, SemanticCache2, semanticCache, SemanticAnalyzerImpl, DEFAULT_CONFIDENCE_THRESHOLD, HIGH_CONFIDENCE_THRESHOLD, languageProfiles, schemaRegistry, DEFAULT_CONFIG, HIGH_FREQUENCY_TRIGGERS, THROTTLE_RECOMMENDED_TRIGGERS, _devModeEnabled, _devModeConfig, CONTEXT_VARS, LOGICAL_OPERATORS, BOOLEAN_LITERALS, TIME_UNITS, ExpressionParser, toggleMapper, addMapper, removeMapper, setMapper, showMapper, hideMapper, incrementMapper, decrementMapper, waitMapper, logMapper, putMapper, fetchMapper, appendMapper, prependMapper, triggerMapper, sendMapper, goMapper, transitionMapper, focusMapper, blurMapper, getMapper, takeMapper, callMapper, returnMapper, haltMapper, throwMapper, settleMapper, swapMapper, morphMapper, cloneMapper, makeMapper, measureMapper, tellMapper, jsMapper, asyncMapper, ifMapper, unlessMapper, repeatMapper, forMapper, whileMapper, continueMapper, defaultMapper, initMapper, behaviorMapper, installMapper, onMapper, mappers, ASTBuilder, LANGUAGE_IMPORTERS, SUPPORTED_LANGUAGES, VERSION, index, HistorySwapBehavior, BoostedBehavior, DEFAULT_EVENT_TYPE, DEFAULT_LANGUAGE$1, compileSyncFn, compileAsyncFn, getRuntimeFn, DEFAULT_LANGUAGE, ASTCache, astCache, semanticAnalyzerInstance, bridgeInstance, config, _defaultRuntime, hyperscript, lokascript, OP_TABLE, Lexer, Tokens, PropertyAccessInputSchema, PossessiveAccessInputSchema, AttributeAccessInputSchema, MyExpression, ItsExpression, AttributeExpression, MAX_HISTORY_SIZE$5, DefInputSchema, TypedDefFeatureImplementation, enhancedDefImplementation, MAX_HISTORY_SIZE$4, EnhancedOnInputSchema, TypedOnFeatureImplementation, enhancedOnImplementation, MAX_HISTORY_SIZE$3, BehaviorsInputSchema, TypedBehaviorsFeatureImplementation, enhancedBehaviorsImplementation, MAX_HISTORY_SIZE$2, SocketsInputSchema, TypedSocketsFeatureImplementation, enhancedSocketsImplementation, MAX_HISTORY_SIZE$1, WebWorkerInputSchema, TypedWebWorkerFeatureImplementation, enhancedWebWorkerImplementation, MAX_HISTORY_SIZE, EventSourceInputSchema, TypedEventSourceFeatureImplementation, enhancedEventSourceImplementation, POS, DiagnosticSeverity, SymbolKind, CompletionItemKind, _semanticModule, SemanticGrammarBridge, bridge;
20628
+ var KEYWORDS$2, COMMAND_TERMINATORS, COMMANDS, COMPOUND_COMMANDS, CONTROL_FLOW_COMMANDS, PUT_OPERATIONS, PUT_OPERATION_KEYWORDS, HYPERSCRIPT_KEYWORDS, CommandClassification, CSS_FUNCTIONS, CONTEXT_VARS$1, LOGICAL_OPERATORS$1, COMPARISON_OPERATORS, DOM_EVENTS, TOKENIZER_KEYWORDS, TokenKind, TokenType, KEYWORDS$1, MATHEMATICAL_OPERATORS, TIME_UNITS$1, isDebugEnabled$1, DEBUG, debug, debugEnabled, debugEventTarget, stats, DEFAULT_CONFIDENCE_THRESHOLD$1, SemanticIntegrationAdapter, MULTI_WORD_PATTERNS, DEFAULT_BOUNDARY_KEYWORDS, CommandNodeBuilder, SWAP_STRATEGY_KEYWORDS, Parser, HookRegistry, CleanupRegistry, sharedGlobals, EventSourceRegistry, ContextProviderRegistry, ExpressionTypeRegistry, expressionTypeRegistry, BOOLEAN_ATTRIBUTES, SPECIAL_DOM_PROPERTIES, BaseExpressionEvaluator, NUMBER_WORDS, isProduction, skipValidation, addDescribeToValidator, v, z, BaseExpressionImpl, MeExpression, YouExpression, ItExpression, CSSelectorInputSchema, CSSSelectorExpression, meExpression, youExpression, itExpression, itsExpression$1, resultExpression, querySelectorExpression, querySelectorAllExpression, idExpression, classExpression, closestExpression, parentExpression, windowExpression, documentExpression, elementWithSelectorExpression, styleRefExpression, possessiveStyleRefExpression, ofStyleRefExpression, referencesExpressions, LRUCache, HyperscriptCache, globalCache, PerformanceTracker, performanceTracker, cleanupInterval, BinaryLogicalInputSchema, UnaryLogicalInputSchema, AndExpression, OrExpression, NotExpression, ComparisonInputSchema, PatternMatchingInputSchema, equalsExpression, strictEqualsExpression, notEqualsExpression, strictNotEqualsExpression, lessThanExpression, lessThanOrEqualExpression, greaterThanExpression, greaterThanOrEqualExpression, andExpression, orExpression, notExpression, isEmptyExpression, noExpression, isNotEmptyExpression, existsExpression, doesNotExistExpression, containsExpression, doesNotContainExpression, startsWithExpression, endsWithExpression, matchesExpression, hasExpression, doesNotHaveExpression, logicalExpressions, enhancedConverters, AsExpressionInputSchema, AsExpression, IsExpressionInputSchema, IsExpression, defaultConversions, asExpression, isExpression, asyncExpression, conversionExpressions, evaluationToHyperScriptType, CollectionInputSchema, IndexInputSchema, RandomInputSchema, FirstExpression, LastExpression, AtExpression, RandomExpression, firstExpression, lastExpression, atExpression, nextExpression, previousExpression, nextWithinExpression, previousWithinExpression, positionalExpressions, UNSAFE_PROPS, possessiveExpression, myExpression, itsExpression, yourExpression, ofExpression, attributeExpression, attributeWithValueExpression, classReferenceExpression, idReferenceExpression, propertiesExpressions, StringLiteralInputSchema, NumberLiteralInputSchema, BooleanLiteralInputSchema, BinaryOperationInputSchema, StringLiteralExpression, NumberLiteralExpression, BooleanLiteralExpression, AdditionExpression, StringConcatenationExpression, MultiplicationExpression, specialExpressions, ExpressionEvaluator, ContextBridge, CommandAdapterV2, CommandRegistryV2, defaultRegistry, RegistryIntegration, eventRecursionDepth, RuntimeBase, COMMAND_NAME, COMMAND_CATEGORY, COMMAND_METADATA, KEYWORD_PREPOSITIONS, VisibilityCommandBase, HideCommand, createHideCommand, ShowCommand, createShowCommand, SMART_ELEMENT_TAGS, DOMModificationBase, AddCommand, createAddCommand, RemoveCommand, createRemoveCommand, PATTERN, BOOL_PROPS, ToggleCommand, createToggleCommand, PutCommand, createPutCommand, MakeCommand, createMakeCommand, SUPPORTS_MOVE_BEFORE, ELEMENT_NODE_TYPE, TEXT_NODE_TYPE, IS_PARENT_NODE_TYPE, Operation, candidateNodes, candidateElements, candidateElementsWithIds, unmatchedNodes, unmatchedElements, whitespaceNodes, _idArrayMap, _idSetMap, _options, _Morph_instances, morphOneToMany_fn, morphOneToOne_fn, morphMatchingElements_fn, morphNonMatchingElements_fn, morphOtherNode_fn, visitAttributes_fn, visitTextArea_fn, replaceNode_fn, removeNode_fn, mapIdArraysForEach_fn, mapIdArrays_fn, mapIdSets_fn, Morph, morphlexMorph, morphlexMorphInner, morphlexEngine, currentEngine, morphAdapter, config$1, transitionQueue, isProcessingQueue, CRITICAL_LAYOUT_ELEMENTS, STRUCTURAL_SEMANTIC_ELEMENTS, WARNING_ELEMENTS, DEFAULT_VALIDATION_CONFIG, globalConfig, STYLES, SEVERITY_ICONS, SEVERITY_LABELS, STRATEGY_KEYWORDS, SwapCommand, MorphCommand, createSwapCommand, createMorphCommand, STRATEGY_MAP, ProcessPartialsCommand, createProcessPartialsCommand, WaitCommand, createWaitCommand, customResponseTypes, FetchCommand, createFetchCommand, SetCommand, createSetCommand, GetCommand, createGetCommand, NumericModifyCommand, createIncrementCommand, createDecrementCommand, LogCommand, createLogCommand, EventDispatchCommand, createTriggerCommand, createSendCommand, GoCommand, createGoCommand, KEYWORDS, HistoryCommand, createPushUrlCommand, createReplaceUrlCommand, ConditionalCommand, createConditionalCommand, createIfCommand, createUnlessCommand, RepeatCommand, createRepeatCommand, ControlFlowSignalBase, BreakCommand, createBreakCommand, ContinueCommand, createContinueCommand, HaltCommand, createHaltCommand, ReturnCommand, createReturnCommand, ExitCommand, createExitCommand, CallCommand, createCallCommand, AppendCommand, createAppendCommand, TransitionCommand, createTransitionCommand, MeasureCommand, createMeasureCommand, SettleCommand, createSettleCommand, JsCommand, createJsCommand, AsyncCommand, createAsyncCommand, DefaultCommand, createDefaultCommand, PseudoCommand, TellCommand, createTellCommand, CopyCommand, createCopyCommand, PickCommand, createPickCommand, ThrowCommand, createThrowCommand, BeepCommand, createBeepCommand, InstallCommand, TakeCommand, createTakeCommand, RenderCommand, Runtime, DebugLogger, _PatternMatcher$1, PatternMatcher$1, StringLiteralExtractor, NumberExtractor, IdentifierExtractor, DEFAULT_REFERENCES, STRUCTURAL_ROLES, TokenStreamImpl, DEFAULT_OPERATORS$1, _BaseTokenizer, BaseTokenizer, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __esm2, __export2, __copyProps2, __toCommonJS2, tokenizers, profiles, patternCache, patternGenerator, registeredPatterns, init_registry, init_token_utils, init_char_classifiers, init_base_tokenizer, init_base, init_types, COMBINED_PREFIXES, SINGLE_PREFIXES, VERB_PREFIXES, SUFFIXES, ArabicMorphologicalNormalizer, init_arabic_normalizer, arabic_exports, arabicProfile, init_arabic, DEFAULT_OPERATORS, OperatorExtractor, DEFAULT_PUNCTUATION, PunctuationExtractor, init_generic_extractors, CssSelectorExtractor, init_css_selector, EventModifierExtractor, init_event_modifier, UrlExtractor, init_url, VariableRefExtractor, init_variable_ref, JapaneseKeywordExtractor, init_japanese_keyword, SINGLE_CHAR_PARTICLES, MULTI_CHAR_PARTICLES, JapaneseParticleExtractor, init_japanese_particle, TEMPORAL_EVENT_SUFFIXES, KoreanKeywordExtractor, init_korean_keyword, SINGLE_CHAR_PARTICLES2, MULTI_CHAR_PARTICLES2, KoreanParticleExtractor, init_korean_particle, ChineseKeywordExtractor, init_chinese_keyword, SINGLE_CHAR_PARTICLES3, MULTI_CHAR_PARTICLES3, ChineseParticleExtractor, init_chinese_particle, isVietnameseLetter, isVietnameseIdentifierChar, PREPOSITIONS, VietnameseKeywordExtractor, init_vietnamese_keyword, isArabic2, PREPOSITIONS2, ArabicKeywordExtractor, init_arabic_keyword, isArabic3, PROCLITICS, ArabicProcliticExtractor, init_arabic_proclitic, isArabic4, TEMPORAL_MARKERS, ArabicTemporalExtractor, init_arabic_temporal, CyrillicKeywordExtractor, RUSSIAN_PREPOSITIONS, UKRAINIAN_PREPOSITIONS, init_cyrillic_keyword, HindiKeywordExtractor, init_hindi_keyword, SINGLE_POSTPOSITIONS, COMPOUND_POSTPOSITIONS, HindiParticleExtractor, init_hindi_particle, BengaliKeywordExtractor, init_bengali_keyword, SINGLE_POSTPOSITIONS2, BengaliParticleExtractor, init_bengali_particle, ThaiKeywordExtractor, init_thai_keyword, MalayKeywordExtractor, init_malay_keyword, PREPOSITIONS3, TagalogKeywordExtractor, init_tagalog_keyword, PREPOSITIONS4, isPolishLetter, isPolishIdentifierChar, PolishKeywordExtractor, init_polish_keyword, PREPOSITIONS5, isIndonesianLetter, isIndonesianIdentifierChar, IndonesianKeywordExtractor, init_indonesian_keyword, PREPOSITIONS6, isSwahiliLetter, isSwahiliIdentifierChar, SwahiliKeywordExtractor, init_swahili_keyword, POSTPOSITIONS, CASE_SUFFIXES, TurkishKeywordExtractor, init_turkish_keyword, SUFFIXES2, POSTPOSITIONS2, QuechuaKeywordExtractor, init_quechua_keyword, isHebrew, PREPOSITIONS7, CONJUNCTIONS, HebrewKeywordExtractor, init_hebrew_keyword, isHebrew2, PROCLITIC_PREFIXES, EVENT_MARKER_PREFIXES, EVENT_NAMES, HebrewProcliticExtractor, init_hebrew_proclitic, AsciiIdentifierExtractor, init_ascii_identifier, init_extractors, init_extractor_helpers, arabic_exports2, CONJUNCTIONS2, PREPOSITIONS8, ARABIC_EXTRAS, ArabicTokenizer, arabicTokenizer, init_arabic2, SUFFIX_RULES, BengaliMorphologicalNormalizer, bengaliMorphologicalNormalizer, init_bengali_normalizer, bengali_exports, bengaliProfile, init_bengali, bengali_exports2, SINGLE_POSTPOSITIONS3, BENGALI_EXTRAS, BengaliTokenizer, bengaliTokenizer, init_bengali2, german_exports, germanProfile, init_german, SEPARABLE_PREFIXES, VERB_ENDINGS, ELN_ERN_ENDINGS, ALL_ENDINGS, GermanMorphologicalNormalizer, init_german_normalizer, isGermanLetter, isGermanIdentifierChar, PREPOSITIONS9, GermanKeywordExtractor, init_german_keyword, german_exports2, GERMAN_EXTRAS, GermanTokenizer, germanTokenizer, init_german2, english_exports, englishProfile, init_english, EnglishKeywordExtractor, init_english_keyword, english_exports2, ENGLISH_EXTRAS, EnglishTokenizer, englishTokenizer, init_english2, SchemaErrorCodes, SchemaErrorMessages, SchemaErrorSuggestions, init_schema_error_codes, schema_validator_exports, MULTI_TYPE_PATIENT_COMMANDS, NO_REQUIRED_ROLES_COMMANDS, init_schema_validator, toggleSchema, addSchema, removeSchema, putSchema, setSchema, showSchema, hideSchema, onSchema, triggerSchema, waitSchema, fetchSchema, incrementSchema, decrementSchema, appendSchema, prependSchema, logSchema, getCommandSchema, takeSchema, makeSchema, haltSchema, settleSchema, throwSchema, sendSchema, ifSchema, unlessSchema, elseSchema, repeatSchema, forSchema, whileSchema, continueSchema, goSchema, transitionSchema, cloneSchema, focusSchema, blurSchema, callSchema, returnSchema, jsSchema, asyncSchema, tellSchema, defaultSchema, initSchema, behaviorSchema, installSchema, measureSchema, swapSchema, morphSchema, beepSchema, breakSchema, copySchema, exitSchema, pickSchema, renderSchema, commandSchemas, init_command_schemas, init_role_positioning, init_marker_resolution, init_event_handlers_sov, init_event_handlers_vso, defaultConfig, init_pattern_generator, init_en, init_en2, init_en3, en_exports, fetchWithResponseTypeEnglish, fetchSimpleEnglish, swapSimpleEnglish, repeatUntilEventFromEnglish, repeatUntilEventEnglish, setPossessiveEnglish, forEnglish, ifEnglish, unlessEnglish, temporalInEnglish, temporalAfterEnglish, init_en4, REFLEXIVE_SUFFIXES, AR_ENDINGS, ER_ENDINGS, IR_ENDINGS, ALL_ENDINGS2, SpanishMorphologicalNormalizer, init_spanish_normalizer, spanish_exports, spanishProfile, init_spanish, isSpanishLetter, isSpanishIdentifierChar, PREPOSITIONS10, SpanishKeywordExtractor, init_spanish_keyword, spanish_exports2, PREPOSITIONS11, SPANISH_EXTRAS, SpanishTokenizer, spanishTokenizer, init_spanish2, french_exports, frenchProfile, init_french, REFLEXIVE_SUFFIXES2, ER_ENDINGS2, IR_ENDINGS2, RE_ENDINGS, ALL_ENDINGS3, FrenchMorphologicalNormalizer, init_french_normalizer, isFrenchLetter, isFrenchIdentifierChar, PREPOSITIONS12, FrenchKeywordExtractor, init_french_keyword, french_exports2, FRENCH_EXTRAS, FrenchTokenizer, frenchTokenizer, init_french2, hebrewProfile, init_hebrew, PREPOSITIONS13, HEBREW_EXTRAS, HebrewTokenizer, hebrewTokenizer, init_he, SUFFIX_RULES2, HindiMorphologicalNormalizer, init_hindi_normalizer, hindi_exports, hindiProfile, init_hindi, hindi_exports2, SINGLE_POSTPOSITIONS4, HINDI_EXTRAS, HindiTokenizer, hindiTokenizer, init_hindi2, indonesian_exports, indonesianProfile, init_indonesian, indonesian_exports2, PREPOSITIONS14, INDONESIAN_EXTRAS, IndonesianTokenizer, indonesianTokenizer, init_indonesian2, REFLEXIVE_SUFFIXES3, ARE_ENDINGS, ERE_ENDINGS, IRE_ENDINGS, ALL_ENDINGS4, ItalianMorphologicalNormalizer, init_italian_normalizer, italian_exports, italianProfile, init_italian, RomanceKeywordExtractor, ITALIAN_PREPOSITIONS, init_romance_language_keyword, italian_exports2, PREPOSITIONS15, ITALIAN_EXTRAS, ItalianTokenizer, italianTokenizer, init_italian2, JAPANESE_SUFFIX_RULES, SURU_PATTERNS, JapaneseMorphologicalNormalizer, init_japanese_normalizer, japanese_exports, japaneseProfile, init_japanese, japanese_exports2, PARTICLES, JAPANESE_EXTRAS, JapaneseTokenizer, japaneseTokenizer, init_japanese2, KOREAN_SUFFIX_RULES, HADA_PATTERNS, KoreanMorphologicalNormalizer, init_korean_normalizer, korean_exports, koreanProfile, init_korean, korean_exports2, PARTICLES2, KOREAN_EXTRAS, KoreanTokenizer, koreanTokenizer, init_korean2, ms_exports, malayProfile, init_ms, ms_exports2, MALAY_EXTRAS, MalayTokenizer, malayTokenizer, init_ms2, polish_exports, polishProfile, init_polish, IMPERATIVE_TO_INFINITIVE, PolishMorphologicalNormalizer, init_polish_normalizer, polish_exports2, PREPOSITIONS16, POLISH_EXTRAS, PolishTokenizer, polishTokenizer, init_polish2, portuguese_exports, portugueseProfile, init_portuguese, REFLEXIVE_SUFFIXES4, AR_ENDINGS2, ER_ENDINGS3, IR_ENDINGS3, ALL_ENDINGS5, PortugueseMorphologicalNormalizer, init_portuguese_normalizer, isPortugueseLetter, isPortugueseIdentifierChar, PREPOSITIONS17, PortugueseKeywordExtractor, init_portuguese_keyword, portuguese_exports2, PREPOSITIONS18, PORTUGUESE_EXTRAS, PortugueseTokenizer, portugueseTokenizer, init_portuguese2, quechua_exports, quechuaProfile, init_quechua, QUECHUA_SUFFIX_RULES, QuechuaMorphologicalNormalizer, quechuaMorphologicalNormalizer, init_quechua_normalizer, quechua_exports2, QuechuaStringLiteralExtractor, SUFFIXES3, QUECHUA_EXTRAS, QuechuaTokenizer, quechuaTokenizer, init_quechua2, IMPERATIVE_TO_INFINITIVE2, RussianMorphologicalNormalizer, init_russian_normalizer, russian_exports, russianProfile, init_russian, russian_exports2, PREPOSITIONS19, RUSSIAN_EXTRAS, RussianTokenizer, russianTokenizer, init_russian2, swahili_exports, swahiliProfile, init_swahili, swahili_exports2, PREPOSITIONS20, SWAHILI_EXTRAS, SwahiliTokenizer, swahiliTokenizer, init_swahili2, thai_exports, thaiProfile, init_thai, thai_exports2, THAI_EXTRAS, ThaiTokenizer, thaiTokenizer, init_thai2, tl_exports, tagalogProfile, init_tl, COMBINED_PREFIXES2, SINGLE_PREFIXES2, INFIXES, SUFFIXES4, TagalogMorphologicalNormalizer, tagalogMorphologicalNormalizer, init_tagalog_normalizer, tl_exports2, TAGALOG_EXTRAS, TagalogTokenizer, tagalogTokenizer, init_tl2, TURKISH_SUFFIX_RULES, TurkishMorphologicalNormalizer, init_turkish_normalizer, turkish_exports, turkishProfile, init_turkish, turkish_exports2, POSTPOSITIONS3, CASE_SUFFIXES2, TURKISH_EXTRAS, TurkishTokenizer, turkishTokenizer, init_turkish2, IMPERATIVE_TO_INFINITIVE3, UkrainianMorphologicalNormalizer, init_ukrainian_normalizer, ukrainian_exports, ukrainianProfile, init_ukrainian, ukrainian_exports2, PREPOSITIONS21, UKRAINIAN_EXTRAS, UkrainianTokenizer, ukrainianTokenizer, init_ukrainian2, vietnamese_exports, vietnameseProfile, init_vietnamese, vietnamese_exports2, VIETNAMESE_EXTRAS, VietnameseTokenizer, vietnameseTokenizer, init_vietnamese2, chinese_exports, chineseProfile, init_chinese, chinese_exports2, PARTICLES3, CHINESE_EXTRAS, ChineseTokenizer, chineseTokenizer, init_chinese2, init_types2, eventNameTranslations, init_shared, init_tokenizers, init_type_validation, init_possessive_keywords, _PatternMatcher2, PatternMatcher, patternMatcher, init_pattern_matcher, SemanticRendererImpl, semanticRenderer, init_renderer, hyperscriptSchemaLookup, init_parser, semantic_parser_exports, _SemanticParserImpl, SemanticParserImpl, semanticParser, init_semantic_parser, spanishMexicoProfile, fetchWithResponseTypeEnglish2, fetchSimpleEnglish2, fetchPatternsEn, swapSimpleEnglish2, swapPatternsEn, repeatUntilEventFromEnglish2, repeatUntilEventEnglish2, repeatPatternsEn, setPossessiveEnglish2, setPatternsEn, forEnglish2, ifEnglish2, unlessEnglish2, controlFlowPatternsEn, temporalInEnglish2, temporalAfterEnglish2, temporalPatternsEn, allEnglishOnlyPatterns, PATTERN_LOADERS, _generatedPatternsPerLanguage, handcraftedLanguages, patternCache2, _allPatterns, allPatterns, SemanticCache2, semanticCache, SemanticAnalyzerImpl, DEFAULT_CONFIDENCE_THRESHOLD, HIGH_CONFIDENCE_THRESHOLD, languageProfiles, schemaRegistry, DEFAULT_CONFIG, HIGH_FREQUENCY_TRIGGERS, THROTTLE_RECOMMENDED_TRIGGERS, _devModeEnabled, _devModeConfig, CONTEXT_VARS, LOGICAL_OPERATORS, BOOLEAN_LITERALS, TIME_UNITS, ExpressionParser, toggleMapper, addMapper, removeMapper, setMapper, showMapper, hideMapper, incrementMapper, decrementMapper, waitMapper, logMapper, putMapper, fetchMapper, appendMapper, prependMapper, triggerMapper, sendMapper, goMapper, transitionMapper, focusMapper, blurMapper, getMapper, takeMapper, callMapper, returnMapper, haltMapper, throwMapper, settleMapper, swapMapper, morphMapper, cloneMapper, makeMapper, measureMapper, tellMapper, jsMapper, asyncMapper, ifMapper, unlessMapper, repeatMapper, forMapper, whileMapper, continueMapper, defaultMapper, initMapper, behaviorMapper, installMapper, onMapper, mappers, ASTBuilder, LANGUAGE_IMPORTERS, SUPPORTED_LANGUAGES, VERSION, index, HistorySwapBehavior, BoostedBehavior, DEFAULT_EVENT_TYPE, DEFAULT_LANGUAGE$1, compileSyncFn, compileAsyncFn, getRuntimeFn, RingBuffer, HISTORY_CAPACITY, DebugController, DEFAULT_LANGUAGE, ASTCache, astCache, semanticAnalyzerInstance, bridgeInstance, config, _defaultRuntime, _debugController, hyperscript, lokascript, OP_TABLE, Lexer, Tokens, PropertyAccessInputSchema, PossessiveAccessInputSchema, AttributeAccessInputSchema, MyExpression, ItsExpression, AttributeExpression, MAX_HISTORY_SIZE$5, DefInputSchema, TypedDefFeatureImplementation, enhancedDefImplementation, MAX_HISTORY_SIZE$4, EnhancedOnInputSchema, TypedOnFeatureImplementation, enhancedOnImplementation, MAX_HISTORY_SIZE$3, BehaviorsInputSchema, TypedBehaviorsFeatureImplementation, enhancedBehaviorsImplementation, MAX_HISTORY_SIZE$2, SocketsInputSchema, TypedSocketsFeatureImplementation, enhancedSocketsImplementation, MAX_HISTORY_SIZE$1, WebWorkerInputSchema, TypedWebWorkerFeatureImplementation, enhancedWebWorkerImplementation, MAX_HISTORY_SIZE, EventSourceInputSchema, TypedEventSourceFeatureImplementation, enhancedEventSourceImplementation, POS, DiagnosticSeverity, SymbolKind, CompletionItemKind, _semanticModule, SemanticGrammarBridge, bridge;
20290
20629
  var init_dist = __esm({
20291
20630
  "../core/dist/index.mjs"() {
20292
20631
  "use strict";
@@ -22906,31 +23245,7 @@ var init_dist = __esm({
22906
23245
  }
22907
23246
  }
22908
23247
  }
22909
- const handlerCommands = [];
22910
- while (!this.isAtEnd() && !this.check("end")) {
22911
- if (this.checkIsCommand() || this.isCommand(this.peek().value)) {
22912
- this.advance();
22913
- const savedError = this.error;
22914
- try {
22915
- const cmd = this.parseCommand();
22916
- if (this.error && this.error !== savedError) {
22917
- this.error = savedError;
22918
- }
22919
- handlerCommands.push(cmd);
22920
- while (!this.isAtEnd() && !this.check("end") && !this.checkIsCommand() && !this.isCommand(this.peek().value)) {
22921
- this.advance();
22922
- }
22923
- } catch (error) {
22924
- this.error = savedError;
22925
- break;
22926
- }
22927
- } else {
22928
- if (!this.check("end")) {
22929
- this.addError(`Unexpected token in event handler: ${this.peek().value}`);
22930
- }
22931
- break;
22932
- }
22933
- }
23248
+ const handlerCommands = this.parseCommandListUntilEnd();
22934
23249
  const handlerNode = {
22935
23250
  type: "eventHandler",
22936
23251
  event: eventName,
@@ -22943,7 +23258,6 @@ var init_dist = __esm({
22943
23258
  column: handlerPos.column
22944
23259
  };
22945
23260
  eventHandlers.push(handlerNode);
22946
- this.consume("end", "Expected 'end' after event handler body");
22947
23261
  } else if (this.match("init")) {
22948
23262
  const initCommands = this.parseCommandBlock(["end"]);
22949
23263
  initBlock = {
@@ -24615,8 +24929,9 @@ var init_dist = __esm({
24615
24929
  outerhtml: (el) => el.outerHTML,
24616
24930
  value: (el) => isFormElement(el) ? el.value : void 0,
24617
24931
  checked: (el) => isInputElement$1(el) ? el.checked : void 0,
24618
- disabled: (el) => isFormElement(el) ? el.disabled : void 0,
24932
+ disabled: (el) => "disabled" in el ? el.disabled : void 0,
24619
24933
  selected: (el) => isOptionElement$1(el) ? el.selected : void 0,
24934
+ tabindex: (el) => isHTMLElement$2(el) ? el.tabIndex : void 0,
24620
24935
  hidden: (el) => isHTMLElement$2(el) ? el.hidden : void 0,
24621
24936
  style: (el) => getComputedStyle(el),
24622
24937
  children: (el) => Array.from(el.children),
@@ -29906,14 +30221,31 @@ var init_dist = __esm({
29906
30221
  }
29907
30222
  async executeBehaviorDefinition(node, _context) {
29908
30223
  const { name, parameters, eventHandlers, initBlock } = node;
29909
- this.behaviorRegistry.set(name, { name, parameters, eventHandlers, initBlock });
29910
- debug.runtime(`RUNTIME BASE: Registered behavior '${name}'`);
30224
+ const imperativeInstaller = node.imperativeInstaller;
30225
+ if (typeof imperativeInstaller === "function") {
30226
+ this.behaviorRegistry.set(name, {
30227
+ name,
30228
+ parameters,
30229
+ type: "imperative",
30230
+ install: imperativeInstaller
30231
+ });
30232
+ debug.runtime(`RUNTIME BASE: Registered imperative behavior '${name}'`);
30233
+ } else {
30234
+ this.behaviorRegistry.set(name, { name, parameters, eventHandlers, initBlock });
30235
+ debug.runtime(`RUNTIME BASE: Registered behavior '${name}'`);
30236
+ }
29911
30237
  }
29912
30238
  async installBehaviorOnElement(behaviorName, element, parameters) {
29913
30239
  debug.runtime(`BEHAVIOR: installBehaviorOnElement called: ${behaviorName}`);
29914
30240
  const behavior = this.behaviorRegistry.get(behaviorName);
29915
30241
  if (!behavior)
29916
30242
  throw new Error(`Behavior "${behaviorName}" not found`);
30243
+ if (behavior.type === "imperative" && typeof behavior.install === "function") {
30244
+ debug.runtime(`BEHAVIOR: Installing imperative behavior '${behaviorName}'`);
30245
+ behavior.install(element, parameters);
30246
+ debug.runtime(`BEHAVIOR: Finished installing imperative behavior '${behaviorName}'`);
30247
+ return;
30248
+ }
29917
30249
  debug.runtime(`BEHAVIOR: Found behavior, eventHandlers count: ${behavior.eventHandlers?.length || 0}`);
29918
30250
  const baseBehaviorContext = {
29919
30251
  me: element,
@@ -31296,6 +31628,7 @@ var init_dist = __esm({
31296
31628
  };
31297
31629
  candidateNodes = /* @__PURE__ */ new Set();
31298
31630
  candidateElements = /* @__PURE__ */ new Set();
31631
+ candidateElementsWithIds = /* @__PURE__ */ new Set();
31299
31632
  unmatchedNodes = /* @__PURE__ */ new Set();
31300
31633
  unmatchedElements = /* @__PURE__ */ new Set();
31301
31634
  whitespaceNodes = /* @__PURE__ */ new Set();
@@ -31327,6 +31660,7 @@ var init_dist = __esm({
31327
31660
  const toChildNodes = [...to.childNodes];
31328
31661
  candidateNodes.clear();
31329
31662
  candidateElements.clear();
31663
+ candidateElementsWithIds.clear();
31330
31664
  unmatchedNodes.clear();
31331
31665
  unmatchedElements.clear();
31332
31666
  whitespaceNodes.clear();
@@ -31342,7 +31676,11 @@ var init_dist = __esm({
31342
31676
  candidateNodeTypeMap[i] = nodeType;
31343
31677
  if (nodeType === ELEMENT_NODE_TYPE) {
31344
31678
  candidateLocalNameMap[i] = candidate.localName;
31345
- candidateElements.add(i);
31679
+ if (candidate.id !== "") {
31680
+ candidateElementsWithIds.add(i);
31681
+ } else {
31682
+ candidateElements.add(i);
31683
+ }
31346
31684
  } else if (nodeType === TEXT_NODE_TYPE && candidate.textContent?.trim() === "") {
31347
31685
  whitespaceNodes.add(i);
31348
31686
  } else {
@@ -31385,13 +31723,13 @@ var init_dist = __esm({
31385
31723
  if (id === "" && !idArray)
31386
31724
  continue;
31387
31725
  candidateLoop:
31388
- for (const candidateIndex of candidateElements) {
31726
+ for (const candidateIndex of candidateElementsWithIds) {
31389
31727
  const candidate = fromChildNodes[candidateIndex];
31390
31728
  if (localNameMap[unmatchedIndex] === candidateLocalNameMap[candidateIndex]) {
31391
31729
  if (id !== "" && id === candidate.id) {
31392
31730
  matches[unmatchedIndex] = candidateIndex;
31393
31731
  op[unmatchedIndex] = Operation.SameElement;
31394
- candidateElements.delete(candidateIndex);
31732
+ candidateElementsWithIds.delete(candidateIndex);
31395
31733
  unmatchedElements.delete(unmatchedIndex);
31396
31734
  break candidateLoop;
31397
31735
  }
@@ -31403,7 +31741,7 @@ var init_dist = __esm({
31403
31741
  if (candidateIdSet.has(arrayId)) {
31404
31742
  matches[unmatchedIndex] = candidateIndex;
31405
31743
  op[unmatchedIndex] = Operation.SameElement;
31406
- candidateElements.delete(candidateIndex);
31744
+ candidateElementsWithIds.delete(candidateIndex);
31407
31745
  unmatchedElements.delete(unmatchedIndex);
31408
31746
  break candidateLoop;
31409
31747
  }
@@ -31478,6 +31816,8 @@ var init_dist = __esm({
31478
31816
  __privateMethod(this, _Morph_instances, removeNode_fn).call(this, fromChildNodes[i]);
31479
31817
  for (const i of candidateElements)
31480
31818
  __privateMethod(this, _Morph_instances, removeNode_fn).call(this, fromChildNodes[i]);
31819
+ for (const i of candidateElementsWithIds)
31820
+ __privateMethod(this, _Morph_instances, removeNode_fn).call(this, fromChildNodes[i]);
31481
31821
  const lisIndices = longestIncreasingSubsequence(matches);
31482
31822
  const shouldNotMove = new Array(fromChildNodes.length);
31483
31823
  for (let i = 0; i < lisIndices.length; i++) {
@@ -36243,7 +36583,7 @@ var init_dist = __esm({
36243
36583
  * a token and the immediately following pattern token fails, the matcher
36244
36584
  * resets to before the optional role and retries the failed token.
36245
36585
  */
36246
- matchTokenSequence(tokens, patternTokens, captured) {
36586
+ matchTokenSequence(tokens, patternTokens, captured, parentStopMarkers) {
36247
36587
  const firstPatternToken = patternTokens[0];
36248
36588
  const patternExpectsConjunction = firstPatternToken?.type === "literal" && (firstPatternToken.value === "and" || firstPatternToken.value === "then" || firstPatternToken.alternatives?.includes("and") || firstPatternToken.alternatives?.includes("then"));
36249
36589
  if (this.currentProfile?.code === "ar" && !patternExpectsConjunction) {
@@ -36267,6 +36607,9 @@ var init_dist = __esm({
36267
36607
  );
36268
36608
  if (patternToken.type === "role" && patternToken.greedy) {
36269
36609
  const stopMarkers = this.collectStopMarkers(patternTokens, i + 1);
36610
+ if (parentStopMarkers) {
36611
+ for (const m of parentStopMarkers) stopMarkers.add(m);
36612
+ }
36270
36613
  const values = [];
36271
36614
  while (!tokens.isAtEnd()) {
36272
36615
  const nextToken = tokens.peek();
@@ -36286,8 +36629,58 @@ var init_dist = __esm({
36286
36629
  return false;
36287
36630
  }
36288
36631
  }
36632
+ if (patternToken.type === "group") {
36633
+ const siblingStopMarkers = this.collectStopMarkers(patternTokens, i + 1);
36634
+ if (parentStopMarkers) {
36635
+ for (const m of parentStopMarkers) siblingStopMarkers.add(m);
36636
+ }
36637
+ const groupMatched = this.matchGroupToken(
36638
+ tokens,
36639
+ patternToken,
36640
+ captured,
36641
+ siblingStopMarkers
36642
+ );
36643
+ if (groupMatched) {
36644
+ prevOptionalMark = null;
36645
+ prevOptionalRole = null;
36646
+ continue;
36647
+ }
36648
+ if (this.isOptional(patternToken)) {
36649
+ continue;
36650
+ }
36651
+ return false;
36652
+ }
36289
36653
  const isOptionalRole = patternToken.type === "role" && patternToken.optional === true;
36290
36654
  const markBefore = isOptionalRole ? tokens.mark() : null;
36655
+ const isRoleToken = patternToken.type === "role";
36656
+ if (isRoleToken && !isOptionalRole) {
36657
+ const nextPT = i + 1 < patternTokens.length ? patternTokens[i + 1] : null;
36658
+ if (nextPT?.type === "literal") {
36659
+ const currentToken = tokens.peek();
36660
+ if (currentToken && this.getMatchType(currentToken, nextPT.value) !== "none") {
36661
+ this.logger.debug(
36662
+ " >> MARKER-STEAL GUARD: current token matches next literal, skipping role"
36663
+ );
36664
+ this.logger.debug(" >> Token match FAILED");
36665
+ if (this.isOptional(patternToken)) {
36666
+ continue;
36667
+ }
36668
+ if (prevOptionalMark && prevOptionalRole) {
36669
+ this.logger.debug(" >> BACKTRACKING: undoing optional role", prevOptionalRole);
36670
+ tokens.reset(prevOptionalMark);
36671
+ captured.delete(prevOptionalRole);
36672
+ prevOptionalMark = null;
36673
+ prevOptionalRole = null;
36674
+ const retryMatched = this.matchPatternToken(tokens, patternToken, captured);
36675
+ this.logger.debug(" >> Backtrack retry result:", retryMatched);
36676
+ if (retryMatched) {
36677
+ continue;
36678
+ }
36679
+ }
36680
+ return false;
36681
+ }
36682
+ }
36683
+ }
36291
36684
  const matched = this.matchPatternToken(tokens, patternToken, captured);
36292
36685
  this.logger.debug(" >> Match result:", matched);
36293
36686
  if (matched) {
@@ -36408,7 +36801,7 @@ var init_dist = __esm({
36408
36801
  const possessiveValue = this.tryMatchPossessiveExpression(tokens);
36409
36802
  if (possessiveValue) {
36410
36803
  if (patternToken.expectedTypes && patternToken.expectedTypes.length > 0) {
36411
- if (!patternToken.expectedTypes.includes(possessiveValue.type) && !patternToken.expectedTypes.includes("expression")) {
36804
+ if (!isTypeCompatible$1(possessiveValue.type, patternToken.expectedTypes)) {
36412
36805
  return patternToken.optional || false;
36413
36806
  }
36414
36807
  }
@@ -36418,7 +36811,7 @@ var init_dist = __esm({
36418
36811
  const methodCallValue = this.tryMatchMethodCallExpression(tokens);
36419
36812
  if (methodCallValue) {
36420
36813
  if (patternToken.expectedTypes && patternToken.expectedTypes.length > 0) {
36421
- if (!patternToken.expectedTypes.includes(methodCallValue.type) && !patternToken.expectedTypes.includes("expression")) {
36814
+ if (!isTypeCompatible$1(methodCallValue.type, patternToken.expectedTypes)) {
36422
36815
  return patternToken.optional || false;
36423
36816
  }
36424
36817
  }
@@ -36438,7 +36831,7 @@ var init_dist = __esm({
36438
36831
  const propertyAccessValue = this.tryMatchPropertyAccessExpression(tokens);
36439
36832
  if (propertyAccessValue) {
36440
36833
  if (patternToken.expectedTypes && patternToken.expectedTypes.length > 0) {
36441
- if (!patternToken.expectedTypes.includes(propertyAccessValue.type) && !patternToken.expectedTypes.includes("expression")) {
36834
+ if (!isTypeCompatible$1(propertyAccessValue.type, patternToken.expectedTypes)) {
36442
36835
  return patternToken.optional || false;
36443
36836
  }
36444
36837
  }
@@ -36757,10 +37150,15 @@ var init_dist = __esm({
36757
37150
  * (e.g., a value like 'hello') to sit between groups without blocking later
36758
37151
  * marker matches.
36759
37152
  */
36760
- matchGroupToken(tokens, patternToken, captured) {
37153
+ matchGroupToken(tokens, patternToken, captured, parentStopMarkers) {
36761
37154
  const mark = tokens.mark();
36762
37155
  const capturedBefore = new Set(captured.keys());
36763
- const success2 = this.matchTokenSequence(tokens, patternToken.tokens, captured);
37156
+ const success2 = this.matchTokenSequence(
37157
+ tokens,
37158
+ patternToken.tokens,
37159
+ captured,
37160
+ parentStopMarkers
37161
+ );
36764
37162
  if (success2) return true;
36765
37163
  tokens.reset(mark);
36766
37164
  for (const role of captured.keys()) {
@@ -36782,7 +37180,12 @@ var init_dist = __esm({
36782
37180
  "- skipping intervening tokens"
36783
37181
  );
36784
37182
  for (let s = 0; s < offset; s++) tokens.advance();
36785
- const retrySuccess = this.matchTokenSequence(tokens, patternToken.tokens, captured);
37183
+ const retrySuccess = this.matchTokenSequence(
37184
+ tokens,
37185
+ patternToken.tokens,
37186
+ captured,
37187
+ parentStopMarkers
37188
+ );
36786
37189
  if (retrySuccess) return true;
36787
37190
  tokens.reset(mark);
36788
37191
  for (const role of captured.keys()) {
@@ -36849,7 +37252,7 @@ var init_dist = __esm({
36849
37252
  break;
36850
37253
  }
36851
37254
  }
36852
- break;
37255
+ if (!pt.optional) break;
36853
37256
  }
36854
37257
  }
36855
37258
  return markers;
@@ -36859,8 +37262,9 @@ var init_dist = __esm({
36859
37262
  */
36860
37263
  isStopMarker(token, stopMarkers) {
36861
37264
  if (stopMarkers.size === 0) return false;
36862
- const value = (token.normalized || token.value).toLowerCase();
36863
- return stopMarkers.has(value);
37265
+ if (stopMarkers.has(token.value.toLowerCase())) return true;
37266
+ if (token.normalized && stopMarkers.has(token.normalized.toLowerCase())) return true;
37267
+ return false;
36864
37268
  }
36865
37269
  /**
36866
37270
  * Convert a language token to a semantic value.
@@ -37329,6 +37733,27 @@ var init_dist = __esm({
37329
37733
  } : null;
37330
37734
  }
37331
37735
  };
37736
+ DEFAULT_REFERENCES = /* @__PURE__ */ new Set([
37737
+ "me",
37738
+ "you",
37739
+ "it",
37740
+ "result",
37741
+ "event",
37742
+ "target",
37743
+ "body"
37744
+ ]);
37745
+ STRUCTURAL_ROLES = /* @__PURE__ */ new Set([
37746
+ "body",
37747
+ "then",
37748
+ "else",
37749
+ "condition",
37750
+ "loop-body",
37751
+ "variable",
37752
+ "catch",
37753
+ // v1.2: try/catch/finally
37754
+ "finally"
37755
+ // v1.2: try/catch/finally
37756
+ ]);
37332
37757
  TokenStreamImpl = class {
37333
37758
  constructor(tokens, language) {
37334
37759
  this.pos = 0;
@@ -42775,6 +43200,10 @@ var init_dist = __esm({
42775
43200
  // Loop commands
42776
43201
  FOR_LOOP_MISSING_SOURCE: "SCHEMA_FOR_LOOP_MISSING_SOURCE",
42777
43202
  WHILE_LOOP_MISSING_CONDITION: "SCHEMA_WHILE_LOOP_MISSING_CONDITION",
43203
+ // Type constraint issues (v1.2)
43204
+ VALUE_TYPE_MISMATCH: "SCHEMA_VALUE_TYPE_MISMATCH",
43205
+ SELECTOR_KIND_MISMATCH: "SCHEMA_SELECTOR_KIND_MISMATCH",
43206
+ SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE: "SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",
42778
43207
  // Keyword collision
42779
43208
  KEYWORD_COLLISION: "PROFILE_KEYWORD_COLLISION"
42780
43209
  };
@@ -42798,6 +43227,10 @@ var init_dist = __esm({
42798
43227
  // Loops
42799
43228
  [SchemaErrorCodes.FOR_LOOP_MISSING_SOURCE]: "For-loop should have a 'source' role for the collection to iterate over.",
42800
43229
  [SchemaErrorCodes.WHILE_LOOP_MISSING_CONDITION]: "While-loop should have a 'condition' role for the loop condition.",
43230
+ // Type constraint (v1.2)
43231
+ [SchemaErrorCodes.VALUE_TYPE_MISMATCH]: "Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",
43232
+ [SchemaErrorCodes.SELECTOR_KIND_MISMATCH]: "Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",
43233
+ [SchemaErrorCodes.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]: "Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",
42801
43234
  // Keyword collision
42802
43235
  [SchemaErrorCodes.KEYWORD_COLLISION]: "Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."
42803
43236
  };
@@ -42812,6 +43245,9 @@ var init_dist = __esm({
42812
43245
  [SchemaErrorCodes.CONDITIONAL_CONDITION_NOT_REQUIRED]: "Set required: true on the 'condition' role.",
42813
43246
  [SchemaErrorCodes.FOR_LOOP_MISSING_SOURCE]: "Add a 'source' role for the collection to iterate over.",
42814
43247
  [SchemaErrorCodes.WHILE_LOOP_MISSING_CONDITION]: "Add a 'condition' role for the loop continuation condition.",
43248
+ [SchemaErrorCodes.VALUE_TYPE_MISMATCH]: "Ensure the value matches one of the expected types: [{expectedTypes}].",
43249
+ [SchemaErrorCodes.SELECTOR_KIND_MISMATCH]: "Use a selector of the correct kind: [{selectorKinds}].",
43250
+ [SchemaErrorCodes.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]: "Either add 'selector' to expectedTypes or remove selectorKinds.",
42815
43251
  [SchemaErrorCodes.KEYWORD_COLLISION]: "Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."
42816
43252
  };
42817
43253
  }
@@ -42824,7 +43260,8 @@ var init_dist = __esm({
42824
43260
  validateAllKeywordCollisions: () => validateAllKeywordCollisions,
42825
43261
  validateAllSchemas: () => validateAllSchemas,
42826
43262
  validateCommandSchema: () => validateCommandSchema,
42827
- validateKeywordCollisions: () => validateKeywordCollisions
43263
+ validateKeywordCollisions: () => validateKeywordCollisions,
43264
+ validateRoleValues: () => validateRoleValues
42828
43265
  });
42829
43266
  init_schema_validator = __esm2({
42830
43267
  "src/generators/schema-validator.ts"() {
@@ -42882,6 +43319,7 @@ var init_dist = __esm({
42882
43319
  description: "The class or attribute to toggle",
42883
43320
  required: true,
42884
43321
  expectedTypes: ["selector"],
43322
+ selectorKinds: ["class", "attribute"],
42885
43323
  svoPosition: 1,
42886
43324
  sovPosition: 2
42887
43325
  },
@@ -54117,15 +54555,6 @@ var init_dist = __esm({
54117
54555
  });
54118
54556
  init_types2 = __esm2({
54119
54557
  "src/types.ts"() {
54120
- VALID_REFERENCES = /* @__PURE__ */ new Set([
54121
- "me",
54122
- "you",
54123
- "it",
54124
- "result",
54125
- "event",
54126
- "target",
54127
- "body"
54128
- ]);
54129
54558
  }
54130
54559
  });
54131
54560
  init_shared = __esm2({
@@ -55288,25 +55717,10 @@ var init_dist = __esm({
55288
55717
  }
55289
55718
  /**
55290
55719
  * Render a semantic node in explicit mode.
55720
+ * Delegates to @lokascript/framework/ir for the core logic.
55291
55721
  */
55292
55722
  renderExplicit(node) {
55293
- if (node.kind === "compound") {
55294
- const compoundNode = node;
55295
- const renderedStatements = compoundNode.statements.map((stmt) => this.renderExplicit(stmt));
55296
- return renderedStatements.join(` ${compoundNode.chainType} `);
55297
- }
55298
- const parts = [node.action];
55299
- for (const [role, value] of node.roles) {
55300
- parts.push(`${role}:${this.valueToString(value)}`);
55301
- }
55302
- if (node.kind === "event-handler") {
55303
- const eventNode = node;
55304
- if (eventNode.body && eventNode.body.length > 0) {
55305
- const bodyParts = eventNode.body.map((n) => this.renderExplicit(n));
55306
- parts.push(`body:${bodyParts.join(" ")}`);
55307
- }
55308
- }
55309
- return `[${parts.join(" ")}]`;
55723
+ return renderExplicit$1(node);
55310
55724
  }
55311
55725
  /**
55312
55726
  * Get all supported languages.
@@ -55399,41 +55813,21 @@ var init_dist = __esm({
55399
55813
  }
55400
55814
  }
55401
55815
  const groupParts = [];
55816
+ let hasRoleValue = false;
55402
55817
  for (const subToken of token.tokens) {
55403
55818
  const rendered = this.renderPatternToken(subToken, node, language);
55404
55819
  if (rendered !== null) {
55405
55820
  groupParts.push(rendered);
55821
+ if (subToken.type === "role") hasRoleValue = true;
55406
55822
  }
55407
55823
  }
55824
+ if (token.optional && !hasRoleValue) return null;
55408
55825
  return groupParts.length > 0 ? groupParts.join(" ") : null;
55409
55826
  }
55410
55827
  default:
55411
55828
  return null;
55412
55829
  }
55413
55830
  }
55414
- /**
55415
- * Convert a semantic value to a string for explicit syntax.
55416
- */
55417
- valueToString(value) {
55418
- switch (value.type) {
55419
- case "literal":
55420
- if (typeof value.value === "string") {
55421
- if (value.dataType === "string" || /\s/.test(value.value)) {
55422
- return `"${value.value}"`;
55423
- }
55424
- return value.value;
55425
- }
55426
- return String(value.value);
55427
- case "selector":
55428
- return value.value;
55429
- case "reference":
55430
- return value.value;
55431
- case "property-path":
55432
- return `${this.valueToString(value.object)}'s ${value.property}`;
55433
- case "expression":
55434
- return value.raw;
55435
- }
55436
- }
55437
55831
  /**
55438
55832
  * Convert a semantic value to natural language string.
55439
55833
  * Uses language-specific possessive rendering when language is provided.
@@ -55453,6 +55847,8 @@ var init_dist = __esm({
55453
55847
  return this.renderPropertyPath(value, language);
55454
55848
  case "expression":
55455
55849
  return value.raw;
55850
+ case "flag":
55851
+ return value.name;
55456
55852
  }
55457
55853
  }
55458
55854
  /**
@@ -55525,8 +55921,8 @@ var init_dist = __esm({
55525
55921
  });
55526
55922
  init_parser = __esm2({
55527
55923
  "src/explicit/parser.ts"() {
55528
- init_types2();
55529
55924
  init_command_schemas();
55925
+ hyperscriptSchemaLookup = { getSchema };
55530
55926
  }
55531
55927
  });
55532
55928
  semantic_parser_exports = {};
@@ -59245,6 +59641,276 @@ var init_dist = __esm({
59245
59641
  };
59246
59642
  DEFAULT_EVENT_TYPE = "click";
59247
59643
  DEFAULT_LANGUAGE$1 = "en";
59644
+ RingBuffer = class {
59645
+ constructor(capacity) {
59646
+ this.capacity = capacity;
59647
+ this.head = 0;
59648
+ this.count = 0;
59649
+ this.items = new Array(capacity);
59650
+ }
59651
+ push(item) {
59652
+ this.items[this.head] = item;
59653
+ this.head = (this.head + 1) % this.capacity;
59654
+ if (this.count < this.capacity)
59655
+ this.count++;
59656
+ }
59657
+ toArray() {
59658
+ if (this.count < this.capacity) {
59659
+ return this.items.slice(0, this.count);
59660
+ }
59661
+ return [...this.items.slice(this.head), ...this.items.slice(0, this.head)];
59662
+ }
59663
+ get length() {
59664
+ return this.count;
59665
+ }
59666
+ clear() {
59667
+ this.head = 0;
59668
+ this.count = 0;
59669
+ }
59670
+ last() {
59671
+ if (this.count === 0)
59672
+ return void 0;
59673
+ const idx = (this.head - 1 + this.capacity) % this.capacity;
59674
+ return this.items[idx];
59675
+ }
59676
+ };
59677
+ HISTORY_CAPACITY = 200;
59678
+ DebugController = class {
59679
+ constructor() {
59680
+ this.state = {
59681
+ enabled: false,
59682
+ paused: false,
59683
+ stepMode: "continue",
59684
+ callDepth: 0,
59685
+ pauseDepth: 0,
59686
+ currentSnapshot: null
59687
+ };
59688
+ this.history = new RingBuffer(HISTORY_CAPACITY);
59689
+ this.breakpoints = /* @__PURE__ */ new Map();
59690
+ this.snapshotIndex = 0;
59691
+ this._resumeResolver = null;
59692
+ this.listeners = /* @__PURE__ */ new Map();
59693
+ this.hooks = {
59694
+ beforeExecute: this.beforeExecute.bind(this),
59695
+ afterExecute: this.afterExecute.bind(this)
59696
+ };
59697
+ }
59698
+ on(event, listener) {
59699
+ let set = this.listeners.get(event);
59700
+ if (!set) {
59701
+ set = /* @__PURE__ */ new Set();
59702
+ this.listeners.set(event, set);
59703
+ }
59704
+ set.add(listener);
59705
+ return () => set.delete(listener);
59706
+ }
59707
+ emit(event, data) {
59708
+ const set = this.listeners.get(event);
59709
+ if (set) {
59710
+ for (const listener of set) {
59711
+ try {
59712
+ listener(data);
59713
+ } catch {
59714
+ }
59715
+ }
59716
+ }
59717
+ }
59718
+ enable() {
59719
+ this.state.enabled = true;
59720
+ this.emit("enabled");
59721
+ }
59722
+ disable() {
59723
+ if (this.state.paused && this._resumeResolver) {
59724
+ this._resumeResolver();
59725
+ this._resumeResolver = null;
59726
+ }
59727
+ this.state.enabled = false;
59728
+ this.state.paused = false;
59729
+ this.state.stepMode = "continue";
59730
+ this.state.callDepth = 0;
59731
+ this.emit("disabled");
59732
+ }
59733
+ get enabled() {
59734
+ return this.state.enabled;
59735
+ }
59736
+ continue() {
59737
+ this.state.stepMode = "continue";
59738
+ this.resume();
59739
+ }
59740
+ pause() {
59741
+ this.state.stepMode = "pause";
59742
+ }
59743
+ stepOver() {
59744
+ this.state.stepMode = "over";
59745
+ this.state.pauseDepth = this.state.callDepth;
59746
+ this.resume();
59747
+ }
59748
+ stepInto() {
59749
+ this.state.stepMode = "into";
59750
+ this.resume();
59751
+ }
59752
+ stepOut() {
59753
+ this.state.stepMode = "out";
59754
+ this.state.pauseDepth = this.state.callDepth;
59755
+ this.resume();
59756
+ }
59757
+ resume() {
59758
+ if (this._resumeResolver) {
59759
+ this.state.paused = false;
59760
+ this.emit("resumed");
59761
+ this._resumeResolver();
59762
+ this._resumeResolver = null;
59763
+ }
59764
+ }
59765
+ setBreakpoint(condition) {
59766
+ const id = `bp_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
59767
+ this.breakpoints.set(id, { ...condition, id, hitCount: 0 });
59768
+ return id;
59769
+ }
59770
+ removeBreakpoint(id) {
59771
+ return this.breakpoints.delete(id);
59772
+ }
59773
+ getBreakpoints() {
59774
+ return Array.from(this.breakpoints.values());
59775
+ }
59776
+ clearBreakpoints() {
59777
+ this.breakpoints.clear();
59778
+ }
59779
+ getState() {
59780
+ return { ...this.state };
59781
+ }
59782
+ getHistory() {
59783
+ return this.history.toArray();
59784
+ }
59785
+ clearHistory() {
59786
+ this.history.clear();
59787
+ this.snapshotIndex = 0;
59788
+ }
59789
+ async beforeExecute(ctx) {
59790
+ if (!this.state.enabled)
59791
+ return;
59792
+ this.state.callDepth++;
59793
+ const snapshot = this.captureSnapshot(ctx);
59794
+ this.history.push(snapshot);
59795
+ this.emit("snapshot", snapshot);
59796
+ if (this.shouldPause(ctx)) {
59797
+ this.state.paused = true;
59798
+ this.state.currentSnapshot = snapshot;
59799
+ this.emit("paused", snapshot);
59800
+ await new Promise((resolve) => {
59801
+ this._resumeResolver = resolve;
59802
+ });
59803
+ this.state.currentSnapshot = null;
59804
+ }
59805
+ }
59806
+ async afterExecute(ctx, result) {
59807
+ if (!this.state.enabled)
59808
+ return;
59809
+ const lastSnapshot = this.history.last();
59810
+ if (lastSnapshot) {
59811
+ lastSnapshot.variables["__result"] = serializeValue(result);
59812
+ }
59813
+ this.state.callDepth = Math.max(0, this.state.callDepth - 1);
59814
+ }
59815
+ shouldPause(ctx) {
59816
+ if (this.hitBreakpoint(ctx))
59817
+ return true;
59818
+ switch (this.state.stepMode) {
59819
+ case "pause":
59820
+ this.state.stepMode = "into";
59821
+ return true;
59822
+ case "into":
59823
+ return true;
59824
+ case "over":
59825
+ return this.state.callDepth <= this.state.pauseDepth;
59826
+ case "out":
59827
+ return this.state.callDepth < this.state.pauseDepth;
59828
+ case "continue":
59829
+ return false;
59830
+ }
59831
+ }
59832
+ hitBreakpoint(ctx) {
59833
+ for (const bp of this.breakpoints.values()) {
59834
+ if (!bp.enabled)
59835
+ continue;
59836
+ let hit = false;
59837
+ switch (bp.type) {
59838
+ case "command":
59839
+ hit = ctx.commandName === bp.value;
59840
+ break;
59841
+ case "element":
59842
+ if (ctx.element) {
59843
+ try {
59844
+ hit = ctx.element.matches(bp.value);
59845
+ } catch {
59846
+ }
59847
+ }
59848
+ break;
59849
+ case "expression":
59850
+ hit = this.evaluateCondition(bp.value, ctx);
59851
+ break;
59852
+ }
59853
+ if (hit) {
59854
+ bp.hitCount++;
59855
+ return true;
59856
+ }
59857
+ }
59858
+ return false;
59859
+ }
59860
+ evaluateCondition(expression, ctx) {
59861
+ try {
59862
+ const ec = ctx.executionContext;
59863
+ const vars = {
59864
+ commandName: ctx.commandName,
59865
+ it: ec.it,
59866
+ result: ec.result,
59867
+ me: ec.me
59868
+ };
59869
+ if (ec.locals) {
59870
+ for (const [k, v2] of ec.locals) {
59871
+ vars[k] = v2;
59872
+ }
59873
+ }
59874
+ const keys = Object.keys(vars);
59875
+ const values = keys.map((k) => vars[k]);
59876
+ const fn = new Function(...keys, `return (${expression});`);
59877
+ return !!fn(...values);
59878
+ } catch {
59879
+ return false;
59880
+ }
59881
+ }
59882
+ captureSnapshot(ctx) {
59883
+ const ec = ctx.executionContext;
59884
+ const variables = {};
59885
+ variables["it"] = serializeValue(ec.it);
59886
+ variables["result"] = serializeValue(ec.result);
59887
+ if (ec.me)
59888
+ variables["me"] = describeElement(ec.me);
59889
+ if (ec.you)
59890
+ variables["you"] = describeElement(ec.you);
59891
+ if (ctx.event) {
59892
+ variables["event.type"] = ctx.event.type;
59893
+ if (ctx.event.target) {
59894
+ variables["event.target"] = describeElement(ctx.event.target);
59895
+ }
59896
+ }
59897
+ if (ec.locals) {
59898
+ for (const [key, value] of ec.locals) {
59899
+ if (!key.startsWith("__")) {
59900
+ variables[`:${key}`] = serializeValue(value);
59901
+ }
59902
+ }
59903
+ }
59904
+ return {
59905
+ commandName: ctx.commandName,
59906
+ element: ctx.element,
59907
+ variables,
59908
+ timestamp: Date.now(),
59909
+ depth: this.state.callDepth,
59910
+ index: this.snapshotIndex++
59911
+ };
59912
+ }
59913
+ };
59248
59914
  DEFAULT_LANGUAGE = "en";
59249
59915
  ASTCache = class {
59250
59916
  constructor(maxSize = 500) {
@@ -59306,6 +59972,7 @@ var init_dist = __esm({
59306
59972
  confidenceThreshold: DEFAULT_CONFIDENCE_THRESHOLD
59307
59973
  };
59308
59974
  _defaultRuntime = null;
59975
+ _debugController = null;
59309
59976
  initializeDOMProcessor(compileSync, compileAsync, getDefaultRuntime);
59310
59977
  hyperscript = {
59311
59978
  compile: compileAsync,
@@ -59328,7 +59995,10 @@ var init_dist = __esm({
59328
59995
  return getDefaultRuntime().getRegisteredHooks();
59329
59996
  },
59330
59997
  clearCache: () => astCache.clear(),
59331
- getCacheStats: () => astCache.getStats()
59998
+ getCacheStats: () => astCache.getStats(),
59999
+ get debug() {
60000
+ return getDebugController();
60001
+ }
59332
60002
  };
59333
60003
  lokascript = hyperscript;
59334
60004
  OP_TABLE = {
@@ -65892,13 +66562,333 @@ function analyze2(ast) {
65892
66562
  const analyzer = new Analyzer();
65893
66563
  return analyzer.analyze(ast);
65894
66564
  }
66565
+ function extractClassOp2(node) {
66566
+ if (node.type !== "command") return null;
66567
+ const cmd = node;
66568
+ if (!CLASS_COMMANDS.has(cmd.name)) return null;
66569
+ const args = cmd.args ?? [];
66570
+ if (args.length === 0) return null;
66571
+ const arg = args[0];
66572
+ if (arg.type !== "selector") return null;
66573
+ const selector = arg.value;
66574
+ if (!selector.startsWith(".")) return null;
66575
+ const className = selector.slice(1);
66576
+ if (!className) return null;
66577
+ return {
66578
+ command: cmd.name,
66579
+ className,
66580
+ hasExplicitTarget: !!cmd.target
66581
+ };
66582
+ }
66583
+ function isSameTarget(a, b) {
66584
+ if (a.type !== "command" || b.type !== "command") return false;
66585
+ const cmdA = a;
66586
+ const cmdB = b;
66587
+ if (!cmdA.target && !cmdB.target) return true;
66588
+ if (cmdA.target && cmdB.target) {
66589
+ return getTargetKey(cmdA.target) === getTargetKey(cmdB.target);
66590
+ }
66591
+ return false;
66592
+ }
66593
+ function getTargetKey(target) {
66594
+ if (target.type === "selector") {
66595
+ return `selector:${target.value}`;
66596
+ }
66597
+ if (target.type === "identifier") {
66598
+ return `identifier:${target.value}`;
66599
+ }
66600
+ return null;
66601
+ }
66602
+ function resolveTarget2(cmd) {
66603
+ if (!cmd.target) return "_ctx.me";
66604
+ if (cmd.target.type === "selector") {
66605
+ const sel = cmd.target.value;
66606
+ if (sel.startsWith("#") && !sel.includes(" ") && !sel.includes(".")) {
66607
+ return `document.getElementById('${sel.slice(1)}')`;
66608
+ }
66609
+ return `document.querySelector('${sel}')`;
66610
+ }
66611
+ if (cmd.target.type === "identifier") {
66612
+ const val = cmd.target.value;
66613
+ if (val === "me") return "_ctx.me";
66614
+ return val;
66615
+ }
66616
+ return "_ctx.me";
66617
+ }
66618
+ function createBatchNode(run) {
66619
+ const adds = [];
66620
+ const removes = [];
66621
+ const toggles = [];
66622
+ for (const node of run) {
66623
+ const op = extractClassOp2(node);
66624
+ switch (op.command) {
66625
+ case "add":
66626
+ adds.push(op.className);
66627
+ break;
66628
+ case "remove":
66629
+ removes.push(op.className);
66630
+ break;
66631
+ case "toggle":
66632
+ toggles.push(op.className);
66633
+ break;
66634
+ }
66635
+ }
66636
+ const target = resolveTarget2(run[0]);
66637
+ return {
66638
+ type: "batchedClassOps",
66639
+ target,
66640
+ adds,
66641
+ removes,
66642
+ toggles
66643
+ };
66644
+ }
66645
+ function batchBody(nodes) {
66646
+ const result = [];
66647
+ let currentRun = [];
66648
+ function flushRun() {
66649
+ if (currentRun.length >= 2) {
66650
+ result.push(createBatchNode(currentRun));
66651
+ } else if (currentRun.length === 1) {
66652
+ result.push(currentRun[0]);
66653
+ }
66654
+ currentRun = [];
66655
+ }
66656
+ for (const node of nodes) {
66657
+ const op = extractClassOp2(node);
66658
+ if (op) {
66659
+ if (currentRun.length > 0 && isSameTarget(currentRun[0], node)) {
66660
+ currentRun.push(node);
66661
+ } else {
66662
+ flushRun();
66663
+ currentRun = [node];
66664
+ }
66665
+ } else {
66666
+ flushRun();
66667
+ result.push(node);
66668
+ }
66669
+ }
66670
+ flushRun();
66671
+ return result;
66672
+ }
66673
+ function walkAndBatch(node) {
66674
+ switch (node.type) {
66675
+ case "event": {
66676
+ const event = node;
66677
+ if (event.body && event.body.length > 0) {
66678
+ return { ...event, body: batchBody(event.body).map(walkAndBatch) };
66679
+ }
66680
+ return node;
66681
+ }
66682
+ case "if": {
66683
+ const ifNode = node;
66684
+ const result = { ...ifNode };
66685
+ result.thenBranch = batchBody(ifNode.thenBranch).map(walkAndBatch);
66686
+ if (ifNode.elseBranch) {
66687
+ result.elseBranch = batchBody(ifNode.elseBranch).map(walkAndBatch);
66688
+ }
66689
+ if (ifNode.elseIfBranches) {
66690
+ result.elseIfBranches = ifNode.elseIfBranches.map((branch) => ({
66691
+ condition: branch.condition,
66692
+ body: batchBody(branch.body).map(walkAndBatch)
66693
+ }));
66694
+ }
66695
+ return result;
66696
+ }
66697
+ case "repeat": {
66698
+ const repeat = node;
66699
+ return { ...repeat, body: batchBody(repeat.body).map(walkAndBatch) };
66700
+ }
66701
+ case "foreach": {
66702
+ const forEach = node;
66703
+ return { ...forEach, body: batchBody(forEach.body).map(walkAndBatch) };
66704
+ }
66705
+ case "while": {
66706
+ const whileNode = node;
66707
+ return { ...whileNode, body: batchBody(whileNode.body).map(walkAndBatch) };
66708
+ }
66709
+ default:
66710
+ return node;
66711
+ }
66712
+ }
65895
66713
  function createOptimizer() {
65896
- return new OptimizationPipeline();
66714
+ return /* @__PURE__ */ new OptimizationPipeline();
65897
66715
  }
65898
66716
  function optimize(ast, analysis, level = 2) {
65899
66717
  const pipeline = new OptimizationPipeline();
65900
66718
  return pipeline.optimize(ast, analysis, level);
65901
66719
  }
66720
+ function classifyCommand(node) {
66721
+ if (node.type !== "command") return null;
66722
+ const cmd = node;
66723
+ switch (cmd.name) {
66724
+ case "add":
66725
+ return classifyAddCommand(cmd);
66726
+ case "remove":
66727
+ return classifyRemoveCommand(cmd);
66728
+ case "put":
66729
+ return classifyPutCommand(cmd);
66730
+ case "set":
66731
+ return classifySetCommand(cmd);
66732
+ default:
66733
+ return null;
66734
+ }
66735
+ }
66736
+ function getIdTarget(cmd) {
66737
+ if (!cmd.target) return null;
66738
+ if (cmd.target.type !== "selector") return null;
66739
+ const sel = cmd.target.value;
66740
+ if (!sel.startsWith("#")) return null;
66741
+ return sel.slice(1);
66742
+ }
66743
+ function classifyAddCommand(cmd) {
66744
+ const targetId = getIdTarget(cmd);
66745
+ if (!targetId) return null;
66746
+ const args = cmd.args ?? [];
66747
+ if (args.length === 0) return null;
66748
+ const arg = args[0];
66749
+ if (arg.type !== "selector") return null;
66750
+ const val = arg.value;
66751
+ if (!val.startsWith(".")) return null;
66752
+ return { type: "addClass", targetId, value: val.slice(1) };
66753
+ }
66754
+ function classifyRemoveCommand(cmd) {
66755
+ const targetId = getIdTarget(cmd);
66756
+ if (!targetId) return null;
66757
+ const args = cmd.args ?? [];
66758
+ if (args.length === 0) return null;
66759
+ const arg = args[0];
66760
+ if (arg.type !== "selector") return null;
66761
+ const val = arg.value;
66762
+ if (!val.startsWith(".")) return null;
66763
+ return { type: "removeClass", targetId, value: val.slice(1) };
66764
+ }
66765
+ function classifyPutCommand(cmd) {
66766
+ const targetId = getIdTarget(cmd);
66767
+ if (!targetId) return null;
66768
+ const args = cmd.args ?? [];
66769
+ if (args.length === 0) return null;
66770
+ const arg = args[0];
66771
+ if (arg.type !== "literal") return null;
66772
+ const val = arg.value;
66773
+ if (typeof val !== "string") return null;
66774
+ return { type: "putContent", targetId, value: val };
66775
+ }
66776
+ function classifySetCommand(cmd) {
66777
+ const targetId = getIdTarget(cmd);
66778
+ if (!targetId) return null;
66779
+ const args = cmd.args ?? [];
66780
+ if (args.length < 2) return null;
66781
+ const attrArg = args[0];
66782
+ if (attrArg.type !== "identifier") return null;
66783
+ const attrValue = attrArg.value;
66784
+ if (!attrValue || !attrValue.startsWith("@")) return null;
66785
+ const attrName = attrValue.slice(1);
66786
+ const valArg = args[1];
66787
+ if (valArg.type !== "literal") return null;
66788
+ const val = valArg.value;
66789
+ if (typeof val !== "string" && typeof val !== "number") return null;
66790
+ return { type: "setAttribute", targetId, value: String(val), attrName };
66791
+ }
66792
+ function classifyInitCommands(commands) {
66793
+ const pure = [];
66794
+ const impure = [];
66795
+ for (let i = 0; i < commands.length; i++) {
66796
+ const classified = classifyCommand(commands[i]);
66797
+ if (classified) {
66798
+ pure.push({ index: i, command: classified });
66799
+ } else {
66800
+ impure.push({ index: i, node: commands[i] });
66801
+ }
66802
+ }
66803
+ return { pure, impure };
66804
+ }
66805
+ function applyPureCommand(html, cmd) {
66806
+ switch (cmd.type) {
66807
+ case "addClass":
66808
+ return addClassToElement(html, cmd.targetId, cmd.value);
66809
+ case "removeClass":
66810
+ return removeClassFromElement(html, cmd.targetId, cmd.value);
66811
+ case "putContent":
66812
+ return putContentIntoElement(html, cmd.targetId, cmd.value);
66813
+ case "setAttribute":
66814
+ return setAttributeOnElement(html, cmd.targetId, cmd.attrName, cmd.value);
66815
+ default:
66816
+ return html;
66817
+ }
66818
+ }
66819
+ function transformElementById(html, id, transform) {
66820
+ const idPattern = new RegExp(`(<[^>]*\\bid=["']${escapeRegExp(id)}["'][^>]*>)`, "i");
66821
+ const match = html.match(idPattern);
66822
+ if (!match) return html;
66823
+ return html.replace(match[1], transform(match[1]));
66824
+ }
66825
+ function addClassToElement(html, id, className) {
66826
+ return transformElementById(html, id, (tag) => {
66827
+ const classMatch = tag.match(/\bclass=["']([^"']*)["']/i);
66828
+ if (classMatch) {
66829
+ const existing = classMatch[1];
66830
+ const classes = existing.split(/\s+/).filter(Boolean);
66831
+ if (!classes.includes(className)) {
66832
+ classes.push(className);
66833
+ }
66834
+ return tag.replace(classMatch[0], `class="${classes.join(" ")}"`);
66835
+ }
66836
+ return tag.replace(/>$/, ` class="${className}">`);
66837
+ });
66838
+ }
66839
+ function removeClassFromElement(html, id, className) {
66840
+ return transformElementById(html, id, (tag) => {
66841
+ const classMatch = tag.match(/\bclass=["']([^"']*)["']/i);
66842
+ if (!classMatch) return tag;
66843
+ const classes = classMatch[1].split(/\s+/).filter((c) => c !== className);
66844
+ if (classes.length === 0) {
66845
+ return tag.replace(classMatch[0], "").replace(/\s+>/, ">");
66846
+ }
66847
+ return tag.replace(classMatch[0], `class="${classes.join(" ")}"`);
66848
+ });
66849
+ }
66850
+ function putContentIntoElement(html, id, content) {
66851
+ const idPattern = new RegExp(
66852
+ `(<[a-zA-Z][^>]*\\bid=["']${escapeRegExp(id)}["'][^>]*>)((?:(?!<\\/[a-zA-Z]).)*?)(<\\/[a-zA-Z][^>]*>)`,
66853
+ "is"
66854
+ );
66855
+ const match = html.match(idPattern);
66856
+ if (!match) return html;
66857
+ return html.replace(match[0], `${match[1]}${escapeHtml(content)}${match[3]}`);
66858
+ }
66859
+ function setAttributeOnElement(html, id, attrName, value) {
66860
+ return transformElementById(html, id, (tag) => {
66861
+ const attrPattern = new RegExp(`\\b${escapeRegExp(attrName)}=["'][^"']*["']`, "i");
66862
+ const attrMatch = tag.match(attrPattern);
66863
+ if (attrMatch) {
66864
+ return tag.replace(attrMatch[0], `${attrName}="${escapeHtml(value)}"`);
66865
+ }
66866
+ return tag.replace(/>$/, ` ${attrName}="${escapeHtml(value)}">`);
66867
+ });
66868
+ }
66869
+ function escapeRegExp(str) {
66870
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
66871
+ }
66872
+ function escapeHtml(str) {
66873
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
66874
+ }
66875
+ function preRenderInitBlock(html, initCommands) {
66876
+ const { pure, impure } = classifyInitCommands(initCommands);
66877
+ let modifiedHtml = html;
66878
+ let preRenderedCount = 0;
66879
+ for (const { command: command2 } of pure) {
66880
+ const before = modifiedHtml;
66881
+ modifiedHtml = applyPureCommand(modifiedHtml, command2);
66882
+ if (modifiedHtml !== before) {
66883
+ preRenderedCount++;
66884
+ }
66885
+ }
66886
+ return {
66887
+ html: modifiedHtml,
66888
+ remainingInitCommands: impure.map((i) => i.node),
66889
+ preRenderedCount
66890
+ };
66891
+ }
65902
66892
  function sanitizeClassName(name) {
65903
66893
  if (!/^-?[a-zA-Z_][a-zA-Z0-9_-]*$/.test(name)) {
65904
66894
  return null;
@@ -66056,12 +67046,13 @@ async function createMultilingualCompiler() {
66056
67046
  }
66057
67047
  return compiler;
66058
67048
  }
66059
- var DEFAULT_OPTIONS, ELEMENT_REGEX, SCRIPT_TAG_REGEX, ID_REGEX, CLASS_REGEX, LANG_REGEX, HTMLScanner, VueScanner, SvelteScanner, JSXScanner, Analyzer, AnalysisVisitor, ConstantFoldingPass, SelectorCachingPass, DeadCodeEliminationPass, LoopUnrollingPass, OptimizationPipeline, ExpressionCodegen, ToggleCodegen, AddCodegen, RemoveCodegen, SetCodegen, PutCodegen, ShowCodegen, HideCodegen, FocusCodegen, BlurCodegen, LogCodegen, WaitCodegen, FetchCodegen, SendCodegen, IncrementCodegen, DecrementCodegen, HaltCodegen, ExitCodegen, ReturnCodegen, CallCodegen, ScrollCodegen, TakeCodegen, UnlessCodegen, ThrowCodegen, DefaultCodegen, GoCodegen, AppendCodegen, PickCodegen, PushUrlCodegen, ReplaceUrlCodegen, GetCodegen, BreakCodegen, ContinueCodegen, BeepCodegen, JsCodegen, CopyCodegen, MakeCodegen, SwapCodegen, MorphCodegen, TransitionCodegen, MeasureCodegen, SettleCodegen, TellCodegen, AsyncCodegen, InstallCodegen, RenderCodegen, commandCodegens, EventHandlerCodegen, DEFAULT_COMPILE_OPTIONS, DEFAULT_CODEGEN_OPTIONS, AOTCompiler, VERSION2;
67049
+ var import_framework2, DEFAULT_OPTIONS, ELEMENT_REGEX, SCRIPT_TAG_REGEX, ID_REGEX, CLASS_REGEX, LANG_REGEX, HTMLScanner, VueScanner, SvelteScanner, JSXScanner, Analyzer, AnalysisVisitor, CLASS_COMMANDS, ClassBatchingPass, ConstantFoldingPass, SelectorCachingPass, DeadCodeEliminationPass, LoopUnrollingPass, OptimizationPipeline, ExpressionCodegen, ToggleCodegen, AddCodegen, RemoveCodegen, SetCodegen, PutCodegen, ShowCodegen, HideCodegen, FocusCodegen, BlurCodegen, LogCodegen, WaitCodegen, FetchCodegen, SendCodegen, IncrementCodegen, DecrementCodegen, HaltCodegen, ExitCodegen, ReturnCodegen, CallCodegen, ScrollCodegen, TakeCodegen, UnlessCodegen, ThrowCodegen, DefaultCodegen, GoCodegen, AppendCodegen, PickCodegen, PushUrlCodegen, ReplaceUrlCodegen, GetCodegen, BreakCodegen, ContinueCodegen, BeepCodegen, JsCodegen, CopyCodegen, MakeCodegen, SwapCodegen, MorphCodegen, TransitionCodegen, MeasureCodegen, SettleCodegen, TellCodegen, AsyncCodegen, InstallCodegen, RenderCodegen, commandCodegens, EventHandlerCodegen, DEFAULT_COMPILE_OPTIONS, DEFAULT_CODEGEN_OPTIONS, AOTCompiler, VERSION2;
66060
67050
  var init_dist2 = __esm({
66061
67051
  "../aot-compiler/dist/index.js"() {
66062
67052
  "use strict";
66063
67053
  init_chunk_PPZXJJ57();
66064
67054
  init_chunk_QKE5BEQY();
67055
+ import_framework2 = require("@lokascript/framework");
66065
67056
  DEFAULT_OPTIONS = {
66066
67057
  attributeNames: ["_", "data-hs", "data-hyperscript"],
66067
67058
  includeScriptTags: true,
@@ -66679,6 +67670,18 @@ var init_dist2 = __esm({
66679
67670
  }
66680
67671
  }
66681
67672
  };
67673
+ CLASS_COMMANDS = /* @__PURE__ */ new Set(["add", "remove", "toggle"]);
67674
+ ClassBatchingPass = class {
67675
+ constructor() {
67676
+ this.name = "class-batching";
67677
+ }
67678
+ shouldRun(analysis) {
67679
+ return analysis.commandsUsed.has("add") || analysis.commandsUsed.has("remove") || analysis.commandsUsed.has("toggle");
67680
+ }
67681
+ transform(ast, _analysis) {
67682
+ return walkAndBatch(ast);
67683
+ }
67684
+ };
66682
67685
  ConstantFoldingPass = class {
66683
67686
  constructor() {
66684
67687
  this.name = "constant-folding";
@@ -67003,6 +68006,7 @@ var init_dist2 = __esm({
67003
68006
  new ConstantFoldingPass(),
67004
68007
  new SelectorCachingPass(),
67005
68008
  new DeadCodeEliminationPass(),
68009
+ new ClassBatchingPass(),
67006
68010
  new LoopUnrollingPass()
67007
68011
  ];
67008
68012
  }
@@ -68798,6 +69802,22 @@ var init_dist2 = __esm({
68798
69802
  const nested = node;
68799
69803
  return this.generateBody(nested.body ?? []);
68800
69804
  }
69805
+ case "batchedClassOps": {
69806
+ const batch = node;
69807
+ const lines = [];
69808
+ if (batch.adds.length > 0) {
69809
+ lines.push(`${batch.target}.classList.add(${batch.adds.map((c) => `'${c}'`).join(", ")})`);
69810
+ }
69811
+ if (batch.removes.length > 0) {
69812
+ lines.push(
69813
+ `${batch.target}.classList.remove(${batch.removes.map((c) => `'${c}'`).join(", ")})`
69814
+ );
69815
+ }
69816
+ for (const t of batch.toggles) {
69817
+ lines.push(`${batch.target}.classList.toggle('${t}')`);
69818
+ }
69819
+ return lines.join(";\n");
69820
+ }
68801
69821
  default:
68802
69822
  return null;
68803
69823
  }
@@ -69022,10 +70042,40 @@ var init_dist2 = __esm({
69022
70042
  // ===========================================================================
69023
70043
  /**
69024
70044
  * Parse a hyperscript string to AST.
70045
+ * Supports natural language, explicit bracket syntax, and JSON input.
69025
70046
  */
69026
70047
  parse(code, options = {}) {
69027
70048
  const { language = "en", confidenceThreshold = 0.7, debug: debug2 = false } = options;
69028
70049
  let ast = null;
70050
+ if ((0, import_framework2.isExplicitSyntax)(code)) {
70051
+ try {
70052
+ const node = (0, import_framework2.parseExplicit)(code);
70053
+ ast = this.semanticNodeToAOT(node);
70054
+ if (debug2) {
70055
+ console.log(`[aot] Parsed explicit syntax: "${code}"`);
70056
+ }
70057
+ } catch (error) {
70058
+ if (debug2) {
70059
+ console.log(`[aot] Explicit parse error for "${code}":`, error);
70060
+ }
70061
+ }
70062
+ if (ast) return this.ensureEventHandler(ast);
70063
+ }
70064
+ if (this.looksLikeJSON(code)) {
70065
+ try {
70066
+ const json = JSON.parse(code.trim());
70067
+ const node = (0, import_framework2.fromProtocolJSON)(json);
70068
+ ast = this.semanticNodeToAOT(node);
70069
+ if (debug2) {
70070
+ console.log(`[aot] Parsed JSON input: "${code.slice(0, 80)}..."`);
70071
+ }
70072
+ } catch (error) {
70073
+ if (debug2) {
70074
+ console.log(`[aot] JSON parse error for "${code.slice(0, 80)}":`, error);
70075
+ }
70076
+ }
70077
+ if (ast) return this.ensureEventHandler(ast);
70078
+ }
69029
70079
  if (language !== "en" && this.semanticParser?.supportsLanguage(language)) {
69030
70080
  const result = this.semanticParser.analyze(code, language);
69031
70081
  if (result.node && result.confidence >= confidenceThreshold) {
@@ -69052,15 +70102,7 @@ var init_dist2 = __esm({
69052
70102
  if (!ast) {
69053
70103
  ast = this.createSimpleAST(code);
69054
70104
  }
69055
- if (ast && ast.type !== "event") {
69056
- ast = {
69057
- type: "event",
69058
- event: "click",
69059
- modifiers: {},
69060
- body: [ast]
69061
- };
69062
- }
69063
- return ast;
70105
+ return this.ensureEventHandler(ast);
69064
70106
  }
69065
70107
  /**
69066
70108
  * Create a simple AST from code (for testing without full parser).
@@ -69225,6 +70267,86 @@ var init_dist2 = __esm({
69225
70267
  return { type: "identifier", value: trimmed };
69226
70268
  }
69227
70269
  // ===========================================================================
70270
+ // EXPLICIT / JSON INPUT HELPERS
70271
+ // ===========================================================================
70272
+ /**
70273
+ * Check if input looks like JSON (LLM JSON format).
70274
+ */
70275
+ looksLikeJSON(code) {
70276
+ const trimmed = code.trim();
70277
+ return trimmed.startsWith("{") && trimmed.includes('"action"');
70278
+ }
70279
+ /**
70280
+ * Ensure top-level node is always an event handler.
70281
+ * The codegen pipeline (EventHandlerCodegen) requires this.
70282
+ */
70283
+ ensureEventHandler(ast) {
70284
+ if (ast && ast.type !== "event") {
70285
+ return {
70286
+ type: "event",
70287
+ event: "click",
70288
+ modifiers: {},
70289
+ body: [ast]
70290
+ };
70291
+ }
70292
+ return ast;
70293
+ }
70294
+ /**
70295
+ * Convert a framework SemanticNode to an AOT ASTNode.
70296
+ * Handles the simple cases produced by explicit/JSON parsing.
70297
+ */
70298
+ semanticNodeToAOT(node) {
70299
+ if (node.kind === "event-handler") {
70300
+ const eh = node;
70301
+ const eventValue = eh.roles.get("event");
70302
+ const eventName = eventValue && "value" in eventValue ? String(eventValue.value) : "click";
70303
+ return {
70304
+ type: "event",
70305
+ event: eventName,
70306
+ modifiers: {},
70307
+ body: (eh.body ?? []).map((child) => this.semanticNodeToAOT(child))
70308
+ };
70309
+ }
70310
+ const roles = {};
70311
+ const args = [];
70312
+ for (const [roleName, value] of node.roles) {
70313
+ const astValue = this.semanticValueToAOT(value);
70314
+ roles[roleName] = astValue;
70315
+ args.push(astValue);
70316
+ }
70317
+ return {
70318
+ type: "command",
70319
+ name: node.action,
70320
+ args,
70321
+ roles
70322
+ };
70323
+ }
70324
+ /**
70325
+ * Convert a SemanticValue to an ASTNode.
70326
+ */
70327
+ semanticValueToAOT(value) {
70328
+ switch (value.type) {
70329
+ case "selector":
70330
+ return { type: "selector", value: value.value };
70331
+ case "reference":
70332
+ return { type: "identifier", value: value.value };
70333
+ case "literal": {
70334
+ const lit = value;
70335
+ if (lit.dataType === "duration") {
70336
+ const str = String(lit.value);
70337
+ const match = /^(\d+(?:\.\d+)?)(ms|s)$/.exec(str);
70338
+ if (match) {
70339
+ const ms = match[2] === "s" ? parseFloat(match[1]) * 1e3 : parseFloat(match[1]);
70340
+ return { type: "literal", value: ms };
70341
+ }
70342
+ }
70343
+ return { type: "literal", value: lit.value };
70344
+ }
70345
+ default:
70346
+ return { type: "literal", value: String(value.value ?? "") };
70347
+ }
70348
+ }
70349
+ // ===========================================================================
69228
70350
  // ANALYSIS
69229
70351
  // ===========================================================================
69230
70352
  /**
@@ -69234,6 +70356,63 @@ var init_dist2 = __esm({
69234
70356
  return this.analyzer.analyze(ast);
69235
70357
  }
69236
70358
  // ===========================================================================
70359
+ // INIT PRE-RENDERING
70360
+ // ===========================================================================
70361
+ /**
70362
+ * Pre-render pure init block commands into an HTML template at build time.
70363
+ *
70364
+ * Analyzes init block commands for purity (static DOM writes with literal
70365
+ * values targeting #id selectors) and applies them directly to the HTML.
70366
+ * Impure commands are preserved for normal runtime execution.
70367
+ *
70368
+ * @param html - The HTML template string
70369
+ * @param initCommands - Parsed commands from an init block
70370
+ * @returns Modified HTML, remaining impure commands, and count of pre-rendered commands
70371
+ */
70372
+ preRenderInit(html, initCommands) {
70373
+ return preRenderInitBlock(html, initCommands);
70374
+ }
70375
+ /**
70376
+ * Extract init blocks from HTML, pre-render pure commands, and return modified HTML.
70377
+ * This is a higher-level convenience that combines extraction, parsing, and pre-rendering.
70378
+ *
70379
+ * @param html - The HTML template string
70380
+ * @param options - Compile options (language, etc.)
70381
+ * @returns Modified HTML with pre-rendered init effects and compilation results
70382
+ */
70383
+ preRenderInitBlocks(html, options = {}) {
70384
+ const scripts = this.extract(html, "template.html");
70385
+ let modifiedHtml = html;
70386
+ let totalPreRendered = 0;
70387
+ const remainingScripts = [];
70388
+ for (const script of scripts) {
70389
+ const ast = this.parse(script.code, {
70390
+ ...options,
70391
+ language: script.language ?? options.language ?? "en"
70392
+ });
70393
+ if (!ast) {
70394
+ remainingScripts.push(script);
70395
+ continue;
70396
+ }
70397
+ const eventNode = ast;
70398
+ if (eventNode.type === "event" && eventNode.event === "init" && eventNode.body) {
70399
+ const result = preRenderInitBlock(modifiedHtml, eventNode.body);
70400
+ modifiedHtml = result.html;
70401
+ totalPreRendered += result.preRenderedCount;
70402
+ if (result.remainingInitCommands.length > 0) {
70403
+ remainingScripts.push(script);
70404
+ }
70405
+ } else {
70406
+ remainingScripts.push(script);
70407
+ }
70408
+ }
70409
+ return {
70410
+ html: modifiedHtml,
70411
+ preRenderedCount: totalPreRendered,
70412
+ remainingScripts
70413
+ };
70414
+ }
70415
+ // ===========================================================================
69237
70416
  // COMPILATION
69238
70417
  // ===========================================================================
69239
70418
  /**
@@ -69356,6 +70535,30 @@ var init_dist2 = __esm({
69356
70535
  }
69357
70536
  };
69358
70537
  }
70538
+ /**
70539
+ * Compile explicit bracket syntax or LLM JSON to JavaScript.
70540
+ * Uses the framework IR directly — no semantic or traditional parser needed.
70541
+ */
70542
+ compileExplicit(code, options = {}) {
70543
+ try {
70544
+ const ast = (0, import_framework2.isExplicitSyntax)(code) ? this.semanticNodeToAOT((0, import_framework2.parseExplicit)(code)) : this.semanticNodeToAOT((0, import_framework2.fromProtocolJSON)(JSON.parse(code.trim())));
70545
+ return this.compileAST(ast, options);
70546
+ } catch (error) {
70547
+ return {
70548
+ success: false,
70549
+ errors: [error instanceof Error ? error.message : String(error)],
70550
+ warnings: [],
70551
+ metadata: {
70552
+ handlerId: "",
70553
+ parserUsed: "traditional",
70554
+ commandsUsed: [],
70555
+ optimizationsApplied: [],
70556
+ needsRuntime: false,
70557
+ runtimeHelpers: []
70558
+ }
70559
+ };
70560
+ }
70561
+ }
69359
70562
  /**
69360
70563
  * Compile multiple extracted scripts.
69361
70564
  */
@@ -69595,8 +70798,8 @@ __export(index_exports, {
69595
70798
  diffBehaviors: () => diffBehaviors,
69596
70799
  extractOperations: () => extractOperations,
69597
70800
  generateCacheKey: () => generateCacheKey,
69598
- jsonToSemanticNode: () => jsonToSemanticNode,
69599
- validateSemanticJSON: () => validateSemanticJSON
70801
+ jsonToSemanticNode: () => import_ir.jsonToSemanticNode,
70802
+ validateSemanticJSON: () => import_ir.validateSemanticJSON
69600
70803
  });
69601
70804
  module.exports = __toCommonJS(index_exports);
69602
70805
 
@@ -69870,119 +71073,8 @@ function detectFormat(input) {
69870
71073
  return "natural";
69871
71074
  }
69872
71075
 
69873
- // src/input/json-schema.ts
69874
- var VALID_VALUE_TYPES = /* @__PURE__ */ new Set(["selector", "literal", "reference", "expression"]);
69875
- function validateSemanticJSON(input) {
69876
- const diagnostics = [];
69877
- if (!input.action || typeof input.action !== "string") {
69878
- diagnostics.push({
69879
- severity: "error",
69880
- code: "INVALID_ACTION",
69881
- message: 'Field "action" is required and must be a string.',
69882
- suggestion: 'Provide a command name like "toggle", "add", "set", etc.'
69883
- });
69884
- return diagnostics;
69885
- }
69886
- if (input.roles && typeof input.roles === "object") {
69887
- for (const [role, value] of Object.entries(input.roles)) {
69888
- if (!value || typeof value !== "object") {
69889
- diagnostics.push({
69890
- severity: "error",
69891
- code: "INVALID_ROLE_VALUE",
69892
- message: `Role "${role}" must be an object with "type" and "value" fields.`,
69893
- suggestion: `Use: { "type": "selector", "value": ".active" }`
69894
- });
69895
- continue;
69896
- }
69897
- const v2 = value;
69898
- if (!VALID_VALUE_TYPES.has(v2.type)) {
69899
- diagnostics.push({
69900
- severity: "error",
69901
- code: "INVALID_VALUE_TYPE",
69902
- message: `Role "${role}" has invalid type "${v2.type}".`,
69903
- suggestion: `Valid types: selector, literal, reference, expression.`
69904
- });
69905
- }
69906
- if (v2.value === void 0 || v2.value === null) {
69907
- diagnostics.push({
69908
- severity: "error",
69909
- code: "MISSING_VALUE",
69910
- message: `Role "${role}" is missing the "value" field.`
69911
- });
69912
- }
69913
- }
69914
- }
69915
- if (input.trigger) {
69916
- if (!input.trigger.event || typeof input.trigger.event !== "string") {
69917
- diagnostics.push({
69918
- severity: "error",
69919
- code: "INVALID_TRIGGER",
69920
- message: 'Trigger "event" is required and must be a string.',
69921
- suggestion: 'Use an event name like "click", "mouseover", "keydown".'
69922
- });
69923
- }
69924
- }
69925
- return diagnostics;
69926
- }
69927
- function jsonToSemanticNode(input) {
69928
- const roles = /* @__PURE__ */ new Map();
69929
- if (input.roles) {
69930
- for (const [role, value] of Object.entries(input.roles)) {
69931
- roles.set(role, convertJSONValue(value));
69932
- }
69933
- }
69934
- if (input.trigger) {
69935
- roles.set("event", { type: "literal", value: input.trigger.event, dataType: "string" });
69936
- const bodyNode = {
69937
- kind: "command",
69938
- action: input.action,
69939
- roles: new Map(roles)
69940
- };
69941
- bodyNode.roles.delete("event");
69942
- return {
69943
- kind: "event-handler",
69944
- action: "on",
69945
- roles,
69946
- body: [bodyNode],
69947
- eventModifiers: input.trigger.modifiers ?? {}
69948
- };
69949
- }
69950
- return {
69951
- kind: "command",
69952
- action: input.action,
69953
- roles
69954
- };
69955
- }
69956
- function convertJSONValue(value) {
69957
- switch (value.type) {
69958
- case "selector":
69959
- return {
69960
- type: "selector",
69961
- value: String(value.value),
69962
- selectorKind: detectSelectorKind(String(value.value))
69963
- };
69964
- case "literal":
69965
- return {
69966
- type: "literal",
69967
- value: value.value,
69968
- dataType: typeof value.value === "number" ? "number" : typeof value.value === "boolean" ? "boolean" : "string"
69969
- };
69970
- case "reference":
69971
- return { type: "reference", value: String(value.value) };
69972
- case "expression":
69973
- return { type: "expression", raw: String(value.value) };
69974
- default:
69975
- return { type: "literal", value: String(value.value), dataType: "string" };
69976
- }
69977
- }
69978
- function detectSelectorKind(selector) {
69979
- if (selector.startsWith("#")) return "id";
69980
- if (selector.startsWith(".")) return "class";
69981
- if (selector.startsWith("[")) return "attribute";
69982
- return "complex";
69983
- }
69984
-
69985
71076
  // src/input/normalize.ts
71077
+ var import_framework = require("@lokascript/framework");
69986
71078
  var _semantic = null;
69987
71079
  function initNormalizer(semantic) {
69988
71080
  _semantic = semantic;
@@ -70077,7 +71169,7 @@ function normalizeExplicit(input) {
70077
71169
  }
70078
71170
  }
70079
71171
  function normalizeJSON(input) {
70080
- const validationErrors = validateSemanticJSON(input);
71172
+ const validationErrors = (0, import_framework.validateProtocolJSON)(input);
70081
71173
  if (validationErrors.some((d) => d.severity === "error")) {
70082
71174
  return {
70083
71175
  node: null,
@@ -70086,7 +71178,7 @@ function normalizeJSON(input) {
70086
71178
  diagnostics: validationErrors
70087
71179
  };
70088
71180
  }
70089
- const node = jsonToSemanticNode(input);
71181
+ const node = (0, import_framework.fromProtocolJSON)(input);
70090
71182
  return {
70091
71183
  node,
70092
71184
  confidence: 1,
@@ -72905,6 +73997,9 @@ function nodeToSemanticJSON(node) {
72905
73997
  }
72906
73998
  return { action: n.action, roles };
72907
73999
  }
74000
+
74001
+ // src/input/json-schema.ts
74002
+ var import_ir = require("@lokascript/framework/ir");
72908
74003
  // Annotate the CommonJS export names for ESM import in node:
72909
74004
  0 && (module.exports = {
72910
74005
  CompilationService,