@inploi/plugin-chatbot 3.18.1 → 3.20.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,476 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-89588fad.cjs");
3
+ const index = require("./index-701e3473.cjs");
4
4
  require("@inploi/sdk");
5
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
6
- function getDefaultExportFromCjs(x) {
7
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
8
- }
9
- var isArray$3 = Array.isArray;
10
- var isArray_1 = isArray$3;
11
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
12
- var _freeGlobal = freeGlobal$1;
13
- var freeGlobal = _freeGlobal;
14
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
15
- var root$3 = freeGlobal || freeSelf || Function("return this")();
16
- var _root = root$3;
17
- var root$2 = _root;
18
- var Symbol$4 = root$2.Symbol;
19
- var _Symbol = Symbol$4;
20
- var Symbol$3 = _Symbol;
21
- var objectProto$4 = Object.prototype;
22
- var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
23
- var nativeObjectToString$1 = objectProto$4.toString;
24
- var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
25
- function getRawTag$1(value) {
26
- var isOwn = hasOwnProperty$3.call(value, symToStringTag$1), tag = value[symToStringTag$1];
27
- try {
28
- value[symToStringTag$1] = void 0;
29
- var unmasked = true;
30
- } catch (e) {
31
- }
32
- var result = nativeObjectToString$1.call(value);
33
- if (unmasked) {
34
- if (isOwn) {
35
- value[symToStringTag$1] = tag;
36
- } else {
37
- delete value[symToStringTag$1];
38
- }
39
- }
40
- return result;
41
- }
42
- var _getRawTag = getRawTag$1;
43
- var objectProto$3 = Object.prototype;
44
- var nativeObjectToString = objectProto$3.toString;
45
- function objectToString$1(value) {
46
- return nativeObjectToString.call(value);
47
- }
48
- var _objectToString = objectToString$1;
49
- var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
50
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
51
- var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
52
- function baseGetTag$2(value) {
53
- if (value == null) {
54
- return value === void 0 ? undefinedTag : nullTag;
55
- }
56
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
57
- }
58
- var _baseGetTag = baseGetTag$2;
59
- function isObjectLike$1(value) {
60
- return value != null && typeof value == "object";
61
- }
62
- var isObjectLike_1 = isObjectLike$1;
63
- var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
64
- var symbolTag = "[object Symbol]";
65
- function isSymbol$3(value) {
66
- return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
67
- }
68
- var isSymbol_1 = isSymbol$3;
69
- var isArray$2 = isArray_1, isSymbol$2 = isSymbol_1;
70
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
71
- function isKey$2(value, object) {
72
- if (isArray$2(value)) {
73
- return false;
74
- }
75
- var type = typeof value;
76
- if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol$2(value)) {
77
- return true;
78
- }
79
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
80
- }
81
- var _isKey = isKey$2;
82
- function isObject$3(value) {
83
- var type = typeof value;
84
- return value != null && (type == "object" || type == "function");
85
- }
86
- var isObject_1 = isObject$3;
87
- var baseGetTag = _baseGetTag, isObject$2 = isObject_1;
88
- var asyncTag = "[object AsyncFunction]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
89
- function isFunction$2(value) {
90
- if (!isObject$2(value)) {
91
- return false;
92
- }
93
- var tag = baseGetTag(value);
94
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
95
- }
96
- var isFunction_1 = isFunction$2;
97
- var root$1 = _root;
98
- var coreJsData$1 = root$1["__core-js_shared__"];
99
- var _coreJsData = coreJsData$1;
100
- var coreJsData = _coreJsData;
101
- var maskSrcKey = function() {
102
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
103
- return uid ? "Symbol(src)_1." + uid : "";
104
- }();
105
- function isMasked$1(func) {
106
- return !!maskSrcKey && maskSrcKey in func;
107
- }
108
- var _isMasked = isMasked$1;
109
- var funcProto$1 = Function.prototype;
110
- var funcToString$1 = funcProto$1.toString;
111
- function toSource$1(func) {
112
- if (func != null) {
113
- try {
114
- return funcToString$1.call(func);
115
- } catch (e) {
116
- }
117
- try {
118
- return func + "";
119
- } catch (e) {
120
- }
121
- }
122
- return "";
123
- }
124
- var _toSource = toSource$1;
125
- var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$1 = isObject_1, toSource = _toSource;
126
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
127
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
128
- var funcProto = Function.prototype, objectProto$2 = Object.prototype;
129
- var funcToString = funcProto.toString;
130
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
131
- var reIsNative = RegExp(
132
- "^" + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
133
- );
134
- function baseIsNative$1(value) {
135
- if (!isObject$1(value) || isMasked(value)) {
136
- return false;
137
- }
138
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
139
- return pattern.test(toSource(value));
140
- }
141
- var _baseIsNative = baseIsNative$1;
142
- function getValue$1(object, key) {
143
- return object == null ? void 0 : object[key];
144
- }
145
- var _getValue = getValue$1;
146
- var baseIsNative = _baseIsNative, getValue = _getValue;
147
- function getNative$2(object, key) {
148
- var value = getValue(object, key);
149
- return baseIsNative(value) ? value : void 0;
150
- }
151
- var _getNative = getNative$2;
152
- var getNative$1 = _getNative;
153
- var nativeCreate$4 = getNative$1(Object, "create");
154
- var _nativeCreate = nativeCreate$4;
155
- var nativeCreate$3 = _nativeCreate;
156
- function hashClear$1() {
157
- this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
158
- this.size = 0;
159
- }
160
- var _hashClear = hashClear$1;
161
- function hashDelete$1(key) {
162
- var result = this.has(key) && delete this.__data__[key];
163
- this.size -= result ? 1 : 0;
164
- return result;
165
- }
166
- var _hashDelete = hashDelete$1;
167
- var nativeCreate$2 = _nativeCreate;
168
- var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
169
- var objectProto$1 = Object.prototype;
170
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
171
- function hashGet$1(key) {
172
- var data = this.__data__;
173
- if (nativeCreate$2) {
174
- var result = data[key];
175
- return result === HASH_UNDEFINED$1 ? void 0 : result;
176
- }
177
- return hasOwnProperty$1.call(data, key) ? data[key] : void 0;
178
- }
179
- var _hashGet = hashGet$1;
180
- var nativeCreate$1 = _nativeCreate;
181
- var objectProto = Object.prototype;
182
- var hasOwnProperty = objectProto.hasOwnProperty;
183
- function hashHas$1(key) {
184
- var data = this.__data__;
185
- return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty.call(data, key);
186
- }
187
- var _hashHas = hashHas$1;
188
- var nativeCreate = _nativeCreate;
189
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
190
- function hashSet$1(key, value) {
191
- var data = this.__data__;
192
- this.size += this.has(key) ? 0 : 1;
193
- data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
194
- return this;
195
- }
196
- var _hashSet = hashSet$1;
197
- var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
198
- function Hash$1(entries) {
199
- var index2 = -1, length = entries == null ? 0 : entries.length;
200
- this.clear();
201
- while (++index2 < length) {
202
- var entry = entries[index2];
203
- this.set(entry[0], entry[1]);
204
- }
205
- }
206
- Hash$1.prototype.clear = hashClear;
207
- Hash$1.prototype["delete"] = hashDelete;
208
- Hash$1.prototype.get = hashGet;
209
- Hash$1.prototype.has = hashHas;
210
- Hash$1.prototype.set = hashSet;
211
- var _Hash = Hash$1;
212
- function listCacheClear$1() {
213
- this.__data__ = [];
214
- this.size = 0;
215
- }
216
- var _listCacheClear = listCacheClear$1;
217
- function eq$1(value, other) {
218
- return value === other || value !== value && other !== other;
219
- }
220
- var eq_1 = eq$1;
221
- var eq = eq_1;
222
- function assocIndexOf$4(array, key) {
223
- var length = array.length;
224
- while (length--) {
225
- if (eq(array[length][0], key)) {
226
- return length;
227
- }
228
- }
229
- return -1;
230
- }
231
- var _assocIndexOf = assocIndexOf$4;
232
- var assocIndexOf$3 = _assocIndexOf;
233
- var arrayProto = Array.prototype;
234
- var splice = arrayProto.splice;
235
- function listCacheDelete$1(key) {
236
- var data = this.__data__, index2 = assocIndexOf$3(data, key);
237
- if (index2 < 0) {
238
- return false;
239
- }
240
- var lastIndex = data.length - 1;
241
- if (index2 == lastIndex) {
242
- data.pop();
243
- } else {
244
- splice.call(data, index2, 1);
245
- }
246
- --this.size;
247
- return true;
248
- }
249
- var _listCacheDelete = listCacheDelete$1;
250
- var assocIndexOf$2 = _assocIndexOf;
251
- function listCacheGet$1(key) {
252
- var data = this.__data__, index2 = assocIndexOf$2(data, key);
253
- return index2 < 0 ? void 0 : data[index2][1];
254
- }
255
- var _listCacheGet = listCacheGet$1;
256
- var assocIndexOf$1 = _assocIndexOf;
257
- function listCacheHas$1(key) {
258
- return assocIndexOf$1(this.__data__, key) > -1;
259
- }
260
- var _listCacheHas = listCacheHas$1;
261
- var assocIndexOf = _assocIndexOf;
262
- function listCacheSet$1(key, value) {
263
- var data = this.__data__, index2 = assocIndexOf(data, key);
264
- if (index2 < 0) {
265
- ++this.size;
266
- data.push([key, value]);
267
- } else {
268
- data[index2][1] = value;
269
- }
270
- return this;
271
- }
272
- var _listCacheSet = listCacheSet$1;
273
- var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
274
- function ListCache$1(entries) {
275
- var index2 = -1, length = entries == null ? 0 : entries.length;
276
- this.clear();
277
- while (++index2 < length) {
278
- var entry = entries[index2];
279
- this.set(entry[0], entry[1]);
280
- }
281
- }
282
- ListCache$1.prototype.clear = listCacheClear;
283
- ListCache$1.prototype["delete"] = listCacheDelete;
284
- ListCache$1.prototype.get = listCacheGet;
285
- ListCache$1.prototype.has = listCacheHas;
286
- ListCache$1.prototype.set = listCacheSet;
287
- var _ListCache = ListCache$1;
288
- var getNative = _getNative, root = _root;
289
- var Map$1 = getNative(root, "Map");
290
- var _Map = Map$1;
291
- var Hash = _Hash, ListCache = _ListCache, Map = _Map;
292
- function mapCacheClear$1() {
293
- this.size = 0;
294
- this.__data__ = {
295
- "hash": new Hash(),
296
- "map": new (Map || ListCache)(),
297
- "string": new Hash()
298
- };
299
- }
300
- var _mapCacheClear = mapCacheClear$1;
301
- function isKeyable$1(value) {
302
- var type = typeof value;
303
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
304
- }
305
- var _isKeyable = isKeyable$1;
306
- var isKeyable = _isKeyable;
307
- function getMapData$4(map, key) {
308
- var data = map.__data__;
309
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
310
- }
311
- var _getMapData = getMapData$4;
312
- var getMapData$3 = _getMapData;
313
- function mapCacheDelete$1(key) {
314
- var result = getMapData$3(this, key)["delete"](key);
315
- this.size -= result ? 1 : 0;
316
- return result;
317
- }
318
- var _mapCacheDelete = mapCacheDelete$1;
319
- var getMapData$2 = _getMapData;
320
- function mapCacheGet$1(key) {
321
- return getMapData$2(this, key).get(key);
322
- }
323
- var _mapCacheGet = mapCacheGet$1;
324
- var getMapData$1 = _getMapData;
325
- function mapCacheHas$1(key) {
326
- return getMapData$1(this, key).has(key);
327
- }
328
- var _mapCacheHas = mapCacheHas$1;
329
- var getMapData = _getMapData;
330
- function mapCacheSet$1(key, value) {
331
- var data = getMapData(this, key), size = data.size;
332
- data.set(key, value);
333
- this.size += data.size == size ? 0 : 1;
334
- return this;
335
- }
336
- var _mapCacheSet = mapCacheSet$1;
337
- var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
338
- function MapCache$1(entries) {
339
- var index2 = -1, length = entries == null ? 0 : entries.length;
340
- this.clear();
341
- while (++index2 < length) {
342
- var entry = entries[index2];
343
- this.set(entry[0], entry[1]);
344
- }
345
- }
346
- MapCache$1.prototype.clear = mapCacheClear;
347
- MapCache$1.prototype["delete"] = mapCacheDelete;
348
- MapCache$1.prototype.get = mapCacheGet;
349
- MapCache$1.prototype.has = mapCacheHas;
350
- MapCache$1.prototype.set = mapCacheSet;
351
- var _MapCache = MapCache$1;
352
- var MapCache = _MapCache;
353
- var FUNC_ERROR_TEXT = "Expected a function";
354
- function memoize$1(func, resolver) {
355
- if (typeof func != "function" || resolver != null && typeof resolver != "function") {
356
- throw new TypeError(FUNC_ERROR_TEXT);
357
- }
358
- var memoized = function() {
359
- var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
360
- if (cache.has(key)) {
361
- return cache.get(key);
362
- }
363
- var result = func.apply(this, args);
364
- memoized.cache = cache.set(key, result) || cache;
365
- return result;
366
- };
367
- memoized.cache = new (memoize$1.Cache || MapCache)();
368
- return memoized;
369
- }
370
- memoize$1.Cache = MapCache;
371
- var memoize_1 = memoize$1;
372
- var memoize = memoize_1;
373
- var MAX_MEMOIZE_SIZE = 500;
374
- function memoizeCapped$1(func) {
375
- var result = memoize(func, function(key) {
376
- if (cache.size === MAX_MEMOIZE_SIZE) {
377
- cache.clear();
378
- }
379
- return key;
380
- });
381
- var cache = result.cache;
382
- return result;
383
- }
384
- var _memoizeCapped = memoizeCapped$1;
385
- var memoizeCapped = _memoizeCapped;
386
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
387
- var reEscapeChar = /\\(\\)?/g;
388
- var stringToPath$2 = memoizeCapped(function(string) {
389
- var result = [];
390
- if (string.charCodeAt(0) === 46) {
391
- result.push("");
392
- }
393
- string.replace(rePropName, function(match, number, quote, subString) {
394
- result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
395
- });
396
- return result;
397
- });
398
- var _stringToPath = stringToPath$2;
399
- function arrayMap$1(array, iteratee) {
400
- var index2 = -1, length = array == null ? 0 : array.length, result = Array(length);
401
- while (++index2 < length) {
402
- result[index2] = iteratee(array[index2], index2, array);
403
- }
404
- return result;
405
- }
406
- var _arrayMap = arrayMap$1;
407
- var Symbol$1 = _Symbol, arrayMap = _arrayMap, isArray$1 = isArray_1, isSymbol$1 = isSymbol_1;
408
- var INFINITY$1 = 1 / 0;
409
- var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
410
- function baseToString$1(value) {
411
- if (typeof value == "string") {
412
- return value;
413
- }
414
- if (isArray$1(value)) {
415
- return arrayMap(value, baseToString$1) + "";
416
- }
417
- if (isSymbol$1(value)) {
418
- return symbolToString ? symbolToString.call(value) : "";
419
- }
420
- var result = value + "";
421
- return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
422
- }
423
- var _baseToString = baseToString$1;
424
- var baseToString = _baseToString;
425
- function toString$1(value) {
426
- return value == null ? "" : baseToString(value);
427
- }
428
- var toString_1 = toString$1;
429
- var isArray = isArray_1, isKey$1 = _isKey, stringToPath$1 = _stringToPath, toString = toString_1;
430
- function castPath$1(value, object) {
431
- if (isArray(value)) {
432
- return value;
433
- }
434
- return isKey$1(value, object) ? [value] : stringToPath$1(toString(value));
435
- }
436
- var _castPath = castPath$1;
437
- var isSymbol = isSymbol_1;
438
- var INFINITY = 1 / 0;
439
- function toKey$1(value) {
440
- if (typeof value == "string" || isSymbol(value)) {
441
- return value;
442
- }
443
- var result = value + "";
444
- return result == "0" && 1 / value == -INFINITY ? "-0" : result;
445
- }
446
- var _toKey = toKey$1;
447
- var castPath = _castPath, toKey = _toKey;
448
- function baseGet$2(object, path) {
449
- path = castPath(path, object);
450
- var index2 = 0, length = path.length;
451
- while (object != null && index2 < length) {
452
- object = object[toKey(path[index2++])];
453
- }
454
- return index2 && index2 == length ? object : void 0;
455
- }
456
- var _baseGet = baseGet$2;
457
- var baseGet$1 = _baseGet;
458
- function get$1(object, path, defaultValue) {
459
- var result = object == null ? void 0 : baseGet$1(object, path);
460
- return result === void 0 ? defaultValue : result;
461
- }
462
- var get_1 = get$1;
463
- const get$2 = /* @__PURE__ */ getDefaultExportFromCjs(get_1);
464
- const isIfBlockConditionMet = (ifBlock, submissions) => {
465
- const [firstSegment, ...rest] = ifBlock.data.compareKey.split(".");
5
+ const isIfBlockConditionMet = (ifBlock, {
6
+ context,
7
+ submissions
8
+ }) => {
9
+ const [firstSegment, ...path] = ifBlock.data.compareKey.split(".");
466
10
  if (!firstSegment)
467
11
  return false;
468
- const answer = submissions == null ? void 0 : submissions[firstSegment];
12
+ const answer = getSubmissionValueToCheck({
13
+ context,
14
+ key: firstSegment,
15
+ path,
16
+ submissions
17
+ });
469
18
  if (!answer)
470
19
  return false;
471
20
  switch (answer.type) {
472
21
  case "address": {
473
- const value = get$2(answer.value, rest.join("."));
22
+ const value = index.get(answer.value, path.join("."));
474
23
  switch (ifBlock.data.compare) {
475
24
  case "equals":
476
25
  return value === ifBlock.data.compareValue;
@@ -492,7 +41,7 @@ const isIfBlockConditionMet = (ifBlock, submissions) => {
492
41
  return false;
493
42
  if (Array.isArray(answer.value))
494
43
  return false;
495
- const value = get$2(answer.value, rest.join("."));
44
+ const value = index.get(answer.value, path.join("."));
496
45
  const newIfBlock = {
497
46
  ...ifBlock,
498
47
  data: {
@@ -503,32 +52,44 @@ const isIfBlockConditionMet = (ifBlock, submissions) => {
503
52
  switch (typeof value) {
504
53
  case "boolean":
505
54
  return isIfBlockConditionMet(newIfBlock, {
506
- ["_temp"]: {
507
- value,
508
- type: "boolean"
509
- }
55
+ submissions: {
56
+ ["_temp"]: {
57
+ value,
58
+ type: "boolean"
59
+ }
60
+ },
61
+ context
510
62
  });
511
63
  case "string":
512
64
  return isIfBlockConditionMet(newIfBlock, {
513
- ["_temp"]: {
514
- value,
515
- type: "string"
516
- }
65
+ submissions: {
66
+ ["_temp"]: {
67
+ value,
68
+ type: "string"
69
+ }
70
+ },
71
+ context
517
72
  });
518
73
  case "number":
519
74
  return isIfBlockConditionMet(newIfBlock, {
520
- ["_temp"]: {
521
- value,
522
- type: "number"
523
- }
75
+ submissions: {
76
+ ["_temp"]: {
77
+ value,
78
+ type: "number"
79
+ }
80
+ },
81
+ context
524
82
  });
525
83
  case "object":
526
84
  if (Array.isArray(value) && value.every(index.isString)) {
527
85
  return isIfBlockConditionMet(newIfBlock, {
528
- ["_temp"]: {
529
- value,
530
- type: "enum"
531
- }
86
+ submissions: {
87
+ ["_temp"]: {
88
+ value,
89
+ type: "enum"
90
+ }
91
+ },
92
+ context
532
93
  });
533
94
  }
534
95
  return false;
@@ -599,6 +160,59 @@ const isIfBlockConditionMet = (ifBlock, submissions) => {
599
160
  }
600
161
  return false;
601
162
  };
163
+ const HANDLEBARS_REGEXP = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;
164
+ const interpolateWithData = (str, {
165
+ context,
166
+ submissions
167
+ }) => {
168
+ return str.replace(HANDLEBARS_REGEXP, (_, key, defaultValue = "") => {
169
+ const [firstSegment, ...path] = key.trim().split(".");
170
+ const entity = getSubmissionValueToCheck({
171
+ key: firstSegment,
172
+ path,
173
+ submissions,
174
+ context
175
+ });
176
+ if (!entity)
177
+ return defaultValue;
178
+ switch (entity.type) {
179
+ case "boolean":
180
+ return entity.value === true ? "true" : "false";
181
+ case "file":
182
+ return entity.value.map((file) => `${file.name} (${index.kbToReadableSize(file.sizeKb)})`).join(", ");
183
+ case "enum":
184
+ return entity.value.join(", ");
185
+ case "address":
186
+ return Object.values(entity.value).filter((line) => line && line.trim().length > 0).join(", ");
187
+ case "number":
188
+ case "string":
189
+ if (!entity.value)
190
+ return defaultValue;
191
+ return entity.value.toString();
192
+ case "integration": {
193
+ if (typeof entity.value !== "object")
194
+ break;
195
+ if (Array.isArray(entity.value))
196
+ break;
197
+ const value = index.get(entity.value, path.join("."));
198
+ switch (typeof value) {
199
+ case "boolean":
200
+ return value === true ? "true" : "false";
201
+ case "string":
202
+ return value;
203
+ case "number":
204
+ return value.toString();
205
+ case "object":
206
+ if (Array.isArray(value) && value.every(index.isString)) {
207
+ return value.join(", ");
208
+ }
209
+ }
210
+ break;
211
+ }
212
+ }
213
+ return defaultValue;
214
+ });
215
+ };
602
216
  const followNodes = ({
603
217
  node,
604
218
  nodes,
@@ -886,32 +500,44 @@ async function interpretLinkNode({
886
500
  chat,
887
501
  next,
888
502
  node,
889
- submissions
503
+ submissions,
504
+ context
890
505
  }) {
891
506
  await chat.sendMessage({
892
507
  type: "link",
893
508
  href: node.data.href,
894
- text: interpolateString(node.data.cta, submissions)
509
+ text: interpolateWithData(node.data.cta, {
510
+ submissions,
511
+ context
512
+ })
895
513
  });
896
514
  next(node.nextId);
897
515
  }
898
516
  async function interpretIfBlockNode({
899
517
  submissions,
900
518
  next,
901
- node
519
+ node,
520
+ context
902
521
  }) {
903
- next(isIfBlockConditionMet(node, submissions) ? node.branchId : node.nextId);
522
+ next(isIfBlockConditionMet(node, {
523
+ submissions,
524
+ context
525
+ }) ? node.branchId : node.nextId);
904
526
  }
905
527
  async function interpretTextNode({
906
528
  chat,
907
529
  next,
908
530
  node,
909
- submissions
531
+ submissions,
532
+ context
910
533
  }) {
911
534
  await chat.sendMessage({
912
535
  author: "bot",
913
536
  type: "text",
914
- text: interpolateString(node.data.text, submissions)
537
+ text: interpolateWithData(node.data.text, {
538
+ submissions,
539
+ context
540
+ })
915
541
  });
916
542
  next(node.nextId);
917
543
  }
@@ -933,12 +559,16 @@ async function interpretQuestionTextNode({
933
559
  chat,
934
560
  next,
935
561
  node,
936
- submissions
562
+ submissions,
563
+ context
937
564
  }) {
938
565
  await chat.sendMessage({
939
566
  author: "bot",
940
567
  type: "text",
941
- text: interpolateString(node.data.question, submissions)
568
+ text: interpolateWithData(node.data.question, {
569
+ submissions,
570
+ context
571
+ })
942
572
  });
943
573
  const reply = await chat.userInput({
944
574
  key: node.data.key,
@@ -969,12 +599,16 @@ async function interpretQuestionNumberNode({
969
599
  chat,
970
600
  next,
971
601
  node,
972
- submissions
602
+ submissions,
603
+ context
973
604
  }) {
974
605
  await chat.sendMessage({
975
606
  author: "bot",
976
607
  type: "text",
977
- text: interpolateString(node.data.question, submissions)
608
+ text: interpolateWithData(node.data.question, {
609
+ submissions,
610
+ context
611
+ })
978
612
  });
979
613
  const reply = await chat.userInput({
980
614
  key: node.data.key,
@@ -1006,12 +640,16 @@ async function interpretQuestionEnumNode({
1006
640
  chat,
1007
641
  next,
1008
642
  node,
1009
- submissions
643
+ submissions,
644
+ context
1010
645
  }) {
1011
646
  await chat.sendMessage({
1012
647
  author: "bot",
1013
648
  type: "text",
1014
- text: interpolateString(node.data.question, submissions)
649
+ text: interpolateWithData(node.data.question, {
650
+ submissions,
651
+ context
652
+ })
1015
653
  });
1016
654
  const reply = await chat.userInput({
1017
655
  key: node.data.key,
@@ -1037,12 +675,16 @@ async function interpretQuestionBooleanNode({
1037
675
  chat,
1038
676
  next,
1039
677
  node,
1040
- submissions
678
+ submissions,
679
+ context
1041
680
  }) {
1042
681
  await chat.sendMessage({
1043
682
  author: "bot",
1044
683
  type: "text",
1045
- text: interpolateString(node.data.question, submissions)
684
+ text: interpolateWithData(node.data.question, {
685
+ submissions,
686
+ context
687
+ })
1046
688
  });
1047
689
  const reply = await chat.userInput({
1048
690
  key: node.data.key,
@@ -1109,12 +751,16 @@ async function interpretQuestionFileNode({
1109
751
  node,
1110
752
  chat,
1111
753
  next,
1112
- submissions
754
+ submissions,
755
+ context
1113
756
  }) {
1114
757
  await chat.sendMessage({
1115
758
  author: "bot",
1116
759
  type: "text",
1117
- text: interpolateString(node.data.question, submissions)
760
+ text: interpolateWithData(node.data.question, {
761
+ submissions,
762
+ context
763
+ })
1118
764
  });
1119
765
  const files = await chat.userInput({
1120
766
  key: node.data.key,
@@ -1157,50 +803,38 @@ async function interpretEndFlowNode({
1157
803
  });
1158
804
  end();
1159
805
  }
1160
- const interpolateString = (str, context) => {
1161
- const regex = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;
1162
- return str.replace(regex, (_, key, defaultValue = "") => {
1163
- const [firstSegment, ...rest] = key.trim().split(".");
1164
- const submission = context == null ? void 0 : context[firstSegment];
1165
- if (!submission)
1166
- return defaultValue;
1167
- switch (submission.type) {
1168
- case "boolean":
1169
- return submission.value === true ? "true" : "false";
1170
- case "file":
1171
- return submission.value.map((file) => `${file.name} (${index.kbToReadableSize(file.sizeKb)})`).join(", ");
1172
- case "enum":
1173
- return submission.value.join(", ");
1174
- case "address":
1175
- return Object.values(submission.value).filter((line) => line && line.trim().length > 0).join(", ");
1176
- case "number":
806
+ const getSubmissionValueToCheck = ({
807
+ key,
808
+ path,
809
+ submissions,
810
+ context
811
+ }) => {
812
+ if (key === "$context") {
813
+ if (!path)
814
+ return void 0;
815
+ const contextData = index.get(context, path.join("."));
816
+ switch (typeof contextData) {
1177
817
  case "string":
1178
- if (!submission.value)
1179
- return defaultValue;
1180
- return submission.value.toString();
1181
- case "integration": {
1182
- if (typeof submission.value !== "object")
1183
- break;
1184
- if (Array.isArray(submission.value))
1185
- break;
1186
- const value = get$2(submission.value, rest.join("."));
1187
- switch (typeof value) {
1188
- case "boolean":
1189
- return value === true ? "true" : "false";
1190
- case "string":
1191
- return value;
1192
- case "number":
1193
- return value.toString();
1194
- case "object":
1195
- if (Array.isArray(value) && value.every(index.isString)) {
1196
- return value.join(", ");
1197
- }
1198
- }
1199
- break;
1200
- }
818
+ return {
819
+ type: "string",
820
+ value: contextData
821
+ };
822
+ case "number":
823
+ return {
824
+ type: "number",
825
+ value: contextData
826
+ };
827
+ case "boolean":
828
+ return {
829
+ type: "boolean",
830
+ value: contextData
831
+ };
832
+ default:
833
+ console.warn(`Unexpected type for $context.${path.join(".")}`, contextData);
834
+ return void 0;
1201
835
  }
1202
- return defaultValue;
1203
- });
836
+ }
837
+ return submissions == null ? void 0 : submissions[key];
1204
838
  };
1205
839
  function debounce(func, wait, immediate) {
1206
840
  var timeout, args, context, timestamp, result;
@@ -1249,7 +883,7 @@ function debounce(func, wait, immediate) {
1249
883
  }
1250
884
  debounce.debounce = debounce;
1251
885
  var debounce_1 = debounce;
1252
- const createDebounce = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
886
+ const createDebounce = /* @__PURE__ */ index.getDefaultExportFromCjs(debounce_1);
1253
887
  function useMeasure(_temp) {
1254
888
  let {
1255
889
  debounce: debounce2,
@@ -2254,14 +1888,14 @@ var isPlainObject = (tempObject) => {
2254
1888
  var isWeb = typeof window !== "undefined" && typeof window.HTMLElement !== "undefined" && typeof document !== "undefined";
2255
1889
  function cloneObject(data) {
2256
1890
  let copy;
2257
- const isArray2 = Array.isArray(data);
1891
+ const isArray = Array.isArray(data);
2258
1892
  if (data instanceof Date) {
2259
1893
  copy = new Date(data);
2260
1894
  } else if (data instanceof Set) {
2261
1895
  copy = new Set(data);
2262
- } else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray2 || isObject(data))) {
2263
- copy = isArray2 ? [] : {};
2264
- if (!isArray2 && !isPlainObject(data)) {
1896
+ } else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray || isObject(data))) {
1897
+ copy = isArray ? [] : {};
1898
+ if (!isArray && !isPlainObject(data)) {
2265
1899
  copy = data;
2266
1900
  } else {
2267
1901
  for (const key in data) {