proskomma-core 0.10.10 → 0.10.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +644 -579
  2. package/dist/index.mjs +644 -579
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1235,10 +1235,7 @@ function getAugmentedNamespace(n) {
1235
1235
  if (typeof f == "function") {
1236
1236
  var a = function a2() {
1237
1237
  if (this instanceof a2) {
1238
- var args = [null];
1239
- args.push.apply(args, arguments);
1240
- var Ctor = Function.bind.apply(f, args);
1241
- return new Ctor();
1238
+ return Reflect.construct(f, arguments, this.constructor);
1242
1239
  }
1243
1240
  return f.apply(this, arguments);
1244
1241
  };
@@ -1475,6 +1472,7 @@ var categories = [
1475
1472
  "bmp": "    -    "
1476
1473
  }
1477
1474
  ];
1475
+ const categories$1 = /* @__PURE__ */ getDefaultExportFromCjs(categories);
1478
1476
  /*!
1479
1477
  * XRegExp Unicode Categories 5.1.1
1480
1478
  * <xregexp.com>
@@ -1485,7 +1483,7 @@ const unicodeCategories = (XRegExp2) => {
1485
1483
  if (!XRegExp2.addUnicodeData) {
1486
1484
  throw new ReferenceError("Unicode Base must be loaded before Unicode Categories");
1487
1485
  }
1488
- XRegExp2.addUnicodeData(categories);
1486
+ XRegExp2.addUnicodeData(categories$1);
1489
1487
  };
1490
1488
  var properties$o = [
1491
1489
  {
@@ -1528,6 +1526,7 @@ var properties$o = [
1528
1526
  "bmp": " -\r …   - \u2028\u2029   "
1529
1527
  }
1530
1528
  ];
1529
+ const properties$p = /* @__PURE__ */ getDefaultExportFromCjs(properties$o);
1531
1530
  /*!
1532
1531
  * XRegExp Unicode Properties 5.1.1
1533
1532
  * <xregexp.com>
@@ -1538,7 +1537,7 @@ const unicodeProperties = (XRegExp2) => {
1538
1537
  if (!XRegExp2.addUnicodeData) {
1539
1538
  throw new ReferenceError("Unicode Base must be loaded before Unicode Properties");
1540
1539
  }
1541
- const unicodeData = properties$o;
1540
+ const unicodeData = properties$p;
1542
1541
  unicodeData.push({
1543
1542
  name: "Assigned",
1544
1543
  // Since this is defined as the inverse of Unicode category Cn (Unassigned), the Unicode
@@ -2209,6 +2208,7 @@ var scripts$1 = [
2209
2208
  "astral": "\uD806[\uDE00-\uDE47]"
2210
2209
  }
2211
2210
  ];
2211
+ const scripts$2 = /* @__PURE__ */ getDefaultExportFromCjs(scripts$1);
2212
2212
  /*!
2213
2213
  * XRegExp Unicode Scripts 5.1.1
2214
2214
  * <xregexp.com>
@@ -2219,7 +2219,7 @@ const unicodeScripts = (XRegExp2) => {
2219
2219
  if (!XRegExp2.addUnicodeData) {
2220
2220
  throw new ReferenceError("Unicode Base must be loaded before Unicode Scripts");
2221
2221
  }
2222
- XRegExp2.addUnicodeData(scripts$1, "Script");
2222
+ XRegExp2.addUnicodeData(scripts$2, "Script");
2223
2223
  };
2224
2224
  build(XRegExp);
2225
2225
  matchRecursive(XRegExp);
@@ -3378,8 +3378,7 @@ function getObjectTag$1(object) {
3378
3378
  const instanceOf = (
3379
3379
  /* c8 ignore next 6 */
3380
3380
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
3381
- // eslint-disable-next-line no-undef
3382
- process.env.NODE_ENV === "production" ? function instanceOf2(value, constructor) {
3381
+ globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function instanceOf2(value, constructor) {
3383
3382
  return value instanceof constructor;
3384
3383
  } : function instanceOf3(value, constructor) {
3385
3384
  if (value instanceof constructor) {
@@ -8850,7 +8849,7 @@ function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPai
8850
8849
  [node2]
8851
8850
  ];
8852
8851
  }
8853
- if (stringifyArguments(node1) !== stringifyArguments(node2)) {
8852
+ if (!sameArguments(node1, node2)) {
8854
8853
  return [
8855
8854
  [responseName, "they have differing arguments"],
8856
8855
  [node1],
@@ -8888,21 +8887,30 @@ function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPai
8888
8887
  return subfieldConflicts(conflicts, responseName, node1, node2);
8889
8888
  }
8890
8889
  }
8891
- function stringifyArguments(fieldNode) {
8892
- var _fieldNode$arguments;
8893
- const args = (
8894
- /* c8 ignore next */
8895
- (_fieldNode$arguments = fieldNode.arguments) !== null && _fieldNode$arguments !== void 0 ? _fieldNode$arguments : []
8896
- );
8897
- const inputObjectWithArgs = {
8898
- kind: Kind.OBJECT,
8899
- fields: args.map((argNode) => ({
8900
- kind: Kind.OBJECT_FIELD,
8901
- name: argNode.name,
8902
- value: argNode.value
8903
- }))
8904
- };
8905
- return print(sortValueNode(inputObjectWithArgs));
8890
+ function sameArguments(node1, node2) {
8891
+ const args1 = node1.arguments;
8892
+ const args2 = node2.arguments;
8893
+ if (args1 === void 0 || args1.length === 0) {
8894
+ return args2 === void 0 || args2.length === 0;
8895
+ }
8896
+ if (args2 === void 0 || args2.length === 0) {
8897
+ return false;
8898
+ }
8899
+ if (args1.length !== args2.length) {
8900
+ return false;
8901
+ }
8902
+ const values2 = new Map(args2.map(({ name: name2, value }) => [name2.value, value]));
8903
+ return args1.every((arg1) => {
8904
+ const value1 = arg1.value;
8905
+ const value2 = values2.get(arg1.name.value);
8906
+ if (value2 === void 0) {
8907
+ return false;
8908
+ }
8909
+ return stringifyValue(value1) === stringifyValue(value2);
8910
+ });
8911
+ }
8912
+ function stringifyValue(value) {
8913
+ return print(sortValueNode(value));
8906
8914
  }
8907
8915
  function doTypesConflict(type1, type2) {
8908
8916
  if (isListType(type1)) {
@@ -9603,7 +9611,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
9603
9611
  onError(
9604
9612
  new GraphQLError(prefix + "; " + error2.message, {
9605
9613
  nodes: varDefNode,
9606
- originalError: error2.originalError
9614
+ originalError: error2
9607
9615
  })
9608
9616
  );
9609
9617
  }
@@ -11009,21 +11017,30 @@ function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields
11009
11017
  function executeFields(exeContext, parentType, sourceValue, path, fields) {
11010
11018
  const results = /* @__PURE__ */ Object.create(null);
11011
11019
  let containsPromise = false;
11012
- for (const [responseName, fieldNodes] of fields.entries()) {
11013
- const fieldPath = addPath(path, responseName, parentType.name);
11014
- const result = executeField(
11015
- exeContext,
11016
- parentType,
11017
- sourceValue,
11018
- fieldNodes,
11019
- fieldPath
11020
- );
11021
- if (result !== void 0) {
11022
- results[responseName] = result;
11023
- if (isPromise(result)) {
11024
- containsPromise = true;
11020
+ try {
11021
+ for (const [responseName, fieldNodes] of fields.entries()) {
11022
+ const fieldPath = addPath(path, responseName, parentType.name);
11023
+ const result = executeField(
11024
+ exeContext,
11025
+ parentType,
11026
+ sourceValue,
11027
+ fieldNodes,
11028
+ fieldPath
11029
+ );
11030
+ if (result !== void 0) {
11031
+ results[responseName] = result;
11032
+ if (isPromise(result)) {
11033
+ containsPromise = true;
11034
+ }
11025
11035
  }
11026
11036
  }
11037
+ } catch (error2) {
11038
+ if (containsPromise) {
11039
+ return promiseForObject(results).finally(() => {
11040
+ throw error2;
11041
+ });
11042
+ }
11043
+ throw error2;
11027
11044
  }
11028
11045
  if (!containsPromise) {
11029
11046
  return results;
@@ -14114,17 +14131,19 @@ function mergeResolvers(resolversDefinitions, options2) {
14114
14131
  return result;
14115
14132
  }
14116
14133
  function mergeArguments$1(args1, args2, config) {
14117
- const result = deduplicateArguments([...args2, ...args1].filter(isSome));
14134
+ const result = deduplicateArguments([...args2, ...args1].filter(isSome), config);
14118
14135
  if (config && config.sort) {
14119
14136
  result.sort(compareNodes);
14120
14137
  }
14121
14138
  return result;
14122
14139
  }
14123
- function deduplicateArguments(args) {
14140
+ function deduplicateArguments(args, config) {
14124
14141
  return args.reduce((acc, current) => {
14125
- const dup = acc.find((arg) => arg.name.value === current.name.value);
14126
- if (!dup) {
14142
+ const dupIndex = acc.findIndex((arg) => arg.name.value === current.name.value);
14143
+ if (dupIndex === -1) {
14127
14144
  return acc.concat([current]);
14145
+ } else if (!(config === null || config === void 0 ? void 0 : config.reverseArguments)) {
14146
+ acc[dupIndex] = current;
14128
14147
  }
14129
14148
  return acc;
14130
14149
  }, []);
@@ -14132,6 +14151,10 @@ function deduplicateArguments(args) {
14132
14151
  function directiveAlreadyExists(directivesArr, otherDirective) {
14133
14152
  return !!directivesArr.find((directive) => directive.name.value === otherDirective.name.value);
14134
14153
  }
14154
+ function isRepeatableDirective(directive, directives) {
14155
+ var _a;
14156
+ return !!((_a = directives === null || directives === void 0 ? void 0 : directives[directive.name.value]) === null || _a === void 0 ? void 0 : _a.repeatable);
14157
+ }
14135
14158
  function nameAlreadyExists(name2, namesArr) {
14136
14159
  return namesArr.some(({ value }) => value === name2.value);
14137
14160
  }
@@ -14157,10 +14180,10 @@ function mergeArguments(a1, a2) {
14157
14180
  }
14158
14181
  return result;
14159
14182
  }
14160
- function deduplicateDirectives(directives) {
14183
+ function deduplicateDirectives(directives, definitions2) {
14161
14184
  return directives.map((directive, i, all) => {
14162
14185
  const firstAt = all.findIndex((d) => d.name.value === directive.name.value);
14163
- if (firstAt !== i) {
14186
+ if (firstAt !== i && !isRepeatableDirective(directive, definitions2)) {
14164
14187
  const dup = all[firstAt];
14165
14188
  directive.arguments = mergeArguments(directive.arguments, dup.arguments);
14166
14189
  return null;
@@ -14168,13 +14191,13 @@ function deduplicateDirectives(directives) {
14168
14191
  return directive;
14169
14192
  }).filter(isSome);
14170
14193
  }
14171
- function mergeDirectives(d1 = [], d2 = [], config) {
14194
+ function mergeDirectives(d1 = [], d2 = [], config, directives) {
14172
14195
  const reverseOrder = config && config.reverseDirectives;
14173
14196
  const asNext = reverseOrder ? d1 : d2;
14174
14197
  const asFirst = reverseOrder ? d2 : d1;
14175
- const result = deduplicateDirectives([...asNext]);
14198
+ const result = deduplicateDirectives([...asNext], directives);
14176
14199
  for (const directive of asFirst) {
14177
- if (directiveAlreadyExists(result, directive)) {
14200
+ if (directiveAlreadyExists(result, directive) && !isRepeatableDirective(directive, directives)) {
14178
14201
  const existingDirectiveIndex = result.findIndex((d) => d.name.value === directive.name.value);
14179
14202
  const existingDirective = result[existingDirectiveIndex];
14180
14203
  result[existingDirectiveIndex].arguments = mergeArguments(directive.arguments || [], existingDirective.arguments || []);
@@ -14194,8 +14217,8 @@ function validateInputs(node, existingNode) {
14194
14217
  description: void 0
14195
14218
  });
14196
14219
  const leaveInputs = new RegExp("(directive @w*d*)|( on .*$)", "g");
14197
- const sameArguments = printedNode.replace(leaveInputs, "") === printedExistingNode.replace(leaveInputs, "");
14198
- if (!sameArguments) {
14220
+ const sameArguments2 = printedNode.replace(leaveInputs, "") === printedExistingNode.replace(leaveInputs, "");
14221
+ if (!sameArguments2) {
14199
14222
  throw new Error(`Unable to merge GraphQL directive "${node.name.value}".
14200
14223
  Existing directive:
14201
14224
  ${printedExistingNode}
@@ -14219,7 +14242,7 @@ function mergeDirective(node, existingNode) {
14219
14242
  function deduplicateLists(source, target, filterFn) {
14220
14243
  return source.concat(target.filter((val) => filterFn(val, source)));
14221
14244
  }
14222
- function mergeEnumValues(first, second, config) {
14245
+ function mergeEnumValues(first, second, config, directives) {
14223
14246
  if (config === null || config === void 0 ? void 0 : config.consistentEnumMerge) {
14224
14247
  const reversed = [];
14225
14248
  if (first) {
@@ -14240,7 +14263,7 @@ function mergeEnumValues(first, second, config) {
14240
14263
  if (enumValueMap.has(enumValue)) {
14241
14264
  const firstValue = enumValueMap.get(enumValue);
14242
14265
  firstValue.description = secondValue.description || firstValue.description;
14243
- firstValue.directives = mergeDirectives(secondValue.directives, firstValue.directives);
14266
+ firstValue.directives = mergeDirectives(secondValue.directives, firstValue.directives, directives);
14244
14267
  } else {
14245
14268
  enumValueMap.set(enumValue, secondValue);
14246
14269
  }
@@ -14252,14 +14275,14 @@ function mergeEnumValues(first, second, config) {
14252
14275
  }
14253
14276
  return result;
14254
14277
  }
14255
- function mergeEnum(e1, e2, config) {
14278
+ function mergeEnum(e1, e2, config, directives) {
14256
14279
  if (e2) {
14257
14280
  return {
14258
14281
  name: e1.name,
14259
14282
  description: e1["description"] || e2["description"],
14260
14283
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || e1.kind === "EnumTypeDefinition" || e2.kind === "EnumTypeDefinition" ? "EnumTypeDefinition" : "EnumTypeExtension",
14261
14284
  loc: e1.loc,
14262
- directives: mergeDirectives(e1.directives, e2.directives, config),
14285
+ directives: mergeDirectives(e1.directives, e2.directives, config, directives),
14263
14286
  values: mergeEnumValues(e1.values, e2.values, config)
14264
14287
  };
14265
14288
  }
@@ -14321,39 +14344,24 @@ function defaultStringComparator(a, b) {
14321
14344
  return CompareVal.A_GREATER_THAN_B;
14322
14345
  return CompareVal.A_EQUALS_B;
14323
14346
  }
14324
- function fieldAlreadyExists(fieldsArr, otherField, config) {
14325
- const result = fieldsArr.find((field) => field.name.value === otherField.name.value);
14326
- if (result && !(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) {
14327
- const t1 = extractType(result.type);
14328
- const t2 = extractType(otherField.type);
14329
- if (t1.name.value !== t2.name.value) {
14330
- throw new Error(`Field "${otherField.name.value}" already defined with a different type. Declared as "${t1.name.value}", but you tried to override with "${t2.name.value}"`);
14331
- }
14332
- }
14333
- return !!result;
14347
+ function fieldAlreadyExists(fieldsArr, otherField) {
14348
+ const resultIndex = fieldsArr.findIndex((field) => field.name.value === otherField.name.value);
14349
+ return [resultIndex > -1 ? fieldsArr[resultIndex] : null, resultIndex];
14334
14350
  }
14335
- function mergeFields(type2, f1, f2, config) {
14351
+ function mergeFields(type2, f1, f2, config, directives) {
14336
14352
  const result = [];
14337
14353
  if (f2 != null) {
14338
14354
  result.push(...f2);
14339
14355
  }
14340
14356
  if (f1 != null) {
14341
14357
  for (const field of f1) {
14342
- if (fieldAlreadyExists(result, field, config)) {
14343
- const existing = result.find((f) => f.name.value === field.name.value);
14344
- if (!(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) {
14345
- if (config === null || config === void 0 ? void 0 : config.throwOnConflict) {
14346
- preventConflicts(type2, existing, field, false);
14347
- } else {
14348
- preventConflicts(type2, existing, field, true);
14349
- }
14350
- if (isNonNullTypeNode(field.type) && !isNonNullTypeNode(existing.type)) {
14351
- existing.type = field.type;
14352
- }
14353
- }
14354
- existing.arguments = mergeArguments$1(field["arguments"] || [], existing.arguments || [], config);
14355
- existing.directives = mergeDirectives(field.directives, existing.directives, config);
14356
- existing.description = field.description || existing.description;
14358
+ const [existing, existingIndex] = fieldAlreadyExists(result, field);
14359
+ if (existing && !(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) {
14360
+ const newField = (config === null || config === void 0 ? void 0 : config.onFieldTypeConflict) && config.onFieldTypeConflict(existing, field, type2, config === null || config === void 0 ? void 0 : config.throwOnConflict) || preventConflicts(type2, existing, field, config === null || config === void 0 ? void 0 : config.throwOnConflict);
14361
+ newField.arguments = mergeArguments$1(field["arguments"] || [], existing["arguments"] || [], config);
14362
+ newField.directives = mergeDirectives(field.directives, existing.directives, config, directives);
14363
+ newField.description = field.description || existing.description;
14364
+ result[existingIndex] = newField;
14357
14365
  } else {
14358
14366
  result.push(field);
14359
14367
  }
@@ -14371,9 +14379,20 @@ function mergeFields(type2, f1, f2, config) {
14371
14379
  function preventConflicts(type2, a, b, ignoreNullability = false) {
14372
14380
  const aType = printTypeNode(a.type);
14373
14381
  const bType = printTypeNode(b.type);
14374
- if (aType !== bType && !safeChangeForFieldType(a.type, b.type, ignoreNullability)) {
14375
- throw new Error(`Field '${type2.name.value}.${a.name.value}' changed type from '${aType}' to '${bType}'`);
14382
+ if (aType !== bType) {
14383
+ const t1 = extractType(a.type);
14384
+ const t2 = extractType(b.type);
14385
+ if (t1.name.value !== t2.name.value) {
14386
+ throw new Error(`Field "${b.name.value}" already defined with a different type. Declared as "${t1.name.value}", but you tried to override with "${t2.name.value}"`);
14387
+ }
14388
+ if (!safeChangeForFieldType(a.type, b.type, !ignoreNullability)) {
14389
+ throw new Error(`Field '${type2.name.value}.${a.name.value}' changed type from '${aType}' to '${bType}'`);
14390
+ }
14391
+ }
14392
+ if (isNonNullTypeNode(b.type) && !isNonNullTypeNode(a.type)) {
14393
+ a.type = b.type;
14376
14394
  }
14395
+ return a;
14377
14396
  }
14378
14397
  function safeChangeForFieldType(oldType, newType, ignoreNullability = false) {
14379
14398
  if (!isWrappingTypeNode(oldType) && !isWrappingTypeNode(newType)) {
@@ -14391,7 +14410,7 @@ function safeChangeForFieldType(oldType, newType, ignoreNullability = false) {
14391
14410
  }
14392
14411
  return false;
14393
14412
  }
14394
- function mergeInputType(node, existingNode, config) {
14413
+ function mergeInputType(node, existingNode, config, directives) {
14395
14414
  if (existingNode) {
14396
14415
  try {
14397
14416
  return {
@@ -14400,7 +14419,7 @@ function mergeInputType(node, existingNode, config) {
14400
14419
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "InputObjectTypeDefinition" || existingNode.kind === "InputObjectTypeDefinition" ? "InputObjectTypeDefinition" : "InputObjectTypeExtension",
14401
14420
  loc: node.loc,
14402
14421
  fields: mergeFields(node, node.fields, existingNode.fields, config),
14403
- directives: mergeDirectives(node.directives, existingNode.directives, config)
14422
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives)
14404
14423
  };
14405
14424
  } catch (e) {
14406
14425
  throw new Error(`Unable to merge GraphQL input type "${node.name.value}": ${e.message}`);
@@ -14421,7 +14440,7 @@ function mergeNamedTypeArray(first = [], second = [], config = {}) {
14421
14440
  }
14422
14441
  return result;
14423
14442
  }
14424
- function mergeInterface(node, existingNode, config) {
14443
+ function mergeInterface(node, existingNode, config, directives) {
14425
14444
  if (existingNode) {
14426
14445
  try {
14427
14446
  return {
@@ -14430,7 +14449,7 @@ function mergeInterface(node, existingNode, config) {
14430
14449
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "InterfaceTypeDefinition" || existingNode.kind === "InterfaceTypeDefinition" ? "InterfaceTypeDefinition" : "InterfaceTypeExtension",
14431
14450
  loc: node.loc,
14432
14451
  fields: mergeFields(node, node.fields, existingNode.fields, config),
14433
- directives: mergeDirectives(node.directives, existingNode.directives, config),
14452
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives),
14434
14453
  interfaces: node["interfaces"] ? mergeNamedTypeArray(node["interfaces"], existingNode["interfaces"], config) : void 0
14435
14454
  };
14436
14455
  } catch (e) {
@@ -14442,7 +14461,7 @@ function mergeInterface(node, existingNode, config) {
14442
14461
  kind: Kind.INTERFACE_TYPE_DEFINITION
14443
14462
  } : node;
14444
14463
  }
14445
- function mergeType(node, existingNode, config) {
14464
+ function mergeType(node, existingNode, config, directives) {
14446
14465
  if (existingNode) {
14447
14466
  try {
14448
14467
  return {
@@ -14451,7 +14470,7 @@ function mergeType(node, existingNode, config) {
14451
14470
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "ObjectTypeDefinition" || existingNode.kind === "ObjectTypeDefinition" ? "ObjectTypeDefinition" : "ObjectTypeExtension",
14452
14471
  loc: node.loc,
14453
14472
  fields: mergeFields(node, node.fields, existingNode.fields, config),
14454
- directives: mergeDirectives(node.directives, existingNode.directives, config),
14473
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives),
14455
14474
  interfaces: mergeNamedTypeArray(node.interfaces, existingNode.interfaces, config)
14456
14475
  };
14457
14476
  } catch (e) {
@@ -14463,14 +14482,14 @@ function mergeType(node, existingNode, config) {
14463
14482
  kind: Kind.OBJECT_TYPE_DEFINITION
14464
14483
  } : node;
14465
14484
  }
14466
- function mergeScalar(node, existingNode, config) {
14485
+ function mergeScalar(node, existingNode, config, directives) {
14467
14486
  if (existingNode) {
14468
14487
  return {
14469
14488
  name: node.name,
14470
14489
  description: node["description"] || existingNode["description"],
14471
14490
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "ScalarTypeDefinition" || existingNode.kind === "ScalarTypeDefinition" ? "ScalarTypeDefinition" : "ScalarTypeExtension",
14472
14491
  loc: node.loc,
14473
- directives: mergeDirectives(node.directives, existingNode.directives, config)
14492
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives)
14474
14493
  };
14475
14494
  }
14476
14495
  return (config === null || config === void 0 ? void 0 : config.convertExtensions) ? {
@@ -14478,13 +14497,13 @@ function mergeScalar(node, existingNode, config) {
14478
14497
  kind: Kind.SCALAR_TYPE_DEFINITION
14479
14498
  } : node;
14480
14499
  }
14481
- function mergeUnion(first, second, config) {
14500
+ function mergeUnion(first, second, config, directives) {
14482
14501
  if (second) {
14483
14502
  return {
14484
14503
  name: first.name,
14485
14504
  description: first["description"] || second["description"],
14486
14505
  // ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility
14487
- directives: mergeDirectives(first.directives, second.directives, config),
14506
+ directives: mergeDirectives(first.directives, second.directives, config, directives),
14488
14507
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || first.kind === "UnionTypeDefinition" || second.kind === "UnionTypeDefinition" ? Kind.UNION_TYPE_DEFINITION : Kind.UNION_TYPE_EXTENSION,
14489
14508
  loc: first.loc,
14490
14509
  types: mergeNamedTypeArray(first.types, second.types, config)
@@ -14510,12 +14529,12 @@ function mergeOperationTypes(opNodeList = [], existingOpNodeList = []) {
14510
14529
  }
14511
14530
  return finalOpNodeList;
14512
14531
  }
14513
- function mergeSchemaDefs(node, existingNode, config) {
14532
+ function mergeSchemaDefs(node, existingNode, config, directives) {
14514
14533
  if (existingNode) {
14515
14534
  return {
14516
14535
  kind: node.kind === Kind.SCHEMA_DEFINITION || existingNode.kind === Kind.SCHEMA_DEFINITION ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
14517
14536
  description: node["description"] || existingNode["description"],
14518
- directives: mergeDirectives(node.directives, existingNode.directives, config),
14537
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives),
14519
14538
  operationTypes: mergeOperationTypes(node.operationTypes, existingNode.operationTypes)
14520
14539
  };
14521
14540
  }
@@ -14528,9 +14547,9 @@ const schemaDefSymbol = "SCHEMA_DEF_SYMBOL";
14528
14547
  function isNamedDefinitionNode(definitionNode) {
14529
14548
  return "name" in definitionNode;
14530
14549
  }
14531
- function mergeGraphQLNodes(nodes, config) {
14550
+ function mergeGraphQLNodes(nodes, config, directives = {}) {
14532
14551
  var _a, _b, _c;
14533
- const mergedResultMap = {};
14552
+ const mergedResultMap = directives;
14534
14553
  for (const nodeDefinition of nodes) {
14535
14554
  if (isNamedDefinitionNode(nodeDefinition)) {
14536
14555
  const name2 = (_a = nodeDefinition.name) === null || _a === void 0 ? void 0 : _a.value;
@@ -14546,27 +14565,27 @@ function mergeGraphQLNodes(nodes, config) {
14546
14565
  switch (nodeDefinition.kind) {
14547
14566
  case Kind.OBJECT_TYPE_DEFINITION:
14548
14567
  case Kind.OBJECT_TYPE_EXTENSION:
14549
- mergedResultMap[name2] = mergeType(nodeDefinition, mergedResultMap[name2], config);
14568
+ mergedResultMap[name2] = mergeType(nodeDefinition, mergedResultMap[name2], config, directives);
14550
14569
  break;
14551
14570
  case Kind.ENUM_TYPE_DEFINITION:
14552
14571
  case Kind.ENUM_TYPE_EXTENSION:
14553
- mergedResultMap[name2] = mergeEnum(nodeDefinition, mergedResultMap[name2], config);
14572
+ mergedResultMap[name2] = mergeEnum(nodeDefinition, mergedResultMap[name2], config, directives);
14554
14573
  break;
14555
14574
  case Kind.UNION_TYPE_DEFINITION:
14556
14575
  case Kind.UNION_TYPE_EXTENSION:
14557
- mergedResultMap[name2] = mergeUnion(nodeDefinition, mergedResultMap[name2], config);
14576
+ mergedResultMap[name2] = mergeUnion(nodeDefinition, mergedResultMap[name2], config, directives);
14558
14577
  break;
14559
14578
  case Kind.SCALAR_TYPE_DEFINITION:
14560
14579
  case Kind.SCALAR_TYPE_EXTENSION:
14561
- mergedResultMap[name2] = mergeScalar(nodeDefinition, mergedResultMap[name2], config);
14580
+ mergedResultMap[name2] = mergeScalar(nodeDefinition, mergedResultMap[name2], config, directives);
14562
14581
  break;
14563
14582
  case Kind.INPUT_OBJECT_TYPE_DEFINITION:
14564
14583
  case Kind.INPUT_OBJECT_TYPE_EXTENSION:
14565
- mergedResultMap[name2] = mergeInputType(nodeDefinition, mergedResultMap[name2], config);
14584
+ mergedResultMap[name2] = mergeInputType(nodeDefinition, mergedResultMap[name2], config, directives);
14566
14585
  break;
14567
14586
  case Kind.INTERFACE_TYPE_DEFINITION:
14568
14587
  case Kind.INTERFACE_TYPE_EXTENSION:
14569
- mergedResultMap[name2] = mergeInterface(nodeDefinition, mergedResultMap[name2], config);
14588
+ mergedResultMap[name2] = mergeInterface(nodeDefinition, mergedResultMap[name2], config, directives);
14570
14589
  break;
14571
14590
  case Kind.DIRECTIVE_DEFINITION:
14572
14591
  mergedResultMap[name2] = mergeDirective(nodeDefinition, mergedResultMap[name2]);
@@ -14600,36 +14619,41 @@ function mergeTypeDefs(typeSource, config) {
14600
14619
  resetComments();
14601
14620
  return result;
14602
14621
  }
14603
- function visitTypeSources(typeSource, options2, allNodes = [], visitedTypeSources = /* @__PURE__ */ new Set()) {
14622
+ function visitTypeSources(typeSource, options2, allDirectives = [], allNodes = [], visitedTypeSources = /* @__PURE__ */ new Set()) {
14604
14623
  if (typeSource && !visitedTypeSources.has(typeSource)) {
14605
14624
  visitedTypeSources.add(typeSource);
14606
14625
  if (typeof typeSource === "function") {
14607
- visitTypeSources(typeSource(), options2, allNodes, visitedTypeSources);
14626
+ visitTypeSources(typeSource(), options2, allDirectives, allNodes, visitedTypeSources);
14608
14627
  } else if (Array.isArray(typeSource)) {
14609
14628
  for (const type2 of typeSource) {
14610
- visitTypeSources(type2, options2, allNodes, visitedTypeSources);
14629
+ visitTypeSources(type2, options2, allDirectives, allNodes, visitedTypeSources);
14611
14630
  }
14612
14631
  } else if (isSchema(typeSource)) {
14613
14632
  const documentNode = getDocumentNodeFromSchema(typeSource, options2);
14614
- visitTypeSources(documentNode.definitions, options2, allNodes, visitedTypeSources);
14633
+ visitTypeSources(documentNode.definitions, options2, allDirectives, allNodes, visitedTypeSources);
14615
14634
  } else if (isStringTypes(typeSource) || isSourceTypes(typeSource)) {
14616
14635
  const documentNode = parse(typeSource, options2);
14617
- visitTypeSources(documentNode.definitions, options2, allNodes, visitedTypeSources);
14636
+ visitTypeSources(documentNode.definitions, options2, allDirectives, allNodes, visitedTypeSources);
14618
14637
  } else if (typeof typeSource === "object" && isDefinitionNode(typeSource)) {
14619
- allNodes.push(typeSource);
14638
+ if (typeSource.kind === Kind.DIRECTIVE_DEFINITION) {
14639
+ allDirectives.push(typeSource);
14640
+ } else {
14641
+ allNodes.push(typeSource);
14642
+ }
14620
14643
  } else if (isDocumentNode(typeSource)) {
14621
- visitTypeSources(typeSource.definitions, options2, allNodes, visitedTypeSources);
14644
+ visitTypeSources(typeSource.definitions, options2, allDirectives, allNodes, visitedTypeSources);
14622
14645
  } else {
14623
14646
  throw new Error(`typeDefs must contain only strings, documents, schemas, or functions, got ${typeof typeSource}`);
14624
14647
  }
14625
14648
  }
14626
- return allNodes;
14649
+ return { allDirectives, allNodes };
14627
14650
  }
14628
14651
  function mergeGraphQLTypes(typeSource, config) {
14629
14652
  var _a, _b, _c;
14630
14653
  resetComments();
14631
- const allNodes = visitTypeSources(typeSource, config);
14632
- const mergedNodes = mergeGraphQLNodes(allNodes, config);
14654
+ const { allDirectives, allNodes } = visitTypeSources(typeSource, config);
14655
+ const mergedDirectives = mergeGraphQLNodes(allDirectives, config);
14656
+ const mergedNodes = mergeGraphQLNodes(allNodes, config, mergedDirectives);
14633
14657
  if (config === null || config === void 0 ? void 0 : config.useSchemaDefinition) {
14634
14658
  const schemaDef = mergedNodes[schemaDefSymbol] || {
14635
14659
  kind: Kind.SCHEMA_DEFINITION,
@@ -14932,17 +14956,8 @@ class Mutex {
14932
14956
  return this._semaphore.cancel();
14933
14957
  }
14934
14958
  }
14935
- var easyCrc32Exports = {};
14936
- var easyCrc32$1 = {
14937
- get exports() {
14938
- return easyCrc32Exports;
14939
- },
14940
- set exports(v) {
14941
- easyCrc32Exports = v;
14942
- }
14943
- };
14944
- var easyCrc32 = {};
14945
- easyCrc32.calculate = function(str) {
14959
+ var easyCrc32$1 = {};
14960
+ easyCrc32$1.calculate = function(str) {
14946
14961
  if (str == null)
14947
14962
  return null;
14948
14963
  var utf8CharCodes = utf8encode(str), crc = -1;
@@ -15225,19 +15240,9 @@ var crcTable = [
15225
15240
  1510334235,
15226
15241
  755167117
15227
15242
  ];
15228
- (function(module2) {
15229
- module2.exports = easyCrc32;
15230
- })(easyCrc32$1);
15231
- const crc32 = /* @__PURE__ */ getDefaultExportFromCjs(easyCrc32Exports);
15232
- var bitsetExports = {};
15233
- var bitset = {
15234
- get exports() {
15235
- return bitsetExports;
15236
- },
15237
- set exports(v) {
15238
- bitsetExports = v;
15239
- }
15240
- };
15243
+ var easyCrc32 = easyCrc32$1;
15244
+ const crc32 = /* @__PURE__ */ getDefaultExportFromCjs(easyCrc32);
15245
+ var bitset = { exports: {} };
15241
15246
  /**
15242
15247
  * @license BitSet.js v5.1.1 2/1/2020
15243
15248
  * http://www.xarg.org/2014/03/javascript-bit-array/
@@ -15981,10 +15986,11 @@ var bitset = {
15981
15986
  module2["exports"] = BitSet2;
15982
15987
  }
15983
15988
  })();
15984
- })(bitset, bitsetExports);
15989
+ })(bitset, bitset.exports);
15990
+ var bitsetExports = bitset.exports;
15985
15991
  const BitSet = /* @__PURE__ */ getDefaultExportFromCjs(bitsetExports);
15986
15992
  const name = "proskomma-core";
15987
- const version = "0.10.10";
15993
+ const version = "0.10.12";
15988
15994
  const description$b = "A Scripture Runtime Engine";
15989
15995
  const files = [
15990
15996
  "dist"
@@ -16578,18 +16584,10 @@ const enumRegexIndexTuples = (enumSuccinct, regex) => {
16578
16584
  return ret;
16579
16585
  };
16580
16586
  const enums = { enumStringIndex, enumRegexIndexTuples };
16581
- var uuidExports = {};
16582
- var uuid = {
16583
- get exports() {
16584
- return uuidExports;
16585
- },
16586
- set exports(v) {
16587
- uuidExports = v;
16588
- }
16589
- };
16587
+ var uuid = { exports: {} };
16590
16588
  /*!
16591
16589
  ** Pure-UUID -- Pure JavaScript Based Universally Unique Identifier (UUID)
16592
- ** Copyright (c) 2004-2021 Dr. Ralf S. Engelschall <rse@engelschall.com>
16590
+ ** Copyright (c) 2004-2023 Dr. Ralf S. Engelschall <rse@engelschall.com>
16593
16591
  **
16594
16592
  ** Permission is hereby granted, free of charge, to any person obtaining
16595
16593
  ** a copy of this software and associated documentation files (the
@@ -17157,7 +17155,21 @@ var uuid = {
17157
17155
  this.state = ui64_clone(this.inc);
17158
17156
  this.next();
17159
17157
  ui64_and(this.state, this.mask);
17160
- seed = ui64_n2i(seed !== void 0 ? seed >>> 0 : Math.random() * 4294967295 >>> 0);
17158
+ var arr;
17159
+ if (seed !== void 0)
17160
+ seed = ui64_n2i(seed >>> 0);
17161
+ else if (typeof window === "object" && typeof window.crypto === "object" && typeof window.crypto.getRandomValues === "function") {
17162
+ arr = new Uint32Array(2);
17163
+ window.crypto.getRandomValues(arr);
17164
+ seed = ui64_or(ui64_n2i(arr[0] >>> 0), ui64_ror(ui64_n2i(arr[1] >>> 0), 32));
17165
+ } else if (typeof globalThis === "object" && typeof globalThis.crypto === "object" && typeof globalThis.crypto.getRandomValues === "function") {
17166
+ arr = new Uint32Array(2);
17167
+ globalThis.crypto.getRandomValues(arr);
17168
+ seed = ui64_or(ui64_n2i(arr[0] >>> 0), ui64_ror(ui64_n2i(arr[1] >>> 0), 32));
17169
+ } else {
17170
+ seed = ui64_n2i(Math.random() * 4294967295 >>> 0);
17171
+ ui64_or(seed, ui64_ror(ui64_n2i((/* @__PURE__ */ new Date()).getTime()), 32));
17172
+ }
17161
17173
  ui64_or(this.state, seed);
17162
17174
  this.next();
17163
17175
  };
@@ -17179,7 +17191,17 @@ var uuid = {
17179
17191
  ui64_xor(output, output2);
17180
17192
  return ui64_i2n(output);
17181
17193
  };
17194
+ PCG.prototype.reseed = function(seed) {
17195
+ if (typeof seed !== "string")
17196
+ throw new Error("UUID: PCG: seed: invalid argument (string expected)");
17197
+ var arr = sha1_core(s2a(seed, { ibits: 8, obits: 32, obigendian: true }), seed.length * 8);
17198
+ for (var i = 0; i < arr.length; i++)
17199
+ ui64_xor(pcg.state, ui64_n2i(arr[i] >>> 0));
17200
+ };
17182
17201
  var pcg = new PCG();
17202
+ PCG.reseed = function(seed) {
17203
+ pcg.reseed(seed);
17204
+ };
17183
17205
  var prng = function(len, radix) {
17184
17206
  var bytes = [];
17185
17207
  for (var i = 0; i < len; i++)
@@ -17210,7 +17232,7 @@ var uuid = {
17210
17232
  var i;
17211
17233
  var uuid2 = this;
17212
17234
  if (version2 === 1) {
17213
- var date = new Date();
17235
+ var date = /* @__PURE__ */ new Date();
17214
17236
  var time_now = date.getTime();
17215
17237
  if (time_now !== time_last)
17216
17238
  time_seq = 0;
@@ -17381,17 +17403,11 @@ var uuid = {
17381
17403
  return UUID2;
17382
17404
  });
17383
17405
  })(uuid);
17384
- const UUID = uuidExports;
17385
- var base64Exports = {};
17386
- var base64$1 = {
17387
- get exports() {
17388
- return base64Exports;
17389
- },
17390
- set exports(v) {
17391
- base64Exports = v;
17392
- }
17393
- };
17406
+ var uuidExports = uuid.exports;
17407
+ const UUID = /* @__PURE__ */ getDefaultExportFromCjs(uuidExports);
17408
+ var base64$1 = { exports: {} };
17394
17409
  /*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */
17410
+ base64$1.exports;
17395
17411
  (function(module2, exports2) {
17396
17412
  (function(root) {
17397
17413
  var freeExports = exports2;
@@ -17489,8 +17505,9 @@ var base64$1 = {
17489
17505
  root.base64 = base642;
17490
17506
  }
17491
17507
  })(commonjsGlobal);
17492
- })(base64$1, base64Exports);
17493
- const base64 = base64Exports;
17508
+ })(base64$1, base64$1.exports);
17509
+ var base64Exports = base64$1.exports;
17510
+ const base64 = /* @__PURE__ */ getDefaultExportFromCjs(base64Exports);
17494
17511
  const generateId = () => base64.encode(new UUID(4)).substring(0, 12);
17495
17512
  const graftLocation = {
17496
17513
  heading: "block",
@@ -19721,15 +19738,7 @@ class DocSet {
19721
19738
  return crc32.calculate(docIdsString);
19722
19739
  }
19723
19740
  }
19724
- var ajvExports = {};
19725
- var ajv = {
19726
- get exports() {
19727
- return ajvExports;
19728
- },
19729
- set exports(v) {
19730
- ajvExports = v;
19731
- }
19732
- };
19741
+ var ajv = { exports: {} };
19733
19742
  var core$2 = {};
19734
19743
  var validate = {};
19735
19744
  var boolSchema = {};
@@ -19900,7 +19909,7 @@ var scope = {};
19900
19909
  (function(UsedValueState2) {
19901
19910
  UsedValueState2[UsedValueState2["Started"] = 0] = "Started";
19902
19911
  UsedValueState2[UsedValueState2["Completed"] = 1] = "Completed";
19903
- })(UsedValueState = exports2.UsedValueState || (exports2.UsedValueState = {}));
19912
+ })(UsedValueState || (exports2.UsedValueState = UsedValueState = {}));
19904
19913
  exports2.varKinds = {
19905
19914
  const: new code_12.Name("const"),
19906
19915
  let: new code_12.Name("let"),
@@ -20742,193 +20751,197 @@ var scope = {};
20742
20751
  }
20743
20752
  })(codegen);
20744
20753
  var util = {};
20745
- (function(exports2) {
20746
- Object.defineProperty(exports2, "__esModule", { value: true });
20747
- exports2.checkStrictMode = exports2.getErrorPath = exports2.Type = exports2.useFunc = exports2.setEvaluated = exports2.evaluatedPropsToName = exports2.mergeEvaluated = exports2.eachItem = exports2.unescapeJsonPointer = exports2.escapeJsonPointer = exports2.escapeFragment = exports2.unescapeFragment = exports2.schemaRefOrVal = exports2.schemaHasRulesButRef = exports2.schemaHasRules = exports2.checkUnknownRules = exports2.alwaysValidSchema = exports2.toHash = void 0;
20748
- const codegen_12 = codegen;
20749
- const code_12 = code$1;
20750
- function toHash(arr) {
20751
- const hash = {};
20752
- for (const item of arr)
20753
- hash[item] = true;
20754
- return hash;
20755
- }
20756
- exports2.toHash = toHash;
20757
- function alwaysValidSchema(it, schema) {
20758
- if (typeof schema == "boolean")
20759
- return schema;
20760
- if (Object.keys(schema).length === 0)
20761
- return true;
20762
- checkUnknownRules(it, schema);
20763
- return !schemaHasRules(schema, it.self.RULES.all);
20764
- }
20765
- exports2.alwaysValidSchema = alwaysValidSchema;
20766
- function checkUnknownRules(it, schema = it.schema) {
20767
- const { opts, self: self2 } = it;
20768
- if (!opts.strictSchema)
20769
- return;
20770
- if (typeof schema === "boolean")
20771
- return;
20772
- const rules2 = self2.RULES.keywords;
20773
- for (const key in schema) {
20774
- if (!rules2[key])
20775
- checkStrictMode(it, `unknown keyword: "${key}"`);
20776
- }
20777
- }
20778
- exports2.checkUnknownRules = checkUnknownRules;
20779
- function schemaHasRules(schema, rules2) {
20780
- if (typeof schema == "boolean")
20781
- return !schema;
20782
- for (const key in schema)
20783
- if (rules2[key])
20784
- return true;
20785
- return false;
20786
- }
20787
- exports2.schemaHasRules = schemaHasRules;
20788
- function schemaHasRulesButRef(schema, RULES) {
20789
- if (typeof schema == "boolean")
20790
- return !schema;
20791
- for (const key in schema)
20792
- if (key !== "$ref" && RULES.all[key])
20793
- return true;
20794
- return false;
20754
+ Object.defineProperty(util, "__esModule", { value: true });
20755
+ util.checkStrictMode = util.getErrorPath = util.Type = util.useFunc = util.setEvaluated = util.evaluatedPropsToName = util.mergeEvaluated = util.eachItem = util.unescapeJsonPointer = util.escapeJsonPointer = util.escapeFragment = util.unescapeFragment = util.schemaRefOrVal = util.schemaHasRulesButRef = util.schemaHasRules = util.checkUnknownRules = util.alwaysValidSchema = util.toHash = void 0;
20756
+ const codegen_1$v = codegen;
20757
+ const code_1$a = code$1;
20758
+ function toHash(arr) {
20759
+ const hash = {};
20760
+ for (const item of arr)
20761
+ hash[item] = true;
20762
+ return hash;
20763
+ }
20764
+ util.toHash = toHash;
20765
+ function alwaysValidSchema(it, schema) {
20766
+ if (typeof schema == "boolean")
20767
+ return schema;
20768
+ if (Object.keys(schema).length === 0)
20769
+ return true;
20770
+ checkUnknownRules(it, schema);
20771
+ return !schemaHasRules(schema, it.self.RULES.all);
20772
+ }
20773
+ util.alwaysValidSchema = alwaysValidSchema;
20774
+ function checkUnknownRules(it, schema = it.schema) {
20775
+ const { opts, self: self2 } = it;
20776
+ if (!opts.strictSchema)
20777
+ return;
20778
+ if (typeof schema === "boolean")
20779
+ return;
20780
+ const rules2 = self2.RULES.keywords;
20781
+ for (const key in schema) {
20782
+ if (!rules2[key])
20783
+ checkStrictMode(it, `unknown keyword: "${key}"`);
20795
20784
  }
20796
- exports2.schemaHasRulesButRef = schemaHasRulesButRef;
20797
- function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
20798
- if (!$data) {
20799
- if (typeof schema == "number" || typeof schema == "boolean")
20800
- return schema;
20801
- if (typeof schema == "string")
20802
- return (0, codegen_12._)`${schema}`;
20803
- }
20804
- return (0, codegen_12._)`${topSchemaRef}${schemaPath}${(0, codegen_12.getProperty)(keyword2)}`;
20805
- }
20806
- exports2.schemaRefOrVal = schemaRefOrVal;
20807
- function unescapeFragment(str) {
20808
- return unescapeJsonPointer(decodeURIComponent(str));
20809
- }
20810
- exports2.unescapeFragment = unescapeFragment;
20811
- function escapeFragment(str) {
20812
- return encodeURIComponent(escapeJsonPointer(str));
20813
- }
20814
- exports2.escapeFragment = escapeFragment;
20815
- function escapeJsonPointer(str) {
20816
- if (typeof str == "number")
20817
- return `${str}`;
20818
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
20819
- }
20820
- exports2.escapeJsonPointer = escapeJsonPointer;
20821
- function unescapeJsonPointer(str) {
20822
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
20823
- }
20824
- exports2.unescapeJsonPointer = unescapeJsonPointer;
20825
- function eachItem(xs, f) {
20826
- if (Array.isArray(xs)) {
20827
- for (const x of xs)
20828
- f(x);
20829
- } else {
20830
- f(xs);
20831
- }
20785
+ }
20786
+ util.checkUnknownRules = checkUnknownRules;
20787
+ function schemaHasRules(schema, rules2) {
20788
+ if (typeof schema == "boolean")
20789
+ return !schema;
20790
+ for (const key in schema)
20791
+ if (rules2[key])
20792
+ return true;
20793
+ return false;
20794
+ }
20795
+ util.schemaHasRules = schemaHasRules;
20796
+ function schemaHasRulesButRef(schema, RULES) {
20797
+ if (typeof schema == "boolean")
20798
+ return !schema;
20799
+ for (const key in schema)
20800
+ if (key !== "$ref" && RULES.all[key])
20801
+ return true;
20802
+ return false;
20803
+ }
20804
+ util.schemaHasRulesButRef = schemaHasRulesButRef;
20805
+ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
20806
+ if (!$data) {
20807
+ if (typeof schema == "number" || typeof schema == "boolean")
20808
+ return schema;
20809
+ if (typeof schema == "string")
20810
+ return (0, codegen_1$v._)`${schema}`;
20832
20811
  }
20833
- exports2.eachItem = eachItem;
20834
- function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
20835
- return (gen, from, to, toName) => {
20836
- const res = to === void 0 ? from : to instanceof codegen_12.Name ? (from instanceof codegen_12.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_12.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to);
20837
- return toName === codegen_12.Name && !(res instanceof codegen_12.Name) ? resultToName(gen, res) : res;
20838
- };
20812
+ return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
20813
+ }
20814
+ util.schemaRefOrVal = schemaRefOrVal;
20815
+ function unescapeFragment(str) {
20816
+ return unescapeJsonPointer(decodeURIComponent(str));
20817
+ }
20818
+ util.unescapeFragment = unescapeFragment;
20819
+ function escapeFragment(str) {
20820
+ return encodeURIComponent(escapeJsonPointer(str));
20821
+ }
20822
+ util.escapeFragment = escapeFragment;
20823
+ function escapeJsonPointer(str) {
20824
+ if (typeof str == "number")
20825
+ return `${str}`;
20826
+ return str.replace(/~/g, "~0").replace(/\//g, "~1");
20827
+ }
20828
+ util.escapeJsonPointer = escapeJsonPointer;
20829
+ function unescapeJsonPointer(str) {
20830
+ return str.replace(/~1/g, "/").replace(/~0/g, "~");
20831
+ }
20832
+ util.unescapeJsonPointer = unescapeJsonPointer;
20833
+ function eachItem(xs, f) {
20834
+ if (Array.isArray(xs)) {
20835
+ for (const x of xs)
20836
+ f(x);
20837
+ } else {
20838
+ f(xs);
20839
20839
  }
20840
- exports2.mergeEvaluated = {
20841
- props: makeMergeEvaluated({
20842
- mergeNames: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true && ${from} !== undefined`, () => {
20843
- gen.if((0, codegen_12._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_12._)`${to} || {}`).code((0, codegen_12._)`Object.assign(${to}, ${from})`));
20844
- }),
20845
- mergeToName: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true`, () => {
20846
- if (from === true) {
20847
- gen.assign(to, true);
20848
- } else {
20849
- gen.assign(to, (0, codegen_12._)`${to} || {}`);
20850
- setEvaluated(gen, to, from);
20851
- }
20852
- }),
20853
- mergeValues: (from, to) => from === true ? true : { ...from, ...to },
20854
- resultToName: evaluatedPropsToName
20855
- }),
20856
- items: makeMergeEvaluated({
20857
- mergeNames: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_12._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
20858
- mergeToName: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_12._)`${to} > ${from} ? ${to} : ${from}`)),
20859
- mergeValues: (from, to) => from === true ? true : Math.max(from, to),
20860
- resultToName: (gen, items2) => gen.var("items", items2)
20861
- })
20840
+ }
20841
+ util.eachItem = eachItem;
20842
+ function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
20843
+ return (gen, from, to, toName) => {
20844
+ const res = to === void 0 ? from : to instanceof codegen_1$v.Name ? (from instanceof codegen_1$v.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$v.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to);
20845
+ return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
20862
20846
  };
20863
- function evaluatedPropsToName(gen, ps) {
20864
- if (ps === true)
20865
- return gen.var("props", true);
20866
- const props = gen.var("props", (0, codegen_12._)`{}`);
20867
- if (ps !== void 0)
20868
- setEvaluated(gen, props, ps);
20869
- return props;
20870
- }
20871
- exports2.evaluatedPropsToName = evaluatedPropsToName;
20872
- function setEvaluated(gen, props, ps) {
20873
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_12._)`${props}${(0, codegen_12.getProperty)(p)}`, true));
20874
- }
20875
- exports2.setEvaluated = setEvaluated;
20876
- const snippets = {};
20877
- function useFunc(gen, f) {
20878
- return gen.scopeValue("func", {
20879
- ref: f,
20880
- code: snippets[f.code] || (snippets[f.code] = new code_12._Code(f.code))
20881
- });
20882
- }
20883
- exports2.useFunc = useFunc;
20884
- var Type;
20885
- (function(Type2) {
20886
- Type2[Type2["Num"] = 0] = "Num";
20887
- Type2[Type2["Str"] = 1] = "Str";
20888
- })(Type = exports2.Type || (exports2.Type = {}));
20889
- function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
20890
- if (dataProp instanceof codegen_12.Name) {
20891
- const isNumber = dataPropType === Type.Num;
20892
- return jsPropertySyntax ? isNumber ? (0, codegen_12._)`"[" + ${dataProp} + "]"` : (0, codegen_12._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_12._)`"/" + ${dataProp}` : (0, codegen_12._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
20893
- }
20894
- return jsPropertySyntax ? (0, codegen_12.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
20895
- }
20896
- exports2.getErrorPath = getErrorPath;
20897
- function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
20898
- if (!mode)
20899
- return;
20900
- msg = `strict mode: ${msg}`;
20901
- if (mode === true)
20902
- throw new Error(msg);
20903
- it.self.logger.warn(msg);
20904
- }
20905
- exports2.checkStrictMode = checkStrictMode;
20906
- })(util);
20847
+ }
20848
+ util.mergeEvaluated = {
20849
+ props: makeMergeEvaluated({
20850
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
20851
+ gen.if((0, codegen_1$v._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$v._)`${to} || {}`).code((0, codegen_1$v._)`Object.assign(${to}, ${from})`));
20852
+ }),
20853
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
20854
+ if (from === true) {
20855
+ gen.assign(to, true);
20856
+ } else {
20857
+ gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
20858
+ setEvaluated(gen, to, from);
20859
+ }
20860
+ }),
20861
+ mergeValues: (from, to) => from === true ? true : { ...from, ...to },
20862
+ resultToName: evaluatedPropsToName
20863
+ }),
20864
+ items: makeMergeEvaluated({
20865
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$v._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
20866
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$v._)`${to} > ${from} ? ${to} : ${from}`)),
20867
+ mergeValues: (from, to) => from === true ? true : Math.max(from, to),
20868
+ resultToName: (gen, items2) => gen.var("items", items2)
20869
+ })
20870
+ };
20871
+ function evaluatedPropsToName(gen, ps) {
20872
+ if (ps === true)
20873
+ return gen.var("props", true);
20874
+ const props = gen.var("props", (0, codegen_1$v._)`{}`);
20875
+ if (ps !== void 0)
20876
+ setEvaluated(gen, props, ps);
20877
+ return props;
20878
+ }
20879
+ util.evaluatedPropsToName = evaluatedPropsToName;
20880
+ function setEvaluated(gen, props, ps) {
20881
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
20882
+ }
20883
+ util.setEvaluated = setEvaluated;
20884
+ const snippets = {};
20885
+ function useFunc(gen, f) {
20886
+ return gen.scopeValue("func", {
20887
+ ref: f,
20888
+ code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
20889
+ });
20890
+ }
20891
+ util.useFunc = useFunc;
20892
+ var Type;
20893
+ (function(Type2) {
20894
+ Type2[Type2["Num"] = 0] = "Num";
20895
+ Type2[Type2["Str"] = 1] = "Str";
20896
+ })(Type || (util.Type = Type = {}));
20897
+ function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
20898
+ if (dataProp instanceof codegen_1$v.Name) {
20899
+ const isNumber = dataPropType === Type.Num;
20900
+ return jsPropertySyntax ? isNumber ? (0, codegen_1$v._)`"[" + ${dataProp} + "]"` : (0, codegen_1$v._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$v._)`"/" + ${dataProp}` : (0, codegen_1$v._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
20901
+ }
20902
+ return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
20903
+ }
20904
+ util.getErrorPath = getErrorPath;
20905
+ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
20906
+ if (!mode)
20907
+ return;
20908
+ msg = `strict mode: ${msg}`;
20909
+ if (mode === true)
20910
+ throw new Error(msg);
20911
+ it.self.logger.warn(msg);
20912
+ }
20913
+ util.checkStrictMode = checkStrictMode;
20907
20914
  var names$1 = {};
20908
20915
  Object.defineProperty(names$1, "__esModule", { value: true });
20909
- const codegen_1$t = codegen;
20916
+ const codegen_1$u = codegen;
20910
20917
  const names = {
20911
20918
  // validation function arguments
20912
- data: new codegen_1$t.Name("data"),
20919
+ data: new codegen_1$u.Name("data"),
20920
+ // data passed to validation function
20913
20921
  // args passed from referencing schema
20914
- valCxt: new codegen_1$t.Name("valCxt"),
20915
- instancePath: new codegen_1$t.Name("instancePath"),
20916
- parentData: new codegen_1$t.Name("parentData"),
20917
- parentDataProperty: new codegen_1$t.Name("parentDataProperty"),
20918
- rootData: new codegen_1$t.Name("rootData"),
20919
- dynamicAnchors: new codegen_1$t.Name("dynamicAnchors"),
20922
+ valCxt: new codegen_1$u.Name("valCxt"),
20923
+ // validation/data context - should not be used directly, it is destructured to the names below
20924
+ instancePath: new codegen_1$u.Name("instancePath"),
20925
+ parentData: new codegen_1$u.Name("parentData"),
20926
+ parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
20927
+ rootData: new codegen_1$u.Name("rootData"),
20928
+ // root data - same as the data passed to the first/top validation function
20929
+ dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
20930
+ // used to support recursiveRef and dynamicRef
20920
20931
  // function scoped variables
20921
- vErrors: new codegen_1$t.Name("vErrors"),
20922
- errors: new codegen_1$t.Name("errors"),
20923
- this: new codegen_1$t.Name("this"),
20932
+ vErrors: new codegen_1$u.Name("vErrors"),
20933
+ // null or array of validation errors
20934
+ errors: new codegen_1$u.Name("errors"),
20935
+ // counter of validation errors
20936
+ this: new codegen_1$u.Name("this"),
20924
20937
  // "globals"
20925
- self: new codegen_1$t.Name("self"),
20926
- scope: new codegen_1$t.Name("scope"),
20938
+ self: new codegen_1$u.Name("self"),
20939
+ scope: new codegen_1$u.Name("scope"),
20927
20940
  // JTD serialize/parse name for JSON string and position
20928
- json: new codegen_1$t.Name("json"),
20929
- jsonPos: new codegen_1$t.Name("jsonPos"),
20930
- jsonLen: new codegen_1$t.Name("jsonLen"),
20931
- jsonPart: new codegen_1$t.Name("jsonPart")
20941
+ json: new codegen_1$u.Name("json"),
20942
+ jsonPos: new codegen_1$u.Name("jsonPos"),
20943
+ jsonLen: new codegen_1$u.Name("jsonLen"),
20944
+ jsonPart: new codegen_1$u.Name("jsonPart")
20932
20945
  };
20933
20946
  names$1.default = names;
20934
20947
  (function(exports2) {
@@ -21001,6 +21014,7 @@ names$1.default = names;
21001
21014
  const E = {
21002
21015
  keyword: new codegen_12.Name("keyword"),
21003
21016
  schemaPath: new codegen_12.Name("schemaPath"),
21017
+ // also used in JTD errors
21004
21018
  params: new codegen_12.Name("params"),
21005
21019
  propertyName: new codegen_12.Name("propertyName"),
21006
21020
  message: new codegen_12.Name("message"),
@@ -21049,8 +21063,8 @@ names$1.default = names;
21049
21063
  })(errors);
21050
21064
  Object.defineProperty(boolSchema, "__esModule", { value: true });
21051
21065
  boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
21052
- const errors_1$2 = errors;
21053
- const codegen_1$s = codegen;
21066
+ const errors_1$3 = errors;
21067
+ const codegen_1$t = codegen;
21054
21068
  const names_1$6 = names$1;
21055
21069
  const boolError = {
21056
21070
  message: "boolean schema is false"
@@ -21062,7 +21076,7 @@ function topBoolOrEmptySchema(it) {
21062
21076
  } else if (typeof schema == "object" && schema.$async === true) {
21063
21077
  gen.return(names_1$6.default.data);
21064
21078
  } else {
21065
- gen.assign((0, codegen_1$s._)`${validateName2}.errors`, null);
21079
+ gen.assign((0, codegen_1$t._)`${validateName2}.errors`, null);
21066
21080
  gen.return(true);
21067
21081
  }
21068
21082
  }
@@ -21089,7 +21103,7 @@ function falseSchemaError(it, overrideAllErrors) {
21089
21103
  params: {},
21090
21104
  it
21091
21105
  };
21092
- (0, errors_1$2.reportError)(cxt, boolError, void 0, overrideAllErrors);
21106
+ (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
21093
21107
  }
21094
21108
  var dataType = {};
21095
21109
  var rules = {};
@@ -21134,185 +21148,183 @@ function shouldUseRule(schema, rule) {
21134
21148
  return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
21135
21149
  }
21136
21150
  applicability.shouldUseRule = shouldUseRule;
21137
- (function(exports2) {
21138
- Object.defineProperty(exports2, "__esModule", { value: true });
21139
- exports2.reportTypeError = exports2.checkDataTypes = exports2.checkDataType = exports2.coerceAndCheckDataType = exports2.getJSONTypes = exports2.getSchemaTypes = exports2.DataType = void 0;
21140
- const rules_1 = rules;
21141
- const applicability_12 = applicability;
21142
- const errors_12 = errors;
21143
- const codegen_12 = codegen;
21144
- const util_12 = util;
21145
- var DataType;
21146
- (function(DataType2) {
21147
- DataType2[DataType2["Correct"] = 0] = "Correct";
21148
- DataType2[DataType2["Wrong"] = 1] = "Wrong";
21149
- })(DataType = exports2.DataType || (exports2.DataType = {}));
21150
- function getSchemaTypes(schema) {
21151
- const types2 = getJSONTypes(schema.type);
21152
- const hasNull = types2.includes("null");
21153
- if (hasNull) {
21154
- if (schema.nullable === false)
21155
- throw new Error("type: null contradicts nullable: false");
21156
- } else {
21157
- if (!types2.length && schema.nullable !== void 0) {
21158
- throw new Error('"nullable" cannot be used without "type"');
21159
- }
21160
- if (schema.nullable === true)
21161
- types2.push("null");
21151
+ Object.defineProperty(dataType, "__esModule", { value: true });
21152
+ dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
21153
+ const rules_1 = rules;
21154
+ const applicability_1$1 = applicability;
21155
+ const errors_1$2 = errors;
21156
+ const codegen_1$s = codegen;
21157
+ const util_1$q = util;
21158
+ var DataType;
21159
+ (function(DataType2) {
21160
+ DataType2[DataType2["Correct"] = 0] = "Correct";
21161
+ DataType2[DataType2["Wrong"] = 1] = "Wrong";
21162
+ })(DataType || (dataType.DataType = DataType = {}));
21163
+ function getSchemaTypes(schema) {
21164
+ const types2 = getJSONTypes(schema.type);
21165
+ const hasNull = types2.includes("null");
21166
+ if (hasNull) {
21167
+ if (schema.nullable === false)
21168
+ throw new Error("type: null contradicts nullable: false");
21169
+ } else {
21170
+ if (!types2.length && schema.nullable !== void 0) {
21171
+ throw new Error('"nullable" cannot be used without "type"');
21162
21172
  }
21163
- return types2;
21173
+ if (schema.nullable === true)
21174
+ types2.push("null");
21164
21175
  }
21165
- exports2.getSchemaTypes = getSchemaTypes;
21166
- function getJSONTypes(ts) {
21167
- const types2 = Array.isArray(ts) ? ts : ts ? [ts] : [];
21168
- if (types2.every(rules_1.isJSONType))
21169
- return types2;
21170
- throw new Error("type must be JSONType or JSONType[]: " + types2.join(","));
21171
- }
21172
- exports2.getJSONTypes = getJSONTypes;
21173
- function coerceAndCheckDataType(it, types2) {
21174
- const { gen, data, opts } = it;
21175
- const coerceTo = coerceToTypes(types2, opts.coerceTypes);
21176
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_12.schemaHasRulesForType)(it, types2[0]));
21177
- if (checkTypes) {
21178
- const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
21179
- gen.if(wrongType, () => {
21180
- if (coerceTo.length)
21181
- coerceData(it, types2, coerceTo);
21182
- else
21183
- reportTypeError(it);
21184
- });
21185
- }
21186
- return checkTypes;
21176
+ return types2;
21177
+ }
21178
+ dataType.getSchemaTypes = getSchemaTypes;
21179
+ function getJSONTypes(ts) {
21180
+ const types2 = Array.isArray(ts) ? ts : ts ? [ts] : [];
21181
+ if (types2.every(rules_1.isJSONType))
21182
+ return types2;
21183
+ throw new Error("type must be JSONType or JSONType[]: " + types2.join(","));
21184
+ }
21185
+ dataType.getJSONTypes = getJSONTypes;
21186
+ function coerceAndCheckDataType(it, types2) {
21187
+ const { gen, data, opts } = it;
21188
+ const coerceTo = coerceToTypes(types2, opts.coerceTypes);
21189
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
21190
+ if (checkTypes) {
21191
+ const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
21192
+ gen.if(wrongType, () => {
21193
+ if (coerceTo.length)
21194
+ coerceData(it, types2, coerceTo);
21195
+ else
21196
+ reportTypeError(it);
21197
+ });
21187
21198
  }
21188
- exports2.coerceAndCheckDataType = coerceAndCheckDataType;
21189
- const COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
21190
- function coerceToTypes(types2, coerceTypes) {
21191
- return coerceTypes ? types2.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
21199
+ return checkTypes;
21200
+ }
21201
+ dataType.coerceAndCheckDataType = coerceAndCheckDataType;
21202
+ const COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
21203
+ function coerceToTypes(types2, coerceTypes) {
21204
+ return coerceTypes ? types2.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
21205
+ }
21206
+ function coerceData(it, types2, coerceTo) {
21207
+ const { gen, data, opts } = it;
21208
+ const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
21209
+ const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
21210
+ if (opts.coerceTypes === "array") {
21211
+ gen.if((0, codegen_1$s._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$s._)`${data}[0]`).assign(dataType2, (0, codegen_1$s._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
21192
21212
  }
21193
- function coerceData(it, types2, coerceTo) {
21194
- const { gen, data, opts } = it;
21195
- const dataType2 = gen.let("dataType", (0, codegen_12._)`typeof ${data}`);
21196
- const coerced = gen.let("coerced", (0, codegen_12._)`undefined`);
21197
- if (opts.coerceTypes === "array") {
21198
- gen.if((0, codegen_12._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_12._)`${data}[0]`).assign(dataType2, (0, codegen_12._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
21199
- }
21200
- gen.if((0, codegen_12._)`${coerced} !== undefined`);
21201
- for (const t of coerceTo) {
21202
- if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
21203
- coerceSpecificType(t);
21204
- }
21205
- }
21206
- gen.else();
21207
- reportTypeError(it);
21208
- gen.endIf();
21209
- gen.if((0, codegen_12._)`${coerced} !== undefined`, () => {
21210
- gen.assign(data, coerced);
21211
- assignParentData(it, coerced);
21212
- });
21213
- function coerceSpecificType(t) {
21214
- switch (t) {
21215
- case "string":
21216
- gen.elseIf((0, codegen_12._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_12._)`"" + ${data}`).elseIf((0, codegen_12._)`${data} === null`).assign(coerced, (0, codegen_12._)`""`);
21217
- return;
21218
- case "number":
21219
- gen.elseIf((0, codegen_12._)`${dataType2} == "boolean" || ${data} === null
21220
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_12._)`+${data}`);
21221
- return;
21222
- case "integer":
21223
- gen.elseIf((0, codegen_12._)`${dataType2} === "boolean" || ${data} === null
21224
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_12._)`+${data}`);
21225
- return;
21226
- case "boolean":
21227
- gen.elseIf((0, codegen_12._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_12._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
21228
- return;
21229
- case "null":
21230
- gen.elseIf((0, codegen_12._)`${data} === "" || ${data} === 0 || ${data} === false`);
21231
- gen.assign(coerced, null);
21232
- return;
21233
- case "array":
21234
- gen.elseIf((0, codegen_12._)`${dataType2} === "string" || ${dataType2} === "number"
21235
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_12._)`[${data}]`);
21236
- }
21213
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
21214
+ for (const t of coerceTo) {
21215
+ if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
21216
+ coerceSpecificType(t);
21237
21217
  }
21238
21218
  }
21239
- function assignParentData({ gen, parentData, parentDataProperty }, expr) {
21240
- gen.if((0, codegen_12._)`${parentData} !== undefined`, () => gen.assign((0, codegen_12._)`${parentData}[${parentDataProperty}]`, expr));
21241
- }
21242
- function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
21243
- const EQ = correct === DataType.Correct ? codegen_12.operators.EQ : codegen_12.operators.NEQ;
21244
- let cond;
21245
- switch (dataType2) {
21219
+ gen.else();
21220
+ reportTypeError(it);
21221
+ gen.endIf();
21222
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
21223
+ gen.assign(data, coerced);
21224
+ assignParentData(it, coerced);
21225
+ });
21226
+ function coerceSpecificType(t) {
21227
+ switch (t) {
21228
+ case "string":
21229
+ gen.elseIf((0, codegen_1$s._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$s._)`"" + ${data}`).elseIf((0, codegen_1$s._)`${data} === null`).assign(coerced, (0, codegen_1$s._)`""`);
21230
+ return;
21231
+ case "number":
21232
+ gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
21233
+ || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
21234
+ return;
21235
+ case "integer":
21236
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
21237
+ || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
21238
+ return;
21239
+ case "boolean":
21240
+ gen.elseIf((0, codegen_1$s._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$s._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
21241
+ return;
21246
21242
  case "null":
21247
- return (0, codegen_12._)`${data} ${EQ} null`;
21243
+ gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
21244
+ gen.assign(coerced, null);
21245
+ return;
21248
21246
  case "array":
21249
- cond = (0, codegen_12._)`Array.isArray(${data})`;
21250
- break;
21251
- case "object":
21252
- cond = (0, codegen_12._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
21253
- break;
21254
- case "integer":
21255
- cond = numCond((0, codegen_12._)`!(${data} % 1) && !isNaN(${data})`);
21256
- break;
21257
- case "number":
21258
- cond = numCond();
21259
- break;
21260
- default:
21261
- return (0, codegen_12._)`typeof ${data} ${EQ} ${dataType2}`;
21262
- }
21263
- return correct === DataType.Correct ? cond : (0, codegen_12.not)(cond);
21264
- function numCond(_cond = codegen_12.nil) {
21265
- return (0, codegen_12.and)((0, codegen_12._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_12._)`isFinite(${data})` : codegen_12.nil);
21266
- }
21267
- }
21268
- exports2.checkDataType = checkDataType;
21269
- function checkDataTypes(dataTypes, data, strictNums, correct) {
21270
- if (dataTypes.length === 1) {
21271
- return checkDataType(dataTypes[0], data, strictNums, correct);
21272
- }
21273
- let cond;
21274
- const types2 = (0, util_12.toHash)(dataTypes);
21275
- if (types2.array && types2.object) {
21276
- const notObj = (0, codegen_12._)`typeof ${data} != "object"`;
21277
- cond = types2.null ? notObj : (0, codegen_12._)`!${data} || ${notObj}`;
21278
- delete types2.null;
21279
- delete types2.array;
21280
- delete types2.object;
21281
- } else {
21282
- cond = codegen_12.nil;
21283
- }
21284
- if (types2.number)
21285
- delete types2.integer;
21286
- for (const t in types2)
21287
- cond = (0, codegen_12.and)(cond, checkDataType(t, data, strictNums, correct));
21288
- return cond;
21289
- }
21290
- exports2.checkDataTypes = checkDataTypes;
21291
- const typeError = {
21292
- message: ({ schema }) => `must be ${schema}`,
21293
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_12._)`{type: ${schema}}` : (0, codegen_12._)`{type: ${schemaValue}}`
21294
- };
21295
- function reportTypeError(it) {
21296
- const cxt = getTypeErrorContext(it);
21297
- (0, errors_12.reportError)(cxt, typeError);
21298
- }
21299
- exports2.reportTypeError = reportTypeError;
21300
- function getTypeErrorContext(it) {
21301
- const { gen, data, schema } = it;
21302
- const schemaCode = (0, util_12.schemaRefOrVal)(it, schema, "type");
21303
- return {
21304
- gen,
21305
- keyword: "type",
21306
- data,
21307
- schema: schema.type,
21308
- schemaCode,
21309
- schemaValue: schemaCode,
21310
- parentSchema: schema,
21311
- params: {},
21312
- it
21313
- };
21247
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
21248
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
21249
+ }
21314
21250
  }
21315
- })(dataType);
21251
+ }
21252
+ function assignParentData({ gen, parentData, parentDataProperty }, expr) {
21253
+ gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
21254
+ }
21255
+ function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
21256
+ const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
21257
+ let cond;
21258
+ switch (dataType2) {
21259
+ case "null":
21260
+ return (0, codegen_1$s._)`${data} ${EQ} null`;
21261
+ case "array":
21262
+ cond = (0, codegen_1$s._)`Array.isArray(${data})`;
21263
+ break;
21264
+ case "object":
21265
+ cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
21266
+ break;
21267
+ case "integer":
21268
+ cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
21269
+ break;
21270
+ case "number":
21271
+ cond = numCond();
21272
+ break;
21273
+ default:
21274
+ return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
21275
+ }
21276
+ return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
21277
+ function numCond(_cond = codegen_1$s.nil) {
21278
+ return (0, codegen_1$s.and)((0, codegen_1$s._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$s._)`isFinite(${data})` : codegen_1$s.nil);
21279
+ }
21280
+ }
21281
+ dataType.checkDataType = checkDataType;
21282
+ function checkDataTypes(dataTypes, data, strictNums, correct) {
21283
+ if (dataTypes.length === 1) {
21284
+ return checkDataType(dataTypes[0], data, strictNums, correct);
21285
+ }
21286
+ let cond;
21287
+ const types2 = (0, util_1$q.toHash)(dataTypes);
21288
+ if (types2.array && types2.object) {
21289
+ const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
21290
+ cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
21291
+ delete types2.null;
21292
+ delete types2.array;
21293
+ delete types2.object;
21294
+ } else {
21295
+ cond = codegen_1$s.nil;
21296
+ }
21297
+ if (types2.number)
21298
+ delete types2.integer;
21299
+ for (const t in types2)
21300
+ cond = (0, codegen_1$s.and)(cond, checkDataType(t, data, strictNums, correct));
21301
+ return cond;
21302
+ }
21303
+ dataType.checkDataTypes = checkDataTypes;
21304
+ const typeError = {
21305
+ message: ({ schema }) => `must be ${schema}`,
21306
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
21307
+ };
21308
+ function reportTypeError(it) {
21309
+ const cxt = getTypeErrorContext(it);
21310
+ (0, errors_1$2.reportError)(cxt, typeError);
21311
+ }
21312
+ dataType.reportTypeError = reportTypeError;
21313
+ function getTypeErrorContext(it) {
21314
+ const { gen, data, schema } = it;
21315
+ const schemaCode = (0, util_1$q.schemaRefOrVal)(it, schema, "type");
21316
+ return {
21317
+ gen,
21318
+ keyword: "type",
21319
+ data,
21320
+ schema: schema.type,
21321
+ schemaCode,
21322
+ schemaValue: schemaCode,
21323
+ parentSchema: schema,
21324
+ params: {},
21325
+ it
21326
+ };
21327
+ }
21316
21328
  var defaults = {};
21317
21329
  Object.defineProperty(defaults, "__esModule", { value: true });
21318
21330
  defaults.assignDefaults = void 0;
@@ -21699,15 +21711,7 @@ var fastDeepEqual = function equal(a, b) {
21699
21711
  }
21700
21712
  return a !== a && b !== b;
21701
21713
  };
21702
- var jsonSchemaTraverseExports = {};
21703
- var jsonSchemaTraverse = {
21704
- get exports() {
21705
- return jsonSchemaTraverseExports;
21706
- },
21707
- set exports(v) {
21708
- jsonSchemaTraverseExports = v;
21709
- }
21710
- };
21714
+ var jsonSchemaTraverse = { exports: {} };
21711
21715
  var traverse$1 = jsonSchemaTraverse.exports = function(schema, opts, cb) {
21712
21716
  if (typeof opts == "function") {
21713
21717
  cb = opts;
@@ -21789,6 +21793,7 @@ function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr,
21789
21793
  function escapeJsonPtr(str) {
21790
21794
  return str.replace(/~/g, "~0").replace(/\//g, "~1");
21791
21795
  }
21796
+ var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
21792
21797
  Object.defineProperty(resolve$1, "__esModule", { value: true });
21793
21798
  resolve$1.getSchemaRefs = resolve$1.resolveUrl = resolve$1.normalizeId = resolve$1._getFullPath = resolve$1.getFullPath = resolve$1.inlineRef = void 0;
21794
21799
  const util_1$m = util;
@@ -21893,15 +21898,15 @@ function getSchemaRefs(schema, baseId) {
21893
21898
  if (parentJsonPtr === void 0)
21894
21899
  return;
21895
21900
  const fullPath = pathPrefix + jsonPtr;
21896
- let baseId2 = baseIds[parentJsonPtr];
21901
+ let innerBaseId = baseIds[parentJsonPtr];
21897
21902
  if (typeof sch[schemaId] == "string")
21898
- baseId2 = addRef.call(this, sch[schemaId]);
21903
+ innerBaseId = addRef.call(this, sch[schemaId]);
21899
21904
  addAnchor.call(this, sch.$anchor);
21900
21905
  addAnchor.call(this, sch.$dynamicAnchor);
21901
- baseIds[jsonPtr] = baseId2;
21906
+ baseIds[jsonPtr] = innerBaseId;
21902
21907
  function addRef(ref2) {
21903
21908
  const _resolve = this.opts.uriResolver.resolve;
21904
- ref2 = normalizeId(baseId2 ? _resolve(baseId2, ref2) : ref2);
21909
+ ref2 = normalizeId(innerBaseId ? _resolve(innerBaseId, ref2) : ref2);
21905
21910
  if (schemaRefs.has(ref2))
21906
21911
  throw ambiguos(ref2);
21907
21912
  schemaRefs.add(ref2);
@@ -22513,6 +22518,7 @@ function compileSchema(sch) {
22513
22518
  parentDataProperty: names_1$2.default.parentDataProperty,
22514
22519
  dataNames: [names_1$2.default.data],
22515
22520
  dataPathArr: [codegen_1$m.nil],
22521
+ // TODO can its length be used as dataLevel if nil is removed?
22516
22522
  dataLevel: 0,
22517
22523
  dataTypes: [],
22518
22524
  definedProperties: /* @__PURE__ */ new Set(),
@@ -22705,15 +22711,7 @@ const require$$9$1 = {
22705
22711
  additionalProperties: additionalProperties$a
22706
22712
  };
22707
22713
  var uri$1 = {};
22708
- var uri_allExports = {};
22709
- var uri_all = {
22710
- get exports() {
22711
- return uri_allExports;
22712
- },
22713
- set exports(v) {
22714
- uri_allExports = v;
22715
- }
22716
- };
22714
+ var uri_all = { exports: {} };
22717
22715
  /** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
22718
22716
  (function(module2, exports2) {
22719
22717
  (function(global2, factory) {
@@ -23753,7 +23751,8 @@ var uri_all = {
23753
23751
  exports3.unescapeComponent = unescapeComponent;
23754
23752
  Object.defineProperty(exports3, "__esModule", { value: true });
23755
23753
  });
23756
- })(uri_all, uri_allExports);
23754
+ })(uri_all, uri_all.exports);
23755
+ var uri_allExports = uri_all.exports;
23757
23756
  Object.defineProperty(uri$1, "__esModule", { value: true });
23758
23757
  const uri = uri_allExports;
23759
23758
  uri.code = 'require("ajv/dist/runtime/uri").default';
@@ -23786,7 +23785,7 @@ uri$1.default = uri;
23786
23785
  } });
23787
23786
  const validation_error_12 = validation_error;
23788
23787
  const ref_error_12 = ref_error;
23789
- const rules_1 = rules;
23788
+ const rules_12 = rules;
23790
23789
  const compile_12 = compile;
23791
23790
  const codegen_2 = codegen;
23792
23791
  const resolve_12 = resolve$1;
@@ -23877,7 +23876,7 @@ uri$1.default = uri;
23877
23876
  this.logger = getLogger(opts.logger);
23878
23877
  const formatOpt = opts.validateFormats;
23879
23878
  opts.validateFormats = false;
23880
- this.RULES = (0, rules_1.getRules)();
23879
+ this.RULES = (0, rules_12.getRules)();
23881
23880
  checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED");
23882
23881
  checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn");
23883
23882
  this._metaOpts = getMetaSchemaOptions.call(this);
@@ -24233,9 +24232,9 @@ uri$1.default = uri;
24233
24232
  }
24234
24233
  }
24235
24234
  }
24236
- exports2.default = Ajv2;
24237
24235
  Ajv2.ValidationError = validation_error_12.default;
24238
24236
  Ajv2.MissingRefError = ref_error_12.default;
24237
+ exports2.default = Ajv2;
24239
24238
  function checkOptions(checkOpts, options2, msg, log = "error") {
24240
24239
  for (const key in checkOpts) {
24241
24240
  const opt = key;
@@ -25829,14 +25828,13 @@ const draft7Vocabularies = [
25829
25828
  draft7.default = draft7Vocabularies;
25830
25829
  var discriminator = {};
25831
25830
  var types = {};
25832
- (function(exports2) {
25833
- Object.defineProperty(exports2, "__esModule", { value: true });
25834
- exports2.DiscrError = void 0;
25835
- (function(DiscrError) {
25836
- DiscrError["Tag"] = "tag";
25837
- DiscrError["Mapping"] = "mapping";
25838
- })(exports2.DiscrError || (exports2.DiscrError = {}));
25839
- })(types);
25831
+ Object.defineProperty(types, "__esModule", { value: true });
25832
+ types.DiscrError = void 0;
25833
+ var DiscrError;
25834
+ (function(DiscrError2) {
25835
+ DiscrError2["Tag"] = "tag";
25836
+ DiscrError2["Mapping"] = "mapping";
25837
+ })(DiscrError || (types.DiscrError = DiscrError = {}));
25840
25838
  Object.defineProperty(discriminator, "__esModule", { value: true });
25841
25839
  const codegen_1 = codegen;
25842
25840
  const types_1 = types;
@@ -26180,7 +26178,7 @@ const require$$3$2 = {
26180
26178
  };
26181
26179
  (function(module2, exports2) {
26182
26180
  Object.defineProperty(exports2, "__esModule", { value: true });
26183
- exports2.MissingRefError = exports2.ValidationError = exports2.CodeGen = exports2.Name = exports2.nil = exports2.stringify = exports2.str = exports2._ = exports2.KeywordCxt = void 0;
26181
+ exports2.MissingRefError = exports2.ValidationError = exports2.CodeGen = exports2.Name = exports2.nil = exports2.stringify = exports2.str = exports2._ = exports2.KeywordCxt = exports2.Ajv = void 0;
26184
26182
  const core_12 = core$2;
26185
26183
  const draft7_1 = draft7;
26186
26184
  const discriminator_1 = discriminator;
@@ -26206,7 +26204,9 @@ const require$$3$2 = {
26206
26204
  return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
26207
26205
  }
26208
26206
  }
26207
+ exports2.Ajv = Ajv2;
26209
26208
  module2.exports = exports2 = Ajv2;
26209
+ module2.exports.Ajv = Ajv2;
26210
26210
  Object.defineProperty(exports2, "__esModule", { value: true });
26211
26211
  exports2.default = Ajv2;
26212
26212
  var validate_12 = validate;
@@ -26240,7 +26240,8 @@ const require$$3$2 = {
26240
26240
  Object.defineProperty(exports2, "MissingRefError", { enumerable: true, get: function() {
26241
26241
  return ref_error_12.default;
26242
26242
  } });
26243
- })(ajv, ajvExports);
26243
+ })(ajv, ajv.exports);
26244
+ var ajvExports = ajv.exports;
26244
26245
  const title$9 = "Root";
26245
26246
  const type$p = "object";
26246
26247
  const description$9 = "Root Element";
@@ -32321,6 +32322,7 @@ function deepCopy(e, t = defaultOpts) {
32321
32322
  return t.detectCircular && s.setAsCopied(e, n), copyObjectContents(e, { destObject: n, srcType: c, watcher: s, options: t }, 0), n;
32322
32323
  }
32323
32324
  var deepCopyAll_min = deepCopy;
32325
+ const deepCopy$1 = /* @__PURE__ */ getDefaultExportFromCjs(deepCopyAll_min);
32324
32326
  var _deepCopyAll = _interopRequireDefault$1(deepCopyAll_min);
32325
32327
  function _interopRequireDefault$1(obj) {
32326
32328
  return obj && obj.__esModule ? obj : { default: obj };
@@ -34182,7 +34184,7 @@ const parseUsfm = (str, parser) => {
34182
34184
  parser.parseItem(preTokenObjectForFragment(matches[n], lexingRegexes));
34183
34185
  }
34184
34186
  };
34185
- var sax = {};
34187
+ var sax$1 = {};
34186
34188
  var emitterComponent;
34187
34189
  var hasRequiredEmitterComponent;
34188
34190
  function requireEmitterComponent() {
@@ -34336,15 +34338,7 @@ function requireStream() {
34336
34338
  return stream;
34337
34339
  }
34338
34340
  var string_decoder = {};
34339
- var safeBufferExports = {};
34340
- var safeBuffer = {
34341
- get exports() {
34342
- return safeBufferExports;
34343
- },
34344
- set exports(v) {
34345
- safeBufferExports = v;
34346
- }
34347
- };
34341
+ var safeBuffer = { exports: {} };
34348
34342
  var buffer = {};
34349
34343
  var ieee754 = {};
34350
34344
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -36139,7 +36133,7 @@ function requireBuffer() {
36139
36133
  var hasRequiredSafeBuffer;
36140
36134
  function requireSafeBuffer() {
36141
36135
  if (hasRequiredSafeBuffer)
36142
- return safeBufferExports;
36136
+ return safeBuffer.exports;
36143
36137
  hasRequiredSafeBuffer = 1;
36144
36138
  (function(module2, exports2) {
36145
36139
  var buffer2 = requireBuffer();
@@ -36194,8 +36188,8 @@ function requireSafeBuffer() {
36194
36188
  }
36195
36189
  return buffer2.SlowBuffer(size);
36196
36190
  };
36197
- })(safeBuffer, safeBufferExports);
36198
- return safeBufferExports;
36191
+ })(safeBuffer, safeBuffer.exports);
36192
+ return safeBuffer.exports;
36199
36193
  }
36200
36194
  var hasRequiredString_decoder;
36201
36195
  function requireString_decoder() {
@@ -36613,6 +36607,9 @@ function requireString_decoder() {
36613
36607
  Stream = function() {
36614
36608
  };
36615
36609
  }
36610
+ if (!Stream)
36611
+ Stream = function() {
36612
+ };
36616
36613
  var streamWraps = sax2.EVENTS.filter(function(ev) {
36617
36614
  return ev !== "error" && ev !== "end";
36618
36615
  });
@@ -37823,9 +37820,16 @@ function requireString_decoder() {
37823
37820
  break;
37824
37821
  }
37825
37822
  if (c === ";") {
37826
- parser[buffer2] += parseEntity(parser);
37827
- parser.entity = "";
37828
- parser.state = returnState;
37823
+ if (parser.opt.unparsedEntities) {
37824
+ var parsedEntity = parseEntity(parser);
37825
+ parser.entity = "";
37826
+ parser.state = returnState;
37827
+ parser.write(parsedEntity);
37828
+ } else {
37829
+ parser[buffer2] += parseEntity(parser);
37830
+ parser.entity = "";
37831
+ parser.state = returnState;
37832
+ }
37829
37833
  } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
37830
37834
  parser.entity += c;
37831
37835
  } else {
@@ -37835,8 +37839,9 @@ function requireString_decoder() {
37835
37839
  parser.state = returnState;
37836
37840
  }
37837
37841
  continue;
37838
- default:
37842
+ default: {
37839
37843
  throw new Error(parser, "Unknown state: " + parser.state);
37844
+ }
37840
37845
  }
37841
37846
  }
37842
37847
  if (parser.position >= parser.bufferCheckPosition) {
@@ -37895,7 +37900,8 @@ function requireString_decoder() {
37895
37900
  })();
37896
37901
  }
37897
37902
  })(exports2);
37898
- })(sax);
37903
+ })(sax$1);
37904
+ const sax = /* @__PURE__ */ getDefaultExportFromCjs(sax$1);
37899
37905
  class UsxLexer {
37900
37906
  constructor() {
37901
37907
  this.sax = sax.parser(true);
@@ -39021,6 +39027,7 @@ const parseNodes = (str, parser, bookCode) => {
39021
39027
  });
39022
39028
  };
39023
39029
  const { labelForScope: labelForScope$2 } = utils.scopeDefs;
39030
+ const idTest = new RegExp(/^[A-Z0-9_]+$/);
39024
39031
  const buildSpecLookup = (specs2) => {
39025
39032
  const ret = {};
39026
39033
  for (const spec of specs2) {
@@ -39065,9 +39072,9 @@ const specs = (pt) => [
39065
39072
  onEnd: (parser, label) => {
39066
39073
  parser.headers[label] = parser.current.sequence.plainText();
39067
39074
  if (label === "id") {
39068
- if (parser.headers[label].length === 3 || parser.headers[label].length > 3 && parser.headers[label].substring(3, 4) === " ") {
39069
- const bookCode = parser.headers[label].substring(0, 3);
39070
- parser.headers["bookCode"] = bookCode;
39075
+ const idBits = parser.headers[label].split(" ", 2);
39076
+ if (idBits[0].length >= 3 && idBits[0].length <= 12 && idTest.test(idBits[0])) {
39077
+ parser.headers["bookCode"] = idBits[0];
39071
39078
  }
39072
39079
  }
39073
39080
  }
@@ -41465,7 +41472,7 @@ const pushModifiedBlocks = (oldSequence, newSequence2, blockFilterFunc, itemFilt
41465
41472
  newSequence2.blocks = [];
41466
41473
  for (const [blockN, block2] of oldSequence.blocks.entries()) {
41467
41474
  if (blockFilterFunc(oldSequence, blockN, block2)) {
41468
- const newBlock2 = blockRewriteFunc(oldSequence, blockN, deepCopyAll_min(block2));
41475
+ const newBlock2 = blockRewriteFunc(oldSequence, blockN, deepCopy$1(block2));
41469
41476
  newBlock2.c.clear();
41470
41477
  modifyBlockItems(
41471
41478
  oldSequence,
@@ -42054,6 +42061,18 @@ const keyValueResolvers = {
42054
42061
  key: (root) => root[0],
42055
42062
  value: (root) => root[1]
42056
42063
  };
42064
+ const keyCountSchemaString = `
42065
+ """Key/Count tuple"""
42066
+ type KeyCount {
42067
+ """The key"""
42068
+ key: String!
42069
+ """The number of occurrences"""
42070
+ count: Int!
42071
+ }`;
42072
+ const keyCountResolvers = {
42073
+ key: (root) => root[0],
42074
+ count: (root) => root[1]
42075
+ };
42057
42076
  const cvSchemaString = `
42058
42077
  """A chapter-verse reference"""
42059
42078
  type cv {
@@ -44521,6 +44540,13 @@ type Sequence {
44521
44540
  """Whether to coerce the strings (toLower|toUpper|none)"""
44522
44541
  coerceCase: String
44523
44542
  ) : [String!]!
44543
+ """A list of token strings the sequence with counts"""
44544
+ uniqueTokenCounts(
44545
+ """Whether to coerce the strings (toLower|toUpper|none)"""
44546
+ coerceCase: String
44547
+ ) : [KeyCount!]!
44548
+ """A list of unique characters in the sequence with counts"""
44549
+ uniqueCharacterCounts: [KeyCount!]!
44524
44550
  """Returns true if a main sequence contains the specified tokens"""
44525
44551
  hasChars(
44526
44552
  """Token strings to be matched exactly"""
@@ -44693,6 +44719,43 @@ const sequenceResolvers = {
44693
44719
  }
44694
44720
  return Array.from(tokens2).sort();
44695
44721
  },
44722
+ uniqueCharacterCounts: (root, args, context) => {
44723
+ const characters = {};
44724
+ root.blocks.forEach(
44725
+ (b) => context.docSet.unsuccinctifyItems(b.c, { tokens: true }, null).forEach(
44726
+ (t) => {
44727
+ const chars = t[2].split("");
44728
+ for (const char of chars) {
44729
+ characters[char] ? characters[char] += 1 : characters[char] = 1;
44730
+ }
44731
+ }
44732
+ )
44733
+ );
44734
+ return Object.entries(characters).sort((a, b) => b[1] - a[1]);
44735
+ },
44736
+ uniqueTokenCounts: (root, args, context) => {
44737
+ const wordlikes = {};
44738
+ root.blocks.forEach(
44739
+ (b) => context.docSet.unsuccinctifyItems(b.c, { tokens: true }, null).forEach(
44740
+ (t) => {
44741
+ let wordlike = t[2];
44742
+ if (args.coerceCase && !["toLower", "toUpper", "none"].includes(args.coerceCase)) {
44743
+ throw new Error(
44744
+ `coerceCase, when present, must be 'toLower', 'toUpper' or 'none', not '${args.coerceCase}'`
44745
+ );
44746
+ }
44747
+ if (args.coerceCase === "toLower") {
44748
+ wordlike = wordlike.toLowerCase();
44749
+ }
44750
+ if (args.coerceCase === "toUpper") {
44751
+ wordlike = wordlike.toUpperCase();
44752
+ }
44753
+ wordlikes[wordlike] ? wordlikes[wordlike] += 1 : wordlikes[wordlike] = 1;
44754
+ }
44755
+ )
44756
+ );
44757
+ return Object.entries(wordlikes).sort((a, b) => b[1] - a[1]);
44758
+ },
44696
44759
  hasChars: (root, args, context) => {
44697
44760
  if (root.type !== "main") {
44698
44761
  throw new Error(`Only available for the main sequence, not ${root.type}`);
@@ -49896,6 +49959,7 @@ const typeDefs = `
49896
49959
  ${querySchemaString}
49897
49960
  ${mutationsSchemaString}
49898
49961
  ${keyValueSchemaString}
49962
+ ${keyCountSchemaString}
49899
49963
  ${cvSchemaString}
49900
49964
  ${idPartsSchemaString}
49901
49965
  ${inputAttSpecSchemaString}
@@ -49937,6 +50001,7 @@ const resolvers = {
49937
50001
  Mutation: mutationsResolvers,
49938
50002
  Query: queryResolvers,
49939
50003
  KeyValue: keyValueResolvers,
50004
+ KeyCount: keyCountResolvers,
49940
50005
  cv: cvResolvers,
49941
50006
  idParts: idPartsResolvers,
49942
50007
  Item: itemResolvers,