@bigbinary/neeto-rules-frontend 2.6.3 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ var Header = require('@bigbinary/neeto-molecules/Header');
13
13
  var Spinner = require('@bigbinary/neetoui/Spinner');
14
14
  var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
15
15
  var reactI18next = require('react-i18next');
16
- var index = require('../index-C8o4tdnQ.js');
16
+ var index = require('../index-Df_k2p4V.js');
17
17
  var useCustomDataStore = require('../useCustomDataStore-DxFx8aCf.js');
18
18
  var useUtilityStore = require('../useUtilityStore-C_U20IMX.js');
19
19
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
@@ -30,9 +30,12 @@ var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
30
30
  var Search = require('@bigbinary/neeto-icons/Search');
31
31
  var Input = require('@bigbinary/neetoui/Input');
32
32
  var Typography = require('@bigbinary/neetoui/Typography');
33
+ var utils = require('@bigbinary/neeto-commons-frontend/utils');
33
34
  var Checkbox = require('@bigbinary/neetoui/Checkbox');
35
+ var DatePicker = require('@bigbinary/neetoui/DatePicker');
34
36
  var Radio = require('@bigbinary/neetoui/Radio');
35
37
  var Textarea = require('@bigbinary/neetoui/Textarea');
38
+ var utils$1 = require('../utils-B3roKiff.js');
36
39
  var Input$1 = require('@bigbinary/neetoui/formik/Input');
37
40
  var Select = require('@bigbinary/neetoui/formik/Select');
38
41
  var Select$1 = require('@bigbinary/neetoui/Select');
@@ -58,10 +61,6 @@ require('@monaco-editor/react');
58
61
  require('@bigbinary/neeto-icons/Help');
59
62
  require('@bigbinary/neeto-molecules/DynamicVariables');
60
63
  require('@bigbinary/neetoui/Label');
61
- require('@bigbinary/neeto-commons-frontend/utils');
62
- require('@bigbinary/neetoui/DatePicker');
63
- require('../utils-B3roKiff.js');
64
- require('@bigbinary/neeto-commons-frontend/initializers');
65
64
  require('@bigbinary/neetoui/formik/MultiEmailInput');
66
65
  require('@bigbinary/neeto-editor/FormikEditor');
67
66
  require('@bigbinary/neeto-icons/Refresh');
@@ -73,6 +72,7 @@ require('@bigbinary/neeto-molecules/PhoneNumber');
73
72
  require('@bigbinary/neetoui/Tag');
74
73
  require('react-select');
75
74
  require('../constants-BjXYr8nk.js');
75
+ require('@bigbinary/neeto-commons-frontend/initializers');
76
76
  require('@bigbinary/neetoui/TimePicker');
77
77
  require('@bigbinary/neeto-editor/utils');
78
78
  require('zustand');
@@ -171,7 +171,8 @@ var BUILDER_PANEL_TYPES = {
171
171
  DELAY: "builder-delay",
172
172
  LEAD_TIME: "builder-lead-time",
173
173
  NAME: "builder-name",
174
- SCOPE: "builder-scope"
174
+ SCOPE: "builder-scope",
175
+ SCOPE_PHONE_FIELD: "builder-scope-phone-field"
175
176
  };
176
177
  var BUILDER_ANCHORS = {
177
178
  TRIGGER_ADD: "trigger-add",
@@ -188,9 +189,10 @@ var BUILDER_ANCHORS = {
188
189
  ACTION_RECIPIENT: "action-recipient",
189
190
  RULE_DELAY: "rule-delay",
190
191
  META_NAME: "meta-name",
191
- SCOPE: "scope"
192
+ SCOPE: "scope",
193
+ SCOPE_PHONE_FIELD: "scope-phone-field"
192
194
  };
193
- var TOKEN_TO_PANEL_TYPE = (_TOKEN_TO_PANEL_TYPE = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.TRIGGER_ADD, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_REPLACE, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_ACTOR, BUILDER_PANEL_TYPES.ACTOR), BUILDER_ANCHORS.COND_FIELD, BUILDER_PANEL_TYPES.CONDITION_FIELD), BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_PANEL_TYPES.OPERATOR), BUILDER_ANCHORS.COND_CONNECTOR, BUILDER_PANEL_TYPES.CONNECTOR), BUILDER_ANCHORS.COND_VALUES, BUILDER_PANEL_TYPES.CONDITION_VALUE), BUILDER_ANCHORS.ACTION_ADD, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_PANEL_TYPES.ACTION_CONFIG), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_PANEL_TYPES.RECIPIENT), BUILDER_ANCHORS.RULE_DELAY, BUILDER_PANEL_TYPES.DELAY), BUILDER_ANCHORS.TRIGGER_LEAD_TIME, BUILDER_PANEL_TYPES.LEAD_TIME), BUILDER_ANCHORS.META_NAME, BUILDER_PANEL_TYPES.NAME), BUILDER_ANCHORS.SCOPE, BUILDER_PANEL_TYPES.SCOPE));
195
+ var TOKEN_TO_PANEL_TYPE = (_TOKEN_TO_PANEL_TYPE = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.TRIGGER_ADD, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_REPLACE, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_ACTOR, BUILDER_PANEL_TYPES.ACTOR), BUILDER_ANCHORS.COND_FIELD, BUILDER_PANEL_TYPES.CONDITION_FIELD), BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_PANEL_TYPES.OPERATOR), BUILDER_ANCHORS.COND_CONNECTOR, BUILDER_PANEL_TYPES.CONNECTOR), BUILDER_ANCHORS.COND_VALUES, BUILDER_PANEL_TYPES.CONDITION_VALUE), BUILDER_ANCHORS.ACTION_ADD, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_PANEL_TYPES.ACTION_CONFIG), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_PANEL_TYPES.RECIPIENT), BUILDER_ANCHORS.RULE_DELAY, BUILDER_PANEL_TYPES.DELAY), BUILDER_ANCHORS.TRIGGER_LEAD_TIME, BUILDER_PANEL_TYPES.LEAD_TIME), BUILDER_ANCHORS.META_NAME, BUILDER_PANEL_TYPES.NAME), BUILDER_ANCHORS.SCOPE, BUILDER_PANEL_TYPES.SCOPE), BUILDER_ANCHORS.SCOPE_PHONE_FIELD, BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD));
194
196
  var LARGE_PANEL_TYPES = [BUILDER_PANEL_TYPES.ACTION_CONFIG, BUILDER_PANEL_TYPES.SCOPE, BUILDER_PANEL_TYPES.NAME];
195
197
  var CONDITION_ANCHORS = [BUILDER_ANCHORS.COND_FIELD, BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_ANCHORS.COND_VALUES, BUILDER_ANCHORS.COND_CONNECTOR];
196
198
  var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT];
@@ -294,6 +296,9 @@ var isMultiValueVerb = function isMultiValueVerb(verb) {
294
296
  var sentencify = function sentencify(label) {
295
297
  return label ? label.charAt(0).toLowerCase() + label.slice(1) : label;
296
298
  };
299
+ var copyFor = function copyFor(value, args) {
300
+ return typeof value === "function" ? value(args) : value;
301
+ };
297
302
  var matchesTrigger = function matchesTrigger(name) {
298
303
  return function (option) {
299
304
  return option.eventValue === name || option.value === name || option.id === name;
@@ -457,24 +462,77 @@ var hasAction = function hasAction(rule) {
457
462
  var isRuleComplete = function isRuleComplete(rule) {
458
463
  return hasTrigger(rule) && hasAction(rule);
459
464
  };
460
- var invalidScopeIndexes = function invalidScopeIndexes(_ref12) {
465
+ var scopeOptionFor = function scopeOptionFor(_ref12) {
466
+ var _item$value, _schema$scope;
467
+ var schema = _ref12.schema,
468
+ item = _ref12.item;
469
+ var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
470
+ return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
471
+ var _candidate$value2;
472
+ return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
473
+ });
474
+ };
475
+ var scopePhoneFields = function scopePhoneFields(_ref13) {
476
+ var _ref14, _item$phoneFields, _scopeOptionFor;
477
+ var schema = _ref13.schema,
478
+ item = _ref13.item;
479
+ return (_ref14 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
480
+ schema: schema,
481
+ item: item
482
+ })) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref14 !== void 0 ? _ref14 : null;
483
+ };
484
+ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref15) {
485
+ var schema = _ref15.schema,
486
+ item = _ref15.item;
487
+ if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
488
+ var phoneFields = scopePhoneFields({
489
+ schema: schema,
490
+ item: item
491
+ });
492
+ return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
493
+ };
494
+ var invalidScopeIndexes = function invalidScopeIndexes(_ref16) {
461
495
  var _scope$requiresPhone;
462
- var rule = _ref12.rule,
463
- schema = _ref12.schema;
496
+ var rule = _ref16.rule,
497
+ schema = _ref16.schema;
464
498
  var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
465
499
  if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone = scope.requiresPhone) !== null && _scope$requiresPhone !== void 0 && _scope$requiresPhone.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
466
500
  return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
467
- var _item$value, _item$hasPhoneField;
468
- var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
469
- var option = (scope.options || []).find(function (candidate) {
470
- var _candidate$value2;
471
- return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
501
+ var _ref17, _item$hasPhoneField;
502
+ var option = scopeOptionFor({
503
+ schema: schema,
504
+ item: item
472
505
  });
473
- var hasPhoneField = (_item$hasPhoneField = item === null || item === void 0 ? void 0 : item.hasPhoneField) !== null && _item$hasPhoneField !== void 0 ? _item$hasPhoneField : option === null || option === void 0 ? void 0 : option.hasPhoneField;
506
+ var phoneFields = scopePhoneFields({
507
+ schema: schema,
508
+ item: item
509
+ });
510
+ var hasPhoneField = (_ref17 = (_item$hasPhoneField = item === null || item === void 0 ? void 0 : item.hasPhoneField) !== null && _item$hasPhoneField !== void 0 ? _item$hasPhoneField : option === null || option === void 0 ? void 0 : option.hasPhoneField) !== null && _ref17 !== void 0 ? _ref17 : phoneFields ? phoneFields.length > 0 : undefined;
474
511
  if (hasPhoneField === false) indexes.push(index);
475
512
  return indexes;
476
513
  }, []);
477
514
  };
515
+ var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref18) {
516
+ var _scope$requiresPhone2;
517
+ var rule = _ref18.rule,
518
+ schema = _ref18.schema;
519
+ var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
520
+ if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone2 = scope.requiresPhone) !== null && _scope$requiresPhone2 !== void 0 && _scope$requiresPhone2.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
521
+ return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
522
+ var phoneFields = scopePhoneFields({
523
+ schema: schema,
524
+ item: item
525
+ });
526
+ var hasChoice = ((phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) || 0) > 1;
527
+ if (hasChoice && !effectiveScopePhoneField({
528
+ schema: schema,
529
+ item: item
530
+ })) {
531
+ indexes.push(index);
532
+ }
533
+ return indexes;
534
+ }, []);
535
+ };
478
536
  var minutesToParts = function minutesToParts(minutes) {
479
537
  var total = Number(minutes) || 0;
480
538
  if (total && total % UNIT_MINUTES.days === 0) {
@@ -494,9 +552,9 @@ var minutesToParts = function minutesToParts(minutes) {
494
552
  unit: "minutes"
495
553
  };
496
554
  };
497
- var partsToMinutes = function partsToMinutes(_ref13) {
498
- var value = _ref13.value,
499
- unit = _ref13.unit;
555
+ var partsToMinutes = function partsToMinutes(_ref19) {
556
+ var value = _ref19.value,
557
+ unit = _ref19.unit;
500
558
  return (
501
559
  // eslint-disable-next-line security/detect-object-injection
502
560
  (Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
@@ -529,17 +587,17 @@ var modeFromJoinType = function modeFromJoinType(joinType) {
529
587
  };
530
588
 
531
589
  // eslint-disable-next-line security/detect-object-injection
532
- var valueAt = function valueAt(_ref14) {
590
+ var valueAt = function valueAt(_ref20) {
533
591
  var _values$key;
534
- var values = _ref14.values,
535
- key = _ref14.key;
592
+ var values = _ref20.values,
593
+ key = _ref20.key;
536
594
  return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
537
595
  };
538
596
  var asArray = function asArray(maybeArray) {
539
597
  return Array.isArray(maybeArray) ? maybeArray : [];
540
598
  };
541
599
  var fieldKeysFromSchema = function fieldKeysFromSchema() {
542
- var _schema$triggers2, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers3, _schema$scope;
600
+ var _schema$triggers2, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers3, _schema$scope2;
543
601
  var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
544
602
  return {
545
603
  triggers: ((_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.fieldKey) || "events",
@@ -548,18 +606,18 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
548
606
  actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
549
607
  delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
550
608
  leadTime: (_schema$triggers3 = schema.triggers) === null || _schema$triggers3 === void 0 || (_schema$triggers3 = _schema$triggers3.leadTime) === null || _schema$triggers3 === void 0 ? void 0 : _schema$triggers3.fieldKey,
551
- scope: ((_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.fieldKey) || "meetingIds",
609
+ scope: ((_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.fieldKey) || "meetingIds",
552
610
  status: "status",
553
611
  name: "name"
554
612
  };
555
613
  };
556
614
  var valuesToRuleModel = function valuesToRuleModel() {
557
615
  var _valueAt, _conditions$;
558
- var _ref15 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
559
- _ref15$values = _ref15.values,
560
- values = _ref15$values === void 0 ? {} : _ref15$values,
561
- _ref15$schema = _ref15.schema,
562
- schema = _ref15$schema === void 0 ? {} : _ref15$schema;
616
+ var _ref21 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
617
+ _ref21$values = _ref21.values,
618
+ values = _ref21$values === void 0 ? {} : _ref21$values,
619
+ _ref21$schema = _ref21.schema,
620
+ schema = _ref21$schema === void 0 ? {} : _ref21$schema;
563
621
  var keys = fieldKeysFromSchema(schema);
564
622
  var conditions = asArray(valueAt({
565
623
  values: values,
@@ -603,42 +661,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
603
661
  }))
604
662
  };
605
663
  };
606
- var setTriggers = function setTriggers(_ref16) {
607
- var schema = _ref16.schema,
608
- triggers = _ref16.triggers;
664
+ var setTriggers = function setTriggers(_ref22) {
665
+ var schema = _ref22.schema,
666
+ triggers = _ref22.triggers;
609
667
  return {
610
668
  path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
611
669
  value: triggers
612
670
  };
613
671
  };
614
- var setPerformer = function setPerformer(_ref17) {
615
- var schema = _ref17.schema,
616
- performer = _ref17.performer;
672
+ var setPerformer = function setPerformer(_ref23) {
673
+ var schema = _ref23.schema,
674
+ performer = _ref23.performer;
617
675
  return {
618
676
  path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
619
677
  value: performer
620
678
  };
621
679
  };
622
- var setActions = function setActions(_ref18) {
623
- var schema = _ref18.schema,
624
- actions = _ref18.actions;
680
+ var setActions = function setActions(_ref24) {
681
+ var schema = _ref24.schema,
682
+ actions = _ref24.actions;
625
683
  return {
626
684
  path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
627
685
  value: actions
628
686
  };
629
687
  };
630
- var setConditions = function setConditions(_ref19) {
631
- var schema = _ref19.schema,
632
- conditions = _ref19.conditions;
688
+ var setConditions = function setConditions(_ref25) {
689
+ var schema = _ref25.schema,
690
+ conditions = _ref25.conditions;
633
691
  return {
634
692
  path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
635
693
  value: conditions
636
694
  };
637
695
  };
638
- var setConditionMode = function setConditionMode(_ref20) {
639
- var schema = _ref20.schema,
640
- conditions = _ref20.conditions,
641
- joinType = _ref20.joinType;
696
+ var setConditionMode = function setConditionMode(_ref26) {
697
+ var schema = _ref26.schema,
698
+ conditions = _ref26.conditions,
699
+ joinType = _ref26.joinType;
642
700
  return setConditions({
643
701
  schema: schema,
644
702
  conditions: conditions.map(function (condition) {
@@ -646,34 +704,34 @@ var setConditionMode = function setConditionMode(_ref20) {
646
704
  })
647
705
  });
648
706
  };
649
- var setDelay = function setDelay(_ref21) {
650
- var schema = _ref21.schema,
651
- delay = _ref21.delay;
707
+ var setDelay = function setDelay(_ref27) {
708
+ var schema = _ref27.schema,
709
+ delay = _ref27.delay;
652
710
  return {
653
711
  path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
654
712
  value: delay !== null && delay !== void 0 ? delay : {}
655
713
  };
656
714
  };
657
- var setActive = function setActive(_ref22) {
658
- var schema = _ref22.schema,
659
- active = _ref22.active;
715
+ var setActive = function setActive(_ref28) {
716
+ var schema = _ref28.schema,
717
+ active = _ref28.active;
660
718
  return {
661
719
  path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
662
720
  value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
663
721
  };
664
722
  };
665
- var setScope = function setScope(_ref23) {
666
- var schema = _ref23.schema,
667
- scope = _ref23.scope;
723
+ var setScope = function setScope(_ref29) {
724
+ var schema = _ref29.schema,
725
+ scope = _ref29.scope;
668
726
  return {
669
727
  path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
670
728
  value: scope
671
729
  };
672
730
  };
673
- var removeArrayItem = function removeArrayItem(_ref24) {
674
- var values = _ref24.values,
675
- fieldKey = _ref24.fieldKey,
676
- index = _ref24.index;
731
+ var removeArrayItem = function removeArrayItem(_ref30) {
732
+ var values = _ref30.values,
733
+ fieldKey = _ref30.fieldKey,
734
+ index = _ref30.index;
677
735
  var list = asArray(valueAt({
678
736
  values: values,
679
737
  key: fieldKey
@@ -1033,7 +1091,7 @@ var itemLabel = function itemLabel(item) {
1033
1091
  return (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.value) || String(item !== null && item !== void 0 ? item : "");
1034
1092
  };
1035
1093
  var ScopeBlock = function ScopeBlock(_ref) {
1036
- var _schema$scope;
1094
+ var _schema$scope, _schema$scope2, _schema$scope2$requir;
1037
1095
  var rule = _ref.rule,
1038
1096
  schema = _ref.schema,
1039
1097
  handleToken = _ref.onToken,
@@ -1050,6 +1108,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1050
1108
  t = _useTranslation.t;
1051
1109
  var scope = rule.scope || [];
1052
1110
  var placeholder = (schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.placeholder) || t("neetoRules.builder.scope.placeholder");
1111
+ var requiresPhone = !!(schema !== null && schema !== void 0 && (_schema$scope2 = schema.scope) !== null && _schema$scope2 !== void 0 && (_schema$scope2$requir = _schema$scope2.requiresPhone) !== null && _schema$scope2$requir !== void 0 && _schema$scope2$requir.call(_schema$scope2, rule.actions || []));
1053
1112
  if (ramda.isEmpty(scope)) {
1054
1113
  return /*#__PURE__*/jsxRuntime.jsx("div", {
1055
1114
  className: "mb-row",
@@ -1079,6 +1138,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1079
1138
  isActive: isActive,
1080
1139
  isInvalid: isInvalid,
1081
1140
  item: item,
1141
+ requiresPhone: requiresPhone,
1082
1142
  schema: schema,
1083
1143
  isLast: index === scope.length - 1,
1084
1144
  key: ((_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item) || index,
@@ -1088,7 +1148,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1088
1148
  });
1089
1149
  };
1090
1150
  var ScopeRow = function ScopeRow(_ref2) {
1091
- var _schema$scope2;
1151
+ var _schema$scope3, _schema$scope4, _schema$scope5;
1092
1152
  var schema = _ref2.schema,
1093
1153
  item = _ref2.item,
1094
1154
  index = _ref2.index,
@@ -1096,13 +1156,30 @@ var ScopeRow = function ScopeRow(_ref2) {
1096
1156
  handleRemoveScope = _ref2.onRemoveScope,
1097
1157
  isActive = _ref2.isActive,
1098
1158
  isInvalid = _ref2.isInvalid,
1099
- isLast = _ref2.isLast;
1159
+ isLast = _ref2.isLast,
1160
+ requiresPhone = _ref2.requiresPhone;
1100
1161
  var _useTranslation2 = reactI18next.useTranslation(),
1101
1162
  t = _useTranslation2.t;
1102
1163
  var _useClearingHover = useClearingHover(),
1103
1164
  clearing = _useClearingHover.clearing,
1104
1165
  clearingHoverProps = _useClearingHover.clearingHoverProps;
1105
- var lead = (schema === null || schema === void 0 || (_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.lead) || t("neetoRules.builder.scope.lead");
1166
+ var lead = (schema === null || schema === void 0 || (_schema$scope3 = schema.scope) === null || _schema$scope3 === void 0 ? void 0 : _schema$scope3.lead) || t("neetoRules.builder.scope.lead");
1167
+ var meeting = itemLabel(item);
1168
+ var phoneFields = requiresPhone ? scopePhoneFields({
1169
+ item: item,
1170
+ schema: schema
1171
+ }) : null;
1172
+ var hasPhoneFieldChoice = ((phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) || 0) > 1;
1173
+ var singlePhoneFieldLabel = (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].label : null;
1174
+ var selectedPhoneField = phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.find(function (field) {
1175
+ return field.value === (item === null || item === void 0 ? void 0 : item.phoneField);
1176
+ });
1177
+ var usingLabel = copyFor(schema === null || schema === void 0 || (_schema$scope4 = schema.scope) === null || _schema$scope4 === void 0 ? void 0 : _schema$scope4.usingLabel, {
1178
+ meeting: meeting
1179
+ }) || t("neetoRules.builder.scope.using");
1180
+ var phoneFieldPlaceholder = copyFor(schema === null || schema === void 0 || (_schema$scope5 = schema.scope) === null || _schema$scope5 === void 0 ? void 0 : _schema$scope5.phoneFieldPlaceholder, {
1181
+ meeting: meeting
1182
+ }) || t("neetoRules.builder.selectPhoneField");
1106
1183
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1107
1184
  className: classNames("mb-row", {
1108
1185
  clearing: clearing
@@ -1127,7 +1204,33 @@ var ScopeRow = function ScopeRow(_ref2) {
1127
1204
  type: BUILDER_ANCHORS.SCOPE
1128
1205
  });
1129
1206
  },
1130
- children: itemLabel(item)
1207
+ children: meeting
1208
+ }), singlePhoneFieldLabel && /*#__PURE__*/jsxRuntime.jsxs("span", {
1209
+ className: "mb-fixed",
1210
+ children: [usingLabel, " ", singlePhoneFieldLabel]
1211
+ }), hasPhoneFieldChoice && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1212
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
1213
+ className: "mb-fixed",
1214
+ children: usingLabel
1215
+ }), /*#__PURE__*/jsxRuntime.jsx(Token, {
1216
+ dataTestid: "scope-phone-field-".concat(index),
1217
+ active: isActive({
1218
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1219
+ index: index
1220
+ }),
1221
+ invalid: isInvalid({
1222
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1223
+ index: index
1224
+ }),
1225
+ state: selectedPhoneField ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
1226
+ onClick: handleToken && function () {
1227
+ return handleToken({
1228
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1229
+ index: index
1230
+ });
1231
+ },
1232
+ children: (selectedPhoneField === null || selectedPhoneField === void 0 ? void 0 : selectedPhoneField.label) || phoneFieldPlaceholder
1233
+ })]
1131
1234
  })]
1132
1235
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1133
1236
  className: "mb-row-actions",
@@ -1788,47 +1891,58 @@ var actionAt = function actionAt(_ref3) {
1788
1891
  index = _ref3.index;
1789
1892
  return rule.actions[index] || {};
1790
1893
  };
1791
- var findField = function findField(_ref4) {
1894
+
1895
+ // eslint-disable-next-line security/detect-object-injection
1896
+ var scopeItemAt = function scopeItemAt(_ref4) {
1897
+ var _rule$scope;
1898
+ var rule = _ref4.rule,
1899
+ index = _ref4.index;
1900
+ return ((_rule$scope = rule.scope) === null || _rule$scope === void 0 ? void 0 : _rule$scope[index]) || {};
1901
+ };
1902
+ var scopeItemLabel = function scopeItemLabel(item) {
1903
+ return (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.value) || String(item !== null && item !== void 0 ? item : "");
1904
+ };
1905
+ var findField = function findField(_ref5) {
1792
1906
  var _schema$conditions;
1793
- var schema = _ref4.schema,
1794
- value = _ref4.value;
1907
+ var schema = _ref5.schema,
1908
+ value = _ref5.value;
1795
1909
  return (((_schema$conditions = schema.conditions) === null || _schema$conditions === void 0 ? void 0 : _schema$conditions.fields) || []).find(function (field) {
1796
1910
  return optionValue(field) === value;
1797
1911
  });
1798
1912
  };
1799
- var findActionOption = function findActionOption(_ref5) {
1913
+ var findActionOption = function findActionOption(_ref6) {
1800
1914
  var _schema$actions;
1801
- var schema = _ref5.schema,
1802
- name = _ref5.name;
1915
+ var schema = _ref6.schema,
1916
+ name = _ref6.name;
1803
1917
  return (((_schema$actions = schema.actions) === null || _schema$actions === void 0 ? void 0 : _schema$actions.options) || []).find(function (option) {
1804
1918
  return optionValue(option) === name;
1805
1919
  });
1806
1920
  };
1807
- var channelOf = function channelOf(_ref6) {
1921
+ var channelOf = function channelOf(_ref7) {
1808
1922
  var _schema$actions2, _schema$actions2$acti;
1809
- var schema = _ref6.schema,
1810
- action = _ref6.action;
1923
+ var schema = _ref7.schema,
1924
+ action = _ref7.action;
1811
1925
  return (action === null || action === void 0 ? void 0 : action.channel) || ((_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$acti = _schema$actions2.actionForName) === null || _schema$actions2$acti === void 0 || (_schema$actions2$acti = _schema$actions2$acti.call(_schema$actions2, action === null || action === void 0 ? void 0 : action.name)) === null || _schema$actions2$acti === void 0 ? void 0 : _schema$actions2$acti.channel);
1812
1926
  };
1813
- var recipientOf = function recipientOf(_ref7) {
1927
+ var recipientOf = function recipientOf(_ref8) {
1814
1928
  var _action$recipient, _schema$actions3, _schema$actions3$acti;
1815
- var schema = _ref7.schema,
1816
- action = _ref7.action;
1929
+ var schema = _ref8.schema,
1930
+ action = _ref8.action;
1817
1931
  return (_action$recipient = action === null || action === void 0 ? void 0 : action.recipient) !== null && _action$recipient !== void 0 ? _action$recipient : (_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3$acti = _schema$actions3.actionForName) === null || _schema$actions3$acti === void 0 || (_schema$actions3$acti = _schema$actions3$acti.call(_schema$actions3, action === null || action === void 0 ? void 0 : action.name)) === null || _schema$actions3$acti === void 0 ? void 0 : _schema$actions3$acti.recipient;
1818
1932
  };
1819
- var channelMetaOf = function channelMetaOf(_ref8) {
1933
+ var channelMetaOf = function channelMetaOf(_ref9) {
1820
1934
  var _schema$actions4;
1821
- var schema = _ref8.schema,
1822
- action = _ref8.action;
1935
+ var schema = _ref9.schema,
1936
+ action = _ref9.action;
1823
1937
  return ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4 = _schema$actions4.channelMeta) === null || _schema$actions4 === void 0 ? void 0 : _schema$actions4[channelOf({
1824
1938
  schema: schema,
1825
1939
  action: action
1826
1940
  })]) || {};
1827
1941
  };
1828
- var actionHasConfig = function actionHasConfig(_ref9) {
1942
+ var actionHasConfig = function actionHasConfig(_ref0) {
1829
1943
  var _schema$actions5, _schema$actions6;
1830
- var schema = _ref9.schema,
1831
- action = _ref9.action;
1944
+ var schema = _ref0.schema,
1945
+ action = _ref0.action;
1832
1946
  var meta = channelMetaOf({
1833
1947
  schema: schema,
1834
1948
  action: action
@@ -1842,10 +1956,10 @@ var actionHasConfig = function actionHasConfig(_ref9) {
1842
1956
  if ((_schema$actions5 = schema.actions) !== null && _schema$actions5 !== void 0 && _schema$actions5.hasConfig) return schema.actions.hasConfig(action);
1843
1957
  return !!((_schema$actions6 = schema.actions) !== null && _schema$actions6 !== void 0 && _schema$actions6.renderConfig);
1844
1958
  };
1845
- var recipientsFor = function recipientsFor(_ref0) {
1959
+ var recipientsFor = function recipientsFor(_ref1) {
1846
1960
  var _schema$actions7, _schema$actions8;
1847
- var schema = _ref0.schema,
1848
- action = _ref0.action;
1961
+ var schema = _ref1.schema,
1962
+ action = _ref1.action;
1849
1963
  var channel = channelOf({
1850
1964
  schema: schema,
1851
1965
  action: action
@@ -1860,11 +1974,11 @@ var recipientsFor = function recipientsFor(_ref0) {
1860
1974
  if (option !== null && option !== void 0 && option.recipients) return option.recipients;
1861
1975
  return ((_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 ? void 0 : _schema$actions8.recipients) || [];
1862
1976
  };
1863
- var nextTriggers = function nextTriggers(_ref1) {
1977
+ var nextTriggers = function nextTriggers(_ref10) {
1864
1978
  var _schema$triggers;
1865
- var schema = _ref1.schema,
1866
- rule = _ref1.rule,
1867
- value = _ref1.value;
1979
+ var schema = _ref10.schema,
1980
+ rule = _ref10.rule,
1981
+ value = _ref10.value;
1868
1982
  if ((_schema$triggers = schema.triggers) !== null && _schema$triggers !== void 0 && _schema$triggers.multi) {
1869
1983
  var names = ramda.pluck("name", rule.triggers);
1870
1984
  return names.includes(value) ? neetoCist.removeBy({
@@ -1877,12 +1991,12 @@ var nextTriggers = function nextTriggers(_ref1) {
1877
1991
  name: value
1878
1992
  }];
1879
1993
  };
1880
- var nextConditionAt = function nextConditionAt(_ref10) {
1994
+ var nextConditionAt = function nextConditionAt(_ref11) {
1881
1995
  var _field$allowMatching;
1882
- var schema = _ref10.schema,
1883
- rule = _ref10.rule,
1884
- index = _ref10.index,
1885
- value = _ref10.value;
1996
+ var schema = _ref11.schema,
1997
+ rule = _ref11.rule,
1998
+ index = _ref11.index,
1999
+ value = _ref11.value;
1886
2000
  var field = findField({
1887
2001
  schema: schema,
1888
2002
  value: value
@@ -1901,12 +2015,12 @@ var nextConditionAt = function nextConditionAt(_ref10) {
1901
2015
  metadata: {}
1902
2016
  });
1903
2017
  };
1904
- var nextActionAt = function nextActionAt(_ref11) {
2018
+ var nextActionAt = function nextActionAt(_ref12) {
1905
2019
  var _schema$actions9;
1906
- var schema = _ref11.schema,
1907
- rule = _ref11.rule,
1908
- index = _ref11.index,
1909
- value = _ref11.value;
2020
+ var schema = _ref12.schema,
2021
+ rule = _ref12.rule,
2022
+ index = _ref12.index,
2023
+ value = _ref12.value;
1910
2024
  if (!((_schema$actions9 = schema.actions) !== null && _schema$actions9 !== void 0 && _schema$actions9.resolveName)) {
1911
2025
  var option = findActionOption({
1912
2026
  schema: schema,
@@ -1964,12 +2078,33 @@ var nextActionAt = function nextActionAt(_ref11) {
1964
2078
  metadata: channelChanged ? {} : prev.metadata
1965
2079
  });
1966
2080
  };
1967
- var nextActionRecipientAt = function nextActionRecipientAt(_ref12) {
2081
+ var appendScopeItem = function appendScopeItem(_ref13) {
2082
+ var _sc$requiresPhone;
2083
+ var schema = _ref13.schema,
2084
+ rule = _ref13.rule,
2085
+ value = _ref13.value;
2086
+ var sc = schema.scope || {};
2087
+ var option = (sc.options || []).find(function (candidate) {
2088
+ return optionValue(candidate) === value;
2089
+ }) || {
2090
+ value: value
2091
+ };
2092
+ var requiresPhone = ((_sc$requiresPhone = sc.requiresPhone) === null || _sc$requiresPhone === void 0 ? void 0 : _sc$requiresPhone.call(sc, rule.actions)) || false;
2093
+ if (!requiresPhone) return option;
2094
+ var phoneFields = scopePhoneFields({
2095
+ schema: schema,
2096
+ item: option
2097
+ });
2098
+ return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? _objectSpread$4(_objectSpread$4({}, option), {}, {
2099
+ phoneField: phoneFields[0].value
2100
+ }) : option;
2101
+ };
2102
+ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
1968
2103
  var _schema$actions1;
1969
- var schema = _ref12.schema,
1970
- rule = _ref12.rule,
1971
- index = _ref12.index,
1972
- value = _ref12.value;
2104
+ var schema = _ref14.schema,
2105
+ rule = _ref14.rule,
2106
+ index = _ref14.index,
2107
+ value = _ref14.value;
1973
2108
  var prev = actionAt({
1974
2109
  rule: rule,
1975
2110
  index: index
@@ -1986,12 +2121,12 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref12) {
1986
2121
  }) : value
1987
2122
  });
1988
2123
  };
1989
- var descriptorFor = function descriptorFor(_ref13) {
2124
+ var descriptorFor = function descriptorFor(_ref15) {
1990
2125
  var _schema$actor2, _schema$conditions2;
1991
- var anchor = _ref13.anchor,
1992
- schema = _ref13.schema,
1993
- rule = _ref13.rule,
1994
- index = _ref13.index;
2126
+ var anchor = _ref15.anchor,
2127
+ schema = _ref15.schema,
2128
+ rule = _ref15.rule,
2129
+ index = _ref15.index;
1995
2130
  switch (anchor) {
1996
2131
  case BUILDER_ANCHORS.TRIGGER_ADD:
1997
2132
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2181,13 +2316,13 @@ var descriptorFor = function descriptorFor(_ref13) {
2181
2316
  }
2182
2317
  case BUILDER_ANCHORS.SCOPE:
2183
2318
  {
2184
- var _sc$requiresPhone;
2319
+ var _sc$requiresPhone2;
2185
2320
  var sc = schema.scope || {};
2186
2321
  var selected = (rule.scope || []).map(function (item) {
2187
2322
  var _item$value;
2188
2323
  return (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
2189
2324
  });
2190
- var requiresPhone = ((_sc$requiresPhone = sc.requiresPhone) === null || _sc$requiresPhone === void 0 ? void 0 : _sc$requiresPhone.call(sc, rule.actions)) || false;
2325
+ var requiresPhone = ((_sc$requiresPhone2 = sc.requiresPhone) === null || _sc$requiresPhone2 === void 0 ? void 0 : _sc$requiresPhone2.call(sc, rule.actions)) || false;
2191
2326
  return {
2192
2327
  title: selected.length ? sc.paneChangeTitle || i18next.t("neetoRules.builder.panes.scopeChangeTitle") : sc.paneTitle || i18next.t("neetoRules.builder.panes.scopeTitle"),
2193
2328
  subtitle: sc.paneSubtitle || i18next.t("neetoRules.builder.panes.scopeSubtitle"),
@@ -2207,6 +2342,36 @@ var descriptorFor = function descriptorFor(_ref13) {
2207
2342
  selectedValues: selected
2208
2343
  };
2209
2344
  }
2345
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2346
+ {
2347
+ var _sc = schema.scope || {};
2348
+ var item = scopeItemAt({
2349
+ rule: rule,
2350
+ index: index
2351
+ });
2352
+ var meeting = scopeItemLabel(item);
2353
+ var options = scopePhoneFields({
2354
+ schema: schema,
2355
+ item: item
2356
+ }) || [];
2357
+ return {
2358
+ title: copyFor(_sc.phoneFieldPaneTitle, {
2359
+ meeting: meeting
2360
+ }) || i18next.t("neetoRules.builder.panes.phoneFieldTitle"),
2361
+ subtitle: copyFor(_sc.phoneFieldPaneSubtitle, {
2362
+ meeting: meeting
2363
+ }) || i18next.t("neetoRules.builder.panes.phoneFieldSubtitle", {
2364
+ meeting: meeting
2365
+ }),
2366
+ options: options.map(function (option) {
2367
+ return {
2368
+ label: option.label,
2369
+ value: optionValue(option)
2370
+ };
2371
+ }),
2372
+ selectedValues: [item.phoneField]
2373
+ };
2374
+ }
2210
2375
  default:
2211
2376
  return {
2212
2377
  title: "",
@@ -2216,13 +2381,13 @@ var descriptorFor = function descriptorFor(_ref13) {
2216
2381
  };
2217
2382
  }
2218
2383
  };
2219
- var commitFor = function commitFor(_ref14) {
2220
- var anchor = _ref14.anchor,
2221
- schema = _ref14.schema,
2222
- rule = _ref14.rule,
2223
- index = _ref14.index,
2224
- value = _ref14.value,
2225
- helpers = _ref14.helpers;
2384
+ var commitFor = function commitFor(_ref16) {
2385
+ var anchor = _ref16.anchor,
2386
+ schema = _ref16.schema,
2387
+ rule = _ref16.rule,
2388
+ index = _ref16.index,
2389
+ value = _ref16.value,
2390
+ helpers = _ref16.helpers;
2226
2391
  var setTriggers = helpers.setTriggers,
2227
2392
  setPerformer = helpers.setPerformer,
2228
2393
  setConditionMode = helpers.setConditionMode,
@@ -2295,8 +2460,7 @@ var commitFor = function commitFor(_ref14) {
2295
2460
  }
2296
2461
  case BUILDER_ANCHORS.SCOPE:
2297
2462
  {
2298
- var sc = schema.scope || {};
2299
- var key = sc.fieldKey || "scope";
2463
+ var key = fieldKeys.scope;
2300
2464
  var current = rule.scope || [];
2301
2465
  var has = current.some(function (item) {
2302
2466
  var _item$value2;
@@ -2305,24 +2469,30 @@ var commitFor = function commitFor(_ref14) {
2305
2469
  var next = has ? current.filter(function (item) {
2306
2470
  var _item$value3;
2307
2471
  return ((_item$value3 = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value3 !== void 0 ? _item$value3 : item) !== value;
2308
- }) : [].concat(_toConsumableArray(current), [(sc.options || []).find(function (option) {
2309
- return optionValue(option) === value;
2310
- }) || {
2472
+ }) : [].concat(_toConsumableArray(current), [appendScopeItem({
2473
+ schema: schema,
2474
+ rule: rule,
2311
2475
  value: value
2312
- }]);
2476
+ })]);
2313
2477
  setFieldValue("".concat(key, ".value"), next);
2314
2478
  return "stay";
2315
2479
  }
2480
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2481
+ {
2482
+ var _key = fieldKeys.scope;
2483
+ setFieldValue("".concat(_key, ".value.").concat(index, ".phoneField"), value);
2484
+ return "stay";
2485
+ }
2316
2486
  default:
2317
2487
  return "close";
2318
2488
  }
2319
2489
  };
2320
- var continueTargetFor = function continueTargetFor(_ref15) {
2490
+ var continueTargetFor = function continueTargetFor(_ref17) {
2321
2491
  var _schema$actor3;
2322
- var anchor = _ref15.anchor,
2323
- schema = _ref15.schema,
2324
- rule = _ref15.rule,
2325
- index = _ref15.index;
2492
+ var anchor = _ref17.anchor,
2493
+ schema = _ref17.schema,
2494
+ rule = _ref17.rule,
2495
+ index = _ref17.index;
2326
2496
  switch (anchor) {
2327
2497
  case BUILDER_ANCHORS.TRIGGER_ADD:
2328
2498
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2395,21 +2565,21 @@ var continueTargetFor = function continueTargetFor(_ref15) {
2395
2565
  return null;
2396
2566
  }
2397
2567
  };
2398
- var replaceAt = function replaceAt(_ref16) {
2399
- var list = _ref16.list,
2400
- index = _ref16.index,
2401
- item = _ref16.item;
2568
+ var replaceAt = function replaceAt(_ref18) {
2569
+ var list = _ref18.list,
2570
+ index = _ref18.index,
2571
+ item = _ref18.item;
2402
2572
  var next = _toConsumableArray(list);
2403
2573
  // eslint-disable-next-line security/detect-object-injection
2404
2574
  next[index] = item;
2405
2575
  return next;
2406
2576
  };
2407
- var applyPreview = function applyPreview(_ref17) {
2408
- var rule = _ref17.rule,
2409
- schema = _ref17.schema,
2410
- anchor = _ref17.anchor,
2411
- index = _ref17.index,
2412
- value = _ref17.value;
2577
+ var applyPreview = function applyPreview(_ref19) {
2578
+ var rule = _ref19.rule,
2579
+ schema = _ref19.schema,
2580
+ anchor = _ref19.anchor,
2581
+ index = _ref19.index,
2582
+ value = _ref19.value;
2413
2583
  switch (anchor) {
2414
2584
  case BUILDER_ANCHORS.TRIGGER_ADD:
2415
2585
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2485,6 +2655,19 @@ var applyPreview = function applyPreview(_ref17) {
2485
2655
  })
2486
2656
  })
2487
2657
  });
2658
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2659
+ return _objectSpread$4(_objectSpread$4({}, rule), {}, {
2660
+ scope: replaceAt({
2661
+ list: rule.scope,
2662
+ index: index,
2663
+ item: _objectSpread$4(_objectSpread$4({}, scopeItemAt({
2664
+ rule: rule,
2665
+ index: index
2666
+ })), {}, {
2667
+ phoneField: value
2668
+ })
2669
+ })
2670
+ });
2488
2671
  default:
2489
2672
  return rule;
2490
2673
  }
@@ -2550,6 +2733,9 @@ var Canvas = function Canvas(_ref) {
2550
2733
  if (ramda.isEmpty(flatErrors) && isRuleComplete(rule) && ramda.isEmpty(invalidScopeIndexes({
2551
2734
  rule: rule,
2552
2735
  schema: schema
2736
+ })) && ramda.isEmpty(invalidScopePhoneFieldIndexes({
2737
+ rule: rule,
2738
+ schema: schema
2553
2739
  }))) {
2554
2740
  return undefined;
2555
2741
  }
@@ -2642,6 +2828,11 @@ var Canvas = function Canvas(_ref) {
2642
2828
  rule: rule,
2643
2829
  schema: schema
2644
2830
  }).includes(index);
2831
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2832
+ return invalidScopePhoneFieldIndexes({
2833
+ rule: rule,
2834
+ schema: schema
2835
+ }).includes(index);
2645
2836
  case BUILDER_ANCHORS.META_NAME:
2646
2837
  return hasErrorAt({
2647
2838
  prefix: "".concat(fieldKeys.name, ".value")
@@ -2694,7 +2885,11 @@ var Canvas = function Canvas(_ref) {
2694
2885
  var isScopeComplete = !(schema !== null && schema !== void 0 && (_schema$scope2 = schema.scope) !== null && _schema$scope2 !== void 0 && _schema$scope2.enabled) || neetoCist.isNotEmpty(rule.scope || []);
2695
2886
  var isComplete = isRuleComplete(rule) && isScopeComplete;
2696
2887
  var handleRemoveScope = function handleRemoveScope(index) {
2697
- return setScope((rule.scope || []).filter(function (_, i) {
2888
+ closePaneIfTargeting({
2889
+ anchors: [BUILDER_ANCHORS.SCOPE_PHONE_FIELD],
2890
+ index: index
2891
+ });
2892
+ setScope((rule.scope || []).filter(function (_, i) {
2698
2893
  return i !== index;
2699
2894
  }));
2700
2895
  };
@@ -2843,6 +3038,25 @@ var Canvas = function Canvas(_ref) {
2843
3038
  });
2844
3039
  };
2845
3040
 
3041
+ var ACTION_CONFIG_TYPES = {
3042
+ emailChannel: "emailChannel",
3043
+ multiSelect: "multiSelect",
3044
+ dropdown: "dropdown",
3045
+ note: "note",
3046
+ textarea: "textarea",
3047
+ number: "number",
3048
+ text: "text",
3049
+ regex: "regex",
3050
+ decimal: "decimal",
3051
+ date: "date"
3052
+ };
3053
+ var CONDITION_VALUE_TYPES = {
3054
+ multiSelect: "multi-select",
3055
+ multiSelectCreate: "multi-select-create",
3056
+ number: "number",
3057
+ email: "email"
3058
+ };
3059
+
2846
3060
  var restoreTokens = function restoreTokens(text) {
2847
3061
  return text ? text.replace(/\[\[/g, "{{").replace(/\]\]/g, "}}") : text;
2848
3062
  };
@@ -2892,7 +3106,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2892
3106
  className: "mb-pane-empty",
2893
3107
  children: t("neetoRules.builder.noMatches")
2894
3108
  });
2895
- if (type === "emailChannel") {
3109
+ if (type === ACTION_CONFIG_TYPES.emailChannel) {
2896
3110
  var _getIn, _action$metadata;
2897
3111
  var subjectPath = "".concat(name, ".subject");
2898
3112
  var bodyPath = "".concat(name, ".body");
@@ -2921,7 +3135,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2921
3135
  }), hintBlock]
2922
3136
  });
2923
3137
  }
2924
- if (type === "multiSelect") {
3138
+ if (type === ACTION_CONFIG_TYPES.multiSelect) {
2925
3139
  if (ramda.isEmpty(options)) return noOptionsMessage();
2926
3140
  var current = formik.getIn(values, valuePath) || [];
2927
3141
  var filtered = filterOptions(options);
@@ -2946,7 +3160,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2946
3160
  })]
2947
3161
  });
2948
3162
  }
2949
- if (type === "dropdown") {
3163
+ if (type === ACTION_CONFIG_TYPES.dropdown) {
2950
3164
  if (ramda.isEmpty(options)) return noOptionsMessage();
2951
3165
  var _current = formik.getIn(values, valuePath);
2952
3166
  var _filtered = filterOptions(options);
@@ -2972,7 +3186,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2972
3186
  })
2973
3187
  });
2974
3188
  }
2975
- if (type === "note") {
3189
+ if (type === ACTION_CONFIG_TYPES.note) {
2976
3190
  var _action$metadata2;
2977
3191
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
2978
3192
  className: "flex flex-col gap-2",
@@ -2986,9 +3200,9 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2986
3200
  }), hintBlock]
2987
3201
  });
2988
3202
  }
2989
- if (type === "textarea" || type === "number") {
3203
+ if (type === ACTION_CONFIG_TYPES.textarea || type === ACTION_CONFIG_TYPES.number) {
2990
3204
  var _getIn2, _getIn3;
2991
- return type === "number" ? /*#__PURE__*/jsxRuntime.jsx(Input, {
3205
+ return type === ACTION_CONFIG_TYPES.number ? /*#__PURE__*/jsxRuntime.jsx(Input, {
2992
3206
  required: true,
2993
3207
  error: fieldError(valuePath),
2994
3208
  label: t("neetoRules.builder.config.value"),
@@ -3016,6 +3230,46 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
3016
3230
  }
3017
3231
  });
3018
3232
  }
3233
+ if (type === ACTION_CONFIG_TYPES.text || type === ACTION_CONFIG_TYPES.regex || type === ACTION_CONFIG_TYPES.decimal) {
3234
+ var _getIn4;
3235
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
3236
+ className: "flex flex-col gap-2",
3237
+ children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
3238
+ required: true,
3239
+ error: fieldError(valuePath),
3240
+ label: t("neetoRules.builder.config.value"),
3241
+ placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
3242
+ size: "large",
3243
+ value: (_getIn4 = formik.getIn(values, valuePath)) !== null && _getIn4 !== void 0 ? _getIn4 : "",
3244
+ onBlur: function onBlur() {
3245
+ return setFieldTouched(valuePath, true);
3246
+ },
3247
+ onChange: function onChange(event) {
3248
+ return setFieldValue(valuePath, event.target.value);
3249
+ }
3250
+ }), hintBlock]
3251
+ });
3252
+ }
3253
+ if (type === ACTION_CONFIG_TYPES.date) {
3254
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
3255
+ className: "flex flex-col gap-2",
3256
+ children: [/*#__PURE__*/jsxRuntime.jsx(DatePicker, {
3257
+ required: true,
3258
+ error: fieldError(valuePath),
3259
+ label: t("neetoRules.builder.config.value"),
3260
+ type: "date",
3261
+ value: formik.getIn(values, valuePath) || "",
3262
+ onBlur: function onBlur() {
3263
+ return setFieldTouched(valuePath, true);
3264
+ },
3265
+ onChange: function onChange(date) {
3266
+ return setFieldValue(valuePath,
3267
+ // eslint-disable-next-line @bigbinary/neeto/use-standard-date-time-formats
3268
+ date ? utils.dayjs(date).format(utils$1.DATE_FORMAT) : "");
3269
+ }
3270
+ }), hintBlock]
3271
+ });
3272
+ }
3019
3273
  return /*#__PURE__*/jsxRuntime.jsx(Typography, {
3020
3274
  style: "body2",
3021
3275
  children: t("neetoRules.builder.noConfig")
@@ -3995,7 +4249,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
3995
4249
  className: "mb-pane-empty",
3996
4250
  children: t("neetoRules.builder.noMatches")
3997
4251
  });
3998
- if (type === "multi-select" && neetoCist.isNotEmpty(enumOptions)) {
4252
+ if (type === CONDITION_VALUE_TYPES.multiSelect && neetoCist.isNotEmpty(enumOptions)) {
3999
4253
  var current = formik.getIn(values, valuesPath) || [];
4000
4254
  var filtered = filterOptions(enumOptions);
4001
4255
  if (term && ramda.isEmpty(filtered)) return noMatches;
@@ -4019,7 +4273,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
4019
4273
  })]
4020
4274
  });
4021
4275
  }
4022
- if (type === "multi-select") {
4276
+ if (type === CONDITION_VALUE_TYPES.multiSelect) {
4023
4277
  return /*#__PURE__*/jsxRuntime.jsx(Typography, {
4024
4278
  className: "neeto-ui-text-gray-500",
4025
4279
  style: "body2",
@@ -4028,7 +4282,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
4028
4282
  }) : t("neetoRules.builder.config.noOptions")
4029
4283
  });
4030
4284
  }
4031
- if (type === "multi-select-create") {
4285
+ if (type === CONDITION_VALUE_TYPES.multiSelectCreate) {
4032
4286
  var _current = formik.getIn(values, valuesPath) || [];
4033
4287
  return /*#__PURE__*/jsxRuntime.jsx(Select$1, {
4034
4288
  autoFocus: true,
@@ -4070,7 +4324,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
4070
4324
  })
4071
4325
  });
4072
4326
  }
4073
- if (valueType === "number") {
4327
+ if (valueType === CONDITION_VALUE_TYPES.number) {
4074
4328
  var _getIn;
4075
4329
  return /*#__PURE__*/jsxRuntime.jsx(Input, {
4076
4330
  autoFocus: true,
@@ -4094,8 +4348,8 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
4094
4348
  label: t("neetoRules.common.value"),
4095
4349
  name: valuePath,
4096
4350
  size: "large",
4097
- type: valueType === "email" ? "email" : "text",
4098
- placeholder: (field === null || field === void 0 ? void 0 : field.placeholder) || (valueType === "email" ? t("neetoRules.builder.config.exampleEmail") : undefined)
4351
+ type: valueType === CONDITION_VALUE_TYPES.email ? "email" : "text",
4352
+ placeholder: (field === null || field === void 0 ? void 0 : field.placeholder) || (valueType === CONDITION_VALUE_TYPES.email ? t("neetoRules.builder.config.exampleEmail") : undefined)
4099
4353
  });
4100
4354
  };
4101
4355
 
@@ -4198,12 +4452,14 @@ var BUILDER_PANEL_TYPE_CONFIG_MAP = (_BUILDER_PANEL_TYPE_C = {}, _defineProperty
4198
4452
  component: ConfigPane
4199
4453
  }), BUILDER_PANEL_TYPES.DELAY, {
4200
4454
  component: DelayPane
4201
- }), _defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.LEAD_TIME, {
4455
+ }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.LEAD_TIME, {
4202
4456
  component: LeadTimePane
4203
4457
  }), BUILDER_PANEL_TYPES.NAME, {
4204
4458
  component: NamePane
4205
4459
  }), BUILDER_PANEL_TYPES.SCOPE, {
4206
4460
  component: OptionsPane
4461
+ }), BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD, {
4462
+ component: OptionsPane
4207
4463
  }));
4208
4464
 
4209
4465
  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; }
@@ -4282,6 +4538,9 @@ var Form = function Form(_ref) {
4282
4538
  if (!isRuleComplete(rule) || invalidScopeIndexes({
4283
4539
  rule: rule,
4284
4540
  schema: schema
4541
+ }).length || invalidScopePhoneFieldIndexes({
4542
+ rule: rule,
4543
+ schema: schema
4285
4544
  }).length) {
4286
4545
  formikBag.setSubmitting(false);
4287
4546
  return;