@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/esm/index.js CHANGED
@@ -2,6 +2,9 @@ import * as React$1 from 'react';
2
2
  import React__default, { useCallback, useEffect, createContext, useContext, useState, useMemo, Children, isValidElement, cloneElement, useRef } from 'react';
3
3
  import { styled as styled$5, Box as Box$2, IconButton as IconButton$2, Avatar, Typography as Typography$2, CircularProgress as CircularProgress$2, Tooltip, Chip as Chip$2, Popper as Popper$2, ClickAwayListener, CardContent, Stack as Stack$2, Popover as Popover$2, TextField as TextField$1, Autocomplete, Divider, Select as Select$2, MenuItem as MenuItem$2, FormControl as FormControl$2, Button as Button$2, Menu as Menu$2, ListItemIcon, ListItemText, Modal as Modal$2, Grid, Backdrop as Backdrop$2, Fade as Fade$2 } from '@mui/material';
4
4
  import { withEmotionCache, ThemeContext, CacheProvider, Global, css, keyframes } from '@emotion/react';
5
+ import { initReactI18next, useTranslation } from 'react-i18next';
6
+ import i18n from 'i18next';
7
+ export { default as i18n } from 'i18next';
5
8
  import * as ReactDOM from 'react-dom';
6
9
  import ReactDOM__default from 'react-dom';
7
10
 
@@ -4718,11 +4721,11 @@ var createStyled$2 = function createStyled(tag, options) {
4718
4721
  };
4719
4722
  };
4720
4723
 
4721
- 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
4724
+ 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
4722
4725
  'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
4723
4726
 
4724
4727
  var newStyled = createStyled$2.bind();
4725
- tags.forEach(function (tagName) {
4728
+ tags$2.forEach(function (tagName) {
4726
4729
  // $FlowFixMe: we can ignore this because its exposed type is defined by the CreateStyled type
4727
4730
  newStyled[tagName] = newStyled(tagName);
4728
4731
  });
@@ -6409,7 +6412,7 @@ function memoize(fn) {
6409
6412
  };
6410
6413
  }
6411
6414
 
6412
- const properties = {
6415
+ const properties$2 = {
6413
6416
  m: 'margin',
6414
6417
  p: 'padding'
6415
6418
  };
@@ -6441,7 +6444,7 @@ const getCssProperties = memoize(prop => {
6441
6444
  }
6442
6445
  }
6443
6446
  const [a, b] = prop.split('');
6444
- const property = properties[a];
6447
+ const property = properties$2[a];
6445
6448
  const direction = directions[b] || '';
6446
6449
  return Array.isArray(direction) ? direction.map(dir => property + dir) : [property + direction];
6447
6450
  });
@@ -7399,21 +7402,21 @@ var styleFunctionSx = /*#__PURE__*/Object.freeze({
7399
7402
 
7400
7403
  var require$$8 = /*@__PURE__*/getAugmentedNamespace(styleFunctionSx);
7401
7404
 
7402
- var _interopRequireDefault$i = interopRequireDefaultExports;
7405
+ var _interopRequireDefault$j = interopRequireDefaultExports;
7403
7406
  Object.defineProperty(createStyled$3, "__esModule", {
7404
7407
  value: true
7405
7408
  });
7406
7409
  var _default = createStyled$3.default = createStyled$1;
7407
7410
  var shouldForwardProp_1 = createStyled$3.shouldForwardProp = shouldForwardProp$1;
7408
7411
  createStyled$3.systemDefaultTheme = void 0;
7409
- var _extends2 = _interopRequireDefault$i(require_extends());
7410
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault$i(requireObjectWithoutPropertiesLoose());
7412
+ var _extends2 = _interopRequireDefault$j(require_extends());
7413
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault$j(requireObjectWithoutPropertiesLoose());
7411
7414
  var _styledEngine$1 = _interopRequireWildcard$2(require$$1$1);
7412
7415
  var _deepmerge = require$$4;
7413
- var _capitalize = _interopRequireDefault$i(require$$5);
7414
- var _getDisplayName = _interopRequireDefault$i(require$$6);
7415
- var _createTheme = _interopRequireDefault$i(require$$7);
7416
- var _styleFunctionSx = _interopRequireDefault$i(require$$8);
7416
+ var _capitalize = _interopRequireDefault$j(require$$5);
7417
+ var _getDisplayName = _interopRequireDefault$j(require$$6);
7418
+ var _createTheme = _interopRequireDefault$j(require$$7);
7419
+ var _styleFunctionSx = _interopRequireDefault$j(require$$8);
7417
7420
  const _excluded$1v = ["ownerState"],
7418
7421
  _excluded2$d = ["variants"],
7419
7422
  _excluded3$4 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
@@ -7683,7 +7686,7 @@ var require$$1 = /*@__PURE__*/getAugmentedNamespace(formatMuiErrorMessage$1);
7683
7686
 
7684
7687
  var require$$2 = /*@__PURE__*/getAugmentedNamespace(clamp);
7685
7688
 
7686
- var _interopRequireDefault$h = interopRequireDefaultExports;
7689
+ var _interopRequireDefault$i = interopRequireDefaultExports;
7687
7690
  Object.defineProperty(colorManipulator, "__esModule", {
7688
7691
  value: true
7689
7692
  });
@@ -7705,8 +7708,8 @@ colorManipulator.private_safeEmphasize = private_safeEmphasize;
7705
7708
  colorManipulator.private_safeLighten = private_safeLighten;
7706
7709
  colorManipulator.recomposeColor = recomposeColor$1;
7707
7710
  colorManipulator.rgbToHex = rgbToHex;
7708
- var _formatMuiErrorMessage2 = _interopRequireDefault$h(require$$1);
7709
- var _clamp = _interopRequireDefault$h(require$$2);
7711
+ var _formatMuiErrorMessage2 = _interopRequireDefault$i(require$$1);
7712
+ var _clamp = _interopRequireDefault$i(require$$2);
7710
7713
  /* eslint-disable @typescript-eslint/naming-convention */
7711
7714
 
7712
7715
  /**
@@ -9072,27 +9075,27 @@ function requireCreateSvgIcon () {
9072
9075
  return createSvgIcon;
9073
9076
  }
9074
9077
 
9075
- var _interopRequireDefault$g = interopRequireDefaultExports;
9078
+ var _interopRequireDefault$h = interopRequireDefaultExports;
9076
9079
  Object.defineProperty(ArrowForward, "__esModule", {
9077
9080
  value: true
9078
9081
  });
9079
- var default_1$h = ArrowForward.default = void 0;
9080
- var _createSvgIcon$g = _interopRequireDefault$g(requireCreateSvgIcon());
9081
- var _jsxRuntime$g = jsxRuntimeExports;
9082
- default_1$h = ArrowForward.default = (0, _createSvgIcon$g.default)( /*#__PURE__*/(0, _jsxRuntime$g.jsx)("path", {
9082
+ var default_1$i = ArrowForward.default = void 0;
9083
+ var _createSvgIcon$h = _interopRequireDefault$h(requireCreateSvgIcon());
9084
+ var _jsxRuntime$h = jsxRuntimeExports;
9085
+ default_1$i = ArrowForward.default = (0, _createSvgIcon$h.default)( /*#__PURE__*/(0, _jsxRuntime$h.jsx)("path", {
9083
9086
  d: "m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"
9084
9087
  }), 'ArrowForward');
9085
9088
 
9086
9089
  var Message = {};
9087
9090
 
9088
- var _interopRequireDefault$f = interopRequireDefaultExports;
9091
+ var _interopRequireDefault$g = interopRequireDefaultExports;
9089
9092
  Object.defineProperty(Message, "__esModule", {
9090
9093
  value: true
9091
9094
  });
9092
- var default_1$g = Message.default = void 0;
9093
- var _createSvgIcon$f = _interopRequireDefault$f(requireCreateSvgIcon());
9094
- var _jsxRuntime$f = jsxRuntimeExports;
9095
- default_1$g = Message.default = (0, _createSvgIcon$f.default)( /*#__PURE__*/(0, _jsxRuntime$f.jsx)("path", {
9095
+ var default_1$h = Message.default = void 0;
9096
+ var _createSvgIcon$g = _interopRequireDefault$g(requireCreateSvgIcon());
9097
+ var _jsxRuntime$g = jsxRuntimeExports;
9098
+ default_1$h = Message.default = (0, _createSvgIcon$g.default)( /*#__PURE__*/(0, _jsxRuntime$g.jsx)("path", {
9096
9099
  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"
9097
9100
  }), 'Message');
9098
9101
 
@@ -9172,7 +9175,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
9172
9175
  handleNavigateToContacts(e);
9173
9176
  onClose();
9174
9177
  }
9175
- }, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$h, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
9178
+ }, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$i, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
9176
9179
  handleNavigateToConversations(e);
9177
9180
  onClose();
9178
9181
  }, onMouseDown: (e) => {
@@ -9181,7 +9184,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
9181
9184
  handleNavigateToConversations(e);
9182
9185
  onClose();
9183
9186
  }
9184
- }, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$g, { fontSize: "small" }) })] }), isLoading ? (jsxRuntimeExports.jsx(LoadingContainer, { children: jsxRuntimeExports.jsx(CircularProgress$2, { 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 })] }));
9187
+ }, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$h, { fontSize: "small" }) })] }), isLoading ? (jsxRuntimeExports.jsx(LoadingContainer, { children: jsxRuntimeExports.jsx(CircularProgress$2, { 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 })] }));
9185
9188
  };
9186
9189
 
9187
9190
  const Container$1 = styled$5(Box$2)({
@@ -15269,6 +15272,166 @@ const MembersSection = ({ contactData, title, navigate }) => {
15269
15272
  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)))] }));
15270
15273
  };
15271
15274
 
15275
+ var add$1 = "Add";
15276
+ var close$1 = "Close";
15277
+ var labels$1 = "Labels";
15278
+ var phone$1 = "Phone";
15279
+ var phones$1 = "Phones";
15280
+ var number$1 = "Number";
15281
+ var business$1 = "Business";
15282
+ var businessMembers$1 = "Business Members";
15283
+ var properties$1 = "Properties";
15284
+ var note$1 = "Note";
15285
+ var view$1 = "View";
15286
+ var email$1 = "Email";
15287
+ var tags$1 = "Tags";
15288
+ var global$2 = {
15289
+ back: "Back",
15290
+ save: "Save",
15291
+ noOptions: "No options",
15292
+ noValue: "No value",
15293
+ birthdate: "Birthdate"
15294
+ };
15295
+ var avatar$1 = {
15296
+ upload: "Upload photo",
15297
+ "delete": "Delete photo"
15298
+ };
15299
+ var contactEdit$1 = {
15300
+ from: "From",
15301
+ to: "To"
15302
+ };
15303
+ var conversations$1 = {
15304
+ contactDetails: {
15305
+ contactOwner: "Contact Owner",
15306
+ business: "Business",
15307
+ createdBy: "Created By",
15308
+ modifiedBy: "Modified By",
15309
+ street: "Street",
15310
+ city: "City",
15311
+ state: "State",
15312
+ postcode: "Postcode",
15313
+ country: "Country",
15314
+ addressInformation: "Address Information",
15315
+ primaryAddress: "Primary Address",
15316
+ secondaryAddress: "Secondary Address",
15317
+ contactInformation: "Contact Information",
15318
+ phones: "Phones",
15319
+ contactInfo: {
15320
+ emptySelection: "No selection"
15321
+ }
15322
+ },
15323
+ businessDetails: {
15324
+ businessOwner: "Business Owner"
15325
+ }
15326
+ };
15327
+ var en = {
15328
+ add: add$1,
15329
+ close: close$1,
15330
+ labels: labels$1,
15331
+ phone: phone$1,
15332
+ phones: phones$1,
15333
+ number: number$1,
15334
+ business: business$1,
15335
+ businessMembers: businessMembers$1,
15336
+ properties: properties$1,
15337
+ note: note$1,
15338
+ view: view$1,
15339
+ email: email$1,
15340
+ tags: tags$1,
15341
+ global: global$2,
15342
+ avatar: avatar$1,
15343
+ contactEdit: contactEdit$1,
15344
+ conversations: conversations$1
15345
+ };
15346
+
15347
+ var add = "Agregar";
15348
+ var close = "Cerrar";
15349
+ var labels = "Etiquetas";
15350
+ var phone = "Teléfono";
15351
+ var phones = "Teléfonos";
15352
+ var number = "Número";
15353
+ var business = "Empresa";
15354
+ var businessMembers = "Miembros de la empresa";
15355
+ var properties = "Propiedades";
15356
+ var note = "Nota";
15357
+ var view = "Ver";
15358
+ var email = "Correo Electrónico";
15359
+ var tags = "Etiquetas";
15360
+ var global$1 = {
15361
+ back: "Atrás",
15362
+ save: "Guardar",
15363
+ noOptions: "Sin opciones",
15364
+ noValue: "Sin valor",
15365
+ birthdate: "Fecha de nacimiento"
15366
+ };
15367
+ var avatar = {
15368
+ upload: "Subir foto",
15369
+ "delete": "Eliminar foto"
15370
+ };
15371
+ var contactEdit = {
15372
+ from: "Desde",
15373
+ to: "Hasta"
15374
+ };
15375
+ var conversations = {
15376
+ contactDetails: {
15377
+ contactOwner: "Propietario del contacto",
15378
+ business: "Empresa",
15379
+ createdBy: "Creado por",
15380
+ modifiedBy: "Modificado por",
15381
+ street: "Calle",
15382
+ city: "Ciudad",
15383
+ state: "Estado",
15384
+ postcode: "Código postal",
15385
+ country: "País",
15386
+ addressInformation: "Información de dirección",
15387
+ primaryAddress: "Dirección principal",
15388
+ secondaryAddress: "Dirección secundaria",
15389
+ contactInformation: "Información de contacto",
15390
+ phones: "Teléfonos",
15391
+ contactInfo: {
15392
+ emptySelection: "Sin selección"
15393
+ }
15394
+ },
15395
+ businessDetails: {
15396
+ businessOwner: "Propietario de la empresa"
15397
+ }
15398
+ };
15399
+ var es = {
15400
+ add: add,
15401
+ close: close,
15402
+ labels: labels,
15403
+ phone: phone,
15404
+ phones: phones,
15405
+ number: number,
15406
+ business: business,
15407
+ businessMembers: businessMembers,
15408
+ properties: properties,
15409
+ note: note,
15410
+ view: view,
15411
+ email: email,
15412
+ tags: tags,
15413
+ global: global$1,
15414
+ avatar: avatar,
15415
+ contactEdit: contactEdit,
15416
+ conversations: conversations
15417
+ };
15418
+
15419
+ const resources = {
15420
+ en: { translation: en },
15421
+ es: { translation: es },
15422
+ };
15423
+ i18n.use(initReactI18next).init({
15424
+ resources,
15425
+ lng: 'en',
15426
+ fallbackLng: 'en',
15427
+ interpolation: {
15428
+ escapeValue: false,
15429
+ },
15430
+ react: {
15431
+ useSuspense: false,
15432
+ },
15433
+ });
15434
+
15272
15435
  const PopupContainer = styled$5(Box$2)(({ theme }) => ({
15273
15436
  //@ts-ignore
15274
15437
  backgroundColor: theme.palette.background.panel,
@@ -15296,15 +15459,14 @@ const PopupContainer = styled$5(Box$2)(({ theme }) => ({
15296
15459
  background: '#616161',
15297
15460
  },
15298
15461
  }));
15299
- const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl, navigate, t = (key) => ({
15300
- labels: 'Etiquetas',
15301
- phone: 'Teléfono',
15302
- business: 'Empresa',
15303
- businessMembers: 'Miembros de la empresa',
15304
- properties: 'Propiedades',
15305
- view: 'Ver',
15306
- email: 'Correo Electrónico',
15307
- }[key] || key), }) => {
15462
+ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl, navigate, language = 'en', }) => {
15463
+ const { t: i18nT, i18n } = useTranslation();
15464
+ useEffect(() => {
15465
+ if (language) {
15466
+ i18n.changeLanguage(language);
15467
+ }
15468
+ }, [language, i18n]);
15469
+ const t = i18nT;
15308
15470
  const dataIsBusiness = isBusiness$1(contactData);
15309
15471
  const dataIsContact = isContact$1(contactData);
15310
15472
  const contactMethods = [
@@ -15355,9 +15517,22 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
15355
15517
  window.removeEventListener('keydown', handleKeyDown);
15356
15518
  };
15357
15519
  }, [open, onClose]);
15358
- return (jsxRuntimeExports.jsx(Popper$2, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(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') })] }) }) }) }));
15520
+ return (jsxRuntimeExports.jsx(Popper$2, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(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') })] }) }) }) }));
15359
15521
  };
15360
15522
 
15523
+ var Close = {};
15524
+
15525
+ var _interopRequireDefault$f = interopRequireDefaultExports;
15526
+ Object.defineProperty(Close, "__esModule", {
15527
+ value: true
15528
+ });
15529
+ var default_1$g = Close.default = void 0;
15530
+ var _createSvgIcon$f = _interopRequireDefault$f(requireCreateSvgIcon());
15531
+ var _jsxRuntime$f = jsxRuntimeExports;
15532
+ default_1$g = Close.default = (0, _createSvgIcon$f.default)( /*#__PURE__*/(0, _jsxRuntime$f.jsx)("path", {
15533
+ 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"
15534
+ }), 'Close');
15535
+
15361
15536
  var Edit = {};
15362
15537
 
15363
15538
  var _interopRequireDefault$e = interopRequireDefaultExports;
@@ -15422,7 +15597,6 @@ const Tags = ({ tags, onEditTags }) => {
15422
15597
  justifyContent: 'center',
15423
15598
  }, children: [jsxRuntimeExports.jsxs(Box$2, { sx: {
15424
15599
  maxWidth: 320,
15425
- pr: 4,
15426
15600
  position: 'relative',
15427
15601
  '&:hover .tags-action, &:focus-within .tags-action': {
15428
15602
  opacity: 1,
@@ -15436,7 +15610,8 @@ const Tags = ({ tags, onEditTags }) => {
15436
15610
  },
15437
15611
  } }, tag.id))), hiddenCount > 0 ? (jsxRuntimeExports.jsx(Chip$2, { label: `+${hiddenCount}`, size: "small", variant: "outlined", onClick: handleOpen, sx: { borderRadius: 999 } })) : null] }), jsxRuntimeExports.jsx(IconButton$2, { className: "tags-action", size: "small", "aria-label": safeTags.length ? t('tags.edit') : t('tags.add'), onClick: onEditTags, sx: {
15438
15612
  position: 'absolute',
15439
- right: 0,
15613
+ left: '100%',
15614
+ ml: 1,
15440
15615
  top: '50%',
15441
15616
  transform: 'translateY(-50%)',
15442
15617
  color: 'text.secondary',
@@ -15447,7 +15622,7 @@ const Tags = ({ tags, onEditTags }) => {
15447
15622
  bgcolor: 'action.hover',
15448
15623
  color: 'text.primary',
15449
15624
  },
15450
- }, children: safeTags.length ? (jsxRuntimeExports.jsx(default_1$f, { fontSize: "small" })) : (jsxRuntimeExports.jsx(default_1$e, { fontSize: "small" })) })] }), jsxRuntimeExports.jsx(Popover$2, { open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }, children: jsxRuntimeExports.jsxs(Box$2, { sx: { p: 1.5, maxWidth: 320, maxHeight: 240, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle2", sx: { mb: 1 }, children: t('tags') }), jsxRuntimeExports.jsx(Stack$2, { direction: "row", spacing: 1, useFlexGap: true, flexWrap: "wrap", children: safeTags.map((tag) => (jsxRuntimeExports.jsx(Chip$2, { label: tag.name, size: "small", variant: "outlined", sx: {
15625
+ }, children: safeTags.length ? jsxRuntimeExports.jsx(default_1$f, { fontSize: "small" }) : jsxRuntimeExports.jsx(default_1$e, { fontSize: "small" }) })] }), jsxRuntimeExports.jsx(Popover$2, { open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }, children: jsxRuntimeExports.jsxs(Box$2, { sx: { p: 1.5, maxWidth: 320, maxHeight: 240, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle2", sx: { mb: 1 }, children: t('tags') }), jsxRuntimeExports.jsx(Stack$2, { direction: "row", spacing: 1, useFlexGap: true, flexWrap: "wrap", children: safeTags.map((tag) => (jsxRuntimeExports.jsx(Chip$2, { label: tag.name, size: "small", variant: "outlined", sx: {
15451
15626
  borderRadius: 999,
15452
15627
  maxWidth: 160,
15453
15628
  '& .MuiChip-label': {
@@ -15474,8 +15649,13 @@ const NameWrapper = styled$5(Box$2)({
15474
15649
  display: 'flex',
15475
15650
  alignItems: 'center',
15476
15651
  justifyContent: 'center',
15477
- gap: '8px',
15478
15652
  width: '100%',
15653
+ });
15654
+ const NameContainer = styled$5(Box$2)({
15655
+ position: 'relative',
15656
+ display: 'flex',
15657
+ justifyContent: 'center',
15658
+ maxWidth: '100%',
15479
15659
  '&:hover .edit-icon': {
15480
15660
  opacity: 1,
15481
15661
  visibility: 'visible',
@@ -15485,6 +15665,10 @@ const EditButton = styled$5(IconButton$2)({
15485
15665
  opacity: 0,
15486
15666
  visibility: 'hidden',
15487
15667
  transition: 'all 0.2s',
15668
+ position: 'absolute',
15669
+ left: '100%',
15670
+ top: '50%',
15671
+ transform: 'translateY(-50%)',
15488
15672
  });
15489
15673
  const ContactName = ({ displayName, contactType, firstName, lastName, name, entityId, onEntityUpdated, }) => {
15490
15674
  const api = useEditContactApi();
@@ -15535,7 +15719,7 @@ const ContactName = ({ displayName, contactType, firstName, lastName, name, enti
15535
15719
  if (isEditing) {
15536
15720
  return (jsxRuntimeExports.jsxs(Box$2, { sx: { display: 'flex', alignItems: 'center', gap: 1, mt: 1 }, children: [contactType === 'contact' ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TextField$1, { value: values.firstName, onChange: (e) => setValues({ ...values, firstName: e.target.value }), size: "small", placeholder: "First Name", sx: { width: 140 } }), jsxRuntimeExports.jsx(TextField$1, { value: values.lastName, onChange: (e) => setValues({ ...values, lastName: e.target.value }), size: "small", placeholder: "Last Name", sx: { width: 140 } })] })) : (jsxRuntimeExports.jsx(TextField$1, { value: values.name, onChange: (e) => setValues({ ...values, name: e.target.value }), size: "small", placeholder: "Name", sx: { width: 280 } })), jsxRuntimeExports.jsx(IconButton$2, { onClick: handleSave, disabled: loading, color: "primary", children: loading ? jsxRuntimeExports.jsx(CircularProgress$2, { size: 24 }) : jsxRuntimeExports.jsx(Save$1, {}) })] }));
15537
15721
  }
15538
- 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" }) }))] }));
15722
+ 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" }) }))] }) }));
15539
15723
  };
15540
15724
 
15541
15725
  var Delete = {};
@@ -24650,7 +24834,7 @@ const PAGE_SIZE = 20;
24650
24834
  const AutocompletePopper = styled$3(MuiPopper)(({ theme }) => ({
24651
24835
  zIndex: theme.zIndex.modal + 1,
24652
24836
  }));
24653
- const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
24837
+ const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving, onCreateNew, isCreatingNew, }) => {
24654
24838
  const t = useTranslationContext();
24655
24839
  const [searchValue, setSearchValue] = useState('');
24656
24840
  const [limit, setLimit] = useState(PAGE_SIZE);
@@ -24666,10 +24850,19 @@ const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
24666
24850
  if (nearBottom)
24667
24851
  setLimit((l) => l + PAGE_SIZE);
24668
24852
  };
24669
- return (jsxRuntimeExports.jsxs(Box$2, { sx: { width: '100%' }, children: [jsxRuntimeExports.jsxs(Stack$2, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 2 }, children: [jsxRuntimeExports.jsx(IconButton$2, { size: "small", onClick: onBack, "aria-label": t('global.back'), disabled: isSaving, children: jsxRuntimeExports.jsx(default_1$b, { fontSize: "small" }) }), jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle1", children: t('tags') }), jsxRuntimeExports.jsx(Box$2, { 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(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(Chip$2, { label: option.name ?? '', ...getTagProps({ index }) }))), size: "small", renderInput: (params) => jsxRuntimeExports.jsx(TextField$1, { ...params, size: "small" }), ListboxProps: {
24853
+ const CustomNoOptionsMessage = () => {
24854
+ const trimmedSearchValue = String(searchValue ?? '').trim();
24855
+ const isDisabled = !trimmedSearchValue || isSaving || isCreatingNew;
24856
+ return (jsxRuntimeExports.jsxs(Box$2, { sx: {
24857
+ display: 'flex',
24858
+ justifyContent: 'space-between',
24859
+ alignItems: 'center',
24860
+ }, 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') })] }));
24861
+ };
24862
+ return (jsxRuntimeExports.jsxs(Box$2, { sx: { width: '100%' }, children: [jsxRuntimeExports.jsxs(Stack$2, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 2 }, children: [jsxRuntimeExports.jsx(IconButton$2, { size: "small", onClick: onBack, "aria-label": t('global.back'), disabled: isSaving, children: jsxRuntimeExports.jsx(default_1$b, { fontSize: "small" }) }), jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle1", children: t('tags') }), jsxRuntimeExports.jsx(Box$2, { 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(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(Chip$2, { label: option.name ?? '', ...getTagProps({ index }) }))), size: "small", renderInput: (params) => jsxRuntimeExports.jsx(TextField$1, { ...params, size: "small" }), ListboxProps: {
24670
24863
  onScroll: onListboxScroll,
24671
24864
  sx: { maxHeight: 280, overflowY: 'auto' },
24672
- }, noOptionsText: t('global.noOptions'), sx: { width: '100%' } })] }));
24865
+ }, noOptionsText: jsxRuntimeExports.jsx(CustomNoOptionsMessage, {}), sx: { width: '100%' } })] }));
24673
24866
  };
24674
24867
 
24675
24868
  class ApiError extends Error {
@@ -24743,17 +24936,22 @@ async function fetchLabels({ baseUrl, spaceId, signal }) {
24743
24936
  const url = joinUrl(urls.CONTACTS, '/labels');
24744
24937
  return requestJson({ url, signal });
24745
24938
  }
24939
+ async function createLabel({ baseUrl, spaceId, name, signal }) {
24940
+ const urls = getApiUrls(baseUrl, spaceId);
24941
+ const url = joinUrl(urls.CONTACTS, '/labels');
24942
+ return requestJson({ url, method: 'POST', body: { name }, signal });
24943
+ }
24746
24944
  async function fetchContact({ baseUrl, spaceId, contactId, signal }) {
24747
24945
  const urls = getApiUrls(baseUrl, spaceId);
24748
24946
  const url = joinUrl(urls.CONTACTS, `/contacts/${encodeURIComponent(contactId)}`);
24749
24947
  return requestJson({ url, signal });
24750
24948
  }
24751
- async function fetchContactFields({ baseUrl, spaceId, forType, signal }) {
24949
+ async function fetchContactFields({ baseUrl, spaceId, forType, signal, }) {
24752
24950
  const urls = getApiUrls(baseUrl, spaceId);
24753
24951
  const url = `${joinUrl(urls.CONTACTS, '/ContactFields')}?filter=custom&for=${encodeURIComponent(forType)}`;
24754
24952
  return requestJson({ url, signal });
24755
24953
  }
24756
- async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }) {
24954
+ async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal, }) {
24757
24955
  const path = entityType === 'business'
24758
24956
  ? `/business/${encodeURIComponent(entityId)}`
24759
24957
  : `/contacts/${encodeURIComponent(entityId)}`;
@@ -24766,7 +24964,7 @@ async function deleteAddress({ baseUrl, spaceId, data, signal }) {
24766
24964
  const url = joinUrl(urls.CONTACTS, '/contactAddresses');
24767
24965
  return requestJson({ url, method: 'DELETE', body: data, signal });
24768
24966
  }
24769
- async function checkContactAddress({ baseUrl, spaceId, data, signal }) {
24967
+ async function checkContactAddress({ baseUrl, spaceId, data, signal, }) {
24770
24968
  const urls = getApiUrls(baseUrl, spaceId);
24771
24969
  const url = joinUrl(urls.CONTACTS, '/contactAddresses/check');
24772
24970
  return requestJson({ url, method: 'POST', body: data, signal });
@@ -24776,7 +24974,7 @@ async function setContactAddress({ baseUrl, spaceId, data, signal }) {
24776
24974
  const url = joinUrl(urls.CONTACTS, '/contactAddresses/set');
24777
24975
  return requestJson({ url, method: 'POST', body: data, signal });
24778
24976
  }
24779
- async function updateContactAddress({ baseUrl, spaceId, data, signal }) {
24977
+ async function updateContactAddress({ baseUrl, spaceId, data, signal, }) {
24780
24978
  const urls = getApiUrls(baseUrl, spaceId);
24781
24979
  const url = joinUrl(urls.CONTACTS, `/contactAddresses/${encodeURIComponent(data.contactAddressId)}`);
24782
24980
  return requestJson({ url, method: 'PUT', body: data, signal });
@@ -24791,12 +24989,12 @@ async function fetchUsers({ baseUrl, spaceId, signal }) {
24791
24989
  const url = joinUrl(urls.SETTINGS, `/users`);
24792
24990
  return requestJson({ url, signal });
24793
24991
  }
24794
- async function fetchUserTriiById({ baseUrl, spaceId, signal, userId }) {
24992
+ async function fetchUserTriiById({ baseUrl, spaceId, signal, userId, }) {
24795
24993
  const urls = getApiUrls(baseUrl, spaceId);
24796
24994
  const url = joinUrl(urls.SETTINGS, `/usersInfor/${userId}`);
24797
24995
  return requestJson({ url, signal });
24798
24996
  }
24799
- async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
24997
+ async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal, }) {
24800
24998
  const urls = getApiUrls(baseUrl, spaceId);
24801
24999
  const fd = new FormData();
24802
25000
  fd.append('file', file, file.name);
@@ -24805,6 +25003,7 @@ async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
24805
25003
  }
24806
25004
  const createEditContactApi = (baseUrl, spaceId) => ({
24807
25005
  fetchLabels: ({ signal } = {}) => fetchLabels({ baseUrl, spaceId, signal }),
25006
+ createLabel: ({ name, signal }) => createLabel({ baseUrl, spaceId, name, signal }),
24808
25007
  fetchContact: ({ contactId, signal }) => fetchContact({ baseUrl, spaceId, contactId, signal }),
24809
25008
  fetchContactFields: ({ forType, signal }) => fetchContactFields({ baseUrl, spaceId, forType, signal }),
24810
25009
  updateEntity: ({ entityType, entityId, body, signal }) => updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }),
@@ -25611,6 +25810,7 @@ var editContactHelper = { getEditedField, getAddressesWithUpdatedValues };
25611
25810
 
25612
25811
  const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, }) => {
25613
25812
  const [isDeletingAddress, setIsDeletingAddress] = useState(false);
25813
+ const [initialSnapshot, setInitialSnapshot] = useState(() => initial);
25614
25814
  const [imsFacebooks, setImsFacebooks] = useState(initial?.ims_facebook || []);
25615
25815
  const [imsMercadolibre, setImsMercadolibre] = useState(initial?.ims_mercadolibre || []);
25616
25816
  const [imsWebchats, setImsWebchats] = useState(initial?.ims_webchat || []);
@@ -25642,6 +25842,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25642
25842
  const addWhatsappVerified = (newWhatsapp) => {
25643
25843
  const updatedWhatsapps = [...imsWhatsapp, newWhatsapp];
25644
25844
  setImsWhatsApp(updatedWhatsapps);
25845
+ setInitialSnapshot((prev) => ({
25846
+ ...(prev ?? {}),
25847
+ ims_whatsapp: updatedWhatsapps,
25848
+ }));
25645
25849
  };
25646
25850
  const replaceAddress = (addressId, newAddress) => {
25647
25851
  if (!newAddress) {
@@ -25655,6 +25859,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25655
25859
  return email;
25656
25860
  });
25657
25861
  setEmails(newEmails);
25862
+ setInitialSnapshot((prev) => ({
25863
+ ...(prev ?? {}),
25864
+ emails: newEmails,
25865
+ }));
25658
25866
  }
25659
25867
  if (newAddress.channelType === 5) {
25660
25868
  const newPhoneNumbers = phoneNumbers.map((phoneNumber) => {
@@ -25664,6 +25872,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25664
25872
  return phoneNumber;
25665
25873
  });
25666
25874
  setPhoneNumbers(newPhoneNumbers);
25875
+ setInitialSnapshot((prev) => ({
25876
+ ...(prev ?? {}),
25877
+ phones: newPhoneNumbers,
25878
+ }));
25667
25879
  }
25668
25880
  if (newAddress.channelType === 13) {
25669
25881
  const newImsWhatsapp = imsWhatsapp.map((item) => {
@@ -25673,6 +25885,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25673
25885
  return item;
25674
25886
  });
25675
25887
  setImsWhatsApp(newImsWhatsapp);
25888
+ setInitialSnapshot((prev) => ({
25889
+ ...(prev ?? {}),
25890
+ ims_whatsapp: newImsWhatsapp,
25891
+ }));
25676
25892
  }
25677
25893
  if (newAddress.channelType === 21) {
25678
25894
  const newImsRCS = imsRCS.map((item) => {
@@ -25682,6 +25898,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25682
25898
  return item;
25683
25899
  });
25684
25900
  setImsRCS(newImsRCS);
25901
+ setInitialSnapshot((prev) => ({
25902
+ ...(prev ?? {}),
25903
+ ims_rcs: newImsRCS,
25904
+ }));
25685
25905
  }
25686
25906
  if (newAddress.channelType === 41) {
25687
25907
  const newImsMercadolibre = imsMercadolibre.map((item) => {
@@ -25691,6 +25911,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25691
25911
  return item;
25692
25912
  });
25693
25913
  setImsMercadolibre(newImsMercadolibre);
25914
+ setInitialSnapshot((prev) => ({
25915
+ ...(prev ?? {}),
25916
+ ims_mercadolibre: newImsMercadolibre,
25917
+ }));
25694
25918
  }
25695
25919
  };
25696
25920
  const handleAddressFieldChange = async (e, fieldId, type) => {
@@ -25843,49 +26067,82 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25843
26067
  case 3:
25844
26068
  const newEmails = emails.filter((email) => email.id !== fieldId);
25845
26069
  setEmails(newEmails);
26070
+ setInitialSnapshot((prev) => ({
26071
+ ...(prev ?? {}),
26072
+ emails: newEmails,
26073
+ }));
25846
26074
  break;
25847
26075
  case 5:
25848
26076
  const newPhoneNumbers = phoneNumbers.filter((phoneNumber) => phoneNumber.id !== fieldId);
25849
26077
  setPhoneNumbers(newPhoneNumbers);
26078
+ setInitialSnapshot((prev) => ({
26079
+ ...(prev ?? {}),
26080
+ phones: newPhoneNumbers,
26081
+ }));
25850
26082
  break;
25851
26083
  case 13:
25852
26084
  const newImsWhatsapp = imsWhatsapp.filter((item) => item.id !== fieldId);
25853
26085
  setImsWhatsApp(newImsWhatsapp);
26086
+ setInitialSnapshot((prev) => ({
26087
+ ...(prev ?? {}),
26088
+ ims_whatsapp: newImsWhatsapp,
26089
+ }));
25854
26090
  break;
25855
26091
  case 21:
25856
26092
  const newImsRCS = imsRCS.filter((item) => item.id !== fieldId);
25857
26093
  setImsRCS(newImsRCS);
26094
+ setInitialSnapshot((prev) => ({
26095
+ ...(prev ?? {}),
26096
+ ims_rcs: newImsRCS,
26097
+ }));
25858
26098
  break;
25859
26099
  case 41:
25860
26100
  const newImsMercadolibre = imsMercadolibre.filter((item) => item.id !== fieldId);
25861
26101
  setImsMercadolibre(newImsMercadolibre);
26102
+ setInitialSnapshot((prev) => ({
26103
+ ...(prev ?? {}),
26104
+ ims_mercadolibre: newImsMercadolibre,
26105
+ }));
25862
26106
  break;
25863
26107
  case 14:
25864
26108
  const newImsFacebooks = imsFacebooks.filter((item) => item.id !== fieldId);
25865
26109
  setImsFacebooks(newImsFacebooks);
26110
+ setInitialSnapshot((prev) => ({
26111
+ ...(prev ?? {}),
26112
+ ims_facebook: newImsFacebooks,
26113
+ }));
25866
26114
  break;
25867
26115
  case 20:
25868
26116
  const newImsWebchats = imsWebchats.filter((item) => item.id !== fieldId);
25869
26117
  setImsWebchats(newImsWebchats);
26118
+ setInitialSnapshot((prev) => ({
26119
+ ...(prev ?? {}),
26120
+ ims_webchat: newImsWebchats,
26121
+ }));
25870
26122
  break;
25871
26123
  case 16:
25872
26124
  const newImsInstagrams = imsInstagrams.filter((item) => item.id !== fieldId);
25873
26125
  setImsInstagrams(newImsInstagrams);
26126
+ setInitialSnapshot((prev) => ({
26127
+ ...(prev ?? {}),
26128
+ ims_instagram: newImsInstagrams,
26129
+ }));
25874
26130
  break;
25875
26131
  }
25876
26132
  }
25877
26133
  };
25878
26134
  function resetToInitialContactInformation() {
25879
- setImsFacebooks(initial?.ims_facebook || []);
25880
- setImsMercadolibre(initial?.ims_mercadolibre || []);
25881
- setImsWebchats(initial?.ims_webchat || []);
25882
- setImsInstagrams(initial?.ims_instagram || []);
25883
- setImsWhatsApp(initial?.ims_whatsapp || []);
25884
- setImsRCS(initial?.ims_rcs || []);
25885
- setEmails(initial?.emails || []);
25886
- setPhoneNumbers(initial?.phones || []);
26135
+ setImsFacebooks(initialSnapshot?.ims_facebook || []);
26136
+ setImsMercadolibre(initialSnapshot?.ims_mercadolibre || []);
26137
+ setImsWebchats(initialSnapshot?.ims_webchat || []);
26138
+ setImsInstagrams(initialSnapshot?.ims_instagram || []);
26139
+ setImsWhatsApp(initialSnapshot?.ims_whatsapp || []);
26140
+ setImsRCS(initialSnapshot?.ims_rcs || []);
26141
+ setEmails(initialSnapshot?.emails || []);
26142
+ setPhoneNumbers(initialSnapshot?.phones || []);
25887
26143
  }
25888
26144
  useEffect(() => {
26145
+ setInitialSnapshot(initial);
25889
26146
  if (initial?.emails && initial?.phones) {
25890
26147
  setEmails(initial.emails);
25891
26148
  setPhoneNumbers(initial.phones);
@@ -25950,7 +26207,7 @@ const useMultipleSelect = ({ initialState = [], } = {}) => {
25950
26207
  };
25951
26208
  };
25952
26209
 
25953
- const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) => {
26210
+ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId, }) => {
25954
26211
  const apiDeleteAddress = useMemo(() => async (payload) => {
25955
26212
  if (!baseUrl || !spaceId)
25956
26213
  return;
@@ -25990,8 +26247,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
25990
26247
  const country = useField$1('text', business?.address1?.country || '');
25991
26248
  const secondaryCountry = useField$1('text', business?.address2?.country || '');
25992
26249
  const getEditedField = (key, originalValue, editedValue) => {
25993
- if (originalValue !== editedValue &&
25994
- !(originalValue === null && editedValue === '')) {
26250
+ if (originalValue !== editedValue && !(originalValue === null && editedValue === '')) {
25995
26251
  return { [key]: editedValue };
25996
26252
  }
25997
26253
  return {};
@@ -26018,9 +26274,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
26018
26274
  id: business.id,
26019
26275
  ...getEditedField('owner', business.owner, contactPropietary.attributes.value),
26020
26276
  ...getEditedField('name', business.name, name.attributes.value),
26021
- imageUrl: contactImage.imageUrl
26022
- ? contactImage.removeParams(contactImage.imageUrl)
26023
- : null,
26277
+ imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
26024
26278
  tags: labelMultipleSelect.attributes.value,
26025
26279
  properties: customProperties,
26026
26280
  members: selectedContacts,
@@ -26035,26 +26289,23 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
26035
26289
  function resetCustomProperty(nameKey) {
26036
26290
  if (!business)
26037
26291
  return;
26038
- const defaultProperty = business.properties.find((property) => property.nameKey === nameKey);
26292
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26293
+ const defaultProperty = business.properties.find((property) => property.nameKey === nameKey) ??
26294
+ business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
26039
26295
  if (!defaultProperty) {
26040
26296
  console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
26041
26297
  return; // Salir de la función si no se encuentra la propiedad
26042
26298
  }
26043
- const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
26044
- ? { ...property, value: defaultProperty.value }
26045
- : property);
26299
+ const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
26046
26300
  setCustomProperties(updatedProperties);
26047
26301
  }
26048
- function replaceSpacesWithHyphen(input) {
26049
- const result = input.replace(/ /g, '-');
26050
- return result;
26051
- }
26052
26302
  const getFilteredCustomProperties = () => {
26053
26303
  if (!business)
26054
26304
  return [];
26055
26305
  return customContactFields.map((customField) => {
26056
- const customFieldWithHyphen = replaceSpacesWithHyphen(customField.nameKey);
26057
- const existingBusinessProperty = business.properties.find((property) => property.nameKey === customFieldWithHyphen);
26306
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26307
+ const existingBusinessProperty = business.properties.find((property) => property.nameKey === customField.nameKey) ??
26308
+ business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
26058
26309
  if (existingBusinessProperty) {
26059
26310
  return {
26060
26311
  ...existingBusinessProperty,
@@ -26139,7 +26390,7 @@ var dayjs_min = {exports: {}};
26139
26390
  var dayjs_minExports = dayjs_min.exports;
26140
26391
  var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
26141
26392
 
26142
- const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26393
+ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId, }) => {
26143
26394
  const apiDeleteAddress = useMemo(() => async (payload) => {
26144
26395
  if (!baseUrl || !spaceId)
26145
26396
  return;
@@ -26223,9 +26474,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26223
26474
  phones: modifiedPhones,
26224
26475
  // ims_whatsapp: modifiedImsWhatsapp,
26225
26476
  tags: modifiedTags,
26226
- imageUrl: contactImage.imageUrl
26227
- ? contactImage.removeParams(contactImage.imageUrl)
26228
- : null,
26477
+ imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
26229
26478
  properties: customProperties,
26230
26479
  // businessId: selectedBusiness[0]?.businessId || '',
26231
26480
  // businessName: selectedBusiness[0]?.businessName || '',
@@ -26251,27 +26500,23 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26251
26500
  function resetCustomProperty(nameKey) {
26252
26501
  if (!contact)
26253
26502
  return;
26254
- const defaultProperty = contact.properties.find((property) => property.nameKey === nameKey);
26503
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26504
+ const defaultProperty = contact.properties.find((property) => property.nameKey === nameKey) ??
26505
+ contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
26255
26506
  if (!defaultProperty) {
26256
26507
  console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
26257
26508
  return; // Salir de la función si no se encuentra la propiedad
26258
26509
  }
26259
- const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
26260
- ? { ...property, value: defaultProperty.value }
26261
- : property);
26510
+ const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
26262
26511
  setCustomProperties(updatedProperties);
26263
26512
  }
26264
- // Utils
26265
- function replaceSpacesWithHyphen(input) {
26266
- const result = input.replace(/ /g, '-');
26267
- return result;
26268
- }
26269
26513
  const getFilteredCustomProperties = () => {
26270
26514
  if (!contact)
26271
26515
  return [];
26272
26516
  return customContactFields.map((customField) => {
26273
- const customFieldWithHypen = replaceSpacesWithHyphen(customField.nameKey);
26274
- const existingProperty = contact.properties.find((property) => property.nameKey === customFieldWithHypen);
26517
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26518
+ const existingProperty = contact.properties.find((property) => property.nameKey === customField.nameKey) ??
26519
+ contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
26275
26520
  if (existingProperty) {
26276
26521
  return {
26277
26522
  ...existingProperty,
@@ -26403,7 +26648,7 @@ const Section = ({ title, children }) => {
26403
26648
  borderRadius: 2,
26404
26649
  p: 2,
26405
26650
  mb: 2,
26406
- }, children: [jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle1", sx: { fontWeight: 600 }, children: title }), jsxRuntimeExports.jsx(Divider, { sx: { my: 1.5 } }), children] }));
26651
+ }, children: [jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(Divider, { sx: { my: 1.5 } }), children] }));
26407
26652
  };
26408
26653
 
26409
26654
  const SectionContent = ({ children, ...boxProps }) => {
@@ -52551,7 +52796,7 @@ function SelectBusinessLabel({ value, displayValue, businessId }) {
52551
52796
  }
52552
52797
  setAnchorEl(targetElement);
52553
52798
  };
52554
- return (jsxRuntimeExports.jsxs(Box$2, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(Typography$2, { onClick: handleOpenInfoPopover, fontWeight: '600', sx: {
52799
+ return (jsxRuntimeExports.jsxs(Box$2, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(Typography$2, { onClick: handleOpenInfoPopover, variant: "body2", fontWeight: '600', sx: {
52555
52800
  padding: 1,
52556
52801
  cursor: 'pointer',
52557
52802
  }, 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(Box$2, { display: "flex", alignItems: "center", justifyContent: "center", p: 1, children: jsxRuntimeExports.jsx(CircularProgress$2, { size: 20 }) }))] }));
@@ -52580,11 +52825,38 @@ const EntityInfoLabel = (props) => {
52580
52825
  const inputType = props.inputType ?? 'text';
52581
52826
  const [isEditing, setIsEditing] = useState(false);
52582
52827
  const [isSaving, setIsSaving] = useState(false);
52828
+ const titleRef = useRef(null);
52829
+ const [isTitleTruncated, setIsTitleTruncated] = useState(false);
52583
52830
  const [inputValue, setInputValue] = useState(() => {
52584
52831
  if (props.entityType === 'business')
52585
52832
  return value;
52586
52833
  return typeof value === 'string' ? value : undefined;
52587
52834
  });
52835
+ useEffect(() => {
52836
+ const el = titleRef.current;
52837
+ if (!el)
52838
+ return;
52839
+ const check = () => {
52840
+ const next = el.scrollWidth > el.clientWidth;
52841
+ setIsTitleTruncated(next);
52842
+ };
52843
+ check();
52844
+ if (typeof ResizeObserver !== 'undefined') {
52845
+ const ro = new ResizeObserver(() => {
52846
+ check();
52847
+ });
52848
+ ro.observe(el);
52849
+ return () => {
52850
+ ro.disconnect();
52851
+ };
52852
+ }
52853
+ if (typeof window === 'undefined')
52854
+ return;
52855
+ window.addEventListener('resize', check);
52856
+ return () => {
52857
+ window.removeEventListener('resize', check);
52858
+ };
52859
+ }, [title, isEditing]);
52588
52860
  useEffect(() => {
52589
52861
  if (props.entityType === 'business') {
52590
52862
  setInputValue(value);
@@ -52689,12 +52961,17 @@ const EntityInfoLabel = (props) => {
52689
52961
  '&:hover .edit-icon': {
52690
52962
  opacity: 1,
52691
52963
  },
52692
- }, children: [jsxRuntimeExports.jsxs(Box$2, { display: "flex", position: "relative", minHeight: '25px', children: [jsxRuntimeExports.jsx(Typography$2, { 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(CircularProgress$2, { 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(Box$2, { width: isEditing ? '100%' : '50%', position: "relative", children: isEditing && inputType === 'text' ? (jsxRuntimeExports.jsx(TextField$1, { value: textValue, onChange: handleInputChange, variant: "standard", size: "small", sx: { width: '100%' } })) : isEditing && (inputType === 'select' || inputType === 'selectMembers') ? (jsxRuntimeExports.jsxs(Select$2, { value: selectValue, onChange: handleSelectChange, variant: "standard", size: "small", sx: { width: '100%' }, children: [props.entityType === 'contact' ? (jsxRuntimeExports.jsx(MenuItem$2, { value: "", children: t('conversations.contactDetails.contactInfo.emptySelection') })) : null, options.map((option, index) => (jsxRuntimeExports.jsx(MenuItem$2, { value: option.id, children: props.entityType === 'contact'
52964
+ }, children: [jsxRuntimeExports.jsxs(Box$2, { display: "flex", position: "relative", minHeight: '25px', children: [isTitleTruncated ? (jsxRuntimeExports.jsx(Tooltip, { title: title, arrow: true, children: jsxRuntimeExports.jsx(Typography$2, { 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: {
52965
+ minWidth: 0,
52966
+ overflow: 'hidden',
52967
+ textOverflow: 'ellipsis',
52968
+ whiteSpace: 'nowrap',
52969
+ }, children: title }) })) : (jsxRuntimeExports.jsx(Typography$2, { 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(CircularProgress$2, { 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(Box$2, { width: isEditing ? '100%' : '50%', position: "relative", children: isEditing && inputType === 'text' ? (jsxRuntimeExports.jsx(TextField$1, { value: textValue, onChange: handleInputChange, variant: "standard", size: "small", sx: { width: '100%' } })) : isEditing && (inputType === 'select' || inputType === 'selectMembers') ? (jsxRuntimeExports.jsxs(Select$2, { value: selectValue, onChange: handleSelectChange, variant: "standard", size: "small", sx: { width: '100%' }, children: [props.entityType === 'contact' ? (jsxRuntimeExports.jsx(MenuItem$2, { value: "", children: t('conversations.contactDetails.contactInfo.emptySelection') })) : null, options.map((option, index) => (jsxRuntimeExports.jsx(MenuItem$2, { value: option.id, children: props.entityType === 'contact'
52693
52970
  ? option.name?.trim() || (isUserInfo(option) ? option.email : '') || 'Sin nombre'
52694
52971
  : 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 &&
52695
52972
  props.entityType === 'contact' &&
52696
52973
  inputType === 'selectBusiness' &&
52697
- props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: value, displayValue: displayValue, businessId: props.businessId })) : (jsxRuntimeExports.jsx(Typography$2, { fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
52974
+ props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: String(value ?? ''), displayValue: String(displayValue ?? ''), businessId: props.businessId })) : (jsxRuntimeExports.jsx(Typography$2, { variant: "body2", fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
52698
52975
  };
52699
52976
 
52700
52977
  const ContactInfoLabel = (props) => {
@@ -54526,13 +54803,19 @@ const ContactBox = styled$5(Box$2)(({ theme }) => ({
54526
54803
  }));
54527
54804
  const FieldName = styled$5(Typography$2)(({ theme }) => ({
54528
54805
  fontWeight: 600,
54806
+ fontSize: '0.875rem',
54529
54807
  alignSelf: 'center',
54530
54808
  color: theme.palette.text.primary,
54531
54809
  letterSpacing: -0.5,
54532
54810
  padding: 0,
54811
+ whiteSpace: 'nowrap',
54812
+ overflow: 'hidden',
54813
+ textOverflow: 'ellipsis',
54814
+ minWidth: 0,
54533
54815
  }));
54534
54816
  const FieldValue = styled$5(Typography$2)(({ theme }) => ({
54535
54817
  fontWeight: 400,
54818
+ fontSize: '0.875rem',
54536
54819
  padding: '2.5px 14px 8.5px 0px',
54537
54820
  color: theme.palette.text.primary,
54538
54821
  wordWrap: 'break-word',
@@ -54545,6 +54828,8 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54545
54828
  const { setCustomProperties } = entity.action;
54546
54829
  const [isEditing, setIsEditing] = useState(false);
54547
54830
  const [isSaving, setIsSaving] = useState(false);
54831
+ const titleRef = useRef(null);
54832
+ const [isTitleTruncated, setIsTitleTruncated] = useState(false);
54548
54833
  const userDateFormat = (userTrii?.regCon_dateFormat || 'YYYY/MM/DD').toUpperCase();
54549
54834
  const userTimeFormat = userTrii?.regCon_timeFormat || '24';
54550
54835
  // Determina si el tipo de campo es numérico
@@ -54650,6 +54935,31 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54650
54935
  const foundField = customContactFields.find((field) => field.nameKey === propertyNameKey);
54651
54936
  return foundField?.name || propertyNameKey;
54652
54937
  };
54938
+ useEffect(() => {
54939
+ const el = titleRef.current;
54940
+ if (!el)
54941
+ return;
54942
+ const check = () => {
54943
+ const next = el.scrollWidth > el.clientWidth;
54944
+ setIsTitleTruncated(next);
54945
+ };
54946
+ check();
54947
+ if (typeof ResizeObserver !== 'undefined') {
54948
+ const ro = new ResizeObserver(() => {
54949
+ check();
54950
+ });
54951
+ ro.observe(el);
54952
+ return () => {
54953
+ ro.disconnect();
54954
+ };
54955
+ }
54956
+ if (typeof window === 'undefined')
54957
+ return;
54958
+ window.addEventListener('resize', check);
54959
+ return () => {
54960
+ window.removeEventListener('resize', check);
54961
+ };
54962
+ }, [customContactFields, property.nameKey, isEditing]);
54653
54963
  const handleInputChange = (name, value) => {
54654
54964
  const updatedValue = property.type === Contacts.ContactField_type.DATERANGE
54655
54965
  ? Array.isArray(value) && value[0] && value[1]
@@ -54702,7 +55012,7 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54702
55012
  else
54703
55013
  return (jsxRuntimeExports.jsx(CustomPropertyInput, { type: type, nameKey: nameKey, value: value, onChange: handleInputChange }));
54704
55014
  };
54705
- return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(Box$2, { 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(CircularProgress$2, { 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(Box$2, { width: isEditing || property.type === Contacts.ContactField_type.LONGTEXT ? '100%' : '50%', position: "relative", children: isEditing ? (EditField()) : (jsxRuntimeExports.jsx(FieldValue, { children: hasValue(property?.value)
55015
+ return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(Box$2, { display: "flex", position: "relative", minHeight: "25px", alignItems: "center", children: [isTitleTruncated ? (jsxRuntimeExports.jsx(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(CircularProgress$2, { 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(Box$2, { width: isEditing || property.type === Contacts.ContactField_type.LONGTEXT ? '100%' : '50%', position: "relative", children: isEditing ? (EditField()) : (jsxRuntimeExports.jsx(FieldValue, { children: hasValue(property?.value)
54706
55016
  ? property.type === Contacts.ContactField_type.DATERANGE
54707
55017
  ? (() => {
54708
55018
  if (typeof property.value === 'string') {
@@ -57169,7 +57479,7 @@ const AddressInformation = ({ entityType, entityData, baseUrl, spaceId, onEntity
57169
57479
  onEntityUpdated,
57170
57480
  };
57171
57481
  const t = useTranslationContext();
57172
- const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(Typography$2, { 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) => ({
57482
+ const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(Typography$2, { 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) => ({
57173
57483
  [addressNumber]: { street: value },
57174
57484
  }), minWidth: "100%" }) }), jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.city'), value: entityData[addressNumber]?.city ?? '', ...commonProps, constructUpdateObject: (value) => ({
57175
57485
  [addressNumber]: { city: value },
@@ -57209,11 +57519,31 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
57209
57519
  const [draftLabels, setDraftLabels] = useState([]);
57210
57520
  const [tagsEditorInitialized, setTagsEditorInitialized] = useState(false);
57211
57521
  const [isSaving, setIsSaving] = useState(false);
57522
+ const [createdLabels, setCreatedLabels] = useState([]);
57523
+ const [isCreatingLabel, setIsCreatingLabel] = useState(false);
57524
+ const labelsOptions = useMemo(() => {
57525
+ const safeLabels = labels ?? [];
57526
+ const safeCreated = createdLabels ?? [];
57527
+ const byId = new Map();
57528
+ for (const label of safeLabels) {
57529
+ if (!label?.id)
57530
+ continue;
57531
+ byId.set(String(label.id), label);
57532
+ }
57533
+ for (const label of safeCreated) {
57534
+ if (!label?.id)
57535
+ continue;
57536
+ byId.set(String(label.id), label);
57537
+ }
57538
+ return Array.from(byId.values());
57539
+ }, [labels, createdLabels]);
57212
57540
  const reset = useCallback(() => {
57213
57541
  setView('main');
57214
57542
  setDraftLabels([]);
57215
57543
  setTagsEditorInitialized(false);
57216
57544
  setIsSaving(false);
57545
+ setCreatedLabels([]);
57546
+ setIsCreatingLabel(false);
57217
57547
  }, []);
57218
57548
  useEffect(() => {
57219
57549
  if (!open) {
@@ -57227,13 +57557,61 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
57227
57557
  }
57228
57558
  if (tagsEditorInitialized)
57229
57559
  return;
57230
- if (!labels.length)
57560
+ if (!labelsOptions.length)
57231
57561
  return;
57232
57562
  const selectedTagIds = new Set(selectedTags.map((t) => String(t.id)));
57233
- const initialDraft = labels.filter((l) => selectedTagIds.has(String(l?.id)));
57563
+ const initialDraft = labelsOptions.filter((l) => selectedTagIds.has(String(l?.id)));
57234
57564
  setDraftLabels(initialDraft);
57235
57565
  setTagsEditorInitialized(true);
57236
- }, [view, tagsEditorInitialized, labels, selectedTags]);
57566
+ }, [view, tagsEditorInitialized, labelsOptions, selectedTags]);
57567
+ const handleCreateLabel = useCallback(async (name) => {
57568
+ if (isCreatingLabel)
57569
+ return;
57570
+ if (!baseUrl || !spaceId)
57571
+ return;
57572
+ const trimmedName = String(name ?? '').trim();
57573
+ if (!trimmedName)
57574
+ return;
57575
+ const normalizedName = trimmedName.toLowerCase();
57576
+ const existing = labelsOptions.find((l) => String(l?.name ?? '')
57577
+ .trim()
57578
+ .toLowerCase() === normalizedName);
57579
+ if (existing?.id) {
57580
+ setDraftLabels((prev) => {
57581
+ const safePrev = prev ?? [];
57582
+ const existsInDraft = safePrev.some((p) => String(p?.id) === String(existing.id));
57583
+ if (existsInDraft)
57584
+ return safePrev;
57585
+ return [...safePrev, existing];
57586
+ });
57587
+ return;
57588
+ }
57589
+ setIsCreatingLabel(true);
57590
+ try {
57591
+ const created = await createLabel({ baseUrl, spaceId, name: trimmedName });
57592
+ setCreatedLabels((prev) => {
57593
+ const safePrev = prev ?? [];
57594
+ if (!created?.id)
57595
+ return safePrev;
57596
+ const existsInCreated = safePrev.some((p) => String(p?.id) === String(created.id));
57597
+ if (existsInCreated)
57598
+ return safePrev;
57599
+ return [...safePrev, created];
57600
+ });
57601
+ setDraftLabels((prev) => {
57602
+ const safePrev = prev ?? [];
57603
+ if (!created?.id)
57604
+ return safePrev;
57605
+ const existsInDraft = safePrev.some((p) => String(p?.id) === String(created.id));
57606
+ if (existsInDraft)
57607
+ return safePrev;
57608
+ return [...safePrev, created];
57609
+ });
57610
+ }
57611
+ finally {
57612
+ setIsCreatingLabel(false);
57613
+ }
57614
+ }, [isCreatingLabel, baseUrl, spaceId, labelsOptions]);
57237
57615
  const handleSaveTags = useCallback(async () => {
57238
57616
  if (isSaving)
57239
57617
  return;
@@ -57267,28 +57645,32 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
57267
57645
  setView,
57268
57646
  draftLabels,
57269
57647
  setDraftLabels,
57648
+ labelsOptions,
57270
57649
  isSaving,
57650
+ isCreatingLabel,
57651
+ handleCreateLabel,
57271
57652
  handleSaveTags,
57272
57653
  };
57273
57654
  };
57274
57655
 
57275
57656
  const useModalCloseHandler = ({ onClose }) => {
57276
- const handleClose = useCallback((event, reason) => {
57657
+ const handleClose = useCallback((_event, reason) => {
57277
57658
  if (reason === 'escapeKeyDown') {
57278
- const maybeEvent = event;
57279
- if (typeof maybeEvent?.stopPropagation === 'function') {
57280
- maybeEvent.stopPropagation();
57281
- }
57282
- if (typeof maybeEvent?.preventDefault === 'function') {
57283
- maybeEvent.preventDefault();
57284
- }
57659
+ return;
57285
57660
  }
57286
57661
  onClose();
57287
57662
  }, [onClose]);
57288
57663
  return handleClose;
57289
57664
  };
57290
57665
 
57291
- const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, t, navigate, }) => {
57666
+ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, language = 'en', navigate, }) => {
57667
+ const { t: i18nT, i18n } = useTranslation();
57668
+ useEffect(() => {
57669
+ if (language) {
57670
+ i18n.changeLanguage(language);
57671
+ }
57672
+ }, [language, i18n]);
57673
+ const t = (key) => i18nT(key);
57292
57674
  const api = useMemo(() => {
57293
57675
  if (!baseUrl || !spaceId)
57294
57676
  return null;
@@ -57304,7 +57686,7 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, t, n
57304
57686
  entity: state.contactData,
57305
57687
  setEntity: (next) => actions.setContactData(next ?? undefined),
57306
57688
  });
57307
- const { view, setView, draftLabels, setDraftLabels, isSaving: isSavingTags, handleSaveTags, } = useTagsEditorController({
57689
+ const { view, setView, draftLabels, setDraftLabels, labelsOptions, isSaving: isSavingTags, isCreatingLabel, handleCreateLabel, handleSaveTags, } = useTagsEditorController({
57308
57690
  open,
57309
57691
  baseUrl,
57310
57692
  spaceId,
@@ -57344,20 +57726,26 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, t, n
57344
57726
  overflow: 'hidden',
57345
57727
  };
57346
57728
  const mergedSx = Array.isArray(sx) ? [baseSx, ...sx] : sx ? [baseSx, sx] : baseSx;
57347
- return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(Modal$2, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: Backdrop$2 }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(Fade$2, { in: open, timeout: 200, children: jsxRuntimeExports.jsx(Box$2, { sx: mergedSx, children: state.isLoading && !state.contactData ? (jsxRuntimeExports.jsx(Box$2, { sx: {
57348
- display: 'flex',
57349
- justifyContent: 'center',
57350
- alignItems: 'center',
57351
- minHeight: 220,
57352
- }, children: jsxRuntimeExports.jsx(CircularProgress$2, {}) })) : state.error ? (jsxRuntimeExports.jsx(Box$2, { 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(Box$2, { sx: { position: 'relative', height: '100%' }, children: [jsxRuntimeExports.jsx(Fade$2, { in: view === 'main', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsxs(Box$2, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Header, { imgUrl: image.imageUrl, displayName: selectors.displayName, tags: selectors.tags, onEditTags: () => {
57353
- setView('tags');
57354
- }, 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(Box$2, { sx: { px: 1, pb: 2 }, children: [jsxRuntimeExports.jsx(General, { dateFormat: selectors.userTrii?.regCon_dateFormat || 'MM/dd/yyyy', entityType: selectors.contactType === 'contact' ||
57355
- selectors.contactType === 'business'
57356
- ? selectors.contactType
57357
- : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' ||
57358
- selectors.contactType === 'business'
57359
- ? selectors.contactType
57360
- : 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsx(ContactInformation, { ownerData: state.contactData })] })] }) }), jsxRuntimeExports.jsx(Fade$2, { in: view === 'tags', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsx(Box$2, { 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 }) }) }) }) }) }));
57729
+ return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(Modal$2, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: Backdrop$2 }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(Fade$2, { in: open, timeout: 200, children: jsxRuntimeExports.jsxs(Box$2, { sx: mergedSx, children: [jsxRuntimeExports.jsx(IconButton$2, { "aria-label": "close", onClick: handleClose, sx: {
57730
+ position: 'absolute',
57731
+ right: 8,
57732
+ top: 8,
57733
+ color: (theme) => theme.palette.grey[500],
57734
+ zIndex: 1,
57735
+ }, children: jsxRuntimeExports.jsx(default_1$g, {}) }), state.isLoading && !state.contactData ? (jsxRuntimeExports.jsx(Box$2, { sx: {
57736
+ display: 'flex',
57737
+ justifyContent: 'center',
57738
+ alignItems: 'center',
57739
+ minHeight: 220,
57740
+ }, children: jsxRuntimeExports.jsx(CircularProgress$2, {}) })) : state.error ? (jsxRuntimeExports.jsx(Box$2, { 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(Box$2, { sx: { position: 'relative', height: '100%' }, children: [jsxRuntimeExports.jsx(Fade$2, { in: view === 'main', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsxs(Box$2, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Header, { imgUrl: image.imageUrl, displayName: selectors.displayName, tags: selectors.tags, onEditTags: () => {
57741
+ setView('tags');
57742
+ }, 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(Box$2, { sx: { px: 1, pb: 2 }, children: [jsxRuntimeExports.jsx(General, { dateFormat: selectors.userTrii?.regCon_dateFormat || 'MM/dd/yyyy', entityType: selectors.contactType === 'contact' ||
57743
+ selectors.contactType === 'business'
57744
+ ? selectors.contactType
57745
+ : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' ||
57746
+ selectors.contactType === 'business'
57747
+ ? selectors.contactType
57748
+ : 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsx(ContactInformation, { ownerData: state.contactData })] })] }) }), jsxRuntimeExports.jsx(Fade$2, { in: view === 'tags', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsx(Box$2, { 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] }) }) }) }) }) }));
57361
57749
  };
57362
57750
 
57363
57751
  export { ContactInfoPopup, EditContactModal };