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.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
+ }
14376
14391
  }
14392
+ if (isNonNullTypeNode(b.type) && !isNonNullTypeNode(a.type)) {
14393
+ a.type = b.type;
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.9";
15993
+ const version = "0.10.11";
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",
@@ -18832,19 +18849,37 @@ const unsuccinctifyItemsWithScriptureCV = (docSet, block2, cv, options2) => {
18832
18849
  }
18833
18850
  };
18834
18851
  const ret = [];
18835
- for (const item of docSet.unsuccinctifyItems(
18836
- block2.c,
18837
- {},
18838
- block2.nt.nByte(0)
18839
- )) {
18840
- if (item[0] === "scope" && item[1] === "start") {
18841
- openScopes.add(item[2]);
18842
- }
18843
- if (itemMatchesCV() && itemInOptions(item)) {
18844
- ret.push(item);
18852
+ if (options2.excludeScopeTypes) {
18853
+ for (const item of docSet.unsuccinctifyItems(
18854
+ block2.c,
18855
+ options2,
18856
+ block2.nt.nByte(0)
18857
+ )) {
18858
+ if (item[0] === "scope" && item[1] === "start") {
18859
+ openScopes.add(item[2]);
18860
+ }
18861
+ if (itemMatchesCV() && itemInOptions(item)) {
18862
+ ret.push(item);
18863
+ }
18864
+ if (item[0] === "scope" && item[1] === "end") {
18865
+ openScopes.delete(item[2]);
18866
+ }
18845
18867
  }
18846
- if (item[0] === "scope" && item[1] === "end") {
18847
- openScopes.delete(item[2]);
18868
+ } else {
18869
+ for (const item of docSet.unsuccinctifyItems(
18870
+ block2.c,
18871
+ {},
18872
+ block2.nt.nByte(0)
18873
+ )) {
18874
+ if (item[0] === "scope" && item[1] === "start") {
18875
+ openScopes.add(item[2]);
18876
+ }
18877
+ if (itemMatchesCV() && itemInOptions(item)) {
18878
+ ret.push(item);
18879
+ }
18880
+ if (item[0] === "scope" && item[1] === "end") {
18881
+ openScopes.delete(item[2]);
18882
+ }
18848
18883
  }
18849
18884
  }
18850
18885
  return ret;
@@ -19703,15 +19738,7 @@ class DocSet {
19703
19738
  return crc32.calculate(docIdsString);
19704
19739
  }
19705
19740
  }
19706
- var ajvExports = {};
19707
- var ajv = {
19708
- get exports() {
19709
- return ajvExports;
19710
- },
19711
- set exports(v) {
19712
- ajvExports = v;
19713
- }
19714
- };
19741
+ var ajv = { exports: {} };
19715
19742
  var core$2 = {};
19716
19743
  var validate = {};
19717
19744
  var boolSchema = {};
@@ -19882,7 +19909,7 @@ var scope = {};
19882
19909
  (function(UsedValueState2) {
19883
19910
  UsedValueState2[UsedValueState2["Started"] = 0] = "Started";
19884
19911
  UsedValueState2[UsedValueState2["Completed"] = 1] = "Completed";
19885
- })(UsedValueState = exports2.UsedValueState || (exports2.UsedValueState = {}));
19912
+ })(UsedValueState || (exports2.UsedValueState = UsedValueState = {}));
19886
19913
  exports2.varKinds = {
19887
19914
  const: new code_12.Name("const"),
19888
19915
  let: new code_12.Name("let"),
@@ -20724,193 +20751,197 @@ var scope = {};
20724
20751
  }
20725
20752
  })(codegen);
20726
20753
  var util = {};
20727
- (function(exports2) {
20728
- Object.defineProperty(exports2, "__esModule", { value: true });
20729
- 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;
20730
- const codegen_12 = codegen;
20731
- const code_12 = code$1;
20732
- function toHash(arr) {
20733
- const hash = {};
20734
- for (const item of arr)
20735
- hash[item] = true;
20736
- return hash;
20737
- }
20738
- exports2.toHash = toHash;
20739
- function alwaysValidSchema(it, schema) {
20740
- if (typeof schema == "boolean")
20741
- return schema;
20742
- if (Object.keys(schema).length === 0)
20743
- return true;
20744
- checkUnknownRules(it, schema);
20745
- return !schemaHasRules(schema, it.self.RULES.all);
20746
- }
20747
- exports2.alwaysValidSchema = alwaysValidSchema;
20748
- function checkUnknownRules(it, schema = it.schema) {
20749
- const { opts, self: self2 } = it;
20750
- if (!opts.strictSchema)
20751
- return;
20752
- if (typeof schema === "boolean")
20753
- return;
20754
- const rules2 = self2.RULES.keywords;
20755
- for (const key in schema) {
20756
- if (!rules2[key])
20757
- checkStrictMode(it, `unknown keyword: "${key}"`);
20758
- }
20759
- }
20760
- exports2.checkUnknownRules = checkUnknownRules;
20761
- function schemaHasRules(schema, rules2) {
20762
- if (typeof schema == "boolean")
20763
- return !schema;
20764
- for (const key in schema)
20765
- if (rules2[key])
20766
- return true;
20767
- return false;
20768
- }
20769
- exports2.schemaHasRules = schemaHasRules;
20770
- function schemaHasRulesButRef(schema, RULES) {
20771
- if (typeof schema == "boolean")
20772
- return !schema;
20773
- for (const key in schema)
20774
- if (key !== "$ref" && RULES.all[key])
20775
- return true;
20776
- 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}"`);
20777
20784
  }
20778
- exports2.schemaHasRulesButRef = schemaHasRulesButRef;
20779
- function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
20780
- if (!$data) {
20781
- if (typeof schema == "number" || typeof schema == "boolean")
20782
- return schema;
20783
- if (typeof schema == "string")
20784
- return (0, codegen_12._)`${schema}`;
20785
- }
20786
- return (0, codegen_12._)`${topSchemaRef}${schemaPath}${(0, codegen_12.getProperty)(keyword2)}`;
20787
- }
20788
- exports2.schemaRefOrVal = schemaRefOrVal;
20789
- function unescapeFragment(str) {
20790
- return unescapeJsonPointer(decodeURIComponent(str));
20791
- }
20792
- exports2.unescapeFragment = unescapeFragment;
20793
- function escapeFragment(str) {
20794
- return encodeURIComponent(escapeJsonPointer(str));
20795
- }
20796
- exports2.escapeFragment = escapeFragment;
20797
- function escapeJsonPointer(str) {
20798
- if (typeof str == "number")
20799
- return `${str}`;
20800
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
20801
- }
20802
- exports2.escapeJsonPointer = escapeJsonPointer;
20803
- function unescapeJsonPointer(str) {
20804
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
20805
- }
20806
- exports2.unescapeJsonPointer = unescapeJsonPointer;
20807
- function eachItem(xs, f) {
20808
- if (Array.isArray(xs)) {
20809
- for (const x of xs)
20810
- f(x);
20811
- } else {
20812
- f(xs);
20813
- }
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}`;
20814
20811
  }
20815
- exports2.eachItem = eachItem;
20816
- function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
20817
- return (gen, from, to, toName) => {
20818
- 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);
20819
- return toName === codegen_12.Name && !(res instanceof codegen_12.Name) ? resultToName(gen, res) : res;
20820
- };
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);
20821
20839
  }
20822
- exports2.mergeEvaluated = {
20823
- props: makeMergeEvaluated({
20824
- mergeNames: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true && ${from} !== undefined`, () => {
20825
- 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})`));
20826
- }),
20827
- mergeToName: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true`, () => {
20828
- if (from === true) {
20829
- gen.assign(to, true);
20830
- } else {
20831
- gen.assign(to, (0, codegen_12._)`${to} || {}`);
20832
- setEvaluated(gen, to, from);
20833
- }
20834
- }),
20835
- mergeValues: (from, to) => from === true ? true : { ...from, ...to },
20836
- resultToName: evaluatedPropsToName
20837
- }),
20838
- items: makeMergeEvaluated({
20839
- 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}`)),
20840
- mergeToName: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_12._)`${to} > ${from} ? ${to} : ${from}`)),
20841
- mergeValues: (from, to) => from === true ? true : Math.max(from, to),
20842
- resultToName: (gen, items2) => gen.var("items", items2)
20843
- })
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;
20844
20846
  };
20845
- function evaluatedPropsToName(gen, ps) {
20846
- if (ps === true)
20847
- return gen.var("props", true);
20848
- const props = gen.var("props", (0, codegen_12._)`{}`);
20849
- if (ps !== void 0)
20850
- setEvaluated(gen, props, ps);
20851
- return props;
20852
- }
20853
- exports2.evaluatedPropsToName = evaluatedPropsToName;
20854
- function setEvaluated(gen, props, ps) {
20855
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_12._)`${props}${(0, codegen_12.getProperty)(p)}`, true));
20856
- }
20857
- exports2.setEvaluated = setEvaluated;
20858
- const snippets = {};
20859
- function useFunc(gen, f) {
20860
- return gen.scopeValue("func", {
20861
- ref: f,
20862
- code: snippets[f.code] || (snippets[f.code] = new code_12._Code(f.code))
20863
- });
20864
- }
20865
- exports2.useFunc = useFunc;
20866
- var Type;
20867
- (function(Type2) {
20868
- Type2[Type2["Num"] = 0] = "Num";
20869
- Type2[Type2["Str"] = 1] = "Str";
20870
- })(Type = exports2.Type || (exports2.Type = {}));
20871
- function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
20872
- if (dataProp instanceof codegen_12.Name) {
20873
- const isNumber = dataPropType === Type.Num;
20874
- 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")`;
20875
- }
20876
- return jsPropertySyntax ? (0, codegen_12.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
20877
- }
20878
- exports2.getErrorPath = getErrorPath;
20879
- function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
20880
- if (!mode)
20881
- return;
20882
- msg = `strict mode: ${msg}`;
20883
- if (mode === true)
20884
- throw new Error(msg);
20885
- it.self.logger.warn(msg);
20886
- }
20887
- exports2.checkStrictMode = checkStrictMode;
20888
- })(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;
20889
20914
  var names$1 = {};
20890
20915
  Object.defineProperty(names$1, "__esModule", { value: true });
20891
- const codegen_1$t = codegen;
20916
+ const codegen_1$u = codegen;
20892
20917
  const names = {
20893
20918
  // validation function arguments
20894
- data: new codegen_1$t.Name("data"),
20919
+ data: new codegen_1$u.Name("data"),
20920
+ // data passed to validation function
20895
20921
  // args passed from referencing schema
20896
- valCxt: new codegen_1$t.Name("valCxt"),
20897
- instancePath: new codegen_1$t.Name("instancePath"),
20898
- parentData: new codegen_1$t.Name("parentData"),
20899
- parentDataProperty: new codegen_1$t.Name("parentDataProperty"),
20900
- rootData: new codegen_1$t.Name("rootData"),
20901
- 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
20902
20931
  // function scoped variables
20903
- vErrors: new codegen_1$t.Name("vErrors"),
20904
- errors: new codegen_1$t.Name("errors"),
20905
- 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"),
20906
20937
  // "globals"
20907
- self: new codegen_1$t.Name("self"),
20908
- scope: new codegen_1$t.Name("scope"),
20938
+ self: new codegen_1$u.Name("self"),
20939
+ scope: new codegen_1$u.Name("scope"),
20909
20940
  // JTD serialize/parse name for JSON string and position
20910
- json: new codegen_1$t.Name("json"),
20911
- jsonPos: new codegen_1$t.Name("jsonPos"),
20912
- jsonLen: new codegen_1$t.Name("jsonLen"),
20913
- 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")
20914
20945
  };
20915
20946
  names$1.default = names;
20916
20947
  (function(exports2) {
@@ -20983,6 +21014,7 @@ names$1.default = names;
20983
21014
  const E = {
20984
21015
  keyword: new codegen_12.Name("keyword"),
20985
21016
  schemaPath: new codegen_12.Name("schemaPath"),
21017
+ // also used in JTD errors
20986
21018
  params: new codegen_12.Name("params"),
20987
21019
  propertyName: new codegen_12.Name("propertyName"),
20988
21020
  message: new codegen_12.Name("message"),
@@ -21031,8 +21063,8 @@ names$1.default = names;
21031
21063
  })(errors);
21032
21064
  Object.defineProperty(boolSchema, "__esModule", { value: true });
21033
21065
  boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
21034
- const errors_1$2 = errors;
21035
- const codegen_1$s = codegen;
21066
+ const errors_1$3 = errors;
21067
+ const codegen_1$t = codegen;
21036
21068
  const names_1$6 = names$1;
21037
21069
  const boolError = {
21038
21070
  message: "boolean schema is false"
@@ -21044,7 +21076,7 @@ function topBoolOrEmptySchema(it) {
21044
21076
  } else if (typeof schema == "object" && schema.$async === true) {
21045
21077
  gen.return(names_1$6.default.data);
21046
21078
  } else {
21047
- gen.assign((0, codegen_1$s._)`${validateName2}.errors`, null);
21079
+ gen.assign((0, codegen_1$t._)`${validateName2}.errors`, null);
21048
21080
  gen.return(true);
21049
21081
  }
21050
21082
  }
@@ -21071,7 +21103,7 @@ function falseSchemaError(it, overrideAllErrors) {
21071
21103
  params: {},
21072
21104
  it
21073
21105
  };
21074
- (0, errors_1$2.reportError)(cxt, boolError, void 0, overrideAllErrors);
21106
+ (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
21075
21107
  }
21076
21108
  var dataType = {};
21077
21109
  var rules = {};
@@ -21116,185 +21148,183 @@ function shouldUseRule(schema, rule) {
21116
21148
  return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
21117
21149
  }
21118
21150
  applicability.shouldUseRule = shouldUseRule;
21119
- (function(exports2) {
21120
- Object.defineProperty(exports2, "__esModule", { value: true });
21121
- exports2.reportTypeError = exports2.checkDataTypes = exports2.checkDataType = exports2.coerceAndCheckDataType = exports2.getJSONTypes = exports2.getSchemaTypes = exports2.DataType = void 0;
21122
- const rules_1 = rules;
21123
- const applicability_12 = applicability;
21124
- const errors_12 = errors;
21125
- const codegen_12 = codegen;
21126
- const util_12 = util;
21127
- var DataType;
21128
- (function(DataType2) {
21129
- DataType2[DataType2["Correct"] = 0] = "Correct";
21130
- DataType2[DataType2["Wrong"] = 1] = "Wrong";
21131
- })(DataType = exports2.DataType || (exports2.DataType = {}));
21132
- function getSchemaTypes(schema) {
21133
- const types2 = getJSONTypes(schema.type);
21134
- const hasNull = types2.includes("null");
21135
- if (hasNull) {
21136
- if (schema.nullable === false)
21137
- throw new Error("type: null contradicts nullable: false");
21138
- } else {
21139
- if (!types2.length && schema.nullable !== void 0) {
21140
- throw new Error('"nullable" cannot be used without "type"');
21141
- }
21142
- if (schema.nullable === true)
21143
- 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"');
21144
21172
  }
21145
- return types2;
21173
+ if (schema.nullable === true)
21174
+ types2.push("null");
21146
21175
  }
21147
- exports2.getSchemaTypes = getSchemaTypes;
21148
- function getJSONTypes(ts) {
21149
- const types2 = Array.isArray(ts) ? ts : ts ? [ts] : [];
21150
- if (types2.every(rules_1.isJSONType))
21151
- return types2;
21152
- throw new Error("type must be JSONType or JSONType[]: " + types2.join(","));
21153
- }
21154
- exports2.getJSONTypes = getJSONTypes;
21155
- function coerceAndCheckDataType(it, types2) {
21156
- const { gen, data, opts } = it;
21157
- const coerceTo = coerceToTypes(types2, opts.coerceTypes);
21158
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_12.schemaHasRulesForType)(it, types2[0]));
21159
- if (checkTypes) {
21160
- const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
21161
- gen.if(wrongType, () => {
21162
- if (coerceTo.length)
21163
- coerceData(it, types2, coerceTo);
21164
- else
21165
- reportTypeError(it);
21166
- });
21167
- }
21168
- 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
+ });
21169
21198
  }
21170
- exports2.coerceAndCheckDataType = coerceAndCheckDataType;
21171
- const COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
21172
- function coerceToTypes(types2, coerceTypes) {
21173
- 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)));
21174
21212
  }
21175
- function coerceData(it, types2, coerceTo) {
21176
- const { gen, data, opts } = it;
21177
- const dataType2 = gen.let("dataType", (0, codegen_12._)`typeof ${data}`);
21178
- const coerced = gen.let("coerced", (0, codegen_12._)`undefined`);
21179
- if (opts.coerceTypes === "array") {
21180
- 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)));
21181
- }
21182
- gen.if((0, codegen_12._)`${coerced} !== undefined`);
21183
- for (const t of coerceTo) {
21184
- if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
21185
- coerceSpecificType(t);
21186
- }
21187
- }
21188
- gen.else();
21189
- reportTypeError(it);
21190
- gen.endIf();
21191
- gen.if((0, codegen_12._)`${coerced} !== undefined`, () => {
21192
- gen.assign(data, coerced);
21193
- assignParentData(it, coerced);
21194
- });
21195
- function coerceSpecificType(t) {
21196
- switch (t) {
21197
- case "string":
21198
- 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._)`""`);
21199
- return;
21200
- case "number":
21201
- gen.elseIf((0, codegen_12._)`${dataType2} == "boolean" || ${data} === null
21202
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_12._)`+${data}`);
21203
- return;
21204
- case "integer":
21205
- gen.elseIf((0, codegen_12._)`${dataType2} === "boolean" || ${data} === null
21206
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_12._)`+${data}`);
21207
- return;
21208
- case "boolean":
21209
- 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);
21210
- return;
21211
- case "null":
21212
- gen.elseIf((0, codegen_12._)`${data} === "" || ${data} === 0 || ${data} === false`);
21213
- gen.assign(coerced, null);
21214
- return;
21215
- case "array":
21216
- gen.elseIf((0, codegen_12._)`${dataType2} === "string" || ${dataType2} === "number"
21217
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_12._)`[${data}]`);
21218
- }
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);
21219
21217
  }
21220
21218
  }
21221
- function assignParentData({ gen, parentData, parentDataProperty }, expr) {
21222
- gen.if((0, codegen_12._)`${parentData} !== undefined`, () => gen.assign((0, codegen_12._)`${parentData}[${parentDataProperty}]`, expr));
21223
- }
21224
- function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
21225
- const EQ = correct === DataType.Correct ? codegen_12.operators.EQ : codegen_12.operators.NEQ;
21226
- let cond;
21227
- 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;
21228
21242
  case "null":
21229
- 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;
21230
21246
  case "array":
21231
- cond = (0, codegen_12._)`Array.isArray(${data})`;
21232
- break;
21233
- case "object":
21234
- cond = (0, codegen_12._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
21235
- break;
21236
- case "integer":
21237
- cond = numCond((0, codegen_12._)`!(${data} % 1) && !isNaN(${data})`);
21238
- break;
21239
- case "number":
21240
- cond = numCond();
21241
- break;
21242
- default:
21243
- return (0, codegen_12._)`typeof ${data} ${EQ} ${dataType2}`;
21244
- }
21245
- return correct === DataType.Correct ? cond : (0, codegen_12.not)(cond);
21246
- function numCond(_cond = codegen_12.nil) {
21247
- return (0, codegen_12.and)((0, codegen_12._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_12._)`isFinite(${data})` : codegen_12.nil);
21248
- }
21249
- }
21250
- exports2.checkDataType = checkDataType;
21251
- function checkDataTypes(dataTypes, data, strictNums, correct) {
21252
- if (dataTypes.length === 1) {
21253
- return checkDataType(dataTypes[0], data, strictNums, correct);
21254
- }
21255
- let cond;
21256
- const types2 = (0, util_12.toHash)(dataTypes);
21257
- if (types2.array && types2.object) {
21258
- const notObj = (0, codegen_12._)`typeof ${data} != "object"`;
21259
- cond = types2.null ? notObj : (0, codegen_12._)`!${data} || ${notObj}`;
21260
- delete types2.null;
21261
- delete types2.array;
21262
- delete types2.object;
21263
- } else {
21264
- cond = codegen_12.nil;
21265
- }
21266
- if (types2.number)
21267
- delete types2.integer;
21268
- for (const t in types2)
21269
- cond = (0, codegen_12.and)(cond, checkDataType(t, data, strictNums, correct));
21270
- return cond;
21271
- }
21272
- exports2.checkDataTypes = checkDataTypes;
21273
- const typeError = {
21274
- message: ({ schema }) => `must be ${schema}`,
21275
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_12._)`{type: ${schema}}` : (0, codegen_12._)`{type: ${schemaValue}}`
21276
- };
21277
- function reportTypeError(it) {
21278
- const cxt = getTypeErrorContext(it);
21279
- (0, errors_12.reportError)(cxt, typeError);
21280
- }
21281
- exports2.reportTypeError = reportTypeError;
21282
- function getTypeErrorContext(it) {
21283
- const { gen, data, schema } = it;
21284
- const schemaCode = (0, util_12.schemaRefOrVal)(it, schema, "type");
21285
- return {
21286
- gen,
21287
- keyword: "type",
21288
- data,
21289
- schema: schema.type,
21290
- schemaCode,
21291
- schemaValue: schemaCode,
21292
- parentSchema: schema,
21293
- params: {},
21294
- it
21295
- };
21247
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
21248
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
21249
+ }
21296
21250
  }
21297
- })(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
+ }
21298
21328
  var defaults = {};
21299
21329
  Object.defineProperty(defaults, "__esModule", { value: true });
21300
21330
  defaults.assignDefaults = void 0;
@@ -21681,15 +21711,7 @@ var fastDeepEqual = function equal(a, b) {
21681
21711
  }
21682
21712
  return a !== a && b !== b;
21683
21713
  };
21684
- var jsonSchemaTraverseExports = {};
21685
- var jsonSchemaTraverse = {
21686
- get exports() {
21687
- return jsonSchemaTraverseExports;
21688
- },
21689
- set exports(v) {
21690
- jsonSchemaTraverseExports = v;
21691
- }
21692
- };
21714
+ var jsonSchemaTraverse = { exports: {} };
21693
21715
  var traverse$1 = jsonSchemaTraverse.exports = function(schema, opts, cb) {
21694
21716
  if (typeof opts == "function") {
21695
21717
  cb = opts;
@@ -21771,6 +21793,7 @@ function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr,
21771
21793
  function escapeJsonPtr(str) {
21772
21794
  return str.replace(/~/g, "~0").replace(/\//g, "~1");
21773
21795
  }
21796
+ var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
21774
21797
  Object.defineProperty(resolve$1, "__esModule", { value: true });
21775
21798
  resolve$1.getSchemaRefs = resolve$1.resolveUrl = resolve$1.normalizeId = resolve$1._getFullPath = resolve$1.getFullPath = resolve$1.inlineRef = void 0;
21776
21799
  const util_1$m = util;
@@ -21875,15 +21898,15 @@ function getSchemaRefs(schema, baseId) {
21875
21898
  if (parentJsonPtr === void 0)
21876
21899
  return;
21877
21900
  const fullPath = pathPrefix + jsonPtr;
21878
- let baseId2 = baseIds[parentJsonPtr];
21901
+ let innerBaseId = baseIds[parentJsonPtr];
21879
21902
  if (typeof sch[schemaId] == "string")
21880
- baseId2 = addRef.call(this, sch[schemaId]);
21903
+ innerBaseId = addRef.call(this, sch[schemaId]);
21881
21904
  addAnchor.call(this, sch.$anchor);
21882
21905
  addAnchor.call(this, sch.$dynamicAnchor);
21883
- baseIds[jsonPtr] = baseId2;
21906
+ baseIds[jsonPtr] = innerBaseId;
21884
21907
  function addRef(ref2) {
21885
21908
  const _resolve = this.opts.uriResolver.resolve;
21886
- ref2 = normalizeId(baseId2 ? _resolve(baseId2, ref2) : ref2);
21909
+ ref2 = normalizeId(innerBaseId ? _resolve(innerBaseId, ref2) : ref2);
21887
21910
  if (schemaRefs.has(ref2))
21888
21911
  throw ambiguos(ref2);
21889
21912
  schemaRefs.add(ref2);
@@ -22495,6 +22518,7 @@ function compileSchema(sch) {
22495
22518
  parentDataProperty: names_1$2.default.parentDataProperty,
22496
22519
  dataNames: [names_1$2.default.data],
22497
22520
  dataPathArr: [codegen_1$m.nil],
22521
+ // TODO can its length be used as dataLevel if nil is removed?
22498
22522
  dataLevel: 0,
22499
22523
  dataTypes: [],
22500
22524
  definedProperties: /* @__PURE__ */ new Set(),
@@ -22687,15 +22711,7 @@ const require$$9$1 = {
22687
22711
  additionalProperties: additionalProperties$a
22688
22712
  };
22689
22713
  var uri$1 = {};
22690
- var uri_allExports = {};
22691
- var uri_all = {
22692
- get exports() {
22693
- return uri_allExports;
22694
- },
22695
- set exports(v) {
22696
- uri_allExports = v;
22697
- }
22698
- };
22714
+ var uri_all = { exports: {} };
22699
22715
  /** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
22700
22716
  (function(module2, exports2) {
22701
22717
  (function(global2, factory) {
@@ -23735,7 +23751,8 @@ var uri_all = {
23735
23751
  exports3.unescapeComponent = unescapeComponent;
23736
23752
  Object.defineProperty(exports3, "__esModule", { value: true });
23737
23753
  });
23738
- })(uri_all, uri_allExports);
23754
+ })(uri_all, uri_all.exports);
23755
+ var uri_allExports = uri_all.exports;
23739
23756
  Object.defineProperty(uri$1, "__esModule", { value: true });
23740
23757
  const uri = uri_allExports;
23741
23758
  uri.code = 'require("ajv/dist/runtime/uri").default';
@@ -23768,7 +23785,7 @@ uri$1.default = uri;
23768
23785
  } });
23769
23786
  const validation_error_12 = validation_error;
23770
23787
  const ref_error_12 = ref_error;
23771
- const rules_1 = rules;
23788
+ const rules_12 = rules;
23772
23789
  const compile_12 = compile;
23773
23790
  const codegen_2 = codegen;
23774
23791
  const resolve_12 = resolve$1;
@@ -23859,7 +23876,7 @@ uri$1.default = uri;
23859
23876
  this.logger = getLogger(opts.logger);
23860
23877
  const formatOpt = opts.validateFormats;
23861
23878
  opts.validateFormats = false;
23862
- this.RULES = (0, rules_1.getRules)();
23879
+ this.RULES = (0, rules_12.getRules)();
23863
23880
  checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED");
23864
23881
  checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn");
23865
23882
  this._metaOpts = getMetaSchemaOptions.call(this);
@@ -24215,9 +24232,9 @@ uri$1.default = uri;
24215
24232
  }
24216
24233
  }
24217
24234
  }
24218
- exports2.default = Ajv2;
24219
24235
  Ajv2.ValidationError = validation_error_12.default;
24220
24236
  Ajv2.MissingRefError = ref_error_12.default;
24237
+ exports2.default = Ajv2;
24221
24238
  function checkOptions(checkOpts, options2, msg, log = "error") {
24222
24239
  for (const key in checkOpts) {
24223
24240
  const opt = key;
@@ -25811,14 +25828,13 @@ const draft7Vocabularies = [
25811
25828
  draft7.default = draft7Vocabularies;
25812
25829
  var discriminator = {};
25813
25830
  var types = {};
25814
- (function(exports2) {
25815
- Object.defineProperty(exports2, "__esModule", { value: true });
25816
- exports2.DiscrError = void 0;
25817
- (function(DiscrError) {
25818
- DiscrError["Tag"] = "tag";
25819
- DiscrError["Mapping"] = "mapping";
25820
- })(exports2.DiscrError || (exports2.DiscrError = {}));
25821
- })(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 = {}));
25822
25838
  Object.defineProperty(discriminator, "__esModule", { value: true });
25823
25839
  const codegen_1 = codegen;
25824
25840
  const types_1 = types;
@@ -26162,7 +26178,7 @@ const require$$3$2 = {
26162
26178
  };
26163
26179
  (function(module2, exports2) {
26164
26180
  Object.defineProperty(exports2, "__esModule", { value: true });
26165
- 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;
26166
26182
  const core_12 = core$2;
26167
26183
  const draft7_1 = draft7;
26168
26184
  const discriminator_1 = discriminator;
@@ -26188,7 +26204,9 @@ const require$$3$2 = {
26188
26204
  return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
26189
26205
  }
26190
26206
  }
26207
+ exports2.Ajv = Ajv2;
26191
26208
  module2.exports = exports2 = Ajv2;
26209
+ module2.exports.Ajv = Ajv2;
26192
26210
  Object.defineProperty(exports2, "__esModule", { value: true });
26193
26211
  exports2.default = Ajv2;
26194
26212
  var validate_12 = validate;
@@ -26222,7 +26240,8 @@ const require$$3$2 = {
26222
26240
  Object.defineProperty(exports2, "MissingRefError", { enumerable: true, get: function() {
26223
26241
  return ref_error_12.default;
26224
26242
  } });
26225
- })(ajv, ajvExports);
26243
+ })(ajv, ajv.exports);
26244
+ var ajvExports = ajv.exports;
26226
26245
  const title$9 = "Root";
26227
26246
  const type$p = "object";
26228
26247
  const description$9 = "Root Element";
@@ -32303,6 +32322,7 @@ function deepCopy(e, t = defaultOpts) {
32303
32322
  return t.detectCircular && s.setAsCopied(e, n), copyObjectContents(e, { destObject: n, srcType: c, watcher: s, options: t }, 0), n;
32304
32323
  }
32305
32324
  var deepCopyAll_min = deepCopy;
32325
+ const deepCopy$1 = /* @__PURE__ */ getDefaultExportFromCjs(deepCopyAll_min);
32306
32326
  var _deepCopyAll = _interopRequireDefault$1(deepCopyAll_min);
32307
32327
  function _interopRequireDefault$1(obj) {
32308
32328
  return obj && obj.__esModule ? obj : { default: obj };
@@ -34164,7 +34184,7 @@ const parseUsfm = (str, parser) => {
34164
34184
  parser.parseItem(preTokenObjectForFragment(matches[n], lexingRegexes));
34165
34185
  }
34166
34186
  };
34167
- var sax = {};
34187
+ var sax$1 = {};
34168
34188
  var emitterComponent;
34169
34189
  var hasRequiredEmitterComponent;
34170
34190
  function requireEmitterComponent() {
@@ -34318,15 +34338,7 @@ function requireStream() {
34318
34338
  return stream;
34319
34339
  }
34320
34340
  var string_decoder = {};
34321
- var safeBufferExports = {};
34322
- var safeBuffer = {
34323
- get exports() {
34324
- return safeBufferExports;
34325
- },
34326
- set exports(v) {
34327
- safeBufferExports = v;
34328
- }
34329
- };
34341
+ var safeBuffer = { exports: {} };
34330
34342
  var buffer = {};
34331
34343
  var ieee754 = {};
34332
34344
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -36121,7 +36133,7 @@ function requireBuffer() {
36121
36133
  var hasRequiredSafeBuffer;
36122
36134
  function requireSafeBuffer() {
36123
36135
  if (hasRequiredSafeBuffer)
36124
- return safeBufferExports;
36136
+ return safeBuffer.exports;
36125
36137
  hasRequiredSafeBuffer = 1;
36126
36138
  (function(module2, exports2) {
36127
36139
  var buffer2 = requireBuffer();
@@ -36176,8 +36188,8 @@ function requireSafeBuffer() {
36176
36188
  }
36177
36189
  return buffer2.SlowBuffer(size);
36178
36190
  };
36179
- })(safeBuffer, safeBufferExports);
36180
- return safeBufferExports;
36191
+ })(safeBuffer, safeBuffer.exports);
36192
+ return safeBuffer.exports;
36181
36193
  }
36182
36194
  var hasRequiredString_decoder;
36183
36195
  function requireString_decoder() {
@@ -36595,6 +36607,9 @@ function requireString_decoder() {
36595
36607
  Stream = function() {
36596
36608
  };
36597
36609
  }
36610
+ if (!Stream)
36611
+ Stream = function() {
36612
+ };
36598
36613
  var streamWraps = sax2.EVENTS.filter(function(ev) {
36599
36614
  return ev !== "error" && ev !== "end";
36600
36615
  });
@@ -37805,9 +37820,16 @@ function requireString_decoder() {
37805
37820
  break;
37806
37821
  }
37807
37822
  if (c === ";") {
37808
- parser[buffer2] += parseEntity(parser);
37809
- parser.entity = "";
37810
- 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
+ }
37811
37833
  } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
37812
37834
  parser.entity += c;
37813
37835
  } else {
@@ -37817,8 +37839,9 @@ function requireString_decoder() {
37817
37839
  parser.state = returnState;
37818
37840
  }
37819
37841
  continue;
37820
- default:
37842
+ default: {
37821
37843
  throw new Error(parser, "Unknown state: " + parser.state);
37844
+ }
37822
37845
  }
37823
37846
  }
37824
37847
  if (parser.position >= parser.bufferCheckPosition) {
@@ -37877,7 +37900,8 @@ function requireString_decoder() {
37877
37900
  })();
37878
37901
  }
37879
37902
  })(exports2);
37880
- })(sax);
37903
+ })(sax$1);
37904
+ const sax = /* @__PURE__ */ getDefaultExportFromCjs(sax$1);
37881
37905
  class UsxLexer {
37882
37906
  constructor() {
37883
37907
  this.sax = sax.parser(true);
@@ -39003,6 +39027,7 @@ const parseNodes = (str, parser, bookCode) => {
39003
39027
  });
39004
39028
  };
39005
39029
  const { labelForScope: labelForScope$2 } = utils.scopeDefs;
39030
+ const idTest = new RegExp(/^[A-Z0-9_]+$/);
39006
39031
  const buildSpecLookup = (specs2) => {
39007
39032
  const ret = {};
39008
39033
  for (const spec of specs2) {
@@ -39047,9 +39072,9 @@ const specs = (pt) => [
39047
39072
  onEnd: (parser, label) => {
39048
39073
  parser.headers[label] = parser.current.sequence.plainText();
39049
39074
  if (label === "id") {
39050
- if (parser.headers[label].length === 3 || parser.headers[label].length > 3 && parser.headers[label].substring(3, 4) === " ") {
39051
- const bookCode = parser.headers[label].substring(0, 3);
39052
- 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];
39053
39078
  }
39054
39079
  }
39055
39080
  }
@@ -41447,7 +41472,7 @@ const pushModifiedBlocks = (oldSequence, newSequence2, blockFilterFunc, itemFilt
41447
41472
  newSequence2.blocks = [];
41448
41473
  for (const [blockN, block2] of oldSequence.blocks.entries()) {
41449
41474
  if (blockFilterFunc(oldSequence, blockN, block2)) {
41450
- const newBlock2 = blockRewriteFunc(oldSequence, blockN, deepCopyAll_min(block2));
41475
+ const newBlock2 = blockRewriteFunc(oldSequence, blockN, deepCopy$1(block2));
41451
41476
  newBlock2.c.clear();
41452
41477
  modifyBlockItems(
41453
41478
  oldSequence,
@@ -44255,8 +44280,14 @@ const blockResolvers = {
44255
44280
  return context.docSet.unsuccinctifyItemsWithScriptureCV(
44256
44281
  root,
44257
44282
  args.withScriptureCV,
44258
- {},
44259
- args.includeContext || false
44283
+ args.excludeScopeTypes ? {
44284
+ tokens: true,
44285
+ scopes: true,
44286
+ grafts: true,
44287
+ excludeScopeTypes: args.excludeScopeTypes || [],
44288
+ anyScope: args.anyScope || false,
44289
+ includeContext: args.includeContext || false
44290
+ } : {}
44260
44291
  );
44261
44292
  } else {
44262
44293
  return context.docSet.unsuccinctifyPrunedItems(root, {