proskomma-core 0.10.9 → 0.10.11

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 +624 -593
  2. package/dist/index.mjs +624 -593
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1237,10 +1237,7 @@ function getAugmentedNamespace(n) {
1237
1237
  if (typeof f == "function") {
1238
1238
  var a = function a2() {
1239
1239
  if (this instanceof a2) {
1240
- var args = [null];
1241
- args.push.apply(args, arguments);
1242
- var Ctor = Function.bind.apply(f, args);
1243
- return new Ctor();
1240
+ return Reflect.construct(f, arguments, this.constructor);
1244
1241
  }
1245
1242
  return f.apply(this, arguments);
1246
1243
  };
@@ -1477,6 +1474,7 @@ var categories = [
1477
1474
  "bmp": "    -    "
1478
1475
  }
1479
1476
  ];
1477
+ const categories$1 = /* @__PURE__ */ getDefaultExportFromCjs(categories);
1480
1478
  /*!
1481
1479
  * XRegExp Unicode Categories 5.1.1
1482
1480
  * <xregexp.com>
@@ -1487,7 +1485,7 @@ const unicodeCategories = (XRegExp2) => {
1487
1485
  if (!XRegExp2.addUnicodeData) {
1488
1486
  throw new ReferenceError("Unicode Base must be loaded before Unicode Categories");
1489
1487
  }
1490
- XRegExp2.addUnicodeData(categories);
1488
+ XRegExp2.addUnicodeData(categories$1);
1491
1489
  };
1492
1490
  var properties$o = [
1493
1491
  {
@@ -1530,6 +1528,7 @@ var properties$o = [
1530
1528
  "bmp": " -\r …   - \u2028\u2029   "
1531
1529
  }
1532
1530
  ];
1531
+ const properties$p = /* @__PURE__ */ getDefaultExportFromCjs(properties$o);
1533
1532
  /*!
1534
1533
  * XRegExp Unicode Properties 5.1.1
1535
1534
  * <xregexp.com>
@@ -1540,7 +1539,7 @@ const unicodeProperties = (XRegExp2) => {
1540
1539
  if (!XRegExp2.addUnicodeData) {
1541
1540
  throw new ReferenceError("Unicode Base must be loaded before Unicode Properties");
1542
1541
  }
1543
- const unicodeData = properties$o;
1542
+ const unicodeData = properties$p;
1544
1543
  unicodeData.push({
1545
1544
  name: "Assigned",
1546
1545
  // Since this is defined as the inverse of Unicode category Cn (Unassigned), the Unicode
@@ -2211,6 +2210,7 @@ var scripts$1 = [
2211
2210
  "astral": "\uD806[\uDE00-\uDE47]"
2212
2211
  }
2213
2212
  ];
2213
+ const scripts$2 = /* @__PURE__ */ getDefaultExportFromCjs(scripts$1);
2214
2214
  /*!
2215
2215
  * XRegExp Unicode Scripts 5.1.1
2216
2216
  * <xregexp.com>
@@ -2221,7 +2221,7 @@ const unicodeScripts = (XRegExp2) => {
2221
2221
  if (!XRegExp2.addUnicodeData) {
2222
2222
  throw new ReferenceError("Unicode Base must be loaded before Unicode Scripts");
2223
2223
  }
2224
- XRegExp2.addUnicodeData(scripts$1, "Script");
2224
+ XRegExp2.addUnicodeData(scripts$2, "Script");
2225
2225
  };
2226
2226
  build(XRegExp);
2227
2227
  matchRecursive(XRegExp);
@@ -3380,8 +3380,7 @@ function getObjectTag$1(object) {
3380
3380
  const instanceOf = (
3381
3381
  /* c8 ignore next 6 */
3382
3382
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
3383
- // eslint-disable-next-line no-undef
3384
- process.env.NODE_ENV === "production" ? function instanceOf2(value, constructor) {
3383
+ globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function instanceOf2(value, constructor) {
3385
3384
  return value instanceof constructor;
3386
3385
  } : function instanceOf3(value, constructor) {
3387
3386
  if (value instanceof constructor) {
@@ -8852,7 +8851,7 @@ function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPai
8852
8851
  [node2]
8853
8852
  ];
8854
8853
  }
8855
- if (stringifyArguments(node1) !== stringifyArguments(node2)) {
8854
+ if (!sameArguments(node1, node2)) {
8856
8855
  return [
8857
8856
  [responseName, "they have differing arguments"],
8858
8857
  [node1],
@@ -8890,21 +8889,30 @@ function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPai
8890
8889
  return subfieldConflicts(conflicts, responseName, node1, node2);
8891
8890
  }
8892
8891
  }
8893
- function stringifyArguments(fieldNode) {
8894
- var _fieldNode$arguments;
8895
- const args = (
8896
- /* c8 ignore next */
8897
- (_fieldNode$arguments = fieldNode.arguments) !== null && _fieldNode$arguments !== void 0 ? _fieldNode$arguments : []
8898
- );
8899
- const inputObjectWithArgs = {
8900
- kind: Kind.OBJECT,
8901
- fields: args.map((argNode) => ({
8902
- kind: Kind.OBJECT_FIELD,
8903
- name: argNode.name,
8904
- value: argNode.value
8905
- }))
8906
- };
8907
- return print(sortValueNode(inputObjectWithArgs));
8892
+ function sameArguments(node1, node2) {
8893
+ const args1 = node1.arguments;
8894
+ const args2 = node2.arguments;
8895
+ if (args1 === void 0 || args1.length === 0) {
8896
+ return args2 === void 0 || args2.length === 0;
8897
+ }
8898
+ if (args2 === void 0 || args2.length === 0) {
8899
+ return false;
8900
+ }
8901
+ if (args1.length !== args2.length) {
8902
+ return false;
8903
+ }
8904
+ const values2 = new Map(args2.map(({ name: name2, value }) => [name2.value, value]));
8905
+ return args1.every((arg1) => {
8906
+ const value1 = arg1.value;
8907
+ const value2 = values2.get(arg1.name.value);
8908
+ if (value2 === void 0) {
8909
+ return false;
8910
+ }
8911
+ return stringifyValue(value1) === stringifyValue(value2);
8912
+ });
8913
+ }
8914
+ function stringifyValue(value) {
8915
+ return print(sortValueNode(value));
8908
8916
  }
8909
8917
  function doTypesConflict(type1, type2) {
8910
8918
  if (isListType(type1)) {
@@ -9605,7 +9613,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
9605
9613
  onError(
9606
9614
  new GraphQLError(prefix + "; " + error2.message, {
9607
9615
  nodes: varDefNode,
9608
- originalError: error2.originalError
9616
+ originalError: error2
9609
9617
  })
9610
9618
  );
9611
9619
  }
@@ -11011,21 +11019,30 @@ function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields
11011
11019
  function executeFields(exeContext, parentType, sourceValue, path, fields) {
11012
11020
  const results = /* @__PURE__ */ Object.create(null);
11013
11021
  let containsPromise = false;
11014
- for (const [responseName, fieldNodes] of fields.entries()) {
11015
- const fieldPath = addPath(path, responseName, parentType.name);
11016
- const result = executeField(
11017
- exeContext,
11018
- parentType,
11019
- sourceValue,
11020
- fieldNodes,
11021
- fieldPath
11022
- );
11023
- if (result !== void 0) {
11024
- results[responseName] = result;
11025
- if (isPromise(result)) {
11026
- containsPromise = true;
11022
+ try {
11023
+ for (const [responseName, fieldNodes] of fields.entries()) {
11024
+ const fieldPath = addPath(path, responseName, parentType.name);
11025
+ const result = executeField(
11026
+ exeContext,
11027
+ parentType,
11028
+ sourceValue,
11029
+ fieldNodes,
11030
+ fieldPath
11031
+ );
11032
+ if (result !== void 0) {
11033
+ results[responseName] = result;
11034
+ if (isPromise(result)) {
11035
+ containsPromise = true;
11036
+ }
11027
11037
  }
11028
11038
  }
11039
+ } catch (error2) {
11040
+ if (containsPromise) {
11041
+ return promiseForObject(results).finally(() => {
11042
+ throw error2;
11043
+ });
11044
+ }
11045
+ throw error2;
11029
11046
  }
11030
11047
  if (!containsPromise) {
11031
11048
  return results;
@@ -14116,17 +14133,19 @@ function mergeResolvers(resolversDefinitions, options2) {
14116
14133
  return result;
14117
14134
  }
14118
14135
  function mergeArguments$1(args1, args2, config) {
14119
- const result = deduplicateArguments([...args2, ...args1].filter(isSome));
14136
+ const result = deduplicateArguments([...args2, ...args1].filter(isSome), config);
14120
14137
  if (config && config.sort) {
14121
14138
  result.sort(compareNodes);
14122
14139
  }
14123
14140
  return result;
14124
14141
  }
14125
- function deduplicateArguments(args) {
14142
+ function deduplicateArguments(args, config) {
14126
14143
  return args.reduce((acc, current) => {
14127
- const dup = acc.find((arg) => arg.name.value === current.name.value);
14128
- if (!dup) {
14144
+ const dupIndex = acc.findIndex((arg) => arg.name.value === current.name.value);
14145
+ if (dupIndex === -1) {
14129
14146
  return acc.concat([current]);
14147
+ } else if (!(config === null || config === void 0 ? void 0 : config.reverseArguments)) {
14148
+ acc[dupIndex] = current;
14130
14149
  }
14131
14150
  return acc;
14132
14151
  }, []);
@@ -14134,6 +14153,10 @@ function deduplicateArguments(args) {
14134
14153
  function directiveAlreadyExists(directivesArr, otherDirective) {
14135
14154
  return !!directivesArr.find((directive) => directive.name.value === otherDirective.name.value);
14136
14155
  }
14156
+ function isRepeatableDirective(directive, directives) {
14157
+ var _a;
14158
+ return !!((_a = directives === null || directives === void 0 ? void 0 : directives[directive.name.value]) === null || _a === void 0 ? void 0 : _a.repeatable);
14159
+ }
14137
14160
  function nameAlreadyExists(name2, namesArr) {
14138
14161
  return namesArr.some(({ value }) => value === name2.value);
14139
14162
  }
@@ -14159,10 +14182,10 @@ function mergeArguments(a1, a2) {
14159
14182
  }
14160
14183
  return result;
14161
14184
  }
14162
- function deduplicateDirectives(directives) {
14185
+ function deduplicateDirectives(directives, definitions2) {
14163
14186
  return directives.map((directive, i, all) => {
14164
14187
  const firstAt = all.findIndex((d) => d.name.value === directive.name.value);
14165
- if (firstAt !== i) {
14188
+ if (firstAt !== i && !isRepeatableDirective(directive, definitions2)) {
14166
14189
  const dup = all[firstAt];
14167
14190
  directive.arguments = mergeArguments(directive.arguments, dup.arguments);
14168
14191
  return null;
@@ -14170,13 +14193,13 @@ function deduplicateDirectives(directives) {
14170
14193
  return directive;
14171
14194
  }).filter(isSome);
14172
14195
  }
14173
- function mergeDirectives(d1 = [], d2 = [], config) {
14196
+ function mergeDirectives(d1 = [], d2 = [], config, directives) {
14174
14197
  const reverseOrder = config && config.reverseDirectives;
14175
14198
  const asNext = reverseOrder ? d1 : d2;
14176
14199
  const asFirst = reverseOrder ? d2 : d1;
14177
- const result = deduplicateDirectives([...asNext]);
14200
+ const result = deduplicateDirectives([...asNext], directives);
14178
14201
  for (const directive of asFirst) {
14179
- if (directiveAlreadyExists(result, directive)) {
14202
+ if (directiveAlreadyExists(result, directive) && !isRepeatableDirective(directive, directives)) {
14180
14203
  const existingDirectiveIndex = result.findIndex((d) => d.name.value === directive.name.value);
14181
14204
  const existingDirective = result[existingDirectiveIndex];
14182
14205
  result[existingDirectiveIndex].arguments = mergeArguments(directive.arguments || [], existingDirective.arguments || []);
@@ -14196,8 +14219,8 @@ function validateInputs(node, existingNode) {
14196
14219
  description: void 0
14197
14220
  });
14198
14221
  const leaveInputs = new RegExp("(directive @w*d*)|( on .*$)", "g");
14199
- const sameArguments = printedNode.replace(leaveInputs, "") === printedExistingNode.replace(leaveInputs, "");
14200
- if (!sameArguments) {
14222
+ const sameArguments2 = printedNode.replace(leaveInputs, "") === printedExistingNode.replace(leaveInputs, "");
14223
+ if (!sameArguments2) {
14201
14224
  throw new Error(`Unable to merge GraphQL directive "${node.name.value}".
14202
14225
  Existing directive:
14203
14226
  ${printedExistingNode}
@@ -14221,7 +14244,7 @@ function mergeDirective(node, existingNode) {
14221
14244
  function deduplicateLists(source, target, filterFn) {
14222
14245
  return source.concat(target.filter((val) => filterFn(val, source)));
14223
14246
  }
14224
- function mergeEnumValues(first, second, config) {
14247
+ function mergeEnumValues(first, second, config, directives) {
14225
14248
  if (config === null || config === void 0 ? void 0 : config.consistentEnumMerge) {
14226
14249
  const reversed = [];
14227
14250
  if (first) {
@@ -14242,7 +14265,7 @@ function mergeEnumValues(first, second, config) {
14242
14265
  if (enumValueMap.has(enumValue)) {
14243
14266
  const firstValue = enumValueMap.get(enumValue);
14244
14267
  firstValue.description = secondValue.description || firstValue.description;
14245
- firstValue.directives = mergeDirectives(secondValue.directives, firstValue.directives);
14268
+ firstValue.directives = mergeDirectives(secondValue.directives, firstValue.directives, directives);
14246
14269
  } else {
14247
14270
  enumValueMap.set(enumValue, secondValue);
14248
14271
  }
@@ -14254,14 +14277,14 @@ function mergeEnumValues(first, second, config) {
14254
14277
  }
14255
14278
  return result;
14256
14279
  }
14257
- function mergeEnum(e1, e2, config) {
14280
+ function mergeEnum(e1, e2, config, directives) {
14258
14281
  if (e2) {
14259
14282
  return {
14260
14283
  name: e1.name,
14261
14284
  description: e1["description"] || e2["description"],
14262
14285
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || e1.kind === "EnumTypeDefinition" || e2.kind === "EnumTypeDefinition" ? "EnumTypeDefinition" : "EnumTypeExtension",
14263
14286
  loc: e1.loc,
14264
- directives: mergeDirectives(e1.directives, e2.directives, config),
14287
+ directives: mergeDirectives(e1.directives, e2.directives, config, directives),
14265
14288
  values: mergeEnumValues(e1.values, e2.values, config)
14266
14289
  };
14267
14290
  }
@@ -14323,39 +14346,24 @@ function defaultStringComparator(a, b) {
14323
14346
  return CompareVal.A_GREATER_THAN_B;
14324
14347
  return CompareVal.A_EQUALS_B;
14325
14348
  }
14326
- function fieldAlreadyExists(fieldsArr, otherField, config) {
14327
- const result = fieldsArr.find((field) => field.name.value === otherField.name.value);
14328
- if (result && !(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) {
14329
- const t1 = extractType(result.type);
14330
- const t2 = extractType(otherField.type);
14331
- if (t1.name.value !== t2.name.value) {
14332
- 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}"`);
14333
- }
14334
- }
14335
- return !!result;
14349
+ function fieldAlreadyExists(fieldsArr, otherField) {
14350
+ const resultIndex = fieldsArr.findIndex((field) => field.name.value === otherField.name.value);
14351
+ return [resultIndex > -1 ? fieldsArr[resultIndex] : null, resultIndex];
14336
14352
  }
14337
- function mergeFields(type2, f1, f2, config) {
14353
+ function mergeFields(type2, f1, f2, config, directives) {
14338
14354
  const result = [];
14339
14355
  if (f2 != null) {
14340
14356
  result.push(...f2);
14341
14357
  }
14342
14358
  if (f1 != null) {
14343
14359
  for (const field of f1) {
14344
- if (fieldAlreadyExists(result, field, config)) {
14345
- const existing = result.find((f) => f.name.value === field.name.value);
14346
- if (!(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) {
14347
- if (config === null || config === void 0 ? void 0 : config.throwOnConflict) {
14348
- preventConflicts(type2, existing, field, false);
14349
- } else {
14350
- preventConflicts(type2, existing, field, true);
14351
- }
14352
- if (isNonNullTypeNode(field.type) && !isNonNullTypeNode(existing.type)) {
14353
- existing.type = field.type;
14354
- }
14355
- }
14356
- existing.arguments = mergeArguments$1(field["arguments"] || [], existing.arguments || [], config);
14357
- existing.directives = mergeDirectives(field.directives, existing.directives, config);
14358
- existing.description = field.description || existing.description;
14360
+ const [existing, existingIndex] = fieldAlreadyExists(result, field);
14361
+ if (existing && !(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) {
14362
+ 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);
14363
+ newField.arguments = mergeArguments$1(field["arguments"] || [], existing["arguments"] || [], config);
14364
+ newField.directives = mergeDirectives(field.directives, existing.directives, config, directives);
14365
+ newField.description = field.description || existing.description;
14366
+ result[existingIndex] = newField;
14359
14367
  } else {
14360
14368
  result.push(field);
14361
14369
  }
@@ -14373,9 +14381,20 @@ function mergeFields(type2, f1, f2, config) {
14373
14381
  function preventConflicts(type2, a, b, ignoreNullability = false) {
14374
14382
  const aType = printTypeNode(a.type);
14375
14383
  const bType = printTypeNode(b.type);
14376
- if (aType !== bType && !safeChangeForFieldType(a.type, b.type, ignoreNullability)) {
14377
- throw new Error(`Field '${type2.name.value}.${a.name.value}' changed type from '${aType}' to '${bType}'`);
14384
+ if (aType !== bType) {
14385
+ const t1 = extractType(a.type);
14386
+ const t2 = extractType(b.type);
14387
+ if (t1.name.value !== t2.name.value) {
14388
+ 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}"`);
14389
+ }
14390
+ if (!safeChangeForFieldType(a.type, b.type, !ignoreNullability)) {
14391
+ throw new Error(`Field '${type2.name.value}.${a.name.value}' changed type from '${aType}' to '${bType}'`);
14392
+ }
14378
14393
  }
14394
+ if (isNonNullTypeNode(b.type) && !isNonNullTypeNode(a.type)) {
14395
+ a.type = b.type;
14396
+ }
14397
+ return a;
14379
14398
  }
14380
14399
  function safeChangeForFieldType(oldType, newType, ignoreNullability = false) {
14381
14400
  if (!isWrappingTypeNode(oldType) && !isWrappingTypeNode(newType)) {
@@ -14393,7 +14412,7 @@ function safeChangeForFieldType(oldType, newType, ignoreNullability = false) {
14393
14412
  }
14394
14413
  return false;
14395
14414
  }
14396
- function mergeInputType(node, existingNode, config) {
14415
+ function mergeInputType(node, existingNode, config, directives) {
14397
14416
  if (existingNode) {
14398
14417
  try {
14399
14418
  return {
@@ -14402,7 +14421,7 @@ function mergeInputType(node, existingNode, config) {
14402
14421
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "InputObjectTypeDefinition" || existingNode.kind === "InputObjectTypeDefinition" ? "InputObjectTypeDefinition" : "InputObjectTypeExtension",
14403
14422
  loc: node.loc,
14404
14423
  fields: mergeFields(node, node.fields, existingNode.fields, config),
14405
- directives: mergeDirectives(node.directives, existingNode.directives, config)
14424
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives)
14406
14425
  };
14407
14426
  } catch (e) {
14408
14427
  throw new Error(`Unable to merge GraphQL input type "${node.name.value}": ${e.message}`);
@@ -14423,7 +14442,7 @@ function mergeNamedTypeArray(first = [], second = [], config = {}) {
14423
14442
  }
14424
14443
  return result;
14425
14444
  }
14426
- function mergeInterface(node, existingNode, config) {
14445
+ function mergeInterface(node, existingNode, config, directives) {
14427
14446
  if (existingNode) {
14428
14447
  try {
14429
14448
  return {
@@ -14432,7 +14451,7 @@ function mergeInterface(node, existingNode, config) {
14432
14451
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "InterfaceTypeDefinition" || existingNode.kind === "InterfaceTypeDefinition" ? "InterfaceTypeDefinition" : "InterfaceTypeExtension",
14433
14452
  loc: node.loc,
14434
14453
  fields: mergeFields(node, node.fields, existingNode.fields, config),
14435
- directives: mergeDirectives(node.directives, existingNode.directives, config),
14454
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives),
14436
14455
  interfaces: node["interfaces"] ? mergeNamedTypeArray(node["interfaces"], existingNode["interfaces"], config) : void 0
14437
14456
  };
14438
14457
  } catch (e) {
@@ -14444,7 +14463,7 @@ function mergeInterface(node, existingNode, config) {
14444
14463
  kind: Kind.INTERFACE_TYPE_DEFINITION
14445
14464
  } : node;
14446
14465
  }
14447
- function mergeType(node, existingNode, config) {
14466
+ function mergeType(node, existingNode, config, directives) {
14448
14467
  if (existingNode) {
14449
14468
  try {
14450
14469
  return {
@@ -14453,7 +14472,7 @@ function mergeType(node, existingNode, config) {
14453
14472
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "ObjectTypeDefinition" || existingNode.kind === "ObjectTypeDefinition" ? "ObjectTypeDefinition" : "ObjectTypeExtension",
14454
14473
  loc: node.loc,
14455
14474
  fields: mergeFields(node, node.fields, existingNode.fields, config),
14456
- directives: mergeDirectives(node.directives, existingNode.directives, config),
14475
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives),
14457
14476
  interfaces: mergeNamedTypeArray(node.interfaces, existingNode.interfaces, config)
14458
14477
  };
14459
14478
  } catch (e) {
@@ -14465,14 +14484,14 @@ function mergeType(node, existingNode, config) {
14465
14484
  kind: Kind.OBJECT_TYPE_DEFINITION
14466
14485
  } : node;
14467
14486
  }
14468
- function mergeScalar(node, existingNode, config) {
14487
+ function mergeScalar(node, existingNode, config, directives) {
14469
14488
  if (existingNode) {
14470
14489
  return {
14471
14490
  name: node.name,
14472
14491
  description: node["description"] || existingNode["description"],
14473
14492
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "ScalarTypeDefinition" || existingNode.kind === "ScalarTypeDefinition" ? "ScalarTypeDefinition" : "ScalarTypeExtension",
14474
14493
  loc: node.loc,
14475
- directives: mergeDirectives(node.directives, existingNode.directives, config)
14494
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives)
14476
14495
  };
14477
14496
  }
14478
14497
  return (config === null || config === void 0 ? void 0 : config.convertExtensions) ? {
@@ -14480,13 +14499,13 @@ function mergeScalar(node, existingNode, config) {
14480
14499
  kind: Kind.SCALAR_TYPE_DEFINITION
14481
14500
  } : node;
14482
14501
  }
14483
- function mergeUnion(first, second, config) {
14502
+ function mergeUnion(first, second, config, directives) {
14484
14503
  if (second) {
14485
14504
  return {
14486
14505
  name: first.name,
14487
14506
  description: first["description"] || second["description"],
14488
14507
  // ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility
14489
- directives: mergeDirectives(first.directives, second.directives, config),
14508
+ directives: mergeDirectives(first.directives, second.directives, config, directives),
14490
14509
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || first.kind === "UnionTypeDefinition" || second.kind === "UnionTypeDefinition" ? Kind.UNION_TYPE_DEFINITION : Kind.UNION_TYPE_EXTENSION,
14491
14510
  loc: first.loc,
14492
14511
  types: mergeNamedTypeArray(first.types, second.types, config)
@@ -14512,12 +14531,12 @@ function mergeOperationTypes(opNodeList = [], existingOpNodeList = []) {
14512
14531
  }
14513
14532
  return finalOpNodeList;
14514
14533
  }
14515
- function mergeSchemaDefs(node, existingNode, config) {
14534
+ function mergeSchemaDefs(node, existingNode, config, directives) {
14516
14535
  if (existingNode) {
14517
14536
  return {
14518
14537
  kind: node.kind === Kind.SCHEMA_DEFINITION || existingNode.kind === Kind.SCHEMA_DEFINITION ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
14519
14538
  description: node["description"] || existingNode["description"],
14520
- directives: mergeDirectives(node.directives, existingNode.directives, config),
14539
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives),
14521
14540
  operationTypes: mergeOperationTypes(node.operationTypes, existingNode.operationTypes)
14522
14541
  };
14523
14542
  }
@@ -14530,9 +14549,9 @@ const schemaDefSymbol = "SCHEMA_DEF_SYMBOL";
14530
14549
  function isNamedDefinitionNode(definitionNode) {
14531
14550
  return "name" in definitionNode;
14532
14551
  }
14533
- function mergeGraphQLNodes(nodes, config) {
14552
+ function mergeGraphQLNodes(nodes, config, directives = {}) {
14534
14553
  var _a, _b, _c;
14535
- const mergedResultMap = {};
14554
+ const mergedResultMap = directives;
14536
14555
  for (const nodeDefinition of nodes) {
14537
14556
  if (isNamedDefinitionNode(nodeDefinition)) {
14538
14557
  const name2 = (_a = nodeDefinition.name) === null || _a === void 0 ? void 0 : _a.value;
@@ -14548,27 +14567,27 @@ function mergeGraphQLNodes(nodes, config) {
14548
14567
  switch (nodeDefinition.kind) {
14549
14568
  case Kind.OBJECT_TYPE_DEFINITION:
14550
14569
  case Kind.OBJECT_TYPE_EXTENSION:
14551
- mergedResultMap[name2] = mergeType(nodeDefinition, mergedResultMap[name2], config);
14570
+ mergedResultMap[name2] = mergeType(nodeDefinition, mergedResultMap[name2], config, directives);
14552
14571
  break;
14553
14572
  case Kind.ENUM_TYPE_DEFINITION:
14554
14573
  case Kind.ENUM_TYPE_EXTENSION:
14555
- mergedResultMap[name2] = mergeEnum(nodeDefinition, mergedResultMap[name2], config);
14574
+ mergedResultMap[name2] = mergeEnum(nodeDefinition, mergedResultMap[name2], config, directives);
14556
14575
  break;
14557
14576
  case Kind.UNION_TYPE_DEFINITION:
14558
14577
  case Kind.UNION_TYPE_EXTENSION:
14559
- mergedResultMap[name2] = mergeUnion(nodeDefinition, mergedResultMap[name2], config);
14578
+ mergedResultMap[name2] = mergeUnion(nodeDefinition, mergedResultMap[name2], config, directives);
14560
14579
  break;
14561
14580
  case Kind.SCALAR_TYPE_DEFINITION:
14562
14581
  case Kind.SCALAR_TYPE_EXTENSION:
14563
- mergedResultMap[name2] = mergeScalar(nodeDefinition, mergedResultMap[name2], config);
14582
+ mergedResultMap[name2] = mergeScalar(nodeDefinition, mergedResultMap[name2], config, directives);
14564
14583
  break;
14565
14584
  case Kind.INPUT_OBJECT_TYPE_DEFINITION:
14566
14585
  case Kind.INPUT_OBJECT_TYPE_EXTENSION:
14567
- mergedResultMap[name2] = mergeInputType(nodeDefinition, mergedResultMap[name2], config);
14586
+ mergedResultMap[name2] = mergeInputType(nodeDefinition, mergedResultMap[name2], config, directives);
14568
14587
  break;
14569
14588
  case Kind.INTERFACE_TYPE_DEFINITION:
14570
14589
  case Kind.INTERFACE_TYPE_EXTENSION:
14571
- mergedResultMap[name2] = mergeInterface(nodeDefinition, mergedResultMap[name2], config);
14590
+ mergedResultMap[name2] = mergeInterface(nodeDefinition, mergedResultMap[name2], config, directives);
14572
14591
  break;
14573
14592
  case Kind.DIRECTIVE_DEFINITION:
14574
14593
  mergedResultMap[name2] = mergeDirective(nodeDefinition, mergedResultMap[name2]);
@@ -14602,36 +14621,41 @@ function mergeTypeDefs(typeSource, config) {
14602
14621
  resetComments();
14603
14622
  return result;
14604
14623
  }
14605
- function visitTypeSources(typeSource, options2, allNodes = [], visitedTypeSources = /* @__PURE__ */ new Set()) {
14624
+ function visitTypeSources(typeSource, options2, allDirectives = [], allNodes = [], visitedTypeSources = /* @__PURE__ */ new Set()) {
14606
14625
  if (typeSource && !visitedTypeSources.has(typeSource)) {
14607
14626
  visitedTypeSources.add(typeSource);
14608
14627
  if (typeof typeSource === "function") {
14609
- visitTypeSources(typeSource(), options2, allNodes, visitedTypeSources);
14628
+ visitTypeSources(typeSource(), options2, allDirectives, allNodes, visitedTypeSources);
14610
14629
  } else if (Array.isArray(typeSource)) {
14611
14630
  for (const type2 of typeSource) {
14612
- visitTypeSources(type2, options2, allNodes, visitedTypeSources);
14631
+ visitTypeSources(type2, options2, allDirectives, allNodes, visitedTypeSources);
14613
14632
  }
14614
14633
  } else if (isSchema(typeSource)) {
14615
14634
  const documentNode = getDocumentNodeFromSchema(typeSource, options2);
14616
- visitTypeSources(documentNode.definitions, options2, allNodes, visitedTypeSources);
14635
+ visitTypeSources(documentNode.definitions, options2, allDirectives, allNodes, visitedTypeSources);
14617
14636
  } else if (isStringTypes(typeSource) || isSourceTypes(typeSource)) {
14618
14637
  const documentNode = parse(typeSource, options2);
14619
- visitTypeSources(documentNode.definitions, options2, allNodes, visitedTypeSources);
14638
+ visitTypeSources(documentNode.definitions, options2, allDirectives, allNodes, visitedTypeSources);
14620
14639
  } else if (typeof typeSource === "object" && isDefinitionNode(typeSource)) {
14621
- allNodes.push(typeSource);
14640
+ if (typeSource.kind === Kind.DIRECTIVE_DEFINITION) {
14641
+ allDirectives.push(typeSource);
14642
+ } else {
14643
+ allNodes.push(typeSource);
14644
+ }
14622
14645
  } else if (isDocumentNode(typeSource)) {
14623
- visitTypeSources(typeSource.definitions, options2, allNodes, visitedTypeSources);
14646
+ visitTypeSources(typeSource.definitions, options2, allDirectives, allNodes, visitedTypeSources);
14624
14647
  } else {
14625
14648
  throw new Error(`typeDefs must contain only strings, documents, schemas, or functions, got ${typeof typeSource}`);
14626
14649
  }
14627
14650
  }
14628
- return allNodes;
14651
+ return { allDirectives, allNodes };
14629
14652
  }
14630
14653
  function mergeGraphQLTypes(typeSource, config) {
14631
14654
  var _a, _b, _c;
14632
14655
  resetComments();
14633
- const allNodes = visitTypeSources(typeSource, config);
14634
- const mergedNodes = mergeGraphQLNodes(allNodes, config);
14656
+ const { allDirectives, allNodes } = visitTypeSources(typeSource, config);
14657
+ const mergedDirectives = mergeGraphQLNodes(allDirectives, config);
14658
+ const mergedNodes = mergeGraphQLNodes(allNodes, config, mergedDirectives);
14635
14659
  if (config === null || config === void 0 ? void 0 : config.useSchemaDefinition) {
14636
14660
  const schemaDef = mergedNodes[schemaDefSymbol] || {
14637
14661
  kind: Kind.SCHEMA_DEFINITION,
@@ -14934,17 +14958,8 @@ class Mutex {
14934
14958
  return this._semaphore.cancel();
14935
14959
  }
14936
14960
  }
14937
- var easyCrc32Exports = {};
14938
- var easyCrc32$1 = {
14939
- get exports() {
14940
- return easyCrc32Exports;
14941
- },
14942
- set exports(v) {
14943
- easyCrc32Exports = v;
14944
- }
14945
- };
14946
- var easyCrc32 = {};
14947
- easyCrc32.calculate = function(str) {
14961
+ var easyCrc32$1 = {};
14962
+ easyCrc32$1.calculate = function(str) {
14948
14963
  if (str == null)
14949
14964
  return null;
14950
14965
  var utf8CharCodes = utf8encode(str), crc = -1;
@@ -15227,19 +15242,9 @@ var crcTable = [
15227
15242
  1510334235,
15228
15243
  755167117
15229
15244
  ];
15230
- (function(module2) {
15231
- module2.exports = easyCrc32;
15232
- })(easyCrc32$1);
15233
- const crc32 = /* @__PURE__ */ getDefaultExportFromCjs(easyCrc32Exports);
15234
- var bitsetExports = {};
15235
- var bitset = {
15236
- get exports() {
15237
- return bitsetExports;
15238
- },
15239
- set exports(v) {
15240
- bitsetExports = v;
15241
- }
15242
- };
15245
+ var easyCrc32 = easyCrc32$1;
15246
+ const crc32 = /* @__PURE__ */ getDefaultExportFromCjs(easyCrc32);
15247
+ var bitset = { exports: {} };
15243
15248
  /**
15244
15249
  * @license BitSet.js v5.1.1 2/1/2020
15245
15250
  * http://www.xarg.org/2014/03/javascript-bit-array/
@@ -15983,10 +15988,11 @@ var bitset = {
15983
15988
  module2["exports"] = BitSet2;
15984
15989
  }
15985
15990
  })();
15986
- })(bitset, bitsetExports);
15991
+ })(bitset, bitset.exports);
15992
+ var bitsetExports = bitset.exports;
15987
15993
  const BitSet = /* @__PURE__ */ getDefaultExportFromCjs(bitsetExports);
15988
15994
  const name = "proskomma-core";
15989
- const version = "0.10.9";
15995
+ const version = "0.10.11";
15990
15996
  const description$b = "A Scripture Runtime Engine";
15991
15997
  const files = [
15992
15998
  "dist"
@@ -16580,18 +16586,10 @@ const enumRegexIndexTuples = (enumSuccinct, regex) => {
16580
16586
  return ret;
16581
16587
  };
16582
16588
  const enums = { enumStringIndex, enumRegexIndexTuples };
16583
- var uuidExports = {};
16584
- var uuid = {
16585
- get exports() {
16586
- return uuidExports;
16587
- },
16588
- set exports(v) {
16589
- uuidExports = v;
16590
- }
16591
- };
16589
+ var uuid = { exports: {} };
16592
16590
  /*!
16593
16591
  ** Pure-UUID -- Pure JavaScript Based Universally Unique Identifier (UUID)
16594
- ** Copyright (c) 2004-2021 Dr. Ralf S. Engelschall <rse@engelschall.com>
16592
+ ** Copyright (c) 2004-2023 Dr. Ralf S. Engelschall <rse@engelschall.com>
16595
16593
  **
16596
16594
  ** Permission is hereby granted, free of charge, to any person obtaining
16597
16595
  ** a copy of this software and associated documentation files (the
@@ -17159,7 +17157,21 @@ var uuid = {
17159
17157
  this.state = ui64_clone(this.inc);
17160
17158
  this.next();
17161
17159
  ui64_and(this.state, this.mask);
17162
- seed = ui64_n2i(seed !== void 0 ? seed >>> 0 : Math.random() * 4294967295 >>> 0);
17160
+ var arr;
17161
+ if (seed !== void 0)
17162
+ seed = ui64_n2i(seed >>> 0);
17163
+ else if (typeof window === "object" && typeof window.crypto === "object" && typeof window.crypto.getRandomValues === "function") {
17164
+ arr = new Uint32Array(2);
17165
+ window.crypto.getRandomValues(arr);
17166
+ seed = ui64_or(ui64_n2i(arr[0] >>> 0), ui64_ror(ui64_n2i(arr[1] >>> 0), 32));
17167
+ } else if (typeof globalThis === "object" && typeof globalThis.crypto === "object" && typeof globalThis.crypto.getRandomValues === "function") {
17168
+ arr = new Uint32Array(2);
17169
+ globalThis.crypto.getRandomValues(arr);
17170
+ seed = ui64_or(ui64_n2i(arr[0] >>> 0), ui64_ror(ui64_n2i(arr[1] >>> 0), 32));
17171
+ } else {
17172
+ seed = ui64_n2i(Math.random() * 4294967295 >>> 0);
17173
+ ui64_or(seed, ui64_ror(ui64_n2i((/* @__PURE__ */ new Date()).getTime()), 32));
17174
+ }
17163
17175
  ui64_or(this.state, seed);
17164
17176
  this.next();
17165
17177
  };
@@ -17181,7 +17193,17 @@ var uuid = {
17181
17193
  ui64_xor(output, output2);
17182
17194
  return ui64_i2n(output);
17183
17195
  };
17196
+ PCG.prototype.reseed = function(seed) {
17197
+ if (typeof seed !== "string")
17198
+ throw new Error("UUID: PCG: seed: invalid argument (string expected)");
17199
+ var arr = sha1_core(s2a(seed, { ibits: 8, obits: 32, obigendian: true }), seed.length * 8);
17200
+ for (var i = 0; i < arr.length; i++)
17201
+ ui64_xor(pcg.state, ui64_n2i(arr[i] >>> 0));
17202
+ };
17184
17203
  var pcg = new PCG();
17204
+ PCG.reseed = function(seed) {
17205
+ pcg.reseed(seed);
17206
+ };
17185
17207
  var prng = function(len, radix) {
17186
17208
  var bytes = [];
17187
17209
  for (var i = 0; i < len; i++)
@@ -17212,7 +17234,7 @@ var uuid = {
17212
17234
  var i;
17213
17235
  var uuid2 = this;
17214
17236
  if (version2 === 1) {
17215
- var date = new Date();
17237
+ var date = /* @__PURE__ */ new Date();
17216
17238
  var time_now = date.getTime();
17217
17239
  if (time_now !== time_last)
17218
17240
  time_seq = 0;
@@ -17383,17 +17405,11 @@ var uuid = {
17383
17405
  return UUID2;
17384
17406
  });
17385
17407
  })(uuid);
17386
- const UUID = uuidExports;
17387
- var base64Exports = {};
17388
- var base64$1 = {
17389
- get exports() {
17390
- return base64Exports;
17391
- },
17392
- set exports(v) {
17393
- base64Exports = v;
17394
- }
17395
- };
17408
+ var uuidExports = uuid.exports;
17409
+ const UUID = /* @__PURE__ */ getDefaultExportFromCjs(uuidExports);
17410
+ var base64$1 = { exports: {} };
17396
17411
  /*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */
17412
+ base64$1.exports;
17397
17413
  (function(module2, exports2) {
17398
17414
  (function(root) {
17399
17415
  var freeExports = exports2;
@@ -17491,8 +17507,9 @@ var base64$1 = {
17491
17507
  root.base64 = base642;
17492
17508
  }
17493
17509
  })(commonjsGlobal);
17494
- })(base64$1, base64Exports);
17495
- const base64 = base64Exports;
17510
+ })(base64$1, base64$1.exports);
17511
+ var base64Exports = base64$1.exports;
17512
+ const base64 = /* @__PURE__ */ getDefaultExportFromCjs(base64Exports);
17496
17513
  const generateId = () => base64.encode(new UUID(4)).substring(0, 12);
17497
17514
  const graftLocation = {
17498
17515
  heading: "block",
@@ -18834,19 +18851,37 @@ const unsuccinctifyItemsWithScriptureCV = (docSet, block2, cv, options2) => {
18834
18851
  }
18835
18852
  };
18836
18853
  const ret = [];
18837
- for (const item of docSet.unsuccinctifyItems(
18838
- block2.c,
18839
- {},
18840
- block2.nt.nByte(0)
18841
- )) {
18842
- if (item[0] === "scope" && item[1] === "start") {
18843
- openScopes.add(item[2]);
18844
- }
18845
- if (itemMatchesCV() && itemInOptions(item)) {
18846
- ret.push(item);
18854
+ if (options2.excludeScopeTypes) {
18855
+ for (const item of docSet.unsuccinctifyItems(
18856
+ block2.c,
18857
+ options2,
18858
+ block2.nt.nByte(0)
18859
+ )) {
18860
+ if (item[0] === "scope" && item[1] === "start") {
18861
+ openScopes.add(item[2]);
18862
+ }
18863
+ if (itemMatchesCV() && itemInOptions(item)) {
18864
+ ret.push(item);
18865
+ }
18866
+ if (item[0] === "scope" && item[1] === "end") {
18867
+ openScopes.delete(item[2]);
18868
+ }
18847
18869
  }
18848
- if (item[0] === "scope" && item[1] === "end") {
18849
- openScopes.delete(item[2]);
18870
+ } else {
18871
+ for (const item of docSet.unsuccinctifyItems(
18872
+ block2.c,
18873
+ {},
18874
+ block2.nt.nByte(0)
18875
+ )) {
18876
+ if (item[0] === "scope" && item[1] === "start") {
18877
+ openScopes.add(item[2]);
18878
+ }
18879
+ if (itemMatchesCV() && itemInOptions(item)) {
18880
+ ret.push(item);
18881
+ }
18882
+ if (item[0] === "scope" && item[1] === "end") {
18883
+ openScopes.delete(item[2]);
18884
+ }
18850
18885
  }
18851
18886
  }
18852
18887
  return ret;
@@ -19705,15 +19740,7 @@ class DocSet {
19705
19740
  return crc32.calculate(docIdsString);
19706
19741
  }
19707
19742
  }
19708
- var ajvExports = {};
19709
- var ajv = {
19710
- get exports() {
19711
- return ajvExports;
19712
- },
19713
- set exports(v) {
19714
- ajvExports = v;
19715
- }
19716
- };
19743
+ var ajv = { exports: {} };
19717
19744
  var core$2 = {};
19718
19745
  var validate = {};
19719
19746
  var boolSchema = {};
@@ -19884,7 +19911,7 @@ var scope = {};
19884
19911
  (function(UsedValueState2) {
19885
19912
  UsedValueState2[UsedValueState2["Started"] = 0] = "Started";
19886
19913
  UsedValueState2[UsedValueState2["Completed"] = 1] = "Completed";
19887
- })(UsedValueState = exports2.UsedValueState || (exports2.UsedValueState = {}));
19914
+ })(UsedValueState || (exports2.UsedValueState = UsedValueState = {}));
19888
19915
  exports2.varKinds = {
19889
19916
  const: new code_12.Name("const"),
19890
19917
  let: new code_12.Name("let"),
@@ -20726,193 +20753,197 @@ var scope = {};
20726
20753
  }
20727
20754
  })(codegen);
20728
20755
  var util = {};
20729
- (function(exports2) {
20730
- Object.defineProperty(exports2, "__esModule", { value: true });
20731
- 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;
20732
- const codegen_12 = codegen;
20733
- const code_12 = code$1;
20734
- function toHash(arr) {
20735
- const hash = {};
20736
- for (const item of arr)
20737
- hash[item] = true;
20738
- return hash;
20739
- }
20740
- exports2.toHash = toHash;
20741
- function alwaysValidSchema(it, schema) {
20742
- if (typeof schema == "boolean")
20743
- return schema;
20744
- if (Object.keys(schema).length === 0)
20745
- return true;
20746
- checkUnknownRules(it, schema);
20747
- return !schemaHasRules(schema, it.self.RULES.all);
20748
- }
20749
- exports2.alwaysValidSchema = alwaysValidSchema;
20750
- function checkUnknownRules(it, schema = it.schema) {
20751
- const { opts, self: self2 } = it;
20752
- if (!opts.strictSchema)
20753
- return;
20754
- if (typeof schema === "boolean")
20755
- return;
20756
- const rules2 = self2.RULES.keywords;
20757
- for (const key in schema) {
20758
- if (!rules2[key])
20759
- checkStrictMode(it, `unknown keyword: "${key}"`);
20760
- }
20761
- }
20762
- exports2.checkUnknownRules = checkUnknownRules;
20763
- function schemaHasRules(schema, rules2) {
20764
- if (typeof schema == "boolean")
20765
- return !schema;
20766
- for (const key in schema)
20767
- if (rules2[key])
20768
- return true;
20769
- return false;
20770
- }
20771
- exports2.schemaHasRules = schemaHasRules;
20772
- function schemaHasRulesButRef(schema, RULES) {
20773
- if (typeof schema == "boolean")
20774
- return !schema;
20775
- for (const key in schema)
20776
- if (key !== "$ref" && RULES.all[key])
20777
- return true;
20778
- return false;
20756
+ Object.defineProperty(util, "__esModule", { value: true });
20757
+ 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;
20758
+ const codegen_1$v = codegen;
20759
+ const code_1$a = code$1;
20760
+ function toHash(arr) {
20761
+ const hash = {};
20762
+ for (const item of arr)
20763
+ hash[item] = true;
20764
+ return hash;
20765
+ }
20766
+ util.toHash = toHash;
20767
+ function alwaysValidSchema(it, schema) {
20768
+ if (typeof schema == "boolean")
20769
+ return schema;
20770
+ if (Object.keys(schema).length === 0)
20771
+ return true;
20772
+ checkUnknownRules(it, schema);
20773
+ return !schemaHasRules(schema, it.self.RULES.all);
20774
+ }
20775
+ util.alwaysValidSchema = alwaysValidSchema;
20776
+ function checkUnknownRules(it, schema = it.schema) {
20777
+ const { opts, self: self2 } = it;
20778
+ if (!opts.strictSchema)
20779
+ return;
20780
+ if (typeof schema === "boolean")
20781
+ return;
20782
+ const rules2 = self2.RULES.keywords;
20783
+ for (const key in schema) {
20784
+ if (!rules2[key])
20785
+ checkStrictMode(it, `unknown keyword: "${key}"`);
20779
20786
  }
20780
- exports2.schemaHasRulesButRef = schemaHasRulesButRef;
20781
- function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
20782
- if (!$data) {
20783
- if (typeof schema == "number" || typeof schema == "boolean")
20784
- return schema;
20785
- if (typeof schema == "string")
20786
- return (0, codegen_12._)`${schema}`;
20787
- }
20788
- return (0, codegen_12._)`${topSchemaRef}${schemaPath}${(0, codegen_12.getProperty)(keyword2)}`;
20789
- }
20790
- exports2.schemaRefOrVal = schemaRefOrVal;
20791
- function unescapeFragment(str) {
20792
- return unescapeJsonPointer(decodeURIComponent(str));
20793
- }
20794
- exports2.unescapeFragment = unescapeFragment;
20795
- function escapeFragment(str) {
20796
- return encodeURIComponent(escapeJsonPointer(str));
20797
- }
20798
- exports2.escapeFragment = escapeFragment;
20799
- function escapeJsonPointer(str) {
20800
- if (typeof str == "number")
20801
- return `${str}`;
20802
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
20803
- }
20804
- exports2.escapeJsonPointer = escapeJsonPointer;
20805
- function unescapeJsonPointer(str) {
20806
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
20807
- }
20808
- exports2.unescapeJsonPointer = unescapeJsonPointer;
20809
- function eachItem(xs, f) {
20810
- if (Array.isArray(xs)) {
20811
- for (const x of xs)
20812
- f(x);
20813
- } else {
20814
- f(xs);
20815
- }
20787
+ }
20788
+ util.checkUnknownRules = checkUnknownRules;
20789
+ function schemaHasRules(schema, rules2) {
20790
+ if (typeof schema == "boolean")
20791
+ return !schema;
20792
+ for (const key in schema)
20793
+ if (rules2[key])
20794
+ return true;
20795
+ return false;
20796
+ }
20797
+ util.schemaHasRules = schemaHasRules;
20798
+ function schemaHasRulesButRef(schema, RULES) {
20799
+ if (typeof schema == "boolean")
20800
+ return !schema;
20801
+ for (const key in schema)
20802
+ if (key !== "$ref" && RULES.all[key])
20803
+ return true;
20804
+ return false;
20805
+ }
20806
+ util.schemaHasRulesButRef = schemaHasRulesButRef;
20807
+ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
20808
+ if (!$data) {
20809
+ if (typeof schema == "number" || typeof schema == "boolean")
20810
+ return schema;
20811
+ if (typeof schema == "string")
20812
+ return (0, codegen_1$v._)`${schema}`;
20816
20813
  }
20817
- exports2.eachItem = eachItem;
20818
- function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
20819
- return (gen, from, to, toName) => {
20820
- 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);
20821
- return toName === codegen_12.Name && !(res instanceof codegen_12.Name) ? resultToName(gen, res) : res;
20822
- };
20814
+ return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
20815
+ }
20816
+ util.schemaRefOrVal = schemaRefOrVal;
20817
+ function unescapeFragment(str) {
20818
+ return unescapeJsonPointer(decodeURIComponent(str));
20819
+ }
20820
+ util.unescapeFragment = unescapeFragment;
20821
+ function escapeFragment(str) {
20822
+ return encodeURIComponent(escapeJsonPointer(str));
20823
+ }
20824
+ util.escapeFragment = escapeFragment;
20825
+ function escapeJsonPointer(str) {
20826
+ if (typeof str == "number")
20827
+ return `${str}`;
20828
+ return str.replace(/~/g, "~0").replace(/\//g, "~1");
20829
+ }
20830
+ util.escapeJsonPointer = escapeJsonPointer;
20831
+ function unescapeJsonPointer(str) {
20832
+ return str.replace(/~1/g, "/").replace(/~0/g, "~");
20833
+ }
20834
+ util.unescapeJsonPointer = unescapeJsonPointer;
20835
+ function eachItem(xs, f) {
20836
+ if (Array.isArray(xs)) {
20837
+ for (const x of xs)
20838
+ f(x);
20839
+ } else {
20840
+ f(xs);
20823
20841
  }
20824
- exports2.mergeEvaluated = {
20825
- props: makeMergeEvaluated({
20826
- mergeNames: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true && ${from} !== undefined`, () => {
20827
- 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})`));
20828
- }),
20829
- mergeToName: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true`, () => {
20830
- if (from === true) {
20831
- gen.assign(to, true);
20832
- } else {
20833
- gen.assign(to, (0, codegen_12._)`${to} || {}`);
20834
- setEvaluated(gen, to, from);
20835
- }
20836
- }),
20837
- mergeValues: (from, to) => from === true ? true : { ...from, ...to },
20838
- resultToName: evaluatedPropsToName
20839
- }),
20840
- items: makeMergeEvaluated({
20841
- 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}`)),
20842
- mergeToName: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_12._)`${to} > ${from} ? ${to} : ${from}`)),
20843
- mergeValues: (from, to) => from === true ? true : Math.max(from, to),
20844
- resultToName: (gen, items2) => gen.var("items", items2)
20845
- })
20842
+ }
20843
+ util.eachItem = eachItem;
20844
+ function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
20845
+ return (gen, from, to, toName) => {
20846
+ 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);
20847
+ return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
20846
20848
  };
20847
- function evaluatedPropsToName(gen, ps) {
20848
- if (ps === true)
20849
- return gen.var("props", true);
20850
- const props = gen.var("props", (0, codegen_12._)`{}`);
20851
- if (ps !== void 0)
20852
- setEvaluated(gen, props, ps);
20853
- return props;
20854
- }
20855
- exports2.evaluatedPropsToName = evaluatedPropsToName;
20856
- function setEvaluated(gen, props, ps) {
20857
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_12._)`${props}${(0, codegen_12.getProperty)(p)}`, true));
20858
- }
20859
- exports2.setEvaluated = setEvaluated;
20860
- const snippets = {};
20861
- function useFunc(gen, f) {
20862
- return gen.scopeValue("func", {
20863
- ref: f,
20864
- code: snippets[f.code] || (snippets[f.code] = new code_12._Code(f.code))
20865
- });
20866
- }
20867
- exports2.useFunc = useFunc;
20868
- var Type;
20869
- (function(Type2) {
20870
- Type2[Type2["Num"] = 0] = "Num";
20871
- Type2[Type2["Str"] = 1] = "Str";
20872
- })(Type = exports2.Type || (exports2.Type = {}));
20873
- function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
20874
- if (dataProp instanceof codegen_12.Name) {
20875
- const isNumber = dataPropType === Type.Num;
20876
- 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")`;
20877
- }
20878
- return jsPropertySyntax ? (0, codegen_12.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
20879
- }
20880
- exports2.getErrorPath = getErrorPath;
20881
- function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
20882
- if (!mode)
20883
- return;
20884
- msg = `strict mode: ${msg}`;
20885
- if (mode === true)
20886
- throw new Error(msg);
20887
- it.self.logger.warn(msg);
20888
- }
20889
- exports2.checkStrictMode = checkStrictMode;
20890
- })(util);
20849
+ }
20850
+ util.mergeEvaluated = {
20851
+ props: makeMergeEvaluated({
20852
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
20853
+ 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})`));
20854
+ }),
20855
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
20856
+ if (from === true) {
20857
+ gen.assign(to, true);
20858
+ } else {
20859
+ gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
20860
+ setEvaluated(gen, to, from);
20861
+ }
20862
+ }),
20863
+ mergeValues: (from, to) => from === true ? true : { ...from, ...to },
20864
+ resultToName: evaluatedPropsToName
20865
+ }),
20866
+ items: makeMergeEvaluated({
20867
+ 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}`)),
20868
+ 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}`)),
20869
+ mergeValues: (from, to) => from === true ? true : Math.max(from, to),
20870
+ resultToName: (gen, items2) => gen.var("items", items2)
20871
+ })
20872
+ };
20873
+ function evaluatedPropsToName(gen, ps) {
20874
+ if (ps === true)
20875
+ return gen.var("props", true);
20876
+ const props = gen.var("props", (0, codegen_1$v._)`{}`);
20877
+ if (ps !== void 0)
20878
+ setEvaluated(gen, props, ps);
20879
+ return props;
20880
+ }
20881
+ util.evaluatedPropsToName = evaluatedPropsToName;
20882
+ function setEvaluated(gen, props, ps) {
20883
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
20884
+ }
20885
+ util.setEvaluated = setEvaluated;
20886
+ const snippets = {};
20887
+ function useFunc(gen, f) {
20888
+ return gen.scopeValue("func", {
20889
+ ref: f,
20890
+ code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
20891
+ });
20892
+ }
20893
+ util.useFunc = useFunc;
20894
+ var Type;
20895
+ (function(Type2) {
20896
+ Type2[Type2["Num"] = 0] = "Num";
20897
+ Type2[Type2["Str"] = 1] = "Str";
20898
+ })(Type || (util.Type = Type = {}));
20899
+ function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
20900
+ if (dataProp instanceof codegen_1$v.Name) {
20901
+ const isNumber = dataPropType === Type.Num;
20902
+ 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")`;
20903
+ }
20904
+ return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
20905
+ }
20906
+ util.getErrorPath = getErrorPath;
20907
+ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
20908
+ if (!mode)
20909
+ return;
20910
+ msg = `strict mode: ${msg}`;
20911
+ if (mode === true)
20912
+ throw new Error(msg);
20913
+ it.self.logger.warn(msg);
20914
+ }
20915
+ util.checkStrictMode = checkStrictMode;
20891
20916
  var names$1 = {};
20892
20917
  Object.defineProperty(names$1, "__esModule", { value: true });
20893
- const codegen_1$t = codegen;
20918
+ const codegen_1$u = codegen;
20894
20919
  const names = {
20895
20920
  // validation function arguments
20896
- data: new codegen_1$t.Name("data"),
20921
+ data: new codegen_1$u.Name("data"),
20922
+ // data passed to validation function
20897
20923
  // args passed from referencing schema
20898
- valCxt: new codegen_1$t.Name("valCxt"),
20899
- instancePath: new codegen_1$t.Name("instancePath"),
20900
- parentData: new codegen_1$t.Name("parentData"),
20901
- parentDataProperty: new codegen_1$t.Name("parentDataProperty"),
20902
- rootData: new codegen_1$t.Name("rootData"),
20903
- dynamicAnchors: new codegen_1$t.Name("dynamicAnchors"),
20924
+ valCxt: new codegen_1$u.Name("valCxt"),
20925
+ // validation/data context - should not be used directly, it is destructured to the names below
20926
+ instancePath: new codegen_1$u.Name("instancePath"),
20927
+ parentData: new codegen_1$u.Name("parentData"),
20928
+ parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
20929
+ rootData: new codegen_1$u.Name("rootData"),
20930
+ // root data - same as the data passed to the first/top validation function
20931
+ dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
20932
+ // used to support recursiveRef and dynamicRef
20904
20933
  // function scoped variables
20905
- vErrors: new codegen_1$t.Name("vErrors"),
20906
- errors: new codegen_1$t.Name("errors"),
20907
- this: new codegen_1$t.Name("this"),
20934
+ vErrors: new codegen_1$u.Name("vErrors"),
20935
+ // null or array of validation errors
20936
+ errors: new codegen_1$u.Name("errors"),
20937
+ // counter of validation errors
20938
+ this: new codegen_1$u.Name("this"),
20908
20939
  // "globals"
20909
- self: new codegen_1$t.Name("self"),
20910
- scope: new codegen_1$t.Name("scope"),
20940
+ self: new codegen_1$u.Name("self"),
20941
+ scope: new codegen_1$u.Name("scope"),
20911
20942
  // JTD serialize/parse name for JSON string and position
20912
- json: new codegen_1$t.Name("json"),
20913
- jsonPos: new codegen_1$t.Name("jsonPos"),
20914
- jsonLen: new codegen_1$t.Name("jsonLen"),
20915
- jsonPart: new codegen_1$t.Name("jsonPart")
20943
+ json: new codegen_1$u.Name("json"),
20944
+ jsonPos: new codegen_1$u.Name("jsonPos"),
20945
+ jsonLen: new codegen_1$u.Name("jsonLen"),
20946
+ jsonPart: new codegen_1$u.Name("jsonPart")
20916
20947
  };
20917
20948
  names$1.default = names;
20918
20949
  (function(exports2) {
@@ -20985,6 +21016,7 @@ names$1.default = names;
20985
21016
  const E = {
20986
21017
  keyword: new codegen_12.Name("keyword"),
20987
21018
  schemaPath: new codegen_12.Name("schemaPath"),
21019
+ // also used in JTD errors
20988
21020
  params: new codegen_12.Name("params"),
20989
21021
  propertyName: new codegen_12.Name("propertyName"),
20990
21022
  message: new codegen_12.Name("message"),
@@ -21033,8 +21065,8 @@ names$1.default = names;
21033
21065
  })(errors);
21034
21066
  Object.defineProperty(boolSchema, "__esModule", { value: true });
21035
21067
  boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
21036
- const errors_1$2 = errors;
21037
- const codegen_1$s = codegen;
21068
+ const errors_1$3 = errors;
21069
+ const codegen_1$t = codegen;
21038
21070
  const names_1$6 = names$1;
21039
21071
  const boolError = {
21040
21072
  message: "boolean schema is false"
@@ -21046,7 +21078,7 @@ function topBoolOrEmptySchema(it) {
21046
21078
  } else if (typeof schema == "object" && schema.$async === true) {
21047
21079
  gen.return(names_1$6.default.data);
21048
21080
  } else {
21049
- gen.assign((0, codegen_1$s._)`${validateName2}.errors`, null);
21081
+ gen.assign((0, codegen_1$t._)`${validateName2}.errors`, null);
21050
21082
  gen.return(true);
21051
21083
  }
21052
21084
  }
@@ -21073,7 +21105,7 @@ function falseSchemaError(it, overrideAllErrors) {
21073
21105
  params: {},
21074
21106
  it
21075
21107
  };
21076
- (0, errors_1$2.reportError)(cxt, boolError, void 0, overrideAllErrors);
21108
+ (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
21077
21109
  }
21078
21110
  var dataType = {};
21079
21111
  var rules = {};
@@ -21118,185 +21150,183 @@ function shouldUseRule(schema, rule) {
21118
21150
  return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
21119
21151
  }
21120
21152
  applicability.shouldUseRule = shouldUseRule;
21121
- (function(exports2) {
21122
- Object.defineProperty(exports2, "__esModule", { value: true });
21123
- exports2.reportTypeError = exports2.checkDataTypes = exports2.checkDataType = exports2.coerceAndCheckDataType = exports2.getJSONTypes = exports2.getSchemaTypes = exports2.DataType = void 0;
21124
- const rules_1 = rules;
21125
- const applicability_12 = applicability;
21126
- const errors_12 = errors;
21127
- const codegen_12 = codegen;
21128
- const util_12 = util;
21129
- var DataType;
21130
- (function(DataType2) {
21131
- DataType2[DataType2["Correct"] = 0] = "Correct";
21132
- DataType2[DataType2["Wrong"] = 1] = "Wrong";
21133
- })(DataType = exports2.DataType || (exports2.DataType = {}));
21134
- function getSchemaTypes(schema) {
21135
- const types2 = getJSONTypes(schema.type);
21136
- const hasNull = types2.includes("null");
21137
- if (hasNull) {
21138
- if (schema.nullable === false)
21139
- throw new Error("type: null contradicts nullable: false");
21140
- } else {
21141
- if (!types2.length && schema.nullable !== void 0) {
21142
- throw new Error('"nullable" cannot be used without "type"');
21143
- }
21144
- if (schema.nullable === true)
21145
- types2.push("null");
21153
+ Object.defineProperty(dataType, "__esModule", { value: true });
21154
+ dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
21155
+ const rules_1 = rules;
21156
+ const applicability_1$1 = applicability;
21157
+ const errors_1$2 = errors;
21158
+ const codegen_1$s = codegen;
21159
+ const util_1$q = util;
21160
+ var DataType;
21161
+ (function(DataType2) {
21162
+ DataType2[DataType2["Correct"] = 0] = "Correct";
21163
+ DataType2[DataType2["Wrong"] = 1] = "Wrong";
21164
+ })(DataType || (dataType.DataType = DataType = {}));
21165
+ function getSchemaTypes(schema) {
21166
+ const types2 = getJSONTypes(schema.type);
21167
+ const hasNull = types2.includes("null");
21168
+ if (hasNull) {
21169
+ if (schema.nullable === false)
21170
+ throw new Error("type: null contradicts nullable: false");
21171
+ } else {
21172
+ if (!types2.length && schema.nullable !== void 0) {
21173
+ throw new Error('"nullable" cannot be used without "type"');
21146
21174
  }
21147
- return types2;
21175
+ if (schema.nullable === true)
21176
+ types2.push("null");
21148
21177
  }
21149
- exports2.getSchemaTypes = getSchemaTypes;
21150
- function getJSONTypes(ts) {
21151
- const types2 = Array.isArray(ts) ? ts : ts ? [ts] : [];
21152
- if (types2.every(rules_1.isJSONType))
21153
- return types2;
21154
- throw new Error("type must be JSONType or JSONType[]: " + types2.join(","));
21155
- }
21156
- exports2.getJSONTypes = getJSONTypes;
21157
- function coerceAndCheckDataType(it, types2) {
21158
- const { gen, data, opts } = it;
21159
- const coerceTo = coerceToTypes(types2, opts.coerceTypes);
21160
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_12.schemaHasRulesForType)(it, types2[0]));
21161
- if (checkTypes) {
21162
- const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
21163
- gen.if(wrongType, () => {
21164
- if (coerceTo.length)
21165
- coerceData(it, types2, coerceTo);
21166
- else
21167
- reportTypeError(it);
21168
- });
21169
- }
21170
- return checkTypes;
21178
+ return types2;
21179
+ }
21180
+ dataType.getSchemaTypes = getSchemaTypes;
21181
+ function getJSONTypes(ts) {
21182
+ const types2 = Array.isArray(ts) ? ts : ts ? [ts] : [];
21183
+ if (types2.every(rules_1.isJSONType))
21184
+ return types2;
21185
+ throw new Error("type must be JSONType or JSONType[]: " + types2.join(","));
21186
+ }
21187
+ dataType.getJSONTypes = getJSONTypes;
21188
+ function coerceAndCheckDataType(it, types2) {
21189
+ const { gen, data, opts } = it;
21190
+ const coerceTo = coerceToTypes(types2, opts.coerceTypes);
21191
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
21192
+ if (checkTypes) {
21193
+ const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
21194
+ gen.if(wrongType, () => {
21195
+ if (coerceTo.length)
21196
+ coerceData(it, types2, coerceTo);
21197
+ else
21198
+ reportTypeError(it);
21199
+ });
21171
21200
  }
21172
- exports2.coerceAndCheckDataType = coerceAndCheckDataType;
21173
- const COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
21174
- function coerceToTypes(types2, coerceTypes) {
21175
- return coerceTypes ? types2.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
21201
+ return checkTypes;
21202
+ }
21203
+ dataType.coerceAndCheckDataType = coerceAndCheckDataType;
21204
+ const COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
21205
+ function coerceToTypes(types2, coerceTypes) {
21206
+ return coerceTypes ? types2.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
21207
+ }
21208
+ function coerceData(it, types2, coerceTo) {
21209
+ const { gen, data, opts } = it;
21210
+ const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
21211
+ const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
21212
+ if (opts.coerceTypes === "array") {
21213
+ 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)));
21176
21214
  }
21177
- function coerceData(it, types2, coerceTo) {
21178
- const { gen, data, opts } = it;
21179
- const dataType2 = gen.let("dataType", (0, codegen_12._)`typeof ${data}`);
21180
- const coerced = gen.let("coerced", (0, codegen_12._)`undefined`);
21181
- if (opts.coerceTypes === "array") {
21182
- 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)));
21183
- }
21184
- gen.if((0, codegen_12._)`${coerced} !== undefined`);
21185
- for (const t of coerceTo) {
21186
- if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
21187
- coerceSpecificType(t);
21188
- }
21189
- }
21190
- gen.else();
21191
- reportTypeError(it);
21192
- gen.endIf();
21193
- gen.if((0, codegen_12._)`${coerced} !== undefined`, () => {
21194
- gen.assign(data, coerced);
21195
- assignParentData(it, coerced);
21196
- });
21197
- function coerceSpecificType(t) {
21198
- switch (t) {
21199
- case "string":
21200
- 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._)`""`);
21201
- return;
21202
- case "number":
21203
- gen.elseIf((0, codegen_12._)`${dataType2} == "boolean" || ${data} === null
21204
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_12._)`+${data}`);
21205
- return;
21206
- case "integer":
21207
- gen.elseIf((0, codegen_12._)`${dataType2} === "boolean" || ${data} === null
21208
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_12._)`+${data}`);
21209
- return;
21210
- case "boolean":
21211
- 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);
21212
- return;
21213
- case "null":
21214
- gen.elseIf((0, codegen_12._)`${data} === "" || ${data} === 0 || ${data} === false`);
21215
- gen.assign(coerced, null);
21216
- return;
21217
- case "array":
21218
- gen.elseIf((0, codegen_12._)`${dataType2} === "string" || ${dataType2} === "number"
21219
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_12._)`[${data}]`);
21220
- }
21215
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
21216
+ for (const t of coerceTo) {
21217
+ if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
21218
+ coerceSpecificType(t);
21221
21219
  }
21222
21220
  }
21223
- function assignParentData({ gen, parentData, parentDataProperty }, expr) {
21224
- gen.if((0, codegen_12._)`${parentData} !== undefined`, () => gen.assign((0, codegen_12._)`${parentData}[${parentDataProperty}]`, expr));
21225
- }
21226
- function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
21227
- const EQ = correct === DataType.Correct ? codegen_12.operators.EQ : codegen_12.operators.NEQ;
21228
- let cond;
21229
- switch (dataType2) {
21221
+ gen.else();
21222
+ reportTypeError(it);
21223
+ gen.endIf();
21224
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
21225
+ gen.assign(data, coerced);
21226
+ assignParentData(it, coerced);
21227
+ });
21228
+ function coerceSpecificType(t) {
21229
+ switch (t) {
21230
+ case "string":
21231
+ 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._)`""`);
21232
+ return;
21233
+ case "number":
21234
+ gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
21235
+ || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
21236
+ return;
21237
+ case "integer":
21238
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
21239
+ || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
21240
+ return;
21241
+ case "boolean":
21242
+ 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);
21243
+ return;
21230
21244
  case "null":
21231
- return (0, codegen_12._)`${data} ${EQ} null`;
21245
+ gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
21246
+ gen.assign(coerced, null);
21247
+ return;
21232
21248
  case "array":
21233
- cond = (0, codegen_12._)`Array.isArray(${data})`;
21234
- break;
21235
- case "object":
21236
- cond = (0, codegen_12._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
21237
- break;
21238
- case "integer":
21239
- cond = numCond((0, codegen_12._)`!(${data} % 1) && !isNaN(${data})`);
21240
- break;
21241
- case "number":
21242
- cond = numCond();
21243
- break;
21244
- default:
21245
- return (0, codegen_12._)`typeof ${data} ${EQ} ${dataType2}`;
21246
- }
21247
- return correct === DataType.Correct ? cond : (0, codegen_12.not)(cond);
21248
- function numCond(_cond = codegen_12.nil) {
21249
- return (0, codegen_12.and)((0, codegen_12._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_12._)`isFinite(${data})` : codegen_12.nil);
21250
- }
21251
- }
21252
- exports2.checkDataType = checkDataType;
21253
- function checkDataTypes(dataTypes, data, strictNums, correct) {
21254
- if (dataTypes.length === 1) {
21255
- return checkDataType(dataTypes[0], data, strictNums, correct);
21256
- }
21257
- let cond;
21258
- const types2 = (0, util_12.toHash)(dataTypes);
21259
- if (types2.array && types2.object) {
21260
- const notObj = (0, codegen_12._)`typeof ${data} != "object"`;
21261
- cond = types2.null ? notObj : (0, codegen_12._)`!${data} || ${notObj}`;
21262
- delete types2.null;
21263
- delete types2.array;
21264
- delete types2.object;
21265
- } else {
21266
- cond = codegen_12.nil;
21267
- }
21268
- if (types2.number)
21269
- delete types2.integer;
21270
- for (const t in types2)
21271
- cond = (0, codegen_12.and)(cond, checkDataType(t, data, strictNums, correct));
21272
- return cond;
21273
- }
21274
- exports2.checkDataTypes = checkDataTypes;
21275
- const typeError = {
21276
- message: ({ schema }) => `must be ${schema}`,
21277
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_12._)`{type: ${schema}}` : (0, codegen_12._)`{type: ${schemaValue}}`
21278
- };
21279
- function reportTypeError(it) {
21280
- const cxt = getTypeErrorContext(it);
21281
- (0, errors_12.reportError)(cxt, typeError);
21282
- }
21283
- exports2.reportTypeError = reportTypeError;
21284
- function getTypeErrorContext(it) {
21285
- const { gen, data, schema } = it;
21286
- const schemaCode = (0, util_12.schemaRefOrVal)(it, schema, "type");
21287
- return {
21288
- gen,
21289
- keyword: "type",
21290
- data,
21291
- schema: schema.type,
21292
- schemaCode,
21293
- schemaValue: schemaCode,
21294
- parentSchema: schema,
21295
- params: {},
21296
- it
21297
- };
21249
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
21250
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
21251
+ }
21298
21252
  }
21299
- })(dataType);
21253
+ }
21254
+ function assignParentData({ gen, parentData, parentDataProperty }, expr) {
21255
+ gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
21256
+ }
21257
+ function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
21258
+ const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
21259
+ let cond;
21260
+ switch (dataType2) {
21261
+ case "null":
21262
+ return (0, codegen_1$s._)`${data} ${EQ} null`;
21263
+ case "array":
21264
+ cond = (0, codegen_1$s._)`Array.isArray(${data})`;
21265
+ break;
21266
+ case "object":
21267
+ cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
21268
+ break;
21269
+ case "integer":
21270
+ cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
21271
+ break;
21272
+ case "number":
21273
+ cond = numCond();
21274
+ break;
21275
+ default:
21276
+ return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
21277
+ }
21278
+ return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
21279
+ function numCond(_cond = codegen_1$s.nil) {
21280
+ 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);
21281
+ }
21282
+ }
21283
+ dataType.checkDataType = checkDataType;
21284
+ function checkDataTypes(dataTypes, data, strictNums, correct) {
21285
+ if (dataTypes.length === 1) {
21286
+ return checkDataType(dataTypes[0], data, strictNums, correct);
21287
+ }
21288
+ let cond;
21289
+ const types2 = (0, util_1$q.toHash)(dataTypes);
21290
+ if (types2.array && types2.object) {
21291
+ const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
21292
+ cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
21293
+ delete types2.null;
21294
+ delete types2.array;
21295
+ delete types2.object;
21296
+ } else {
21297
+ cond = codegen_1$s.nil;
21298
+ }
21299
+ if (types2.number)
21300
+ delete types2.integer;
21301
+ for (const t in types2)
21302
+ cond = (0, codegen_1$s.and)(cond, checkDataType(t, data, strictNums, correct));
21303
+ return cond;
21304
+ }
21305
+ dataType.checkDataTypes = checkDataTypes;
21306
+ const typeError = {
21307
+ message: ({ schema }) => `must be ${schema}`,
21308
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
21309
+ };
21310
+ function reportTypeError(it) {
21311
+ const cxt = getTypeErrorContext(it);
21312
+ (0, errors_1$2.reportError)(cxt, typeError);
21313
+ }
21314
+ dataType.reportTypeError = reportTypeError;
21315
+ function getTypeErrorContext(it) {
21316
+ const { gen, data, schema } = it;
21317
+ const schemaCode = (0, util_1$q.schemaRefOrVal)(it, schema, "type");
21318
+ return {
21319
+ gen,
21320
+ keyword: "type",
21321
+ data,
21322
+ schema: schema.type,
21323
+ schemaCode,
21324
+ schemaValue: schemaCode,
21325
+ parentSchema: schema,
21326
+ params: {},
21327
+ it
21328
+ };
21329
+ }
21300
21330
  var defaults = {};
21301
21331
  Object.defineProperty(defaults, "__esModule", { value: true });
21302
21332
  defaults.assignDefaults = void 0;
@@ -21683,15 +21713,7 @@ var fastDeepEqual = function equal(a, b) {
21683
21713
  }
21684
21714
  return a !== a && b !== b;
21685
21715
  };
21686
- var jsonSchemaTraverseExports = {};
21687
- var jsonSchemaTraverse = {
21688
- get exports() {
21689
- return jsonSchemaTraverseExports;
21690
- },
21691
- set exports(v) {
21692
- jsonSchemaTraverseExports = v;
21693
- }
21694
- };
21716
+ var jsonSchemaTraverse = { exports: {} };
21695
21717
  var traverse$1 = jsonSchemaTraverse.exports = function(schema, opts, cb) {
21696
21718
  if (typeof opts == "function") {
21697
21719
  cb = opts;
@@ -21773,6 +21795,7 @@ function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr,
21773
21795
  function escapeJsonPtr(str) {
21774
21796
  return str.replace(/~/g, "~0").replace(/\//g, "~1");
21775
21797
  }
21798
+ var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
21776
21799
  Object.defineProperty(resolve$1, "__esModule", { value: true });
21777
21800
  resolve$1.getSchemaRefs = resolve$1.resolveUrl = resolve$1.normalizeId = resolve$1._getFullPath = resolve$1.getFullPath = resolve$1.inlineRef = void 0;
21778
21801
  const util_1$m = util;
@@ -21877,15 +21900,15 @@ function getSchemaRefs(schema, baseId) {
21877
21900
  if (parentJsonPtr === void 0)
21878
21901
  return;
21879
21902
  const fullPath = pathPrefix + jsonPtr;
21880
- let baseId2 = baseIds[parentJsonPtr];
21903
+ let innerBaseId = baseIds[parentJsonPtr];
21881
21904
  if (typeof sch[schemaId] == "string")
21882
- baseId2 = addRef.call(this, sch[schemaId]);
21905
+ innerBaseId = addRef.call(this, sch[schemaId]);
21883
21906
  addAnchor.call(this, sch.$anchor);
21884
21907
  addAnchor.call(this, sch.$dynamicAnchor);
21885
- baseIds[jsonPtr] = baseId2;
21908
+ baseIds[jsonPtr] = innerBaseId;
21886
21909
  function addRef(ref2) {
21887
21910
  const _resolve = this.opts.uriResolver.resolve;
21888
- ref2 = normalizeId(baseId2 ? _resolve(baseId2, ref2) : ref2);
21911
+ ref2 = normalizeId(innerBaseId ? _resolve(innerBaseId, ref2) : ref2);
21889
21912
  if (schemaRefs.has(ref2))
21890
21913
  throw ambiguos(ref2);
21891
21914
  schemaRefs.add(ref2);
@@ -22497,6 +22520,7 @@ function compileSchema(sch) {
22497
22520
  parentDataProperty: names_1$2.default.parentDataProperty,
22498
22521
  dataNames: [names_1$2.default.data],
22499
22522
  dataPathArr: [codegen_1$m.nil],
22523
+ // TODO can its length be used as dataLevel if nil is removed?
22500
22524
  dataLevel: 0,
22501
22525
  dataTypes: [],
22502
22526
  definedProperties: /* @__PURE__ */ new Set(),
@@ -22689,15 +22713,7 @@ const require$$9$1 = {
22689
22713
  additionalProperties: additionalProperties$a
22690
22714
  };
22691
22715
  var uri$1 = {};
22692
- var uri_allExports = {};
22693
- var uri_all = {
22694
- get exports() {
22695
- return uri_allExports;
22696
- },
22697
- set exports(v) {
22698
- uri_allExports = v;
22699
- }
22700
- };
22716
+ var uri_all = { exports: {} };
22701
22717
  /** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
22702
22718
  (function(module2, exports2) {
22703
22719
  (function(global2, factory) {
@@ -23737,7 +23753,8 @@ var uri_all = {
23737
23753
  exports3.unescapeComponent = unescapeComponent;
23738
23754
  Object.defineProperty(exports3, "__esModule", { value: true });
23739
23755
  });
23740
- })(uri_all, uri_allExports);
23756
+ })(uri_all, uri_all.exports);
23757
+ var uri_allExports = uri_all.exports;
23741
23758
  Object.defineProperty(uri$1, "__esModule", { value: true });
23742
23759
  const uri = uri_allExports;
23743
23760
  uri.code = 'require("ajv/dist/runtime/uri").default';
@@ -23770,7 +23787,7 @@ uri$1.default = uri;
23770
23787
  } });
23771
23788
  const validation_error_12 = validation_error;
23772
23789
  const ref_error_12 = ref_error;
23773
- const rules_1 = rules;
23790
+ const rules_12 = rules;
23774
23791
  const compile_12 = compile;
23775
23792
  const codegen_2 = codegen;
23776
23793
  const resolve_12 = resolve$1;
@@ -23861,7 +23878,7 @@ uri$1.default = uri;
23861
23878
  this.logger = getLogger(opts.logger);
23862
23879
  const formatOpt = opts.validateFormats;
23863
23880
  opts.validateFormats = false;
23864
- this.RULES = (0, rules_1.getRules)();
23881
+ this.RULES = (0, rules_12.getRules)();
23865
23882
  checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED");
23866
23883
  checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn");
23867
23884
  this._metaOpts = getMetaSchemaOptions.call(this);
@@ -24217,9 +24234,9 @@ uri$1.default = uri;
24217
24234
  }
24218
24235
  }
24219
24236
  }
24220
- exports2.default = Ajv2;
24221
24237
  Ajv2.ValidationError = validation_error_12.default;
24222
24238
  Ajv2.MissingRefError = ref_error_12.default;
24239
+ exports2.default = Ajv2;
24223
24240
  function checkOptions(checkOpts, options2, msg, log = "error") {
24224
24241
  for (const key in checkOpts) {
24225
24242
  const opt = key;
@@ -25813,14 +25830,13 @@ const draft7Vocabularies = [
25813
25830
  draft7.default = draft7Vocabularies;
25814
25831
  var discriminator = {};
25815
25832
  var types = {};
25816
- (function(exports2) {
25817
- Object.defineProperty(exports2, "__esModule", { value: true });
25818
- exports2.DiscrError = void 0;
25819
- (function(DiscrError) {
25820
- DiscrError["Tag"] = "tag";
25821
- DiscrError["Mapping"] = "mapping";
25822
- })(exports2.DiscrError || (exports2.DiscrError = {}));
25823
- })(types);
25833
+ Object.defineProperty(types, "__esModule", { value: true });
25834
+ types.DiscrError = void 0;
25835
+ var DiscrError;
25836
+ (function(DiscrError2) {
25837
+ DiscrError2["Tag"] = "tag";
25838
+ DiscrError2["Mapping"] = "mapping";
25839
+ })(DiscrError || (types.DiscrError = DiscrError = {}));
25824
25840
  Object.defineProperty(discriminator, "__esModule", { value: true });
25825
25841
  const codegen_1 = codegen;
25826
25842
  const types_1 = types;
@@ -26164,7 +26180,7 @@ const require$$3$2 = {
26164
26180
  };
26165
26181
  (function(module2, exports2) {
26166
26182
  Object.defineProperty(exports2, "__esModule", { value: true });
26167
- exports2.MissingRefError = exports2.ValidationError = exports2.CodeGen = exports2.Name = exports2.nil = exports2.stringify = exports2.str = exports2._ = exports2.KeywordCxt = void 0;
26183
+ exports2.MissingRefError = exports2.ValidationError = exports2.CodeGen = exports2.Name = exports2.nil = exports2.stringify = exports2.str = exports2._ = exports2.KeywordCxt = exports2.Ajv = void 0;
26168
26184
  const core_12 = core$2;
26169
26185
  const draft7_1 = draft7;
26170
26186
  const discriminator_1 = discriminator;
@@ -26190,7 +26206,9 @@ const require$$3$2 = {
26190
26206
  return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
26191
26207
  }
26192
26208
  }
26209
+ exports2.Ajv = Ajv2;
26193
26210
  module2.exports = exports2 = Ajv2;
26211
+ module2.exports.Ajv = Ajv2;
26194
26212
  Object.defineProperty(exports2, "__esModule", { value: true });
26195
26213
  exports2.default = Ajv2;
26196
26214
  var validate_12 = validate;
@@ -26224,7 +26242,8 @@ const require$$3$2 = {
26224
26242
  Object.defineProperty(exports2, "MissingRefError", { enumerable: true, get: function() {
26225
26243
  return ref_error_12.default;
26226
26244
  } });
26227
- })(ajv, ajvExports);
26245
+ })(ajv, ajv.exports);
26246
+ var ajvExports = ajv.exports;
26228
26247
  const title$9 = "Root";
26229
26248
  const type$p = "object";
26230
26249
  const description$9 = "Root Element";
@@ -32305,6 +32324,7 @@ function deepCopy(e, t = defaultOpts) {
32305
32324
  return t.detectCircular && s.setAsCopied(e, n), copyObjectContents(e, { destObject: n, srcType: c, watcher: s, options: t }, 0), n;
32306
32325
  }
32307
32326
  var deepCopyAll_min = deepCopy;
32327
+ const deepCopy$1 = /* @__PURE__ */ getDefaultExportFromCjs(deepCopyAll_min);
32308
32328
  var _deepCopyAll = _interopRequireDefault$1(deepCopyAll_min);
32309
32329
  function _interopRequireDefault$1(obj) {
32310
32330
  return obj && obj.__esModule ? obj : { default: obj };
@@ -34166,7 +34186,7 @@ const parseUsfm = (str, parser) => {
34166
34186
  parser.parseItem(preTokenObjectForFragment(matches[n], lexingRegexes));
34167
34187
  }
34168
34188
  };
34169
- var sax = {};
34189
+ var sax$1 = {};
34170
34190
  var emitterComponent;
34171
34191
  var hasRequiredEmitterComponent;
34172
34192
  function requireEmitterComponent() {
@@ -34320,15 +34340,7 @@ function requireStream() {
34320
34340
  return stream;
34321
34341
  }
34322
34342
  var string_decoder = {};
34323
- var safeBufferExports = {};
34324
- var safeBuffer = {
34325
- get exports() {
34326
- return safeBufferExports;
34327
- },
34328
- set exports(v) {
34329
- safeBufferExports = v;
34330
- }
34331
- };
34343
+ var safeBuffer = { exports: {} };
34332
34344
  var buffer = {};
34333
34345
  var ieee754 = {};
34334
34346
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -36123,7 +36135,7 @@ function requireBuffer() {
36123
36135
  var hasRequiredSafeBuffer;
36124
36136
  function requireSafeBuffer() {
36125
36137
  if (hasRequiredSafeBuffer)
36126
- return safeBufferExports;
36138
+ return safeBuffer.exports;
36127
36139
  hasRequiredSafeBuffer = 1;
36128
36140
  (function(module2, exports2) {
36129
36141
  var buffer2 = requireBuffer();
@@ -36178,8 +36190,8 @@ function requireSafeBuffer() {
36178
36190
  }
36179
36191
  return buffer2.SlowBuffer(size);
36180
36192
  };
36181
- })(safeBuffer, safeBufferExports);
36182
- return safeBufferExports;
36193
+ })(safeBuffer, safeBuffer.exports);
36194
+ return safeBuffer.exports;
36183
36195
  }
36184
36196
  var hasRequiredString_decoder;
36185
36197
  function requireString_decoder() {
@@ -36597,6 +36609,9 @@ function requireString_decoder() {
36597
36609
  Stream = function() {
36598
36610
  };
36599
36611
  }
36612
+ if (!Stream)
36613
+ Stream = function() {
36614
+ };
36600
36615
  var streamWraps = sax2.EVENTS.filter(function(ev) {
36601
36616
  return ev !== "error" && ev !== "end";
36602
36617
  });
@@ -37807,9 +37822,16 @@ function requireString_decoder() {
37807
37822
  break;
37808
37823
  }
37809
37824
  if (c === ";") {
37810
- parser[buffer2] += parseEntity(parser);
37811
- parser.entity = "";
37812
- parser.state = returnState;
37825
+ if (parser.opt.unparsedEntities) {
37826
+ var parsedEntity = parseEntity(parser);
37827
+ parser.entity = "";
37828
+ parser.state = returnState;
37829
+ parser.write(parsedEntity);
37830
+ } else {
37831
+ parser[buffer2] += parseEntity(parser);
37832
+ parser.entity = "";
37833
+ parser.state = returnState;
37834
+ }
37813
37835
  } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
37814
37836
  parser.entity += c;
37815
37837
  } else {
@@ -37819,8 +37841,9 @@ function requireString_decoder() {
37819
37841
  parser.state = returnState;
37820
37842
  }
37821
37843
  continue;
37822
- default:
37844
+ default: {
37823
37845
  throw new Error(parser, "Unknown state: " + parser.state);
37846
+ }
37824
37847
  }
37825
37848
  }
37826
37849
  if (parser.position >= parser.bufferCheckPosition) {
@@ -37879,7 +37902,8 @@ function requireString_decoder() {
37879
37902
  })();
37880
37903
  }
37881
37904
  })(exports2);
37882
- })(sax);
37905
+ })(sax$1);
37906
+ const sax = /* @__PURE__ */ getDefaultExportFromCjs(sax$1);
37883
37907
  class UsxLexer {
37884
37908
  constructor() {
37885
37909
  this.sax = sax.parser(true);
@@ -39005,6 +39029,7 @@ const parseNodes = (str, parser, bookCode) => {
39005
39029
  });
39006
39030
  };
39007
39031
  const { labelForScope: labelForScope$2 } = utils.scopeDefs;
39032
+ const idTest = new RegExp(/^[A-Z0-9_]+$/);
39008
39033
  const buildSpecLookup = (specs2) => {
39009
39034
  const ret = {};
39010
39035
  for (const spec of specs2) {
@@ -39049,9 +39074,9 @@ const specs = (pt) => [
39049
39074
  onEnd: (parser, label) => {
39050
39075
  parser.headers[label] = parser.current.sequence.plainText();
39051
39076
  if (label === "id") {
39052
- if (parser.headers[label].length === 3 || parser.headers[label].length > 3 && parser.headers[label].substring(3, 4) === " ") {
39053
- const bookCode = parser.headers[label].substring(0, 3);
39054
- parser.headers["bookCode"] = bookCode;
39077
+ const idBits = parser.headers[label].split(" ", 2);
39078
+ if (idBits[0].length >= 3 && idBits[0].length <= 12 && idTest.test(idBits[0])) {
39079
+ parser.headers["bookCode"] = idBits[0];
39055
39080
  }
39056
39081
  }
39057
39082
  }
@@ -41449,7 +41474,7 @@ const pushModifiedBlocks = (oldSequence, newSequence2, blockFilterFunc, itemFilt
41449
41474
  newSequence2.blocks = [];
41450
41475
  for (const [blockN, block2] of oldSequence.blocks.entries()) {
41451
41476
  if (blockFilterFunc(oldSequence, blockN, block2)) {
41452
- const newBlock2 = blockRewriteFunc(oldSequence, blockN, deepCopyAll_min(block2));
41477
+ const newBlock2 = blockRewriteFunc(oldSequence, blockN, deepCopy$1(block2));
41453
41478
  newBlock2.c.clear();
41454
41479
  modifyBlockItems(
41455
41480
  oldSequence,
@@ -44257,8 +44282,14 @@ const blockResolvers = {
44257
44282
  return context.docSet.unsuccinctifyItemsWithScriptureCV(
44258
44283
  root,
44259
44284
  args.withScriptureCV,
44260
- {},
44261
- args.includeContext || false
44285
+ args.excludeScopeTypes ? {
44286
+ tokens: true,
44287
+ scopes: true,
44288
+ grafts: true,
44289
+ excludeScopeTypes: args.excludeScopeTypes || [],
44290
+ anyScope: args.anyScope || false,
44291
+ includeContext: args.includeContext || false
44292
+ } : {}
44262
44293
  );
44263
44294
  } else {
44264
44295
  return context.docSet.unsuccinctifyPrunedItems(root, {