@inploi/plugin-chatbot 3.14.1 → 3.16.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,5 +1,603 @@
1
- import { _, g as getHeadOrThrow, i as invariant, A as AbortedError, N, a as getFlowSubmissionsPayload, k as kbToReadableSize, h, b as _$1, p, F, o as o$1, c as clsx, y, s as store, d as a$2, e as debounce$1, f as k, j as parse, l as picklist, m as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, u as minLength, v as record, w as boolean, x as string, z as email, B as url, D as regex, E as cva, G as ERROR_MESSAGES } from "./index-788a0a7f.js";
1
+ import { g as getHeadOrThrow, i as invariant, A as AbortedError, N, a as getFlowSubmissionsPayload, _, k as kbToReadableSize, h, b as _$1, p, F, o as o$1, c as clsx, y, s as store, d as a$2, e as debounce$1, f as k, j as parse, l as picklist, m as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, u as minLength, v as record, w as boolean, x as string, z as email, B as url, D as regex, E as cva, G as ERROR_MESSAGES } from "./index-063bd7e8.js";
2
2
  import "@inploi/sdk";
3
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
4
+ function getDefaultExportFromCjs(x) {
5
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
6
+ }
7
+ var isArray$3 = Array.isArray;
8
+ var isArray_1 = isArray$3;
9
+ var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
10
+ var _freeGlobal = freeGlobal$1;
11
+ var freeGlobal = _freeGlobal;
12
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
13
+ var root$3 = freeGlobal || freeSelf || Function("return this")();
14
+ var _root = root$3;
15
+ var root$2 = _root;
16
+ var Symbol$4 = root$2.Symbol;
17
+ var _Symbol = Symbol$4;
18
+ var Symbol$3 = _Symbol;
19
+ var objectProto$4 = Object.prototype;
20
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
21
+ var nativeObjectToString$1 = objectProto$4.toString;
22
+ var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
23
+ function getRawTag$1(value) {
24
+ var isOwn = hasOwnProperty$3.call(value, symToStringTag$1), tag = value[symToStringTag$1];
25
+ try {
26
+ value[symToStringTag$1] = void 0;
27
+ var unmasked = true;
28
+ } catch (e) {
29
+ }
30
+ var result = nativeObjectToString$1.call(value);
31
+ if (unmasked) {
32
+ if (isOwn) {
33
+ value[symToStringTag$1] = tag;
34
+ } else {
35
+ delete value[symToStringTag$1];
36
+ }
37
+ }
38
+ return result;
39
+ }
40
+ var _getRawTag = getRawTag$1;
41
+ var objectProto$3 = Object.prototype;
42
+ var nativeObjectToString = objectProto$3.toString;
43
+ function objectToString$1(value) {
44
+ return nativeObjectToString.call(value);
45
+ }
46
+ var _objectToString = objectToString$1;
47
+ var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
48
+ var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
49
+ var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
50
+ function baseGetTag$2(value) {
51
+ if (value == null) {
52
+ return value === void 0 ? undefinedTag : nullTag;
53
+ }
54
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
55
+ }
56
+ var _baseGetTag = baseGetTag$2;
57
+ function isObjectLike$1(value) {
58
+ return value != null && typeof value == "object";
59
+ }
60
+ var isObjectLike_1 = isObjectLike$1;
61
+ var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
62
+ var symbolTag = "[object Symbol]";
63
+ function isSymbol$3(value) {
64
+ return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
65
+ }
66
+ var isSymbol_1 = isSymbol$3;
67
+ var isArray$2 = isArray_1, isSymbol$2 = isSymbol_1;
68
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
69
+ function isKey$2(value, object2) {
70
+ if (isArray$2(value)) {
71
+ return false;
72
+ }
73
+ var type = typeof value;
74
+ if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol$2(value)) {
75
+ return true;
76
+ }
77
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object2 != null && value in Object(object2);
78
+ }
79
+ var _isKey = isKey$2;
80
+ function isObject$3(value) {
81
+ var type = typeof value;
82
+ return value != null && (type == "object" || type == "function");
83
+ }
84
+ var isObject_1 = isObject$3;
85
+ var baseGetTag = _baseGetTag, isObject$2 = isObject_1;
86
+ var asyncTag = "[object AsyncFunction]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
87
+ function isFunction$2(value) {
88
+ if (!isObject$2(value)) {
89
+ return false;
90
+ }
91
+ var tag = baseGetTag(value);
92
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
93
+ }
94
+ var isFunction_1 = isFunction$2;
95
+ var root$1 = _root;
96
+ var coreJsData$1 = root$1["__core-js_shared__"];
97
+ var _coreJsData = coreJsData$1;
98
+ var coreJsData = _coreJsData;
99
+ var maskSrcKey = function() {
100
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
101
+ return uid ? "Symbol(src)_1." + uid : "";
102
+ }();
103
+ function isMasked$1(func) {
104
+ return !!maskSrcKey && maskSrcKey in func;
105
+ }
106
+ var _isMasked = isMasked$1;
107
+ var funcProto$1 = Function.prototype;
108
+ var funcToString$1 = funcProto$1.toString;
109
+ function toSource$1(func) {
110
+ if (func != null) {
111
+ try {
112
+ return funcToString$1.call(func);
113
+ } catch (e) {
114
+ }
115
+ try {
116
+ return func + "";
117
+ } catch (e) {
118
+ }
119
+ }
120
+ return "";
121
+ }
122
+ var _toSource = toSource$1;
123
+ var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$1 = isObject_1, toSource = _toSource;
124
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
125
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
126
+ var funcProto = Function.prototype, objectProto$2 = Object.prototype;
127
+ var funcToString = funcProto.toString;
128
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
129
+ var reIsNative = RegExp(
130
+ "^" + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
131
+ );
132
+ function baseIsNative$1(value) {
133
+ if (!isObject$1(value) || isMasked(value)) {
134
+ return false;
135
+ }
136
+ var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
137
+ return pattern.test(toSource(value));
138
+ }
139
+ var _baseIsNative = baseIsNative$1;
140
+ function getValue$1(object2, key) {
141
+ return object2 == null ? void 0 : object2[key];
142
+ }
143
+ var _getValue = getValue$1;
144
+ var baseIsNative = _baseIsNative, getValue = _getValue;
145
+ function getNative$2(object2, key) {
146
+ var value = getValue(object2, key);
147
+ return baseIsNative(value) ? value : void 0;
148
+ }
149
+ var _getNative = getNative$2;
150
+ var getNative$1 = _getNative;
151
+ var nativeCreate$4 = getNative$1(Object, "create");
152
+ var _nativeCreate = nativeCreate$4;
153
+ var nativeCreate$3 = _nativeCreate;
154
+ function hashClear$1() {
155
+ this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
156
+ this.size = 0;
157
+ }
158
+ var _hashClear = hashClear$1;
159
+ function hashDelete$1(key) {
160
+ var result = this.has(key) && delete this.__data__[key];
161
+ this.size -= result ? 1 : 0;
162
+ return result;
163
+ }
164
+ var _hashDelete = hashDelete$1;
165
+ var nativeCreate$2 = _nativeCreate;
166
+ var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
167
+ var objectProto$1 = Object.prototype;
168
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
169
+ function hashGet$1(key) {
170
+ var data = this.__data__;
171
+ if (nativeCreate$2) {
172
+ var result = data[key];
173
+ return result === HASH_UNDEFINED$1 ? void 0 : result;
174
+ }
175
+ return hasOwnProperty$1.call(data, key) ? data[key] : void 0;
176
+ }
177
+ var _hashGet = hashGet$1;
178
+ var nativeCreate$1 = _nativeCreate;
179
+ var objectProto = Object.prototype;
180
+ var hasOwnProperty = objectProto.hasOwnProperty;
181
+ function hashHas$1(key) {
182
+ var data = this.__data__;
183
+ return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty.call(data, key);
184
+ }
185
+ var _hashHas = hashHas$1;
186
+ var nativeCreate = _nativeCreate;
187
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
188
+ function hashSet$1(key, value) {
189
+ var data = this.__data__;
190
+ this.size += this.has(key) ? 0 : 1;
191
+ data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
192
+ return this;
193
+ }
194
+ var _hashSet = hashSet$1;
195
+ var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
196
+ function Hash$1(entries) {
197
+ var index = -1, length = entries == null ? 0 : entries.length;
198
+ this.clear();
199
+ while (++index < length) {
200
+ var entry = entries[index];
201
+ this.set(entry[0], entry[1]);
202
+ }
203
+ }
204
+ Hash$1.prototype.clear = hashClear;
205
+ Hash$1.prototype["delete"] = hashDelete;
206
+ Hash$1.prototype.get = hashGet;
207
+ Hash$1.prototype.has = hashHas;
208
+ Hash$1.prototype.set = hashSet;
209
+ var _Hash = Hash$1;
210
+ function listCacheClear$1() {
211
+ this.__data__ = [];
212
+ this.size = 0;
213
+ }
214
+ var _listCacheClear = listCacheClear$1;
215
+ function eq$1(value, other) {
216
+ return value === other || value !== value && other !== other;
217
+ }
218
+ var eq_1 = eq$1;
219
+ var eq = eq_1;
220
+ function assocIndexOf$4(array, key) {
221
+ var length = array.length;
222
+ while (length--) {
223
+ if (eq(array[length][0], key)) {
224
+ return length;
225
+ }
226
+ }
227
+ return -1;
228
+ }
229
+ var _assocIndexOf = assocIndexOf$4;
230
+ var assocIndexOf$3 = _assocIndexOf;
231
+ var arrayProto = Array.prototype;
232
+ var splice = arrayProto.splice;
233
+ function listCacheDelete$1(key) {
234
+ var data = this.__data__, index = assocIndexOf$3(data, key);
235
+ if (index < 0) {
236
+ return false;
237
+ }
238
+ var lastIndex = data.length - 1;
239
+ if (index == lastIndex) {
240
+ data.pop();
241
+ } else {
242
+ splice.call(data, index, 1);
243
+ }
244
+ --this.size;
245
+ return true;
246
+ }
247
+ var _listCacheDelete = listCacheDelete$1;
248
+ var assocIndexOf$2 = _assocIndexOf;
249
+ function listCacheGet$1(key) {
250
+ var data = this.__data__, index = assocIndexOf$2(data, key);
251
+ return index < 0 ? void 0 : data[index][1];
252
+ }
253
+ var _listCacheGet = listCacheGet$1;
254
+ var assocIndexOf$1 = _assocIndexOf;
255
+ function listCacheHas$1(key) {
256
+ return assocIndexOf$1(this.__data__, key) > -1;
257
+ }
258
+ var _listCacheHas = listCacheHas$1;
259
+ var assocIndexOf = _assocIndexOf;
260
+ function listCacheSet$1(key, value) {
261
+ var data = this.__data__, index = assocIndexOf(data, key);
262
+ if (index < 0) {
263
+ ++this.size;
264
+ data.push([key, value]);
265
+ } else {
266
+ data[index][1] = value;
267
+ }
268
+ return this;
269
+ }
270
+ var _listCacheSet = listCacheSet$1;
271
+ var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
272
+ function ListCache$1(entries) {
273
+ var index = -1, length = entries == null ? 0 : entries.length;
274
+ this.clear();
275
+ while (++index < length) {
276
+ var entry = entries[index];
277
+ this.set(entry[0], entry[1]);
278
+ }
279
+ }
280
+ ListCache$1.prototype.clear = listCacheClear;
281
+ ListCache$1.prototype["delete"] = listCacheDelete;
282
+ ListCache$1.prototype.get = listCacheGet;
283
+ ListCache$1.prototype.has = listCacheHas;
284
+ ListCache$1.prototype.set = listCacheSet;
285
+ var _ListCache = ListCache$1;
286
+ var getNative = _getNative, root = _root;
287
+ var Map$1 = getNative(root, "Map");
288
+ var _Map = Map$1;
289
+ var Hash = _Hash, ListCache = _ListCache, Map = _Map;
290
+ function mapCacheClear$1() {
291
+ this.size = 0;
292
+ this.__data__ = {
293
+ "hash": new Hash(),
294
+ "map": new (Map || ListCache)(),
295
+ "string": new Hash()
296
+ };
297
+ }
298
+ var _mapCacheClear = mapCacheClear$1;
299
+ function isKeyable$1(value) {
300
+ var type = typeof value;
301
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
302
+ }
303
+ var _isKeyable = isKeyable$1;
304
+ var isKeyable = _isKeyable;
305
+ function getMapData$4(map, key) {
306
+ var data = map.__data__;
307
+ return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
308
+ }
309
+ var _getMapData = getMapData$4;
310
+ var getMapData$3 = _getMapData;
311
+ function mapCacheDelete$1(key) {
312
+ var result = getMapData$3(this, key)["delete"](key);
313
+ this.size -= result ? 1 : 0;
314
+ return result;
315
+ }
316
+ var _mapCacheDelete = mapCacheDelete$1;
317
+ var getMapData$2 = _getMapData;
318
+ function mapCacheGet$1(key) {
319
+ return getMapData$2(this, key).get(key);
320
+ }
321
+ var _mapCacheGet = mapCacheGet$1;
322
+ var getMapData$1 = _getMapData;
323
+ function mapCacheHas$1(key) {
324
+ return getMapData$1(this, key).has(key);
325
+ }
326
+ var _mapCacheHas = mapCacheHas$1;
327
+ var getMapData = _getMapData;
328
+ function mapCacheSet$1(key, value) {
329
+ var data = getMapData(this, key), size = data.size;
330
+ data.set(key, value);
331
+ this.size += data.size == size ? 0 : 1;
332
+ return this;
333
+ }
334
+ var _mapCacheSet = mapCacheSet$1;
335
+ var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
336
+ function MapCache$1(entries) {
337
+ var index = -1, length = entries == null ? 0 : entries.length;
338
+ this.clear();
339
+ while (++index < length) {
340
+ var entry = entries[index];
341
+ this.set(entry[0], entry[1]);
342
+ }
343
+ }
344
+ MapCache$1.prototype.clear = mapCacheClear;
345
+ MapCache$1.prototype["delete"] = mapCacheDelete;
346
+ MapCache$1.prototype.get = mapCacheGet;
347
+ MapCache$1.prototype.has = mapCacheHas;
348
+ MapCache$1.prototype.set = mapCacheSet;
349
+ var _MapCache = MapCache$1;
350
+ var MapCache = _MapCache;
351
+ var FUNC_ERROR_TEXT = "Expected a function";
352
+ function memoize$1(func, resolver) {
353
+ if (typeof func != "function" || resolver != null && typeof resolver != "function") {
354
+ throw new TypeError(FUNC_ERROR_TEXT);
355
+ }
356
+ var memoized = function() {
357
+ var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
358
+ if (cache.has(key)) {
359
+ return cache.get(key);
360
+ }
361
+ var result = func.apply(this, args);
362
+ memoized.cache = cache.set(key, result) || cache;
363
+ return result;
364
+ };
365
+ memoized.cache = new (memoize$1.Cache || MapCache)();
366
+ return memoized;
367
+ }
368
+ memoize$1.Cache = MapCache;
369
+ var memoize_1 = memoize$1;
370
+ var memoize = memoize_1;
371
+ var MAX_MEMOIZE_SIZE = 500;
372
+ function memoizeCapped$1(func) {
373
+ var result = memoize(func, function(key) {
374
+ if (cache.size === MAX_MEMOIZE_SIZE) {
375
+ cache.clear();
376
+ }
377
+ return key;
378
+ });
379
+ var cache = result.cache;
380
+ return result;
381
+ }
382
+ var _memoizeCapped = memoizeCapped$1;
383
+ var memoizeCapped = _memoizeCapped;
384
+ var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
385
+ var reEscapeChar = /\\(\\)?/g;
386
+ var stringToPath$2 = memoizeCapped(function(string2) {
387
+ var result = [];
388
+ if (string2.charCodeAt(0) === 46) {
389
+ result.push("");
390
+ }
391
+ string2.replace(rePropName, function(match, number, quote, subString) {
392
+ result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
393
+ });
394
+ return result;
395
+ });
396
+ var _stringToPath = stringToPath$2;
397
+ function arrayMap$1(array, iteratee) {
398
+ var index = -1, length = array == null ? 0 : array.length, result = Array(length);
399
+ while (++index < length) {
400
+ result[index] = iteratee(array[index], index, array);
401
+ }
402
+ return result;
403
+ }
404
+ var _arrayMap = arrayMap$1;
405
+ var Symbol$1 = _Symbol, arrayMap = _arrayMap, isArray$1 = isArray_1, isSymbol$1 = isSymbol_1;
406
+ var INFINITY$1 = 1 / 0;
407
+ var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
408
+ function baseToString$1(value) {
409
+ if (typeof value == "string") {
410
+ return value;
411
+ }
412
+ if (isArray$1(value)) {
413
+ return arrayMap(value, baseToString$1) + "";
414
+ }
415
+ if (isSymbol$1(value)) {
416
+ return symbolToString ? symbolToString.call(value) : "";
417
+ }
418
+ var result = value + "";
419
+ return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
420
+ }
421
+ var _baseToString = baseToString$1;
422
+ var baseToString = _baseToString;
423
+ function toString$1(value) {
424
+ return value == null ? "" : baseToString(value);
425
+ }
426
+ var toString_1 = toString$1;
427
+ var isArray = isArray_1, isKey$1 = _isKey, stringToPath$1 = _stringToPath, toString = toString_1;
428
+ function castPath$1(value, object2) {
429
+ if (isArray(value)) {
430
+ return value;
431
+ }
432
+ return isKey$1(value, object2) ? [value] : stringToPath$1(toString(value));
433
+ }
434
+ var _castPath = castPath$1;
435
+ var isSymbol = isSymbol_1;
436
+ var INFINITY = 1 / 0;
437
+ function toKey$1(value) {
438
+ if (typeof value == "string" || isSymbol(value)) {
439
+ return value;
440
+ }
441
+ var result = value + "";
442
+ return result == "0" && 1 / value == -INFINITY ? "-0" : result;
443
+ }
444
+ var _toKey = toKey$1;
445
+ var castPath = _castPath, toKey = _toKey;
446
+ function baseGet$2(object2, path) {
447
+ path = castPath(path, object2);
448
+ var index = 0, length = path.length;
449
+ while (object2 != null && index < length) {
450
+ object2 = object2[toKey(path[index++])];
451
+ }
452
+ return index && index == length ? object2 : void 0;
453
+ }
454
+ var _baseGet = baseGet$2;
455
+ var baseGet$1 = _baseGet;
456
+ function get$1(object2, path, defaultValue) {
457
+ var result = object2 == null ? void 0 : baseGet$1(object2, path);
458
+ return result === void 0 ? defaultValue : result;
459
+ }
460
+ var get_1 = get$1;
461
+ const get$2 = /* @__PURE__ */ getDefaultExportFromCjs(get_1);
462
+ const isString$1 = (value) => typeof value === "string";
463
+ const isIfBlockConditionMet = (ifBlock, submissions) => {
464
+ const [firstSegment, ...rest] = ifBlock.data.compareKey.split(".");
465
+ if (!firstSegment)
466
+ return false;
467
+ const answer = submissions == null ? void 0 : submissions[firstSegment];
468
+ if (!answer)
469
+ return false;
470
+ switch (answer.type) {
471
+ case "address": {
472
+ const value = get$2(answer.value, rest.join("."));
473
+ switch (ifBlock.data.compare) {
474
+ case "equals":
475
+ return value === ifBlock.data.compareValue;
476
+ case "contains":
477
+ if (!value)
478
+ return false;
479
+ return value.includes(ifBlock.data.compareValue);
480
+ case "notEquals":
481
+ return value !== ifBlock.data.compareValue;
482
+ case "notContains":
483
+ if (!value)
484
+ return true;
485
+ return !value.includes(ifBlock.data.compareValue);
486
+ }
487
+ break;
488
+ }
489
+ case "integration": {
490
+ if (typeof answer.value !== "object")
491
+ return false;
492
+ if (Array.isArray(answer.value))
493
+ return false;
494
+ const value = get$2(answer.value, rest.join("."));
495
+ const newIfBlock = {
496
+ ...ifBlock,
497
+ data: {
498
+ ...ifBlock.data,
499
+ compareKey: "_temp"
500
+ }
501
+ };
502
+ switch (typeof value) {
503
+ case "boolean":
504
+ return isIfBlockConditionMet(newIfBlock, {
505
+ ["_temp"]: {
506
+ value,
507
+ type: "boolean"
508
+ }
509
+ });
510
+ case "string":
511
+ return isIfBlockConditionMet(newIfBlock, {
512
+ ["_temp"]: {
513
+ value,
514
+ type: "string"
515
+ }
516
+ });
517
+ case "number":
518
+ return isIfBlockConditionMet(newIfBlock, {
519
+ ["_temp"]: {
520
+ value,
521
+ type: "number"
522
+ }
523
+ });
524
+ case "object":
525
+ if (Array.isArray(value) && value.every(isString$1)) {
526
+ return isIfBlockConditionMet(newIfBlock, {
527
+ ["_temp"]: {
528
+ value,
529
+ type: "enum"
530
+ }
531
+ });
532
+ }
533
+ return false;
534
+ }
535
+ break;
536
+ }
537
+ case "boolean": {
538
+ const compareBoolean = ifBlock.data.compareValue === "true";
539
+ switch (ifBlock.data.compare) {
540
+ case "equals":
541
+ return answer.value === compareBoolean;
542
+ case "notEquals":
543
+ return answer.value !== compareBoolean;
544
+ }
545
+ break;
546
+ }
547
+ case "string":
548
+ switch (ifBlock.data.compare) {
549
+ case "equals":
550
+ return answer.value === ifBlock.data.compareValue;
551
+ case "contains":
552
+ if (!answer.value)
553
+ return false;
554
+ return answer.value.includes(ifBlock.data.compareValue);
555
+ case "notEquals":
556
+ return answer.value !== ifBlock.data.compareValue;
557
+ case "notContains":
558
+ if (!answer.value)
559
+ return true;
560
+ return !answer.value.includes(ifBlock.data.compareValue);
561
+ }
562
+ break;
563
+ case "number": {
564
+ try {
565
+ const compareNumber = Number(ifBlock.data.compareValue);
566
+ switch (ifBlock.data.compare) {
567
+ case "equals":
568
+ return answer.value === compareNumber;
569
+ case "notEquals":
570
+ return answer.value !== compareNumber;
571
+ case "greaterThan":
572
+ return answer.value > compareNumber;
573
+ case "greaterThanOrEqualTo":
574
+ return answer.value >= compareNumber;
575
+ case "lessThan":
576
+ return answer.value < compareNumber;
577
+ case "lessThanOrEqualTo":
578
+ return answer.value <= compareNumber;
579
+ }
580
+ } catch {
581
+ console.error(`Failed to parse number in if-block ${ifBlock.id}`, answer.value);
582
+ return false;
583
+ }
584
+ break;
585
+ }
586
+ case "enum":
587
+ switch (ifBlock.data.compare) {
588
+ case "equals":
589
+ return answer.value.length === 1 && answer.value[0] === ifBlock.data.compareValue;
590
+ case "notEquals":
591
+ return answer.value.length === 1 && answer.value[0] !== ifBlock.data.compareValue;
592
+ case "contains":
593
+ return answer.value.includes(ifBlock.data.compareValue);
594
+ case "notContains":
595
+ return !answer.value.includes(ifBlock.data.compareValue);
596
+ }
597
+ break;
598
+ }
599
+ return false;
600
+ };
3
601
  const followNodes = ({
4
602
  node,
5
603
  nodes,
@@ -72,7 +670,8 @@ const createFlowInterpreter = ({
72
670
  userInput: async (input) => chatService.input({
73
671
  input,
74
672
  signal: controller.signal
75
- })
673
+ }),
674
+ addToSubmissions: chatService.addToSubmissions
76
675
  },
77
676
  next: (nodeId) => {
78
677
  const nextNode = nodeId ? flow.find((node2) => node2.id === nodeId) : fallthroughBranch({
@@ -222,6 +821,11 @@ async function interpretSubmitNode({
222
821
  submissions: getFlowSubmissionsPayload(submissions || {})
223
822
  })
224
823
  }).catch((e) => e);
824
+ if (node.data.key)
825
+ chat.addToSubmissions(node.data.key, {
826
+ type: "integration",
827
+ value: response
828
+ });
225
829
  await N(response).with({
226
830
  ats_data: {
227
831
  redirect_url: _.string
@@ -279,8 +883,7 @@ async function interpretIfBlockNode({
279
883
  next,
280
884
  node
281
885
  }) {
282
- const nextId = isIfBlockConditionMet(node, submissions) ? node.branchId : node.nextId;
283
- next(nextId);
886
+ next(isIfBlockConditionMet(node, submissions) ? node.branchId : node.nextId);
284
887
  }
285
888
  async function interpretTextNode({
286
889
  chat,
@@ -330,7 +933,7 @@ async function interpretQuestionTextNode({
330
933
  maxChars: node.data.maxChars
331
934
  }
332
935
  });
333
- if (reply.value === null) {
936
+ if (reply === null) {
334
937
  await chat.sendMessage({
335
938
  type: "system",
336
939
  variant: "info",
@@ -365,7 +968,7 @@ async function interpretQuestionNumberNode({
365
968
  format: "text"
366
969
  }
367
970
  });
368
- if (reply.value === null) {
971
+ if (reply === null) {
369
972
  await chat.sendMessage({
370
973
  type: "system",
371
974
  variant: "info",
@@ -422,7 +1025,7 @@ async function interpretQuestionBooleanNode({
422
1025
  type: "text",
423
1026
  text: interpolateString(node.data.question, submissions)
424
1027
  });
425
- const input = await chat.userInput({
1028
+ const reply = await chat.userInput({
426
1029
  key: node.data.key,
427
1030
  type: "boolean",
428
1031
  config: {
@@ -433,7 +1036,6 @@ async function interpretQuestionBooleanNode({
433
1036
  }
434
1037
  }
435
1038
  });
436
- const reply = input.value;
437
1039
  if (reply === null) {
438
1040
  await chat.sendMessage({
439
1041
  type: "system",
@@ -444,10 +1046,7 @@ async function interpretQuestionBooleanNode({
444
1046
  await chat.sendMessage({
445
1047
  author: "user",
446
1048
  type: "text",
447
- text: {
448
- true: node.data.trueLabel,
449
- false: node.data.falseLabel
450
- }[reply]
1049
+ text: reply.value === true ? node.data.trueLabel : node.data.falseLabel
451
1050
  });
452
1051
  }
453
1052
  next(node.nextId);
@@ -471,7 +1070,7 @@ async function interpretQuestionAddressNode({
471
1070
  placeholder: node.data.placeholder
472
1071
  }
473
1072
  });
474
- if (response.value === null) {
1073
+ if (response === null) {
475
1074
  await chat.sendMessage({
476
1075
  type: "system",
477
1076
  variant: "info",
@@ -509,7 +1108,7 @@ async function interpretQuestionFileNode({
509
1108
  allowMultiple: node.data.multiple === true
510
1109
  }
511
1110
  });
512
- if (files.value === null) {
1111
+ if (files === null) {
513
1112
  await chat.sendMessage({
514
1113
  type: "system",
515
1114
  variant: "info",
@@ -539,83 +1138,34 @@ async function interpretEndFlowNode({
539
1138
  });
540
1139
  end();
541
1140
  }
542
- const possibleContainsValue = _.union(_.string, _.array(_.string), null);
543
- const isIfBlockConditionMet = (ifBlock, submissions) => {
544
- const answer = submissions == null ? void 0 : submissions[ifBlock.data.compareKey];
545
- if (!answer)
546
- return false;
547
- return N({
548
- ...ifBlock.data,
549
- answer
550
- }).with({
551
- compare: "equals"
552
- }, ({
553
- compareValue
554
- }) => {
555
- if (typeof answer.value === "string" || typeof answer.value === "boolean")
556
- return compareValue === answer.value.toString();
557
- return false;
558
- }).with({
559
- compare: "notEquals"
560
- }, ({
561
- compareValue
562
- }) => {
563
- if (typeof answer.value === "string" || typeof answer.value === "boolean")
564
- return compareValue !== answer.value.toString();
565
- return false;
566
- }).with({
567
- compare: "contains",
568
- answer: {
569
- value: possibleContainsValue
570
- }
571
- }, ({
572
- compareValue,
573
- answer: answer2
574
- }) => answer2.value !== null && answer2.value.includes(compareValue)).with({
575
- compare: "notContains",
576
- answer: {
577
- value: possibleContainsValue
578
- }
579
- }, ({
580
- compareValue,
581
- answer: answer2
582
- }) => answer2.value === null || !answer2.value.includes(compareValue)).with({
583
- answer: {
584
- type: "file"
585
- }
586
- }, () => false).with({
587
- answer: {
588
- type: "address",
589
- value: _.any
590
- }
591
- }, () => {
592
- return false;
593
- }).exhaustive();
594
- };
595
1141
  const interpolateString = (str, context) => {
596
1142
  const regex2 = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;
597
- return str.replace(regex2, (match2, key, defaultValue = "") => {
1143
+ return str.replace(regex2, (_2, key, defaultValue = "") => {
598
1144
  key = key.trim();
599
1145
  const submission = context == null ? void 0 : context[key];
600
1146
  if (!submission)
601
1147
  return defaultValue;
602
1148
  switch (submission.type) {
603
1149
  case "boolean":
604
- return submission.value === "true" ? "true" : "false";
1150
+ return submission.value === true ? "true" : "false";
605
1151
  case "file":
606
- if (!submission.value)
607
- return "no files";
608
1152
  return submission.value.map((file) => `${file.name} (${kbToReadableSize(file.sizeKb)})`).join(", ");
609
- case "multiple-choice":
1153
+ case "enum":
610
1154
  return submission.value.join(", ");
1155
+ case "address":
1156
+ return Object.values(submission.value).filter((line) => line && line.trim().length > 0).join(", ");
1157
+ case "number":
1158
+ case "string":
1159
+ if (!submission.value)
1160
+ return defaultValue;
1161
+ return submission.value.toString();
1162
+ case "integration":
1163
+ return JSON.stringify(submission.value);
611
1164
  default:
612
- return submission.value || defaultValue;
1165
+ return defaultValue;
613
1166
  }
614
1167
  });
615
1168
  };
616
- function getDefaultExportFromCjs(x) {
617
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
618
- }
619
1169
  function debounce(func, wait, immediate) {
620
1170
  var timeout, args, context, timestamp, result;
621
1171
  if (null == wait)
@@ -874,39 +1424,15 @@ const useChatService = () => {
874
1424
  }
875
1425
  };
876
1426
  }, [chatRef]);
877
- const chatService = F(() => ({
878
- send: async ({
879
- message,
880
- signal: signal2,
881
- groupId
882
- }) => {
883
- await N(message).with({
884
- author: "bot",
885
- type: "text"
886
- }, async (message2) => {
887
- if (signal2 == null ? void 0 : signal2.aborted)
888
- throw new AbortedError();
889
- chatStore.isBotTyping$.value = true;
890
- const typingTime = Math.min(Math.max(20, message2.text.length), 100) * TYPING_SPEED_MS_PER_CHARACTER;
891
- await new Promise((resolve) => {
892
- return setTimeout(resolve, typingTime, {
893
- signal: signal2
894
- });
895
- });
896
- chatStore.isBotTyping$.value = false;
897
- }).otherwise(async () => void 0);
898
- if (signal2 == null ? void 0 : signal2.aborted)
899
- throw new AbortedError();
900
- store.addMessage(message, groupId);
901
- },
902
- input: async ({
1427
+ const chatService = F(() => {
1428
+ const inputFn = ({
903
1429
  input,
904
1430
  signal: signal2
905
1431
  }) => {
906
1432
  if (signal2 == null ? void 0 : signal2.aborted)
907
1433
  throw new AbortedError();
908
1434
  store.setInput(input);
909
- return await new Promise((resolve) => {
1435
+ return new Promise((resolve) => {
910
1436
  const submitFunction = (submission) => {
911
1437
  if (signal2 == null ? void 0 : signal2.aborted)
912
1438
  throw new AbortedError();
@@ -918,8 +1444,36 @@ const useChatService = () => {
918
1444
  };
919
1445
  chatStore.onSubmitSuccessFn$.value = submitFunction;
920
1446
  });
921
- }
922
- }), []);
1447
+ };
1448
+ return {
1449
+ addToSubmissions: (key, value) => store.setSubmission(key, value),
1450
+ send: async ({
1451
+ message,
1452
+ signal: signal2,
1453
+ groupId
1454
+ }) => {
1455
+ await N(message).with({
1456
+ author: "bot",
1457
+ type: "text"
1458
+ }, async (message2) => {
1459
+ if (signal2 == null ? void 0 : signal2.aborted)
1460
+ throw new AbortedError();
1461
+ chatStore.isBotTyping$.value = true;
1462
+ const typingTime = Math.min(Math.max(20, message2.text.length), 100) * TYPING_SPEED_MS_PER_CHARACTER;
1463
+ await new Promise((resolve) => {
1464
+ return setTimeout(resolve, typingTime, {
1465
+ signal: signal2
1466
+ });
1467
+ });
1468
+ chatStore.isBotTyping$.value = false;
1469
+ }).otherwise(async () => void 0);
1470
+ if (signal2 == null ? void 0 : signal2.aborted)
1471
+ throw new AbortedError();
1472
+ store.addMessage(message, groupId);
1473
+ },
1474
+ input: inputFn
1475
+ };
1476
+ }, []);
923
1477
  return {
924
1478
  chatRef,
925
1479
  chatService
@@ -950,6 +1504,7 @@ const SkipButton = ({
950
1504
  })]
951
1505
  }), "Skip"]
952
1506
  });
1507
+ 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"];
953
1508
  const keyToAddressComponents = {
954
1509
  line1: ["street_number", "floor", "room", "premise"],
955
1510
  line2: ["subpremise", "street_address", "route"],
@@ -989,7 +1544,8 @@ const useGooglePlaces = () => {
989
1544
  const {
990
1545
  predictions
991
1546
  } = await autocomplete.getPlacePredictions({
992
- input
1547
+ input,
1548
+ language: "en"
993
1549
  });
994
1550
  return predictions.map((p2) => ({
995
1551
  label: p2.description,
@@ -999,7 +1555,8 @@ const useGooglePlaces = () => {
999
1555
  getPlaceDetails: async (placeId) => {
1000
1556
  const result = await new Promise((resolve, reject) => places.getDetails({
1001
1557
  placeId,
1002
- fields: ["address_components"]
1558
+ fields: ["address_components"],
1559
+ language: "en"
1003
1560
  }, (result2, status) => {
1004
1561
  if (status !== google.maps.places.PlacesServiceStatus["OK"])
1005
1562
  return reject(status);
@@ -1171,7 +1728,7 @@ const ChatInputAddressQuery = ({
1171
1728
  ref,
1172
1729
  name: "address",
1173
1730
  id: "chat-address",
1174
- autocomplete: "on",
1731
+ autocomplete: "address-line1 country-name postal-code",
1175
1732
  autoFocus: true,
1176
1733
  class: "outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest w-full rounded-full px-3 py-1 text-base outline outline-2 transition-all",
1177
1734
  placeholder: input.config.placeholder || "Search an address",
@@ -1249,7 +1806,10 @@ const ChatInputAddressDetails = ({
1249
1806
  onSubmit: (e) => {
1250
1807
  const formData = new FormData(e.currentTarget);
1251
1808
  const fields = Object.fromEntries(formData.entries());
1252
- onSubmitSuccess(fields);
1809
+ onSubmitSuccess({
1810
+ type: "address",
1811
+ value: fields
1812
+ });
1253
1813
  },
1254
1814
  children: [o$1("div", {
1255
1815
  class: "bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",
@@ -1266,9 +1826,42 @@ const ChatInputAddressDetails = ({
1266
1826
  children: addressKeyToLabel[key]
1267
1827
  }), o$1("div", {
1268
1828
  class: "flex flex-col items-stretch gap-1.5",
1269
- children: [o$1("input", {
1829
+ children: [key === "country" ? o$1("div", {
1830
+ class: "relative",
1831
+ children: [o$1("select", {
1832
+ 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",
1833
+ name,
1834
+ id: labelId,
1835
+ defaultValue: addressFields[key],
1836
+ required: true,
1837
+ children: [addressFields.country && !countryNames.includes(addressFields.country) ? o$1("option", {
1838
+ value: addressFields[key],
1839
+ children: addressFields[key]
1840
+ }) : o$1("option", {
1841
+ value: "",
1842
+ children: "Select a country"
1843
+ }), countryNames.map((country) => o$1("option", {
1844
+ value: country,
1845
+ children: country
1846
+ }, country))]
1847
+ }), o$1("svg", {
1848
+ class: "text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",
1849
+ width: "16",
1850
+ height: "16",
1851
+ stroke: "currentColor",
1852
+ "stroke-width": "1.5",
1853
+ "stroke-linecap": "round",
1854
+ "stroke-linejoin": "round",
1855
+ viewBox: "0 0 16 16",
1856
+ fill: "none",
1857
+ xmlns: "http://www.w3.org/2000/svg",
1858
+ children: o$1("path", {
1859
+ d: "M4 6.5L8 10.5L12 6.5"
1860
+ })
1861
+ })]
1862
+ }) : o$1("input", {
1270
1863
  autoFocus: i2 === 0 ? true : void 0,
1271
- class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 flex-1 rounded-lg border-solid bg-transparent px-3 py-1.5 text-base transition-colors focus:outline-none",
1864
+ class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 flex-1 rounded-lg border-solid bg-transparent px-3 py-1.5 text-base transition-colors autofill:shadow-[inset_0_0_0_1000px_hsl(210_16.7%_97.6%)] focus:outline-none",
1272
1865
  name,
1273
1866
  id: labelId,
1274
1867
  defaultValue: addressFields[key],
@@ -1323,7 +1916,10 @@ const ChatInputBoolean = ({
1323
1916
  throw new Error("invalid form");
1324
1917
  });
1325
1918
  const answer = parse(AnswerSchema, value);
1326
- onSubmitSuccess(answer);
1919
+ onSubmitSuccess({
1920
+ type: "boolean",
1921
+ value: answer === "true"
1922
+ });
1327
1923
  },
1328
1924
  children: [o$1("div", {
1329
1925
  class: "flex items-center gap-2 p-2.5",
@@ -1458,7 +2054,7 @@ const ChatInputFile = ({
1458
2054
  }) => {
1459
2055
  var _a;
1460
2056
  const submission = (_a = store.current$.value.flow) == null ? void 0 : _a.data.submissions[input.key];
1461
- const [files, setFiles] = h(isFileSubmission(submission) && submission.value !== null ? submission.value : []);
2057
+ const [files, setFiles] = h(isFileSubmission(submission) ? submission.value : []);
1462
2058
  const [error, setError] = h();
1463
2059
  const hiddenFileCount = files.length - FILENAMES_TO_SHOW_QTY;
1464
2060
  const totalSize = addFileSizesKb(files);
@@ -1494,7 +2090,10 @@ const ChatInputFile = ({
1494
2090
  type: "invalid",
1495
2091
  message: "Only one file is allowed"
1496
2092
  });
1497
- return onSubmitSuccess(files);
2093
+ return onSubmitSuccess({
2094
+ type: "file",
2095
+ value: files
2096
+ });
1498
2097
  },
1499
2098
  children: [o$1("div", {
1500
2099
  class: "flex items-center gap-2",
@@ -1619,14 +2218,14 @@ var isPlainObject = (tempObject) => {
1619
2218
  var isWeb = typeof window !== "undefined" && typeof window.HTMLElement !== "undefined" && typeof document !== "undefined";
1620
2219
  function cloneObject(data) {
1621
2220
  let copy;
1622
- const isArray = Array.isArray(data);
2221
+ const isArray2 = Array.isArray(data);
1623
2222
  if (data instanceof Date) {
1624
2223
  copy = new Date(data);
1625
2224
  } else if (data instanceof Set) {
1626
2225
  copy = new Set(data);
1627
- } else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray || isObject(data))) {
1628
- copy = isArray ? [] : {};
1629
- if (!isArray && !isPlainObject(data)) {
2226
+ } else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray2 || isObject(data))) {
2227
+ copy = isArray2 ? [] : {};
2228
+ if (!isArray2 && !isPlainObject(data)) {
1630
2229
  copy = data;
1631
2230
  } else {
1632
2231
  for (const key in data) {
@@ -3077,7 +3676,7 @@ const submitIfSingleChecked = (form) => {
3077
3676
  bubbles: true
3078
3677
  }));
3079
3678
  };
3080
- const isMultipleChoiceSubmission = isSubmissionOfType("multiple-choice");
3679
+ const isMultipleChoiceSubmission = isSubmissionOfType("enum");
3081
3680
  const getResolver$1 = (config) => {
3082
3681
  const length = {
3083
3682
  min: config.minSelected ?? 0,
@@ -3117,7 +3716,10 @@ const ChatInputMultipleChoice = ({
3117
3716
  },
3118
3717
  onSubmit: handleSubmit((submission2) => {
3119
3718
  const checked = submission2.checked;
3120
- onSubmitSuccess(checked);
3719
+ onSubmitSuccess({
3720
+ type: "enum",
3721
+ value: checked
3722
+ });
3121
3723
  }),
3122
3724
  children: [o$1("div", {
3123
3725
  class: "flex items-center gap-1",
@@ -3159,7 +3761,10 @@ const ChatInputMultipleChoice = ({
3159
3761
  class: "flex flex-col items-center gap-2",
3160
3762
  children: [!isSingleChoice && o$1(SendButton, {}), input.config.minSelected === 0 && o$1(SkipButton, {
3161
3763
  type: "button",
3162
- onClick: () => onSubmitSuccess([])
3764
+ onClick: () => onSubmitSuccess({
3765
+ type: "enum",
3766
+ value: []
3767
+ })
3163
3768
  })]
3164
3769
  })]
3165
3770
  }), o$1("div", {
@@ -3232,7 +3837,7 @@ const inputFormatToProps = {
3232
3837
  formNoValidate: true
3233
3838
  }
3234
3839
  };
3235
- const isTextSubmission = isSubmissionOfType("text");
3840
+ const isTextSubmission = isSubmissionOfType("string");
3236
3841
  const getResolver = (config) => {
3237
3842
  const maxLengthError = `Please enter no more than ${config.maxChars} characters`;
3238
3843
  return i(object({
@@ -3276,42 +3881,43 @@ const ChatInputText = ({
3276
3881
  ref.current.select();
3277
3882
  }
3278
3883
  }, []);
3279
- return o$1(k, {
3280
- children: o$1("form", {
3281
- noValidate: true,
3282
- class: "flex flex-col gap-1 p-2.5",
3283
- onSubmit: handleSubmit((submission2) => {
3284
- onSubmitSuccess(submission2.text);
3285
- }),
3884
+ return o$1("form", {
3885
+ noValidate: true,
3886
+ class: "flex flex-col gap-1 p-2.5",
3887
+ onSubmit: handleSubmit((submission2) => {
3888
+ onSubmitSuccess({
3889
+ type: "string",
3890
+ value: submission2.text
3891
+ });
3892
+ }),
3893
+ children: [o$1("div", {
3894
+ class: "flex items-center gap-2",
3286
3895
  children: [o$1("div", {
3287
- class: "flex items-center gap-2",
3288
- children: [o$1("div", {
3289
- class: "relative min-w-0 flex-grow",
3290
- children: [o$1("input", {
3291
- id: "chat-input",
3292
- ...props,
3293
- ...inputFormatToProps[input.config.format],
3294
- autocomplete: "off",
3295
- autoCapitalize: "off",
3296
- autoCorrect: "off",
3297
- autoFocus: true,
3298
- ref: (element) => {
3299
- if (element) {
3300
- ref.current = element;
3301
- }
3302
- setRef(element);
3303
- },
3304
- class: "outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest w-full rounded-full px-3 py-1 text-base outline outline-2 transition-all",
3305
- placeholder: input.config.placeholder
3306
- }), input.config.optional && o$1(SkipButton, {
3307
- class: "absolute right-0 top-0",
3308
- onClick: () => onSubmitSuccess(null)
3309
- })]
3310
- }), o$1(SendButton, {})]
3311
- }), o$1(InputError, {
3312
- error: errors2.text
3313
- })]
3314
- })
3896
+ class: "relative min-w-0 flex-grow",
3897
+ children: [o$1("input", {
3898
+ id: "chat-input",
3899
+ ...props,
3900
+ ...inputFormatToProps[input.config.format],
3901
+ autocomplete: "off",
3902
+ autoCapitalize: "off",
3903
+ autoCorrect: "off",
3904
+ autoFocus: true,
3905
+ ref: (element) => {
3906
+ if (element) {
3907
+ ref.current = element;
3908
+ }
3909
+ setRef(element);
3910
+ },
3911
+ class: "outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest w-full rounded-full px-3 py-1 text-base outline outline-2 transition-all",
3912
+ placeholder: input.config.placeholder
3913
+ }), input.config.optional && o$1(SkipButton, {
3914
+ class: "absolute right-0 top-0",
3915
+ onClick: () => onSubmitSuccess(null)
3916
+ })]
3917
+ }), o$1(SendButton, {})]
3918
+ }), o$1(InputError, {
3919
+ error: errors2.text
3920
+ })]
3315
3921
  });
3316
3922
  };
3317
3923
  const ChatInput = () => {
@@ -3333,10 +3939,6 @@ const ChatInput = () => {
3333
3939
  wrapper.removeEventListener("transitionend", chatStore.scrollToEnd.smooth);
3334
3940
  };
3335
3941
  }, []);
3336
- const handleSubmitSuccess = (type) => (value) => chatStore.onSubmitSuccessFn$.value({
3337
- type,
3338
- value
3339
- });
3340
3942
  return o$1("div", {
3341
3943
  ref: inputWrapperRef,
3342
3944
  class: "ease-expo-out absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-xl transition-all duration-700 will-change-[height]",
@@ -3367,44 +3969,50 @@ const ChatInput = () => {
3367
3969
  type: "text"
3368
3970
  }
3369
3971
  }, (props) => o$1(ChatInputText, {
3370
- onSubmitSuccess: handleSubmitSuccess(props.input.type),
3972
+ onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
3371
3973
  ...props
3372
3974
  })).with({
3373
3975
  input: {
3374
3976
  type: "multiple-choice"
3375
3977
  }
3376
3978
  }, (props) => o$1(ChatInputMultipleChoice, {
3377
- onSubmitSuccess: handleSubmitSuccess(props.input.type),
3979
+ onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
3378
3980
  ...props
3379
3981
  })).with({
3380
3982
  input: {
3381
3983
  type: "boolean"
3382
3984
  }
3383
3985
  }, (props) => o$1(ChatInputBoolean, {
3384
- onSubmitSuccess: handleSubmitSuccess(props.input.type),
3986
+ onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
3385
3987
  ...props
3386
3988
  })).with({
3387
3989
  input: {
3388
3990
  type: "file"
3389
3991
  }
3390
3992
  }, (props) => o$1(ChatInputFile, {
3391
- onSubmitSuccess: handleSubmitSuccess(props.input.type),
3993
+ onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
3392
3994
  ...props
3393
3995
  })).with({
3394
3996
  input: {
3395
3997
  type: "submit"
3396
3998
  }
3397
3999
  }, (props) => o$1(ChatInputSubmit, {
3398
- onSubmitSuccess: handleSubmitSuccess(props.input.type),
4000
+ onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
3399
4001
  ...props
3400
4002
  })).with({
3401
4003
  input: {
3402
4004
  type: "address"
3403
4005
  }
3404
4006
  }, (props) => o$1(ChatInputAddress, {
3405
- onSubmitSuccess: handleSubmitSuccess(props.input.type),
4007
+ onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
3406
4008
  ...props
3407
- })).exhaustive()
4009
+ })).with({
4010
+ input: {
4011
+ type: "number"
4012
+ }
4013
+ }, () => {
4014
+ throw new Error("Not implemented");
4015
+ }).exhaustive()
3408
4016
  })
3409
4017
  });
3410
4018
  };