@bigbinary/neeto-rules-frontend 2.6.2 → 2.7.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.
@@ -169,7 +169,8 @@ var BUILDER_PANEL_TYPES = {
169
169
  DELAY: "builder-delay",
170
170
  LEAD_TIME: "builder-lead-time",
171
171
  NAME: "builder-name",
172
- SCOPE: "builder-scope"
172
+ SCOPE: "builder-scope",
173
+ SCOPE_PHONE_FIELD: "builder-scope-phone-field"
173
174
  };
174
175
  var BUILDER_ANCHORS = {
175
176
  TRIGGER_ADD: "trigger-add",
@@ -186,9 +187,10 @@ var BUILDER_ANCHORS = {
186
187
  ACTION_RECIPIENT: "action-recipient",
187
188
  RULE_DELAY: "rule-delay",
188
189
  META_NAME: "meta-name",
189
- SCOPE: "scope"
190
+ SCOPE: "scope",
191
+ SCOPE_PHONE_FIELD: "scope-phone-field"
190
192
  };
191
- 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));
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(_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));
192
194
  var LARGE_PANEL_TYPES = [BUILDER_PANEL_TYPES.ACTION_CONFIG, BUILDER_PANEL_TYPES.SCOPE, BUILDER_PANEL_TYPES.NAME];
193
195
  var CONDITION_ANCHORS = [BUILDER_ANCHORS.COND_FIELD, BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_ANCHORS.COND_VALUES, BUILDER_ANCHORS.COND_CONNECTOR];
194
196
  var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT];
@@ -292,6 +294,9 @@ var isMultiValueVerb = function isMultiValueVerb(verb) {
292
294
  var sentencify = function sentencify(label) {
293
295
  return label ? label.charAt(0).toLowerCase() + label.slice(1) : label;
294
296
  };
297
+ var copyFor = function copyFor(value, args) {
298
+ return typeof value === "function" ? value(args) : value;
299
+ };
295
300
  var matchesTrigger = function matchesTrigger(name) {
296
301
  return function (option) {
297
302
  return option.eventValue === name || option.value === name || option.id === name;
@@ -455,24 +460,77 @@ var hasAction = function hasAction(rule) {
455
460
  var isRuleComplete = function isRuleComplete(rule) {
456
461
  return hasTrigger(rule) && hasAction(rule);
457
462
  };
458
- var invalidScopeIndexes = function invalidScopeIndexes(_ref12) {
463
+ var scopeOptionFor = function scopeOptionFor(_ref12) {
464
+ var _item$value, _schema$scope;
465
+ var schema = _ref12.schema,
466
+ item = _ref12.item;
467
+ var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
468
+ return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
469
+ var _candidate$value2;
470
+ return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
471
+ });
472
+ };
473
+ var scopePhoneFields = function scopePhoneFields(_ref13) {
474
+ var _ref14, _item$phoneFields, _scopeOptionFor;
475
+ var schema = _ref13.schema,
476
+ item = _ref13.item;
477
+ return (_ref14 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
478
+ schema: schema,
479
+ item: item
480
+ })) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref14 !== void 0 ? _ref14 : null;
481
+ };
482
+ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref15) {
483
+ var schema = _ref15.schema,
484
+ item = _ref15.item;
485
+ if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
486
+ var phoneFields = scopePhoneFields({
487
+ schema: schema,
488
+ item: item
489
+ });
490
+ return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
491
+ };
492
+ var invalidScopeIndexes = function invalidScopeIndexes(_ref16) {
459
493
  var _scope$requiresPhone;
460
- var rule = _ref12.rule,
461
- schema = _ref12.schema;
494
+ var rule = _ref16.rule,
495
+ schema = _ref16.schema;
462
496
  var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
463
497
  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 [];
464
498
  return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
465
- var _item$value, _item$hasPhoneField;
466
- var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
467
- var option = (scope.options || []).find(function (candidate) {
468
- var _candidate$value2;
469
- return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
499
+ var _ref17, _item$hasPhoneField;
500
+ var option = scopeOptionFor({
501
+ schema: schema,
502
+ item: item
503
+ });
504
+ var phoneFields = scopePhoneFields({
505
+ schema: schema,
506
+ item: item
470
507
  });
471
- 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;
508
+ 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;
472
509
  if (hasPhoneField === false) indexes.push(index);
473
510
  return indexes;
474
511
  }, []);
475
512
  };
513
+ var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref18) {
514
+ var _scope$requiresPhone2;
515
+ var rule = _ref18.rule,
516
+ schema = _ref18.schema;
517
+ var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
518
+ 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 [];
519
+ return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
520
+ var phoneFields = scopePhoneFields({
521
+ schema: schema,
522
+ item: item
523
+ });
524
+ var hasChoice = ((phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) || 0) > 1;
525
+ if (hasChoice && !effectiveScopePhoneField({
526
+ schema: schema,
527
+ item: item
528
+ })) {
529
+ indexes.push(index);
530
+ }
531
+ return indexes;
532
+ }, []);
533
+ };
476
534
  var minutesToParts = function minutesToParts(minutes) {
477
535
  var total = Number(minutes) || 0;
478
536
  if (total && total % UNIT_MINUTES.days === 0) {
@@ -492,9 +550,9 @@ var minutesToParts = function minutesToParts(minutes) {
492
550
  unit: "minutes"
493
551
  };
494
552
  };
495
- var partsToMinutes = function partsToMinutes(_ref13) {
496
- var value = _ref13.value,
497
- unit = _ref13.unit;
553
+ var partsToMinutes = function partsToMinutes(_ref19) {
554
+ var value = _ref19.value,
555
+ unit = _ref19.unit;
498
556
  return (
499
557
  // eslint-disable-next-line security/detect-object-injection
500
558
  (Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
@@ -527,17 +585,17 @@ var modeFromJoinType = function modeFromJoinType(joinType) {
527
585
  };
528
586
 
529
587
  // eslint-disable-next-line security/detect-object-injection
530
- var valueAt = function valueAt(_ref14) {
588
+ var valueAt = function valueAt(_ref20) {
531
589
  var _values$key;
532
- var values = _ref14.values,
533
- key = _ref14.key;
590
+ var values = _ref20.values,
591
+ key = _ref20.key;
534
592
  return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
535
593
  };
536
594
  var asArray = function asArray(maybeArray) {
537
595
  return Array.isArray(maybeArray) ? maybeArray : [];
538
596
  };
539
597
  var fieldKeysFromSchema = function fieldKeysFromSchema() {
540
- var _schema$triggers2, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers3, _schema$scope;
598
+ var _schema$triggers2, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers3, _schema$scope2;
541
599
  var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
542
600
  return {
543
601
  triggers: ((_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.fieldKey) || "events",
@@ -546,18 +604,18 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
546
604
  actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
547
605
  delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
548
606
  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,
549
- scope: ((_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.fieldKey) || "meetingIds",
607
+ scope: ((_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.fieldKey) || "meetingIds",
550
608
  status: "status",
551
609
  name: "name"
552
610
  };
553
611
  };
554
612
  var valuesToRuleModel = function valuesToRuleModel() {
555
613
  var _valueAt, _conditions$;
556
- var _ref15 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
557
- _ref15$values = _ref15.values,
558
- values = _ref15$values === void 0 ? {} : _ref15$values,
559
- _ref15$schema = _ref15.schema,
560
- schema = _ref15$schema === void 0 ? {} : _ref15$schema;
614
+ var _ref21 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
615
+ _ref21$values = _ref21.values,
616
+ values = _ref21$values === void 0 ? {} : _ref21$values,
617
+ _ref21$schema = _ref21.schema,
618
+ schema = _ref21$schema === void 0 ? {} : _ref21$schema;
561
619
  var keys = fieldKeysFromSchema(schema);
562
620
  var conditions = asArray(valueAt({
563
621
  values: values,
@@ -601,42 +659,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
601
659
  }))
602
660
  };
603
661
  };
604
- var setTriggers = function setTriggers(_ref16) {
605
- var schema = _ref16.schema,
606
- triggers = _ref16.triggers;
662
+ var setTriggers = function setTriggers(_ref22) {
663
+ var schema = _ref22.schema,
664
+ triggers = _ref22.triggers;
607
665
  return {
608
666
  path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
609
667
  value: triggers
610
668
  };
611
669
  };
612
- var setPerformer = function setPerformer(_ref17) {
613
- var schema = _ref17.schema,
614
- performer = _ref17.performer;
670
+ var setPerformer = function setPerformer(_ref23) {
671
+ var schema = _ref23.schema,
672
+ performer = _ref23.performer;
615
673
  return {
616
674
  path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
617
675
  value: performer
618
676
  };
619
677
  };
620
- var setActions = function setActions(_ref18) {
621
- var schema = _ref18.schema,
622
- actions = _ref18.actions;
678
+ var setActions = function setActions(_ref24) {
679
+ var schema = _ref24.schema,
680
+ actions = _ref24.actions;
623
681
  return {
624
682
  path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
625
683
  value: actions
626
684
  };
627
685
  };
628
- var setConditions = function setConditions(_ref19) {
629
- var schema = _ref19.schema,
630
- conditions = _ref19.conditions;
686
+ var setConditions = function setConditions(_ref25) {
687
+ var schema = _ref25.schema,
688
+ conditions = _ref25.conditions;
631
689
  return {
632
690
  path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
633
691
  value: conditions
634
692
  };
635
693
  };
636
- var setConditionMode = function setConditionMode(_ref20) {
637
- var schema = _ref20.schema,
638
- conditions = _ref20.conditions,
639
- joinType = _ref20.joinType;
694
+ var setConditionMode = function setConditionMode(_ref26) {
695
+ var schema = _ref26.schema,
696
+ conditions = _ref26.conditions,
697
+ joinType = _ref26.joinType;
640
698
  return setConditions({
641
699
  schema: schema,
642
700
  conditions: conditions.map(function (condition) {
@@ -644,34 +702,34 @@ var setConditionMode = function setConditionMode(_ref20) {
644
702
  })
645
703
  });
646
704
  };
647
- var setDelay = function setDelay(_ref21) {
648
- var schema = _ref21.schema,
649
- delay = _ref21.delay;
705
+ var setDelay = function setDelay(_ref27) {
706
+ var schema = _ref27.schema,
707
+ delay = _ref27.delay;
650
708
  return {
651
709
  path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
652
710
  value: delay !== null && delay !== void 0 ? delay : {}
653
711
  };
654
712
  };
655
- var setActive = function setActive(_ref22) {
656
- var schema = _ref22.schema,
657
- active = _ref22.active;
713
+ var setActive = function setActive(_ref28) {
714
+ var schema = _ref28.schema,
715
+ active = _ref28.active;
658
716
  return {
659
717
  path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
660
718
  value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
661
719
  };
662
720
  };
663
- var setScope = function setScope(_ref23) {
664
- var schema = _ref23.schema,
665
- scope = _ref23.scope;
721
+ var setScope = function setScope(_ref29) {
722
+ var schema = _ref29.schema,
723
+ scope = _ref29.scope;
666
724
  return {
667
725
  path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
668
726
  value: scope
669
727
  };
670
728
  };
671
- var removeArrayItem = function removeArrayItem(_ref24) {
672
- var values = _ref24.values,
673
- fieldKey = _ref24.fieldKey,
674
- index = _ref24.index;
729
+ var removeArrayItem = function removeArrayItem(_ref30) {
730
+ var values = _ref30.values,
731
+ fieldKey = _ref30.fieldKey,
732
+ index = _ref30.index;
675
733
  var list = asArray(valueAt({
676
734
  values: values,
677
735
  key: fieldKey
@@ -1031,7 +1089,7 @@ var itemLabel = function itemLabel(item) {
1031
1089
  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 : "");
1032
1090
  };
1033
1091
  var ScopeBlock = function ScopeBlock(_ref) {
1034
- var _schema$scope;
1092
+ var _schema$scope, _schema$scope2, _schema$scope2$requir;
1035
1093
  var rule = _ref.rule,
1036
1094
  schema = _ref.schema,
1037
1095
  handleToken = _ref.onToken,
@@ -1048,6 +1106,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1048
1106
  t = _useTranslation.t;
1049
1107
  var scope = rule.scope || [];
1050
1108
  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");
1109
+ 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 || []));
1051
1110
  if (isEmpty(scope)) {
1052
1111
  return /*#__PURE__*/jsx("div", {
1053
1112
  className: "mb-row",
@@ -1077,6 +1136,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1077
1136
  isActive: isActive,
1078
1137
  isInvalid: isInvalid,
1079
1138
  item: item,
1139
+ requiresPhone: requiresPhone,
1080
1140
  schema: schema,
1081
1141
  isLast: index === scope.length - 1,
1082
1142
  key: ((_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item) || index,
@@ -1086,7 +1146,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1086
1146
  });
1087
1147
  };
1088
1148
  var ScopeRow = function ScopeRow(_ref2) {
1089
- var _schema$scope2;
1149
+ var _schema$scope3, _schema$scope4, _schema$scope5;
1090
1150
  var schema = _ref2.schema,
1091
1151
  item = _ref2.item,
1092
1152
  index = _ref2.index,
@@ -1094,13 +1154,30 @@ var ScopeRow = function ScopeRow(_ref2) {
1094
1154
  handleRemoveScope = _ref2.onRemoveScope,
1095
1155
  isActive = _ref2.isActive,
1096
1156
  isInvalid = _ref2.isInvalid,
1097
- isLast = _ref2.isLast;
1157
+ isLast = _ref2.isLast,
1158
+ requiresPhone = _ref2.requiresPhone;
1098
1159
  var _useTranslation2 = useTranslation(),
1099
1160
  t = _useTranslation2.t;
1100
1161
  var _useClearingHover = useClearingHover(),
1101
1162
  clearing = _useClearingHover.clearing,
1102
1163
  clearingHoverProps = _useClearingHover.clearingHoverProps;
1103
- 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");
1164
+ 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");
1165
+ var meeting = itemLabel(item);
1166
+ var phoneFields = requiresPhone ? scopePhoneFields({
1167
+ item: item,
1168
+ schema: schema
1169
+ }) : null;
1170
+ var hasPhoneFieldChoice = ((phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) || 0) > 1;
1171
+ var singlePhoneFieldLabel = (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].label : null;
1172
+ var selectedPhoneField = phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.find(function (field) {
1173
+ return field.value === (item === null || item === void 0 ? void 0 : item.phoneField);
1174
+ });
1175
+ var usingLabel = copyFor(schema === null || schema === void 0 || (_schema$scope4 = schema.scope) === null || _schema$scope4 === void 0 ? void 0 : _schema$scope4.usingLabel, {
1176
+ meeting: meeting
1177
+ }) || t("neetoRules.builder.scope.using");
1178
+ var phoneFieldPlaceholder = copyFor(schema === null || schema === void 0 || (_schema$scope5 = schema.scope) === null || _schema$scope5 === void 0 ? void 0 : _schema$scope5.phoneFieldPlaceholder, {
1179
+ meeting: meeting
1180
+ }) || t("neetoRules.builder.selectPhoneField");
1104
1181
  return /*#__PURE__*/jsxs("div", {
1105
1182
  className: classNames("mb-row", {
1106
1183
  clearing: clearing
@@ -1125,7 +1202,33 @@ var ScopeRow = function ScopeRow(_ref2) {
1125
1202
  type: BUILDER_ANCHORS.SCOPE
1126
1203
  });
1127
1204
  },
1128
- children: itemLabel(item)
1205
+ children: meeting
1206
+ }), singlePhoneFieldLabel && /*#__PURE__*/jsxs("span", {
1207
+ className: "mb-fixed",
1208
+ children: [usingLabel, " ", singlePhoneFieldLabel]
1209
+ }), hasPhoneFieldChoice && /*#__PURE__*/jsxs(Fragment, {
1210
+ children: [/*#__PURE__*/jsx("span", {
1211
+ className: "mb-fixed",
1212
+ children: usingLabel
1213
+ }), /*#__PURE__*/jsx(Token, {
1214
+ dataTestid: "scope-phone-field-".concat(index),
1215
+ active: isActive({
1216
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1217
+ index: index
1218
+ }),
1219
+ invalid: isInvalid({
1220
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1221
+ index: index
1222
+ }),
1223
+ state: selectedPhoneField ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
1224
+ onClick: handleToken && function () {
1225
+ return handleToken({
1226
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1227
+ index: index
1228
+ });
1229
+ },
1230
+ children: (selectedPhoneField === null || selectedPhoneField === void 0 ? void 0 : selectedPhoneField.label) || phoneFieldPlaceholder
1231
+ })]
1129
1232
  })]
1130
1233
  }), /*#__PURE__*/jsxs("div", {
1131
1234
  className: "mb-row-actions",
@@ -1786,41 +1889,58 @@ var actionAt = function actionAt(_ref3) {
1786
1889
  index = _ref3.index;
1787
1890
  return rule.actions[index] || {};
1788
1891
  };
1789
- var findField = function findField(_ref4) {
1892
+
1893
+ // eslint-disable-next-line security/detect-object-injection
1894
+ var scopeItemAt = function scopeItemAt(_ref4) {
1895
+ var _rule$scope;
1896
+ var rule = _ref4.rule,
1897
+ index = _ref4.index;
1898
+ return ((_rule$scope = rule.scope) === null || _rule$scope === void 0 ? void 0 : _rule$scope[index]) || {};
1899
+ };
1900
+ var scopeItemLabel = function scopeItemLabel(item) {
1901
+ 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 : "");
1902
+ };
1903
+ var findField = function findField(_ref5) {
1790
1904
  var _schema$conditions;
1791
- var schema = _ref4.schema,
1792
- value = _ref4.value;
1905
+ var schema = _ref5.schema,
1906
+ value = _ref5.value;
1793
1907
  return (((_schema$conditions = schema.conditions) === null || _schema$conditions === void 0 ? void 0 : _schema$conditions.fields) || []).find(function (field) {
1794
1908
  return optionValue(field) === value;
1795
1909
  });
1796
1910
  };
1797
- var findActionOption = function findActionOption(_ref5) {
1911
+ var findActionOption = function findActionOption(_ref6) {
1798
1912
  var _schema$actions;
1799
- var schema = _ref5.schema,
1800
- name = _ref5.name;
1913
+ var schema = _ref6.schema,
1914
+ name = _ref6.name;
1801
1915
  return (((_schema$actions = schema.actions) === null || _schema$actions === void 0 ? void 0 : _schema$actions.options) || []).find(function (option) {
1802
1916
  return optionValue(option) === name;
1803
1917
  });
1804
1918
  };
1805
- var channelOf = function channelOf(_ref6) {
1919
+ var channelOf = function channelOf(_ref7) {
1806
1920
  var _schema$actions2, _schema$actions2$acti;
1807
- var schema = _ref6.schema,
1808
- action = _ref6.action;
1809
- 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);
1810
- };
1811
- var channelMetaOf = function channelMetaOf(_ref7) {
1812
- var _schema$actions3;
1813
1921
  var schema = _ref7.schema,
1814
1922
  action = _ref7.action;
1815
- return ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3 = _schema$actions3.channelMeta) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3[channelOf({
1923
+ 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);
1924
+ };
1925
+ var recipientOf = function recipientOf(_ref8) {
1926
+ var _action$recipient, _schema$actions3, _schema$actions3$acti;
1927
+ var schema = _ref8.schema,
1928
+ action = _ref8.action;
1929
+ 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;
1930
+ };
1931
+ var channelMetaOf = function channelMetaOf(_ref9) {
1932
+ var _schema$actions4;
1933
+ var schema = _ref9.schema,
1934
+ action = _ref9.action;
1935
+ 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({
1816
1936
  schema: schema,
1817
1937
  action: action
1818
1938
  })]) || {};
1819
1939
  };
1820
- var actionHasConfig = function actionHasConfig(_ref8) {
1821
- var _schema$actions4, _schema$actions5;
1822
- var schema = _ref8.schema,
1823
- action = _ref8.action;
1940
+ var actionHasConfig = function actionHasConfig(_ref0) {
1941
+ var _schema$actions5, _schema$actions6;
1942
+ var schema = _ref0.schema,
1943
+ action = _ref0.action;
1824
1944
  var meta = channelMetaOf({
1825
1945
  schema: schema,
1826
1946
  action: action
@@ -1831,18 +1951,18 @@ var actionHasConfig = function actionHasConfig(_ref8) {
1831
1951
  name: action === null || action === void 0 ? void 0 : action.name
1832
1952
  });
1833
1953
  if (option !== null && option !== void 0 && option.component || option !== null && option !== void 0 && option.renderConfig) return true;
1834
- if ((_schema$actions4 = schema.actions) !== null && _schema$actions4 !== void 0 && _schema$actions4.hasConfig) return schema.actions.hasConfig(action);
1835
- return !!((_schema$actions5 = schema.actions) !== null && _schema$actions5 !== void 0 && _schema$actions5.renderConfig);
1954
+ if ((_schema$actions5 = schema.actions) !== null && _schema$actions5 !== void 0 && _schema$actions5.hasConfig) return schema.actions.hasConfig(action);
1955
+ return !!((_schema$actions6 = schema.actions) !== null && _schema$actions6 !== void 0 && _schema$actions6.renderConfig);
1836
1956
  };
1837
- var recipientsFor = function recipientsFor(_ref9) {
1838
- var _schema$actions6, _schema$actions7;
1839
- var schema = _ref9.schema,
1840
- action = _ref9.action;
1957
+ var recipientsFor = function recipientsFor(_ref1) {
1958
+ var _schema$actions7, _schema$actions8;
1959
+ var schema = _ref1.schema,
1960
+ action = _ref1.action;
1841
1961
  var channel = channelOf({
1842
1962
  schema: schema,
1843
1963
  action: action
1844
1964
  });
1845
- if (channel && (_schema$actions6 = schema.actions) !== null && _schema$actions6 !== void 0 && _schema$actions6.recipientsFor) {
1965
+ if (channel && (_schema$actions7 = schema.actions) !== null && _schema$actions7 !== void 0 && _schema$actions7.recipientsFor) {
1846
1966
  return schema.actions.recipientsFor(channel);
1847
1967
  }
1848
1968
  var option = findActionOption({
@@ -1850,13 +1970,13 @@ var recipientsFor = function recipientsFor(_ref9) {
1850
1970
  name: channel
1851
1971
  });
1852
1972
  if (option !== null && option !== void 0 && option.recipients) return option.recipients;
1853
- return ((_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 ? void 0 : _schema$actions7.recipients) || [];
1973
+ return ((_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 ? void 0 : _schema$actions8.recipients) || [];
1854
1974
  };
1855
- var nextTriggers = function nextTriggers(_ref0) {
1975
+ var nextTriggers = function nextTriggers(_ref10) {
1856
1976
  var _schema$triggers;
1857
- var schema = _ref0.schema,
1858
- rule = _ref0.rule,
1859
- value = _ref0.value;
1977
+ var schema = _ref10.schema,
1978
+ rule = _ref10.rule,
1979
+ value = _ref10.value;
1860
1980
  if ((_schema$triggers = schema.triggers) !== null && _schema$triggers !== void 0 && _schema$triggers.multi) {
1861
1981
  var names = pluck("name", rule.triggers);
1862
1982
  return names.includes(value) ? removeBy({
@@ -1869,12 +1989,12 @@ var nextTriggers = function nextTriggers(_ref0) {
1869
1989
  name: value
1870
1990
  }];
1871
1991
  };
1872
- var nextConditionAt = function nextConditionAt(_ref1) {
1992
+ var nextConditionAt = function nextConditionAt(_ref11) {
1873
1993
  var _field$allowMatching;
1874
- var schema = _ref1.schema,
1875
- rule = _ref1.rule,
1876
- index = _ref1.index,
1877
- value = _ref1.value;
1994
+ var schema = _ref11.schema,
1995
+ rule = _ref11.rule,
1996
+ index = _ref11.index,
1997
+ value = _ref11.value;
1878
1998
  var field = findField({
1879
1999
  schema: schema,
1880
2000
  value: value
@@ -1893,13 +2013,13 @@ var nextConditionAt = function nextConditionAt(_ref1) {
1893
2013
  metadata: {}
1894
2014
  });
1895
2015
  };
1896
- var nextActionAt = function nextActionAt(_ref10) {
1897
- var _schema$actions8;
1898
- var schema = _ref10.schema,
1899
- rule = _ref10.rule,
1900
- index = _ref10.index,
1901
- value = _ref10.value;
1902
- if (!((_schema$actions8 = schema.actions) !== null && _schema$actions8 !== void 0 && _schema$actions8.resolveName)) {
2016
+ var nextActionAt = function nextActionAt(_ref12) {
2017
+ var _schema$actions9;
2018
+ var schema = _ref12.schema,
2019
+ rule = _ref12.rule,
2020
+ index = _ref12.index,
2021
+ value = _ref12.value;
2022
+ if (!((_schema$actions9 = schema.actions) !== null && _schema$actions9 !== void 0 && _schema$actions9.resolveName)) {
1903
2023
  var option = findActionOption({
1904
2024
  schema: schema,
1905
2025
  name: value
@@ -1937,10 +2057,10 @@ var nextActionAt = function nextActionAt(_ref10) {
1937
2057
  var channelChanged = prevChannel !== value;
1938
2058
  var recipient = channelChanged ? undefined : prev.recipient;
1939
2059
  if (channelChanged) {
1940
- var _schema$actions9;
2060
+ var _schema$actions0;
1941
2061
  var channelRecipients =
1942
2062
  // eslint-disable-next-line security/detect-object-injection
1943
- ((_schema$actions9 = schema.actions) === null || _schema$actions9 === void 0 || (_schema$actions9 = _schema$actions9.recipientsByChannel) === null || _schema$actions9 === void 0 ? void 0 : _schema$actions9[value]) || [];
2063
+ ((_schema$actions0 = schema.actions) === null || _schema$actions0 === void 0 || (_schema$actions0 = _schema$actions0.recipientsByChannel) === null || _schema$actions0 === void 0 ? void 0 : _schema$actions0[value]) || [];
1944
2064
  if (channelRecipients.length === 1) {
1945
2065
  var _channelRecipients = _slicedToArray(channelRecipients, 1);
1946
2066
  recipient = _channelRecipients[0];
@@ -1956,12 +2076,33 @@ var nextActionAt = function nextActionAt(_ref10) {
1956
2076
  metadata: channelChanged ? {} : prev.metadata
1957
2077
  });
1958
2078
  };
1959
- var nextActionRecipientAt = function nextActionRecipientAt(_ref11) {
1960
- var _schema$actions0;
1961
- var schema = _ref11.schema,
1962
- rule = _ref11.rule,
1963
- index = _ref11.index,
1964
- value = _ref11.value;
2079
+ var appendScopeItem = function appendScopeItem(_ref13) {
2080
+ var _sc$requiresPhone;
2081
+ var schema = _ref13.schema,
2082
+ rule = _ref13.rule,
2083
+ value = _ref13.value;
2084
+ var sc = schema.scope || {};
2085
+ var option = (sc.options || []).find(function (candidate) {
2086
+ return optionValue(candidate) === value;
2087
+ }) || {
2088
+ value: value
2089
+ };
2090
+ var requiresPhone = ((_sc$requiresPhone = sc.requiresPhone) === null || _sc$requiresPhone === void 0 ? void 0 : _sc$requiresPhone.call(sc, rule.actions)) || false;
2091
+ if (!requiresPhone) return option;
2092
+ var phoneFields = scopePhoneFields({
2093
+ schema: schema,
2094
+ item: option
2095
+ });
2096
+ return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? _objectSpread$4(_objectSpread$4({}, option), {}, {
2097
+ phoneField: phoneFields[0].value
2098
+ }) : option;
2099
+ };
2100
+ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
2101
+ var _schema$actions1;
2102
+ var schema = _ref14.schema,
2103
+ rule = _ref14.rule,
2104
+ index = _ref14.index,
2105
+ value = _ref14.value;
1965
2106
  var prev = actionAt({
1966
2107
  rule: rule,
1967
2108
  index: index
@@ -1972,18 +2113,18 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref11) {
1972
2113
  });
1973
2114
  return _objectSpread$4(_objectSpread$4({}, prev), {}, {
1974
2115
  recipient: value,
1975
- name: (_schema$actions0 = schema.actions) !== null && _schema$actions0 !== void 0 && _schema$actions0.resolveName ? schema.actions.resolveName({
2116
+ name: (_schema$actions1 = schema.actions) !== null && _schema$actions1 !== void 0 && _schema$actions1.resolveName ? schema.actions.resolveName({
1976
2117
  channel: channel,
1977
2118
  recipient: value
1978
2119
  }) : value
1979
2120
  });
1980
2121
  };
1981
- var descriptorFor = function descriptorFor(_ref12) {
2122
+ var descriptorFor = function descriptorFor(_ref15) {
1982
2123
  var _schema$actor2, _schema$conditions2;
1983
- var anchor = _ref12.anchor,
1984
- schema = _ref12.schema,
1985
- rule = _ref12.rule,
1986
- index = _ref12.index;
2124
+ var anchor = _ref15.anchor,
2125
+ schema = _ref15.schema,
2126
+ rule = _ref15.rule,
2127
+ index = _ref15.index;
1987
2128
  switch (anchor) {
1988
2129
  case BUILDER_ANCHORS.TRIGGER_ADD:
1989
2130
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2093,22 +2234,22 @@ var descriptorFor = function descriptorFor(_ref12) {
2093
2234
  case BUILDER_ANCHORS.ACTION_ADD:
2094
2235
  case BUILDER_ANCHORS.ACTION_CHANNEL:
2095
2236
  {
2096
- var _schema$actions10, _schema$actions11, _channelOf;
2237
+ var _schema$actions11, _schema$actions12, _channelOf;
2097
2238
  var isSwap = anchor === BUILDER_ANCHORS.ACTION_CHANNEL;
2098
2239
  var channelMetaFor = function channelMetaFor(value) {
2099
- var _schema$actions1;
2240
+ var _schema$actions10;
2100
2241
  return (
2101
2242
  // eslint-disable-next-line security/detect-object-injection
2102
- ((_schema$actions1 = schema.actions) === null || _schema$actions1 === void 0 || (_schema$actions1 = _schema$actions1.channelMeta) === null || _schema$actions1 === void 0 ? void 0 : _schema$actions1[value]) || {}
2243
+ ((_schema$actions10 = schema.actions) === null || _schema$actions10 === void 0 || (_schema$actions10 = _schema$actions10.channelMeta) === null || _schema$actions10 === void 0 ? void 0 : _schema$actions10[value]) || {}
2103
2244
  );
2104
2245
  };
2105
2246
  var rank = function rank(value) {
2106
2247
  var idx = SWAP_CHANNEL_ORDER.indexOf(value);
2107
2248
  return idx === -1 ? SWAP_CHANNEL_ORDER.length : idx;
2108
2249
  };
2109
- var sourceOptions = isSwap ? _toConsumableArray(((_schema$actions10 = schema.actions) === null || _schema$actions10 === void 0 ? void 0 : _schema$actions10.options) || []).sort(function (optionA, optionB) {
2250
+ var sourceOptions = isSwap ? _toConsumableArray(((_schema$actions11 = schema.actions) === null || _schema$actions11 === void 0 ? void 0 : _schema$actions11.options) || []).sort(function (optionA, optionB) {
2110
2251
  return rank(optionValue(optionA)) - rank(optionValue(optionB));
2111
- }) : ((_schema$actions11 = schema.actions) === null || _schema$actions11 === void 0 ? void 0 : _schema$actions11.options) || [];
2252
+ }) : ((_schema$actions12 = schema.actions) === null || _schema$actions12 === void 0 ? void 0 : _schema$actions12.options) || [];
2112
2253
  return {
2113
2254
  title: isSwap ? t("neetoRules.builder.panes.actionSwapTitle") : t("neetoRules.builder.panes.actionAddTitle"),
2114
2255
  subtitle: isSwap ? t("neetoRules.builder.panes.actionSwapSubtitle") : t("neetoRules.builder.panes.actionAddSubtitle"),
@@ -2138,7 +2279,7 @@ var descriptorFor = function descriptorFor(_ref12) {
2138
2279
  }
2139
2280
  case BUILDER_ANCHORS.ACTION_RECIPIENT:
2140
2281
  {
2141
- var _schema$actions12;
2282
+ var _schema$actions13;
2142
2283
  var action = actionAt({
2143
2284
  rule: rule,
2144
2285
  index: index
@@ -2148,7 +2289,7 @@ var descriptorFor = function descriptorFor(_ref12) {
2148
2289
  action: action
2149
2290
  });
2150
2291
  // eslint-disable-next-line security/detect-object-injection
2151
- var meta = ((_schema$actions12 = schema.actions) === null || _schema$actions12 === void 0 || (_schema$actions12 = _schema$actions12.channelMeta) === null || _schema$actions12 === void 0 ? void 0 : _schema$actions12[channel]) || {};
2292
+ var meta = ((_schema$actions13 = schema.actions) === null || _schema$actions13 === void 0 || (_schema$actions13 = _schema$actions13.channelMeta) === null || _schema$actions13 === void 0 ? void 0 : _schema$actions13[channel]) || {};
2152
2293
  var option = findActionOption({
2153
2294
  schema: schema,
2154
2295
  name: channel
@@ -2165,18 +2306,21 @@ var descriptorFor = function descriptorFor(_ref12) {
2165
2306
  value: optionValue(recipient)
2166
2307
  };
2167
2308
  }),
2168
- selectedValues: [action.recipient]
2309
+ selectedValues: [recipientOf({
2310
+ schema: schema,
2311
+ action: action
2312
+ })]
2169
2313
  };
2170
2314
  }
2171
2315
  case BUILDER_ANCHORS.SCOPE:
2172
2316
  {
2173
- var _sc$requiresPhone;
2317
+ var _sc$requiresPhone2;
2174
2318
  var sc = schema.scope || {};
2175
2319
  var selected = (rule.scope || []).map(function (item) {
2176
2320
  var _item$value;
2177
2321
  return (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
2178
2322
  });
2179
- var requiresPhone = ((_sc$requiresPhone = sc.requiresPhone) === null || _sc$requiresPhone === void 0 ? void 0 : _sc$requiresPhone.call(sc, rule.actions)) || false;
2323
+ var requiresPhone = ((_sc$requiresPhone2 = sc.requiresPhone) === null || _sc$requiresPhone2 === void 0 ? void 0 : _sc$requiresPhone2.call(sc, rule.actions)) || false;
2180
2324
  return {
2181
2325
  title: selected.length ? sc.paneChangeTitle || t("neetoRules.builder.panes.scopeChangeTitle") : sc.paneTitle || t("neetoRules.builder.panes.scopeTitle"),
2182
2326
  subtitle: sc.paneSubtitle || t("neetoRules.builder.panes.scopeSubtitle"),
@@ -2196,6 +2340,36 @@ var descriptorFor = function descriptorFor(_ref12) {
2196
2340
  selectedValues: selected
2197
2341
  };
2198
2342
  }
2343
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2344
+ {
2345
+ var _sc = schema.scope || {};
2346
+ var item = scopeItemAt({
2347
+ rule: rule,
2348
+ index: index
2349
+ });
2350
+ var meeting = scopeItemLabel(item);
2351
+ var options = scopePhoneFields({
2352
+ schema: schema,
2353
+ item: item
2354
+ }) || [];
2355
+ return {
2356
+ title: copyFor(_sc.phoneFieldPaneTitle, {
2357
+ meeting: meeting
2358
+ }) || t("neetoRules.builder.panes.phoneFieldTitle"),
2359
+ subtitle: copyFor(_sc.phoneFieldPaneSubtitle, {
2360
+ meeting: meeting
2361
+ }) || t("neetoRules.builder.panes.phoneFieldSubtitle", {
2362
+ meeting: meeting
2363
+ }),
2364
+ options: options.map(function (option) {
2365
+ return {
2366
+ label: option.label,
2367
+ value: optionValue(option)
2368
+ };
2369
+ }),
2370
+ selectedValues: [item.phoneField]
2371
+ };
2372
+ }
2199
2373
  default:
2200
2374
  return {
2201
2375
  title: "",
@@ -2205,13 +2379,13 @@ var descriptorFor = function descriptorFor(_ref12) {
2205
2379
  };
2206
2380
  }
2207
2381
  };
2208
- var commitFor = function commitFor(_ref13) {
2209
- var anchor = _ref13.anchor,
2210
- schema = _ref13.schema,
2211
- rule = _ref13.rule,
2212
- index = _ref13.index,
2213
- value = _ref13.value,
2214
- helpers = _ref13.helpers;
2382
+ var commitFor = function commitFor(_ref16) {
2383
+ var anchor = _ref16.anchor,
2384
+ schema = _ref16.schema,
2385
+ rule = _ref16.rule,
2386
+ index = _ref16.index,
2387
+ value = _ref16.value,
2388
+ helpers = _ref16.helpers;
2215
2389
  var setTriggers = helpers.setTriggers,
2216
2390
  setPerformer = helpers.setPerformer,
2217
2391
  setConditionMode = helpers.setConditionMode,
@@ -2284,8 +2458,7 @@ var commitFor = function commitFor(_ref13) {
2284
2458
  }
2285
2459
  case BUILDER_ANCHORS.SCOPE:
2286
2460
  {
2287
- var sc = schema.scope || {};
2288
- var key = sc.fieldKey || "scope";
2461
+ var key = fieldKeys.scope;
2289
2462
  var current = rule.scope || [];
2290
2463
  var has = current.some(function (item) {
2291
2464
  var _item$value2;
@@ -2294,24 +2467,30 @@ var commitFor = function commitFor(_ref13) {
2294
2467
  var next = has ? current.filter(function (item) {
2295
2468
  var _item$value3;
2296
2469
  return ((_item$value3 = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value3 !== void 0 ? _item$value3 : item) !== value;
2297
- }) : [].concat(_toConsumableArray(current), [(sc.options || []).find(function (option) {
2298
- return optionValue(option) === value;
2299
- }) || {
2470
+ }) : [].concat(_toConsumableArray(current), [appendScopeItem({
2471
+ schema: schema,
2472
+ rule: rule,
2300
2473
  value: value
2301
- }]);
2474
+ })]);
2302
2475
  setFieldValue("".concat(key, ".value"), next);
2303
2476
  return "stay";
2304
2477
  }
2478
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2479
+ {
2480
+ var _key = fieldKeys.scope;
2481
+ setFieldValue("".concat(_key, ".value.").concat(index, ".phoneField"), value);
2482
+ return "stay";
2483
+ }
2305
2484
  default:
2306
2485
  return "close";
2307
2486
  }
2308
2487
  };
2309
- var continueTargetFor = function continueTargetFor(_ref14) {
2488
+ var continueTargetFor = function continueTargetFor(_ref17) {
2310
2489
  var _schema$actor3;
2311
- var anchor = _ref14.anchor,
2312
- schema = _ref14.schema,
2313
- rule = _ref14.rule,
2314
- index = _ref14.index;
2490
+ var anchor = _ref17.anchor,
2491
+ schema = _ref17.schema,
2492
+ rule = _ref17.rule,
2493
+ index = _ref17.index;
2315
2494
  switch (anchor) {
2316
2495
  case BUILDER_ANCHORS.TRIGGER_ADD:
2317
2496
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2384,21 +2563,21 @@ var continueTargetFor = function continueTargetFor(_ref14) {
2384
2563
  return null;
2385
2564
  }
2386
2565
  };
2387
- var replaceAt = function replaceAt(_ref15) {
2388
- var list = _ref15.list,
2389
- index = _ref15.index,
2390
- item = _ref15.item;
2566
+ var replaceAt = function replaceAt(_ref18) {
2567
+ var list = _ref18.list,
2568
+ index = _ref18.index,
2569
+ item = _ref18.item;
2391
2570
  var next = _toConsumableArray(list);
2392
2571
  // eslint-disable-next-line security/detect-object-injection
2393
2572
  next[index] = item;
2394
2573
  return next;
2395
2574
  };
2396
- var applyPreview = function applyPreview(_ref16) {
2397
- var rule = _ref16.rule,
2398
- schema = _ref16.schema,
2399
- anchor = _ref16.anchor,
2400
- index = _ref16.index,
2401
- value = _ref16.value;
2575
+ var applyPreview = function applyPreview(_ref19) {
2576
+ var rule = _ref19.rule,
2577
+ schema = _ref19.schema,
2578
+ anchor = _ref19.anchor,
2579
+ index = _ref19.index,
2580
+ value = _ref19.value;
2402
2581
  switch (anchor) {
2403
2582
  case BUILDER_ANCHORS.TRIGGER_ADD:
2404
2583
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2474,6 +2653,19 @@ var applyPreview = function applyPreview(_ref16) {
2474
2653
  })
2475
2654
  })
2476
2655
  });
2656
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2657
+ return _objectSpread$4(_objectSpread$4({}, rule), {}, {
2658
+ scope: replaceAt({
2659
+ list: rule.scope,
2660
+ index: index,
2661
+ item: _objectSpread$4(_objectSpread$4({}, scopeItemAt({
2662
+ rule: rule,
2663
+ index: index
2664
+ })), {}, {
2665
+ phoneField: value
2666
+ })
2667
+ })
2668
+ });
2477
2669
  default:
2478
2670
  return rule;
2479
2671
  }
@@ -2539,6 +2731,9 @@ var Canvas = function Canvas(_ref) {
2539
2731
  if (isEmpty(flatErrors) && isRuleComplete(rule) && isEmpty(invalidScopeIndexes({
2540
2732
  rule: rule,
2541
2733
  schema: schema
2734
+ })) && isEmpty(invalidScopePhoneFieldIndexes({
2735
+ rule: rule,
2736
+ schema: schema
2542
2737
  }))) {
2543
2738
  return undefined;
2544
2739
  }
@@ -2631,6 +2826,11 @@ var Canvas = function Canvas(_ref) {
2631
2826
  rule: rule,
2632
2827
  schema: schema
2633
2828
  }).includes(index);
2829
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2830
+ return invalidScopePhoneFieldIndexes({
2831
+ rule: rule,
2832
+ schema: schema
2833
+ }).includes(index);
2634
2834
  case BUILDER_ANCHORS.META_NAME:
2635
2835
  return hasErrorAt({
2636
2836
  prefix: "".concat(fieldKeys.name, ".value")
@@ -2683,7 +2883,11 @@ var Canvas = function Canvas(_ref) {
2683
2883
  var isScopeComplete = !(schema !== null && schema !== void 0 && (_schema$scope2 = schema.scope) !== null && _schema$scope2 !== void 0 && _schema$scope2.enabled) || isNotEmpty(rule.scope || []);
2684
2884
  var isComplete = isRuleComplete(rule) && isScopeComplete;
2685
2885
  var handleRemoveScope = function handleRemoveScope(index) {
2686
- return setScope((rule.scope || []).filter(function (_, i) {
2886
+ closePaneIfTargeting({
2887
+ anchors: [BUILDER_ANCHORS.SCOPE_PHONE_FIELD],
2888
+ index: index
2889
+ });
2890
+ setScope((rule.scope || []).filter(function (_, i) {
2687
2891
  return i !== index;
2688
2892
  }));
2689
2893
  };
@@ -3846,7 +4050,7 @@ var RecipientField = function RecipientField(_ref) {
3846
4050
  };
3847
4051
 
3848
4052
  var RecipientPane = function RecipientPane(_ref) {
3849
- var _schema$actions, _schema$actions$actio, _schema$actions2, _schema$actions2$rend, _schema$actions3, _schema$actions3$opti, _schema$actions4, _schema$actions4$opti, _schema$actions5, _schema$actions6, _schema$actions$rende, _schema$actions7, _schema$actions7$rend, _action$metadata, _schema$actions8;
4053
+ var _schema$actions, _schema$actions$actio, _action$recipient, _schema$actions2, _schema$actions2$acti, _schema$actions3, _schema$actions3$rend, _schema$actions4, _schema$actions4$opti, _schema$actions5, _schema$actions5$opti, _schema$actions6, _schema$actions7, _schema$actions$rende, _schema$actions8, _schema$actions8$rend, _action$metadata, _schema$actions9;
3850
4054
  var schema = _ref.schema,
3851
4055
  index = _ref.index;
3852
4056
  var _useTranslation = useTranslation(),
@@ -3860,13 +4064,14 @@ var RecipientPane = function RecipientPane(_ref) {
3860
4064
  // eslint-disable-next-line security/detect-object-injection
3861
4065
  var action = rule.actions[index] || {};
3862
4066
  var channel = action.channel || ((_schema$actions = schema.actions) === null || _schema$actions === void 0 || (_schema$actions$actio = _schema$actions.actionForName) === null || _schema$actions$actio === void 0 || (_schema$actions$actio = _schema$actions$actio.call(_schema$actions, action.name)) === null || _schema$actions$actio === void 0 ? void 0 : _schema$actions$actio.channel);
4067
+ var recipient = (_action$recipient = action.recipient) !== null && _action$recipient !== void 0 ? _action$recipient : (_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.name)) === null || _schema$actions2$acti === void 0 ? void 0 : _schema$actions2$acti.recipient;
3863
4068
  var name = "".concat(fieldKeys.actions, ".value.").concat(index, ".metadata");
3864
- var editor = (_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$rend = _schema$actions2.renderRecipientEditor) === null || _schema$actions2$rend === void 0 ? void 0 : _schema$actions2$rend.call(_schema$actions2, {
4069
+ var editor = (_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3$rend = _schema$actions3.renderRecipientEditor) === null || _schema$actions3$rend === void 0 ? void 0 : _schema$actions3$rend.call(_schema$actions3, {
3865
4070
  channel: channel,
3866
4071
  name: name,
3867
4072
  action: action
3868
4073
  });
3869
- var flatOption = ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3$opti = _schema$actions3.optionForName) === null || _schema$actions3$opti === void 0 ? void 0 : _schema$actions3$opti.call(_schema$actions3, action.name)) || ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4$opti = _schema$actions4.optionForChannel) === null || _schema$actions4$opti === void 0 ? void 0 : _schema$actions4$opti.call(_schema$actions4, channel));
4074
+ var flatOption = ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4$opti = _schema$actions4.optionForName) === null || _schema$actions4$opti === void 0 ? void 0 : _schema$actions4$opti.call(_schema$actions4, action.name)) || ((_schema$actions5 = schema.actions) === null || _schema$actions5 === void 0 || (_schema$actions5$opti = _schema$actions5.optionForChannel) === null || _schema$actions5$opti === void 0 ? void 0 : _schema$actions5$opti.call(_schema$actions5, channel));
3870
4075
  var isSmsToNumbers = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.type) === SMS_TO_NUMBERS;
3871
4076
  var recipientFieldPath = isSmsToNumbers ? "".concat(name, ".phoneNumbers") : "".concat(name, ".emails");
3872
4077
  usePaneValidation(recipientFieldPath);
@@ -3880,11 +4085,11 @@ var RecipientPane = function RecipientPane(_ref) {
3880
4085
  }, 0);
3881
4086
  // eslint-disable-next-line react-hooks/exhaustive-deps
3882
4087
  }, [!editor]);
3883
- var recipientConfig = (((_schema$actions5 = schema.actions) === null || _schema$actions5 === void 0 ? void 0 : _schema$actions5.options) || []).flatMap(function (option) {
4088
+ var recipientConfig = (((_schema$actions6 = schema.actions) === null || _schema$actions6 === void 0 ? void 0 : _schema$actions6.options) || []).flatMap(function (option) {
3884
4089
  return option.recipients || [];
3885
- }).concat(((_schema$actions6 = schema.actions) === null || _schema$actions6 === void 0 ? void 0 : _schema$actions6.recipients) || []).find(function (item) {
4090
+ }).concat(((_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 ? void 0 : _schema$actions7.recipients) || []).find(function (item) {
3886
4091
  var _item$value;
3887
- return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === action.recipient;
4092
+ return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === recipient;
3888
4093
  });
3889
4094
  var builtInRecipientField = recipientConfig !== null && recipientConfig !== void 0 && recipientConfig.field ? /*#__PURE__*/jsx(RecipientField, {
3890
4095
  name: name,
@@ -3892,9 +4097,9 @@ var RecipientPane = function RecipientPane(_ref) {
3892
4097
  field: recipientConfig.field,
3893
4098
  placeholder: recipientConfig.placeholder
3894
4099
  }) : null;
3895
- var recipientField = (_schema$actions$rende = (_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 || (_schema$actions7$rend = _schema$actions7.renderRecipientField) === null || _schema$actions7$rend === void 0 ? void 0 : _schema$actions7$rend.call(_schema$actions7, {
4100
+ var recipientField = (_schema$actions$rende = (_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 || (_schema$actions8$rend = _schema$actions8.renderRecipientField) === null || _schema$actions8$rend === void 0 ? void 0 : _schema$actions8$rend.call(_schema$actions8, {
3896
4101
  channel: channel,
3897
- recipient: action.recipient,
4102
+ recipient: recipient,
3898
4103
  name: name,
3899
4104
  action: action
3900
4105
  })) !== null && _schema$actions$rende !== void 0 ? _schema$actions$rende : builtInRecipientField;
@@ -3929,7 +4134,7 @@ var RecipientPane = function RecipientPane(_ref) {
3929
4134
  }
3930
4135
 
3931
4136
  // eslint-disable-next-line security/detect-object-injection
3932
- var meta = ((_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 || (_schema$actions8 = _schema$actions8.channelMeta) === null || _schema$actions8 === void 0 ? void 0 : _schema$actions8[channel]) || {};
4137
+ var meta = ((_schema$actions9 = schema.actions) === null || _schema$actions9 === void 0 || (_schema$actions9 = _schema$actions9.channelMeta) === null || _schema$actions9 === void 0 ? void 0 : _schema$actions9[channel]) || {};
3933
4138
  return /*#__PURE__*/jsxs(Fragment, {
3934
4139
  children: [/*#__PURE__*/jsx(Panel.Header, {
3935
4140
  children: /*#__PURE__*/jsxs("div", {
@@ -4186,12 +4391,14 @@ var BUILDER_PANEL_TYPE_CONFIG_MAP = (_BUILDER_PANEL_TYPE_C = {}, _defineProperty
4186
4391
  component: ConfigPane
4187
4392
  }), BUILDER_PANEL_TYPES.DELAY, {
4188
4393
  component: DelayPane
4189
- }), _defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.LEAD_TIME, {
4394
+ }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.LEAD_TIME, {
4190
4395
  component: LeadTimePane
4191
4396
  }), BUILDER_PANEL_TYPES.NAME, {
4192
4397
  component: NamePane
4193
4398
  }), BUILDER_PANEL_TYPES.SCOPE, {
4194
4399
  component: OptionsPane
4400
+ }), BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD, {
4401
+ component: OptionsPane
4195
4402
  }));
4196
4403
 
4197
4404
  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; }
@@ -4270,6 +4477,9 @@ var Form = function Form(_ref) {
4270
4477
  if (!isRuleComplete(rule) || invalidScopeIndexes({
4271
4478
  rule: rule,
4272
4479
  schema: schema
4480
+ }).length || invalidScopePhoneFieldIndexes({
4481
+ rule: rule,
4482
+ schema: schema
4273
4483
  }).length) {
4274
4484
  formikBag.setSubmitting(false);
4275
4485
  return;