@inploi/plugin-chatbot 3.15.0 → 3.16.1
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/cdn/index.js +11 -11
- package/dist/{chatbot-body-0131fc86.js → chatbot-body-59fab6f6.js} +754 -174
- package/dist/{chatbot-body-daedf7bd.cjs → chatbot-body-9bce9c3f.cjs} +754 -174
- package/dist/chatbot.d.ts +1 -3
- package/dist/chatbot.state.d.ts +127 -0
- package/dist/chatbot.utils.d.ts +10 -7
- package/dist/conditions.d.ts +3 -0
- package/dist/conditions.test.d.ts +1 -0
- package/dist/{index-51b0335a.cjs → index-154bf9a3.cjs} +3 -1
- package/dist/{index-b1d81d1c.js → index-dfe3ef24.js} +26 -24
- package/dist/interpreter.d.ts +8 -7
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +2 -2
- package/package.json +7 -6
|
@@ -1,5 +1,602 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as isString$1, g as getHeadOrThrow, a as invariant, A as AbortedError, N, b as getFlowSubmissionsPayload, _, k as kbToReadableSize, h, c as _$1, p, F, o as o$1, d as clsx, y, s as store, e as a$2, f as debounce$1, j as k, l as parse, m as picklist, n as isSubmissionOfType, C as Cn, q as parseAsync, V as ValiError, r as object, t as transform, u as maxLength, v as minLength, w as record, x as boolean, z as string, B as email, D as url, E as regex, G as cva, H as ERROR_MESSAGES } from "./index-dfe3ef24.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 isIfBlockConditionMet = (ifBlock, submissions) => {
|
|
463
|
+
const [firstSegment, ...rest] = ifBlock.data.compareKey.split(".");
|
|
464
|
+
if (!firstSegment)
|
|
465
|
+
return false;
|
|
466
|
+
const answer = submissions == null ? void 0 : submissions[firstSegment];
|
|
467
|
+
if (!answer)
|
|
468
|
+
return false;
|
|
469
|
+
switch (answer.type) {
|
|
470
|
+
case "address": {
|
|
471
|
+
const value = get$2(answer.value, rest.join("."));
|
|
472
|
+
switch (ifBlock.data.compare) {
|
|
473
|
+
case "equals":
|
|
474
|
+
return value === ifBlock.data.compareValue;
|
|
475
|
+
case "contains":
|
|
476
|
+
if (!value)
|
|
477
|
+
return false;
|
|
478
|
+
return value.includes(ifBlock.data.compareValue);
|
|
479
|
+
case "notEquals":
|
|
480
|
+
return value !== ifBlock.data.compareValue;
|
|
481
|
+
case "notContains":
|
|
482
|
+
if (!value)
|
|
483
|
+
return true;
|
|
484
|
+
return !value.includes(ifBlock.data.compareValue);
|
|
485
|
+
}
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
case "integration": {
|
|
489
|
+
if (typeof answer.value !== "object")
|
|
490
|
+
return false;
|
|
491
|
+
if (Array.isArray(answer.value))
|
|
492
|
+
return false;
|
|
493
|
+
const value = get$2(answer.value, rest.join("."));
|
|
494
|
+
const newIfBlock = {
|
|
495
|
+
...ifBlock,
|
|
496
|
+
data: {
|
|
497
|
+
...ifBlock.data,
|
|
498
|
+
compareKey: "_temp"
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
switch (typeof value) {
|
|
502
|
+
case "boolean":
|
|
503
|
+
return isIfBlockConditionMet(newIfBlock, {
|
|
504
|
+
["_temp"]: {
|
|
505
|
+
value,
|
|
506
|
+
type: "boolean"
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
case "string":
|
|
510
|
+
return isIfBlockConditionMet(newIfBlock, {
|
|
511
|
+
["_temp"]: {
|
|
512
|
+
value,
|
|
513
|
+
type: "string"
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
case "number":
|
|
517
|
+
return isIfBlockConditionMet(newIfBlock, {
|
|
518
|
+
["_temp"]: {
|
|
519
|
+
value,
|
|
520
|
+
type: "number"
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
case "object":
|
|
524
|
+
if (Array.isArray(value) && value.every(isString$1)) {
|
|
525
|
+
return isIfBlockConditionMet(newIfBlock, {
|
|
526
|
+
["_temp"]: {
|
|
527
|
+
value,
|
|
528
|
+
type: "enum"
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
case "boolean": {
|
|
537
|
+
const compareBoolean = ifBlock.data.compareValue === "true";
|
|
538
|
+
switch (ifBlock.data.compare) {
|
|
539
|
+
case "equals":
|
|
540
|
+
return answer.value === compareBoolean;
|
|
541
|
+
case "notEquals":
|
|
542
|
+
return answer.value !== compareBoolean;
|
|
543
|
+
}
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
case "string":
|
|
547
|
+
switch (ifBlock.data.compare) {
|
|
548
|
+
case "equals":
|
|
549
|
+
return answer.value === ifBlock.data.compareValue;
|
|
550
|
+
case "contains":
|
|
551
|
+
if (!answer.value)
|
|
552
|
+
return false;
|
|
553
|
+
return answer.value.includes(ifBlock.data.compareValue);
|
|
554
|
+
case "notEquals":
|
|
555
|
+
return answer.value !== ifBlock.data.compareValue;
|
|
556
|
+
case "notContains":
|
|
557
|
+
if (!answer.value)
|
|
558
|
+
return true;
|
|
559
|
+
return !answer.value.includes(ifBlock.data.compareValue);
|
|
560
|
+
}
|
|
561
|
+
break;
|
|
562
|
+
case "number": {
|
|
563
|
+
try {
|
|
564
|
+
const compareNumber = Number(ifBlock.data.compareValue);
|
|
565
|
+
switch (ifBlock.data.compare) {
|
|
566
|
+
case "equals":
|
|
567
|
+
return answer.value === compareNumber;
|
|
568
|
+
case "notEquals":
|
|
569
|
+
return answer.value !== compareNumber;
|
|
570
|
+
case "greaterThan":
|
|
571
|
+
return answer.value > compareNumber;
|
|
572
|
+
case "greaterThanOrEqualTo":
|
|
573
|
+
return answer.value >= compareNumber;
|
|
574
|
+
case "lessThan":
|
|
575
|
+
return answer.value < compareNumber;
|
|
576
|
+
case "lessThanOrEqualTo":
|
|
577
|
+
return answer.value <= compareNumber;
|
|
578
|
+
}
|
|
579
|
+
} catch {
|
|
580
|
+
console.error(`Failed to parse number in if-block ${ifBlock.id}`, answer.value);
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
case "enum":
|
|
586
|
+
switch (ifBlock.data.compare) {
|
|
587
|
+
case "equals":
|
|
588
|
+
return answer.value.length === 1 && answer.value[0] === ifBlock.data.compareValue;
|
|
589
|
+
case "notEquals":
|
|
590
|
+
return answer.value.length === 1 && answer.value[0] !== ifBlock.data.compareValue;
|
|
591
|
+
case "contains":
|
|
592
|
+
return answer.value.includes(ifBlock.data.compareValue);
|
|
593
|
+
case "notContains":
|
|
594
|
+
return !answer.value.includes(ifBlock.data.compareValue);
|
|
595
|
+
}
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
return false;
|
|
599
|
+
};
|
|
3
600
|
const followNodes = ({
|
|
4
601
|
node,
|
|
5
602
|
nodes,
|
|
@@ -72,7 +669,8 @@ const createFlowInterpreter = ({
|
|
|
72
669
|
userInput: async (input) => chatService.input({
|
|
73
670
|
input,
|
|
74
671
|
signal: controller.signal
|
|
75
|
-
})
|
|
672
|
+
}),
|
|
673
|
+
addToSubmissions: chatService.addToSubmissions
|
|
76
674
|
},
|
|
77
675
|
next: (nodeId) => {
|
|
78
676
|
const nextNode = nodeId ? flow.find((node2) => node2.id === nodeId) : fallthroughBranch({
|
|
@@ -222,6 +820,11 @@ async function interpretSubmitNode({
|
|
|
222
820
|
submissions: getFlowSubmissionsPayload(submissions || {})
|
|
223
821
|
})
|
|
224
822
|
}).catch((e) => e);
|
|
823
|
+
if (node.data.key)
|
|
824
|
+
chat.addToSubmissions(node.data.key, {
|
|
825
|
+
type: "integration",
|
|
826
|
+
value: response
|
|
827
|
+
});
|
|
225
828
|
await N(response).with({
|
|
226
829
|
ats_data: {
|
|
227
830
|
redirect_url: _.string
|
|
@@ -279,8 +882,7 @@ async function interpretIfBlockNode({
|
|
|
279
882
|
next,
|
|
280
883
|
node
|
|
281
884
|
}) {
|
|
282
|
-
|
|
283
|
-
next(nextId);
|
|
885
|
+
next(isIfBlockConditionMet(node, submissions) ? node.branchId : node.nextId);
|
|
284
886
|
}
|
|
285
887
|
async function interpretTextNode({
|
|
286
888
|
chat,
|
|
@@ -330,7 +932,7 @@ async function interpretQuestionTextNode({
|
|
|
330
932
|
maxChars: node.data.maxChars
|
|
331
933
|
}
|
|
332
934
|
});
|
|
333
|
-
if (reply
|
|
935
|
+
if (reply === null) {
|
|
334
936
|
await chat.sendMessage({
|
|
335
937
|
type: "system",
|
|
336
938
|
variant: "info",
|
|
@@ -365,7 +967,7 @@ async function interpretQuestionNumberNode({
|
|
|
365
967
|
format: "text"
|
|
366
968
|
}
|
|
367
969
|
});
|
|
368
|
-
if (reply
|
|
970
|
+
if (reply === null) {
|
|
369
971
|
await chat.sendMessage({
|
|
370
972
|
type: "system",
|
|
371
973
|
variant: "info",
|
|
@@ -422,7 +1024,7 @@ async function interpretQuestionBooleanNode({
|
|
|
422
1024
|
type: "text",
|
|
423
1025
|
text: interpolateString(node.data.question, submissions)
|
|
424
1026
|
});
|
|
425
|
-
const
|
|
1027
|
+
const reply = await chat.userInput({
|
|
426
1028
|
key: node.data.key,
|
|
427
1029
|
type: "boolean",
|
|
428
1030
|
config: {
|
|
@@ -433,7 +1035,6 @@ async function interpretQuestionBooleanNode({
|
|
|
433
1035
|
}
|
|
434
1036
|
}
|
|
435
1037
|
});
|
|
436
|
-
const reply = input.value;
|
|
437
1038
|
if (reply === null) {
|
|
438
1039
|
await chat.sendMessage({
|
|
439
1040
|
type: "system",
|
|
@@ -444,10 +1045,7 @@ async function interpretQuestionBooleanNode({
|
|
|
444
1045
|
await chat.sendMessage({
|
|
445
1046
|
author: "user",
|
|
446
1047
|
type: "text",
|
|
447
|
-
text:
|
|
448
|
-
true: node.data.trueLabel,
|
|
449
|
-
false: node.data.falseLabel
|
|
450
|
-
}[reply]
|
|
1048
|
+
text: reply.value === true ? node.data.trueLabel : node.data.falseLabel
|
|
451
1049
|
});
|
|
452
1050
|
}
|
|
453
1051
|
next(node.nextId);
|
|
@@ -471,7 +1069,7 @@ async function interpretQuestionAddressNode({
|
|
|
471
1069
|
placeholder: node.data.placeholder
|
|
472
1070
|
}
|
|
473
1071
|
});
|
|
474
|
-
if (response
|
|
1072
|
+
if (response === null) {
|
|
475
1073
|
await chat.sendMessage({
|
|
476
1074
|
type: "system",
|
|
477
1075
|
variant: "info",
|
|
@@ -509,7 +1107,7 @@ async function interpretQuestionFileNode({
|
|
|
509
1107
|
allowMultiple: node.data.multiple === true
|
|
510
1108
|
}
|
|
511
1109
|
});
|
|
512
|
-
if (files
|
|
1110
|
+
if (files === null) {
|
|
513
1111
|
await chat.sendMessage({
|
|
514
1112
|
type: "system",
|
|
515
1113
|
variant: "info",
|
|
@@ -539,91 +1137,51 @@ async function interpretEndFlowNode({
|
|
|
539
1137
|
});
|
|
540
1138
|
end();
|
|
541
1139
|
}
|
|
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
|
-
}).with({
|
|
594
|
-
compare: "greaterThan"
|
|
595
|
-
}, () => false).with({
|
|
596
|
-
compare: "lessThan"
|
|
597
|
-
}, () => false).with({
|
|
598
|
-
compare: "greaterThanOrEqualTo"
|
|
599
|
-
}, () => false).with({
|
|
600
|
-
compare: "lessThanOrEqualTo"
|
|
601
|
-
}, () => false).exhaustive();
|
|
602
|
-
};
|
|
603
1140
|
const interpolateString = (str, context) => {
|
|
604
1141
|
const regex2 = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;
|
|
605
|
-
return str.replace(regex2, (
|
|
606
|
-
|
|
607
|
-
const submission = context == null ? void 0 : context[
|
|
1142
|
+
return str.replace(regex2, (_2, key, defaultValue = "") => {
|
|
1143
|
+
const [firstSegment, ...rest] = key.trim().split(".");
|
|
1144
|
+
const submission = context == null ? void 0 : context[firstSegment];
|
|
608
1145
|
if (!submission)
|
|
609
1146
|
return defaultValue;
|
|
610
1147
|
switch (submission.type) {
|
|
611
1148
|
case "boolean":
|
|
612
|
-
return submission.value ===
|
|
1149
|
+
return submission.value === true ? "true" : "false";
|
|
613
1150
|
case "file":
|
|
614
|
-
if (!submission.value)
|
|
615
|
-
return "no files";
|
|
616
1151
|
return submission.value.map((file) => `${file.name} (${kbToReadableSize(file.sizeKb)})`).join(", ");
|
|
617
|
-
case "
|
|
1152
|
+
case "enum":
|
|
618
1153
|
return submission.value.join(", ");
|
|
619
|
-
|
|
620
|
-
return submission.value
|
|
1154
|
+
case "address":
|
|
1155
|
+
return Object.values(submission.value).filter((line) => line && line.trim().length > 0).join(", ");
|
|
1156
|
+
case "number":
|
|
1157
|
+
case "string":
|
|
1158
|
+
if (!submission.value)
|
|
1159
|
+
return defaultValue;
|
|
1160
|
+
return submission.value.toString();
|
|
1161
|
+
case "integration": {
|
|
1162
|
+
if (typeof submission.value !== "object")
|
|
1163
|
+
break;
|
|
1164
|
+
if (Array.isArray(submission.value))
|
|
1165
|
+
break;
|
|
1166
|
+
const value = get$2(submission.value, rest.join("."));
|
|
1167
|
+
switch (typeof value) {
|
|
1168
|
+
case "boolean":
|
|
1169
|
+
return value === true ? "true" : "false";
|
|
1170
|
+
case "string":
|
|
1171
|
+
return value;
|
|
1172
|
+
case "number":
|
|
1173
|
+
return value.toString();
|
|
1174
|
+
case "object":
|
|
1175
|
+
if (Array.isArray(value) && value.every(isString$1)) {
|
|
1176
|
+
return value.join(", ");
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
621
1181
|
}
|
|
1182
|
+
return defaultValue;
|
|
622
1183
|
});
|
|
623
1184
|
};
|
|
624
|
-
function getDefaultExportFromCjs(x) {
|
|
625
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
626
|
-
}
|
|
627
1185
|
function debounce(func, wait, immediate) {
|
|
628
1186
|
var timeout, args, context, timestamp, result;
|
|
629
1187
|
if (null == wait)
|
|
@@ -882,39 +1440,15 @@ const useChatService = () => {
|
|
|
882
1440
|
}
|
|
883
1441
|
};
|
|
884
1442
|
}, [chatRef]);
|
|
885
|
-
const chatService = F(() =>
|
|
886
|
-
|
|
887
|
-
message,
|
|
888
|
-
signal: signal2,
|
|
889
|
-
groupId
|
|
890
|
-
}) => {
|
|
891
|
-
await N(message).with({
|
|
892
|
-
author: "bot",
|
|
893
|
-
type: "text"
|
|
894
|
-
}, async (message2) => {
|
|
895
|
-
if (signal2 == null ? void 0 : signal2.aborted)
|
|
896
|
-
throw new AbortedError();
|
|
897
|
-
chatStore.isBotTyping$.value = true;
|
|
898
|
-
const typingTime = Math.min(Math.max(20, message2.text.length), 100) * TYPING_SPEED_MS_PER_CHARACTER;
|
|
899
|
-
await new Promise((resolve) => {
|
|
900
|
-
return setTimeout(resolve, typingTime, {
|
|
901
|
-
signal: signal2
|
|
902
|
-
});
|
|
903
|
-
});
|
|
904
|
-
chatStore.isBotTyping$.value = false;
|
|
905
|
-
}).otherwise(async () => void 0);
|
|
906
|
-
if (signal2 == null ? void 0 : signal2.aborted)
|
|
907
|
-
throw new AbortedError();
|
|
908
|
-
store.addMessage(message, groupId);
|
|
909
|
-
},
|
|
910
|
-
input: async ({
|
|
1443
|
+
const chatService = F(() => {
|
|
1444
|
+
const inputFn = ({
|
|
911
1445
|
input,
|
|
912
1446
|
signal: signal2
|
|
913
1447
|
}) => {
|
|
914
1448
|
if (signal2 == null ? void 0 : signal2.aborted)
|
|
915
1449
|
throw new AbortedError();
|
|
916
1450
|
store.setInput(input);
|
|
917
|
-
return
|
|
1451
|
+
return new Promise((resolve) => {
|
|
918
1452
|
const submitFunction = (submission) => {
|
|
919
1453
|
if (signal2 == null ? void 0 : signal2.aborted)
|
|
920
1454
|
throw new AbortedError();
|
|
@@ -926,8 +1460,36 @@ const useChatService = () => {
|
|
|
926
1460
|
};
|
|
927
1461
|
chatStore.onSubmitSuccessFn$.value = submitFunction;
|
|
928
1462
|
});
|
|
929
|
-
}
|
|
930
|
-
|
|
1463
|
+
};
|
|
1464
|
+
return {
|
|
1465
|
+
addToSubmissions: (key, value) => store.setSubmission(key, value),
|
|
1466
|
+
send: async ({
|
|
1467
|
+
message,
|
|
1468
|
+
signal: signal2,
|
|
1469
|
+
groupId
|
|
1470
|
+
}) => {
|
|
1471
|
+
await N(message).with({
|
|
1472
|
+
author: "bot",
|
|
1473
|
+
type: "text"
|
|
1474
|
+
}, async (message2) => {
|
|
1475
|
+
if (signal2 == null ? void 0 : signal2.aborted)
|
|
1476
|
+
throw new AbortedError();
|
|
1477
|
+
chatStore.isBotTyping$.value = true;
|
|
1478
|
+
const typingTime = Math.min(Math.max(20, message2.text.length), 100) * TYPING_SPEED_MS_PER_CHARACTER;
|
|
1479
|
+
await new Promise((resolve) => {
|
|
1480
|
+
return setTimeout(resolve, typingTime, {
|
|
1481
|
+
signal: signal2
|
|
1482
|
+
});
|
|
1483
|
+
});
|
|
1484
|
+
chatStore.isBotTyping$.value = false;
|
|
1485
|
+
}).otherwise(async () => void 0);
|
|
1486
|
+
if (signal2 == null ? void 0 : signal2.aborted)
|
|
1487
|
+
throw new AbortedError();
|
|
1488
|
+
store.addMessage(message, groupId);
|
|
1489
|
+
},
|
|
1490
|
+
input: inputFn
|
|
1491
|
+
};
|
|
1492
|
+
}, []);
|
|
931
1493
|
return {
|
|
932
1494
|
chatRef,
|
|
933
1495
|
chatService
|
|
@@ -1260,7 +1822,10 @@ const ChatInputAddressDetails = ({
|
|
|
1260
1822
|
onSubmit: (e) => {
|
|
1261
1823
|
const formData = new FormData(e.currentTarget);
|
|
1262
1824
|
const fields = Object.fromEntries(formData.entries());
|
|
1263
|
-
onSubmitSuccess(
|
|
1825
|
+
onSubmitSuccess({
|
|
1826
|
+
type: "address",
|
|
1827
|
+
value: fields
|
|
1828
|
+
});
|
|
1264
1829
|
},
|
|
1265
1830
|
children: [o$1("div", {
|
|
1266
1831
|
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]",
|
|
@@ -1367,7 +1932,10 @@ const ChatInputBoolean = ({
|
|
|
1367
1932
|
throw new Error("invalid form");
|
|
1368
1933
|
});
|
|
1369
1934
|
const answer = parse(AnswerSchema, value);
|
|
1370
|
-
onSubmitSuccess(
|
|
1935
|
+
onSubmitSuccess({
|
|
1936
|
+
type: "boolean",
|
|
1937
|
+
value: answer === "true"
|
|
1938
|
+
});
|
|
1371
1939
|
},
|
|
1372
1940
|
children: [o$1("div", {
|
|
1373
1941
|
class: "flex items-center gap-2 p-2.5",
|
|
@@ -1502,7 +2070,7 @@ const ChatInputFile = ({
|
|
|
1502
2070
|
}) => {
|
|
1503
2071
|
var _a;
|
|
1504
2072
|
const submission = (_a = store.current$.value.flow) == null ? void 0 : _a.data.submissions[input.key];
|
|
1505
|
-
const [files, setFiles] = h(isFileSubmission(submission)
|
|
2073
|
+
const [files, setFiles] = h(isFileSubmission(submission) ? submission.value : []);
|
|
1506
2074
|
const [error, setError] = h();
|
|
1507
2075
|
const hiddenFileCount = files.length - FILENAMES_TO_SHOW_QTY;
|
|
1508
2076
|
const totalSize = addFileSizesKb(files);
|
|
@@ -1538,7 +2106,10 @@ const ChatInputFile = ({
|
|
|
1538
2106
|
type: "invalid",
|
|
1539
2107
|
message: "Only one file is allowed"
|
|
1540
2108
|
});
|
|
1541
|
-
return onSubmitSuccess(
|
|
2109
|
+
return onSubmitSuccess({
|
|
2110
|
+
type: "file",
|
|
2111
|
+
value: files
|
|
2112
|
+
});
|
|
1542
2113
|
},
|
|
1543
2114
|
children: [o$1("div", {
|
|
1544
2115
|
class: "flex items-center gap-2",
|
|
@@ -1663,14 +2234,14 @@ var isPlainObject = (tempObject) => {
|
|
|
1663
2234
|
var isWeb = typeof window !== "undefined" && typeof window.HTMLElement !== "undefined" && typeof document !== "undefined";
|
|
1664
2235
|
function cloneObject(data) {
|
|
1665
2236
|
let copy;
|
|
1666
|
-
const
|
|
2237
|
+
const isArray2 = Array.isArray(data);
|
|
1667
2238
|
if (data instanceof Date) {
|
|
1668
2239
|
copy = new Date(data);
|
|
1669
2240
|
} else if (data instanceof Set) {
|
|
1670
2241
|
copy = new Set(data);
|
|
1671
|
-
} else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (
|
|
1672
|
-
copy =
|
|
1673
|
-
if (!
|
|
2242
|
+
} else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray2 || isObject(data))) {
|
|
2243
|
+
copy = isArray2 ? [] : {};
|
|
2244
|
+
if (!isArray2 && !isPlainObject(data)) {
|
|
1674
2245
|
copy = data;
|
|
1675
2246
|
} else {
|
|
1676
2247
|
for (const key in data) {
|
|
@@ -3121,7 +3692,7 @@ const submitIfSingleChecked = (form) => {
|
|
|
3121
3692
|
bubbles: true
|
|
3122
3693
|
}));
|
|
3123
3694
|
};
|
|
3124
|
-
const isMultipleChoiceSubmission = isSubmissionOfType("
|
|
3695
|
+
const isMultipleChoiceSubmission = isSubmissionOfType("enum");
|
|
3125
3696
|
const getResolver$1 = (config) => {
|
|
3126
3697
|
const length = {
|
|
3127
3698
|
min: config.minSelected ?? 0,
|
|
@@ -3161,7 +3732,10 @@ const ChatInputMultipleChoice = ({
|
|
|
3161
3732
|
},
|
|
3162
3733
|
onSubmit: handleSubmit((submission2) => {
|
|
3163
3734
|
const checked = submission2.checked;
|
|
3164
|
-
onSubmitSuccess(
|
|
3735
|
+
onSubmitSuccess({
|
|
3736
|
+
type: "enum",
|
|
3737
|
+
value: checked
|
|
3738
|
+
});
|
|
3165
3739
|
}),
|
|
3166
3740
|
children: [o$1("div", {
|
|
3167
3741
|
class: "flex items-center gap-1",
|
|
@@ -3203,7 +3777,10 @@ const ChatInputMultipleChoice = ({
|
|
|
3203
3777
|
class: "flex flex-col items-center gap-2",
|
|
3204
3778
|
children: [!isSingleChoice && o$1(SendButton, {}), input.config.minSelected === 0 && o$1(SkipButton, {
|
|
3205
3779
|
type: "button",
|
|
3206
|
-
onClick: () => onSubmitSuccess(
|
|
3780
|
+
onClick: () => onSubmitSuccess({
|
|
3781
|
+
type: "enum",
|
|
3782
|
+
value: []
|
|
3783
|
+
})
|
|
3207
3784
|
})]
|
|
3208
3785
|
})]
|
|
3209
3786
|
}), o$1("div", {
|
|
@@ -3276,7 +3853,7 @@ const inputFormatToProps = {
|
|
|
3276
3853
|
formNoValidate: true
|
|
3277
3854
|
}
|
|
3278
3855
|
};
|
|
3279
|
-
const isTextSubmission = isSubmissionOfType("
|
|
3856
|
+
const isTextSubmission = isSubmissionOfType("string");
|
|
3280
3857
|
const getResolver = (config) => {
|
|
3281
3858
|
const maxLengthError = `Please enter no more than ${config.maxChars} characters`;
|
|
3282
3859
|
return i(object({
|
|
@@ -3320,42 +3897,43 @@ const ChatInputText = ({
|
|
|
3320
3897
|
ref.current.select();
|
|
3321
3898
|
}
|
|
3322
3899
|
}, []);
|
|
3323
|
-
return o$1(
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3900
|
+
return o$1("form", {
|
|
3901
|
+
noValidate: true,
|
|
3902
|
+
class: "flex flex-col gap-1 p-2.5",
|
|
3903
|
+
onSubmit: handleSubmit((submission2) => {
|
|
3904
|
+
onSubmitSuccess({
|
|
3905
|
+
type: "string",
|
|
3906
|
+
value: submission2.text
|
|
3907
|
+
});
|
|
3908
|
+
}),
|
|
3909
|
+
children: [o$1("div", {
|
|
3910
|
+
class: "flex items-center gap-2",
|
|
3330
3911
|
children: [o$1("div", {
|
|
3331
|
-
class: "
|
|
3332
|
-
children: [o$1("
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
error: errors2.text
|
|
3357
|
-
})]
|
|
3358
|
-
})
|
|
3912
|
+
class: "relative min-w-0 flex-grow",
|
|
3913
|
+
children: [o$1("input", {
|
|
3914
|
+
id: "chat-input",
|
|
3915
|
+
...props,
|
|
3916
|
+
...inputFormatToProps[input.config.format],
|
|
3917
|
+
autocomplete: "off",
|
|
3918
|
+
autoCapitalize: "off",
|
|
3919
|
+
autoCorrect: "off",
|
|
3920
|
+
autoFocus: true,
|
|
3921
|
+
ref: (element) => {
|
|
3922
|
+
if (element) {
|
|
3923
|
+
ref.current = element;
|
|
3924
|
+
}
|
|
3925
|
+
setRef(element);
|
|
3926
|
+
},
|
|
3927
|
+
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",
|
|
3928
|
+
placeholder: input.config.placeholder
|
|
3929
|
+
}), input.config.optional && o$1(SkipButton, {
|
|
3930
|
+
class: "absolute right-0 top-0",
|
|
3931
|
+
onClick: () => onSubmitSuccess(null)
|
|
3932
|
+
})]
|
|
3933
|
+
}), o$1(SendButton, {})]
|
|
3934
|
+
}), o$1(InputError, {
|
|
3935
|
+
error: errors2.text
|
|
3936
|
+
})]
|
|
3359
3937
|
});
|
|
3360
3938
|
};
|
|
3361
3939
|
const ChatInput = () => {
|
|
@@ -3377,10 +3955,6 @@ const ChatInput = () => {
|
|
|
3377
3955
|
wrapper.removeEventListener("transitionend", chatStore.scrollToEnd.smooth);
|
|
3378
3956
|
};
|
|
3379
3957
|
}, []);
|
|
3380
|
-
const handleSubmitSuccess = (type) => (value) => chatStore.onSubmitSuccessFn$.value({
|
|
3381
|
-
type,
|
|
3382
|
-
value
|
|
3383
|
-
});
|
|
3384
3958
|
return o$1("div", {
|
|
3385
3959
|
ref: inputWrapperRef,
|
|
3386
3960
|
class: "ease-expo-out absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-xl transition-all duration-700 will-change-[height]",
|
|
@@ -3411,44 +3985,50 @@ const ChatInput = () => {
|
|
|
3411
3985
|
type: "text"
|
|
3412
3986
|
}
|
|
3413
3987
|
}, (props) => o$1(ChatInputText, {
|
|
3414
|
-
onSubmitSuccess:
|
|
3988
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3415
3989
|
...props
|
|
3416
3990
|
})).with({
|
|
3417
3991
|
input: {
|
|
3418
3992
|
type: "multiple-choice"
|
|
3419
3993
|
}
|
|
3420
3994
|
}, (props) => o$1(ChatInputMultipleChoice, {
|
|
3421
|
-
onSubmitSuccess:
|
|
3995
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3422
3996
|
...props
|
|
3423
3997
|
})).with({
|
|
3424
3998
|
input: {
|
|
3425
3999
|
type: "boolean"
|
|
3426
4000
|
}
|
|
3427
4001
|
}, (props) => o$1(ChatInputBoolean, {
|
|
3428
|
-
onSubmitSuccess:
|
|
4002
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3429
4003
|
...props
|
|
3430
4004
|
})).with({
|
|
3431
4005
|
input: {
|
|
3432
4006
|
type: "file"
|
|
3433
4007
|
}
|
|
3434
4008
|
}, (props) => o$1(ChatInputFile, {
|
|
3435
|
-
onSubmitSuccess:
|
|
4009
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3436
4010
|
...props
|
|
3437
4011
|
})).with({
|
|
3438
4012
|
input: {
|
|
3439
4013
|
type: "submit"
|
|
3440
4014
|
}
|
|
3441
4015
|
}, (props) => o$1(ChatInputSubmit, {
|
|
3442
|
-
onSubmitSuccess:
|
|
4016
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3443
4017
|
...props
|
|
3444
4018
|
})).with({
|
|
3445
4019
|
input: {
|
|
3446
4020
|
type: "address"
|
|
3447
4021
|
}
|
|
3448
4022
|
}, (props) => o$1(ChatInputAddress, {
|
|
3449
|
-
onSubmitSuccess:
|
|
4023
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3450
4024
|
...props
|
|
3451
|
-
})).
|
|
4025
|
+
})).with({
|
|
4026
|
+
input: {
|
|
4027
|
+
type: "number"
|
|
4028
|
+
}
|
|
4029
|
+
}, () => {
|
|
4030
|
+
throw new Error("Not implemented");
|
|
4031
|
+
}).exhaustive()
|
|
3452
4032
|
})
|
|
3453
4033
|
});
|
|
3454
4034
|
};
|