@trii/components 2.0.45 → 2.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cjs/index.js +512 -124
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/ContactInfoPopup/ContactInfoPopup.d.ts +3 -2
  4. package/dist/cjs/types/components/EditContactModal/EditContactModal.d.ts +3 -2
  5. package/dist/cjs/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +3 -1
  6. package/dist/cjs/types/components/EditContactModal/context/EditContactApiContext.d.ts +10 -0
  7. package/dist/cjs/types/components/EditContactModal/hooks/useEditBusiness/useEditBusiness.d.ts +1 -1
  8. package/dist/cjs/types/components/EditContactModal/hooks/useEditContact/useEditContact.d.ts +1 -1
  9. package/dist/cjs/types/components/EditContactModal/hooks/useModalCloseHandler.d.ts +1 -1
  10. package/dist/cjs/types/components/EditContactModal/hooks/useTagsEditorController.d.ts +3 -0
  11. package/dist/cjs/types/components/EditContactModal/layout/Section.d.ts +1 -1
  12. package/dist/cjs/types/components/EditContactModal/services/api.d.ts +14 -6
  13. package/dist/cjs/types/i18n/config.d.ts +2 -0
  14. package/dist/cjs/types/i18n/index.d.ts +2 -0
  15. package/dist/cjs/types/index.d.ts +1 -0
  16. package/dist/esm/index.js +510 -122
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/types/components/ContactInfoPopup/ContactInfoPopup.d.ts +3 -2
  19. package/dist/esm/types/components/EditContactModal/EditContactModal.d.ts +3 -2
  20. package/dist/esm/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +3 -1
  21. package/dist/esm/types/components/EditContactModal/context/EditContactApiContext.d.ts +10 -0
  22. package/dist/esm/types/components/EditContactModal/hooks/useEditBusiness/useEditBusiness.d.ts +1 -1
  23. package/dist/esm/types/components/EditContactModal/hooks/useEditContact/useEditContact.d.ts +1 -1
  24. package/dist/esm/types/components/EditContactModal/hooks/useModalCloseHandler.d.ts +1 -1
  25. package/dist/esm/types/components/EditContactModal/hooks/useTagsEditorController.d.ts +3 -0
  26. package/dist/esm/types/components/EditContactModal/layout/Section.d.ts +1 -1
  27. package/dist/esm/types/components/EditContactModal/services/api.d.ts +14 -6
  28. package/dist/esm/types/i18n/config.d.ts +2 -0
  29. package/dist/esm/types/i18n/index.d.ts +2 -0
  30. package/dist/esm/types/index.d.ts +1 -0
  31. package/dist/index.d.ts +5 -4
  32. package/package.json +5 -2
package/dist/cjs/index.js CHANGED
@@ -3,6 +3,8 @@
3
3
  var React$1 = require('react');
4
4
  var material = require('@mui/material');
5
5
  var react = require('@emotion/react');
6
+ var reactI18next = require('react-i18next');
7
+ var i18n = require('i18next');
6
8
  var ReactDOM = require('react-dom');
7
9
 
8
10
  function _interopNamespaceDefault(e) {
@@ -4738,11 +4740,11 @@ var createStyled$2 = function createStyled(tag, options) {
4738
4740
  };
4739
4741
  };
4740
4742
 
4741
- var tags = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', // SVG
4743
+ var tags$2 = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', // SVG
4742
4744
  'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
4743
4745
 
4744
4746
  var newStyled = createStyled$2.bind();
4745
- tags.forEach(function (tagName) {
4747
+ tags$2.forEach(function (tagName) {
4746
4748
  // $FlowFixMe: we can ignore this because its exposed type is defined by the CreateStyled type
4747
4749
  newStyled[tagName] = newStyled(tagName);
4748
4750
  });
@@ -6429,7 +6431,7 @@ function memoize(fn) {
6429
6431
  };
6430
6432
  }
6431
6433
 
6432
- const properties = {
6434
+ const properties$2 = {
6433
6435
  m: 'margin',
6434
6436
  p: 'padding'
6435
6437
  };
@@ -6461,7 +6463,7 @@ const getCssProperties = memoize(prop => {
6461
6463
  }
6462
6464
  }
6463
6465
  const [a, b] = prop.split('');
6464
- const property = properties[a];
6466
+ const property = properties$2[a];
6465
6467
  const direction = directions[b] || '';
6466
6468
  return Array.isArray(direction) ? direction.map(dir => property + dir) : [property + direction];
6467
6469
  });
@@ -7419,21 +7421,21 @@ var styleFunctionSx = /*#__PURE__*/Object.freeze({
7419
7421
 
7420
7422
  var require$$8 = /*@__PURE__*/getAugmentedNamespace(styleFunctionSx);
7421
7423
 
7422
- var _interopRequireDefault$i = interopRequireDefaultExports;
7424
+ var _interopRequireDefault$j = interopRequireDefaultExports;
7423
7425
  Object.defineProperty(createStyled$3, "__esModule", {
7424
7426
  value: true
7425
7427
  });
7426
7428
  var _default = createStyled$3.default = createStyled$1;
7427
7429
  var shouldForwardProp_1 = createStyled$3.shouldForwardProp = shouldForwardProp$1;
7428
7430
  createStyled$3.systemDefaultTheme = void 0;
7429
- var _extends2 = _interopRequireDefault$i(require_extends());
7430
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault$i(requireObjectWithoutPropertiesLoose());
7431
+ var _extends2 = _interopRequireDefault$j(require_extends());
7432
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault$j(requireObjectWithoutPropertiesLoose());
7431
7433
  var _styledEngine$1 = _interopRequireWildcard$2(require$$1$1);
7432
7434
  var _deepmerge = require$$4;
7433
- var _capitalize = _interopRequireDefault$i(require$$5);
7434
- var _getDisplayName = _interopRequireDefault$i(require$$6);
7435
- var _createTheme = _interopRequireDefault$i(require$$7);
7436
- var _styleFunctionSx = _interopRequireDefault$i(require$$8);
7435
+ var _capitalize = _interopRequireDefault$j(require$$5);
7436
+ var _getDisplayName = _interopRequireDefault$j(require$$6);
7437
+ var _createTheme = _interopRequireDefault$j(require$$7);
7438
+ var _styleFunctionSx = _interopRequireDefault$j(require$$8);
7437
7439
  const _excluded$1v = ["ownerState"],
7438
7440
  _excluded2$d = ["variants"],
7439
7441
  _excluded3$4 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
@@ -7703,7 +7705,7 @@ var require$$1 = /*@__PURE__*/getAugmentedNamespace(formatMuiErrorMessage$1);
7703
7705
 
7704
7706
  var require$$2 = /*@__PURE__*/getAugmentedNamespace(clamp);
7705
7707
 
7706
- var _interopRequireDefault$h = interopRequireDefaultExports;
7708
+ var _interopRequireDefault$i = interopRequireDefaultExports;
7707
7709
  Object.defineProperty(colorManipulator, "__esModule", {
7708
7710
  value: true
7709
7711
  });
@@ -7725,8 +7727,8 @@ colorManipulator.private_safeEmphasize = private_safeEmphasize;
7725
7727
  colorManipulator.private_safeLighten = private_safeLighten;
7726
7728
  colorManipulator.recomposeColor = recomposeColor$1;
7727
7729
  colorManipulator.rgbToHex = rgbToHex;
7728
- var _formatMuiErrorMessage2 = _interopRequireDefault$h(require$$1);
7729
- var _clamp = _interopRequireDefault$h(require$$2);
7730
+ var _formatMuiErrorMessage2 = _interopRequireDefault$i(require$$1);
7731
+ var _clamp = _interopRequireDefault$i(require$$2);
7730
7732
  /* eslint-disable @typescript-eslint/naming-convention */
7731
7733
 
7732
7734
  /**
@@ -9092,27 +9094,27 @@ function requireCreateSvgIcon () {
9092
9094
  return createSvgIcon;
9093
9095
  }
9094
9096
 
9095
- var _interopRequireDefault$g = interopRequireDefaultExports;
9097
+ var _interopRequireDefault$h = interopRequireDefaultExports;
9096
9098
  Object.defineProperty(ArrowForward, "__esModule", {
9097
9099
  value: true
9098
9100
  });
9099
- var default_1$h = ArrowForward.default = void 0;
9100
- var _createSvgIcon$g = _interopRequireDefault$g(requireCreateSvgIcon());
9101
- var _jsxRuntime$g = jsxRuntimeExports;
9102
- default_1$h = ArrowForward.default = (0, _createSvgIcon$g.default)( /*#__PURE__*/(0, _jsxRuntime$g.jsx)("path", {
9101
+ var default_1$i = ArrowForward.default = void 0;
9102
+ var _createSvgIcon$h = _interopRequireDefault$h(requireCreateSvgIcon());
9103
+ var _jsxRuntime$h = jsxRuntimeExports;
9104
+ default_1$i = ArrowForward.default = (0, _createSvgIcon$h.default)( /*#__PURE__*/(0, _jsxRuntime$h.jsx)("path", {
9103
9105
  d: "m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"
9104
9106
  }), 'ArrowForward');
9105
9107
 
9106
9108
  var Message = {};
9107
9109
 
9108
- var _interopRequireDefault$f = interopRequireDefaultExports;
9110
+ var _interopRequireDefault$g = interopRequireDefaultExports;
9109
9111
  Object.defineProperty(Message, "__esModule", {
9110
9112
  value: true
9111
9113
  });
9112
- var default_1$g = Message.default = void 0;
9113
- var _createSvgIcon$f = _interopRequireDefault$f(requireCreateSvgIcon());
9114
- var _jsxRuntime$f = jsxRuntimeExports;
9115
- default_1$g = Message.default = (0, _createSvgIcon$f.default)( /*#__PURE__*/(0, _jsxRuntime$f.jsx)("path", {
9114
+ var default_1$h = Message.default = void 0;
9115
+ var _createSvgIcon$g = _interopRequireDefault$g(requireCreateSvgIcon());
9116
+ var _jsxRuntime$g = jsxRuntimeExports;
9117
+ default_1$h = Message.default = (0, _createSvgIcon$g.default)( /*#__PURE__*/(0, _jsxRuntime$g.jsx)("path", {
9116
9118
  d: "M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-2 12H6v-2h12zm0-3H6V9h12zm0-3H6V6h12z"
9117
9119
  }), 'Message');
9118
9120
 
@@ -9192,7 +9194,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
9192
9194
  handleNavigateToContacts(e);
9193
9195
  onClose();
9194
9196
  }
9195
- }, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$h, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
9197
+ }, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$i, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
9196
9198
  handleNavigateToConversations(e);
9197
9199
  onClose();
9198
9200
  }, onMouseDown: (e) => {
@@ -9201,7 +9203,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
9201
9203
  handleNavigateToConversations(e);
9202
9204
  onClose();
9203
9205
  }
9204
- }, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$g, { fontSize: "small" }) })] }), isLoading ? (jsxRuntimeExports.jsx(LoadingContainer, { children: jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) })) : (jsxRuntimeExports.jsx(ContactAvatar, { src: imgUrl, alt: avatarAlt, onError: () => onError?.(new Error('Failed to load avatar')) })), jsxRuntimeExports.jsx(ContactName$1, { variant: "h6", title: displayName, children: displayName })] }));
9206
+ }, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$h, { fontSize: "small" }) })] }), isLoading ? (jsxRuntimeExports.jsx(LoadingContainer, { children: jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) })) : (jsxRuntimeExports.jsx(ContactAvatar, { src: imgUrl, alt: avatarAlt, onError: () => onError?.(new Error('Failed to load avatar')) })), jsxRuntimeExports.jsx(ContactName$1, { variant: "h6", title: displayName, children: displayName })] }));
9205
9207
  };
9206
9208
 
9207
9209
  const Container$1 = material.styled(material.Box)({
@@ -15289,6 +15291,166 @@ const MembersSection = ({ contactData, title, navigate }) => {
15289
15291
  return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(SectionTitle, { gutterBottom: true, mt: 2, variant: "subtitle1", children: title }), contactData?.members.map((member) => (jsxRuntimeExports.jsx(MemberItem, { memberId: String(member.id), name: member.name, navigate: navigate }, member.id)))] }));
15290
15292
  };
15291
15293
 
15294
+ var add$1 = "Add";
15295
+ var close$1 = "Close";
15296
+ var labels$1 = "Labels";
15297
+ var phone$1 = "Phone";
15298
+ var phones$1 = "Phones";
15299
+ var number$1 = "Number";
15300
+ var business$1 = "Business";
15301
+ var businessMembers$1 = "Business Members";
15302
+ var properties$1 = "Properties";
15303
+ var note$1 = "Note";
15304
+ var view$1 = "View";
15305
+ var email$1 = "Email";
15306
+ var tags$1 = "Tags";
15307
+ var global$2 = {
15308
+ back: "Back",
15309
+ save: "Save",
15310
+ noOptions: "No options",
15311
+ noValue: "No value",
15312
+ birthdate: "Birthdate"
15313
+ };
15314
+ var avatar$1 = {
15315
+ upload: "Upload photo",
15316
+ "delete": "Delete photo"
15317
+ };
15318
+ var contactEdit$1 = {
15319
+ from: "From",
15320
+ to: "To"
15321
+ };
15322
+ var conversations$1 = {
15323
+ contactDetails: {
15324
+ contactOwner: "Contact Owner",
15325
+ business: "Business",
15326
+ createdBy: "Created By",
15327
+ modifiedBy: "Modified By",
15328
+ street: "Street",
15329
+ city: "City",
15330
+ state: "State",
15331
+ postcode: "Postcode",
15332
+ country: "Country",
15333
+ addressInformation: "Address Information",
15334
+ primaryAddress: "Primary Address",
15335
+ secondaryAddress: "Secondary Address",
15336
+ contactInformation: "Contact Information",
15337
+ phones: "Phones",
15338
+ contactInfo: {
15339
+ emptySelection: "No selection"
15340
+ }
15341
+ },
15342
+ businessDetails: {
15343
+ businessOwner: "Business Owner"
15344
+ }
15345
+ };
15346
+ var en = {
15347
+ add: add$1,
15348
+ close: close$1,
15349
+ labels: labels$1,
15350
+ phone: phone$1,
15351
+ phones: phones$1,
15352
+ number: number$1,
15353
+ business: business$1,
15354
+ businessMembers: businessMembers$1,
15355
+ properties: properties$1,
15356
+ note: note$1,
15357
+ view: view$1,
15358
+ email: email$1,
15359
+ tags: tags$1,
15360
+ global: global$2,
15361
+ avatar: avatar$1,
15362
+ contactEdit: contactEdit$1,
15363
+ conversations: conversations$1
15364
+ };
15365
+
15366
+ var add = "Agregar";
15367
+ var close = "Cerrar";
15368
+ var labels = "Etiquetas";
15369
+ var phone = "Teléfono";
15370
+ var phones = "Teléfonos";
15371
+ var number = "Número";
15372
+ var business = "Empresa";
15373
+ var businessMembers = "Miembros de la empresa";
15374
+ var properties = "Propiedades";
15375
+ var note = "Nota";
15376
+ var view = "Ver";
15377
+ var email = "Correo Electrónico";
15378
+ var tags = "Etiquetas";
15379
+ var global$1 = {
15380
+ back: "Atrás",
15381
+ save: "Guardar",
15382
+ noOptions: "Sin opciones",
15383
+ noValue: "Sin valor",
15384
+ birthdate: "Fecha de nacimiento"
15385
+ };
15386
+ var avatar = {
15387
+ upload: "Subir foto",
15388
+ "delete": "Eliminar foto"
15389
+ };
15390
+ var contactEdit = {
15391
+ from: "Desde",
15392
+ to: "Hasta"
15393
+ };
15394
+ var conversations = {
15395
+ contactDetails: {
15396
+ contactOwner: "Propietario del contacto",
15397
+ business: "Empresa",
15398
+ createdBy: "Creado por",
15399
+ modifiedBy: "Modificado por",
15400
+ street: "Calle",
15401
+ city: "Ciudad",
15402
+ state: "Estado",
15403
+ postcode: "Código postal",
15404
+ country: "País",
15405
+ addressInformation: "Información de dirección",
15406
+ primaryAddress: "Dirección principal",
15407
+ secondaryAddress: "Dirección secundaria",
15408
+ contactInformation: "Información de contacto",
15409
+ phones: "Teléfonos",
15410
+ contactInfo: {
15411
+ emptySelection: "Sin selección"
15412
+ }
15413
+ },
15414
+ businessDetails: {
15415
+ businessOwner: "Propietario de la empresa"
15416
+ }
15417
+ };
15418
+ var es = {
15419
+ add: add,
15420
+ close: close,
15421
+ labels: labels,
15422
+ phone: phone,
15423
+ phones: phones,
15424
+ number: number,
15425
+ business: business,
15426
+ businessMembers: businessMembers,
15427
+ properties: properties,
15428
+ note: note,
15429
+ view: view,
15430
+ email: email,
15431
+ tags: tags,
15432
+ global: global$1,
15433
+ avatar: avatar,
15434
+ contactEdit: contactEdit,
15435
+ conversations: conversations
15436
+ };
15437
+
15438
+ const resources = {
15439
+ en: { translation: en },
15440
+ es: { translation: es },
15441
+ };
15442
+ i18n.use(reactI18next.initReactI18next).init({
15443
+ resources,
15444
+ lng: 'en',
15445
+ fallbackLng: 'en',
15446
+ interpolation: {
15447
+ escapeValue: false,
15448
+ },
15449
+ react: {
15450
+ useSuspense: false,
15451
+ },
15452
+ });
15453
+
15292
15454
  const PopupContainer = material.styled(material.Box)(({ theme }) => ({
15293
15455
  //@ts-ignore
15294
15456
  backgroundColor: theme.palette.background.panel,
@@ -15316,15 +15478,14 @@ const PopupContainer = material.styled(material.Box)(({ theme }) => ({
15316
15478
  background: '#616161',
15317
15479
  },
15318
15480
  }));
15319
- const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl, navigate, t = (key) => ({
15320
- labels: 'Etiquetas',
15321
- phone: 'Teléfono',
15322
- business: 'Empresa',
15323
- businessMembers: 'Miembros de la empresa',
15324
- properties: 'Propiedades',
15325
- view: 'Ver',
15326
- email: 'Correo Electrónico',
15327
- }[key] || key), }) => {
15481
+ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl, navigate, language = 'en', }) => {
15482
+ const { t: i18nT, i18n } = reactI18next.useTranslation();
15483
+ React$1.useEffect(() => {
15484
+ if (language) {
15485
+ i18n.changeLanguage(language);
15486
+ }
15487
+ }, [language, i18n]);
15488
+ const t = i18nT;
15328
15489
  const dataIsBusiness = isBusiness$1(contactData);
15329
15490
  const dataIsContact = isContact$1(contactData);
15330
15491
  const contactMethods = [
@@ -15375,9 +15536,22 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
15375
15536
  window.removeEventListener('keydown', handleKeyDown);
15376
15537
  };
15377
15538
  }, [open, onClose]);
15378
- return (jsxRuntimeExports.jsx(material.Popper, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(material.ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(material.CardContent, { children: [jsxRuntimeExports.jsx(Header$1, { navigate: navigate, contactId: contactData?.id, imgUrl: avatarImgUrl, name: contactData?.name, onClose: onClose, isBusiness: dataIsBusiness }), jsxRuntimeExports.jsx(LabelsSection, { contactData: contactData, title: t('labels') }), dataIsContact && (jsxRuntimeExports.jsx(BusinessSection, { contactData: contactData, title: t('business') })), dataIsBusiness && (jsxRuntimeExports.jsx(MembersSection, { contactData: contactData, title: t('businessMembers'), navigate: navigate })), contactMethods.map((method, index) => (jsxRuntimeExports.jsx(ContactMethod$1, { icon: method.icon, title: method.title, contactList: method.contactList, showTitle: method.showTitle }, index))), jsxRuntimeExports.jsx(Properties, { properties: contactData?.properties, title: t('properties') })] }) }) }) }));
15539
+ return (jsxRuntimeExports.jsx(material.Popper, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(material.ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(material.CardContent, { children: [jsxRuntimeExports.jsx(Header$1, { navigate: navigate, contactId: contactData?.id, imgUrl: avatarImgUrl, name: contactData?.name, onClose: onClose, isBusiness: dataIsBusiness }), jsxRuntimeExports.jsx(LabelsSection, { contactData: contactData, title: t('labels') }), dataIsContact && jsxRuntimeExports.jsx(BusinessSection, { contactData: contactData, title: t('business') }), dataIsBusiness && (jsxRuntimeExports.jsx(MembersSection, { contactData: contactData, title: t('businessMembers'), navigate: navigate })), contactMethods.map((method, index) => (jsxRuntimeExports.jsx(ContactMethod$1, { icon: method.icon, title: method.title, contactList: method.contactList, showTitle: method.showTitle }, index))), jsxRuntimeExports.jsx(Properties, { properties: contactData?.properties, title: t('properties') })] }) }) }) }));
15379
15540
  };
15380
15541
 
15542
+ var Close = {};
15543
+
15544
+ var _interopRequireDefault$f = interopRequireDefaultExports;
15545
+ Object.defineProperty(Close, "__esModule", {
15546
+ value: true
15547
+ });
15548
+ var default_1$g = Close.default = void 0;
15549
+ var _createSvgIcon$f = _interopRequireDefault$f(requireCreateSvgIcon());
15550
+ var _jsxRuntime$f = jsxRuntimeExports;
15551
+ default_1$g = Close.default = (0, _createSvgIcon$f.default)( /*#__PURE__*/(0, _jsxRuntime$f.jsx)("path", {
15552
+ d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
15553
+ }), 'Close');
15554
+
15381
15555
  var Edit = {};
15382
15556
 
15383
15557
  var _interopRequireDefault$e = interopRequireDefaultExports;
@@ -15442,7 +15616,6 @@ const Tags = ({ tags, onEditTags }) => {
15442
15616
  justifyContent: 'center',
15443
15617
  }, children: [jsxRuntimeExports.jsxs(material.Box, { sx: {
15444
15618
  maxWidth: 320,
15445
- pr: 4,
15446
15619
  position: 'relative',
15447
15620
  '&:hover .tags-action, &:focus-within .tags-action': {
15448
15621
  opacity: 1,
@@ -15456,7 +15629,8 @@ const Tags = ({ tags, onEditTags }) => {
15456
15629
  },
15457
15630
  } }, tag.id))), hiddenCount > 0 ? (jsxRuntimeExports.jsx(material.Chip, { label: `+${hiddenCount}`, size: "small", variant: "outlined", onClick: handleOpen, sx: { borderRadius: 999 } })) : null] }), jsxRuntimeExports.jsx(material.IconButton, { className: "tags-action", size: "small", "aria-label": safeTags.length ? t('tags.edit') : t('tags.add'), onClick: onEditTags, sx: {
15458
15631
  position: 'absolute',
15459
- right: 0,
15632
+ left: '100%',
15633
+ ml: 1,
15460
15634
  top: '50%',
15461
15635
  transform: 'translateY(-50%)',
15462
15636
  color: 'text.secondary',
@@ -15467,7 +15641,7 @@ const Tags = ({ tags, onEditTags }) => {
15467
15641
  bgcolor: 'action.hover',
15468
15642
  color: 'text.primary',
15469
15643
  },
15470
- }, children: safeTags.length ? (jsxRuntimeExports.jsx(default_1$f, { fontSize: "small" })) : (jsxRuntimeExports.jsx(default_1$e, { fontSize: "small" })) })] }), jsxRuntimeExports.jsx(material.Popover, { open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }, children: jsxRuntimeExports.jsxs(material.Box, { sx: { p: 1.5, maxWidth: 320, maxHeight: 240, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle2", sx: { mb: 1 }, children: t('tags') }), jsxRuntimeExports.jsx(material.Stack, { direction: "row", spacing: 1, useFlexGap: true, flexWrap: "wrap", children: safeTags.map((tag) => (jsxRuntimeExports.jsx(material.Chip, { label: tag.name, size: "small", variant: "outlined", sx: {
15644
+ }, children: safeTags.length ? jsxRuntimeExports.jsx(default_1$f, { fontSize: "small" }) : jsxRuntimeExports.jsx(default_1$e, { fontSize: "small" }) })] }), jsxRuntimeExports.jsx(material.Popover, { open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }, children: jsxRuntimeExports.jsxs(material.Box, { sx: { p: 1.5, maxWidth: 320, maxHeight: 240, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle2", sx: { mb: 1 }, children: t('tags') }), jsxRuntimeExports.jsx(material.Stack, { direction: "row", spacing: 1, useFlexGap: true, flexWrap: "wrap", children: safeTags.map((tag) => (jsxRuntimeExports.jsx(material.Chip, { label: tag.name, size: "small", variant: "outlined", sx: {
15471
15645
  borderRadius: 999,
15472
15646
  maxWidth: 160,
15473
15647
  '& .MuiChip-label': {
@@ -15494,8 +15668,13 @@ const NameWrapper = material.styled(material.Box)({
15494
15668
  display: 'flex',
15495
15669
  alignItems: 'center',
15496
15670
  justifyContent: 'center',
15497
- gap: '8px',
15498
15671
  width: '100%',
15672
+ });
15673
+ const NameContainer = material.styled(material.Box)({
15674
+ position: 'relative',
15675
+ display: 'flex',
15676
+ justifyContent: 'center',
15677
+ maxWidth: '100%',
15499
15678
  '&:hover .edit-icon': {
15500
15679
  opacity: 1,
15501
15680
  visibility: 'visible',
@@ -15505,6 +15684,10 @@ const EditButton = material.styled(material.IconButton)({
15505
15684
  opacity: 0,
15506
15685
  visibility: 'hidden',
15507
15686
  transition: 'all 0.2s',
15687
+ position: 'absolute',
15688
+ left: '100%',
15689
+ top: '50%',
15690
+ transform: 'translateY(-50%)',
15508
15691
  });
15509
15692
  const ContactName = ({ displayName, contactType, firstName, lastName, name, entityId, onEntityUpdated, }) => {
15510
15693
  const api = useEditContactApi();
@@ -15555,7 +15738,7 @@ const ContactName = ({ displayName, contactType, firstName, lastName, name, enti
15555
15738
  if (isEditing) {
15556
15739
  return (jsxRuntimeExports.jsxs(material.Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mt: 1 }, children: [contactType === 'contact' ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(material.TextField, { value: values.firstName, onChange: (e) => setValues({ ...values, firstName: e.target.value }), size: "small", placeholder: "First Name", sx: { width: 140 } }), jsxRuntimeExports.jsx(material.TextField, { value: values.lastName, onChange: (e) => setValues({ ...values, lastName: e.target.value }), size: "small", placeholder: "Last Name", sx: { width: 140 } })] })) : (jsxRuntimeExports.jsx(material.TextField, { value: values.name, onChange: (e) => setValues({ ...values, name: e.target.value }), size: "small", placeholder: "Name", sx: { width: 280 } })), jsxRuntimeExports.jsx(material.IconButton, { onClick: handleSave, disabled: loading, color: "primary", children: loading ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(Save$1, {}) })] }));
15557
15740
  }
15558
- return (jsxRuntimeExports.jsxs(NameWrapper, { children: [jsxRuntimeExports.jsx(NameText, { variant: "h6", title: displayName, children: displayName }), showEdit && (jsxRuntimeExports.jsx(EditButton, { size: "small", onClick: () => setIsEditing(true), className: "edit-icon", children: jsxRuntimeExports.jsx(Edit$1, { fontSize: "small" }) }))] }));
15741
+ return (jsxRuntimeExports.jsx(NameWrapper, { children: jsxRuntimeExports.jsxs(NameContainer, { children: [jsxRuntimeExports.jsx(NameText, { variant: "h6", title: displayName, children: displayName }), showEdit && (jsxRuntimeExports.jsx(EditButton, { size: "small", onClick: () => setIsEditing(true), className: "edit-icon", sx: { ml: 1 }, children: jsxRuntimeExports.jsx(Edit$1, { fontSize: "small" }) }))] }) }));
15559
15742
  };
15560
15743
 
15561
15744
  var Delete = {};
@@ -24670,7 +24853,7 @@ const PAGE_SIZE = 20;
24670
24853
  const AutocompletePopper = styled$3(MuiPopper)(({ theme }) => ({
24671
24854
  zIndex: theme.zIndex.modal + 1,
24672
24855
  }));
24673
- const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
24856
+ const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving, onCreateNew, isCreatingNew, }) => {
24674
24857
  const t = useTranslationContext();
24675
24858
  const [searchValue, setSearchValue] = React$1.useState('');
24676
24859
  const [limit, setLimit] = React$1.useState(PAGE_SIZE);
@@ -24686,10 +24869,19 @@ const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
24686
24869
  if (nearBottom)
24687
24870
  setLimit((l) => l + PAGE_SIZE);
24688
24871
  };
24689
- return (jsxRuntimeExports.jsxs(material.Box, { sx: { width: '100%' }, children: [jsxRuntimeExports.jsxs(material.Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 2 }, children: [jsxRuntimeExports.jsx(material.IconButton, { size: "small", onClick: onBack, "aria-label": t('global.back'), disabled: isSaving, children: jsxRuntimeExports.jsx(default_1$b, { fontSize: "small" }) }), jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", children: t('tags') }), jsxRuntimeExports.jsx(material.Box, { sx: { flex: 1 } }), jsxRuntimeExports.jsx(LoadingButton$1, { variant: "contained", size: "small", startIcon: jsxRuntimeExports.jsx(default_1$a, {}), onClick: onSave, loading: isSaving, disabled: isSaving, children: t('global.save') })] }), jsxRuntimeExports.jsx(material.Autocomplete, { multiple: true, value: value, onChange: (_, newValue) => onChange(newValue), options: visibleOptions, filterOptions: (x) => x, inputValue: searchValue, onInputChange: handleSearchChange, getOptionLabel: (option) => option?.name ?? '', isOptionEqualToValue: (o, v) => String(o?.id) === String(v?.id), PopperComponent: AutocompletePopper, renderOption: (props, option) => jsxRuntimeExports.jsx("li", { ...props, children: option.name ?? '' }), renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => (jsxRuntimeExports.jsx(material.Chip, { label: option.name ?? '', ...getTagProps({ index }) }))), size: "small", renderInput: (params) => jsxRuntimeExports.jsx(material.TextField, { ...params, size: "small" }), ListboxProps: {
24872
+ const CustomNoOptionsMessage = () => {
24873
+ const trimmedSearchValue = String(searchValue ?? '').trim();
24874
+ const isDisabled = !trimmedSearchValue || isSaving || isCreatingNew;
24875
+ return (jsxRuntimeExports.jsxs(material.Box, { sx: {
24876
+ display: 'flex',
24877
+ justifyContent: 'space-between',
24878
+ alignItems: 'center',
24879
+ }, children: [t('global.noOptions'), jsxRuntimeExports.jsx(LoadingButton$1, { onClick: () => onCreateNew(trimmedSearchValue), loading: isCreatingNew, disabled: isDisabled, variant: "contained", size: "small", sx: { marginTop: 1.3 }, children: t('global.createNew') })] }));
24880
+ };
24881
+ return (jsxRuntimeExports.jsxs(material.Box, { sx: { width: '100%' }, children: [jsxRuntimeExports.jsxs(material.Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 2 }, children: [jsxRuntimeExports.jsx(material.IconButton, { size: "small", onClick: onBack, "aria-label": t('global.back'), disabled: isSaving, children: jsxRuntimeExports.jsx(default_1$b, { fontSize: "small" }) }), jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", children: t('tags') }), jsxRuntimeExports.jsx(material.Box, { sx: { flex: 1 } }), jsxRuntimeExports.jsx(LoadingButton$1, { variant: "contained", size: "small", startIcon: jsxRuntimeExports.jsx(default_1$a, {}), onClick: onSave, loading: isSaving, disabled: isSaving, children: t('global.save') })] }), jsxRuntimeExports.jsx(material.Autocomplete, { multiple: true, disablePortal: false, value: value, onChange: (_, newValue) => onChange(newValue), options: visibleOptions, filterOptions: (x) => x, inputValue: searchValue, onInputChange: handleSearchChange, getOptionLabel: (option) => option?.name ?? '', isOptionEqualToValue: (o, v) => String(o?.id) === String(v?.id), PopperComponent: AutocompletePopper, renderOption: (props, option) => jsxRuntimeExports.jsx("li", { ...props, children: option.name ?? '' }), renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => (jsxRuntimeExports.jsx(material.Chip, { label: option.name ?? '', ...getTagProps({ index }) }))), size: "small", renderInput: (params) => jsxRuntimeExports.jsx(material.TextField, { ...params, size: "small" }), ListboxProps: {
24690
24882
  onScroll: onListboxScroll,
24691
24883
  sx: { maxHeight: 280, overflowY: 'auto' },
24692
- }, noOptionsText: t('global.noOptions'), sx: { width: '100%' } })] }));
24884
+ }, noOptionsText: jsxRuntimeExports.jsx(CustomNoOptionsMessage, {}), sx: { width: '100%' } })] }));
24693
24885
  };
24694
24886
 
24695
24887
  class ApiError extends Error {
@@ -24763,17 +24955,22 @@ async function fetchLabels({ baseUrl, spaceId, signal }) {
24763
24955
  const url = joinUrl(urls.CONTACTS, '/labels');
24764
24956
  return requestJson({ url, signal });
24765
24957
  }
24958
+ async function createLabel({ baseUrl, spaceId, name, signal }) {
24959
+ const urls = getApiUrls(baseUrl, spaceId);
24960
+ const url = joinUrl(urls.CONTACTS, '/labels');
24961
+ return requestJson({ url, method: 'POST', body: { name }, signal });
24962
+ }
24766
24963
  async function fetchContact({ baseUrl, spaceId, contactId, signal }) {
24767
24964
  const urls = getApiUrls(baseUrl, spaceId);
24768
24965
  const url = joinUrl(urls.CONTACTS, `/contacts/${encodeURIComponent(contactId)}`);
24769
24966
  return requestJson({ url, signal });
24770
24967
  }
24771
- async function fetchContactFields({ baseUrl, spaceId, forType, signal }) {
24968
+ async function fetchContactFields({ baseUrl, spaceId, forType, signal, }) {
24772
24969
  const urls = getApiUrls(baseUrl, spaceId);
24773
24970
  const url = `${joinUrl(urls.CONTACTS, '/ContactFields')}?filter=custom&for=${encodeURIComponent(forType)}`;
24774
24971
  return requestJson({ url, signal });
24775
24972
  }
24776
- async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }) {
24973
+ async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal, }) {
24777
24974
  const path = entityType === 'business'
24778
24975
  ? `/business/${encodeURIComponent(entityId)}`
24779
24976
  : `/contacts/${encodeURIComponent(entityId)}`;
@@ -24786,7 +24983,7 @@ async function deleteAddress({ baseUrl, spaceId, data, signal }) {
24786
24983
  const url = joinUrl(urls.CONTACTS, '/contactAddresses');
24787
24984
  return requestJson({ url, method: 'DELETE', body: data, signal });
24788
24985
  }
24789
- async function checkContactAddress({ baseUrl, spaceId, data, signal }) {
24986
+ async function checkContactAddress({ baseUrl, spaceId, data, signal, }) {
24790
24987
  const urls = getApiUrls(baseUrl, spaceId);
24791
24988
  const url = joinUrl(urls.CONTACTS, '/contactAddresses/check');
24792
24989
  return requestJson({ url, method: 'POST', body: data, signal });
@@ -24796,7 +24993,7 @@ async function setContactAddress({ baseUrl, spaceId, data, signal }) {
24796
24993
  const url = joinUrl(urls.CONTACTS, '/contactAddresses/set');
24797
24994
  return requestJson({ url, method: 'POST', body: data, signal });
24798
24995
  }
24799
- async function updateContactAddress({ baseUrl, spaceId, data, signal }) {
24996
+ async function updateContactAddress({ baseUrl, spaceId, data, signal, }) {
24800
24997
  const urls = getApiUrls(baseUrl, spaceId);
24801
24998
  const url = joinUrl(urls.CONTACTS, `/contactAddresses/${encodeURIComponent(data.contactAddressId)}`);
24802
24999
  return requestJson({ url, method: 'PUT', body: data, signal });
@@ -24811,12 +25008,12 @@ async function fetchUsers({ baseUrl, spaceId, signal }) {
24811
25008
  const url = joinUrl(urls.SETTINGS, `/users`);
24812
25009
  return requestJson({ url, signal });
24813
25010
  }
24814
- async function fetchUserTriiById({ baseUrl, spaceId, signal, userId }) {
25011
+ async function fetchUserTriiById({ baseUrl, spaceId, signal, userId, }) {
24815
25012
  const urls = getApiUrls(baseUrl, spaceId);
24816
25013
  const url = joinUrl(urls.SETTINGS, `/usersInfor/${userId}`);
24817
25014
  return requestJson({ url, signal });
24818
25015
  }
24819
- async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
25016
+ async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal, }) {
24820
25017
  const urls = getApiUrls(baseUrl, spaceId);
24821
25018
  const fd = new FormData();
24822
25019
  fd.append('file', file, file.name);
@@ -24825,6 +25022,7 @@ async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
24825
25022
  }
24826
25023
  const createEditContactApi = (baseUrl, spaceId) => ({
24827
25024
  fetchLabels: ({ signal } = {}) => fetchLabels({ baseUrl, spaceId, signal }),
25025
+ createLabel: ({ name, signal }) => createLabel({ baseUrl, spaceId, name, signal }),
24828
25026
  fetchContact: ({ contactId, signal }) => fetchContact({ baseUrl, spaceId, contactId, signal }),
24829
25027
  fetchContactFields: ({ forType, signal }) => fetchContactFields({ baseUrl, spaceId, forType, signal }),
24830
25028
  updateEntity: ({ entityType, entityId, body, signal }) => updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }),
@@ -25631,6 +25829,7 @@ var editContactHelper = { getEditedField, getAddressesWithUpdatedValues };
25631
25829
 
25632
25830
  const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, }) => {
25633
25831
  const [isDeletingAddress, setIsDeletingAddress] = React$1.useState(false);
25832
+ const [initialSnapshot, setInitialSnapshot] = React$1.useState(() => initial);
25634
25833
  const [imsFacebooks, setImsFacebooks] = React$1.useState(initial?.ims_facebook || []);
25635
25834
  const [imsMercadolibre, setImsMercadolibre] = React$1.useState(initial?.ims_mercadolibre || []);
25636
25835
  const [imsWebchats, setImsWebchats] = React$1.useState(initial?.ims_webchat || []);
@@ -25662,6 +25861,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25662
25861
  const addWhatsappVerified = (newWhatsapp) => {
25663
25862
  const updatedWhatsapps = [...imsWhatsapp, newWhatsapp];
25664
25863
  setImsWhatsApp(updatedWhatsapps);
25864
+ setInitialSnapshot((prev) => ({
25865
+ ...(prev ?? {}),
25866
+ ims_whatsapp: updatedWhatsapps,
25867
+ }));
25665
25868
  };
25666
25869
  const replaceAddress = (addressId, newAddress) => {
25667
25870
  if (!newAddress) {
@@ -25675,6 +25878,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25675
25878
  return email;
25676
25879
  });
25677
25880
  setEmails(newEmails);
25881
+ setInitialSnapshot((prev) => ({
25882
+ ...(prev ?? {}),
25883
+ emails: newEmails,
25884
+ }));
25678
25885
  }
25679
25886
  if (newAddress.channelType === 5) {
25680
25887
  const newPhoneNumbers = phoneNumbers.map((phoneNumber) => {
@@ -25684,6 +25891,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25684
25891
  return phoneNumber;
25685
25892
  });
25686
25893
  setPhoneNumbers(newPhoneNumbers);
25894
+ setInitialSnapshot((prev) => ({
25895
+ ...(prev ?? {}),
25896
+ phones: newPhoneNumbers,
25897
+ }));
25687
25898
  }
25688
25899
  if (newAddress.channelType === 13) {
25689
25900
  const newImsWhatsapp = imsWhatsapp.map((item) => {
@@ -25693,6 +25904,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25693
25904
  return item;
25694
25905
  });
25695
25906
  setImsWhatsApp(newImsWhatsapp);
25907
+ setInitialSnapshot((prev) => ({
25908
+ ...(prev ?? {}),
25909
+ ims_whatsapp: newImsWhatsapp,
25910
+ }));
25696
25911
  }
25697
25912
  if (newAddress.channelType === 21) {
25698
25913
  const newImsRCS = imsRCS.map((item) => {
@@ -25702,6 +25917,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25702
25917
  return item;
25703
25918
  });
25704
25919
  setImsRCS(newImsRCS);
25920
+ setInitialSnapshot((prev) => ({
25921
+ ...(prev ?? {}),
25922
+ ims_rcs: newImsRCS,
25923
+ }));
25705
25924
  }
25706
25925
  if (newAddress.channelType === 41) {
25707
25926
  const newImsMercadolibre = imsMercadolibre.map((item) => {
@@ -25711,6 +25930,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25711
25930
  return item;
25712
25931
  });
25713
25932
  setImsMercadolibre(newImsMercadolibre);
25933
+ setInitialSnapshot((prev) => ({
25934
+ ...(prev ?? {}),
25935
+ ims_mercadolibre: newImsMercadolibre,
25936
+ }));
25714
25937
  }
25715
25938
  };
25716
25939
  const handleAddressFieldChange = async (e, fieldId, type) => {
@@ -25863,49 +26086,82 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25863
26086
  case 3:
25864
26087
  const newEmails = emails.filter((email) => email.id !== fieldId);
25865
26088
  setEmails(newEmails);
26089
+ setInitialSnapshot((prev) => ({
26090
+ ...(prev ?? {}),
26091
+ emails: newEmails,
26092
+ }));
25866
26093
  break;
25867
26094
  case 5:
25868
26095
  const newPhoneNumbers = phoneNumbers.filter((phoneNumber) => phoneNumber.id !== fieldId);
25869
26096
  setPhoneNumbers(newPhoneNumbers);
26097
+ setInitialSnapshot((prev) => ({
26098
+ ...(prev ?? {}),
26099
+ phones: newPhoneNumbers,
26100
+ }));
25870
26101
  break;
25871
26102
  case 13:
25872
26103
  const newImsWhatsapp = imsWhatsapp.filter((item) => item.id !== fieldId);
25873
26104
  setImsWhatsApp(newImsWhatsapp);
26105
+ setInitialSnapshot((prev) => ({
26106
+ ...(prev ?? {}),
26107
+ ims_whatsapp: newImsWhatsapp,
26108
+ }));
25874
26109
  break;
25875
26110
  case 21:
25876
26111
  const newImsRCS = imsRCS.filter((item) => item.id !== fieldId);
25877
26112
  setImsRCS(newImsRCS);
26113
+ setInitialSnapshot((prev) => ({
26114
+ ...(prev ?? {}),
26115
+ ims_rcs: newImsRCS,
26116
+ }));
25878
26117
  break;
25879
26118
  case 41:
25880
26119
  const newImsMercadolibre = imsMercadolibre.filter((item) => item.id !== fieldId);
25881
26120
  setImsMercadolibre(newImsMercadolibre);
26121
+ setInitialSnapshot((prev) => ({
26122
+ ...(prev ?? {}),
26123
+ ims_mercadolibre: newImsMercadolibre,
26124
+ }));
25882
26125
  break;
25883
26126
  case 14:
25884
26127
  const newImsFacebooks = imsFacebooks.filter((item) => item.id !== fieldId);
25885
26128
  setImsFacebooks(newImsFacebooks);
26129
+ setInitialSnapshot((prev) => ({
26130
+ ...(prev ?? {}),
26131
+ ims_facebook: newImsFacebooks,
26132
+ }));
25886
26133
  break;
25887
26134
  case 20:
25888
26135
  const newImsWebchats = imsWebchats.filter((item) => item.id !== fieldId);
25889
26136
  setImsWebchats(newImsWebchats);
26137
+ setInitialSnapshot((prev) => ({
26138
+ ...(prev ?? {}),
26139
+ ims_webchat: newImsWebchats,
26140
+ }));
25890
26141
  break;
25891
26142
  case 16:
25892
26143
  const newImsInstagrams = imsInstagrams.filter((item) => item.id !== fieldId);
25893
26144
  setImsInstagrams(newImsInstagrams);
26145
+ setInitialSnapshot((prev) => ({
26146
+ ...(prev ?? {}),
26147
+ ims_instagram: newImsInstagrams,
26148
+ }));
25894
26149
  break;
25895
26150
  }
25896
26151
  }
25897
26152
  };
25898
26153
  function resetToInitialContactInformation() {
25899
- setImsFacebooks(initial?.ims_facebook || []);
25900
- setImsMercadolibre(initial?.ims_mercadolibre || []);
25901
- setImsWebchats(initial?.ims_webchat || []);
25902
- setImsInstagrams(initial?.ims_instagram || []);
25903
- setImsWhatsApp(initial?.ims_whatsapp || []);
25904
- setImsRCS(initial?.ims_rcs || []);
25905
- setEmails(initial?.emails || []);
25906
- setPhoneNumbers(initial?.phones || []);
26154
+ setImsFacebooks(initialSnapshot?.ims_facebook || []);
26155
+ setImsMercadolibre(initialSnapshot?.ims_mercadolibre || []);
26156
+ setImsWebchats(initialSnapshot?.ims_webchat || []);
26157
+ setImsInstagrams(initialSnapshot?.ims_instagram || []);
26158
+ setImsWhatsApp(initialSnapshot?.ims_whatsapp || []);
26159
+ setImsRCS(initialSnapshot?.ims_rcs || []);
26160
+ setEmails(initialSnapshot?.emails || []);
26161
+ setPhoneNumbers(initialSnapshot?.phones || []);
25907
26162
  }
25908
26163
  React$1.useEffect(() => {
26164
+ setInitialSnapshot(initial);
25909
26165
  if (initial?.emails && initial?.phones) {
25910
26166
  setEmails(initial.emails);
25911
26167
  setPhoneNumbers(initial.phones);
@@ -25970,7 +26226,7 @@ const useMultipleSelect = ({ initialState = [], } = {}) => {
25970
26226
  };
25971
26227
  };
25972
26228
 
25973
- const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) => {
26229
+ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId, }) => {
25974
26230
  const apiDeleteAddress = React$1.useMemo(() => async (payload) => {
25975
26231
  if (!baseUrl || !spaceId)
25976
26232
  return;
@@ -26010,8 +26266,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
26010
26266
  const country = useField$1('text', business?.address1?.country || '');
26011
26267
  const secondaryCountry = useField$1('text', business?.address2?.country || '');
26012
26268
  const getEditedField = (key, originalValue, editedValue) => {
26013
- if (originalValue !== editedValue &&
26014
- !(originalValue === null && editedValue === '')) {
26269
+ if (originalValue !== editedValue && !(originalValue === null && editedValue === '')) {
26015
26270
  return { [key]: editedValue };
26016
26271
  }
26017
26272
  return {};
@@ -26038,9 +26293,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
26038
26293
  id: business.id,
26039
26294
  ...getEditedField('owner', business.owner, contactPropietary.attributes.value),
26040
26295
  ...getEditedField('name', business.name, name.attributes.value),
26041
- imageUrl: contactImage.imageUrl
26042
- ? contactImage.removeParams(contactImage.imageUrl)
26043
- : null,
26296
+ imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
26044
26297
  tags: labelMultipleSelect.attributes.value,
26045
26298
  properties: customProperties,
26046
26299
  members: selectedContacts,
@@ -26055,26 +26308,23 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
26055
26308
  function resetCustomProperty(nameKey) {
26056
26309
  if (!business)
26057
26310
  return;
26058
- const defaultProperty = business.properties.find((property) => property.nameKey === nameKey);
26311
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26312
+ const defaultProperty = business.properties.find((property) => property.nameKey === nameKey) ??
26313
+ business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
26059
26314
  if (!defaultProperty) {
26060
26315
  console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
26061
26316
  return; // Salir de la función si no se encuentra la propiedad
26062
26317
  }
26063
- const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
26064
- ? { ...property, value: defaultProperty.value }
26065
- : property);
26318
+ const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
26066
26319
  setCustomProperties(updatedProperties);
26067
26320
  }
26068
- function replaceSpacesWithHyphen(input) {
26069
- const result = input.replace(/ /g, '-');
26070
- return result;
26071
- }
26072
26321
  const getFilteredCustomProperties = () => {
26073
26322
  if (!business)
26074
26323
  return [];
26075
26324
  return customContactFields.map((customField) => {
26076
- const customFieldWithHyphen = replaceSpacesWithHyphen(customField.nameKey);
26077
- const existingBusinessProperty = business.properties.find((property) => property.nameKey === customFieldWithHyphen);
26325
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26326
+ const existingBusinessProperty = business.properties.find((property) => property.nameKey === customField.nameKey) ??
26327
+ business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
26078
26328
  if (existingBusinessProperty) {
26079
26329
  return {
26080
26330
  ...existingBusinessProperty,
@@ -26159,7 +26409,7 @@ var dayjs_min = {exports: {}};
26159
26409
  var dayjs_minExports = dayjs_min.exports;
26160
26410
  var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
26161
26411
 
26162
- const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26412
+ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId, }) => {
26163
26413
  const apiDeleteAddress = React$1.useMemo(() => async (payload) => {
26164
26414
  if (!baseUrl || !spaceId)
26165
26415
  return;
@@ -26243,9 +26493,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26243
26493
  phones: modifiedPhones,
26244
26494
  // ims_whatsapp: modifiedImsWhatsapp,
26245
26495
  tags: modifiedTags,
26246
- imageUrl: contactImage.imageUrl
26247
- ? contactImage.removeParams(contactImage.imageUrl)
26248
- : null,
26496
+ imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
26249
26497
  properties: customProperties,
26250
26498
  // businessId: selectedBusiness[0]?.businessId || '',
26251
26499
  // businessName: selectedBusiness[0]?.businessName || '',
@@ -26271,27 +26519,23 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26271
26519
  function resetCustomProperty(nameKey) {
26272
26520
  if (!contact)
26273
26521
  return;
26274
- const defaultProperty = contact.properties.find((property) => property.nameKey === nameKey);
26522
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26523
+ const defaultProperty = contact.properties.find((property) => property.nameKey === nameKey) ??
26524
+ contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
26275
26525
  if (!defaultProperty) {
26276
26526
  console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
26277
26527
  return; // Salir de la función si no se encuentra la propiedad
26278
26528
  }
26279
- const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
26280
- ? { ...property, value: defaultProperty.value }
26281
- : property);
26529
+ const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
26282
26530
  setCustomProperties(updatedProperties);
26283
26531
  }
26284
- // Utils
26285
- function replaceSpacesWithHyphen(input) {
26286
- const result = input.replace(/ /g, '-');
26287
- return result;
26288
- }
26289
26532
  const getFilteredCustomProperties = () => {
26290
26533
  if (!contact)
26291
26534
  return [];
26292
26535
  return customContactFields.map((customField) => {
26293
- const customFieldWithHypen = replaceSpacesWithHyphen(customField.nameKey);
26294
- const existingProperty = contact.properties.find((property) => property.nameKey === customFieldWithHypen);
26536
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26537
+ const existingProperty = contact.properties.find((property) => property.nameKey === customField.nameKey) ??
26538
+ contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
26295
26539
  if (existingProperty) {
26296
26540
  return {
26297
26541
  ...existingProperty,
@@ -26423,7 +26667,7 @@ const Section = ({ title, children }) => {
26423
26667
  borderRadius: 2,
26424
26668
  p: 2,
26425
26669
  mb: 2,
26426
- }, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", sx: { fontWeight: 600 }, children: title }), jsxRuntimeExports.jsx(material.Divider, { sx: { my: 1.5 } }), children] }));
26670
+ }, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(material.Divider, { sx: { my: 1.5 } }), children] }));
26427
26671
  };
26428
26672
 
26429
26673
  const SectionContent = ({ children, ...boxProps }) => {
@@ -52571,7 +52815,7 @@ function SelectBusinessLabel({ value, displayValue, businessId }) {
52571
52815
  }
52572
52816
  setAnchorEl(targetElement);
52573
52817
  };
52574
- return (jsxRuntimeExports.jsxs(material.Box, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(material.Typography, { onClick: handleOpenInfoPopover, fontWeight: '600', sx: {
52818
+ return (jsxRuntimeExports.jsxs(material.Box, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(material.Typography, { onClick: handleOpenInfoPopover, variant: "body2", fontWeight: '600', sx: {
52575
52819
  padding: 1,
52576
52820
  cursor: 'pointer',
52577
52821
  }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' }), businessData && (jsxRuntimeExports.jsx(ContactInfoPopup, { contactData: businessData, open: Boolean(anchorEl), anchorEl: anchorEl, onClose: () => setAnchorEl(null), navigate: navigate, avatarImgUrl: userImage.imageUrl })), isLoadingData && (jsxRuntimeExports.jsx(material.Box, { display: "flex", alignItems: "center", justifyContent: "center", p: 1, children: jsxRuntimeExports.jsx(material.CircularProgress, { size: 20 }) }))] }));
@@ -52600,11 +52844,38 @@ const EntityInfoLabel = (props) => {
52600
52844
  const inputType = props.inputType ?? 'text';
52601
52845
  const [isEditing, setIsEditing] = React$1.useState(false);
52602
52846
  const [isSaving, setIsSaving] = React$1.useState(false);
52847
+ const titleRef = React$1.useRef(null);
52848
+ const [isTitleTruncated, setIsTitleTruncated] = React$1.useState(false);
52603
52849
  const [inputValue, setInputValue] = React$1.useState(() => {
52604
52850
  if (props.entityType === 'business')
52605
52851
  return value;
52606
52852
  return typeof value === 'string' ? value : undefined;
52607
52853
  });
52854
+ React$1.useEffect(() => {
52855
+ const el = titleRef.current;
52856
+ if (!el)
52857
+ return;
52858
+ const check = () => {
52859
+ const next = el.scrollWidth > el.clientWidth;
52860
+ setIsTitleTruncated(next);
52861
+ };
52862
+ check();
52863
+ if (typeof ResizeObserver !== 'undefined') {
52864
+ const ro = new ResizeObserver(() => {
52865
+ check();
52866
+ });
52867
+ ro.observe(el);
52868
+ return () => {
52869
+ ro.disconnect();
52870
+ };
52871
+ }
52872
+ if (typeof window === 'undefined')
52873
+ return;
52874
+ window.addEventListener('resize', check);
52875
+ return () => {
52876
+ window.removeEventListener('resize', check);
52877
+ };
52878
+ }, [title, isEditing]);
52608
52879
  React$1.useEffect(() => {
52609
52880
  if (props.entityType === 'business') {
52610
52881
  setInputValue(value);
@@ -52709,12 +52980,17 @@ const EntityInfoLabel = (props) => {
52709
52980
  '&:hover .edit-icon': {
52710
52981
  opacity: 1,
52711
52982
  },
52712
- }, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: '25px', children: [jsxRuntimeExports.jsx(material.Typography, { letterSpacing: -0.5, fontWeight: '600', alignSelf: 'center', flexGrow: isEditing ? 1 : 0, color: (theme) => theme.palette.text.primary, children: title }), isNotEditable ? null : isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$3, { className: "edit-icon", size: "small", onClick: handleEditClick, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(material.Box, { width: isEditing ? '100%' : '50%', position: "relative", children: isEditing && inputType === 'text' ? (jsxRuntimeExports.jsx(material.TextField, { value: textValue, onChange: handleInputChange, variant: "standard", size: "small", sx: { width: '100%' } })) : isEditing && (inputType === 'select' || inputType === 'selectMembers') ? (jsxRuntimeExports.jsxs(material.Select, { value: selectValue, onChange: handleSelectChange, variant: "standard", size: "small", sx: { width: '100%' }, children: [props.entityType === 'contact' ? (jsxRuntimeExports.jsx(material.MenuItem, { value: "", children: t('conversations.contactDetails.contactInfo.emptySelection') })) : null, options.map((option, index) => (jsxRuntimeExports.jsx(material.MenuItem, { value: option.id, children: props.entityType === 'contact'
52983
+ }, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: '25px', children: [isTitleTruncated ? (jsxRuntimeExports.jsx(material.Tooltip, { title: title, arrow: true, children: jsxRuntimeExports.jsx(material.Typography, { ref: titleRef, component: "span", variant: "body2", letterSpacing: -0.5, fontWeight: '600', alignSelf: 'center', flexGrow: isEditing ? 1 : 0, color: (theme) => theme.palette.text.primary, noWrap: true, sx: {
52984
+ minWidth: 0,
52985
+ overflow: 'hidden',
52986
+ textOverflow: 'ellipsis',
52987
+ whiteSpace: 'nowrap',
52988
+ }, children: title }) })) : (jsxRuntimeExports.jsx(material.Typography, { ref: titleRef, component: "span", variant: "body2", letterSpacing: -0.5, fontWeight: '600', alignSelf: 'center', flexGrow: isEditing ? 1 : 0, color: (theme) => theme.palette.text.primary, noWrap: true, sx: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: title })), isNotEditable ? null : isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$3, { className: "edit-icon", size: "small", onClick: handleEditClick, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(material.Box, { width: isEditing ? '100%' : '50%', position: "relative", children: isEditing && inputType === 'text' ? (jsxRuntimeExports.jsx(material.TextField, { value: textValue, onChange: handleInputChange, variant: "standard", size: "small", sx: { width: '100%' } })) : isEditing && (inputType === 'select' || inputType === 'selectMembers') ? (jsxRuntimeExports.jsxs(material.Select, { value: selectValue, onChange: handleSelectChange, variant: "standard", size: "small", sx: { width: '100%' }, children: [props.entityType === 'contact' ? (jsxRuntimeExports.jsx(material.MenuItem, { value: "", children: t('conversations.contactDetails.contactInfo.emptySelection') })) : null, options.map((option, index) => (jsxRuntimeExports.jsx(material.MenuItem, { value: option.id, children: props.entityType === 'contact'
52713
52989
  ? option.name?.trim() || (isUserInfo(option) ? option.email : '') || 'Sin nombre'
52714
52990
  : option.name?.trim() || option.email || 'Sin nombre' }, index)))] })) : isEditing && isContactBirthdayProps(props) ? (jsxRuntimeExports.jsx(DateSelect, { birthDate: props.contact.field.birthDate, setBirthDate: props.contact.action.setBirthDate, dateFormat: props.dateFormat })) : !isEditing &&
52715
52991
  props.entityType === 'contact' &&
52716
52992
  inputType === 'selectBusiness' &&
52717
- props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: value, displayValue: displayValue, businessId: props.businessId })) : (jsxRuntimeExports.jsx(material.Typography, { fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
52993
+ props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: String(value ?? ''), displayValue: String(displayValue ?? ''), businessId: props.businessId })) : (jsxRuntimeExports.jsx(material.Typography, { variant: "body2", fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
52718
52994
  };
52719
52995
 
52720
52996
  const ContactInfoLabel = (props) => {
@@ -54546,13 +54822,19 @@ const ContactBox = material.styled(material.Box)(({ theme }) => ({
54546
54822
  }));
54547
54823
  const FieldName = material.styled(material.Typography)(({ theme }) => ({
54548
54824
  fontWeight: 600,
54825
+ fontSize: '0.875rem',
54549
54826
  alignSelf: 'center',
54550
54827
  color: theme.palette.text.primary,
54551
54828
  letterSpacing: -0.5,
54552
54829
  padding: 0,
54830
+ whiteSpace: 'nowrap',
54831
+ overflow: 'hidden',
54832
+ textOverflow: 'ellipsis',
54833
+ minWidth: 0,
54553
54834
  }));
54554
54835
  const FieldValue = material.styled(material.Typography)(({ theme }) => ({
54555
54836
  fontWeight: 400,
54837
+ fontSize: '0.875rem',
54556
54838
  padding: '2.5px 14px 8.5px 0px',
54557
54839
  color: theme.palette.text.primary,
54558
54840
  wordWrap: 'break-word',
@@ -54565,6 +54847,8 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54565
54847
  const { setCustomProperties } = entity.action;
54566
54848
  const [isEditing, setIsEditing] = React$1.useState(false);
54567
54849
  const [isSaving, setIsSaving] = React$1.useState(false);
54850
+ const titleRef = React$1.useRef(null);
54851
+ const [isTitleTruncated, setIsTitleTruncated] = React$1.useState(false);
54568
54852
  const userDateFormat = (userTrii?.regCon_dateFormat || 'YYYY/MM/DD').toUpperCase();
54569
54853
  const userTimeFormat = userTrii?.regCon_timeFormat || '24';
54570
54854
  // Determina si el tipo de campo es numérico
@@ -54670,6 +54954,31 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54670
54954
  const foundField = customContactFields.find((field) => field.nameKey === propertyNameKey);
54671
54955
  return foundField?.name || propertyNameKey;
54672
54956
  };
54957
+ React$1.useEffect(() => {
54958
+ const el = titleRef.current;
54959
+ if (!el)
54960
+ return;
54961
+ const check = () => {
54962
+ const next = el.scrollWidth > el.clientWidth;
54963
+ setIsTitleTruncated(next);
54964
+ };
54965
+ check();
54966
+ if (typeof ResizeObserver !== 'undefined') {
54967
+ const ro = new ResizeObserver(() => {
54968
+ check();
54969
+ });
54970
+ ro.observe(el);
54971
+ return () => {
54972
+ ro.disconnect();
54973
+ };
54974
+ }
54975
+ if (typeof window === 'undefined')
54976
+ return;
54977
+ window.addEventListener('resize', check);
54978
+ return () => {
54979
+ window.removeEventListener('resize', check);
54980
+ };
54981
+ }, [customContactFields, property.nameKey, isEditing]);
54673
54982
  const handleInputChange = (name, value) => {
54674
54983
  const updatedValue = property.type === Contacts.ContactField_type.DATERANGE
54675
54984
  ? Array.isArray(value) && value[0] && value[1]
@@ -54722,7 +55031,7 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54722
55031
  else
54723
55032
  return (jsxRuntimeExports.jsx(CustomPropertyInput, { type: type, nameKey: nameKey, value: value, onChange: handleInputChange }));
54724
55033
  };
54725
- return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: "25px", children: [jsxRuntimeExports.jsx(FieldName, { flexGrow: isEditing ? 1 : 0, children: getPropertyName(property.nameKey) }), isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$2, { className: "edit-icon", size: "small", onClick: toggleEdit, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(material.Box, { width: isEditing || property.type === Contacts.ContactField_type.LONGTEXT ? '100%' : '50%', position: "relative", children: isEditing ? (EditField()) : (jsxRuntimeExports.jsx(FieldValue, { children: hasValue(property?.value)
55034
+ return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: "25px", alignItems: "center", children: [isTitleTruncated ? (jsxRuntimeExports.jsx(material.Tooltip, { title: getPropertyName(property.nameKey), arrow: true, children: jsxRuntimeExports.jsx(FieldName, { ref: titleRef, flexGrow: 1, noWrap: true, children: getPropertyName(property.nameKey) }) })) : (jsxRuntimeExports.jsx(FieldName, { ref: titleRef, flexGrow: 1, noWrap: true, children: getPropertyName(property.nameKey) })), isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$2, { className: "edit-icon", size: "small", onClick: toggleEdit, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(material.Box, { width: isEditing || property.type === Contacts.ContactField_type.LONGTEXT ? '100%' : '50%', position: "relative", children: isEditing ? (EditField()) : (jsxRuntimeExports.jsx(FieldValue, { children: hasValue(property?.value)
54726
55035
  ? property.type === Contacts.ContactField_type.DATERANGE
54727
55036
  ? (() => {
54728
55037
  if (typeof property.value === 'string') {
@@ -57189,7 +57498,7 @@ const AddressInformation = ({ entityType, entityData, baseUrl, spaceId, onEntity
57189
57498
  onEntityUpdated,
57190
57499
  };
57191
57500
  const t = useTranslationContext();
57192
- const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(material.Typography, { variant: "h6", children: title }), jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-x-4 gap-y-3", children: [jsxRuntimeExports.jsx("div", { className: "col-span-2", children: jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.street'), value: entityData[addressNumber]?.street ?? '', ...commonProps, constructUpdateObject: (value) => ({
57501
+ const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(material.Typography, { variant: "body2", children: title }), jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-x-4 gap-y-3", children: [jsxRuntimeExports.jsx("div", { className: "col-span-2", children: jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.street'), value: entityData[addressNumber]?.street ?? '', ...commonProps, constructUpdateObject: (value) => ({
57193
57502
  [addressNumber]: { street: value },
57194
57503
  }), minWidth: "100%" }) }), jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.city'), value: entityData[addressNumber]?.city ?? '', ...commonProps, constructUpdateObject: (value) => ({
57195
57504
  [addressNumber]: { city: value },
@@ -57229,11 +57538,31 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
57229
57538
  const [draftLabels, setDraftLabels] = React$1.useState([]);
57230
57539
  const [tagsEditorInitialized, setTagsEditorInitialized] = React$1.useState(false);
57231
57540
  const [isSaving, setIsSaving] = React$1.useState(false);
57541
+ const [createdLabels, setCreatedLabels] = React$1.useState([]);
57542
+ const [isCreatingLabel, setIsCreatingLabel] = React$1.useState(false);
57543
+ const labelsOptions = React$1.useMemo(() => {
57544
+ const safeLabels = labels ?? [];
57545
+ const safeCreated = createdLabels ?? [];
57546
+ const byId = new Map();
57547
+ for (const label of safeLabels) {
57548
+ if (!label?.id)
57549
+ continue;
57550
+ byId.set(String(label.id), label);
57551
+ }
57552
+ for (const label of safeCreated) {
57553
+ if (!label?.id)
57554
+ continue;
57555
+ byId.set(String(label.id), label);
57556
+ }
57557
+ return Array.from(byId.values());
57558
+ }, [labels, createdLabels]);
57232
57559
  const reset = React$1.useCallback(() => {
57233
57560
  setView('main');
57234
57561
  setDraftLabels([]);
57235
57562
  setTagsEditorInitialized(false);
57236
57563
  setIsSaving(false);
57564
+ setCreatedLabels([]);
57565
+ setIsCreatingLabel(false);
57237
57566
  }, []);
57238
57567
  React$1.useEffect(() => {
57239
57568
  if (!open) {
@@ -57247,13 +57576,61 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
57247
57576
  }
57248
57577
  if (tagsEditorInitialized)
57249
57578
  return;
57250
- if (!labels.length)
57579
+ if (!labelsOptions.length)
57251
57580
  return;
57252
57581
  const selectedTagIds = new Set(selectedTags.map((t) => String(t.id)));
57253
- const initialDraft = labels.filter((l) => selectedTagIds.has(String(l?.id)));
57582
+ const initialDraft = labelsOptions.filter((l) => selectedTagIds.has(String(l?.id)));
57254
57583
  setDraftLabels(initialDraft);
57255
57584
  setTagsEditorInitialized(true);
57256
- }, [view, tagsEditorInitialized, labels, selectedTags]);
57585
+ }, [view, tagsEditorInitialized, labelsOptions, selectedTags]);
57586
+ const handleCreateLabel = React$1.useCallback(async (name) => {
57587
+ if (isCreatingLabel)
57588
+ return;
57589
+ if (!baseUrl || !spaceId)
57590
+ return;
57591
+ const trimmedName = String(name ?? '').trim();
57592
+ if (!trimmedName)
57593
+ return;
57594
+ const normalizedName = trimmedName.toLowerCase();
57595
+ const existing = labelsOptions.find((l) => String(l?.name ?? '')
57596
+ .trim()
57597
+ .toLowerCase() === normalizedName);
57598
+ if (existing?.id) {
57599
+ setDraftLabels((prev) => {
57600
+ const safePrev = prev ?? [];
57601
+ const existsInDraft = safePrev.some((p) => String(p?.id) === String(existing.id));
57602
+ if (existsInDraft)
57603
+ return safePrev;
57604
+ return [...safePrev, existing];
57605
+ });
57606
+ return;
57607
+ }
57608
+ setIsCreatingLabel(true);
57609
+ try {
57610
+ const created = await createLabel({ baseUrl, spaceId, name: trimmedName });
57611
+ setCreatedLabels((prev) => {
57612
+ const safePrev = prev ?? [];
57613
+ if (!created?.id)
57614
+ return safePrev;
57615
+ const existsInCreated = safePrev.some((p) => String(p?.id) === String(created.id));
57616
+ if (existsInCreated)
57617
+ return safePrev;
57618
+ return [...safePrev, created];
57619
+ });
57620
+ setDraftLabels((prev) => {
57621
+ const safePrev = prev ?? [];
57622
+ if (!created?.id)
57623
+ return safePrev;
57624
+ const existsInDraft = safePrev.some((p) => String(p?.id) === String(created.id));
57625
+ if (existsInDraft)
57626
+ return safePrev;
57627
+ return [...safePrev, created];
57628
+ });
57629
+ }
57630
+ finally {
57631
+ setIsCreatingLabel(false);
57632
+ }
57633
+ }, [isCreatingLabel, baseUrl, spaceId, labelsOptions]);
57257
57634
  const handleSaveTags = React$1.useCallback(async () => {
57258
57635
  if (isSaving)
57259
57636
  return;
@@ -57287,28 +57664,32 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
57287
57664
  setView,
57288
57665
  draftLabels,
57289
57666
  setDraftLabels,
57667
+ labelsOptions,
57290
57668
  isSaving,
57669
+ isCreatingLabel,
57670
+ handleCreateLabel,
57291
57671
  handleSaveTags,
57292
57672
  };
57293
57673
  };
57294
57674
 
57295
57675
  const useModalCloseHandler = ({ onClose }) => {
57296
- const handleClose = React$1.useCallback((event, reason) => {
57676
+ const handleClose = React$1.useCallback((_event, reason) => {
57297
57677
  if (reason === 'escapeKeyDown') {
57298
- const maybeEvent = event;
57299
- if (typeof maybeEvent?.stopPropagation === 'function') {
57300
- maybeEvent.stopPropagation();
57301
- }
57302
- if (typeof maybeEvent?.preventDefault === 'function') {
57303
- maybeEvent.preventDefault();
57304
- }
57678
+ return;
57305
57679
  }
57306
57680
  onClose();
57307
57681
  }, [onClose]);
57308
57682
  return handleClose;
57309
57683
  };
57310
57684
 
57311
- const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, t, navigate, }) => {
57685
+ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, language = 'en', navigate, }) => {
57686
+ const { t: i18nT, i18n } = reactI18next.useTranslation();
57687
+ React$1.useEffect(() => {
57688
+ if (language) {
57689
+ i18n.changeLanguage(language);
57690
+ }
57691
+ }, [language, i18n]);
57692
+ const t = (key) => i18nT(key);
57312
57693
  const api = React$1.useMemo(() => {
57313
57694
  if (!baseUrl || !spaceId)
57314
57695
  return null;
@@ -57324,7 +57705,7 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, t, n
57324
57705
  entity: state.contactData,
57325
57706
  setEntity: (next) => actions.setContactData(next ?? undefined),
57326
57707
  });
57327
- const { view, setView, draftLabels, setDraftLabels, isSaving: isSavingTags, handleSaveTags, } = useTagsEditorController({
57708
+ const { view, setView, draftLabels, setDraftLabels, labelsOptions, isSaving: isSavingTags, isCreatingLabel, handleCreateLabel, handleSaveTags, } = useTagsEditorController({
57328
57709
  open,
57329
57710
  baseUrl,
57330
57711
  spaceId,
@@ -57364,22 +57745,29 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, t, n
57364
57745
  overflow: 'hidden',
57365
57746
  };
57366
57747
  const mergedSx = Array.isArray(sx) ? [baseSx, ...sx] : sx ? [baseSx, sx] : baseSx;
57367
- return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(material.Modal, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: material.Backdrop }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(material.Fade, { in: open, timeout: 200, children: jsxRuntimeExports.jsx(material.Box, { sx: mergedSx, children: state.isLoading && !state.contactData ? (jsxRuntimeExports.jsx(material.Box, { sx: {
57368
- display: 'flex',
57369
- justifyContent: 'center',
57370
- alignItems: 'center',
57371
- minHeight: 220,
57372
- }, children: jsxRuntimeExports.jsx(material.CircularProgress, {}) })) : state.error ? (jsxRuntimeExports.jsx(material.Box, { sx: { mb: 2 }, children: "Failed to load contact" })) : state.contactData ? (jsxRuntimeExports.jsx(EditEntityProvider, { entityType: selectors.contactType === 'business' ? 'business' : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, children: jsxRuntimeExports.jsxs(material.Box, { sx: { position: 'relative', height: '100%' }, children: [jsxRuntimeExports.jsx(material.Fade, { in: view === 'main', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsxs(material.Box, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Header, { imgUrl: image.imageUrl, displayName: selectors.displayName, tags: selectors.tags, onEditTags: () => {
57373
- setView('tags');
57374
- }, onUploadPhoto: image.action.uploadImage, onPhotoFileChange: image.inputAtributes.onChange, photoInputRef: image.inputAtributes.ref, isUploadingPhoto: image.isUploading, onDeletePhoto: image.action.deleteImage, isDeletingPhoto: image.isDeleting, contactType: selectors.contactType, entityId: state.contactData?.id, firstName: selectors.isContact ? state.contactData.firstName : undefined, lastName: selectors.isContact ? state.contactData.lastName : undefined, name: selectors.isBusiness ? state.contactData.name : undefined, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsxs(material.Box, { sx: { px: 1, pb: 2 }, children: [jsxRuntimeExports.jsx(General, { dateFormat: selectors.userTrii?.regCon_dateFormat || 'MM/dd/yyyy', entityType: selectors.contactType === 'contact' ||
57375
- selectors.contactType === 'business'
57376
- ? selectors.contactType
57377
- : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' ||
57378
- selectors.contactType === 'business'
57379
- ? selectors.contactType
57380
- : 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsx(ContactInformation, { ownerData: state.contactData })] })] }) }), jsxRuntimeExports.jsx(material.Fade, { in: view === 'tags', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsx(material.Box, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: jsxRuntimeExports.jsx(TagsEditor, { value: draftLabels, options: selectors.labels, onChange: setDraftLabels, onBack: () => setView('main'), onSave: handleSaveTags, isSaving: isSavingTags }) }) })] }) })) : null }) }) }) }) }) }));
57381
- };
57382
-
57748
+ return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(material.Modal, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: material.Backdrop }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(material.Fade, { in: open, timeout: 200, children: jsxRuntimeExports.jsxs(material.Box, { sx: mergedSx, children: [jsxRuntimeExports.jsx(material.IconButton, { "aria-label": "close", onClick: handleClose, sx: {
57749
+ position: 'absolute',
57750
+ right: 8,
57751
+ top: 8,
57752
+ color: (theme) => theme.palette.grey[500],
57753
+ zIndex: 1,
57754
+ }, children: jsxRuntimeExports.jsx(default_1$g, {}) }), state.isLoading && !state.contactData ? (jsxRuntimeExports.jsx(material.Box, { sx: {
57755
+ display: 'flex',
57756
+ justifyContent: 'center',
57757
+ alignItems: 'center',
57758
+ minHeight: 220,
57759
+ }, children: jsxRuntimeExports.jsx(material.CircularProgress, {}) })) : state.error ? (jsxRuntimeExports.jsx(material.Box, { sx: { mb: 2 }, children: "Failed to load contact" })) : state.contactData ? (jsxRuntimeExports.jsx(EditEntityProvider, { entityType: selectors.contactType === 'business' ? 'business' : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, children: jsxRuntimeExports.jsxs(material.Box, { sx: { position: 'relative', height: '100%' }, children: [jsxRuntimeExports.jsx(material.Fade, { in: view === 'main', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsxs(material.Box, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Header, { imgUrl: image.imageUrl, displayName: selectors.displayName, tags: selectors.tags, onEditTags: () => {
57760
+ setView('tags');
57761
+ }, onUploadPhoto: image.action.uploadImage, onPhotoFileChange: image.inputAtributes.onChange, photoInputRef: image.inputAtributes.ref, isUploadingPhoto: image.isUploading, onDeletePhoto: image.action.deleteImage, isDeletingPhoto: image.isDeleting, contactType: selectors.contactType, entityId: state.contactData?.id, firstName: selectors.isContact ? state.contactData.firstName : undefined, lastName: selectors.isContact ? state.contactData.lastName : undefined, name: selectors.isBusiness ? state.contactData.name : undefined, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsxs(material.Box, { sx: { px: 1, pb: 2 }, children: [jsxRuntimeExports.jsx(General, { dateFormat: selectors.userTrii?.regCon_dateFormat || 'MM/dd/yyyy', entityType: selectors.contactType === 'contact' ||
57762
+ selectors.contactType === 'business'
57763
+ ? selectors.contactType
57764
+ : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' ||
57765
+ selectors.contactType === 'business'
57766
+ ? selectors.contactType
57767
+ : 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsx(ContactInformation, { ownerData: state.contactData })] })] }) }), jsxRuntimeExports.jsx(material.Fade, { in: view === 'tags', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsx(material.Box, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: jsxRuntimeExports.jsx(TagsEditor, { value: draftLabels, options: labelsOptions, onChange: setDraftLabels, onBack: () => setView('main'), onSave: handleSaveTags, isSaving: isSavingTags, onCreateNew: handleCreateLabel, isCreatingNew: isCreatingLabel }) }) })] }) })) : null] }) }) }) }) }) }));
57768
+ };
57769
+
57770
+ exports.i18n = i18n;
57383
57771
  exports.ContactInfoPopup = ContactInfoPopup;
57384
57772
  exports.EditContactModal = EditContactModal;
57385
57773
  //# sourceMappingURL=index.js.map