@claritylabs/cl-sdk 3.0.31 → 3.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3313,6 +3313,15 @@ function moneyValue(value) {
3313
3313
  if (/^\d{1,3}(?:,\d{3})*(?:\.\d{2})?$/.test(clean)) return `$${clean}`;
3314
3314
  return clean;
3315
3315
  }
3316
+ function premiumValue(value) {
3317
+ const clean = cleanValue(value);
3318
+ if (!clean) return void 0;
3319
+ if (/\$[A-Z0-9]/i.test(clean)) return clean;
3320
+ if (/\b(?:CAD|USD)\b/i.test(clean) && /(?:\d|X{2,})/i.test(clean)) return clean;
3321
+ if (/^\d{1,3}(?:,\d{3})+\.\d{2}$/.test(clean) || /^\d+\.\d{2}$/.test(clean)) return `$${clean}`;
3322
+ if (/^X{2,}(?:,X{3})*(?:\.X{2})$/i.test(clean)) return clean;
3323
+ return void 0;
3324
+ }
3316
3325
  function nodeText(node) {
3317
3326
  return normalizeWhitespace3([
3318
3327
  node.title,
@@ -3394,7 +3403,11 @@ function firstCleanMatch(nodes, patterns, clean) {
3394
3403
  function cleanNamedInsured(value) {
3395
3404
  const clean = cleanValue(value.replace(/\bborn\s+on\b.*$/i, "").replace(/\bage\s+nearest\b.*$/i, "").replace(/\bbeneficiary\b.*$/i, ""));
3396
3405
  if (!clean || clean.length > 160) return void 0;
3406
+ if (!/[A-Za-z0-9]/.test(clean)) return void 0;
3397
3407
  if (/^(person|persons)\b/i.test(clean)) return void 0;
3408
+ if (/^(insurance amount|benefit amount|policy number|policy date|owner|beneficiary|premium|coverage|risk classification)\b/i.test(clean)) {
3409
+ return void 0;
3410
+ }
3398
3411
  if (/\b(table of contents|policy wording|provided solely|convenience|not to be construed|actual policy issued)\b/i.test(clean)) {
3399
3412
  return void 0;
3400
3413
  }
@@ -3402,7 +3415,8 @@ function cleanNamedInsured(value) {
3402
3415
  }
3403
3416
  function namedInsuredFromNodes(nodes) {
3404
3417
  return firstCleanMatch(nodes, [
3405
- /\b(?:named insured|insured name|insured persons?|insured person)\s*:?\s*(.+?)(?=\s+(?:insurance amount|benefit amount|policy number|policy date|owner|beneficiary|premium|coverage|risk classification|date this)\b|[|;\n]|$)/i,
3418
+ /\b(?:named insured|insured name)\s*:?\s*(.+?)(?=\s+(?:insurance amount|benefit amount|policy number|policy date|owner|beneficiary|premium|coverage|risk classification|date this)\b|[|;\n]|$)/i,
3419
+ /\b(?:insured persons?|insured person)\s*:\s*(.+?)(?=\s+(?:insurance amount|benefit amount|policy number|policy date|owner|beneficiary|premium|coverage|risk classification|date this)\b|[|;\n]|$)/i,
3406
3420
  /\b(?:applicant|policyholder)\s*:?\s*(.+?)(?=\s+(?:coverage|policy number|insurer|carrier|premium|effective|expiration)\b|[|;\n]|$)/i
3407
3421
  ], cleanNamedInsured);
3408
3422
  }
@@ -3469,7 +3483,14 @@ function deductibleFromText(text) {
3469
3483
  return moneyValue(text.match(/\b(?:deductible|retention|sir)\s*:?\s*(\$?\d[\d,]*(?:\.\d{2})?)/i)?.[1]);
3470
3484
  }
3471
3485
  function premiumFromText(text) {
3472
- return moneyValue(text.match(/\b(?:premium|total premium|total cost|amount due)\s*:?\s*(\$?\d[\d,]*(?:\.\d{2})?)/i)?.[1]);
3486
+ return premiumValue(text.match(/\b(?:premium|total premium|total cost|amount due)\b(?:\s*(?:is|:|-))?\s*(\$?(?:\d[\d,]*(?:\.\d{2})?|X{2,}(?:,X{3})*(?:\.X{2})?))/i)?.[1]);
3487
+ }
3488
+ function premiumFromNodes(nodes) {
3489
+ for (const node of compactFactNodes(nodes)) {
3490
+ const value = premiumFromText(nodeText(node));
3491
+ if (value) return valueFromNode(node, value, "high");
3492
+ }
3493
+ return void 0;
3473
3494
  }
3474
3495
  function moneyAmount(value) {
3475
3496
  const match = value?.match(/\$?\s*([0-9][0-9,]*(?:\.\d+)?)/);
@@ -3891,9 +3912,7 @@ function buildDeterministicOperationalProfile(params) {
3891
3912
  retroactiveDate: firstMatch(nodes, [
3892
3913
  /\bretroactive date\s*:?\s*([0-9]{1,2}[/-][0-9]{1,2}[/-][0-9]{2,4}|full prior acts|none)/i
3893
3914
  ]),
3894
- premium: firstMatch(nodes, [
3895
- /\b(?:total premium|premium|total cost|amount due)\s*:?\s*(\$?\d[\d,]*(?:\.\d{2})?)/i
3896
- ])
3915
+ premium: premiumFromNodes(nodes)
3897
3916
  };
3898
3917
  const coverages = buildCoverages(nodes);
3899
3918
  const coverageTypes = [...new Set(coverages.map((coverage) => coverage.name))];