@inploi/plugin-chatbot 3.25.0 → 3.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { g as get$1, i as isString$1, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, N, c as getFlowSubmissionsPayload, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as k, m as k$1, n as getFormSubmitter, q as parse, r as picklist, t as isSubmissionOfType, C as Cn, u as parseAsync, V as ValiError, v as object, w as transform, x as cva, z as maxLength, B as minLength, D as record, E as boolean, G as number, H as minValue, I as maxValue, J as custom, K as string, L as email, M as url, O as regex, P as LoadingIndicator, Q as ERROR_MESSAGES } from "./index-91ddb671.js";
1
+ import { g as get$1, i as isString$2, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, N, c as getFlowSubmissionsPayload, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as k, m as k$1, n as getFormSubmitter, q as parse, r as picklist, t as isSubmissionOfType, C as Cn, u as parseAsync, V as ValiError, v as object, w as transform, x as cva, z as maxLength, B as minLength, D as record, E as boolean, G as number, H as minValue, I as maxValue, J as custom, K as string, L as regex, M as email, O as url, P as LoadingIndicator, Q as ERROR_MESSAGES } from "./index-dd385762.js";
2
2
  import "@inploi/sdk";
3
3
  const isIfBlockConditionMet = (ifBlock, {
4
4
  context,
@@ -79,7 +79,7 @@ const isIfBlockConditionMet = (ifBlock, {
79
79
  context
80
80
  });
81
81
  case "object":
82
- if (Array.isArray(value) && value.every(isString$1)) {
82
+ if (Array.isArray(value) && value.every(isString$2)) {
83
83
  return isIfBlockConditionMet(newIfBlock, {
84
84
  submissions: {
85
85
  ["_temp"]: {
@@ -201,7 +201,7 @@ const interpolateWithData = (str, {
201
201
  case "number":
202
202
  return value.toString();
203
203
  case "object":
204
- if (Array.isArray(value) && value.every(isString$1)) {
204
+ if (Array.isArray(value) && value.every(isString$2)) {
205
205
  return value.join(", ");
206
206
  }
207
207
  }
@@ -478,17 +478,25 @@ async function interpretSubmitNode({
478
478
  });
479
479
  }).otherwise(() => {
480
480
  });
481
- await N(response).with({
482
- ats_data: {
481
+ await N(response).with(_.union({
482
+ ats_data: _.select("redirect", {
483
483
  redirect_url: _.string
484
+ })
485
+ }, {
486
+ integration_response: {
487
+ data: _.select("redirect", {
488
+ redirect_url: _.string
489
+ })
484
490
  }
485
- }, async (response2) => {
491
+ }), async (response2) => {
492
+ if (response2.redirect === void 0)
493
+ return;
486
494
  await chat.sendMessage({
487
495
  type: "text",
488
496
  author: "bot",
489
497
  text: "Almost there! Please complete your submission here:"
490
498
  });
491
- const href = new URL(response2.ats_data.redirect_url);
499
+ const href = new URL(response2.redirect.redirect_url);
492
500
  if (anonymous_id && !href.searchParams.has("anonymous_id")) {
493
501
  href.searchParams.set("anonymous_id", anonymous_id);
494
502
  }
@@ -497,8 +505,10 @@ async function interpretSubmitNode({
497
505
  href: href.toString(),
498
506
  text: "Complete submission",
499
507
  onClick: () => {
500
- if (!session_id)
501
- return logger.error("session_id not set, cannot log FLOW_REDIRECT event");
508
+ if (!session_id) {
509
+ logger.error("session_id not set, cannot log FLOW_REDIRECT event");
510
+ return;
511
+ }
502
512
  analytics.log({
503
513
  event: "FLOW_REDIRECT",
504
514
  properties: {
@@ -522,17 +532,24 @@ async function interpretSubmitNode({
522
532
  text: "Submission completed!"
523
533
  });
524
534
  next(node.nextId);
525
- }).with({
526
- sucess: false,
527
- ats_data: {
535
+ }).with(_.union({
536
+ success: false,
537
+ ats_data: _.select("error", {
528
538
  message: _.string
539
+ })
540
+ }, {
541
+ integration_response: {
542
+ error: _.select("error", {
543
+ message: _.string
544
+ })
529
545
  }
530
- }, async (response2) => {
531
- logger.error(response2.ats_data);
546
+ }), async (response2) => {
547
+ var _a;
548
+ logger.error(response2.error);
532
549
  await chat.sendMessage({
533
550
  type: "system",
534
551
  variant: "error",
535
- text: response2.ats_data.message
552
+ text: ((_a = response2.error) == null ? void 0 : _a.message) || "Failed to submit"
536
553
  });
537
554
  await submit(false);
538
555
  }).otherwise(async (response2) => {
@@ -624,7 +641,16 @@ async function interpretQuestionTextNode({
624
641
  context
625
642
  })
626
643
  });
627
- const reply = await chat.userInput({
644
+ const reply = node.data.format === "phone" ? await chat.userInput({
645
+ key: node.data.key,
646
+ type: "phone",
647
+ config: {
648
+ optional: node.data.optional,
649
+ placeholder: node.data.placeholder,
650
+ maxChars: node.data.maxChars,
651
+ minChars: node.data.minChars
652
+ }
653
+ }) : await chat.userInput({
628
654
  key: node.data.key,
629
655
  type: "text",
630
656
  config: {
@@ -1229,7 +1255,256 @@ const SkipButton = ({
1229
1255
  })]
1230
1256
  }), "Skip"]
1231
1257
  });
1232
- const countryNames = ["Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Caribbean Netherlands", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Curaçao", "Cyprus", "Czechia", "Côte d'Ivoire", "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Eswatini", "Ethiopia", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern and Antarctic Lands", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar (Burma)", "Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "North Macedonia", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestine", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Réunion", "Saint Barthélemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Sweden", "Switzerland", "Syria", "São Tomé and Príncipe", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas", "The Gambia", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Türkiye", "U.S. Virgin Islands", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe", "Åland Islands"];
1258
+ const countries = {
1259
+ Afghanistan: "93",
1260
+ Albania: "355",
1261
+ Algeria: "213",
1262
+ "American Samoa": "1",
1263
+ Andorra: "376",
1264
+ Angola: "244",
1265
+ Anguilla: "1",
1266
+ Antarctica: "672",
1267
+ "Antigua and Barbuda": "1",
1268
+ Argentina: "54",
1269
+ Armenia: "374",
1270
+ Aruba: "297",
1271
+ Australia: "61",
1272
+ Austria: "43",
1273
+ Azerbaijan: "994",
1274
+ Bahrain: "973",
1275
+ Bangladesh: "880",
1276
+ Barbados: "1",
1277
+ Belarus: "375",
1278
+ Belgium: "32",
1279
+ Belize: "501",
1280
+ Benin: "229",
1281
+ Bermuda: "1",
1282
+ Bhutan: "975",
1283
+ Bolivia: "591",
1284
+ "Bosnia and Herzegovina": "387",
1285
+ Botswana: "267",
1286
+ "Bouvet Island": "47",
1287
+ Brazil: "55",
1288
+ "British Indian Ocean Territory": "246",
1289
+ "British Virgin Islands": "1",
1290
+ Brunei: "673",
1291
+ Bulgaria: "359",
1292
+ "Burkina Faso": "226",
1293
+ Burundi: "257",
1294
+ "Cabo Verde": "238",
1295
+ Cambodia: "855",
1296
+ Cameroon: "237",
1297
+ Canada: "1",
1298
+ "Caribbean Netherlands": "599",
1299
+ "Cayman Islands": "1",
1300
+ "Central African Republic": "236",
1301
+ Chad: "235",
1302
+ Chile: "56",
1303
+ China: "86",
1304
+ "Christmas Island": "61",
1305
+ "Cocos (Keeling) Islands": "61",
1306
+ Colombia: "57",
1307
+ Comoros: "269",
1308
+ "Cook Islands": "682",
1309
+ "Costa Rica": "506",
1310
+ Croatia: "385",
1311
+ Cuba: "53",
1312
+ Curaçao: "599",
1313
+ Cyprus: "357",
1314
+ Czechia: "420",
1315
+ "Côte d'Ivoire": "225",
1316
+ "Democratic Republic of the Congo": "243",
1317
+ Denmark: "45",
1318
+ Djibouti: "253",
1319
+ "Dominican Republic": "1",
1320
+ Ecuador: "593",
1321
+ Egypt: "20",
1322
+ "El Salvador": "503",
1323
+ "Equatorial Guinea": "240",
1324
+ Eritrea: "291",
1325
+ Estonia: "372",
1326
+ Eswatini: "268",
1327
+ Ethiopia: "251",
1328
+ "Falkland Islands (Islas Malvinas)": "500",
1329
+ "Faroe Islands": "298",
1330
+ Fiji: "679",
1331
+ Finland: "358",
1332
+ France: "33",
1333
+ "French Guiana": "594",
1334
+ "French Polynesia": "689",
1335
+ "French Southern and Antarctic Lands": "260",
1336
+ Gabon: "241",
1337
+ Georgia: "995",
1338
+ Germany: "49",
1339
+ Ghana: "233",
1340
+ Gibraltar: "350",
1341
+ Greece: "30",
1342
+ Greenland: "299",
1343
+ Grenada: "1",
1344
+ Guadeloupe: "590",
1345
+ Guam: "1",
1346
+ Guatemala: "502",
1347
+ Guernsey: "44",
1348
+ Guinea: "224",
1349
+ "Guinea-Bissau": "245",
1350
+ Guyana: "592",
1351
+ Haiti: "509",
1352
+ "Heard Island and McDonald Islands": "334",
1353
+ Honduras: "504",
1354
+ "Hong Kong": "852",
1355
+ Hungary: "36",
1356
+ Iceland: "354",
1357
+ India: "91",
1358
+ Indonesia: "62",
1359
+ Iran: "98",
1360
+ Iraq: "964",
1361
+ Ireland: "352",
1362
+ "Isle of Man": "44",
1363
+ Israel: "972",
1364
+ Italy: "39",
1365
+ Jamaica: "1",
1366
+ Japan: "81",
1367
+ Jersey: "44",
1368
+ Jordan: "962",
1369
+ Kazakhstan: "7",
1370
+ Kenya: "254",
1371
+ Kiribati: "686",
1372
+ Kosovo: "383",
1373
+ Kuwait: "965",
1374
+ Kyrgyzstan: "996",
1375
+ Laos: "856",
1376
+ Latvia: "371",
1377
+ Lebanon: "961",
1378
+ Lesotho: "266",
1379
+ Liberia: "231",
1380
+ Libya: "218",
1381
+ Liechtenstein: "423",
1382
+ Lithuania: "370",
1383
+ Luxembourg: "352",
1384
+ Macao: "853",
1385
+ Madagascar: "261",
1386
+ Malawi: "265",
1387
+ Malaysia: "60",
1388
+ Maldives: "960",
1389
+ Mali: "223",
1390
+ Malta: "356",
1391
+ "Marshall Islands": "692",
1392
+ Martinique: "596",
1393
+ Mauritania: "222",
1394
+ Mauritius: "230",
1395
+ Mayotte: "262",
1396
+ Mexico: "52",
1397
+ Micronesia: "691",
1398
+ Moldova: "373",
1399
+ Monaco: "377",
1400
+ Mongolia: "976",
1401
+ Montenegro: "382",
1402
+ Montserrat: "1",
1403
+ Morocco: "212",
1404
+ Mozambique: "258",
1405
+ "Myanmar (Burma)": "95",
1406
+ Namibia: "264",
1407
+ Nauru: "674",
1408
+ Nepal: "977",
1409
+ Netherlands: "31",
1410
+ "New Caledonia": "687",
1411
+ "New Zealand": "64",
1412
+ Nicaragua: "505",
1413
+ Niger: "227",
1414
+ Nigeria: "234",
1415
+ Niue: "683",
1416
+ "Norfolk Island": "672",
1417
+ "North Korea": "852",
1418
+ "North Macedonia": "389",
1419
+ "Northern Mariana Islands": "1",
1420
+ Norway: "47",
1421
+ Oman: "968",
1422
+ Pakistan: "92",
1423
+ Palau: "680",
1424
+ Palestine: "970",
1425
+ Panama: "507",
1426
+ "Papua New Guinea": "675",
1427
+ Paraguay: "595",
1428
+ Peru: "51",
1429
+ Philippines: "63",
1430
+ "Pitcairn Islands": "64",
1431
+ Poland: "48",
1432
+ Portugal: "351",
1433
+ "Puerto Rico": "1",
1434
+ Qatar: "974",
1435
+ Romania: "40",
1436
+ Russia: "7",
1437
+ Rwanda: "250",
1438
+ Réunion: "262",
1439
+ "Saint Barthélemy": "590",
1440
+ "Saint Helena, Ascension and Tristan da Cunha": "290",
1441
+ "Saint Kitts and Nevis": "1",
1442
+ "Saint Lucia": "1",
1443
+ "Saint Martin": "590",
1444
+ "Saint Pierre and Miquelon": "508",
1445
+ "Saint Vincent and the Grenadines": "1",
1446
+ Samoa: "685",
1447
+ "San Marino": "378",
1448
+ "Saudi Arabia": "966",
1449
+ Senegal: "221",
1450
+ Serbia: "381",
1451
+ Seychelles: "248",
1452
+ "Sierra Leone": "232",
1453
+ Singapore: "65",
1454
+ "Sint Maarten": "1",
1455
+ Slovakia: "421",
1456
+ Slovenia: "386",
1457
+ "Solomon Islands": "677",
1458
+ Somalia: "252",
1459
+ "South Africa": "27",
1460
+ "South Georgia and the South Sandwich Islands": "500",
1461
+ "South Korea": "82",
1462
+ "South Sudan": "211",
1463
+ Spain: "34",
1464
+ "Sri Lanka": "94",
1465
+ Sudan: "249",
1466
+ Suriname: "597",
1467
+ "Svalbard and Jan Mayen": "47",
1468
+ Sweden: "46",
1469
+ Switzerland: "41",
1470
+ Syria: "963",
1471
+ "São Tomé and Príncipe": "293",
1472
+ Taiwan: "886",
1473
+ Tajikistan: "992",
1474
+ Tanzania: "255",
1475
+ Thailand: "66",
1476
+ "The Bahamas": "1",
1477
+ "The Gambia": "220",
1478
+ "Timor-Leste": "670",
1479
+ Togo: "228",
1480
+ Tokelau: "690",
1481
+ Tonga: "676",
1482
+ "Trinidad and Tobago": "1",
1483
+ Tunisia: "216",
1484
+ Turkmenistan: "993",
1485
+ "Turks and Caicos Islands": "1",
1486
+ Tuvalu: "688",
1487
+ Türkiye: "90",
1488
+ "U.S. Virgin Islands": "1",
1489
+ Uganda: "256",
1490
+ Ukraine: "380",
1491
+ "United Arab Emirates": "971",
1492
+ "United Kingdom": "44",
1493
+ "United States": "1",
1494
+ "United States Minor Outlying Islands": "1",
1495
+ Uruguay: "598",
1496
+ Uzbekistan: "998",
1497
+ Vanuatu: "678",
1498
+ "Vatican City": "379",
1499
+ Venezuela: "58",
1500
+ Vietnam: "84",
1501
+ "Wallis and Futuna": "681",
1502
+ "Western Sahara": "212",
1503
+ Yemen: "967",
1504
+ Zambia: "260",
1505
+ Zimbabwe: "263",
1506
+ "Åland Islands": "358"
1507
+ };
1233
1508
  const keyToAddressComponents = {
1234
1509
  line1: ["street_number", "floor", "room", "premise"],
1235
1510
  line2: ["subpremise", "street_address", "route"],
@@ -1558,6 +1833,7 @@ const ChatInputAddressDetails = ({
1558
1833
  }
1559
1834
  }
1560
1835
  }, []);
1836
+ const countryNames = Object.keys(countries);
1561
1837
  return o$1("form", {
1562
1838
  class: "bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",
1563
1839
  onSubmit: (e) => {
@@ -1586,7 +1862,7 @@ const ChatInputAddressDetails = ({
1586
1862
  children: [key === "country" ? o$1("div", {
1587
1863
  class: "relative",
1588
1864
  children: [o$1("select", {
1589
- class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",
1865
+ class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",
1590
1866
  name,
1591
1867
  id: labelId,
1592
1868
  defaultValue: addressFields[key],
@@ -1597,10 +1873,10 @@ const ChatInputAddressDetails = ({
1597
1873
  }) : o$1("option", {
1598
1874
  value: "",
1599
1875
  children: "Select a country"
1600
- }), countryNames.map((country) => o$1("option", {
1601
- value: country,
1602
- children: country
1603
- }, country))]
1876
+ }), countryNames.map((countryName) => o$1("option", {
1877
+ value: countryName,
1878
+ children: countryName
1879
+ }, countryName))]
1604
1880
  }), o$1("svg", {
1605
1881
  class: "text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",
1606
1882
  width: "16",
@@ -2071,9 +2347,9 @@ function useSubscribe(props) {
2071
2347
  };
2072
2348
  }, [props.disabled]);
2073
2349
  }
2074
- var isString = (value) => typeof value === "string";
2350
+ var isString$1 = (value) => typeof value === "string";
2075
2351
  var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
2076
- if (isString(names)) {
2352
+ if (isString$1(names)) {
2077
2353
  isGlobal && _names.watch.add(names);
2078
2354
  return get(formValues, names, defaultValue);
2079
2355
  }
@@ -2149,7 +2425,7 @@ var isHTMLElement = (value) => {
2149
2425
  const owner = value ? value.ownerDocument : 0;
2150
2426
  return value instanceof (owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement);
2151
2427
  };
2152
- var isMessage = (value) => isString(value);
2428
+ var isMessage = (value) => isString$1(value);
2153
2429
  var isRadioInput = (element) => element.type === "radio";
2154
2430
  var isRegex = (value) => value instanceof RegExp;
2155
2431
  const defaultResult = {
@@ -2252,10 +2528,10 @@ var validateField = async (field, formValues, validateAllFieldCriteria, shouldUs
2252
2528
  const convertTimeToDate = (time) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + time);
2253
2529
  const isTime = ref.type == "time";
2254
2530
  const isWeek = ref.type == "week";
2255
- if (isString(maxOutput.value) && inputValue) {
2531
+ if (isString$1(maxOutput.value) && inputValue) {
2256
2532
  exceedMax = isTime ? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value) : isWeek ? inputValue > maxOutput.value : valueDate > new Date(maxOutput.value);
2257
2533
  }
2258
- if (isString(minOutput.value) && inputValue) {
2534
+ if (isString$1(minOutput.value) && inputValue) {
2259
2535
  exceedMin = isTime ? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value) : isWeek ? inputValue < minOutput.value : valueDate < new Date(minOutput.value);
2260
2536
  }
2261
2537
  }
@@ -2267,7 +2543,7 @@ var validateField = async (field, formValues, validateAllFieldCriteria, shouldUs
2267
2543
  }
2268
2544
  }
2269
2545
  }
2270
- if ((maxLength2 || minLength2) && !isEmpty && (isString(inputValue) || isFieldArray && Array.isArray(inputValue))) {
2546
+ if ((maxLength2 || minLength2) && !isEmpty && (isString$1(inputValue) || isFieldArray && Array.isArray(inputValue))) {
2271
2547
  const maxLengthOutput = getValueAndMessage(maxLength2);
2272
2548
  const minLengthOutput = getValueAndMessage(minLength2);
2273
2549
  const exceedMax = !isNullOrUndefined(maxLengthOutput.value) && inputValue.length > +maxLengthOutput.value;
@@ -2280,7 +2556,7 @@ var validateField = async (field, formValues, validateAllFieldCriteria, shouldUs
2280
2556
  }
2281
2557
  }
2282
2558
  }
2283
- if (pattern && !isEmpty && isString(inputValue)) {
2559
+ if (pattern && !isEmpty && isString$1(inputValue)) {
2284
2560
  const { value: patternValue, message } = getValueAndMessage(pattern);
2285
2561
  if (isRegex(patternValue) && !inputValue.match(patternValue)) {
2286
2562
  error[name] = {
@@ -2467,7 +2743,7 @@ function getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues
2467
2743
  return dirtyFieldsFromValues;
2468
2744
  }
2469
2745
  var getDirtyFields = (defaultValues, formValues) => getDirtyFieldsFromDefaultValues(defaultValues, formValues, markFieldsDirty(formValues));
2470
- var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value) ? value : valueAsNumber ? value === "" ? NaN : value ? +value : value : valueAsDate && isString(value) ? new Date(value) : setValueAs ? setValueAs(value) : value;
2746
+ var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value) ? value : valueAsNumber ? value === "" ? NaN : value ? +value : value : valueAsDate && isString$1(value) ? new Date(value) : setValueAs ? setValueAs(value) : value;
2471
2747
  function getFieldValue(_f) {
2472
2748
  const ref = _f.ref;
2473
2749
  if (_f.refs ? _f.refs.every((ref2) => ref2.disabled) : ref.disabled) {
@@ -2761,7 +3037,7 @@ function createFormControl(props = {}, flushRootRender) {
2761
3037
  };
2762
3038
  const _getDirty = (name, data) => (name && data && set(_formValues, name, data), !deepEqual(getValues(), _defaultValues));
2763
3039
  const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {
2764
- ..._state.mount ? _formValues : isUndefined(defaultValue) ? _defaultValues : isString(names) ? { [names]: defaultValue } : defaultValue
3040
+ ..._state.mount ? _formValues : isUndefined(defaultValue) ? _defaultValues : isString$1(names) ? { [names]: defaultValue } : defaultValue
2765
3041
  }, isGlobal, defaultValue);
2766
3042
  const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
2767
3043
  const setFieldValue = (name, value, options2 = {}) => {
@@ -2920,7 +3196,7 @@ function createFormControl(props = {}, flushRootRender) {
2920
3196
  validationResult = isValid = await executeBuiltInValidation(_fields);
2921
3197
  }
2922
3198
  _subjects.state.next({
2923
- ...!isString(name) || _proxyFormState.isValid && isValid !== _formState.isValid ? {} : { name },
3199
+ ...!isString$1(name) || _proxyFormState.isValid && isValid !== _formState.isValid ? {} : { name },
2924
3200
  ..._options.resolver || !name ? { isValid } : {},
2925
3201
  errors: _formState.errors,
2926
3202
  isValidating: false
@@ -2933,7 +3209,7 @@ function createFormControl(props = {}, flushRootRender) {
2933
3209
  ..._defaultValues,
2934
3210
  ..._state.mount ? _formValues : {}
2935
3211
  };
2936
- return isUndefined(fieldNames) ? values : isString(fieldNames) ? get(values, fieldNames) : fieldNames.map((name) => get(values, name));
3212
+ return isUndefined(fieldNames) ? values : isString$1(fieldNames) ? get(values, fieldNames) : fieldNames.map((name) => get(values, name));
2937
3213
  };
2938
3214
  const getFieldState = (name, formState) => ({
2939
3215
  invalid: !!get((formState || _formState).errors, name),
@@ -3431,7 +3707,7 @@ const LABEL_HEIGHT = 27;
3431
3707
  const GAP = 12;
3432
3708
  const PADDING = 10;
3433
3709
  const isMultipleChoiceSubmission = isSubmissionOfType("enum");
3434
- const getResolver$2 = (config) => {
3710
+ const getResolver$3 = (config) => {
3435
3711
  const length = {
3436
3712
  min: config.minSelected ?? 0,
3437
3713
  max: config.maxSelected ?? config.options.length
@@ -3485,7 +3761,7 @@ const ChatInputMultipleChoice = ({
3485
3761
  defaultValues: {
3486
3762
  checked: isSingleChoice ? {} : isMultipleChoiceSubmission(submission) ? Object.fromEntries(submission.value.map((key) => [key, true])) : {}
3487
3763
  },
3488
- resolver: getResolver$2(input.config)
3764
+ resolver: getResolver$3(input.config)
3489
3765
  });
3490
3766
  const focusRef = useFocusOnMount();
3491
3767
  if (isBooleanLike) {
@@ -3586,7 +3862,7 @@ const errors$1 = {
3586
3862
  max: (max) => `Please enter a number less than or equal to ${max}`,
3587
3863
  decimalCases: (decimalCases) => `Please enter a number with at most ${decimalCases} decimal cases`
3588
3864
  };
3589
- const getResolver$1 = (config) => {
3865
+ const getResolver$2 = (config) => {
3590
3866
  const min = config.min ?? Number.MIN_SAFE_INTEGER;
3591
3867
  const max = config.max ?? Number.MAX_SAFE_INTEGER;
3592
3868
  const decimalCases = config.decimalCases ?? 0;
@@ -3613,7 +3889,7 @@ const ChatInputNumber = ({
3613
3889
  defaultValues: {
3614
3890
  number: defaultValue ? Number(defaultValue) : isNumberSubmission(submission) ? submission.value : void 0
3615
3891
  },
3616
- resolver: getResolver$1(input.config)
3892
+ resolver: getResolver$2(input.config)
3617
3893
  });
3618
3894
  const {
3619
3895
  ref: setRef,
@@ -3671,6 +3947,115 @@ const ChatInputNumber = ({
3671
3947
  })]
3672
3948
  });
3673
3949
  };
3950
+ const invalidPhoneErrorMessage = "That doesn’t look like a valid phone number";
3951
+ const UK_CODE = "44";
3952
+ const PhoneSchema = string(invalidPhoneErrorMessage, [regex(/^\+?[0-9 -]+$/, invalidPhoneErrorMessage)]);
3953
+ const getResolver$1 = (config) => {
3954
+ const configErrors = {
3955
+ maxLength: `Please enter no more than ${config.maxChars ?? 999} characters`,
3956
+ minLength: `Please enter ${config.minChars ?? 1} or more characters`
3957
+ };
3958
+ return i(object({
3959
+ text: transform(PhoneSchema, (value) => value.replace(/[^0-9]/g, ""), [minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)])
3960
+ }));
3961
+ };
3962
+ const isTextSubmission$1 = isSubmissionOfType("string");
3963
+ const ChatInputPhoneNumber = ({
3964
+ input,
3965
+ onSubmitSuccess
3966
+ }) => {
3967
+ var _a;
3968
+ const submission = input.key ? (_a = store.current$.value.flow) == null ? void 0 : _a.data.submissions[input.key] : void 0;
3969
+ const defaultValue = input.config.defaultValue;
3970
+ const {
3971
+ register,
3972
+ handleSubmit,
3973
+ formState: {
3974
+ errors: errors2
3975
+ }
3976
+ } = useForm({
3977
+ defaultValues: {
3978
+ text: defaultValue ? defaultValue : isTextSubmission$1(submission) ? submission.value : ""
3979
+ },
3980
+ resolver: getResolver$1(input.config)
3981
+ });
3982
+ const {
3983
+ ref: setRef,
3984
+ ...props
3985
+ } = register("text", {
3986
+ required: !input.config.optional
3987
+ });
3988
+ const defaultCode = UK_CODE;
3989
+ const [countryCode, setCountryCode] = h(defaultCode);
3990
+ const inputRef = _$1();
3991
+ const selectRef = _$1(null);
3992
+ y(() => {
3993
+ if (inputRef.current) {
3994
+ inputRef.current.focus();
3995
+ inputRef.current.select();
3996
+ }
3997
+ }, []);
3998
+ return o$1("form", {
3999
+ noValidate: true,
4000
+ class: "flex flex-col gap-1 p-2.5",
4001
+ onSubmit: handleSubmit((submission2) => {
4002
+ onSubmitSuccess({
4003
+ type: "string",
4004
+ value: countryCode + submission2.text
4005
+ });
4006
+ }),
4007
+ children: [o$1("div", {
4008
+ class: "flex items-center gap-2",
4009
+ children: [o$1("div", {
4010
+ class: "relative flex min-w-0 flex-1 flex-grow gap-2",
4011
+ children: [o$1("label", {
4012
+ class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus-within:bg-neutral-5 focus-within:outline-accent-7 relative flex h-full w-12 appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-lg border-solid bg-transparent bg-none py-1.5 text-center text-base transition-colors focus-within:outline-none",
4013
+ htmlFor: `isdk_phone_${input.key}`,
4014
+ children: [o$1("span", {
4015
+ children: ["+", countryCode]
4016
+ }), o$1("select", {
4017
+ ref: selectRef,
4018
+ onChange: (e) => {
4019
+ var _a2;
4020
+ const selectedCode = (_a2 = e.currentTarget.selectedOptions[0]) == null ? void 0 : _a2.value;
4021
+ setCountryCode(selectedCode);
4022
+ },
4023
+ required: true,
4024
+ defaultValue: defaultCode,
4025
+ id: `isdk_phone_${input.key}`,
4026
+ class: "absolute inset-0 opacity-0",
4027
+ children: Object.entries(countries).map(([countryName, countryCode2]) => o$1("option", {
4028
+ value: countryCode2,
4029
+ children: [countryName, " (+", countryCode2, ")"]
4030
+ }, countryName))
4031
+ })]
4032
+ }), o$1("input", {
4033
+ ...props,
4034
+ id: "chat-input",
4035
+ type: "tel",
4036
+ inputMode: "tel",
4037
+ autocomplete: "off",
4038
+ autoCapitalize: "off",
4039
+ autoCorrect: "off",
4040
+ autoFocus: true,
4041
+ ref: (element) => {
4042
+ if (element) {
4043
+ inputRef.current = element;
4044
+ }
4045
+ setRef(element);
4046
+ },
4047
+ class: "outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest flex-1 rounded-full px-3 py-1 text-base outline outline-2 transition-all",
4048
+ placeholder: input.config.placeholder
4049
+ }), input.config.optional && o$1(SkipButton, {
4050
+ class: "absolute right-0 top-0",
4051
+ onClick: () => onSubmitSuccess(null)
4052
+ })]
4053
+ }), o$1(SendButton, {})]
4054
+ }), o$1(InputError, {
4055
+ error: errors2.text
4056
+ })]
4057
+ });
4058
+ };
3674
4059
  const ChatInputSubmit = ({
3675
4060
  input,
3676
4061
  onSubmitSuccess
@@ -3712,17 +4097,12 @@ const errors = {
3712
4097
  phone: "That doesn’t look like a valid phone number",
3713
4098
  url: "That doesn’t look like a valid URL"
3714
4099
  };
3715
- const PhoneSchema = string(errors.phone, [regex(/^\+?[0-9 -]+$/, errors.phone)]);
3716
4100
  const inputFormatToProps = {
3717
4101
  email: {
3718
4102
  type: "email",
3719
4103
  inputMode: "email",
3720
4104
  formNoValidate: true
3721
4105
  },
3722
- phone: {
3723
- type: "tel",
3724
- inputMode: "tel"
3725
- },
3726
4106
  text: {
3727
4107
  type: "text",
3728
4108
  inputMode: "text"
@@ -3742,7 +4122,6 @@ const getResolver = (config) => {
3742
4122
  return i(object({
3743
4123
  text: {
3744
4124
  email: string(errors.email, [email(errors.email), minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)]),
3745
- phone: transform(PhoneSchema, (value) => value.replace(/[^0-9]/g, ""), [minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)]),
3746
4125
  text: string([minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)]),
3747
4126
  url: string([url(errors.url), minLength(config.minChars ?? 1, configErrors.minLength), maxLength(config.maxChars ?? Infinity, configErrors.maxLength)])
3748
4127
  }[config.format]
@@ -3773,11 +4152,11 @@ const ChatInputText = ({
3773
4152
  } = register("text", {
3774
4153
  required: !input.config.optional
3775
4154
  });
3776
- const ref = _$1();
4155
+ const inputRef = _$1();
3777
4156
  y(() => {
3778
- if (ref.current) {
3779
- ref.current.focus();
3780
- ref.current.select();
4157
+ if (inputRef.current) {
4158
+ inputRef.current.focus();
4159
+ inputRef.current.select();
3781
4160
  }
3782
4161
  }, []);
3783
4162
  return o$1("form", {
@@ -3792,7 +4171,7 @@ const ChatInputText = ({
3792
4171
  children: [o$1("div", {
3793
4172
  class: "flex items-center gap-2",
3794
4173
  children: [o$1("div", {
3795
- class: "relative min-w-0 flex-grow",
4174
+ class: "relative min-w-0 flex-1",
3796
4175
  children: [o$1("input", {
3797
4176
  id: "chat-input",
3798
4177
  ...props,
@@ -3803,7 +4182,7 @@ const ChatInputText = ({
3803
4182
  autoFocus: true,
3804
4183
  ref: (element) => {
3805
4184
  if (element) {
3806
- ref.current = element;
4185
+ inputRef.current = element;
3807
4186
  }
3808
4187
  setRef(element);
3809
4188
  },
@@ -3870,6 +4249,13 @@ const ChatInput = () => {
3870
4249
  }, (props) => o$1(ChatInputText, {
3871
4250
  onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
3872
4251
  ...props
4252
+ })).with({
4253
+ input: {
4254
+ type: "phone"
4255
+ }
4256
+ }, (props) => o$1(ChatInputPhoneNumber, {
4257
+ onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
4258
+ ...props
3873
4259
  })).with({
3874
4260
  input: {
3875
4261
  type: "multiple-choice"
@@ -3916,6 +4302,77 @@ const ChatInput = () => {
3916
4302
  })
3917
4303
  });
3918
4304
  };
4305
+ var isRegExp = function(re) {
4306
+ return re instanceof RegExp;
4307
+ };
4308
+ var escapeRegExp = function escapeRegExp2(string2) {
4309
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar.source);
4310
+ return string2 && reHasRegExpChar.test(string2) ? string2.replace(reRegExpChar, "\\$&") : string2;
4311
+ };
4312
+ var isString = function(value) {
4313
+ return typeof value === "string";
4314
+ };
4315
+ var flatten = function(array) {
4316
+ var newArray = [];
4317
+ array.forEach(function(item) {
4318
+ if (Array.isArray(item)) {
4319
+ newArray = newArray.concat(item);
4320
+ } else {
4321
+ newArray.push(item);
4322
+ }
4323
+ });
4324
+ return newArray;
4325
+ };
4326
+ function replaceString(str, match, fn) {
4327
+ var curCharStart = 0;
4328
+ var curCharLen = 0;
4329
+ if (str === "") {
4330
+ return str;
4331
+ } else if (!str || !isString(str)) {
4332
+ throw new TypeError("First argument to react-string-replace#replaceString must be a string");
4333
+ }
4334
+ var re = match;
4335
+ if (!isRegExp(re)) {
4336
+ re = new RegExp("(" + escapeRegExp(re) + ")", "gi");
4337
+ }
4338
+ var result = str.split(re);
4339
+ for (var i2 = 1, length = result.length; i2 < length; i2 += 2) {
4340
+ if (result[i2] === void 0 || result[i2 - 1] === void 0) {
4341
+ console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");
4342
+ continue;
4343
+ }
4344
+ curCharLen = result[i2].length;
4345
+ curCharStart += result[i2 - 1].length;
4346
+ result[i2] = fn(result[i2], i2, curCharStart);
4347
+ curCharStart += curCharLen;
4348
+ }
4349
+ return result;
4350
+ }
4351
+ var reactStringReplace = function reactStringReplace2(source, match, fn) {
4352
+ if (!Array.isArray(source))
4353
+ source = [source];
4354
+ return flatten(source.map(function(x) {
4355
+ return isString(x) ? replaceString(x, match, fn) : x;
4356
+ }));
4357
+ };
4358
+ const reactStringReplace$1 = /* @__PURE__ */ getDefaultExportFromCjs(reactStringReplace);
4359
+ const urlRegexp = /(https?:\/\/[^\s]+)/g;
4360
+ const emRegexp = /_(.*?)_/g;
4361
+ const strongRegexp = /\*\*(.*?)\*\*/g;
4362
+ const parseMarkdownToJSX = (input) => {
4363
+ const withLinks = reactStringReplace$1(input, urlRegexp, (url2, i2) => o$1("a", {
4364
+ class: "text-accent-10 hover:text-accent-11 no-underline",
4365
+ href: url2,
4366
+ children: url2
4367
+ }, url2 + i2));
4368
+ const withEm = reactStringReplace$1(withLinks, emRegexp, (match, i2) => o$1("em", {
4369
+ children: match
4370
+ }, match + i2));
4371
+ const withStrong = reactStringReplace$1(withEm, strongRegexp, (match, i2) => o$1("strong", {
4372
+ children: match
4373
+ }, match + i2));
4374
+ return withStrong;
4375
+ };
3919
4376
  const chatBubbleVariants = cva("max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative", {
3920
4377
  variants: {
3921
4378
  side: {
@@ -4047,7 +4504,7 @@ const Conversation = ({
4047
4504
  return o$1(ChatBubble, {
4048
4505
  animate: isLastMessage,
4049
4506
  side: authorToSide[message2.author],
4050
- children: [message2.text, isLastSentMessage ? lastSentMessageFooter : null]
4507
+ children: [parseMarkdownToJSX(message2.text), isLastSentMessage ? lastSentMessageFooter : null]
4051
4508
  }, i2);
4052
4509
  }).with({
4053
4510
  type: "link"