zenit-sdk 0.1.8 → 0.1.9

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.
@@ -640,6 +640,55 @@ function useGeolocation(options) {
640
640
 
641
641
  // src/react/map/map-utils.ts
642
642
  import L2 from "leaflet";
643
+
644
+ // src/config/modalWhitelist.ts
645
+ var SECTOR_MODAL_WHITELIST = [
646
+ { key: "Sector", label: "Sector" },
647
+ { key: "Promotor", label: "Promotor" },
648
+ { key: "Capital Total", label: "Capital Total" },
649
+ { key: "Total Capital Mora", label: "Capital en Mora" },
650
+ { key: "Tendencia Mora", label: "Tendencia de Mora", hint: "trend_icon" },
651
+ { key: "Tendencia Capital", label: "Tendencia de Capital", hint: "trend_icon" },
652
+ { key: "Tendencia Castigos", label: "Tendencia de Castigos", hint: "trend_icon" },
653
+ { key: "Impacto Sector", label: "Impacto del Sector" },
654
+ { key: "Total Clientes Sector", label: "Total de Clientes" },
655
+ { key: "Total Clientes Sanos", label: "Clientes Sanos" },
656
+ { key: "Total Clientes Morosos", label: "Clientes en Mora" },
657
+ { key: "Total Clientes Castigados", label: "Clientes Castigados" },
658
+ { key: "Total Clientes Nuevos", label: "Clientes Nuevos" },
659
+ { key: "Total Clientes Salidos", label: "Clientes Salidos" },
660
+ { key: "Insights", label: "An\xE1lisis IA", hint: "collapsible" },
661
+ { key: "Recomendaciones", label: "Recomendaciones IA", hint: "collapsible" }
662
+ ];
663
+ var CLIENTE_MODAL_WHITELIST = [
664
+ { key: "nombre del cliente", label: "Nombre del Cliente" },
665
+ { key: "dpi", label: "DPI" },
666
+ { key: "kpi", label: "Estado", hint: "kpi_badge" },
667
+ { key: "tel principal", label: "Tel\xE9fono", hint: "phone_link" },
668
+ { key: "capital concedido", label: "Capital Concedido" },
669
+ { key: "mora", label: "Monto en Mora", hint: "mora_alert" },
670
+ { key: "etapa", label: "Etapa del Cr\xE9dito" },
671
+ { key: "prestamo", label: "No. de Pr\xE9stamo" },
672
+ { key: "sucursal", label: "Sucursal", aliases: ["nombre sucursal"] }
673
+ ];
674
+ function applyModalWhitelist(rawData, whitelist) {
675
+ const keys = Object.keys(rawData ?? {});
676
+ return whitelist.map(({ key, label, hint, aliases = [] }) => {
677
+ const keysToTry = [key, ...aliases];
678
+ let value = void 0;
679
+ for (const k of keysToTry) {
680
+ const match = keys.find((rawKey) => rawKey.toLowerCase() === k.toLowerCase());
681
+ if (match !== void 0 && rawData[match] !== null && rawData[match] !== void 0) {
682
+ value = rawData[match];
683
+ break;
684
+ }
685
+ }
686
+ if (value === void 0) return null;
687
+ return { label, value, hint: hint ?? null };
688
+ }).filter((entry) => Boolean(entry));
689
+ }
690
+
691
+ // src/react/map/map-utils.ts
643
692
  var POPUP_STYLE_ID = "zenit-leaflet-popup-styles";
644
693
  var POPUP_EXCLUDED_KEYS = /* @__PURE__ */ new Set(["geom", "geometry", "_private"]);
645
694
  var POPUP_TITLE_KEYS = ["id", "nombre", "name", "title", "titulo", "cluster"];
@@ -876,6 +925,10 @@ function shouldIncludePopupEntry(key, value) {
876
925
  return true;
877
926
  }
878
927
  function createPopupContent(properties) {
928
+ const whitelistedRows = buildWhitelistedRows(properties);
929
+ if (whitelistedRows) {
930
+ return whitelistedRows;
931
+ }
879
932
  const header = findHeaderProperties(properties);
880
933
  const headerText = header.title?.value ?? extractPopupHeader(properties);
881
934
  const usedKeys = new Set([header.title?.key, header.badge?.key, header.description?.key].filter(Boolean));
@@ -915,6 +968,37 @@ function createPopupContent(properties) {
915
968
  }).join("");
916
969
  return `<div>${colorBar}${headerHtml}${descriptionHtml}${rowsHtml}</div>`;
917
970
  }
971
+ function buildWhitelistedRows(properties) {
972
+ const whitelist = selectModalWhitelist(properties);
973
+ if (!whitelist) return null;
974
+ const entries = applyModalWhitelist(properties, whitelist);
975
+ if (entries.length === 0) {
976
+ return '<div style="padding:8px 0; color:#64748b; text-align:center;">Sin datos disponibles</div>';
977
+ }
978
+ const rowsHtml = entries.map(({ label, value }) => {
979
+ const valueHtml = renderPopupValue(value);
980
+ return `
981
+ <div style="display:grid; grid-template-columns:minmax(90px, 35%) 1fr; gap:8px; padding:6px 0; border-bottom:1px solid #e2e8f0;">
982
+ <div style="font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.04em; color:#64748b;">${escapeHtml(label)}</div>
983
+ <div style="font-size:13px; color:#0f172a; word-break:break-word;">${valueHtml}</div>
984
+ </div>
985
+ `;
986
+ }).join("");
987
+ return `<div>${rowsHtml}</div>`;
988
+ }
989
+ function countWhitelistMatches(properties, whitelist) {
990
+ const keys = Object.keys(properties).map((key) => key.toLowerCase());
991
+ return whitelist.reduce((count, item) => {
992
+ const candidates = [item.key, ...item.aliases ?? []].map((candidate) => candidate.toLowerCase());
993
+ return candidates.some((candidate) => keys.includes(candidate)) ? count + 1 : count;
994
+ }, 0);
995
+ }
996
+ function selectModalWhitelist(properties) {
997
+ const sectorMatches = countWhitelistMatches(properties, SECTOR_MODAL_WHITELIST);
998
+ const clienteMatches = countWhitelistMatches(properties, CLIENTE_MODAL_WHITELIST);
999
+ if (sectorMatches === 0 && clienteMatches === 0) return null;
1000
+ return sectorMatches >= clienteMatches ? SECTOR_MODAL_WHITELIST : CLIENTE_MODAL_WHITELIST;
1001
+ }
918
1002
  function isPolygonType(layerType, geometryType) {
919
1003
  const candidate = (layerType ?? geometryType ?? "").toLowerCase();
920
1004
  return candidate === "polygon" || candidate === "multipolygon";
@@ -5129,4 +5213,4 @@ export {
5129
5213
  useSendMessageStream,
5130
5214
  FloatingChatBox
5131
5215
  };
5132
- //# sourceMappingURL=chunk-HCGYF65R.mjs.map
5216
+ //# sourceMappingURL=chunk-3M57OBM6.mjs.map