myio-js-library 0.1.579 → 0.1.581

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.
package/dist/index.cjs CHANGED
@@ -989,7 +989,7 @@ module.exports = __toCommonJS(src_exports);
989
989
  // package.json
990
990
  var package_default = {
991
991
  name: "myio-js-library",
992
- version: "0.1.579",
992
+ version: "0.1.581",
993
993
  description: "A clean, standalone JS SDK for MYIO projects",
994
994
  license: "MIT",
995
995
  repository: "github:gh-myio/myio-js-library",
@@ -21082,10 +21082,18 @@ function indicatorStateText(ind, short = false) {
21082
21082
  if (ind.kind === "valve") return ind.active ? short ? "Aberta" : "aberta" : short ? "Fechada" : "fechada";
21083
21083
  return ind.active ? short ? "Ligada" : "ligada" : short ? "Deslig." : "desligada";
21084
21084
  }
21085
+ var SHORT_TAG_MAX = 4;
21086
+ function indicatorTag(ind) {
21087
+ const label = String(ind?.label ?? "").trim();
21088
+ return label && label.length <= SHORT_TAG_MAX && !/\s/.test(label) ? label : String(ind?.code ?? "");
21089
+ }
21085
21090
  function indicatorTitle(ind) {
21086
21091
  const profile = ind.deviceProfile ? ` (${ind.deviceProfile})` : "";
21087
21092
  const since = ind.since ? ` desde ${formatClock(ind.since)}` : "";
21088
- return `${ind.code} \xB7 ${ind.label}${profile}: ${indicatorStateText(ind)}${ind.active === null || ind.active === void 0 ? "" : since}`;
21093
+ const tag = indicatorTag(ind);
21094
+ const name = String(ind.label ?? "").trim();
21095
+ const head = name && name !== tag ? `${tag} \xB7 ${name}` : tag;
21096
+ return `${head}${profile}: ${indicatorStateText(ind)}${ind.active === null || ind.active === void 0 ? "" : since}`;
21089
21097
  }
21090
21098
  function ensureEquipmentIndicatorStyles() {
21091
21099
  if (typeof document === "undefined" || document.getElementById(STYLE_ID4)) return;
@@ -21140,7 +21148,8 @@ function ensureEquipmentIndicatorStyles() {
21140
21148
  function renderEquipmentStripHTML(indicators) {
21141
21149
  return (indicators || []).map((ind) => {
21142
21150
  const cls = indicatorStateClass(ind);
21143
- const content = ind.kind === "valve" && ind.code.length <= 1 ? VALVE_SVG : escapeHtml2(ind.code);
21151
+ const tag = indicatorTag(ind);
21152
+ const content = ind.kind === "valve" && tag.length <= 1 ? VALVE_SVG : escapeHtml2(tag);
21144
21153
  return `<span class="myio-eq-b ${cls}" data-code="${escapeHtml2(ind.code)}" title="${escapeHtml2(indicatorTitle(ind))}">${content}</span>`;
21145
21154
  }).join("");
21146
21155
  }
@@ -21165,12 +21174,12 @@ function renderEquipmentTilesHTML(indicators) {
21165
21174
  if (!indicators?.length) return "";
21166
21175
  return `<div class="myio-eq-tiles">${indicators.map((ind) => {
21167
21176
  const cls = indicatorStateClass(ind);
21168
- return `<div class="myio-eq-ti ${cls}" title="${escapeHtml2(indicatorTitle(ind))}"><i></i><b>${escapeHtml2(ind.code)}</b><small>${indicatorStateText(ind, true)}</small></div>`;
21177
+ return `<div class="myio-eq-ti ${cls}" title="${escapeHtml2(indicatorTitle(ind))}"><i></i><b>${escapeHtml2(indicatorTag(ind))}</b><small>${indicatorStateText(ind, true)}</small></div>`;
21169
21178
  }).join("")}</div>`;
21170
21179
  }
21171
21180
  function renderEquipmentShortcutHTML(indicators, label = "Bombas") {
21172
21181
  const anyOn = (indicators || []).some((i) => i.kind === "pump" && i.active === true);
21173
- return `<span class="${anyOn ? "myio-eq-spin" : ""}" style="display:inline-flex">${PUMP_SVG}</span><span>${escapeHtml2(label)}</span>` + (indicators || []).map((ind) => `<i class="${indicatorStateClass(ind)}">${escapeHtml2(ind.code)}</i>`).join("");
21182
+ return `<span class="${anyOn ? "myio-eq-spin" : ""}" style="display:inline-flex">${PUMP_SVG}</span><span>${escapeHtml2(label)}</span>` + (indicators || []).map((ind) => `<i class="${indicatorStateClass(ind)}">${escapeHtml2(indicatorTag(ind))}</i>`).join("");
21174
21183
  }
21175
21184
 
21176
21185
  // src/components/financial-goals/moneyFormat.ts
@@ -33874,12 +33883,26 @@ var DEFAULT_GRANULARITY_OPTIONS = [
33874
33883
  { value: "1h", title: "Hora" },
33875
33884
  { value: "1d", title: "Dia" }
33876
33885
  ];
33886
+ var TEMPERATURE_GRANULARITY_OPTIONS = [
33887
+ { value: "15m", title: "15 minutos" },
33888
+ { value: "30m", title: "30 minutos" },
33889
+ { value: "1h", title: "Hora" },
33890
+ { value: "1d", title: "Dia" }
33891
+ ];
33892
+ function granularityMinutes(g) {
33893
+ return g === "15m" ? 15 : g === "30m" ? 30 : g === "1h" ? 60 : 1440;
33894
+ }
33877
33895
 
33878
33896
  // src/components/granularity-selector/createGranularitySelector.ts
33879
33897
  var P = GRANULARITY_SELECTOR_CSS_PREFIX;
33880
- var DEFAULT_TITLES = { "1h": "Hora", "1d": "Dia" };
33898
+ var DEFAULT_TITLES = {
33899
+ "15m": "15 minutos",
33900
+ "30m": "30 minutos",
33901
+ "1h": "Hora",
33902
+ "1d": "Dia"
33903
+ };
33881
33904
  function isGranularity(v) {
33882
- return v === "1h" || v === "1d";
33905
+ return v === "15m" || v === "30m" || v === "1h" || v === "1d";
33883
33906
  }
33884
33907
  function createGranularitySelector(container, params = {}) {
33885
33908
  injectGranularitySelectorStyles();
@@ -35215,7 +35238,10 @@ var EnergyModalView = class {
35215
35238
  value: this.currentGranularity,
35216
35239
  themeMode: this.currentTheme
35217
35240
  },
35218
- onChange: (granularity) => this.setGranularity(granularity)
35241
+ // Opções default (1h | 1d) — 15m/30m só existem nos relatórios de temperatura
35242
+ onChange: (granularity) => {
35243
+ if (granularity === "1h" || granularity === "1d") this.setGranularity(granularity);
35244
+ }
35219
35245
  });
35220
35246
  dbg2("[EnergyModalView] [RFC-0097] Granularity selector initialized with:", this.currentGranularity);
35221
35247
  }
@@ -37527,7 +37553,7 @@ var DeviceReportModal = class {
37527
37553
  const domain = params.domain || "energy";
37528
37554
  this.domainConfig = DOMAIN_CONFIG[domain];
37529
37555
  this.granularity = params.granularity === "1h" ? "1h" : "1d";
37530
- this.energyFetcher = params.fetcher || createDefaultEnergyFetcher(params, () => this.granularity);
37556
+ this.energyFetcher = params.fetcher || createDefaultEnergyFetcher(params, () => this.apiGranularity);
37531
37557
  }
37532
37558
  modal;
37533
37559
  authClient;
@@ -37538,6 +37564,8 @@ var DeviceReportModal = class {
37538
37564
  dateRangePicker = null;
37539
37565
  sortState = { key: null, direction: "asc" };
37540
37566
  domainConfig;
37567
+ // Temperatura: 15m | 30m | 1h | 1d (15/30 min agregados no cliente a partir dos blocos de
37568
+ // 15 min que o Ingestion devolve com granularity=1h). Demais domínios: 1h | 1d.
37541
37569
  granularity = "1d";
37542
37570
  // Granularity selector (shared component — same pill 1h|1d as EnergyModal/AllReportModal).
37543
37571
  granularitySelector = null;
@@ -37549,6 +37577,25 @@ var DeviceReportModal = class {
37549
37577
  participationChart = null;
37550
37578
  // Período do último load — alimenta os headers dos exports PDF/XLS.
37551
37579
  exportPeriod = null;
37580
+ /** Linhas intradiárias (15 min, 30 min ou hora) — tudo que não é '1d' */
37581
+ get isIntraday() {
37582
+ return this.granularity !== "1d";
37583
+ }
37584
+ /** O Ingestion só aceita 1h|1d: 15/30 min buscam 1h (blocos de 15 min) e agregam aqui */
37585
+ get apiGranularity() {
37586
+ return this.isIntraday ? "1h" : "1d";
37587
+ }
37588
+ /** Rótulo da linha intradiária: "Hora" (1h) ou "Horário" (15/30 min) */
37589
+ get intradayLabel() {
37590
+ return this.granularity === "1h" ? "Hora" : "Hor\xE1rio";
37591
+ }
37592
+ /** Rótulo legível da granularidade (CSV/avisos) */
37593
+ get granularityText() {
37594
+ return { "15m": "15 minutos", "30m": "30 minutos", "1h": "Hora", "1d": "Dia" }[this.granularity];
37595
+ }
37596
+ get isTemperatureDomain() {
37597
+ return (this.params.domain || "energy") === "temperature";
37598
+ }
37552
37599
  // Header: "Relatório - <identifier> - <label>" + nome do device (sutil, com copiar).
37553
37600
  // O customer já aparece no footer premium. Texto escapado — o shell usa innerHTML no título.
37554
37601
  buildHeaderTitleHTML() {
@@ -37771,13 +37818,16 @@ var DeviceReportModal = class {
37771
37818
  // sem label interno (o form group acima já tem "Granularidade").
37772
37819
  label: "",
37773
37820
  themeMode: this.params.ui?.theme === "dark" ? "dark" : "light",
37821
+ // Temperatura: 15m | 30m | 1h | 1d; demais domínios: 1h | 1d (default do componente)
37822
+ ...this.isTemperatureDomain ? { options: TEMPERATURE_GRANULARITY_OPTIONS } : {},
37774
37823
  tooltip: {
37775
37824
  enabled: true,
37776
37825
  title: "Granularidade",
37777
- text: "Em <b>Dia</b>, a tabela traz uma linha por dia; em <b>Hora</b>, uma linha por hora e o seletor de per\xEDodo ganha hora/minuto. KPIs e gr\xE1fico recalculam conforme a granularidade."
37826
+ text: this.isTemperatureDomain ? "Em <b>Dia</b>, uma linha por dia (m\xE9dia do dia); em <b>15m</b>, <b>30m</b> e <b>1h</b>, uma linha por janela (m\xE9dia da janela) e o seletor de per\xEDodo ganha hora/minuto. KPIs e gr\xE1fico recalculam conforme a granularidade." : "Em <b>Dia</b>, a tabela traz uma linha por dia; em <b>Hora</b>, uma linha por hora e o seletor de per\xEDodo ganha hora/minuto. KPIs e gr\xE1fico recalculam conforme a granularidade."
37778
37827
  }
37779
37828
  },
37780
37829
  onChange: async (value) => {
37830
+ if (!this.isTemperatureDomain && value !== "1h" && value !== "1d") return;
37781
37831
  this.granularity = value;
37782
37832
  await this.rebuildDateRangePicker(dateRangeInput);
37783
37833
  this.resetAfterGranularityChange();
@@ -37796,7 +37846,7 @@ var DeviceReportModal = class {
37796
37846
  if (tableContainer) {
37797
37847
  tableContainer.innerHTML = `
37798
37848
  <div style="text-align: center; padding: 40px; color: var(--myio-text-muted);">
37799
- Granularidade alterada para <strong>${this.granularity}</strong>. Clique em "Carregar" para atualizar os dados.
37849
+ Granularidade alterada para <strong>${this.granularityText}</strong>. Clique em "Carregar" para atualizar os dados.
37800
37850
  </div>
37801
37851
  `;
37802
37852
  }
@@ -37840,7 +37890,7 @@ var DeviceReportModal = class {
37840
37890
  presetEnd,
37841
37891
  // Ciclo de rateio (dia D → dia D do mês seguinte) tem até 32 dias corridos (ex.: 15/08→15/09)
37842
37892
  maxRangeDays: 32,
37843
- includeTime: this.granularity === "1h",
37893
+ includeTime: this.isIntraday,
37844
37894
  timePrecision: "minute",
37845
37895
  parentEl: this.modal.element,
37846
37896
  onApply: ({ startISO, endISO }) => {
@@ -37859,7 +37909,7 @@ var DeviceReportModal = class {
37859
37909
  // Contrato do getDates(): hora LOCAL + offset (YYYY-MM-DDTHH:mm:ss±HH:MM) — os 10
37860
37910
  // primeiros caracteres são o dia exibido e os 6 últimos, o offset.
37861
37911
  resolveQueryWindow(range) {
37862
- if (this.granularity === "1h" || !range.startISO || !range.endISO) return range;
37912
+ if (this.isIntraday || !range.startISO || !range.endISO) return range;
37863
37913
  const day = (iso) => iso.slice(0, 10);
37864
37914
  const offset = (iso) => iso.slice(-6);
37865
37915
  return {
@@ -37899,7 +37949,8 @@ var DeviceReportModal = class {
37899
37949
  ingestionId: this.params.ingestionId,
37900
37950
  startISO,
37901
37951
  endISO,
37902
- granularity: this.granularity
37952
+ // API só conhece 1h|1d — 15/30 min vêm do 1h e são agregados em processApiResponse
37953
+ granularity: this.apiGranularity
37903
37954
  });
37904
37955
  this.data = this.processApiResponse(apiResponse, dateRange);
37905
37956
  this.renderSummary();
@@ -37925,7 +37976,7 @@ var DeviceReportModal = class {
37925
37976
  }
37926
37977
  processApiResponse(apiResponse, dateRange) {
37927
37978
  const dataArray = Array.isArray(apiResponse) ? apiResponse : apiResponse.data || [];
37928
- const isHourly = this.granularity === "1h";
37979
+ const isHourly = this.isIntraday;
37929
37980
  if (!Array.isArray(dataArray) || dataArray.length === 0) {
37930
37981
  console.warn("[DeviceReportModal] API returned empty or invalid response, zero-filling date range");
37931
37982
  if (isHourly) return [];
@@ -37950,7 +38001,7 @@ var DeviceReportModal = class {
37950
38001
  }
37951
38002
  if (isHourly) {
37952
38003
  const isAvg = this.domainConfig.summaryType === "average";
37953
- const HOUR = 3600 * 1e3;
38004
+ const HOUR = granularityMinutes(this.granularity) * 60 * 1e3;
37954
38005
  const byHour = /* @__PURE__ */ new Map();
37955
38006
  consumption.forEach((item) => {
37956
38007
  if (!item.timestamp || item.value == null) return;
@@ -38020,7 +38071,7 @@ var DeviceReportModal = class {
38020
38071
  computeKpis() {
38021
38072
  const fmt2 = this.domainConfig.formatter;
38022
38073
  const unit = this.domainConfig.unit;
38023
- const isHourly = this.granularity === "1h";
38074
+ const isHourly = this.isIntraday;
38024
38075
  const isTemperature = this.domainConfig.summaryType === "average";
38025
38076
  const total = this.calculateTotal();
38026
38077
  const rows = this.validRows;
@@ -38037,7 +38088,7 @@ var DeviceReportModal = class {
38037
38088
  null
38038
38089
  );
38039
38090
  const zeroCount = this.data.filter((r) => r.consumption <= 0).length;
38040
- const rowLabel = isHourly ? "Hora" : "Dia";
38091
+ const rowLabel = isHourly ? this.intradayLabel : "Dia";
38041
38092
  let perDay;
38042
38093
  if (isTemperature) {
38043
38094
  const byDay = /* @__PURE__ */ new Map();
@@ -38076,7 +38127,7 @@ var DeviceReportModal = class {
38076
38127
  kpis.push({ value: String(zeroCount), label: isHourly ? "Horas sem Consumo" : "Dias sem Consumo" });
38077
38128
  } else {
38078
38129
  const noData = this.data.length - rows.length;
38079
- if (noData > 0) kpis.push({ value: String(noData), label: isHourly ? "Horas sem Leitura" : "Dias sem Leitura" });
38130
+ if (noData > 0) kpis.push({ value: String(noData), label: isHourly ? `${this.intradayLabel}s sem Leitura` : "Dias sem Leitura" });
38080
38131
  }
38081
38132
  return kpis;
38082
38133
  }
@@ -38098,7 +38149,7 @@ var DeviceReportModal = class {
38098
38149
  // Temperatura (painel direito): ranking em barras — 1d = dias mais quentes (média do dia);
38099
38150
  // 1h = horas mais quentes (top 24). Escala comum + faixa ideal sombreada (padrão AllReport).
38100
38151
  renderTemperatureRanking(container) {
38101
- const isHourly = this.granularity === "1h";
38152
+ const isHourly = this.isIntraday;
38102
38153
  const valid = this.validRows;
38103
38154
  if (!valid.length) {
38104
38155
  container.innerHTML = `<div style="border:1px dashed var(--myio-border,#e5e7eb);border-radius:10px;padding:32px 16px;text-align:center;font-size:13px;color:var(--myio-text-muted,#6b7280);">Sem leituras no per\xEDodo</div>`;
@@ -38125,7 +38176,7 @@ var DeviceReportModal = class {
38125
38176
  <span style="text-align:right;font-variant-numeric:tabular-nums;font-weight:600;">${r ? this.domainConfig.formatter(r.consumption) : "\u2014"}</span>
38126
38177
  </div>`;
38127
38178
  const unit = this.domainConfig.unit;
38128
- const title = isHourly ? `${this.domainConfig.rankingHourTitle}${ranked.length > TOP_HOURS ? ` (top ${TOP_HOURS})` : ""}` : this.domainConfig.rankingDayTitle;
38179
+ const title = isHourly ? `${this.intradayRankingTitle()}${ranked.length > TOP_HOURS ? ` (top ${TOP_HOURS})` : ""}` : this.domainConfig.rankingDayTitle;
38129
38180
  container.innerHTML = `
38130
38181
  <div style="border:1px solid var(--myio-border,#e5e7eb);border-radius:10px;padding:12px 14px;max-height:620px;overflow-y:auto;">
38131
38182
  <div style="font-weight:700;font-size:14px;margin-bottom:2px;">${title}</div>
@@ -38136,6 +38187,12 @@ var DeviceReportModal = class {
38136
38187
  ${noData.map((r) => line(this.formatDate(r.date), null)).join("")}
38137
38188
  </div>`;
38138
38189
  }
38190
+ // "Horas mais quentes" (1h) / "Horários mais quentes (15 min)" (15/30 min)
38191
+ intradayRankingTitle() {
38192
+ const base = this.domainConfig.rankingHourTitle || "";
38193
+ if (this.granularity === "1h") return base;
38194
+ return `${base.replace(/^Horas/, "Hor\xE1rios")} (${this.granularityText})`;
38195
+ }
38139
38196
  updateDayChart() {
38140
38197
  const container = document.getElementById("participation-chart-container");
38141
38198
  if (!container) return;
@@ -38189,7 +38246,7 @@ var DeviceReportModal = class {
38189
38246
  <thead style="position: sticky; top: 0; background: var(--myio-bg); z-index: 1;">
38190
38247
  <tr>
38191
38248
  <th style="cursor: pointer;" data-sort="date">
38192
- ${this.granularity === "1h" ? "Data/Hora" : "Data"}
38249
+ ${this.isIntraday ? "Data/Hora" : "Data"}
38193
38250
  <span style="margin-left: 4px; opacity: ${this.sortState.key === "date" ? "1" : "0.5"};">${getSortIndicator("date")}</span>
38194
38251
  </th>
38195
38252
  <th style="cursor: pointer; text-align: right;" data-sort="consumption">
@@ -38272,16 +38329,16 @@ var DeviceReportModal = class {
38272
38329
  ...isTemp && off !== 0 ? [["Offset aplicado (\xB0C)", this.domainConfig.formatter(off), ""]] : [],
38273
38330
  ...this.resolveCustomerName() ? [["Cliente", this.resolveCustomerName(), ""]] : [],
38274
38331
  ...p?.startISO ? [["Per\xEDodo", `${fmtD(p.startISO)} \u2014 ${fmtD(p.endISO)}`, ""]] : [],
38275
- ["Granularidade", this.granularity === "1h" ? "Hora" : "Dia", ""],
38332
+ ["Granularidade", this.granularityText, ""],
38276
38333
  ["DATA EMISS\xC3O", timestamp, ""],
38277
38334
  [],
38278
38335
  ...this.computeKpis().map((k) => [k.label, k.value, k.sub || ""]),
38279
38336
  [],
38280
- [this.granularity === "1h" ? "Data/Hora" : "Data", this.domainConfig.label, ""],
38337
+ [this.isIntraday ? "Data/Hora" : "Data", this.domainConfig.label, ""],
38281
38338
  ...this.data.map((row) => [this.formatDate(row.date), row.noData ? "Sem leitura" : this.domainConfig.formatter(row.consumption)])
38282
38339
  ];
38283
38340
  const csvContent = toCsv(csvData);
38284
- const granSuffix = this.granularity === "1h" ? "-1h" : "";
38341
+ const granSuffix = this.isIntraday ? `-${this.granularity}` : "";
38285
38342
  this.downloadCSV(csvContent, `relatorio-${this.params.identifier || "dispositivo"}${granSuffix}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`);
38286
38343
  }
38287
38344
  // Accent hex da paleta do dashboard (params.theme) para os exports — cai no
@@ -38322,18 +38379,18 @@ var DeviceReportModal = class {
38322
38379
  exportColumnOptions() {
38323
38380
  const isTemp = this.domainConfig.summaryType === "average";
38324
38381
  return {
38325
- nameLabel: this.granularity === "1h" ? "Data/Hora" : "Data",
38382
+ nameLabel: this.isIntraday ? "Data/Hora" : "Data",
38326
38383
  hideIdentifier: true,
38327
38384
  // Mesmo rótulo da coluna da tela (antes saía "Consumo (°C)" em temperatura)
38328
38385
  valueLabel: this.domainConfig.label,
38329
- countLabel: this.granularity === "1h" ? "hora(s)" : "dia(s)",
38386
+ countLabel: this.isIntraday ? this.granularity === "1h" ? "hora(s)" : "hor\xE1rio(s)" : "dia(s)",
38330
38387
  ...isTemp ? { hidePerc: true, emptyValueText: "Sem leitura", valueDecimals: 2 } : {}
38331
38388
  };
38332
38389
  }
38333
38390
  // Gráfico da página final do PDF = painel da direita da tela
38334
38391
  async buildExportChart() {
38335
38392
  if (this.domainConfig.summaryType === "average") {
38336
- const isHourly = this.granularity === "1h";
38393
+ const isHourly = this.isIntraday;
38337
38394
  const ranked = [...this.validRows].sort((a, b) => b.consumption - a.consumption);
38338
38395
  const shown = isHourly ? ranked.slice(0, 24) : ranked;
38339
38396
  const noData = isHourly ? [] : this.data.filter((r) => r.noData);
@@ -38346,7 +38403,7 @@ var DeviceReportModal = class {
38346
38403
  accent: this.resolveAccentHex(),
38347
38404
  unit: this.domainConfig.unit
38348
38405
  });
38349
- const title = isHourly ? `${this.domainConfig.rankingHourTitle}${ranked.length > 24 ? " (top 24)" : ""}` : this.domainConfig.rankingDayTitle;
38406
+ const title = isHourly ? `${this.intradayRankingTitle()}${ranked.length > 24 ? " (top 24)" : ""}` : this.domainConfig.rankingDayTitle;
38350
38407
  return png ? { ...png, title } : null;
38351
38408
  }
38352
38409
  const chartPng = await this.participationChart?.toPngDataUrl?.().catch(() => null);
@@ -40179,7 +40236,8 @@ var AllReportModal = class {
40179
40236
  debugEnabled;
40180
40237
  // Domain configuration
40181
40238
  domainConfig;
40182
- // Granularity: '1d' (daily) | '1h' (hourly)
40239
+ // Granularity: '1d' (daily) | '1h' (hourly). Temperatura também '15m' | '30m' — agregados
40240
+ // aqui a partir dos blocos de 15 min que o Ingestion devolve com granularity=1h.
40183
40241
  granularity = "1d";
40184
40242
  // Temperatura: estatísticas por sensor (key = ingestionId) da última carga
40185
40243
  temperatureStats = /* @__PURE__ */ new Map();
@@ -40590,13 +40648,16 @@ var AllReportModal = class {
40590
40648
  // Padrão FIEL ao EnergyModal: pill "1h | 1d" (opções default do componente),
40591
40649
  // sem label interno (o form group acima já tem "Granularidade").
40592
40650
  label: "",
40651
+ // Temperatura: 15m | 30m | 1h | 1d; demais domínios: 1h | 1d (default do componente)
40652
+ ...this.isTemperature ? { options: TEMPERATURE_GRANULARITY_OPTIONS } : {},
40593
40653
  tooltip: {
40594
40654
  enabled: true,
40595
40655
  title: "Granularidade",
40596
- text: this.isTemperature ? "A tabela mostra a <b>m\xE9dia do per\xEDodo</b> de cada sensor. Clique em \u25B8 no sensor para ver a s\xE9rie <b>por hora</b> ou <b>por dia</b>; o CSV segue a mesma granularidade." : "A tabela mostra os <b>totais do per\xEDodo</b>. Clique em \u25B8 no dispositivo para ver a s\xE9rie <b>por hora</b> ou <b>por dia</b>; em Hora, o CSV traz uma linha por dispositivo \xD7 hora."
40656
+ text: this.isTemperature ? "A tabela mostra a <b>m\xE9dia do per\xEDodo</b> de cada sensor. Clique em \u25B8 no sensor para ver a s\xE9rie <b>por 15 min</b>, <b>30 min</b>, <b>hora</b> ou <b>dia</b> (m\xE9dia da janela); o CSV segue a mesma granularidade." : "A tabela mostra os <b>totais do per\xEDodo</b>. Clique em \u25B8 no dispositivo para ver a s\xE9rie <b>por hora</b> ou <b>por dia</b>; em Hora, o CSV traz uma linha por dispositivo \xD7 hora."
40597
40657
  }
40598
40658
  },
40599
40659
  onChange: (value) => {
40660
+ if (!this.isTemperature && value !== "1h" && value !== "1d") return;
40600
40661
  this.granularity = value;
40601
40662
  this.hourlySeriesCache = null;
40602
40663
  if (this.data.length && this.expandedIds.size) this.renderTable();
@@ -40969,7 +41030,7 @@ var AllReportModal = class {
40969
41030
  renderRowHTML(row, grandTotal, showId) {
40970
41031
  const expandable = !!row.id;
40971
41032
  const expanded = expandable && this.expandedIds.has(row.id);
40972
- const expandBtn = expandable ? `<button type="button" class="rp-expand" data-expand-id="${row.id}" aria-expanded="${expanded}" title="Ver s\xE9rie por ${this.granularity === "1h" ? "hora" : "dia"}">\u25B8</button>` : "";
41033
+ const expandBtn = expandable ? `<button type="button" class="rp-expand" data-expand-id="${row.id}" aria-expanded="${expanded}" title="Ver s\xE9rie por ${this.granularityNoun(this.granularity)}">\u25B8</button>` : "";
40973
41034
  const idTd = showId ? `<td data-label="Identificador" style="font-family: monospace; font-weight: bold; text-transform: uppercase;">${row.identifier}</td>` : "";
40974
41035
  const off = this.isTemperature && row.id && !row.noData ? this.temperatureOffsetFor(row.id) : 0;
40975
41036
  const offsetTag = off ? ` <span class="rp-offset" title="Offset do sensor aplicado \xE0s leituras">offset ${off > 0 ? "+" : "\u2212"}${fmtPt(Math.abs(off))} \xB0C</span>` : "";
@@ -41059,14 +41120,15 @@ var AllReportModal = class {
41059
41120
  async fillSeries(id, box) {
41060
41121
  const row = this.data.find((r) => r.id === id);
41061
41122
  const gran = this.granularity;
41123
+ const intraday = gran !== "1d";
41062
41124
  try {
41063
41125
  const points = await this.getDeviceSeries(id, gran);
41064
41126
  if (!box.isConnected) return;
41065
41127
  if (!points.length) {
41066
- box.innerHTML = `<span class="rp-muted">Sem dados ${gran === "1h" ? "hor\xE1rios" : "di\xE1rios"} no per\xEDodo.</span>`;
41128
+ box.innerHTML = `<span class="rp-muted">Sem dados ${intraday ? "hor\xE1rios" : "di\xE1rios"} no per\xEDodo.</span>`;
41067
41129
  return;
41068
41130
  }
41069
- const fmtTs = (ts) => gran === "1h" ? new Date(ts).toLocaleString("pt-BR", {
41131
+ const fmtTs = (ts) => intraday ? new Date(ts).toLocaleString("pt-BR", {
41070
41132
  day: "2-digit",
41071
41133
  month: "2-digit",
41072
41134
  year: "numeric",
@@ -41074,15 +41136,16 @@ var AllReportModal = class {
41074
41136
  minute: "2-digit",
41075
41137
  timeZone: "America/Sao_Paulo"
41076
41138
  }) : new Date(ts).toLocaleDateString("pt-BR", { timeZone: "America/Sao_Paulo" });
41077
- const valueLabel = this.isTemperature ? gran === "1h" ? "Temperatura (\xB0C)" : "M\xE9dia do dia (\xB0C)" : this.domainConfig.label;
41078
- if (this.bucketMoney(id, points[0].timestamp, gran, points[0].value)) {
41079
- const money = points.map((p) => this.bucketMoney(id, p.timestamp, gran, p.value));
41139
+ const valueLabel = this.isTemperature ? intraday ? "Temperatura (\xB0C)" : "M\xE9dia do dia (\xB0C)" : this.domainConfig.label;
41140
+ const moneyGran = intraday ? "1h" : "1d";
41141
+ if (this.bucketMoney(id, points[0].timestamp, moneyGran, points[0].value)) {
41142
+ const money = points.map((p) => this.bucketMoney(id, p.timestamp, moneyGran, p.value));
41080
41143
  const cell = (m) => m && m.state === "complete" && m.amount ? formatBRL(m.amount) : `<span class="rp-muted" title="Sem custo estimado para este intervalo">\u2014</span>`;
41081
41144
  const sub = sumItemMoney(money);
41082
41145
  const subCell = sub.state === "complete" && sub.amount ? formatBRL(sub.amount) : `<span class="rp-muted">Cobertura incompleta (${sub.covered} de ${sub.total})</span>`;
41083
41146
  box.innerHTML = `
41084
41147
  <table>
41085
- <thead><tr><th>${gran === "1h" ? "Data/Hora" : "Dia"}</th><th class="num">${valueLabel}</th><th class="num">${this.moneyHeaderLabel()}</th></tr></thead>
41148
+ <thead><tr><th>${intraday ? "Data/Hora" : "Dia"}</th><th class="num">${valueLabel}</th><th class="num">${this.moneyHeaderLabel()}</th></tr></thead>
41086
41149
  <tbody>${points.map((p, i) => `<tr><td>${fmtTs(p.timestamp)}</td><td class="num">${fmtPt(p.value)}</td><td class="num" data-money-cell="1">${cell(money[i])}</td></tr>`).join("")}</tbody>
41087
41150
  <tfoot><tr><td><strong>Subtotal</strong></td><td class="num"><strong>${fmtPt(points.reduce((s, p) => s + p.value, 0))}</strong></td><td class="num" data-money-subtotal="1"><strong>${subCell}</strong></td></tr></tfoot>
41088
41151
  </table>`;
@@ -41090,7 +41153,7 @@ var AllReportModal = class {
41090
41153
  }
41091
41154
  box.innerHTML = `
41092
41155
  <table>
41093
- <thead><tr><th>${gran === "1h" ? "Data/Hora" : "Dia"}</th><th class="num">${valueLabel}</th></tr></thead>
41156
+ <thead><tr><th>${intraday ? "Data/Hora" : "Dia"}</th><th class="num">${valueLabel}</th></tr></thead>
41094
41157
  <tbody>${points.map((p) => `<tr><td>${fmtTs(p.timestamp)}</td><td class="num">${fmtPt(p.value)}</td></tr>`).join("")}</tbody>
41095
41158
  </table>`;
41096
41159
  } catch (err) {
@@ -41105,8 +41168,9 @@ var AllReportModal = class {
41105
41168
  async getDeviceSeries(id, gran) {
41106
41169
  if (this.isTemperature) {
41107
41170
  const raw = this.temperatureStats.get(id)?.series || [];
41108
- return gran === "1h" ? this.aggregateHourly(raw, "avg") : this.aggregateDaily(raw, "avg");
41171
+ return gran === "1d" ? this.aggregateDaily(raw, "avg") : this.aggregateHourly(raw, "avg", granularityMinutes(gran));
41109
41172
  }
41173
+ if (gran !== "1h" && gran !== "1d") gran = "1h";
41110
41174
  const key = `${gran}|${id}`;
41111
41175
  const cached = this.deviceSeriesCache.get(key);
41112
41176
  if (cached) return cached;
@@ -41130,10 +41194,10 @@ var AllReportModal = class {
41130
41194
  const ent = Array.isArray(body) ? body[0] : body;
41131
41195
  return (ent?.consumption || []).map((p) => ({ timestamp: new Date(p?.timestamp).getTime(), value: Number(p?.value) })).filter((p) => Number.isFinite(p.timestamp) && Number.isFinite(p.value)).sort((a, b) => a.timestamp - b.timestamp);
41132
41196
  }
41133
- // Consolida em HORA FECHADA (início da hora): média (temperatura) ou soma (consumo).
41134
- // Fusos inteiros → a hora UTC coincide com a hora de São Paulo.
41135
- aggregateHourly(points, mode) {
41136
- const HOUR = 3600 * 1e3;
41197
+ // Consolida em JANELA FECHADA de `minutes` (padrão 60 = hora; 15/30 em temperatura):
41198
+ // média (temperatura) ou soma (consumo). Fusos inteiros → alinha também em São Paulo.
41199
+ aggregateHourly(points, mode, minutes = 60) {
41200
+ const HOUR = minutes * 60 * 1e3;
41137
41201
  const byHour = /* @__PURE__ */ new Map();
41138
41202
  for (const p of points) {
41139
41203
  const h3 = Math.floor(p.timestamp / HOUR) * HOUR;
@@ -41144,6 +41208,10 @@ var AllReportModal = class {
41144
41208
  }
41145
41209
  return [...byHour.entries()].sort((a, b) => a[0] - b[0]).map(([h3, { sum: sum2, n }]) => ({ timestamp: h3, value: mode === "avg" ? sum2 / n : sum2 }));
41146
41210
  }
41211
+ // "hora" | "15 minutos" | "30 minutos" | "dia" — textos de ▸ e CSV
41212
+ granularityNoun(g) {
41213
+ return { "15m": "15 minutos", "30m": "30 minutos", "1h": "hora", "1d": "dia" }[g];
41214
+ }
41147
41215
  // Agrega série horária por dia civil (São Paulo): média (temperatura) ou soma (consumo)
41148
41216
  aggregateDaily(points, mode) {
41149
41217
  const byDay = /* @__PURE__ */ new Map();
@@ -41419,7 +41487,7 @@ var AllReportModal = class {
41419
41487
  ["Relat\xF3rio", this.resolveTitle()],
41420
41488
  ...this.params.customerName ? [["Cliente", this.params.customerName]] : [],
41421
41489
  ...p?.startISO ? [["Per\xEDodo", `${fmtD(p.startISO)} \u2014 ${fmtD(p.endISO)}`]] : [],
41422
- ["Granularidade", gran === "1h" ? "Hora" : "Dia"],
41490
+ ["Granularidade", { "15m": "15 minutos", "30m": "30 minutos", "1h": "Hora", "1d": "Dia" }[gran]],
41423
41491
  ["Gerado em", (/* @__PURE__ */ new Date()).toLocaleString("pt-BR")],
41424
41492
  [],
41425
41493
  ...this.computeKpis().map((k) => [k.label, k.value, k.sub || ""]),
@@ -41440,8 +41508,8 @@ var AllReportModal = class {
41440
41508
  String(r.discarded ?? "")
41441
41509
  ])
41442
41510
  ];
41443
- const series = [[...idHead, "Sensor", gran === "1h" ? "Data/Hora" : "Dia", "Temperatura (\xB0C)"]];
41444
- const fmtTs = (ts) => gran === "1h" ? new Date(ts).toLocaleString("pt-BR", {
41511
+ const series = [[...idHead, "Sensor", gran !== "1d" ? "Data/Hora" : "Dia", "Temperatura (\xB0C)"]];
41512
+ const fmtTs = (ts) => gran !== "1d" ? new Date(ts).toLocaleString("pt-BR", {
41445
41513
  day: "2-digit",
41446
41514
  month: "2-digit",
41447
41515
  year: "numeric",
@@ -41451,7 +41519,7 @@ var AllReportModal = class {
41451
41519
  }) : new Date(ts).toLocaleDateString("pt-BR", { timeZone: "America/Sao_Paulo" });
41452
41520
  for (const r of rows) {
41453
41521
  const raw = r.id && this.temperatureStats.get(r.id)?.series || [];
41454
- const pts = gran === "1h" ? this.aggregateHourly(raw, "avg") : this.aggregateDaily(raw, "avg");
41522
+ const pts = gran === "1d" ? this.aggregateDaily(raw, "avg") : this.aggregateHourly(raw, "avg", granularityMinutes(gran));
41455
41523
  for (const p2 of pts) series.push([...idCol(r), r.name, fmtTs(p2.timestamp), n2(p2.value)]);
41456
41524
  }
41457
41525
  const csvContent = toCsv([...meta, ...summary, [], ...series]);
@@ -63967,11 +64035,13 @@ var WellEquipmentTab = class {
63967
64035
  <label for="wet-b2-device">Bomba B2</label>${options("pump", "B2", binding(this.bindings.pumps, "B2"))}${labelInput("B2", binding(this.bindings.pumps, "B2"))}
63968
64036
  <label for="wet-s-device">Solenoide S</label>${options("valve", "S", binding(this.bindings.valves, "S"))}${labelInput("S", binding(this.bindings.valves, "S"))}
63969
64037
  </div>
64038
+ <p class="wet-hint">R\xF3tulos com at\xE9 4 caracteres (ex.: B3) aparecem no card no lugar de B1/B2/S.</p>
63970
64039
  <p id="wet-message" class="wet-message" role="status" aria-live="polite"></p>
63971
64040
  <button type="button" id="wet-save" ${this.loaded ? "" : "disabled"}>Salvar v\xEDnculos</button>
63972
64041
  </section>
63973
64042
  <style>
63974
64043
  .wet-tab{padding:24px;color:#374151}.wet-grid{display:grid;grid-template-columns:130px minmax(180px,1fr) minmax(180px,1fr);gap:12px;align-items:center}
64044
+ .wet-hint{margin:12px 0 0;font-size:12px;color:#6b7280}
63975
64045
  .wet-grid label{font-weight:600}.wet-grid select,.wet-grid input{box-sizing:border-box;width:100%;min-height:38px;padding:7px 9px;border:1px solid #d1d5db;border-radius:6px;background:white}
63976
64046
  #wet-save{margin-top:18px;padding:9px 16px;border:0;border-radius:6px;background:#2563eb;color:white;font-weight:600;cursor:pointer}
63977
64047
  #wet-save:disabled{opacity:.6;cursor:wait}.wet-message{min-height:20px;margin:12px 0 0}.wet-message.wet-error,.wet-error{color:#b91c1c}.wet-message.wet-success{color:#15803d}.wet-state{text-align:center;padding:30px;color:#6b7280}
@@ -64073,7 +64143,8 @@ var WellEquipmentTab = class {
64073
64143
  // src/components/premium-modals/settings/retrolavagem/RetrolavagemTab.ts
64074
64144
  var RETROLAVAGEM_PROFILE = "HIDROMETRO_ENTRADA_RETROLAVAGEM";
64075
64145
  var RETROLAVAGEM_BINDINGS_KEY = "retrolavagemBindings";
64076
- var MAX_RETROLAVAGEM_DEVICES_PER_SIDE = 10;
64146
+ var MAX_RETROLAVAGEM_DEVICES_PER_SIDE = 5;
64147
+ var RETROLAVAGEM_LEGACY_MAX_PER_SIDE = 10;
64077
64148
  var MAX_CUSTOMER_DEVICE_PAGES2 = 100;
64078
64149
  var SIDE_TEXT = {
64079
64150
  inputs: { title: "Entrada", add: "+ Adicionar entrada", hint: "Hidr\xF4metros que medem a \xE1gua que entra na retrolavagem." },
@@ -64103,7 +64174,7 @@ function normalizeRetrolavagemBindings(value) {
64103
64174
  }
64104
64175
  const raw = parsed && typeof parsed === "object" ? parsed : {};
64105
64176
  const seen = /* @__PURE__ */ new Set();
64106
- const side = (items) => (Array.isArray(items) ? items : []).filter((item) => !!item && typeof item === "object" && typeof item.tbId === "string" && !!item.tbId).filter((item) => seen.has(item.tbId) ? false : (seen.add(item.tbId), true)).slice(0, MAX_RETROLAVAGEM_DEVICES_PER_SIDE).map((item) => ({
64177
+ const side = (items) => (Array.isArray(items) ? items : []).filter((item) => !!item && typeof item === "object" && typeof item.tbId === "string" && !!item.tbId).filter((item) => seen.has(item.tbId) ? false : (seen.add(item.tbId), true)).slice(0, RETROLAVAGEM_LEGACY_MAX_PER_SIDE).map((item) => ({
64107
64178
  tbId: item.tbId,
64108
64179
  label: String(item.label || item.tbId),
64109
64180
  ...item.gcdrId ? { gcdrId: String(item.gcdrId) } : {}
@@ -64210,6 +64281,7 @@ var RetrolavagemTab = class {
64210
64281
  const text2 = SIDE_TEXT[side];
64211
64282
  const rows = this.rows[side];
64212
64283
  const full = rows.length >= MAX_RETROLAVAGEM_DEVICES_PER_SIDE;
64284
+ const excess = rows.length - MAX_RETROLAVAGEM_DEVICES_PER_SIDE;
64213
64285
  const options = (current) => {
64214
64286
  const missing = current && !this.catalog.some((o) => o.tbId === current) ? `<option value="${escapeHtml7(current)}" selected data-unavailable="true">V\xEDnculo atual indispon\xEDvel \u2014 ${escapeHtml7(
64215
64287
  this.storedRef(current)?.label || current
@@ -64222,6 +64294,7 @@ var RetrolavagemTab = class {
64222
64294
  <fieldset class="rlt-side" data-side="${side}">
64223
64295
  <legend>${text2.title} <span class="rlt-count">${rows.length}/${MAX_RETROLAVAGEM_DEVICES_PER_SIDE}</span></legend>
64224
64296
  <p class="rlt-hint">${text2.hint}</p>
64297
+ ${excess > 0 ? `<p class="rlt-over" role="alert">Esta retrolavagem tem ${rows.length} hidr\xF4metros de ${text2.title.toLowerCase()}, acima do limite de ${MAX_RETROLAVAGEM_DEVICES_PER_SIDE}. O painel continua somando todos. Remova ${excess} para poder salvar.</p>` : ""}
64225
64298
  ${rows.length ? rows.map(
64226
64299
  (tbId, i) => `<div class="rlt-row">
64227
64300
  <select data-side="${side}" data-index="${i}" aria-label="${text2.title} ${i + 1}">${options(tbId)}</select>
@@ -64247,6 +64320,7 @@ var RetrolavagemTab = class {
64247
64320
  .rlt-side{border:1px solid #e5e7eb;border-radius:8px;padding:12px 14px;margin:0}.rlt-side legend{font-weight:700;padding:0 6px}
64248
64321
  .rlt-count{font-weight:500;color:#6b7280;font-size:12px}.rlt-hint,.rlt-empty,.rlt-note{margin:0 0 10px;font-size:13px;color:#6b7280}
64249
64322
  .rlt-note{background:#f1ecfa;color:#3e1a7d;border-radius:6px;padding:8px 10px}
64323
+ .rlt-over{margin:0 0 10px;font-size:13px;color:#92400e;background:#fffbeb;border:1px solid #fde68a;border-radius:6px;padding:8px 10px}
64250
64324
  .rlt-row{display:flex;gap:8px;margin-bottom:8px}.rlt-row select{flex:1;min-width:0;min-height:36px;padding:6px 8px;border:1px solid #d1d5db;border-radius:6px;background:#fff}
64251
64325
  .rlt-remove{border:1px solid #d1d5db;background:#fff;border-radius:6px;padding:0 10px;cursor:pointer;color:#6b7280}
64252
64326
  .rlt-add{border:1px dashed #9ca3af;background:#fff;border-radius:6px;padding:7px 12px;cursor:pointer;color:#374151;font-weight:600}
@@ -66158,10 +66232,14 @@ var SettingsModalView = class _SettingsModalView {
66158
66232
  isWellEquipmentDevice() {
66159
66233
  return ["CISTERNA", "CISTERNA_ENTRADA"].includes(String(this.config.deviceProfile || "").toUpperCase());
66160
66234
  }
66161
- /** Retrolavagem virtual: escolhe os hidrômetros de entrada e de saída (aba só para SuperAdmin). */
66235
+ /** Retrolavagem virtual: escolhe os hidrômetros de entrada e de saída. */
66162
66236
  isRetrolavagemDevice() {
66163
66237
  return String(this.config.deviceProfile || "").toUpperCase() === RETROLAVAGEM_PROFILE;
66164
66238
  }
66239
+ /** Permissão de configuração: SuperAdmin ou administrador da holding já validado pelo host. */
66240
+ canManageRetrolavagem() {
66241
+ return this.isSuperAdmin() || this.config.holdingAdmin === true;
66242
+ }
66165
66243
  render(initialData) {
66166
66244
  this.originalActiveElement = document.activeElement;
66167
66245
  document.body.appendChild(this.container);
@@ -66197,7 +66275,7 @@ var SettingsModalView = class _SettingsModalView {
66197
66275
  if (this.isWellEquipmentDevice() && this.isSuperAdmin()) {
66198
66276
  this.initWellEquipmentTab();
66199
66277
  }
66200
- if (this.isRetrolavagemDevice() && this.isSuperAdmin()) {
66278
+ if (this.isRetrolavagemDevice() && this.canManageRetrolavagem()) {
66201
66279
  this.initRetrolavagemTab();
66202
66280
  }
66203
66281
  if (this.config.isGateway && this.isSuperAdmin()) {
@@ -66479,7 +66557,7 @@ var SettingsModalView = class _SettingsModalView {
66479
66557
  }
66480
66558
  async initRetrolavagemTab() {
66481
66559
  const container = this.modal.querySelector("#retrolavagem-tab-content");
66482
- if (!container || !this.isRetrolavagemDevice() || !this.isSuperAdmin()) return;
66560
+ if (!container || !this.isRetrolavagemDevice() || !this.canManageRetrolavagem()) return;
66483
66561
  const customerId = this.config.customerId || window.MyIOUtils?.customerTB_ID;
66484
66562
  const { deviceId, jwtToken, tbBaseUrl } = this.config;
66485
66563
  if (!deviceId || !jwtToken || !customerId) {
@@ -66747,7 +66825,7 @@ var SettingsModalView = class _SettingsModalView {
66747
66825
  </svg>
66748
66826
  Equipamentos do Po\xE7o
66749
66827
  </button>` : ""}
66750
- ${this.isRetrolavagemDevice() && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="retrolavagem">
66828
+ ${this.isRetrolavagemDevice() && this.canManageRetrolavagem() ? `<button type="button" class="modal-tab" data-tab="retrolavagem">
66751
66829
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
66752
66830
  <path d="M3 12h7M14 12h7"></path>
66753
66831
  <path d="M7 8l-4 4 4 4"></path>
@@ -66812,7 +66890,7 @@ var SettingsModalView = class _SettingsModalView {
66812
66890
  ${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<div id="well-equipment-tab-content" class="tab-content" style="display:none;">
66813
66891
  <p class="wet-state">Carregando v\xEDnculos e equipamentos\u2026</p>
66814
66892
  </div>` : ""}
66815
- ${this.isRetrolavagemDevice() && this.isSuperAdmin() ? `<div id="retrolavagem-tab-content" class="tab-content" style="display:none;">
66893
+ ${this.isRetrolavagemDevice() && this.canManageRetrolavagem() ? `<div id="retrolavagem-tab-content" class="tab-content" style="display:none;">
66816
66894
  <p class="rlt-state">Carregando v\xEDnculos e hidr\xF4metros\u2026</p>
66817
66895
  </div>` : ""}
66818
66896
  <!-- RFC-0232: Incidentes (interpola\xE7\xE3o) Tab Content \u2014 central + admin MyIO only.
@@ -80820,6 +80898,12 @@ function timelineHTML(history, now, kind) {
80820
80898
  <small><span>${formatClock(now - DAY_MS)}</span><span>agora</span></small>
80821
80899
  </div>`;
80822
80900
  }
80901
+ function equipmentNameHTML(item, fallbackProfile) {
80902
+ const tag = indicatorTag(item);
80903
+ const label = String(item.label ?? "").trim();
80904
+ const name = label && label !== tag ? label : item.identifier || item.deviceProfile || fallbackProfile;
80905
+ return `<span class="myio-wp-tag">${escapeHtml2(tag)}</span>${escapeHtml2(name)}`;
80906
+ }
80823
80907
  function pumpCardHTML(p, now, images, focusWellId) {
80824
80908
  const on = isActive(p.history);
80825
80909
  const known = Array.isArray(p.history);
@@ -80836,7 +80920,7 @@ function pumpCardHTML(p, now, images, focusWellId) {
80836
80920
  <div class="myio-wp-top">
80837
80921
  <img class="myio-wp-img" src="${escapeHtml2(images.pump)}" alt="">
80838
80922
  <div>
80839
- <div class="myio-wp-name"><span class="myio-wp-tag">${escapeHtml2(p.code)}</span>${escapeHtml2(p.label)}</div>
80923
+ <div class="myio-wp-name">${equipmentNameHTML(p, "BOMBA_POCO")}</div>
80840
80924
  <div class="myio-wp-meta"><span class="myio-wp-prof">${escapeHtml2(p.deviceProfile || "BOMBA_POCO")}</span>${meta}</div>
80841
80925
  </div>
80842
80926
  <span class="myio-wp-state ${!known ? "unk" : on ? "on" : "off"}">${PUMP_SVG}${!known ? "SEM LEITURA" : on ? "LIGADA" : "DESLIGADA"}</span>
@@ -80866,7 +80950,7 @@ function valveCardHTML(v, now, images) {
80866
80950
  <div style="display:flex;flex-direction:column;gap:10px;min-width:0">
80867
80951
  <div class="myio-wp-top">
80868
80952
  <div>
80869
- <div class="myio-wp-name"><span class="myio-wp-tag">${escapeHtml2(v.code)}</span>${escapeHtml2(v.label)}</div>
80953
+ <div class="myio-wp-name">${equipmentNameHTML(v, "SOLENOIDE")}</div>
80870
80954
  <div class="myio-wp-meta"><span class="myio-wp-prof">${escapeHtml2(v.deviceProfile || "SOLENOIDE")}</span>${meta}</div>
80871
80955
  </div>
80872
80956
  <span class="myio-wp-state ${!known ? "unk" : open ? "open" : "closed"}">${VALVE_SVG}${!known ? "SEM LEITURA" : open ? "ABERTA" : "FECHADA"}</span>
package/dist/index.d.cts CHANGED
@@ -25516,7 +25516,8 @@ declare const EXPORT_BUTTON_CSS_PREFIX = "myio-export-btn";
25516
25516
  /** Injeta os estilos base (idempotente). Cores por kind/tema são inline (settings). */
25517
25517
  declare function injectExportButtonStyles(): void;
25518
25518
 
25519
- type Granularity = '1h' | '1d';
25519
+ /** 15m/30m: só onde houver opções explícitas (ex.: relatórios de temperatura) — default segue 1h|1d */
25520
+ type Granularity = '15m' | '30m' | '1h' | '1d';
25520
25521
  type GranularitySelectorThemeMode = 'light' | 'dark';
25521
25522
  interface GranularitySelectorOption {
25522
25523
  value: Granularity;