@bigbinary/neeto-message-templates-frontend 1.0.2 → 1.2.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.
Files changed (43) hide show
  1. package/dist/ApiTemplates.js +439 -0
  2. package/dist/ApiTemplates.js.map +1 -0
  3. package/dist/MessageTemplates.js +1248 -0
  4. package/dist/MessageTemplates.js.map +1 -0
  5. package/dist/NoDataPage-00b22095.js +58 -0
  6. package/dist/NoDataPage-00b22095.js.map +1 -0
  7. package/dist/NoDataPage-4ba91a9f.js +51 -0
  8. package/dist/NoDataPage-4ba91a9f.js.map +1 -0
  9. package/dist/SendMessagePane.js +356 -0
  10. package/dist/SendMessagePane.js.map +1 -0
  11. package/dist/SendToApiPane.js +151 -0
  12. package/dist/SendToApiPane.js.map +1 -0
  13. package/dist/cjs/ApiTemplates.js +459 -0
  14. package/dist/cjs/ApiTemplates.js.map +1 -0
  15. package/dist/cjs/MessageTemplates.js +1289 -0
  16. package/dist/cjs/MessageTemplates.js.map +1 -0
  17. package/dist/cjs/SendMessagePane.js +390 -0
  18. package/dist/cjs/SendMessagePane.js.map +1 -0
  19. package/dist/cjs/SendToApiPane.js +181 -0
  20. package/dist/cjs/SendToApiPane.js.map +1 -0
  21. package/dist/cjs/index.js +61 -0
  22. package/dist/cjs/index.js.map +1 -0
  23. package/dist/index.js +49 -4587
  24. package/dist/index.js.map +1 -1
  25. package/dist/slicedToArray-b4278ecd.js +57 -0
  26. package/dist/slicedToArray-b4278ecd.js.map +1 -0
  27. package/dist/slicedToArray-f320d9e7.js +61 -0
  28. package/dist/slicedToArray-f320d9e7.js.map +1 -0
  29. package/dist/toConsumableArray-1cc38429.js +20 -0
  30. package/dist/toConsumableArray-1cc38429.js.map +1 -0
  31. package/dist/toConsumableArray-9abb3858.js +22 -0
  32. package/dist/toConsumableArray-9abb3858.js.map +1 -0
  33. package/dist/useTemplatesApi-45d43d41.js +2240 -0
  34. package/dist/useTemplatesApi-45d43d41.js.map +1 -0
  35. package/dist/useTemplatesApi-943ef380.js +2256 -0
  36. package/dist/useTemplatesApi-943ef380.js.map +1 -0
  37. package/dist/utils-90248b52.js +188 -0
  38. package/dist/utils-90248b52.js.map +1 -0
  39. package/dist/utils-b93467c8.js +151 -0
  40. package/dist/utils-b93467c8.js.map +1 -0
  41. package/package.json +24 -12
  42. package/dist/index.cjs.js +0 -4642
  43. package/dist/index.cjs.js.map +0 -1
package/dist/index.cjs.js DELETED
@@ -1,4642 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var react = require('react');
6
- var neetoCist = require('@bigbinary/neeto-cist');
7
- var neetoFiltersFrontend = require('@bigbinary/neeto-filters-frontend');
8
- var Container = require('@bigbinary/neeto-molecules/Container');
9
- var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
10
- var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
11
- var SubHeader = require('@bigbinary/neeto-molecules/SubHeader');
12
- var Button = require('@bigbinary/neetoui/Button');
13
- var Typography = require('@bigbinary/neetoui/Typography');
14
- var ramda = require('ramda');
15
- var reactI18next = require('react-i18next');
16
- var i18next = require('i18next');
17
- var constants = require('@bigbinary/neeto-commons-frontend/constants');
18
- var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
19
- var reactQuery = require('@tanstack/react-query');
20
- var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
21
- var axios = require('axios');
22
- var require$$0 = require('util');
23
- var zustand = require('zustand');
24
- var jsxRuntime = require('react/jsx-runtime');
25
- var Pane = require('@bigbinary/neetoui/Pane');
26
- var FormikEditor = require('@bigbinary/neeto-editor/FormikEditor');
27
- var NeetoUIForm = require('@bigbinary/neetoui/formik/Form');
28
- var Input = require('@bigbinary/neetoui/formik/Input');
29
- var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
30
- var formik = require('formik');
31
- var Textarea = require('@bigbinary/neetoui/formik/Textarea');
32
- var PhoneNumber = require('@bigbinary/neeto-molecules/PhoneNumber');
33
- var yup = require('yup');
34
- var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
35
- var Alert = require('@bigbinary/neetoui/Alert');
36
- var Table = require('@bigbinary/neetoui/Table');
37
- var NoData = require('@bigbinary/neetoui/NoData');
38
- var Spinner = require('@bigbinary/neetoui/Spinner');
39
- var Select = require('@bigbinary/neetoui/Select');
40
- var Textarea$1 = require('@bigbinary/neetoui/Textarea');
41
- var Select$1 = require('@bigbinary/neetoui/formik/Select');
42
- var Delete = require('@bigbinary/neeto-icons/Delete');
43
- var Label = require('@bigbinary/neetoui/Label');
44
-
45
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
46
-
47
- function _interopNamespace(e) {
48
- if (e && e.__esModule) return e;
49
- var n = Object.create(null);
50
- if (e) {
51
- Object.keys(e).forEach(function (k) {
52
- if (k !== 'default') {
53
- var d = Object.getOwnPropertyDescriptor(e, k);
54
- Object.defineProperty(n, k, d.get ? d : {
55
- enumerable: true,
56
- get: function () { return e[k]; }
57
- });
58
- }
59
- });
60
- }
61
- n["default"] = e;
62
- return Object.freeze(n);
63
- }
64
-
65
- var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
66
- var NeetoHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoHeader);
67
- var HelpPopover__default = /*#__PURE__*/_interopDefaultLegacy(HelpPopover);
68
- var SubHeader__default = /*#__PURE__*/_interopDefaultLegacy(SubHeader);
69
- var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
70
- var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
71
- var MoreDropdown__default = /*#__PURE__*/_interopDefaultLegacy(MoreDropdown);
72
- var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
73
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
74
- var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
75
- var FormikEditor__default = /*#__PURE__*/_interopDefaultLegacy(FormikEditor);
76
- var NeetoUIForm__default = /*#__PURE__*/_interopDefaultLegacy(NeetoUIForm);
77
- var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
78
- var ActionBlock__default = /*#__PURE__*/_interopDefaultLegacy(ActionBlock);
79
- var Textarea__default = /*#__PURE__*/_interopDefaultLegacy(Textarea);
80
- var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
81
- var TableWrapper__default = /*#__PURE__*/_interopDefaultLegacy(TableWrapper);
82
- var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
83
- var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table);
84
- var NoData__default = /*#__PURE__*/_interopDefaultLegacy(NoData);
85
- var Spinner__default = /*#__PURE__*/_interopDefaultLegacy(Spinner);
86
- var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
87
- var Textarea__default$1 = /*#__PURE__*/_interopDefaultLegacy(Textarea$1);
88
- var Select__default$1 = /*#__PURE__*/_interopDefaultLegacy(Select$1);
89
- var Delete__default = /*#__PURE__*/_interopDefaultLegacy(Delete);
90
- var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
91
-
92
- function _typeof$1(o) {
93
- "@babel/helpers - typeof";
94
-
95
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
96
- return typeof o;
97
- } : function (o) {
98
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
99
- }, _typeof$1(o);
100
- }
101
-
102
- function _toPrimitive(input, hint) {
103
- if (_typeof$1(input) !== "object" || input === null) return input;
104
- var prim = input[Symbol.toPrimitive];
105
- if (prim !== undefined) {
106
- var res = prim.call(input, hint || "default");
107
- if (_typeof$1(res) !== "object") return res;
108
- throw new TypeError("@@toPrimitive must return a primitive value.");
109
- }
110
- return (hint === "string" ? String : Number)(input);
111
- }
112
-
113
- function _toPropertyKey(arg) {
114
- var key = _toPrimitive(arg, "string");
115
- return _typeof$1(key) === "symbol" ? key : String(key);
116
- }
117
-
118
- function _defineProperty(obj, key, value) {
119
- key = _toPropertyKey(key);
120
- if (key in obj) {
121
- Object.defineProperty(obj, key, {
122
- value: value,
123
- enumerable: true,
124
- configurable: true,
125
- writable: true
126
- });
127
- } else {
128
- obj[key] = value;
129
- }
130
- return obj;
131
- }
132
-
133
- function _arrayWithHoles(arr) {
134
- if (Array.isArray(arr)) return arr;
135
- }
136
-
137
- function _iterableToArrayLimit(r, l) {
138
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
139
- if (null != t) {
140
- var e,
141
- n,
142
- i,
143
- u,
144
- a = [],
145
- f = !0,
146
- o = !1;
147
- try {
148
- if (i = (t = t.call(r)).next, 0 === l) {
149
- if (Object(t) !== t) return;
150
- f = !1;
151
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
152
- } catch (r) {
153
- o = !0, n = r;
154
- } finally {
155
- try {
156
- if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
157
- } finally {
158
- if (o) throw n;
159
- }
160
- }
161
- return a;
162
- }
163
- }
164
-
165
- function _arrayLikeToArray(arr, len) {
166
- if (len == null || len > arr.length) len = arr.length;
167
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
168
- return arr2;
169
- }
170
-
171
- function _unsupportedIterableToArray(o, minLen) {
172
- if (!o) return;
173
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
174
- var n = Object.prototype.toString.call(o).slice(8, -1);
175
- if (n === "Object" && o.constructor) n = o.constructor.name;
176
- if (n === "Map" || n === "Set") return Array.from(o);
177
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
178
- }
179
-
180
- function _nonIterableRest() {
181
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
182
- }
183
-
184
- function _slicedToArray(arr, i) {
185
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
186
- }
187
-
188
- var MESSAGE_TEMPLATES = {
189
- email: {
190
- label: i18next.t("neetoMessageTemplate.template.emailTemplates"),
191
- value: "email_template",
192
- addText: i18next.t("neetoMessageTemplate.template.addEmailTemplate"),
193
- labelSingular: i18next.t("neetoMessageTemplate.template.emailTemplate"),
194
- editText: i18next.t("neetoMessageTemplate.template.editEmailTemplate")
195
- },
196
- sms: {
197
- label: i18next.t("neetoMessageTemplate.template.smsTemplates"),
198
- value: "sms_template",
199
- addText: i18next.t("neetoMessageTemplate.template.addSmsTemplate"),
200
- labelSingular: i18next.t("neetoMessageTemplate.template.smsTemplate"),
201
- editText: i18next.t("neetoMessageTemplate.template.editSmsTemplate")
202
- },
203
- whatsapp: {
204
- label: i18next.t("neetoMessageTemplate.template.whatsappTemplates"),
205
- value: "whatsapp_template",
206
- addText: i18next.t("neetoMessageTemplate.template.addWhatsappTemplate"),
207
- labelSingular: i18next.t("neetoMessageTemplate.template.whatsappTemplate"),
208
- editText: i18next.t("neetoMessageTemplate.template.editWhatsappTemplate")
209
- },
210
- api: {
211
- label: i18next.t("neetoMessageTemplate.template.apiTemplates"),
212
- value: "api_template",
213
- addText: i18next.t("neetoMessageTemplate.api.addApiTemplate")
214
- }
215
- };
216
- var MESSAGE_TYPES = {
217
- sms: i18next.t("messageType.sms"),
218
- email: i18next.t("messageType.email"),
219
- whatsapp: i18next.t("messageType.whatsapp")
220
- };
221
- var DEFAULT_EDITOR_ROW_COUNT = 15;
222
- var DEFAULT_PAGE_PROPERTIES = {
223
- size: constants.DEFAULT_PAGE_SIZE,
224
- index: constants.DEFAULT_PAGE_INDEX
225
- };
226
-
227
- var MESSAGE_TEMPLATE_INITIAL_STATE = {
228
- isOpen: false,
229
- isEdit: false,
230
- isDelete: false,
231
- template: {}
232
- };
233
-
234
- function getDefaultExportFromCjs (x) {
235
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
236
- }
237
-
238
- /* eslint complexity: [2, 18], max-statements: [2, 33] */
239
- var shams = function hasSymbols() {
240
- if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
241
- if (typeof Symbol.iterator === 'symbol') { return true; }
242
-
243
- var obj = {};
244
- var sym = Symbol('test');
245
- var symObj = Object(sym);
246
- if (typeof sym === 'string') { return false; }
247
-
248
- if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
249
- if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
250
-
251
- // temp disabled per https://github.com/ljharb/object.assign/issues/17
252
- // if (sym instanceof Symbol) { return false; }
253
- // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
254
- // if (!(symObj instanceof Symbol)) { return false; }
255
-
256
- // if (typeof Symbol.prototype.toString !== 'function') { return false; }
257
- // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
258
-
259
- var symVal = 42;
260
- obj[sym] = symVal;
261
- for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
262
- if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
263
-
264
- if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
265
-
266
- var syms = Object.getOwnPropertySymbols(obj);
267
- if (syms.length !== 1 || syms[0] !== sym) { return false; }
268
-
269
- if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
270
-
271
- if (typeof Object.getOwnPropertyDescriptor === 'function') {
272
- var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
273
- if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
274
- }
275
-
276
- return true;
277
- };
278
-
279
- var origSymbol = typeof Symbol !== 'undefined' && Symbol;
280
- var hasSymbolSham = shams;
281
-
282
- var hasSymbols$1 = function hasNativeSymbols() {
283
- if (typeof origSymbol !== 'function') { return false; }
284
- if (typeof Symbol !== 'function') { return false; }
285
- if (typeof origSymbol('foo') !== 'symbol') { return false; }
286
- if (typeof Symbol('bar') !== 'symbol') { return false; }
287
-
288
- return hasSymbolSham();
289
- };
290
-
291
- var test = {
292
- foo: {}
293
- };
294
-
295
- var $Object = Object;
296
-
297
- var hasProto$1 = function hasProto() {
298
- return { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object);
299
- };
300
-
301
- /* eslint no-invalid-this: 1 */
302
-
303
- var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
304
- var slice = Array.prototype.slice;
305
- var toStr$1 = Object.prototype.toString;
306
- var funcType = '[object Function]';
307
-
308
- var implementation$1 = function bind(that) {
309
- var target = this;
310
- if (typeof target !== 'function' || toStr$1.call(target) !== funcType) {
311
- throw new TypeError(ERROR_MESSAGE + target);
312
- }
313
- var args = slice.call(arguments, 1);
314
-
315
- var bound;
316
- var binder = function () {
317
- if (this instanceof bound) {
318
- var result = target.apply(
319
- this,
320
- args.concat(slice.call(arguments))
321
- );
322
- if (Object(result) === result) {
323
- return result;
324
- }
325
- return this;
326
- } else {
327
- return target.apply(
328
- that,
329
- args.concat(slice.call(arguments))
330
- );
331
- }
332
- };
333
-
334
- var boundLength = Math.max(0, target.length - args.length);
335
- var boundArgs = [];
336
- for (var i = 0; i < boundLength; i++) {
337
- boundArgs.push('$' + i);
338
- }
339
-
340
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
341
-
342
- if (target.prototype) {
343
- var Empty = function Empty() {};
344
- Empty.prototype = target.prototype;
345
- bound.prototype = new Empty();
346
- Empty.prototype = null;
347
- }
348
-
349
- return bound;
350
- };
351
-
352
- var implementation = implementation$1;
353
-
354
- var functionBind = Function.prototype.bind || implementation;
355
-
356
- var bind$1 = functionBind;
357
-
358
- var src = bind$1.call(Function.call, Object.prototype.hasOwnProperty);
359
-
360
- var undefined$1;
361
-
362
- var $SyntaxError = SyntaxError;
363
- var $Function = Function;
364
- var $TypeError$1 = TypeError;
365
-
366
- // eslint-disable-next-line consistent-return
367
- var getEvalledConstructor = function (expressionSyntax) {
368
- try {
369
- return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
370
- } catch (e) {}
371
- };
372
-
373
- var $gOPD = Object.getOwnPropertyDescriptor;
374
- if ($gOPD) {
375
- try {
376
- $gOPD({}, '');
377
- } catch (e) {
378
- $gOPD = null; // this is IE 8, which has a broken gOPD
379
- }
380
- }
381
-
382
- var throwTypeError = function () {
383
- throw new $TypeError$1();
384
- };
385
- var ThrowTypeError = $gOPD
386
- ? (function () {
387
- try {
388
- // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
389
- arguments.callee; // IE 8 does not throw here
390
- return throwTypeError;
391
- } catch (calleeThrows) {
392
- try {
393
- // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
394
- return $gOPD(arguments, 'callee').get;
395
- } catch (gOPDthrows) {
396
- return throwTypeError;
397
- }
398
- }
399
- }())
400
- : throwTypeError;
401
-
402
- var hasSymbols = hasSymbols$1();
403
- var hasProto = hasProto$1();
404
-
405
- var getProto = Object.getPrototypeOf || (
406
- hasProto
407
- ? function (x) { return x.__proto__; } // eslint-disable-line no-proto
408
- : null
409
- );
410
-
411
- var needsEval = {};
412
-
413
- var TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined$1 : getProto(Uint8Array);
414
-
415
- var INTRINSICS = {
416
- '%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
417
- '%Array%': Array,
418
- '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
419
- '%ArrayIteratorPrototype%': hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined$1,
420
- '%AsyncFromSyncIteratorPrototype%': undefined$1,
421
- '%AsyncFunction%': needsEval,
422
- '%AsyncGenerator%': needsEval,
423
- '%AsyncGeneratorFunction%': needsEval,
424
- '%AsyncIteratorPrototype%': needsEval,
425
- '%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
426
- '%BigInt%': typeof BigInt === 'undefined' ? undefined$1 : BigInt,
427
- '%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined$1 : BigInt64Array,
428
- '%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined$1 : BigUint64Array,
429
- '%Boolean%': Boolean,
430
- '%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
431
- '%Date%': Date,
432
- '%decodeURI%': decodeURI,
433
- '%decodeURIComponent%': decodeURIComponent,
434
- '%encodeURI%': encodeURI,
435
- '%encodeURIComponent%': encodeURIComponent,
436
- '%Error%': Error,
437
- '%eval%': eval, // eslint-disable-line no-eval
438
- '%EvalError%': EvalError,
439
- '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
440
- '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
441
- '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined$1 : FinalizationRegistry,
442
- '%Function%': $Function,
443
- '%GeneratorFunction%': needsEval,
444
- '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
445
- '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
446
- '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
447
- '%isFinite%': isFinite,
448
- '%isNaN%': isNaN,
449
- '%IteratorPrototype%': hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
450
- '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
451
- '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
452
- '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
453
- '%Math%': Math,
454
- '%Number%': Number,
455
- '%Object%': Object,
456
- '%parseFloat%': parseFloat,
457
- '%parseInt%': parseInt,
458
- '%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
459
- '%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
460
- '%RangeError%': RangeError,
461
- '%ReferenceError%': ReferenceError,
462
- '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
463
- '%RegExp%': RegExp,
464
- '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
465
- '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
466
- '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
467
- '%String%': String,
468
- '%StringIteratorPrototype%': hasSymbols && getProto ? getProto(''[Symbol.iterator]()) : undefined$1,
469
- '%Symbol%': hasSymbols ? Symbol : undefined$1,
470
- '%SyntaxError%': $SyntaxError,
471
- '%ThrowTypeError%': ThrowTypeError,
472
- '%TypedArray%': TypedArray,
473
- '%TypeError%': $TypeError$1,
474
- '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
475
- '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
476
- '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
477
- '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
478
- '%URIError%': URIError,
479
- '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
480
- '%WeakRef%': typeof WeakRef === 'undefined' ? undefined$1 : WeakRef,
481
- '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet
482
- };
483
-
484
- if (getProto) {
485
- try {
486
- null.error; // eslint-disable-line no-unused-expressions
487
- } catch (e) {
488
- // https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229
489
- var errorProto = getProto(getProto(e));
490
- INTRINSICS['%Error.prototype%'] = errorProto;
491
- }
492
- }
493
-
494
- var doEval = function doEval(name) {
495
- var value;
496
- if (name === '%AsyncFunction%') {
497
- value = getEvalledConstructor('async function () {}');
498
- } else if (name === '%GeneratorFunction%') {
499
- value = getEvalledConstructor('function* () {}');
500
- } else if (name === '%AsyncGeneratorFunction%') {
501
- value = getEvalledConstructor('async function* () {}');
502
- } else if (name === '%AsyncGenerator%') {
503
- var fn = doEval('%AsyncGeneratorFunction%');
504
- if (fn) {
505
- value = fn.prototype;
506
- }
507
- } else if (name === '%AsyncIteratorPrototype%') {
508
- var gen = doEval('%AsyncGenerator%');
509
- if (gen && getProto) {
510
- value = getProto(gen.prototype);
511
- }
512
- }
513
-
514
- INTRINSICS[name] = value;
515
-
516
- return value;
517
- };
518
-
519
- var LEGACY_ALIASES = {
520
- '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
521
- '%ArrayPrototype%': ['Array', 'prototype'],
522
- '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
523
- '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
524
- '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
525
- '%ArrayProto_values%': ['Array', 'prototype', 'values'],
526
- '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
527
- '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
528
- '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
529
- '%BooleanPrototype%': ['Boolean', 'prototype'],
530
- '%DataViewPrototype%': ['DataView', 'prototype'],
531
- '%DatePrototype%': ['Date', 'prototype'],
532
- '%ErrorPrototype%': ['Error', 'prototype'],
533
- '%EvalErrorPrototype%': ['EvalError', 'prototype'],
534
- '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
535
- '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
536
- '%FunctionPrototype%': ['Function', 'prototype'],
537
- '%Generator%': ['GeneratorFunction', 'prototype'],
538
- '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
539
- '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
540
- '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
541
- '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
542
- '%JSONParse%': ['JSON', 'parse'],
543
- '%JSONStringify%': ['JSON', 'stringify'],
544
- '%MapPrototype%': ['Map', 'prototype'],
545
- '%NumberPrototype%': ['Number', 'prototype'],
546
- '%ObjectPrototype%': ['Object', 'prototype'],
547
- '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
548
- '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
549
- '%PromisePrototype%': ['Promise', 'prototype'],
550
- '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
551
- '%Promise_all%': ['Promise', 'all'],
552
- '%Promise_reject%': ['Promise', 'reject'],
553
- '%Promise_resolve%': ['Promise', 'resolve'],
554
- '%RangeErrorPrototype%': ['RangeError', 'prototype'],
555
- '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
556
- '%RegExpPrototype%': ['RegExp', 'prototype'],
557
- '%SetPrototype%': ['Set', 'prototype'],
558
- '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
559
- '%StringPrototype%': ['String', 'prototype'],
560
- '%SymbolPrototype%': ['Symbol', 'prototype'],
561
- '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
562
- '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
563
- '%TypeErrorPrototype%': ['TypeError', 'prototype'],
564
- '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
565
- '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
566
- '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
567
- '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
568
- '%URIErrorPrototype%': ['URIError', 'prototype'],
569
- '%WeakMapPrototype%': ['WeakMap', 'prototype'],
570
- '%WeakSetPrototype%': ['WeakSet', 'prototype']
571
- };
572
-
573
- var bind = functionBind;
574
- var hasOwn$1 = src;
575
- var $concat$1 = bind.call(Function.call, Array.prototype.concat);
576
- var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
577
- var $replace$1 = bind.call(Function.call, String.prototype.replace);
578
- var $strSlice = bind.call(Function.call, String.prototype.slice);
579
- var $exec = bind.call(Function.call, RegExp.prototype.exec);
580
-
581
- /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
582
- var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
583
- var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
584
- var stringToPath = function stringToPath(string) {
585
- var first = $strSlice(string, 0, 1);
586
- var last = $strSlice(string, -1);
587
- if (first === '%' && last !== '%') {
588
- throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
589
- } else if (last === '%' && first !== '%') {
590
- throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
591
- }
592
- var result = [];
593
- $replace$1(string, rePropName, function (match, number, quote, subString) {
594
- result[result.length] = quote ? $replace$1(subString, reEscapeChar, '$1') : number || match;
595
- });
596
- return result;
597
- };
598
- /* end adaptation */
599
-
600
- var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
601
- var intrinsicName = name;
602
- var alias;
603
- if (hasOwn$1(LEGACY_ALIASES, intrinsicName)) {
604
- alias = LEGACY_ALIASES[intrinsicName];
605
- intrinsicName = '%' + alias[0] + '%';
606
- }
607
-
608
- if (hasOwn$1(INTRINSICS, intrinsicName)) {
609
- var value = INTRINSICS[intrinsicName];
610
- if (value === needsEval) {
611
- value = doEval(intrinsicName);
612
- }
613
- if (typeof value === 'undefined' && !allowMissing) {
614
- throw new $TypeError$1('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
615
- }
616
-
617
- return {
618
- alias: alias,
619
- name: intrinsicName,
620
- value: value
621
- };
622
- }
623
-
624
- throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
625
- };
626
-
627
- var getIntrinsic = function GetIntrinsic(name, allowMissing) {
628
- if (typeof name !== 'string' || name.length === 0) {
629
- throw new $TypeError$1('intrinsic name must be a non-empty string');
630
- }
631
- if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
632
- throw new $TypeError$1('"allowMissing" argument must be a boolean');
633
- }
634
-
635
- if ($exec(/^%?[^%]*%?$/, name) === null) {
636
- throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
637
- }
638
- var parts = stringToPath(name);
639
- var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
640
-
641
- var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
642
- var intrinsicRealName = intrinsic.name;
643
- var value = intrinsic.value;
644
- var skipFurtherCaching = false;
645
-
646
- var alias = intrinsic.alias;
647
- if (alias) {
648
- intrinsicBaseName = alias[0];
649
- $spliceApply(parts, $concat$1([0, 1], alias));
650
- }
651
-
652
- for (var i = 1, isOwn = true; i < parts.length; i += 1) {
653
- var part = parts[i];
654
- var first = $strSlice(part, 0, 1);
655
- var last = $strSlice(part, -1);
656
- if (
657
- (
658
- (first === '"' || first === "'" || first === '`')
659
- || (last === '"' || last === "'" || last === '`')
660
- )
661
- && first !== last
662
- ) {
663
- throw new $SyntaxError('property names with quotes must have matching quotes');
664
- }
665
- if (part === 'constructor' || !isOwn) {
666
- skipFurtherCaching = true;
667
- }
668
-
669
- intrinsicBaseName += '.' + part;
670
- intrinsicRealName = '%' + intrinsicBaseName + '%';
671
-
672
- if (hasOwn$1(INTRINSICS, intrinsicRealName)) {
673
- value = INTRINSICS[intrinsicRealName];
674
- } else if (value != null) {
675
- if (!(part in value)) {
676
- if (!allowMissing) {
677
- throw new $TypeError$1('base intrinsic for ' + name + ' exists, but the property is not available.');
678
- }
679
- return void undefined$1;
680
- }
681
- if ($gOPD && (i + 1) >= parts.length) {
682
- var desc = $gOPD(value, part);
683
- isOwn = !!desc;
684
-
685
- // By convention, when a data property is converted to an accessor
686
- // property to emulate a data property that does not suffer from
687
- // the override mistake, that accessor's getter is marked with
688
- // an `originalValue` property. Here, when we detect this, we
689
- // uphold the illusion by pretending to see that original data
690
- // property, i.e., returning the value rather than the getter
691
- // itself.
692
- if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
693
- value = desc.get;
694
- } else {
695
- value = value[part];
696
- }
697
- } else {
698
- isOwn = hasOwn$1(value, part);
699
- value = value[part];
700
- }
701
-
702
- if (isOwn && !skipFurtherCaching) {
703
- INTRINSICS[intrinsicRealName] = value;
704
- }
705
- }
706
- }
707
- return value;
708
- };
709
-
710
- var callBind$1 = {exports: {}};
711
-
712
- callBind$1.exports;
713
-
714
- (function (module) {
715
-
716
- var bind = functionBind;
717
- var GetIntrinsic = getIntrinsic;
718
-
719
- var $apply = GetIntrinsic('%Function.prototype.apply%');
720
- var $call = GetIntrinsic('%Function.prototype.call%');
721
- var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
722
-
723
- var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
724
- var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
725
- var $max = GetIntrinsic('%Math.max%');
726
-
727
- if ($defineProperty) {
728
- try {
729
- $defineProperty({}, 'a', { value: 1 });
730
- } catch (e) {
731
- // IE 8 has a broken defineProperty
732
- $defineProperty = null;
733
- }
734
- }
735
-
736
- module.exports = function callBind(originalFunction) {
737
- var func = $reflectApply(bind, $call, arguments);
738
- if ($gOPD && $defineProperty) {
739
- var desc = $gOPD(func, 'length');
740
- if (desc.configurable) {
741
- // original length, plus the receiver, minus any additional arguments (after the receiver)
742
- $defineProperty(
743
- func,
744
- 'length',
745
- { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
746
- );
747
- }
748
- }
749
- return func;
750
- };
751
-
752
- var applyBind = function applyBind() {
753
- return $reflectApply(bind, $apply, arguments);
754
- };
755
-
756
- if ($defineProperty) {
757
- $defineProperty(module.exports, 'apply', { value: applyBind });
758
- } else {
759
- module.exports.apply = applyBind;
760
- }
761
- } (callBind$1));
762
-
763
- var callBindExports = callBind$1.exports;
764
-
765
- var GetIntrinsic$1 = getIntrinsic;
766
-
767
- var callBind = callBindExports;
768
-
769
- var $indexOf = callBind(GetIntrinsic$1('String.prototype.indexOf'));
770
-
771
- var callBound$1 = function callBoundIntrinsic(name, allowMissing) {
772
- var intrinsic = GetIntrinsic$1(name, !!allowMissing);
773
- if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
774
- return callBind(intrinsic);
775
- }
776
- return intrinsic;
777
- };
778
-
779
- var util_inspect = require$$0__default["default"].inspect;
780
-
781
- var hasMap = typeof Map === 'function' && Map.prototype;
782
- var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
783
- var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
784
- var mapForEach = hasMap && Map.prototype.forEach;
785
- var hasSet = typeof Set === 'function' && Set.prototype;
786
- var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
787
- var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
788
- var setForEach = hasSet && Set.prototype.forEach;
789
- var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
790
- var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
791
- var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
792
- var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
793
- var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
794
- var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
795
- var booleanValueOf = Boolean.prototype.valueOf;
796
- var objectToString = Object.prototype.toString;
797
- var functionToString = Function.prototype.toString;
798
- var $match = String.prototype.match;
799
- var $slice = String.prototype.slice;
800
- var $replace = String.prototype.replace;
801
- var $toUpperCase = String.prototype.toUpperCase;
802
- var $toLowerCase = String.prototype.toLowerCase;
803
- var $test = RegExp.prototype.test;
804
- var $concat = Array.prototype.concat;
805
- var $join = Array.prototype.join;
806
- var $arrSlice = Array.prototype.slice;
807
- var $floor = Math.floor;
808
- var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
809
- var gOPS = Object.getOwnPropertySymbols;
810
- var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
811
- var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
812
- // ie, `has-tostringtag/shams
813
- var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol')
814
- ? Symbol.toStringTag
815
- : null;
816
- var isEnumerable = Object.prototype.propertyIsEnumerable;
817
-
818
- var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || (
819
- [].__proto__ === Array.prototype // eslint-disable-line no-proto
820
- ? function (O) {
821
- return O.__proto__; // eslint-disable-line no-proto
822
- }
823
- : null
824
- );
825
-
826
- function addNumericSeparator(num, str) {
827
- if (
828
- num === Infinity
829
- || num === -Infinity
830
- || num !== num
831
- || (num && num > -1000 && num < 1000)
832
- || $test.call(/e/, str)
833
- ) {
834
- return str;
835
- }
836
- var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
837
- if (typeof num === 'number') {
838
- var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num)
839
- if (int !== num) {
840
- var intStr = String(int);
841
- var dec = $slice.call(str, intStr.length + 1);
842
- return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
843
- }
844
- }
845
- return $replace.call(str, sepRegex, '$&_');
846
- }
847
-
848
- var utilInspect = util_inspect;
849
- var inspectCustom = utilInspect.custom;
850
- var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
851
-
852
- var objectInspect = function inspect_(obj, options, depth, seen) {
853
- var opts = options || {};
854
-
855
- if (has$3(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
856
- throw new TypeError('option "quoteStyle" must be "single" or "double"');
857
- }
858
- if (
859
- has$3(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number'
860
- ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
861
- : opts.maxStringLength !== null
862
- )
863
- ) {
864
- throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
865
- }
866
- var customInspect = has$3(opts, 'customInspect') ? opts.customInspect : true;
867
- if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
868
- throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
869
- }
870
-
871
- if (
872
- has$3(opts, 'indent')
873
- && opts.indent !== null
874
- && opts.indent !== '\t'
875
- && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
876
- ) {
877
- throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
878
- }
879
- if (has$3(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
880
- throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
881
- }
882
- var numericSeparator = opts.numericSeparator;
883
-
884
- if (typeof obj === 'undefined') {
885
- return 'undefined';
886
- }
887
- if (obj === null) {
888
- return 'null';
889
- }
890
- if (typeof obj === 'boolean') {
891
- return obj ? 'true' : 'false';
892
- }
893
-
894
- if (typeof obj === 'string') {
895
- return inspectString(obj, opts);
896
- }
897
- if (typeof obj === 'number') {
898
- if (obj === 0) {
899
- return Infinity / obj > 0 ? '0' : '-0';
900
- }
901
- var str = String(obj);
902
- return numericSeparator ? addNumericSeparator(obj, str) : str;
903
- }
904
- if (typeof obj === 'bigint') {
905
- var bigIntStr = String(obj) + 'n';
906
- return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
907
- }
908
-
909
- var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
910
- if (typeof depth === 'undefined') { depth = 0; }
911
- if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
912
- return isArray$3(obj) ? '[Array]' : '[Object]';
913
- }
914
-
915
- var indent = getIndent(opts, depth);
916
-
917
- if (typeof seen === 'undefined') {
918
- seen = [];
919
- } else if (indexOf(seen, obj) >= 0) {
920
- return '[Circular]';
921
- }
922
-
923
- function inspect(value, from, noIndent) {
924
- if (from) {
925
- seen = $arrSlice.call(seen);
926
- seen.push(from);
927
- }
928
- if (noIndent) {
929
- var newOpts = {
930
- depth: opts.depth
931
- };
932
- if (has$3(opts, 'quoteStyle')) {
933
- newOpts.quoteStyle = opts.quoteStyle;
934
- }
935
- return inspect_(value, newOpts, depth + 1, seen);
936
- }
937
- return inspect_(value, opts, depth + 1, seen);
938
- }
939
-
940
- if (typeof obj === 'function' && !isRegExp$1(obj)) { // in older engines, regexes are callable
941
- var name = nameOf(obj);
942
- var keys = arrObjKeys(obj, inspect);
943
- return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
944
- }
945
- if (isSymbol(obj)) {
946
- var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
947
- return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
948
- }
949
- if (isElement(obj)) {
950
- var s = '<' + $toLowerCase.call(String(obj.nodeName));
951
- var attrs = obj.attributes || [];
952
- for (var i = 0; i < attrs.length; i++) {
953
- s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
954
- }
955
- s += '>';
956
- if (obj.childNodes && obj.childNodes.length) { s += '...'; }
957
- s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
958
- return s;
959
- }
960
- if (isArray$3(obj)) {
961
- if (obj.length === 0) { return '[]'; }
962
- var xs = arrObjKeys(obj, inspect);
963
- if (indent && !singleLineValues(xs)) {
964
- return '[' + indentedJoin(xs, indent) + ']';
965
- }
966
- return '[ ' + $join.call(xs, ', ') + ' ]';
967
- }
968
- if (isError(obj)) {
969
- var parts = arrObjKeys(obj, inspect);
970
- if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {
971
- return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
972
- }
973
- if (parts.length === 0) { return '[' + String(obj) + ']'; }
974
- return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
975
- }
976
- if (typeof obj === 'object' && customInspect) {
977
- if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
978
- return utilInspect(obj, { depth: maxDepth - depth });
979
- } else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
980
- return obj.inspect();
981
- }
982
- }
983
- if (isMap(obj)) {
984
- var mapParts = [];
985
- if (mapForEach) {
986
- mapForEach.call(obj, function (value, key) {
987
- mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
988
- });
989
- }
990
- return collectionOf('Map', mapSize.call(obj), mapParts, indent);
991
- }
992
- if (isSet(obj)) {
993
- var setParts = [];
994
- if (setForEach) {
995
- setForEach.call(obj, function (value) {
996
- setParts.push(inspect(value, obj));
997
- });
998
- }
999
- return collectionOf('Set', setSize.call(obj), setParts, indent);
1000
- }
1001
- if (isWeakMap(obj)) {
1002
- return weakCollectionOf('WeakMap');
1003
- }
1004
- if (isWeakSet(obj)) {
1005
- return weakCollectionOf('WeakSet');
1006
- }
1007
- if (isWeakRef(obj)) {
1008
- return weakCollectionOf('WeakRef');
1009
- }
1010
- if (isNumber(obj)) {
1011
- return markBoxed(inspect(Number(obj)));
1012
- }
1013
- if (isBigInt(obj)) {
1014
- return markBoxed(inspect(bigIntValueOf.call(obj)));
1015
- }
1016
- if (isBoolean(obj)) {
1017
- return markBoxed(booleanValueOf.call(obj));
1018
- }
1019
- if (isString(obj)) {
1020
- return markBoxed(inspect(String(obj)));
1021
- }
1022
- if (!isDate(obj) && !isRegExp$1(obj)) {
1023
- var ys = arrObjKeys(obj, inspect);
1024
- var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
1025
- var protoTag = obj instanceof Object ? '' : 'null prototype';
1026
- var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
1027
- var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
1028
- var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
1029
- if (ys.length === 0) { return tag + '{}'; }
1030
- if (indent) {
1031
- return tag + '{' + indentedJoin(ys, indent) + '}';
1032
- }
1033
- return tag + '{ ' + $join.call(ys, ', ') + ' }';
1034
- }
1035
- return String(obj);
1036
- };
1037
-
1038
- function wrapQuotes(s, defaultStyle, opts) {
1039
- var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
1040
- return quoteChar + s + quoteChar;
1041
- }
1042
-
1043
- function quote(s) {
1044
- return $replace.call(String(s), /"/g, '&quot;');
1045
- }
1046
-
1047
- function isArray$3(obj) { return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1048
- function isDate(obj) { return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1049
- function isRegExp$1(obj) { return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1050
- function isError(obj) { return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1051
- function isString(obj) { return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1052
- function isNumber(obj) { return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1053
- function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1054
-
1055
- // Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
1056
- function isSymbol(obj) {
1057
- if (hasShammedSymbols) {
1058
- return obj && typeof obj === 'object' && obj instanceof Symbol;
1059
- }
1060
- if (typeof obj === 'symbol') {
1061
- return true;
1062
- }
1063
- if (!obj || typeof obj !== 'object' || !symToString) {
1064
- return false;
1065
- }
1066
- try {
1067
- symToString.call(obj);
1068
- return true;
1069
- } catch (e) {}
1070
- return false;
1071
- }
1072
-
1073
- function isBigInt(obj) {
1074
- if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
1075
- return false;
1076
- }
1077
- try {
1078
- bigIntValueOf.call(obj);
1079
- return true;
1080
- } catch (e) {}
1081
- return false;
1082
- }
1083
-
1084
- var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
1085
- function has$3(obj, key) {
1086
- return hasOwn.call(obj, key);
1087
- }
1088
-
1089
- function toStr(obj) {
1090
- return objectToString.call(obj);
1091
- }
1092
-
1093
- function nameOf(f) {
1094
- if (f.name) { return f.name; }
1095
- var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
1096
- if (m) { return m[1]; }
1097
- return null;
1098
- }
1099
-
1100
- function indexOf(xs, x) {
1101
- if (xs.indexOf) { return xs.indexOf(x); }
1102
- for (var i = 0, l = xs.length; i < l; i++) {
1103
- if (xs[i] === x) { return i; }
1104
- }
1105
- return -1;
1106
- }
1107
-
1108
- function isMap(x) {
1109
- if (!mapSize || !x || typeof x !== 'object') {
1110
- return false;
1111
- }
1112
- try {
1113
- mapSize.call(x);
1114
- try {
1115
- setSize.call(x);
1116
- } catch (s) {
1117
- return true;
1118
- }
1119
- return x instanceof Map; // core-js workaround, pre-v2.5.0
1120
- } catch (e) {}
1121
- return false;
1122
- }
1123
-
1124
- function isWeakMap(x) {
1125
- if (!weakMapHas || !x || typeof x !== 'object') {
1126
- return false;
1127
- }
1128
- try {
1129
- weakMapHas.call(x, weakMapHas);
1130
- try {
1131
- weakSetHas.call(x, weakSetHas);
1132
- } catch (s) {
1133
- return true;
1134
- }
1135
- return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
1136
- } catch (e) {}
1137
- return false;
1138
- }
1139
-
1140
- function isWeakRef(x) {
1141
- if (!weakRefDeref || !x || typeof x !== 'object') {
1142
- return false;
1143
- }
1144
- try {
1145
- weakRefDeref.call(x);
1146
- return true;
1147
- } catch (e) {}
1148
- return false;
1149
- }
1150
-
1151
- function isSet(x) {
1152
- if (!setSize || !x || typeof x !== 'object') {
1153
- return false;
1154
- }
1155
- try {
1156
- setSize.call(x);
1157
- try {
1158
- mapSize.call(x);
1159
- } catch (m) {
1160
- return true;
1161
- }
1162
- return x instanceof Set; // core-js workaround, pre-v2.5.0
1163
- } catch (e) {}
1164
- return false;
1165
- }
1166
-
1167
- function isWeakSet(x) {
1168
- if (!weakSetHas || !x || typeof x !== 'object') {
1169
- return false;
1170
- }
1171
- try {
1172
- weakSetHas.call(x, weakSetHas);
1173
- try {
1174
- weakMapHas.call(x, weakMapHas);
1175
- } catch (s) {
1176
- return true;
1177
- }
1178
- return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
1179
- } catch (e) {}
1180
- return false;
1181
- }
1182
-
1183
- function isElement(x) {
1184
- if (!x || typeof x !== 'object') { return false; }
1185
- if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
1186
- return true;
1187
- }
1188
- return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
1189
- }
1190
-
1191
- function inspectString(str, opts) {
1192
- if (str.length > opts.maxStringLength) {
1193
- var remaining = str.length - opts.maxStringLength;
1194
- var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
1195
- return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
1196
- }
1197
- // eslint-disable-next-line no-control-regex
1198
- var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
1199
- return wrapQuotes(s, 'single', opts);
1200
- }
1201
-
1202
- function lowbyte(c) {
1203
- var n = c.charCodeAt(0);
1204
- var x = {
1205
- 8: 'b',
1206
- 9: 't',
1207
- 10: 'n',
1208
- 12: 'f',
1209
- 13: 'r'
1210
- }[n];
1211
- if (x) { return '\\' + x; }
1212
- return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
1213
- }
1214
-
1215
- function markBoxed(str) {
1216
- return 'Object(' + str + ')';
1217
- }
1218
-
1219
- function weakCollectionOf(type) {
1220
- return type + ' { ? }';
1221
- }
1222
-
1223
- function collectionOf(type, size, entries, indent) {
1224
- var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
1225
- return type + ' (' + size + ') {' + joinedEntries + '}';
1226
- }
1227
-
1228
- function singleLineValues(xs) {
1229
- for (var i = 0; i < xs.length; i++) {
1230
- if (indexOf(xs[i], '\n') >= 0) {
1231
- return false;
1232
- }
1233
- }
1234
- return true;
1235
- }
1236
-
1237
- function getIndent(opts, depth) {
1238
- var baseIndent;
1239
- if (opts.indent === '\t') {
1240
- baseIndent = '\t';
1241
- } else if (typeof opts.indent === 'number' && opts.indent > 0) {
1242
- baseIndent = $join.call(Array(opts.indent + 1), ' ');
1243
- } else {
1244
- return null;
1245
- }
1246
- return {
1247
- base: baseIndent,
1248
- prev: $join.call(Array(depth + 1), baseIndent)
1249
- };
1250
- }
1251
-
1252
- function indentedJoin(xs, indent) {
1253
- if (xs.length === 0) { return ''; }
1254
- var lineJoiner = '\n' + indent.prev + indent.base;
1255
- return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
1256
- }
1257
-
1258
- function arrObjKeys(obj, inspect) {
1259
- var isArr = isArray$3(obj);
1260
- var xs = [];
1261
- if (isArr) {
1262
- xs.length = obj.length;
1263
- for (var i = 0; i < obj.length; i++) {
1264
- xs[i] = has$3(obj, i) ? inspect(obj[i], obj) : '';
1265
- }
1266
- }
1267
- var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
1268
- var symMap;
1269
- if (hasShammedSymbols) {
1270
- symMap = {};
1271
- for (var k = 0; k < syms.length; k++) {
1272
- symMap['$' + syms[k]] = syms[k];
1273
- }
1274
- }
1275
-
1276
- for (var key in obj) { // eslint-disable-line no-restricted-syntax
1277
- if (!has$3(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
1278
- if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
1279
- if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
1280
- // this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
1281
- continue; // eslint-disable-line no-restricted-syntax, no-continue
1282
- } else if ($test.call(/[^\w$]/, key)) {
1283
- xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
1284
- } else {
1285
- xs.push(key + ': ' + inspect(obj[key], obj));
1286
- }
1287
- }
1288
- if (typeof gOPS === 'function') {
1289
- for (var j = 0; j < syms.length; j++) {
1290
- if (isEnumerable.call(obj, syms[j])) {
1291
- xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
1292
- }
1293
- }
1294
- }
1295
- return xs;
1296
- }
1297
-
1298
- var GetIntrinsic = getIntrinsic;
1299
- var callBound = callBound$1;
1300
- var inspect = objectInspect;
1301
-
1302
- var $TypeError = GetIntrinsic('%TypeError%');
1303
- var $WeakMap = GetIntrinsic('%WeakMap%', true);
1304
- var $Map = GetIntrinsic('%Map%', true);
1305
-
1306
- var $weakMapGet = callBound('WeakMap.prototype.get', true);
1307
- var $weakMapSet = callBound('WeakMap.prototype.set', true);
1308
- var $weakMapHas = callBound('WeakMap.prototype.has', true);
1309
- var $mapGet = callBound('Map.prototype.get', true);
1310
- var $mapSet = callBound('Map.prototype.set', true);
1311
- var $mapHas = callBound('Map.prototype.has', true);
1312
-
1313
- /*
1314
- * This function traverses the list returning the node corresponding to the
1315
- * given key.
1316
- *
1317
- * That node is also moved to the head of the list, so that if it's accessed
1318
- * again we don't need to traverse the whole list. By doing so, all the recently
1319
- * used nodes can be accessed relatively quickly.
1320
- */
1321
- var listGetNode = function (list, key) { // eslint-disable-line consistent-return
1322
- for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
1323
- if (curr.key === key) {
1324
- prev.next = curr.next;
1325
- curr.next = list.next;
1326
- list.next = curr; // eslint-disable-line no-param-reassign
1327
- return curr;
1328
- }
1329
- }
1330
- };
1331
-
1332
- var listGet = function (objects, key) {
1333
- var node = listGetNode(objects, key);
1334
- return node && node.value;
1335
- };
1336
- var listSet = function (objects, key, value) {
1337
- var node = listGetNode(objects, key);
1338
- if (node) {
1339
- node.value = value;
1340
- } else {
1341
- // Prepend the new node to the beginning of the list
1342
- objects.next = { // eslint-disable-line no-param-reassign
1343
- key: key,
1344
- next: objects.next,
1345
- value: value
1346
- };
1347
- }
1348
- };
1349
- var listHas = function (objects, key) {
1350
- return !!listGetNode(objects, key);
1351
- };
1352
-
1353
- var sideChannel = function getSideChannel() {
1354
- var $wm;
1355
- var $m;
1356
- var $o;
1357
- var channel = {
1358
- assert: function (key) {
1359
- if (!channel.has(key)) {
1360
- throw new $TypeError('Side channel does not contain ' + inspect(key));
1361
- }
1362
- },
1363
- get: function (key) { // eslint-disable-line consistent-return
1364
- if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
1365
- if ($wm) {
1366
- return $weakMapGet($wm, key);
1367
- }
1368
- } else if ($Map) {
1369
- if ($m) {
1370
- return $mapGet($m, key);
1371
- }
1372
- } else {
1373
- if ($o) { // eslint-disable-line no-lonely-if
1374
- return listGet($o, key);
1375
- }
1376
- }
1377
- },
1378
- has: function (key) {
1379
- if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
1380
- if ($wm) {
1381
- return $weakMapHas($wm, key);
1382
- }
1383
- } else if ($Map) {
1384
- if ($m) {
1385
- return $mapHas($m, key);
1386
- }
1387
- } else {
1388
- if ($o) { // eslint-disable-line no-lonely-if
1389
- return listHas($o, key);
1390
- }
1391
- }
1392
- return false;
1393
- },
1394
- set: function (key, value) {
1395
- if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
1396
- if (!$wm) {
1397
- $wm = new $WeakMap();
1398
- }
1399
- $weakMapSet($wm, key, value);
1400
- } else if ($Map) {
1401
- if (!$m) {
1402
- $m = new $Map();
1403
- }
1404
- $mapSet($m, key, value);
1405
- } else {
1406
- if (!$o) {
1407
- /*
1408
- * Initialize the linked list as an empty node, so that we don't have
1409
- * to special-case handling of the first node: we can always refer to
1410
- * it as (previous node).next, instead of something like (list).head
1411
- */
1412
- $o = { key: {}, next: null };
1413
- }
1414
- listSet($o, key, value);
1415
- }
1416
- }
1417
- };
1418
- return channel;
1419
- };
1420
-
1421
- var replace = String.prototype.replace;
1422
- var percentTwenties = /%20/g;
1423
-
1424
- var Format = {
1425
- RFC1738: 'RFC1738',
1426
- RFC3986: 'RFC3986'
1427
- };
1428
-
1429
- var formats$3 = {
1430
- 'default': Format.RFC3986,
1431
- formatters: {
1432
- RFC1738: function (value) {
1433
- return replace.call(value, percentTwenties, '+');
1434
- },
1435
- RFC3986: function (value) {
1436
- return String(value);
1437
- }
1438
- },
1439
- RFC1738: Format.RFC1738,
1440
- RFC3986: Format.RFC3986
1441
- };
1442
-
1443
- var formats$2 = formats$3;
1444
-
1445
- var has$2 = Object.prototype.hasOwnProperty;
1446
- var isArray$2 = Array.isArray;
1447
-
1448
- var hexTable = (function () {
1449
- var array = [];
1450
- for (var i = 0; i < 256; ++i) {
1451
- array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
1452
- }
1453
-
1454
- return array;
1455
- }());
1456
-
1457
- var compactQueue = function compactQueue(queue) {
1458
- while (queue.length > 1) {
1459
- var item = queue.pop();
1460
- var obj = item.obj[item.prop];
1461
-
1462
- if (isArray$2(obj)) {
1463
- var compacted = [];
1464
-
1465
- for (var j = 0; j < obj.length; ++j) {
1466
- if (typeof obj[j] !== 'undefined') {
1467
- compacted.push(obj[j]);
1468
- }
1469
- }
1470
-
1471
- item.obj[item.prop] = compacted;
1472
- }
1473
- }
1474
- };
1475
-
1476
- var arrayToObject = function arrayToObject(source, options) {
1477
- var obj = options && options.plainObjects ? Object.create(null) : {};
1478
- for (var i = 0; i < source.length; ++i) {
1479
- if (typeof source[i] !== 'undefined') {
1480
- obj[i] = source[i];
1481
- }
1482
- }
1483
-
1484
- return obj;
1485
- };
1486
-
1487
- var merge = function merge(target, source, options) {
1488
- /* eslint no-param-reassign: 0 */
1489
- if (!source) {
1490
- return target;
1491
- }
1492
-
1493
- if (typeof source !== 'object') {
1494
- if (isArray$2(target)) {
1495
- target.push(source);
1496
- } else if (target && typeof target === 'object') {
1497
- if ((options && (options.plainObjects || options.allowPrototypes)) || !has$2.call(Object.prototype, source)) {
1498
- target[source] = true;
1499
- }
1500
- } else {
1501
- return [target, source];
1502
- }
1503
-
1504
- return target;
1505
- }
1506
-
1507
- if (!target || typeof target !== 'object') {
1508
- return [target].concat(source);
1509
- }
1510
-
1511
- var mergeTarget = target;
1512
- if (isArray$2(target) && !isArray$2(source)) {
1513
- mergeTarget = arrayToObject(target, options);
1514
- }
1515
-
1516
- if (isArray$2(target) && isArray$2(source)) {
1517
- source.forEach(function (item, i) {
1518
- if (has$2.call(target, i)) {
1519
- var targetItem = target[i];
1520
- if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
1521
- target[i] = merge(targetItem, item, options);
1522
- } else {
1523
- target.push(item);
1524
- }
1525
- } else {
1526
- target[i] = item;
1527
- }
1528
- });
1529
- return target;
1530
- }
1531
-
1532
- return Object.keys(source).reduce(function (acc, key) {
1533
- var value = source[key];
1534
-
1535
- if (has$2.call(acc, key)) {
1536
- acc[key] = merge(acc[key], value, options);
1537
- } else {
1538
- acc[key] = value;
1539
- }
1540
- return acc;
1541
- }, mergeTarget);
1542
- };
1543
-
1544
- var assign = function assignSingleSource(target, source) {
1545
- return Object.keys(source).reduce(function (acc, key) {
1546
- acc[key] = source[key];
1547
- return acc;
1548
- }, target);
1549
- };
1550
-
1551
- var decode = function (str, decoder, charset) {
1552
- var strWithoutPlus = str.replace(/\+/g, ' ');
1553
- if (charset === 'iso-8859-1') {
1554
- // unescape never throws, no try...catch needed:
1555
- return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
1556
- }
1557
- // utf-8
1558
- try {
1559
- return decodeURIComponent(strWithoutPlus);
1560
- } catch (e) {
1561
- return strWithoutPlus;
1562
- }
1563
- };
1564
-
1565
- var encode = function encode(str, defaultEncoder, charset, kind, format) {
1566
- // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
1567
- // It has been adapted here for stricter adherence to RFC 3986
1568
- if (str.length === 0) {
1569
- return str;
1570
- }
1571
-
1572
- var string = str;
1573
- if (typeof str === 'symbol') {
1574
- string = Symbol.prototype.toString.call(str);
1575
- } else if (typeof str !== 'string') {
1576
- string = String(str);
1577
- }
1578
-
1579
- if (charset === 'iso-8859-1') {
1580
- return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
1581
- return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
1582
- });
1583
- }
1584
-
1585
- var out = '';
1586
- for (var i = 0; i < string.length; ++i) {
1587
- var c = string.charCodeAt(i);
1588
-
1589
- if (
1590
- c === 0x2D // -
1591
- || c === 0x2E // .
1592
- || c === 0x5F // _
1593
- || c === 0x7E // ~
1594
- || (c >= 0x30 && c <= 0x39) // 0-9
1595
- || (c >= 0x41 && c <= 0x5A) // a-z
1596
- || (c >= 0x61 && c <= 0x7A) // A-Z
1597
- || (format === formats$2.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
1598
- ) {
1599
- out += string.charAt(i);
1600
- continue;
1601
- }
1602
-
1603
- if (c < 0x80) {
1604
- out = out + hexTable[c];
1605
- continue;
1606
- }
1607
-
1608
- if (c < 0x800) {
1609
- out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
1610
- continue;
1611
- }
1612
-
1613
- if (c < 0xD800 || c >= 0xE000) {
1614
- out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
1615
- continue;
1616
- }
1617
-
1618
- i += 1;
1619
- c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
1620
- /* eslint operator-linebreak: [2, "before"] */
1621
- out += hexTable[0xF0 | (c >> 18)]
1622
- + hexTable[0x80 | ((c >> 12) & 0x3F)]
1623
- + hexTable[0x80 | ((c >> 6) & 0x3F)]
1624
- + hexTable[0x80 | (c & 0x3F)];
1625
- }
1626
-
1627
- return out;
1628
- };
1629
-
1630
- var compact = function compact(value) {
1631
- var queue = [{ obj: { o: value }, prop: 'o' }];
1632
- var refs = [];
1633
-
1634
- for (var i = 0; i < queue.length; ++i) {
1635
- var item = queue[i];
1636
- var obj = item.obj[item.prop];
1637
-
1638
- var keys = Object.keys(obj);
1639
- for (var j = 0; j < keys.length; ++j) {
1640
- var key = keys[j];
1641
- var val = obj[key];
1642
- if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
1643
- queue.push({ obj: obj, prop: key });
1644
- refs.push(val);
1645
- }
1646
- }
1647
- }
1648
-
1649
- compactQueue(queue);
1650
-
1651
- return value;
1652
- };
1653
-
1654
- var isRegExp = function isRegExp(obj) {
1655
- return Object.prototype.toString.call(obj) === '[object RegExp]';
1656
- };
1657
-
1658
- var isBuffer = function isBuffer(obj) {
1659
- if (!obj || typeof obj !== 'object') {
1660
- return false;
1661
- }
1662
-
1663
- return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
1664
- };
1665
-
1666
- var combine = function combine(a, b) {
1667
- return [].concat(a, b);
1668
- };
1669
-
1670
- var maybeMap = function maybeMap(val, fn) {
1671
- if (isArray$2(val)) {
1672
- var mapped = [];
1673
- for (var i = 0; i < val.length; i += 1) {
1674
- mapped.push(fn(val[i]));
1675
- }
1676
- return mapped;
1677
- }
1678
- return fn(val);
1679
- };
1680
-
1681
- var utils$2 = {
1682
- arrayToObject: arrayToObject,
1683
- assign: assign,
1684
- combine: combine,
1685
- compact: compact,
1686
- decode: decode,
1687
- encode: encode,
1688
- isBuffer: isBuffer,
1689
- isRegExp: isRegExp,
1690
- maybeMap: maybeMap,
1691
- merge: merge
1692
- };
1693
-
1694
- var getSideChannel = sideChannel;
1695
- var utils$1 = utils$2;
1696
- var formats$1 = formats$3;
1697
- var has$1 = Object.prototype.hasOwnProperty;
1698
-
1699
- var arrayPrefixGenerators = {
1700
- brackets: function brackets(prefix) {
1701
- return prefix + '[]';
1702
- },
1703
- comma: 'comma',
1704
- indices: function indices(prefix, key) {
1705
- return prefix + '[' + key + ']';
1706
- },
1707
- repeat: function repeat(prefix) {
1708
- return prefix;
1709
- }
1710
- };
1711
-
1712
- var isArray$1 = Array.isArray;
1713
- var push = Array.prototype.push;
1714
- var pushToArray = function (arr, valueOrArray) {
1715
- push.apply(arr, isArray$1(valueOrArray) ? valueOrArray : [valueOrArray]);
1716
- };
1717
-
1718
- var toISO = Date.prototype.toISOString;
1719
-
1720
- var defaultFormat = formats$1['default'];
1721
- var defaults$1 = {
1722
- addQueryPrefix: false,
1723
- allowDots: false,
1724
- charset: 'utf-8',
1725
- charsetSentinel: false,
1726
- delimiter: '&',
1727
- encode: true,
1728
- encoder: utils$1.encode,
1729
- encodeValuesOnly: false,
1730
- format: defaultFormat,
1731
- formatter: formats$1.formatters[defaultFormat],
1732
- // deprecated
1733
- indices: false,
1734
- serializeDate: function serializeDate(date) {
1735
- return toISO.call(date);
1736
- },
1737
- skipNulls: false,
1738
- strictNullHandling: false
1739
- };
1740
-
1741
- var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
1742
- return typeof v === 'string'
1743
- || typeof v === 'number'
1744
- || typeof v === 'boolean'
1745
- || typeof v === 'symbol'
1746
- || typeof v === 'bigint';
1747
- };
1748
-
1749
- var sentinel = {};
1750
-
1751
- var stringify$1 = function stringify(
1752
- object,
1753
- prefix,
1754
- generateArrayPrefix,
1755
- commaRoundTrip,
1756
- strictNullHandling,
1757
- skipNulls,
1758
- encoder,
1759
- filter,
1760
- sort,
1761
- allowDots,
1762
- serializeDate,
1763
- format,
1764
- formatter,
1765
- encodeValuesOnly,
1766
- charset,
1767
- sideChannel
1768
- ) {
1769
- var obj = object;
1770
-
1771
- var tmpSc = sideChannel;
1772
- var step = 0;
1773
- var findFlag = false;
1774
- while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
1775
- // Where object last appeared in the ref tree
1776
- var pos = tmpSc.get(object);
1777
- step += 1;
1778
- if (typeof pos !== 'undefined') {
1779
- if (pos === step) {
1780
- throw new RangeError('Cyclic object value');
1781
- } else {
1782
- findFlag = true; // Break while
1783
- }
1784
- }
1785
- if (typeof tmpSc.get(sentinel) === 'undefined') {
1786
- step = 0;
1787
- }
1788
- }
1789
-
1790
- if (typeof filter === 'function') {
1791
- obj = filter(prefix, obj);
1792
- } else if (obj instanceof Date) {
1793
- obj = serializeDate(obj);
1794
- } else if (generateArrayPrefix === 'comma' && isArray$1(obj)) {
1795
- obj = utils$1.maybeMap(obj, function (value) {
1796
- if (value instanceof Date) {
1797
- return serializeDate(value);
1798
- }
1799
- return value;
1800
- });
1801
- }
1802
-
1803
- if (obj === null) {
1804
- if (strictNullHandling) {
1805
- return encoder && !encodeValuesOnly ? encoder(prefix, defaults$1.encoder, charset, 'key', format) : prefix;
1806
- }
1807
-
1808
- obj = '';
1809
- }
1810
-
1811
- if (isNonNullishPrimitive(obj) || utils$1.isBuffer(obj)) {
1812
- if (encoder) {
1813
- var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$1.encoder, charset, 'key', format);
1814
- return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults$1.encoder, charset, 'value', format))];
1815
- }
1816
- return [formatter(prefix) + '=' + formatter(String(obj))];
1817
- }
1818
-
1819
- var values = [];
1820
-
1821
- if (typeof obj === 'undefined') {
1822
- return values;
1823
- }
1824
-
1825
- var objKeys;
1826
- if (generateArrayPrefix === 'comma' && isArray$1(obj)) {
1827
- // we need to join elements in
1828
- if (encodeValuesOnly && encoder) {
1829
- obj = utils$1.maybeMap(obj, encoder);
1830
- }
1831
- objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
1832
- } else if (isArray$1(filter)) {
1833
- objKeys = filter;
1834
- } else {
1835
- var keys = Object.keys(obj);
1836
- objKeys = sort ? keys.sort(sort) : keys;
1837
- }
1838
-
1839
- var adjustedPrefix = commaRoundTrip && isArray$1(obj) && obj.length === 1 ? prefix + '[]' : prefix;
1840
-
1841
- for (var j = 0; j < objKeys.length; ++j) {
1842
- var key = objKeys[j];
1843
- var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
1844
-
1845
- if (skipNulls && value === null) {
1846
- continue;
1847
- }
1848
-
1849
- var keyPrefix = isArray$1(obj)
1850
- ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix
1851
- : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
1852
-
1853
- sideChannel.set(object, step);
1854
- var valueSideChannel = getSideChannel();
1855
- valueSideChannel.set(sentinel, sideChannel);
1856
- pushToArray(values, stringify(
1857
- value,
1858
- keyPrefix,
1859
- generateArrayPrefix,
1860
- commaRoundTrip,
1861
- strictNullHandling,
1862
- skipNulls,
1863
- generateArrayPrefix === 'comma' && encodeValuesOnly && isArray$1(obj) ? null : encoder,
1864
- filter,
1865
- sort,
1866
- allowDots,
1867
- serializeDate,
1868
- format,
1869
- formatter,
1870
- encodeValuesOnly,
1871
- charset,
1872
- valueSideChannel
1873
- ));
1874
- }
1875
-
1876
- return values;
1877
- };
1878
-
1879
- var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
1880
- if (!opts) {
1881
- return defaults$1;
1882
- }
1883
-
1884
- if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
1885
- throw new TypeError('Encoder has to be a function.');
1886
- }
1887
-
1888
- var charset = opts.charset || defaults$1.charset;
1889
- if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
1890
- throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
1891
- }
1892
-
1893
- var format = formats$1['default'];
1894
- if (typeof opts.format !== 'undefined') {
1895
- if (!has$1.call(formats$1.formatters, opts.format)) {
1896
- throw new TypeError('Unknown format option provided.');
1897
- }
1898
- format = opts.format;
1899
- }
1900
- var formatter = formats$1.formatters[format];
1901
-
1902
- var filter = defaults$1.filter;
1903
- if (typeof opts.filter === 'function' || isArray$1(opts.filter)) {
1904
- filter = opts.filter;
1905
- }
1906
-
1907
- return {
1908
- addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults$1.addQueryPrefix,
1909
- allowDots: typeof opts.allowDots === 'undefined' ? defaults$1.allowDots : !!opts.allowDots,
1910
- charset: charset,
1911
- charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$1.charsetSentinel,
1912
- delimiter: typeof opts.delimiter === 'undefined' ? defaults$1.delimiter : opts.delimiter,
1913
- encode: typeof opts.encode === 'boolean' ? opts.encode : defaults$1.encode,
1914
- encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults$1.encoder,
1915
- encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults$1.encodeValuesOnly,
1916
- filter: filter,
1917
- format: format,
1918
- formatter: formatter,
1919
- serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults$1.serializeDate,
1920
- skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults$1.skipNulls,
1921
- sort: typeof opts.sort === 'function' ? opts.sort : null,
1922
- strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$1.strictNullHandling
1923
- };
1924
- };
1925
-
1926
- var stringify_1 = function (object, opts) {
1927
- var obj = object;
1928
- var options = normalizeStringifyOptions(opts);
1929
-
1930
- var objKeys;
1931
- var filter;
1932
-
1933
- if (typeof options.filter === 'function') {
1934
- filter = options.filter;
1935
- obj = filter('', obj);
1936
- } else if (isArray$1(options.filter)) {
1937
- filter = options.filter;
1938
- objKeys = filter;
1939
- }
1940
-
1941
- var keys = [];
1942
-
1943
- if (typeof obj !== 'object' || obj === null) {
1944
- return '';
1945
- }
1946
-
1947
- var arrayFormat;
1948
- if (opts && opts.arrayFormat in arrayPrefixGenerators) {
1949
- arrayFormat = opts.arrayFormat;
1950
- } else if (opts && 'indices' in opts) {
1951
- arrayFormat = opts.indices ? 'indices' : 'repeat';
1952
- } else {
1953
- arrayFormat = 'indices';
1954
- }
1955
-
1956
- var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
1957
- if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
1958
- throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
1959
- }
1960
- var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
1961
-
1962
- if (!objKeys) {
1963
- objKeys = Object.keys(obj);
1964
- }
1965
-
1966
- if (options.sort) {
1967
- objKeys.sort(options.sort);
1968
- }
1969
-
1970
- var sideChannel = getSideChannel();
1971
- for (var i = 0; i < objKeys.length; ++i) {
1972
- var key = objKeys[i];
1973
-
1974
- if (options.skipNulls && obj[key] === null) {
1975
- continue;
1976
- }
1977
- pushToArray(keys, stringify$1(
1978
- obj[key],
1979
- key,
1980
- generateArrayPrefix,
1981
- commaRoundTrip,
1982
- options.strictNullHandling,
1983
- options.skipNulls,
1984
- options.encode ? options.encoder : null,
1985
- options.filter,
1986
- options.sort,
1987
- options.allowDots,
1988
- options.serializeDate,
1989
- options.format,
1990
- options.formatter,
1991
- options.encodeValuesOnly,
1992
- options.charset,
1993
- sideChannel
1994
- ));
1995
- }
1996
-
1997
- var joined = keys.join(options.delimiter);
1998
- var prefix = options.addQueryPrefix === true ? '?' : '';
1999
-
2000
- if (options.charsetSentinel) {
2001
- if (options.charset === 'iso-8859-1') {
2002
- // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
2003
- prefix += 'utf8=%26%2310003%3B&';
2004
- } else {
2005
- // encodeURIComponent('✓')
2006
- prefix += 'utf8=%E2%9C%93&';
2007
- }
2008
- }
2009
-
2010
- return joined.length > 0 ? prefix + joined : '';
2011
- };
2012
-
2013
- var utils = utils$2;
2014
-
2015
- var has = Object.prototype.hasOwnProperty;
2016
- var isArray = Array.isArray;
2017
-
2018
- var defaults = {
2019
- allowDots: false,
2020
- allowPrototypes: false,
2021
- allowSparse: false,
2022
- arrayLimit: 20,
2023
- charset: 'utf-8',
2024
- charsetSentinel: false,
2025
- comma: false,
2026
- decoder: utils.decode,
2027
- delimiter: '&',
2028
- depth: 5,
2029
- ignoreQueryPrefix: false,
2030
- interpretNumericEntities: false,
2031
- parameterLimit: 1000,
2032
- parseArrays: true,
2033
- plainObjects: false,
2034
- strictNullHandling: false
2035
- };
2036
-
2037
- var interpretNumericEntities = function (str) {
2038
- return str.replace(/&#(\d+);/g, function ($0, numberStr) {
2039
- return String.fromCharCode(parseInt(numberStr, 10));
2040
- });
2041
- };
2042
-
2043
- var parseArrayValue = function (val, options) {
2044
- if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
2045
- return val.split(',');
2046
- }
2047
-
2048
- return val;
2049
- };
2050
-
2051
- // This is what browsers will submit when the ✓ character occurs in an
2052
- // application/x-www-form-urlencoded body and the encoding of the page containing
2053
- // the form is iso-8859-1, or when the submitted form has an accept-charset
2054
- // attribute of iso-8859-1. Presumably also with other charsets that do not contain
2055
- // the ✓ character, such as us-ascii.
2056
- var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('&#10003;')
2057
-
2058
- // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
2059
- var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
2060
-
2061
- var parseValues = function parseQueryStringValues(str, options) {
2062
- var obj = { __proto__: null };
2063
-
2064
- var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
2065
- var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
2066
- var parts = cleanStr.split(options.delimiter, limit);
2067
- var skipIndex = -1; // Keep track of where the utf8 sentinel was found
2068
- var i;
2069
-
2070
- var charset = options.charset;
2071
- if (options.charsetSentinel) {
2072
- for (i = 0; i < parts.length; ++i) {
2073
- if (parts[i].indexOf('utf8=') === 0) {
2074
- if (parts[i] === charsetSentinel) {
2075
- charset = 'utf-8';
2076
- } else if (parts[i] === isoSentinel) {
2077
- charset = 'iso-8859-1';
2078
- }
2079
- skipIndex = i;
2080
- i = parts.length; // The eslint settings do not allow break;
2081
- }
2082
- }
2083
- }
2084
-
2085
- for (i = 0; i < parts.length; ++i) {
2086
- if (i === skipIndex) {
2087
- continue;
2088
- }
2089
- var part = parts[i];
2090
-
2091
- var bracketEqualsPos = part.indexOf(']=');
2092
- var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
2093
-
2094
- var key, val;
2095
- if (pos === -1) {
2096
- key = options.decoder(part, defaults.decoder, charset, 'key');
2097
- val = options.strictNullHandling ? null : '';
2098
- } else {
2099
- key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
2100
- val = utils.maybeMap(
2101
- parseArrayValue(part.slice(pos + 1), options),
2102
- function (encodedVal) {
2103
- return options.decoder(encodedVal, defaults.decoder, charset, 'value');
2104
- }
2105
- );
2106
- }
2107
-
2108
- if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
2109
- val = interpretNumericEntities(val);
2110
- }
2111
-
2112
- if (part.indexOf('[]=') > -1) {
2113
- val = isArray(val) ? [val] : val;
2114
- }
2115
-
2116
- if (has.call(obj, key)) {
2117
- obj[key] = utils.combine(obj[key], val);
2118
- } else {
2119
- obj[key] = val;
2120
- }
2121
- }
2122
-
2123
- return obj;
2124
- };
2125
-
2126
- var parseObject = function (chain, val, options, valuesParsed) {
2127
- var leaf = valuesParsed ? val : parseArrayValue(val, options);
2128
-
2129
- for (var i = chain.length - 1; i >= 0; --i) {
2130
- var obj;
2131
- var root = chain[i];
2132
-
2133
- if (root === '[]' && options.parseArrays) {
2134
- obj = [].concat(leaf);
2135
- } else {
2136
- obj = options.plainObjects ? Object.create(null) : {};
2137
- var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
2138
- var index = parseInt(cleanRoot, 10);
2139
- if (!options.parseArrays && cleanRoot === '') {
2140
- obj = { 0: leaf };
2141
- } else if (
2142
- !isNaN(index)
2143
- && root !== cleanRoot
2144
- && String(index) === cleanRoot
2145
- && index >= 0
2146
- && (options.parseArrays && index <= options.arrayLimit)
2147
- ) {
2148
- obj = [];
2149
- obj[index] = leaf;
2150
- } else if (cleanRoot !== '__proto__') {
2151
- obj[cleanRoot] = leaf;
2152
- }
2153
- }
2154
-
2155
- leaf = obj;
2156
- }
2157
-
2158
- return leaf;
2159
- };
2160
-
2161
- var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
2162
- if (!givenKey) {
2163
- return;
2164
- }
2165
-
2166
- // Transform dot notation to bracket notation
2167
- var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
2168
-
2169
- // The regex chunks
2170
-
2171
- var brackets = /(\[[^[\]]*])/;
2172
- var child = /(\[[^[\]]*])/g;
2173
-
2174
- // Get the parent
2175
-
2176
- var segment = options.depth > 0 && brackets.exec(key);
2177
- var parent = segment ? key.slice(0, segment.index) : key;
2178
-
2179
- // Stash the parent if it exists
2180
-
2181
- var keys = [];
2182
- if (parent) {
2183
- // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
2184
- if (!options.plainObjects && has.call(Object.prototype, parent)) {
2185
- if (!options.allowPrototypes) {
2186
- return;
2187
- }
2188
- }
2189
-
2190
- keys.push(parent);
2191
- }
2192
-
2193
- // Loop through children appending to the array until we hit depth
2194
-
2195
- var i = 0;
2196
- while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
2197
- i += 1;
2198
- if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
2199
- if (!options.allowPrototypes) {
2200
- return;
2201
- }
2202
- }
2203
- keys.push(segment[1]);
2204
- }
2205
-
2206
- // If there's a remainder, just add whatever is left
2207
-
2208
- if (segment) {
2209
- keys.push('[' + key.slice(segment.index) + ']');
2210
- }
2211
-
2212
- return parseObject(keys, val, options, valuesParsed);
2213
- };
2214
-
2215
- var normalizeParseOptions = function normalizeParseOptions(opts) {
2216
- if (!opts) {
2217
- return defaults;
2218
- }
2219
-
2220
- if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
2221
- throw new TypeError('Decoder has to be a function.');
2222
- }
2223
-
2224
- if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
2225
- throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
2226
- }
2227
- var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
2228
-
2229
- return {
2230
- allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
2231
- allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
2232
- allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
2233
- arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
2234
- charset: charset,
2235
- charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
2236
- comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
2237
- decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
2238
- delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
2239
- // eslint-disable-next-line no-implicit-coercion, no-extra-parens
2240
- depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,
2241
- ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
2242
- interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
2243
- parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
2244
- parseArrays: opts.parseArrays !== false,
2245
- plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
2246
- strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
2247
- };
2248
- };
2249
-
2250
- var parse$1 = function (str, opts) {
2251
- var options = normalizeParseOptions(opts);
2252
-
2253
- if (str === '' || str === null || typeof str === 'undefined') {
2254
- return options.plainObjects ? Object.create(null) : {};
2255
- }
2256
-
2257
- var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
2258
- var obj = options.plainObjects ? Object.create(null) : {};
2259
-
2260
- // Iterate over the keys and setup the new object
2261
-
2262
- var keys = Object.keys(tempObj);
2263
- for (var i = 0; i < keys.length; ++i) {
2264
- var key = keys[i];
2265
- var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
2266
- obj = utils.merge(obj, newObj, options);
2267
- }
2268
-
2269
- if (options.allowSparse === true) {
2270
- return obj;
2271
- }
2272
-
2273
- return utils.compact(obj);
2274
- };
2275
-
2276
- var stringify = stringify_1;
2277
- var parse = parse$1;
2278
- var formats = formats$3;
2279
-
2280
- var lib = {
2281
- formats: formats,
2282
- parse: parse,
2283
- stringify: stringify
2284
- };
2285
-
2286
- var qs = /*@__PURE__*/getDefaultExportFromCjs(lib);
2287
-
2288
- var MESSAGE_TEMPLATE_BASE_URL = "/neeto_message_templates_engine/api/v1/message_templates";
2289
-
2290
- var fetchMessageTemplates = function fetchMessageTemplates(params) {
2291
- return axios__default["default"].get(MESSAGE_TEMPLATE_BASE_URL, {
2292
- params: params,
2293
- paramsSerializer: function paramsSerializer(params) {
2294
- return qs.stringify(params, {
2295
- arrayFormat: "brackets"
2296
- });
2297
- }
2298
- });
2299
- };
2300
- var createMessageTemplate = function createMessageTemplate(_ref) {
2301
- var messageTemplate = _ref.messageTemplate,
2302
- ownerId = _ref.ownerId;
2303
- return axios__default["default"].post(MESSAGE_TEMPLATE_BASE_URL, {
2304
- messageTemplate: messageTemplate,
2305
- ownerId: ownerId
2306
- });
2307
- };
2308
- var updateMessageTemplate = function updateMessageTemplate(_ref2) {
2309
- var id = _ref2.id,
2310
- messageTemplate = _ref2.messageTemplate,
2311
- ownerId = _ref2.ownerId;
2312
- return axios__default["default"].patch("".concat(MESSAGE_TEMPLATE_BASE_URL, "/").concat(id), {
2313
- messageTemplate: messageTemplate,
2314
- ownerId: ownerId
2315
- });
2316
- };
2317
- var deleteMessageTemplate = function deleteMessageTemplate(_ref3) {
2318
- var id = _ref3.id,
2319
- ownerId = _ref3.ownerId;
2320
- return axios__default["default"]["delete"]("".concat(MESSAGE_TEMPLATE_BASE_URL, "/").concat(id), {
2321
- data: {
2322
- ownerId: ownerId
2323
- }
2324
- });
2325
- };
2326
- var messageTemplatesApi = {
2327
- fetchAll: fetchMessageTemplates,
2328
- create: createMessageTemplate,
2329
- update: updateMessageTemplate,
2330
- "delete": deleteMessageTemplate
2331
- };
2332
-
2333
- var QUERY_KEYS = {
2334
- NEETO_MESSAGE_TEMPLATES: "neeto-message-templates"
2335
- };
2336
-
2337
- function ownKeys$d(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2338
- function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2339
- var ownerIdValue = function ownerIdValue(ownerId) {
2340
- return ramda.isEmpty(ownerId) ? undefined : ownerId;
2341
- };
2342
- var useFetchTemplates = function useFetchTemplates(params, options) {
2343
- return reactQuery.useQuery(_objectSpread$d({
2344
- queryKey: [QUERY_KEYS.NEETO_MESSAGE_TEMPLATES, params],
2345
- queryFn: function queryFn() {
2346
- return messageTemplatesApi.fetchAll(params);
2347
- }
2348
- }, options));
2349
- };
2350
- var useCreateTemplate = function useCreateTemplate(ownerId, options) {
2351
- return reactUtils.useMutationWithInvalidation(function (messageTemplate) {
2352
- return messageTemplatesApi.create({
2353
- messageTemplate: messageTemplate,
2354
- ownerId: ownerIdValue(ownerId)
2355
- });
2356
- }, _objectSpread$d({
2357
- keysToInvalidate: [[QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]]
2358
- }, options));
2359
- };
2360
- var useUpdateTemplate = function useUpdateTemplate(ownerId) {
2361
- return reactUtils.useMutationWithInvalidation(function (_ref) {
2362
- var id = _ref.id,
2363
- payload = _ref.payload;
2364
- return messageTemplatesApi.update({
2365
- id: id,
2366
- messageTemplate: payload,
2367
- ownerId: ownerIdValue(ownerId)
2368
- });
2369
- }, {
2370
- keysToInvalidate: [[QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]]
2371
- });
2372
- };
2373
- var useDeleteTemplate = function useDeleteTemplate(ownerId) {
2374
- return reactUtils.useMutationWithInvalidation(function (id) {
2375
- return messageTemplatesApi["delete"]({
2376
- id: id,
2377
- ownerId: ownerIdValue(ownerId)
2378
- });
2379
- }, {
2380
- keysToInvalidate: [[QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]]
2381
- });
2382
- };
2383
-
2384
- /** @type {import("neetocommons/react-utils").ZustandStoreHook} */
2385
- var useTemplateStore = zustand.create(reactUtils.withImmutableActions(function (set) {
2386
- return {
2387
- templateType: "",
2388
- setTemplateState: set
2389
- };
2390
- }));
2391
-
2392
- var MENU_ITEMS = {
2393
- EDIT: "edit",
2394
- DELETE: "delete",
2395
- STATUS: "status"
2396
- };
2397
-
2398
- var getMenuItems = function getMenuItems(_ref) {
2399
- var handleDeleteTemplate = _ref.handleDeleteTemplate,
2400
- handleEditTemplate = _ref.handleEditTemplate,
2401
- handleMarkActiveInactive = _ref.handleMarkActiveInactive,
2402
- status = _ref.status;
2403
- return [{
2404
- key: MENU_ITEMS.EDIT,
2405
- label: i18next.t("neetoMessageTemplate.template.edit"),
2406
- onClick: handleEditTemplate,
2407
- "data-cy": "message-template-edit-button"
2408
- }, {
2409
- key: MENU_ITEMS.STATUS,
2410
- label: ramda.equals(status, "active") ? i18next.t("neetoMessageTemplate.template.markAsInactive") : i18next.t("neetoMessageTemplate.template.markAsActive"),
2411
- onClick: function onClick() {
2412
- return handleMarkActiveInactive(status);
2413
- },
2414
- "data-cy": "message-template-status-button"
2415
- }, {
2416
- key: MENU_ITEMS.DELETE,
2417
- label: i18next.t("neetoMessageTemplate.template.delete"),
2418
- onClick: handleDeleteTemplate,
2419
- "data-cy": "message-template-delete-button"
2420
- }];
2421
- };
2422
-
2423
- function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2424
- function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2425
- var RowActions = function RowActions(_ref) {
2426
- var template = _ref.template,
2427
- setManageTemplatePane = _ref.setManageTemplatePane,
2428
- ownerId = _ref.ownerId,
2429
- onMutationSuccess = _ref.onMutationSuccess;
2430
- var _useUpdateTemplate = useUpdateTemplate(ownerId),
2431
- update = _useUpdateTemplate.mutate;
2432
- var status = template.status,
2433
- id = template.id;
2434
- var templateType = useTemplateStore(ramda.prop("templateType"));
2435
- var handleEditTemplate = function handleEditTemplate() {
2436
- return setManageTemplatePane(_objectSpread$c(_objectSpread$c({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
2437
- isOpen: true,
2438
- isEdit: true,
2439
- template: template
2440
- }));
2441
- };
2442
- var handleDeleteTemplate = function handleDeleteTemplate() {
2443
- return setManageTemplatePane(_objectSpread$c(_objectSpread$c({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
2444
- isDelete: true,
2445
- template: template
2446
- }));
2447
- };
2448
- var handleMarkActiveInactive = function handleMarkActiveInactive(activeState) {
2449
- var status = activeState === "active" ? "inactive" : "active";
2450
- update({
2451
- payload: {
2452
- status: status,
2453
- templateType: templateType
2454
- },
2455
- id: id
2456
- }, {
2457
- onSuccess: onMutationSuccess
2458
- });
2459
- };
2460
- return /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], {
2461
- dropdownButtonProps: {
2462
- "data-cy": "message-template-dropdown"
2463
- },
2464
- dropdownProps: {
2465
- strategy: "fixed"
2466
- },
2467
- menuItems: getMenuItems({
2468
- handleDeleteTemplate: handleDeleteTemplate,
2469
- handleEditTemplate: handleEditTemplate,
2470
- handleMarkActiveInactive: handleMarkActiveInactive,
2471
- status: status
2472
- })
2473
- });
2474
- };
2475
-
2476
- function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2477
- function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2478
- var handleEditTemplate = function handleEditTemplate(setManageTemplatePane, template) {
2479
- return setManageTemplatePane(_objectSpread$b(_objectSpread$b({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
2480
- isOpen: true,
2481
- isEdit: true,
2482
- template: template
2483
- }));
2484
- };
2485
- var renderSearchProps = function renderSearchProps(label, value) {
2486
- return {
2487
- className: "w-52",
2488
- placeholder: i18next.t("neetoMessageTemplate.template.search", {
2489
- what: label
2490
- }),
2491
- "data-cy": "".concat(neetoCist.hyphenate(value), "-search-input")
2492
- };
2493
- };
2494
- var buildTableColumnData$1 = function buildTableColumnData(setManageTemplatePane, ownerId, onMutationSuccess) {
2495
- return [{
2496
- dataIndex: "name",
2497
- key: "name",
2498
- node: "name",
2499
- title: i18next.t("neetoMessageTemplate.template.name"),
2500
- label: i18next.t("neetoMessageTemplate.template.name"),
2501
- type: "text",
2502
- render: function render(name, template) {
2503
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
2504
- className: "flex items-center justify-between gap-x-3",
2505
- children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
2506
- label: name,
2507
- style: "link",
2508
- onClick: function onClick() {
2509
- return handleEditTemplate(setManageTemplatePane, template);
2510
- }
2511
- }), /*#__PURE__*/jsxRuntime.jsx(RowActions, {
2512
- onMutationSuccess: onMutationSuccess,
2513
- ownerId: ownerId,
2514
- setManageTemplatePane: setManageTemplatePane,
2515
- template: template
2516
- })]
2517
- });
2518
- }
2519
- }, {
2520
- dataIndex: "status",
2521
- key: "status",
2522
- node: "status",
2523
- title: i18next.t("neetoMessageTemplate.template.active"),
2524
- label: i18next.t("neetoMessageTemplate.template.active"),
2525
- type: "single_option",
2526
- values: [{
2527
- label: "Yes",
2528
- value: "active"
2529
- }, {
2530
- label: "No",
2531
- value: "inactive"
2532
- }],
2533
- render: function render(status) {
2534
- return status === "active" ? "Yes" : "No";
2535
- },
2536
- width: "20%"
2537
- }];
2538
- };
2539
-
2540
- function _objectWithoutPropertiesLoose(source, excluded) {
2541
- if (source == null) return {};
2542
- var target = {};
2543
- var sourceKeys = Object.keys(source);
2544
- var key, i;
2545
- for (i = 0; i < sourceKeys.length; i++) {
2546
- key = sourceKeys[i];
2547
- if (excluded.indexOf(key) >= 0) continue;
2548
- target[key] = source[key];
2549
- }
2550
- return target;
2551
- }
2552
-
2553
- function _objectWithoutProperties(source, excluded) {
2554
- if (source == null) return {};
2555
- var target = _objectWithoutPropertiesLoose(source, excluded);
2556
- var key, i;
2557
- if (Object.getOwnPropertySymbols) {
2558
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
2559
- for (i = 0; i < sourceSymbolKeys.length; i++) {
2560
- key = sourceSymbolKeys[i];
2561
- if (excluded.indexOf(key) >= 0) continue;
2562
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
2563
- target[key] = source[key];
2564
- }
2565
- }
2566
- return target;
2567
- }
2568
-
2569
- var _excluded = ["label", "name"];
2570
- function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2571
- function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2572
- var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
2573
- var label = _ref.label,
2574
- name = _ref.name,
2575
- otherProps = _objectWithoutProperties(_ref, _excluded);
2576
- var _useFormikContext = formik.useFormikContext(),
2577
- submitForm = _useFormikContext.submitForm;
2578
- var handleKeyDown = function handleKeyDown(event) {
2579
- if (event.key !== "Enter" || event.shiftKey) return;
2580
- event.preventDefault();
2581
- submitForm();
2582
- };
2583
- return /*#__PURE__*/jsxRuntime.jsx(Textarea__default["default"], _objectSpread$a({
2584
- label: label,
2585
- name: name,
2586
- className: "neeto-message-templates-nano-adaptive-input",
2587
- resize: "none",
2588
- size: "small",
2589
- onKeyDown: handleKeyDown
2590
- }, otherProps));
2591
- };
2592
-
2593
- // eslint-disable-next-line @bigbinary/neeto/file-name-and-export-name-standards
2594
- var formatEditorContent$1 = function formatEditorContent(value) {
2595
- return value === null || value === void 0 ? void 0 : value.replaceAll(/<\/?(?!img)\w*\b[^>]*>/gi, "").trim();
2596
- };
2597
- var EMAIL_TEMPLATE_INITIAL_VALUES = {
2598
- name: "",
2599
- subject: "",
2600
- body: "",
2601
- testEmailAddress: ""
2602
- };
2603
- var SMS_TEMPLATE_INITIAL_VALUES = {
2604
- name: "",
2605
- body: "",
2606
- testPhoneNumber: ""
2607
- };
2608
- var EMAIL_TEMPLATE_FORM_SCHEMA = yup__namespace.object({
2609
- name: yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.namePresence")),
2610
- subject: yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.subjectPresence")),
2611
- body: yup__namespace.string().test("name", i18next.t("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
2612
- return !!formatEditorContent$1(value);
2613
- })
2614
- });
2615
- var SMS_TEMPLATE_FORM_VALIDATION_SCHEMA = yup__namespace.object({
2616
- name: yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.namePresence")),
2617
- body: yup__namespace.string().test("body", i18next.t("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
2618
- return !!formatEditorContent$1(value);
2619
- })
2620
- });
2621
- var SEND_TEST_EMAIL_SCHEMA = yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.emailAddressPresence")).email(i18next.t("neetoMessageTemplate.template.validation.emailAddressFormatValidation"));
2622
- var PHONE_NUMBER_VALIDATION_SCHEMA = yup__namespace.string().test("testPhoneNumber", i18next.t("neetoMessageTemplate.template.validation.validPhoneNumber"), function (value) {
2623
- return PhoneNumber.isPhoneNumberValid(value);
2624
- });
2625
-
2626
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2627
- try {
2628
- var info = gen[key](arg);
2629
- var value = info.value;
2630
- } catch (error) {
2631
- reject(error);
2632
- return;
2633
- }
2634
- if (info.done) {
2635
- resolve(value);
2636
- } else {
2637
- Promise.resolve(value).then(_next, _throw);
2638
- }
2639
- }
2640
- function _asyncToGenerator(fn) {
2641
- return function () {
2642
- var self = this,
2643
- args = arguments;
2644
- return new Promise(function (resolve, reject) {
2645
- var gen = fn.apply(self, args);
2646
- function _next(value) {
2647
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2648
- }
2649
- function _throw(err) {
2650
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2651
- }
2652
- _next(undefined);
2653
- });
2654
- };
2655
- }
2656
-
2657
- var regeneratorRuntime$1 = {exports: {}};
2658
-
2659
- var _typeof = {exports: {}};
2660
-
2661
- _typeof.exports;
2662
-
2663
- (function (module) {
2664
- function _typeof(o) {
2665
- "@babel/helpers - typeof";
2666
-
2667
- return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
2668
- return typeof o;
2669
- } : function (o) {
2670
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
2671
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
2672
- }
2673
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
2674
- } (_typeof));
2675
-
2676
- var _typeofExports = _typeof.exports;
2677
-
2678
- regeneratorRuntime$1.exports;
2679
-
2680
- (function (module) {
2681
- var _typeof = _typeofExports["default"];
2682
- function _regeneratorRuntime() {
2683
- module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
2684
- return e;
2685
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
2686
- var t,
2687
- e = {},
2688
- r = Object.prototype,
2689
- n = r.hasOwnProperty,
2690
- o = Object.defineProperty || function (t, e, r) {
2691
- t[e] = r.value;
2692
- },
2693
- i = "function" == typeof Symbol ? Symbol : {},
2694
- a = i.iterator || "@@iterator",
2695
- c = i.asyncIterator || "@@asyncIterator",
2696
- u = i.toStringTag || "@@toStringTag";
2697
- function define(t, e, r) {
2698
- return Object.defineProperty(t, e, {
2699
- value: r,
2700
- enumerable: !0,
2701
- configurable: !0,
2702
- writable: !0
2703
- }), t[e];
2704
- }
2705
- try {
2706
- define({}, "");
2707
- } catch (t) {
2708
- define = function define(t, e, r) {
2709
- return t[e] = r;
2710
- };
2711
- }
2712
- function wrap(t, e, r, n) {
2713
- var i = e && e.prototype instanceof Generator ? e : Generator,
2714
- a = Object.create(i.prototype),
2715
- c = new Context(n || []);
2716
- return o(a, "_invoke", {
2717
- value: makeInvokeMethod(t, r, c)
2718
- }), a;
2719
- }
2720
- function tryCatch(t, e, r) {
2721
- try {
2722
- return {
2723
- type: "normal",
2724
- arg: t.call(e, r)
2725
- };
2726
- } catch (t) {
2727
- return {
2728
- type: "throw",
2729
- arg: t
2730
- };
2731
- }
2732
- }
2733
- e.wrap = wrap;
2734
- var h = "suspendedStart",
2735
- l = "suspendedYield",
2736
- f = "executing",
2737
- s = "completed",
2738
- y = {};
2739
- function Generator() {}
2740
- function GeneratorFunction() {}
2741
- function GeneratorFunctionPrototype() {}
2742
- var p = {};
2743
- define(p, a, function () {
2744
- return this;
2745
- });
2746
- var d = Object.getPrototypeOf,
2747
- v = d && d(d(values([])));
2748
- v && v !== r && n.call(v, a) && (p = v);
2749
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
2750
- function defineIteratorMethods(t) {
2751
- ["next", "throw", "return"].forEach(function (e) {
2752
- define(t, e, function (t) {
2753
- return this._invoke(e, t);
2754
- });
2755
- });
2756
- }
2757
- function AsyncIterator(t, e) {
2758
- function invoke(r, o, i, a) {
2759
- var c = tryCatch(t[r], t, o);
2760
- if ("throw" !== c.type) {
2761
- var u = c.arg,
2762
- h = u.value;
2763
- return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
2764
- invoke("next", t, i, a);
2765
- }, function (t) {
2766
- invoke("throw", t, i, a);
2767
- }) : e.resolve(h).then(function (t) {
2768
- u.value = t, i(u);
2769
- }, function (t) {
2770
- return invoke("throw", t, i, a);
2771
- });
2772
- }
2773
- a(c.arg);
2774
- }
2775
- var r;
2776
- o(this, "_invoke", {
2777
- value: function value(t, n) {
2778
- function callInvokeWithMethodAndArg() {
2779
- return new e(function (e, r) {
2780
- invoke(t, n, e, r);
2781
- });
2782
- }
2783
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
2784
- }
2785
- });
2786
- }
2787
- function makeInvokeMethod(e, r, n) {
2788
- var o = h;
2789
- return function (i, a) {
2790
- if (o === f) throw new Error("Generator is already running");
2791
- if (o === s) {
2792
- if ("throw" === i) throw a;
2793
- return {
2794
- value: t,
2795
- done: !0
2796
- };
2797
- }
2798
- for (n.method = i, n.arg = a;;) {
2799
- var c = n.delegate;
2800
- if (c) {
2801
- var u = maybeInvokeDelegate(c, n);
2802
- if (u) {
2803
- if (u === y) continue;
2804
- return u;
2805
- }
2806
- }
2807
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
2808
- if (o === h) throw o = s, n.arg;
2809
- n.dispatchException(n.arg);
2810
- } else "return" === n.method && n.abrupt("return", n.arg);
2811
- o = f;
2812
- var p = tryCatch(e, r, n);
2813
- if ("normal" === p.type) {
2814
- if (o = n.done ? s : l, p.arg === y) continue;
2815
- return {
2816
- value: p.arg,
2817
- done: n.done
2818
- };
2819
- }
2820
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
2821
- }
2822
- };
2823
- }
2824
- function maybeInvokeDelegate(e, r) {
2825
- var n = r.method,
2826
- o = e.iterator[n];
2827
- if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
2828
- var i = tryCatch(o, e.iterator, r.arg);
2829
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
2830
- var a = i.arg;
2831
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
2832
- }
2833
- function pushTryEntry(t) {
2834
- var e = {
2835
- tryLoc: t[0]
2836
- };
2837
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
2838
- }
2839
- function resetTryEntry(t) {
2840
- var e = t.completion || {};
2841
- e.type = "normal", delete e.arg, t.completion = e;
2842
- }
2843
- function Context(t) {
2844
- this.tryEntries = [{
2845
- tryLoc: "root"
2846
- }], t.forEach(pushTryEntry, this), this.reset(!0);
2847
- }
2848
- function values(e) {
2849
- if (e || "" === e) {
2850
- var r = e[a];
2851
- if (r) return r.call(e);
2852
- if ("function" == typeof e.next) return e;
2853
- if (!isNaN(e.length)) {
2854
- var o = -1,
2855
- i = function next() {
2856
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
2857
- return next.value = t, next.done = !0, next;
2858
- };
2859
- return i.next = i;
2860
- }
2861
- }
2862
- throw new TypeError(_typeof(e) + " is not iterable");
2863
- }
2864
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
2865
- value: GeneratorFunctionPrototype,
2866
- configurable: !0
2867
- }), o(GeneratorFunctionPrototype, "constructor", {
2868
- value: GeneratorFunction,
2869
- configurable: !0
2870
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
2871
- var e = "function" == typeof t && t.constructor;
2872
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
2873
- }, e.mark = function (t) {
2874
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
2875
- }, e.awrap = function (t) {
2876
- return {
2877
- __await: t
2878
- };
2879
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
2880
- return this;
2881
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
2882
- void 0 === i && (i = Promise);
2883
- var a = new AsyncIterator(wrap(t, r, n, o), i);
2884
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
2885
- return t.done ? t.value : a.next();
2886
- });
2887
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
2888
- return this;
2889
- }), define(g, "toString", function () {
2890
- return "[object Generator]";
2891
- }), e.keys = function (t) {
2892
- var e = Object(t),
2893
- r = [];
2894
- for (var n in e) r.push(n);
2895
- return r.reverse(), function next() {
2896
- for (; r.length;) {
2897
- var t = r.pop();
2898
- if (t in e) return next.value = t, next.done = !1, next;
2899
- }
2900
- return next.done = !0, next;
2901
- };
2902
- }, e.values = values, Context.prototype = {
2903
- constructor: Context,
2904
- reset: function reset(e) {
2905
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
2906
- },
2907
- stop: function stop() {
2908
- this.done = !0;
2909
- var t = this.tryEntries[0].completion;
2910
- if ("throw" === t.type) throw t.arg;
2911
- return this.rval;
2912
- },
2913
- dispatchException: function dispatchException(e) {
2914
- if (this.done) throw e;
2915
- var r = this;
2916
- function handle(n, o) {
2917
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
2918
- }
2919
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
2920
- var i = this.tryEntries[o],
2921
- a = i.completion;
2922
- if ("root" === i.tryLoc) return handle("end");
2923
- if (i.tryLoc <= this.prev) {
2924
- var c = n.call(i, "catchLoc"),
2925
- u = n.call(i, "finallyLoc");
2926
- if (c && u) {
2927
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
2928
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
2929
- } else if (c) {
2930
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
2931
- } else {
2932
- if (!u) throw new Error("try statement without catch or finally");
2933
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
2934
- }
2935
- }
2936
- }
2937
- },
2938
- abrupt: function abrupt(t, e) {
2939
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
2940
- var o = this.tryEntries[r];
2941
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
2942
- var i = o;
2943
- break;
2944
- }
2945
- }
2946
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
2947
- var a = i ? i.completion : {};
2948
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
2949
- },
2950
- complete: function complete(t, e) {
2951
- if ("throw" === t.type) throw t.arg;
2952
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
2953
- },
2954
- finish: function finish(t) {
2955
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
2956
- var r = this.tryEntries[e];
2957
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
2958
- }
2959
- },
2960
- "catch": function _catch(t) {
2961
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
2962
- var r = this.tryEntries[e];
2963
- if (r.tryLoc === t) {
2964
- var n = r.completion;
2965
- if ("throw" === n.type) {
2966
- var o = n.arg;
2967
- resetTryEntry(r);
2968
- }
2969
- return o;
2970
- }
2971
- }
2972
- throw new Error("illegal catch attempt");
2973
- },
2974
- delegateYield: function delegateYield(e, r, n) {
2975
- return this.delegate = {
2976
- iterator: values(e),
2977
- resultName: r,
2978
- nextLoc: n
2979
- }, "next" === this.method && (this.arg = t), y;
2980
- }
2981
- }, e;
2982
- }
2983
- module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
2984
- } (regeneratorRuntime$1));
2985
-
2986
- var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
2987
-
2988
- // TODO(Babel 8): Remove this file.
2989
-
2990
- var runtime = regeneratorRuntimeExports();
2991
- var regenerator = runtime;
2992
-
2993
- // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
2994
- try {
2995
- regeneratorRuntime = runtime;
2996
- } catch (accidentalStrictMode) {
2997
- if (typeof globalThis === "object") {
2998
- globalThis.regeneratorRuntime = runtime;
2999
- } else {
3000
- Function("r", "regeneratorRuntime = r")(runtime);
3001
- }
3002
- }
3003
-
3004
- var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
3005
-
3006
- function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3007
- function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3008
- var TestMessage = function TestMessage(_ref) {
3009
- var isEmailTemplate = _ref.isEmailTemplate,
3010
- handleSubmitTestTemplate = _ref.handleSubmitTestTemplate,
3011
- isTestMessageLoading = _ref.isTestMessageLoading,
3012
- isTestingTemplateDisabled = _ref.isTestingTemplateDisabled,
3013
- customFields = _ref.customFields;
3014
- var _useState = react.useState(true),
3015
- _useState2 = _slicedToArray(_useState, 2),
3016
- isTestingTemplateRestricted = _useState2[0],
3017
- setIsTestingTemplateRestricted = _useState2[1];
3018
- var _useFormikContext = formik.useFormikContext(),
3019
- values = _useFormikContext.values,
3020
- isValid = _useFormikContext.isValid;
3021
- var _useTranslation = reactI18next.useTranslation(),
3022
- t = _useTranslation.t;
3023
- var handleTestValidation = /*#__PURE__*/function () {
3024
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
3025
- var value;
3026
- return _regeneratorRuntime.wrap(function _callee$(_context) {
3027
- while (1) switch (_context.prev = _context.next) {
3028
- case 0:
3029
- value = event.target.value;
3030
- _context.prev = 1;
3031
- if (!isEmailTemplate) {
3032
- _context.next = 7;
3033
- break;
3034
- }
3035
- _context.next = 5;
3036
- return SEND_TEST_EMAIL_SCHEMA.validate(value);
3037
- case 5:
3038
- _context.next = 9;
3039
- break;
3040
- case 7:
3041
- _context.next = 9;
3042
- return PHONE_NUMBER_VALIDATION_SCHEMA.validate(value);
3043
- case 9:
3044
- setIsTestingTemplateRestricted(false);
3045
- _context.next = 15;
3046
- break;
3047
- case 12:
3048
- _context.prev = 12;
3049
- _context.t0 = _context["catch"](1);
3050
- setIsTestingTemplateRestricted(true);
3051
- case 15:
3052
- case "end":
3053
- return _context.stop();
3054
- }
3055
- }, _callee, null, [[1, 12]]);
3056
- }));
3057
- return function handleTestValidation(_x) {
3058
- return _ref2.apply(this, arguments);
3059
- };
3060
- }();
3061
- var isTestTemplateButtonDisabled = !isValid || isTestingTemplateDisabled || isTestingTemplateRestricted || isTestMessageLoading;
3062
- var handleKeyDown = function handleKeyDown(event) {
3063
- if (event.key !== "Enter") return;
3064
- event.stopPropagation();
3065
- event.preventDefault();
3066
- !isTestTemplateButtonDisabled && handleSubmitTestTemplate(values);
3067
- };
3068
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3069
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
3070
- className: "neeto-ui-flex left-0 flex items-start gap-x-2",
3071
- children: [/*#__PURE__*/jsxRuntime.jsx(Input__default["default"], _objectSpread$9(_objectSpread$9({
3072
- "data-cy": "message-template-test-input"
3073
- }, !isEmailTemplate && {
3074
- helpText: t("neetoMessageTemplate.template.phoneNumberHelpText")
3075
- }), {}, {
3076
- name: isEmailTemplate ? "testEmailAddress" : "testPhoneNumber",
3077
- placeholder: t(isEmailTemplate ? "neetoMessageTemplate.template.emailAddress" : "neetoMessageTemplate.template.phoneNumber"),
3078
- onKeyDown: handleKeyDown,
3079
- onKeyUp: handleTestValidation
3080
- })), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
3081
- "data-cy": "message-template-test-button",
3082
- disabled: isTestTemplateButtonDisabled,
3083
- loading: isTestMessageLoading,
3084
- style: "primary",
3085
- type: "button",
3086
- label: isEmailTemplate ? t("neetoMessageTemplate.template.sendTestEmail") : t("neetoMessageTemplate.template.sendTestSms"),
3087
- onClick: function onClick() {
3088
- return handleSubmitTestTemplate(values);
3089
- }
3090
- })]
3091
- }), !isEmailTemplate && /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
3092
- style: "body2",
3093
- children: t("neetoMessageTemplate.sendMessage.testSmsNote")
3094
- }), customFields]
3095
- });
3096
- };
3097
-
3098
- function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3099
- function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3100
- var Form$1 = function Form(_ref) {
3101
- var onClose = _ref.onClose,
3102
- isEdit = _ref.isEdit,
3103
- _ref$template = _ref.template,
3104
- template = _ref$template === void 0 ? {} : _ref$template,
3105
- createUpdateTemplate = _ref.createUpdateTemplate,
3106
- setInitialFocusField = _ref.setInitialFocusField,
3107
- handleSubmitTestTemplate = _ref.handleSubmitTestTemplate,
3108
- isTestMessageLoading = _ref.isTestMessageLoading,
3109
- shouldIncludeTestTemplate = _ref.shouldIncludeTestTemplate,
3110
- templateVariables = _ref.templateVariables,
3111
- isTestingTemplateDisabled = _ref.isTestingTemplateDisabled,
3112
- customFields = _ref.customFields,
3113
- onMutationSuccess = _ref.onMutationSuccess;
3114
- var _useTranslation = reactI18next.useTranslation(),
3115
- t = _useTranslation.t;
3116
- var editorRef = react.useRef(null);
3117
- var templateType = useTemplateStore(ramda.prop("templateType"));
3118
- var isEmailTemplate = ramda.equals(templateType, "email_template");
3119
- var isTestTemplateVisible = ramda.includes(templateType, ["sms_template", "email_template"]) && shouldIncludeTestTemplate;
3120
- var _ref2 = isEmailTemplate ? [_objectSpread$8(_objectSpread$8({}, EMAIL_TEMPLATE_INITIAL_VALUES), ramda.pick(["name", "body", "subject", "active"], template)), EMAIL_TEMPLATE_FORM_SCHEMA] : [_objectSpread$8(_objectSpread$8({}, SMS_TEMPLATE_INITIAL_VALUES), ramda.pick(["name", "body", "active"], template)), SMS_TEMPLATE_FORM_VALIDATION_SCHEMA],
3121
- _ref3 = _slicedToArray(_ref2, 2),
3122
- TEMPLATE_INITIAL_VALUES = _ref3[0],
3123
- TEMPLATE_FORM_SCHEMA = _ref3[1];
3124
- var handleSubmit = function handleSubmit(values) {
3125
- var filteredValues = isEmailTemplate ? ramda.omit(["name", "testEmailAddress"], values) : ramda.omit(["name", "testPhoneNumber"], values);
3126
- var payload = {
3127
- templateType: templateType,
3128
- name: values.name,
3129
- entity: filteredValues
3130
- };
3131
- createUpdateTemplate({
3132
- isEdit: isEdit,
3133
- payload: payload,
3134
- id: template.id
3135
- }, {
3136
- onSuccess: function onSuccess() {
3137
- onMutationSuccess.apply(void 0, arguments);
3138
- onClose();
3139
- }
3140
- });
3141
- };
3142
- var messageBodyLabel = isEmailTemplate ? t("neetoMessageTemplate.template.emailBody") : t("neetoMessageTemplate.template.smsBody");
3143
- return /*#__PURE__*/jsxRuntime.jsxs(NeetoUIForm__default["default"], {
3144
- formProps: {
3145
- noValidate: true,
3146
- className: "flex w-full flex-col gap-y-4 pb-6"
3147
- },
3148
- formikProps: {
3149
- initialValues: TEMPLATE_INITIAL_VALUES,
3150
- validationSchema: TEMPLATE_FORM_SCHEMA,
3151
- validateOnBlur: true,
3152
- validateOnChange: true,
3153
- onSubmit: handleSubmit
3154
- },
3155
- children: [/*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
3156
- required: true,
3157
- label: t("neetoMessageTemplate.template.templateName"),
3158
- name: "name",
3159
- ref: setInitialFocusField
3160
- }), isEmailTemplate && /*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, {
3161
- required: true,
3162
- label: t("neetoMessageTemplate.template.emailSubject"),
3163
- name: "subject"
3164
- }), /*#__PURE__*/jsxRuntime.jsx(FormikEditor__default["default"], {
3165
- hideSlashCommands: true,
3166
- required: true,
3167
- contentClassName: "max-h-40",
3168
- defaults: isEmailTemplate ? undefined : [],
3169
- label: messageBodyLabel,
3170
- name: "body",
3171
- ref: editorRef,
3172
- rows: DEFAULT_EDITOR_ROW_COUNT,
3173
- variables: templateVariables
3174
- }), isTestTemplateVisible && /*#__PURE__*/jsxRuntime.jsx(TestMessage, {
3175
- customFields: customFields,
3176
- handleSubmitTestTemplate: handleSubmitTestTemplate,
3177
- isEmailTemplate: isEmailTemplate,
3178
- isTestMessageLoading: isTestMessageLoading,
3179
- isTestingTemplateDisabled: isTestingTemplateDisabled
3180
- }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
3181
- className: "absolute bottom-0 left-0",
3182
- children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
3183
- cancelButtonProps: {
3184
- "data-cy": "message-template-reset-button",
3185
- onClick: onClose
3186
- },
3187
- submitButtonProps: {
3188
- "data-cy": "message-template-submit-button"
3189
- }
3190
- })
3191
- })]
3192
- });
3193
- };
3194
-
3195
- var AddEdit = function AddEdit(_ref) {
3196
- var onClose = _ref.onClose,
3197
- createUpdateTemplate = _ref.createUpdateTemplate,
3198
- manageTemplatePane = _ref.manageTemplatePane,
3199
- isTestMessageLoading = _ref.isTestMessageLoading,
3200
- handleSubmitTestTemplate = _ref.handleSubmitTestTemplate,
3201
- shouldIncludeTestTemplate = _ref.shouldIncludeTestTemplate,
3202
- addText = _ref.addText,
3203
- editText = _ref.editText,
3204
- templateVariables = _ref.templateVariables,
3205
- isTestingTemplateDisabled = _ref.isTestingTemplateDisabled,
3206
- customFields = _ref.customFields,
3207
- onMutationSuccess = _ref.onMutationSuccess;
3208
- var initialFocusField = react.useRef();
3209
- var setInitialFocusField = function setInitialFocusField(fieldRef) {
3210
- return initialFocusField.current = fieldRef;
3211
- };
3212
- var isOpen = manageTemplatePane.isOpen,
3213
- isEdit = manageTemplatePane.isEdit,
3214
- template = manageTemplatePane.template;
3215
- var label = isEdit ? editText : addText;
3216
- return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
3217
- isOpen: isOpen,
3218
- onClose: onClose,
3219
- initialFocusRef: initialFocusField,
3220
- children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
3221
- children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
3222
- style: "h2",
3223
- weight: "semibold",
3224
- children: label
3225
- })
3226
- }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
3227
- children: /*#__PURE__*/jsxRuntime.jsx(Form$1, {
3228
- createUpdateTemplate: createUpdateTemplate,
3229
- customFields: customFields,
3230
- handleSubmitTestTemplate: handleSubmitTestTemplate,
3231
- isEdit: isEdit,
3232
- isTestMessageLoading: isTestMessageLoading,
3233
- isTestingTemplateDisabled: isTestingTemplateDisabled,
3234
- onClose: onClose,
3235
- onMutationSuccess: onMutationSuccess,
3236
- setInitialFocusField: setInitialFocusField,
3237
- shouldIncludeTestTemplate: shouldIncludeTestTemplate,
3238
- template: template,
3239
- templateVariables: templateVariables
3240
- })
3241
- })]
3242
- });
3243
- };
3244
-
3245
- function _arrayWithoutHoles(arr) {
3246
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
3247
- }
3248
-
3249
- function _iterableToArray(iter) {
3250
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
3251
- }
3252
-
3253
- function _nonIterableSpread() {
3254
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3255
- }
3256
-
3257
- function _toConsumableArray(arr) {
3258
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
3259
- }
3260
-
3261
- var useFilters = function useFilters() {
3262
- var _useState = react.useState(DEFAULT_PAGE_PROPERTIES),
3263
- _useState2 = _slicedToArray(_useState, 2),
3264
- pageProperties = _useState2[0],
3265
- setPageProperties = _useState2[1];
3266
- var _useQueryParams = reactUtils.useQueryParams(),
3267
- _useQueryParams$searc = _useQueryParams.searchTerm,
3268
- searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
3269
- var filterColumns = buildTableColumnData$1().filter(ramda.prop("node"));
3270
- var searchKeywordProps = {
3271
- key: "search_term",
3272
- node: "name",
3273
- value: searchTerm,
3274
- setValue: neetoCist.noop
3275
- };
3276
- var _useState3 = react.useState(function () {
3277
- return neetoFiltersFrontend.buildFiltersFromURL([].concat(_toConsumableArray(filterColumns), [searchKeywordProps]));
3278
- }),
3279
- _useState4 = _slicedToArray(_useState3, 2),
3280
- filters = _useState4[0],
3281
- setFilters = _useState4[1];
3282
- return {
3283
- filterColumns: filterColumns,
3284
- searchKeywordProps: searchKeywordProps,
3285
- searchTerm: searchTerm,
3286
- filters: filters,
3287
- setFilters: setFilters,
3288
- pageProperties: pageProperties,
3289
- setPageProperties: setPageProperties
3290
- };
3291
- };
3292
-
3293
- var useTemplates = function useTemplates(_ref) {
3294
- var type = _ref.type,
3295
- ownerId = _ref.ownerId,
3296
- filters = _ref.filters,
3297
- pageProperties = _ref.pageProperties;
3298
- var pageIndex = pageProperties.index,
3299
- pageSize = pageProperties.size;
3300
- var templateParams = {
3301
- page: pageIndex,
3302
- pageSize: pageSize,
3303
- filters: filters,
3304
- templateType: MESSAGE_TEMPLATES[type].value,
3305
- ownerId: ramda.isEmpty(ownerId) ? undefined : ownerId
3306
- };
3307
- var _useFetchTemplates = useFetchTemplates(templateParams),
3308
- _useFetchTemplates$da = _useFetchTemplates.data,
3309
- templatesData = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
3310
- isLoadingTemplates = _useFetchTemplates.isLoading,
3311
- isFetching = _useFetchTemplates.isFetching;
3312
- var _useCreateTemplate = useCreateTemplate(ownerId),
3313
- create = _useCreateTemplate.mutate;
3314
- var _useUpdateTemplate = useUpdateTemplate(ownerId),
3315
- update = _useUpdateTemplate.mutate;
3316
- var createUpdateTemplate = function createUpdateTemplate(_ref2, options) {
3317
- var isEdit = _ref2.isEdit,
3318
- payload = _ref2.payload,
3319
- _ref2$id = _ref2.id,
3320
- id = _ref2$id === void 0 ? null : _ref2$id;
3321
- return isEdit ? update({
3322
- id: id,
3323
- payload: payload
3324
- }, options) : create(payload, options);
3325
- };
3326
- var isLoaderVisible = isLoadingTemplates || isFetching;
3327
- return {
3328
- templatesData: templatesData,
3329
- isLoading: isLoaderVisible,
3330
- createUpdateTemplate: createUpdateTemplate
3331
- };
3332
- };
3333
-
3334
- function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3335
- function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3336
- var List = function List(_ref) {
3337
- var setManageTemplatePane = _ref.setManageTemplatePane,
3338
- templatesData = _ref.templatesData,
3339
- isLoading = _ref.isLoading,
3340
- manageTemplatePane = _ref.manageTemplatePane,
3341
- labelSingular = _ref.labelSingular,
3342
- setPageProperties = _ref.setPageProperties,
3343
- pageProperties = _ref.pageProperties,
3344
- label = _ref.label,
3345
- addText = _ref.addText,
3346
- isFilterApplied = _ref.isFilterApplied,
3347
- ownerId = _ref.ownerId,
3348
- type = _ref.type,
3349
- onMutationSuccess = _ref.onMutationSuccess,
3350
- helpDocUrl = _ref.helpDocUrl;
3351
- var _useTranslation = reactI18next.useTranslation(),
3352
- t = _useTranslation.t;
3353
- var _useDeleteTemplate = useDeleteTemplate(ownerId),
3354
- deleteTemplate = _useDeleteTemplate.mutate,
3355
- isDeleting = _useDeleteTemplate.isPending;
3356
- var templates = templatesData.templates,
3357
- totalCount = templatesData.totalCount;
3358
- var template = manageTemplatePane.template,
3359
- isDelete = manageTemplatePane.isDelete;
3360
- var pageIndex = pageProperties.index,
3361
- pageSize = pageProperties.size;
3362
- var isSms = type === "sms";
3363
- var typeLabelSingular = isSms ? labelSingular : labelSingular.toLowerCase();
3364
- var emptyStateLabel = isSms ? label : label.toLowerCase();
3365
- var noDataProps = _objectSpread$7(_objectSpread$7({}, !isFilterApplied && {
3366
- primaryButtonProps: {
3367
- label: addText,
3368
- onClick: function onClick() {
3369
- return setManageTemplatePane(ramda.assoc("isOpen", true));
3370
- }
3371
- },
3372
- helpText: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
3373
- i18nKey: "neetoMessageTemplate.template.linkToHelpArticle",
3374
- values: {
3375
- entity: label
3376
- },
3377
- components: {
3378
- Link: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
3379
- className: "underline",
3380
- href: helpDocUrl,
3381
- style: "link",
3382
- target: "_blank"
3383
- })
3384
- }
3385
- })
3386
- }), {}, {
3387
- title: isFilterApplied ? t("neetoMessageTemplate.template.filtersEmptyState", {
3388
- type: emptyStateLabel
3389
- }) : t("neetoMessageTemplate.template.emptyState", {
3390
- type: emptyStateLabel
3391
- })
3392
- });
3393
- var handleDelete = function handleDelete() {
3394
- deleteTemplate(template.id, {
3395
- onSuccess: onMutationSuccess,
3396
- onSettled: function onSettled() {
3397
- setManageTemplatePane(ramda.assoc("isDelete", false));
3398
- }
3399
- });
3400
- };
3401
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3402
- children: [!ramda.isEmpty(templates) ? /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
3403
- hasPagination: totalCount > pageSize,
3404
- children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
3405
- totalCount: totalCount,
3406
- fixedHeight: true,
3407
- currentPageNumber: pageIndex,
3408
- defaultPageSize: pageSize,
3409
- loading: isLoading,
3410
- rowData: templates,
3411
- scroll: {
3412
- x: "100%"
3413
- },
3414
- columnData: buildTableColumnData$1(setManageTemplatePane, ownerId, onMutationSuccess),
3415
- handlePageChange: function handlePageChange(index, size) {
3416
- return setPageProperties({
3417
- index: index,
3418
- size: size
3419
- });
3420
- }
3421
- })
3422
- }) : /*#__PURE__*/jsxRuntime.jsx("div", {
3423
- className: "flex h-full w-full items-center justify-center",
3424
- children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], _objectSpread$7({}, noDataProps))
3425
- }), /*#__PURE__*/jsxRuntime.jsx(Alert__default["default"], {
3426
- isOpen: isDelete,
3427
- isSubmitting: isDeleting,
3428
- submitButtonLabel: t("neetoMessageTemplate.template.delete"),
3429
- message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
3430
- i18nKey: "neetoMessageTemplate.template.templateDeleteConfirmation",
3431
- values: {
3432
- name: template.name
3433
- }
3434
- }),
3435
- title: t("neetoMessageTemplate.template.deleteTemplate", {
3436
- label: typeLabelSingular
3437
- }),
3438
- onClose: function onClose() {
3439
- return setManageTemplatePane(ramda.assoc("isDelete", false));
3440
- },
3441
- onSubmit: handleDelete
3442
- })]
3443
- });
3444
- };
3445
-
3446
- function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3447
- function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3448
- var MessageTemplates = function MessageTemplates(_ref) {
3449
- var _helpPopoverProps$hel;
3450
- var _ref$breadcrumbs = _ref.breadcrumbs,
3451
- breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
3452
- _ref$type = _ref.type,
3453
- type = _ref$type === void 0 ? "" : _ref$type,
3454
- _ref$handleSubmitTest = _ref.handleSubmitTestTemplate,
3455
- handleSubmitTestTemplate = _ref$handleSubmitTest === void 0 ? neetoCist.noop : _ref$handleSubmitTest,
3456
- _ref$isTestMessageLoa = _ref.isTestMessageLoading,
3457
- isTestMessageLoading = _ref$isTestMessageLoa === void 0 ? false : _ref$isTestMessageLoa,
3458
- _ref$shouldIncludeTes = _ref.shouldIncludeTestTemplate,
3459
- shouldIncludeTestTemplate = _ref$shouldIncludeTes === void 0 ? true : _ref$shouldIncludeTes,
3460
- _ref$templateVariable = _ref.templateVariables,
3461
- templateVariables = _ref$templateVariable === void 0 ? {} : _ref$templateVariable,
3462
- _ref$ownerId = _ref.ownerId,
3463
- ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId,
3464
- _ref$isTestingTemplat = _ref.isTestingTemplateDisabled,
3465
- isTestingTemplateDisabled = _ref$isTestingTemplat === void 0 ? false : _ref$isTestingTemplat,
3466
- _ref$manageTemplatesP = _ref.manageTemplatesPaneCustomFields,
3467
- manageTemplatesPaneCustomFields = _ref$manageTemplatesP === void 0 ? null : _ref$manageTemplatesP,
3468
- _ref$onMutationSucces = _ref.onMutationSuccess,
3469
- onMutationSuccess = _ref$onMutationSucces === void 0 ? neetoCist.noop : _ref$onMutationSucces,
3470
- _ref$helpPopoverProps = _ref.helpPopoverProps,
3471
- helpPopoverProps = _ref$helpPopoverProps === void 0 ? {} : _ref$helpPopoverProps;
3472
- var _useState = react.useState(MESSAGE_TEMPLATE_INITIAL_STATE),
3473
- _useState2 = _slicedToArray(_useState, 2),
3474
- manageTemplatePane = _useState2[0],
3475
- setManageTemplatePane = _useState2[1];
3476
- var _useState3 = react.useState(false),
3477
- _useState4 = _slicedToArray(_useState3, 2),
3478
- isFilterPaneOpen = _useState4[0],
3479
- setIsFilterPaneOpen = _useState4[1];
3480
- var _useTranslation = reactI18next.useTranslation(),
3481
- t = _useTranslation.t;
3482
- var _useFilters = useFilters(),
3483
- searchKeywordProps = _useFilters.searchKeywordProps,
3484
- filterColumns = _useFilters.filterColumns,
3485
- searchTerm = _useFilters.searchTerm,
3486
- filters = _useFilters.filters,
3487
- setFilters = _useFilters.setFilters,
3488
- pageProperties = _useFilters.pageProperties,
3489
- setPageProperties = _useFilters.setPageProperties;
3490
- var _useTemplates = useTemplates({
3491
- type: type,
3492
- ownerId: ownerId,
3493
- filters: filters,
3494
- pageProperties: pageProperties
3495
- }),
3496
- isLoading = _useTemplates.isLoading,
3497
- templatesData = _useTemplates.templatesData,
3498
- createUpdateTemplate = _useTemplates.createUpdateTemplate;
3499
- var setTemplateState = useTemplateStore(ramda.prop("setTemplateState"));
3500
- var _MESSAGE_TEMPLATES$ty = MESSAGE_TEMPLATES[type],
3501
- label = _MESSAGE_TEMPLATES$ty.label,
3502
- value = _MESSAGE_TEMPLATES$ty.value,
3503
- addText = _MESSAGE_TEMPLATES$ty.addText,
3504
- labelSingular = _MESSAGE_TEMPLATES$ty.labelSingular,
3505
- editText = _MESSAGE_TEMPLATES$ty.editText;
3506
- var isFilterApplied = neetoCist.isNotEmpty(filters) || neetoCist.isNotEmpty(searchTerm);
3507
- var handleActionClick = function handleActionClick() {
3508
- return setManageTemplatePane(_objectSpread$6(_objectSpread$6({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
3509
- isOpen: true
3510
- }));
3511
- };
3512
- var handleChange = function handleChange(filters) {
3513
- setFilters(filters);
3514
- setPageProperties(DEFAULT_PAGE_PROPERTIES);
3515
- };
3516
- var templatesCount = (templatesData === null || templatesData === void 0 ? void 0 : templatesData.totalCount) || 0;
3517
- react.useEffect(function () {
3518
- setTemplateState({
3519
- templateType: value
3520
- });
3521
- }, [value]);
3522
- var shouldShowTemplatesCount = !isLoading && (isFilterApplied || templatesCount > 0);
3523
- var helpDocUrl = (helpPopoverProps === null || helpPopoverProps === void 0 || (_helpPopoverProps$hel = helpPopoverProps.helpLinkProps) === null || _helpPopoverProps$hel === void 0 ? void 0 : _helpPopoverProps$hel.href) || "";
3524
- return /*#__PURE__*/jsxRuntime.jsxs(Container__default["default"], {
3525
- children: [/*#__PURE__*/jsxRuntime.jsx(NeetoHeader__default["default"], {
3526
- breadcrumbs: breadcrumbs,
3527
- searchProps: renderSearchProps(label, value),
3528
- size: "small",
3529
- actionBlock: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
3530
- "data-cy": "add-".concat(neetoCist.hyphenate(value), "-button"),
3531
- label: addText,
3532
- onClick: handleActionClick
3533
- }),
3534
- title: /*#__PURE__*/jsxRuntime.jsxs("span", {
3535
- className: "flex",
3536
- children: [label, /*#__PURE__*/jsxRuntime.jsx(HelpPopover__default["default"], _objectSpread$6(_objectSpread$6({
3537
- className: "ml-2 self-center"
3538
- }, helpPopoverProps), {}, {
3539
- title: (helpPopoverProps === null || helpPopoverProps === void 0 ? void 0 : helpPopoverProps.title) || label
3540
- }))]
3541
- })
3542
- }), /*#__PURE__*/jsxRuntime.jsx(SubHeader__default["default"], {
3543
- leftActionBlock: shouldShowTemplatesCount && /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
3544
- component: "h4",
3545
- children: t("neetoMessageTemplate.template.messageTemplatesWithCount", {
3546
- type: MESSAGE_TYPES[type],
3547
- count: templatesCount
3548
- })
3549
- }),
3550
- rightActionBlock: /*#__PURE__*/jsxRuntime.jsx(SubHeader__default["default"].RightBlock, {
3551
- dataProps: {
3552
- totalCount: isFilterApplied ? null : templatesCount
3553
- },
3554
- filterProps: {
3555
- columns: filterColumns,
3556
- isOpen: isFilterPaneOpen,
3557
- keyword: searchKeywordProps,
3558
- setIsOpen: setIsFilterPaneOpen,
3559
- onChange: handleChange
3560
- }
3561
- })
3562
- }), /*#__PURE__*/jsxRuntime.jsx(neetoFiltersFrontend.Bar, {
3563
- columns: filterColumns,
3564
- keyword: searchKeywordProps,
3565
- setIsPaneOpen: setIsFilterPaneOpen,
3566
- onChange: handleChange
3567
- }), /*#__PURE__*/jsxRuntime.jsx(List, {
3568
- addText: addText,
3569
- helpDocUrl: helpDocUrl,
3570
- isFilterApplied: isFilterApplied,
3571
- isLoading: isLoading,
3572
- label: label,
3573
- labelSingular: labelSingular,
3574
- manageTemplatePane: manageTemplatePane,
3575
- onMutationSuccess: onMutationSuccess,
3576
- ownerId: ownerId,
3577
- pageProperties: pageProperties,
3578
- setManageTemplatePane: setManageTemplatePane,
3579
- setPageProperties: setPageProperties,
3580
- templatesData: templatesData,
3581
- type: type
3582
- }), /*#__PURE__*/jsxRuntime.jsx(AddEdit, {
3583
- addText: addText,
3584
- createUpdateTemplate: createUpdateTemplate,
3585
- editText: editText,
3586
- handleSubmitTestTemplate: handleSubmitTestTemplate,
3587
- isTestMessageLoading: isTestMessageLoading,
3588
- isTestingTemplateDisabled: isTestingTemplateDisabled,
3589
- manageTemplatePane: manageTemplatePane,
3590
- onMutationSuccess: onMutationSuccess,
3591
- shouldIncludeTestTemplate: shouldIncludeTestTemplate,
3592
- templateVariables: templateVariables,
3593
- customFields: manageTemplatesPaneCustomFields,
3594
- onClose: function onClose() {
3595
- return setManageTemplatePane(ramda.assoc("isOpen", false));
3596
- }
3597
- })]
3598
- });
3599
- };
3600
-
3601
- var NoDataPage = function NoDataPage(_ref) {
3602
- var type = _ref.type,
3603
- addNewTemplateRoute = _ref.addNewTemplateRoute,
3604
- _ref$helpDocUrl = _ref.helpDocUrl,
3605
- helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl;
3606
- var _useTranslation = reactI18next.useTranslation(),
3607
- t = _useTranslation.t;
3608
- var _MESSAGE_TEMPLATES$ty = MESSAGE_TEMPLATES[type],
3609
- addText = _MESSAGE_TEMPLATES$ty.addText,
3610
- label = _MESSAGE_TEMPLATES$ty.label;
3611
- if (type === MESSAGE_TYPES.whatsapp) {
3612
- return /*#__PURE__*/jsxRuntime.jsx("div", {
3613
- className: "flex h-full w-full items-center justify-center px-6 text-center",
3614
- children: /*#__PURE__*/jsxRuntime.jsxs(Typography__default["default"], {
3615
- children: [t("neetoMessageTemplate.template.emptyState", {
3616
- type: t("neetoMessageTemplate.template.whatsappTemplates")
3617
- }), " ", helpDocUrl && /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
3618
- i18nKey: "neetoMessageTemplate.template.whatsapp.helpDocText",
3619
- components: {
3620
- Link: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
3621
- href: helpDocUrl,
3622
- size: "large",
3623
- style: "link"
3624
- })
3625
- }
3626
- })]
3627
- })
3628
- });
3629
- }
3630
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
3631
- className: "flex h-full w-full flex-col items-center justify-center",
3632
- children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
3633
- children: t("neetoMessageTemplate.template.emptyState", {
3634
- type: label
3635
- })
3636
- }), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
3637
- className: "mt-4",
3638
- label: addText,
3639
- to: addNewTemplateRoute
3640
- })]
3641
- });
3642
- };
3643
-
3644
- var formatEditorContent = function formatEditorContent(value) {
3645
- return value === null || value === void 0 ? void 0 : value.replaceAll(/<\/?(?!img)\w*\b[^>]*>/gi, "").trim();
3646
- };
3647
- var SEND_MESSAGE_INITIAL_VALUES = {
3648
- subject: "",
3649
- body: ""
3650
- };
3651
- var EMAIL_MESSAGE_FORM_SCHEMA = yup__namespace.object().shape({
3652
- subject: yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.subjectPresence")),
3653
- body: yup__namespace.string().test("body", i18next.t("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
3654
- return !!formatEditorContent(value);
3655
- }).required(i18next.t("neetoMessageTemplate.template.validation.bodyPresence"))
3656
- });
3657
- var SMS_MESSAGE_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
3658
- body: yup__namespace.string().required(i18next.t("neetoMessageTemplate.template.validation.bodyPresence")).test("body", i18next.t("neetoMessageTemplate.template.validation.bodyPresence"), function (value) {
3659
- return !!formatEditorContent(value);
3660
- })
3661
- });
3662
- var WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA = yup__namespace.object().shape({
3663
- variableContents: yup__namespace.object().shape({
3664
- body: yup__namespace.array().of(yup__namespace.string().required(i18next.t("neetoMessageTemplate.template.validation.variablePresence")))
3665
- })
3666
- });
3667
-
3668
- function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3669
- function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3670
- var EmailAndSms = function EmailAndSms(_ref) {
3671
- var onClose = _ref.onClose,
3672
- templates = _ref.templates,
3673
- setFocusField = _ref.setFocusField,
3674
- templateVariables = _ref.templateVariables,
3675
- customFields = _ref.customFields,
3676
- customFieldsInitialValues = _ref.customFieldsInitialValues,
3677
- customFieldsValidationSchema = _ref.customFieldsValidationSchema,
3678
- type = _ref.type,
3679
- handleSubmit = _ref.handleSubmit;
3680
- var editorRef = react.useRef(null);
3681
- var _useTranslation = reactI18next.useTranslation(),
3682
- t = _useTranslation.t;
3683
- var isEmailTemplate = type === "email";
3684
- var _ref2 = isEmailTemplate ? [SEND_MESSAGE_INITIAL_VALUES, EMAIL_MESSAGE_FORM_SCHEMA] : [ramda.pick(["body"], SEND_MESSAGE_INITIAL_VALUES), SMS_MESSAGE_FORM_VALIDATION_SCHEMA],
3685
- _ref3 = _slicedToArray(_ref2, 2),
3686
- INITIAL_VALUES = _ref3[0],
3687
- SEND_MESSAGE_FORM_SCHEMA = _ref3[1];
3688
- var updatedInitialValues = ramda.mergeAll([INITIAL_VALUES, customFieldsInitialValues]);
3689
- var updatedValidationSchema = yup__namespace.object().shape(_objectSpread$5(_objectSpread$5({}, SEND_MESSAGE_FORM_SCHEMA === null || SEND_MESSAGE_FORM_SCHEMA === void 0 ? void 0 : SEND_MESSAGE_FORM_SCHEMA.fields), customFieldsValidationSchema === null || customFieldsValidationSchema === void 0 ? void 0 : customFieldsValidationSchema.fields));
3690
- var initialValueKeys = Object.keys(INITIAL_VALUES);
3691
- return /*#__PURE__*/jsxRuntime.jsx(NeetoUIForm__default["default"], {
3692
- formProps: {
3693
- noValidate: true,
3694
- className: "flex w-full flex-col gap-y-4 pb-6"
3695
- },
3696
- formikProps: {
3697
- initialValues: updatedInitialValues,
3698
- validationSchema: updatedValidationSchema,
3699
- onSubmit: handleSubmit
3700
- },
3701
- children: function children(_ref4) {
3702
- var setValues = _ref4.setValues,
3703
- values = _ref4.values;
3704
- var handleTemplateChange = function handleTemplateChange(value) {
3705
- var _editorRef$current;
3706
- if (!value) return;
3707
- var customFieldValues = ramda.omit(initialValueKeys, values);
3708
- var template = neetoCist.findBy({
3709
- id: value === null || value === void 0 ? void 0 : value.value
3710
- }, templates);
3711
- setValues(_objectSpread$5(_objectSpread$5({}, template), customFieldValues));
3712
- (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.editor) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.commands) === null || _editorRef$current === void 0 || _editorRef$current.setContent(template.body);
3713
- };
3714
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3715
- children: [/*#__PURE__*/jsxRuntime.jsx(Select__default["default"], {
3716
- isClearable: true,
3717
- isSearchable: true,
3718
- innerRef: setFocusField,
3719
- label: t("neetoMessageTemplate.template.title"),
3720
- options: neetoCist.renameKeys({
3721
- name: "label",
3722
- id: "value"
3723
- }, templates),
3724
- placeholder: t("neetoMessageTemplate.sendMessage.selectTemplate"),
3725
- onChange: handleTemplateChange
3726
- }), customFields, isEmailTemplate && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
3727
- required: true,
3728
- label: t("neetoMessageTemplate.template.subject"),
3729
- name: "subject"
3730
- }), /*#__PURE__*/jsxRuntime.jsx(FormikEditor__default["default"], {
3731
- hideSlashCommands: true,
3732
- required: true,
3733
- contentClassName: "max-h-40",
3734
- defaults: isEmailTemplate ? undefined : [],
3735
- label: t("neetoMessageTemplate.template.body"),
3736
- name: "body",
3737
- ref: editorRef,
3738
- rows: DEFAULT_EDITOR_ROW_COUNT,
3739
- variables: templateVariables
3740
- }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
3741
- className: "absolute bottom-0 left-0",
3742
- children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
3743
- cancelButtonProps: {
3744
- "data-cy": "message-template-cancel-button",
3745
- onClick: onClose
3746
- },
3747
- submitButtonProps: {
3748
- "data-cy": "message-template-send-button",
3749
- label: t("neetoMessageTemplate.template.send")
3750
- }
3751
- })
3752
- })]
3753
- });
3754
- }
3755
- });
3756
- };
3757
-
3758
- function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3759
- function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3760
- var Whatsapp = function Whatsapp(_ref) {
3761
- var _templates$, _templates$2, _templates$3, _templates$4;
3762
- var templates = _ref.templates,
3763
- onClose = _ref.onClose,
3764
- handleSubmit = _ref.handleSubmit,
3765
- customFields = _ref.customFields,
3766
- customFieldsInitialValues = _ref.customFieldsInitialValues,
3767
- customFieldsValidationSchema = _ref.customFieldsValidationSchema;
3768
- var _useTranslation = reactI18next.useTranslation(),
3769
- t = _useTranslation.t;
3770
- var getInitialVariableComponents = function getInitialVariableComponents(variables) {
3771
- var initialComponents = {};
3772
- variables === null || variables === void 0 || variables.forEach(function (_ref2) {
3773
- var type = _ref2.type,
3774
- count = _ref2.count;
3775
- initialComponents[type] = Array(count).fill("");
3776
- });
3777
- return initialComponents;
3778
- };
3779
- var getTemplateMessage = function getTemplateMessage(components) {
3780
- var _nullSafe;
3781
- return (_nullSafe = neetoCist.nullSafe(ramda.pluck)("text", components)) === null || _nullSafe === void 0 ? void 0 : _nullSafe.join("\n");
3782
- };
3783
- var initialFormValues = {
3784
- selectedTemplate: {
3785
- label: (_templates$ = templates[0]) === null || _templates$ === void 0 ? void 0 : _templates$.name,
3786
- value: (_templates$2 = templates[0]) === null || _templates$2 === void 0 ? void 0 : _templates$2.id
3787
- },
3788
- templateMessage: getTemplateMessage((_templates$3 = templates[0]) === null || _templates$3 === void 0 ? void 0 : _templates$3.components),
3789
- variableContents: getInitialVariableComponents((_templates$4 = templates[0]) === null || _templates$4 === void 0 ? void 0 : _templates$4.variableCount)
3790
- };
3791
- var updatedInitialValues = ramda.mergeAll([initialFormValues, customFieldsInitialValues]);
3792
- var updatedValidationSchema = yup__namespace.object().shape(_objectSpread$4(_objectSpread$4({}, WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA === null || WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA === void 0 ? void 0 : WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA.fields), customFieldsValidationSchema === null || customFieldsValidationSchema === void 0 ? void 0 : customFieldsValidationSchema.fields));
3793
- var initialValueKeys = Object.keys(initialFormValues);
3794
- return /*#__PURE__*/jsxRuntime.jsx(NeetoUIForm__default["default"], {
3795
- formProps: {
3796
- noValidate: true,
3797
- className: "flex w-full flex-col gap-y-4 pb-6"
3798
- },
3799
- formikProps: {
3800
- initialValues: updatedInitialValues,
3801
- validationSchema: updatedValidationSchema,
3802
- onSubmit: handleSubmit
3803
- },
3804
- children: function children(_ref3) {
3805
- var values = _ref3.values,
3806
- setValues = _ref3.setValues;
3807
- var handleTemplateChange = function handleTemplateChange(value) {
3808
- if (!value) return;
3809
- var template = neetoCist.findBy({
3810
- id: value === null || value === void 0 ? void 0 : value.value
3811
- }, templates);
3812
- var customFieldValues = ramda.omit(initialValueKeys, values);
3813
- setValues(_objectSpread$4({
3814
- selectedTemplate: {
3815
- label: template.name,
3816
- value: template.id
3817
- },
3818
- templateMessage: getTemplateMessage(template.components),
3819
- variableContents: getInitialVariableComponents(template.variableCount)
3820
- }, customFieldValues));
3821
- };
3822
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3823
- children: [/*#__PURE__*/jsxRuntime.jsx(Select__default$1["default"], {
3824
- required: true,
3825
- defaultValue: initialFormValues.selectedTemplate,
3826
- label: t("neetoMessageTemplate.template.title"),
3827
- name: "selectedTemplate",
3828
- options: neetoCist.renameKeys({
3829
- name: "label",
3830
- id: "value"
3831
- }, templates),
3832
- onChange: handleTemplateChange
3833
- }), customFields, /*#__PURE__*/jsxRuntime.jsx(Textarea__default$1["default"], {
3834
- disabled: true,
3835
- nakedTextarea: true,
3836
- label: t("neetoMessageTemplate.template.preview"),
3837
- value: values.templateMessage
3838
- }), neetoCist.isNotEmpty(values.variableContents) && /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
3839
- children: Object.keys(values.variableContents).map(function (group) {
3840
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
3841
- className: "flex flex-col gap-y-2",
3842
- children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
3843
- style: "h4",
3844
- children: t("neetoMessageTemplate.template.resolveVariable", {
3845
- type: neetoCist.capitalize(group)
3846
- })
3847
- }), values.variableContents[group].map(function (_, index) {
3848
- return /*#__PURE__*/jsxRuntime.jsx("div", {
3849
- children: /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
3850
- required: true,
3851
- label: "{{".concat(index + 1, "}}"),
3852
- name: "variableContents.".concat(group, ".").concat(index)
3853
- }, "".concat(group, "-").concat(index))
3854
- }, "".concat(group, "-").concat(index));
3855
- })]
3856
- }, group);
3857
- })
3858
- }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
3859
- className: "absolute bottom-0 left-0",
3860
- children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
3861
- cancelButtonProps: {
3862
- "data-cy": "message-template-cancel-button",
3863
- onClick: onClose
3864
- },
3865
- submitButtonProps: {
3866
- "data-cy": "message-template-send-button",
3867
- label: t("neetoMessageTemplate.template.send")
3868
- }
3869
- })
3870
- })]
3871
- });
3872
- }
3873
- });
3874
- };
3875
-
3876
- function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3877
- function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3878
- var SendMessagePane = function SendMessagePane(props) {
3879
- var isOpen = props.isOpen,
3880
- onClose = props.onClose;
3881
- return /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"], {
3882
- isOpen: isOpen,
3883
- onClose: onClose,
3884
- children: function children(paneProps) {
3885
- return /*#__PURE__*/jsxRuntime.jsx(SendMessageForm, _objectSpread$3({}, _objectSpread$3(_objectSpread$3({}, props), {}, {
3886
- paneProps: paneProps
3887
- })));
3888
- }
3889
- });
3890
- };
3891
- var SendMessageForm = function SendMessageForm(_ref) {
3892
- var _ref$type = _ref.type,
3893
- type = _ref$type === void 0 ? "" : _ref$type,
3894
- _ref$handleSubmit = _ref.handleSubmit,
3895
- handleSubmit = _ref$handleSubmit === void 0 ? neetoCist.noop : _ref$handleSubmit,
3896
- _ref$onClose = _ref.onClose,
3897
- onClose = _ref$onClose === void 0 ? neetoCist.noop : _ref$onClose,
3898
- _ref$customFields = _ref.customFields,
3899
- customFields = _ref$customFields === void 0 ? null : _ref$customFields,
3900
- _ref$customFieldsInit = _ref.customFieldsInitialValues,
3901
- customFieldsInitialValues = _ref$customFieldsInit === void 0 ? {} : _ref$customFieldsInit,
3902
- _ref$customFieldsVali = _ref.customFieldsValidationSchema,
3903
- customFieldsValidationSchema = _ref$customFieldsVali === void 0 ? {} : _ref$customFieldsVali,
3904
- _ref$templateVariable = _ref.templateVariables,
3905
- templateVariables = _ref$templateVariable === void 0 ? {} : _ref$templateVariable,
3906
- _ref$ownerId = _ref.ownerId,
3907
- ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId,
3908
- _ref$helpDocUrl = _ref.helpDocUrl,
3909
- helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
3910
- _ref$addNewTemplateRo = _ref.addNewTemplateRoute,
3911
- addNewTemplateRoute = _ref$addNewTemplateRo === void 0 ? "" : _ref$addNewTemplateRo,
3912
- setFocusField = _ref.paneProps.setFocusField;
3913
- var _useTranslation = reactI18next.useTranslation(),
3914
- t = _useTranslation.t;
3915
- var value = MESSAGE_TEMPLATES[type].value;
3916
- var isWhatsappTemplate = type === "whatsapp";
3917
- var templateParams = {
3918
- status: "active",
3919
- templateType: value,
3920
- ownerId: ownerId
3921
- };
3922
- var _useFetchTemplates = useFetchTemplates(templateParams),
3923
- _useFetchTemplates$da = _useFetchTemplates.data,
3924
- _useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
3925
- _useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
3926
- templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3,
3927
- isLoading = _useFetchTemplates.isLoading;
3928
- if (isLoading) {
3929
- return /*#__PURE__*/jsxRuntime.jsx("div", {
3930
- className: "flex h-full w-full items-center justify-center",
3931
- children: /*#__PURE__*/jsxRuntime.jsx(Spinner__default["default"], {})
3932
- });
3933
- }
3934
- if (ramda.isEmpty(templates)) {
3935
- return /*#__PURE__*/jsxRuntime.jsx(NoDataPage, {
3936
- addNewTemplateRoute: addNewTemplateRoute,
3937
- helpDocUrl: helpDocUrl,
3938
- type: type
3939
- });
3940
- }
3941
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3942
- children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
3943
- children: /*#__PURE__*/jsxRuntime.jsxs(Typography__default["default"], {
3944
- style: "h2",
3945
- weight: "semibold",
3946
- children: [t("neetoMessageTemplate.common.send"), " ", MESSAGE_TYPES[type]]
3947
- })
3948
- }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
3949
- children: isWhatsappTemplate ? /*#__PURE__*/jsxRuntime.jsx(Whatsapp, {
3950
- customFields: customFields,
3951
- customFieldsInitialValues: customFieldsInitialValues,
3952
- customFieldsValidationSchema: customFieldsValidationSchema,
3953
- handleSubmit: handleSubmit,
3954
- onClose: onClose,
3955
- templates: templates
3956
- }) : /*#__PURE__*/jsxRuntime.jsx(EmailAndSms, {
3957
- customFields: customFields,
3958
- customFieldsInitialValues: customFieldsInitialValues,
3959
- customFieldsValidationSchema: customFieldsValidationSchema,
3960
- handleSubmit: handleSubmit,
3961
- onClose: onClose,
3962
- setFocusField: setFocusField,
3963
- templateVariables: templateVariables,
3964
- templates: templates,
3965
- type: type
3966
- })
3967
- })]
3968
- });
3969
- };
3970
-
3971
- var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
3972
-
3973
- var css = ".neeto-message-templates-nano-adaptive-input textarea{--neeto-ui-input-line-height:1.5}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3N0eWxlc2hlZXRzL2NvbXBvbmVudHMvX2FkYXB0aXZlX2lucHV0LnNjc3MiLCJhcHAvamF2YXNjcmlwdC9zdHlsZXNoZWV0cy9hcHBsaWNhdGlvbi5zY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNFLHNEQUNFLGdDQ0FKIiwic291cmNlc0NvbnRlbnQiOlsiLm5lZXRvLW1lc3NhZ2UtdGVtcGxhdGVzLW5hbm8tYWRhcHRpdmUtaW5wdXQge1xuICB0ZXh0YXJlYSB7XG4gICAgLS1uZWV0by11aS1pbnB1dC1saW5lLWhlaWdodDogMS41O1xuICB9XG59XG4iLCIubmVldG8tbWVzc2FnZS10ZW1wbGF0ZXMtbmFuby1hZGFwdGl2ZS1pbnB1dCB0ZXh0YXJlYSB7XG4gIC0tbmVldG8tdWktaW5wdXQtbGluZS1oZWlnaHQ6IDEuNTtcbn0iXX0= */";
3974
- n(css,{});
3975
-
3976
- var VALID_URL_REGEX = /^(https?):\/\/([a-zA-Z0-9-]+\.){1,}[a-zA-Z]{2,}\/?[^\s]*$/;
3977
- var ADDITIONAL_DATA_INITIAL_VALUE = {
3978
- key: "",
3979
- value: ""
3980
- };
3981
- var API_TEMPLATE_TYPE = "api_template";
3982
-
3983
- [{
3984
- dataIndex: "name",
3985
- key: "name",
3986
- title: i18next.t("neetoMessageTemplate.template.name")
3987
- }, {
3988
- dataIndex: "status",
3989
- key: "status",
3990
- title: i18next.t("neetoMessageTemplate.template.active"),
3991
- render: function render(status) {
3992
- return status === "active" ? i18next.t("neetoMessageTemplate.yes") : i18next.t("neetoMessageTemplate.no");
3993
- },
3994
- width: "20%"
3995
- }];
3996
- var FILTER_COLUMNS = [{
3997
- key: "name",
3998
- node: "name",
3999
- label: i18next.t("neetoMessageTemplate.template.name"),
4000
- type: "text"
4001
- }, {
4002
- key: "status",
4003
- node: "status",
4004
- label: i18next.t("neetoMessageTemplate.template.active"),
4005
- type: "single_option",
4006
- values: [{
4007
- label: i18next.t("neetoMessageTemplate.yes"),
4008
- value: "active"
4009
- }, {
4010
- label: i18next.t("neetoMessageTemplate.no"),
4011
- value: "inactive"
4012
- }]
4013
- }];
4014
- var API_TEMPLATE_INITIAL_VALUES = {
4015
- name: "",
4016
- endpoint: "",
4017
- additionalData: [ADDITIONAL_DATA_INITIAL_VALUE]
4018
- };
4019
- var SAMPLE_URL = "https://example.com";
4020
- var API_TEMPLATE_FORM_VALIDATION_SCHEMA = yup__namespace.object({
4021
- name: yup__namespace.string().trim().required(i18next.t("neetoMessageTemplate.template.validation.namePresence")),
4022
- endpoint: yup__namespace.string().required(i18next.t("neetoMessageTemplate.api.validation.endpointPresence")).matches(VALID_URL_REGEX, i18next.t("neetoMessageTemplate.api.validation.validEndpoint")),
4023
- additionalData: yup__namespace.array().of(yup__namespace.object({
4024
- key: yup__namespace.string(),
4025
- value: yup__namespace.string()
4026
- }))
4027
- });
4028
- var TEMPLATE_STATUS = {
4029
- ACTIVE: "active",
4030
- INACTIVE: "inactive"
4031
- };
4032
-
4033
- var removeOption = function removeOption(_ref) {
4034
- var arrayHelpers = _ref.arrayHelpers,
4035
- index = _ref.index,
4036
- data = _ref.data;
4037
- if (data.length === 1) {
4038
- arrayHelpers.remove(index);
4039
- arrayHelpers.push(ADDITIONAL_DATA_INITIAL_VALUE);
4040
- return;
4041
- }
4042
- arrayHelpers.remove(index);
4043
- };
4044
- var addOption = function addOption(arrayHelpers) {
4045
- return arrayHelpers.push(ADDITIONAL_DATA_INITIAL_VALUE);
4046
- };
4047
- var isKeyOrValueNotEmpty = ramda.whereAny({
4048
- key: neetoCist.isNotEmpty,
4049
- value: neetoCist.isNotEmpty
4050
- });
4051
-
4052
- var KeyValuePairs = reactUtils.withT(function (_ref) {
4053
- var t = _ref.t,
4054
- name = _ref.name,
4055
- _ref$label = _ref.label,
4056
- label = _ref$label === void 0 ? "" : _ref$label;
4057
- return /*#__PURE__*/jsxRuntime.jsx(formik.FieldArray, {
4058
- name: name,
4059
- children: function children(arrayHelpers) {
4060
- var data = arrayHelpers.form.values[name];
4061
- var showDeleteButton = data.length > 1 || isKeyOrValueNotEmpty(data[0]);
4062
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
4063
- className: "space-y-2",
4064
- children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
4065
- children: label
4066
- }), data.map(function (_, index) {
4067
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
4068
- className: "flex h-8 space-x-3",
4069
- children: [/*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
4070
- className: "w-2/5",
4071
- "data-cy": "key-input-".concat(index),
4072
- name: "".concat(name, ".").concat(index, ".key"),
4073
- placeholder: t("neetoMessageTemplate.api.key")
4074
- }), /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
4075
- className: "w-3/5",
4076
- "data-cy": "value-input-".concat(index),
4077
- name: "".concat(name, ".").concat(index, ".value"),
4078
- placeholder: t("neetoMessageTemplate.api.value"),
4079
- suffix: showDeleteButton && /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
4080
- "data-cy": "delete-key-value-pair-".concat(index),
4081
- icon: Delete__default["default"],
4082
- size: "small",
4083
- style: "text",
4084
- onClick: function onClick() {
4085
- return removeOption({
4086
- arrayHelpers: arrayHelpers,
4087
- index: index,
4088
- data: data
4089
- });
4090
- }
4091
- })
4092
- })]
4093
- }, index);
4094
- }), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
4095
- className: "w-full justify-center",
4096
- "data-cy": "add-key-value-pair-button",
4097
- label: t("neetoMessageTemplate.api.addKeyValuePair"),
4098
- style: "secondary",
4099
- onClick: function onClick() {
4100
- return addOption(arrayHelpers);
4101
- }
4102
- })]
4103
- });
4104
- }
4105
- });
4106
- });
4107
-
4108
- var rejectEmptyKeyValuePairs = ramda.reject(ramda.whereAny({
4109
- key: ramda.isEmpty,
4110
- value: ramda.isEmpty
4111
- }));
4112
-
4113
- function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4114
- function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4115
- var buildApiTemplatePayload = function buildApiTemplatePayload(values) {
4116
- return {
4117
- entity: {
4118
- endpoint: values.endpoint,
4119
- additionalData: rejectEmptyKeyValuePairs(values.additionalData)
4120
- },
4121
- templateType: API_TEMPLATE_TYPE,
4122
- name: values.name
4123
- };
4124
- };
4125
- var buildTableColumnData = function buildTableColumnData(_ref) {
4126
- var handleMarkAsActiveOrInactive = _ref.handleMarkAsActiveOrInactive,
4127
- handleOpenDeleteAlert = _ref.handleOpenDeleteAlert,
4128
- handleOpenEditPane = _ref.handleOpenEditPane;
4129
- return [{
4130
- dataIndex: "name",
4131
- key: "name",
4132
- title: i18next.t("neetoMessageTemplate.template.name"),
4133
- render: function render(name, apiTemplate) {
4134
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
4135
- className: "flex items-center justify-between gap-x-3",
4136
- children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
4137
- "data-cy": "api-template-name-link",
4138
- label: name,
4139
- style: "link",
4140
- onClick: function onClick() {
4141
- return handleOpenEditPane(apiTemplate);
4142
- }
4143
- }), /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], {
4144
- dropdownButtonProps: {
4145
- "data-cy": "api-template-dropdown"
4146
- },
4147
- dropdownProps: {
4148
- strategy: "fixed"
4149
- },
4150
- menuItems: [{
4151
- key: "edit",
4152
- label: i18next.t("neetoMessageTemplate.template.edit"),
4153
- "data-cy": "api-template-button-edit-button",
4154
- onClick: function onClick() {
4155
- return handleOpenEditPane(apiTemplate);
4156
- }
4157
- }, {
4158
- key: "status",
4159
- label: ramda.equals(apiTemplate.status, TEMPLATE_STATUS.ACTIVE) ? i18next.t("neetoMessageTemplate.template.markAsInactive") : i18next.t("neetoMessageTemplate.template.markAsActive"),
4160
- "data-cy": "api-template-button-status-button",
4161
- onClick: function onClick() {
4162
- return handleMarkAsActiveOrInactive(apiTemplate);
4163
- }
4164
- }, {
4165
- key: "delete",
4166
- label: i18next.t("neetoMessageTemplate.template.delete"),
4167
- "data-cy": "api-template-button-delete-button",
4168
- onClick: function onClick() {
4169
- return handleOpenDeleteAlert(apiTemplate);
4170
- }
4171
- }]
4172
- })]
4173
- });
4174
- }
4175
- }, {
4176
- dataIndex: "status",
4177
- key: "status",
4178
- title: i18next.t("neetoMessageTemplate.template.active"),
4179
- render: function render(status) {
4180
- return status === "active" ? i18next.t("neetoMessageTemplate.yes") : i18next.t("neetoMessageTemplate.no");
4181
- },
4182
- width: "20%"
4183
- }];
4184
- };
4185
- var buildApiTemplateInitialValues = function buildApiTemplateInitialValues(isEdit, apiTemplate) {
4186
- if (!isEdit) return API_TEMPLATE_INITIAL_VALUES;
4187
- var additionalData = ramda.isEmpty(apiTemplate.additionalData) ? [ADDITIONAL_DATA_INITIAL_VALUE] : apiTemplate.additionalData;
4188
- return _objectSpread$2(_objectSpread$2({}, ramda.pick(["name", "endpoint"], apiTemplate)), {}, {
4189
- additionalData: additionalData
4190
- });
4191
- };
4192
-
4193
- var Form = function Form(_ref) {
4194
- var setFocusField = _ref.setFocusField,
4195
- onClose = _ref.onClose,
4196
- ownerId = _ref.ownerId,
4197
- selectedApiTemplate = _ref.selectedApiTemplate,
4198
- onMutationSuccess = _ref.onMutationSuccess;
4199
- var _useTranslation = reactI18next.useTranslation(),
4200
- t = _useTranslation.t;
4201
- var _useCreateTemplate = useCreateTemplate(ownerId),
4202
- createApiTemplate = _useCreateTemplate.mutate,
4203
- isCreating = _useCreateTemplate.isPending;
4204
- var _useUpdateTemplate = useUpdateTemplate(ownerId),
4205
- updateApiTemplate = _useUpdateTemplate.mutate,
4206
- isUpdating = _useUpdateTemplate.isPending;
4207
- var isEdit = neetoCist.isNotEmpty(selectedApiTemplate);
4208
- var handleSubmit = function handleSubmit(values, _ref2) {
4209
- var setSubmitting = _ref2.setSubmitting;
4210
- var payload = buildApiTemplatePayload(values);
4211
- var options = {
4212
- onSuccess: function onSuccess() {
4213
- onMutationSuccess.apply(void 0, arguments);
4214
- onClose();
4215
- },
4216
- onSettled: function onSettled() {
4217
- return setSubmitting(false);
4218
- }
4219
- };
4220
- if (isEdit) {
4221
- updateApiTemplate({
4222
- id: selectedApiTemplate.id,
4223
- payload: payload
4224
- }, options);
4225
- return;
4226
- }
4227
- createApiTemplate(payload, options);
4228
- };
4229
- var isMutating = isUpdating || isCreating;
4230
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4231
- children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
4232
- children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
4233
- style: "h2",
4234
- weight: "semibold",
4235
- children: isEdit ? t("neetoMessageTemplate.api.editApiTemplate") : t("neetoMessageTemplate.api.addApiTemplate")
4236
- })
4237
- }), /*#__PURE__*/jsxRuntime.jsxs(NeetoUIForm__default["default"], {
4238
- formikProps: {
4239
- initialValues: buildApiTemplateInitialValues(isEdit, selectedApiTemplate),
4240
- validationSchema: API_TEMPLATE_FORM_VALIDATION_SCHEMA,
4241
- onSubmit: handleSubmit
4242
- },
4243
- children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
4244
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
4245
- className: "w-full space-y-5",
4246
- children: [/*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
4247
- required: true,
4248
- label: t("neetoMessageTemplate.template.name"),
4249
- name: "name",
4250
- ref: setFocusField
4251
- }), /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
4252
- required: true,
4253
- label: t("neetoMessageTemplate.api.endpoint"),
4254
- name: "endpoint",
4255
- placeholder: SAMPLE_URL
4256
- }), /*#__PURE__*/jsxRuntime.jsx(KeyValuePairs, {
4257
- label: t("neetoMessageTemplate.api.additionalData"),
4258
- name: "additionalData"
4259
- })]
4260
- })
4261
- }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
4262
- children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
4263
- cancelButtonProps: {
4264
- onClick: onClose
4265
- },
4266
- isSubmitting: isMutating
4267
- })
4268
- })]
4269
- })]
4270
- });
4271
- };
4272
-
4273
- function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4274
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4275
- var ApiTemplates = function ApiTemplates(_ref) {
4276
- var _helpPopoverProps$hel;
4277
- var ownerId = _ref.ownerId,
4278
- _ref$breadcrumbs = _ref.breadcrumbs,
4279
- breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
4280
- _ref$helpPopoverProps = _ref.helpPopoverProps,
4281
- helpPopoverProps = _ref$helpPopoverProps === void 0 ? {} : _ref$helpPopoverProps,
4282
- _ref$onMutationSucces = _ref.onMutationSuccess,
4283
- onMutationSuccess = _ref$onMutationSucces === void 0 ? neetoCist.noop : _ref$onMutationSucces;
4284
- var _useTranslation = reactI18next.useTranslation(),
4285
- t = _useTranslation.t;
4286
- var _useState = react.useState(DEFAULT_PAGE_PROPERTIES),
4287
- _useState2 = _slicedToArray(_useState, 2),
4288
- pageParams = _useState2[0],
4289
- setPageParams = _useState2[1];
4290
- var _useState3 = react.useState(false),
4291
- _useState4 = _slicedToArray(_useState3, 2),
4292
- isFiltersPaneOpen = _useState4[0],
4293
- setIsFiltersPaneOpen = _useState4[1];
4294
- var _useState5 = react.useState(false),
4295
- _useState6 = _slicedToArray(_useState5, 2),
4296
- isFormPaneOpen = _useState6[0],
4297
- setIsFormPaneOpen = _useState6[1];
4298
- var _useState7 = react.useState({}),
4299
- _useState8 = _slicedToArray(_useState7, 2),
4300
- selectedApiTemplate = _useState8[0],
4301
- setSelectedApiTemplate = _useState8[1];
4302
- var _useState9 = react.useState(false),
4303
- _useState10 = _slicedToArray(_useState9, 2),
4304
- isDeleteAlertOpen = _useState10[0],
4305
- setIsDeleteAlertOpen = _useState10[1];
4306
- var _useQueryParams = reactUtils.useQueryParams(),
4307
- _useQueryParams$searc = _useQueryParams.searchTerm,
4308
- searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
4309
- var searchKeywordProps = {
4310
- key: "search_term",
4311
- node: "name",
4312
- value: searchTerm
4313
- };
4314
- var _useState11 = react.useState(function () {
4315
- return neetoFiltersFrontend.buildFiltersFromURL([].concat(_toConsumableArray(FILTER_COLUMNS), [searchKeywordProps]));
4316
- }),
4317
- _useState12 = _slicedToArray(_useState11, 2),
4318
- filters = _useState12[0],
4319
- setFilters = _useState12[1];
4320
- var _useFetchTemplates = useFetchTemplates({
4321
- filters: filters,
4322
- page: pageParams.index,
4323
- pageSize: pageParams.size,
4324
- templateType: API_TEMPLATE_TYPE,
4325
- ownerId: ramda.isEmpty(ownerId) ? undefined : ownerId
4326
- }),
4327
- _useFetchTemplates$da = _useFetchTemplates.data,
4328
- _useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
4329
- templates = _useFetchTemplates$da2.templates,
4330
- totalCount = _useFetchTemplates$da2.totalCount,
4331
- isLoading = _useFetchTemplates.isLoading,
4332
- isFetching = _useFetchTemplates.isFetching;
4333
- var title = t("neetoMessageTemplate.template.apiTemplates");
4334
- var isFilterApplied = neetoCist.isNotEmpty(filters);
4335
- var handleFiltersChange = function handleFiltersChange(filters) {
4336
- setFilters(filters);
4337
- setPageParams(DEFAULT_PAGE_PROPERTIES);
4338
- };
4339
- var _useDeleteTemplate = useDeleteTemplate(ownerId),
4340
- deleteTemplate = _useDeleteTemplate.mutate,
4341
- isDeleting = _useDeleteTemplate.isPending;
4342
- var _useUpdateTemplate = useUpdateTemplate(ownerId),
4343
- updateTemplate = _useUpdateTemplate.mutate;
4344
- var handleOpenEditPane = function handleOpenEditPane(apiTemplate) {
4345
- setSelectedApiTemplate(apiTemplate);
4346
- setIsFormPaneOpen(true);
4347
- };
4348
- var handleOpenDeleteAlert = function handleOpenDeleteAlert(apiTemplate) {
4349
- setSelectedApiTemplate(apiTemplate);
4350
- setIsDeleteAlertOpen(true);
4351
- };
4352
- var handleCloseDeleteAlertAndFormPane = function handleCloseDeleteAlertAndFormPane() {
4353
- setIsDeleteAlertOpen(false);
4354
- setIsFormPaneOpen(false);
4355
- setSelectedApiTemplate({});
4356
- };
4357
- var handleMarkAsActiveOrInactive = function handleMarkAsActiveOrInactive(_ref2) {
4358
- var status = _ref2.status,
4359
- id = _ref2.id;
4360
- var newStatus = ramda.equals(status, TEMPLATE_STATUS.ACTIVE) ? TEMPLATE_STATUS.INACTIVE : TEMPLATE_STATUS.ACTIVE;
4361
- updateTemplate({
4362
- payload: {
4363
- status: newStatus,
4364
- templateType: API_TEMPLATE_TYPE
4365
- },
4366
- id: id
4367
- }, {
4368
- onSuccess: onMutationSuccess
4369
- });
4370
- };
4371
- var handleDeleteApiTemplate = function handleDeleteApiTemplate() {
4372
- return deleteTemplate(selectedApiTemplate.id, {
4373
- onSuccess: function onSuccess() {
4374
- onMutationSuccess.apply(void 0, arguments);
4375
- handleCloseDeleteAlertAndFormPane();
4376
- }
4377
- });
4378
- };
4379
- var helpDocUrl = (helpPopoverProps === null || helpPopoverProps === void 0 || (_helpPopoverProps$hel = helpPopoverProps.helpLinkProps) === null || _helpPopoverProps$hel === void 0 ? void 0 : _helpPopoverProps$hel.href) || "";
4380
- var noDataProps = _objectSpread$1(_objectSpread$1({}, !isFilterApplied && {
4381
- primaryButtonProps: {
4382
- label: t("neetoMessageTemplate.api.addApiTemplate"),
4383
- onClick: function onClick() {
4384
- return setIsFormPaneOpen(true);
4385
- }
4386
- },
4387
- helpText: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
4388
- i18nKey: "neetoMessageTemplate.template.linkToHelpArticle",
4389
- values: {
4390
- entity: title
4391
- },
4392
- components: {
4393
- Link: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
4394
- className: "underline",
4395
- href: helpDocUrl,
4396
- style: "link",
4397
- target: "_blank"
4398
- })
4399
- }
4400
- })
4401
- }), {}, {
4402
- title: isFilterApplied ? t("neetoMessageTemplate.template.filtersEmptyState", {
4403
- type: title
4404
- }) : t("neetoMessageTemplate.template.emptyState", {
4405
- type: title
4406
- })
4407
- });
4408
- var shouldShowTemplatesCount = !isLoading && (isFilterApplied || totalCount > 0);
4409
- return /*#__PURE__*/jsxRuntime.jsxs(Container__default["default"], {
4410
- children: [/*#__PURE__*/jsxRuntime.jsx(NeetoHeader__default["default"], {
4411
- breadcrumbs: breadcrumbs,
4412
- size: "small",
4413
- actionBlock: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
4414
- "data-cy": "add-api-templates-button",
4415
- label: t("neetoMessageTemplate.api.addApiTemplate"),
4416
- onClick: function onClick() {
4417
- return setIsFormPaneOpen(true);
4418
- }
4419
- }),
4420
- searchProps: {
4421
- placeholder: t("neetoMessageTemplate.template.searchApiTemplates"),
4422
- "data-cy": "api-templates-search-input"
4423
- },
4424
- title: /*#__PURE__*/jsxRuntime.jsxs("span", {
4425
- className: "flex",
4426
- children: [title, /*#__PURE__*/jsxRuntime.jsx(HelpPopover__default["default"], _objectSpread$1(_objectSpread$1({
4427
- className: "ml-2 self-center"
4428
- }, helpPopoverProps), {}, {
4429
- title: (helpPopoverProps === null || helpPopoverProps === void 0 ? void 0 : helpPopoverProps.title) || title
4430
- }))]
4431
- })
4432
- }), /*#__PURE__*/jsxRuntime.jsx(SubHeader__default["default"], {
4433
- leftActionBlock: shouldShowTemplatesCount && /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
4434
- component: "h4",
4435
- children: t("neetoMessageTemplate.template.messageTemplatesWithCount", {
4436
- type: t("messageType.api"),
4437
- count: totalCount
4438
- })
4439
- }),
4440
- rightActionBlock: /*#__PURE__*/jsxRuntime.jsx(SubHeader__default["default"].RightBlock, {
4441
- dataProps: {
4442
- totalCount: isFilterApplied ? null : totalCount
4443
- },
4444
- filterProps: {
4445
- columns: FILTER_COLUMNS,
4446
- isOpen: isFiltersPaneOpen,
4447
- keyword: searchKeywordProps,
4448
- setIsOpen: setIsFiltersPaneOpen,
4449
- onChange: handleFiltersChange
4450
- }
4451
- })
4452
- }), /*#__PURE__*/jsxRuntime.jsx(neetoFiltersFrontend.Bar, {
4453
- columns: FILTER_COLUMNS,
4454
- keyword: searchKeywordProps,
4455
- setIsPaneOpen: setIsFiltersPaneOpen,
4456
- onChange: handleFiltersChange
4457
- }), neetoCist.isNotEmpty(templates) ? /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
4458
- hasPagination: totalCount > pageParams.size,
4459
- children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
4460
- totalCount: totalCount,
4461
- fixedHeight: true,
4462
- currentPageNumber: pageParams.index,
4463
- defaultPageSize: pageParams.size,
4464
- handlePageChange: function handlePageChange(index, size) {
4465
- return setPageParams({
4466
- index: index,
4467
- size: size
4468
- });
4469
- },
4470
- loading: isLoading || isFetching,
4471
- rowData: templates,
4472
- scroll: {
4473
- x: "100%"
4474
- },
4475
- columnData: buildTableColumnData({
4476
- handleMarkAsActiveOrInactive: handleMarkAsActiveOrInactive,
4477
- handleOpenDeleteAlert: handleOpenDeleteAlert,
4478
- handleOpenEditPane: handleOpenEditPane
4479
- })
4480
- })
4481
- }) : /*#__PURE__*/jsxRuntime.jsx("div", {
4482
- className: "flex h-full w-full items-center justify-center",
4483
- children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], _objectSpread$1({}, noDataProps))
4484
- }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"], {
4485
- isOpen: isFormPaneOpen,
4486
- onClose: handleCloseDeleteAlertAndFormPane,
4487
- children: function children(_ref3) {
4488
- var setFocusField = _ref3.setFocusField;
4489
- return /*#__PURE__*/jsxRuntime.jsx(Form, {
4490
- onMutationSuccess: onMutationSuccess,
4491
- ownerId: ownerId,
4492
- selectedApiTemplate: selectedApiTemplate,
4493
- setFocusField: setFocusField,
4494
- onClose: handleCloseDeleteAlertAndFormPane
4495
- });
4496
- }
4497
- }), /*#__PURE__*/jsxRuntime.jsx(Alert__default["default"], {
4498
- isOpen: isDeleteAlertOpen,
4499
- isSubmitting: isDeleting,
4500
- submitButtonLabel: t("neetoMessageTemplate.template.delete"),
4501
- title: t("neetoMessageTemplate.api.deleteApiTemplate"),
4502
- message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
4503
- i18nKey: "neetoMessageTemplate.template.templateDeleteConfirmation",
4504
- values: {
4505
- name: selectedApiTemplate.name
4506
- }
4507
- }),
4508
- onClose: handleCloseDeleteAlertAndFormPane,
4509
- onSubmit: handleDeleteApiTemplate
4510
- })]
4511
- });
4512
- };
4513
-
4514
- var SEND_TO_API_FORM_INITIAL_VALUES = {
4515
- endpoint: "",
4516
- additionalData: [ADDITIONAL_DATA_INITIAL_VALUE]
4517
- };
4518
- var SEND_TO_API_FORM_VALIDATION_SCHEMA = yup__namespace.object({
4519
- endpoint: yup__namespace.string().required(i18next.t("neetoMessageTemplate.api.validation.endpointPresence")).matches(VALID_URL_REGEX, i18next.t("neetoMessageTemplate.api.validation.validEndpoint")),
4520
- additionalData: yup__namespace.array().of(yup__namespace.object({
4521
- key: yup__namespace.string(),
4522
- value: yup__namespace.string()
4523
- }))
4524
- });
4525
-
4526
- var formatAdditionalData = function formatAdditionalData(additionalData) {
4527
- return neetoCist.isPresent(additionalData) ? additionalData : [ADDITIONAL_DATA_INITIAL_VALUE];
4528
- };
4529
-
4530
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4531
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4532
- var SendToApiPane = function SendToApiPane(props) {
4533
- var isOpen = props.isOpen,
4534
- onClose = props.onClose;
4535
- return /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"], {
4536
- isOpen: isOpen,
4537
- onClose: onClose,
4538
- children: function children(paneProps) {
4539
- return /*#__PURE__*/jsxRuntime.jsx(SendToApiForm, _objectSpread({}, _objectSpread(_objectSpread({}, props), {}, {
4540
- paneProps: paneProps
4541
- })));
4542
- }
4543
- });
4544
- };
4545
- var SendToApiForm = function SendToApiForm(_ref) {
4546
- var ownerId = _ref.ownerId,
4547
- onClose = _ref.onClose,
4548
- onSubmit = _ref.onSubmit,
4549
- isSubmitting = _ref.isSubmitting,
4550
- addNewTemplateRoute = _ref.addNewTemplateRoute,
4551
- setFocusField = _ref.paneProps.setFocusField;
4552
- var _useTranslation = reactI18next.useTranslation(),
4553
- t = _useTranslation.t;
4554
- var _useFetchTemplates = useFetchTemplates({
4555
- status: "active",
4556
- templateType: API_TEMPLATE_TYPE,
4557
- ownerId: ownerId
4558
- }),
4559
- _useFetchTemplates$da = _useFetchTemplates.data,
4560
- _useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
4561
- _useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
4562
- templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3,
4563
- isLoadingTemplates = _useFetchTemplates.isLoading;
4564
- var handleTemplateChange = function handleTemplateChange(setFieldValue, template) {
4565
- setFieldValue("endpoint", template.endpoint);
4566
- setFieldValue("additionalData", formatAdditionalData(template.additionalData));
4567
- };
4568
- var handleSubmit = function handleSubmit(formValues) {
4569
- var additionalDataModifiedFormValues = ramda.modify("additionalData", rejectEmptyKeyValuePairs, formValues);
4570
- onSubmit(additionalDataModifiedFormValues);
4571
- };
4572
- if (ramda.isEmpty(templates)) {
4573
- return /*#__PURE__*/jsxRuntime.jsx(NoDataPage, {
4574
- addNewTemplateRoute: addNewTemplateRoute,
4575
- type: "api"
4576
- });
4577
- }
4578
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4579
- children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
4580
- children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
4581
- style: "h2",
4582
- weight: "semibold",
4583
- children: t("neetoMessageTemplate.api.sendToApi")
4584
- })
4585
- }), /*#__PURE__*/jsxRuntime.jsx(NeetoUIForm__default["default"], {
4586
- formikProps: {
4587
- initialValues: SEND_TO_API_FORM_INITIAL_VALUES,
4588
- validationSchema: SEND_TO_API_FORM_VALIDATION_SCHEMA,
4589
- onSubmit: handleSubmit
4590
- },
4591
- children: function children(_ref2) {
4592
- var setFieldValue = _ref2.setFieldValue;
4593
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4594
- children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
4595
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
4596
- className: "w-full space-y-5",
4597
- children: [/*#__PURE__*/jsxRuntime.jsx(Select__default["default"], {
4598
- innerRef: setFocusField,
4599
- isLoading: isLoadingTemplates,
4600
- label: t("neetoMessageTemplate.template.title"),
4601
- options: neetoCist.renameKeys({
4602
- name: "label",
4603
- id: "value"
4604
- }, templates),
4605
- placeholder: t("neetoMessageTemplate.sendMessage.selectTemplate"),
4606
- onChange: function onChange(template) {
4607
- return handleTemplateChange(setFieldValue, template);
4608
- }
4609
- }), /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
4610
- required: true,
4611
- label: t("neetoMessageTemplate.api.endpoint"),
4612
- name: "endpoint",
4613
- placeholder: SAMPLE_URL
4614
- }), /*#__PURE__*/jsxRuntime.jsx(KeyValuePairs, {
4615
- label: t("neetoMessageTemplate.api.additionalData"),
4616
- name: "additionalData"
4617
- })]
4618
- })
4619
- }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
4620
- children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
4621
- isSubmitting: isSubmitting,
4622
- cancelButtonProps: {
4623
- onClick: onClose,
4624
- "data-cy": "api-template-cancel-button"
4625
- },
4626
- submitButtonProps: {
4627
- label: t("neetoMessageTemplate.template.send"),
4628
- "data-cy": "api-template-send-button"
4629
- }
4630
- })
4631
- })]
4632
- });
4633
- }
4634
- })]
4635
- });
4636
- };
4637
-
4638
- exports.ApiTemplates = ApiTemplates;
4639
- exports.MessageTemplates = MessageTemplates;
4640
- exports.SendMessagePane = SendMessagePane;
4641
- exports.SendToApiPane = SendToApiPane;
4642
- //# sourceMappingURL=index.cjs.js.map